You are here

function filter_formats in Drupal 4

Same name and namespace in other branches
  1. 8 core/modules/filter/filter.module \filter_formats()
  2. 5 modules/filter/filter.module \filter_formats()
  3. 6 modules/filter/filter.module \filter_formats()
  4. 7 modules/filter/filter.module \filter_formats()
  5. 9 core/modules/filter/filter.module \filter_formats()

Retrieve a list of input formats.

6 calls to filter_formats()
blogapi_mt_supported_text_filters in modules/blogapi.module
Blogging API callback. Sends a list of available input formats.
filter_access in modules/filter.module
Returns true if the user is allowed to access this format.
filter_admin_overview in modules/filter.module
Displays a list of all input formats and which one is the default
filter_form in modules/filter.module
Generate a selector for choosing a format in a form.
filter_menu in modules/filter.module
Implementation of hook_menu().

... See full list

1 string reference to 'filter_formats'
system_update_169 in database/updates.inc

File

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

Code

function filter_formats() {
  global $user;
  static $formats;

  // Administrators can always use all input formats.
  $all = user_access('administer filters');
  if (!isset($formats)) {
    $formats = array();
    $query = 'SELECT * FROM {filter_formats}';

    // Build query for selecting the format(s) based on the user's roles.
    if (!$all) {
      $where = array();
      foreach ($user->roles as $rid => $role) {
        $where[] = "roles LIKE '%%,%d,%%'";
        $args[] = $rid;
      }
      $query .= ' WHERE ' . implode(' OR ', $where) . ' OR format = %d';
      $args[] = variable_get('filter_default_format', 1);
    }
    $result = db_query($query, $args);
    while ($format = db_fetch_object($result)) {
      $formats[$format->format] = $format;
    }
  }
  return $formats;
}