diff --git a/apps/tasks/ajax/addtask.php b/apps/tasks/ajax/addtask.php index c768d3e7d9..0c8cb89e7f 100644 --- a/apps/tasks/ajax/addtask.php +++ b/apps/tasks/ajax/addtask.php @@ -8,11 +8,7 @@ OC_JSON::checkAppEnabled('tasks'); $l10n = new OC_L10N('tasks'); $cid = $_POST['id']; -$calendar = OC_Calendar_Calendar::findCalendar( $cid ); -if( $calendar === false || $calendar['userid'] != OC_USER::getUser()){ - OC_JSON::error(array('data' => array( 'message' => $l10n->t('This is not your calendar!')))); - exit(); -} +$calendar = OC_Calendar_App::getCalendar( $cid ); $errors = OC_Task_App::validateRequest($_POST); if (!empty($errors)) { @@ -30,4 +26,7 @@ $tmpl->assign('details',$vcalendar->VTODO); $tmpl->assign('id',$id); $page = $tmpl->fetchPage(); -OC_JSON::success(array('data' => array( 'id' => $id, 'page' => $page ))); +$user_timezone = OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezone', date_default_timezone_get()); +$task = OC_Task_App::arrayForJSON($id, $vcalendar->VTODO, $user_timezone); + +OC_JSON::success(array('data' => array( 'id' => $id, 'page' => $page, 'task' => $task ))); diff --git a/apps/tasks/ajax/addtaskform.php b/apps/tasks/ajax/addtaskform.php index 222ccbd79a..d4a0bb0310 100644 --- a/apps/tasks/ajax/addtaskform.php +++ b/apps/tasks/ajax/addtaskform.php @@ -8,8 +8,16 @@ OC_JSON::checkAppEnabled('tasks'); $l10n = new OC_L10N('tasks'); $calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser(), true); +$category_options = OC_Calendar_Object::getCategoryOptions($l10n); +$percent_options = range(0, 100, 10); +$priority_options = OC_Task_App::getPriorityOptions(); $tmpl = new OC_Template('tasks','part.addtaskform'); $tmpl->assign('calendars',$calendars); +$tmpl->assign('category_options', $category_options); +$tmpl->assign('percent_options', $percent_options); +$tmpl->assign('priority_options', $priority_options); +$tmpl->assign('details', new OC_VObject('VTODO')); +$tmpl->assign('categories', array()); $page = $tmpl->fetchPage(); OC_JSON::success(array('data' => array( 'page' => $page ))); diff --git a/apps/tasks/ajax/edittask.php b/apps/tasks/ajax/edittask.php index a7215ce078..ae937a7dca 100644 --- a/apps/tasks/ajax/edittask.php +++ b/apps/tasks/ajax/edittask.php @@ -26,4 +26,7 @@ $tmpl->assign('details', $vcalendar->VTODO); $tmpl->assign('id', $id); $page = $tmpl->fetchPage(); -OC_JSON::success(array('data' => array( 'id' => $id, 'page' => $page ))); +$user_timezone = OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezone', date_default_timezone_get()); +$task = OC_Task_App::arrayForJSON($id, $vcalendar->VTODO, $user_timezone); + +OC_JSON::success(array('data' => array( 'id' => $id, 'page' => $page, 'task' => $task ))); diff --git a/apps/tasks/ajax/gettasks.php b/apps/tasks/ajax/gettasks.php index 7dc94dacb4..ee871c344c 100644 --- a/apps/tasks/ajax/gettasks.php +++ b/apps/tasks/ajax/gettasks.php @@ -26,32 +26,7 @@ foreach( $calendars as $calendar ){ } $object = OC_VObject::parse($task['calendardata']); $vtodo = $object->VTODO; - $task = array( 'id' => $task['id'] ); - $task['summary'] = $vtodo->getAsString('SUMMARY'); - $task['description'] = $vtodo->getAsString('DESCRIPTION'); - $task['location'] = $vtodo->getAsString('LOCATION'); - $task['categories'] = $vtodo->getAsArray('CATEGORIES'); - $due = $vtodo->DUE; - if ($due) { - $due = $due->getDateTime(); - $due->setTimezone(new DateTimeZone($user_timezone)); - $task['due'] = $due->format('Y-m-d H:i:s'); - } - else { - $task['due'] = false; - } - $task['priority'] = $vtodo->getAsString('PRIORITY'); - $completed = $vtodo->COMPLETED; - if ($completed) { - $completed = $completed->getDateTime(); - $completed->setTimezone(new DateTimeZone($user_timezone)); - $task['completed'] = $completed->format('Y-m-d H:i:s'); - } - else { - $task['completed'] = false; - } - $task['complete'] = $vtodo->getAsString('PERCENT-COMPLETE'); - $tasks[] = $task; + $tasks[] = OC_Task_App::arrayForJSON($task['id'], $vtodo, $user_timezone); } } diff --git a/apps/tasks/js/tasks.js b/apps/tasks/js/tasks.js index 37ab504a72..3cf428b33a 100644 --- a/apps/tasks/js/tasks.js +++ b/apps/tasks/js/tasks.js @@ -1,4 +1,52 @@ OC.Tasks = { + create_task_div:function(task) { + var task_container = $('
') + .html(''+task.summary+'') + .addClass('summary') + .attr('title', task.description) + ) + //.append(actions.clone().removeAttr('id')) + ; + var checkbox = $(''); + if (task.completed) { + checkbox.attr('checked', 'checked'); + } + $('
') - .html(''+task.summary+'') - .addClass('summary') - ) - //.append(actions.clone().removeAttr('id')) - ; - var checkbox = $(''); - if (task.completed) { - checkbox.attr('checked', 'checked'); - } - $('