idcolumn = 'dav_id'; $db = new Database(DBDRIVER, DBHOST, DAV_DBNAME, DBUSER, DBPASS); parent::__construct('calendar_item', $id, $db); } protected function postLoad() { $start = explode(' ', $this->data->dtstart); $starttime = explode(':', $start[1]); $end = explode(' ', $this->data->dtend); $endtime = explode(':', $end[1]); $this->isRegular = $start[0] == $end[0]; if ($this->isRegular) { if ($starttime[1] == '00' && $endtime[1] == '00') { if ($starttime[0] == $endtime[0]) $this->timespan = $starttime[0]; else $this->timespan = $starttime[0] .'-'. $endtime[0]; } else { $this->timespan = sprintf('%d:%02d-%d:%02d', $starttime[0], $starttime[1], $endtime[0], $endtime[1]); } } else { $startTimeStamp = strtotime($start[0]) + (3*60*60); $endTimeStamp = strtotime($end[0]); while ($startTimeStamp < $endTimeStamp) { $this->timeDays[] = date('Y-m-d', $startTimeStamp); $startTimeStamp += (24*60*60); } } } public function isRegular() { return $this->isRegular; } public function timespan() { return $this->timespan; } public function getDays() { return $this->timeDays; } public function toSpan() { $tooltip = ''; if ($this->data->description) $tooltip .= (strlen($tooltip)?', ':'').$this->data->description; if ($this->data->location) $tooltip .= (strlen($tooltip)?', ':'').'Ort: '.$this->data->location; if (strlen($tooltip)) $tooltip = sprintf(' title="%s"', $tooltip); $sql = sprintf("SELECT color FROM calendar_item_data WHERE dav_id = %d", $this->id); $bgcolor = $this->fetchValue($sql); if ($bgcolor) $bgcolor = sprintf(' style="background:%s;"', $bgcolor); return sprintf('%s %s', $this->id, $tooltip, $bgcolor, $this->timespan(), $this->data->summary); } public function ajaxSetColor(Array $data) { $sql = sprintf("SELECT id FROM calendar_item_data WHERE dav_id = %d", $this->id); $id = $this->fetchValue($sql); if ($id) $sql = sprintf("UPDATE calendar_item_data SET color = %s WHERE id = %d", $this->quote($data['color']), $id); else $sql = sprintf("INSERT INTO calendar_item_data (dav_id, color) VALUES (%d,%s)", $this->id, $this->quote($data['color'])); return $this->execute($sql); } public function ajaxLog(Array $data) { $title = $this->data->summary; if ($this->data->location) $title .= ', ' . $this->data->location; $out = sprintf('