diff --git a/apps/calendar/lib/app.php b/apps/calendar/lib/app.php
index eb440b5794..8cbef4646f 100755
--- a/apps/calendar/lib/app.php
+++ b/apps/calendar/lib/app.php
@@ -179,7 +179,7 @@ class OC_Calendar_App{
foreach($events as $event) {
$vobject = OC_VObject::parse($event['calendardata']);
if(!is_null($vobject)) {
- $vcategories->loadFromVObject($vobject->VEVENT, true);
+ self::loadCategoriesFromVCalendar($vobject);
}
}
}
@@ -190,7 +190,16 @@ class OC_Calendar_App{
* @see OC_VCategories::loadFromVObject
*/
public static function loadCategoriesFromVCalendar(OC_VObject $calendar) {
- self::getVCategories()->loadFromVObject($calendar->VEVENT, true);
+ $object = null;
+ if (isset($calendar->VEVENT)) {
+ $object = $calendar->VEVENT;
+ } else
+ if (isset($calendar->VTODO)) {
+ $object = $calendar->VTODO;
+ }
+ if ($object) {
+ self::getVCategories()->loadFromVObject($object, true);
+ }
}
public static function getRepeatOptions(){
diff --git a/apps/tasks/ajax/addtask.php b/apps/tasks/ajax/addtask.php
new file mode 100644
index 0000000000..891fbdb96d
--- /dev/null
+++ b/apps/tasks/ajax/addtask.php
@@ -0,0 +1,26 @@
+serialize());
+
+$user_timezone = OCP\Config::getUserValue(OCP\User::getUser(), 'calendar', 'timezone', date_default_timezone_get());
+$task = OC_Task_App::arrayForJSON($id, $vcalendar->VTODO, $user_timezone);
+
+OCP\JSON::success(array('task' => $task));
diff --git a/apps/tasks/ajax/addtaskform.php b/apps/tasks/ajax/addtaskform.php
new file mode 100644
index 0000000000..20797f31ab
--- /dev/null
+++ b/apps/tasks/ajax/addtaskform.php
@@ -0,0 +1,20 @@
+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', '');
+$page = $tmpl->fetchPage();
+
+OCP\JSON::success(array('data' => array( 'page' => $page )));
diff --git a/apps/tasks/ajax/delete.php b/apps/tasks/ajax/delete.php
new file mode 100644
index 0000000000..6d2868748d
--- /dev/null
+++ b/apps/tasks/ajax/delete.php
@@ -0,0 +1,31 @@
+.
+ *
+ */
+
+// Init owncloud
+OCP\JSON::checkLoggedIn();
+OCP\JSON::checkAppEnabled('tasks');
+
+$id = $_GET['id'];
+$task = OC_Calendar_App::getEventObject( $id );
+
+OC_Calendar_Object::delete($id);
+OCP\JSON::success(array('data' => array( 'id' => $id )));
diff --git a/apps/tasks/ajax/edittask.php b/apps/tasks/ajax/edittask.php
new file mode 100644
index 0000000000..78d1f19393
--- /dev/null
+++ b/apps/tasks/ajax/edittask.php
@@ -0,0 +1,31 @@
+ array( 'errors' => $errors )));
+ exit();
+}
+
+OC_Task_App::updateVCalendarFromRequest($_POST, $vcalendar);
+OC_Calendar_Object::edit($id, $vcalendar->serialize());
+
+$priority_options = OC_Task_App::getPriorityOptions();
+$tmpl = new OC_Template('tasks','part.details');
+$tmpl->assign('priority_options', $priority_options);
+$tmpl->assign('details', $vcalendar->VTODO);
+$tmpl->assign('id', $id);
+$page = $tmpl->fetchPage();
+
+$user_timezone = OCP\Config::getUserValue(OCP\User::getUser(), 'calendar', 'timezone', date_default_timezone_get());
+$task = OC_Task_App::arrayForJSON($id, $vcalendar->VTODO, $user_timezone);
+
+OCP\JSON::success(array('data' => array( 'id' => $id, 'page' => $page, 'task' => $task )));
diff --git a/apps/tasks/ajax/edittaskform.php b/apps/tasks/ajax/edittaskform.php
new file mode 100644
index 0000000000..a439a0c031
--- /dev/null
+++ b/apps/tasks/ajax/edittaskform.php
@@ -0,0 +1,24 @@
+VTODO;
+$categories = $details->getAsString('CATEGORIES');
+
+$category_options = OC_Calendar_App::getCategoryOptions();
+$percent_options = range(0, 100, 10);
+$priority_options = OC_Task_App::getPriorityOptions();
+
+$tmpl = new OC_Template('tasks','part.edittaskform');
+$tmpl->assign('category_options', $category_options);
+$tmpl->assign('percent_options', $percent_options);
+$tmpl->assign('priority_options', $priority_options);
+$tmpl->assign('id',$id);
+$tmpl->assign('details',$details);
+$tmpl->assign('categories', $categories);
+$page = $tmpl->fetchPage();
+
+OCP\JSON::success(array('data' => array( 'page' => $page )));
diff --git a/apps/tasks/ajax/getdetails.php b/apps/tasks/ajax/getdetails.php
new file mode 100644
index 0000000000..34ddaa7791
--- /dev/null
+++ b/apps/tasks/ajax/getdetails.php
@@ -0,0 +1,24 @@
+assign('priority_options', $priority_options);
+$tmpl->assign('details',$details->VTODO);
+$tmpl->assign('id',$id);
+$page = $tmpl->fetchPage();
+
+OCP\JSON::success(array('data' => array( 'id' => $id, 'page' => $page )));
diff --git a/apps/tasks/ajax/gettasks.php b/apps/tasks/ajax/gettasks.php
new file mode 100644
index 0000000000..011730d0a1
--- /dev/null
+++ b/apps/tasks/ajax/gettasks.php
@@ -0,0 +1,36 @@
+
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+// Init owncloud
+OCP\JSON::checkLoggedIn();
+OCP\JSON::checkAppEnabled('tasks');
+
+$calendars = OC_Calendar_Calendar::allCalendars(OCP\User::getUser(), true);
+$user_timezone = OCP\Config::getUserValue(OCP\User::getUser(), 'calendar', 'timezone', date_default_timezone_get());
+
+$tasks = array();
+foreach( $calendars as $calendar ){
+ $calendar_tasks = OC_Calendar_Object::all($calendar['id']);
+ foreach( $calendar_tasks as $task ){
+ if($task['objecttype']!='VTODO'){
+ continue;
+ }
+ if(is_null($task['summary'])){
+ continue;
+ }
+ $object = OC_VObject::parse($task['calendardata']);
+ $vtodo = $object->VTODO;
+ try {
+ $tasks[] = OC_Task_App::arrayForJSON($task['id'], $vtodo, $user_timezone);
+ } catch(Exception $e) {
+ OCP\Util::writeLog('tasks', $e->getMessage(), OCP\Util::ERROR);
+ }
+ }
+}
+
+OCP\JSON::encodedPrint($tasks);
diff --git a/apps/tasks/ajax/update_property.php b/apps/tasks/ajax/update_property.php
new file mode 100644
index 0000000000..46521cf6c5
--- /dev/null
+++ b/apps/tasks/ajax/update_property.php
@@ -0,0 +1,68 @@
+
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+// Init owncloud
+OCP\JSON::checkLoggedIn();
+OCP\JSON::checkAppEnabled('tasks');
+
+$id = $_POST['id'];
+$property = $_POST['type'];
+$vcalendar = OC_Calendar_App::getVCalendar( $id );
+
+$vtodo = $vcalendar->VTODO;
+switch($property) {
+ case 'summary':
+ $summary = $_POST['summary'];
+ $vtodo->setString('SUMMARY', $summary);
+ break;
+ case 'description':
+ $description = $_POST['description'];
+ $vtodo->setString('DESCRIPTION', $description);
+ break;
+ case 'location':
+ $location = $_POST['location'];
+ $vtodo->setString('LOCATION', $location);
+ break;
+ case 'categories':
+ $categories = $_POST['categories'];
+ $vtodo->setString('CATEGORIES', $categories);
+ break;
+ case 'due':
+ $due = $_POST['due'];
+ $due_date_only = $_POST['date'];
+ $type = null;
+ if ($due != 'false') {
+ try {
+ $timezone = OCP\Config::getUserValue(OCP\User::getUser(), 'calendar', 'timezone', date_default_timezone_get());
+ $timezone = new DateTimeZone($timezone);
+ $due = new DateTime('@'.$due);
+ $due->setTimezone($timezone);
+ $type = Sabre_VObject_Element_DateTime::LOCALTZ;
+ if ($due_date_only) {
+ $type = Sabre_VObject_Element_DateTime::DATE;
+ }
+ } catch (Exception $e) {
+ OCP\JSON::error(array('data'=>array('message'=>OC_Task_App::$l10n->t('Invalid date/time'))));
+ exit();
+ }
+ }
+ $vtodo->setDateTime('DUE', $due, $type);
+ break;
+ case 'complete':
+ $checked = $_POST['checked'];
+ OC_Task_App::setComplete($vtodo, $checked ? '100' : '0', null);
+ break;
+ default:
+ OCP\JSON::error(array('data'=>array('message'=>'Unknown type')));
+ exit();
+}
+OC_Calendar_Object::edit($id, $vcalendar->serialize());
+
+$user_timezone = OCP\Config::getUserValue(OCP\User::getUser(), 'calendar', 'timezone', date_default_timezone_get());
+$task_info = OC_Task_App::arrayForJSON($id, $vtodo, $user_timezone);
+OCP\JSON::success(array('data' => $task_info));
diff --git a/apps/tasks/appinfo/app.php b/apps/tasks/appinfo/app.php
new file mode 100644
index 0000000000..f346e2aa4c
--- /dev/null
+++ b/apps/tasks/appinfo/app.php
@@ -0,0 +1,16 @@
+ 11,
+ 'id' => 'tasks',
+ 'name' => 'Tasks' ));
+
+OCP\App::addNavigationEntry( array(
+ 'id' => 'tasks_index',
+ 'order' => 11,
+ 'href' => OCP\Util::linkTo( 'tasks', 'index.php' ),
+ 'icon' => OCP\Util::imagePath( 'tasks', 'icon.png' ),
+ 'name' => $l->t('Tasks')));
diff --git a/apps/tasks/appinfo/info.xml b/apps/tasks/appinfo/info.xml
new file mode 100644
index 0000000000..21ab9a2476
--- /dev/null
+++ b/apps/tasks/appinfo/info.xml
@@ -0,0 +1,10 @@
+
+
') + .attr('title', task.description) + ; + OC.Tasks.setSummary(summary_container, task); + var task_container = $('