function postProcess() { // process all form values and save valid settings $values = $this->exportValues(); // save generic settings CRM_Donrec_Logic_Settings::set('donrec_packet_size', $values['packet_size']); if ($values['pdfinfo_path']) { CRM_Donrec_Logic_Settings::set('donrec_pdfinfo_path', $values['pdfinfo_path']); } // first, update current values into slected profile if (!empty($values['selected_profile'])) { $profile = $values['selected_profile']; $profile_data = json_decode($values['profile_data'], 1); $profile_defaults = CRM_Donrec_Logic_Profile::defaultProfileData(); foreach (array_keys($profile_defaults) as $field_name) { $value = CRM_Utils_Array::value($field_name, $values, NULL); if ($value != NULL) { $profile_data[$profile][$field_name] = $value; } } // verify some stuff foreach ($profile_data as $profile_name => $profile) { // test the ID pattern try { $generator = new CRM_Donrec_Logic_IDGenerator($profile['id_pattern'], false); } catch (Exception $e) { $session = CRM_Core_Session::singleton(); $session->setStatus(ts("One of the Receipt ID patterns are invalid! Changes NOT saved!", array('domain' => 'de.systopia.donrec')), ts('Error', array('domain' => 'de.systopia.donrec')), 'error'); return; } } // then store the profiles CRM_Donrec_Logic_Profile::setAllData($profile_data); } $session = CRM_Core_Session::singleton(); $session->setStatus(ts("Settings successfully saved", array('domain' => 'de.systopia.donrec')), ts('Settings', array('domain' => 'de.systopia.donrec')), 'success'); $session->replaceUserContext(CRM_Utils_System::url('civicrm/admin/setting/donrec')); }