X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCustom%2FForm%2FOption.php;h=14e7b509e16a9455650a1db786c62fbc02636033;hb=cc58f6c5756ba74b4a914e21bb011332d5d79c80;hp=dffed8944eb1b4cf83401b7fa60026372737e025;hpb=e13bdcecfa64fe6e56702de4b56421a5f2640232;p=civicrm-core.git diff --git a/CRM/Custom/Form/Option.php b/CRM/Custom/Form/Option.php index dffed8944e..14e7b509e1 100644 --- a/CRM/Custom/Form/Option.php +++ b/CRM/Custom/Form/Option.php @@ -1,34 +1,18 @@ _id)) { - $params = array('id' => $this->_id); + $params = ['id' => $this->_id]; CRM_Core_BAO_CustomOption::retrieve($params, $defaults); - $paramsField = array('id' => $this->_fid); + $paramsField = ['id' => $this->_fid]; CRM_Core_BAO_CustomField::retrieve($paramsField, $fieldDefaults); if ($fieldDefaults['html_type'] == 'CheckBox' @@ -136,7 +121,7 @@ class CRM_Custom_Form_Option extends CRM_Core_Form { } if ($this->_action & CRM_Core_Action::ADD) { - $fieldValues = array('option_group_id' => $this->_optionGroupID); + $fieldValues = ['option_group_id' => $this->_optionGroupID]; $defaults['weight'] = CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_OptionValue', $fieldValues); } @@ -150,20 +135,19 @@ class CRM_Custom_Form_Option extends CRM_Core_Form { */ public function buildQuickForm() { if ($this->_action == CRM_Core_Action::DELETE) { - $option = civicrm_api3('option_value', 'getsingle', array('id' => $this->_id)); + $option = civicrm_api3('option_value', 'getsingle', ['id' => $this->_id]); $this->assign('label', $option['label']); - $this->addButtons(array( - array( - 'type' => 'next', - 'name' => ts('Delete'), - 'isDefault' => TRUE, - ), - array( - 'type' => 'cancel', - 'name' => ts('Cancel'), - ), - ) - ); + $this->addButtons([ + [ + 'type' => 'next', + 'name' => ts('Delete'), + 'isDefault' => TRUE, + ], + [ + 'type' => 'cancel', + 'name' => ts('Cancel'), + ], + ]); } else { // lets trim all the whitespace @@ -192,26 +176,25 @@ class CRM_Custom_Form_Option extends CRM_Core_Form { $this->add('checkbox', 'default_value', ts('Default')); // add a custom form rule - $this->addFormRule(array('CRM_Custom_Form_Option', 'formRule'), $this); + $this->addFormRule(['CRM_Custom_Form_Option', 'formRule'], $this); // add buttons - $this->addButtons(array( - array( - 'type' => 'next', - 'name' => ts('Save'), - 'isDefault' => TRUE, - ), - array( - 'type' => 'next', - 'name' => ts('Save and New'), - 'subName' => 'new', - ), - array( - 'type' => 'cancel', - 'name' => ts('Cancel'), - ), - ) - ); + $this->addButtons([ + [ + 'type' => 'next', + 'name' => ts('Save'), + 'isDefault' => TRUE, + ], + [ + 'type' => 'next', + 'name' => ts('Save and New'), + 'subName' => 'new', + ], + [ + 'type' => 'cancel', + 'name' => ts('Cancel'), + ], + ]); // if view mode pls freeze it with the done button. if ($this->_action & CRM_Core_Action::VIEW) { @@ -223,7 +206,7 @@ class CRM_Custom_Form_Option extends CRM_Core_Form { $this->addElement('button', 'done', ts('Done'), - array('onclick' => "location.href='$url'", 'class' => 'crm-form-submit cancel', 'crm-icon' => 'fa-times') + ['onclick' => "location.href='$url'", 'class' => 'crm-form-submit cancel', 'crm-icon' => 'fa-times'] ); } } @@ -248,17 +231,17 @@ class CRM_Custom_Form_Option extends CRM_Core_Form { $fieldId = $form->_fid; $optionGroupId = $form->_optionGroupID; - $temp = array(); + $temp = []; if (empty($form->_id)) { $query = " SELECT count(*) FROM civicrm_option_value WHERE option_group_id = %1 AND label = %2"; - $params = array( - 1 => array($optionGroupId, 'Integer'), - 2 => array($optionLabel, 'String'), - ); + $params = [ + 1 => [$optionGroupId, 'Integer'], + 2 => [$optionLabel, 'String'], + ]; if (CRM_Core_DAO::singleValueQuery($query, $params) > 0) { $errors['label'] = ts('There is an entry with the same label.'); } @@ -268,10 +251,10 @@ SELECT count(*) FROM civicrm_option_value WHERE option_group_id = %1 AND value = %2"; - $params = array( - 1 => array($optionGroupId, 'Integer'), - 2 => array($optionValue, 'String'), - ); + $params = [ + 1 => [$optionGroupId, 'Integer'], + 2 => [$optionValue, 'String'], + ]; if (CRM_Core_DAO::singleValueQuery($query, $params) > 0) { $errors['value'] = ts('There is an entry with the same value.'); } @@ -287,11 +270,11 @@ SELECT count(*) WHERE option_group_id = %1 AND id != %2 AND label = %3"; - $params = array( - 1 => array($optionGroupId, 'Integer'), - 2 => array($optionId, 'Integer'), - 3 => array($optionLabel, 'String'), - ); + $params = [ + 1 => [$optionGroupId, 'Integer'], + 2 => [$optionId, 'Integer'], + 3 => [$optionLabel, 'String'], + ]; if (CRM_Core_DAO::singleValueQuery($query, $params) > 0) { $errors['label'] = ts('There is an entry with the same label.'); } @@ -303,11 +286,11 @@ SELECT count(*) WHERE option_group_id = %1 AND id != %2 AND value = %3"; - $params = array( - 1 => array($optionGroupId, 'Integer'), - 2 => array($optionId, 'Integer'), - 3 => array($optionValue, 'String'), - ); + $params = [ + 1 => [$optionGroupId, 'Integer'], + 2 => [$optionId, 'Integer'], + 3 => [$optionValue, 'String'], + ]; if (CRM_Core_DAO::singleValueQuery($query, $params) > 0) { $errors['value'] = ts('There is an entry with the same value.'); } @@ -317,7 +300,7 @@ SELECT count(*) SELECT data_type FROM civicrm_custom_field WHERE id = %1"; - $params = array(1 => array($fieldId, 'Integer')); + $params = [1 => [$fieldId, 'Integer']]; $dao = CRM_Core_DAO::executeQuery($query, $params); if ($dao->fetch()) { switch ($dao->data_type) { @@ -356,7 +339,7 @@ SELECT data_type case 'Country': if (!empty($fields["value"])) { - $params = array(1 => array($fields['value'], 'String')); + $params = [1 => [$fields['value'], 'String']]; $query = "SELECT count(*) FROM civicrm_country WHERE name = %1 OR iso_code = %1"; if (CRM_Core_DAO::singleValueQuery($query, $params) <= 0) { $errors['value'] = ts('Invalid default value for country.'); @@ -366,7 +349,7 @@ SELECT data_type case 'StateProvince': if (!empty($fields["value"])) { - $params = array(1 => array($fields['value'], 'String')); + $params = [1 => [$fields['value'], 'String']]; $query = " SELECT count(*) FROM civicrm_state_province @@ -393,11 +376,11 @@ SELECT count(*) $params = $this->controller->exportValues('Option'); if ($this->_action == CRM_Core_Action::DELETE) { - $option = civicrm_api3('option_value', 'getsingle', array('id' => $this->_id)); - $fieldValues = array('option_group_id' => $this->_optionGroupID); + $option = civicrm_api3('option_value', 'getsingle', ['id' => $this->_id]); + $fieldValues = ['option_group_id' => $this->_optionGroupID]; CRM_Utils_Weight::delWeight('CRM_Core_DAO_OptionValue', $this->_id, $fieldValues); CRM_Core_BAO_CustomOption::del($this->_id); - CRM_Core_Session::setStatus(ts('Option "%1" has been deleted.', array(1 => $option['label'])), ts('Deleted'), 'success'); + CRM_Core_Session::setStatus(ts('Option "%1" has been deleted.', [1 => $option['label']]), ts('Deleted'), 'success'); return; } @@ -417,7 +400,7 @@ SELECT count(*) $oldWeight = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', $this->_id, 'weight', 'id'); } - $fieldValues = array('option_group_id' => $this->_optionGroupID); + $fieldValues = ['option_group_id' => $this->_optionGroupID]; $customOption->weight = CRM_Utils_Weight::updateOtherWeights( 'CRM_Core_DAO_OptionValue', @@ -443,7 +426,7 @@ SELECT count(*) if (!empty($params['default_value'])) { if (!in_array($customOption->value, $defVal)) { if (empty($defVal[0])) { - $defVal = array($customOption->value); + $defVal = [$customOption->value]; } else { $defVal[] = $customOption->value; @@ -456,7 +439,7 @@ SELECT count(*) } } elseif (in_array($customOption->value, $defVal)) { - $tempVal = array(); + $tempVal = []; foreach ($defVal as $v) { if ($v != $customOption->value) { $tempVal[] = $v; @@ -498,7 +481,7 @@ SELECT count(*) $customOption->save(); - $msg = ts('Your multiple choice option \'%1\' has been saved', array(1 => $customOption->label)); + $msg = ts('Your multiple choice option \'%1\' has been saved', [1 => $customOption->label]); CRM_Core_Session::setStatus($msg, '', 'success'); $buttonName = $this->controller->getButtonName(); $session = CRM_Core_Session::singleton();