/** * Delete document category * * @param void * @return void */ function delete() { if ($this->active_document_category->isNew()) { $this->httpError(HTTP_ERR_NOT_FOUND); } // if if (!$this->active_document_category->canDelete($this->logged_user)) { $this->httpError(HTTP_ERR_FORBIDDEN); } // if if ($this->request->isSubmitted()) { db_begin_work(); $delete = $this->active_document_category->delete(); if ($delete && !is_error($delete)) { db_commit(); if ($this->request->isApiCall()) { $this->httpOk(); } else { flash_success('Document category ":name" has been deleted', array('name' => $this->active_document_category->getName())); $this->redirectTo('document_categories'); } // if } else { db_rollback(); if ($this->request->isAsyncCall()) { $this->serveData($delete); } else { flash_success('Failed to delete ":name" document category', array('name' => $this->active_document_category->getName())); $this->redirectTo('document_categories'); } // if } // if } else { $this->httpError(HTTP_ERR_BAD_REQUEST); } // if }