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


PHP Container::getUserManager方法代码示例

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


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

示例1: update_user

 /**
  * Update user information with all the parameters passed to this function
  * @param int The ID of the user to be updated
  * @param string The user's firstname
  * @param string The user's lastname
  * @param string The user's username (login)
  * @param string The user's password
  * @param string The authentication source (default: "platform")
  * @param string The user's e-mail address
  * @param int The user's status
  * @param string The user's official code (usually just an internal institutional code)
  * @param string The user's phone number
  * @param string The user's picture URL (internal to the Chamilo directory)
  * @param int The user ID of the person who registered this user (optional, defaults to null)
  * @param int The department of HR in which the user is registered (optional, defaults to 0)
  * @param    array    A series of additional fields to add to this user as extra fields (optional, defaults to null)
  * @return boolean true if the user information was updated
  * @assert (false) === false
  */
 public static function update_user($user_id, $firstname, $lastname, $username, $password = null, $auth_source = null, $email = null, $status = STUDENT, $official_code = null, $phone = null, $picture_uri = null, $expiration_date = null, $active = 1, $creator_id = null, $hr_dept_id = 0, $extra = null, $language = 'english', $encrypt_method = '', $send_email = false, $reset_password = 0)
 {
     global $_configuration;
     $original_password = $password;
     $user_info = api_get_user_info($user_id, false, true);
     if ($reset_password == 0) {
         $password = null;
         $auth_source = $user_info['auth_source'];
     } elseif ($reset_password == 1) {
         $original_password = $password = api_generate_password();
         $auth_source = PLATFORM_AUTH_SOURCE;
     } elseif ($reset_password == 2) {
         $password = $password;
         $auth_source = PLATFORM_AUTH_SOURCE;
     } elseif ($reset_password == 3) {
         $password = $password;
         $auth_source = $auth_source;
     }
     if ($user_id != strval(intval($user_id))) {
         return false;
     }
     if ($user_id === false) {
         return false;
     }
     // Checking the user language.
     $languages = api_get_platform_isocodes();
     if (!in_array($language, $languages)) {
         $language = Container::getTranslator()->getLocale();
     }
     if (!is_null($password)) {
         if ($encrypt_method == '') {
             $password = api_get_encrypted_password($password);
         } else {
             if ($_configuration['password_encryption'] === $encrypt_method) {
                 if ($encrypt_method == 'md5' && !preg_match('/^[A-Fa-f0-9]{32}$/', $password)) {
                     return api_set_failure('encrypt_method invalid');
                 } else {
                     if ($encrypt_method == 'sha1' && !preg_match('/^[A-Fa-f0-9]{40}$/', $password)) {
                         return api_set_failure('encrypt_method invalid');
                     }
                 }
             } else {
                 return api_set_failure('encrypt_method invalid');
             }
         }
     }
     $em = Database::getManager();
     /** @var Chamilo\UserBundle\Entity\User $user */
     $user = $em->getRepository('ChamiloUserBundle:User')->find($user_id);
     if (is_array($extra) && count($extra) > 0) {
         $res = true;
         foreach ($extra as $name => $value) {
             //$userField = $em->getRepository('ChamiloUserBundle:UserField')->findOneByName($name);
             $res = $res && self::update_extra_field_value($user_id, $name, $value);
         }
     }
     if ($user_info['active'] != $active) {
         self::change_active_state($user_id, $active);
     }
     // Updating user
     $user->setLastname($lastname)->setFirstname($firstname)->setUsername($username)->setAuthSource($auth_source)->setLanguage($language)->setEmail($email)->setOfficialCode($official_code)->setPhone($phone)->setPictureUri($picture_uri)->setExpirationDate($expiration_date)->setActive($active)->setHrDeptId($hr_dept_id);
     if (!empty($original_password)) {
         $user->setPlainPassword($original_password);
     }
     if (is_array($status)) {
         foreach ($status as $groupId) {
             $group = $em->getRepository('ChamiloUserBundle:Group')->find($groupId);
             $user->addGroup($group);
         }
     } else {
         $group = $em->getRepository('ChamiloUserBundle:Group')->find($status);
         $user->addGroup($group);
     }
     Container::getUserManager()->updateUser($user, true);
     if (!empty($email) && $send_email) {
         $recipient_name = api_get_person_name($firstname, $lastname, null, PERSON_NAME_EMAIL_ADDRESS);
         $emailsubject = '[' . api_get_setting('platform.site_name') . '] ' . get_lang('YourReg') . ' ' . api_get_setting('platform.site_name');
         $sender_name = api_get_person_name(api_get_setting('platform.administrator_name'), api_get_setting('platform.administrator_surname'), null, PERSON_NAME_EMAIL_ADDRESS);
         $email_admin = api_get_setting('platform.administrator_email');
         $emailbody = null;
         /*api_mail_html($recipient_name, $email, $emailsubject,
//.........这里部分代码省略.........
开发者ID:ragebat,项目名称:chamilo-lms,代码行数:101,代码来源:usermanager.lib.php


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