/** * Delete project * * @param void * @return null */ function delete() { if ($this->request->isApiCall() && !$this->request->isSubmitted()) { $this->httpError(HTTP_ERR_BAD_REQUEST, null, true, $this->request->isApiCall()); } // if if ($this->active_project->isNew()) { $this->httpError(HTTP_ERR_NOT_FOUND, null, true, $this->request->isApiCall()); } // if if (!$this->active_project->canDelete($this->logged_user)) { $this->httpError(HTTP_ERR_FORBIDDEN, null, true, $this->request->isApiCall()); } // if if ($this->request->isSubmitted()) { $delete = $this->active_project->delete(); if ($delete && !is_error($delete)) { if ($this->request->isApiCall()) { $this->httpOk(); } else { flash_success("Project ':name' has been deleted", array('name' => $this->active_project->getName())); $this->redirectTo('projects'); } // if } else { if ($this->request->isApiCall()) { $this->serveData($delete); } else { flash_error("Failed to delete ':name' project", array('name' => $this->active_project->getName())); $this->redirectTo('projects'); } // if } // if } else { $this->httpError(HTTP_ERR_BAD_REQUEST, null, true, $this->request->isApiCall()); } // if }