You are here

function forena_user_data_blocks in Forena Reports 6

Same name and namespace in other branches
  1. 6.2 forena.admin.inc \forena_user_data_blocks()
  2. 7 forena.admin.inc \forena_user_data_blocks()
  3. 7.2 forena.admin.inc \forena_user_data_blocks()
  4. 7.3 forena.admin.inc \forena_user_data_blocks()

Provides list of blocks that a user has access to that are in any repository matching a specified search string

Parameters

string $search block to search for.:

Return value

array list of blocks the user has access to.

1 call to forena_user_data_blocks()
forena_data_block_autocomplete in ./forena.module
Auto complete for data blocks

File

./forena.admin.inc, line 1184

Code

function forena_user_data_blocks($search) {
  $repos = forena_repository();
  foreach ($repos as $name => $r) {

    // Make really sure the data provider objects have been instantiated
    $provider = $r;
    if (!$provider['data']) {
      $provider = forena_repository($name);
    }
    $repos[$name] = $provider;

    // Invoke the list block function to find out all of the block names
    $o = $provider['data'];
    if (method_exists($o, 'list_blocks')) {
      $blocks = $o
        ->list_blocks($search);
      foreach ($blocks as $block) {
        $block_info = $o
          ->load_block($block);
        if (method_exists($o, 'access')) {
          $allow = $o
            ->access($block_info['access']);
          if ($allow) {
            $user_blocks[] = $name . '/' . $block;
          }
        }
      }
    }
  }
  return $user_blocks;
}