You are here

function forena_get_user_reports in Forena Reports 6

Same name and namespace in other branches
  1. 8 forena.common.inc \forena_get_user_reports()
  2. 6.2 forena.common.inc \forena_get_user_reports()
  3. 7.5 forena.common.inc \forena_get_user_reports()
  4. 7 forena.common.inc \forena_get_user_reports()
  5. 7.2 forena.common.inc \forena_get_user_reports()
  6. 7.3 forena.common.inc \forena_get_user_reports()
  7. 7.4 forena.common.inc \forena_get_user_reports()
2 calls to forena_get_user_reports()
forena_my_reports_block in ./forena.common.inc
Render the my reports category block
forena_user_reports in ./forena.module

File

./forena.common.inc, line 908
Common functions used throughout the project but loaded in this file to keep the module file lean.

Code

function forena_get_user_reports() {
  $result = db_query('SELECT * FROM {forena_reports} where hidden=0 ORDER BY category,title asc');
  $reports = array();
  while ($row = db_fetch_object($result)) {
    $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) {
      $reports[$row->category][] = array(
        'title' => $row->title,
        'report_name' => $row->report_name,
      );
    }
  }
  return $reports;
}