You are here

function forena_query_editor_validate in Forena Reports 7.5

Same name and namespace in other branches
  1. 8 forena_query/forena_query.inc \forena_query_editor_validate()
  2. 7.4 forena_query.inc \forena_query_editor_validate()
1 string reference to 'forena_query_editor_validate'
forena_query_editor in ./forena_query.inc
Basic SQL Editor form hook implementation

File

./forena_query.inc, line 183

Code

function forena_query_editor_validate($form, &$form_state) {
  $o = Frx::BlockEditor();
  $o
    ->load($form_state['storage']['block_name']);
  if (user_access('forena data security')) {
    $r = $o
      ->repos();
    $access = $r
      ->access($form_state['values']['access']);
    if (!$access) {
      form_set_error('access', t('You must be granted access to use this right.'));
    }
  }
  if (!Frx::DataFile()
    ->isWritable(Frx::BlockEditor()->block_name . '.sql')) {
    form_set_error('block', t('Insufficient Permission to save file'));
  }
  $config = array_merge($form_state['storage']['block'], $form_state['values']['config']);
  $o
    ->configValidate($form_state['values']['builder'], $config);
  $form_state['storage']['block'] = $config;
}