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


PHP UserManager::is_username_too_long方法代码示例

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


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

示例1: validate_data

/**
 * Validates imported data.
 */
function validate_data($user_classes)
{
    global $purification_option_for_usernames;
    $errors = array();
    $classcodes = array();
    $usergroup = new UserGroup();
    foreach ($user_classes as $index => $user_class) {
        $user_class['line'] = $index + 1;
        // 1. Check whether mandatory fields are set.
        $mandatory_fields = array('UserName', 'ClassName');
        foreach ($mandatory_fields as $field) {
            if (!isset($user_class[$field]) || strlen($user_class[$field]) == 0) {
                $user_class['error'] = get_lang($field . 'Mandatory');
                $errors[] = $user_class;
            }
        }
        // 2. Check whether class code exists.
        if (isset($user_class['ClassName']) && strlen($user_class['ClassName']) != 0) {
            // 2.1 Check whether code has been already used in this CVS-file.
            if (!isset($classcodes[$user_class['ClassName']])) {
                // 2.1.1 Check whether code exists in DB
                $exists = $usergroup->usergroup_exists($user_class['ClassName']);
                if (!$exists) {
                    $user_class['error'] = get_lang('CodeDoesNotExists') . ': ' . $user_class['ClassName'];
                    $errors[] = $user_class;
                } else {
                    $classcodes[$user_class['CourseCode']] = 1;
                }
            }
        }
        // 3. Check username, first, check whether it is empty.
        if (!UserManager::is_username_empty($user_class['UserName'])) {
            // 3.1. Check whether username is too long.
            if (UserManager::is_username_too_long($user_class['UserName'])) {
                $user_class['error'] = get_lang('UserNameTooLong') . ': ' . $user_class['UserName'];
                $errors[] = $user_class;
            }
            $username = UserManager::purify_username($user_class['UserName'], $purification_option_for_usernames);
            // 3.2. Check whether username exists.
            if (UserManager::is_username_available($username)) {
                $user_class['error'] = get_lang('UnknownUser') . ': ' . $username;
                $errors[] = $user_class;
            }
        }
    }
    return $errors;
}
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:50,代码来源:usergroup_user_import.php

示例2: validate_data

/**
 * Validates imported data.
 */
function validate_data($users)
{
    global $defined_auth_sources;
    $errors = array();
    $usernames = array();
    if (is_array($users)) {
        foreach ($users as $index => $user) {
            // 1. Check whether mandatory fields have been set.
            $mandatory_fields = array('LastName', 'FirstName');
            if (api_get_setting('registration', 'email') == 'true') {
                $mandatory_fields[] = 'Email';
            }
            foreach ($mandatory_fields as $key => $field) {
                if (!isset($user[$field]) || strlen($user[$field]) == 0) {
                    $user['error'] = get_lang($field . 'Mandatory');
                    $errors[] = $user;
                }
            }
            // 2. Check username.
            if (!UserManager::is_username_empty($user['UserName'])) {
                // 2.1. Check whether username was used twice in the import file.
                if (isset($usernames[$user['UserName']])) {
                    $user['error'] = get_lang('UserNameUsedTwice');
                    $errors[] = $user;
                }
                $usernames[$user['UserName']] = 1;
                // 2.2. Check whether username is allready in use in database.
                if (!UserManager::is_username_available($user['UserName'])) {
                    $user['error'] = get_lang('UserNameNotAvailable');
                    $errors[] = $user;
                }
                // 2.3. Check whether username is too long.
                if (UserManager::is_username_too_long($user['UserName'])) {
                    $user['error'] = get_lang('UserNameTooLong');
                    $errors[] = $user;
                }
            }
            // 3. Check status.
            if (isset($user['Status']) && !api_status_exists($user['Status'])) {
                $user['error'] = get_lang('WrongStatus');
                $errors[] = $user;
            }
            // 4. Check classname.
            if (isset($user['ClassName']) && strlen($user['ClassName']) != 0) {
                if (!ClassManager::class_name_exists($user['ClassName'])) {
                    $user['error'] = get_lang('ClassNameNotAvailable');
                    $errors[] = $user;
                }
            }
            // 5. Check authentication source.
            if (isset($user['AuthSource']) && strlen($user['AuthSource']) != 0) {
                if (!in_array($user['AuthSource'], $defined_auth_sources)) {
                    $user['error'] = get_lang('AuthSourceNotAvailable');
                    $errors[] = $user;
                }
            }
        }
    }
    return $errors;
}
开发者ID:KRCM13,项目名称:chamilo-lms,代码行数:63,代码来源:import.lib.php

示例3: validate_data

/**
 * Validates imported data.
 */
function validate_data($user_classes)
{
    global $purification_option_for_usernames;
    $errors = array();
    $classcodes = array();
    if (!isset($_POST['subscribe']) && !isset($_POST['subscribe'])) {
        $user_class['error'] = get_lang('SelectAnAction');
        $errors[] = $user_class;
        return $errors;
    }
    foreach ($user_classes as $index => $user_class) {
        $user_class['line'] = $index + 1;
        // 1. Check whether mandatory fields are set.
        $mandatory_fields = array('UserName', 'ClassName');
        foreach ($mandatory_fields as $key => $field) {
            if (!isset($user_class[$field]) || strlen($user_class[$field]) == 0) {
                $user_class['error'] = get_lang($field . 'Mandatory');
                $errors[] = $user_class;
            }
        }
        // 2. Check whether classcode exists.
        if (isset($user_class['ClassName']) && strlen($user_class['ClassName']) != 0) {
            // 2.1 Check whether code has been allready used in this CVS-file.
            if (!isset($classcodes[$user_class['ClassName']])) {
                // 2.1.1 Check whether code exists in DB.
                $class_table = Database::get_main_table(TABLE_MAIN_CLASS);
                $sql = "SELECT * FROM {$class_table} WHERE name = '" . Database::escape_string($user_class['ClassName']) . "'";
                $res = Database::query($sql);
                if (Database::num_rows($res) == 0) {
                    $user_class['error'] = get_lang('CodeDoesNotExists') . ': ' . $user_class['ClassName'];
                    $errors[] = $user_class;
                } else {
                    $classcodes[$user_class['CourseCode']] = 1;
                }
            }
        }
        // 3. Check username, first, check whether it is empty.
        if (!UserManager::is_username_empty($user_class['UserName'])) {
            // 3.1. Check whether username is too long.
            if (UserManager::is_username_too_long($user_class['UserName'])) {
                $user_class['error'] = get_lang('UserNameTooLong') . ': ' . $user_class['UserName'];
                $errors[] = $user_class;
            }
            $username = UserManager::purify_username($user_class['UserName'], $purification_option_for_usernames);
            // 3.2. Check whether username exists.
            if (UserManager::is_username_available($username)) {
                $user_class['error'] = get_lang('UnknownUser') . ': ' . $username;
                $errors[] = $user_class;
            }
        }
    }
    return $errors;
}
开发者ID:ilosada,项目名称:chamilo-lms-icpna,代码行数:56,代码来源:class_user_import.php

示例4: validate_data

function validate_data($users)
{
    global $defined_auth_sources;
    $errors = array();
    $usernames = array();
    // 1. Check if mandatory fields are set.
    $mandatory_fields = array('LastName', 'FirstName');
    if (api_get_setting('registration', 'email') == 'true') {
        $mandatory_fields[] = 'Email';
    }
    $classExistList = array();
    $usergroup = new UserGroup();
    foreach ($users as $user) {
        foreach ($mandatory_fields as $field) {
            if (isset($user[$field])) {
                if (empty($user[$field])) {
                    $user['error'] = get_lang($field . 'Mandatory');
                    $errors[] = $user;
                }
            }
        }
        // 2. Check username, first, check whether it is empty.
        if (isset($user['NewUserName'])) {
            if (!UserManager::is_username_empty($user['NewUserName'])) {
                // 2.1. Check whether username is too long.
                if (UserManager::is_username_too_long($user['NewUserName'])) {
                    $user['error'] = get_lang('UserNameTooLong');
                    $errors[] = $user;
                }
                // 2.2. Check whether the username was used twice in import file.
                if (isset($usernames[$user['NewUserName']])) {
                    $user['error'] = get_lang('UserNameUsedTwice');
                    $errors[] = $user;
                }
                $usernames[$user['UserName']] = 1;
                // 2.3. Check whether username is allready occupied.
                if (!UserManager::is_username_available($user['NewUserName']) && $user['NewUserName'] != $user['UserName']) {
                    $user['error'] = get_lang('UserNameNotAvailable');
                    $errors[] = $user;
                }
            }
        }
        // 3. Check status.
        if (isset($user['Status']) && !api_status_exists($user['Status'])) {
            $user['error'] = get_lang('WrongStatus');
            $errors[] = $user;
        }
        // 4. Check ClassId
        if (!empty($user['ClassId'])) {
            $classId = explode('|', trim($user['ClassId']));
            foreach ($classId as $id) {
                if (in_array($id, $classExistList)) {
                    continue;
                }
                $info = $usergroup->get($id);
                if (empty($info)) {
                    $user['error'] = sprintf(get_lang('ClassIdDoesntExists'), $id);
                    $errors[] = $user;
                } else {
                    $classExistList[] = $info['id'];
                }
            }
        }
        // 5. Check authentication source
        if (!empty($user['AuthSource'])) {
            if (!in_array($user['AuthSource'], $defined_auth_sources)) {
                $user['error'] = get_lang('AuthSourceNotAvailable');
                $errors[] = $user;
            }
        }
    }
    return $errors;
}
开发者ID:jloguercio,项目名称:chamilo-lms,代码行数:73,代码来源:user_update_import.php

示例5: validate_data

 /**
  * Validates imported data.
  * @param list of users
  */
 function validate_data($users, $id_session = null)
 {
     $errors = array();
     $new_users = array();
     foreach ($users as $index => $user) {
         // 1. Check whether mandatory fields are set.
         $mandatory_fields = array('LastName', 'FirstName');
         if (api_get_setting('registration', 'email') == 'true') {
             $mandatory_fields[] = 'Email';
         }
         foreach ($mandatory_fields as $key => $field) {
             if (!isset($user[$field]) || strlen($user[$field]) == 0) {
                 $user['error'] = get_lang($field . 'Mandatory');
                 $errors[] = $user;
             }
         }
         // 2. Check whether the username is too long.
         if (UserManager::is_username_too_long($user['UserName'])) {
             $user['error'] = get_lang('UserNameTooLong');
             $errors[] = $user;
         }
         $user['UserName'] = trim($user['UserName']);
         if (empty($user['UserName'])) {
             $user['UserName'] = UserManager::create_username($user['FirstName'], $user['LastName']);
         }
         $new_users[] = $user;
     }
     $results = array('errors' => $errors, 'users' => $new_users);
     return $results;
 }
开发者ID:feroli1000,项目名称:chamilo-lms,代码行数:34,代码来源:myspace.lib.php


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