public static function getCampaignGraphChild(EiCampaignGraph $ei_campaignGraph, Doctrine_Connection $conn = null) { if ($conn == null) { $conn = Doctrine_Manager::connection(); } $child = $conn->createQuery()->from('EiCampaignGraph cg')->leftJoin('cg.graphCampaignChildren cp')->leftJoin('cg.EiCampaignGraphType gt')->leftJoin('cg.EiScenario s')->leftJoin('cg.EiDataSet ds')->where('cp.parent_id = ' . $ei_campaignGraph->getId())->execute(); if (count($child) > 0) { return $child->getFirst(); } return null; }
public function executeCreate(sfWebRequest $request) { $this->forward404Unless($request->isMethod(sfRequest::POST)); $this->checkProject($request); //Récupération du projet $this->checkProfile($request, $this->ei_project); //Récupération du profil courant //Recherche de la campagne concernée $this->checkCampaign($request, $this->ei_project); $this->getNodeParent($request); //Récupération du noeud parent $this->position = $request->getParameter('position'); //Récupération de la position //Initialisation du formulaire $ei_campaign_graph = new EiCampaignGraph(); $ei_campaign_graph->setEiCampaign($this->ei_campaign); $this->form = new EiCampaignGraphForm($ei_campaign_graph, array('ei_project' => $this->ei_project)); $graphRelation = new EiCampaignGraphHasGraph(); $graphRelation->setParentId($this->parent_id); $graphRelation->setCampaignChild($ei_campaign_graph); $graphRelation->setEiCampaign($this->ei_campaign); $graphRelation->setPosition($this->position); $this->form->embedForm('graphParent', new EiCampaignGraphHasGraphForm($graphRelation)); $this->processForm($request, $this->form); //Récupération du root folder du projet $this->root_folder = Doctrine_Core::getTable('EiNode')->getRootFolder($this->project_ref, $this->project_id); //Récupération des noeuds enfants du dossier $this->ei_nodes = $this->root_folder->getNodes(false, false); //Récupération du chemin firefox dans les settings utilisateur /** @var EiUser $user */ $user = $this->getUser()->getGuardUser()->getEiUser(); $this->user_settings = Doctrine_Core::getTable('EiUserSettings')->findOneByUserRefAndUserId($user->getRefId(), $user->getUserId()); $firefoxPath = $this->user_settings == null ?: $this->user_settings->getFirefoxPath(); if ($this->success) { $this->campaignGraphBlockType = Doctrine_Core::getTable('EiBlockType')->findAll(); $campaignGraphLine = $this->urlParameters; $campaignGraphLine['ei_campaign_graph'] = Doctrine_Core::getTable('EiCampaignGraph')->getCampaignGraphStep($this->ei_campaign_graph->getId()); $campaignGraphLine['project_name'] = $this->ei_project->getName(); $campaignGraphLine['firefox_path'] = $firefoxPath; $campaignGraphLine['campaignGraphBlockType'] = $this->campaignGraphBlockType; $campaign_graph_new = $this->urlParameters; $campaign_graph_new['campaign_id'] = $this->ei_campaign_graph->getId(); $campaign_graph_new['parent_id'] = $this->ei_campaign_graph->getId(); return $this->renderText(json_encode(array('html' => $this->getPartial('eicampaigngraph/campaignGraphLine', $campaignGraphLine), 'new_create_url' => $this->generateUrl('campaign_graph_new', $campaign_graph_new), 'updateMode' => false, 'success' => true))); } else { $uri_form = $this->urlParameters; $uri_form['form'] = $this->form; $uri_form['ei_nodes'] = $this->ei_nodes; $uri_form['campaign_id'] = $this->campaign_id; $uri_form['root_folder'] = $this->root_folder; $uri_form['parent_id'] = $this->parent_id; return $this->renderText(json_encode(array('html' => $this->getPartial('eicampaigngraph/form', $uri_form), 'success' => false))); } //Retour de la réponse json en cas de succès return sfView::NONE; }
public function getGraphHasChainedList(EiCampaign $ei_campaign, Doctrine_Connection $conn = null) { if ($conn == null) { $conn = Doctrine_Manager::connection(); } $graphRoot = $this->getRootCampaign($ei_campaign, $conn); $list = array(); if ($graphRoot == null) { return $list; } $child = $graphRoot; while ($child != null && !(is_int($child) && $child == -1)) { $list[] = $child; $child = EiCampaignGraph::getCampaignGraphChild($child, $conn); } return $list; }