X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FAdmin%2FForm%2FPreferences%2FContribute.php;h=6fc6b26d50164f7fdd9d2d9a476624291e2bc410;hb=780c8f48c69ad81040949dab1ddb58240b97315b;hp=7efb2d2e1ef841d2752680a8f0c5ff4d7415d87c;hpb=1d9a471dfd15fcbae1efa35c044c84abbd12f623;p=civicrm-core.git diff --git a/CRM/Admin/Form/Preferences/Contribute.php b/CRM/Admin/Form/Preferences/Contribute.php index 7efb2d2e1e..6fc6b26d50 100644 --- a/CRM/Admin/Form/Preferences/Contribute.php +++ b/CRM/Admin/Form/Preferences/Contribute.php @@ -187,33 +187,13 @@ class CRM_Admin_Form_Preferences_Contribute extends CRM_Admin_Form_Preferences { // store the submitted values in an array $params = $this->controller->exportValues($this->_name); $invoiceParams = array_intersect_key($params, $this->invoiceSettings); + // This is a hack - invoicing is it's own setting but it is being used from invoice params + // too. This means that saving from api will not have the desired core effect. + // but we should fix that elsewhere - ie. stop abusing the settings + // and fix the code repetition associated with invoicing + $invoiceParams['invoicing'] = CRM_Utils_Array::value('invoicing', $params, 0); Civi::settings()->set('contribution_invoice_settings', $invoiceParams); parent::postProcess(); - - // @todo - all this should be handled by defining an on change action in the metadata. - // to set default value for 'Invoices / Credit Notes' checkbox on display preferences - $values = CRM_Core_BAO_Setting::getItem("CiviCRM Preferences"); - $optionValues = CRM_Core_OptionGroup::values('user_dashboard_options', FALSE, FALSE, FALSE, NULL, 'name'); - $setKey = array_search('Invoices / Credit Notes', $optionValues); - - if (isset($params['invoicing'])) { - $value = array($setKey => $optionValues[$setKey]); - $setInvoice = CRM_Core_DAO::VALUE_SEPARATOR . - implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($value)) . - CRM_Core_DAO::VALUE_SEPARATOR; - Civi::settings()->set('user_dashboard_options', $values['user_dashboard_options'] . $setInvoice); - } - else { - $setting = explode(CRM_Core_DAO::VALUE_SEPARATOR, substr($values['user_dashboard_options'], 1, -1)); - $invoiceKey = array_search($setKey, $setting); - if ($invoiceKey !== FALSE) { - unset($setting[$invoiceKey]); - } - $settingName = CRM_Core_DAO::VALUE_SEPARATOR . - implode(CRM_Core_DAO::VALUE_SEPARATOR, array_values($setting)) . - CRM_Core_DAO::VALUE_SEPARATOR; - Civi::settings()->set('user_dashboard_options', $settingName); - } } }