Nag_Task::toHash PHP Method

toHash() public method

Returns a hash representation for this task.
public toHash ( ) : array
return array A task hash.
    public function toHash()
    {
        $hash = array('tasklist_id' => $this->tasklist, 'task_id' => $this->id, 'uid' => $this->uid, 'parent' => $this->parent_id, 'owner' => $this->owner, 'assignee' => $this->assignee, 'name' => $this->name, 'desc' => $this->desc, 'start' => $this->start, 'due' => $this->due, 'priority' => $this->priority, 'estimate' => $this->estimate, 'completed' => $this->completed, 'completed_date' => $this->completed_date, 'alarm' => $this->alarm, 'methods' => $this->methods, 'private' => $this->private, 'recurrence' => $this->recurrence, 'tags' => $this->tags, 'organizer' => $this->organizer, 'status' => $this->status, 'actual' => $this->actual);
        return $hash;
    }

Usage Example

Beispiel #1
0
 /**
  * Replaces the task identified by UID with the content represented in the
  * specified content type.
  *
  * If you want to replace multiple tasks with the UID specified in the
  * VCALENDAR data, you may use $this->import instead. This automatically does a
  * replace if existings UIDs are found.
  *
  *
  * @param string $uid          Identify the task to replace.
  * @param string $content      The content of the task.
  * @param string $contentType  What format is the data in? Currently supports:
  *                             - text/x-vcalendar
  *                             - text/calendar
  *
  * @return boolean  Success or failure.
  */
 public function replace($uid, $content, $contentType)
 {
     $factory = $GLOBALS['injector']->getInstance('Nag_Factory_Driver');
     $existing = $factory->create('')->getByUID($uid);
     $taskId = $existing->id;
     $owner = $existing->owner;
     if (!Nag::hasPermission($existing->tasklist, Horde_Perms::EDIT)) {
         throw new Horde_Exception_PermissionDenied();
     }
     switch ($contentType) {
         case 'text/calendar':
         case 'text/x-vcalendar':
             if (!$content instanceof Horde_Icalendar_Vtodo) {
                 $iCal = new Horde_Icalendar();
                 if (!$iCal->parsevCalendar($content)) {
                     throw new Nag_Exception(_("There was an error importing the iCalendar data."));
                 }
                 $components = $iCal->getComponents();
                 $component = null;
                 foreach ($components as $content) {
                     if ($content instanceof Horde_Icalendar_Vtodo) {
                         if ($component !== null) {
                             throw new Nag_Exception(_("Multiple iCalendar components found; only one vTodo is supported."));
                         }
                         $component = $content;
                     }
                 }
                 if ($component === null) {
                     throw new Nag_Exception(_("No iCalendar data was found."));
                 }
             }
             $task = new Nag_Task();
             $task->fromiCalendar($content);
             $task->owner = $owner;
             $factory->create($existing->tasklist)->modify($taskId, $task->toHash());
             break;
         case 'activesync':
             $task = new Nag_Task();
             $task->fromASTask($content);
             $task->owner = $owner;
             $factory->create($existing->tasklist)->modify($taskId, $task->toHash());
             break;
         default:
             throw new Nag_Exception(sprintf(_("Unsupported Content-Type: %s"), $contentType));
     }
     return $result;
 }
All Usage Examples Of Nag_Task::toHash