* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /** * Promote a user as a super administrator. * * @package symfony * @subpackage task * @author Fabien Potencier * @version SVN: $Id: sfGuardCreateAdminTask.class.php 8637 2008-04-27 10:24:36Z nicolas $ */ class sfGuardPromoteSuperAdminTask extends sfDoctrineBaseTask { /** * @see sfTask */ protected function configure() { $this->addArguments(array( new sfCommandArgument('username', sfCommandArgument::REQUIRED, 'The user name'), )); $this->addOptions(array( new sfCommandOption('application', null, sfCommandOption::PARAMETER_OPTIONAL, 'The application name', null), new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'), new sfCommandOption('connection', null, sfCommandOption::PARAMETER_REQUIRED, 'The connection name', 'propel'), )); $this->namespace = 'guard'; $this->name = 'promote'; $this->briefDescription = 'Promotes a user as a super administrator'; $this->detailedDescription = <<configuration); $user = Doctrine::getTable('sfGuardUser')->findOneByUsername($arguments['username']); if (!$user) { throw new sfCommandException(sprintf('User "%s" does not exist.', $arguments['username'])); } $user->setIsSuperAdmin(true); $user->save(); $this->logSection('guard', sprintf('Promote user %s as a super administrator', $arguments['username'])); } }