function filter_formats
7.x filter.module | filter_formats( |
6.x filter.module | filter_formats($index = NULL) |
Retrieve a list of input formats.
6 calls to filter_formats()
- blogapi_mt_supported_text_filters in drupal-6.x/
modules/ blogapi/ blogapi.module - Blogging API callback. Sends a list of available input formats.
- filter_access in drupal-6.x/
modules/ filter/ filter.module - Returns TRUE if the user is allowed to access this format.
- filter_admin_overview in drupal-6.x/
modules/ filter/ filter.admin.inc - Menu callback; Displays a list of all input formats and which one is the default.
- filter_form in drupal-6.x/
modules/ filter/ filter.module - Generates a selector for choosing a format in a form.
- filter_format_load in drupal-6.x/
modules/ filter/ filter.module
2 string references to 'filter_formats'
- filter_schema in drupal-6.x/
modules/ filter/ filter.install - Implementation of hook_schema().
- system_install in drupal-6.x/
modules/ system/ system.install - Implementation of hook_install().
File
- drupal-6.x/
modules/ filter/ filter.module, line 290 - Framework for handling filtering of content.
Code
function filter_formats($index = NULL) {
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.
$args = array();
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;
}
}
if (isset($index)) {
return isset($formats[$index]) ? $formats[$index] : FALSE;
}
return $formats;
}