=> array( 'type' => 'varchar', 'required' => true, ), 'location' => array( 'type' => 'varchar', ), 'start_time' => array( 'type' => 'datetime', ), 'end_time' => array( 'type' => 'datetime', 'null' => true, ), 'day_event' => array( 'type' => 'boolean', ), 'annotation' => array( 'type' => 'text', ), 'show_annotation' => array( 'type' => 'boolean', ), 'body' => array( 'type' => 'text', ), 'locked' => array( 'type' => 'boolean', ), 'published' => array( 'type' => 'boolean', ), 'submitted' => array( 'type' => 'boolean', ), 'labels' => array( 'type' => 'has_and_belongs_to_many', ), 'owner' => array( 'type' => 'integer', ), ); function getListQuery($calendar) { if ($calendar) { $id = $calendar->id; } else { $id = null; } $q = $this->createQuery(); $q->filter('calendar', $id); $q->order('created_at'); return $q; } private $_tools = false; function parseFlags($raw) { $flags = array(); $parts = explode('||', $raw); $title = trim(array_shift($parts)); if ($parts) { $tools = $this->_tools; if ($tools === false) { $tools = $this->getSite()->getObject('DPages:/xinha'); $this->_tools = $tools; } if ($tools) { $flags = $tools->parseFlags($parts); } } if (!$flags) { $flags = array(); } return array($title, $flags); } } class m_DEvents_events_event_record extends dgRecord { function get_may_access() { return $this->calendar->may_access; } function get_may_view() { return $this->calendar->may_view_events; } function get_may_edit() { if ($this->may_publish) { return true; } if ($this->published || $this->submitted) { return false; } if (!$this->isNew() && $this->owner != $this->site()->user->id) { return false; } return $this->calendar->editor_rights; } function get_may_submit() { if ($this->published || $this->may_publish) { return false; } if (!$this->isNew() && $this->owner != $this->site()->user->id) { return false; } return $this->calendar->editor_rights; } function get_may_publish() { return $this->calendar->publishing_rights; } function get_real_title() { list($title, $flags) = $this->getModel()->parseFlags($this->title); $this->real_title = $title; $this->flags = $flags; return $title; } function get_flags() { list($title, $flags) = $this->getModel()->parseFlags($this->title); $this->real_title = $title; $this->flags = $flags; return $this->flags; } function get_time() { $start_ts = strtotime($this->start_time); $start_date = strftime('%d.%m.%Y', $start_ts); if ($this->end_time) { $end_ts = strtotime($this->end_time); $end_date = strftime('%d.%m.%Y', $end_ts); } else { $end_ts = $end_date = null; } $until = ''; if ($this->day_event) { // DD.MM.YYYY $time = $start_date; if ($end_date && $start_date != $end_date) { // DD.MM.YYYY-DD.MM.YYYY $until = $end_date; } } else { $time = strftime('%d.%m.%Y %H:%M', $start_ts); if ($end_date) { if ($start_date == $end_date) { // DD.MM.YYYY HH:MM-HH:MM $until = strftime('%H:%M', $end_ts); } else { // DD.MM.YYYY HH:MM-DD.MM.YYY HH:MM $until = strftime('%d.%m.%Y %H:%M', $end_ts); } } } if ($until) { $time .= '-' . $until; } return $time; } function get_created_time() { return strftime('%d.%m.%Y %H:%M', strtotime($this->created_at)); } private $_status_icons = null; function get_status_icons() { if ($this->_status_icons === null) { $_ = $this->getModel()->Node->getStrings(); $icons = array(); if ($this->locked) { $icons[] = array('type' => 'locked', 'label' => $_->EVENT_LOCKED); } if (!$this->published) { if ($this->submitted) { $icons[] = array('type' => 'draft', 'label' => $_->EVENT_SUBMITTED); } else { $icons[] = array('type' => 'draft', 'label' => $_->EVENT_UNPUBLISHED); } } $this->_status_icons = $icons; } return $this->_status_icons; } function isProtected() { return $this->calendar->isProtected(); } } ?>