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 /************************************************************************/
12 // $Id: index.php 10499 2010-12-09 17:16:28Z cindy $
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);
151 <form method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">
152 <div class="input-form">
154 <h3><?php echo _AT('results_found', count($keys)); ?></h3>
158 <?php echo _AT('type'); ?><br />
159 <input type="checkbox" name="core" value="1" id="t0" <?php if ($_GET['core']) { echo 'checked="checked"'; } ?> /><label for="t0"><?php echo _AT('core'); ?></label>
161 <input type="checkbox" name="standard" value="1" id="t1" <?php if ($_GET['standard']) { echo 'checked="checked"'; } ?> /><label for="t1"><?php echo _AT('standard'); ?></label>
163 <input type="checkbox" name="extra" value="1" id="t2" <?php if ($_GET['extra']) { echo 'checked="checked"'; } ?> /><label for="t2"><?php echo _AT('extra'); ?></label>
168 <?php echo _AT('status'); ?><br />
169 <input type="checkbox" name="enabled" value="1" id="s0" <?php if ($_GET['enabled']) { echo 'checked="checked"'; } ?> /><label for="s0"><?php echo _AT('enabled'); ?></label>
171 <input type="checkbox" name="disabled" value="1" id="s1" <?php if ($_GET['disabled']) { echo 'checked="checked"'; } ?> /><label for="s1"><?php echo _AT('disabled'); ?></label>
173 <input type="checkbox" name="missing" value="1" id="s2" <?php if ($_GET['missing']) { echo 'checked="checked"'; } ?> /><label for="s2"><?php echo _AT('missing'); ?></label>
175 <input type="checkbox" name="partially_uninstalled" value="1" id="s3" <?php if ($_GET['partially_uninstalled']) { echo 'checked="checked"'; } ?> /><label for="s3"><?php echo _AT('partially_uninstalled'); ?></label>
178 <div class="row buttons">
179 <input type="submit" name="filter" value="<?php echo _AT('filter'); ?>" />
180 <input type="submit" name="reset_filter" value="<?php echo _AT('reset_filter'); ?>" />
185 <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get" name="form">
187 <input type="hidden" name="enabled" value="<?php echo (int) $_GET['enabled']; ?>" />
188 <input type="hidden" name="disabled" value="<?php echo (int) $_GET['disabled']; ?>" />
189 <input type="hidden" name="core" value="<?php echo (int) $_GET['core']; ?>" />
190 <input type="hidden" name="standard" value="<?php echo (int) $_GET['standard']; ?>" />
191 <input type="hidden" name="extra" value="<?php echo (int) $_GET['extra']; ?>" />
192 <input type="hidden" name="missing" value="<?php echo (int) $_GET['missing']; ?>" />
193 <input type="hidden" name="partially_uninstalled" value="<?php echo (int) $_GET['partially_uninstalled']; ?>" />
195 <table class="data" summary="" rules="cols">
203 <th scope="col"> </th>
204 <th scope="col"><?php echo _AT('module_name'); ?></th>
205 <th scope="col"><?php echo _AT('type'); ?></th>
206 <th scope="col"><?php echo _AT('status'); ?></th>
207 <th scope="col"><?php echo _AT('cron'); ?></th>
208 <th scope="col"><?php echo _AT('directory_name'); ?></th>
214 <input type="submit" name="details" value="<?php echo _AT('details'); ?>" />
215 <input type="submit" name="enable" value="<?php echo _AT('enable'); ?>" />
216 <input type="submit" name="disable" value="<?php echo _AT('disable'); ?>" />
217 <input type="submit" name="uninstall" value="<?php echo _AT('uninstall'); ?>" />
218 <input type="submit" name="export" value="<?php echo _AT('export'); ?>" />
226 <?php foreach($keys as $dir_name) : $module =& $module_list[$dir_name]; $i++; $readme = get_readme(AT_INCLUDE_PATH.'../mods/'.$dir_name);?>
228 <tr onmousedown="document.form['t_<?php echo $i; ?>'].checked = true; rowselect(this);" id="r_<?php echo $i; ?>">
229 <td valign="top"><input type="radio" id="t_<?php echo $i; ?>" name="mod_dir" value="<?php echo $dir_name; ?>" /></td>
230 <td nowrap="nowrap" valign="top"><label for="t_<?php echo $i; ?>"><?php echo $module->getName(); if ($readme <> '') echo ' <a href="#" onclick="ATutor.poptastic(\''.AT_BASE_HREF.'mods/'.$dir_name.'/'.$readme.'\');return false;">'._AT('view_readme').'</a>'; ?></label></td>
231 <td valign="top"><?php
232 if ($module->isCore()) {
233 echo '<strong>'._AT('core').'</strong>';
234 } else if ($module->isStandard()) {
235 echo _AT('standard');
240 <td valign="top"><?php
241 if ($module->isEnabled()) {
243 } else if ($module->isMissing()) {
244 echo '<strong>'._AT('missing').'</strong>';
245 } else if ($module->isPartiallyUninstalled()) {
246 echo _AT('partially_uninstalled');
248 echo '<strong>'._AT('disabled').'</strong>';
251 <td valign="top" align="center">
252 <?php if ($module->getCronInterval()): ?>
253 <?php echo _AT('minutes', $module->getCronInterval()); ?>
258 <td valign="top"><code><?php echo $dir_name; ?>/</code></td>
261 <?php if (!$keys): ?>
263 <td colspan="6"><?php echo _AT('none_found'); ?></td>
270 <?php require(AT_INCLUDE_PATH.'footer.inc.php'); ?>