diff options
author | Bart Visscher <bartv@thisnet.nl> | 2011-12-09 21:41:21 +0100 |
---|---|---|
committer | Bart Visscher <bartv@thisnet.nl> | 2011-12-09 21:41:21 +0100 |
commit | 76c37792cb322338f73f25a559a2ccfe5ae8b59d (patch) | |
tree | e57ee4db0e664abc5ab84188ea2731cd4f75ac35 /apps/tasks | |
parent | 487c23e27f6b562fb96eda980776b32398908932 (diff) | |
download | nextcloud-server-76c37792cb322338f73f25a559a2ccfe5ae8b59d.tar.gz nextcloud-server-76c37792cb322338f73f25a559a2ccfe5ae8b59d.zip |
WIP
Diffstat (limited to 'apps/tasks')
-rw-r--r-- | apps/tasks/ajax/edittask.php | 2 | ||||
-rw-r--r-- | apps/tasks/ajax/getdetails.php | 8 | ||||
-rw-r--r-- | apps/tasks/index.php | 4 | ||||
-rw-r--r-- | apps/tasks/lib/vtodo.php | 62 |
4 files changed, 28 insertions, 48 deletions
diff --git a/apps/tasks/ajax/edittask.php b/apps/tasks/ajax/edittask.php index e9603d92da9..115f2f078ab 100644 --- a/apps/tasks/ajax/edittask.php +++ b/apps/tasks/ajax/edittask.php @@ -26,7 +26,7 @@ if (!empty($errors)) { exit(); } -$vcalendar = Sabre_VObject_Reader::read($task['calendardata']); +$vcalendar = OC_VObject::parse($task['calendardata']); OC_Task_VTodo::updateVCalendarFromRequest($_POST, $vcalendar); OC_Calendar_Object::edit($id, $vcalendar->serialize()); diff --git a/apps/tasks/ajax/getdetails.php b/apps/tasks/ajax/getdetails.php index 08bf6c9ecf6..222c426d524 100644 --- a/apps/tasks/ajax/getdetails.php +++ b/apps/tasks/ajax/getdetails.php @@ -9,12 +9,16 @@ $l10n = new OC_L10N('tasks'); $id = $_GET['id']; $task = OC_Calendar_Object::find($id); -$details = Sabre_VObject_Reader::read($task['calendardata'])->VTODO; +$details = OC_VObject::parse($task['calendardata']); +if (!$details){ + OC_JSON::error(); + exit; +} $priority_options = OC_Task_VTodo::getPriorityOptions($l10n); $tmpl = new OC_Template('tasks','part.details'); $tmpl->assign('priority_options', $priority_options); -$tmpl->assign('details',$details); +$tmpl->assign('details',$details->VTODO); $tmpl->assign('id',$id); $page = $tmpl->fetchPage(); diff --git a/apps/tasks/index.php b/apps/tasks/index.php index d2624a1cf01..145ec145aea 100644 --- a/apps/tasks/index.php +++ b/apps/tasks/index.php @@ -44,8 +44,12 @@ if( !is_null($id) || count($tasks)){ OC_UTIL::addScript('tasks', 'tasks'); OC_UTIL::addStyle('tasks', 'style'); OC_APP::setActiveNavigationEntry('tasks_index'); + +$l10n = new OC_L10N('tasks'); +$priority_options = OC_Task_VTodo::getPriorityOptions($l10n); $output = new OC_Template('tasks', 'tasks', 'user'); $output->assign('tasks', $tasks); $output->assign('details', $details); +$output->assign('priority_options', $priority_options); $output->assign('id',$id); $output -> printPage(); diff --git a/apps/tasks/lib/vtodo.php b/apps/tasks/lib/vtodo.php index 925ad77dea1..967f5b87a54 100644 --- a/apps/tasks/lib/vtodo.php +++ b/apps/tasks/lib/vtodo.php @@ -39,7 +39,7 @@ class OC_Task_VTodo extends OC_Calendar_Object{ '9' => $l10n->t('9=lowest'), ); } - public static function validateRequest($request, $l10n) + public static function validateRequest($request, $l10n=null) { $errors = array(); if($request['summary'] == ''){ @@ -102,7 +102,7 @@ class OC_Task_VTodo extends OC_Calendar_Object{ public static function updateVCalendarFromRequest($request, $vcalendar) { $summary = $request['summary']; - $categories = $request['categories']; + $categories = isset($request["categories"]) ? $request["categories"] : array(); $priority = $request['priority']; $percent_complete = $request['percent_complete']; $completed = $request['completed']; @@ -110,55 +110,28 @@ class OC_Task_VTodo extends OC_Calendar_Object{ $due = $request['due']; $description = $request['description']; - $now = new DateTime(); - $vtodo = $vcalendar->VTODO[0]; - - $last_modified = new Sabre_VObject_Element_DateTime('LAST-MODIFIED'); - $last_modified->setDateTime($now, Sabre_VObject_Element_DateTime::UTC); - $vtodo->__set('LAST-MODIFIED', $last_modified); - - $dtstamp = new Sabre_VObject_Element_DateTime('DTSTAMP'); - $dtstamp->setDateTime($now, Sabre_VObject_Element_DateTime::UTC); - $vtodo->DTSTAMP = $dtstamp; - - $vtodo->SUMMARY = $summary; - - if ($location != '') { - $vtodo->LOCATION = $location; - }else{ - unset($vtodo->LOCATION); - } - - if ($categories != '') { - $vtodo->CATEGORIES = join(',',$categories); - }else{ - unset($vtodo->CATEGORIES); - } + $vtodo = $vcalendar->VTODO; - if ($priority != '') { - $vtodo->PRIORITY = $priority; - }else{ - unset($vtodo->PRIORITY); - } + $vtodo->setDateTime('LAST-MODIFIED', 'now', Sabre_VObject_Element_DateTime::UTC); + $vtodo->setDateTime('DTSTAMP', 'now', Sabre_VObject_Element_DateTime::UTC); + $vtodo->setString('SUMMARY', $summary); - if ($description != '') { - $vtodo->DESCRIPTION = $description; - }else{ - unset($vtodo->DESCRIPTION); - } + $vtodo->setString('LOCATION', $location); + $vtodo->setString('DESCRIPTION', $description); + $vtodo->setString('CATEGORIES', join(',', $categories)); + $vtodo->setString('PRIORITY', $priority); if ($due) { - $due_property = new Sabre_VObject_Element_DateTime('DUE'); - $timezone = OC_Preferences::getValue(OC_USER::getUser(), "calendar", "timezone", "Europe/London"); + $timezone = OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezone', date_default_timezone_get()); $timezone = new DateTimeZone($timezone); - $due_property->setDateTime(new DateTime($due, $timezone)); - $vtodo->DUE = $due_property; + $due = new DateTime($due, $timezone); + $vtodo->setDateTime('DUE', $due); } else { unset($vtodo->DUE); } if (!empty($percent_complete)) { - $vtodo->__set('PERCENT-COMPLETE', $percent_complete); + $vtodo->setString('PERCENT-COMPLETE', $percent_complete); }else{ $vtodo->__unset('PERCENT-COMPLETE'); } @@ -171,11 +144,10 @@ class OC_Task_VTodo extends OC_Calendar_Object{ $completed = null; } if ($completed) { - $completed_property = new Sabre_VObject_Element_DateTime('COMPLETED'); - $timezone = OC_Preferences::getValue(OC_USER::getUser(), "calendar", "timezone", "Europe/London"); + $timezone = OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezone', date_default_timezone_get()); $timezone = new DateTimeZone($timezone); - $completed_property->setDateTime(new DateTime($completed, $timezone)); - $vtodo->COMPLETED = $completed_property; + $completed = new DateTime($completed, $timezone); + $vtodo->setDateTime('COMPLETED', $completed); } else { unset($vtodo->COMPLETED); } |