Source for file actions.class.php
Documentation is available at actions.class.php
require_once(sfConfig::get('sf_plugins_dir'). '/sfGuardPlugin/modules/sfGuardGroup/lib/BasesfGuardGroupActions.class.php');
* @subpackage sfGuardGroup
* @author Fabien Potencier
* @version SVN: $Id: actions.class.php 12965 2008-11-13 06:02:38Z fabien $
$this->sfGuardGroup_tableMap = sfGuardGroupPeer::getTableMap();
$this->sfGuardGroup_form = new sfGuardGroupForm();
$result = array('success'=> true);
$this->getResponse()->setHttpHeader("X-JSON", '()'); // set a header, (although it is empty, it is nicer than without a correct header. Filling the header with the result will not be parsed by extjs as far as I have seen).
return $this->renderText('{"metaData":{"totalProperty":"totalCount","root":"results","id":"id","fields":[{"name":"id","type":"int"},{"name":"firstname"},{"name":"lastname"},{"name":"username"},{"name":"email"},{"name":"active"},{"name":"updateTime"}]},"totalCount":1,"results":[{"id":160,"class":"TutorAccount","active":"Yes","createTime":new Date(1240424045000),"email":"wilt@moore.com","firstname":"Wsda","lastname":"Moore","note":"ssdf","password":"tota","updateTime":new Date(1240559517000),"username":"wilt"}]}');
* Used in server grid to list permissions group available
* return json array response
$groups = sfGuardGroupPeer::doSelect($c);
foreach ($groups as $group){
$elements[] = $group->toArray();
return $this->renderText($result);
$isAjax = $request->isXmlHttpRequest();
if(!$isAjax) return $this->redirect('@homepage');
if(!$request->isMethod('post')){
$info = array('success'=> false,'errors'=> 'Wrong parameters');
$error = $this->setJsonError($info);
return $this->renderText($error);
$this->form = new sfGuardGroupForm();
$error = $this->setJsonError($result);
return $this->renderText($error);
$this->getContext()->getResponse()->setHttpHeader("X-JSON", '()'); // set a header, (although it is empty, it is nicer than without a correct header. Filling the header with the result will not be parsed by extjs as far as I have seen).
return $this->renderText($result);
$isAjax = $request->isXmlHttpRequest();
if(!$isAjax) return $this->redirect('@homepage');
if(!$request->isMethod('post') && !$request->isMethod('put')){
$info = array('success'=> false,'errors'=> 'Wrong parameters');
$error = $this->setJsonError($info);
return $this->renderText($error);
if(!$sfGuardGroup = sfGuardGroupPeer::retrieveByPk($request->getParameter('id'))){
$error_msg = sprintf('Object sfGuardGroup does not exist (%s).', $request->getParameter('id'));
$info = array('success'=> false,'errors'=> $error_msg);
$error = $this->setJsonError($info);
return $this->renderText($error);
$sfGuardGroup->setByName($request->getParameter('field'), $request->getParameter('value'));
$result = array('success'=> true);
$this->getResponse()->setHttpHeader("X-JSON", '()'); // set a header, (although it is empty, it is nicer than without a correct header. Filling the header with the result will not be parsed by extjs as far as I have seen).
return $this->renderText($result);
$isAjax = $request->isXmlHttpRequest();
if(!$isAjax) return $this->redirect('@homepage');
if(!$sfGuardGroup = sfGuardGroupPeer::retrieveByPk($request->getParameter('id'))){
$error_msg = sprintf('Object sfGuardGroup does not exist (%s).', $request->getParameter('id'));
$info = array('success'=> false,'errors'=> $error_msg);
$error = $this->setJsonError($info);
return $this->renderText($error);
$result = array('success'=> true);
$this->getResponse()->setHttpHeader("X-JSON", '()'); // set a header, (although it is empty, it is nicer than without a correct header. Filling the header with the result will not be parsed by extjs as far as I have seen).
return $this->renderText($result);
$isAjax = $request->isXmlHttpRequest();
if(!$isAjax) return $this->redirect('@homepage');
$limit = $this->getRequestParameter('limit', 10);
$page = floor($this->getRequestParameter('start', 0) / $limit)+ 1;
$this->pager = new sfPropelPager('sfGuardGroup', $limit);
$this->pager->setCriteria($c);
$this->pager->setPage($page);
$this->pager->setPeerMethod('doSelect');
$this->pager->setPeerCountMethod('doCount');
foreach($this->pager->getResults() as $item)
$elements[] = $item->toArray();
'total' => $this->pager->getNbResults(),
$this->getResponse()->setHttpHeader("X-JSON", '()'); // set a header, (although it is empty, it is nicer than without a correct header. Filling the header with the result will not be parsed by extjs as far as I have seen).
return $this->renderText($result);
if ($this->getRequestParameter('sort')== '') return;
$column = sfGuardGroupPeer::translateFieldName(sfInflector::camelize($this->getRequestParameter('sort')), BasePeer::TYPE_PHPNAME, BasePeer::TYPE_COLNAME);
if ('asc' == strtolower($this->getRequestParameter('dir')))
$criteria->addAscendingOrderByColumn($column);
$criteria->addDescendingOrderByColumn($column);
$form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
$sfGuardGroup = $form->save();
$result = array('success'=> true,'insert_id'=> $sfGuardGroup->getId());
foreach ($form->getErrorSchema() as $field => $error)
$errors[$field] = $error->getMessage();
$result = array('success'=> false,'errors'=> $errors);
private function setJsonError($info,$statusCode = 400){
$this->getContext()->getResponse()->setStatusCode($statusCode);
$this->getContext()->getResponse()->setHttpHeader("X-JSON", '()');
|