コード例 #1
0
ファイル: TaskFilter.php プロジェクト: jakoubek/kanboard
 /**
  * Get common events for task ical events
  *
  * @access protected
  * @param  array   $task
  * @param  string  $uid
  * @return Event
  */
 protected function getTaskIcalEvent(array &$task, $uid)
 {
     $dateCreation = new DateTime();
     $dateCreation->setTimestamp($task['date_creation']);
     $dateModif = new DateTime();
     $dateModif->setTimestamp($task['date_modification']);
     $vEvent = new Event($uid);
     $vEvent->setCreated($dateCreation);
     $vEvent->setModified($dateModif);
     $vEvent->setUseTimezone(true);
     $vEvent->setSummary(t('#%d', $task['id']) . ' ' . $task['title']);
     $vEvent->setUrl($this->helper->url->base() . $this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])));
     if (!empty($task['owner_id'])) {
         $vEvent->setOrganizer('MAILTO:' . ($task['assignee_email'] ?: $task['assignee_username'] . '@kanboard.local'));
     }
     if (!empty($task['creator_id'])) {
         $attendees = new Attendees();
         $attendees->add('MAILTO:' . ($task['creator_email'] ?: $task['creator_username'] . '@kanboard.local'));
         $vEvent->setAttendees($attendees);
     }
     return $vEvent;
 }
コード例 #2
0
ファイル: Calendar.php プロジェクト: cmbuckley/letterboxd-ics
 public function loadEvents()
 {
     if ($this->components === array()) {
         $diary = @fopen($this->getFile(), 'r');
         $headers = null;
         if ($diary === false) {
             $error = error_get_last();
             throw new Exception("Cannot find event file: " . $error['message']);
         }
         $this->log->info('Parsing diary CSV');
         while (false !== ($row = fgetcsv($diary))) {
             if ($headers === null) {
                 $headers = $row;
             } else {
                 $row = array_combine($headers, $row);
                 $event = new Event();
                 $event->setDtStart(new \DateTime($row[$this->headers['date']]));
                 $event->setDtEnd(new \DateTime($row[$this->headers['date']]));
                 $event->setNoTime(true);
                 $event->setSummary($row[$this->headers['summary']]);
                 $event->setDescription($this->getEventDescription($row));
                 $event->setUrl($row[$this->headers['url']]);
                 $this->addEvent($event);
             }
         }
         $this->log->info('Parsing complete');
     }
 }