source: trunk/admin/plugins_update.php @ 2585

Last change on this file since 2585 was 2530, checked in by vdigital, 16 years ago

Wigo becomes "goto".
Admin tpl files are moved.

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 6.2 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based picture gallery                                  |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2008      Piwigo Team                  http://piwigo.org |
6// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
7// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
8// +-----------------------------------------------------------------------+
9// | This program is free software; you can redistribute it and/or modify  |
10// | it under the terms of the GNU General Public License as published by  |
11// | the Free Software Foundation                                          |
12// |                                                                       |
13// | This program is distributed in the hope that it will be useful, but   |
14// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
15// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
16// | General Public License for more details.                              |
17// |                                                                       |
18// | You should have received a copy of the GNU General Public License     |
19// | along with this program; if not, write to the Free Software           |
20// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
21// | USA.                                                                  |
22// +-----------------------------------------------------------------------+
23
24if( !defined("PHPWG_ROOT_PATH") )
25{
26  die ("Hacking attempt!");
27}
28
29include_once(PHPWG_ROOT_PATH.'admin/include/plugins.class.php');
30
31$template->set_filenames(array('plugins' => 'plugins_update.tpl'));
32
33$base_url = get_root_url().'admin.php?page='.$page['page'];
34
35$plugins = new plugins();
36
37//-----------------------------------------------------------automatic upgrade
38if (isset($_GET['upgrade']) and isset($_GET['plugin']) and !is_adviser())
39{
40  $plugin_id = $_GET['plugin'];
41
42  if (isset($plugins->db_plugins_by_id[$plugin_id])
43    and $plugins->db_plugins_by_id[$plugin_id]['state'] == 'active')
44  {
45    $plugins->perform_action('deactivate', $plugin_id);
46
47    redirect($base_url
48      . '&upgrade=' . $_GET['upgrade']
49      . '&plugin=' . $plugin_id
50      . '&reactivate=true');
51  }
52
53  $upgrade_status =
54    $plugins->extract_plugin_files('upgrade', $_GET['upgrade'], $plugin_id);
55
56  if (isset($_GET['reactivate']))
57  {
58    $plugins->perform_action('activate', $plugin_id);
59  }
60  redirect($base_url.'&plugin='.$plugin_id.'&upgradestatus='.$upgrade_status);
61}
62
63//--------------------------------------------------------------upgrade result
64if (isset($_GET['upgradestatus']) and isset($_GET['plugin']))
65{
66  switch ($_GET['upgradestatus'])
67  {
68    case 'ok':
69      array_push($page['infos'],
70         sprintf(
71            l10n('plugins_upgrade_ok'),
72            $plugins->fs_plugins[$_GET['plugin']]['name']));
73      break;
74
75    case 'temp_path_error':
76      array_push($page['errors'], l10n('plugins_temp_path_error'));
77      break;
78
79    case 'dl_archive_error':
80      array_push($page['errors'], l10n('plugins_dl_archive_error'));
81      break;
82
83    case 'archive_error':
84      array_push($page['errors'], l10n('plugins_archive_error'));
85      break;
86
87    default:
88      array_push($page['errors'],
89        sprintf(l10n('plugins_extract_error'), $_GET['installstatus']),
90        l10n('plugins_check_chmod'));
91  } 
92}
93
94//--------------------------------------------------------------------Tabsheet
95set_plugins_tabsheet($page['page']);
96
97// +-----------------------------------------------------------------------+
98// |                     start template output                             |
99// +-----------------------------------------------------------------------+
100$plugins->get_server_plugins();
101
102if (is_array($plugins->server_plugins))
103{
104  foreach($plugins->fs_plugins as $plugin_id => $fs_plugin)
105  {
106    if (isset($fs_plugin['extension'])
107      and isset($plugins->server_plugins[$fs_plugin['extension']]))
108    {
109      $plugin_info = $plugins->server_plugins[$fs_plugin['extension']];
110
111      $ext_desc = nl2br(htmlspecialchars(strip_tags(
112                    utf8_encode($plugin_info['ext_description']))));
113
114      $ver_desc = sprintf(l10n('plugins_description'),
115          $plugin_info['version'],
116          date('Y-m-d', $plugin_info['date']),
117          nl2br(htmlspecialchars(strip_tags(
118              utf8_encode($plugin_info['description'])))));
119
120      if ($plugins->plugin_version_compare($fs_plugin, $plugin_info))
121      {
122        // Plugin is up to date
123        $template->append('plugins_uptodate',
124              array('URL' => $fs_plugin['uri'],
125                'NAME' => $fs_plugin['name'],
126                'EXT_DESC' => $ext_desc,
127                'VERSION' => $fs_plugin['version']));
128      }
129      else
130      {
131        // Plugin need upgrade
132        $url_auto_update = $base_url
133          . '&amp;plugin=' . $plugin_id
134          . '&amp;upgrade=%2Fupload%2Fextension-' . $fs_plugin['extension']
135          . '%2Frevision-' . $plugin_info['id_revision']
136          . '%2F' . str_replace(' ', '%20',$plugin_info['url']);
137
138        $url_download = PEM_URL.'/upload/extension-'. $fs_plugin['extension']
139          . '/revision-' . $plugin_info['id_revision']
140          . '/' . str_replace(' ', '%20',$plugin_info['url']);
141
142        $template->append('plugins_not_uptodate',
143          array('EXT_NAME' => $fs_plugin['name'],
144            'EXT_URL' => $fs_plugin['uri'],
145            'EXT_DESC' => $ext_desc,
146            'VERSION' => $fs_plugin['version'],
147            'VERSION_URL' => PEM_URL.'/revision_view.php?rid='.$plugin_info['id_revision'],
148            'NEW_VERSION' => $plugin_info['version'],
149            'NEW_VER_DESC' => $ver_desc,
150            'URL_UPDATE' => $url_auto_update,
151            'URL_DOWNLOAD' => $url_download));
152      }
153    }
154    else
155    {
156      // Can't check plugin
157      $template->append('plugins_cant_check',
158          array('NAME' => $fs_plugin['name'],
159            'VERSION' => $fs_plugin['version']));
160    }
161  }
162}
163else
164{
165  array_push($page['errors'], l10n('plugins_server_error'));
166}
167
168$template->assign_var_from_handle('ADMIN_CONTENT', 'plugins');
169?>
Note: See TracBrowser for help on using the repository browser.