Skip to content

Commit

Permalink
Import/export estimations and effort with iCalendar.
Browse files Browse the repository at this point in the history
  • Loading branch information
yunosh committed Aug 11, 2017
1 parent 4a393ba commit ed4b624
Showing 1 changed file with 46 additions and 12 deletions.
58 changes: 46 additions & 12 deletions nag/lib/Task.php
Expand Up @@ -1369,6 +1369,12 @@ public function toiCalendar(Horde_Icalendar $calendar)
$vTodo->setAttribute('STATUS', 'NEEDS-ACTION');
}
}
if (!empty($this->estimate)) {
$vTodo->setAttribute('X-HORDE-ESTIMATE', $this->estimate);
}
if (!empty($this->actual)) {
$vTodo->setAttribute('X-HORDE-EFFORT', $this->actual);
}

// Recurrence.
// We may have to implicitely set DTSTART if not set explicitely, may
Expand Down Expand Up @@ -1558,7 +1564,8 @@ public function fromiCalendar(Horde_Icalendar_Vtodo $vTodo)
if (!is_array($organizer)) {
$this->organizer = $organizer;
}
} catch (Horde_Icalendar_Exception $e) {}
} catch (Horde_Icalendar_Exception $e) {
}

// If an attendee matches our from_addr, add current user as assignee.
try {
Expand Down Expand Up @@ -1604,7 +1611,8 @@ public function fromiCalendar(Horde_Icalendar_Vtodo $vTodo)
try {
$uid = $vTodo->getAttribute('UID');
if (!is_array($uid)) { $this->uid = $uid; }
} catch (Horde_Icalendar_Exception $e) {}
} catch (Horde_Icalendar_Exception $e) {
}

try {
$relations = $vTodo->getAttribute('RELATED-TO');
Expand All @@ -1623,7 +1631,8 @@ public function fromiCalendar(Horde_Icalendar_Vtodo $vTodo)
break;
}
}
} catch (Horde_Icalendar_Exception $e) {}
} catch (Horde_Icalendar_Exception $e) {
}

try {
$start = $vTodo->getAttribute('DTSTART');
Expand All @@ -1634,7 +1643,8 @@ public function fromiCalendar(Horde_Icalendar_Vtodo $vTodo)
// Date field
$this->start = mktime(0, 0, 0, (int)$start['month'], (int)$start['mday'], (int)$start['year']);
}
} catch (Horde_Icalendar_Exception $e) {}
} catch (Horde_Icalendar_Exception $e) {
}

try {
$due = $vTodo->getAttribute('DUE');
Expand All @@ -1643,7 +1653,8 @@ public function fromiCalendar(Horde_Icalendar_Vtodo $vTodo)
} elseif (!empty($due)) {
$this->due = $due;
}
} catch (Horde_Icalendar_Exception $e) {}
} catch (Horde_Icalendar_Exception $e) {
}

// Recurrence.
try {
Expand All @@ -1670,7 +1681,8 @@ public function fromiCalendar(Horde_Icalendar_Vtodo $vTodo)
}
}
}
} catch (Horde_Icalendar_Exception $e) {}
} catch (Horde_Icalendar_Exception $e) {
}

// vCalendar 1.0 alarms
try {
Expand All @@ -1682,7 +1694,8 @@ public function fromiCalendar(Horde_Icalendar_Vtodo $vTodo)
$this->alarm = 1;
}
}
} catch (Horde_Icalendar_Exception $e) {}
} catch (Horde_Icalendar_Exception $e) {
}

// vCalendar 2.0 alarms
foreach ($vTodo->getComponents() as $alarm) {
Expand Down Expand Up @@ -1761,36 +1774,57 @@ public function fromiCalendar(Horde_Icalendar_Vtodo $vTodo)
if (!is_array($desc)) {
$this->desc = $desc;
}
} catch (Horde_Icalendar_Exception $e) {}
} catch (Horde_Icalendar_Exception $e) {
}

try {
$priority = $vTodo->getAttribute('PRIORITY');
if (!is_array($priority)) {
$this->priority = $priority;
}
} catch (Horde_Icalendar_Exception $e) {}
} catch (Horde_Icalendar_Exception $e) {
}

try {
$cat = $vTodo->getAttribute('CATEGORIES');
if (!is_array($cat)) {
$this->tags = $cat;
}
} catch (Horde_Icalendar_Exception $e) {}
} catch (Horde_Icalendar_Exception $e) {
}

try {
$status = $vTodo->getAttribute('STATUS');
if (!is_array($status)) {
$this->completed = !strcasecmp($status, 'COMPLETED');
}
} catch (Horde_Icalendar_Exception $e) {}
} catch (Horde_Icalendar_Exception $e) {
}

try {
$class = $vTodo->getAttribute('CLASS');
if (!is_array($class)) {
$class = Horde_String::upper($class);
$this->private = $class == 'PRIVATE' || $class == 'CONFIDENTIAL';
}
} catch (Horde_Icalendar_Exception $e) {}
} catch (Horde_Icalendar_Exception $e) {
}

try {
$estimate = $vTodo->getAttribute('X-HORDE-ESTIMATE');
if (!is_array($estimate)) {
$this->estimate = $estimate;
}
} catch (Horde_Icalendar_Exception $e) {
}

try {
$effort = $vTodo->getAttribute('X-HORDE-EFFORT');
if (!is_array($effort)) {
$this->actual = $effort;
}
} catch (Horde_Icalendar_Exception $e) {
}
}

/**
Expand Down

0 comments on commit ed4b624

Please sign in to comment.