function filter_get_roles_by_format

Same name in other branches
  1. 9 core/modules/filter/filter.module \filter_get_roles_by_format()
  2. 8.9.x core/modules/filter/filter.module \filter_get_roles_by_format()
  3. 10 core/modules/filter/filter.module \filter_get_roles_by_format()
  4. 11.x core/modules/filter/filter.module \filter_get_roles_by_format()

Retrieves a list of roles that are allowed to use a given text format.

Parameters

$format: An object representing the text format.

Return value

An array of role names, keyed by role ID.

4 calls to filter_get_roles_by_format()
FilterFormatAccessTestCase::testFormatRoles in modules/filter/filter.test
Tests if text format is available to a role.
filter_admin_format_form in modules/filter/filter.admin.inc
Form constructor for the text format add/edit form.
filter_admin_overview in modules/filter/filter.admin.inc
Page callback: Form constructor for a form to list and reorder text formats.
filter_get_formats_by_role in modules/filter/filter.module
Retrieves a list of text formats that are allowed for a given role.

File

modules/filter/filter.module, line 475

Code

function filter_get_roles_by_format($format) {
    // Handle the fallback format upfront (all roles have access to this format).
    if ($format->format == filter_fallback_format()) {
        return user_roles();
    }
    // Do not list any roles if the permission does not exist.
    $permission = filter_permission_name($format);
    return !empty($permission) ? user_roles(FALSE, $permission) : array();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.