本文整理汇总了PHP中sfWebRequest::setRequestFormat方法的典型用法代码示例。如果您正苦于以下问题:PHP sfWebRequest::setRequestFormat方法的具体用法?PHP sfWebRequest::setRequestFormat怎么用?PHP sfWebRequest::setRequestFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfWebRequest
的用法示例。
在下文中一共展示了sfWebRequest::setRequestFormat方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: executeCreate
/**
* 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();
}
示例2: executeUndo_tree_ajax
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;
}
}
示例3: executeCreate_tree
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;
}
}
示例4: executeView
/**
* 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;
}
示例5: executeSave_bost_group
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;
}
}
示例6: executeValidhash
/**
* 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);
}
示例7: executeCreate
/**
* 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;
}
示例8: executeTime
/**
* 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);
}
示例9: executeCollectAnonymousVisite
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;
}
}
示例10: executeIndex
/**
* 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);
}
示例11: executeCreate
/**
* 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);
}
示例12: executeSave_indicator
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;
}
}
示例13: executeCreate
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();
}
示例14: executeNeeds
/**
* 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));
}
示例15: executeShow_tree
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';
}
}