You are here

function forena_repository in Forena Reports 7

Same name and namespace in other branches
  1. 6 forena.common.inc \forena_repository()
5 calls to forena_repository()
forena_get_formatter in ./forena.common.inc
Load the formatters for all initialized repositories.
forena_invoke_data_provider in ./forena.common.inc
Extract the data by running a block
forena_load_block in ./forena.common.inc
Returns an array of information about the data block
forena_load_cache in ./forena.common.inc
Biuld cache
forena_user_data_blocks in ./forena.admin.inc
Provides list of blocks that a user has access to that are in any repository matching a specified search string

File

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

Code

function forena_repository($name = '') {
  global $_forena_repositories;
  static $repos = '';

  // Empty repository so we need to initialize
  if (!$repos) {

    // Build the default sample one
    $path = drupal_get_path('module', 'forena');
    $repos = array();

    // Load the repository list from the global settings.php file.
    if ($_forena_repositories) {
      $repos = $_forena_repositories;
    }

    // Overide difinitions of the sample and drupal repositories.
    $repos['forena_help'] = array(
      'path' => $path . '/repos/forena_help',
      'title' => 'Forena Sample Reports',
    );
    $repos['drupal'] = array(
      'path' => $path . '/repos/drupal',
      'title' => 'Drupal Reports',
    );
    $repos['sampledb'] = array(
      'path' => $path . '/repos/sample',
      'title' => 'Sample DB Repository',
    );
  }

  // Now determine if the object exists
  if ($name) {
    if (isset($repos[$name])) {
      if (!isset($repos[$name]['data']) || !is_object($repos[$name]['data']) || !isset($repos[$name]['auth']) || !is_object($repos[$name]['auth'])) {
        __forena_load_repository($repos[$name]);
      }
      return $repos[$name];
    }
    else {
      forena_error('Undefined repository' . $name, "Undefined Repository: {$name} <pre>" . print_r($repos, 1) . '</pre>');
    }
  }
  else {
    return $repos;
  }
}