home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Freeware / Programare / groupoffice-com-2.01 / administrator / settings / index.php < prev    next >
Encoding:
PHP Script  |  2004-03-08  |  3.7 KB  |  120 lines

  1. <?php
  2. /*
  3. Copyright Intermesh 2003
  4. Author: Merijn Schering <mschering@intermesh.nl>
  5. Version: 1.0 Release date: 08 July 2003
  6.  
  7. This program is free software; you can redistribute it and/or modify it
  8. under the terms of the GNU General Public License as published by the
  9. Free Software Foundation; either version 2 of the License, or (at your
  10. option) any later version.
  11. */
  12.  
  13. require("../../Group-Office.php");
  14. $GO_SECURITY->authenticate(true);
  15. require($GO_LANGUAGE->get_language_file('settings'));
  16.  
  17. $task = isset($_REQUEST['task']) ? $_REQUEST['task'] : '';
  18. $return_to = $GO_CONFIG->host.'configuration/';
  19. $tabtable = new tabtable('settings', $menu_modules, '500','300');
  20.  
  21. require_once($GO_CONFIG->class_path.'filesystem.class.inc');
  22. $fs = new filesystem();
  23.  
  24. $modules = $fs->get_folders($GO_CONFIG->module_path);
  25. $existing_modules = array();
  26. $selected_modules = isset($_POST['selected_modules']) ? $_POST['selected_modules'] : array();
  27.  
  28. $page_title = $menu_modules;
  29. require($GO_THEME->theme_path."header.inc");
  30.  
  31. if ($task == 'save_modules')
  32. {
  33.     require_once($GO_CONFIG->class_path.'filesystem.class.inc');
  34.     $fs = new filesystem();
  35.  
  36.     $modules = $fs->get_folders($GO_CONFIG->module_path);
  37.     $existing_modules = array();
  38.     $selected_modules = isset($_POST['selected_modules']) ? $_POST['selected_modules'] : array();
  39.     if ($_SERVER['REQUEST_METHOD'] == 'POST')
  40.     {
  41.         for ($i=0;$i<count($modules);$i++)
  42.         {
  43.             $existing_modules[] = $modules[$i]['path'];
  44.             if (in_array($modules[$i]['path'],$selected_modules))
  45.             {
  46.                 if (!$GO_MODULES->is_registered_module($modules[$i]['path']))
  47.                 {
  48.                     $module_id = $modules[$i]['name'];
  49.                     $path = str_replace($GO_CONFIG->root_path,'',$modules[$i]['path']);
  50.                     if (substr($path, -1) != $GO_CONFIG->slash)
  51.                     {
  52.                         $path .= $GO_CONFIG->slash;
  53.                     }
  54.                     $acl_read = $GO_SECURITY->get_new_acl('Module read: '.$module_id, 0);
  55.                     $acl_write = $GO_SECURITY->get_new_acl('Module write: '.$module_id, 0);
  56.  
  57.                     if ($acl_read > 0 && $acl_write > 0)
  58.                     {
  59.                         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))
  60.                         {
  61.                             if(!$GO_MODULES->add_module($module_id, $path, $acl_read, $acl_write))
  62.                             {
  63.                                 $feedback = '<p class="Error">'.$strSaveError.'</p>';
  64.                             }
  65.                         }else
  66.                         {
  67.                             $GO_SECURITY->delete_acl($acl_read);
  68.                             $GO_SECURITY->delete_acl($acl_write);
  69.                             $feedback = '<p class="Error">'.$strAclError.'</p>';
  70.                         }
  71.                     }else
  72.                     {
  73.                         $feedback = '<p class="Error">'.$strAclError.'</p>';
  74.                     }
  75.                 }
  76.             }else
  77.             {
  78.                 if ($GO_MODULES->is_registered_module($modules[$i]['path']))
  79.                 {
  80.                     $GO_MODULES->delete_module($modules[$i]['name']);
  81.                 }
  82.             }
  83.         }
  84.         //delete non existent modules
  85.         $GO_MODULES->get_modules();
  86.         while($GO_MODULES->next_record())
  87.         {
  88.             if (!in_array(substr($GO_CONFIG->root_path.$GO_MODULES->f('path'),0,-1), $existing_modules))
  89.             {
  90.                 $GO_MODULES2 = new GO_MODULES();
  91.                 $GO_MODULES2->delete_module(basename($GO_MODULES->f('path')));
  92.             }
  93.         }
  94.  
  95.  
  96.         echo '<script type="text/javascript">';
  97.  
  98.         if (!isset($feedback) && $_POST['close'] == 'true')
  99.         {
  100.             echo 'parent.location="'.$GO_CONFIG->host.'index.php?return_to='.urlencode($return_to).'";';
  101.         }else
  102.         {
  103.             echo 'parent.location="'.$GO_CONFIG->host.'index.php?return_to='.urlencode($_SERVER['PHP_SELF']).'";';
  104.         }
  105.         echo '</script>';
  106.     }
  107. }
  108.  
  109. echo '<form method="post" name="modules" action="'.$_SERVER['PHP_SELF'].'">';
  110. echo '<input type="hidden" name="task" />';
  111. echo '<input type="hidden" name="close" value="false" />';
  112.  
  113. $tabtable->print_head();
  114. require('modules.inc');
  115. $tabtable->print_foot();
  116. echo '</form>';
  117.  
  118. require($GO_THEME->theme_path."footer.inc");
  119. ?>
  120.