function imce_sorted_roles in IMCE 7
Same name and namespace in other branches
- 5 imce.module \imce_sorted_roles()
- 6.2 inc/imce.admin.inc \imce_sorted_roles()
- 6 inc/admin.inc \imce_sorted_roles()
Sort roles according to their weights.
1 call to imce_sorted_roles()
- imce_admin_form in inc/
imce.admin.inc - Admin form.
File
- inc/
imce.admin.inc, line 756 - Serves administration pages of IMCE.
Code
function imce_sorted_roles() {
static $sorted;
if (!isset($sorted)) {
$sorted = array();
$roles = user_roles();
$profiles = variable_get('imce_profiles', array());
$roles_profiles = variable_get('imce_roles_profiles', array());
$roles_profiles[DRUPAL_ANONYMOUS_RID]['weight'] = 12;
$roles_profiles[DRUPAL_AUTHENTICATED_RID]['weight'] = 11;
$schemes = array_keys(file_get_stream_wrappers(STREAM_WRAPPERS_VISIBLE));
foreach ($roles as $rid => $name) {
$sorted[$rid] = array(
'name' => $name,
'weight' => isset($roles_profiles[$rid]['weight']) ? $roles_profiles[$rid]['weight'] : 0,
);
foreach ($schemes as $scheme) {
$key = $scheme . '_pid';
$sorted[$rid][$key] = isset($roles_profiles[$rid][$key]) && isset($profiles[$roles_profiles[$rid][$key]]) ? $roles_profiles[$rid][$key] : 0;
}
}
uasort($sorted, 'imce_rolesort');
}
return $sorted;
}