Exemplo n.º 1
0
 public function executeAddManyStepsInContent(sfWebRequest $request)
 {
     $this->conn = Doctrine_Manager::connection();
     $this->success = false;
     $this->html = '';
     $selectStepTab = MyFunction::parseSimpleStringToTab($request->getParameter('selectStepTab'));
     if (count($selectStepTab) == 0) {
         return $this->renderText(json_encode(array('html' => "No step has been selected ...", 'success' => $this->success)));
     }
     try {
         //Récupération des paramètres indispensables au process
         if ($this->preAddStepInContent($request) == -1) {
             throw new Exception('error');
         }
         $this->conn->beginTransaction();
         /* Recherche des éléments entre lesquelles on va insérer les steps */
         $this->lastStep = null;
         if ($this->before_step_id == 0) {
             $this->firstStep = Doctrine_Core::getTable('EiCampaignGraph')->findOneById($selectStepTab[0]);
             $this->lastStep = $this->current_campaign->getRootCampaign();
         } else {
             $this->firstStep = Doctrine_Core::getTable('EiCampaignGraph')->findOneById($this->before_step_id);
             $nextStep = $this->firstStep->getNextStep($this->conn);
             if ($nextStep != null) {
                 $this->lastStep = $nextStep;
             }
         }
         /* A ce niveau on a tous les éléments permettant l'insertion des steps */
         $this->addManyStepProcess($this->current_campaign, $selectStepTab, $this->firstStep, $this->lastStep);
         /* On tente de récupérer le root de la campagne en fin de process.
          * S'il y'a eu des soucis, cette fonction lèvera une exception et annulera la transaction */
         $this->current_campaign->getRootCampaign();
         /* Validation globale de la transaction */
         $this->conn->commit();
         $manyStepsLineContent = $this->urlParameters;
         $manyStepsLineContent['ei_campaign'] = $this->ei_campaign;
         $manyStepsLineContent['steps'] = $this->collection_step;
         $this->html = $this->getPartial('eicampaigngraph/manyStepsLineContent', $manyStepsLineContent);
         $this->success = true;
     } catch (Exception $e) {
         $this->conn->rollback();
         throw $e;
     }
     return $this->renderText(json_encode(array('html' => $this->html, 'success' => $this->success)));
     return sfView::NONE;
 }
Exemplo n.º 2
0
 public function executeChooseDelForManySub(sfWebRequest $request)
 {
     $this->forward404unless($request->isXmlHttpRequest());
     $this->checkProject($request);
     //Récupération du projet
     $this->checkProfile($request, $this->ei_project);
     //Récupération du profil courant
     $this->delivery_id = intval($request->getParameter('delivery_id'));
     if ($this->delivery_id == null) {
         return $this->renderText(json_encode(array('html' => 'Error .Missing delivery parameters ...', 'success' => false)));
     }
     $this->ei_delivery = doctrine_core::getTable('EiDelivery')->findOneByProjectIdAndProjectRefAndId($this->project_id, $this->project_ref, $this->delivery_id);
     if ($this->ei_delivery == null) {
         return $this->renderText(json_encode(array('html' => 'Error .Delivery nor found with theses parameters ...', 'success' => false)));
     }
     $this->selectSubjects = $request->getParameter('selectSubjectTab');
     $this->selectSubjectTab = MyFunction::parseSimpleStringToTab($this->selectSubjects);
     $this->html = "Error on process ... ";
     $this->success = false;
     $conn = Doctrine_Manager::connection();
     try {
         $conn->beginTransaction();
         if ($this->selectSubjectTab != null && count($this->selectSubjectTab) > 0) {
             $this->field = 'delivery_id';
             $q = 'UPDATE ei_subject 
                          SET ' . $this->field . ' =' . $this->delivery_id;
             $q .= '  WHERE id IN (' . $this->selectSubjects . ')';
             $q .= '  AND project_id = ' . $this->project_id;
             $q .= '  AND project_ref = ' . $this->project_ref;
             $conn->execute($q);
             $conn->commit();
             $this->html = "success";
             $this->success = true;
         } else {
             $this->html = "Error. No subject selected ... ";
         }
         return $this->renderText(json_encode(array('html' => $this->html, 'success' => $this->success, 'referer' => $request->getReferer())));
     } catch (Exception $e) {
         $conn->rollback();
         return $this->renderText(json_encode(array('html' => $this->html, 'success' => $this->success, 'referer' => $request->getReferer())));
     }
     return sfView::NONE;
 }