当前位置: 首页>>代码示例>>PHP>>正文


PHP sfGuardUserPeer::retrieveByUsername方法代码示例

本文整理汇总了PHP中sfGuardUserPeer::retrieveByUsername方法的典型用法代码示例。如果您正苦于以下问题:PHP sfGuardUserPeer::retrieveByUsername方法的具体用法?PHP sfGuardUserPeer::retrieveByUsername怎么用?PHP sfGuardUserPeer::retrieveByUsername使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sfGuardUserPeer的用法示例。


在下文中一共展示了sfGuardUserPeer::retrieveByUsername方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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);
 }
开发者ID:havvg,项目名称:sfNotificationsPlugin,代码行数:29,代码来源:NotificationTest.php

示例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')));
 }
开发者ID:nvidela,项目名称:kimkelen,代码行数:28,代码来源:sfGuardValidatorUser.class.php

示例3: 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;
 }
开发者ID:xfifix,项目名称:Jenkins-Khan,代码行数:38,代码来源:ValidatorUser.class.php

示例4: retrieveByUsername

 public static function retrieveByUsername($value)
 {
     $user = sfGuardUserPeer::retrieveByUsername($value);
     if ($user != null) {
         return $user->getProfile();
     }
     return null;
 }
开发者ID:sgrove,项目名称:cothinker,代码行数:8,代码来源:sfGuardUserProfilePeer.php

示例5: 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);
 }
开发者ID:vcgato29,项目名称:poff,代码行数:14,代码来源:sfFacebookSecurityFilter.class.php

示例6: 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;
 }
开发者ID:sgrove,项目名称:cothinker,代码行数:9,代码来源:userUniqueValidator.class.php

示例7: 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']));
 }
开发者ID:ketheriel,项目名称:ETVA,代码行数:13,代码来源:sfGuardAddPermissionTask.class.php

示例8: execute

 public function execute(&$value, &$error)
 {
     sfPropelApprovableBehavior::disable();
     if (sfGuardUserPeer::retrieveByUsername($value) == false) {
         $error = $this->getParameter('user_error');
         $error = "Sorry, couldn't find {$value} in our records - probably means no one signed up using this name.";
         return false;
     }
     return true;
 }
开发者ID:sgrove,项目名称:cothinker,代码行数:10,代码来源:userExistsValidator.class.php

示例9: 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->setIsSuperAdmin(true);
     $user->save();
     $this->logSection('guard', sprintf('Promote user %s as a super administrator', $arguments['username']));
 }
开发者ID:ketheriel,项目名称:ETVA,代码行数:14,代码来源:sfGuardCreateAdminTask.class.php

示例10: 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->setPassword($arguments['password']);
     $user->save();
     $this->logSection('guard', sprintf('Password changed successfully for user %s', $arguments['username']));
 }
开发者ID:bradInside,项目名称:sfGuardPlugin,代码行数:14,代码来源:sfGuardChangePasswordTask.class.php

示例11: save

 public function save($con = null)
 {
     if ($this->getUserId() == null) {
         if (sfContext::getInstance()->getUser()->isAuthenticated()) {
             $this->setUserId(sfContext::getInstance()->getUser()->getId());
         } else {
             $user = sfGuardUserPeer::retrieveByUsername('admin');
             $this->setUserId($user->getId());
         }
     }
     parent::save();
 }
开发者ID:sgrove,项目名称:cothinker,代码行数:12,代码来源:HistoryEvent.php

示例12: executeViewProfile

 public function executeViewProfile()
 {
     $username = $this->getRequestParameter('username');
     $this->user = sfGuardUserPeer::retrieveByUsername($username);
     $c = new Criteria();
     $c->add(SnippetPeer::USER_ID, $this->user->getId());
     $c->add(SnippetPeer::DRAFT, false);
     $this->snippet_count = SnippetPeer::doCount($c);
     $this->pager = new sfPropelPager('Snippet', sfConfig::get('app_pager', 10));
     $this->pager->setCriteria($c);
     $this->pager->setPage($this->getRequestParameter('page', 1));
     $this->pager->init();
 }
开发者ID:hoydaa,项目名称:snippets.hoydaa.org,代码行数:13,代码来源:actions.class.php

示例13: execute

 public function execute(&$value, &$error)
 {
     $password_field = $this->getParameterHolder()->get('password_field');
     $password = $this->getContext()->getRequest()->getParameter($password_field);
     $remember = false;
     $remember_field = $this->getParameterHolder()->get('remember_field');
     $remember = $this->getContext()->getRequest()->getParameter($remember_field);
     $username = $value;
     $authMessage = '';
     $TEST_MODE = sfConfig::get('app_stKerberosPlugin_skip_auth', false);
     if ($TEST_MODE !== true && !extension_loaded('krb5')) {
         if (!@dl('krb5.so')) {
             $error = "{netid_auth} krb5 extension unavailable";
             if (sfConfig::get('sf_logging_enabled')) {
                 sfContext::getInstance()->getLogger()->alert($error);
             }
             return false;
         }
     }
     if ($TEST_MODE === true && !extension_loaded('krb5')) {
         $kerb_constants = array('KRB5_OK', 'KRB5_NOTOK', 'KRB5_BAD_PASSWORD', 'KRB5_BAD_USER');
         foreach ($kerb_constants as $k => $v) {
             define($v, 100 + $k);
             // arbitrarily assign a value to each constant
         }
     }
     // netid_auth will set authMessage with an error message
     // and may also set protected loginAs variable
     if (KRB5_OK === $this->netid_auth($username, $password, $authMessage)) {
         // get or retrieve the sf_guard user associated with this kerberos username
         $user = sfGuardUserPeer::retrieveByUsername($username);
         if ($user) {
             $this->getContext()->getUser()->signIn($user, $remember);
             // If this is an admin user and they logged in with two usernames,
             // reauthenticate as that second username.
             if ($this->loginAs !== false && $this->getContext()->getUser()->hasCredential(array('admin'), false)) {
                 $otherUser = sfGuardUserPeer::retrieveByUsername($this->loginAs);
                 if ($otherUser) {
                     $this->getContext()->getUser()->signIn($otherUser, false);
                 }
             }
         } else {
             // if there is no user create one
             $user = $this->createUserAndProfile($username);
             $this->getContext()->getUser()->signin($user, $remember);
         }
         return true;
     }
     $error = $this->getParameterHolder()->get('username_error', $authMessage);
     return false;
 }
开发者ID:stereoscott,项目名称:stKerberosPlugin,代码行数:51,代码来源:stKerberosValidator.php

示例14: retrieveUserByEmail

 public static function retrieveUserByEmail($email)
 {
     sfContext::getInstance()->getLogger()->info('checking to see if [' . $email . '] is a username...');
     $user = sfGuardUserPeer::retrieveByUsername($email);
     if ($user != null) {
         return $user;
     }
     sfContext::getInstance()->getLogger()->info('checking to see if [' . $email . '] is in any contacts...');
     $user = sfGuardUserProfilePeer::retrieveByEmail($email);
     if ($user != null) {
         return $user->getsfGuardUser();
     }
     return $user;
 }
开发者ID:sgrove,项目名称:cothinker,代码行数:14,代码来源:myToolkit.class.php

示例15: doClean

 /**
  * @see sfValidatorBase
  */
 protected function doClean($value)
 {
     $clean = $value;
     mysfLog::log($this, "{$clean}");
     // check for active user
     if (sfGuardUserPeer::retrieveByUsername($clean, true)) {
         throw new sfValidatorError($this, 'used', array('value' => $value));
     }
     // check for not active user
     if (sfGuardUserPeer::retrieveByUsername($clean, false)) {
         throw new sfValidatorError($this, 'used', array('value' => $value));
     }
     return $clean;
 }
开发者ID:EQ4,项目名称:smint,代码行数:17,代码来源:EmailNotInUseValidator.class.php


注:本文中的sfGuardUserPeer::retrieveByUsername方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。