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


PHP sfGuardUser::delete方法代码示例

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


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

示例1: testGetFirstByUserSubredditAndMemberships

 /**
  * Since a User can only have one membership in a Subreddit, this tests that
  * the first returned sfGuardUserSubredditMembership is the exact same as
  * the only one made.  The limitation on sfGuardUserSubredditMemberships is
  * in place using Unique indexes in the database, so we depend upon that to
  * prevent multiple Subreddit Memberships.
  */
 public function testGetFirstByUserSubredditAndMemberships()
 {
     $user = new sfGuardUser();
     $user->setEmailAddress(rand(0, 1000));
     $user->setUsername(rand(0, 1000));
     $user->setIsValidated(1);
     $user->save();
     $subreddit = new Subreddit();
     $subreddit->setName(rand(0, 1000));
     $subreddit->setDomain(rand(0, 1000));
     $subreddit->save();
     $membership = MembershipTable::getInstance()->findOneByType('user');
     $second_membership = MembershipTable::getInstance()->findOneByType('admin');
     $user_subreddit_membership = new sfGuardUserSubredditMembership();
     $user_subreddit_membership->setSfGuardUserId($user->getIncremented());
     $user_subreddit_membership->setSubredditId($subreddit->getIncremented());
     $user_subreddit_membership->setMembership($membership);
     $user_subreddit_membership->save();
     $second_user_subreddit_membership = new sfGuardUserSubredditMembership();
     $second_user_subreddit_membership->setSfGuardUserId($user->getIncremented());
     $second_user_subreddit_membership->setSubredditId($subreddit->getIncremented());
     $second_user_subreddit_membership->setMembership($second_membership);
     $exception_thrown = false;
     try {
         $second_user_subreddit_membership->save();
     } catch (Exception $exception) {
         unset($exception);
         $exception_thrown = true;
     }
     $retrieved_object = sfGuardUserSubredditMembershipTable::getInstance()->getFirstByUserSubredditAndMemberships($user->getIncremented(), $subreddit->getIncremented(), array($membership->getType()));
     $this->assertEquals($retrieved_object->getIncremented(), $user_subreddit_membership->getIncremented());
     $user_subreddit_membership->delete();
     $subreddit->delete();
     $user->delete();
     $this->assertTrue($exception_thrown);
 }
开发者ID:nocoolnametom,项目名称:OpenMicNight,代码行数:43,代码来源:sfGuardUserSubredditMembershipTableTest.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::delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。