source: branches/2.1/admin/plugins_update.php @ 6323

Last change on this file since 6323 was 6323, checked in by plg, 14 years ago

merge r6320 from trunk to branch 2.1

bug 1667 fixed: r6027 was fixing a minor error on tabs for Google Chrome/Safari
BUT was introducing a major visual issue for IE8. Backmerged + adds the -webkit
radius anyway.

This is a quickfix for release 2.1.1, the improved display introduced by nikrou
was nice and it would be better to have it, but working in IE8

File size: 6.4 KB
RevLine 
[2242]1<?php
2// +-----------------------------------------------------------------------+
[2297]3// | Piwigo - a PHP based picture gallery                                  |
4// +-----------------------------------------------------------------------+
[5196]5// | Copyright(C) 2008-2010 Piwigo Team                  http://piwigo.org |
[2297]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// +-----------------------------------------------------------------------+
[2242]23
24if( !defined("PHPWG_ROOT_PATH") )
25{
26  die ("Hacking attempt!");
27}
28
[2263]29include_once(PHPWG_ROOT_PATH.'admin/include/plugins.class.php');
[2255]30
[2530]31$template->set_filenames(array('plugins' => 'plugins_update.tpl'));
[2242]32
[2264]33$base_url = get_root_url().'admin.php?page='.$page['page'];
[2242]34
[2264]35$plugins = new plugins();
36
[2242]37//-----------------------------------------------------------automatic upgrade
[2647]38if (isset($_GET['plugin']) and isset($_GET['revision']) and !is_adviser())
[2242]39{
[5406]40  if (!is_webmaster())
[2264]41  {
[5406]42    array_push($page['errors'], l10n('Webmaster status is required.'));
[2264]43  }
[5406]44  else
45  {
46    check_pwg_token();
47   
48    $plugin_id = $_GET['plugin'];
49    $revision = $_GET['revision'];
[2264]50
[5406]51    if (isset($plugins->db_plugins_by_id[$plugin_id])
52      and $plugins->db_plugins_by_id[$plugin_id]['state'] == 'active')
53    {
54      $plugins->perform_action('deactivate', $plugin_id);
[2264]55
[5406]56      redirect($base_url
57        . '&revision=' . $revision
58        . '&plugin=' . $plugin_id
59        . '&pwg_token='.get_pwg_token()
60        . '&reactivate=true');
61    }
62
63    $upgrade_status = $plugins->extract_plugin_files('upgrade', $revision, $plugin_id);
64
65    if (isset($_GET['reactivate']))
66    {
67      $plugins->perform_action('activate', $plugin_id);
68    }
69    redirect($base_url.'&plugin='.$plugin_id.'&upgradestatus='.$upgrade_status);
[2264]70  }
[2242]71}
72
73//--------------------------------------------------------------upgrade result
74if (isset($_GET['upgradestatus']) and isset($_GET['plugin']))
75{
[2264]76  switch ($_GET['upgradestatus'])
77  {
78    case 'ok':
79      array_push($page['infos'],
80         sprintf(
[5021]81            l10n('%s has been successfully upgraded.'),
[2264]82            $plugins->fs_plugins[$_GET['plugin']]['name']));
83      break;
84
85    case 'temp_path_error':
[5021]86      array_push($page['errors'], l10n('Can\'t create temporary file.'));
[2264]87      break;
88
89    case 'dl_archive_error':
[5021]90      array_push($page['errors'], l10n('Can\'t download archive.'));
[2264]91      break;
92
93    case 'archive_error':
[5021]94      array_push($page['errors'], l10n('Can\'t read or extract archive.'));
[2264]95      break;
96
97    default:
98      array_push($page['errors'],
[5021]99        sprintf(l10n('An error occured during extraction (%s).'), $_GET['upgradestatus']),
[5039]100        l10n('Please check "plugins" folder and sub-folders permissions (CHMOD).'));
[2264]101  } 
[2242]102}
103
[2264]104//--------------------------------------------------------------------Tabsheet
[5367]105$plugins->set_tabsheet($page['page']);
[2264]106
[2242]107// +-----------------------------------------------------------------------+
108// |                     start template output                             |
109// +-----------------------------------------------------------------------+
[2880]110if ($plugins->get_server_plugins())
[2242]111{
[2263]112  foreach($plugins->fs_plugins as $plugin_id => $fs_plugin)
[2243]113  {
114    if (isset($fs_plugin['extension'])
[2263]115      and isset($plugins->server_plugins[$fs_plugin['extension']]))
[2243]116    {
[2263]117      $plugin_info = $plugins->server_plugins[$fs_plugin['extension']];
[2245]118
[2647]119      list($date, ) = explode(' ', $plugin_info['revision_date']);
120
[3143]121      $ext_desc = '<i>'.l10n('Downloads').':</i> '.$plugin_info['extension_nb_downloads']."\r\n"
122        ."\r\n"
123        .$plugin_info['extension_description'];
[2245]124
[3143]125      $rev_desc = '<i>'.l10n('Version').':</i> '.$plugin_info['revision_name']."\r\n"
126        .'<i>'.l10n('Released on').':</i> '.$date."\r\n"
127        .'<i>'.l10n('Downloads').':</i> '.$plugin_info['revision_nb_downloads']."\r\n"
128        ."\r\n"
129        .$plugin_info['revision_description'];
130
[2647]131      if ($plugins->plugin_version_compare($fs_plugin['version'], $plugin_info['revision_name']))
[2243]132      {
133        // Plugin is up to date
[2647]134        $template->append('plugins_uptodate', array(
[3143]135          'URL' => PEM_URL.'/extension_view.php?eid='.$plugin_info['extension_id'],
[2647]136          'NAME' => $fs_plugin['name'],
[3143]137          'EXT_DESC' => $ext_desc,
138          'VERSION' => $fs_plugin['version'],
139          'VER_DESC' => $rev_desc));
[2243]140      }
141      else
142      {
143        // Plugin need upgrade
[2264]144        $url_auto_update = $base_url
[2647]145          . '&amp;revision=' . $plugin_info['revision_id']
[5195]146          . '&amp;plugin=' . $plugin_id
147          . '&amp;pwg_token='.get_pwg_token()
148          ;
[2245]149
[2647]150        $template->append('plugins_not_uptodate', array(
151          'EXT_NAME' => $fs_plugin['name'],
[3143]152          'EXT_URL' => PEM_URL.'/extension_view.php?eid='.$plugin_info['extension_id'],
153          'EXT_DESC' => $ext_desc,
[2647]154          'VERSION' => $fs_plugin['version'],
155          'NEW_VERSION' => $plugin_info['revision_name'],
[3143]156          'NEW_VER_DESC' => $rev_desc,
[2647]157          'URL_UPDATE' => $url_auto_update,
158          'URL_DOWNLOAD' => $plugin_info['download_url'] . '&amp;origin=piwigo_download'));
[2243]159      }
160    }
[2245]161    else
[2243]162    {
163      // Can't check plugin
[2647]164      $template->append('plugins_cant_check', array(
165        'NAME' => $fs_plugin['name'],
166        'VERSION' => $fs_plugin['version']));
[2243]167    }
168  }
[2242]169}
170else
171{
[5021]172  array_push($page['errors'], l10n('Can\'t connect to server.'));
[2242]173}
174
[2255]175$template->assign_var_from_handle('ADMIN_CONTENT', 'plugins');
[2242]176?>
Note: See TracBrowser for help on using the repository browser.