/** * Delete a post * * @apiMethod DELETE * @apiUri /collections/{id}/posts/{id} * @apiParameter { * "name": "id", * "description": "Entry identifier", * "type": "integer", * "required": true, * "default": null * } * @return void */ public function deleteTask() { $this->requiresAuthentication(); $ids = Request::getVar('id', array()); $ids = !is_array($ids) ? array($ids) : $ids; if (count($ids) <= 0) { throw new Exception(Lang::txt('COM_COLLECTIONS_ERROR_MISSING_ID'), 500); } foreach ($ids as $id) { $row = new Post(intval($id)); if (!$row->exists()) { throw new Exception(Lang::txt('COM_COLLECTIONS_ERROR_MISSING_RECORD'), 404); } if (!$row->delete()) { throw new Exception($row->getError(), 500); } } $this->send(null, 204); }
/** * Save post reordering * * @return void */ public function reorderTask() { // Check for request forgeries Request::checkToken(['get', 'post']); // Incoming $posts = Request::getVar('post', array()); if (is_array($posts)) { $folder = null; $i = 0; foreach ($posts as $post) { $post = intval($post); if (!$post) { continue; } $row = new Post($post); if (!$row->exists()) { continue; } $row->set('ordering', $i + 1); $row->store(false); $i++; } } if (!$no_html) { // Output messsage and redirect App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller), Lang::txt('COM_COLLECTIONS_POSTS_REORDERED')); return; } $response = new \stdClass(); $response->success = 1; $response->message = Lang::txt('COM_COLLECTIONS_POSTS_REORDERED'); echo json_encode($response); }