本文整理汇总了PHP中UserGroup::usergroup_exists方法的典型用法代码示例。如果您正苦于以下问题:PHP UserGroup::usergroup_exists方法的具体用法?PHP UserGroup::usergroup_exists怎么用?PHP UserGroup::usergroup_exists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserGroup
的用法示例。
在下文中一共展示了UserGroup::usergroup_exists方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: validate_data
/**
* Validates imported data.
*/
function validate_data($classes)
{
$errors = array();
$usergroup = new UserGroup();
foreach ($classes as $index => $class) {
// 1. Check wheter ClassName is available.
if (!isset($class['name']) || strlen(trim($class['name'])) == 0) {
$class['line'] = $index + 2;
$class['error'] = get_lang('MissingClassName');
$errors[] = $class;
} else {
if ($usergroup->usergroup_exists($class['name'])) {
$class['line'] = $index + 2;
$class['error'] = get_lang('ClassNameExists') . ' <strong>' . $class['ClassName'] . '</strong>';
$errors[] = $class;
}
}
}
return $errors;
}