filter_formats

Versions
4.6 – 5
filter_formats()
6
filter_formats($index = NULL)
7
filter_formats($account = NULL)

Retrieve a list of input formats.

▾ 6 functions call 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
Menu callback; allows administrators to set up input formats.
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().
_filter_tips in modules/filter.module
Helper function for fetching filter tips.

Code

modules/filter.module, line 544

<?php
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;
}
?>
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.