You are here

function forena_create_trans_form_submit in Forena Reports 6.2

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

File

./forena.admin.inc, line 956

Code

function forena_create_trans_form_submit($form, &$form_state) {
  $values = $form_state['values'];
  $base_name = $values['base_name'];
  $desc = forena_report_desc(str_replace('/', '.', $values['report_name']));
  $filename = $desc['filename'];
  $report_name = $desc['name'];
  $r = forena_get_report_editor($report_name);
  $new_name = $values['save_report_language'] . '.' . $base_name;
  $desc = forena_report_desc($new_name);
  $filename = $desc['filename'];
  $report_name = $desc['name'];

  // Title and category
  $r
    ->setTitle($values['title']);

  //determine redirection.
  if (file_exists($filename)) {
    drupal_set_message(t('Report %s already exists', array(
      '%s' => $new_name,
    )), 'error');
    return;
  }
  if (forena_save_report($report_name, $r
    ->asXML(), TRUE) == 1) {
    drupal_set_message(t('Translation,  %s has been created. Switch languages to translate  ', array(
      '%s' => $values['title'],
    )));

    //if this is a new report then redirect to data blocks
    $form_state['redirect'] = array(
      'reports/' . $values['save_report_language'] . '.' . str_replace('/', '.', $base_name) . '/edit/layout',
    );
    unset($form_state['storage']);
  }
}