source: trunk/admin/plugins_update.php @ 2264

Last change on this file since 2264 was 2264, checked in by patdenice, 17 years ago

Corrections in plugins management.

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