diff options
author | Raimund Schlüßler <raimund.schluessler@googlemail.com> | 2015-06-19 22:14:22 +0300 |
---|---|---|
committer | Raimund Schlüßler <raimund.schluessler@googlemail.com> | 2015-06-21 13:40:44 +0300 |
commit | 4715e7da509aeedcd4f9fbf1a5e4667f936552d2 (patch) | |
tree | 29dbcb445a45871ff6f8e321a97e544ad49a754f /service | |
parent | dbc740037c7a109452e671593885ebbe806056e8 (diff) |
Implement priority support
Diffstat (limited to 'service')
-rw-r--r-- | service/tasksservice.php | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/service/tasksservice.php b/service/tasksservice.php index 166abc95..8b3e47de 100644 --- a/service/tasksservice.php +++ b/service/tasksservice.php @@ -198,27 +198,6 @@ class TasksService { } /** - * star or unstar task by id - * - * @param int $taskID - * @param bool $isStarred - */ - public function setStarred($taskID, $isStarred) { - try { - $vcalendar = \OC_Calendar_App::getVCalendar($taskID); - $vtodo = $vcalendar->VTODO; - if($isStarred) { - $vtodo->PRIORITY = 5; // prio: medium - } else { - $vtodo->PRIORITY = 0; - } - return \OC_Calendar_Object::edit($taskID, $vcalendar->serialize()); - } catch(\Exception $e) { - return false; - } - } - - /** * set completeness of task in percent by id * * @param int $taskID @@ -251,6 +230,28 @@ class TasksService { } /** + * set priority of task by id + * + * @param int $taskID + * @param int $priority + * @return bool + */ + public function setPriority($taskID, $priority){ + try { + $vcalendar = \OC_Calendar_App::getVCalendar($taskID); + $vtodo = $vcalendar->VTODO; + if($priority){ + $vtodo->PRIORITY = (10 - $priority) % 10; + }else{ + $vtodo->__unset('PRIORITY'); + } + return \OC_Calendar_Object::edit($taskID, $vcalendar->serialize()); + } catch(\Exception $e) { + return false;// throw new BusinessLayerException($e->getMessage()); + } + } + + /** * set due date of task by id * * @param int $taskID |