/** * Update project group * * @param void * @return null */ function edit() { $this->wireframe->print_button = false; if ($this->active_project_group->isNew()) { $this->httpError(HTTP_ERR_NOT_FOUND); } // if if (!$this->active_project_group->canEdit($this->logged_user)) { $this->httpError(HTTP_ERR_FORBIDDEN); } // if $project_group_data = $this->request->post('project_group'); if (!is_array($project_group_data)) { $project_group_data = array('name' => $this->active_project_group->getName()); } // if $this->smarty->assign('project_group_data', $project_group_data); if ($this->request->isSubmitted()) { $old_name = $this->active_project_group->getName(); $this->active_project_group->setAttributes($project_group_data); $save = $this->active_project_group->save(); if ($save && !is_error($save)) { if ($this->request->isApiCall()) { $this->serveData($this->active_project_group, 'project_group'); } elseif ($this->request->isAsyncCall()) { print $this->active_project_group->getName(); die; } else { flash_success("Project group ':name' has been updated", array('name' => $old_name)); $this->redirectTo('project_groups'); } // if } else { if ($this->request->isApiCall() || $this->request->isAsyncCall()) { $this->serveData($save); } else { $this->smarty->assign('errors', $save); } // if } // if } else { if ($this->request->isApiCall()) { $this->httpError(HTTP_ERR_BAD_REQUEST); } // if } // if }