You are here

function bueditor_sorted_roles in BUEditor 6.2

Same name and namespace in other branches
  1. 5 bueditor.module \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.

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

File

admin/bueditor.admin.inc, line 836

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;
    $keys = array(
      'weight',
      'editor',
      'alt',
    );
    foreach ($roles as $rid => $name) {
      $sorted[$rid]['name'] = $name;
      foreach ($keys as $key) {
        $sorted[$rid][$key] = empty($broles[$rid][$key]) ? 0 : (int) $broles[$rid][$key];
      }
    }
    uasort($sorted, 'bueditor_rolesort');
  }
  return $sorted;
}