Example #1
0
 public function executeEdit(sfWebRequest $request)
 {
     $this->forward404Unless($request->isXmlHttpRequest());
     $this->checkProject($request);
     $this->checkProfile($request, $this->ei_project);
     $this->checkFunction($request, $this->ei_project);
     $version_notice_id = $request->getParameter('version_notice_id');
     $notice_id = $request->getParameter('notice_id');
     $notice_ref = $request->getParameter('notice_ref');
     $lang = $request->getParameter('lang');
     $this->ei_version_notice = Doctrine_Core::getTable('EiVersionNotice')->findOneByVersionNoticeIdAndNoticeIdAndNoticeRefAndLang($version_notice_id, $notice_id, $notice_ref, $lang);
     /* Si la version de notice n'existe pas pour la langue , on la crée sur l'application distante */
     if ($this->ei_version_notice == null) {
         $this->ei_version_notice = EiVersionNotice::createDistantNoticeLang($version_notice_id, $notice_id, $notice_ref, $lang);
         if ($this->ei_version_notice == null || is_array($this->ei_version_notice)) {
             // La version de notice n'a pas pu être créée sur le site distant : on retourne une erreur
             return $this->renderText(json_encode(array('header' => $this->ei_version_notice['message'], 'formContent' => "Version notice can't be created on central system ...", 'success' => false)));
         }
     }
     /* Récupération de toutes les langues du projet */
     $this->project_langs = $this->ei_project->getProjectLangs();
     /* Récupération des versions de notices de la fonction */
     $this->noticeVersionsForDropdownList = Doctrine_Core::getTable('EiVersionNotice')->getNoticeVersionsForDropdownList($this->kal_function);
     /*Récupération des profils actifs sur une notice */
     $this->activesProfilesForNoticeVersion = Doctrine_Core::getTable('EiVersionNotice')->getActiveProfilesForVersion($this->ei_project, $this->kal_function, $this->ei_version_notice->getVersionNoticeId(), $this->ei_version_notice->getNoticeId(), $this->ei_version_notice->getNoticeRef());
     $this->form = new EiVersionNoticeForm($this->ei_version_notice);
     /*Récupération des paramètres d'entrées et de sortie dela fonction */
     $this->getAndParseFunctionAndProjectParametersToArray();
     //Récupération des paramètres de fonction et de projet sous forme de tableau
     /* Gestion des retours json */
     /* En tête de la notice */
     $headerParams = $this->urlParameters;
     $headerParams['function_id'] = $this->kal_function->getFunctionId();
     $headerParams['function_ref'] = $this->kal_function->getFunctionRef();
     $headerParams['ei_version_notice'] = $this->ei_version_notice;
     $headerParams['noticeVersions'] = $this->noticeVersionsForDropdownList;
     $headerParams['project_langs'] = $this->project_langs;
     $headerParams['activesProfilesForNoticeVersion'] = $this->activesProfilesForNoticeVersion;
     $headerParams['default_notice_lang'] = $this->ei_project->getDefaultNoticeLang();
     /* Formulaire de la notice */
     $formContentParams = $this->urlParameters;
     $formContentParams['function_id'] = $this->kal_function->getFunctionId();
     $formContentParams['function_ref'] = $this->kal_function->getFunctionRef();
     $formContentParams['version_notice_id'] = $this->ei_version_notice->getVersionNoticeId();
     $formContentParams['notice_id'] = $this->ei_version_notice->getNoticeId();
     $formContentParams['notice_ref'] = $this->ei_version_notice->getNoticeRef();
     $formContentParams['lang'] = $this->ei_version_notice->getLang();
     $formContentParams['action'] = "update";
     /* Retour de la réponse json*/
     return $this->renderText(json_encode(array('header' => $this->getPartial("versionNoticeHeader", $headerParams), 'formContent' => $this->getPartial("blockForm", array("form" => $this->form, "url_form" => $formContentParams, 'inParameters' => $this->inTabParameters, 'outParameters' => $this->outTabParameters)), 'success' => true)));
     return sfView::NONE;
 }
 public function reload($projets, $project_id, $project_ref, Doctrine_Connection $conn = null)
 {
     if ($conn == null) {
         $conn = Doctrine_Manager::connection();
     }
     //Création de la collection d'objet EiVersionNotice à ajouter
     $collection = new Doctrine_Collection("EiVersionNotice");
     //Supression des versions de notice qui n'existent plus sur script
     $this->deleteNotFoundVersionNotice($conn);
     $items = $projets->getElementsByTagName("ei_version_notices");
     if ($items->length > 0) {
         //ya t-il des éléments à traiter?
         $ei_version_notices = $items->item(0)->getElementsByTagName("ei_version_notice");
         if ($ei_version_notices->length > 0) {
             foreach ($ei_version_notices as $ei_version_notice) {
                 $notice_id = $ei_version_notice->getAttribute("notice_id");
                 $notice_ref = $ei_version_notice->getAttribute("notice_ref");
                 $version_notice_id = $ei_version_notice->getAttribute("version_notice_id");
                 $lang = $ei_version_notice->getAttribute("lang");
                 //recherche du profil en base
                 if ($notice_id != null && $notice_ref != null && $version_notice_id != null && $lang != null) {
                     $q = Doctrine_Core::getTable('EiVersionNotice')->findOneByNoticeIdAndNoticeRefAndVersionNoticeIdAndLang($notice_id, $notice_ref, $version_notice_id, $lang);
                     if ($q && $q != null) {
                         //si l'element existe , on fait une mise à jour
                         $q->setName($ei_version_notice->getElementsByTagName("name")->item(0)->nodeValue);
                         $q->setDescription($ei_version_notice->getElementsByTagName("description")->item(0)->nodeValue);
                         $q->setExpected($ei_version_notice->getElementsByTagName("expected")->item(0)->nodeValue);
                         $q->setResult($ei_version_notice->getElementsByTagName("result")->item(0)->nodeValue);
                         $q->setIsActive($ei_version_notice->getElementsByTagName("is_active")->item(0)->nodeValue);
                         $q->save($conn);
                     } else {
                         //l'élément n'existe pas encore, et dans ce cas on le crée
                         $new_ei_version_notice = new EiVersionNotice();
                         $new_ei_version_notice->setNoticeId($notice_id);
                         $new_ei_version_notice->setNoticeRef($notice_ref);
                         $new_ei_version_notice->setVersionNoticeId($version_notice_id);
                         $new_ei_version_notice->setLang($lang);
                         $new_ei_version_notice->setDescription($ei_version_notice->getElementsByTagName("description")->item(0)->nodeValue);
                         $new_ei_version_notice->setExpected($ei_version_notice->getElementsByTagName("expected")->item(0)->nodeValue);
                         $new_ei_version_notice->setResult($ei_version_notice->getElementsByTagName("result")->item(0)->nodeValue);
                         $new_ei_version_notice->setName($ei_version_notice->getElementsByTagName("name")->item(0)->nodeValue);
                         $new_ei_version_notice->setIsActive($ei_version_notice->getElementsByTagName("is_active")->item(0)->nodeValue);
                         $collection->add($new_ei_version_notice);
                     }
                 }
             }
             if ($collection->getFirst()) {
                 $collection->save($conn);
             }
             //Sauvegarde de la collection
             return 1;
         }
         return null;
     }
 }
Example #3
0
 public function findDefaultEiFunctionNoticeLangs(EiVersionNotice $vn)
 {
     $this->functionNoticeLangs = Doctrine_Core::getTable('EiVersionNotice')->findByVersionNoticeIdAndNoticeIdAndNoticeRef($vn->getVersionNoticeId(), $vn->getNoticeId(), $vn->getNoticeRef());
 }