/**
  * Update project
  *
  * @param void
  * @return null
  */
 function edit()
 {
     $this->wireframe->print_button = false;
     if ($this->request->isApiCall() && !$this->request->isSubmitted()) {
         $this->httpError(HTTP_ERR_BAD_REQUEST, null, true, true);
     }
     // if
     if ($this->active_project->isNew()) {
         $this->httpError(HTTP_ERR_NOT_FOUND);
     }
     // if
     if (!$this->active_project->canEdit($this->logged_user)) {
         $this->httpError(HTTP_ERR_FORBIDDEN);
     }
     // if
     $project_data = $this->request->post('project');
     if (!is_array($project_data)) {
         $project_data = array('name' => $this->active_project->getName(), 'overview' => $this->active_project->getOverview(), 'default_visibility' => $this->active_project->getDefaultVisibility(), 'leader_id' => $this->active_project->getLeaderId(), 'group_id' => $this->active_project->getGroupId(), 'company_id' => $this->active_project->getCompanyId(), 'default_visibility' => $this->active_project->getDefaultVisibility(), 'starts_on' => $this->active_project->getStartsOn());
     }
     // if
     $this->smarty->assign('project_data', $project_data);
     if ($this->request->isSubmitted()) {
         db_begin_work();
         $old_name = $this->active_project->getName();
         $this->active_project->setAttributes($project_data);
         if ($this->active_project->isModified('leader_id') && $this->active_project->getLeaderId()) {
             $leader = Users::findById($this->active_project->getLeaderId());
             if (instance_of($leader, 'User')) {
                 $this->active_project->setLeader($leader);
             }
             // if
         }
         // if
         if ($this->active_project->isModified('company_id')) {
             cache_remove('project_icons');
         }
         // if
         $save = $this->active_project->save();
         if ($save && !is_error($save)) {
             db_commit();
             if ($this->request->isApiCall()) {
                 $this->serveData($this->active_project, 'project');
             } else {
                 flash_success('Project :name has been updated', array('name' => $old_name));
                 $this->redirectToUrl($this->active_project->getOverviewUrl());
             }
             // if
         } else {
             db_rollback();
             if ($this->request->isApiCall()) {
                 $this->serveData($save);
             } else {
                 $this->smarty->assign('errors', $save);
             }
             // if
         }
         // if
     }
     // if
 }