示例#1
0
 public function executeIndex(sfWebRequest $request)
 {
     // sorting
     if (!$request->getParameter('sort') && !$this->isValidSortColumn($request->getParameter('sort'))) {
         $request->setParameter('sort', 'date');
         $request->setParameter('sort_type', 'desc');
     }
     parent::executeIndex($request);
 }
示例#2
0
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeIndex(sfWebRequest $request)
 {
     opApplicationConfiguration::registerJanRainOpenID();
     require_once 'Auth/OpenID/Server.php';
     require_once 'Auth/OpenID/FileStore.php';
     $url = $this->getController()->genUrl('OpenID/index', true);
     $server = new Auth_OpenID_Server(new Auth_OpenID_FileStore(sfConfig::get('sf_cache_dir')), $url);
     $this->getResponse()->setHttpHeader('X-XRDS-Location', $this->getController()->genUrl('OpenID/signonXrds', true));
     $openIDRequest = $server->decodeRequest();
     if (!$openIDRequest) {
         $_SESSION['request'] = null;
         return sfView::SUCCESS;
     }
     $sregRequest = Auth_OpenID_SRegRequest::fromOpenIDRequest($openIDRequest);
     $axRequest = Auth_OpenID_AX_FetchRequest::fromOpenIDRequest($openIDRequest);
     $this->requestedProfiles = $this->createListOfRequestedProfiles($sregRequest, $axRequest);
     $_SESSION['request'] = serialize($openIDRequest);
     if (!empty($openIDRequest->mode) && in_array($openIDRequest->mode, array('checkid_immediate', 'checkid_setup'))) {
         if ($openIDRequest->idSelect()) {
             if ($openIDRequest->mode === 'checkid_immediate') {
                 $response = $openIDRequest->answer(false);
             } else {
                 $this->getRequest()->setMethod(sfWebRequest::GET);
                 $_SERVER['QUERY_STRING'] = http_build_query($openIDRequest->message->toPostArgs());
                 $this->forwardUnless($this->getUser()->isAuthenticated() && $this->getUser()->getMember(), 'member', 'login');
                 $log = Doctrine::getTable('OpenIDTrustLog')->findByOpenID($openIDRequest->trust_root, $this->getUser()->getMemberId());
                 if ($log && $log->is_permanent) {
                     $request->setParameter('trust', '1');
                     $this->forward('OpenID', 'trust');
                 }
                 $this->info = $openIDRequest;
                 return 'Trust';
             }
         } elseif (!$openIDRequest->identity && !$openIDRequest->idSelect()) {
             $this->forward('@error');
         } elseif ($openIDRequest->immediate) {
             $response = $openIDRequest->answer(false, $url);
         } else {
             $this->forwardUnless($this->getUser()->isAuthenticated() && $this->getUser()->getMember(), 'member', 'login');
             $log = Doctrine::getTable('OpenIDTrustLog')->findByOpenID($openIDRequest->trust_root, $this->getUser()->getMemberId());
             if ($log && $log->is_permanent) {
                 $request->setParameter('trust', '1');
                 $this->forward('OpenID', 'trust');
             }
             $this->info = $openIDRequest;
             return 'Trust';
         }
     } else {
         $response = $server->handleRequest($openIDRequest);
     }
     $response = $server->encodeResponse($response);
     return $this->writeResponse($response);
 }
 /**
  * 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/xml');
     $this->getUser()->signIn($this->user, true);
     /* @var EiTestSet $test_set */
     $test_set = $this->getRoute()->getObject();
     $request->setParameter("ei_test_set_id", $test_set->getId());
     $request->setParameter("project_ref", $test_set->getEiScenario()->getProjectRef());
     $request->setParameter("project_id", $test_set->getEiScenario()->getProjectId());
     $request->setParameter("ei_scenario_id", $test_set->getEiScenario()->getId());
     $content = $this->getController()->getPresentationFor("eitestset", "downloadOracle");
     return $this->renderText($content);
 }
 /**
  * executes an action defined by an ecrypted url parameter bypassing authentication
  * This action must be called with the request parameter 'encrypted_uri'
  * containing the target module/action and optional parameters encrypted
  * using the class 'Encryption'.
  *
  * Example:
  *  Encryption::encode('module=myModule&action=myAction&param1=value1, ...');
  *
  * @param sfWebRequest $request
  * @return
  */
 public function executeIndex(sfWebRequest $request)
 {
     //--------------------------------------------------------------------------
     // make sure required parameter 'encrypted_uri' is provided
     //--------------------------------------------------------------------------
     $this->forward404If(!($encrypted_uri = $request->getParameter('encrypted_uri')));
     //--------------------------------------------------------------------------
     // decrypt parameters
     //  v1: 'action', 'module', 'parameters' & 'sfGuardUserId'
     //  v2: 'uri' & 'sfGuardUserId'
     //--------------------------------------------------------------------------
     $data = Encryption::decryptUri($encrypted_uri);
     //--------------------------------------------------------------------------
     // make sure required 'uri' is provided
     //--------------------------------------------------------------------------
     $this->forward404If(!isset($data['module']) or !isset($data['action']));
     $request->setParameter('module', $data['module']);
     $request->setParameter('action', $data['action']);
     if (is_array($data['parameters'])) {
         foreach ($data['parameters'] as $key => $value) {
             $request->setParameter($key, $value);
         }
     }
     //--------------------------------------------------------------------------
     // handle automatic authentication if turned on, otherwise skip it
     //--------------------------------------------------------------------------
     if ($data['sfGuardUserId'] > 0 and sfConfig::get('app_esUriEncryptionPlugin_authenticate')) {
         //------------------------------------------------------------------------
         // make sure sfGuardPlugin is installed and enabled
         //------------------------------------------------------------------------
         if (!class_exists('sfGuardUser')) {
             throw new sfException('esUriEncryptionPlugin: sfGuardPlugin not found - cannot authenticate.');
         }
         //------------------------------------------------------------------------
         // determine user identified by sfGuardUserId
         //------------------------------------------------------------------------
         if ($user = Doctrine::getTable('sfGuardUser')->find($data['sfGuardUserId'])) {
             $this->getUser()->signin($user);
         }
         if (sfConfig::get('app_esUriEncryptionPlugin_debug')) {
             sfContext::getInstance()->getLogger()->debug('esUriEncryptionPlugin: user logged in, id=' . $data['sfGuardUserId']);
         }
     }
     //--------------------------------------------------------------------------
     // forward to destination action
     //--------------------------------------------------------------------------
     $this->forward($data['module'], $data['action']);
 }
示例#5
0
 /**
  * Executes save action
  *
  * @param sfWebRequest $request A request object
  */
 public function executeSave(sfWebRequest $request)
 {
     $member = $this->getUser()->getMember();
     $isValid = $member->getConfig('paint_is_valid');
     $this->forward404Unless($isValid);
     $member->setConfig('paint_is_valid', false);
     $id = $request->getParameter('id', 0);
     $ccccImage = Doctrine::getTable('CcccImage')->find($id);
     if (!$ccccImage) {
         $ccccImage = new CcccImage();
     }
     $ccccComaId = $ccccImage->getCcccComaId();
     if ($ccccComaId && $ccccImage->getCcccComa()->getCcccImageId() == $ccccImage->getId()) {
         $ccccImage->getPchFile()->delete();
         $newCcccImage = new CcccImage();
         $newCcccImage->setBaseCcccImage($ccccImage);
         $ccccImage =& $newCcccImage;
     }
     $raw = new RawSpainter(base64_decode($member->getConfig('paint_rawdata')));
     $member->setConfig('paint_rawdata', '');
     $ccccImage->saveImageFileFromRawData($raw->getImage());
     $ccccImage->savePchFileFromRawData($raw->getPch());
     $ccccImage->setMember($member);
     $ccccImage->setCcccComaId($ccccComaId);
     $ccccImage->save();
     if ($ccccComaId) {
         $ccccComa = $ccccImage->getCcccComa();
         $ccccComa->setCcccImage($ccccImage);
         $ccccComa->save();
         $request->setParameter('id', $ccccComa->getCcccMangaId());
         $this->forward('ccccManga', 'index');
     }
     $this->forward('ccccImage', 'index');
 }
示例#6
0
 public function checkEiScenario(sfWebRequest $request, EiProjet $ei_project)
 {
     if (($this->ei_scenario_id = $request->getParameter('ei_scenario_id')) != null) {
         //Recherche du scénario en base
         $this->ei_scenario = Doctrine_Core::getTable('EiScenario')->findOneByIdAndProjectIdAndProjectRef($this->ei_scenario_id, $ei_project->getProjectId(), $ei_project->getRefId());
         //Si le scénario n'existe pas , alors on retourne un erreur 404
         if ($this->ei_scenario == null) {
             $message = 'Scénario  introuvable!! l identificateur n\'est pas spécifié';
             $request->setParameter('msg', $message);
             $request->setParameter('back_link', $request->getReferer());
             $this->forward('erreur', 'error404');
         }
     } else {
         $this->forward404('Missing scenario parameters  ...');
     }
 }
 /**
  * Add Holiday
  * @param sfWebRequest $request
  */
 public function execute($request)
 {
     //Keep Menu in Leave/Config
     $request->setParameter('initialActionName', 'viewHolidayList');
     $this->form = new HolidayForm();
     $editId = $request->getParameter('hdnEditId');
     $this->editMode = false;
     // Pass edit mode for teh view
     $this->form->editMode = false;
     // Pass edit mode for form
     if ($editId && $editId != '') {
         $this->form->setDefaultValues($editId);
     }
     if ($editId && $editId != '' || $request->getParameter('hdnEditMode') == 'yes') {
         $this->editMode = true;
         $this->form->editMode = true;
     }
     if ($request->isMethod('post')) {
         $this->form->bind($request->getParameter($this->form->getName()));
         if ($this->form->isValid()) {
             $post = $this->form->getValues();
             /* Save holiday */
             if ($post['id'] != '') {
                 $this->getUser()->setFlash('success', __(TopLevelMessages::UPDATE_SUCCESS));
             } else {
                 $this->getUser()->setFlash('success', __(TopLevelMessages::SAVE_SUCCESS));
             }
             $date = $post['date'];
             $holidayId = $post['id'];
             /* Read the holiday by date */
             $holidayObjectDate = $this->getHolidayService()->readHolidayByDate($date);
             $allowToAdd = true;
             if ($this->editMode) {
                 $holidayObject = $this->getHolidayService()->readHoliday($holidayId);
                 if ($date != $holidayObjectDate->getDate() && $holidayObjectDate->getRecurring()) {
                     $allowToAdd = false;
                 }
             } else {
                 /* Days already added can not be selected to add */
                 if ($date == $holidayObjectDate->getDate() || $holidayObjectDate->getRecurring() == 1) {
                     $allowToAdd = false;
                 }
             }
             /* Error will not return if the date if not in the correct format */
             if (!$allowToAdd && !is_null($date)) {
                 $this->templateMessage = array('WARNING', __('Failed to Save: Date Already Assigned'));
             } else {
                 $holidayObject = $this->getHolidayService()->readHoliday($post['id']);
                 $holidayObject->setDescription($post['description']);
                 $holidayObject->setDate($post['date']);
                 $recurringValue = $post['recurring'] == 'on' ? 1 : 0;
                 $holidayObject->setRecurring($recurringValue);
                 $holidayObject->setLength($post['length']);
                 $this->getHolidayService()->saveHoliday($holidayObject);
                 $this->redirect('leave/viewHolidayList');
             }
         }
     }
 }
 public function executeList(sfWebRequest $request)
 {
     if (!$request->hasParameter('model')) {
         throw new sfException('sfDoctrineFBAutocompleteJson : Model is not defined');
     }
     $this->items = Doctrine_Core::getTable($request->getParameter('model'))->findAll();
     $this->setLayout(false);
     $request->setParameter('sf_format', 'json');
 }
 /**
  * Action permettant de générer un nouveau token pour l'utilisateur courant.
  *
  * @param sfWebRequest $request
  */
 public function execute($request)
 {
     $this->setLayout(false);
     $this->getResponse()->setContentType('application/json');
     $request->setParameter("ei_user", $this->user);
     /** @var EiUser $user */
     $user = $this->getUser()->getGuardUser()->getEiUser();
     $token = $user->getTokenApi();
     return $this->renderText(json_encode(array("token" => $token)));
 }
 /**
  * Action permettant de générer un nouveau token pour l'utilisateur courant.
  *
  * @param sfWebRequest $request
  */
 public function execute($request)
 {
     $this->setLayout(false);
     $this->getResponse()->setContentType('application/json');
     $request->setParameter("ei_user", $this->user);
     /** @var EiUserTable $table */
     $table = Doctrine_Core::getTable('EiUser');
     $token = $table::getInstance()->generateToken($this->getUser()->getGuardUser()->getEiUser());
     return $this->renderText(json_encode(array("token" => $token)));
 }
 /**
  * Action permettant de créer un data set.
  *
  * @param sfWebRequest $request
  */
 public function execute($request)
 {
     $this->setLayout(false);
     $this->logger = sfContext::getInstance()->getLogger();
     // On détermine le type de contenu retourné.
     $this->getResponse()->setContentType('application/xml');
     $this->getUser()->signIn($this->user, true);
     /** @var EiProfilTable $tableProfil */
     $tableProfil = Doctrine_Core::getTable("EiProfil");
     /* @var EiDataSet $data_set */
     $data_set = $this->getRoute()->getObject();
     /** @var EiScenario $scenario */
     $scenario = Doctrine_Core::getTable("EiDataSet")->getDataSetScenario($data_set);
     /** @var EiProfil $profil */
     $profil = $tableProfil->findOneByProfileRefAndProfileId($request->getParameter("profil_ref"), $request->getParameter("profil_id"));
     $request->setParameter("ei_test_set_id", $data_set->getId());
     $request->setParameter("project_ref", $scenario->getProjectRef());
     $request->setParameter("project_id", $scenario->getProjectId());
     $request->setParameter("profile_ref", $profil->getProfileRef());
     $request->setParameter("profile_id", $profil->getProfileId());
     $request->setParameter("profile_name", $profil->getName());
     $this->logger->info("----------------------------------------------------------");
     $chronometre = new Chronometre();
     $chronometre->lancerChrono("PERFORMANCE RECUPERATION JDD");
     $content = $this->getController()->getPresentationFor("eidataset", "download");
     // Fin mesure
     $chronometre->arreterEtAfficherChrono();
     $this->logger->info("----------------------------------------------------------");
     return $this->renderText($content);
 }
示例#12
0
 public function executeUpdate(sfWebRequest $request)
 {
     $this->forward404Unless($request->isMethod('post'));
     $invoice_params = $request->getParameter('invoice');
     $request->setParameter('id', $invoice_params['id']);
     $invoice = $this->getRecurringInvoice($request);
     $this->invoiceForm = new RecurringInvoiceForm($invoice, array('culture' => $this->culture));
     $this->processForm($request, $this->invoiceForm);
     $i18n = $this->getContext()->getI18N();
     $this->title = $i18n->__('Edit Invoice');
     $this->action = 'update';
     $this->setTemplate('edit');
 }
示例#13
0
 public function executeUpdate(sfWebRequest $request)
 {
     $product_params = $request->getParameter('product');
     $request->setParameter('id', $product_params['id']);
     $this->forward404Unless($request->isMethod('post'));
     $product = $this->getProduct($request);
     $this->productForm = new ProductForm($product, array('culture' => $this->culture));
     $this->processForm($request, $this->productForm);
     $i18n = $this->getContext()->getI18N();
     $this->title = $i18n->__('Edit Product');
     $this->action = 'update';
     $this->setTemplate('edit');
 }
 public function executePost(sfWebRequest $request)
 {
     $form = new opTweetForm();
     $form->bind($request->getParameter('tweet'));
     if ($form->isValid()) {
         $activity = $form->save();
         if ($form->getValue('twitter')) {
             $request->setParameter('id', $activity->id);
             $this->forward('twitter', 'login');
         }
     }
     $this->redirect('@homepage');
 }
示例#15
0
 public function executeUpdate(sfWebRequest $request)
 {
     $estimate_params = $request->getParameter('invoice');
     $request->setParameter('id', $estimate_params['id']);
     $this->forward404Unless($request->isMethod('post'));
     $estimate = $this->getEstimate($request);
     $this->db_draft = $estimate->getDraft();
     $this->estimateForm = new EstimateForm($estimate, array('culture' => $this->culture));
     $this->processForm($request, $this->estimateForm);
     $i18n = $this->getContext()->getI18N();
     $this->title = $i18n->__('Edit Estimate');
     $this->action = 'update';
     $this->setTemplate('edit');
 }
示例#16
0
 public function executeIndex(sfWebRequest $request)
 {
     // searching
     if ($request->hasParameter('search')) {
         $this->setSearch($request->getParameter('search'));
         $request->setParameter('page', 1);
     }
     // filtering
     if ($request->getParameter('filters')) {
         $this->setFilters($request->getParameter('filters'));
     }
     // sorting
     if ($request->getParameter('sort')) {
         $this->setSort(array($request->getParameter('sort'), $request->getParameter('sort_type')));
     }
     //maxPerPage
     if ($request->getParameter('maxPerPage')) {
         $this->setMaxPerPage($request->getParameter('maxPerPage'));
         $this->setPage(1);
     }
     // pager
     if ($request->getParameter('page')) {
         $this->setPage($request->getParameter('page'));
     }
     $this->pager = $this->getPager();
     $this->sort = $this->getSort();
     if ($request->isXmlHttpRequest()) {
         $partialFilter = null;
         sfConfig::set('sf_web_debug', false);
         $this->setLayout(false);
         sfProjectConfiguration::getActive()->loadHelpers(array('I18N', 'Date'));
         if ($request->hasParameter('search')) {
             $partialSearch = $this->getPartial('visite/search', array('configuration' => $this->configuration));
         }
         if ($request->hasParameter('_reset')) {
             $partialFilter = $this->getPartial('visite/filters', array('form' => $this->filters, 'configuration' => $this->configuration));
         }
         $partialList = $this->getPartial('visite/list', array('pager' => $this->pager, 'sort' => $this->sort, 'helper' => $this->helper));
         if (isset($partialSearch)) {
             $partialList .= '#__filter__#' . $partialSearch;
         }
         if (isset($partialFilter)) {
             $partialList .= '#__filter__#' . $partialFilter;
         }
         return $this->renderText($partialList);
     }
     return sfView::SUCCESS;
 }
示例#17
0
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeIndex(sfWebRequest $request)
 {
     $this->structure = Doctrine::getTable('Structure')->createQuery('a')->fetchOne();
     sfContext::getInstance()->getUser()->setAttribute('relativeUrlRoot', $request->getRelativeUrlRoot());
     if ($request->isMethod(sfRequest::POST)) {
         /*$context=sfContext::getInstance();*/
         $login = $this->getRequestParameter('login');
         $password = $this->getRequestParameter('password');
         $usersAuth = new usersAuth();
         $checked = $usersAuth->verifyAuth($login, $password);
         //if the authentification is done
         if ($checked == 1 || $checked == 2) {
             ParametersConfiguration::setUserPrefix(sfContext::getInstance()->getUser()->getAttribute('login'));
             $loginDisplay = ParametersConfiguration::getDefault('default_follow_moderator');
             /*According to the 'default_follow_moderator' parameter, the login will appear in logs or not*/
             if ($loginDisplay == 1) {
                 $this->getContext()->get('Kernel')->addLog("info", "Authentification success for the login \"" . $login . "\".");
             } else {
                 $this->getContext()->get('Kernel')->addLog("info", "Authentification success.");
             }
             //Get the preferred culture of the user, based on those which are installed:
             $culture = ParametersConfiguration::getDefault('default_language');
             $this->getUser()->setCulture($culture);
             $request->setParameter('sf_culture', $culture);
             $this->redirect('@localized_homepage');
         } else {
             if ($checked === 0) {
                 // this delay complicates a brute force attack
                 sleep(1);
                 $this->getUser()->setFlash('error', 'Login or password incorrect. Please try again.', true);
                 $this->getContext()->get('Kernel')->addLog("error", "Authentification denied for the login \"" . $login . "\".");
             } else {
                 if ($checked === -2) {
                     $this->getUser()->setFlash('error', 'Login and password are correct but your account is locked.', true);
                     $this->getContext()->get('Kernel')->addLog("error", "Authentification denied for the login \"" . $login . "\". Account is locked.");
                 } else {
                     //The error message is copied in the error log
                     $this->getContext()->get('Kernel')->addLog("error", "Connection to the database failed:\"" . $checked . "\".");
                     $this->getUser()->setFlash('error', 'Impossible authentification. Check the connection to the database.', true);
                 }
             }
         }
     } else {
         $this->login = null;
         $this->password = null;
     }
 }
 public function executePost(sfWebRequest $request)
 {
     $room = $this->getRoute()->getObject();
     $member_id = $this->getUser()->getMemberId();
     $this->forward404Unless($room->isWritable() && $room->isActive($member_id));
     $chat = new ChatContent();
     $chat->ChatRoom = $room;
     $chat->member_id = $member_id;
     $this->form = new ChatContentForm($chat);
     $this->form->bindAndSave($request->getParameter('chat_content'));
     if ($request->isXmlHttpRequest()) {
         $request->setParameter('view', 'chat');
         $this->forward('chat', 'show');
     } else {
         $this->forward('chat', 'heartbeat');
     }
 }
示例#19
0
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeIndex(sfWebRequest $request)
 {
     $lUrl = $request->getParameter("url", null);
     $lUrl = UrlUtils::narmalizeUrlScheme($lUrl);
     $request->setParameter("url", $lUrl);
     $this->url = $lUrl;
     $this->error = $this->pError = null;
     if (!$lUrl) {
         return $this->setTemplate("share");
     }
     if ($request->getMethod() == "POST") {
         $lParams = $request->getParameter('like');
         $lParams['u_id'] = $this->getUser()->getUserId();
         $lActivity = new Documents\YiidActivity();
         $lActivity->fromArray($lParams);
         // try to save activity
         try {
             $lActivity->save();
             $this->redirect("@deal?url=" . urlencode($lUrl));
         } catch (Exception $e) {
             // send error on exception
             $this->getLogger()->err($e->getMessage());
             $this->pError = $e->getMessage();
         }
     }
     $dm = MongoManager::getDM();
     $this->pActivity = $dm->getRepository("Documents\\YiidActivity")->findOneBy(array("url" => $lUrl, "u_id" => intval($this->getUser()->getId()), "d_id" => array('$exists' => false)));
     // if user has already liked
     if ($this->pActivity) {
         $this->redirect("@deal?url=" . urlencode($lUrl));
     }
     $lYiidMeta = new YiidMeta();
     $lYiidMeta->fromParams($request->getParameterHolder());
     $this->pYiidMeta = SocialObjectParser::fetch($request->getParameter("url"), $lYiidMeta);
     if ($this->pYiidMeta === false) {
         $this->error = "the url '{$lUrl}' is not well formed!";
         return $this->setTemplate("share");
     }
     $domainProfile = DomainProfileTable::getInstance()->retrieveByUrl($lUrl);
     $this->trackingUrl = null;
     if ($domainProfile) {
         $this->trackingUrl = $domainProfile->getTrackingUrl();
     }
     $this->getResponse()->setSlot('js_document_ready', $this->getPartial('like/js_init_like.js', array('pImgCount' => count($this->pYiidMeta->getImages()), 'pUrl' => $request->getParameter("url"))));
 }
示例#20
0
 /**
  * Search Parameters
  */
 public function updateSearch(sfWebRequest $request)
 {
     $changed = false;
     $ns = $request->getParameter('searchNamespace');
     // if reset, remove all search parameters from request and user
     if ($request->getParameter('reset')) {
         $request->getParameterHolder()->remove('search');
         $this->getAttributeHolder()->remove('search', null, $ns);
         $changed = true;
     } else {
         // check if some parameters have changed, and setting them into user
         $params = array('search', 'sort');
         foreach ($params as $param) {
             $value = $request->getParameter($param, null);
             if ($value && $this->getAttribute($param, null, $ns) != $value) {
                 $this->setAttribute($param, $value, $ns);
                 $changed = true;
             }
         }
     }
     // If something has changed we reset page to 1
     if ($changed) {
         $request->setParameter('page', 1);
     }
     // if page comes as parameter insert as attribute
     if ($page = $request->getParameter('page')) {
         $this->setAttribute('page', $page, $ns);
     }
     if ($ns == 'invoices') {
         $search = $this->getSearchSettings($this->getAttribute('search', null, $ns));
     } else {
         $search = $this->getAttribute('search', null, $ns);
     }
     // this is to put the customer name in the autocomplete field
     if (isset($search['customer_id']) && $search['customer_id'] > 0) {
         if ($cust = Doctrine::getTable('Customer')->find($search['customer_id'])) {
             $search['customer_name'] = $cust->getName();
         } else {
             unset($search['customer_name']);
             unset($search['customer_id']);
         }
     }
     $this->setAttribute('search', $search, $ns);
 }
示例#21
0
 public function executeForgetPassword(sfWebRequest $request)
 {
     $this->form = new forgetPasswordForm();
     if ($request->isMethod('post')) {
         try {
             $this->form->bind($request->getParameter('forget_password'));
             if (!$this->form->isValid()) {
                 throw new Exception('Preencha todos os campos');
             }
             $usuario = Doctrine::getTable('Usuario')->createQuery('u')->where('u.email = ?', $this->form->getValue('email'))->andWhere('u.matricula = ?', $this->form->getValue('matricula'))->fetchOne();
             if ($usuario == false) {
                 throw new Exception('E-mail/Matricula inválido');
             }
             $this->sendPassword($usuario);
             $request->setParameter('forget_password', null);
             $this->setTemplate('sent');
         } catch (Exception $e) {
             $this->getUser()->setFlash('error', $e->getMessage());
         }
     }
 }
 /**
  * Action permettant d'indiquer le statut d'un robot et de retourner le cas échéant quelque chose à faire.
  *
  * @param sfWebRequest $request
  */
 public function execute($request)
 {
     try {
         $this->setLayout(false);
         $this->getResponse()->setContentType('application/json');
         $response = array();
         $statut = $request->getParameter("status");
         $device_identitifier = $request->getParameter("mac");
         // Récupération de la table gérant les exécutions.
         /** @var EiExecutionStackTable $tableExecutionStack */
         $tableExecutionStack = Doctrine_Core::getTable("EiExecutionStack");
         // Récupération de la connexion.
         $conn = Doctrine_Manager::connection();
         // Récupération du gestionnaire de vérouillage.
         $lockingManager = new Doctrine_Locking_Manager_Pessimistic($conn);
         if ($device_identitifier != null && $statut != null && $statut == 1) {
             $device = Doctrine_Core::getTable("EiDevice")->findOneBy('device_identifier', $device_identitifier);
             $device_id = intval($device->getId());
             /* On arrête les exécutions précédentes */
             $tableExecutionStack->abortPreviousProcessingExecutions($device_id);
             /* On recherche la première tâche de la liste assignée à notre device */
             $firstElement = $tableExecutionStack->getFirstElementToExecuteForDevice($device_id);
             if ($firstElement == null) {
                 $devicedrivers = $device->getEiDeviceDriver();
                 /* S'il n'en existe pas, on va rechercher une tâche parmi celles non assignées à un device et sur un couple driver / browser que le device possède  */
                 foreach ($devicedrivers as $devicedriver) {
                     $driverBrowsers = $devicedriver->getEiDriverBrowser();
                     foreach ($driverBrowsers as $driverBrowser) {
                         $firstElement = $tableExecutionStack->getFirstElementToExecuteForDriversAndBrowsers($devicedriver['driver_type_id'], $driverBrowser['browser_type_id'], $device_id);
                         if ($firstElement != null) {
                             /* On arrête dès que l'on trouve la première tâche remplissant les conditions décrites précédemment */
                             /* On met ici à jour le device_id de l'exécution */
                             $tableExecutionStack->updateDeviceId($firstElement->getId(), $device_id);
                             break;
                         }
                     }
                 }
             }
             if ($firstElement != null && !is_bool($firstElement)) {
                 $lockingManager->releaseAgedLocks(30);
                 $gotLock = $lockingManager->getLock($firstElement, "robot");
                 if ($gotLock) {
                     /** @var EiProfil $profile */
                     $profile = Doctrine_Core::getTable("EiProfil")->findOneByProjectRefAndProjectIdAndProfileRefAndProfileId($firstElement->getProjectRef(), $firstElement->getProjectId(), $firstElement->getProfileRef(), $firstElement->getProfileId());
                     /** @var EiProjet $project */
                     $project = Doctrine_Core::getTable("EiProjet")->findOneByRefIdAndProjectId($firstElement->getProjectRef(), $firstElement->getProjectId());
                     // Récupération de la première demande non-traitée.
                     $firstElement->setStatus(StatusConst::STATUS_PROCESSING_DB);
                     $firstElement->setUpdatedAt(date("Y-m-d H:i:s"));
                     $response = array("profile_ref" => intval($firstElement->getProfileRef()), "profile_id" => intval($firstElement->getProfileId()), "profile_name" => $profile->getName(), "project_ref" => intval($firstElement->getProjectRef()), "project_id" => intval($firstElement->getProjectId()), "project_name" => $project->getName(), "token" => $firstElement->getSfGuardUser()->getEiUser()->getTokenApi());
                     if ($firstElement->isCampaign()) {
                         $response["type"] = "campaign";
                         //***********************************************//
                         //**********     GENERER EXECUTION     **********//
                         //***********************************************//
                         $response["campaign_id"] = intval($firstElement->getEiCampaignId());
                         $response["start_pos"] = intval($firstElement->getStartPos());
                         $response["end_pos"] = intval($firstElement->getEndPos());
                         // Si des positions de début/fin ont été fixées, ont les précisent sinon on prend celles par défaut.
                         $request->setParameter("projet", $project->getName());
                         $request->setParameter("profile_name", $profile->getName());
                         $request->setParameter("profil", $profile->getName());
                         $request->setParameter("campagne", $firstElement->getEiCampaignId());
                         $request->setParameter("position_debut", $firstElement->getStartPos());
                         $request->setParameter("position_fin", $firstElement->getEndPos());
                         $request->setParameter("onError", $firstElement->getEiCampaign()->getOnError());
                         $request->setParameter("internal", true);
                         // Authentification de l'utilisateur.
                         $this->getUser()->signIn($firstElement->getSfGuardUser(), true);
                         $this->getController()->getPresentationFor("eicampaignexecution", "create");
                         $firstElement->setEiCampaignExecutionId($this->getUser()->getAttribute("executionIdForRobot"));
                         //************************************************//
                         //**********     AJOUT EXECUTION ID     **********//
                         //************************************************//
                         $response["execution_id"] = intval($firstElement->getEiCampaignExecutionId());
                     } else {
                         $response["type"] = "scenario";
                         $response["scenario_name"] = $firstElement->getEiScenario()->getNomScenario();
                         $response["scenario_id"] = intval($firstElement->getEiScenarioId());
                         $response["jdd_id"] = $firstElement->getEiDataSetId() == "" ? 0 : intval($firstElement->getEiDataSetId());
                     }
                     $driver = Doctrine_Core::getTable("EiDriverType")->findOneBy("id", $firstElement->getDriverId());
                     $browser = Doctrine_Core::getTable("EiBrowserType")->findOneBy("id", $firstElement->getBrowserId());
                     $response["driver_type"] = $driver['hidden_name'];
                     $response["browser_type"] = $browser['hidden_name'];
                     $firstElement->save($conn);
                 } else {
                     $response["error"] = "An error occurred during processing.";
                 }
             } else {
                 $response["error"] = "Nothing to execute.";
             }
         } else {
             $response["error"] = "Invalid parameters or robot busy.";
         }
     } catch (Exception $ex) {
         $response["error"] = "An error occurred during processing: " . $ex->getMessage();
         $response["success"] = false;
     }
     return $this->renderText(json_encode($response));
 }
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
 public function executeIndex(sfWebRequest $request)
 {
     $this->form = new ReserveDriverForm();
     $b = new sfWebBrowser();
     $now = strtotime('+15 minute');
     $depart_date = array('year' => date('Y', $now), 'month' => date('n', $now), 'day' => date('j', $now));
     $depart_time = array('hour' => date('G', $now), 'minute' => (int) date('i', $now));
     $b->post(sfConfig::get('sf_takutomo_get_profile_url'), array('id' => $this->getRequestParameter('driver_id')));
     if ((int) $xml->status->code >= 1000) {
         $this->form->getErrorSchema()->addError(new sfValidatorError(new sfValidatorPass(), (string) $xml->status->description));
     } else {
         //xmlを連想配列に変換
         $options = array('complexType' => 'array');
         $Unserializer = new XML_Unserializer($options);
         $status = $Unserializer->unserialize($b->getResponseText());
         $this->member = $Unserializer->getUnserializedData();
     }
     if ($request->isMethod('get')) {
         $mixi = new MixiAppMobileApi();
         $persistence = $mixi->get(sfConfig::get('sf_opensocial_persistence_api'));
         $mixi_persistence = $persistence->entry->{'mixi.jp:' . MixiAppMobileApi::$ownerId};
         $this->form->setDefault('to_address', $mixi_persistence->to_address);
         $this->form->setDefault('to_lon', $mixi_persistence->to_lon);
         $this->form->setDefault('to_lat', $mixi_persistence->to_lat);
         $this->form->setDefault('from_address', $mixi_persistence->from_address);
         $this->form->setDefault('from_lon', $mixi_persistence->from_lon);
         $this->form->setDefault('from_lat', $mixi_persistence->from_lat);
         $this->form->setDefault('depart_date', $depart_date['year'] . sprintf('%02d', $depart_date['month']) . $depart_date['day']);
         $this->form->setDefault('depart_time', $depart_time['hour'] . sprintf('%02d', $depart_time['minute']));
         $this->form->setDefault('driver_m_id', $request->getParameter('driver_id'));
         $this->form->setDefault('phone', $request->getParameter('phone'));
         $request->setParameter('from_address', $mixi_persistence->from_address);
         $request->setParameter('to_address', $mixi_persistence->to_address);
         $request->setParameter('depart_date', $depart_date['year'] . sprintf('%02d', $depart_date['month']) . $depart_date['day']);
         $request->setParameter('depart_time', $depart_time['hour'] . sprintf('%02d', $depart_time['minute']));
     } else {
         if ($request->isMethod('post')) {
             $this->form->bind($request->getParameterHolder()->getAll());
             if ($this->form->isValid()) {
                 $b->post(sfConfig::get('sf_takutomo_reserve_driver_url'), array('guid' => 'DEBUG,sample_member_001', 'email' => $this->getUser()->getEmail(), 'password' => $this->getUser()->getPassword(), 'from_address' => $this->getRequestParameter('from_address'), 'from_lat' => $this->getRequestParameter('from_lat'), 'from_lon' => $this->getRequestParameter('from_lon'), 'to_address' => $this->getRequestParameter('to_address'), 'to_lat' => $this->getRequestParameter('to_lat'), 'to_lon' => $this->getRequestParameter('to_lon'), 'depart_date' => $this->getRequestParameter('depart_date'), 'depart_hour' => substr($this->getRequestParameter('depart_time'), 0, 2), 'depart_min' => substr($this->getRequestParameter('depart_time'), 2, 2), 'driver_m_id' => $request->getParameter('driver_m_id'), 'phone' => $request->getParameter('phone')));
                 $xml = new SimpleXMLElement($b->getResponseText());
                 //print $b->getResponseText();
                 //print((string)$xml->status->code);
                 if ((int) $xml->status->code >= 1000) {
                     $this->form->getErrorSchema()->addError(new sfValidatorError(new sfValidatorPass(), (string) $xml->status->description));
                 } else {
                     //検索条件をsessionに格納
                     $this->getUser()->setToAddress($this->getRequestParameter('to_address'));
                     $this->getUser()->setToLon($this->getRequestParameter('to_lon'));
                     $this->getUser()->setToLat($this->getRequestParameter('to_lat'));
                     $this->getUser()->setFromAddress($this->getRequestParameter('from_address'));
                     $this->getUser()->setFromLon($this->getRequestParameter('from_lon'));
                     $this->getUser()->setFromLat($this->getRequestParameter('from_lat'));
                     $this->setTemplate('submit');
                 }
                 $this->display_description = (string) $xml->status->description;
                 $this->display_phone = (string) $xml->taxi_data->phone;
             }
         }
     }
 }
 /**
  * view Holiday list
  * @param sfWebRequest $request
  */
 public function execute($request)
 {
     //Keep Menu in Leave/Config
     $request->setParameter('initialActionName', 'viewHolidayList');
     $this->searchForm = $this->getSearchForm();
     $dateRange = $this->getLeavePeriodService()->getCalenderYearByDate(time());
     $startDate = $dateRange[0];
     $endDate = $dateRange[1];
     if ($request->isMethod('post')) {
         $this->searchForm->bind($request->getParameter($this->searchForm->getName()));
         if ($this->searchForm->isValid()) {
             $values = $this->searchForm->getValues();
             $startDate = $values['calFromDate'];
             $endDate = $values['calToDate'];
         }
     }
     $this->daysLenthList = WorkWeek::getDaysLengthList();
     $this->yesNoList = WorkWeek::getYesNoList();
     $this->holidayList = $this->getHolidayService()->searchHolidays($startDate, $endDate);
     $this->setListComponent($this->holidayList);
     $message = $this->getUser()->getFlash('templateMessage');
     $this->messageType = isset($message[0]) ? strtolower($message[0]) : "";
     $this->message = isset($message[1]) ? $message[1] : "";
     if ($this->getUser()->hasFlash('templateMessage')) {
         $this->templateMessage = $this->getUser()->getFlash('templateMessage');
         $this->getUser()->setFlash('templateMessage', array());
     }
 }
示例#25
0
 /**
  * DOCUMENT ME
  * @param sfWebRequest $request
  * @return mixed
  */
 public function executeSettings(sfWebRequest $request)
 {
     $this->lockTree();
     $new = $request->getParameter('new');
     $this->parent = null;
     if ($new) {
         $this->page = new aPage();
         $this->parent = $this->retrievePageForEditingBySlugParameter('parent', 'manage');
         $event = new sfEvent($this->parent, 'a.filterNewPage', array());
         $this->dispatcher->filter($event, $this->page);
         $this->page = $event->getReturnValue();
     } else {
         if ($request->hasParameter('settings')) {
             $settings = $request->getParameter('settings');
             $this->page = $this->retrievePageForEditingById($settings['id']);
         } else {
             $this->page = $this->retrievePageForEditingByIdParameter();
         }
     }
     // get the form and page tags
     $this->stem = $this->page->isNew() ? 'a-create-page' : 'a-page-settings';
     $this->form = new aPageSettingsForm($this->page, $this->parent);
     $event = new sfEvent($this->page, 'a.filterPageSettingsForm', array('parent' => $this->parent));
     $this->dispatcher->filter($event, $this->form);
     $this->form = $event->getReturnValue();
     $mainFormValid = false;
     $engine = $this->page->engine;
     if ($request->hasParameter('settings')) {
         $settings = $request->getParameter('settings');
         if (isset($settings['joinedtemplate'])) {
             list($engine, $template) = preg_split('/:/', $settings['joinedtemplate']);
             if ($engine === 'a') {
                 $engine = '';
             }
         }
         $this->form->bind($settings);
         if ($this->form->isValid()) {
             $mainFormValid = true;
         }
     }
     // Don't look at $this->page->engine which may have just changed. Instead look
     // at what was actually submitted and validated as the new engine name
     if ($engine) {
         $engineFormClass = $engine . 'EngineForm';
         if (class_exists($engineFormClass)) {
             // Used for the initial render. We also ajax re-render this bit when they pick a
             // different engine from the dropdown, see below
             $this->engineForm = new $engineFormClass($this->page);
             $this->engineSettingsPartial = $engine . '/settings';
         }
     }
     if ($mainFormValid && !isset($this->engineForm)) {
         $this->form->save();
         $this->page->requestSearchUpdate();
         // $pathComponent = aTools::slugify($this->form->getValue('title'), false);
         //
         // $base = $parent->getSlug();
         // if ($base === '/')
         // {
         //   $base = '';
         // }
         // $slug = "$base/$pathComponent";
         // $page = new aPage();
         // // Allow both the old pkContextCMS name and a more intuitive name for this option
         //
         // $page->setSlug($slug);
         // $existingPage = aPageTable::retrieveBySlug($slug);
         $this->unlockTree();
         return 'Redirect';
     }
     if ($request->hasParameter('enginesettings') && isset($this->engineForm)) {
         // If it's a new page we need the page id so we can save the engine's setting
         $request->setParameter("enginesettings[pageid]", $this->page->id);
         $this->engineForm->bind($request->getParameter("enginesettings"));
         if ($this->engineForm->isValid()) {
             if ($mainFormValid) {
                 // Yes, this does save the same object twice in some cases, but Symfony
                 // embedded forms are an unreliable alternative with many issues and
                 // no proper documentation as yet
                 $this->form->save();
                 if ($new) {
                     // If the page was new, we won't be able to save the
                     // engine form if it's a conventional subclass of aPageForm;
                     // they don't like being saved consecutively for the
                     // same new object. Make a new form and bind it to exactly
                     // the same data
                     $this->engineForm = new $engineFormClass($this->page);
                     $this->engineForm->bind($request->getParameter("enginesettings"));
                     $this->forward404Unless($this->engineForm->isValid());
                 }
                 $this->engineForm->save();
                 $this->page->requestSearchUpdate();
                 $this->unlockTree();
                 return 'Redirect';
             }
         }
     }
     // The slug stem is what we try to append the title to when creating a new slug
     if ($new) {
         // TODO: make this UTF8-aware but not no-UTF8-support-hostile, etc.
         $this->slugStem = preg_replace('/\\/$/', '', $this->parent->slug);
     } else {
         if (preg_match('/^(.*?)\\/[^\\/]*$/', $this->page->slug, $matches)) {
             $this->slugStem = $matches[1];
         } else {
             $this->slugStem = $this->page->slug;
         }
     }
     $this->unlockTree();
 }
示例#26
0
 public function executeGet_url_detail(sfWebRequest $request)
 {
     $selector = $request->getParameter("date-selector");
     switch ($selector) {
         case "now":
         case "yesterday":
             $request->setParameter("date-to", date("Y-m-d", strtotime($selector)));
             break;
         case "7":
         case "30":
             $request->setParameter("date-to", date("Y-m-d", strtotime("yesterday")));
             $request->setParameter("date-from", date("Y-m-d", strtotime($selector . " days ago")));
             break;
     }
     if ($request->getParameter("date-from")) {
         $this->forward('analytics', 'get_url_detail_by_range');
     } else {
         $this->forward('analytics', 'get_url_detail_by_day');
     }
 }
 /**
  * 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);
 }
示例#28
0
 public function executeWorst(sfWebRequest $request)
 {
     $this->pager = $this->getPager(Doctrine::getTable('Fortune')->getWorstQuery());
     $request->setParameter('section', 'worst');
     $this->setTemplate('index');
 }
 public function render($name, $value = null, $attributes = array(), $errors = array())
 {
     $class = array('class' => '');
     if (isset($attributes['class'])) {
         $class = array_merge($class, $attributes);
         $attributes['class'] .= ' hidden';
     }
     $class = ' ' . $class['class'];
     $values = array_merge(array('text' => '', 'is_empty' => false), is_array($value) ? $value : array());
     $obj_name = $this->getName($value);
     if ($this->getOption('default_name')) {
         $obj_name = $this->getOption('default_name');
     }
     $input = parent::render($name, $value, $attributes, $errors);
     if (strlen($this->getOption('button_class')) > 0) {
         $class .= ' ' . $this->getOption('button_class');
     }
     if ($this->getOption('button_is_hidden') && $value == 0) {
         $class .= ' hidden';
     }
     $input .= '<div title="' . $this->getOption('box_title') . '" id="' . $this->generateId($name) . '_button" class="ref_name' . $class . '">';
     $in_text = '<span class="on">' . __('Choose !') . '</span>';
     $url_params = '';
     if (count($this->getOption('url_params')) != 0) {
         $url_params = '?';
         foreach ($this->getOption('url_params') as $k => $v) {
             $url_params .= urlencode($k) . '=' . urlencode($v);
         }
     }
     $partial_url_params = '';
     if (count($this->getOption('partial_url_params')) != 0) {
         $partial_url_params = '?';
         foreach ($this->getOption('partial_url_params') as $k => $v) {
             $partial_url_params .= urlencode($k) . '=' . urlencode($v);
         }
     }
     $hidden = ' hidden';
     $json_splited_values = array();
     $rendered_partial = '';
     if (!empty($value)) {
         if (is_int($value) > 0) {
             $json_splited_values[] = array("id" => $value);
             $hidden = '';
         } else {
             $splited_values = preg_split('/[,]/', $value);
             if (count($splited_values) > 0) {
                 $hidden = '';
                 foreach ($splited_values as $split_val) {
                     if (intval($split_val) > 0) {
                         $json_splited_values[] = array("id" => $split_val);
                     }
                 }
             }
         }
     }
     if (count($json_splited_values) > 0) {
         try {
             $context = sfContext::getInstance();
             $partial_request = new sfWebRequest($context->getEventDispatcher());
             $partial_request->setMethod('POST');
             $partial_request->setParameter('field_id', $this->generateId($name));
             $partial_request->setParameter('row_data', $json_splited_values);
             $partial_request->setParameter('from_db', '1');
             $partial_request->setParameter('catalogue', $this->getOption('model'));
             $partial_controler = new sfFrontWebController($context);
             $partial_controler_action = $partial_controler->getAction($this->getOption('partial_controler'), $this->getOption('partial_action'));
             $rendered_partial = $partial_controler_action->execute($partial_request);
         } catch (Exception $e) {
             $hidden = ' hidden';
             $rendered_partial = '';
         }
     }
     $input .= '<a href="' . url_for($this->getOption('link_url')) . $url_params . '" class="but_text_multiple">' . $in_text . '</a>';
     $input .= '</div>';
     $input .= '<div id="' . $this->generateId($name) . '_result_table" class="results_container but_ref_multiple' . $hidden . '">
              <table class="results">
                <thead>
                  <tr>
                    <th>' . __('Name') . '</th>
                    <th>' . __('Level') . '</th>
                    <th></th>
                  </tr>
                </thead>
                <tbody>';
     $input .= $rendered_partial;
     $input .= '     </tbody>
              </table>
            </div>
           ';
     $input .= '<script  type="text/javascript">
              $(document).ready(function () {
                $("#' . $this->generateId($name) . '_button a.but_text_multiple").button_ref_multiple({
                  q_tip_text : "Choose a ' . $this->getLabel() . '",
                  update_row_fct: $.fn.button_ref_multiple.addEntry,
                  ids_list_target_input_id: "#' . $this->generateId($name) . '",
                  names_list_target_table_id: "#' . $this->generateId($name) . '_result_table",
                  partial_url:"' . url_for($this->getOption('partial_url')) . $partial_url_params . '",
                  attached_field_id:"' . $this->generateId($name) . '"
                });';
     $on_change_attached_to_id = $this->getOption('on_change_attached_to_id');
     $on_change_url_for_widget_renew = $this->getOption('on_change_url_for_widget_renew');
     if (!empty($on_change_attached_to_id) && !empty($on_change_url_for_widget_renew)) {
         $input .= '
              $("#' . $this->getOption('on_change_attached_to_id') . '").off("change").on(
                  "change",
                  {
                      control_to_replace:"' . $this->generateId($name) . '",
                      replacement_url:"' . url_for($this->getOption('on_change_url_for_widget_renew')) . '",
                      replacement_url_name_param:"' . $this->getOption('on_change_url_for_widget_renew_params', '') . '",
                      widget_button_ref_multiple_refresh:1
                  },
                  $.fn.button_ref_multiple.replaceControl
              );';
     }
     $input .= '  });
            </script>';
     return $input;
 }
示例#30
0
 /**
  *
  * @param $type_of_imputation
  * @param $request
  * @param $imputation_parameters
  * @param $mop_ids
  * @param $account_ids
  * @param $computer_ids
  */
 private function processEachForm($type_of_imputation, sfWebRequest $request, $imputation_parameters, $mop_ids, $account_ids, $computer_ids = null)
 {
     $ret = true;
     $first = true;
     /*For each user represented by its method_of_payment_id (mop_id):*/
     foreach ($mop_ids as $user_id => $mop_id) {
         //we set the parameters:
         $imputation_parameters['imputation']['user_id'] = $user_id;
         $imputation_parameters['imputation']['method_of_payment_id'] = $mop_id;
         $imputation_parameters['imputation']['account_id'] = $account_ids[$user_id];
         if ($imputation_parameters['imputation']['imputation_type'] == ImputationDefaultValues::UNITARY_SERVICE_TYPE) {
             $imputation_parameters['computer_id'] = $computer_ids[$user_id];
         }
         //we set theses parameters in the request object:
         $request->setParameter('imputation_' . $type_of_imputation, $imputation_parameters);
         //create the object which will be used for creating the form:
         $object = Imputation::instanciate($type_of_imputation);
         $object->getImputation()->setUserId($user_id);
         $object->getImputation()->setActId($imputation_parameters['imputation']['act_id']);
         //we build the form based on the object:
         $this->form = Imputation::instanciateForm($type_of_imputation, $object, array('culture' => ParametersConfiguration::getDefault('default_language')));
         //we try to validate this form with request which contains the correct parameters:
         if ($imputation_parameters['imputation']['imputation_type'] == ImputationDefaultValues::COUNTABLE_SERVICE_TYPE) {
             if ($imputation_parameters['account_is_shared'] == 'on' && isset($this->current_account_id)) {
                 $ret = $ret && $this->processForm($request, $this->form, $this->current_account_id);
             } else {
                 $ret = $ret && $this->processForm($request, $this->form);
             }
         } else {
             $ret = $ret && $this->processForm($request, $this->form);
         }
         $first = false;
     }
     return $ret;
 }