You are here

function FrxReportGenerator::block_access in Forena Reports 7.2

Same name and namespace in other branches
  1. 6.2 FrxReportGenerator.inc \FrxReportGenerator::block_access()

Check access control using the block in a data block. In this case public assess returns true.

Parameters

$block Repository block used to test access:

$path xpath to user right within xml data.:

$access Access to test:

Return value

unknown_type

File

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

Class

FrxReportGenerator

Code

function block_access($block, $path, $access, $cache = TRUE) {

  // PUBLIC always returns true.
  if ($access == 'PUBLIC') {
    return TRUE;
  }
  if (!isset($_SESSION['forena_access'])) {
    $_SESSION['forena_access'] = array();
  }
  if ($cache && isset($_SESSION['forena_access'][$block])) {
    $rights = $_SESSION['forena_access'][$block];
  }
  else {
    $rights = array();

    // Get the block from the repository
    $frxData = FrxData::instance();
    $frxData
      ->push(array(), 'frx-block-access');
    $data = $this
      ->invoke_data_provider($block, array(), NULL);
    $frxData
      ->pop();
    if ($data) {
      if (!$path) {
        $path = '*/*';
      }
      $nodes = $data
        ->xpath($path);
      if ($nodes) {
        foreach ($nodes as $node) {
          $rights[] = (string) $node;
        }
      }
      $_SESSION['forena_access'][$block] = $rights;
    }
  }
  foreach ($rights as $right) {
    if ($access == $right) {
      return TRUE;
    }
  }
  return FALSE;
}