/** * Action permettant de créer un data set. * * @param sfWebRequest $request */ public function execute($request) { $this->setLayout(false); // On détermine le type de contenu retourné. $this->getResponse()->setContentType('application/json'); // On authentifie l'utilisateur. $this->getUser()->signIn($this->user, true); // On déclare le résultat à retourner. $resultat = array("not_found" => true); /** @var EiExcelRequestsTable $table */ $table = EiExcelRequestsTable::getInstance(); // TODO: Amélioration de l'appel EI_EXCEL_REQUESTS NATIVE REQUEST. // Mise à jour des états des demandes qui ont plus de 1 jour. $sqlUpdate = "UPDATE ei_excel_requests SET state = 1 WHERE created_at <= DATE_ADD(NOW(), INTERVAL -3 MINUTE);"; // Exécution. Doctrine_Manager::connection()->execute($sqlUpdate); /** @var EiExcelRequests $requete */ $requete = $table->getLastUserRequest($this->user->getEiUser()->getRefId(), $this->user->getEiUser()->getUserId()); if ($requete != null && $requete->getProfil() != null && $requete->getScenario() != null) { $resultat = array("id" => $requete->getId(), "project_id" => $requete->getProjectId(), "project_ref" => $requete->getProjectRef(), "project_name" => $requete->getScenario()->getEiProjet()->getName(), "profile_id" => $requete->getProfileId(), "profile_ref" => $requete->getProfileRef(), "profile_name" => $requete->getProfil()->getName(), "scenario_id" => $requete->getScenario()->getId(), "scenario_name" => $requete->getScenario()->getNomScenario(), "scenario_url" => $this->generateUrl("projet_new_eiversion", array("action" => "editVersionWithoutId", "project_id" => $requete->getProjectId(), "project_ref" => $requete->getProjectRef(), "profile_name" => $requete->getProfil()->getName(), "profile_id" => $requete->getProfileId(), "profile_ref" => $requete->getProfileRef(), "ei_scenario_id" => $requete->getScenario()->getId()), true), "ei_data_set_id" => $requete->getEiDataSetId(), "ei_data_set_name" => $requete->getEiDataSetId() != "" ? $requete->getEiDataSet()->getName() : "", "ei_data_set_desc" => $requete->getEiDataSetId() != "" ? $requete->getEiDataSet()->getDescription() : "", "ei_test_set_id" => $requete->getEiTestSetId(), "state" => $requete->getState()); if ($requete->getEiTestSetId() == "") { $requete->setEiTestSet(null); } if ($requete->getEiDataSetId() == "") { $requete->setEiDataSet(null); $requete->setEiDataSetTemplate(null); } $requete->setState(true); $requete->save(); } return $this->renderText(json_encode($resultat)); }
public function preExecute() { /** @var EiUserTable $table */ $table = Doctrine_Core::getTable('EiUser'); $this->token = $this->getRequest()->getParameter("token"); $this->user = $table::getInstance()->getUserByTokenApi($this->token); $this->forward404If(is_bool($this->user) && $this->user === false, "You are not allowed to access this page."); $this->user = $this->user->getGuardUser(); }
/** * Action permettant de créer un data set. * * @param sfWebRequest $request */ public function execute($request) { $this->ei_scenario = Doctrine_Core::getTable('EiScenario')->find($this->scenario->getId()); $this->forward404Unless($this->ei_scenario); $this->forward404Unless(Doctrine_Core::getTable("EiProjectUser")->getEiProjet($this->ei_scenario->getProjectId(), $this->ei_scenario->getProjectRef(), $this->user->getEiUser())); /** @var EiDataSetStructure $ei_root_node */ $ei_root_node = Doctrine_Core::getTable("EiDataSetStructure")->getRoot($this->ei_scenario->getId()); $this->forward404Unless($ei_root_node); /** @var DOMDocument $xsd */ $xsd = EiDataSetStructure::createXSD($ei_root_node); $xsd->formatOutput = true; $xsd = $xsd->saveXML(); $response = $this->getResponse(); $response->setContentType('text/xml'); $response->setHttpHeader('Content-Disposition', 'attachment; filename="' . $this->ei_scenario->getNomScenario() . '-XSD.xsd'); $response->setContent($xsd); return sfView::NONE; }
/** * Action permettant de retourner la description et les notices d'une fonction. * En POST, le matching est directement réalisé. * * @param sfWebRequest $request */ public function execute($request) { $this->setLayout(false); // On détermine le type de contenu retourné. $this->getResponse()->setContentType('application/json'); $this->getUser()->signIn($this->user, true); // Récupération du JDT. $test_set_id = $request->getParameter("ei_test_set_id"); $testSet = Doctrine_Core::getTable('EiTestSet')->find($test_set_id); // Récupération de la fonction. $function_id = $request->getParameter("function_id"); $function_ref = $request->getParameter("function_ref"); // Récupération du projet. $project_id = $request->getParameter("project_id"); $project_ref = $request->getParameter("project_ref"); $project = Doctrine_Core::getTable('EiProjet')->findOneByProjectIdAndRefId($project_id, $project_ref); // Récupération du profil. $profile_id = $request->getParameter("profile_id"); $profile_ref = $request->getParameter("profile_ref"); /** @var EiProfil $profile */ $profile = Doctrine_Core::getTable('EiProfil')->findOneByProfileIdAndProfileRefAndProjectIdAndProjectRef($profile_id, $profile_ref, $project_id, $project_ref); //Recherche des paramètres de profil à utiliser pour interpreter des éventuels paramètres variables $profileParams = $profile->getParamsWithName($this->user->getEiUser()); //Récupération de l'oracle du jeu de test ( notice du jeu de test) $oracle = $testSet->getTestSetOracle($project, $project->getDefaultNoticeLang(), $function_id, $function_ref, false); $oracle = isset($oracle[0]) ? $oracle[0] : $oracle; // Récupération des paramètres d'entrée. $params = Doctrine_Core::getTable('EiTestSetParam')->getParamForTestSetAndEiTestFunction($test_set_id, $oracle['ei_test_set_function_id']); $paramsOut = Doctrine_Core::getTable('EiFunctionHasParam')->findByFunctionRefAndFunctionIdAndParamType($function_ref, $function_id, 'OUT'); // Transformation de la notice $noticeDesc = MyFunction::parseAndExtractParamsValue($oracle["description"], $params, $profileParams); $noticeExp = MyFunction::parseAndExtractParamsValue($oracle["expected"], $params, $profileParams); if ($paramsOut != null && $paramsOut->count() > 0) { $tmpParams = array(); /** @var EiFunctionHasParam $param */ foreach ($paramsOut as $param) { $tmpParams[] = array("name" => $param->getName(), "value" => $param->getDefaultValue()); } $paramsOut = $tmpParams; } else { $paramsOut = array(); } return $this->renderText(json_encode(array("func_desc" => $oracle["func_desc"], "notice_desc" => $noticeDesc, "notice_expected" => $noticeExp, "in_params" => $params, 'out_params' => $paramsOut))); }
/** * Action permettant de créer un data set. * * @param sfWebRequest $request */ public function execute($request) { $this->logger = sfContext::getInstance()->getLogger(); $this->logger->info("----------------------------------------------------------"); $this->logger->info("--- DEBUT SAUVEGARDE DATA SET"); $this->setLayout(false); $this->getResponse()->setContentType('application/json'); $this->getUser()->signIn($this->user, true); // On récupère le noeud parent du scénario. $noeud_id = $this->scenario->getEiNode()->getId(); $noeud_parent = Doctrine_Core::getTable("EiNode")->findOneByRootIdAndType($noeud_id, "EiDataSetFolder"); $noeud_parent_id = $noeud_parent->getId(); // Récupération du nom & description. $nom = $request->getPostParameter("name"); $desc = $request->getPostParameter("description"); // On récupère le data set source (si enregistrement). $dataSetSourceId = $request->getPostParameter("jddSource"); // On récupère le data set template source (si enregistrement). $dataSetTemplateSourceId = $request->getPostParameter("jddTemplateSource"); // On récupère le dossier où enregistrer le JDD. $dataSetDirId = $request->getPostParameter("jddDir"); // On décode le fichier. $request->setParameter("file", str_replace("%3E", ">", str_replace("%3C", "<", $request->getParameter("file")))); // LOGS $this->logger->info("-- NOM : " . $nom); $this->logger->info("-- DESCRIPTION : " . $desc); $this->logger->info("-- JDD SOURCE ID : " . $dataSetSourceId); $this->logger->info("-- JDD TEMPLATE SOURCE ID : " . $dataSetTemplateSourceId); $this->logger->info("-- NOEUD ID PARENT : " . $noeud_parent_id); $this->logger->info("----------------------------------------------------------"); $this->logger->info("--- FIN SAUVEGARDE DATA SET"); $this->logger->info("----------------------------------------------------------"); $request->setParameter("ei_user", $this->user->getEiUser()); $request->setParameter("name", $nom); $request->setParameter("description", $desc); $request->setParameter("ei_node_parent_id", $noeud_parent_id); if ($dataSetSourceId != null && $dataSetSourceId != -1) { $request->setParameter("dataSetSource", $dataSetSourceId); } if ($dataSetTemplateSourceId != null && $dataSetTemplateSourceId != -1) { $request->setParameter("dataSetTemplateSource", $dataSetTemplateSourceId); } if ($dataSetDirId != null && $dataSetDirId != -1) { $oJddDir = Doctrine_Core::getTable("EiNode")->find($dataSetDirId); if ($oJddDir != null && $oJddDir->getObjId() != "") { $request->setParameter("dataSetDir", $dataSetDirId); $request->setParameter("ei_node_parent_id", $dataSetDirId); } } $this->logger->info("----------------------------------------------------------"); $chronometre = new Chronometre(); $chronometre->lancerChrono("PERFORMANCE CREATION JDD"); try { $content = $this->getController()->getPresentationFor("eidataset", "lightCreateFromXml"); } catch (Exception $exc) { $this->logger->info("--- ERREUR : " . $exc->getMessage() . " ---"); } // Fin mesure $chronometre->arreterEtAfficherChrono(); $this->logger->info("----------------------------------------------------------"); return $this->renderText($content); }
/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param SfGuardUser $value A SfGuardUser object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool(SfGuardUser $obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getId(); } // if key === null self::$instances[$key] = $obj; } }
public function executeAddNewSubscriber(sfWebRequest $request) { $this->minyan = Utils::extractDomainObjectFromRequest($request, 'Minyan', 'minyanId', true); $this->form = new SignupForm(); unset($this->form['password']); if ($request->isMethod('post')) { $this->form->bind($request->getParameter('signup')); if ($this->form->isValid()) { $fields = $this->form->getValues(); $con = Doctrine::getConnectionByTableName('SfGuardUser'); try { $con->beginTransaction(); $this->logMessage("Executing signup for new user for minyan {$this->minyan->getName()}: {$fields['email']}", 'notice'); $sgu = new SfGuardUser(); $sgu->setFirstName($fields['first_name']); $sgu->setLastName($fields['last_name']); $sgu->setUsername($fields['email']); $sgu->setEmailAddress($fields['email']); $sgu->setPhone($fields['phone']); $sgu->setPassword(sfConfig::get('app_temp_password')); $sgu->setIsActive(true); $sgu->save(); $contactMethods = $request->getParameter('contact_method'); foreach ($contactMethods as $name => $method) { $contactMethods[$name] = Utils::toBoolean($method); } $minyanUser = new MinyanUser(); $minyanUser->setMinyanId($this->minyan->getId()); $minyanUser->setUserId($sgu->getId()); $minyanUser->setUsePhone($contactMethods['phone']); $minyanUser->setUseSms($contactMethods['text']); $minyanUser->setUseEmail($contactMethods['email']); $minyanUser->save(); $con->commit(); } catch (Exception $e) { $con->rollback(); $this->logMessage("Problem when signing up user {$fields['email']}: {$e->getMessage()}", 'notice'); throw $e; } MAMUtils::sendInternalEmail("New Make a Minyan User Alert for minyan {$this->minyan->getName()}! - {$sgu->getFullName()}", ""); //send email $options = array(); $options['template'] = 'welcomeToMinyan'; $options['subject'] = 'Welcome!'; $options['minyan'] = $this->minyan; $options['user'] = $sgu; $options['minyanUser'] = $minyanUser; $options['first_name'] = $sgu->getFirstName(); $options['to'] = $sgu->getUsername(); EmailUtils::send($options); $this->logMessage('Welcome email sent to ' . $sgu->getUsername(), 'notice'); $this->getUser()->setFlash('subscribersSuccess', 'Added ' . $sgu->getUsername() . ' successfully!'); echo Utils::ajaxResponse(true, $this->minyan->getId()); return sfView::NONE; } } }
/** * Executes index action * * @param sfRequest $request A request object */ public function executeIndex(sfWebRequest $request) { $this->form = new SignupForm(); if ($request->isMethod('post')) { $this->form->bind($request->getParameter('signup')); if ($this->form->isValid()) { $fields = $this->form->getValues(); $con = Doctrine::getConnectionByTableName('SfGuardUser'); try { $con->beginTransaction(); $this->logMessage("Executing signup for new user: {$fields['email']}", 'notice'); $sgu = new SfGuardUser(); $sgu->setFirstName($fields['first_name']); $sgu->setLastName($fields['last_name']); $sgu->setUsername($fields['email']); $sgu->setEmailAddress($fields['email']); $sgu->setPhone($fields['phone']); $sgu->setPassword($fields['password']); $sgu->setIsActive(true); $sgu->save(); $con->commit(); } catch (Exception $e) { $con->rollback(); $this->logMessage("Problem when signing up user {$fields['email']}: {$e->getMessage()}", 'notice'); throw $e; } MAMUtils::sendInternalEmail("New Make a Minyan User Alert! - {$sgu->getFullName()}, Plan: {$this->plan['name']}", ""); //send email $options = array(); $options['template'] = 'welcome'; $options['subject'] = 'Welcome!'; $options['first_name'] = $sgu->getFirstName(); $options['to'] = $sgu->getUsername(); EmailUtils::send($options); $this->logMessage('Welcome email sent to ' . $sgu->getUsername(), 'notice'); $this->redirect('signup/thanks'); } } }
public function executeRegister() { if ($this->getRequest()->getMethod() != sfRequest::POST) { return sfView::SUCCESS; } $user = new SfGuardUser(); $user->setUsername($this->getRequestParameter('username')); $user->setPassword($this->getRequestParameter('password')); $user->setIsActive(false); $profile = new UserProfile(); $profile->setEmail($this->getRequestParameter('email')); $profile->setFirstName($this->getRequestParameter('first_name')); $profile->setLastName($this->getRequestParameter('last_name')); $profile->setGender($this->getRequestParameter('gender') ? $this->getRequestParameter('gender') : null); $profile->setBirthday($this->getRequestParameter('birthday') ? $this->getRequestParameter('birthday') : null); $user->addUserProfile($profile); $user->save(); $this->getRequest()->setAttribute('email', $profile->getEmail()); $this->getRequest()->setAttribute('full_name', $profile->getFullName()); $this->getRequest()->setAttribute('activation_key', $profile->getConfirmation()); $raw_email = $this->sendEmail('mail', 'register'); $this->logMessage($raw_email, 'debug'); $this->setFlash('info', 'We sent a confirmation email to your email address.'); $this->forward('site', 'message'); }