You are here

function forena_layout_form_validate in Forena Reports 6

Same name and namespace in other branches
  1. 6.2 forena.admin.inc \forena_layout_form_validate()
  2. 7 forena.admin.inc \forena_layout_form_validate()
  3. 7.2 forena.admin.inc \forena_layout_form_validate()
  4. 7.3 forena.admin.inc \forena_layout_form_validate()
1 string reference to 'forena_layout_form_validate'
forena_layout_form in ./forena.admin.inc
Form function for the edit report form

File

./forena.admin.inc, line 531

Code

function forena_layout_form_validate($form, &$form_state) {
  $values = $form_state['values'];
  $regexp = "/^[A-Za-z0-9\\/\\_\\-]*\$/";
  $save_report_name = $values['save_report_name'];
  $report_name = $values['report_name'];

  //checking illegal characters
  if (!preg_match($regexp, $save_report_name)) {
    form_set_error('save_report_name', t('Invalid character entered in Report Name'));
  }

  //comparing the report names to see if they have changed.

  //If they have, making sure the new name does not already exist.
  if ($report_name != $save_report_name) {
    $report_path = forena_report_path();
    $filename = $report_path . '/' . $save_report_name . '.frx';
    if (file_exists($filename)) {
      form_set_error('save_report_name', t('The file ' . $save_report_name . ' already exists. Please enter another name.'));
    }
  }
}