Navigation Menu

Skip to content

Commit

Permalink
Correctly map priorities from/to iCalendar.
Browse files Browse the repository at this point in the history
  • Loading branch information
yunosh committed Aug 11, 2017
1 parent 630ce20 commit 56613fc
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions nag/lib/Task.php
Expand Up @@ -1235,7 +1235,14 @@ public function toiCalendar(Horde_Icalendar $calendar)
}

if (isset($this->priority)) {
$vTodo->setAttribute('PRIORITY', $this->priority);
$priorityMap = array(
1 => 1,
2 => 3,
3 => 5,
4 => 7,
5 => 9,
);
$vTodo->setAttribute('PRIORITY', $priorityMap[$this->priority]);
}

if (!empty($this->parent_id) && !empty($this->parent)) {
Expand Down Expand Up @@ -1520,7 +1527,21 @@ public function fromiCalendar(Horde_Icalendar_Vtodo $vTodo)
try {
$priority = $vTodo->getAttribute('PRIORITY');
if (!is_array($priority)) {
$this->priority = $priority;
$priorityMap = array(
0 => 3,
1 => 1,
2 => 1,
3 => 2,
4 => 2,
5 => 3,
6 => 4,
7 => 4,
8 => 5,
9 => 5,
);
$this->priority = isset($priorityMap[$priority])
? $priorityMap[$priority]
: 3;
}
} catch (Horde_Icalendar_Exception $e) {
}
Expand Down

0 comments on commit 56613fc

Please sign in to comment.