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();
- $GO_MODULES->authenticate('calendar');
- require($GO_LANGUAGE->get_language_file('calendar'));
-
- require($GO_CONFIG->class_path.'calendar.class.inc');
- $cal = new calendar();
-
- $post_action = isset($_REQUEST['post_action']) ? $_REQUEST['post_action'] : '';
- $task = isset($_POST['task']) ? $_POST['task'] : '';
- $return_to = isset($_REQUEST['return_to']) ? $_REQUEST['return_to'] : $_SERVER['HTTP_REFERER'];
-
- $calendar_id = isset($_REQUEST['calendar_id']) ? $_REQUEST['calendar_id'] : 0;
-
-
- switch ($task)
- {
- case 'delete_calendar':
- $calendar = $cal->get_calendar($_POST['delete_calendar_id']);
-
- if($GO_SECURITY->has_permission($GO_SECURITY->user_id, $calendar['acl_write']))
- {
- $default_id = $cal->get_default_calendar($GO_SECURITY->user_id);
- $cal->unsubscribe($GO_SECURITY->user_id, $_POST['delete_calendar_id']);
- if ($cal->delete_calendar($_POST['delete_calendar_id']))
- {
- $holidays->delete_holidays($GO_SECURITY->user_id, $_POST['delete_calendar_id']);
- $GO_SECURITY->delete_acl($calendar['acl_write']);
- $GO_SECURITY->delete_acl($calendar['acl_read']);
- }
-
- $cal->get_subscribed($GO_SECURITY->user_id);
- if ($cal->next_record())
- {
- $next_id = $cal->f('id');
- if ($_POST['delete_calendar_id'] == $default_id)
- {
- $cal->set_default_calendar($GO_SECURITY->user_id, $next_id);
- }
- if ($calendar_id == $_POST['delete_calendar_id'])
- {
- $calendar_id = $next_id;
- }
- }else
- {
- unset($calendar_id);
- }
- }
- break;
-
- case 'save_calendar':
- $calendars = isset($_POST['calendars']) ? $_POST['calendars'] : array();
- $cal->get_calendars($GO_SECURITY->user_id);
- $cal2 = new calendar();
- while ($cal->next_record())
- {
- if (in_array($cal->f('id'), $calendars))
- {
- if (!$cal2->is_subscribed($GO_SECURITY->user_id, $cal->f('id')))
- {
- $cal2->subscribe($GO_SECURITY->user_id, $cal->f('id'));
- }
- }else
- {
- if ($cal2->is_subscribed($GO_SECURITY->user_id, $cal->f('id')))
- {
- $cal2->unsubscribe($GO_SECURITY->user_id, $cal->f('id'));
- }
- }
- }
- $cal->set_default_calendar($GO_SECURITY->user_id, $_POST['default_calendar_id']);
- if ($_POST['close_action'] == 'true')
- {
- header('Location: '.$return_to);
- exit();
- }
- break;
- }
-
- $tabtable = new tabtable('calendar', $sc_calendars, '400', '400', '120', '', true);
- require($GO_THEME->theme_path.'header.inc');
-
- echo '<form name="events" method="post" action="'.$_SERVER['PHP_SELF'].'">';
- echo '<input type="hidden" name="calendar_id" value="'.$calendar_id.'" />';
- echo '<input type="hidden" name="return_to" value="'.$return_to.'" />';
- echo '<input type="hidden" name="delete_calendar_id" value="" />';
- echo '<input type="hidden" name="task" value="'.$task.'" />';
- echo '<input type="hidden" name="close_action" value="false" />';
-
- $tabtable->print_head();
- require('calendars.inc');
- $tabtable->print_foot();
- echo '</form>';
- require($GO_THEME->theme_path.'footer.inc');
- ?>
-