Beispiel #1
0
     }
 } else {
     if ($_POST['action'] == "new_list") {
         if (isset($_POST['name'])) {
             if (empty(trim($_POST['name']))) {
                 echo json_encode(array('status' => 'validation', 'reason' => 'Your task list name is empty!'));
                 die;
             }
             /*if (strlen($_POST['name']) > 32)
             		{
             			echo json_encode(array('status'=>'validation', 'reason' => 'Your task list name is too long!'));
             			die();
             		}*/
             $tasklist = new TaskList();
             $tasklist->setUserId(Authentication::getUserObject()->getId());
             $tasklist->setName($_POST['name']);
             $tasklist->setIcon($_POST['icon']);
             $tasklist->save();
             echo json_encode(array('status' => 'success', 'tasklist-id' => $tasklist->getId()));
         } else {
             echo json_encode(array('status' => 'error', 'reason' => 'List name not supplied.'));
         }
     } else {
         if ($_POST['action'] == "delete_list") {
             if (isset($_POST['id'])) {
                 $list = TaskList::get($where = array('id' => $_POST['id']))[0];
                 foreach (Task::get($where = array('list_id' => $list->getId())) as $task) {
                     $task->delete();
                 }
                 $list->delete();
                 echo json_encode(array('status' => 'success'));