Files
grzanieplus.pl/plugins/sfGuardPlugin/lib/model/sfGuardUserPeer.php
2025-03-12 17:06:23 +01:00

53 lines
1.5 KiB
PHP

<?php
/*
* This file is part of the symfony package.
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/**
*
* @package symfony
* @subpackage plugin
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
* @version SVN: $Id: sfGuardUserPeer.php 4 2008-09-24 08:40:58Z marek $
*/
class sfGuardUserPeer extends BasesfGuardUserPeer
{
public static function retrieveByUsername($username, $isActive = true)
{
$c = new Criteria();
$c->add(self::USERNAME, $username);
$c->add(self::IS_ACTIVE, $isActive);
return self::doSelectOne($c);
}
/**
* Tworzy nową instancję modelu użytkownika i ustawia go jako anonymowego
* Użytkownik nie jest zapisywany do bazy i wymaga wywołania sfGuardUser::save()
*
* @param string $username Nazwa użytkownika/email
* @return sfGuardUser|null
* @throws sfException
* @throws sfException
* @throws PropelException
*/
public static function createAnonymous($username)
{
$user = new sfGuardUser();
$user->setUsername($username);
$user->setPassword('anonymous');
$user->setHashCode(md5(microtime()));
$group = sfGuardGroupPeer::retrieveByName('user');
$guardUserGroup = new sfGuardUserGroup();
$guardUserGroup->setGroupId($group->getId());
$user->addsfGuardUserGroup($guardUserGroup);
return $user;
}
}