You are here

function imce_sorted_roles in IMCE 5

Same name and namespace in other branches
  1. 6.2 inc/imce.admin.inc \imce_sorted_roles()
  2. 6 inc/admin.inc \imce_sorted_roles()
  3. 7 inc/imce.admin.inc \imce_sorted_roles()

sort roles according to precedence settings. previously sorted roles are followed by latest added roles.

2 calls to imce_sorted_roles()
imce_form_admin_form in ./imce.module
return the form for admin/settings/imce
imce_settings_user in ./imce.module
get current user's settings

File

./imce.module, line 512

Code

function imce_sorted_roles() {
  static $order;
  if (isset($order)) {
    return $order;
  }
  $order = array();
  $roles = user_roles(0, 'access imce');
  foreach (variable_get('imce_settings_rank', array()) as $rid) {
    if (isset($roles[$rid])) {
      $order[$rid] = $roles[$rid];
      unset($roles[$rid]);
    }
  }
  krsort($roles);

  //sort the remaining unsorted roles by id, descending.
  $order += $roles;
  return $order;
}