/** * @dataProvider timeRangeTestData */ public function testInTimeRange(VTodo $vtodo, $start, $end, $outcome) { $this->assertEquals($outcome, $vtodo->isInTimeRange($start, $end)); }
/** * parse VTODO part of VCALENDAR * * @param \Sabre\VObject\Component\VTodo $_vevent the VTODO to parse * @param Tasks_Model_Task $_vtodo the Tine 2.0 event to update */ protected function _convertVtodo(\Sabre\VObject\Component\VTodo $_vtodo, Tasks_Model_Task $_task, $options) { if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) { Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' vtodo ' . $_vtodo->serialize()); } $task = $_task; $task->alarms = new Tinebase_Record_RecordSet('Tinebase_Model_Alarm'); $task->priority = 'NORMAL'; $task->status = 'NEEDS-ACTION'; foreach ($_vtodo->children() as $property) { switch ($property->name) { case 'CREATED': case 'DTSTAMP': // do nothing break; case 'LAST-MODIFIED': $task->last_modified_time = new Tinebase_DateTime($property->getValue()); break; case 'CLASS': if (in_array($property->getValue(), array(Tasks_Model_Task::CLASS_PRIVATE, Tasks_Model_Task::CLASS_PUBLIC))) { $task->class = $property->getValue(); } else { $task->class = Tasks_Model_Task::CLASS_PUBLIC; } break; case 'COMPLETED': if (isset($property['VALUE']) && strtoupper($property['VALUE']) == 'DATE') { // all day event //$task->is_all_day_event = true; $dtend = $this->_convertToTinebaseDateTime($property, TRUE); // whole day events ends at 23:59:59 in Tine 2.0 but 00:00 the next day in vcalendar $dtend->subSecond(1); } else { //$task->is_all_day_event = false; $dtend = $this->_convertToTinebaseDateTime($property); } $task->completed = $dtend; break; case 'DUE': if (isset($property['VALUE']) && strtoupper($property['VALUE']) == 'DATE') { // all day event //$task->is_all_day_event = true; $due = $this->_convertToTinebaseDateTime($property, TRUE); } else { //$task->is_all_day_event = false; $due = $this->_convertToTinebaseDateTime($property); } $task->originator_tz = $due->getTimezone()->getName(); $task->due = $due; break; case 'DTSTART': if (isset($property['VALUE']) && strtoupper($property['VALUE']) == 'DATE') { // all day event //$task->is_all_day_event = true; $dtstart = $this->_convertToTinebaseDateTime($property, TRUE); // whole day events ends at 23:59:59 in Tine 2.0 but 00:00 the next day in vcalendar $dtstart->subSecond(1); } else { //$task->is_all_day_event = false; $dtstart = $this->_convertToTinebaseDateTime($property); } $task->originator_tz = $dtstart->getTimezone()->getName(); $task->dtstart = $dtstart; break; case 'STATUS': $task->status = $property->getValue(); break; case 'PERCENT-COMPLETE': $task->percent = $property->getValue(); break; case 'SEQUENCE': if (!isset($options[self::OPTION_USE_SERVER_MODLOG]) || $options[self::OPTION_USE_SERVER_MODLOG] !== true) { $task->seq = $property->getValue(); } break; case 'PRIORITY': if (is_numeric($property->getValue())) { switch ($property->getValue()) { case '0': $task->priority = 'NORMAL'; break; case '1': $task->priority = 'HIGH'; break; case '9': $task->priority = 'LOW'; break; } } else { $task->priority = $property->getValue(); } break; case 'DESCRIPTION': case 'LOCATION': case 'SUMMARY': $key = strtolower($property->name); //$task->$key = empty($property->getValue()) ? "With aout summary" : $property->getValue(); $task->{$key} = $property->getValue(); break; case 'ORGANIZER': if (preg_match('/mailto:(?P<email>.*)/i', $property->getValue(), $matches)) { // it's not possible to change the organizer by spec if (empty($task->organizer)) { $user = Tinebase_User::getInstance()->getUserByPropertyFromSqlBackend('accountEmailAddress', $matches['email']); $task->organizer = $user ? $user->getId() : Tinebase_Core::getUser()->getId(); } } break; case 'UID': // it's not possible to change the uid by spec if (!empty($task->uid)) { continue; } $task->uid = $property->getValue(); break; case 'VALARM': $this->_parseAlarm($task, $property, $_vtodo); break; case 'CATEGORIES': $tags = Tinebase_Model_Tag::resolveTagNameToTag($property->getParts(), 'Tasks'); if (!isset($task->tags)) { $task->tags = $tags; } else { $task->tags->merge($tags); } break; case 'X-MOZ-LASTACK': $lastAck = $this->_convertToTinebaseDateTime($property); break; case 'X-MOZ-SNOOZE-TIME': $snoozeTime = $this->_convertToTinebaseDateTime($property); break; default: break; } } if (empty($task->percent)) { $task->percent = 0; } if (empty($task->class)) { $task->class = Tasks_Model_Task::CLASS_PUBLIC; } // convert all datetime fields to UTC $task->setTimezone('UTC'); }