Commit c7cd4e2c authored by eileen's avatar eileen

Fix e-notices on Address settings page, convert YesNo field

This fixes enotices & also does our first preferences conversion of a YesNo / Radio field
parent 880f730b
...@@ -35,84 +35,16 @@ ...@@ -35,84 +35,16 @@
* This class generates form components for Address Section. * This class generates form components for Address Section.
*/ */
class CRM_Admin_Form_Preferences_Address extends CRM_Admin_Form_Preferences { class CRM_Admin_Form_Preferences_Address extends CRM_Admin_Form_Preferences {
public function preProcess() {
CRM_Utils_System::setTitle(ts('Settings - Addresses'));
// Address Standardization
$addrProviders = array(
'' => '- select -',
) + CRM_Core_SelectValues::addressProvider();
$this->_varNames = array(
CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME => array(
'address_options' => array(
'html_type' => 'checkboxes',
'title' => ts('Address Fields'),
'weight' => 1,
),
'address_format' => array(
'html_type' => 'textarea',
'title' => ts('Display Format'),
'description' => NULL,
'weight' => 2,
),
'mailing_format' => array(
'html_type' => 'textarea',
'title' => ts('Mailing Label Format'),
'description' => NULL,
'weight' => 3,
),
'hideCountryMailingLabels' => array(
'html_type' => 'YesNo',
'title' => ts('Hide Country in Mailing Labels when same as domain country'),
'weight' => 4,
),
),
CRM_Core_BAO_Setting::ADDRESS_STANDARDIZATION_PREFERENCES_NAME => array(
'address_standardization_provider' => array(
'html_type' => 'select',
'title' => ts('Provider'),
'option_values' => $addrProviders,
'weight' => 5,
),
'address_standardization_userid' => array(
'html_type' => 'text',
'title' => ts('User ID'),
'description' => NULL,
'weight' => 6,
),
'address_standardization_url' => array(
'html_type' => 'text',
'title' => ts('Web Service URL'),
'description' => NULL,
'weight' => 7,
),
),
);
parent::preProcess();
}
/**
* @return array
*/
public function setDefaultValues() {
$defaults = array();
$defaults['address_standardization_provider'] = $this->_config->address_standardization_provider;
$defaults['address_standardization_userid'] = $this->_config->address_standardization_userid;
$defaults['address_standardization_url'] = $this->_config->address_standardization_url;
$this->addressSequence = isset($newSequence) ? $newSequence : "";
$defaults['address_format'] = $this->_config->address_format; protected $_settings = [
$defaults['mailing_format'] = $this->_config->mailing_format; 'address_options' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
$defaults['hideCountryMailingLabels'] = $this->_config->hideCountryMailingLabels; 'address_format' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
'mailing_format' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
parent::cbsDefaultValues($defaults); 'hideCountryMailingLabels' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
'address_standardization_provider' => CRM_Core_BAO_Setting::ADDRESS_STANDARDIZATION_PREFERENCES_NAME,
return $defaults; 'address_standardization_userid' => CRM_Core_BAO_Setting::ADDRESS_STANDARDIZATION_PREFERENCES_NAME,
} 'address_standardization_url' => CRM_Core_BAO_Setting::ADDRESS_STANDARDIZATION_PREFERENCES_NAME,
];
/** /**
* Build the form object. * Build the form object.
...@@ -142,13 +74,9 @@ class CRM_Admin_Form_Preferences_Address extends CRM_Admin_Form_Preferences { ...@@ -142,13 +74,9 @@ class CRM_Admin_Form_Preferences_Address extends CRM_Admin_Form_Preferences {
// make sure that there is a value for all of them // make sure that there is a value for all of them
// if any of them are set // if any of them are set
if ($p || $u || $w) { if ($p || $u || $w) {
if (!CRM_Utils_System::checkPHPVersion(5, FALSE)) {
$errors['_qf_default'] = ts('Address Standardization features require PHP version 5 or greater.');
return $errors;
}
if (!($p && $u && $w)) { if (!($p && $u && $w)) {
$errors['_qf_default'] = ts('You must provide values for all three Address Standarization fields.'); $errors['_qf_default'] = ts('You must provide values for all three Address Standardization fields.');
return $errors; return $errors;
} }
} }
......
...@@ -188,6 +188,9 @@ trait CRM_Admin_Form_SettingTrait { ...@@ -188,6 +188,9 @@ trait CRM_Admin_Form_SettingTrait {
elseif ($add === 'addEntityRef') { elseif ($add === 'addEntityRef') {
$this->$add($setting, ts($props['title']), $props['entity_reference_options']); $this->$add($setting, ts($props['title']), $props['entity_reference_options']);
} }
elseif ($add === 'addYesNo' && ($props['type'] === 'Boolean')) {
$this->addRadio($setting, ts($props['title']), array(1 => 'Yes', 0 => 'No'), NULL, '  ');
}
else { else {
$this->$add($setting, ts($props['title']), $options); $this->$add($setting, ts($props['title']), $options);
} }
......
...@@ -466,7 +466,7 @@ class CRM_Core_SelectValues { ...@@ -466,7 +466,7 @@ class CRM_Core_SelectValues {
public static function addressProvider() { public static function addressProvider() {
static $addr = NULL; static $addr = NULL;
if (!$addr) { if (!$addr) {
$addr = CRM_Utils_System::getPluginList('CRM/Utils/Address', '.php', array('BatchUpdate')); $addr = array_merge(['' => '- select -'], CRM_Utils_System::getPluginList('CRM/Utils/Address', '.php', array('BatchUpdate')));
} }
return $addr; return $addr;
} }
......
...@@ -229,6 +229,10 @@ class CRM_Utils_Rule { ...@@ -229,6 +229,10 @@ class CRM_Utils_Rule {
* @return bool * @return bool
*/ */
public static function url($url) { public static function url($url) {
if (!$url) {
// If this is required then that should be checked elsewhere - here we are not assuming it is required.
return TRUE;
}
if (preg_match('/^\//', $url)) { if (preg_match('/^\//', $url)) {
// allow relative URL's (CRM-15598) // allow relative URL's (CRM-15598)
$url = 'http://' . $_SERVER['HTTP_HOST'] . $url; $url = 'http://' . $_SERVER['HTTP_HOST'] . $url;
......
...@@ -29,10 +29,9 @@ ...@@ -29,10 +29,9 @@
* *
* @package CRM * @package CRM
* @copyright CiviCRM LLC (c) 2004-2017 * @copyright CiviCRM LLC (c) 2004-2017
* $Id$
*
*/ */
/*
/**
* Settings metadata file * Settings metadata file
*/ */
return array( return array(
...@@ -41,10 +40,11 @@ return array( ...@@ -41,10 +40,11 @@ return array(
'group' => 'address', 'group' => 'address',
'name' => 'address_standardization_provider', 'name' => 'address_standardization_provider',
'type' => 'String', 'type' => 'String',
'html_type' => 'Select', 'html_type' => 'select',
'default' => NULL, 'default' => NULL,
'add' => '4.1', 'add' => '4.1',
'title' => 'Address Standardization Provider.', 'title' => ts('Address Standardization Provider.'),
'pseudoconstant' => ['callback' => 'CRM_Core_SelectValues::addressProvider'],
'is_domain' => 1, 'is_domain' => 1,
'is_contact' => 0, 'is_contact' => 0,
'description' => NULL, 'description' => NULL,
...@@ -55,10 +55,10 @@ return array( ...@@ -55,10 +55,10 @@ return array(
'group' => 'address', 'group' => 'address',
'name' => 'address_standardization_userid', 'name' => 'address_standardization_userid',
'type' => 'String', 'type' => 'String',
'html_type' => 'Text', 'html_type' => 'text',
'default' => NULL, 'default' => NULL,
'add' => '4.1', 'add' => '4.1',
'title' => 'Web service user ID', 'title' => ts('Provider service user ID'),
'is_domain' => 1, 'is_domain' => 1,
'is_contact' => 0, 'is_contact' => 0,
'description' => NULL, 'description' => NULL,
...@@ -69,10 +69,10 @@ return array( ...@@ -69,10 +69,10 @@ return array(
'group' => 'address', 'group' => 'address',
'name' => 'address_standardization_url', 'name' => 'address_standardization_url',
'type' => 'Text', 'type' => 'Text',
'html_type' => 'Text', 'html_type' => 'text',
'default' => NULL, 'default' => NULL,
'add' => '4.1', 'add' => '4.1',
'title' => 'Web Service URL', 'title' => ts('Provider Service URL'),
'is_domain' => 1, 'is_domain' => 1,
'is_contact' => 0, 'is_contact' => 0,
'description' => NULL, 'description' => NULL,
...@@ -87,7 +87,7 @@ return array( ...@@ -87,7 +87,7 @@ return array(
'quick_form_type' => 'YesNo', 'quick_form_type' => 'YesNo',
'default' => 0, 'default' => 0,
'add' => '4.7', 'add' => '4.7',
'title' => 'Hide Country in Mailing Labels when same as domain country', 'title' => ts('Hide Country in Mailing Labels when same as domain country'),
'is_domain' => 1, 'is_domain' => 1,
'is_contact' => 0, 'is_contact' => 0,
'description' => 'Do not display the country field in mailing labels when the country is the same as that of the domain', 'description' => 'Do not display the country field in mailing labels when the country is the same as that of the domain',
......
...@@ -112,27 +112,28 @@ return array( ...@@ -112,27 +112,28 @@ return array(
'group' => 'core', 'group' => 'core',
'name' => 'address_options', 'name' => 'address_options',
'type' => 'String', 'type' => 'String',
'html_type' => 'Text', 'html_type' => 'checkboxes',
'pseudoconstant' => array( 'pseudoconstant' => array(
'optionGroupName' => 'address_options', 'optionGroupName' => 'address_options',
), ),
'default' => '123456891011', 'default' => '123456891011',
'add' => '4.1', 'add' => '4.1',
'title' => 'Addressing Options', 'title' => ts('Address Fields'),
'is_domain' => 1, 'is_domain' => 1,
'is_contact' => 0, 'is_contact' => 0,
'description' => NULL, 'description' => NULL,
'help_text' => NULL, 'help_text' => NULL,
'serialize' => CRM_Core_DAO::SERIALIZE_SEPARATOR_BOOKEND,
), ),
'address_format' => array( 'address_format' => array(
'group_name' => 'CiviCRM Preferences', 'group_name' => 'CiviCRM Preferences',
'group' => 'core', 'group' => 'core',
'name' => 'address_format', 'name' => 'address_format',
'type' => 'String', 'type' => 'String',
'html_type' => 'TextArea', 'html_type' => 'textarea',
'default' => "{contact.address_name}\n{contact.street_address}\n{contact.supplemental_address_1}\n{contact.supplemental_address_2}\n{contact.supplemental_address_3}\n{contact.city}{, }{contact.state_province}{ }{contact.postal_code}\n{contact.country}", 'default' => "{contact.address_name}\n{contact.street_address}\n{contact.supplemental_address_1}\n{contact.supplemental_address_2}\n{contact.supplemental_address_3}\n{contact.city}{, }{contact.state_province}{ }{contact.postal_code}\n{contact.country}",
'add' => '4.1', 'add' => '4.1',
'title' => 'Address Format', 'title' => ts('Address Display Format'),
'is_domain' => 1, 'is_domain' => 1,
'is_contact' => 0, 'is_contact' => 0,
'description' => NULL, 'description' => NULL,
...@@ -143,10 +144,10 @@ return array( ...@@ -143,10 +144,10 @@ return array(
'group' => 'core', 'group' => 'core',
'name' => 'mailing_format', 'name' => 'mailing_format',
'type' => 'String', 'type' => 'String',
'html_type' => 'Text', 'html_type' => 'textarea',
'default' => "{contact.addressee}\n{contact.street_address}\n{contact.supplemental_address_1}\n{contact.supplemental_address_2}\n{contact.supplemental_address_3}\n{contact.city}{, }{contact.state_province}{ }{contact.postal_code}\n{contact.country}", 'default' => "{contact.addressee}\n{contact.street_address}\n{contact.supplemental_address_1}\n{contact.supplemental_address_2}\n{contact.supplemental_address_3}\n{contact.city}{, }{contact.state_province}{ }{contact.postal_code}\n{contact.country}",
'add' => '4.1', 'add' => '4.1',
'title' => 'Mailing Format', 'title' => ts('Mailing Label Format'),
'is_domain' => 1, 'is_domain' => 1,
'is_contact' => 0, 'is_contact' => 0,
'description' => NULL, 'description' => NULL,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment