From ed4b6247305be0d9ca4b2e632e4f0774ddfc9974 Mon Sep 17 00:00:00 2001 From: Jan Schneider Date: Fri, 11 Aug 2017 12:30:15 +0200 Subject: [PATCH] Import/export estimations and effort with iCalendar. --- nag/lib/Task.php | 58 ++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 46 insertions(+), 12 deletions(-) diff --git a/nag/lib/Task.php b/nag/lib/Task.php index 63a362e427d..a617dc142a1 100644 --- a/nag/lib/Task.php +++ b/nag/lib/Task.php @@ -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 @@ -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 { @@ -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'); @@ -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'); @@ -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'); @@ -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 { @@ -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 { @@ -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) { @@ -1761,28 +1774,32 @@ 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'); @@ -1790,7 +1807,24 @@ public function fromiCalendar(Horde_Icalendar_Vtodo $vTodo) $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) { + } } /**