You are here

function forena_query_validate_block in Forena Reports 7.3

1 string reference to 'forena_query_validate_block'
forena_query_builder_form in ./forena_query.inc

File

./forena_query.inc, line 228

Code

function forena_query_validate_block($form, &$form_state) {
  $repos_list = Frx::RepoMan()->repositories;
  @(list($provider, $block) = @explode('/', $form_state['values']['block'], 2));
  if (!isset($repos_list[$provider])) {
    form_set_error('block', t('Invalid Data Source'));
  }
  else {
    if (!user_access('forena data security') || $_POST['op'] == t('Load')) {
      $block = @Frx::RepoMan()
        ->loadBlock($form_state['values']['block']);
      if (!$block) {
        form_set_error('block', t('Query does not exist'));
      }
    }
  }
  if (isset($form_state['values']['access'])) {
    $r = Frx::RepoMan()
      ->repository($provider);
    $access = $r
      ->access($form_state['values']['access']);
    if (!$access) {
      form_set_error('access', 'You must have access to use this right.');
    }
  }
}