X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FAdmin%2FForm%2FOptions.php;h=09ef9be861b62a6a7fec23f78eac04cdeaeeccc5;hb=694ca46e05b80a5950504b87b109403de9e8ca3b;hp=87acdefb9d373488c27026f80dc209c4dd3ff307;hpb=4761e98e60472f02b1504e0babd52028a0c83404;p=civicrm-core.git
diff --git a/CRM/Admin/Form/Options.php b/CRM/Admin/Form/Options.php
index 87acdefb9d..09ef9be861 100644
--- a/CRM/Admin/Form/Options.php
+++ b/CRM/Admin/Form/Options.php
@@ -53,12 +53,12 @@ class CRM_Admin_Form_Options extends CRM_Admin_Form {
* @var array
* @static
*/
- protected $_GName;
+ protected $_gLabel;
/**
* Function to pre-process
*
- * @return None
+ * @return void
* @access public
*/
public function preProcess() {
@@ -78,9 +78,9 @@ class CRM_Admin_Form_Options extends CRM_Admin_Form {
else {
$this->_gName = $this->get('gName');
}
- $this->_GName = ucwords(str_replace('_', ' ', $this->_gName));
+ $this->_gLabel = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', $this->_gid, 'title');
$url = "civicrm/admin/options/{$this->_gName}";
- $params = "group={$this->_gName}&reset=1";
+ $params = "reset=1";
if (($this->_action & CRM_Core_Action::DELETE) &&
in_array($this->_gName, array('email_greeting', 'postal_greeting', 'addressee'))
@@ -93,7 +93,7 @@ class CRM_Admin_Form_Options extends CRM_Admin_Form {
$isInUse = CRM_Core_DAO::singleValueQuery($sql, $queryParam);
if ($isInUse) {
$scriptURL = "" . ts('Learn more about a script that can automatically update contact addressee and greeting options.') . "";
- CRM_Core_Session::setStatus(ts('The selected %1 option has not been deleted because it is currently in use. Please update these contacts to use a different format before deleting this option. %2', array(1 => $this->_GName, 2 => $scriptURL)), ts('Sorry'), 'error');
+ CRM_Core_Session::setStatus(ts('The selected %1 option has not been deleted because it is currently in use. Please update these contacts to use a different format before deleting this option. %2', array(1 => $this->_gLabel, 2 => $scriptURL)), ts('Sorry'), 'error');
$redirect = CRM_Utils_System::url($url, $params);
CRM_Utils_System::redirect($redirect);
}
@@ -117,7 +117,7 @@ class CRM_Admin_Form_Options extends CRM_Admin_Form {
*
* @access public
*
- * @return None
+ * @return void
*/
function setDefaultValues() {
$defaults = parent::setDefaultValues();
@@ -142,7 +142,7 @@ class CRM_Admin_Form_Options extends CRM_Admin_Form {
/**
* Function to build the form
*
- * @return None
+ * @return void
* @access public
*/
public function buildQuickForm() {
@@ -270,8 +270,20 @@ class CRM_Admin_Form_Options extends CRM_Admin_Form {
}
//fix for CRM-3552, CRM-4575
- if (in_array($this->_gName, array(
- 'email_greeting', 'postal_greeting', 'addressee', 'from_email_address', 'case_status', 'encounter_medium', 'case_type', 'payment_instrument'))) {
+ $showIsDefaultGroups = array(
+ 'email_greeting',
+ 'postal_greeting',
+ 'addressee',
+ 'from_email_address',
+ 'case_status',
+ 'encounter_medium',
+ 'case_type',
+ 'payment_instrument',
+ 'communication_style',
+ 'soft_credit_type',
+ );
+
+ if (in_array($this->_gName, $showIsDefaultGroups)) {
$this->assign('showDefault', TRUE);
$this->add('checkbox', 'is_default', ts('Default Option?'));
}
@@ -314,13 +326,11 @@ class CRM_Admin_Form_Options extends CRM_Admin_Form {
*/
static function formRule($fields, $files, $self) {
$errors = array();
- if ($self->_gName == 'case_status' && !CRM_Utils_Array::value('grouping', $fields)) {
+ if ($self->_gName == 'case_status' && empty($fields['grouping'])) {
$errors['grouping'] = ts('Status class is a required field');
}
- if (in_array($self->_gName, array('email_greeting', 'postal_greeting', 'addressee'))
- && !CRM_Utils_Array::value('is_reserved', $self->_defaultValues)
- ) {
+ if (in_array($self->_gName, array('email_greeting', 'postal_greeting', 'addressee')) && empty($self->_defaultValues['is_reserved'])) {
$label = $fields['label'];
$condition = " AND v.label = '{$label}' ";
$values = CRM_Core_OptionGroup::values($self->_gName, FALSE, FALSE, FALSE, $condition, 'filter');
@@ -342,7 +352,7 @@ class CRM_Admin_Form_Options extends CRM_Admin_Form {
}
$formName = explode('"', $fields['label']);
- if (!CRM_Utils_Array::value(1, $formName) || count($formName) != 3) {
+ if (empty($formName[1]) || count($formName) != 3) {
$errors['label'] = ts('Please follow the proper format for From Email Address');
}
}
@@ -355,7 +365,7 @@ class CRM_Admin_Form_Options extends CRM_Admin_Form {
*
* @access public
*
- * @return None
+ * @return void
*/
public function postProcess() {
if ($this->_action & CRM_Core_Action::DELETE) {
@@ -367,10 +377,10 @@ class CRM_Admin_Form_Options extends CRM_Admin_Form {
CRM_Core_BAO_Phone::setOptionToNull(CRM_Utils_Array::value('value', $this->_defaultValues));
}
- CRM_Core_Session::setStatus(ts('Selected %1 type has been deleted.', array(1 => $this->_GName)), ts('Record Deleted'), 'success');
+ CRM_Core_Session::setStatus(ts('Selected %1 type has been deleted.', array(1 => $this->_gLabel)), ts('Record Deleted'), 'success');
}
else {
- CRM_Core_Session::setStatus(ts('Selected %1 type has not been deleted.', array(1 => $this->_GName)), ts('Sorry'), 'error');
+ CRM_Core_Session::setStatus(ts('Selected %1 type has not been deleted.', array(1 => $this->_gLabel)), ts('Sorry'), 'error');
CRM_Utils_Weight::correctDuplicateWeights('CRM_Core_DAO_OptionValue', $fieldValues);
}
}
@@ -395,16 +405,20 @@ class CRM_Admin_Form_Options extends CRM_Admin_Form {
}
}
- // set db value of filter in params if filter is non editable
- if ($this->_id && !array_key_exists('filter', $params) && !$this->_gName == 'participant_role') {
- $params['filter'] = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', $this->_id, 'filter', 'id');
+ // set value of filter if not present in params
+ if ($this->_id && !array_key_exists('filter', $params)) {
+ if ($this->_gName == 'participant_role') {
+ $params['filter'] = 0;
+ } else {
+ $params['filter'] = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', $this->_id, 'filter', 'id');
+ }
}
$groupParams = array('name' => ($this->_gName));
$optionValue = CRM_Core_OptionValue::addOptionValue($params, $groupParams, $this->_action, $this->_id);
// CRM-11516
- if (CRM_Utils_Array::value('financial_account_id', $params)) {
+ if (!empty($params['financial_account_id'])) {
$relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Asset Account is' "));
$params = array(
'entity_table' => 'civicrm_option_value',
@@ -415,7 +429,7 @@ class CRM_Admin_Form_Options extends CRM_Admin_Form {
CRM_Financial_BAO_FinancialTypeAccount::add($params);
}
- CRM_Core_Session::setStatus(ts('The %1 \'%2\' has been saved.', array(1 => $this->_GName, 2 => $optionValue->label)), ts('Saved'), 'success');
+ CRM_Core_Session::setStatus(ts('The %1 \'%2\' has been saved.', array(1 => $this->_gLabel, 2 => $optionValue->label)), ts('Saved'), 'success');
}
}
}