本文整理汇总了PHP中sfGuardUserPeer类的典型用法代码示例。如果您正苦于以下问题:PHP sfGuardUserPeer类的具体用法?PHP sfGuardUserPeer怎么用?PHP sfGuardUserPeer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了sfGuardUserPeer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getSfGuardUser
function getSfGuardUser()
{
if (!$this->sf_guard_user) {
$this->sf_guard_user = sfGuardUserPeer::retrieveByPK($this->sf_guard_user_id);
}
return $this->sf_guard_user;
}
示例2: doClean
protected function doClean($values)
{
$username = isset($values[$this->getOption('username_field')]) ? $values[$this->getOption('username_field')] : '';
$password = isset($values[$this->getOption('password_field')]) ? $values[$this->getOption('password_field')] : '';
$remember = isset($values[$this->getOption('rememeber_checkbox')]) ? $values[$this->getOption('rememeber_checkbox')] : '';
$session_user = sfContext::getInstance()->getUser();
// user exists?
if ($user = sfGuardUserPeer::retrieveByUsername($username)) {
// password is ok?
if ($user->checkPassword($password)) {
/* Added for sfGuardSecurity */
$this->checkForceRedirectPasswordChange($user);
$session_user->setAttribute('sf_guard_secure_plugin_login_failure_detected', 0);
/* end */
return array_merge($values, array('user' => $user));
}
}
if ($this->getOption('check_login_failure')) {
/* Added for sfGuardSecurity */
sfGuardLoginFailure::trackFailure($username);
$this->checkSecurityAttack($username);
/* end */
}
if ($this->getOption('throw_global_error')) {
throw new sfValidatorError($this, 'invalid');
}
throw new sfValidatorErrorSchema($this, array($this->getOption('username_field') => new sfValidatorError($this, 'invalid')));
}
示例3: testNotify
/**
* @depends testNotifierExists
* @depends testConcreteNotificationExists
*/
public function testNotify()
{
/* @var $user sfGuardUser */
$user = sfGuardUserPeer::retrieveByUsername('Username');
$this->assertInstanceOf('sfGuardUser', $user);
/* @var $type NotificationType */
$type = NotificationTypePeer::retrieveByName('SimpleFile');
$this->assertInstanceOf('NotificationType', $type);
$criteria = new Criteria(NotificationConfigurationPeer::DATABASE_NAME);
$criteria->add(NotificationConfigurationPeer::NAME, 'Sample Configuration for SimpleFile');
$criteria->add(NotificationConfigurationPeer::NOTIFICATION_TYPE_ID, $type->getId());
$criteria->add(NotificationConfigurationPeer::USER_ID, $user->getId());
/* @var $configuration NotificationConfiguration */
$configuration = NotificationConfigurationPeer::doSelectOne($criteria);
$this->assertInstanceOf('NotificationConfiguration', $configuration);
$this->assertTrue($configuration->hasAttribute('filename'));
$notification = new TestConcreteNotification();
$notification->setNotificationConfiguration($configuration);
$data = array('Simple array', 'to put into a file.');
$notification->notify($data);
$filename = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'simple_notifications.log';
$content = file($filename);
$this->assertEquals($data, unserialize($content[0]));
unlink($filename);
}
示例4: executeDelete
public function executeDelete(sfWebRequest $request)
{
$request->checkCSRFProtection();
$this->forward404Unless($sfGuardUser = sfGuardUserPeer::retrieveByPk($request->getParameter('id')), sprintf('Object sfGuardUser does not exist (%s).', $request->getParameter('id')));
$sfGuardUser->delete();
$this->redirect('sfguarduser/index');
}
示例5: execute
/**
* @param sfWebRequest $request
* @return void
*/
public function execute($request)
{
$this->user = sfGuardUserPeer::retrieveByPK($request->getParameter('id'));
$this->forward404Unless($this->user, 'User Not Found');
$this->statusActions = StatusActionPeer::getStatusActionsForBoard($this->user->getId());
$this->commentBoards = CommentPeer::getCommentsForBoard($this->user->getId());
}
示例6: executeShow
/**
*Method responsible for showing only piece of advice. It transfers advice and author object
* @param sfWebRequest $request
*/
public function executeShow(sfWebRequest $request)
{
$myadvice = $this->getRoute()->getObject();
$this->thisauthor = sfGuardUserPeer::getUserBy($myadvice->getUserId());
$this->advice = $myadvice;
$this->forward404Unless($this->advice);
}
示例7: doClean
/**
* @see sfValidatorBase
*/
protected function doClean($values)
{
// only validate if username and password are both present
if (isset($values[$this->getOption('username_field')]) && isset($values[$this->getOption('password_field')])) {
$username = $values[$this->getOption('username_field')];
$password = $values[$this->getOption('password_field')];
// user exists?
if ($user = sfGuardUserPeer::retrieveByUsername($username)) {
// password is ok?
if ($user->getIsActive()) {
if (Configuration::get('ldap_enabled', false)) {
if (authLDAP::checkPassword($username, $password)) {
return array_merge($values, array('user' => $user));
}
} elseif ($user->checkPassword($password)) {
return array_merge($values, array('user' => $user));
}
}
} elseif (Configuration::get('ldap_enabled', false) && Configuration::get('ldap_create_user', false) && authLDAP::checkPassword($username, $password)) {
$user = new sfGuardUser();
$user->setUsername($username);
$user->save();
$profile = new Profile();
$profile->setSfGuardUserId($user->getId());
$profile->save();
return array_merge($values, array('user' => $user));
}
if ($this->getOption('throw_global_error')) {
throw new sfValidatorError($this, 'invalid');
}
throw new sfValidatorErrorSchema($this, array($this->getOption('username_field') => new sfValidatorError($this, 'invalid')));
}
// assume a required error has already been thrown, skip validation
return $values;
}
示例8: retrieveByUsername
public static function retrieveByUsername($value)
{
$user = sfGuardUserPeer::retrieveByUsername($value);
if ($user != null) {
return $user->getProfile();
}
return null;
}
示例9: doClean
protected function doClean($value)
{
$clean = (string) $value;
// user exists?
if (!is_null(sfGuardUserPeer::retrieveByUsernameOrEmail($clean))) {
return $value;
}
throw new sfValidatorError($this, 'invalid', array('value' => $value));
}
示例10: execute
/**
* Executes this filter.
*
* @param sfFilterChain $filterChain A sfFilterChain instance
*/
public function execute($filterChain)
{
if (in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', '::1'))) {
sfContext::getInstance()->getUser()->signin(sfGuardUserPeer::retrieveByUsername('fabriceb'));
} else {
sfFacebook::requireLogin();
}
parent::execute($filterChain);
}
示例11: tearDownAfterClass
public static function tearDownAfterClass()
{
parent::tearDownAfterClass();
NotificationConfigurationValuePeer::doDeleteAll();
NotificationConfigurationPeer::doDeleteAll();
NotificationTypeAttributePeer::doDeleteAll();
NotificationTypePeer::doDeleteAll();
sfGuardUserPeer::doDeleteAll();
}
示例12: getOtherUser
public function getOtherUser($user_id)
{
$id = $this->getOther($user_id);
if ($id != false) {
return sfGuardUserPeer::retrieveByPk($id);
} else {
return false;
}
}
示例13: doCall
protected function doCall()
{
$this->context = $this->getContext(true);
$admin = sfGuardUserPeer::retrieveByPk(1);
$this->context->getUser()->signIn($admin);
ob_start();
$this->context->getController()->dispatch();
$html = ob_get_clean();
}
示例14: execute
public function execute(&$value, &$error)
{
sfPropelApprovableBehavior::disable();
if (sfGuardUserPeer::retrieveByUsername($value) != null) {
$error = $this->getParameter('user_unique_error', "*This email is already registered with us. Did you need to <strong>reset your password</strong>?");
return false;
}
return true;
}
示例15: execute
/**
* @see sfTask
*/
protected function execute($arguments = array(), $options = array())
{
$databaseManager = new sfDatabaseManager($this->configuration);
$user = sfGuardUserPeer::retrieveByUsername($arguments['username']);
if (!$user) {
throw new sfCommandException(sprintf('User "%s" does not exist.', $arguments['username']));
}
$user->addPermissionByName($arguments['permission']);
$this->logSection('guard', sprintf('Add permission %s to user %s', $arguments['permission'], $arguments['username']));
}