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


PHP UserManager::updateUser方法代码示例

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


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

示例1: loadUserByOAuthUserResponse

 public function loadUserByOAuthUserResponse(UserResponseInterface $response)
 {
     $socialID = $response->getUsername();
     /** @var User $user */
     $user = $this->userManager->loadUser(['facebookId' => $socialID]);
     $update = true;
     $email = $response->getEmail();
     //check if the user already has the corresponding social account
     if (null === $user) {
         //check if the user has a normal account
         $user = $this->userManager->loadUser($email, 'email');
         if (null === $user || !$user instanceof UserInterface) {
             //if the user does not have a normal account, set it up:
             /** @var User $user */
             $name = $response->getNickname() ?? $response->getRealName();
             $user = $this->userManager->createUser($name, md5(uniqid()), $response->getEmail(), ['ROLE_OAUTH_USER']);
             $user->setEmail($email);
             $user->setFullName($name);
             $user->setEnabled(true);
             $violations = $this->validator->validate($user);
             $update = !$violations->count() === 0;
             if ($violations->count() === 0) {
                 $this->session->getFlashBag()->add('warning', 'Welcome! You must complete your profile in order to use the features on the site.');
             } else {
                 throw new CustomUserMessageAuthenticationException('An account in your name already exists.');
             }
         }
         if ($update) {
             //then set its corresponding social id
             $service = $response->getResourceOwner()->getName();
             switch ($service) {
                 case 'google':
                     $user->setGoogleID($socialID);
                     break;
                 case 'facebook':
                     $user->setFacebookID($socialID);
                     break;
             }
             $this->userManager->updateUser($user);
         }
     } else {
         //and then login the user
         $token = new UsernamePasswordToken($user, null, 'main', $user->getRoles());
         $this->tokenStorage->setToken($token);
     }
     $user->setLastLoggedIn(new \DateTime());
     $this->userManager->updateUser($user);
     return $user;
 }
开发者ID:ampisoft,项目名称:user-bundle,代码行数:49,代码来源:OAuthUserProvider.php

示例2: UserManager

<?php

require_once '../../config.php';
require_once BUSINESS_DIR_USER . 'User.php';
require_once BUSINESS_DIR_USER . 'UserManager.php';
require_once BUSINESS_DIR_LOCATION . 'LocationManager.php';
$userManager = new UserManager();
// check and update user
if ($_POST) {
    $userId = $_POST['id'];
    $fname = $_POST['fname'];
    $lname = $_POST['lname'];
    $birth = $_POST['birth'];
    $language = $_POST['language'];
    $email = $_POST['email'];
    $user_update = $userManager->getUserByUserId($userId);
    $user_update->setFirstName($fname);
    $user_update->setLastName($lname);
    $user_update->setEmail($email);
    $user_update->setUserLanguage($language);
    $user_update->setDOB($birth);
    $updated = $userManager->updateUser($user_update);
    if (!$updated) {
        echo "Updating " . $userId . " failed.";
    } else {
        header("Location: ../../profile.php");
    }
} else {
    header("Location: ../../profile.php");
}
开发者ID:kevin000,项目名称:Tarboz,代码行数:30,代码来源:update.php

示例3: updateUser

 public function updateUser(AbstractUser $user)
 {
     $this->userManager->updateUser($user);
 }
开发者ID:ampisoft,项目名称:user-bundle,代码行数:4,代码来源:AmpUserProvider.php

示例4: updateUser

 /**
  * 
  * updateUser
  * 
  * @param String $ErrorString
  * @param String $StatusString
  */
 public function updateUser($ErrorString = "", $StatusString = "")
 {
     if (Controler_Main::getInstance()->getUserLevel() < BACKEND_USERLEVEL) {
         $ControlerStart = new Controler_Start();
         $ControlerStart->start();
         return false;
     }
     $Request = new Request();
     $Controler_Main = Controler_Main::getInstance();
     $ErrorString = "";
     if (strlen($Request->getAsString("tb_Name")) < 3) {
         $ErrorString .= ":T_REGISTER_ERROR1: <br />";
     }
     if (strlen($Request->getAsString("tb_Pass")) < 5) {
         $ErrorString .= ":T_REGISTER_ERROR2: <br />";
     }
     if (strlen($Request->getAsString("tb_Pass")) === $Request->getAsString("tb_PassConfirme")) {
         $ErrorString .= ":T_REGISTER_ERROR3:<br />";
     }
     $UserFinder = new UserFinder();
     if (strlen($Request->getAsString("tb_Mail")) > 3) {
         $User = $UserFinder->findByMail($Request->getAsString("tb_Mail"));
         if ($User->getId() != 0) {
             $ErrorString .= ":T_REGISTER_ERROR4: <br />";
         }
     } else {
         $ErrorString .= ":T_REGISTER_ERROR5: <br />";
     }
     if (strlen($Request->getAsString("tb_Mail")) === $Request->getAsString("tb_MailConfirme")) {
         $ErrorString .= ":T_REGISTER_ERROR6:<br />";
     }
     if (strlen($Request->getAsString("tb_Name"))) {
         $User = $UserFinder->findByName($Request->getAsString("tb_Name"));
         if ($User->getId() != 0) {
             $ErrorString .= ":T_REGISTER_ERROR7: <br />";
         }
     }
     if (!$this->isMailCorrect($Request->getAsString("tb_Mail"))) {
         $ErrorString .= ":T_REGISTER_ERROR8: <br />";
     }
     if (strlen($ErrorString) != 0) {
         $this->showNewUser($ErrorString);
         return false;
     }
     /* TODO: Salt für Passwort */
     $UserManager = new UserManager();
     $UserManager->updateUser($User);
     if (!$UserManager->getLastInsertId()) {
         $this->showRegister($ErrorString);
         return false;
     }
     $this->showRegister("", ":T_USER_UPDATED_STATUS:");
 }
开发者ID:0xF3ERROR,项目名称:Home-Control,代码行数:60,代码来源:cls_Controler_Users.php

示例5: updateUser

 public function updateUser(User $user)
 {
     $result = parent::updateUser($user);
     $this->invalidateUserCacheByUserId($user->id);
     return $result;
 }
开发者ID:Welvin,项目名称:stingle,代码行数:6,代码来源:UserManagerCaching.class.php

示例6: UserManager

 //$data = array("action" => $action, "user_name" => $user_name);
 if ($action == 'delete' && !empty($user_name)) {
     $um = new UserManager();
     $um->deleteUser($user_name);
     $data = array("status" => "success", "msg" => "User '{$user_name}' deleted.");
     echo json_encode($data, JSON_FORCE_OBJECT);
     return;
 } else {
     if ($action == 'update' && !empty($userid)) {
         $newFirstName = $parameters->getValue('newFirstName');
         $newLastName = $parameters->getValue('newLastName');
         $newUserName = $parameters->getValue('newUserName');
         $userid = $parameters->getValue('userid');
         if (!empty($newFirstName)) {
             $um = new UserManager();
             $count = $um->updateUser($userid, $newFirstName, $newLastName, $newUserName);
             if ($count > 0) {
                 $data = array("status" => "success", "msg" => "User '{$user_name}' updated with new first name ('{$newFirstName}').");
             } else {
                 $data = array("status" => "fail", "msg" => "User '{$userid}' was NOT updated with new first name ('{$newFirstName}').");
             }
         } else {
             $data = array("status" => "fail", "msg" => "New user name must be present - value was '{$newFirstName}' for '{$user_name}'.");
         }
         echo json_encode($data, JSON_FORCE_OBJECT);
         return;
     } else {
         if ($action == 'add') {
             $newFirstName = $parameters->getValue('newFirstName');
             $newLastName = $parameters->getValue('newLastName');
             $newUserName = $parameters->getValue('newUserName');
开发者ID:siobhan-walsh,项目名称:kiki,代码行数:31,代码来源:users.php


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