filter_access

Versions
4.6 – 6
filter_access($format)
7
filter_access($format, $account = NULL)

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.

Return value

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

▾ 2 functions call filter_access()

block_custom_block_form in modules/block/block.module
Define the custom block form.
filter_formats in modules/filter/filter.module
Retrieve a list of text formats, ordered by weight.

Code

modules/filter/filter.module, line 701

<?php
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, and administrators have access to all formats.
  if (user_access('administer filters', $account) || $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);
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.