function uif_parse_roles in User Import Framework 7
Parse input roles if any.
3 calls to uif_parse_roles()
- uif_create_user in ./
uif.admin.inc - Create a new user.
- uif_uif_validate_user in ./
uif.admin.inc - Implementation of hook_uif_validate_user().
- uif_update_user in ./
uif.admin.inc - Update an existing user.
File
- ./
uif.admin.inc, line 713 - Simple, extensible user import from a CSV file.
Code
function uif_parse_roles($roles_string, &$errors = array()) {
$roles = array();
$errors = array();
if ($roles_string) {
$role_names = explode(variable_get('uif_value_delimiter', '|'), $roles_string);
foreach ($role_names as $name) {
$rid = db_query('SELECT rid FROM {role} WHERE name = :name', array(
':name' => $name,
))
->fetchField();
if (is_numeric($rid) && $rid < 2) {
$errors[] = t('System-managed roles are not allowed: %name', array(
'%name' => $name,
));
}
elseif ($rid) {
$roles[$rid] = $name;
}
else {
$errors[] = t('Unrecognized role: %name', array(
'%name' => $name,
));
}
}
}
return $roles;
}