Exemple #1
0
 /**
  * @param sfWebRequest $request
  */
 public function executeDecisionSave(sfWebRequest $request)
 {
     $decision_id = $this->getUser()->getAttribute('decision_id', null, 'sfGuardSecurityUser');
     if ($decision_id) {
         $decision = DecisionTable::getInstance()->getDecisionForUser($this->getUser()->getGuardUser(), $decision_id);
         $this->forward404Unless(is_object($decision));
     } else {
         $decision = new Decision();
         $decision->type_id = 2;
         // Product development
         $type_template = TypeTemplate::getInstance()->createQuery('t')->where('t.user_id is NULL')->andWhere('t.type_id = ?', 2)->andWhere('t.name = ?', 'Default')->execute();
         $decision->template_id = $type_template[0]->getId();
         // Default template
         $folder = Folder::getInstance()->createQuery('t')->where('t.user_id = ?', $this->getUser()->getGuardUser()->id)->andWhere('t.deletable = ?', 0)->execute();
         if (!empty($folder)) {
             $decision->setFolderId($folder[0]->getId());
         }
     }
     $decision->name = $request->getParameter('name');
     if ($decision->name == '') {
         $decision->name = 'New project';
     }
     $decision->save();
     $this->getUser()->setAttribute('decision_id', $decision->id, 'sfGuardSecurityUser');
     $this->redirect('@wizard\\alternatives?decision_id=' . $decision->id);
 }
Exemple #2
0
 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'));
 }
Exemple #3
0
 public function preSave($event)
 {
     if (array_key_exists('template_id', $this->getModified()) && !$this->isNew()) {
         $this->template_changed = true;
     }
     if (empty($this->start_date)) {
         $this->start_date = null;
     }
     if (empty($this->end_date)) {
         $this->end_date = null;
     }
     if (!$this->folder_id) {
         $this->folder_id = Folder::getInstance()->getNotDeletableForUser(sfContext::getInstance()->getUser()->getGuardUser(), Folder::TYPE_PROJECT)->getId();
     }
 }
Exemple #4
0
 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_ROADMAP);
     if (!Folder::getInstance()->getNotDeletableForUser($this->getUser()->getGuardUser(), Folder::TYPE_ROADMAP, 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()));
 }