You are here

function forena_create_trans_form_submit in Forena Reports 7.5

Same name and namespace in other branches
  1. 8 forena_ui/forena.admin.inc \forena_create_trans_form_submit()
  2. 6.2 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 355

Code

function forena_create_trans_form_submit($form, &$form_state) {
  global $language;
  $language = language_default();
  $values = $form_state['values'];
  $base_name = $values['base_name'];
  $new_name = $values['save_report_language'] . '/' . $base_name;
  $r = Frx::Editor($base_name, TRUE);
  $link = $r->report_link;

  // Determine new fielname
  $desc = Frx::Menu()
    ->parseURL($new_name);
  $filename = $desc['filename'];
  $report_name = $desc['name'];

  //determine redirection.
  if (Frx::File()
    ->exists($filename, FALSE)) {
    drupal_set_message(t('Report %s already exists', array(
      '%s' => $new_name,
    )), 'error');
    return;
  }
  else {

    // Title and category
    $r
      ->setTitle($values['title']);
    $r
      ->update();
    $r
      ->rename($new_name);
    drupal_set_message(t('Translation,  %s has been created. Switch languages to translate.', array(
      '%s' => $values['title'],
    )));

    //$r->cancel();
    $r
      ->save();
    $form_state['redirect'] = $link . '/edit';
  }

  //if this is a new report then redirect to data blocks
}