home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Freeware / Programare / groupoffice-com-2.01 / modules / cms / index.php < prev    next >
PHP Script  |  2004-03-08  |  3KB  |  123 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. //load Group-Office
  14. require("../../Group-Office.php");
  15.  
  16. //load the CMS module class library
  17. require($GO_CONFIG->class_path.'cms.class.inc');
  18. $cms = new cms();
  19.  
  20. //authenticate the user
  21. $GO_SECURITY->authenticate();
  22.  
  23. //see if the user has access to this module
  24. //for this to work there must be a module named 'example'
  25. $GO_MODULES->authenticate('cms');
  26.  
  27. //get the language file
  28. require($GO_LANGUAGE->get_language_file('cms'));
  29.  
  30. //create a tab window
  31. $tabtable = new tabtable('sites', $lang_modules['cms'], '600', '400');
  32. $tabtable->add_tab('subscribed.inc', $cms_your_sites);
  33. $tabtable->add_tab('sites.inc', $cms_all_sites);
  34.  
  35. if ($GO_MODULES->write_permissions)
  36. {
  37.     $tabtable->add_tab('templates.inc', $cms_themes_menu);
  38.     $tabtable->add_tab('configuration.inc', $menu_configuration);
  39. }
  40.  
  41. //perform tasks before output to client
  42. $task = isset($_REQUEST['task']) ? $_REQUEST['task'] : '';
  43.  
  44. if(isset($_REQUEST['tabindex']))
  45. {
  46.     $tabtable->set_active_tab($_REQUEST['tabindex']);
  47. }
  48.  
  49. switch($task)
  50. {
  51.     case 'sites':
  52.         if($_SERVER['REQUEST_METHOD'] == 'POST')
  53.         {
  54.              $subscribed = isset($_POST['subscribed']) ? $_POST['subscribed'] : array();
  55.  
  56.              $cms->get_authorized_sites($GO_SECURITY->user_id);
  57.              $cms2 = new cms();
  58.              while ($cms->next_record())
  59.              {
  60.                  $is_subscribed = $cms2->is_subscribed($GO_SECURITY->user_id, $cms->f('id'));
  61.                  $in_array = in_array($cms->f('id'), $subscribed);
  62.  
  63.                  if ($is_subscribed && !$in_array)
  64.                  {
  65.                      $cms2->unsubscribe_site($GO_SECURITY->user_id, $cms->f('id'));
  66.                  }
  67.  
  68.                  if (!$is_subscribed && $in_array)
  69.                  {
  70.                      $cms2->subscribe_site($GO_SECURITY->user_id, $cms->f('id'));
  71.                  }
  72.              }
  73.         }
  74.     break;
  75.  
  76.     case 'configuration':
  77.         if($_SERVER['REQUEST_METHOD'] == 'POST')
  78.         {
  79.             if (isset($_POST['publish_path']))
  80.             {
  81.                 $publish_path = trim($_POST['publish_path']);
  82.                 if (!is_writable($publish_path))
  83.                 {
  84.                     $feedback ='<p class="Error">'.$cms_path_not_writable.'</p>';
  85.                 }else
  86.                 {
  87.                     $publish_url = trim($_POST['publish_url']);
  88.                     if (substr($publish_path, -1) != $GO_CONFIG->slash) $publish_path = $publish_path.$GO_CONFIG->slash;
  89.                     if (!eregi('(^http[s]*:[/]+)(.*)', $publish_url))
  90.                     {
  91.                         $publish_url= "http://".$publish_url;
  92.                     }
  93.                     if (substr($publish_url, -1) != '/') $publish_url = $publish_url.'/';
  94.                     $GO_CONFIG->save_setting('cms_publish_path', $publish_path);
  95.                     $GO_CONFIG->save_setting('cms_publish_url', $publish_url);
  96.                 }
  97.             }else
  98.             {
  99.                 $GO_CONFIG->delete_setting('cms_publish_path');
  100.                 $GO_CONFIG->delete_setting('cms_publish_url');
  101.             }
  102.         }
  103.     break;
  104. }
  105.  
  106. //set the page title for the header file
  107. $page_title = $lang_modules['cms'];
  108.  
  109. //require the header file. This will draw the logo's and the menu
  110. require($GO_THEME->theme_path."header.inc");
  111. ?>
  112. <form name="cms" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
  113.  
  114. <?php
  115. $tabtable->print_head();
  116. require($tabtable->get_active_tab_id());
  117. $tabtable->print_foot();
  118. ?>
  119.  
  120. </form>
  121. <?php
  122. require($GO_THEME->theme_path."footer.inc");
  123. ?>