source: trunk/admin/plugins_update.php @ 2272

Last change on this file since 2272 was 2272, checked in by patdenice, 16 years ago

Corrections in plugins management.
Add "Last revisions" sort order.

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 6.1 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 2272 2008-03-10 18:01:17Z patdenice $
7// | last update   : $Date: 2008-03-10 18:01:17 +0000 (Mon, 10 Mar 2008) $
8// | last modifier : $Author: patdenice $
9// | revision      : $Revision: 2272 $
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
97set_plugins_tabsheet($page['page']);
98
99// +-----------------------------------------------------------------------+
100// |                     start template output                             |
101// +-----------------------------------------------------------------------+
102$plugins->get_server_plugins();
103
104if (is_array($plugins->server_plugins))
105{
106  foreach($plugins->fs_plugins as $plugin_id => $fs_plugin)
107  {
108    if (isset($fs_plugin['extension'])
109      and isset($plugins->server_plugins[$fs_plugin['extension']]))
110    {
111      $plugin_info = $plugins->server_plugins[$fs_plugin['extension']];
112
113      $ext_desc = nl2br(htmlspecialchars(strip_tags(
114                    utf8_encode($plugin_info['ext_description']))));
115
116      $ver_desc = sprintf(l10n('plugins_description'),
117          $plugin_info['version'],
118          date('Y-m-d', $plugin_info['date']),
119          nl2br(htmlspecialchars(strip_tags(
120              utf8_encode($plugin_info['description'])))));
121
122      if ($plugins->plugin_version_compare($fs_plugin, $plugin_info))
123      {
124        // Plugin is up to date
125        $template->append('plugins_uptodate',
126              array('URL' => $fs_plugin['uri'],
127                'NAME' => $fs_plugin['name'],
128                'EXT_DESC' => $ext_desc,
129                'VERSION' => $fs_plugin['version']));
130      }
131      else
132      {
133        // Plugin need upgrade
134        $url_auto_update = $base_url
135          . '&amp;plugin=' . $plugin_id
136          . '&amp;upgrade=%2Fupload%2Fextension-' . $fs_plugin['extension']
137          . '%2Frevision-' . $plugin_info['id_revision']
138          . '%2F' . str_replace(' ', '%20',$plugin_info['url']);
139
140        $url_download = PEM_URL.'/upload/extension-'. $fs_plugin['extension']
141          . '/revision-' . $plugin_info['id_revision']
142          . '/' . str_replace(' ', '%20',$plugin_info['url']);
143
144        $template->append('plugins_not_uptodate',
145          array('EXT_NAME' => $fs_plugin['name'],
146            'EXT_URL' => $fs_plugin['uri'],
147            'EXT_DESC' => $ext_desc,
148            'VERSION' => $fs_plugin['version'],
149            'VERSION_URL' => PEM_URL.'/revision_view.php?rid='.$plugin_info['id_revision'],
150            'NEW_VERSION' => $plugin_info['version'],
151            'NEW_VER_DESC' => $ver_desc,
152            'URL_UPDATE' => $url_auto_update,
153            'URL_DOWNLOAD' => $url_download));
154      }
155    }
156    else
157    {
158      // Can't check plugin
159      $template->append('plugins_cant_check',
160          array('NAME' => $fs_plugin['name'],
161            'VERSION' => $fs_plugin['version']));
162    }
163  }
164}
165else
166{
167  array_push($page['errors'], l10n('plugins_server_error'));
168}
169
170$template->assign_var_from_handle('ADMIN_CONTENT', 'plugins');
171?>
Note: See TracBrowser for help on using the repository browser.