You are here

protected function FrxDataSource::loadBlockFromDB in Forena Reports 7.3

1 call to FrxDataSource::loadBlockFromDB()
FrxDataSource::loadBlock in ./FrxDataSource.inc
Load blcok data from filesystem

File

./FrxDataSource.inc, line 55
Class that defines default methods for access control in an FrxDataSource

Class

FrxDataSource
@file Class that defines default methods for access control in an FrxDataSource

Code

protected function loadBlockFromDB($block_name) {
  $block = array();

  // IF load from the database if forena_query is there.
  if (module_exists('forena_query')) {

    // See if we have one in the database first
    $sql = 'SELECT * FROM {forena_data_blocks} WHERE repository=:repos AND block_name = :block_name';
    $rs = db_query($sql, array(
      ':repos' => $this->name,
      ':block_name' => $block_name,
    ));
    if ($b = $rs
      ->fetchObject()) {
      $block = array(
        'repository' => $b->repository,
        'block_name' => $b->block_name,
        'type' => $b->block_type,
        'file' => $b->src,
        'builder' => $b->builder,
        'access' => $b->access,
        'title' => $b->title,
        'locked' => $b->locked,
        'modified' => $b->modified,
      );
      switch ($block['type']) {
        case 'sql':
          $block = array_merge($block, $this
            ->parseSQLFile($block['file']));
          break;
        case 'xml':
          $block = array_merge($block, $this
            ->parseXMLFile($block['file']));
          break;
      }
      if ($block['builder']) {
        $block['builder'] = unserialize($block['builder']);
      }
    }
  }
  return $block;
}