home *** CD-ROM | disk | FTP | other *** search
- <?php
- /*
- Copyright Intermesh 2003
- Author: Merijn Schering <mschering@intermesh.nl>
- Version: 1.0 Release date: 08 July 2003
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
- */
-
- require("../../Group-Office.php");
- $GO_SECURITY->authenticate(true);
- require($GO_LANGUAGE->get_language_file('settings'));
-
- $task = isset($_REQUEST['task']) ? $_REQUEST['task'] : '';
- $return_to = $GO_CONFIG->host.'configuration/';
- $tabtable = new tabtable('settings', $menu_modules, '500','300');
-
- require_once($GO_CONFIG->class_path.'filesystem.class.inc');
- $fs = new filesystem();
-
- $modules = $fs->get_folders($GO_CONFIG->module_path);
- $existing_modules = array();
- $selected_modules = isset($_POST['selected_modules']) ? $_POST['selected_modules'] : array();
-
- $page_title = $menu_modules;
- require($GO_THEME->theme_path."header.inc");
-
- if ($task == 'save_modules')
- {
- require_once($GO_CONFIG->class_path.'filesystem.class.inc');
- $fs = new filesystem();
-
- $modules = $fs->get_folders($GO_CONFIG->module_path);
- $existing_modules = array();
- $selected_modules = isset($_POST['selected_modules']) ? $_POST['selected_modules'] : array();
- if ($_SERVER['REQUEST_METHOD'] == 'POST')
- {
- for ($i=0;$i<count($modules);$i++)
- {
- $existing_modules[] = $modules[$i]['path'];
- if (in_array($modules[$i]['path'],$selected_modules))
- {
- if (!$GO_MODULES->is_registered_module($modules[$i]['path']))
- {
- $module_id = $modules[$i]['name'];
- $path = str_replace($GO_CONFIG->root_path,'',$modules[$i]['path']);
- if (substr($path, -1) != $GO_CONFIG->slash)
- {
- $path .= $GO_CONFIG->slash;
- }
- $acl_read = $GO_SECURITY->get_new_acl('Module read: '.$module_id, 0);
- $acl_write = $GO_SECURITY->get_new_acl('Module write: '.$module_id, 0);
-
- if ($acl_read > 0 && $acl_write > 0)
- {
- if ($GO_SECURITY->add_group_to_acl($GO_SECURITY->group_root,$acl_write) && $GO_SECURITY->add_group_to_acl($GO_SECURITY->group_root,$acl_read))
- {
- if(!$GO_MODULES->add_module($module_id, $path, $acl_read, $acl_write))
- {
- $feedback = '<p class="Error">'.$strSaveError.'</p>';
- }
- }else
- {
- $GO_SECURITY->delete_acl($acl_read);
- $GO_SECURITY->delete_acl($acl_write);
- $feedback = '<p class="Error">'.$strAclError.'</p>';
- }
- }else
- {
- $feedback = '<p class="Error">'.$strAclError.'</p>';
- }
- }
- }else
- {
- if ($GO_MODULES->is_registered_module($modules[$i]['path']))
- {
- $GO_MODULES->delete_module($modules[$i]['name']);
- }
- }
- }
- //delete non existent modules
- $GO_MODULES->get_modules();
- while($GO_MODULES->next_record())
- {
- if (!in_array(substr($GO_CONFIG->root_path.$GO_MODULES->f('path'),0,-1), $existing_modules))
- {
- $GO_MODULES2 = new GO_MODULES();
- $GO_MODULES2->delete_module(basename($GO_MODULES->f('path')));
- }
- }
-
-
- echo '<script type="text/javascript">';
-
- if (!isset($feedback) && $_POST['close'] == 'true')
- {
- echo 'parent.location="'.$GO_CONFIG->host.'index.php?return_to='.urlencode($return_to).'";';
- }else
- {
- echo 'parent.location="'.$GO_CONFIG->host.'index.php?return_to='.urlencode($_SERVER['PHP_SELF']).'";';
- }
- echo '</script>';
- }
- }
-
- echo '<form method="post" name="modules" action="'.$_SERVER['PHP_SELF'].'">';
- echo '<input type="hidden" name="task" />';
- echo '<input type="hidden" name="close" value="false" />';
-
- $tabtable->print_head();
- require('modules.inc');
- $tabtable->print_foot();
- echo '</form>';
-
- require($GO_THEME->theme_path."footer.inc");
- ?>
-