/** * Constructor. * * @param array $event The event data. */ public function __construct(array $event) { if (isset($event['uid'])) { $this->_event_id = $event['uid']; } if (!$event['start-date'] instanceof Horde_Date) { $this->_start = new Horde_Date($event['start-date']); } else { $this->_start = $event['start-date']; } if (!$event['end-date'] instanceof Horde_Date) { $this->_end = new Horde_Date($event['end-date']); } else { $this->_end = $event['end-date']; } if (isset($event['summary'])) { $this->_title = $event['summary']; } if (isset($event['location'])) { $this->_location = $event['location']; } if (isset($event['sensitivity']) && ($event['sensitivity'] == 'private' || $event['sensitivity'] == 'confidential')) { $this->_private = true; } if (isset($event['show-time-as'])) { $this->_status = $event['show-time-as']; } else { $this->_status = self::STATUS_NONE; } // Recurrence if (isset($event['recurrence'])) { $this->_recurrence = new Horde_Date_Recurrence($this->_start); $this->_recurrence->fromKolab($event['recurrence']); } }
/** * Build a task based a data array * * @todo Use 'organizer' but migrate old format. * * @param array $task The data for the task * * @return array The converted data array representing the task */ protected function _buildTask($task) { // This decoding of parent ID hashes is required because of a // previous bug in Nag_Driver_Kolab. // See Bug: 14197 $parent_uid = $task['parent']; if (!empty($parent_uid) && $this->_isBase64EncodedUid($parent_uid)) { $parent_uid = Horde_Url::uriB64Decode($parent_uid); } $result = array('task_id' => Horde_Url::uriB64Encode($task['uid']), 'uid' => $task['uid'], 'name' => $task['summary'], 'desc' => $task['body'], 'priority' => $task['priority'], 'parent' => Horde_Url::uriB64Encode($parent_uid), 'alarm' => $task['alarm'], 'completed' => !empty($task['completed']), 'completed_date' => $task['completed_date'], 'private' => $task['sensitivity'] != 'public', 'owner' => $GLOBALS['nag_shares']->getShare($this->_tasklist)->get('owner')); if (isset($task['categories'])) { $result['internaltags'] = $task['categories']; } if (!empty($task['start-date'])) { $result['start'] = $task['start-date']->format('U'); } if (!empty($task['due-date'])) { $result['due'] = $task['due-date']->format('U'); } if (!empty($task['creation-date'])) { $result['created'] = new Horde_Date($task['creation-date']); } if (!empty($task['last-modification-date'])) { $result['modified'] = new Horde_Date($task['last-modification-date']); } if (isset($task['recurrence']) && isset($task['due-date'])) { $recurrence = new Horde_Date_Recurrence($task['due-date']); $recurrence->fromKolab($task['recurrence']); $result['recurrence'] = $recurrence; } if (isset($task['organizer'])) { $result['assignee'] = $task['organizer']['smtp-address']; } if (isset($task['horde-estimate'])) { $result['estimate'] = $task['horde-estimate']; } if (isset($task['horde-alarm-methods'])) { $result['methods'] = @unserialize($task['horde-alarm-methods']); } return $result; }
/** * Build a task based a data array * * @todo Use 'organizer' but migrate old format. * * @param array $task The data for the task * * @return array The converted data array representing the task */ protected function _buildTask($task) { $result = array('task_id' => Horde_Url::uriB64Encode($task['uid']), 'uid' => $task['uid'], 'name' => $task['summary'], 'desc' => $task['body'], 'priority' => $task['priority'], 'parent' => $task['parent'], 'alarm' => $task['alarm'], 'completed' => !empty($task['completed']), 'completed_date' => $task['completed_date'], 'private' => $task['sensitivity'] != 'public', 'owner' => $GLOBALS['nag_shares']->getShare($this->_tasklist)->get('owner')); if (isset($task['categories'])) { $result['internaltags'] = $task['categories']; } if (!empty($task['start-date'])) { $result['start'] = $task['start-date']->format('U'); } if (!empty($task['due-date'])) { $result['due'] = $task['due-date']->format('U'); } if (!empty($task['creation-date'])) { $result['created'] = new Horde_Date($task['creation-date']); } if (!empty($task['last-modification-date'])) { $result['modified'] = new Horde_Date($task['last-modification-date']); } if (isset($task['recurrence']) && isset($task['due-date'])) { $recurrence = new Horde_Date_Recurrence($task['due-date']); $recurrence->fromKolab($task['recurrence']); $result['recurrence'] = $recurrence; } if (isset($task['organizer'])) { $result['assignee'] = $task['organizer']['smtp-address']; } if (isset($task['horde-estimate'])) { $result['estimate'] = $task['horde-estimate']; } if (isset($task['horde-alarm-methods'])) { $result['methods'] = @unserialize($task['horde-alarm-methods']); } return $result; }
/** */ public function testCompletions() { $r = new Horde_Date_Recurrence(new Horde_Date(1970, 1, 1)); $r->setRecurType(Horde_Date_Recurrence::RECUR_DAILY); $r->addCompletion(1970, 1, 2); $this->assertTrue($r->hasCompletion(1970, 1, 2)); $this->assertEquals(1, count($r->getCompletions())); $r->addCompletion(1970, 1, 4); $this->assertEquals(2, count($r->getCompletions())); $r->deleteCompletion(1970, 1, 2); $this->assertEquals(1, count($r->getCompletions())); $this->assertFalse($r->hasCompletion(1970, 1, 2)); $r->addCompletion(1970, 1, 2); $r->addException(1970, 1, 1); $r->addException(1970, 1, 3); $next = $r->nextRecurrence(new Horde_Date($r->start)); $this->assertEquals(1, $next->mday); $this->assertTrue($r->hasException($next->year, $next->month, $next->mday)); $next->mday++; $next = $r->nextRecurrence($next); $this->assertTrue($r->hasCompletion($next->year, $next->month, $next->mday)); $next->mday++; $next = $r->nextRecurrence($next); $this->assertTrue($r->hasException($next->year, $next->month, $next->mday)); $next->mday++; $next = $r->nextRecurrence($next); $this->assertTrue($r->hasCompletion($next->year, $next->month, $next->mday)); $r->setRecurEnd(new Horde_Date(1970, 1, 4)); $this->assertTrue($r->hasRecurEnd()); $this->assertFalse($r->hasActiveRecurrence()); $s = new Horde_Date_Recurrence(new Horde_Date(1970, 1, 1)); $s->fromKolab($r->toKolab()); $this->assertTrue($s->hasRecurEnd()); $next = $s->nextRecurrence(new Horde_Date($s->start)); $this->assertEquals(1, $next->mday); $this->assertTrue($s->hasException($next->year, $next->month, $next->mday)); $next->mday++; $next = $s->nextRecurrence($next); $this->assertTrue($s->hasCompletion($next->year, $next->month, $next->mday)); $next->mday++; $next = $s->nextRecurrence($next); $this->assertTrue($s->hasException($next->year, $next->month, $next->mday)); $next->mday++; $next = $s->nextRecurrence($next); $this->assertTrue($s->hasCompletion($next->year, $next->month, $next->mday)); $this->assertEquals(2, count($s->getCompletions())); $this->assertEquals(2, count($s->getExceptions())); $this->assertFalse($s->hasActiveRecurrence()); $this->assertEquals(2, count($s->getCompletions())); $s->deleteCompletion(1970, 1, 2); $this->assertEquals(1, count($s->getCompletions())); $s->deleteCompletion(1970, 1, 4); $this->assertEquals(0, count($s->getCompletions())); }