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


PHP User::getErrors方法代码示例

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


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

示例1: handleLdapUser

 /**
  * Updates or creates user by given ldap node
  * 
  * @param Zend_Ldap_Node $node
  * @return User User Object
  */
 public function handleLdapUser($node)
 {
     $usernameAttribute = Setting::Get('usernameAttribute', 'authentication_ldap');
     if ($usernameAttribute == '') {
         $usernameAttribute = 'sAMAccountName';
     }
     $emailAttribute = Setting::Get('emailAttribute', 'authentication_ldap');
     if ($emailAttribute == '') {
         $emailAttribute = 'mail';
     }
     $username = $node->getAttribute($usernameAttribute, 0);
     $email = $node->getAttribute($emailAttribute, 0);
     $guid = $this->binToStrGuid($node->getAttribute('objectGUID', 0));
     // Try to load User:
     $userChanged = false;
     $user = null;
     if ($guid != "") {
         $user = User::findOne(array('guid' => $guid, 'auth_mode' => User::AUTH_MODE_LDAP));
     } else {
         // Fallback use e-mail
         $user = User::findOne(array('email' => $email, 'auth_mode' => User::AUTH_MODE_LDAP));
     }
     if ($user === null) {
         $user = new User();
         if ($guid != "") {
             $user->guid = $guid;
         }
         $user->status = User::STATUS_ENABLED;
         $user->auth_mode = User::AUTH_MODE_LDAP;
         $user->group_id = 1;
         Yii::info('Create ldap user ' . $username . '!');
     }
     // Update Users Field
     if ($user->username != $username) {
         $userChanged = true;
         $user->username = $username;
     }
     if ($user->email != $email) {
         $userChanged = true;
         $user->email = $email;
     }
     if ($user->validate()) {
         // Only Save user when something is changed
         if ($userChanged || $user->isNewRecord) {
             $user->save();
         }
         // Update Profile Fields
         foreach (ProfileField::find()->andWhere(['!=', 'ldap_attribute', ''])->all() as $profileField) {
             $ldapAttribute = $profileField->ldap_attribute;
             $profileFieldName = $profileField->internal_name;
             $user->profile->{$profileFieldName} = $node->getAttribute($ldapAttribute, 0);
         }
         if ($user->profile->validate() && $user->profile->save()) {
             $this->trigger(self::EVENT_UPDATE_USER, new ParameterEvent(['user' => $user, 'node' => $node]));
         } else {
             Yii::error('Could not create or update ldap user profile! (' . print_r($user->profile->getErrors(), true) . ")");
         }
     } else {
         Yii::error('Could not create or update ldap user! (' . print_r($user->getErrors(), true) . ")");
     }
     return $user;
 }
开发者ID:1resu,项目名称:humhub,代码行数:68,代码来源:Ldap.php

示例2: handleLdapUser

 /**
  * Updates or creates user by given ldap node
  * 
  * @param Zend_Ldap_Node $node
  * @return User User Object
  */
 public function handleLdapUser($node)
 {
     $username = $node->getAttribute(Setting::Get('usernameAttribute', 'authentication_ldap'), 0);
     $email = $node->getAttribute('mail', 0);
     $guid = $this->binToStrGuid($node->getAttribute('objectGUID', 0));
     // Try to load User:
     $userChanged = false;
     $user = null;
     if ($guid != "") {
         $user = User::findOne(array('guid' => $guid, 'auth_mode' => User::AUTH_MODE_LDAP));
     } else {
         // Fallback use e-mail
         $user = User::findOne(array('email' => $email, 'auth_mode' => User::AUTH_MODE_LDAP));
     }
     if ($user === null) {
         $user = new User();
         if ($guid != "") {
             $user->guid = $guid;
         }
         $user->status = User::STATUS_ENABLED;
         $user->auth_mode = User::AUTH_MODE_LDAP;
         $user->group_id = 1;
         Yii::info('Create ldap user ' . $username . '!');
     }
     // Update Group Mapping
     foreach (Group::find()->andWhere(['!=', 'ldap_dn', ""])->all() as $group) {
         if (in_array($group->ldap_dn, $node->getAttribute('memberOf'))) {
             if ($user->group_id != $group->id) {
                 $userChanged = true;
                 $user->group_id = $group->id;
             }
         }
     }
     // Update Users Field
     if ($user->username != $username) {
         $userChanged = true;
         $user->username = $username;
     }
     if ($user->email != $email) {
         $userChanged = true;
         $user->email = $email;
     }
     if ($user->validate()) {
         // Only Save user when something is changed
         if ($userChanged || $user->isNewRecord) {
             $user->save();
         }
         // Update Profile Fields
         foreach (ProfileField::find()->andWhere(['!=', 'ldap_attribute', ''])->all() as $profileField) {
             $ldapAttribute = $profileField->ldap_attribute;
             $profileFieldName = $profileField->internal_name;
             $user->profile->{$profileFieldName} = $node->getAttribute($ldapAttribute, 0);
         }
         if ($user->profile->validate()) {
             $user->profile->save();
             // Update Space Mapping
             foreach (Space::find()->andWhere(['!=', 'ldap_dn', ''])->all() as $space) {
                 if (in_array($space->ldap_dn, $node->getAttribute('memberOf'))) {
                     $space->addMember($user->id);
                 }
             }
         } else {
             Yii::error('Could not create or update ldap user profile! (' . print_r($user->profile->getErrors(), true) . ")");
         }
     } else {
         Yii::error('Could not create or update ldap user! (' . print_r($user->getErrors(), true) . ")");
     }
     return $user;
 }
开发者ID:aldorath,项目名称:humhub,代码行数:75,代码来源:Ldap.php


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