You are here

public function DataFileSystem::userBlocks in Forena Reports 8

List all data blocks a sure has access to.

Return value

array Array of data blocks.

File

src/File/DataFileSystem.php, line 36

Class

DataFileSystem

Namespace

Drupal\forena\File

Code

public function userBlocks($search = '*') {
  $blocks = array();
  $this
    ->validateAllCache();
  $sql = $this
    ->getCache('sql');
  $inc = $this
    ->getCache('inc');
  $xml = $this
    ->getCache('xml');
  $data = array_merge($xml, $sql, $inc);
  if ($data) {
    foreach ($data as $base_name => $obj) {
      if ($search == '*' || drupal_match_path($base_name, $search)) {
        if ($obj->cache) {
          $r = $this->dmSvc
            ->repository($obj->cache['provider']);
          if ($r && $r
            ->access($obj->cache['access'])) {
            $blocks[$base_name] = $obj;
          }
        }
      }
    }
  }
  uksort($blocks, '\\Drupal\\forena\\File\\DataFile::blockCompare');
  return $blocks;
}