diff --git a/api/v1/entries/todo.php b/api/v1/entries/todo.php index 7e66f8bed7..82d5d56619 100644 --- a/api/v1/entries/todo.php +++ b/api/v1/entries/todo.php @@ -14,28 +14,28 @@ class todoEntry extends entry $control->view($todoID, $this->param('from', 'my')); $data = $this->getData(); - $todo = $data->data->todo; + $todo = $data->data->todo; $this->send(200, $this->format($todo, 'assignedDate:time,finishedDate:time,closedDate:time')); } public function put($todoID) { - $oldTodo = $this->loadModel('todo')->getByID($todoID); - $oldTodo->date = date("Y-m-d", strtotime($oldTodo->date)); + $oldTodo = $this->loadModel('todo')->getByID($todoID); /* Set $_POST variables. */ $fields = 'date,type,name,pri,desc,status,begin,end,private'; $this->batchSetPost($fields, $oldTodo); $this->setPost('idvalue', 0); + $this->setPost('date', date("Y-m-d", strtotime($oldTodo->date))); $control = $this->loadController('todo', 'edit'); $control->edit($todoID); $data = $this->getData(); - if(isset($data->status) and $data->status == 'fail') return $this->sendError(400, $data->message); if(!isset($data->status)) return $this->sendError(400, 'error'); + if(isset($data->status) and $data->status == 'fail') return $this->sendError(400, $data->message); $todo = $this->todo->getByID($todoID); $this->send(200, $this->format($todo, 'assignedDate:time,finishedDate:time,closedDate:time')); diff --git a/api/v1/entries/todos.php b/api/v1/entries/todos.php index 0521f6ec12..3b7a19728e 100644 --- a/api/v1/entries/todos.php +++ b/api/v1/entries/todos.php @@ -14,19 +14,16 @@ class todosEntry extends entry $control->todo($this->param('date', 'all'), $this->param('user', ''), $this->param('status', 'all'), $this->param('order', 'date_desc'), 0, $this->param('total', 0), $this->param('limit', 20), $this->param('page', 1)); $data = $this->getData(); - if(isset($data->status) and $data->status == 'success') - { - $pager = $data->data->pager; - $result = array(); - foreach($data->data->todos as $todo) - { - $result[] = $this->format($todo, 'assignedDate:time,finishedDate:time,closedDate:time'); - } - return $this->send(200, array('page' => $pager->pageID, 'total' => $pager->recTotal, 'limit' => $pager->recPerPage, 'todos' => $result)); - } + if(!isset($data->status)) return $this->sendError(400, 'error'); if(isset($data->status) and $data->status == 'fail') return $this->sendError(400, $data->message); - return $this->sendError(400, 'error'); + $pager = $data->data->pager; + $result = array(); + foreach($data->data->todos as $todo) + { + $result[] = $this->format($todo, 'assignedDate:time,finishedDate:time,closedDate:time'); + } + return $this->send(200, array('page' => $pager->pageID, 'total' => $pager->recTotal, 'limit' => $pager->recPerPage, 'todos' => $result)); } public function post() diff --git a/module/todo/control.php b/module/todo/control.php index 8335be389d..cdd04f55d8 100644 --- a/module/todo/control.php +++ b/module/todo/control.php @@ -149,6 +149,8 @@ class todo extends control $actionID = $this->loadModel('action')->create('todo', $todoID, 'edited'); $this->action->logHistory($actionID, $changes); } + + if(defined('RUN_MODE') && RUN_MODE == 'api') return $this->send(array('status' => 'success')); die(js::locate($this->session->todoList, 'parent.parent')); } @@ -434,7 +436,9 @@ class todo extends control } return $this->send($response); } - if(isonlybody())die(js::reload('parent.parent')); + + if(defined('RUN_MODE') && RUN_MODE == 'api') return $this->send(array('status' => 'success')); + if(isonlybody()) die(js::reload('parent.parent')); $browseLink = $this->session->todoList ? $this->session->todoList : $this->createLink('my', 'todo'); die(js::locate($browseLink, 'parent'));