Exemple #1
0
 /**
  * @NoAdminRequired
  */
 public function deleteTask()
 {
     $id = $this->params('id');
     $task = CalendarApp::getEventObject($id);
     //Search for Sub Tasks
     $subTaskIds = '';
     if ($task['relatedto'] === '') {
         $subTaskIds = TasksApp::getSubTasks($task['eventuid']);
         if ($subTaskIds !== '') {
             $tempIds = explode(',', $subTaskIds);
             foreach ($tempIds as $subIds) {
                 Object::delete($subIds);
             }
         }
     }
     Object::delete($id);
     $params = ['id' => $id];
     $response = new JSONResponse();
     $response->setData($params);
     return $response;
 }
 /**
  * @NoAdminRequired
  */
 public function setCompletedTask()
 {
     $id = $this->params('id');
     $checked = $this->params('checked');
     $vcalendar = CalendarApp::getVCalendar($id);
     $vtodo = $vcalendar->VTODO;
     TasksApp::setComplete($vtodo, $checked ? 100 : 0, null);
     Object::edit($id, $vcalendar->serialize());
     $user_timezone = CalendarApp::getTimezone();
     $aTask = TasksApp::getEventObject($id, true, true);
     $aCalendar = CalendarCalendar::find($aTask['calendarid']);
     $task_info[] = TasksApp::arrayForJSON($id, $vtodo, $user_timezone, $aCalendar, $aTask);
     $subTaskIds = '';
     if ($aTask['relatedto'] === '') {
         $subTaskIds = TasksApp::getSubTasks($aTask['eventuid']);
         if ($subTaskIds !== '') {
             $tempIds = explode(',', $subTaskIds);
             foreach ($tempIds as $subIds) {
                 $vcalendar = TasksApp::getVCalendar($subIds, true, true);
                 $vtodo = $vcalendar->VTODO;
                 TasksApp::setComplete($vtodo, $checked ? 100 : 0, null);
                 TasksApp::edit($subIds, $vcalendar->serialize());
                 $task_info[] = TasksApp::arrayForJSON($subIds, $vtodo, $user_timezone, $aCalendar, $aTask);
             }
         }
     }
     $params = ['status' => 'success', 'data' => $task_info];
     $response = new JSONResponse($params);
     return $response;
 }