home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Freeware / Programare / groupoffice-com-2.01 / modules / calendar / calendars.php < prev    next >
PHP Script  |  2004-03-08  |  3KB  |  109 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.  
  15. $GO_SECURITY->authenticate();
  16. $GO_MODULES->authenticate('calendar');
  17. require($GO_LANGUAGE->get_language_file('calendar'));
  18.  
  19. require($GO_CONFIG->class_path.'calendar.class.inc');
  20. $cal = new calendar();
  21.  
  22. $post_action = isset($_REQUEST['post_action']) ? $_REQUEST['post_action'] : '';
  23. $task = isset($_POST['task']) ? $_POST['task'] : '';
  24. $return_to = isset($_REQUEST['return_to']) ? $_REQUEST['return_to'] : $_SERVER['HTTP_REFERER'];
  25.  
  26. $calendar_id = isset($_REQUEST['calendar_id']) ? $_REQUEST['calendar_id'] : 0;
  27.  
  28.  
  29. switch ($task)
  30. {
  31.     case 'delete_calendar':
  32.         $calendar = $cal->get_calendar($_POST['delete_calendar_id']);
  33.  
  34.         if($GO_SECURITY->has_permission($GO_SECURITY->user_id, $calendar['acl_write']))
  35.         {
  36.             $default_id = $cal->get_default_calendar($GO_SECURITY->user_id);
  37.             $cal->unsubscribe($GO_SECURITY->user_id, $_POST['delete_calendar_id']);
  38.             if ($cal->delete_calendar($_POST['delete_calendar_id']))
  39.             {
  40.                 $holidays->delete_holidays($GO_SECURITY->user_id, $_POST['delete_calendar_id']);
  41.                 $GO_SECURITY->delete_acl($calendar['acl_write']);
  42.                 $GO_SECURITY->delete_acl($calendar['acl_read']);
  43.             }
  44.  
  45.             $cal->get_subscribed($GO_SECURITY->user_id);
  46.             if ($cal->next_record())
  47.             {
  48.                 $next_id = $cal->f('id');
  49.                 if ($_POST['delete_calendar_id'] == $default_id)
  50.                 {
  51.                     $cal->set_default_calendar($GO_SECURITY->user_id, $next_id);
  52.                 }
  53.                 if ($calendar_id == $_POST['delete_calendar_id'])
  54.                 {
  55.                     $calendar_id = $next_id;
  56.                 }
  57.             }else
  58.             {
  59.                 unset($calendar_id);
  60.             }
  61.         }
  62.     break;
  63.  
  64.     case 'save_calendar':
  65.         $calendars = isset($_POST['calendars']) ? $_POST['calendars'] : array();
  66.         $cal->get_calendars($GO_SECURITY->user_id);
  67.         $cal2 = new calendar();
  68.         while ($cal->next_record())
  69.         {
  70.             if (in_array($cal->f('id'), $calendars))
  71.             {
  72.                 if (!$cal2->is_subscribed($GO_SECURITY->user_id, $cal->f('id')))
  73.                 {
  74.                     $cal2->subscribe($GO_SECURITY->user_id, $cal->f('id'));
  75.                 }
  76.             }else
  77.             {
  78.                 if ($cal2->is_subscribed($GO_SECURITY->user_id, $cal->f('id')))
  79.                 {
  80.                     $cal2->unsubscribe($GO_SECURITY->user_id, $cal->f('id'));
  81.                 }
  82.             }
  83.         }
  84.         $cal->set_default_calendar($GO_SECURITY->user_id, $_POST['default_calendar_id']);
  85.         if ($_POST['close_action'] == 'true')
  86.         {
  87.             header('Location: '.$return_to);
  88.             exit();
  89.         }
  90.     break;
  91. }
  92.  
  93. $tabtable = new tabtable('calendar', $sc_calendars, '400', '400', '120', '', true);
  94. require($GO_THEME->theme_path.'header.inc');
  95.  
  96. echo '<form name="events" method="post" action="'.$_SERVER['PHP_SELF'].'">';
  97. echo '<input type="hidden" name="calendar_id" value="'.$calendar_id.'" />';
  98. echo '<input type="hidden" name="return_to" value="'.$return_to.'" />';
  99. echo '<input type="hidden" name="delete_calendar_id" value="" />';
  100. echo '<input type="hidden" name="task" value="'.$task.'" />';
  101. echo '<input type="hidden" name="close_action" value="false" />';
  102.  
  103. $tabtable->print_head();
  104. require('calendars.inc');
  105. $tabtable->print_foot();
  106. echo '</form>';
  107. require($GO_THEME->theme_path.'footer.inc');
  108. ?>
  109.