/**
  * Override the edit action to supply some selectable relationships
  *
  * @param MappedObject $model
  */
 protected function prepareForEdit($model = null)
 {
     $clientid = $model && $model->clientid ? $model->clientid : (int) $this->_getParam('clientid');
     // check the existence of the client to add this contact to
     $client = $clientid ? $this->clientService->getClient($clientid) : null;
     // check the existence of the client to add this contact to
     $this->view->owners = $this->groupService->getGroups();
     $this->view->users = $this->userService->getUserList();
     $this->view->client = $client;
     $this->view->clients = $this->clientService->getClients();
     $this->view->projects = $clientid ? $this->projectService->getProjectsForClient($client) : array();
     parent::prepareForEdit($model);
 }
 /**
  * Prepare a feature to be edited
  *
  * @param Feature $model
  * @return
  */
 public function prepareForEdit($model)
 {
     $project = $this->projectService->getProject((int) $this->_getParam('projectid', $model->projectid));
     $parentFeature = $this->projectService->getFeature((int) $this->_getParam('parent'));
     if ($project == null) {
         $this->flash("Specified project not found");
         $this->renderView('error.php');
         return;
     }
     $this->view->project = $project;
     if ($parentFeature) {
         $this->view->parentfeature = $parentFeature->id;
     }
     if ($model->id) {
         $this->view->linkedToFeatures = $this->itemLinkService->getLinkedItems($model, 'from', 'Feature');
         $this->view->linkedFromFeatures = $this->itemLinkService->getLinkedItems($model, 'to', 'Feature');
     } else {
         $model->milestone = $this->_getParam('milestone');
     }
     $this->view->projects = $this->projectService->getProjectsForClient($project->clientid);
     $this->view->projectFeatures = $this->featureService->getFeatures(array('projectid=' => $project->id));
     $this->view->projectTasks = $this->projectService->getTasks(array('projectid=' => $project->id), 'title asc');
     $this->view->priorities = array('Must Have', 'Should Have', 'Would Like', 'Nice To Have');
     $this->view->statuses = $model->constraints['status']->getValues();
     $this->view->linkedTasks = array();
     if ($model->id) {
         $this->view->linkedTasks = $this->itemLinkService->getLinkedItemsOfType($model, 'from', 'Task');
     }
     parent::prepareForEdit($model);
 }