File
- ./
devel_node_access.module, line 683 - This module gives developers feedback as to what their node_access table contains, and which nodes are protected or visible to the public.
Code
function _devel_node_access_filter_formats($index, $account = NULL) {
global $user;
static $formats = array();
if (!isset($account)) {
$account = $user;
}
// Administrators can always use all text formats.
$all = user_access('administer filters', $account);
if (!isset($formats[$account->uid])) {
$formats[$account->uid] = 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 ($account->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[$account->uid][$format->format] = $format;
}
}
if (isset($index)) {
return isset($formats[$account->uid][$index]) ? $formats[$account->uid][$index] : FALSE;
}
return $formats[$account->uid];
}