You are here

function bueditor_sorted_roles in BUEditor 5

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

Sort roles according to their weights.

2 calls to bueditor_sorted_roles()
bueditor_form_admin in ./bueditor.module
Admin form.
theme_bueditor_form_admin in ./bueditor.module
Admin form themed.

File

./bueditor.module, line 581

Code

function bueditor_sorted_roles() {
  static $sorted;
  if (!isset($sorted)) {
    $sorted = array();
    $roles = user_roles();
    $stored = variable_get('bueditor_roles', array());
    $stored[DRUPAL_ANONYMOUS_RID]['weight'] = 10;
    foreach ($roles as $rid => $rname) {
      $sorted[$rid] = array(
        'name' => $rname,
        'weight' => (int) $stored[$rid]['weight'],
        'editor' => (int) $stored[$rid]['editor'],
      );
    }
    uasort($sorted, 'bueditor_rolesort');
  }
  return $sorted;
}