You are here

function forena_settings_submit in Forena Reports 6

Same name and namespace in other branches
  1. 8 forena_ui/forena.admin.inc \forena_settings_submit()
  2. 6.2 forena.admin.inc \forena_settings_submit()
  3. 7.5 forena.admin.inc \forena_settings_submit()
  4. 7 forena.admin.inc \forena_settings_submit()
  5. 7.2 forena.admin.inc \forena_settings_submit()
  6. 7.3 forena.admin.inc \forena_settings_submit()
  7. 7.4 forena.admin.inc \forena_settings_submit()

Added submit handler to create directories and clear menu cache

_state

Parameters

unknown_type $form:

1 string reference to 'forena_settings_submit'
forena_settings in ./forena.admin.inc
Forena admin settings form

File

./forena.admin.inc, line 315

Code

function forena_settings_submit($form, &$form_state) {
  $values = $form_state['values'];
  $path = $values['forena_report_repos'];
  $src_dir = drupal_get_path('module', 'forena') . '/repos/reports';
  if (!file_exists($path)) {
    try {
      if (file_exists($path)) {
        drupal_set_message(t('Created directory %s', array(
          $path,
        )));
      }
      mkdir($path);
    } catch (Exception $e) {
      forena_error(t('Unable to create report directory'), $e
        ->getMessage());
    }
  }
  if (file_exists($path) && $path != $src_dir) {

    // Copy the reports from the
    $i = _forena_copy_reports($src_dir);
    drupal_set_message($i . ' delivered reports copied from ' . $src_dir . ' to ' . $path);
  }
  $save_count = forena_db_sync();
  drupal_set_message('Imported ' . $save_count . ' reports into the database');
  menu_cache_clear();
}