You are here

public function FrxDataSource::saveBlock in Forena Reports 7.3

Save a data block

Parameters

$block_name String name of block to save:

$data array fields of block to save.:

File

./FrxDataSource.inc, line 432
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

public function saveBlock($block_name, $data) {
  $modified = time();
  $builder = @$data['builder'];
  if (is_array($builder)) {
    $builder = serialize($builder);
  }
  $rs = db_query('SELECT * from {forena_data_blocks} WHERE repository=:repos AND
      block_name = :block_name', array(
    ':repos' => $this->name,
    ':block_name' => $block_name,
  ));
  if ($block = $rs
    ->fetchObject()) {
    db_update('forena_data_blocks')
      ->fields(array(
      'src' => $data['file'],
      'builder' => $builder,
      'access' => $data['access'],
      'modified' => $modified,
    ))
      ->condition('repository', $this->name)
      ->condition('block_name', $block_name)
      ->execute();
  }
  else {
    db_insert('forena_data_blocks')
      ->fields(array(
      'repository' => $this->name,
      'block_name' => $block_name,
      'block_type' => $data['type'],
      'src' => $data['file'],
      'builder' => $builder,
      'access' => $data['access'],
      'locked' => 0,
      'modified' => $modified,
    ))
      ->execute();
  }
}