Beispiel #1
0
 /**
  * Creates a rfid_groupe object :
  *     affecter tous les badges rfid groupe sélectionnés
  *     générer des visiteurs anonymes (autant qu'il y a de badges)
  *     générer une visite à chaque visiteur
  * 
  * @param   sfWebRequest   $request a request object
  * @return  string
  */
 public function executeCreate(sfWebRequest $request)
 {
     $this->forward404Unless($request->isMethod(sfRequest::POST));
     $content = $request->getContent();
     // Restores backward compatibility. Content can be the HTTP request full body, or a form encoded "content" var.
     if (strpos($content, 'content=') === 0) {
         $content = $request->getParameter('content');
     }
     $request->setRequestFormat('html');
     $serializer = $this->getSerializer();
     $this->getResponse()->setContentType($serializer->getContentType());
     try {
         $this->validateCreate($content);
     } catch (Exception $e) {
         $this->getResponse()->setStatusCode(406);
         $error = $e->getMessage();
         // event filter to enable customisation of the error message.
         $result = $this->dispatcher->filter(new sfEvent($this, 'sfDoctrineRestGenerator.filter_error_output'), $error)->getReturnValue();
         if ($error === $result) {
             $error = array(array('message' => $error));
             $this->output = $serializer->serialize($error, 'error');
         } else {
             $this->output = $serializer->serialize($result);
         }
         $this->setTemplate('index');
         return sfView::SUCCESS;
     }
     $this->object = $this->createObject();
     $this->updateObjectFromRequest($content);
     $this->doSave();
 }
 public function executeUndo_tree_ajax(sfWebRequest $request)
 {
     $request->setRequestFormat('json');
     $id_tree = $request->getParameter('treeId');
     $production = $request->getParameter('production');
     $user = $this->getUser()->getAttribute(sfConfig::get('app_session_current_user'), null);
     if ($user != null) {
         $tree = TreeScPeer::retrieveByPK($id_tree);
         if (is_object($tree)) {
             //si es el dueño del arbol
             if ($tree->getUserId() == $user->getId()) {
                 $tree->setFlag(1);
                 if ($production == 'production') {
                     $tree->setProduccion('production');
                 }
                 $tree->save();
                 return sfView::SUCCESS;
             } else {
                 $this->message = 'owner not found';
                 return sfView::ERROR;
             }
         } else {
             $this->message = 'objet not found';
             return sfView::ERROR;
         }
     } else {
         $this->message = 'session expird';
         return sfView::ERROR;
     }
 }
 public function executeCreate_tree(sfWebRequest $request)
 {
     $request->setRequestFormat('json');
     $title = $request->getParameter('item_title');
     $user = $this->getUser()->getAttribute('s_current_user', null);
     if ($user != null) {
         try {
             $conn = Propel::getConnection();
             $conn->beginTransaction();
             $tree_bean = new TreeSc();
             $tree_bean->setName($title);
             $tree_bean->setUserId($user->getId());
             $tree_bean->setConfigureFlag('');
             $tree_bean->setConfigureDesign('');
             $tree_bean->setFlag(1);
             $tree_bean->save();
             $tree_user_bean = new TreeUser();
             $tree_user_bean->setUserId($tree_bean->getUserId());
             $tree_user_bean->setTreeId($tree_bean->getId());
             $tree_user_bean->save();
             $conn->commit();
             $this->message = 'success';
             $this->treepk = $tree_bean->getId();
             $this->title = $tree_bean->getName();
             return sfView::SUCCESS;
         } catch (Exception $e) {
             $this->message = $e->getMessage();
             return sfView::ERROR;
         }
     } else {
         $this->message = 'session expired';
         return sfView::ERROR;
     }
 }
 /**
  * Handles view action
  *
  * @param sfWebRequest $request Web request object
  */
 public function executeView($request)
 {
     $this->jotag = TagPeer::getFromField(TagPeer::JOTAG, $request->getParameter('jotag'));
     // check if active
     if (!$this->jotag || $this->jotag->getStatus() != TagPeer::ST_ACTIVE) {
         $this->forward404();
     }
     if (!$this->jotag->haveContacts()) {
         return sfView::ERROR;
     }
     $nextOption = $this->getUser()->getAttribute('nextOption');
     // check privacy settings
     $this->form = new PrivacyCheckForm($this->jotag, array('webservice' => $this->isWebserviceCall()), null, $nextOption);
     if (!TagPrivacyPeer::allowedToView($this->getUser(), $this->jotag)) {
         // user not allowed to view jotag, display security check form
         if ($request->isMethod('post')) {
             $this->form->bind($request->getParameter('privacy'));
             if ($this->form->isValid()) {
                 if ($this->jotag->getTagPrivacy()->getPrivacyType() == TagPrivacyPeer::PRIVACY_AUTH || $nextOption == "fck editor") {
                     if (!$this->getUser()->isAuthenticated()) {
                         throw new sfException('User must be logged in to perform this action');
                     }
                     if ($this->jotag->getAuthStatus($this->getUser()->getSubscriber()) != TagAuthPeer::STATUS_NONE) {
                         throw new sfException('User already requested authorization');
                     }
                     // add authorization request
                     $this->jotag->addAuthRequest($this->getUser()->getSubscriber());
                     // change format back to html
                     $sf_format = $request->getParameter("sf_format");
                     $request->setRequestFormat("html");
                     // notify owner
                     Mailer::sendEmail($this->jotag->getUser()->getPrimaryEmail(), 'authRequest', array('jotag' => $this->jotag, 'user' => $this->getUser()->getSubscriber(), 'message' => $this->form->getValue('message')), $this->jotag->getUser()->getPreferedLanguage());
                     //$this->getUser()->getAttributeHolder()->remove('nextOption');
                     $this->redirect("jotag/view?jotag=" . $this->jotag->getJotag() . '&sf_format=' . $sf_format);
                 } else {
                     // user passed security check, allow him to view
                     TagprivacyPeer::allowToView($this->getUser(), $this->jotag);
                     $this->redirect("jotag/view?jotag=" . $this->jotag->getJotag() . '&sf_format=' . $request->getParameter('sf_format'));
                 }
             }
         }
         // not authorized
         return sfView::ERROR;
     }
     $this->allowed = true;
     $this->show = $request->getParameter('show') ? true : false;
 }
 public function executeSave_bost_group(sfWebRequest $request)
 {
     $request->setRequestFormat('json');
     $user = $this->getUser()->getAttribute(sfConfig::get('app_session_current_user'), null);
     $bost_id = $request->getParameter('bostId');
     $rowId = $request->getParameter('rowId');
     if ($user != null) {
         $row = DetalleGrupoTrabajoScPeer::retrieveByPK($rowId);
         if (is_object($row)) {
             if ($bost_id == "none") {
                 $row->setBostId(0);
             } else {
                 $row->setBostId($bost_id);
             }
             $row->save();
             return sfView::SUCCESS;
         } else {
             return sfView::ERROR;
         }
     } else {
         return sfView::ERROR;
     }
 }
 /**
  * Creates a token referring to an sfGuardUser object
  * @param   sfWebRequest   $request a request object
  * @return  string
  */
 public function executeValidhash(sfWebRequest $request)
 {
     $this->forward404Unless($request->isMethod(sfRequest::GET));
     $params = $request->getParameterHolder()->getAll();
     // notify an event before the action's body starts
     $this->dispatcher->notify(new sfEvent($this, 'sfDoctrineRestGenerator.get.pre', array('params' => $params)));
     $request->setRequestFormat('html');
     $this->setTemplate('index');
     $params = $this->cleanupParameters($params);
     $is_valid = false;
     try {
         $format = $this->getFormat();
         if (!array_key_exists('subreddit_id', $params) && !array_key_exists('id_hash', $params)) {
             throw new sfException('Missing reference to subreddit_id and id_hash!', 400);
         }
         if (!array_key_exists('subreddit_id', $params)) {
             throw new sfException('Missing reference to subreddit_id!', 400);
         }
         if (!array_key_exists('id_hash', $params)) {
             throw new sfException('Missing reference to id_hash!', 400);
         }
         $check = EpisodeAssignmentTable::getInstance()->getByIdHash($params['id_hash'], $params['subreddit_id']);
         if ($check) {
             $is_valid = true;
         }
     } catch (Exception $e) {
         $this->getResponse()->setStatusCode($e->getCode() ? $e->getCode() : 406);
         $serializer = $this->getSerializer();
         $this->getResponse()->setContentType($serializer->getContentType());
         $error = $e->getMessage();
         // event filter to enable customisation of the error message.
         $result = $this->dispatcher->filter(new sfEvent($this, 'sfDoctrineRestGenerator.filter_error_output'), $error)->getReturnValue();
         if ($error === $result) {
             $error = array(array('message' => $error));
             $this->output = $serializer->serialize($error, 'error');
         } else {
             $this->output = $serializer->serialize($result);
         }
         return sfView::SUCCESS;
     }
     $serializer = $this->getSerializer();
     $this->getResponse()->setContentType($serializer->getContentType());
     $this->output = $serializer->serialize(array('is_valid' => $is_valid), $this->model, false);
 }
Beispiel #7
0
 /**
  * Creates a VisiteurMedaille object
  * @param   sfWebRequest   $request a request object
  * @return  string
  */
 public function executeCreate(sfWebRequest $request)
 {
     $this->forward404Unless($request->isMethod(sfRequest::POST));
     $content = $request->getContent();
     // Restores backward compatibility. Content can be the HTTP request full body, or a form encoded "content" var.
     if (strpos($content, 'content=') === 0) {
         $content = $request->getParameter('content');
     }
     $request->setRequestFormat('html');
     $serializer = $this->getSerializer();
     try {
         $params = $this->parsePayload($content);
         $this->validateCreate($content, $params);
         $this->getResponse()->setContentType($serializer->getContentType());
         $this->object = $this->createObject();
         $this->updateObjectFromRequest($content);
         //$connection =  isset($params['connection'])?$params['connection']: 'insitu';
         if ($this->object->hasAlreadyMedaille($params['univers_id'], $params['contexte_id'])) {
             throw new Exception(sprintf("The medal %s is unique for this visitor %s", $this->object->getMedailleId(), $this->object->getVisiteurId()));
         }
         $this->doSave();
         VisiteurUniversStatusGainTable::hasNewStatus($this->object->getVisiteurId(), $this->object->getMedailleId(), $this->object->getContexteId());
         $output = array(array('message' => "ok"));
         $this->output = $serializer->serialize($output);
     } catch (Exception $e) {
         $this->getResponse()->setStatusCode(406);
         $error = $e->getMessage();
         // event filter to enable customisation of the error message.
         $result = $this->dispatcher->filter(new sfEvent($this, 'sfDoctrineRestGenerator.filter_error_output'), $error)->getReturnValue();
         if ($error === $result) {
             $error = array(array('message' => $error));
             $this->output = $serializer->serialize($error, 'error');
         } else {
             $this->output = $serializer->serialize($result);
         }
         $this->setTemplate('index');
         return sfView::SUCCESS;
     }
     return sfView::SUCCESS;
 }
 /**
  * Creates a token referring to an sfGuardUser object
  * @param   sfWebRequest   $request a request object
  * @return  string
  */
 public function executeTime(sfWebRequest $request)
 {
     $this->forward404Unless($request->isMethod(sfRequest::GET));
     $params = $request->getParameterHolder()->getAll();
     // notify an event before the action's body starts
     $this->dispatcher->notify(new sfEvent($this, 'sfDoctrineRestGenerator.get.pre', array('params' => $params)));
     $request->setRequestFormat('html');
     $this->setTemplate('index');
     $params = $this->cleanupParameters($params);
     try {
         $format = $this->getFormat();
     } catch (Exception $e) {
         $this->getResponse()->setStatusCode($e->getCode() ? $e->getCode() : 406);
         $serializer = $this->getSerializer();
         $this->getResponse()->setContentType($serializer->getContentType());
         $error = $e->getMessage();
         // event filter to enable customisation of the error message.
         $result = $this->dispatcher->filter(new sfEvent($this, 'sfDoctrineRestGenerator.filter_error_output'), $error)->getReturnValue();
         if ($error === $result) {
             $error = array(array('message' => $error));
             $this->output = $serializer->serialize($error, 'error');
         } else {
             $this->output = $serializer->serialize($result);
         }
         return sfView::SUCCESS;
     }
     $serializer = $this->getSerializer();
     $this->getResponse()->setContentType($serializer->getContentType());
     $user_id = $this->requestTokenUserId();
     $this->output = $serializer->serialize(array('time' => time()), $this->model, false);
 }
Beispiel #9
0
 public function executeCollectAnonymousVisite(sfWebRequest $request)
 {
     $this->forward404unless($request->getParameter('visiteur_id') && $request->getParameter('visite_id'));
     $visiteur_id = $request->getParameter('visiteur_id');
     $visite_id = $request->getParameter('visite_id');
     $request->setRequestFormat('html');
     $serializer = $this->getSerializer();
     // check visiteur
     $visiteur = Doctrine_Query::create()->from('Visiteur')->where('guid = ?', $visiteur_id)->andWhereIn('is_anonyme', array(0, null))->limit(1)->execute();
     if (!$visiteur) {
         $this->getResponse()->setStatusCode(406);
         $result = array(array('message' => sprintf('visiteur %s not exist', $visiteur_id), 'code' => 'E_VISITEUR_00'));
         $this->output = $serializer->serialize($result, 'error');
         return sfView::SUCCESS;
     }
     // check visite
     $visite = Doctrine_Core::getTable('Visite')->findOneByGuid($visite_id);
     if (!$visite) {
         $this->getResponse()->setStatusCode(406);
         $result = array(array('message' => sprintf('visite %s not exist', $visite_id), 'code' => 'E_VISITE_00'));
         $this->output = $serializer->serialize($result, 'error');
         return sfView::SUCCESS;
     } else {
         $details = array();
         // get anonymous_visiteur
         $anonymous_visiteur_id = $visite->getVisiteurId();
         //$anonymous_visiteur_id->deleteActionFromCreateVisiteur();
         // already change
         if ($anonymous_visiteur_id == $visiteur_id) {
             $this->getResponse()->setStatusCode(406);
             $result = array(array('message' => 'visite already changed'));
             $this->output = $serializer->serialize($result, 'error');
             return sfView::SUCCESS;
         }
         // update Visite
         $visite->setVisiteurId($visiteur_id);
         $visite->save();
         // update LogVisite
         $log_visites = Doctrine_Core::getTable('LogVisite')->findByVisiteurId($anonymous_visiteur_id);
         $details['logVisite'] = count($log_visites);
         foreach ($log_visites as $log_visite) {
             $log_visite->setVisiteurId($visiteur_id);
             $log_visite->setVisiteId($visite_id);
             $log_visite->save();
         }
         // visiteur medaille
         $visiteur_medailles = Doctrine_Core::getTable('VisiteurMedaille')->findByVisiteurId($anonymous_visiteur_id);
         $details['VisiteurMedaille'] = count($visiteur_medailles);
         foreach ($visiteur_medailles as $visiteur_medaille) {
             $visiteur_medaille->setVisiteurId($visiteur_id);
             $visiteur_medaille->save();
         }
         // visiteur medaille
         $visiteur_univers = Doctrine_Core::getTable('VisiteurUniversStatusGain')->findByVisiteurId($anonymous_visiteur_id);
         $details['VisiteurUniversStatusGain'] = count($visiteur_univers);
         foreach ($visiteur_univers as $visiteur_univer) {
             $visiteur_univer->setVisiteurId($visiteur_id);
             $visiteur_univer->save();
         }
         // udate Xp
         $xps = Doctrine_Core::getTable('Xp')->findByVisiteurId($anonymous_visiteur_id);
         $details['Xp'] = count($xps);
         foreach ($xps as $xp) {
             $xp->setVisiteurId($visiteur_id);
             $xp->save();
         }
         // update Notification
         $notifications = Doctrine_Core::getTable('Notification')->findByVisiteurId($anonymous_visiteur_id);
         $details['Notification'] = count($notifications);
         foreach ($notifications as $notification) {
             $notification->setVisiteurId($visiteur_id);
             $notification->save();
         }
         $fileSystem = new sfFilesystem();
         $finder = new sfFinder();
         $path = sfConfig::get('sf_web_dir') . "/visiteur/" . $anonymous_visiteur_id;
         @$fileSystem->mirror(sfConfig::get('sf_web_dir') . "/visiteur/" . $anonymous_visiteur_id, sfConfig::get('sf_web_dir') . "/visiteur/" . $visiteur_id, $finder, array('override' => true));
         $result = array(array_merge(array('message' => 'ok'), array('details' => $details)));
         $this->output = $serializer->serialize($result, 'result');
         return sfView::SUCCESS;
     }
 }
Beispiel #10
0
 /**
  * Retrieves a  collection of Parcours objects
  * @param   sfWebRequest   $request a request object
  * @return  string
  */
 public function executeIndex(sfWebRequest $request)
 {
     $this->forward404Unless($request->isMethod(sfRequest::GET));
     $params = $request->getParameterHolder()->getAll();
     // notify an event before the action's body starts
     $this->dispatcher->notify(new sfEvent($this, 'sfDoctrineRestGenerator.get.pre', array('params' => $params)));
     $request->setRequestFormat('html');
     //get the exposition_id param
     if (isset($params['exposition_id'])) {
         $exposition_id = $params['exposition_id'];
     }
     //get the exposition_id param
     if (isset($params['interactif_id'])) {
         $interactif_id = $params['interactif_id'];
     }
     $params = $this->cleanupParameters($params);
     try {
         $format = $this->getFormat();
         $this->validateIndex($params);
     } catch (Exception $e) {
         $this->getResponse()->setStatusCode(406);
         $serializer = $this->getSerializer();
         $this->getResponse()->setContentType($serializer->getContentType());
         $error = $e->getMessage();
         // event filter to enable customisation of the error message.
         $result = $this->dispatcher->filter(new sfEvent($this, 'sfDoctrineRestGenerator.filter_error_output'), $error)->getReturnValue();
         if ($error === $result) {
             $error = array(array('message' => $error));
             $this->output = $serializer->serialize($error, 'error');
         } else {
             $this->output = $serializer->serialize($result);
         }
         return sfView::SUCCESS;
     }
     $this->queryExecute($params);
     $isset_pk = (!isset($isset_pk) || $isset_pk) && isset($params['guid']);
     if ($isset_pk && count($this->objects) == 0) {
         $request->setRequestFormat($format);
         $this->forward404();
     }
     //Filter by exposition_id
     if (isset($exposition_id)) {
         $new_object = array();
         foreach ($this->objects as $key => $object) {
             $filtered = true;
             if (isset($exposition_id)) {
                 $expositions = Doctrine_Query::create()->from('ExpositionsParcours ep')->andWhere('ep.parcours_id = ?', $object['guid'])->andWhere('ep.exposition_id = ?', $exposition_id)->execute(array(), Doctrine::HYDRATE_ARRAY);
                 if (count($expositions) > 0) {
                     $filtered = false;
                 }
             }
             if (!$filtered && isset($this->objects[$key])) {
                 $new_object[] = $this->objects[$key];
             }
         }
         $this->objects = $new_object;
     }
     //Filter by exposition_id
     if (isset($interactif_id)) {
         $new_object = array();
         foreach ($this->objects as $key => $object) {
             $filtered = true;
             if (isset($interactif_id)) {
                 $interactifs = Doctrine_Query::create()->from('ParcoursInteractif pi')->andWhere('pi.parcours_id = ?', $object['guid'])->andWhere('pi.interactif_id = ?', $interactif_id)->execute(array(), Doctrine::HYDRATE_ARRAY);
                 if (count($interactifs) > 0) {
                     $filtered = false;
                 }
             }
             if (!$filtered && isset($this->objects[$key])) {
                 $new_object[] = $this->objects[$key];
             }
         }
         $this->objects = $new_object;
     }
     // configure the fields of the returned objects and eventually hide some
     $this->setFieldVisibility();
     $this->configureFields();
     $serializer = $this->getSerializer();
     $this->getResponse()->setContentType($serializer->getContentType());
     $this->output = $serializer->serialize($this->objects, $this->model);
     unset($this->objects);
 }
 /**
  * Creates a Message object
  * @param   sfWebRequest   $request a request object
  * @return  string
  */
 public function executeCreate(sfWebRequest $request)
 {
     $this->forward404Unless($request->isMethod(sfRequest::POST));
     $content = $request->getContent();
     // Restores backward compatibility. Content can be the HTTP request full body, or a form encoded "content" var.
     if (strpos($content, 'content=') === 0) {
         $content = $request->getParameter('content');
     }
     if ($content === false) {
         $content = $request->getPostParameter('content');
         // Last chance to get the content!
     }
     $request->setRequestFormat('html');
     try {
         $parameters = $request->getParameterHolder()->getAll();
         $params = $this->getApiAuthFieldValues($parameters, $content);
         $this->validateApiAuth($parameters, $content);
         $this->validateCreate($content, $request);
     } catch (Exception $e) {
         $this->getResponse()->setStatusCode($e->getCode() ? $e->getCode() : 406);
         $serializer = $this->getSerializer();
         $this->getResponse()->setContentType($serializer->getContentType());
         $error = $e->getMessage();
         // event filter to enable customisation of the error message.
         $result = $this->dispatcher->filter(new sfEvent($this, 'sfDoctrineRestGenerator.filter_error_output'), $error)->getReturnValue();
         if ($error === $result) {
             $error = array(array('message' => $error));
             $this->output = $serializer->serialize($error, 'error');
         } else {
             $this->output = $serializer->serialize($result);
         }
         $this->setTemplate('index');
         return sfView::SUCCESS;
     }
     $object_params = $this->parsePayload($content);
     if (!$this->getUser()->isSuperAdmin() || !array_key_exists('sender_id', $object_params)) {
         $object_params['sender_id'] = $this->getUser()->getGuardUser()->getIncremented();
     }
     $this->object = $this->createObject();
     $this->object->importFrom('array', $object_params);
     return $this->doSave($params);
 }
 public function executeSave_indicator(sfWebRequest $request)
 {
     $request->setRequestFormat('json');
     $indicadorId = $request->getParameter('indicatorId');
     $titulo = $request->getParameter('title');
     $descripcion = $request->getParameter('description');
     $valor_minimo = $request->getParameter('valueMin');
     $valor_deseado = $request->getParameter('valueDes');
     $valor_optimo = $request->getParameter('valueOpt');
     $responsable_id = $request->getParameter('responsableId');
     $responsable_email = $request->getParameter('responsableEmail');
     $grupo_trabajo_id = $request->getParameter('workGroup');
     $json_children = $request->getParameter('indicatorChildren');
     $json = json_decode($json_children);
     if (count($json) > 0) {
         foreach ($json as $row) {
             $indicador_children = IndicatorsScPeer::retrieveByPK($row->{'pk'});
             $indicador_children->setConectoresConfigure($row->{'values'});
             $indicador_children->save();
         }
     }
     //primero validamos y esta logeado
     //segundo validamos si el idicador existe
     //tercero verificamos si se asigno un usuario
     //(si se le asigno un usuario)cuarto vamos a revisar si el usuario que es asignado esta en e grupo de trabajo
     /*si no esta en grupo de trabajo envio una solictud ( antes verifico si no le mande una solicitud antes)
      * por que no se va estar mandando varias solicitudes al mismo usuario
      * en este caso las solicitudes son 1 vez por grupo de trabajo y no por indicador
      */
     //despues de vefiricar grabamos la primera vesion del indicador con los datos secundarios
     $user = $this->getUser()->getAttribute(sfConfig::get('app_session_current_user'), null);
     if ($user != null) {
         $indicador = IndicatorsScPeer::retrieveByPK($indicadorId);
         if (is_object($indicador)) {
             if ($responsable_email != "") {
                 /* aca vamos crear el registro de asignaciones, esta tabla me permite manejar un
                    historial  de las asignacion de resposanble x indicador
                    asi podre ver todas los responsables de un determinado indicador.*/
                 $asignacion_indicador = new AsignacionSc();
                 $asignacion_indicador->setGrupoId($grupo_trabajo_id);
                 $asignacion_indicador->setEmail($responsable_email);
                 $asignacion_indicador->setTreeId($indicador->getTreeId());
                 $asignacion_indicador->setIndicadorId($indicador->getId());
                 $asignacion_indicador->setCreateAt(time());
                 $asignacion_indicador->setUpdateAt(time());
                 /**********************************************************************/
                 if ($responsable_id != "") {
                     $asignacion_indicador->setFlag(json_encode(array("estado" => true, "owner_id" => $user->getId())));
                     $asignacion_indicador->setUserId($responsable_id);
                     $indicador->setResponsableId($responsable_id);
                     $indicador->setEmailResponsable($responsable_email);
                 } else {
                     //envio solicitud
                     //antes verificar si no le enviando una solicitud antes
                     $rsp = $this->evaluar_solicitud($responsable_email, $grupo_trabajo_id, $user);
                     if ($rsp['success']) {
                         $indicador->setEmailResponsable($responsable_email);
                         $indicador->setResponsableId(null);
                         $asignacion_indicador->setFlag(json_encode(array("estado" => false, "owner_id" => $user->getId())));
                     } else {
                         $this->message = $rsp['message'];
                         return sfView::ERROR;
                     }
                 }
                 $asignacion_indicador->save();
             } else {
                 $indicador->setResponsableId(null);
                 $indicador->setEmailResponsable('');
             }
             if ($descripcion != "") {
                 $indicador->setDescripcion($descripcion);
             }
             if ($valor_minimo != "") {
                 $indicador->setValorMinimo($valor_minimo);
             }
             if ($valor_deseado != "") {
                 $indicador->setValorDeseado($valor_deseado);
             }
             if ($valor_optimo != "") {
                 $indicador->setValorOptimo($valor_optimo);
             }
             if ($titulo != "") {
                 $indicador->setTitulo($titulo);
             }
             $indicador->save();
         } else {
             $this->message = 'not found indicator';
             return sfView::ERROR;
         }
     } else {
         $this->message = 'session expired';
         return sfView::ERROR;
     }
 }
Beispiel #13
0
 public function executeCreate(sfWebRequest $request)
 {
     $this->forward404Unless($request->isMethod(sfRequest::POST));
     $content = $request->getContent();
     // Restores backward compatibility. Content can be the HTTP request full body, or a form encoded "content" var.
     if (strpos($content, 'content=') === 0) {
         $content = $request->getParameter('content');
     }
     $request->setRequestFormat('html');
     $serializer = $this->getSerializer();
     $this->getResponse()->setContentType($serializer->getContentType());
     $parameters = $this->parsePayload($content, true);
     // $content = $serializer->serialize($parameters);
     $interactif_id = $parameters['interactif_id'];
     $visite_id = isset($parameters['visite_id']) ? $parameters['visite_id'] : '';
     $start_at = $parameters['start_at'];
     $end_at = $parameters['end_at'];
     $connection = $parameters['connection'];
     if ($start_at) {
         $start_at = date('Y-m-d H:i:s', $start_at);
         $parameters['start_at'] = $start_at;
     }
     if ($end_at) {
         $end_at = date('Y-m-d H:i:s', $end_at);
         $parameters['end_at'] = $end_at;
     }
     try {
         if (isset($connection) && $connection == 'insitu') {
             $this->validateCreateInsitu($content);
         } else {
             $this->validateCreate($content);
         }
     } catch (Exception $e) {
         $this->getResponse()->setStatusCode(406);
         $serializer = $this->getSerializer();
         $this->getResponse()->setContentType($serializer->getContentType());
         $error = $e->getMessage();
         // event filter to enable customisation of the error message.
         $result = $this->dispatcher->filter(new sfEvent($this, 'sfDoctrineRestGenerator.filter_error_output'), $error)->getReturnValue();
         if ($error === $result) {
             $error = array(array('message' => $error));
             $this->output = $serializer->serialize($error, 'error');
         } else {
             $this->output = $serializer->serialize($result);
         }
         return sfView::SUCCESS;
     }
     $this->object = $this->createObject();
     $this->updateObjectFromRequest($serializer->serialize($parameters));
     return $this->doSave();
 }
Beispiel #14
0
 /**
  * Retrieves a  collection of needs objects for a visitor
  * @param   sfWebRequest   $request a request object
  * @return  string
  */
 public function executeNeeds(sfWebRequest $request)
 {
     $this->forward404Unless($request->isMethod(sfRequest::GET));
     $params = $request->getParameterHolder()->getAll();
     // notify an event before the action's body starts
     $this->dispatcher->notify(new sfEvent($this, 'sfDoctrineRestGenerator.get.pre', array('params' => $params)));
     $request->setRequestFormat('html');
     $params = $this->cleanupParameters($params);
     try {
         if (empty($params)) {
             throw new sfException("the service must have at least one parameter");
         }
         $format = $this->getFormat();
         $this->validateNeeds($params);
         $visiteur = Doctrine::getTable($this->model)->findOneByGuid($params["guid"]);
         $needs = Doctrine::getTable('ExpositionVisiteurNeeds')->findOneByGuid($params["exposition_visiteur_needs_id"]);
     } catch (Exception $e) {
         $this->getResponse()->setStatusCode(406);
         $serializer = $this->getSerializer();
         $this->getResponse()->setContentType($serializer->getContentType());
         $error = $e->getMessage();
         // event filter to enable customisation of the error message.
         $result = $this->dispatcher->filter(new sfEvent($this, 'sfDoctrineRestGenerator.filter_error_output'), $error)->getReturnValue();
         if ($error === $result) {
             $error = array(array('message' => $error));
             $this->output = $serializer->serialize($error, 'error');
         } else {
             $this->output = $serializer->serialize($result);
         }
         return sfView::SUCCESS;
     }
     $serializer = $this->getSerializer();
     $this->getResponse()->setContentType($serializer->getContentType());
     $this->output = $serializer->serialize($visiteur->getNeeds($needs));
 }
 public function executeShow_tree(sfWebRequest $request)
 {
     $request->setRequestFormat('json');
     $tree_id = explode('-', $request->getParameter('treeId'));
     $tree_id = $tree_id[1];
     $tree = TreeScPeer::retrieveByPK($tree_id);
     if (is_object($tree)) {
         //por aqui tambien deveria validar si el usuario tiene permisos para editar este nodo
         //por si se me escapa en el la vista cliente...(pendiente)
         $this->tree = $tree;
         return sfView::SUCCESS;
     } else {
         return sfView::ERROR;
         $this->message = 'tree no encontrado';
     }
 }
 /**
  * Allows for the upload of a Subreddit intro sound file.
  * @param   sfWebRequest   $request a request object
  * @return  string
  */
 public function executeUpload_outro(sfWebRequest $request)
 {
     // PUT makes more sense, but I am limited currently by my API to POST.
     $this->forward404Unless($request->isMethod(sfRequest::POST));
     $content = $request->getContent();
     // Restores backward compatibility. Content can be the HTTP request full body, or a form encoded "content" var.
     if (strpos($content, 'content=') === 0 || $request->hasParameter('content')) {
         $content = $request->getParameter('content');
     }
     $request->setRequestFormat('html');
     try {
         $parameters = $request->getParameterHolder()->getAll();
         $params = $this->getApiAuthFieldValues($parameters, $content);
         $this->validateUpload($content, $request);
     } catch (Exception $e) {
         $this->getResponse()->setStatusCode($e->getCode() ? $e->getCode() : 406);
         $serializer = $this->getSerializer();
         $this->getResponse()->setContentType($serializer->getContentType());
         $error = $e->getMessage();
         // event filter to enable customisation of the error message.
         $result = $this->dispatcher->filter(new sfEvent($this, 'sfDoctrineRestGenerator.filter_error_output'), $error)->getReturnValue();
         if ($error === $result) {
             $error = array(array('message' => $error));
             $this->output = $serializer->serialize($error, 'error');
         } else {
             $this->output = $serializer->serialize($result);
         }
         $this->setTemplate('index');
         return sfView::SUCCESS;
     }
     // We move the file from its temporary location to the Episode in question.
     if ($this->_nice_filename && $this->_temporary_file_location) {
         $targetDir = rtrim(ProjectConfiguration::getSubredditAudioFileLocalDirectory(), '/');
         $pattern = '/\\.([^\\.]+)$/';
         preg_match($pattern, $filename, $matches);
         $extension = array_key_exists(1, $matches) ? $matches[1] : 'mp3';
         // We don't need the upload hash because we're not uploading AJAX-like in real time.
         $hash = sha1(microtime() . $this->object->getIncremented());
         $fileName = $hash . '.' . $extension;
         //Move the file.
         rename($this->_temporary_file_location, $targetDir . '/' . $fileName);
         // update and save it
         $this->object->setEpisodeOutro($fileName);
     }
     return $this->doSave($params);
 }
 public function executeAjax_show_records_indicators(sfWebRequest $request)
 {
     $request->setRequestFormat('json');
     /*recojo el id del indicador para este caso es ultimo de lo
       contrario arrojara un mensaje de error*/
     $id_indicators = $request->getParameter('id_indicators');
     $user = $this->getUser()->getAttribute(sfConfig::get('app_session_current_user'), null);
     /*Se elimina todos los registros de las dos tablas temporales.*/
     $new_criteria = new Criteria();
     $new_criteria->add(TmpDataReportsPeer::FLAG, $user->getId());
     TmpDataReportsPeer::doDelete($new_criteria);
     $new_criteria->clear();
     $new_criteria->add(TmpTreeScPeer::FLAG, $user->getId());
     TmpTreeScPeer::doDelete($new_criteria);
     /*************************************************************/
     /*obetengo el nodo para asi obtener a que arbol pertenece y asi
       sacar todos los ultimos nodos */
     $criteria = new Criteria();
     $criteria->add(IndicatorsScPeer::ID, $id_indicators);
     $indicators = IndicatorsScPeer::doSelectOne($criteria);
     $criteria->clear();
     if (is_object($indicators)) {
         $this->indicator = $indicators;
         //obtengo los indicadores que son los ultimos nodos
         $criteria->add(IndicatorsScPeer::TREE_ID, $indicators->getTreeId());
         $criteria->add(IndicatorsScPeer::ULTIMO_NODO, '1', Criteria::LIKE);
         $list_last_indicators = IndicatorsScPeer::doSelect($criteria);
         $criteria->clear();
         //----------> lista de los indicadores que son ultimos nodos
         $this->list_last_indicators = $list_last_indicators;
         /*obtengo la cantidad de registros que tiene en la tabla 'data_indicadores'
          *verifico si el indicador es  ultimo nodo*/
         foreach ($list_last_indicators as $obj_id_indicators) {
             if ($obj_id_indicators->getId() == $id_indicators) {
                 //si el id del indicador que estoy buscando es igual a uno de los ultimos nodos
                 $id = $obj_id_indicators->getId();
                 break;
             }
             $id = null;
         }
         if ($id != null) {
             // si es ultimo nodo
             //Verifico la cantidad de rows que tiene
             $criteria->add(DataIndicadoresPeer::INDICADOR_ID, $id);
             $rows_in_data_indicadores = DataIndicadoresPeer::doCount($criteria);
             if ($rows_in_data_indicadores > 0) {
                 $object_rows = DataIndicadoresPeer::doSelect($criteria);
                 $this->indicator = $indicators;
                 $this->object_rows = $object_rows;
                 $this->object_rows_2 = $object_rows;
                 $this->type_rpt = 'node';
                 $criteria->clear();
             }
         } else {
             // si el indicador no es ultimo nodo
             /* obtengo el numero de registros que tiene la tabla 'data_indicadores'
              * solo me hace falta obtener un indicador de esa lista para saber la cantidad de registros*/
             $obj_evaluado = $list_last_indicators[0];
             //verifico los registros ingresados por ese indicador
             $criteria->add(DataIndicadoresPeer::INDICADOR_ID, $obj_evaluado->getId());
             /*   $rows_in_data_indicadores = DataIndicadoresPeer::doCount($criteria);
                    1) saco la informacion de los registros
                    2) $obj_evaluado->getId() ----->este ID esta en muchos registros
                  */
             $rows_in_data_indicadores = DataIndicadoresPeer::doCount($criteria);
             //------>numero de registros
             $data_indicators = DataIndicadoresPeer::doSelect($criteria);
             //---> obtengo los registros por cada ID
             // efectuo el for para replicar el arbol y llenar los valores de cada indicador
             if ($rows_in_data_indicadores > 0) {
                 //realizo el for con el numero de registros
                 //    for($i=0; $i<$rows_in_data_indicadores ; $i++){
                 $data_list_grafico = null;
                 foreach ($data_indicators as $reg_indicators) {
                     $criteria->clear();
                     $criteria->add(DataIndicadoresPeer::GROUP_DATA, $reg_indicators->getGroupData());
                     //---> BUSCO EL PRIMER GRUPO DE DATOS
                     // $criteria->addDescendingOrderByColumn(DataIndicadoresPeer::GROUP_DATA);
                     $data_util_graficos = DataIndicadoresPeer::doSelect($criteria);
                     $lista_relaciones = null;
                     //obtengo el id del arbol creado en temporal
                     $array_result = $this->executeEspejo_reportes($indicators->getTreeId(), $data_util_graficos, $reg_indicators->getUpdateAt());
                     $id_tmp_creado = $array_result['array'];
                     $lista_relaciones = $array_result['lista'];
                     //obtengo los ultmimos nodos pero de los indicadores que estan creados en la tabla temporal
                     $criteria->add(TmpDataReportsPeer::TREE_ID, $id_tmp_creado);
                     $criteria->add(TmpDataReportsPeer::ULTIMO_NODO, '1', Criteria::LIKE);
                     $list_tmp_last_indicators = TmpDataReportsPeer::doSelect($criteria);
                     //----> lista de los ultimos nodos de la tabla tmp
                     //$list_relation = null;
                     foreach ($list_tmp_last_indicators as $ob) {
                         $this->recalculate_tree($ob, $reg_indicators->getUpdateAt());
                     }
                     //obtengo el id del indicador relacionado
                     $id_relation = $this->return_relation_id($lista_relaciones, $indicators->getId());
                     //busco en la tabla temporal por el id
                     $data_list_grafico[] = $id_relation;
                 }
                 //envio datos para el grafico
                 $criteria->clear();
                 $criteria->add(TmpDataReportsPeer::INDICADOR_ID, $indicators->getId());
                 $list_indicators_reports = TmpDataReportsPeer::doSelect($criteria);
                 //  }
             }
             $this->indicator = $indicators;
             $this->object_rows = $list_indicators_reports;
             $this->object_rows_2 = $list_indicators_reports;
             $this->type_rpt = 'tmp';
         }
     } else {
         // $this->indicators = null;
         $this->list_last_indicators = null;
         $this->object_rows = null;
     }
 }
 public function executeSurveys_answers(sfWebRequest $request)
 {
     $request->setRequestFormat('json');
     $list_answers = $request->getParameter('list');
     $encuesta_id = $request->getParameter('surveysId');
     $criterio = new Criteria();
     $criterio->add(EvaluacionesUserPeer::HEAD_ID, $encuesta_id);
     $lista = EvaluacionesUserPeer::doSelect($criterio);
     $headBean = HeadEvaluacionesPeer::retrieveByPK($encuesta_id);
     if (is_object($headBean)) {
         $contador = 0;
         foreach ($lista as $row) {
             $row->setRespuesta($list_answers[$contador]);
             $row->save();
             $contador++;
         }
         $headBean->setFlag(2);
         $headBean->save();
         return sfView::SUCCESS;
     } else {
         return sfView::ERROR;
     }
 }
Beispiel #19
0
 public function executeBrowseDocuments(sfWebRequest $request)
 {
     $request->setRequestFormat('html');
     $this->forward404Unless($request->isMethod(sfRequest::GET));
     $visiteurs = $request->getParameter('visiteur_id');
     $interactifs = $request->getParameter('interactif_id');
     $serializer = $this->getSerializer();
     $this->getResponse()->setContentType($serializer->getContentType());
     if (is_null($interactifs)) {
         $this->getResponse()->setStatusCode(406);
         $error = array("message" => "parameter interactif_id mandatory");
         $this->output = $serializer->serialize(array($error), 'error');
         return sfView::SUCCESS;
     }
     $visiteur_keys = array();
     $interactif_keys = array();
     $interactif_keys = explode(',', $interactifs);
     if ($visiteurs) {
         $visiteur_keys = explode(',', $visiteurs);
     }
     $page = $request->getParameter('page');
     if (!$page) {
         $page = 1;
     }
     $page_size = $request->getParameter('page_size');
     if (!$page_size) {
         $page_size = 5000;
     }
     $offset = ($page - 1) * $page_size;
     $limit = $page_size;
     //echo("offset=$offset && page_size=$page_size");
     $results = array();
     foreach ($interactif_keys as $interactif_id) {
         $item = Doctrine::getTable($this->model)->findOneByGuid($interactif_id);
         if (!$item && count($interactif_keys) == 1) {
             $this->getResponse()->setStatusCode(406);
             $error = array("message" => "unknown interactif " . $interactif_id);
             $this->output = $serializer->serialize(array($error), 'error');
             return sfView::SUCCESS;
         }
         $query = 'SELECT e.guid AS guid, e.libelle AS libelle';
         $query .= ' FROM exposition e, exposition_parcours e2, parcours_interactif p, interactif i';
         $query .= ' WHERE (';
         $query .= ' e.guid = e2.exposition_id';
         $query .= ' AND e2.parcours_id = p.parcours_id';
         $query .= ' AND p.interactif_id = i.guid';
         $query .= ' AND i.guid = "' . $interactif_id . '"';
         $query .= ' ) group by guid';
         $exposition = Doctrine_Manager::getInstance()->getCurrentConnection()->fetchAssoc($query);
         $interactif_info = array();
         if ($exposition) {
             $interactif_info = array('libelle' => $item->getLibelle(), 'synopsis' => $item->getSynopsis(), 'description' => $item->getDescription(), 'logo' => $item->getLogo(), 'url_illustration' => $item->getUrlIllustration(), 'url_market_ios' => $item->getUrlMarketIos(), 'url_market_android' => $item->getUrlMarketAndroid(), 'image1' => $item->getImage1(), 'image2' => $item->getImage2(), 'image3' => $item->getImage3(), 'expositions' => $exposition);
         }
         $results[$interactif_id] = $interactif_info;
         if (count($visiteur_keys) > 0) {
             $docs = array();
             foreach ($visiteur_keys as $visiteur_id) {
                 $doc = $item->browseDocuments($interactif_id, $visiteur_id, array('page_size' => $page_size, 'offset' => $offset));
                 if (count($doc)) {
                     $docs[] = $doc;
                 }
             }
             if (count($docs)) {
                 $results = array_merge($results, array("documents" => $docs));
             }
         } else {
             $doc = $item->browseDocuments($interactif_id, "", array('page_size' => $page_size, 'offset' => $offset));
             if (count($doc)) {
                 $results = array_merge($results, array("documents" => $doc));
             }
         }
     }
     if (count($results) > 0) {
         $results = array($results);
     }
     $this->output = $serializer->serialize($results, 'result');
     return sfView::SUCCESS;
 }
 public function executeSave_indicator(sfWebRequest $request)
 {
     $request->setRequestFormat('json');
     $indicadorId = $request->getParameter('indicatorId');
     $titulo = $request->getParameter('title');
     $descripcion = $request->getParameter('description');
     $valor_minimo = $request->getParameter('valueMin');
     $valor_deseado = $request->getParameter('valueDes');
     $valor_optimo = $request->getParameter('valueOpt');
     $responsable_id = $request->getParameter('responsableId');
     $responsable_email = $request->getParameter('responsableEmail');
     $grupo_trabajo_id = $request->getParameter('workGroup');
     $conector_id = $request->getParameter('conectorId');
     /* Google, Facebook, Twitter */
     $attribute_id = $request->getParameter('attributeId');
     $tableId = $request->getParameter('tableId');
     $facebook_username = $request->getParameter('facebook_username');
     $twitter_username = $request->getParameter('twitter_username');
     $fec_ini = $request->getParameter('fec_ini');
     $fec_fin = $request->getParameter('fec_fin');
     $json_children = $request->getParameter('indicatorChildren');
     $oaux_manejo_data = $request->getParameter('oaux_manejo_data');
     $json = json_decode($json_children);
     if (count($json) > 0) {
         foreach ($json as $row) {
             $indicador_children = IndicatorsScPeer::retrieveByPK($row->{'pk'});
             $indicador_children->setConectoresConfigure($row->{'values'});
             $indicador_children->save();
         }
     }
     //primero validamos y esta logeado
     //segundo validamos si el idicador existe
     //tercero verificamos si se asigno un usuario
     //(si se le asigno un usuario)cuarto vamos a revisar si el usuario que es asignado esta en e grupo de trabajo
     /*si no esta en grupo de trabajo envio una solictud ( antes verifico si no le mande una solicitud antes)
      * por que no se va estar mandando varias solicitudes al mismo usuario
      * en este caso las solicitudes son 1 vez por grupo de trabajo y no por indicador
      */
     //despues de vefiricar grabamos la primera vesion del indicador con los datos secundarios
     $user = $this->getUser()->getAttribute(sfConfig::get('app_session_current_user'), null);
     if ($user != null) {
         $indicador = IndicatorsScPeer::retrieveByPK($indicadorId);
         if (is_object($indicador)) {
             if ($responsable_email != "") {
                 /* aca vamos crear el registro de asignaciones, esta tabla me permite manejar un
                    historial  de las asignacion de resposanble x indicador
                    asi podre ver todas los responsables de un determinado indicador.*/
                 $asignacion_indicador = new AsignacionSc();
                 $asignacion_indicador->setGrupoId($grupo_trabajo_id);
                 $asignacion_indicador->setEmail($responsable_email);
                 $asignacion_indicador->setTreeId($indicador->getTreeId());
                 $asignacion_indicador->setIndicadorId($indicador->getId());
                 $asignacion_indicador->setCreateAt(time());
                 $asignacion_indicador->setUpdateAt(time());
                 /**********************************************************************/
                 if ($responsable_id != "") {
                     /*
                      *
                      */
                     if ($responsable_id != $indicador->getResponsableId()) {
                         $serviceDataIndicadores = new dataIndicadoresImplementation();
                         $serviceDataIndicadores->changeOwnerIndicadores($indicador, $responsable_id);
                     }
                     /******************************************/
                     $asignacion_indicador->setFlag(json_encode(array("estado" => true, "owner_id" => $user->getId())));
                     $asignacion_indicador->setUserId($responsable_id);
                     $indicador->setResponsableId($responsable_id);
                     $indicador->setEmailResponsable($responsable_email);
                 } else {
                     //envio solicitud
                     //antes verificar si no le enviando una solicitud antes
                     $rsp = $this->evaluar_solicitud($responsable_email, $grupo_trabajo_id, $user);
                     if ($rsp['success']) {
                         $criterio = new Criteria();
                         $criterio->add(DetalleGrupoTrabajoScPeer::EMAIL, '%' . $responsable_email . '%', Criteria::LIKE);
                         $criterio->add(DetalleGrupoTrabajoScPeer::GRUPO_ID, $grupo_trabajo_id);
                         $cantidad = DetalleGrupoTrabajoScPeer::doCount($criterio);
                         if ($cantidad <= 0) {
                             $newDetalle = new DetalleGrupoTrabajoSc();
                             $newDetalle->setEmail($responsable_email);
                             $newDetalle->setGrupoId($grupo_trabajo_id);
                             $newDetalle->save();
                         }
                         $indicador->setEmailResponsable($responsable_email);
                         $indicador->setResponsableId(null);
                         $asignacion_indicador->setFlag(json_encode(array("estado" => false, "owner_id" => $user->getId())));
                     } else {
                         $this->message = $rsp['message'];
                         return sfView::ERROR;
                     }
                 }
                 $asignacion_indicador->save();
             } else {
                 $indicador->setResponsableId(null);
                 $indicador->setEmailResponsable('');
             }
             if ($descripcion != "") {
                 $indicador->setDescripcion($descripcion);
             }
             if ($valor_minimo != "") {
                 $indicador->setValorMinimo($valor_minimo);
             }
             if ($valor_deseado != "") {
                 $indicador->setValorDeseado($valor_deseado);
             }
             if ($valor_optimo != "") {
                 $indicador->setValorOptimo($valor_optimo);
             }
             if ($titulo != "") {
                 $indicador->setTitulo($titulo);
             }
             if ($oaux_manejo_data == '1') {
                 /* ingreso manual */
                 $indicador->setDetNetworkAttributeId(null);
                 $indicador->setUsernameInNetwork(null);
                 $indicador->setValorActualEntregado(0);
                 $indicador->setGaFecIni(null);
                 $indicador->setGaFecFin(null);
             } elseif ($oaux_manejo_data == '2') {
                 /* ingreso automatico */
                 if ($conector_id != '' && $attribute_id != '') {
                     $c = new Criteria();
                     $c->add(NetworkPeer::NAME, $conector_id);
                     $c->add(DetNetworkAttributePeer::ATTRIBUTE_ID, $attribute_id);
                     $c->addJoin(NetworkPeer::ID, DetNetworkAttributePeer::NETWORK_ID);
                     $det_network_attribute = DetNetworkAttributePeer::doSelectOne($c);
                     if ($conector_id == 'Facebook') {
                         if ($facebook_username != '') {
                             $indicador->setDetNetworkAttributeId($det_network_attribute->getId());
                             $indicador->setUsernameInNetwork($facebook_username);
                             /* se extrae valor de la consulta */
                             $data = $this->privateFunctionGetFacebookData($facebook_username, $det_network_attribute->getId());
                             if ($data != null) {
                                 $indicador->setValorActualEntregado($data);
                             } else {
                                 $indicador->setValorActualEntregado(0);
                             }
                         } else {
                             $indicador->setDetNetworkAttributeId(null);
                             $indicador->setUsernameInNetwork(null);
                             $indicador->setValorActualEntregado(0);
                             $indicador->setGaFecIni(null);
                             $indicador->setGaFecFin(null);
                         }
                     } elseif ($conector_id == 'Twitter') {
                         if ($twitter_username != '') {
                             $indicador->setDetNetworkAttributeId($det_network_attribute->getId());
                             $indicador->setUsernameInNetwork($twitter_username);
                             /* se extrae valor de la consulta */
                             $data = $this->privateFunctionGetTwitterData($twitter_username, $det_network_attribute->getId());
                             $indicador->setValorActualEntregado($data);
                         } else {
                             $indicador->setDetNetworkAttributeId(null);
                             $indicador->setUsernameInNetwork(null);
                             $indicador->setValorActualEntregado(0);
                             $indicador->setGaFecIni(null);
                             $indicador->setGaFecFin(null);
                         }
                     } elseif ($conector_id == 'Google Analytics') {
                         if ($tableId != '' && $tableId != 'null') {
                             $indicador->setDetNetworkAttributeId($det_network_attribute->getId());
                             $indicador->setUsernameInNetwork($tableId);
                             /* se extrae valor de la consulta */
                             $data = $this->privateFunctionGetGoogleAnalyticsData($indicador->getId(), $tableId, $fec_ini, $fec_fin, $det_network_attribute->getId());
                             $indicador->setGaFecIni($fec_ini);
                             $indicador->setGaFecFin($fec_fin);
                             $indicador->setValorActualEntregado($data);
                         } else {
                             if (is_object($det_network_attribute)) {
                                 $indicador->setDetNetworkAttributeId($det_network_attribute->getId());
                             } else {
                                 $indicador->setDetNetworkAttributeId(null);
                             }
                             $indicador->setUsernameInNetwork(null);
                             $indicador->setValorActualEntregado(0);
                             $indicador->setGaFecIni(null);
                             $indicador->setGaFecFin(null);
                         }
                     }
                 } else {
                     $indicador->setDetNetworkAttributeId(null);
                     $indicador->setUsernameInNetwork(null);
                     $indicador->setValorActualEntregado(0);
                     $indicador->setGaFecIni(null);
                     $indicador->setGaFecFin(null);
                 }
             }
             $indicador->save();
         } else {
             $this->message = 'not found indicator';
             return sfView::ERROR;
         }
     } else {
         $this->message = 'session expired';
         return sfView::ERROR;
     }
 }
Beispiel #21
0
 /**
  * Retrieves a  collection of Exposition objects
  * @param   sfWebRequest   $request a request object
  * @return  string
  */
 public function executeIndex(sfWebRequest $request)
 {
     $this->forward404Unless($request->isMethod(sfRequest::GET));
     $params = $request->getParameterHolder()->getAll();
     // notify an event before the action's body starts
     $this->dispatcher->notify(new sfEvent($this, 'sfDoctrineRestGenerator.get.pre', array('params' => $params)));
     $request->setRequestFormat('html');
     //get the is_active param
     if (isset($params['is_active'])) {
         $is_active = $params['is_active'];
     }
     $params = $this->cleanupParameters($params);
     try {
         $format = $this->getFormat();
         $this->validateIndex($params);
     } catch (Exception $e) {
         $this->getResponse()->setStatusCode(406);
         $serializer = $this->getSerializer();
         $this->getResponse()->setContentType($serializer->getContentType());
         $error = $e->getMessage();
         // event filter to enable customisation of the error message.
         $result = $this->dispatcher->filter(new sfEvent($this, 'sfDoctrineRestGenerator.filter_error_output'), $error)->getReturnValue();
         if ($error === $result) {
             $error = array(array('message' => $error));
             $this->output = $serializer->serialize($error, 'error');
         } else {
             $this->output = $serializer->serialize($result);
         }
         return sfView::SUCCESS;
     }
     $this->queryExecute($params);
     $isset_pk = (!isset($isset_pk) || $isset_pk) && isset($params['guid']);
     if ($isset_pk && count($this->objects) == 0) {
         $request->setRequestFormat($format);
         $this->forward404();
     }
     //Filter by exposition_id
     if (isset($is_active)) {
         $new_object = array();
         foreach ($this->objects as $key => $object) {
             if (isset($object["end_at"])) {
                 $date1 = new DateTime("now");
                 $date2 = new DateTime($object["end_at"]);
                 if ($is_active == true) {
                     if ($date2 > $date1) {
                         $new_object[] = $this->objects[$key];
                     }
                 } else {
                     if ($date2 < $date1) {
                         $new_object[] = $this->objects[$key];
                     }
                 }
             }
         }
         $this->objects = $new_object;
     }
     // configure the fields of the returned objects and eventually hide some
     $this->setFieldVisibility();
     $this->configureFields();
     $serializer = $this->getSerializer();
     $this->getResponse()->setContentType($serializer->getContentType());
     $this->output = $serializer->serialize($this->objects, $this->model);
     unset($this->objects);
 }