Created
April 13, 2011 05:58
-
-
Save bshaffer/917043 to your computer and use it in GitHub Desktop.
Old Admin: from actions.class.php - batchAction
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
abstract class autoSf_guard_user_oldActions extends sfActions | |
{ | |
// .... | |
public function executeBatch(sfWebRequest $request) | |
{ | |
$request->checkCSRFProtection(); | |
if (!$ids = $request->getParameter('ids')) | |
{ | |
$this->getUser()->setFlash('error', 'You must at least select one item.'); | |
$this->redirect('@sf_guard_user_sf_guard_user_old'); | |
} | |
if (!$action = $request->getParameter('batch_action')) | |
{ | |
$this->getUser()->setFlash('error', 'You must select an action to execute on the selected items.'); | |
$this->redirect('@sf_guard_user_sf_guard_user_old'); | |
} | |
if (!method_exists($this, $method = 'execute'.ucfirst($action))) | |
{ | |
throw new InvalidArgumentException(sprintf('You must create a "%s" method for action "%s"', $method, $action)); | |
} | |
if (!$this->getUser()->hasCredential($this->configuration->getCredentials($action))) | |
{ | |
$this->forward(sfConfig::get('sf_secure_module'), sfConfig::get('sf_secure_action')); | |
} | |
$validator = new sfValidatorDoctrineChoice(array('multiple' => true, 'model' => 'sfGuardUser')); | |
try | |
{ | |
// validate ids | |
$ids = $validator->clean($ids); | |
// execute batch | |
$this->$method($request); | |
} | |
catch (sfValidatorError $e) | |
{ | |
$this->getUser()->setFlash('error', 'A problem occurs when deleting the selected items as some items do not exist anymore.'); | |
} | |
$this->redirect('@sf_guard_user_sf_guard_user_old'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment