You are here

function bueditor_sorted_roles in BUEditor 7

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

Sort roles according to their weights.

1 call to bueditor_sorted_roles()
bueditor_admin_form in admin/bueditor.admin.inc
Admin form.

File

admin/bueditor.admin.inc, line 941

Code

function bueditor_sorted_roles() {
  static $sorted;
  if (!isset($sorted)) {
    $sorted = array();
    $roles = user_roles();
    $broles = variable_get('bueditor_roles', array());
    $broles[DRUPAL_ANONYMOUS_RID]['weight'] = 12;
    $broles[DRUPAL_AUTHENTICATED_RID]['weight'] = 11;
    foreach ($roles as $rid => $name) {
      $sorted[$rid] = array(
        'name' => $name,
        'weight' => isset($broles[$rid]['weight']) ? $broles[$rid]['weight'] : 0,
        'editor' => isset($broles[$rid]['editor']) ? $broles[$rid]['editor'] : 0,
        'alt' => isset($broles[$rid]['alt']) ? $broles[$rid]['alt'] : 0,
      );
    }
    uasort($sorted, 'bueditor_rolesort');
  }
  return $sorted;
}