You are here

function forena_report_general_form_submit in Forena Reports 8

Same name and namespace in other branches
  1. 7.5 forena.report.inc \forena_report_general_form_submit()
  2. 7.4 forena.report.inc \forena_report_general_form_submit()
1 string reference to 'forena_report_general_form_submit'
forena_report_general_form in ./forena.report.inc

File

./forena.report.inc, line 471

Code

function forena_report_general_form_submit($form, &$form_state) {
  $values = $form_state['values'];
  $report_name = $values['report_name'];
  $r = Frx::Editor($report_name);
  $r_link = $r->report_link;

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

  // Form options
  $options = array(
    'hidden' => $values['hidden'],
  );
  $r
    ->setOptions($options);
  $menu = $r
    ->getMenu();
  $menu['enabled'] = (int) (bool) @$menu['path'];
  $new_menu = $form_state['values']['menu'];
  $new_menu = $values['menu'];

  // Preprocess the menu
  if (!$values['menu']['enabled']) {
    $new_menu = array_fill_keys(array_keys($new_menu), '');
  }
  elseif ($new_menu['type'] !== 'normal-item') {
    $new_menu['plid'] = '';
    $new_menu['menu_name'] = '';
  }
  else {
    @(list($new_menu['menu_name'], $new_menu['plid']) = explode(':', $new_menu['parent'], 2));
    unset($new_menu['parent']);
  }
  unset($menu['enabled']);

  // If the menu is different, save it.
  if ($values['menu'] != $menu) {
    $r
      ->setMenu($new_menu);
  }
  $cache = $r->cache;
  if ($values['cache'] != $cache) {
    $r
      ->setCache($values['cache']);
  }
  $r
    ->update();
  $form_state['redirect'] = array(
    "{$r_link}/edit",
    array(
      'query' => Frx::parms(),
    ),
  );
}