function execute(&$form, $action_id) { $config = $form->actions_config[$action_id]; $this->config = $config = new \GCore\Libs\Parameter($config); if ((bool) $config->get('enabled', 0) === false) { return; } $skipped = $config->get('skipped', ''); if (!empty($skipped)) { $skipped = explode(',', $skipped); array_walk($skipped, create_function('&$val', '$val = trim($val);')); } else { $skipped = array(); } $del = $config->get('delimiter', ','); //handle specific fields only ? if (strlen($config->get('fields_list', ''))) { $fields_list = explode(',', $config->get('fields_list', '')); foreach ($fields_list as $field) { $field = trim($field); //get field value $field_value = \GCore\Libs\Arr::getVal($form->data, explode('.', $field)); if (is_array($field_value)) { $form->data = \GCore\Libs\Arr::setVal($form->data, explode('.', $field), implode($del, $field_value)); } } } else { $form->data = $this->array_handler($form->data, $skipped, $del); } }
function save() { $session = \GCore\Libs\Base::getSession(); parent::_settings('chronoforms'); $chronoforms_settings = new \GCore\Libs\Parameter($this->data['Chronoforms']); if ($chronoforms_settings->get('wizard.safe_save', 1)) { $s_form = array(); //parse_str($this->data['serialized_form_data'], $s_form); if (!empty($this->data['serialized_form_data_chunks'])) { $chunks = $this->data['serialized_form_data_chunks']; $this->data['serialized_form_data'] = implode('', $chunks); } $pairs = explode('&', $this->data['serialized_form_data']); $result = array(); foreach ($pairs as $pair) { $dummy = array(); parse_str($pair, $dummy); $path = array(); self::extract_array_path($dummy, $path); $path = implode('.', $path); $new_path = explode('.', $path); //check if the last path item is numeric, then its an array of values if (is_numeric($new_path[count($new_path) - 1])) { $value = \GCore\Libs\Arr::getVal($dummy, $new_path); $last_numeric_index = $new_path[count($new_path) - 1]; unset($new_path[count($new_path) - 1]); $existing_results = (array) \GCore\Libs\Arr::getVal($result, $new_path, array()); if (!in_array($last_numeric_index, array_keys($existing_results))) { $existing_results[$last_numeric_index] = $value; } else { $existing_results[] = $value; } $result = \GCore\Libs\Arr::setVal($result, $new_path, $existing_results); continue; } if (in_array('{N}', $new_path) !== false) { continue; } $result = \GCore\Libs\Arr::setVal($result, $new_path, \GCore\Libs\Arr::getVal($dummy, $new_path)); } $s_form = $result; $this->data = $s_form; } $result = parent::_save(); if ($result) { $this->_limit_forms(); if ($this->Request->get('save_act') == 'apply') { $this->redirect(r_('index.php?ext=chronoforms&act=edit&id=' . $this->Form->id)); } else { $session->setFlash('success', sprintf(l_('CF_FORM_X_HAS_BEEN_UPDATED'), $this->data['Form']['title'])); $this->redirect(r_('index.php?ext=chronoforms')); } } else { $this->edit(); $this->view = 'edit'; $session->setFlash('error', \GCore\Libs\Arr::flatten($this->Form->errors)); } }
function save() { parent::_settings('chronoforms'); $chronoforms_settings = new \GCore\Libs\Parameter($this->data['Chronoforms']); if ($chronoforms_settings->get('wizard.safe_save', 1)) { $s_form = array(); //parse_str($this->data['serialized_form_data'], $s_form); $pairs = explode('&', $this->data['serialized_form_data']); $result = array(); foreach ($pairs as $pair) { $dummy = array(); parse_str($pair, $dummy); $path = array(); self::extract_array_path($dummy, $path); $path = implode('.', $path); $new_path = explode('.', $path); $result = \GCore\Libs\Arr::setVal($result, $new_path, \GCore\Libs\Arr::getVal($dummy, $new_path)); } $s_form = $result; $this->data = $s_form; } $result = parent::_save(); if ($result) { if ($this->Request->get('save_act') == 'apply') { $this->redirect(r_('index.php?ext=chronoforms&act=edit&id=' . $this->Form->id)); } else { $this->redirect(r_('index.php?ext=chronoforms')); } } else { $this->edit(); $this->view = 'edit'; $session = \GCore\Libs\Base::getSession(); $session->setFlash('error', \GCore\Libs\Arr::flatten($this->Form->errors)); } }