source: trunk/admin/plugins_list.php @ 9994

Last change on this file since 9994 was 9994, checked in by mistic100, 13 years ago

bug:2022 admins can uninstall plugins

  • Property svn:eol-style set to LF
File size: 4.3 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based photo gallery                                    |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2008-2011 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_list.tpl'));
32
33$base_url = get_root_url().'admin.php?page='.$page['page'];
34$action_url = $base_url.'&amp;plugin='.'%s'.'&amp;pwg_token='.get_pwg_token();
35
36$plugins = new plugins();
37
38//--------------------------------------------------perform requested actions
39if (isset($_GET['action']) and isset($_GET['plugin']))
40{
41  if ($_GET['action'] == 'uninstall' AND !is_webmaster())
42  {
43    array_push($page['errors'], l10n('Webmaster status is required.'));
44  }
45  else
46  {
47    check_pwg_token();
48
49    $page['errors'] = $plugins->perform_action($_GET['action'], $_GET['plugin']);
50
51    if (empty($page['errors']))
52    {
53      if ($_GET['action'] == 'activate' or $_GET['action'] == 'deactivate')
54      {
55        $template->delete_compiled_templates();
56      }
57      redirect($base_url);
58    }
59  }
60}
61
62//--------------------------------------------------------------------Tabsheet
63$plugins->set_tabsheet($page['page']);
64
65// +-----------------------------------------------------------------------+
66// |                     start template output                             |
67// +-----------------------------------------------------------------------+
68
69$plugins->sort_fs_plugins('name');
70
71foreach($plugins->fs_plugins as $plugin_id => $fs_plugin)
72{
73  $tpl_plugin = array(
74    'NAME' => $fs_plugin['name'],
75    'VISIT_URL' => $fs_plugin['uri'],
76    'VERSION' => $fs_plugin['version'],
77    'DESC' => $fs_plugin['description'],
78    'AUTHOR' => $fs_plugin['author'],
79    'AUTHOR_URL' => @$fs_plugin['author uri'],
80    'U_ACTION' => sprintf($action_url, $plugin_id)
81    );
82
83  if (isset($plugins->db_plugins_by_id[$plugin_id]))
84  {
85    $tpl_plugin['STATE'] = $plugins->db_plugins_by_id[$plugin_id]['state'];
86  }
87  else
88  {
89    $tpl_plugin['STATE'] = 'uninstalled';
90  }
91
92  $template->append('plugins', $tpl_plugin);
93}
94
95$missing_plugin_ids = array_diff(
96  array_keys($plugins->db_plugins_by_id),
97  array_keys($plugins->fs_plugins)
98  );
99
100foreach($missing_plugin_ids as $plugin_id)
101{
102  $template->append(
103    'plugins',
104    array(
105      'NAME' => $plugin_id,
106      'VERSION' => $plugins->db_plugins_by_id[$plugin_id]['version'],
107      'DESC' => "ERROR: THIS PLUGIN IS MISSING BUT IT IS INSTALLED! UNINSTALL IT NOW !",
108      'U_ACTION' => sprintf($action_url, $plugin_id),
109      'STATE' => 'missing',
110      )
111    );
112}
113
114$template->append('plugin_states', 'active');
115$template->append('plugin_states', 'inactive');
116$template->append('plugin_states', 'uninstalled');
117
118if (count($missing_plugin_ids) > 0)
119{
120  $template->append('plugin_states', 'missing');
121}
122
123$template->assign_var_from_handle('ADMIN_CONTENT', 'plugins');
124?>
Note: See TracBrowser for help on using the repository browser.