function forena_get_categories in Forena Reports 7.2
Same name and namespace in other branches
- 8 forena_ui/forena.admin.inc \forena_get_categories()
- 6.2 forena.admin.inc \forena_get_categories()
- 6 forena.admin.inc \forena_get_categories()
- 7.5 forena.admin.inc \forena_get_categories()
- 7 forena.admin.inc \forena_get_categories()
- 7.3 forena.admin.inc \forena_get_categories()
- 7.4 forena.admin.inc \forena_get_categories()
Auto complete function for categories Checks access for security as well.
Parameters
$string = string to be matched against categories:
Return value
An array containing all matching categories
1 call to forena_get_categories()
- forena_categories_autocomplete in ./
forena.module - Auto complete for categories
File
- ./
forena.admin.inc, line 2597
Code
function forena_get_categories($string = '') {
$result = db_query("SELECT * FROM {forena_reports} where hidden=0 AND category LIKE :category ORDER BY category, title asc", array(
':category' => $string . '%',
));
$categories = array();
foreach ($result as $row) {
$access = TRUE;
$cache = $row->cache;
if ($cache) {
$cache = unserialize($cache);
// Check each callback function to see if we have an error.
if ($cache['access']) {
foreach ($cache['access'] as $callback => $args) {
if ($callback) {
foreach ($args as $arg) {
$access = FALSE;
if (function_exists($callback)) {
$a = $callback($arg);
}
if ($a) {
$access = TRUE;
}
}
}
else {
$access = TRUE;
}
}
}
}
if ($access && !$categories[$row->category]) {
$categories[$row->category] = $row->category;
}
}
return $categories;
}