function __construct() { parent::__construct(); $this->prefs = Preferences::singleton($this->session->userdata('prefs')); $this->load->library('caldav'); $this->output->set_content_type('application/json'); }
function __construct() { parent::__construct(); // Force authentication $this->auth->force_auth(); // Preferences $this->prefs = Preferences::singleton($this->session->userdata('prefs')); }
function __construct() { parent::__construct(); if (!$this->auth->is_authenticated()) { $this->extended_logs->message('INFO', 'Anonymous access attempt to ' . uri_string()); $this->output->set_status_header('401'); $this->output->_display(); die; } $this->calendar_colors = $this->config->item('calendar_colors'); $this->prefs = Preferences::singleton($this->session->userdata('prefs')); $this->load->library('caldav'); $this->output->set_content_type('application/json'); }
function __construct() { parent::__construct(); if (!$this->auth->is_authenticated()) { $this->extended_logs->message('INFO', 'Anonymous access attempt to ' . uri_string()); $this->output->set_status_header('401'); $this->output->_display(); die; } $this->date_format = $this->dates->date_format_string('date'); $this->time_format = $this->dates->time_format_string('date'); $this->tz = $this->timezonemanager->getTz($this->config->item('default_timezone')); $this->tz_utc = $this->timezonemanager->getTz('UTC'); $this->prefs = Preferences::singleton($this->session->userdata('prefs')); $this->load->library('caldav'); $this->output->set_content_type('application/json'); }
/** * Generates a view to add an event */ function create_event() { // Start/end date passed? $start = $this->input->post('start'); $end = $this->input->post('end'); if (FALSE === $start) { $start = time(); } // All day? $allday = $this->input->post('allday'); if ($allday === FALSE || $allday == 'false') { $allday = FALSE; } else { $allday = TRUE; } // View $view = $this->input->post('view'); $dstart = null; $dend = null; // Base DateTime start $dstart = $this->dates->fullcalendar2datetime($start, $this->tz_utc); // TODO make default duration configurable if ($view == 'month') { // Calculate times $now = $this->dates->approx_by_factor(null, $this->tz); $dstart->setTime($now->format('H'), $now->format('i')); if ($end === FALSE || $start == $end) { $dend = clone $dstart; $dend->add(new DateInterval('PT60M')); } else { $dend = $this->dates->fullcalendar2datetime($end, $this->tz_utc); $dend->setTime($dstart->format('H'), $dstart->format('i')); } } elseif ($allday === FALSE) { if ($end === FALSE || $start == $end) { $dend = clone $dstart; $dend->add(new DateInterval('PT60M')); // 1h } else { $dend = $this->dates->fullcalendar2datetime($end, $this->tz_utc); } } else { $dstart->setTime(0, 0); if ($end === FALSE) { $dend = clone $dstart; } else { $dend = $this->dates->fullcalendar2datetime($end, $this->tz_utc); } } // Calendars $tmp_cals = $this->session->userdata('available_calendars'); $calendars = array(); if ($tmp_cals === FALSE) { $this->extended_logs->message('ERROR', 'Call to create_or_modify_event() with no calendars stored in session'); } else { foreach ($tmp_cals as $id => $data) { if (!$data->shared || $data->write_access == '1') { $calendars[$id] = $data->displayname; } } } // Currently selected calendar (or calendar on which // this event is placed on) $calendar = $this->input->post('current_calendar'); if ($calendar === FALSE) { // Use the calendar specified in preferences $prefs = Preferences::singleton($this->session->userdata('prefs')); $calendar = $prefs->default_calendar; if ($calendar === FALSE) { $calendar = array_shift(array_keys($calendars)); } } $data = array('start_date' => $dstart->format($this->date_format), 'start_time' => $dstart->format($this->time_format), 'end_date' => $dend->format($this->date_format), 'end_time' => $dend->format($this->time_format), 'allday' => $allday, 'calendars' => $calendars, 'calendar' => $calendar); $this->load->view('dialogs/create_or_modify_event', $data); }