You are here

function FrxRepoMan::blockAccess in Forena Reports 7.3

Same name and namespace in other branches
  1. 7.4 FrxRepoMan.inc \FrxRepoMan::blockAccess()

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

boolean

File

./FrxRepoMan.inc, line 320
FrxRepoMan.inc Enter description here ... @author davidmetzler

Class

FrxRepoMan
@file FrxRepoMan.inc Enter description here ... @author davidmetzler

Code

function blockAccess($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 = Frx::Data();
    $frxData
      ->push(array(), 'frx-block-access');
    $data = Frx::RepoMan()
      ->data($block);
    $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;
}