示例#1
0
    $view_id = $cal_settings['default_view_id'];
    $calendar_id = $cal_settings['default_cal_id'];
}
//if a view is given then display view. Otherwise open a calendar
if ($view_id > 0) {
    $view = $cal->get_view($view_id);
    if ($view) {
        $title = $view['name'];
        $calendar_id = 0;
        $cal_start_hour = $view['start_hour'];
        $cal_end_hour = $view['end_hour'];
    }
}
if (!isset($view) || !$view) {
    //get the calendar properties and check permissions
    if ($calendar_id != 0 && ($calendar = $cal->get_calendar($calendar_id))) {
        $calendar['read_permission'] = $GO_SECURITY->has_permission($GO_SECURITY->user_id, $calendar['acl_read']);
        $calendar['write_permission'] = $GO_SECURITY->has_permission($GO_SECURITY->user_id, $calendar['acl_write']);
        if (!$calendar['read_permission'] && !$calendar['write_permission']) {
            //hmm no calendar_id given and default calendar is set
            //Does this user even have calendars?
            $cal->get_user_calendars($GO_SECURITY->user_id);
            if ($cal->next_record()) {
                //yes he does so set it default
                $calendar_id = $cal->f('id');
            } else {
                $calendar_name = $_SESSION['GO_SESSION']['name'];
                $new_calendar_name = $calendar_name;
                $x = 1;
                while ($cal->get_calendar_by_name($new_calendar_name)) {
                    $new_calendar_name = $calendar_name . ' (' . $x . ')';
require "../../Group-Office.php";
$GO_SECURITY->authenticate();
$GO_MODULES->authenticate('calendar');
require $GO_LANGUAGE->get_language_file('calendar');
require $GO_MODULES->path . 'classes/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'];
$link_back = isset($_REQUEST['link_back']) ? $_REQUEST['link_back'] : $_SERVER['REQUEST_URI'];
$view_type = isset($_REQUEST['view_type']) ? $_REQUEST['view_type'] : 0;
$calendar_id = isset($_REQUEST['calendar_id']) ? $_REQUEST['calendar_id'] : 0;
$db = new db();
switch ($task) {
    case 'delete_calendar':
        $calendar = $cal->get_calendar($_POST['delete_calendar_id']);
        if ($GO_SECURITY->user_id == $calendar['user_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']);
            }
        }
        $db->query("SELECT calendar_id FROM cal_config WHERE user_id='" . $GO_SECURITY->user_id . "'");
        while ($db->next_record()) {
            $subscribed[] = $db->f('calendar_id');
        }
        break;
    case 'save_calendar':
        $cal->set_default_calendar($GO_SECURITY->user_id, $_POST['default_calendar_id']);
        if ($_POST['close_action'] == 'true') {
示例#3
0
 while ($cal->next_record()) {
     if ($GO_SECURITY->has_permission($GO_SECURITY->user_id, $cal->f('acl_write'))) {
         //remember the first ab that is writable
         if (!isset($first_writable_cal)) {
             $first_writable_cal = $cal->f('id');
         }
         $dropbox->add_value($cal->f('id'), $cal->f('name'));
         if (isset($marked_calendars) && is_array($marked_calendars) && in_array($cal->f('id'), $marked_calendars)) {
             $event['calendars'][] = $cal->f('id');
         }
         $count++;
     }
 }
 //get the given calendar
 if ($calendar_id > 0) {
     $calendar = $cal->get_calendar($calendar_id);
 } else {
     $calendar = false;
 }
 //if there was no or a read only addressbook given then change to the first writable
 if (!$calendar || !$GO_SECURITY->has_permission($GO_SECURITY->user_id, $calendar['acl_write'])) {
     //there is no writable addressbook so add one
     if (!isset($first_writable_cal)) {
         $cal_name = $_SESSION['GO_SESSION']['name'];
         $new_cal_name = $cal_name;
         $x = 1;
         while ($cal->get_calendar_by_name($new_cal_name)) {
             $new_cal_name = $cal_name . ' (' . $x . ')';
             $x++;
         }
         $calendar_id = $cal->add_calendar($GO_SECURITY->user_id, addslashes($new_cal_name), 7, 20);