You are here

public function DataManager::__construct in Forena Reports 7.5

Same name and namespace in other branches
  1. 8 src/DataManager.php \Drupal\forena\DataManager::__construct()

File

src/DataManager.php, line 18
DataManager.inc Enter description here ... @author davidmetzler

Class

DataManager

Namespace

Drupal\forena

Code

public function __construct() {
  global $_forena_repositories;

  // Empty repository so we need to initialize
  // Build the default sample one
  $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.
  $path = drupal_get_path('module', 'forena');
  $repos['forena_help'] = array(
    'path' => $path . '/data/forena_help',
    'title' => 'Forena Help Reports',
  );
  $repos['drupal'] = array(
    'path' => $path . '/data/drupal',
    'title' => 'Drupal Reports',
  );
  $repos['sampledb'] = array(
    'path' => $path . '/data/sample',
    'title' => 'Sample DB Repository',
  );
  drupal_alter('forena_repos', $repos);

  // Retrieve the repositories defined in the database;
  $results = db_query('SELECT * FROM {forena_repositories}');
  foreach ($results as $r) {
    if ($r->config) {
      $new_r = unserialize($r->config);
    }
    else {
      $new_r = array();
    }
    $r_name = $r->repository;
    if (is_array(@$repos[$r_name])) {
      $new_r = array_merge($new_r, $repos[$r_name]);
    }
    else {
      $new_r['source'] = 'user';
    }
    $new_r['title'] = $r->title;
    $new_r['enabled'] = $r->enabled;
    $repos[$r_name] = $new_r;
  }
  if ($_forena_repositories) {
    array_merge($repos, $_forena_repositories);
  }
  $this->repositories = $repos;
}