You are here

function imce_sorted_roles in IMCE 6.2

Same name and namespace in other branches
  1. 5 imce.module \imce_sorted_roles()
  2. 6 inc/admin.inc \imce_sorted_roles()
  3. 7 inc/imce.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 662
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());
    $irp = variable_get('imce_roles_profiles', array());
    $irp[DRUPAL_ANONYMOUS_RID]['weight'] = 12;
    $irp[DRUPAL_AUTHENTICATED_RID]['weight'] = 11;
    foreach ($roles as $rid => $rname) {
      $sorted[$rid] = array(
        'name' => $rname,
        'weight' => isset($irp[$rid]['weight']) ? $irp[$rid]['weight'] : 0,
        'pid' => isset($irp[$rid]['pid']) && isset($profiles[$irp[$rid]['pid']]) ? $irp[$rid]['pid'] : 0,
      );
    }
    uasort($sorted, 'imce_rolesort');
  }
  return $sorted;
}