aboutsummaryrefslogtreecommitdiffstats
path: root/admin/plugins.php
diff options
context:
space:
mode:
Diffstat (limited to 'admin/plugins.php')
-rw-r--r--admin/plugins.php162
1 files changed, 1 insertions, 161 deletions
diff --git a/admin/plugins.php b/admin/plugins.php
index a4260513b..2206be228 100644
--- a/admin/plugins.php
+++ b/admin/plugins.php
@@ -31,8 +31,6 @@ if( !defined("PHPWG_ROOT_PATH") )
include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
check_status(ACCESS_ADMINISTRATOR);
-$my_base_url = PHPWG_ROOT_PATH.'admin.php?page=plugins';
-
// +-----------------------------------------------------------------------+
// | Sections definitions |
@@ -46,7 +44,7 @@ else
$page['section'] = $_GET['section'];
}
-$tab_link = $my_base_url . '&section=';
+$tab_link = get_root_url().'admin.php?page=plugins&section=';
// TabSheet
$tabsheet = new tabsheet();
@@ -59,168 +57,10 @@ $tabsheet->select($page['section']);
// Assign tabsheet to template
$tabsheet->assign();
-$my_base_url .= '&section=' . $page['section'];
-
-
-// +-----------------------------------------------------------------------+
-// | perform requested actions |
-// +-----------------------------------------------------------------------+
-if (isset($_GET['action']) and isset($_GET['plugin']) and !is_adviser())
-{
- $plugin_id = $_GET['plugin'];
- $crt_db_plugin = get_db_plugins('', $plugin_id);
- if (!empty($crt_db_plugin))
- {
- $crt_db_plugin = $crt_db_plugin[0];
- }
- else
- {
- unset($crt_db_plugin);
- }
-
- $errors = array();
- $file_to_include = PHPWG_PLUGINS_PATH . $plugin_id . '/maintain.inc.php';
-
- switch ($_GET['action'])
- {
- case 'install':
- if (!empty($crt_db_plugin))
- {
- array_push($errors, 'CANNOT install - ALREADY INSTALLED');
- break;
- }
- $fs_plugins = get_fs_plugins();
- if (!isset($fs_plugins[$plugin_id]))
- {
- array_push($errors, 'CANNOT install - NO SUCH PLUGIN');
- break;
- }
- if (file_exists($file_to_include))
- {
- include_once($file_to_include);
- if (function_exists('plugin_install'))
- {
- plugin_install($plugin_id, $fs_plugins[$plugin_id]['version'], $errors);
- }
- }
- if (empty($errors))
- {
- $query = '
-INSERT INTO ' . PLUGINS_TABLE . ' (id,version) VALUES ("'
-. $plugin_id . '","' . $fs_plugins[$plugin_id]['version'] . '"
-)';
- pwg_query($query);
- }
- break;
-
- case 'activate':
- if (!isset($crt_db_plugin))
- {
- array_push($errors, 'CANNOT ' . $_GET['action'] . ' - NOT INSTALLED');
- break;
- }
- if ($crt_db_plugin['state'] != 'inactive')
- {
- array_push($errors, 'invalid current state ' . $crt_db_plugin['state']);
- break;
- }
- if (file_exists($file_to_include))
- {
- include_once($file_to_include);
- if (function_exists('plugin_activate'))
- {
- plugin_activate($plugin_id, $crt_db_plugin['version'], $errors);
- }
- }
- if (empty($errors))
- {
- $query = '
-UPDATE ' . PLUGINS_TABLE . ' SET state="active" WHERE id="' . $plugin_id . '"';
- pwg_query($query);
- }
- break;
-
- case 'deactivate':
- if (!isset($crt_db_plugin))
- {
- die ('CANNOT ' . $_GET['action'] . ' - NOT INSTALLED');
- }
- if ($crt_db_plugin['state'] != 'active')
- {
- die('invalid current state ' . $crt_db_plugin['state']);
- }
- $query = '
-UPDATE ' . PLUGINS_TABLE . ' SET state="inactive" WHERE id="' . $plugin_id . '"';
- pwg_query($query);
- if (file_exists($file_to_include))
- {
- include_once($file_to_include);
- if (function_exists('plugin_deactivate'))
- {
- plugin_deactivate($plugin_id);
- }
- }
- break;
-
- case 'uninstall':
- if (!isset($crt_db_plugin))
- {
- die ('CANNOT ' . $_GET['action'] . ' - NOT INSTALLED');
- }
- $query = '
-DELETE FROM ' . PLUGINS_TABLE . ' WHERE id="' . $plugin_id . '"';
- pwg_query($query);
- if (file_exists($file_to_include))
- {
- include_once($file_to_include);
- if (function_exists('plugin_uninstall'))
- {
- plugin_uninstall($plugin_id);
- }
- }
- break;
-
- case 'delete':
- if (!empty($crt_db_plugin))
- {
- array_push($errors, 'CANNOT delete - PLUGIN IS INSTALLED');
- }
- elseif (!deltree(PHPWG_PLUGINS_PATH . $plugin_id))
- {
- send_to_trash(PHPWG_PLUGINS_PATH . $plugin_id);
- }
- break;
- }
- if (empty($errors))
- {
- $my_base_url .= isset($_GET['upgrade']) ?
- '&plugin='.$plugin_id.'&upgrade='.$_GET['upgrade'].'&reactivate=true':'';
-
- $my_base_url .= isset($_GET['upgradestatus']) ?
- '&plugin='.$plugin_id.'&upgradestatus='.$_GET['upgradestatus']:'';
-
- redirect($my_base_url);
- }
- else
- {
- $page['errors'] = array_merge($page['errors'], $errors);
- }
-}
-
// +-----------------------------------------------------------------------+
// | start template output |
// +-----------------------------------------------------------------------+
-$fs_plugins = get_fs_plugins();
-uasort($fs_plugins, 'name_compare');
-$db_plugins = get_db_plugins();
-$db_plugins_by_id = array();
-foreach ($db_plugins as $db_plugin) {
- $db_plugins_by_id[$db_plugin['id']] = $db_plugin;
-}
include(PHPWG_ROOT_PATH.'admin/plugins_'.$page['section'].'.php');
-
-$template->assign_var_from_handle('ADMIN_CONTENT', 'plugins');
-
?> \ No newline at end of file