function user_user_import_roles_data in User Import 7
Same name and namespace in other branches
- 8 supported/user.inc \user_user_import_roles_data()
- 5 supported/user.inc \user_user_import_roles_data()
- 6.4 supported/user.inc \user_user_import_roles_data()
- 6.2 supported/user.inc \user_user_import_roles_data()
- 7.3 supported/user.inc \user_user_import_roles_data()
- 7.2 supported/user.inc \user_user_import_roles_data()
1 call to user_user_import_roles_data()
- user_user_import_data in supported/
user.inc - Implementation of hook_user_import_data().
File
- supported/
user.inc, line 293
Code
function user_user_import_roles_data($data, $new_roles_allowed) {
$roles = array();
if (empty($data)) {
return;
}
$values = explode(',', $data);
// check if any roles are specified that don't already exist
$existing_roles = user_roles();
foreach ($values as $piece) {
$role = trim($piece);
$unrecognised = array();
if (!empty($role)) {
// only add if role is recognized or adding new roles is allowed
if (empty($new_roles_allowed) && !array_search($role, $existing_roles)) {
$unrecognised[] = $role;
}
else {
$roles[] = $role;
}
}
}
if (!empty($unrecognised)) {
user_import_errors(t('The following unrecognised roles were specified:') . implode(',', $unrecognised));
}
return $roles;
}