2 /************************************************************************/
4 /************************************************************************/
5 /* Copyright (c) 2002-2010 */
6 /* Inclusive Design Institute */
8 /* This program is free software. You can redistribute it and/or */
9 /* modify it under the terms of the GNU General Public License */
10 /* as published by the Free Software Foundation. */
11 /************************************************************************/
14 define('AT_INCLUDE_PATH', '../../../include/');
15 require(AT_INCLUDE_PATH.'vitals.inc.php');
16 admin_authenticate(AT_ADMIN_PRIV_MODULES);
18 require_once(AT_INCLUDE_PATH.'../mods/_core/file_manager/filemanager.inc.php');
20 $dir_name = str_replace(array('.','..'), '', $_GET['mod_dir']);
24 if (isset($_GET['enabled']) && $_GET['enabled']) { $args .= 'enabled=1'; }
25 if (isset($_GET['disabled']) && $_GET['disabled']) { $args .= SEP.'disabled=1'; }
26 if (isset($_GET['missing']) && $_GET['missing']) { $args .= SEP.'missing=1'; }
27 if (isset($_GET['partially_uninstalled']) && $_GET['partially_uninstalled']) { $args .= SEP.'partially_uninstalled=1'; }
28 if (isset($_GET['core']) && $_GET['core']) { $args .= SEP.'core=1'; }
29 if (isset($_GET['standard']) && $_GET['standard']) { $args .= SEP.'standard=1'; }
30 if (isset($_GET['extra']) && $_GET['extra']) { $args .= SEP.'extra=1'; }
32 if (isset($_GET['reset_filter'])) {
33 header('Location: '.$_SERVER['PHP_SELF']);
37 if (isset($_GET['mod_dir'], $_GET['enable'])) {
38 $module = $moduleFactory->getModule($_GET['mod_dir']);
39 if (!$module->isEnabled() && !$module->isCore() && !$module->isMissing() && !$module->isPartiallyUninstalled()) {
41 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
44 header('Location: '.$_SERVER['PHP_SELF'] . '?' . $args);
46 } else if (isset($_GET['mod_dir'], $_GET['disable'])) {
47 $module = $moduleFactory->getModule($_GET['mod_dir']);
48 if ($module->isCore()) {
49 // core modules cannot be disabled!
50 $msg->addError('DISABLE_CORE_MODULE');
51 } else if ($module->isMissing()) {
52 $msg->addError('DISABLE_MISSING_MODULE');
53 } else if ($module->isPartiallyUninstalled()) {
54 $msg->addError('DISABLE_PARTIALLY_UNINSTALLED_MODULE');
55 } else if ($module->isEnabled()) {
57 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
59 header('Location: '.$_SERVER['PHP_SELF'] . '?' . $args);
61 } else if (isset($_GET['mod_dir'], $_GET['details'])) {
62 header('Location: details.php?mod='.$_GET['mod_dir'] . SEP . $args);
65 } else if (isset($_GET['mod_dir'], $_GET['uninstall'])) {
66 $module = $moduleFactory->getModule($_GET['mod_dir']);
68 $module_folder = '../../../mods/'.$_GET['mod_dir'];
69 // check if the module has been un-installed
70 if (!file_exists($module_folder))
72 $msg->addError('ALREADY_UNINSTALLED');
75 // only extra modules can be uninstalled
76 if (!$module->isExtra()) {
77 $msg->addError('ONLY_UNINSTALL_EXTRA_MODULE');
79 // check if the module is installed via "Available Extra Modules"
80 // which are the modules can be un-installed
81 else if (!file_exists($module_folder.'/module_uninstall.php') || !is_writable($module_folder))
83 $msg->addError('CANNOT_UNINSTALL_MANUAL_MODULE');
86 if (!$msg->containsErrors())
88 header('Location: module_uninstall_step_1.php?mod=' . urlencode($_GET['mod_dir']) . SEP.'args='.urlencode($args));
92 } else if (isset($_GET['mod_dir'], $_GET['export'])) {
93 $module = $moduleFactory->getModule($_GET['mod_dir']);
95 $module_folder = '../../../mods/'.$_GET['mod_dir'];
96 // check if the module has been un-installed
97 if (!file_exists($module_folder))
99 $msg->addError('ITEM_NOT_FOUND');
102 // only extra modules can be uninstalled
103 if (!$module->isExtra()) {
104 $msg->addError('ONLY_EXPORT_EXTRA_MODULE');
107 if (!$msg->containsErrors())
109 require(AT_INCLUDE_PATH.'classes/zipfile.class.php'); /* for zipfile */
111 $zipfile = new zipfile();
112 $zipfile->add_dir('../../../mods/'.$_GET['mod_dir'].'/', $_GET['mod_dir'].'/');
114 $zipfile->send_file($_GET['mod_dir']);
118 } else if (isset($_GET['disable']) || isset($_GET['enable']) || isset($_GET['details']) || isset($_GET['uninstall']) || isset($_GET['export'])) {
119 $msg->addError('NO_ITEM_SELECTED');
120 header('Location: '.$_SERVER['PHP_SELF'] . '?' . $args);
124 require(AT_INCLUDE_PATH.'header.inc.php');
126 $module_status_bits = $module_type_bits = 0;
128 if ($_GET['enabled']) { $module_status_bits += AT_MODULE_STATUS_ENABLED; }
129 if ($_GET['disabled']) { $module_status_bits += AT_MODULE_STATUS_DISABLED; }
130 if ($_GET['missing']) { $module_status_bits += AT_MODULE_STATUS_MISSING; }
131 if ($_GET['partially_uninstalled']) { $module_status_bits += AT_MODULE_STATUS_PARTIALLY_UNINSTALLED; }
133 if ($_GET['core']) { $module_type_bits += AT_MODULE_TYPE_CORE; }
134 if ($_GET['standard']) { $module_type_bits += AT_MODULE_TYPE_STANDARD; }
135 if ($_GET['extra']) { $module_type_bits += AT_MODULE_TYPE_EXTRA; }
137 if ($module_status_bits == 0) {
138 $module_status_bits = AT_MODULE_STATUS_DISABLED | AT_MODULE_STATUS_ENABLED | AT_MODULE_STATUS_MISSING | AT_MODULE_STATUS_PARTIALLY_UNINSTALLED;
139 $_GET['enabled'] = $_GET['disabled'] = $_GET['missing'] = $_GET['partially_uninstalled'] = 1;
142 if ($module_type_bits == 0) {
143 $module_type_bits = AT_MODULE_TYPE_STANDARD + AT_MODULE_TYPE_EXTRA;
144 $_GET['standard'] = $_GET['extra'] = 1;
148 $module_list = $moduleFactory->getModules($module_status_bits, $module_type_bits, $sort = TRUE);
149 $keys = array_keys($module_list);
150 $savant->assign('module_list', $module_list);
151 $savant->assign('keys', $keys);
152 $savant->display('admin/modules/index.tmpl.php');
153 require(AT_INCLUDE_PATH.'footer.inc.php'); ?>