コード例 #1
0
ファイル: Roadmap.class.php プロジェクト: sensorsix/app
 public function preSave($event)
 {
     if (!$this->folder_id) {
         $this->folder_id = Folder::getInstance()->getNotDeletableForUser(sfContext::getInstance()->getUser()->getGuardUser(), Folder::TYPE_ROADMAP)->getId();
     }
     $log = new Log();
     $log->injectDataAndPersist($this, sfContext::getInstance()->getUser()->getGuardUser(), array('action' => $this->isNew() ? 'new' : 'edit'));
 }
コード例 #2
0
ファイル: actions.class.php プロジェクト: sensorsix/app
 public function executeNewFolder(sfWebRequest $request)
 {
     $this->forward404Unless($request->isXmlHttpRequest());
     $folder = new Folder();
     $folder->setName('New ' . InterfaceLabelTable::getInstance()->get($this->getuser()->getGuardUser(), InterfaceLabelTable::FOLDER_TYPE));
     $folder->setUser($this->getUser()->getGuardUser());
     $folder->setType(Folder::TYPE_PROJECT);
     if (!Folder::getInstance()->getNotDeletableForUser($this->getUser()->getGuardUser(), Folder::TYPE_PROJECT, false)) {
         $folder->setDeletable(false);
     }
     $folder->save();
     // Create log
     $log = new Log();
     $log->injectDataAndPersist($folder, $this->getUser()->getGuardUser(), array('action' => 'new'));
     return $this->renderText(json_encode($folder->getRowData()));
 }
コード例 #3
0
ファイル: actions.class.php プロジェクト: sensorsix/app
 public function executeCreate(sfWebRequest $request)
 {
     $this->forward404Unless($request->isXmlHttpRequest());
     $this->forward404Unless($request->isMethod(sfRequest::POST) || $request->isMethod(sfRequest::PUT));
     $criterion = new Criterion();
     $criterion->decision_id = $request->getParameter('decision_id');
     $form = new CriterionForm($criterion);
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $form->save();
         // Create log
         $log = new Log();
         $log->injectDataAndPersist($criterion, $this->getUser()->getGuardUser(), array('action' => 'new'));
         return $this->renderText(json_encode($criterion->getRowData()));
     } else {
         return $this->renderPartial('form', array('form' => $form, 'type' => 'new'));
     }
 }
コード例 #4
0
ファイル: actions.class.php プロジェクト: sensorsix/app
 public function executeCreate(sfWebRequest $request)
 {
     $this->forward404Unless($request->isXmlHttpRequest());
     $this->forward404Unless($request->isMethod(sfRequest::POST) || $request->isMethod(sfRequest::PUT));
     $role = new Role();
     $role->decision_id = $request->getParameter('decision_id');
     $form = new RoleForm($role);
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $form->save();
         // Create log
         $log = new Log();
         $log->injectDataAndPersist($role, $this->getUser()->getGuardUser(), array('action' => 'new'));
         $matrix = json_decode($request->getParameter('matrix'), true);
         $role = $this->plannedMeasurementSaveNew($role, $matrix);
         $role->refresh(true);
         return $this->renderText(json_encode($role->getRowData()));
     } else {
         return $this->renderPartial('form', array('form' => $form, 'type' => 'new'));
     }
 }
コード例 #5
0
ファイル: actions.class.php プロジェクト: sensorsix/app
 /**
  * @param sfWebRequest $request
  * @return sfView|string
  */
 public function executeUpdateRelease(sfWebRequest $request)
 {
     $this->forward404Unless($request->isXmlHttpRequest());
     $this->forward404Unless($request->isMethod(sfRequest::POST) || $request->isMethod(sfRequest::PUT));
     $this->forward404Unless($object = Doctrine_Core::getTable($this->model)->find(array($request->getParameter('id'))), sprintf('Object decision does not exist (%s).', $request->getParameter('id')));
     $formClass = $this->model . 'Form';
     $this->form = new $formClass($object, array('user' => $this->getUser()));
     $this->form->bind($request->getParameter($this->form->getName()), $request->getFiles($this->form->getName()));
     if ($this->form->isValid()) {
         $this->form->save();
         $this->form_valid = true;
         // Process tags
         $tags_request = json_decode($request->getParameter('tags'));
         $tags = array();
         foreach ($object->getTagRelease() as $tag) {
             $tags[] = $tag->Tag->name;
         }
         foreach (array_diff($tags_request, $tags) as $result) {
             Tag::newTag($this->getUser()->getGuardUser(), $request->getParameter('id'), $result, 'release');
         }
         foreach (array_diff($tags, $tags_request) as $result) {
             Tag::removeTag($this->getUser()->getGuardUser(), $request->getParameter('id'), $result, 'release');
         }
         $object->refresh(true);
         // Create log
         $log = new Log();
         $log->injectDataAndPersist($object, $this->getUser()->getGuardUser(), array('action' => 'edit'));
         return $this->renderText(json_encode(array('id' => $object->id, 'name' => $object->name)));
     }
     return $this->renderPartial('form', array('form' => $this->form));
 }
コード例 #6
0
ファイル: actions.class.php プロジェクト: sensorsix/app
 /**
  * @param sfWebRequest $request
  * @return string
  */
 public function executeUpdateRelease(sfWebRequest $request)
 {
     $release = Doctrine::getTable('ProjectRelease')->find($request->getParameter('id'));
     $this->forward404Unless($release);
     $release->name = $request->getParameter('name');
     $release->save();
     // Create log
     $log = new Log();
     $log->injectDataAndPersist($release, $this->getUser()->getGuardUser(), array('action' => 'edit'));
     return sfView::NONE;
 }
コード例 #7
0
ファイル: actions.class.php プロジェクト: sensorsix/app
 public function executeUpdate(sfWebRequest $request)
 {
     $this->forward404Unless($request->isXmlHttpRequest());
     $this->forward404Unless($request->isMethod(sfRequest::POST) || $request->isMethod(sfRequest::PUT));
     $this->forward404Unless($roadmap = Doctrine_Core::getTable('Roadmap')->find(array($request->getParameter('id'))), sprintf('Object decision does not exist (%s).', $request->getParameter('id')));
     $form = new RoadmapForm($roadmap);
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $form->save();
         // Create log
         $log = new Log();
         $log->injectDataAndPersist($roadmap, $this->getUser()->getGuardUser(), array('action' => 'edit'));
         // Process decisions
         $decisions_request = json_decode($request->getParameter('decisions_id'), true);
         $decisions = array();
         foreach ($form->getObject()->getRoadmapDecision() as $roadmap_decision) {
             $decisions[] = $roadmap_decision->getDecision()->getId();
         }
         foreach (array_diff($decisions_request, $decisions) as $result) {
             if (DecisionTable::getInstance()->getDecisionForUser($this->getUser()->getGuardUser(), $result)) {
                 $form->getObject()->addDecision($result);
             }
         }
         $form->getObject()->RoadmapDecision->save();
         foreach (array_diff($decisions, $decisions_request) as $result) {
             RoadmapDecisionTable::getInstance()->findByRoadmapIdAndDecisionId($form->getObject()->getId(), $result)->delete();
         }
         return $this->renderText(json_encode($form->getObject()->getRowData()));
     }
     return $this->executeEdit($request, $form);
 }
コード例 #8
0
 public function executeUpdate(sfWebRequest $request)
 {
     $this->forward404Unless($request->isXmlHttpRequest());
     $this->forward404Unless($request->isMethod(sfRequest::POST) || $request->isMethod(sfRequest::PUT));
     $this->forward404Unless($object = Doctrine_Core::getTable($this->model)->find(array($request->getParameter('id'))), sprintf('Object decision does not exist (%s).', $request->getParameter('id')));
     $formClass = $this->model . 'Form';
     $this->form = new $formClass($object, array('user' => $this->getUser()));
     $this->form->bind($request->getParameter($this->form->getName()), $request->getFiles($this->form->getName()));
     if ($this->form->isValid()) {
         $this->form->save();
         $this->form_valid = true;
         // Create log
         $log = new Log();
         $log->injectDataAndPersist($object, $this->getUser()->getGuardUser(), array('action' => 'edit'));
         return sfView::NONE;
     }
     return $this->renderPartial('form', array('form' => $this->form));
 }
コード例 #9
0
ファイル: actions.class.php プロジェクト: sensorsix/app
 public function executeUpdate(sfWebRequest $request)
 {
     $this->forward404Unless($request->isXmlHttpRequest());
     $this->forward404Unless($request->isMethod(sfRequest::POST) || $request->isMethod(sfRequest::PUT));
     $this->forward404Unless($alternative = Doctrine_Core::getTable($this->model)->find(array($request->getParameter('id'))), sprintf('Object decision does not exist (%s).', $request->getParameter('id')));
     $form = new AlternativeForm($alternative, array('user' => $this->getUser()));
     $alternative->setUpdatedBy(Alternative::generateUpdateAndCreatedBy($this->getUser()->getGuardUser()));
     $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
     if ($form->isValid()) {
         $form->save();
         // Create log
         $log = new Log();
         $log->injectDataAndPersist($alternative, $this->getUser()->getGuardUser(), array('action' => 'edit'));
         // Process tags
         $tags_request = json_decode($request->getParameter('tags'));
         $tags = array();
         foreach ($alternative->getTagAlternative() as $tag) {
             $tags[] = $tag->Tag->name;
         }
         foreach (array_diff($tags_request, $tags) as $result) {
             Tag::newTag($this->getUser()->getGuardUser(), $request->getParameter('id'), $result, 'alternative');
         }
         foreach (array_diff($tags, $tags_request) as $result) {
             Tag::removeTag($this->getUser()->getGuardUser(), $request->getParameter('id'), $result, 'alternative');
         }
         // Process links
         $links = array();
         foreach ($alternative->getAlternativeLink() as $link) {
             $links[$link->id] = $link->link;
         }
         $links_request_new = array();
         $links_request_old = array();
         $links_request = json_decode($request->getParameter('links'), true);
         foreach ($links_request as $link_request) {
             if (is_array($link_request) && array_key_exists('id', $link_request)) {
                 $links_request_old[$link_request['id']] = $link_request['link'];
             } else {
                 $links_request_new[] = $link_request;
             }
         }
         foreach ($links_request_new as $link_request_new) {
             $link = new AlternativeLink();
             $link->link = $link_request_new['link'];
             $link->alternative_id = $request->getParameter('id');
             $link->save();
         }
         foreach (array_diff(array_keys($links), array_keys($links_request_old)) as $result) {
             AlternativeLinkTable::getInstance()->find($result)->delete();
         }
         foreach ($links_request_old as $key => $link) {
             if ($links_request_old[$key] !== $links[$key]) {
                 $alternative_link = AlternativeLinkTable::getInstance()->find($key);
                 $alternative_link->link = $links_request_old[$key];
                 $alternative_link->save();
             }
         }
         // Process related alternatives
         $related_alternatives_request = json_decode($request->getParameter('related_alternatives'), true);
         if (!$related_alternatives_request) {
             $related_alternatives_request = array();
         }
         $related_alternatives = array();
         foreach ($alternative->getAlternativeRelation() as $related_alternative) {
             $related_alternatives[] = $related_alternative->to_id;
         }
         foreach (array_diff($related_alternatives_request, $related_alternatives) as $result) {
             if (AlternativeTable::getInstance()->getOneForUser($this->getUser()->getGuardUser(), $result)) {
                 $alternative_relation = new AlternativeRelation();
                 $alternative_relation->setFromId($alternative->getId());
                 $alternative_relation->setToId($result);
                 $alternative_relation->setCreatedBy(Alternative::generateUpdateAndCreatedBy($this->getUser()->getGuardUser()));
                 $alternative_relation->save();
             }
         }
         foreach (array_diff($related_alternatives, $related_alternatives_request) as $result) {
             AlternativeRelationTable::getInstance()->findByFromIdAndToId($alternative->getId(), $result)->delete();
         }
         $alternative->refresh(true);
         return $this->renderText(json_encode($alternative->getRowData()));
     } else {
         return $this->renderPartial('form', array('form' => $form));
     }
 }
コード例 #10
0
ファイル: actions.class.php プロジェクト: sensorsix/app
 /**
  * @param sfWebRequest $request
  * @return string
  */
 public function executeAlternativeModalSave(sfWebRequest $request)
 {
     $this->forward404Unless($request->isXmlHttpRequest());
     $decision_id = $this->getUser()->getAttribute('decision_id', null, 'sfGuardSecurityUser');
     if (!empty($decision_id)) {
         $this->decision = DecisionTable::getInstance()->getDecisionForUser($this->getUser()->getGuardUser(), $decision_id);
         $this->forward404Unless(is_object($this->decision));
     } else {
         $this->forward404();
     }
     $alternative = new Alternative();
     $alternative->setName($request->getParameter('name'));
     $alternative->setDecision($this->decision);
     $alternative->setCreatedBy(Alternative::generateUpdateAndCreatedBy($this->getUser()->getGuardUser()));
     $alternative->setUpdatedBy(Alternative::generateUpdateAndCreatedBy($this->getUser()->getGuardUser()));
     $alternative->save();
     $dashboard_role = $this->decision->getDashboardRole();
     if ($dashboard_role) {
         foreach ($this->decision->getCriterion() as $criterion) {
             $planned_alternative_measurement = new PlannedAlternativeMeasurement();
             $planned_alternative_measurement->setAlternative($alternative);
             $planned_alternative_measurement->setCriterion($criterion);
             $dashboard_role->PlannedAlternativeMeasurement->add($planned_alternative_measurement);
         }
         $dashboard_role->PlannedAlternativeMeasurement->save();
     }
     $additional_roles = Doctrine_Query::create()->from('Role r')->leftJoin('r.Decision d')->where('d.id = ?', $this->decision->getId())->andWhere('d.user_id = ?', $this->getUser()->getGuardUser()->id)->execute();
     $criterion_estimates = Doctrine_Query::create()->from('Criterion c')->leftJoin('c.Decision d')->where('d.id = ?', $this->decision->getId())->andWhere('d.user_id = ?', $this->getUser()->getGuardUser()->id)->andWhere('c.name = ?', 'Hour Estimate')->fetchOne();
     $criterion_value = Doctrine_Query::create()->from('Criterion c')->leftJoin('c.Decision d')->where('d.id = ?', $this->decision->getId())->andWhere('d.user_id = ?', $this->getUser()->getGuardUser()->id)->andWhere('c.name = ?', 'Value')->fetchOne();
     $criterion_usability = Doctrine_Query::create()->from('Criterion c')->leftJoin('c.Decision d')->where('d.id = ?', $this->decision->getId())->andWhere('d.user_id = ?', $this->getUser()->getGuardUser()->id)->andWhere('c.name = ?', 'Usability')->fetchOne();
     $criterion_feasibility = Doctrine_Query::create()->from('Criterion c')->leftJoin('c.Decision d')->where('d.id = ?', $this->decision->getId())->andWhere('d.user_id = ?', $this->getUser()->getGuardUser()->id)->andWhere('c.name = ?', 'Feasibility')->fetchOne();
     foreach ($additional_roles as $additional_role) {
         if ($additional_role->getName() == 'Collect Estimates' && $criterion_estimates) {
             $planned_alternative_measurement = new PlannedAlternativeMeasurement();
             $planned_alternative_measurement->setAlternative($alternative);
             $planned_alternative_measurement->setCriterion($criterion_estimates);
             $planned_alternative_measurement->setRole($additional_role);
             $planned_alternative_measurement->save();
         } elseif ($additional_role->getName() == 'Collect input on Value' && $criterion_value) {
             $planned_alternative_measurement = new PlannedAlternativeMeasurement();
             $planned_alternative_measurement->setAlternative($alternative);
             $planned_alternative_measurement->setCriterion($criterion_value);
             $planned_alternative_measurement->setRole($additional_role);
             $planned_alternative_measurement->save();
         } elseif ($additional_role->getName() == 'Collect input on Usability' && $criterion_usability) {
             $planned_alternative_measurement = new PlannedAlternativeMeasurement();
             $planned_alternative_measurement->setAlternative($alternative);
             $planned_alternative_measurement->setCriterion($criterion_usability);
             $planned_alternative_measurement->setRole($additional_role);
             $planned_alternative_measurement->save();
         } elseif ($additional_role->getName() == 'Collect input on Feasibility' && $criterion_feasibility) {
             $planned_alternative_measurement = new PlannedAlternativeMeasurement();
             $planned_alternative_measurement->setAlternative($alternative);
             $planned_alternative_measurement->setCriterion($criterion_feasibility);
             $planned_alternative_measurement->setRole($additional_role);
             $planned_alternative_measurement->save();
         }
     }
     // Create log
     $log = new Log();
     $log->injectDataAndPersist($alternative, $this->getUser()->getGuardUser(), array('action' => 'new'));
     return sfView::NONE;
 }