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


PHP sfGuardUser::getUsername方法代码示例

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


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

示例1: executeRegister

 /**
  * executeRegister
  *
  * @access public
  * @return void
  */
 public function executeRegister(sfWebRequest $request)
 {
     $this->form = new sfGuardFormRegister();
     if ($request->isMethod(sfRequest::POST)) {
         $this->form->bind($request->getParameter($this->form->getName()));
         if ($this->form->isValid()) {
             $values = $this->form->getValues();
             $sfGuardUser = new sfGuardUser();
             $sfGuardUser->fromArray($values, BasePeer::TYPE_FIELDNAME);
             if (isset($values['email'])) {
                 $sfGuardUser->setEmail($values['email']);
             }
             $sfGuardUser->setIsActive(false);
             $sfGuardUser->save();
             $messageParams = array('sfGuardUser' => $sfGuardUser, 'password' => $values['password']);
             $body = $this->getComponent($this->getModuleName(), 'send_request_confirm', $messageParams);
             $from = sfConfig::get('app_sf_guard_extra_plugin_mail_from', 'noreply@example.org');
             $fromName = sfConfig::get('app_sf_guard_extra_plugin_name_from', 'noreply');
             $to = $sfGuardUser->getEmail();
             $toName = $sfGuardUser->getUsername();
             $subject = sfConfig::get('app_sf_guard_extra_plugin_subject_confirm', 'Confirm Registration');
             $mailer = $this->getMailer();
             $message = $mailer->compose(array($from => $fromName), array($to => $toName), $subject, $body);
             $mailer->send($message);
             $this->getUser()->setFlash('values', $values);
             $this->getUser()->setFlash('sfGuardUser', $sfGuardUser);
             return $this->redirect('@sf_guard_do_register');
         }
     }
 }
开发者ID:lendji4000,项目名称:compose,代码行数:36,代码来源:BasesfGuardRegisterActions.class.php

示例2: sfSimpleForumPost

$msg2->setUserId($user2->getId());
$msg2->save();
$topic = sfSimpleForumTopicPeer::retrieveByPk($topic->getId());
$t->is($topic->getNbPosts(), 2, 'Adding a second message increments the topic number of posts');
$t->is($topic->getNbReplies(), 1, 'A topic can calculate its number of replies based on its number of posts');
$t->is($topic->getUpdatedAt('U'), $msg2->getCreatedAt('U'), 'Adding a second message changes the latest reply date of the topic to the message creation date');
$t->is($topic->getLatestPost()->getAuthorName(), $user2->getUsername(), 'Adding a second message changes the latest reply author name to the message author name');
sleep(1);
$msg3 = new sfSimpleForumPost();
$msg3->setTopicId($topic->getId());
$msg3->setUserId($user3->getId());
$msg3->save();
$topic = sfSimpleForumTopicPeer::retrieveByPk($topic->getId());
$t->is($topic->getNbPosts(), 3, 'Adding a third message increments the topic number of replies');
$t->is($topic->getUpdatedAt('U'), $msg3->getCreatedAt('U'), 'Adding a third message changes the latest reply date of the topic to the message creation date');
$t->is($topic->getLatestPost()->getAuthorName(), $user3->getUsername(), 'Adding a third message changes the latest reply author name to the  message author name');
$t->diag('Updating a message');
sleep(1);
$msg1 = sfSimpleForumPostPeer::retrieveByPk($msg1->getId());
$msg1->setTitle('this is a test');
$msg1->save();
$topic = sfSimpleForumTopicPeer::retrieveByPk($topic->getId());
$t->is($topic->getNbPosts(), 3, 'Updating a message doesn\'t change the topic post count');
$t->is($topic->getUpdatedAt('U'), $msg3->getCreatedAt('U'), 'Updating a message doesn\'t change the topic\'s last update date');
$t->is($topic->getLatestPost()->getId(), $msg3->getId(), 'Updating a message doesn\'t change the topic\'s latest reply');
$forum = sfSimpleForumForumPeer::retrieveByPk($forum->getId());
$t->is($forum->getNbPosts(), 3, 'Updating a message doesn\'t change the forum\'s post count');
$t->is($forum->getUpdatedAt('U'), $msg3->getCreatedAt('U'), 'Updating a message doesn\'t change the forum\'s last update date');
$t->is($forum->getLatestPost()->getId(), $msg3->getId(), 'Updating a message doesn\'t change the forum\'s last reply');
$t->diag('Updating the topic');
sleep(1);
开发者ID:kriswallsmith,项目名称:sfSimpleForumPlugin,代码行数:31,代码来源:sfSimpleForumPostTest.php

示例3: createUserAndProfile

 protected function createUserAndProfile($username, $con = null)
 {
     // no user with this username
     if (null === $con) {
         $con = Propel::getConnection(sfGuardUserPeer::DATABASE_NAME);
     }
     try {
         $con->begin();
         // create a new user object
         $user = new sfGuardUser();
         $user->setUsername($username);
         $user->setIsActive(1);
         $user->setAlgorithm('');
         $user->save($con);
         // do we have a profile in the system with this net_id?
         // this could happen if the profile was added manually by an admin
         $userProfile = UserProfilePeer::selectByNetIdWithNoUserId($username);
         if ($userProfile) {
             // there is already a dangling user profile with this net id, link the user with the profile
             $userProfile->setUserId($user->getId());
             $userProfile->save($con);
         } else {
             // make a new user profile
             $userProfile = new UserProfile();
             $userProfile->setUserId($user->getId());
             $userProfile->setNetId($user->getUsername());
             $userProfile->save($con);
         }
         $con->commit();
     } catch (PropelException $e) {
         $con->rollback();
         throw $e;
     }
     return $user;
 }
开发者ID:stereoscott,项目名称:stKerberosPlugin,代码行数:35,代码来源:stKerberosValidator.php

示例4: executeSignin

 public function executeSignin($request)
 {
     $this->op = $request->getParameter('op');
     //echo $this->op;
     //die;
     $dialog = $request->getParameter('dialog', false);
     /* IF FB CONNECT */
     if ($this->op == 'fbc' && ($facebook_uid = VoFacebook::getUid())) {
         //echo "FBC";die;
         $c = new Criteria();
         $c->addJoin(SfGuardUserProfilePeer::USER_ID, SfGuardUserPeer::ID);
         $c->add(SfGuardUserProfilePeer::FACEBOOK_UID, $facebook_uid);
         $sfGuardUser = SfGuardUserPeer::doSelectOne($c);
         if (!$sfGuardUser instanceof sfGuardUser) {
             // Comprobación de que no existe ya el usuario con ese username (bug #734)
             $c = new Criteria();
             $c->add(sfGuardUserPeer::USERNAME, 'Facebook_' . $facebook_uid);
             $existingUser = sfGuardUserPeer::doSelectOne($c);
             if ($existingUser) {
                 $existingUser->setUsername('Facebook_' . $facebook_uid . '-' . time());
                 $existingUser->save();
             }
             $sfGuardUser = new sfGuardUser();
             $sfGuardUser->setUsername('Facebook_' . $facebook_uid);
             $sfGuardUser->save();
             $voProfile = $sfGuardUser->getProfile();
             $vanityUrl = SfVoUtil::encodeVanity('Facebook_' . $facebook_uid);
             $voProfile->setFacebookUid($facebook_uid);
             if (!$voProfile->getNombre()) {
                 $data = VoFacebook::getData($voProfile->getFacebookUid());
                 $voProfile->setNombre($data->first_name);
                 $voProfile->setApellidos($data->last_name);
             }
             $c2 = new Criteria();
             $c2->add(SfGuardUserProfilePeer::VANITY, "{$vanityUrl}%", Criteria::LIKE);
             $usuariosLikeMe = SfGuardUserProfilePeer::doSelect($c2);
             $counter = 0;
             foreach ($usuariosLikeMe as $usuarioLikeMe) {
                 if (preg_match("/^Facebook_{$facebook_uid}-([0-9]*)/i", $usuarioLikeMe->getVanity(), $matches)) {
                     $curIdx = $matches[1];
                     if ($curIdx > $counter) {
                         $counter = $curIdx + 1;
                     }
                 } else {
                     $counter++;
                 }
             }
             $voProfile->setVanity("{$vanityUrl}" . ($counter == 0 ? '' : "-{$counter}"));
             $voProfile->setMailsComentarios(0);
             $voProfile->setMailsNoticias(0);
             $voProfile->setMailsContacto(0);
             $voProfile->setMailsSeguidor(0);
             $voProfile->save();
         }
         $this->getUser()->signin($sfGuardUser, false);
         $signinUrl = sfConfig::get('app_sf_guard_plugin_success_signin_url', $this->getUser()->getReferer('@homepage'));
         $this->redirect($signinUrl);
     }
     /* FI FB CONNECT */
     $this->registrationform = new RegistrationForm();
     $this->signinform = new SigninForm();
     if ($request->isMethod('post') && !$dialog) {
         // Register
         if ($this->op == 'r') {
             $this->registrationform = new RegistrationForm();
             $this->registrationform->bind($request->getParameter('registration'));
             if ($this->registrationform->isValid()) {
                 $user = new sfGuardUser();
                 $user->setUsername($this->registrationform->getValue('username'));
                 $user->setPassword($this->registrationform->getValue('password'));
                 $user->setIsActive(0);
                 $user->setCreatedAt(time());
                 $c = new Criteria();
                 $c->add(sfGuardUserPeer::USERNAME, $user->getUsername());
                 sfGuardUserPeer::doInsert($user);
                 $user = sfGuardUserPeer::doSelect($c);
                 if (count($user) == 1) {
                     $profile = $user[0]->getProfile();
                     $profile->setNombre($this->registrationform->getValue('nombre'));
                     $profile->setApellidos($this->registrationform->getValue('apellidos'));
                     $profile->setPresentacion($this->registrationform->getValue('presentacion'));
                     $profile->setAnonymous($this->registrationform->getValue('anonymous'));
                     $profile->setCodigo(util::generateUID());
                     /* Generar vanity */
                     if ($profile->getVanity() == '') {
                         $vanityUrl = SfVoUtil::encodeVanity($profile->getNombre() . "-" . $profile->getApellidos());
                         $c2 = new Criteria();
                         $c2->add(SfGuardUserProfilePeer::VANITY, "{$vanityUrl}%", Criteria::LIKE);
                         $c2->add(SfGuardUserProfilePeer::ID, $user[0]->getId(), Criteria::NOT_EQUAL);
                         $usuariosLikeMe = SfGuardUserProfilePeer::doSelect($c2);
                         $counter = 0;
                         foreach ($usuariosLikeMe as $usuarioLikeMe) {
                             $counter++;
                         }
                         $profile->setVanity("{$vanityUrl}" . ($counter == 0 ? '' : "-{$counter}"));
                     }
                     /* Fin Generar vanity */
                     sfGuardUserProfilePeer::doInsert($profile);
                     $this->sendWelcome($user[0]);
                     $this->user = $user[0];
//.........这里部分代码省略.........
开发者ID:voota,项目名称:voota,代码行数:101,代码来源:actions.class.php


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