You are here

forena_query.module in Forena Reports 7.3

Same filename and directory in other branches
  1. 7.5 forena_query.module
  2. 7.4 forena_query.module

Provides the ability to create saved queries and to test sql data blocks.

File

forena_query.module
View source
<?php

/**
 * @file
 * Provides the ability to create saved queries
 * and to test sql data blocks.
 */

/**
 * Implementation of hook_menu
 */
function forena_query_menu() {
  $items = array();
  $items['admin/structure/forena/data'] = array(
    'type' => MENU_LOCAL_TASK,
    'title' => 'Data',
    'access arguments' => array(
      'build forena sql blocks',
    ),
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'forena_query_builder_form',
    ),
    'file' => 'forena_query.inc',
  );
  return $items;
}

/**
 * Implementation of hook_permission
 */
function forena_query_permission() {
  $perms = array(
    'build forena sql blocks' => array(
      'title' => 'Build Forena Data Blocks using SQL',
      'description' => 'Direct access to SQL should not be given without understanding of security ramifications',
    ),
    'forena data security' => array(
      'title' => 'Manage forena data security',
      'description' => 'Allows to create new data queries and alter security on saved queries.',
    ),
  );
  foreach (Frx::RepoMan()->repositories as $repos => $conf) {
    $name = $conf['title'] ? $conf['title'] : $repos;
    $perms['create ' . $repos . ' blocks'] = array(
      'title' => 'Create ' . $name . ' Data Blocks',
    );
  }
  return $perms;
}

/**
 * Return permission as to whether the user can save data
 * in the repository.
 * @param $repos string
 */
function forena_query_access_repository($repos) {
  @(list($repos, $block) = @explode('/', $repos, 2));
  return user_access('create ' . $repos . ' blocks');
}

Functions

Namesort descending Description
forena_query_access_repository Return permission as to whether the user can save data in the repository.
forena_query_menu Implementation of hook_menu
forena_query_permission Implementation of hook_permission