function filter_access

You are here

7 filter.module filter_access($format, $account = NULL)
4.6 filter.module filter_access($format)
4.7 filter.module filter_access($format)
5 filter.module filter_access($format)
6 filter.module filter_access($format)

Checks if a user has access to a particular text format.

Parameters

$format: An object representing the text format.

$account: (optional) The user account to check access for; if omitted, the currently logged-in user is used. Defaults to NULL.

Return value

Boolean TRUE if the user is allowed to access the given format.

5 calls to filter_access()
FilterAdminTestCase::testFilterAdmin in modules/filter/filter.test
Tests filter administration functionality.
FilterFormatAccessTestCase::testFormatPermissions in modules/filter/filter.test
Tests the Filter format access permissions functionality.
filter_formats in modules/filter/filter.module
Retrieves a list of text formats, ordered by weight.
hook_field_prepare_translation in modules/field/field.api.php
Define custom prepare_translation behavior for this module's field types.
text_field_prepare_translation in modules/field/modules/text/text.module
Implements hook_field_prepare_translation().

File

modules/filter/filter.module, line 1022
Framework for handling the filtering of content.

Code

function filter_access($format, $account = NULL) {
  global $user;
  if (!isset($account)) {
    $account = $user;
  }
  // Handle special cases up front. All users have access to the fallback
  // format.
  if ($format->format == filter_fallback_format()) {
    return TRUE;
  }
  // Check the permission if one exists; otherwise, we have a non-existent
  // format so we return FALSE.
  $permission = filter_permission_name($format);
  return !empty($permission) && user_access($permission, $account);
}