function 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.

6 calls to filter_get_roles_by_format()
FilterDefaultConfigTest::testInstallation in drupal/core/modules/filter/lib/Drupal/filter/Tests/FilterDefaultConfigTest.php
Tests installation of default formats.
FilterDefaultConfigTest::testUpdateRoles in drupal/core/modules/filter/lib/Drupal/filter/Tests/FilterDefaultConfigTest.php
Tests that changes to FilterFormat::$roles do not have an effect.
FilterFormatAccessTest::testFormatRoles in drupal/core/modules/filter/lib/Drupal/filter/Tests/FilterFormatAccessTest.php
Tests if text format is available to a role.
filter_admin_format_form in drupal/core/modules/filter/filter.admin.inc
Form constructor for the text format add/edit form.
filter_admin_overview in drupal/core/modules/filter/filter.admin.inc
Page callback: Form constructor for a form to list and reorder text formats.

... See full list

File

drupal/core/modules/filter/filter.module, line 326
Framework for handling the filtering of content.

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_role_names();
  }

  // Do not list any roles if the permission does not exist.
  $permission = filter_permission_name($format);
  return !empty($permission) ? user_role_names(FALSE, $permission) : array();
}