calendars = array(); $this->uid = $uid; $this->session_start = time(); } public function setCalendars($calendars) { $this->calendars = $calendars; } public function addCalendar($id, CalendarInfo $calendar) { $this->calendars[$id] = $calendar; } public function removeCalendar($id) { unset($this->calendars[$id]); } public function setSettings($settings) { //file_put_contents('/tmp/davical.log', // __FILE__ . ": " . var_export($settings, TRUE), FILE_APPEND); $first = TRUE; foreach ($settings as $row) { if ($first) { $this->viewStyle = $row['userview']; $this->startWeek = ($row['weekstart']) ? TRUE : FALSE; $this->startHour = $row['daystart']; $this->endHour = $row['dayend']; $this->role = (int) $row['userrole']; $this->timeout = (int) $row['timeout']; $this->timezone = $row['timezone']; $first = FALSE; } if (isset($row['id']) && $row['id'] >= 0) { $calendar = new CalendarInfo(); $calendar->name = $row['name']; $calendar->color = $row['color']; $calendar->config = $row['config']; $this->calendars[$row['id']] = $calendar; } } $this->isTimeout(TRUE); } public function getCalendars() { return $this->calendars; } public function getCalendar($name) { foreach ($this->calendars as $calendar) { if ($calendar->name == $name) return $calendar->config; } return NULL; } public function getViewStyle() { return $this->viewStyle; } public function getStartWeek() { return $this->startWeek; } public function getStartHour() { return $this->startHour; } public function getEndHour() { return $this->endHour; } public function getRole() { return (int) $this->role; } public function getTimeout() { return $this->timeout; } public function isTimeout($reset = FALSE) { $terminate = TRUE; $now = time(); if ($reset) $this->session_start = $now; //echo "$this->session_start -> $this->timeout -> $now
"; $_SESSION['isTimeout'] = TRUE; if ($this->session_start + $this->timeout > $now) { $this->session_start = $now; $terminate = FALSE; $remain = $this->timeout / 60; setcookie('WEBCAL_EXPIRE', $remain, 0, $_SESSION['WEB_ROOT']); } else { header('Location: ' . $_SESSION['WEB_ROOT'] . 'logout.php'); exit; } } public function getUid() { return $this->uid; } public function getTimezone() { return $this->timezone; } }