Пример #1
0
 public function checkCampaignSubject(sfWebRequest $request, EiProjet $ei_project, EiCampaign $ei_campaign = null)
 {
     $this->subject_id = $request->getParameter('subject_id');
     if ($this->subject_id == null) {
         $this->ei_subject = null;
     } else {
         //Recherche du sujet tout en s'assurant qu'elle corresponde au projet courant
         $this->ei_subject = Doctrine_Core::getTable('EiSubject')->findOneByIdAndProjectIdAndProjectRef($this->subject_id, $ei_project->getProjectId(), $ei_project->getRefId());
         if ($this->ei_subject != null && $ei_campaign != null) {
             //On vérifie l'association entre la campagne et le sujet
             $link = Doctrine_Core::getTable('EiSubjectHasCampaign')->findOneBySubjectIdAndCampaignId($this->subject_id, $ei_campaign->getId());
             if ($link == null) {
                 throw new Exception('This campaign is not associate to the intervention ...');
             }
         }
     }
 }
Пример #2
0
 public function executeCreate(sfWebRequest $request)
 {
     $this->forward404Unless($request->isMethod(sfRequest::POST));
     $this->checkProject($request);
     $this->checkProfile($request, $this->ei_project);
     $this->checkSubject($request, $this->ei_project);
     $subject_has_campaign = new EiSubjectHasCampaign();
     $subject_has_campaign->setSubjectId($this->ei_subject->getId());
     $ei_campaign = new EiCampaign();
     $ei_campaign->setProjectId($this->ei_project->getProjectId());
     $ei_campaign->setProjectRef($this->ei_project->getRefId());
     $ei_campaign->setAuthorId($this->getUser()->getGuardUser()->getId());
     $subject_has_campaign->setEiCampaign($ei_campaign);
     $this->form = new EiSubjectHasCampaignForm($subject_has_campaign);
     $this->form->embedForm('ei_subject_campaign', new EiCampaignForm($ei_campaign));
     $this->processForm($request, $this->form);
     $this->setTemplate('new');
 }
Пример #3
0
 public function createStepAsRoot(EiCampaign $current_campaign, EiCampaignGraph $new_root, Doctrine_Connection $conn = null)
 {
     if ($conn == null) {
         $conn = Doctrine_Manager::connection();
     }
     try {
         $conn->beginTransaction();
         //throw new Exception($current_campaign->getId());
         if (!$new_root->isNew()) {
             $new_root1 = $new_root->copy();
             $new_root->delete($conn);
             $new_root = $new_root1;
         }
         $ei_campaign_root = $current_campaign->getRootCampaign();
         //Si la campagne a déjà un root , on le change , sinn on l'ajoute
         if ($ei_campaign_root instanceof EiCampaignGraph) {
             //Le root existe, on le change
             $new_root->save($conn);
             //Ajout de la relation père-fils
             $new_relation = new EiCampaignGraphHasGraph();
             $new_relation->setParentId($new_root->getId());
             $new_relation->setChildId($ei_campaign_root->getId());
             $new_relation->setCampaignId($current_campaign->getId());
             $new_relation->save($conn);
             $conn->commit();
             return $new_root;
         } else {
             //On crèe le noeud comme root
             if ($ei_campaign_root == null) {
                 $new_root->save($conn);
                 $conn->commit();
                 return $new_root;
             }
             $conn->close();
             return null;
         }
     } catch (Exception $e) {
         $conn->rollback();
         throw $e;
     }
 }
Пример #4
0
 public function addManyStepProcess(EiCampaign $ei_campaign, array $selectStepTab, EiCampaignGraph $firstStep, EiCampaignGraph $lastStep = null)
 {
     $bef = $firstStep;
     $this->collection_step = new Doctrine_Collection('EiCampaignGraph');
     foreach ($selectStepTab as $i => $stepId) {
         if ($this->before_step_id == 0 && $i == 0) {
             $step = $bef->copy();
             $step->setCampaignId($ei_campaign->getId());
             $step->save($this->conn);
             $this->collection_step->add($step);
             //Enregistrement du step dans la collection à retourner
             $bef = $step;
         } else {
             $step = Doctrine_Core::getTable('EiCampaignGraph')->findOneById($stepId);
             $step = $step->copy();
             $step->setCampaignId($ei_campaign->getId());
             $step->save($this->conn);
             $this->collection_step->add($step);
             //Enregistrement du step dans la collection à retourner
             //Création de la relation
             $new_relation = new EiCampaignGraphHasGraph();
             $new_relation->setParentId($bef->getId());
             $new_relation->setChildId($step->getId());
             $new_relation->setCampaignId($ei_campaign->getId());
             $new_relation->save($this->conn);
             //Changement du bef
             $bef = $step;
         }
     }
     //On vérifie s'il existait un élément après le curseur
     if ($lastStep != null) {
         //Création de la relation
         $new_relation = new EiCampaignGraphHasGraph();
         $new_relation->setParentId($bef->getId());
         $new_relation->setChildId($lastStep->getId());
         $new_relation->setCampaignId($ei_campaign->getId());
         $new_relation->save($this->conn);
     }
 }
 public function setEiCampaignId(EiCampaign $ei_campaign)
 {
     $this->setCampaignId($ei_campaign->getId());
 }
Пример #6
0
 public function createDefaultTnr(Doctrine_Connection $conn = null)
 {
     if ($conn == null) {
         $conn = Doctrine_Manager::connection();
     }
     $guard = sfContext::getInstance()->getUser()->getGuardUser();
     $default_tnr = new EiCampaign(null, null, $this->getEiProject());
     $default_tnr->setName('ValidationTests_S' . $this->getId());
     $default_tnr->setAuthorId($guard->getId());
     $default_tnr->save($conn);
     //Association du tnr par défaut au bug
     $default_tnr_relation = new EiSubjectHasCampaign(null, null, $this, $default_tnr);
     $default_tnr_relation->setIsTnr(true);
     $default_tnr_relation->save($conn);
 }
 /**
  * Action permettant de récupérer l'arbre des jeux de données.
  *
  * @param sfWebRequest $request
  */
 public function execute($request)
 {
     $this->getResponse()->setContentType('application/json');
     $this->setLayout(false);
     /** @var EiCampaignGraphTable $tableCampaignGraph */
     $tableCampaignGraph = Doctrine_Core::getTable("EiCampaignGraph");
     $found = false;
     $profileRef = $request->getParameter("profile_ref");
     $profileId = $request->getParameter("profile_id");
     $projectRef = $request->getParameter("project_ref");
     $projectId = $request->getParameter("project_id");
     $startPos = $request->getParameter("start");
     $endPos = $request->getParameter("end");
     $deviceId = $request->getParameter("device_id");
     $driverId = $request->getParameter("driver_id");
     $browserId = $request->getParameter("browser_id");
     $date = $request->getParameter("date");
     $expectedDate = str_replace("*", " ", $date);
     $expectedDate = str_replace("_", ":", $expectedDate);
     $response = array("error" => "An error occured when we try to add campaign into execution stack.");
     try {
         $this->getUser()->signIn($this->user, true);
         $execution = new EiExecutionStack();
         $execution->setEiCampaign($this->campaign);
         $execution->setSfGuardUser($this->user);
         $execution->setProfileRef($profileRef);
         $execution->setProfileId($profileId);
         $execution->setProjectRef($projectRef);
         $execution->setProjectId($projectId);
         if ($startPos != null && $endPos != null) {
             /** @var EiCampaignGraph $start */
             $start = $tableCampaignGraph->find($startPos);
             /** @var EiCampaignGraph $end */
             $end = $tableCampaignGraph->find($endPos);
             if ($start != null && $start->getId() != "" && $end != null && $end->getId() != "") {
                 $execution->setStartPos($start->getId());
                 $execution->setEndPos($end->getId());
                 $found = true;
             }
         }
         if (!$found) {
             /** @var EiCampaignGraph $start */
             $start = $tableCampaignGraph->getFirstStep($this->campaign->getId());
             /** @var EiCampaignGraph $end */
             $end = $tableCampaignGraph->getLastStep($this->campaign->getId());
             $execution->setStartPos($start->getId());
             $execution->setEndPos($end->getId());
         }
         if ($deviceId != null && $deviceId != 'null') {
             $execution->setDeviceId($deviceId);
         }
         $execution->setDriverId($driverId);
         $execution->setBrowserId($browserId);
         $execution->setExpectedDate($expectedDate);
         $execution->save();
         unset($response["error"]);
         $response["success"] = true;
         $response["id"] = $execution->getId();
     } catch (Exception $e) {
         $response = array();
     }
     return $this->renderText(json_encode($response));
 }
 public function getCampaignGraphs(EiCampaign $ei_campaign, Doctrine_Connection $conn = null)
 {
     if ($conn == null) {
         $conn = Doctrine_Manager::connection();
     }
     $q = $this->getCampaiGraphQuery($conn)->where('cg.campaign_id= ? ', array($ei_campaign->getId()));
     return $q->execute();
 }