public function ReportFile::reportsByCategory in Forena Reports 7.5
Generate an ordered list of reports by category
Parameters
$categories:
Return value
array Categories
File
- src/
File/ ReportFile.php, line 125
Class
Namespace
Drupal\forena\FileCode
public function reportsByCategory($categories = array()) {
global $language;
$this
->validateAllCache();
$data = $this
->allReports();
$reports = array();
if ($data) {
foreach ($data as $base_name => $obj) {
if ($obj->cache && @$obj->cache['category'] && !$obj->cache['hidden']) {
$cache = $obj->cache;
if (!$categories || array_search($cache['category'], $categories) !== FALSE) {
// Check each callback function to see if we have an error.
$access = TRUE;
if (@$cache['access']) {
$access = FALSE;
foreach ($cache['access'] as $provider => $callbacks) {
if (user_access('access ' . $provider . ' data')) {
foreach ($callbacks as $callback => $args) {
if ($callback) {
foreach ($args as $arg) {
if (function_exists($callback) && $arg) {
$a = $callback($arg);
if ($a) {
$access = TRUE;
}
}
else {
$access = TRUE;
}
}
}
else {
$access = TRUE;
}
}
}
}
}
if ($access) {
$reports[$cache['category']][] = array(
'title' => $cache['title'],
'category' => $cache['category'],
'report_name' => $base_name,
);
}
}
}
}
}
$sort = defined('SORT_NATURAL') ? SORT_NATURAL : SORT_REGULAR;
// Sort the reports
if ($reports) {
foreach ($reports as $category => $list) {
uasort($reports[$category], '\\Drupal\\forena\\File\\ReportFile::reportTitleCompare');
}
}
ksort($reports, $sort);
return $reports;
}