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


PHP sfGuardUser::setCreatedAt方法代码示例

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


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

示例1: 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

示例2: processLdap

 /**
  *
  * @param sfWebRequest $request
  * @param LdapForm $form
  */
 protected function processLdap(sfWebRequest $request, LdapForm $form)
 {
     $form->bind($request->getParameter('signin'));
     if ($form->isValid()) {
         $values = $form->getValues();
         // Check if user already exists in the DB
         $user = Doctrine::getTable('sfGuardUser')->findOneByUsername($values["username"]);
         // If not, create an account for him
         if (empty($user)) {
             $datetime = date("Y-m-d H:i:s");
             // Create entry in sfGuardUser
             $sfGuardUser = new sfGuardUser();
             $sfGuardUser->setEmailAddress($values["username"]);
             $sfGuardUser->setUsername($values["username"]);
             $sfGuardUser->setFirstName($values["firstname"]);
             $sfGuardUser->setLastName($values["lastname"]);
             $sfGuardUser->setCreatedAt($datetime);
             $sfGuardUser->setUpdatedAt($datetime);
             $sfGuardUser->save();
             // Additional informations for user's profile
             $sfGuardUserProfile = new sfGuardUserProfile();
             $sfGuardUserProfile->setUserId($sfGuardUser->getId());
             $sfGuardUserProfile->setToken(MiscUtils::generateToken());
             $sfGuardUserProfile->setSecurityLevel(sfConfig::get("app_security_level_new_user", 0));
             $sfGuardUserProfile->save();
             $permission = Doctrine_Core::getTable("sfGuardPermission")->findOneByName(sfConfig::get("app_permission_new_user", "User"));
             if (!$permission) {
                 $this->getUser()->setFlash("error", "Unable to set permissions for this account! Contact your administrator.");
                 $sfGuardUserProfile->delete();
                 $sfGuardUser->delete();
                 return;
             }
             // Give basic permissions for user
             $sfGuardPermission = new sfGuardUserPermission();
             $sfGuardPermission->setUserId($sfGuardUser->getId());
             $sfGuardPermission->setPermissionId($permission->getId());
             $sfGuardPermission->setCreatedAt($datetime);
             $sfGuardPermission->setUpdatedAt($datetime);
             $sfGuardPermission->save();
             $userGroup = Doctrine_Core::getTable("sfGuardGroup")->findOneByName(sfConfig::get("app_project_group"));
             if (!$userGroup) {
                 $this->getUser()->setFlash("error", "Unable to set project group for this account! Contact your administrator.");
                 $sfGuardUserProfile->delete();
                 $sfGuardUser->delete();
                 $sfGuardPermission->delete();
                 return;
             }
             // Create new entry into sfGuardUserGroup table
             $sfGuardGroup = new sfGuardUserGroup();
             $sfGuardGroup->setUserId($sfGuardUser->getId());
             $sfGuardGroup->setGroupId($userGroup->getId());
             $sfGuardGroup->setCreatedAt($datetime);
             $sfGuardGroup->setUpdatedAt($datetime);
             $sfGuardGroup->save();
             $user = $sfGuardUser;
         }
         $this->getUser()->signIn($user, array_key_exists('remember', $values) ? $values['remember'] : false);
         // Set the tow previous referer to the same value for:
         // 1) redirect to previous user's location
         // 2) avoid redirect loop in signin
         $this->getUser()->setReferer($this->getUser()->getReferer());
         // Redirect to referer
         return $this->redirect($this->getUser()->getReferer());
     }
 }
开发者ID:alex1818,项目名称:TestReportCenter,代码行数:70,代码来源:actions.class.php


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