diff --git a/CRM/ACL/Page/ACL.php b/CRM/ACL/Page/ACL.php index fabb7de4252d..7816abcfe0da 100644 --- a/CRM/ACL/Page/ACL.php +++ b/CRM/ACL/Page/ACL.php @@ -135,7 +135,7 @@ public function browse() { $acl[$dao->id]['is_active'] = $dao->is_active; if ($acl[$dao->id]['entity_id']) { - $acl[$dao->id]['entity'] = CRM_Utils_Array::value($acl[$dao->id]['entity_id'], $roles); + $acl[$dao->id]['entity'] = $roles[$acl[$dao->id]['entity_id']] ?? NULL; } else { $acl[$dao->id]['entity'] = ts('Everyone'); @@ -143,22 +143,22 @@ public function browse() { switch ($acl[$dao->id]['object_table']) { case 'civicrm_saved_search': - $acl[$dao->id]['object'] = CRM_Utils_Array::value($acl[$dao->id]['object_id'], $group); + $acl[$dao->id]['object'] = $group[$acl[$dao->id]['object_id']] ?? NULL; $acl[$dao->id]['object_name'] = ts('Group'); break; case 'civicrm_uf_group': - $acl[$dao->id]['object'] = CRM_Utils_Array::value($acl[$dao->id]['object_id'], $ufGroup); + $acl[$dao->id]['object'] = $ufGroup[$acl[$dao->id]['object_id']] ?? NULL; $acl[$dao->id]['object_name'] = ts('Profile'); break; case 'civicrm_custom_group': - $acl[$dao->id]['object'] = CRM_Utils_Array::value($acl[$dao->id]['object_id'], $customGroup); + $acl[$dao->id]['object'] = $customGroup[$acl[$dao->id]['object_id']] ?? NULL; $acl[$dao->id]['object_name'] = ts('Custom Group'); break; case 'civicrm_event': - $acl[$dao->id]['object'] = CRM_Utils_Array::value($acl[$dao->id]['object_id'], $event); + $acl[$dao->id]['object'] = $event[$acl[$dao->id]['object_id']] ?? NULL; $acl[$dao->id]['object_name'] = ts('Event'); break; } diff --git a/CRM/ACL/Page/ACLBasic.php b/CRM/ACL/Page/ACLBasic.php index 0129f0390662..ff643d0890f2 100644 --- a/CRM/ACL/Page/ACLBasic.php +++ b/CRM/ACL/Page/ACLBasic.php @@ -114,7 +114,7 @@ public function browse() { $acl[$dao->entity_id]['name'] = $dao->name; $acl[$dao->entity_id]['entity_id'] = $dao->entity_id; $acl[$dao->entity_id]['entity_table'] = $dao->entity_table; - $acl[$dao->entity_id]['object_table'] = CRM_Utils_Array::value($dao->object_table, $permissions); + $acl[$dao->entity_id]['object_table'] = $permissions[$dao->object_table] ?? NULL; $acl[$dao->entity_id]['is_active'] = 1; if ($acl[$dao->entity_id]['entity_id']) { diff --git a/CRM/ACL/Page/EntityRole.php b/CRM/ACL/Page/EntityRole.php index 3b2ca6d762a4..0e7b5b809773 100644 --- a/CRM/ACL/Page/EntityRole.php +++ b/CRM/ACL/Page/EntityRole.php @@ -127,7 +127,7 @@ public function browse() { $entityRoles[$dao->id] = []; CRM_Core_DAO::storeValues($dao, $entityRoles[$dao->id]); - $entityRoles[$dao->id]['acl_role'] = CRM_Utils_Array::value($dao->acl_role_id, $aclRoles); + $entityRoles[$dao->id]['acl_role'] = $aclRoles[$dao->acl_role_id] ?? NULL; $entityRoles[$dao->id]['entity'] = $groups[$dao->entity_id]; // form all action links diff --git a/CRM/Activity/BAO/Activity.php b/CRM/Activity/BAO/Activity.php index 06f0e91b62bd..77607f4616a2 100644 --- a/CRM/Activity/BAO/Activity.php +++ b/CRM/Activity/BAO/Activity.php @@ -153,7 +153,7 @@ public static function deleteActivity(&$params, $moveToTrash = FALSE) { $sourceRecordIds = implode(',', $params['source_record_id']); } else { - $sourceRecordIds = CRM_Utils_Array::value('source_record_id', $params); + $sourceRecordIds = $params['source_record_id'] ?? NULL; } $result = NULL; @@ -490,7 +490,7 @@ public static function create(&$params) { } else { // at worst, take source for recently viewed display - $recentContactId = CRM_Utils_Array::value('source_contact_id', $params); + $recentContactId = $params['source_contact_id'] ?? NULL; } if (isset($params['assignee_contact_id'])) { @@ -582,7 +582,7 @@ public static function create(&$params) { // if the subject contains a ‘[case #…]’ string, file that activity on the related case (CRM-5916) $matches = []; - $subjectToMatch = CRM_Utils_Array::value('subject', $params); + $subjectToMatch = $params['subject'] ?? NULL; if (preg_match('/\[case #([0-9a-h]{7})\]/', $subjectToMatch, $matches)) { $key = CRM_Core_DAO::escapeString(CIVICRM_SITE_KEY); $hash = $matches[1]; @@ -804,7 +804,7 @@ public static function getActivities($params) { } // case related fields elseif ($apiKey == 'case_id' && !$isBulkActivity) { - $activities[$id][$expectedName] = CRM_Utils_Array::value($apiKey, $activity); + $activities[$id][$expectedName] = $activity[$apiKey] ?? NULL; // fetch case subject for case ID found if (!empty($activity['case_id'])) { @@ -815,9 +815,9 @@ public static function getActivities($params) { } else { // @todo this generic assign could just be handled in array declaration earlier. - $activities[$id][$expectedName] = CRM_Utils_Array::value($apiKey, $activity); + $activities[$id][$expectedName] = $activity[$apiKey] ?? NULL; if ($apiKey == 'campaign_id') { - $activities[$id]['campaign'] = CRM_Utils_Array::value($activities[$id][$expectedName], $allCampaigns); + $activities[$id]['campaign'] = $allCampaigns[$activities[$id][$expectedName]] ?? NULL; } } } @@ -1427,7 +1427,7 @@ public static function sendSMSMessage( // To get primary mobile phonenumber, if not get the first mobile phonenumber if (!empty($toPhoneNumbers)) { $toPhoneNumberDetails = reset($toPhoneNumbers); - $toPhoneNumber = CRM_Utils_Array::value('phone', $toPhoneNumberDetails); + $toPhoneNumber = $toPhoneNumberDetails['phone'] ?? NULL; // Contact allows to send sms } } @@ -2002,8 +2002,8 @@ public static function createFollowupActivity($activityId, $params) { $followupParams['activity_type_id'] = $params['followup_activity_type_id']; // Get Subject of Follow-up Activiity, CRM-4491 - $followupParams['subject'] = CRM_Utils_Array::value('followup_activity_subject', $params); - $followupParams['assignee_contact_id'] = CRM_Utils_Array::value('followup_assignee_contact_id', $params); + $followupParams['subject'] = $params['followup_activity_subject'] ?? NULL; + $followupParams['assignee_contact_id'] = $params['followup_assignee_contact_id'] ?? NULL; // Create target contact for followup. if (!empty($params['target_contact_id'])) { @@ -2523,9 +2523,9 @@ public static function getContactActivitySelector(&$params) { // Format the params. $params['offset'] = ($params['page'] - 1) * $params['rp']; $params['rowCount'] = $params['rp']; - $params['sort'] = CRM_Utils_Array::value('sortBy', $params); + $params['sort'] = $params['sortBy'] ?? NULL; $params['caseId'] = NULL; - $context = CRM_Utils_Array::value('context', $params); + $context = $params['context'] ?? NULL; $showContactOverlay = !CRM_Utils_String::startsWith($context, "dashlet"); $activityTypeInfo = civicrm_api3('OptionValue', 'get', [ 'option_group_id' => "activity_type", @@ -2897,8 +2897,8 @@ public function setApiFilter(&$params) { */ public static function sendToAssignee($activity, $mailToContacts, $params = []) { if (!CRM_Utils_Array::crmIsEmptyArray($mailToContacts)) { - $clientID = CRM_Utils_Array::value('client_id', $params); - $caseID = CRM_Utils_Array::value('case_id', $params); + $clientID = $params['client_id'] ?? NULL; + $caseID = $params['case_id'] ?? NULL; $ics = new CRM_Activity_BAO_ICalendar($activity); $attachments = CRM_Core_BAO_File::getEntityFile('civicrm_activity', $activity->id); diff --git a/CRM/Activity/Form/Activity.php b/CRM/Activity/Form/Activity.php index 84880f2c020d..6f1885e7bd39 100644 --- a/CRM/Activity/Form/Activity.php +++ b/CRM/Activity/Form/Activity.php @@ -230,7 +230,7 @@ public function setFields() { */ public function preProcess() { CRM_Core_Form_RecurringEntity::preProcess('civicrm_activity'); - $this->_atypefile = CRM_Utils_Array::value('atypefile', $_GET); + $this->_atypefile = $_GET['atypefile'] ?? NULL; $this->assign('atypefile', FALSE); if ($this->_atypefile) { $this->assign('atypefile', TRUE); @@ -444,7 +444,7 @@ public function preProcess() { // hack to retrieve activity type id from post variables if (!$this->_activityTypeId) { - $this->_activityTypeId = CRM_Utils_Array::value('activity_type_id', $_POST); + $this->_activityTypeId = $_POST['activity_type_id'] ?? NULL; } // when custom data is included in this page @@ -540,8 +540,8 @@ public function setDefaultValues() { } // Fixme: why are we getting the wrong keys from upstream? - $defaults['target_contact_id'] = CRM_Utils_Array::value('target_contact', $defaults); - $defaults['assignee_contact_id'] = CRM_Utils_Array::value('assignee_contact', $defaults); + $defaults['target_contact_id'] = $defaults['target_contact'] ?? NULL; + $defaults['assignee_contact_id'] = $defaults['assignee_contact'] ?? NULL; // set default tags if exists $defaults['tag'] = implode(',', CRM_Core_BAO_EntityTag::getTag($this->_activityId, 'civicrm_activity')); @@ -649,7 +649,7 @@ public function buildQuickForm() { foreach ($this->_fields as $field => $values) { if (!empty($this->_fields[$field])) { - $attribute = CRM_Utils_Array::value('attributes', $values); + $attribute = $values['attributes'] ?? NULL; $required = !empty($values['required']); if ($values['type'] == 'select' && empty($attribute)) { @@ -831,8 +831,8 @@ public static function formRule($fields, $files, $self) { $errors['activity_type_id'] = ts('Activity Type is a required field'); } - $activity_type_id = CRM_Utils_Array::value('activity_type_id', $fields); - $activity_status_id = CRM_Utils_Array::value('status_id', $fields); + $activity_type_id = $fields['activity_type_id'] ?? NULL; + $activity_status_id = $fields['status_id'] ?? NULL; $scheduled_status_id = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'status_id', 'Scheduled'); if ($activity_type_id && $activity_status_id == $scheduled_status_id) { @@ -1237,7 +1237,7 @@ public function assignActivityType() { // Set title. if (isset($activityTypeDisplayLabels)) { // FIXME - it's not clear why the if line just above is needed here and why we can't just set this once above and re-use. What is interesting, but can't possibly be the reason, is that the first if block will fail if the label is the string '0', whereas this one won't. But who would have an activity type called '0'? - $activityTypeDisplayLabel = CRM_Utils_Array::value($this->_activityTypeId, $activityTypeDisplayLabels); + $activityTypeDisplayLabel = $activityTypeDisplayLabels[$this->_activityTypeId] ?? NULL; if ($this->_currentlyViewedContactId) { $displayName = CRM_Contact_BAO_Contact::displayName($this->_currentlyViewedContactId); diff --git a/CRM/Activity/Form/ActivityView.php b/CRM/Activity/Form/ActivityView.php index e3df30c80a04..172ff26c394d 100644 --- a/CRM/Activity/Form/ActivityView.php +++ b/CRM/Activity/Form/ActivityView.php @@ -59,7 +59,7 @@ public function preProcess() { $this->assign('activityTypeDescription', $activityTypeDescription); if (!empty($defaults['mailingId'])) { - $this->_mailing_id = CRM_Utils_Array::value('source_record_id', $defaults); + $this->_mailing_id = $defaults['source_record_id'] ?? NULL; $mailingReport = CRM_Mailing_BAO_Mailing::report($this->_mailing_id, TRUE); CRM_Mailing_BAO_Mailing::getMailingContent($mailingReport, $this); $this->assign('mailingReport', $mailingReport); diff --git a/CRM/Activity/Form/Search.php b/CRM/Activity/Form/Search.php index 06dab35143ad..56035b42a19f 100644 --- a/CRM/Activity/Form/Search.php +++ b/CRM/Activity/Form/Search.php @@ -251,7 +251,7 @@ public function fixFormValues() { if ($survey) { $this->_formValues['activity_survey_id'] = $this->_defaults['activity_survey_id'] = $survey; - $sid = CRM_Utils_Array::value('activity_survey_id', $this->_formValues); + $sid = $this->_formValues['activity_survey_id'] ?? NULL; $activity_type_id = CRM_Core_DAO::getFieldValue('CRM_Campaign_DAO_Survey', $sid, 'activity_type_id'); // since checkbox are replaced by multiple select option diff --git a/CRM/Activity/Form/Task/Batch.php b/CRM/Activity/Form/Task/Batch.php index ce68c080d95e..b061e86ec40e 100644 --- a/CRM/Activity/Form/Task/Batch.php +++ b/CRM/Activity/Form/Task/Batch.php @@ -146,7 +146,7 @@ public function buildQuickForm() { $typeId = CRM_Core_DAO::getFieldValue("CRM_Activity_DAO_Activity", $activityId, 'activity_type_id'); foreach ($this->_fields as $name => $field) { if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($name)) { - $customValue = CRM_Utils_Array::value($customFieldID, $customFields); + $customValue = $customFields[$customFieldID] ?? NULL; if (!empty($customValue['extends_entity_column_value'])) { $entityColumnValue = explode(CRM_Core_DAO::VALUE_SEPARATOR, $customValue['extends_entity_column_value'] diff --git a/CRM/Activity/Import/Form/MapField.php b/CRM/Activity/Import/Form/MapField.php index 7d68f31b0a60..51cb5aa42baf 100644 --- a/CRM/Activity/Import/Form/MapField.php +++ b/CRM/Activity/Import/Form/MapField.php @@ -309,7 +309,7 @@ public static function formRule($fields) { } if (!empty($fields['saveMapping'])) { - $nameField = CRM_Utils_Array::value('saveMappingName', $fields); + $nameField = $fields['saveMappingName'] ?? NULL; if (empty($nameField)) { $errors['saveMappingName'] = ts('Name is required to save Import Mapping'); } diff --git a/CRM/Activity/Page/AJAX.php b/CRM/Activity/Page/AJAX.php index 26da6433d521..1edf516e6f88 100644 --- a/CRM/Activity/Page/AJAX.php +++ b/CRM/Activity/Page/AJAX.php @@ -249,7 +249,7 @@ public static function convertToCaseActivity() { $params = ['caseID', 'activityID', 'contactID', 'newSubject', 'targetContactIds', 'mode']; $vals = []; foreach ($params as $param) { - $vals[$param] = CRM_Utils_Array::value($param, $_POST); + $vals[$param] = $_POST[$param] ?? NULL; } CRM_Utils_JSON::output(self::_convertToCaseActivity($vals)); diff --git a/CRM/Activity/Selector/Search.php b/CRM/Activity/Selector/Search.php index e2d38c551d9e..d0367750cb8b 100644 --- a/CRM/Activity/Selector/Search.php +++ b/CRM/Activity/Selector/Search.php @@ -282,9 +282,9 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { } } - $contactId = CRM_Utils_Array::value('contact_id', $row); + $contactId = $row['contact_id'] ?? NULL; if (!$contactId) { - $contactId = CRM_Utils_Array::value('source_contact_id', $row); + $contactId = $row['source_contact_id'] ?? NULL; } $row['target_contact_name'] = CRM_Activity_BAO_ActivityContact::getNames($row['activity_id'], $targetID); @@ -339,7 +339,7 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { ); // Carry campaign to selector. - $row['campaign'] = CRM_Utils_Array::value($result->activity_campaign_id, $allCampaigns); + $row['campaign'] = $allCampaigns[$result->activity_campaign_id] ?? NULL; $row['campaign_id'] = $result->activity_campaign_id; if ($engagementLevel = CRM_Utils_Array::value('activity_engagement_level', $row)) { diff --git a/CRM/Activity/StateMachine/Search.php b/CRM/Activity/StateMachine/Search.php index 7249d8c45441..56c408af1248 100644 --- a/CRM/Activity/StateMachine/Search.php +++ b/CRM/Activity/StateMachine/Search.php @@ -65,7 +65,7 @@ public function __construct($controller, $action = CRM_Core_Action::NONE) { */ public function taskName($controller, $formName = 'Search') { // total hack, check POST vars and then session to determine stuff - $value = CRM_Utils_Array::value('task', $_POST); + $value = $_POST['task'] ?? NULL; if (!isset($value)) { $value = $this->_controller->get('task'); } diff --git a/CRM/Admin/Form/MailSettings.php b/CRM/Admin/Form/MailSettings.php index 034228b8a57e..4de49fe41356 100644 --- a/CRM/Admin/Form/MailSettings.php +++ b/CRM/Admin/Form/MailSettings.php @@ -157,7 +157,7 @@ public function postProcess() { $params[$f] = CRM_Utils_Array::value($f, $formValues, FALSE); } else { - $params[$f] = CRM_Utils_Array::value($f, $formValues); + $params[$f] = $formValues[$f] ?? NULL; } } diff --git a/CRM/Admin/Form/MessageTemplates.php b/CRM/Admin/Form/MessageTemplates.php index 47aa143ccbd4..b1bb3419728f 100644 --- a/CRM/Admin/Form/MessageTemplates.php +++ b/CRM/Admin/Form/MessageTemplates.php @@ -94,7 +94,7 @@ public function buildQuickForm() { ]); } else { - $this->_workflow_id = CRM_Utils_Array::value('workflow_id', $this->_values); + $this->_workflow_id = $this->_values['workflow_id'] ?? NULL; $this->checkUserPermission($this->_workflow_id); $this->assign('workflow_id', $this->_workflow_id); @@ -289,7 +289,7 @@ public function postProcess() { } } - $this->_workflow_id = CRM_Utils_Array::value('workflow_id', $this->_values); + $this->_workflow_id = $this->_values['workflow_id'] ?? NULL; if ($this->_workflow_id) { $params['workflow_id'] = $this->_workflow_id; $params['is_active'] = TRUE; diff --git a/CRM/Admin/Form/Navigation.php b/CRM/Admin/Form/Navigation.php index ffd148fc485f..510d039c1372 100644 --- a/CRM/Admin/Form/Navigation.php +++ b/CRM/Admin/Form/Navigation.php @@ -98,7 +98,7 @@ public function setDefaultValues() { if (isset($this->_id)) { //Take parent id in object variable to calculate the menu //weight if menu parent id changed - $this->_currentParentID = CRM_Utils_Array::value('parent_id', $this->_defaults); + $this->_currentParentID = $this->_defaults['parent_id'] ?? NULL; } else { $defaults['permission'] = "access CiviCRM"; diff --git a/CRM/Admin/Form/ParticipantStatusType.php b/CRM/Admin/Form/ParticipantStatusType.php index 4f7516d8d11d..d25661c40bd9 100644 --- a/CRM/Admin/Form/ParticipantStatusType.php +++ b/CRM/Admin/Form/ParticipantStatusType.php @@ -65,7 +65,7 @@ public function setDefaultValues() { if (empty($defaults['weight'])) { $defaults['weight'] = CRM_Utils_Weight::getDefaultWeight('CRM_Event_DAO_ParticipantStatusType'); } - $this->_isReserved = CRM_Utils_Array::value('is_reserved', $defaults); + $this->_isReserved = $defaults['is_reserved'] ?? NULL; if ($this->_isReserved) { $this->freeze(['name', 'class', 'is_active']); } diff --git a/CRM/Admin/Form/RelationshipType.php b/CRM/Admin/Form/RelationshipType.php index 5fc015bd8ed7..ea8bf121351d 100644 --- a/CRM/Admin/Form/RelationshipType.php +++ b/CRM/Admin/Form/RelationshipType.php @@ -138,12 +138,12 @@ public function setDefaultValues() { $params = ['id' => $this->_id]; $baoName = $this->_BAOName; $baoName::retrieve($params, $defaults); - $defaults['contact_types_a'] = CRM_Utils_Array::value('contact_type_a', $defaults); + $defaults['contact_types_a'] = $defaults['contact_type_a'] ?? NULL; if (!empty($defaults['contact_sub_type_a'])) { $defaults['contact_types_a'] .= '__' . $defaults['contact_sub_type_a']; } - $defaults['contact_types_b'] = CRM_Utils_Array::value('contact_type_b', $defaults); + $defaults['contact_types_b'] = $defaults['contact_type_b'] ?? NULL; if (!empty($defaults['contact_sub_type_b'])) { $defaults['contact_types_b'] .= '__' . $defaults['contact_sub_type_b']; } @@ -187,7 +187,7 @@ public function postProcess() { $params['contact_sub_type_b'] = $cTypeB[1] ? $cTypeB[1] : 'null'; if (!strlen(trim(CRM_Utils_Array::value('label_b_a', $params)))) { - $params['label_b_a'] = CRM_Utils_Array::value('label_a_b', $params); + $params['label_b_a'] = $params['label_a_b'] ?? NULL; } if (empty($params['id'])) { diff --git a/CRM/Admin/Form/ScheduleReminders.php b/CRM/Admin/Form/ScheduleReminders.php index e0fd77de3cb4..a7b94e70f411 100644 --- a/CRM/Admin/Form/ScheduleReminders.php +++ b/CRM/Admin/Form/ScheduleReminders.php @@ -387,7 +387,7 @@ public function setDefaultValues() { $entityValue = explode(CRM_Core_DAO::VALUE_SEPARATOR, CRM_Utils_Array::value('entity_value', $defaults)); $entityStatus = explode(CRM_Core_DAO::VALUE_SEPARATOR, CRM_Utils_Array::value('entity_status', $defaults)); if (empty($this->getContext())) { - $defaults['entity'][0] = CRM_Utils_Array::value('mapping_id', $defaults); + $defaults['entity'][0] = $defaults['mapping_id'] ?? NULL; $defaults['entity'][1] = $entityValue; $defaults['entity'][2] = $entityStatus; } @@ -400,11 +400,11 @@ public function setDefaultValues() { $recipientListing ); } - $defaults['text_message'] = CRM_Utils_Array::value('body_text', $defaults); - $defaults['html_message'] = CRM_Utils_Array::value('body_html', $defaults); - $defaults['sms_text_message'] = CRM_Utils_Array::value('sms_body_text', $defaults); - $defaults['template'] = CRM_Utils_Array::value('msg_template_id', $defaults); - $defaults['SMStemplate'] = CRM_Utils_Array::value('sms_template_id', $defaults); + $defaults['text_message'] = $defaults['body_text'] ?? NULL; + $defaults['html_message'] = $defaults['body_html'] ?? NULL; + $defaults['sms_text_message'] = $defaults['sms_body_text'] ?? NULL; + $defaults['template'] = $defaults['msg_template_id'] ?? NULL; + $defaults['SMStemplate'] = $defaults['sms_template_id'] ?? NULL; if (!empty($defaults['group_id'])) { $defaults['recipient'] = 'group'; } @@ -489,7 +489,7 @@ public function parseActionSchedule($values) { 'from_email', ]; foreach ($keys as $key) { - $params[$key] = CRM_Utils_Array::value($key, $values); + $params[$key] = $values[$key] ?? NULL; } $params['is_repeat'] = CRM_Utils_Array::value('is_repeat', $values, 0); @@ -515,15 +515,15 @@ public function parseActionSchedule($values) { $params[$mkey] = 'null'; continue; } - $params[$mkey] = CRM_Utils_Array::value($mkey, $values); + $params[$mkey] = $values[$mkey] ?? NULL; } - $params['body_text'] = CRM_Utils_Array::value('text_message', $values); - $params['sms_body_text'] = CRM_Utils_Array::value('sms_text_message', $values); - $params['body_html'] = CRM_Utils_Array::value('html_message', $values); + $params['body_text'] = $values['text_message'] ?? NULL; + $params['sms_body_text'] = $values['sms_text_message'] ?? NULL; + $params['body_html'] = $values['html_message'] ?? NULL; if (CRM_Utils_Array::value('recipient', $values) == 'manual') { - $params['recipient_manual'] = CRM_Utils_Array::value('recipient_manual_id', $values); + $params['recipient_manual'] = $values['recipient_manual_id'] ?? NULL; $params['group_id'] = $params['recipient'] = $params['recipient_listing'] = 'null'; } elseif (CRM_Utils_Array::value('recipient', $values) == 'group') { @@ -531,14 +531,14 @@ public function parseActionSchedule($values) { $params['recipient_manual'] = $params['recipient'] = $params['recipient_listing'] = 'null'; } elseif (isset($values['recipient_listing']) && isset($values['limit_to']) && !CRM_Utils_System::isNull($values['recipient_listing']) && !CRM_Utils_System::isNull($values['limit_to'])) { - $params['recipient'] = CRM_Utils_Array::value('recipient', $values); + $params['recipient'] = $values['recipient'] ?? NULL; $params['recipient_listing'] = implode(CRM_Core_DAO::VALUE_SEPARATOR, CRM_Utils_Array::value('recipient_listing', $values) ); $params['group_id'] = $params['recipient_manual'] = 'null'; } else { - $params['recipient'] = CRM_Utils_Array::value('recipient', $values); + $params['recipient'] = $values['recipient'] ?? NULL; $params['group_id'] = $params['recipient_manual'] = $params['recipient_listing'] = 'null'; } @@ -573,7 +573,7 @@ public function parseActionSchedule($values) { // multilingual options $params['filter_contact_language'] = CRM_Utils_Array::value('filter_contact_language', $values, []); $params['filter_contact_language'] = implode(CRM_Core_DAO::VALUE_SEPARATOR, $params['filter_contact_language']); - $params['communication_language'] = CRM_Utils_Array::value('communication_language', $values, NULL); + $params['communication_language'] = $values['communication_language'] ?? NULL; if ($this->_action & CRM_Core_Action::UPDATE) { $params['id'] = $this->_id; @@ -657,7 +657,7 @@ public function parseActionSchedule($values) { $params['sms_template_id'] = $msgTemplate->id; } else { - $params['sms_template_id'] = CRM_Utils_Array::value('SMStemplate', $values); + $params['sms_template_id'] = $values['SMStemplate'] ?? NULL; } } else { @@ -665,7 +665,7 @@ public function parseActionSchedule($values) { $params['msg_template_id'] = $msgTemplate->id; } else { - $params['msg_template_id'] = CRM_Utils_Array::value('template', $values); + $params['msg_template_id'] = $values['template'] ?? NULL; } } } diff --git a/CRM/Admin/Form/SettingTrait.php b/CRM/Admin/Form/SettingTrait.php index 416409979af7..f1d0e918931c 100644 --- a/CRM/Admin/Form/SettingTrait.php +++ b/CRM/Admin/Form/SettingTrait.php @@ -162,7 +162,7 @@ protected function addFieldsDefinedInSettingsMetadata() { foreach ($settingMetaData as $setting => $props) { $quickFormType = $this->getQuickFormType($props); if (isset($quickFormType)) { - $options = CRM_Utils_Array::value('options', $props); + $options = $props['options'] ?? NULL; if ($options) { if ($props['html_type'] === 'Select' && isset($props['is_required']) && $props['is_required'] === FALSE && !isset($options[''])) { // If the spec specifies the field is not required add a null option. @@ -233,7 +233,7 @@ protected function addFieldsDefinedInSettingsMetadata() { $this->$add($setting, $props['title'], $options); } // Migrate to using an array as easier in smart... - $description = CRM_Utils_Array::value('description', $props); + $description = $props['description'] ?? NULL; $descriptions[$setting] = $description; $this->assign("{$setting}_description", $description); if ($setting === 'max_attachments') { diff --git a/CRM/Admin/Form/WordReplacements.php b/CRM/Admin/Form/WordReplacements.php index 820b3c9aeab0..646379a50788 100644 --- a/CRM/Admin/Form/WordReplacements.php +++ b/CRM/Admin/Form/WordReplacements.php @@ -31,7 +31,7 @@ public function preProcess() { // should rewrite this UI. CRM_Core_BAO_WordReplacement::rebuild(FALSE); - $this->_soInstance = CRM_Utils_Array::value('instance', $_GET); + $this->_soInstance = $_GET['instance'] ?? NULL; $this->assign('soInstance', $this->_soInstance); } @@ -148,10 +148,10 @@ public function buildQuickForm() { public static function formRule($values) { $errors = []; - $oldValues = CRM_Utils_Array::value('old', $values); - $newValues = CRM_Utils_Array::value('new', $values); - $enabled = CRM_Utils_Array::value('enabled', $values); - $exactMatch = CRM_Utils_Array::value('cb', $values); + $oldValues = $values['old'] ?? NULL; + $newValues = $values['new'] ?? NULL; + $enabled = $values['enabled'] ?? NULL; + $exactMatch = $values['cb'] ?? NULL; foreach ($oldValues as $k => $v) { if ($v && !$newValues[$k]) { diff --git a/CRM/Admin/Page/APIExplorer.php b/CRM/Admin/Page/APIExplorer.php index c3669134ed1b..13363ee23122 100644 --- a/CRM/Admin/Page/APIExplorer.php +++ b/CRM/Admin/Page/APIExplorer.php @@ -131,9 +131,9 @@ public static function getExampleFile() { public static function getDoc() { // Verify the API handler we're talking to is valid. $entities = civicrm_api3('Entity', 'get'); - $entity = CRM_Utils_Array::value('entity', $_GET); + $entity = $_GET['entity'] ?? NULL; if (!empty($entity) && in_array($entity, $entities['values']) && strpos($entity, '.') === FALSE) { - $action = CRM_Utils_Array::value('action', $_GET); + $action = $_GET['action'] ?? NULL; $doc = self::getDocblock($entity, $action); $result = [ 'doc' => $doc ? self::formatDocBlock($doc[0]) : 'Not found.', diff --git a/CRM/Admin/Page/MailSettings.php b/CRM/Admin/Page/MailSettings.php index 475f8c5a7d7e..6ede83649efa 100644 --- a/CRM/Admin/Page/MailSettings.php +++ b/CRM/Admin/Page/MailSettings.php @@ -84,7 +84,7 @@ public function browse() { $mailSetting->find(); while ($mailSetting->fetch()) { //replace protocol value with name - $mailSetting->protocol = CRM_Utils_Array::value($mailSetting->protocol, $allProtocols); + $mailSetting->protocol = $allProtocols[$mailSetting->protocol] ?? NULL; CRM_Core_DAO::storeValues($mailSetting, $allMailSettings[$mailSetting->id]); //form all action links diff --git a/CRM/Badge/BAO/Badge.php b/CRM/Badge/BAO/Badge.php index 892c719e31cb..dea0e356c74e 100644 --- a/CRM/Badge/BAO/Badge.php +++ b/CRM/Badge/BAO/Badge.php @@ -204,10 +204,10 @@ public function labelCreator(&$formattedRow, $cellspacing = 0) { if ((CRM_Utils_Array::value('height_image_1', $formattedRow) > CRM_Utils_Array::value('height_image_2', $formattedRow)) && !empty($formattedRow['height_image_1']) ) { - $startOffset = CRM_Utils_Array::value('height_image_1', $formattedRow); + $startOffset = $formattedRow['height_image_1'] ?? NULL; } elseif (!empty($formattedRow['height_image_2'])) { - $startOffset = CRM_Utils_Array::value('height_image_2', $formattedRow); + $startOffset = $formattedRow['height_image_2'] ?? NULL; } if (!empty($formattedRow['participant_image'])) { diff --git a/CRM/Batch/BAO/Batch.php b/CRM/Batch/BAO/Batch.php index 782c6697ab8a..c777fa4acb36 100644 --- a/CRM/Batch/BAO/Batch.php +++ b/CRM/Batch/BAO/Batch.php @@ -43,7 +43,7 @@ class CRM_Batch_BAO_Batch extends CRM_Batch_DAO_Batch { */ public static function create(&$params) { $op = 'edit'; - $batchId = CRM_Utils_Array::value('id', $params); + $batchId = $params['id'] ?? NULL; if (!$batchId) { $op = 'create'; $params['name'] = CRM_Utils_String::titleToVar($params['title']); @@ -150,7 +150,7 @@ public static function getBatchListSelector(&$params) { // format the params $params['offset'] = ($params['page'] - 1) * $params['rp']; $params['rowCount'] = $params['rp']; - $params['sort'] = CRM_Utils_Array::value('sortBy', $params); + $params['sort'] = $params['sortBy'] ?? NULL; // get batches $batches = self::getBatchList($params); @@ -185,8 +185,8 @@ public static function getBatchListSelector(&$params) { $batch['batch_name'] = $value['title']; $batch['total'] = ''; $batch['payment_instrument'] = $value['payment_instrument']; - $batch['item_count'] = CRM_Utils_Array::value('item_count', $value); - $batch['type'] = CRM_Utils_Array::value('batch_type', $value); + $batch['item_count'] = $value['item_count'] ?? NULL; + $batch['type'] = $value['batch_type'] ?? NULL; if (!empty($value['total'])) { // CRM-21205 $batch['total'] = CRM_Utils_Money::format($value['total'], $value['currency']); diff --git a/CRM/Batch/BAO/EntityBatch.php b/CRM/Batch/BAO/EntityBatch.php index 581f6db0b10f..caebb1a87074 100644 --- a/CRM/Batch/BAO/EntityBatch.php +++ b/CRM/Batch/BAO/EntityBatch.php @@ -24,7 +24,7 @@ class CRM_Batch_BAO_EntityBatch extends CRM_Batch_DAO_EntityBatch { */ public static function create(&$params) { $op = 'edit'; - $entityId = CRM_Utils_Array::value('id', $params); + $entityId = $params['id'] ?? NULL; if (!$entityId) { $op = 'create'; } @@ -46,7 +46,7 @@ public static function del($params) { $params = ['id' => $params]; } $entityBatch = new CRM_Batch_DAO_EntityBatch(); - $entityId = CRM_Utils_Array::value('id', $params); + $entityId = $params['id'] ?? NULL; CRM_Utils_Hook::pre('delete', 'EntityBatch', $entityId, $params); $entityBatch->copyValues($params); $entityBatch->delete(); diff --git a/CRM/Batch/Form/Entry.php b/CRM/Batch/Form/Entry.php index a62c649b3254..687c4282e056 100644 --- a/CRM/Batch/Form/Entry.php +++ b/CRM/Batch/Form/Entry.php @@ -463,7 +463,7 @@ private function processContribution(&$params) { continue; } - $value['contact_id'] = CRM_Utils_Array::value($key, $params['primary_contact_id']); + $value['contact_id'] = $params['primary_contact_id'][$key] ?? NULL; // update contact information $this->updateContactInfo($value); @@ -647,7 +647,7 @@ private function processMembership(&$params) { continue; } - $value['contact_id'] = CRM_Utils_Array::value($key, $params['primary_contact_id']); + $value['contact_id'] = $params['primary_contact_id'][$key] ?? NULL; // update contact information $this->updateContactInfo($value); @@ -779,12 +779,12 @@ private function processMembership(&$params) { // The following parameter setting may be obsolete. $this->_params = $params; $value['is_renew'] = TRUE; - $isPayLater = CRM_Utils_Array::value('is_pay_later', $params); + $isPayLater = $params['is_pay_later'] ?? NULL; $campaignId = NULL; if (isset($this->_values) && is_array($this->_values) && !empty($this->_values)) { - $campaignId = CRM_Utils_Array::value('campaign_id', $this->_params); + $campaignId = $this->_params['campaign_id'] ?? NULL; if (!array_key_exists('campaign_id', $this->_params)) { - $campaignId = CRM_Utils_Array::value('campaign_id', $this->_values); + $campaignId = $this->_values['campaign_id'] ?? NULL; } } @@ -792,7 +792,7 @@ private function processMembership(&$params) { 'end_date' => $value['membership_end_date'] ?? NULL, 'start_date' => $value['membership_start_date'] ?? NULL, ]; - $membershipSource = CRM_Utils_Array::value('source', $value); + $membershipSource = $value['source'] ?? NULL; list($membership) = CRM_Member_BAO_Membership::processMembership( $value['contact_id'], $value['membership_type_id'], FALSE, //$numTerms should be default to 1. @@ -822,7 +822,7 @@ private function processMembership(&$params) { ]; foreach ($dateTypes as $dateField => $dateVariable) { $$dateVariable = CRM_Utils_Date::processDate($value[$dateField]); - $fDate[$dateField] = CRM_Utils_Array::value($dateField, $value); + $fDate[$dateField] = $value[$dateField] ?? NULL; } $calcDates = []; @@ -833,9 +833,9 @@ private function processMembership(&$params) { foreach ($calcDates as $memType => $calcDate) { foreach ($dates as $d) { //first give priority to form values then calDates. - $date = CRM_Utils_Array::value($d, $value); + $date = $value[$d] ?? NULL; if (!$date) { - $date = CRM_Utils_Array::value($d, $calcDate); + $date = $calcDate[$d] ?? NULL; } $value[$d] = CRM_Utils_Date::processDate($date); diff --git a/CRM/Campaign/BAO/Campaign.php b/CRM/Campaign/BAO/Campaign.php index 3446316570c2..4696f9e655f6 100644 --- a/CRM/Campaign/BAO/Campaign.php +++ b/CRM/Campaign/BAO/Campaign.php @@ -577,7 +577,7 @@ public static function addCampaign(&$form, $connectedCampaignId = NULL) { $campaignDetails = self::getPermissionedCampaigns($connectedCampaignId, NULL, TRUE, TRUE, $appendDates); $fields = ['campaigns', 'hasAccessCampaign', 'isCampaignEnabled']; foreach ($fields as $fld) { - $$fld = CRM_Utils_Array::value($fld, $campaignDetails); + $$fld = $campaignDetails[$fld] ?? NULL; } $showAddCampaign = FALSE; @@ -618,7 +618,7 @@ public static function addCampaignInComponentSearch(&$form, $elementName = 'camp $campaignDetails = self::getPermissionedCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE); $fields = ['campaigns', 'hasAccessCampaign', 'isCampaignEnabled']; foreach ($fields as $fld) { - $$fld = CRM_Utils_Array::value($fld, $campaignDetails); + $$fld = $campaignDetails[$fld] ?? NULL; } $showCampaignInSearch = FALSE; if ($isCampaignEnabled && $hasAccessCampaign && !empty($campaigns)) { diff --git a/CRM/Campaign/BAO/Query.php b/CRM/Campaign/BAO/Query.php index 8e3191cbcc5f..e70340cffbb4 100644 --- a/CRM/Campaign/BAO/Query.php +++ b/CRM/Campaign/BAO/Query.php @@ -440,8 +440,8 @@ public static function voterClause($params) { if (!is_array($params) || empty($params)) { return $voterClause; } - $surveyId = CRM_Utils_Array::value('campaign_survey_id', $params); - $searchVoterFor = CRM_Utils_Array::value('campaign_search_voter_for', $params); + $surveyId = $params['campaign_survey_id'] ?? NULL; + $searchVoterFor = $params['campaign_search_voter_for'] ?? NULL; //get the survey activities. $activityStatus = CRM_Core_PseudoConstant::activityStatus('name'); @@ -478,7 +478,7 @@ public static function voterClause($params) { ) { $voterIds = []; foreach ($voterActValues as $values) { - $numOfDays = CRM_Utils_Array::value($values['result'], $recontactInterval); + $numOfDays = $recontactInterval[$values['result']] ?? NULL; if ($numOfDays && $values['status_id'] == $completedStatusId ) { diff --git a/CRM/Campaign/Form/Gotv.php b/CRM/Campaign/Form/Gotv.php index bab464051f89..cea96a40baf3 100644 --- a/CRM/Campaign/Form/Gotv.php +++ b/CRM/Campaign/Form/Gotv.php @@ -35,7 +35,7 @@ class CRM_Campaign_Form_Gotv extends CRM_Core_Form { * Processing needed for buildForm and later. */ public function preProcess() { - $this->_search = CRM_Utils_Array::value('search', $_GET); + $this->_search = $_GET['search'] ?? NULL; $this->_force = CRM_Utils_Request::retrieve('force', 'Boolean', $this, FALSE); $this->_surveyId = CRM_Utils_Request::retrieve('sid', 'Positive', $this); $this->_interviewerId = CRM_Utils_Request::retrieve('cid', 'Positive', $this); diff --git a/CRM/Campaign/Form/Petition/Signature.php b/CRM/Campaign/Form/Petition/Signature.php index 4e72b62cf9bc..97dfcea1c443 100644 --- a/CRM/Campaign/Form/Petition/Signature.php +++ b/CRM/Campaign/Form/Petition/Signature.php @@ -487,7 +487,7 @@ public function postProcess() { // create the signature activity record $params['contactId'] = $this->_contactId; - $params['activity_campaign_id'] = CRM_Utils_Array::value('campaign_id', $this->petition); + $params['activity_campaign_id'] = $this->petition['campaign_id'] ?? NULL; $result = $this->bao->createSignature($params); // send thank you or email verification emails diff --git a/CRM/Campaign/Form/Search.php b/CRM/Campaign/Form/Search.php index ca86ffd86b55..66d744995c68 100644 --- a/CRM/Campaign/Form/Search.php +++ b/CRM/Campaign/Form/Search.php @@ -186,7 +186,7 @@ public function buildQuickForm() { 'release' => CRM_Campaign_Task::RELEASE, ); - $currentTaskValue = CRM_Utils_Array::value($this->_operation, $taskMapping); + $currentTaskValue = $taskMapping[$this->_operation] ?? NULL; $taskValue = array($currentTaskValue => $allTasks[$currentTaskValue]); if ($this->_operation == 'interview' && !empty($this->_formValues['campaign_survey_id'])) { $activityTypes = CRM_Core_PseudoConstant::activityType(FALSE, TRUE, FALSE, 'label', TRUE); @@ -288,7 +288,7 @@ public function postProcess() { } public function formatParams() { - $interviewerId = CRM_Utils_Array::value('survey_interviewer_id', $this->_formValues); + $interviewerId = $this->_formValues['survey_interviewer_id'] ?? NULL; if ($interviewerId) { $this->set('interviewerId', $interviewerId); } @@ -298,7 +298,7 @@ public function formatParams() { if ($this->_force) { continue; } - $paramValue = CRM_Utils_Array::value($param, $this->_formValues); + $paramValue = $this->_formValues[$param] ?? NULL; if ($paramValue && is_array($paramValue)) { unset($this->_formValues[$param]); foreach ($paramValue as $key => $value) { @@ -323,7 +323,7 @@ public function formatParams() { //allow voter search in sub-part of given constituents, //but make sure in case user does not select any group. //get all associated campaign groups in where filter, CRM-7406 - $groups = CRM_Utils_Array::value('group', $this->_formValues); + $groups = $this->_formValues['group'] ?? NULL; if ($campaignId && CRM_Utils_System::isNull($groups)) { $campGroups = CRM_Campaign_BAO_Campaign::getCampaignGroups($campaignId); foreach ($campGroups as $id => $title) { @@ -410,7 +410,7 @@ public function voterClause() { ); foreach ($clauseFields as $param => $key) { - $params[$key] = CRM_Utils_Array::value($key, $this->_formValues); + $params[$key] = $this->_formValues[$key] ?? NULL; if (!$params[$key]) { $params[$key] = $this->get($param); } diff --git a/CRM/Campaign/Form/Search/Campaign.php b/CRM/Campaign/Form/Search/Campaign.php index 1471311c5997..3b9928a63469 100644 --- a/CRM/Campaign/Form/Search/Campaign.php +++ b/CRM/Campaign/Form/Search/Campaign.php @@ -40,7 +40,7 @@ public function getDefaultEntity() { * Processing needed for buildForm and later. */ public function preProcess() { - $this->_search = CRM_Utils_Array::value('search', $_GET); + $this->_search = $_GET['search'] ?? NULL; $this->_force = CRM_Utils_Request::retrieve('force', 'Boolean', $this, FALSE, FALSE); $this->_searchTab = CRM_Utils_Request::retrieve('type', 'String', $this, FALSE, 'campaign'); diff --git a/CRM/Campaign/Form/Search/Petition.php b/CRM/Campaign/Form/Search/Petition.php index ac753280739c..bf26cc626ba2 100644 --- a/CRM/Campaign/Form/Search/Petition.php +++ b/CRM/Campaign/Form/Search/Petition.php @@ -31,7 +31,7 @@ class CRM_Campaign_Form_Search_Petition extends CRM_Core_Form { * Processing needed for buildForm and later. */ public function preProcess() { - $this->_search = CRM_Utils_Array::value('search', $_GET); + $this->_search = $_GET['search'] ?? NULL; $this->_force = CRM_Utils_Request::retrieve('force', 'Boolean', $this, FALSE, FALSE); $this->_searchTab = CRM_Utils_Request::retrieve('type', 'String', $this, FALSE, 'petition'); diff --git a/CRM/Campaign/Form/Search/Survey.php b/CRM/Campaign/Form/Search/Survey.php index be1664a1ea40..cdc54144da1c 100644 --- a/CRM/Campaign/Form/Search/Survey.php +++ b/CRM/Campaign/Form/Search/Survey.php @@ -31,7 +31,7 @@ class CRM_Campaign_Form_Search_Survey extends CRM_Core_Form { * Processing needed for buildForm and later. */ public function preProcess() { - $this->_search = CRM_Utils_Array::value('search', $_GET); + $this->_search = $_GET['search'] ?? NULL; $this->_force = CRM_Utils_Request::retrieve('force', 'Boolean', $this, FALSE, FALSE); $this->_searchTab = CRM_Utils_Request::retrieve('type', 'String', $this, FALSE, 'survey'); diff --git a/CRM/Campaign/Form/Task.php b/CRM/Campaign/Form/Task.php index 4e93fc577e36..f59cc30ea60f 100644 --- a/CRM/Campaign/Form/Task.php +++ b/CRM/Campaign/Form/Task.php @@ -35,7 +35,7 @@ public function preProcess() { $this->_task = $values['task']; $campaignTasks = CRM_Campaign_Task::tasks(); - $taskName = CRM_Utils_Array::value($this->_task, $campaignTasks); + $taskName = $campaignTasks[$this->_task] ?? NULL; $this->assign('taskName', $taskName); $ids = []; diff --git a/CRM/Campaign/Form/Task/Interview.php b/CRM/Campaign/Form/Task/Interview.php index fb178f363601..19df2380e9e3 100644 --- a/CRM/Campaign/Form/Task/Interview.php +++ b/CRM/Campaign/Form/Task/Interview.php @@ -87,7 +87,7 @@ public function preProcess() { $buttonName = $this->controller->getButtonName(); $walkListActivityId = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'WalkList'); if ($buttonName == '_qf_Interview_submit_orderBy' && !empty($_POST['order_bys'])) { - $orderByParams = CRM_Utils_Array::value('order_bys', $_POST); + $orderByParams = $_POST['order_bys'] ?? NULL; } elseif ($walkListActivityId == $this->_surveyDetails['activity_type_id']) { $orderByParams @@ -160,9 +160,9 @@ public function preProcess() { $activityIds = []; foreach ($this->_contactIds as $key => $voterId) { - $actVals = CRM_Utils_Array::value($voterId, $this->_surveyActivityIds); - $statusId = CRM_Utils_Array::value('status_id', $actVals); - $activityId = CRM_Utils_Array::value('activity_id', $actVals); + $actVals = $this->_surveyActivityIds[$voterId] ?? NULL; + $statusId = $actVals['status_id'] ?? NULL; + $activityId = $actVals['activity_id'] ?? NULL; if ($activityId && $statusId && $scheduledStatusId == $statusId @@ -233,7 +233,7 @@ public function preProcess() { } //set the title. - $this->_surveyTypeId = CRM_Utils_Array::value('activity_type_id', $this->_surveyValues); + $this->_surveyTypeId = $this->_surveyValues['activity_type_id'] ?? NULL; $surveyTypeLabel = CRM_Core_PseudoConstant::getLabel('CRM_Activity_BAO_Activity', 'activity_type_id', $this->_surveyTypeId); CRM_Utils_System::setTitle(ts('Record %1 Responses', [1 => $surveyTypeLabel])); } @@ -446,8 +446,8 @@ public function postProcess() { * @return mixed */ public static function registerInterview($params) { - $activityId = CRM_Utils_Array::value('activity_id', $params); - $surveyTypeId = CRM_Utils_Array::value('activity_type_id', $params); + $activityId = $params['activity_id'] ?? NULL; + $surveyTypeId = $params['activity_type_id'] ?? NULL; if (!is_array($params) || !$surveyTypeId || !$activityId) { return FALSE; } @@ -496,7 +496,7 @@ public static function registerInterview($params) { } } - $contactId = CRM_Utils_Array::value('voter_id', $params); + $contactId = $params['voter_id'] ?? NULL; if ($contactId && !empty($contactParams)) { CRM_Contact_BAO_Contact::createProfileContact($contactParams, $fields, $contactId); } @@ -516,7 +516,7 @@ public static function registerInterview($params) { } $subject = ''; - $surveyTitle = CRM_Utils_Array::value('surveyTitle', $params); + $surveyTitle = $params['surveyTitle'] ?? NULL; if ($surveyTitle) { $subject = $surveyTitle . ' - '; } diff --git a/CRM/Campaign/Form/Task/Reserve.php b/CRM/Campaign/Form/Task/Reserve.php index aebc1692c434..b0b814b6905a 100644 --- a/CRM/Campaign/Form/Task/Reserve.php +++ b/CRM/Campaign/Form/Task/Reserve.php @@ -104,7 +104,7 @@ public function preProcess() { public function validateSurvey() { $errorMsg = NULL; - $maxVoters = CRM_Utils_Array::value('max_number_of_contacts', $this->_surveyDetails); + $maxVoters = $this->_surveyDetails['max_number_of_contacts'] ?? NULL; if ($maxVoters) { if ($maxVoters <= $this->_numVoters) { $errorMsg = ts('The maximum number of contacts is already reserved for this interviewer.'); @@ -119,7 +119,7 @@ public function validateSurvey() { } } - $defaultNum = CRM_Utils_Array::value('default_number_of_contacts', $this->_surveyDetails); + $defaultNum = $this->_surveyDetails['default_number_of_contacts'] ?? NULL; if (!$errorMsg && $defaultNum && (count($this->_contactIds) > $defaultNum)) { $errorMsg = ts('You can reserve a maximum of %count contact at a time for this survey.', [ @@ -219,7 +219,7 @@ public static function formRule($fields, $files, $self) { public function postProcess() { //add reservation. $countVoters = 0; - $maxVoters = CRM_Utils_Array::value('max_number_of_contacts', $this->_surveyDetails); + $maxVoters = $this->_surveyDetails['max_number_of_contacts'] ?? NULL; $activityStatus = CRM_Core_PseudoConstant::activityStatus('name'); $statusHeld = array_search('Scheduled', $activityStatus); @@ -297,8 +297,8 @@ private function _addRespondentToGroup($contactIds) { $params = $this->controller->exportValues($this->_name); $groups = CRM_Utils_Array::value('groups', $params, []); - $newGroupName = CRM_Utils_Array::value('newGroupName', $params); - $newGroupDesc = CRM_Utils_Array::value('newGroupDesc', $params); + $newGroupName = $params['newGroupName'] ?? NULL; + $newGroupDesc = $params['newGroupDesc'] ?? NULL; $newGroupId = NULL; //create new group. @@ -317,7 +317,7 @@ private function _addRespondentToGroup($contactIds) { $existingGroups = CRM_Core_PseudoConstant::group(); foreach ($groups as $groupId) { $addCount = CRM_Contact_BAO_GroupContact::addContactsToGroup($contactIds, $groupId); - $totalCount = CRM_Utils_Array::value(1, $addCount); + $totalCount = $addCount[1] ?? NULL; if ($groupId == $newGroupId) { $name = $newGroupName; $new = TRUE; diff --git a/CRM/Campaign/Page/AJAX.php b/CRM/Campaign/Page/AJAX.php index 45005703b596..79dcfff17af6 100644 --- a/CRM/Campaign/Page/AJAX.php +++ b/CRM/Campaign/Page/AJAX.php @@ -34,9 +34,9 @@ public static function registerInterview() { $params = []; foreach ($fields as $fld) { - $params[$fld] = CRM_Utils_Array::value($fld, $_POST); + $params[$fld] = $_POST[$fld] ?? NULL; } - $params['details'] = CRM_Utils_Array::value('note', $_POST); + $params['details'] = $_POST['note'] ?? NULL; $voterId = $params['voter_id']; $activityId = $params['activity_id']; @@ -145,7 +145,7 @@ public function voterList() { 'group', 'contact_type', ] as $param) { - $paramValue = CRM_Utils_Array::value($param, $params); + $paramValue = $params[$param] ?? NULL; if ($paramValue) { unset($params[$param]); $paramValue = explode(',', $paramValue); @@ -161,7 +161,7 @@ public function voterList() { 'survey_interviewer_id', 'campaign_search_voter_for', ] as $fld) { - $voterClauseParams[$fld] = CRM_Utils_Array::value($fld, $params); + $voterClauseParams[$fld] = $params[$fld] ?? NULL; } $interviewerId = $surveyTypeId = $surveyId = NULL; @@ -178,7 +178,7 @@ public function voterList() { //allow voter search in sub-part of given constituents, //but make sure in case user does not select any group. //get all associated campaign groups in where filter, CRM-7406 - $groups = CRM_Utils_Array::value('group', $params); + $groups = $params['group'] ?? NULL; if ($campaignId && CRM_Utils_System::isNull($groups)) { $campaignGroups = CRM_Campaign_BAO_Campaign::getCampaignGroups($campaignId); foreach ($campaignGroups as $id => $group) { @@ -392,7 +392,7 @@ public function processVoterData() { ]; $activityParams = []; foreach ($ids as $id) { - $val = CRM_Utils_Array::value($id, $_POST); + $val = $_POST[$id] ?? NULL; if (!$val) { $createActivity = FALSE; break; @@ -415,7 +415,7 @@ public function processVoterData() { $activityTypeId = $surveyValues['activity_type_id']; - $surveytitle = CRM_Utils_Array::value('surveyTitle', $_POST); + $surveytitle = $_POST['surveyTitle'] ?? NULL; if (!$surveytitle) { $surveytitle = $surveyValues['title']; } @@ -442,7 +442,7 @@ public function processVoterData() { [$scheduledStatusId] ); foreach ($activities as $voterId => $values) { - $activityId = CRM_Utils_Array::value('activity_id', $values); + $activityId = $values['activity_id'] ?? NULL; if ($activityId && ($values['status_id'] == $scheduledStatusId)) { CRM_Core_DAO::setFieldValue('CRM_Activity_DAO_Activity', $activityId, @@ -604,7 +604,7 @@ public static function campaignList() { } foreach ($campaigns as $campaignID => $values) { foreach ($selectorCols as $col) { - $searchRows[$campaignID][$col] = CRM_Utils_Array::value($col, $values); + $searchRows[$campaignID][$col] = $values[$col] ?? NULL; } } } @@ -709,7 +709,7 @@ public function surveyList() { } foreach ($surveys as $surveyID => $values) { foreach ($selectorCols as $col) { - $searchRows[$surveyID][$col] = CRM_Utils_Array::value($col, $values); + $searchRows[$surveyID][$col] = $values[$col] ?? NULL; } } } @@ -809,7 +809,7 @@ public function petitionList() { } foreach ($petitions as $petitionID => $values) { foreach ($selectorCols as $col) { - $searchRows[$petitionID][$col] = CRM_Utils_Array::value($col, $values); + $searchRows[$petitionID][$col] = $values[$col] ?? NULL; } } } diff --git a/CRM/Campaign/Page/DashBoard.php b/CRM/Campaign/Page/DashBoard.php index 9af9324cc507..1318dd1c576b 100644 --- a/CRM/Campaign/Page/DashBoard.php +++ b/CRM/Campaign/Page/DashBoard.php @@ -202,10 +202,10 @@ public static function getCampaignSummary($params = []) { ]; foreach ($campaigns as $cmpid => $campaign) { foreach ($properties as $prop) { - $campaignsData[$cmpid][$prop] = CRM_Utils_Array::value($prop, $campaign); + $campaignsData[$cmpid][$prop] = $campaign[$prop] ?? NULL; } - $statusId = CRM_Utils_Array::value('status_id', $campaign); - $campaignsData[$cmpid]['status'] = CRM_Utils_Array::value($statusId, $campaignStatus); + $statusId = $campaign['status_id'] ?? NULL; + $campaignsData[$cmpid]['status'] = $campaignStatus[$statusId] ?? NULL; $campaignsData[$cmpid]['campaign_id'] = $campaign['id']; $campaignsData[$cmpid]['campaign_type'] = $campaignType[$campaign['campaign_type_id']]; @@ -291,8 +291,8 @@ public static function getSurveySummary($params = []) { $surveyType = CRM_Campaign_BAO_Survey::getSurveyActivityType(); foreach ($surveys as $sid => $survey) { $surveysData[$sid] = $survey; - $campaignId = CRM_Utils_Array::value('campaign_id', $survey); - $surveysData[$sid]['campaign'] = CRM_Utils_Array::value($campaignId, $campaigns); + $campaignId = $survey['campaign_id'] ?? NULL; + $surveysData[$sid]['campaign'] = $campaigns[$campaignId] ?? NULL; $surveysData[$sid]['activity_type'] = $surveyType[$survey['activity_type_id']]; if (!empty($survey['release_frequency'])) { $surveysData[$sid]['release_frequency'] = ts('1 Day', ['plural' => '%count Days', 'count' => $survey['release_frequency']]); @@ -397,8 +397,8 @@ public static function getPetitionSummary($params = []) { $petitionType = CRM_Campaign_BAO_Survey::getSurveyActivityType('label', TRUE); foreach ($petitions as $pid => $petition) { $petitionsData[$pid] = $petition; - $camapignId = CRM_Utils_Array::value('campaign_id', $petition); - $petitionsData[$pid]['campaign'] = CRM_Utils_Array::value($camapignId, $campaigns); + $camapignId = $petition['campaign_id'] ?? NULL; + $petitionsData[$pid]['campaign'] = $campaigns[$camapignId] ?? NULL; $petitionsData[$pid]['activity_type'] = $petitionType[$petition['activity_type_id']]; $action = array_sum(array_keys(self::petitionActionLinks())); diff --git a/CRM/Campaign/Selector/Search.php b/CRM/Campaign/Selector/Search.php index a0d3c096e860..73ae1cb41d7b 100644 --- a/CRM/Campaign/Selector/Search.php +++ b/CRM/Campaign/Selector/Search.php @@ -140,8 +140,8 @@ public function __construct( $this->_context = $context; $this->_campaignClause = $surveyClause; - $this->_campaignFromClause = CRM_Utils_Array::value('fromClause', $surveyClause); - $this->_campaignWhereClause = CRM_Utils_Array::value('whereClause', $surveyClause); + $this->_campaignFromClause = $surveyClause['fromClause'] ?? NULL; + $this->_campaignWhereClause = $surveyClause['whereClause'] ?? NULL; // type of selector $this->_action = $action; diff --git a/CRM/Campaign/StateMachine/Search.php b/CRM/Campaign/StateMachine/Search.php index 4b69cbc0368f..f69e47296827 100644 --- a/CRM/Campaign/StateMachine/Search.php +++ b/CRM/Campaign/StateMachine/Search.php @@ -67,7 +67,7 @@ public function __construct($controller, $action = CRM_Core_Action::NONE) { */ public function taskName($controller, $formName = 'Search') { // total hack, check POST vars and then session to determine stuff - $value = CRM_Utils_Array::value('task', $_POST); + $value = $_POST['task'] ?? NULL; if (!isset($value)) { $value = $this->_controller->get('task'); } diff --git a/CRM/Case/BAO/Case.php b/CRM/Case/BAO/Case.php index 1af50d3a0387..0d12748dfe33 100644 --- a/CRM/Case/BAO/Case.php +++ b/CRM/Case/BAO/Case.php @@ -602,15 +602,15 @@ public static function getCases($allCases = TRUE, $params = [], $context = 'dash $case['case_id'] ); $casesList[$key]['subject'] = $case['case_subject']; - $casesList[$key]['case_status'] = CRM_Utils_Array::value($case['case_status_id'], $caseStatuses); + $casesList[$key]['case_status'] = $caseStatuses[$case['case_status_id']] ?? NULL; if ($case['case_status_id'] == CRM_Case_PseudoConstant::getKey('CRM_Case_BAO_Case', 'case_status_id', 'Urgent')) { $casesList[$key]['case_status'] = sprintf('%s', strtoupper($casesList[$key]['case_status'])); } - $casesList[$key]['case_type'] = CRM_Utils_Array::value($case['case_type_id'], $caseTypeTitles); + $casesList[$key]['case_type'] = $caseTypeTitles[$case['case_type_id']] ?? NULL; $casesList[$key]['case_role'] = CRM_Utils_Array::value('case_role', $case, '---'); $casesList[$key]['manager'] = self::getCaseManagerContact($caseTypes[$case['case_type_id']], $case['case_id']); - $casesList[$key]['date'] = CRM_Utils_Array::value($case['activity_type_id'], $activityTypeLabels); + $casesList[$key]['date'] = $activityTypeLabels[$case['activity_type_id']] ?? NULL; if ($actId = CRM_Utils_Array::value('activity_id', $case)) { if (self::checkPermission($actId, 'view', $case['activity_type_id'], $userID)) { if ($type == 'recent') { @@ -951,7 +951,7 @@ public static function getCaseActivity($caseID, &$params, $contactID, $context = $groupBy = " GROUP BY ca.id, tcc.id, scc.id, acc.id, ov.value"; - $sortBy = CRM_Utils_Array::value('sortBy', $params); + $sortBy = $params['sortBy'] ?? NULL; if (!$sortBy) { // CRM-5081 - added id to act like creation date $orderBy = " @@ -962,8 +962,8 @@ public static function getCaseActivity($caseID, &$params, $contactID, $context = $orderBy = " ORDER BY $sortBy "; } - $page = CRM_Utils_Array::value('page', $params); - $rp = CRM_Utils_Array::value('rp', $params); + $page = $params['page'] ?? NULL; + $rp = $params['rp'] ?? NULL; if (!$page) { $page = 1; @@ -1198,7 +1198,7 @@ public static function getRelatedContacts($caseID, $includeDetails = TRUE) { ]; // Add more info about the role (creator, manager) // The XML historically has the reverse direction, so look up reverse. - $role = CRM_Utils_Array::value($dao->role_name_reverse, $caseRoles); + $role = $caseRoles[$dao->role_name_reverse] ?? NULL; if ($role) { unset($role['name']); $details += $role; @@ -1300,7 +1300,7 @@ public static function sendActivityCopy($clientId, $activityId, $contacts, $atta $tplParams['contact'] = $info; self::buildPermissionLinks($tplParams, $activityParams); - $displayName = CRM_Utils_Array::value('display_name', $info); + $displayName = $info['display_name'] ?? NULL; list($result[CRM_Utils_Array::value('contact_id', $info)], $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate( [ @@ -1417,11 +1417,11 @@ public static function getNextScheduledActivity($cases, $type = 'upcoming') { while ($res->fetch()) { if ($type == 'upcoming') { $activityInfo[$res->case_id]['date'] = $res->activity_date_time; - $activityInfo[$res->case_id]['type'] = CRM_Utils_Array::value($res->activity_type_id, $activityTypes); + $activityInfo[$res->case_id]['type'] = $activityTypes[$res->activity_type_id] ?? NULL; } else { $activityInfo[$res->case_id]['date'] = $res->activity_date_time; - $activityInfo[$res->case_id]['type'] = CRM_Utils_Array::value($res->activity_type_id, $activityTypes); + $activityInfo[$res->case_id]['type'] = $activityTypes[$res->activity_type_id] ?? NULL; } } @@ -2022,7 +2022,7 @@ public static function mergeCases( //for duplicate cases do not process singleton activities. $otherActivityIds = $singletonActivityIds = []; foreach ($otherCaseActivities as $caseActivityId => $otherIds) { - $otherActId = CRM_Utils_Array::value('activity_id', $otherIds); + $otherActId = $otherIds['activity_id'] ?? NULL; if (!$otherActId || in_array($otherActId, $otherActivityIds)) { continue; } @@ -2425,7 +2425,7 @@ public static function checkPermission($activityId, $operation, $actTypeId = NUL //check for core permission. $hasPermissions = []; - $checkPermissions = CRM_Utils_Array::value($operation, $permissions); + $checkPermissions = $permissions[$operation] ?? NULL; if (is_array($checkPermissions)) { foreach ($checkPermissions as $per) { if (CRM_Core_Permission::check($per)) { diff --git a/CRM/Case/BAO/CaseType.php b/CRM/Case/BAO/CaseType.php index a65deb470bdf..9937c5627257 100644 --- a/CRM/Case/BAO/CaseType.php +++ b/CRM/Case/BAO/CaseType.php @@ -45,7 +45,7 @@ public static function add(&$params) { $caseTypeDAO = new CRM_Case_DAO_CaseType(); // form the name only if missing: CRM-627 - $nameParam = CRM_Utils_Array::value('name', $params, NULL); + $nameParam = $params['name'] ?? NULL; if (!$nameParam && empty($params['id'])) { $params['name'] = CRM_Utils_String::titleToVar($params['title']); } diff --git a/CRM/Case/Form/Activity.php b/CRM/Case/Form/Activity.php index 219fa7dc057d..293d179aa9ef 100644 --- a/CRM/Case/Form/Activity.php +++ b/CRM/Case/Form/Activity.php @@ -616,7 +616,7 @@ public function postProcess($params = NULL) { if (isset($id) && array_key_exists($id, $this->_relatedContacts) && isset($this->_relatedContacts[$id]['email'])) { //if email already exists in array then append with ', ' another role only otherwise add it to array. if ($contactDetails = CRM_Utils_Array::value($this->_relatedContacts[$id]['email'], $mailToContacts)) { - $caseRole = CRM_Utils_Array::value('role', $this->_relatedContacts[$id]); + $caseRole = $this->_relatedContacts[$id]['role'] ?? NULL; $mailToContacts[$this->_relatedContacts[$id]['email']]['role'] = $contactDetails['role'] . ', ' . $caseRole; } else { diff --git a/CRM/Case/Form/Activity/ChangeCaseStatus.php b/CRM/Case/Form/Activity/ChangeCaseStatus.php index 9c985a2257dd..4acf0cf93f3e 100644 --- a/CRM/Case/Form/Activity/ChangeCaseStatus.php +++ b/CRM/Case/Form/Activity/ChangeCaseStatus.php @@ -127,7 +127,7 @@ public static function formRule($values, $files, $form) { * @param array $params */ public static function beginPostProcess(&$form, &$params) { - $params['id'] = CRM_Utils_Array::value('case_id', $params); + $params['id'] = $params['case_id'] ?? NULL; if (CRM_Utils_Array::value('updateLinkedCases', $params) === '1') { $caseID = CRM_Utils_Array::first($form->_caseId); diff --git a/CRM/Case/Form/Activity/LinkCases.php b/CRM/Case/Form/Activity/LinkCases.php index 3e39759d57af..d8c9ea4fe3eb 100644 --- a/CRM/Case/Form/Activity/LinkCases.php +++ b/CRM/Case/Form/Activity/LinkCases.php @@ -98,7 +98,7 @@ public static function buildQuickForm(&$form) { public static function formRule($values, $files, $form) { $errors = []; - $linkCaseId = CRM_Utils_Array::value('link_to_case_id', $values); + $linkCaseId = $values['link_to_case_id'] ?? NULL; assert('is_numeric($linkCaseId)'); if ($linkCaseId == CRM_Utils_Array::first($form->_caseId)) { $errors['link_to_case'] = ts('Please select some other case to link.'); @@ -133,7 +133,7 @@ public static function beginPostProcess(&$form, &$params) { */ public static function endPostProcess(&$form, &$params, &$activity) { $activityId = $activity->id; - $linkCaseID = CRM_Utils_Array::value('link_to_case_id', $params); + $linkCaseID = $params['link_to_case_id'] ?? NULL; //create a link between two cases. if ($activityId && $linkCaseID) { diff --git a/CRM/Case/Form/Activity/OpenCase.php b/CRM/Case/Form/Activity/OpenCase.php index ae9405cc1e32..6c5f82aaaa48 100644 --- a/CRM/Case/Form/Activity/OpenCase.php +++ b/CRM/Case/Form/Activity/OpenCase.php @@ -212,7 +212,7 @@ public static function beginPostProcess(&$form, &$params) { } // rename activity_location param to the correct column name for activity DAO - $params['location'] = CRM_Utils_Array::value('activity_location', $params); + $params['location'] = $params['activity_location'] ?? NULL; // Add attachments CRM_Core_BAO_File::formatAttachment( diff --git a/CRM/Case/Form/CaseView.php b/CRM/Case/Form/CaseView.php index 89283b99131d..a6a244219fea 100644 --- a/CRM/Case/Form/CaseView.php +++ b/CRM/Case/Form/CaseView.php @@ -29,7 +29,7 @@ class CRM_Case_Form_CaseView extends CRM_Core_Form { * Set variables up before form is built. */ public function preProcess() { - $this->_showRelatedCases = CRM_Utils_Array::value('relatedCases', $_GET); + $this->_showRelatedCases = $_GET['relatedCases'] ?? NULL; $xmlProcessorProcess = new CRM_Case_XMLProcessor_Process(); $isMultiClient = $xmlProcessorProcess->getAllowMultipleCaseClients(); @@ -470,7 +470,7 @@ public static function activityForm($form, $aTypes = []) { $allCaseActTypes = CRM_Case_PseudoConstant::caseActivityType(); foreach ($allCaseActTypes as $typeDetails) { if (!in_array($typeDetails['name'], ['Open Case'])) { - $aTypesFilter[$typeDetails['id']] = CRM_Utils_Array::value('label', $typeDetails); + $aTypesFilter[$typeDetails['id']] = $typeDetails['label'] ?? NULL; } } $aTypesFilter = $aTypesFilter + $aTypes; diff --git a/CRM/Case/Form/Task/Batch.php b/CRM/Case/Form/Task/Batch.php index 702e0971f02e..ed0d9e050cdd 100644 --- a/CRM/Case/Form/Task/Batch.php +++ b/CRM/Case/Form/Task/Batch.php @@ -60,7 +60,7 @@ public function postProcess() { // Get the case status $daoClass = 'CRM_Case_DAO_Case'; - $caseStatus = CRM_Utils_Array::value('case_status', $value); + $caseStatus = $value['case_status'] ?? NULL; if (!$caseStatus) { // default to existing status ID $caseStatus = CRM_Core_DAO::getFieldValue($daoClass, $key, 'status_id'); diff --git a/CRM/Case/StateMachine/Search.php b/CRM/Case/StateMachine/Search.php index 327fb746dce5..a89c2c6a3674 100644 --- a/CRM/Case/StateMachine/Search.php +++ b/CRM/Case/StateMachine/Search.php @@ -69,7 +69,7 @@ public function __construct($controller, $action = CRM_Core_Action::NONE) { */ public function taskName($controller, $formName = 'Search') { // total hack, check POST vars and then session to determine stuff - $value = CRM_Utils_Array::value('task', $_POST); + $value = $_POST['task'] ?? NULL; if (!isset($value)) { $value = $this->_controller->get('task'); } diff --git a/CRM/Case/XMLProcessor/Process.php b/CRM/Case/XMLProcessor/Process.php index 066f01f02691..90e1adeb5010 100644 --- a/CRM/Case/XMLProcessor/Process.php +++ b/CRM/Case/XMLProcessor/Process.php @@ -81,8 +81,8 @@ public function get($caseType, $fieldSet, $isLabel = FALSE, $maskAction = FALSE) * @throws Exception */ public function process($xml, &$params) { - $standardTimeline = CRM_Utils_Array::value('standardTimeline', $params); - $activitySetName = CRM_Utils_Array::value('activitySetName', $params); + $standardTimeline = $params['standardTimeline'] ?? NULL; + $activitySetName = $params['activitySetName'] ?? NULL; if ('Open Case' == CRM_Utils_Array::value('activityTypeName', $params)) { // create relationships for the ones that are required @@ -269,7 +269,7 @@ public function activityTypes($activityTypesXML, $maxInst = FALSE, $isLabel = FA foreach ($activityTypeXML as $recordXML) { $activityTypeName = (string ) $recordXML->name; $maxInstances = (string ) $recordXML->max_instances; - $activityTypeInfo = CRM_Utils_Array::value($activityTypeName, $activityTypes); + $activityTypeInfo = $activityTypes[$activityTypeName] ?? NULL; if ($activityTypeInfo['id']) { if ($maskAction) { @@ -415,7 +415,7 @@ public function isActivityPresent(&$params) { public function createActivity($activityTypeXML, &$params) { $activityTypeName = (string) $activityTypeXML->name; $activityTypes = &$this->allActivityTypes(TRUE, TRUE); - $activityTypeInfo = CRM_Utils_Array::value($activityTypeName, $activityTypes); + $activityTypeInfo = $activityTypes[$activityTypeName] ?? NULL; if (!$activityTypeInfo) { $docLink = CRM_Utils_System::docURL2("user/case-management/set-up"); @@ -503,7 +503,7 @@ public function createActivity($activityTypeXML, &$params) { $activityDate = $params['activity_date_time']; } else { - $referenceActivityInfo = CRM_Utils_Array::value($referenceActivityName, $activityTypes); + $referenceActivityInfo = $activityTypes[$referenceActivityName] ?? NULL; if ($referenceActivityInfo['id']) { $caseActivityParams = ['activity_type_id' => $referenceActivityInfo['id']]; @@ -516,7 +516,7 @@ public function createActivity($activityTypeXML, &$params) { if (is_array($referenceActivity)) { foreach ($referenceActivity as $aId => $details) { - $activityDate = CRM_Utils_Array::value('activity_date', $details); + $activityDate = $details['activity_date'] ?? NULL; break; } } diff --git a/CRM/Case/XMLProcessor/Report.php b/CRM/Case/XMLProcessor/Report.php index 453f39ecf965..20ab7a2a650e 100644 --- a/CRM/Case/XMLProcessor/Report.php +++ b/CRM/Case/XMLProcessor/Report.php @@ -116,7 +116,7 @@ public function getActivityTypes($xml, $activitySetName) { foreach ($activitySetXML->ActivityTypes as $activityTypesXML) { foreach ($activityTypesXML as $activityTypeXML) { $activityTypeName = (string ) $activityTypeXML->name; - $activityTypeInfo = CRM_Utils_Array::value($activityTypeName, $allActivityTypes); + $activityTypeInfo = $allActivityTypes[$activityTypeName] ?? NULL; if ($activityTypeInfo) { $activityTypes[$activityTypeInfo['id']] = $activityTypeInfo; } @@ -743,7 +743,7 @@ public static function populateCaseReportTemplate($clientID, $caseID, $activityS $xml = $form->retrieve($case['caseTypeName']); $activitySetNames = CRM_Case_XMLProcessor_Process::activitySets($xml->ActivitySets); - $pageTitle = CRM_Utils_Array::value($activitySetName, $activitySetNames); + $pageTitle = $activitySetNames[$activitySetName] ?? NULL; $template->assign('pageTitle', $pageTitle); if ($activitySetName) { diff --git a/CRM/Contact/BAO/Contact.php b/CRM/Contact/BAO/Contact.php index 50eb6d391462..4f973287651c 100644 --- a/CRM/Contact/BAO/Contact.php +++ b/CRM/Contact/BAO/Contact.php @@ -105,7 +105,7 @@ public function __construct() { */ public static function add(&$params) { $contact = new CRM_Contact_DAO_Contact(); - $contactID = CRM_Utils_Array::value('contact_id', $params); + $contactID = $params['contact_id'] ?? NULL; if (empty($params)) { return NULL; } @@ -164,7 +164,7 @@ public static function add(&$params) { $contact->sort_name = substr($contact->sort_name, 0, 128); } - $privacy = CRM_Utils_Array::value('privacy', $params); + $privacy = $params['privacy'] ?? NULL; if ($privacy && is_array($privacy) && !empty($privacy) @@ -199,7 +199,7 @@ public static function add(&$params) { if ($contact->contact_type === 'Individual' && (isset($params['current_employer']) || isset($params['employer_id']))) { // Create current employer. - $newEmployer = !empty($params['employer_id']) ? $params['employer_id'] : CRM_Utils_Array::value('current_employer', $params); + $newEmployer = !empty($params['employer_id']) ? $params['employer_id'] : $params['current_employer'] ?? NULL; $newContact = FALSE; if (empty($params['contact_id'])) { @@ -433,7 +433,7 @@ public static function unsetProtectedFields(&$contacts) { $currentUser = CRM_Core_Session::getLoggedInContactID(); $editOwn = $currentUser && CRM_Core_Permission::check('edit own api keys'); foreach ($contacts as &$contact) { - $cid = is_object($contact) ? $contact->id : CRM_Utils_Array::value('id', $contact); + $cid = is_object($contact) ? $contact->id : $contact['id'] ?? NULL; if (!($editOwn && $cid == $currentUser)) { if (is_object($contact)) { unset($contact->api_key); @@ -1602,7 +1602,7 @@ public static function &exportableFields($contactType = 'Individual', $status = //Sorting fields in alphabetical order(CRM-1507) foreach ($fields as $k => $v) { - $sortArray[$k] = CRM_Utils_Array::value('title', $v); + $sortArray[$k] = $v['title'] ?? NULL; } $fields = array_merge($sortArray, $fields); @@ -1740,7 +1740,7 @@ public static function &makeHierReturnProperties($fields, $contactId = NULL) { $locationTypeName = 1; } else { - $locationTypeName = CRM_Utils_Array::value($id, $locationTypes); + $locationTypeName = $locationTypes[$id] ?? NULL; if (!$locationTypeName) { continue; } @@ -1806,7 +1806,7 @@ public static function getPrimaryLocationType($contactId, $skipDefaultPriamry = $blocks = CRM_Core_BAO_Location::getValues($entityBlock); foreach ($blocks[$block] as $key => $value) { if (!empty($value['is_primary'])) { - $locationType = CRM_Utils_Array::value('location_type_id', $value); + $locationType = $value['location_type_id'] ?? NULL; } } } @@ -2048,8 +2048,8 @@ public static function formatProfileContactParams( $details = self::getHierContactDetails($contactID, $fields); $contactDetails = $details[$contactID]; - $data['contact_type'] = CRM_Utils_Array::value('contact_type', $contactDetails); - $data['contact_sub_type'] = CRM_Utils_Array::value('contact_sub_type', $contactDetails); + $data['contact_type'] = $contactDetails['contact_type'] ?? NULL; + $data['contact_sub_type'] = $contactDetails['contact_sub_type'] ?? NULL; } else { //we should get contact type only if contact @@ -2098,10 +2098,10 @@ public static function formatProfileContactParams( } if ($ctype == 'Organization') { - $data['organization_name'] = CRM_Utils_Array::value('organization_name', $contactDetails); + $data['organization_name'] = $contactDetails['organization_name'] ?? NULL; } elseif ($ctype == 'Household') { - $data['household_name'] = CRM_Utils_Array::value('household_name', $contactDetails); + $data['household_name'] = $contactDetails['household_name'] ?? NULL; } $locationType = []; @@ -2598,7 +2598,7 @@ public static function getValues(&$params, &$values) { CRM_Core_OptionGroup::lookupValues($temp, $names, FALSE); $values['preferred_communication_method'] = $preffComm; - $values['preferred_communication_method_display'] = CRM_Utils_Array::value('preferred_communication_method_display', $temp); + $values['preferred_communication_method_display'] = $temp['preferred_communication_method_display'] ?? NULL; if ($contact->preferred_mail_format) { $preferredMailingFormat = CRM_Core_SelectValues::pmf(); @@ -2615,8 +2615,8 @@ public static function getValues(&$params, &$values) { $birthDate = CRM_Utils_Date::customFormat($contact->birth_date, '%Y%m%d'); if ($birthDate < date('Ymd')) { $age = CRM_Utils_Date::calculateAge($birthDate); - $values['age']['y'] = CRM_Utils_Array::value('years', $age); - $values['age']['m'] = CRM_Utils_Array::value('months', $age); + $values['age']['y'] = $age['years'] ?? NULL; + $values['age']['m'] = $age['months'] ?? NULL; } } @@ -3246,7 +3246,7 @@ public static function contextMenu($contactId = NULL) { * TRUE if user has all permissions, FALSE if otherwise. */ public static function checkUserMenuPermissions($aclPermissionedTasks, $corePermission, $menuOptions) { - $componentName = CRM_Utils_Array::value('component', $menuOptions); + $componentName = $menuOptions['component'] ?? NULL; // if component action - make sure component is enable. if ($componentName && !in_array($componentName, CRM_Core_Config::singleton()->enableComponents)) { @@ -3256,7 +3256,7 @@ public static function checkUserMenuPermissions($aclPermissionedTasks, $corePerm // make sure user has all required permissions. $hasAllPermissions = FALSE; - $permissions = CRM_Utils_Array::value('permissions', $menuOptions); + $permissions = $menuOptions['permissions'] ?? NULL; if (!is_array($permissions) || empty($permissions)) { $hasAllPermissions = TRUE; } diff --git a/CRM/Contact/BAO/Contact/Utils.php b/CRM/Contact/BAO/Contact/Utils.php index 2e43667b7325..c72691a78a04 100644 --- a/CRM/Contact/BAO/Contact/Utils.php +++ b/CRM/Contact/BAO/Contact/Utils.php @@ -63,7 +63,7 @@ public static function getImage($contactType, $urlOnly = FALSE, $contactId = NUL $type = CRM_Contact_BAO_ContactType::getBasicType($typeInfo['name']) . '-subtype'; } else { - $type = CRM_Utils_Array::value('name', $typeInfo); + $type = $typeInfo['name'] ?? NULL; } // do not add title since it hides contact name @@ -209,9 +209,9 @@ public static function validChecksum($contactID, $inputCheck) { $input = CRM_Utils_System::explode('_', $inputCheck, 3); - $inputCS = CRM_Utils_Array::value(0, $input); - $inputTS = CRM_Utils_Array::value(1, $input); - $inputLF = CRM_Utils_Array::value(2, $input); + $inputCS = $input[0] ?? NULL; + $inputTS = $input[1] ?? NULL; + $inputLF = $input[2] ?? NULL; $check = self::generateChecksum($contactID, $inputTS, $inputLF); // Joomla_11 - If $inputcheck is null without explicitly casting to a string @@ -584,7 +584,7 @@ public static function formatContactIDSToLinks($contactIDs, $addViewLink = TRUE, $contactLinks['rows'][$i]['primary_email'] = $dao->email; // get the permission for current contact id. - $hasPermissions = CRM_Utils_Array::value($dao->id, $permissionedContactIds); + $hasPermissions = $permissionedContactIds[$dao->id] ?? NULL; if (!is_array($hasPermissions) || empty($hasPermissions)) { $i++; continue; @@ -799,7 +799,7 @@ public static function processSharedAddress(&$address) { // 3. get the address details for master_id $masterAddress = new CRM_Core_BAO_Address(); - $masterAddress->id = CRM_Utils_Array::value('master_id', $values); + $masterAddress->id = $values['master_id'] ?? NULL; $masterAddress->find(TRUE); // 4. CRM-10336: Empty all fields (execept the fields to skip) @@ -893,9 +893,9 @@ public static function clearContactCaches($isEmptyPrevNextTable = FALSE) { public static function updateGreeting($params) { $contactType = $params['ct']; $greeting = $params['gt']; - $valueID = $id = CRM_Utils_Array::value('id', $params); - $force = CRM_Utils_Array::value('force', $params); - $limit = CRM_Utils_Array::value('limit', $params); + $valueID = $id = $params['id'] ?? NULL; + $force = $params['force'] ?? NULL; + $limit = $params['limit'] ?? NULL; // if valueID is not passed use default value if (!$valueID) { @@ -908,14 +908,14 @@ public static function updateGreeting($params) { ]; $allGreetings = CRM_Core_PseudoConstant::greeting($filter); - $originalGreetingString = $greetingString = CRM_Utils_Array::value($valueID, $allGreetings); + $originalGreetingString = $greetingString = $allGreetings[$valueID] ?? NULL; if (!$greetingString) { throw new CRM_Core_Exception(ts('Incorrect greeting value id %1, or no default greeting for this contact type and greeting type.', [1 => $valueID])); } // build return properties based on tokens $greetingTokens = CRM_Utils_Token::getTokens($greetingString); - $tokens = CRM_Utils_Array::value('contact', $greetingTokens); + $tokens = $greetingTokens['contact'] ?? NULL; $greetingsReturnProperties = []; if (is_array($tokens)) { $greetingsReturnProperties = array_fill_keys(array_values($tokens), 1); diff --git a/CRM/Contact/BAO/ContactType.php b/CRM/Contact/BAO/ContactType.php index 69b774299b17..c79a77c14821 100644 --- a/CRM/Contact/BAO/ContactType.php +++ b/CRM/Contact/BAO/ContactType.php @@ -515,7 +515,7 @@ public static function getCreateNewList() { foreach ($contactTypes as $key => $value) { if ($key) { $typeValue = explode(CRM_Core_DAO::VALUE_SEPARATOR, $key); - $cType = CRM_Utils_Array::value('0', $typeValue); + $cType = $typeValue['0'] ?? NULL; $typeUrl = 'ct=' . $cType; if ($csType = CRM_Utils_Array::value('1', $typeValue)) { $typeUrl .= "&cst=$csType"; @@ -612,7 +612,7 @@ public static function add(&$params) { $contactType = new CRM_Contact_DAO_ContactType(); $contactType->copyValues($params); - $contactType->id = CRM_Utils_Array::value('id', $params); + $contactType->id = $params['id'] ?? NULL; $contactType->is_active = CRM_Utils_Array::value('is_active', $params, 0); $contactType->save(); diff --git a/CRM/Contact/BAO/Group.php b/CRM/Contact/BAO/Group.php index 0dd64ed62eeb..ec214b814201 100644 --- a/CRM/Contact/BAO/Group.php +++ b/CRM/Contact/BAO/Group.php @@ -364,7 +364,7 @@ public static function create(&$params) { } } // form the name only if missing: CRM-627 - $nameParam = CRM_Utils_Array::value('name', $params, NULL); + $nameParam = $params['name'] ?? NULL; if (!$nameParam && empty($params['id'])) { $params['name'] = CRM_Utils_String::titleToVar($params['title']); } @@ -645,7 +645,7 @@ public function __toString() { * ( smartGroupId, ssId ) smart group id and saved search id */ public static function createHiddenSmartGroup($params) { - $ssId = CRM_Utils_Array::value('saved_search_id', $params); + $ssId = $params['saved_search_id'] ?? NULL; //add mapping record only for search builder saved search $mappingId = NULL; @@ -677,7 +677,7 @@ public static function createHiddenSmartGroup($params) { $formValues = $params['search_context'] === 'builder' ? $params['form_values'] : CRM_Contact_BAO_Query::convertFormValues($params['form_values']); $savedSearch->form_values = serialize($formValues); $savedSearch->mapping_id = $mappingId; - $savedSearch->search_custom_id = CRM_Utils_Array::value('search_custom_id', $params); + $savedSearch->search_custom_id = $params['search_custom_id'] ?? NULL; $savedSearch->save(); $ssId = $savedSearch->id; @@ -735,7 +735,7 @@ public static function getGroupListSelector(&$params) { // format the params $params['offset'] = ($params['page'] - 1) * $params['rp']; $params['rowCount'] = $params['rp']; - $params['sort'] = CRM_Utils_Array::value('sortBy', $params); + $params['sort'] = $params['sortBy'] ?? NULL; // get groups $groups = CRM_Contact_BAO_Group::getGroupList($params); @@ -781,7 +781,7 @@ public static function getGroupListSelector(&$params) { $group['DT_RowAttr']['data-id'] = $value['id']; $group['DT_RowAttr']['data-entity'] = 'group'; - $group['description'] = CRM_Utils_Array::value('description', $value); + $group['description'] = $value['description'] ?? NULL; if (!empty($value['group_type'])) { $group['group_type'] = $value['group_type']; @@ -792,8 +792,8 @@ public static function getGroupListSelector(&$params) { $group['visibility'] = $value['visibility']; $group['links'] = $value['action']; - $group['org_info'] = CRM_Utils_Array::value('org_info', $value); - $group['created_by'] = CRM_Utils_Array::value('created_by', $value); + $group['org_info'] = $value['org_info'] ?? NULL; + $group['created_by'] = $value['created_by'] ?? NULL; $group['is_parent'] = $value['is_parent']; @@ -942,7 +942,7 @@ public static function getGroupList(&$params) { ); $types = []; foreach ($groupTypes as $type) { - $types[] = CRM_Utils_Array::value($type, $allTypes); + $types[] = $allTypes[$type] ?? NULL; } $values[$object->id]['group_type'] = implode(', ', $types); } @@ -1167,7 +1167,7 @@ public static function getGroupCount(&$params) { */ public static function whereClause(&$params, $sortBy = TRUE, $excludeHidden = TRUE) { $values = []; - $title = CRM_Utils_Array::value('title', $params); + $title = $params['title'] ?? NULL; if ($title) { $clauses[] = "`groups`.title LIKE %1"; if (strpos($title, '%') !== FALSE) { @@ -1178,7 +1178,7 @@ public static function whereClause(&$params, $sortBy = TRUE, $excludeHidden = TR } } - $groupType = CRM_Utils_Array::value('group_type', $params); + $groupType = $params['group_type'] ?? NULL; if ($groupType) { $types = explode(',', $groupType); if (!empty($types)) { @@ -1188,13 +1188,13 @@ public static function whereClause(&$params, $sortBy = TRUE, $excludeHidden = TR } } - $visibility = CRM_Utils_Array::value('visibility', $params); + $visibility = $params['visibility'] ?? NULL; if ($visibility) { $clauses[] = '`groups`.visibility = %3'; $params[3] = [$visibility, 'String']; } - $groupStatus = CRM_Utils_Array::value('status', $params); + $groupStatus = $params['status'] ?? NULL; if ($groupStatus) { switch ($groupStatus) { case 1: @@ -1213,13 +1213,13 @@ public static function whereClause(&$params, $sortBy = TRUE, $excludeHidden = TR } } - $parentsOnly = CRM_Utils_Array::value('parentsOnly', $params); + $parentsOnly = $params['parentsOnly'] ?? NULL; if ($parentsOnly) { $clauses[] = '`groups`.parents IS NULL'; } // only show child groups of a specific parent group - $parent_id = CRM_Utils_Array::value('parent_id', $params); + $parent_id = $params['parent_id'] ?? NULL; if ($parent_id) { $clauses[] = '`groups`.id IN (SELECT child_group_id FROM civicrm_group_nesting WHERE parent_group_id = %5)'; $params[5] = [$parent_id, 'Integer']; diff --git a/CRM/Contact/BAO/Individual.php b/CRM/Contact/BAO/Individual.php index f19325b3b26f..679e9229f50f 100644 --- a/CRM/Contact/BAO/Individual.php +++ b/CRM/Contact/BAO/Individual.php @@ -225,7 +225,7 @@ public static function format(&$params, &$contact) { } } } - $uniqId = CRM_Utils_Array::value('user_unique_id', $params); + $uniqId = $params['user_unique_id'] ?? NULL; if (!$email && $contact->id) { $email = CRM_Contact_BAO_Contact::getPrimaryEmail($contact->id); } diff --git a/CRM/Contact/BAO/Query.php b/CRM/Contact/BAO/Query.php index 9be1b0f2075d..fce0081f3930 100644 --- a/CRM/Contact/BAO/Query.php +++ b/CRM/Contact/BAO/Query.php @@ -1118,7 +1118,7 @@ public function addHierarchicalElements() { $elementType = '-' . $elementType; } - $field = CRM_Utils_Array::value($elementName, $this->_fields); + $field = $this->_fields[$elementName] ?? NULL; // hack for profile, add location id if (!$field) { @@ -1127,28 +1127,28 @@ public function addHierarchicalElements() { !is_numeric($elementType) ) { if (is_numeric($name)) { - $field = CRM_Utils_Array::value($elementName . "-Primary$elementType", $this->_fields); + $field = $this->_fields[$elementName . "-Primary$elementType"] ?? NULL; } else { - $field = CRM_Utils_Array::value($elementName . "-$locationTypeId$elementType", $this->_fields); + $field = $this->_fields[$elementName . "-$locationTypeId$elementType"] ?? NULL; } } elseif (is_numeric($name)) { //this for phone type to work if (in_array($elementName, ['phone', 'phone_ext'])) { - $field = CRM_Utils_Array::value($elementName . "-Primary" . $elementType, $this->_fields); + $field = $this->_fields[$elementName . "-Primary" . $elementType] ?? NULL; } else { - $field = CRM_Utils_Array::value($elementName . "-Primary", $this->_fields); + $field = $this->_fields[$elementName . "-Primary"] ?? NULL; } } else { //this is for phone type to work for profile edit if (in_array($elementName, ['phone', 'phone_ext'])) { - $field = CRM_Utils_Array::value($elementName . "-$locationTypeId$elementType", $this->_fields); + $field = $this->_fields[$elementName . "-$locationTypeId$elementType"] ?? NULL; } else { - $field = CRM_Utils_Array::value($elementName . "-$locationTypeId", $this->_fields); + $field = $this->_fields[$elementName . "-$locationTypeId"] ?? NULL; } } } @@ -2040,7 +2040,7 @@ public function whereClause($isForcePrimaryEmailOnly = NULL) { // check for both id and contact_id if ($this->_params[$id][0] == 'id' || $this->_params[$id][0] == 'contact_id') { $this->_where[0][] = self::buildClause("contact_a.id", $this->_params[$id][1], $this->_params[$id][2]); - $field = CRM_Utils_Array::value('id', $this->_fields); + $field = $this->_fields['id'] ?? NULL; list($qillop, $qillVal) = CRM_Contact_BAO_Query::buildQillForFieldValue( 'CRM_Contact_BAO_Contact', "contact_a.id", @@ -2108,11 +2108,11 @@ public function whereClause($isForcePrimaryEmailOnly = NULL) { * @throws Exception */ public function restWhere(&$values) { - $name = CRM_Utils_Array::value(0, $values); - $op = CRM_Utils_Array::value(1, $values); - $value = CRM_Utils_Array::value(2, $values); - $grouping = CRM_Utils_Array::value(3, $values); - $wildcard = CRM_Utils_Array::value(4, $values); + $name = $values[0] ?? NULL; + $op = $values[1] ?? NULL; + $value = $values[2] ?? NULL; + $grouping = $values[3] ?? NULL; + $wildcard = $values[4] ?? NULL; if (isset($grouping) && empty($this->_where[$grouping])) { $this->_where[$grouping] = []; @@ -2131,10 +2131,10 @@ public function restWhere(&$values) { } } - $field = CRM_Utils_Array::value($name, $this->_fields); + $field = $this->_fields[$name] ?? NULL; if (!$field) { - $field = CRM_Utils_Array::value($locType[0], $this->_fields); + $field = $this->_fields[$locType[0]] ?? NULL; if (!$field) { // Strip any trailing _high & _low that might be appended. @@ -2893,7 +2893,7 @@ public function contactType(&$values) { else { $contactTypeANDSubType = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value, 2); $contactType = $contactTypeANDSubType[0]; - $subType = CRM_Utils_Array::value(1, $contactTypeANDSubType); + $subType = $contactTypeANDSubType[1] ?? NULL; if (!empty($subType)) { $subTypes[$subType] = 1; } @@ -3902,7 +3902,7 @@ public function county(&$values, $status = NULL) { $county = CRM_Core_PseudoConstant::county(); foreach ($value as $id) { - $names[] = CRM_Utils_Array::value($id, $county); + $names[] = $county[$id] ?? NULL; } } else { @@ -4058,7 +4058,7 @@ public function privacy(&$values) { else { $this->_where[$grouping][] = "contact_a.{$name} $op $value"; } - $field = CRM_Utils_Array::value($name, $this->_fields); + $field = $this->_fields[$name] ?? NULL; $op = CRM_Utils_Array::value($op, CRM_Core_SelectValues::getSearchBuilderOperators(), $op); $title = $field ? $field['title'] : $name; $this->_qill[$grouping][] = "$title $op $value"; @@ -4096,7 +4096,7 @@ public function privacyOptions($values) { $qill = []; foreach ($value as $dontCare => $pOption) { $clauses[] = " ( contact_a.{$pOption} = 1 ) "; - $field = CRM_Utils_Array::value($pOption, $this->_fields); + $field = $this->_fields[$pOption] ?? NULL; $title = $field ? $field['title'] : $pOption; $qill[] = " $title = 1 "; } @@ -4255,7 +4255,7 @@ public function relationship(&$values) { if (!empty($relQill)) { $relQill .= ' OR '; } - $relQill .= CRM_Utils_Array::value($rel, $allRelationshipType); + $relQill .= $allRelationshipType[$rel] ?? NULL; } $this->_qill[$grouping][] = 'Relationship Type(s) ' . $relQill . " ( " . implode(", ", $qillNames) . " )"; } @@ -4732,8 +4732,8 @@ protected static function convertCustomRelativeFields(&$formValues, &$params, $v return; } - $from = CRM_Utils_Array::value($customFieldName . '_from', $formValues, NULL); - $to = CRM_Utils_Array::value($customFieldName . '_to', $formValues, NULL); + $from = $formValues[$customFieldName . '_from'] ?? NULL; + $to = $formValues[$customFieldName . '_to'] ?? NULL; if (self::isCustomDateField($customFieldName)) { list($from, $to) = CRM_Utils_Date::getFromTo(NULL, $from, $to); @@ -6024,7 +6024,7 @@ public function convertToPseudoNames(&$dao, $return = FALSE, $usedForAPI = FALSE } $dao->$key = ($usedForAPI) ? $convertedValues : implode(', ', $convertedValues); - $realFieldName = CRM_Utils_Array::value('field_name', $this->_pseudoConstantsSelect[$key]); + $realFieldName = $this->_pseudoConstantsSelect[$key]['field_name'] ?? NULL; if ($usedForAPI && $realFieldName) { // normally we would see 2 fields returned for pseudoConstants. An exception is // preferred_communication_method where there is no id-variant. @@ -6316,7 +6316,7 @@ public static function processSpecialFormValue(&$formValues, $specialFields, $ch $nullableFields = ['contribution_batch_id']; foreach ($specialFields as $element) { - $value = CRM_Utils_Array::value($element, $formValues); + $value = $formValues[$element] ?? NULL; if ($value) { if (is_array($value)) { if (in_array($element, array_keys($changeNames))) { @@ -6809,9 +6809,9 @@ public function getSearchSQLParts($offset = 0, $rowCount = 0, $sort = NULL, // if we’re explicitly looking for a certain contact’s contribs, events, etc. // and that contact happens to be deleted, set $onlyDeleted to true foreach ($this->_params as $values) { - $name = CRM_Utils_Array::value(0, $values); - $op = CRM_Utils_Array::value(1, $values); - $value = CRM_Utils_Array::value(2, $values); + $name = $values[0] ?? NULL; + $op = $values[1] ?? NULL; + $value = $values[2] ?? NULL; if ($name == 'contact_id' and $op == '=') { if (CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $value, 'is_deleted')) { $onlyDeleted = TRUE; @@ -6953,7 +6953,7 @@ public function getMetadataForRealField($fieldName) { protected function addPseudoconstantFieldToSelect($name) { $field = $this->getMetadataForRealField($name); $realFieldName = $field['name']; - $pseudoFieldName = CRM_Utils_Array::value('pseudofield_name', $field); + $pseudoFieldName = $field['pseudofield_name'] ?? NULL; if ($pseudoFieldName) { // @todo - we don't really need to build this array now we have metadata more available with getMetadataForField fn. $this->_pseudoConstantsSelect[$pseudoFieldName] = [ @@ -7054,7 +7054,7 @@ protected function isADateRangeField($fieldName) { * @param $values */ protected function buildRelativeDateQuery(&$values) { - $value = CRM_Utils_Array::value(2, $values); + $value = $values[2] ?? NULL; if (empty($value)) { return; } @@ -7062,7 +7062,7 @@ protected function buildRelativeDateQuery(&$values) { $fieldSpec = $this->_fields[$fieldName]; $tableName = $fieldSpec['table_name']; $filters = CRM_Core_OptionGroup::values('relative_date_filters'); - $grouping = CRM_Utils_Array::value(3, $values); + $grouping = $values[3] ?? NULL; // If the table value is already set for a custom field it will be more nuanced than just '1'. $this->_tables[$tableName] = $this->_tables[$tableName] ?? 1; $this->_whereTables[$tableName] = $this->_whereTables[$tableName] ?? 1; diff --git a/CRM/Contact/BAO/Relationship.php b/CRM/Contact/BAO/Relationship.php index a88193f071fb..18dd1a5472f8 100644 --- a/CRM/Contact/BAO/Relationship.php +++ b/CRM/Contact/BAO/Relationship.php @@ -288,7 +288,7 @@ public static function add($params, $ids = [], $contactId = NULL) { } CRM_Utils_Hook::pre($hook, 'Relationship', $params['id'], $params); - $relationshipTypes = CRM_Utils_Array::value('relationship_type_id', $params); + $relationshipTypes = $params['relationship_type_id'] ?? NULL; // explode the string with _ to get the relationship type id // and to know which contact has to be inserted in // contact_id_a and which one in contact_id_b @@ -475,14 +475,14 @@ public static function setContactABFromIDs($params, $ids = [], $contactID = NULL throw new CRM_Core_Exception('Cannot create relationship, insufficient contact IDs provided'); } if (isset($params['relationship_type_id']) && !is_numeric($params['relationship_type_id'])) { - $relationshipTypes = CRM_Utils_Array::value('relationship_type_id', $params); + $relationshipTypes = $params['relationship_type_id'] ?? NULL; list($relationshipTypeID, $first) = explode('_', $relationshipTypes); $returnFields['relationship_type_id'] = $relationshipTypeID; foreach (['a', 'b'] as $contactLetter) { if (empty($params['contact_' . $contactLetter])) { if ($first == $contactLetter) { - $returnFields['contact_id_' . $contactLetter] = CRM_Utils_Array::value('contact', $ids); + $returnFields['contact_id_' . $contactLetter] = $ids['contact'] ?? NULL; } else { $returnFields['contact_id_' . $contactLetter] = $contactID; @@ -931,7 +931,7 @@ public static function checkValidRelationship($params, $ids, $contactId) { * true if record exists else false */ public static function checkDuplicateRelationship(&$params, $id, $contactId = 0, $relationshipId = 0) { - $relationshipTypeId = CRM_Utils_Array::value('relationship_type_id', $params); + $relationshipTypeId = $params['relationship_type_id'] ?? NULL; list($type) = explode('_', $relationshipTypeId); $queryString = " @@ -1728,7 +1728,7 @@ public static function relatedMemberships($contactId, &$params, $ids, $action = $relIds = [$params['id']]; } else { - $relIds = CRM_Utils_Array::value('relationship_ids', $params); + $relIds = $params['relationship_ids'] ?? NULL; } if (self::isRelatedMembershipExpired($relTypeIds, $contactId, $mainRelatedContactId, $relTypeId, $relIds) && !empty($membershipValues['owner_membership_id'] @@ -2009,7 +2009,7 @@ public static function membershipTypeToRelationshipTypes(&$params, $direction = public static function getContactRelationshipSelector(&$params) { // format the params $params['offset'] = ($params['page'] - 1) * $params['rp']; - $params['sort'] = CRM_Utils_Array::value('sortBy', $params); + $params['sort'] = $params['sortBy'] ?? NULL; if ($params['context'] == 'past') { $relationshipStatus = CRM_Contact_BAO_Relationship::INACTIVE; @@ -2226,11 +2226,11 @@ public static function buildOptions($fieldName, $context = NULL, $props = []) { * @return array */ public static function buildRelationshipTypeOptions($params = []) { - $contactId = CRM_Utils_Array::value('contact_id', $params); + $contactId = $params['contact_id'] ?? NULL; $direction = CRM_Utils_Array::value('relationship_direction', $params, 'a_b'); - $relationshipId = CRM_Utils_Array::value('relationship_id', $params); - $contactType = CRM_Utils_Array::value('contact_type', $params); - $isForm = CRM_Utils_Array::value('is_form', $params); + $relationshipId = $params['relationship_id'] ?? NULL; + $contactType = $params['contact_type'] ?? NULL; + $isForm = $params['is_form'] ?? NULL; $showAll = FALSE; // getContactRelationshipType will return an empty set if these are not set diff --git a/CRM/Contact/BAO/SavedSearch.php b/CRM/Contact/BAO/SavedSearch.php index f5753039acd1..7e1ddd302e5c 100644 --- a/CRM/Contact/BAO/SavedSearch.php +++ b/CRM/Contact/BAO/SavedSearch.php @@ -94,11 +94,11 @@ public static function getFormValues($id) { $specialFields = ['contact_type', 'group', 'contact_tags', 'member_membership_type_id', 'member_status_id']; foreach ($result as $element => $value) { if (CRM_Contact_BAO_Query::isAlreadyProcessedForQueryFormat($value)) { - $id = CRM_Utils_Array::value(0, $value); - $value = CRM_Utils_Array::value(2, $value); + $id = $value[0] ?? NULL; + $value = $value[2] ?? NULL; if (is_array($value) && in_array(key($value), CRM_Core_DAO::acceptedSQLOperators(), TRUE)) { $op = key($value); - $value = CRM_Utils_Array::value($op, $value); + $value = $value[$op] ?? NULL; if (in_array($op, ['BETWEEN', '>=', '<='])) { self::decodeRelativeFields($result, $id, $op, $value); unset($result[$element]); @@ -150,7 +150,7 @@ public static function getFormValues($id) { // As per the OK (Operator as Key) value format, value array may contain key // as an operator so to ensure the default is always set actual value elseif (in_array(key($value), CRM_Core_DAO::acceptedSQLOperators(), TRUE)) { - $result[$element] = CRM_Utils_Array::value(key($value), $value); + $result[$element] = $value[key($value)] ?? NULL; if (is_string($result[$element])) { $result[$element] = str_replace("%", '', $result[$element]); } diff --git a/CRM/Contact/DAO/Factory.php b/CRM/Contact/DAO/Factory.php index 8af2fc1ac416..ef11dad723c0 100644 --- a/CRM/Contact/DAO/Factory.php +++ b/CRM/Contact/DAO/Factory.php @@ -30,7 +30,7 @@ class CRM_Contact_DAO_Factory { * @return mixed */ public static function create($className) { - $type = CRM_Utils_Array::value($className, self::$_classes); + $type = self::$_classes[$className] ?? NULL; if (!$type) { return CRM_Core_DAO_Factory::create($className); } diff --git a/CRM/Contact/Form/Contact.php b/CRM/Contact/Form/Contact.php index fff3ef2c8c70..4911e878bb84 100644 --- a/CRM/Contact/Form/Contact.php +++ b/CRM/Contact/Form/Contact.php @@ -200,8 +200,8 @@ public function preProcess() { CRM_Core_Error::statusBounce(ts('A Contact with that ID does not exist: %1', [1 => $this->_contactId])); } - $this->_contactType = CRM_Utils_Array::value('contact_type', $defaults); - $this->_contactSubType = CRM_Utils_Array::value('contact_sub_type', $defaults); + $this->_contactType = $defaults['contact_type'] ?? NULL; + $this->_contactSubType = $defaults['contact_sub_type'] ?? NULL; // check for permissions $session = CRM_Core_Session::singleton(); @@ -321,7 +321,7 @@ public function preProcess() { // retain the multiple count custom fields value if (!empty($_POST['hidden_custom'])) { - $customGroupCount = CRM_Utils_Array::value('hidden_custom_group_count', $_POST); + $customGroupCount = $_POST['hidden_custom_group_count'] ?? NULL; if ($contactSubType = CRM_Utils_Array::value('contact_sub_type', $_POST)) { $paramSubType = implode(',', $contactSubType); @@ -614,7 +614,7 @@ public static function formRule($fields, &$errors, $contactId, $contactType) { $dataExists = self::blockDataExists($blockValues); if (!$dataExists && $name == 'address') { - $dataExists = CRM_Utils_Array::value('use_shared_address', $fields['address'][$instance]); + $dataExists = $fields['address'][$instance]['use_shared_address'] ?? NULL; } if ($dataExists) { @@ -652,7 +652,7 @@ public static function formRule($fields, &$errors, $contactId, $contactType) { if ($name == 'openid' && !empty($blockValues[$name])) { $oid = new CRM_Core_DAO_OpenID(); - $oid->openid = $openIds[$instance] = CRM_Utils_Array::value($name, $blockValues); + $oid->openid = $openIds[$instance] = $blockValues[$name] ?? NULL; $cid = isset($contactId) ? $contactId : 0; if ($oid->find(TRUE) && ($oid->contact_id != $cid)) { $errors["{$name}[$instance][openid]"] = ts('%1 already exist.', [1 => $blocks['OpenID']]); @@ -869,7 +869,7 @@ public function postProcess() { $params['preferred_communication_method'] = 'null'; } - $group = CRM_Utils_Array::value('group', $params); + $group = $params['group'] ?? NULL; if (!empty($group) && is_array($group)) { unset($params['group']); foreach ($group as $key => $value) { @@ -1175,15 +1175,15 @@ public static function checkDuplicateContacts(&$fields, &$errors, $contactID, $c for ($i = 0; $i < count($contactLinks['rows']); $i++) { $row .= ' '; $row .= ' '; - $row .= CRM_Utils_Array::value('display_name', $contactLinks['rows'][$i]); + $row .= $contactLinks['rows'][$i]['display_name'] ?? NULL; $row .= ' '; $row .= ' '; - $row .= CRM_Utils_Array::value('primary_email', $contactLinks['rows'][$i]); + $row .= $contactLinks['rows'][$i]['primary_email'] ?? NULL; $row .= ' '; $row .= ' '; - $row .= CRM_Utils_Array::value('view', $contactLinks['rows'][$i]); - $row .= CRM_Utils_Array::value('edit', $contactLinks['rows'][$i]); - $row .= CRM_Utils_Array::value('merge', $contactLinks['rows'][$i]); + $row .= $contactLinks['rows'][$i]['view'] ?? NULL; + $row .= $contactLinks['rows'][$i]['edit'] ?? NULL; + $row .= $contactLinks['rows'][$i]['merge'] ?? NULL; $row .= ' '; $row .= ' '; } @@ -1256,7 +1256,7 @@ public function parseAddress(&$params) { } // main parse string. - $parseString = CRM_Utils_Array::value($parseFieldName, $address); + $parseString = $address[$parseFieldName] ?? NULL; // parse address field. $parsedFields = CRM_Core_BAO_Address::parseStreetAddress($parseString); @@ -1288,13 +1288,13 @@ public function parseAddress(&$params) { $streetAddress .= ' '; } // CRM-17619 - if the street number suffix begins with a number, add a space - $thesuffix = CRM_Utils_Array::value('street_number_suffix', $address); + $thesuffix = $address['street_number_suffix'] ?? NULL; if ($fld === 'street_number_suffix' && $thesuffix) { if (ctype_digit(substr($thesuffix, 0, 1))) { $streetAddress .= ' '; } } - $streetAddress .= CRM_Utils_Array::value($fld, $address); + $streetAddress .= $address[$fld] ?? NULL; } $address['street_address'] = trim($streetAddress); $parseSuccess[$instance] = TRUE; diff --git a/CRM/Contact/Form/CustomData.php b/CRM/Contact/Form/CustomData.php index da71a117d184..86dc621b4654 100644 --- a/CRM/Contact/Form/CustomData.php +++ b/CRM/Contact/Form/CustomData.php @@ -90,7 +90,7 @@ class CRM_Contact_Form_CustomData extends CRM_Core_Form { * Gets session variables for table name, id of entity in table, type of entity and stores them. */ public function preProcess() { - $this->_cdType = CRM_Utils_Array::value('type', $_GET); + $this->_cdType = $_GET['type'] ?? NULL; $this->assign('cdType', FALSE); $this->_multiRecordDisplay = CRM_Utils_Request::retrieve('multiRecordDisplay', 'String', $this); if ($this->_cdType || $this->_multiRecordDisplay == 'single') { diff --git a/CRM/Contact/Form/Edit/Address.php b/CRM/Contact/Form/Edit/Address.php index 9ea5b2af70d2..3d4d2dec42e0 100644 --- a/CRM/Contact/Form/Edit/Address.php +++ b/CRM/Contact/Form/Edit/Address.php @@ -287,13 +287,13 @@ public static function setDefaultValues(&$defaults, &$form) { $streetAddress .= ' '; } // CRM-17619 - if the street number suffix begins with a number, add a space - $numsuffix = CRM_Utils_Array::value($fld, $address); + $numsuffix = $address[$fld] ?? NULL; if ($fld === 'street_number_suffix' && !empty($numsuffix)) { if (ctype_digit(substr($numsuffix, 0, 1))) { $streetAddress .= ' '; } } - $streetAddress .= CRM_Utils_Array::value($fld, $address); + $streetAddress .= $address[$fld] ?? NULL; } $streetAddress = trim($streetAddress); if (!empty($streetAddress)) { @@ -301,7 +301,7 @@ public static function setDefaultValues(&$defaults, &$form) { } if (isset($address['street_number'])) { // CRM-17619 - if the street number suffix begins with a number, add a space - $thesuffix = CRM_Utils_Array::value('street_number_suffix', $address); + $thesuffix = $address['street_number_suffix'] ?? NULL; if ($thesuffix) { if (ctype_digit(substr($thesuffix, 0, 1))) { $address['street_number'] .= " "; @@ -311,7 +311,7 @@ public static function setDefaultValues(&$defaults, &$form) { } // build array for set default. foreach ($parseFields as $field) { - $addressValues["{$field}_{$cnt}"] = CRM_Utils_Array::value($field, $address); + $addressValues["{$field}_{$cnt}"] = $address[$field] ?? NULL; } // don't load fields, use js to populate. foreach (['street_number', 'street_name', 'street_unit'] as $f) { diff --git a/CRM/Contact/Form/Edit/CustomData.php b/CRM/Contact/Form/Edit/CustomData.php index 7260b7041266..0d65448ca2c8 100644 --- a/CRM/Contact/Form/Edit/CustomData.php +++ b/CRM/Contact/Form/Edit/CustomData.php @@ -71,7 +71,7 @@ public static function buildQuickForm(&$form) { $contactSubType = $_POST['contact_sub_type']; } else { - $contactSubType = CRM_Utils_Array::value('contact_sub_type', $form->_values); + $contactSubType = $form->_values['contact_sub_type'] ?? NULL; } $form->assign('contactType', $form->_contactType); $form->assign('contactSubType', $contactSubType); diff --git a/CRM/Contact/Form/Relationship.php b/CRM/Contact/Form/Relationship.php index 50c8c7c3ce0e..7cea222016ab 100644 --- a/CRM/Contact/Form/Relationship.php +++ b/CRM/Contact/Form/Relationship.php @@ -207,14 +207,14 @@ public function setDefaultValues() { if ($this->_action & CRM_Core_Action::UPDATE) { if (!empty($this->_values)) { $defaults['relationship_type_id'] = $this->_rtypeId; - $defaults['start_date'] = CRM_Utils_Array::value('start_date', $this->_values); - $defaults['end_date'] = CRM_Utils_Array::value('end_date', $this->_values); - $defaults['description'] = CRM_Utils_Array::value('description', $this->_values); - $defaults['is_active'] = CRM_Utils_Array::value('is_active', $this->_values); + $defaults['start_date'] = $this->_values['start_date'] ?? NULL; + $defaults['end_date'] = $this->_values['end_date'] ?? NULL; + $defaults['description'] = $this->_values['description'] ?? NULL; + $defaults['is_active'] = $this->_values['is_active'] ?? NULL; // The postprocess function will swap these fields if it is a b_a relationship, so we compensate here - $defaults['is_permission_a_b'] = CRM_Utils_Array::value('is_permission_' . $this->_rtype, $this->_values); - $defaults['is_permission_b_a'] = CRM_Utils_Array::value('is_permission_' . strrev($this->_rtype), $this->_values); + $defaults['is_permission_a_b'] = $this->_values['is_permission_' . $this->_rtype] ?? NULL; + $defaults['is_permission_b_a'] = $this->_values['is_permission_' . strrev($this->_rtype)] ?? NULL; $defaults['is_current_employer'] = $this->_isCurrentEmployer; @@ -239,7 +239,7 @@ public function setDefaultValues() { 'version' => 3, ]; $note = civicrm_api('Note', 'getsingle', $noteParams); - $defaults['note'] = CRM_Utils_Array::value('note', $note); + $defaults['note'] = $note['note'] ?? NULL; } } else { @@ -493,7 +493,7 @@ public static function getRelationshipTypeMetadata($relationshipList) { $jsData[$id] = array_filter(array_intersect_key($allRelationshipNames[$id], $whatWeWant)); // Add user-friendly placeholder foreach (['a', 'b'] as $x) { - $type = !empty($jsData[$id]["contact_sub_type_$x"]) ? $jsData[$id]["contact_sub_type_$x"] : CRM_Utils_Array::value("contact_type_$x", $jsData[$id]); + $type = !empty($jsData[$id]["contact_sub_type_$x"]) ? $jsData[$id]["contact_sub_type_$x"] : $jsData[$id]["contact_type_$x"] ?? NULL; $jsData[$id]["placeholder_$x"] = $type ? ts('- select %1 -', [strtolower($contactTypes[$type]['label'])]) : ts('- select contact -'); } } diff --git a/CRM/Contact/Form/Search.php b/CRM/Contact/Form/Search.php index 38b218ab171b..be3603d2b1c5 100644 --- a/CRM/Contact/Form/Search.php +++ b/CRM/Contact/Form/Search.php @@ -364,7 +364,7 @@ public function buildTaskList() { if ($this->_context !== 'amtg') { $taskParams['deletedContacts'] = FALSE; if ($this->_componentMode == CRM_Contact_BAO_Query::MODE_CONTACTS || $this->_componentMode == CRM_Contact_BAO_Query::MODE_CONTACTSRELATED) { - $taskParams['deletedContacts'] = CRM_Utils_Array::value('deleted_contacts', $this->_formValues); + $taskParams['deletedContacts'] = $this->_formValues['deleted_contacts'] ?? NULL; } $className = $this->_modeValue['taskClassName']; $taskParams['ssID'] = isset($this->_ssID) ? $this->_ssID : NULL; @@ -398,9 +398,9 @@ public function buildQuickForm() { if ($this->_context === 'smog') { // CRM-11788, we might want to do this for all of search where force=1 - $formQFKey = CRM_Utils_Array::value('qfKey', $this->_formValues); - $getQFKey = CRM_Utils_Array::value('qfKey', $_GET); - $postQFKey = CRM_Utils_Array::value('qfKey', $_POST); + $formQFKey = $this->_formValues['qfKey'] ?? NULL; + $getQFKey = $_GET['qfKey'] ?? NULL; + $postQFKey = $_POST['qfKey'] ?? NULL; if ($formQFKey && empty($getQFKey) && empty($postQFKey)) { $url = CRM_Utils_System::makeURL('qfKey') . $formQFKey; CRM_Utils_System::redirect($url); @@ -481,7 +481,7 @@ public function buildQuickForm() { } $selectedContactIds = []; - $qfKeyParam = CRM_Utils_Array::value('qfKey', $this->_formValues); + $qfKeyParam = $this->_formValues['qfKey'] ?? NULL; // We use ajax to handle selections only if the search results component_mode is set to "contacts" if ($qfKeyParam && ($this->get('component_mode') <= CRM_Contact_BAO_Query::MODE_CONTACTS || $this->get('component_mode') == CRM_Contact_BAO_Query::MODE_CONTACTSRELATED)) { $this->addClass('crm-ajax-selection-form'); diff --git a/CRM/Contact/Form/Search/Advanced.php b/CRM/Contact/Form/Search/Advanced.php index 6a4127b25aaf..4bc5d28dbfcd 100644 --- a/CRM/Contact/Form/Search/Advanced.php +++ b/CRM/Contact/Form/Search/Advanced.php @@ -38,7 +38,7 @@ public function preProcess() { public function buildQuickForm() { $this->set('context', 'advanced'); - $this->_searchPane = CRM_Utils_Array::value('searchPane', $_GET); + $this->_searchPane = $_GET['searchPane'] ?? NULL; $this->_searchOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'advanced_search_options' @@ -303,7 +303,7 @@ public function postProcess() { * multiple purposes (queries, save/edit etc) */ public function normalizeFormValues() { - $contactType = CRM_Utils_Array::value('contact_type', $this->_formValues); + $contactType = $this->_formValues['contact_type'] ?? NULL; if ($contactType && is_array($contactType)) { unset($this->_formValues['contact_type']); @@ -334,7 +334,7 @@ public function normalizeFormValues() { ]; CRM_Contact_BAO_Query::processSpecialFormValue($this->_formValues, $specialParams, $changeNames); - $taglist = CRM_Utils_Array::value('contact_taglist', $this->_formValues); + $taglist = $this->_formValues['contact_taglist'] ?? NULL; if ($taglist && is_array($taglist)) { unset($this->_formValues['contact_taglist']); diff --git a/CRM/Contact/Form/Search/Basic.php b/CRM/Contact/Form/Search/Basic.php index 9d236d501424..1b6ae423fa4d 100644 --- a/CRM/Contact/Form/Search/Basic.php +++ b/CRM/Contact/Form/Search/Basic.php @@ -83,7 +83,7 @@ public function buildQuickForm() { public function setDefaultValues() { $defaults = []; - $defaults['sort_name'] = CRM_Utils_Array::value('sort_name', $this->_formValues); + $defaults['sort_name'] = $this->_formValues['sort_name'] ?? NULL; foreach (self::$csv as $v) { if (!empty($this->_formValues[$v]) && is_array($this->_formValues[$v])) { $tmpArray = array_keys($this->_formValues[$v]); diff --git a/CRM/Contact/Form/Search/Builder.php b/CRM/Contact/Form/Search/Builder.php index 6f3bc7cac29f..fc51f6580d35 100644 --- a/CRM/Contact/Form/Search/Builder.php +++ b/CRM/Contact/Form/Search/Builder.php @@ -190,8 +190,8 @@ public static function formRule($values, $files, $self) { $fldName = substr($v[0], 13); } - $fldValue = CRM_Utils_Array::value($fldName, $fields); - $fldType = CRM_Utils_Array::value('type', $fldValue); + $fldValue = $fields[$fldName] ?? NULL; + $fldType = $fldValue['type'] ?? NULL; $type = CRM_Utils_Type::typeToString($fldType); if (strstr($v[1], 'IN')) { @@ -328,7 +328,7 @@ public function postProcess() { return; } // Add another field - $addMore = CRM_Utils_Array::value('addMore', $params); + $addMore = $params['addMore'] ?? NULL; for ($x = 1; $x <= $this->_blockCount; $x++) { if (!empty($addMore[$x])) { $this->set('newBlock', $x); diff --git a/CRM/Contact/Form/Search/Criteria.php b/CRM/Contact/Form/Search/Criteria.php index 89010bee1545..206451c8e345 100644 --- a/CRM/Contact/Form/Search/Criteria.php +++ b/CRM/Contact/Form/Search/Criteria.php @@ -449,7 +449,7 @@ public static function location(&$form) { } if ($addressOptions['postal_code']) { - $attr = ['class' => 'six'] + (array) CRM_Utils_Array::value('postal_code', $attributes); + $attr = ['class' => 'six'] + (array) $attributes['postal_code'] ?? NULL; $form->addElement('text', 'postal_code_low', NULL, $attr + ['placeholder' => ts('From')]); $form->addElement('text', 'postal_code_high', NULL, $attr + ['placeholder' => ts('To')]); } diff --git a/CRM/Contact/Form/Search/Custom/ContribSYBNT.php b/CRM/Contact/Form/Search/Custom/ContribSYBNT.php index f811a9222ccb..00a471369da2 100644 --- a/CRM/Contact/Form/Search/Custom/ContribSYBNT.php +++ b/CRM/Contact/Form/Search/Custom/ContribSYBNT.php @@ -58,7 +58,7 @@ public function __construct(&$formValues) { $this->_checkboxes = ['is_first_amount' => ts('First Donation?')]; foreach ($this->_amounts as $name => $title) { - $this->{$name} = CRM_Utils_Array::value($name, $this->_formValues); + $this->{$name} = $this->_formValues[$name] ?? NULL; } foreach ($this->_checkboxes as $name => $title) { @@ -329,12 +329,12 @@ public function where($includeContactIDs = FALSE) { */ public function having($includeContactIDs = FALSE) { $clauses = []; - $min = CRM_Utils_Array::value('min_amount', $this->_formValues); + $min = $this->_formValues['min_amount'] ?? NULL; if ($min) { $clauses[] = "sum(contrib_1.total_amount) >= $min"; } - $max = CRM_Utils_Array::value('max_amount', $this->_formValues); + $max = $this->_formValues['max_amount'] ?? NULL; if ($max) { $clauses[] = "sum(contrib_1.total_amount) <= $max"; } diff --git a/CRM/Contact/Form/Search/Custom/ContributionAggregate.php b/CRM/Contact/Form/Search/Custom/ContributionAggregate.php index 88ee10723924..89f0be3febae 100644 --- a/CRM/Contact/Form/Search/Custom/ContributionAggregate.php +++ b/CRM/Contact/Form/Search/Custom/ContributionAggregate.php @@ -269,13 +269,13 @@ public function where($includeContactIDs = FALSE) { */ public function having($includeContactIDs = FALSE) { $clauses = []; - $min = CRM_Utils_Array::value('min_amount', $this->_formValues); + $min = $this->_formValues['min_amount'] ?? NULL; if ($min) { $min = CRM_Utils_Rule::cleanMoney($min); $clauses[] = "sum(contrib.total_amount) >= $min"; } - $max = CRM_Utils_Array::value('max_amount', $this->_formValues); + $max = $this->_formValues['max_amount'] ?? NULL; if ($max) { $max = CRM_Utils_Rule::cleanMoney($max); $clauses[] = "sum(contrib.total_amount) <= $max"; diff --git a/CRM/Contact/Form/Search/Custom/FullText.php b/CRM/Contact/Form/Search/Custom/FullText.php index 091e5a1df094..c8ea5961aa32 100644 --- a/CRM/Contact/Form/Search/Custom/FullText.php +++ b/CRM/Contact/Form/Search/Custom/FullText.php @@ -126,7 +126,7 @@ public function __construct(&$formValues) { * @return mixed|null */ public function getFieldValue($formValues, $field, $type, $default = NULL) { - $value = CRM_Utils_Array::value($field, $formValues); + $value = $formValues[$field] ?? NULL; if (!$value) { return CRM_Utils_Request::retrieve($field, $type, CRM_Core_DAO::$_nullObject, FALSE, $default); } @@ -384,7 +384,7 @@ public function summary() { $row[$name] = $dao->$name; } else { - $row['activity_type'] = CRM_Utils_Array::value($dao->$name, $activityTypes); + $row['activity_type'] = $activityTypes[$dao->$name] ?? NULL; } } if (isset($row['participant_role'])) { @@ -411,7 +411,7 @@ public function summary() { $summary['Count'] = []; foreach (array_keys($summary) as $table) { - $summary['Count'][$table] = CRM_Utils_Array::value($table, $this->_foundRows); + $summary['Count'][$table] = $this->_foundRows[$table] ?? NULL; if ($summary['Count'][$table] >= self::LIMIT) { $summary['addShowAllLink'][$table] = TRUE; } diff --git a/CRM/Contact/Form/Search/Custom/Group.php b/CRM/Contact/Form/Search/Custom/Group.php index 4dcb40dceb2b..b6e4d59d6451 100644 --- a/CRM/Contact/Form/Search/Custom/Group.php +++ b/CRM/Contact/Form/Search/Custom/Group.php @@ -91,7 +91,7 @@ public function __construct(&$formValues) { $this->_allSearch = FALSE; $this->_groups = FALSE; $this->_tags = FALSE; - $this->_andOr = CRM_Utils_Array::value('andOr', $this->_formValues); + $this->_andOr = $this->_formValues['andOr'] ?? NULL; //make easy to check conditions for groups and tags are //selected or it is empty search if (empty($this->_includeGroups) && empty($this->_excludeGroups) && diff --git a/CRM/Contact/Form/Search/Custom/MultipleValues.php b/CRM/Contact/Form/Search/Custom/MultipleValues.php index 9e1ccb6952a1..bd000d85e756 100644 --- a/CRM/Contact/Form/Search/Custom/MultipleValues.php +++ b/CRM/Contact/Form/Search/Custom/MultipleValues.php @@ -33,9 +33,9 @@ public function __construct(&$formValues) { $this->_groupTree = CRM_Core_BAO_CustomGroup::getTree("'Contact', 'Individual', 'Organization', 'Household'", NULL, NULL, -1); - $this->_group = CRM_Utils_Array::value('group', $this->_formValues); + $this->_group = $this->_formValues['group'] ?? NULL; - $this->_tag = CRM_Utils_Array::value('tag', $this->_formValues); + $this->_tag = $this->_formValues['tag'] ?? NULL; $this->_columns = [ ts('Contact ID') => 'contact_id', @@ -43,7 +43,7 @@ public function __construct(&$formValues) { ts('Name') => 'sort_name', ]; - $this->_customGroupIDs = CRM_Utils_Array::value('custom_group', $formValues); + $this->_customGroupIDs = $formValues['custom_group'] ?? NULL; if (!empty($this->_customGroupIDs)) { $this->addColumns(); diff --git a/CRM/Contact/Form/Search/Custom/PriceSet.php b/CRM/Contact/Form/Search/Custom/PriceSet.php index a927dc5b0bc5..740d8a35e83a 100644 --- a/CRM/Contact/Form/Search/Custom/PriceSet.php +++ b/CRM/Contact/Form/Search/Custom/PriceSet.php @@ -229,7 +229,7 @@ public function setColumns() { foreach ($priceSet[$dao->price_set_id]['fields'] as $key => $value) { if (is_array($value['options'])) { foreach ($value['options'] as $oKey => $oValue) { - $columnHeader = CRM_Utils_Array::value('label', $value); + $columnHeader = $value['label'] ?? NULL; if (CRM_Utils_Array::value('html_type', $value) != 'Text') { $columnHeader .= ' - ' . $oValue['label']; } diff --git a/CRM/Contact/Form/Search/Custom/Proximity.php b/CRM/Contact/Form/Search/Custom/Proximity.php index 6a9b4e4ac6f0..34026c06de81 100644 --- a/CRM/Contact/Form/Search/Custom/Proximity.php +++ b/CRM/Contact/Form/Search/Custom/Proximity.php @@ -54,9 +54,9 @@ public function __construct(&$formValues) { } $this->_distance = $this->_formValues['distance'] * $conversionFactor; } - $this->_group = CRM_Utils_Array::value('group', $this->_formValues); + $this->_group = $this->_formValues['group'] ?? NULL; - $this->_tag = CRM_Utils_Array::value('tag', $this->_formValues); + $this->_tag = $this->_formValues['tag'] ?? NULL; $this->_columns = [ ts('Name') => 'sort_name', diff --git a/CRM/Contact/Form/Search/Custom/RandomSegment.php b/CRM/Contact/Form/Search/Custom/RandomSegment.php index 127d0c3eb52c..b09d151fce84 100644 --- a/CRM/Contact/Form/Search/Custom/RandomSegment.php +++ b/CRM/Contact/Form/Search/Custom/RandomSegment.php @@ -39,11 +39,11 @@ public function __construct(&$formValues) { } public function initialize() { - $this->_segmentSize = CRM_Utils_Array::value('segmentSize', $this->_formValues); + $this->_segmentSize = $this->_formValues['segmentSize'] ?? NULL; - $this->_includeGroups = CRM_Utils_Array::value('includeGroups', $this->_formValues); + $this->_includeGroups = $this->_formValues['includeGroups'] ?? NULL; - $this->_excludeGroups = CRM_Utils_Array::value('excludeGroups', $this->_formValues); + $this->_excludeGroups = $this->_formValues['excludeGroups'] ?? NULL; $this->_allSearch = FALSE; $this->_groups = FALSE; diff --git a/CRM/Contact/Form/Search/Custom/TagContributions.php b/CRM/Contact/Form/Search/Custom/TagContributions.php index cdee4a9d890e..7b1cd6a65d5f 100644 --- a/CRM/Contact/Form/Search/Custom/TagContributions.php +++ b/CRM/Contact/Form/Search/Custom/TagContributions.php @@ -173,7 +173,7 @@ public function where($includeContactIDs = FALSE) { $clauses[] = "civicrm_contribution.receive_date <= '{$this->_formValues['end_date']} 23:59:59'"; } - $tag = CRM_Utils_Array::value('tag', $this->_formValues); + $tag = $this->_formValues['tag'] ?? NULL; if ($tag) { $clauses[] = "civicrm_entity_tag.tag_id = $tag"; $clauses[] = "civicrm_tag.id = civicrm_entity_tag.tag_id"; diff --git a/CRM/Contact/Form/Task.php b/CRM/Contact/Form/Task.php index 718d5c4bbc3c..b478fb486799 100644 --- a/CRM/Contact/Form/Task.php +++ b/CRM/Contact/Form/Task.php @@ -133,7 +133,7 @@ public static function preProcessCommon(&$form) { $session = CRM_Core_Session::singleton(); $session->replaceUserContext($url); - $form->_task = CRM_Utils_Array::value('task', self::$_searchFormValues); + $form->_task = self::$_searchFormValues['task'] ?? NULL; $crmContactTaskTasks = CRM_Contact_Task::taskTitles(); $form->assign('taskName', CRM_Utils_Array::value($form->_task, $crmContactTaskTasks)); @@ -251,7 +251,7 @@ public static function preProcessCommon(&$form) { if (CRM_Utils_Array::value('radio_ts', self::$_searchFormValues) == 'ts_sel' && ($form->_action != CRM_Core_Action::COPY) ) { - $sel = CRM_Utils_Array::value('radio_ts', self::$_searchFormValues); + $sel = self::$_searchFormValues['radio_ts'] ?? NULL; $form->assign('searchtype', $sel); $result = self::getSelectedContactNames(); $form->assign("value", $result); diff --git a/CRM/Contact/Form/Task/AddToGroup.php b/CRM/Contact/Form/Task/AddToGroup.php index 091010ca3bb3..5385ed1fc736 100644 --- a/CRM/Contact/Form/Task/AddToGroup.php +++ b/CRM/Contact/Form/Task/AddToGroup.php @@ -175,7 +175,7 @@ public static function formRule($params) { */ public function postProcess() { $params = $this->controller->exportValues(); - $groupOption = CRM_Utils_Array::value('group_option', $params, NULL); + $groupOption = $params['group_option'] ?? NULL; if ($groupOption) { $groupParams = []; $groupParams['title'] = $params['title']; diff --git a/CRM/Contact/Form/Task/AlterPreferences.php b/CRM/Contact/Form/Task/AlterPreferences.php index d0be40d34345..fd3a239dd03e 100644 --- a/CRM/Contact/Form/Task/AlterPreferences.php +++ b/CRM/Contact/Form/Task/AlterPreferences.php @@ -79,7 +79,7 @@ public function postProcess() { //get the submitted values in an array $params = $this->controller->exportValues($this->_name); - $actionTypeOption = CRM_Utils_Array::value('actionTypeOption', $params, NULL); + $actionTypeOption = $params['actionTypeOption'] ?? NULL; // If remove option has been selected set new privacy value to "false" $privacyValueNew = empty($actionTypeOption); diff --git a/CRM/Contact/Form/Task/EmailCommon.php b/CRM/Contact/Form/Task/EmailCommon.php index d8e7af4c33a1..cbaeb8898836 100644 --- a/CRM/Contact/Form/Task/EmailCommon.php +++ b/CRM/Contact/Form/Task/EmailCommon.php @@ -304,7 +304,7 @@ public static function buildQuickForm(&$form) { foreach ($fields as $field => $values) { if (!empty($fields[$field])) { - $attribute = CRM_Utils_Array::value('attributes', $values); + $attribute = $values['attributes'] ?? NULL; $required = !empty($values['required']); if ($values['type'] == 'select' && empty($attribute)) { @@ -380,7 +380,7 @@ public static function postProcess(&$form) { public static function submit(&$form, $formValues) { self::saveMessageTemplate($formValues); - $from = CRM_Utils_Array::value('from_email_address', $formValues); + $from = $formValues['from_email_address'] ?? NULL; // dev/core#357 User Emails are keyed by their id so that the Signature is able to be added // If we have had a contact email used here the value returned from the line above will be the // numerical key where as $from for use in the sendEmail in Activity needs to be of format of "To Name" diff --git a/CRM/Contact/Form/Task/Label.php b/CRM/Contact/Form/Task/Label.php index ad9010a4b416..02e73d127dd1 100644 --- a/CRM/Contact/Form/Task/Label.php +++ b/CRM/Contact/Form/Task/Label.php @@ -83,7 +83,7 @@ public static function buildLabelForm($form) { public function setDefaultValues() { $defaults = []; $format = CRM_Core_BAO_LabelFormat::getDefaultValues(); - $defaults['label_name'] = CRM_Utils_Array::value('name', $format); + $defaults['label_name'] = $format['name'] ?? NULL; $defaults['do_not_mail'] = 1; return $defaults; @@ -227,7 +227,7 @@ public function postProcess($params = NULL) { $details[0][$value]["custom_{$cfID}"] = CRM_Core_BAO_CustomField::displayValue($details[0][$value]["custom_{$cfID}"], $cfID); } } - $contact = CRM_Utils_Array::value($value, $details['0']); + $contact = $details['0'][$value] ?? NULL; if (is_a($contact, 'CRM_Core_Error')) { return NULL; diff --git a/CRM/Contact/Form/Task/LabelCommon.php b/CRM/Contact/Form/Task/LabelCommon.php index b35673517666..ddc289154d04 100644 --- a/CRM/Contact/Form/Task/LabelCommon.php +++ b/CRM/Contact/Form/Task/LabelCommon.php @@ -149,7 +149,7 @@ public static function getRows($contactIDs, $locationTypeID, $respectDoNotMail, $details[$value]["custom_{$cfID}"] = CRM_Core_BAO_CustomField::displayValue($details[$value]["custom_{$cfID}"], $cfID); } } - $contact = CRM_Utils_Array::value($value, $details); + $contact = $details[$value] ?? NULL; if (is_a($contact, 'CRM_Core_Error')) { return NULL; diff --git a/CRM/Contact/Form/Task/PDF.php b/CRM/Contact/Form/Task/PDF.php index f69a1f84a6cf..59b14006da8c 100644 --- a/CRM/Contact/Form/Task/PDF.php +++ b/CRM/Contact/Form/Task/PDF.php @@ -76,7 +76,7 @@ public function setDefaultValues() { if (isset($this->_activityId)) { $params = ['id' => $this->_activityId]; CRM_Activity_BAO_Activity::retrieve($params, $defaults); - $defaults['html_message'] = CRM_Utils_Array::value('details', $defaults); + $defaults['html_message'] = $defaults['details'] ?? NULL; } $defaults = $defaults + CRM_Contact_Form_Task_PDFLetterCommon::setDefaultValues(); return $defaults; diff --git a/CRM/Contact/Form/Task/SMSCommon.php b/CRM/Contact/Form/Task/SMSCommon.php index c352a4751621..269f1f40183f 100644 --- a/CRM/Contact/Form/Task/SMSCommon.php +++ b/CRM/Contact/Form/Task/SMSCommon.php @@ -204,7 +204,7 @@ public static function buildQuickForm(&$form) { $mobilePhone = CRM_Utils_Array::retrieveValueRecursive($contactPhones, 'phone'); $form->_contactDetails[$contactId]['phone_id'] = CRM_Utils_Array::retrieveValueRecursive($contactPhones, 'id'); $form->_contactDetails[$contactId]['phone'] = $mobilePhone; - $form->_contactDetails[$contactId]['phone_type_id'] = CRM_Utils_Array::value('Mobile', $phoneTypes); + $form->_contactDetails[$contactId]['phone_type_id'] = $phoneTypes['Mobile'] ?? NULL; } else { $suppressedSms++; @@ -226,7 +226,7 @@ public static function buildQuickForm(&$form) { $phone = $value['phone']; } else { - $phone = CRM_Utils_Array::value($key, $form->_toContactPhone); + $phone = $form->_toContactPhone[$key] ?? NULL; } if ($phone) { @@ -302,7 +302,7 @@ public static function formRule($fields, $dontCare, $self) { } else { if (!empty($fields['sms_text_message'])) { - $messageCheck = CRM_Utils_Array::value('sms_text_message', $fields); + $messageCheck = $fields['sms_text_message'] ?? NULL; $messageCheck = str_replace("\r\n", "\n", $messageCheck); if ($messageCheck && (strlen($messageCheck) > CRM_SMS_Provider::MAX_SMS_CHAR)) { $errors['sms_text_message'] = ts("You can configure the SMS message body up to %1 characters", [1 => CRM_SMS_Provider::MAX_SMS_CHAR]); diff --git a/CRM/Contact/Form/Task/SaveSearch.php b/CRM/Contact/Form/Task/SaveSearch.php index f8114ce8d1d5..a98a29fee0ad 100644 --- a/CRM/Contact/Form/Task/SaveSearch.php +++ b/CRM/Contact/Form/Task/SaveSearch.php @@ -54,7 +54,7 @@ public function preProcess() { $modeValue = CRM_Contact_Form_Search::getModeValue(CRM_Utils_Array::value('component_mode', $values, CRM_Contact_BAO_Query::MODE_CONTACTS)); $className = $modeValue['taskClassName']; $taskList = $className::taskTitles(); - $this->_task = CRM_Utils_Array::value('task', $values); + $this->_task = $values['task'] ?? NULL; $this->assign('taskName', CRM_Utils_Array::value($this->_task, $taskList)); } diff --git a/CRM/Contact/Import/Form/MapField.php b/CRM/Contact/Import/Form/MapField.php index 7b1899569791..d347d6638428 100644 --- a/CRM/Contact/Import/Form/MapField.php +++ b/CRM/Contact/Import/Form/MapField.php @@ -429,7 +429,7 @@ public function buildQuickForm() { public static function formRule($fields) { $errors = []; if (!empty($fields['saveMapping'])) { - $nameField = CRM_Utils_Array::value('saveMappingName', $fields); + $nameField = $fields['saveMappingName'] ?? NULL; if (empty($nameField)) { $errors['saveMappingName'] = ts('Name is required to save Import Mapping'); } @@ -532,10 +532,10 @@ public function submit($params, $mapperKeys) { for ($i = 0; $i < $this->_columnCount; $i++) { - $fldName = CRM_Utils_Array::value(0, $mapperKeys[$i]); - $selOne = CRM_Utils_Array::value(1, $mapperKeys[$i]); - $selTwo = CRM_Utils_Array::value(2, $mapperKeys[$i]); - $selThree = CRM_Utils_Array::value(3, $mapperKeys[$i]); + $fldName = $mapperKeys[$i][0] ?? NULL; + $selOne = $mapperKeys[$i][1] ?? NULL; + $selTwo = $mapperKeys[$i][2] ?? NULL; + $selThree = $mapperKeys[$i][3] ?? NULL; $mapper[$i] = $this->_mapperFields[$mapperKeys[$i][0]]; $mapperKeysMain[$i] = $fldName; @@ -569,7 +569,7 @@ public function submit($params, $mapperKeys) { $parserParameters['relatedContactWebsiteType'][$i] = $websiteTypes[$selTwo]; } else { - $parserParameters['relatedContactLocType'][$i] = CRM_Utils_Array::value($selTwo, $locationTypes); + $parserParameters['relatedContactLocType'][$i] = $locationTypes[$selTwo] ?? NULL; if ($selThree) { if ($selOne === 'phone') { $parserParameters['relatedContactPhoneType'][$i] = $phoneTypes[$selThree]; @@ -623,7 +623,7 @@ public function submit($params, $mapperKeys) { for ($i = 0; $i < $this->_columnCount; $i++) { $updateMappingFields = new CRM_Core_DAO_MappingField(); - $updateMappingFields->id = CRM_Utils_Array::value($i, $mappingFieldsId); + $updateMappingFields->id = $mappingFieldsId[$i] ?? NULL; $updateMappingFields->mapping_id = $params['mappingId']; $updateMappingFields->column_number = $i; diff --git a/CRM/Contact/Import/ImportJob.php b/CRM/Contact/Import/ImportJob.php index e15f7e3f8696..e732f2335cd5 100644 --- a/CRM/Contact/Import/ImportJob.php +++ b/CRM/Contact/Import/ImportJob.php @@ -133,11 +133,11 @@ public function runImport(&$form, $timeout = 55) { foreach ($mapper as $key => $value) { - $fldName = CRM_Utils_Array::value(0, $mapper[$key]); + $fldName = $mapper[$key][0] ?? NULL; $header = array($this->_mapFields[$fldName]); - $selOne = CRM_Utils_Array::value(1, $mapper[$key]); - $selTwo = CRM_Utils_Array::value(2, $mapper[$key]); - $selThree = CRM_Utils_Array::value(3, $mapper[$key]); + $selOne = $mapper[$key][1] ?? NULL; + $selTwo = $mapper[$key][2] ?? NULL; + $selThree = $mapper[$key][3] ?? NULL; $this->_mapperKeys[$key] = $fldName; //need to differentiate non location elements. diff --git a/CRM/Contact/Import/Parser.php b/CRM/Contact/Import/Parser.php index d3791a59732a..146c1b5d37da 100644 --- a/CRM/Contact/Import/Parser.php +++ b/CRM/Contact/Import/Parser.php @@ -865,8 +865,8 @@ public function formatCommonData($params, &$formatted, &$contactFields) { !array_key_exists($customFieldID, $addressCustomFields) ) { - $extends = CRM_Utils_Array::value('extends', $customFields[$customFieldID]); - $htmlType = CRM_Utils_Array::value('html_type', $customFields[$customFieldID]); + $extends = $customFields[$customFieldID]['extends'] ?? NULL; + $htmlType = $customFields[$customFieldID]['html_type'] ?? NULL; switch ($htmlType) { case 'Select': case 'Radio': @@ -874,8 +874,8 @@ public function formatCommonData($params, &$formatted, &$contactFields) { if ($customFields[$customFieldID]['data_type'] == 'String' || $customFields[$customFieldID]['data_type'] == 'Int') { $customOption = CRM_Core_BAO_CustomOption::getCustomOption($customFieldID, TRUE); foreach ($customOption as $customValue) { - $val = CRM_Utils_Array::value('value', $customValue); - $label = CRM_Utils_Array::value('label', $customValue); + $val = $customValue['value'] ?? NULL; + $label = $customValue['label'] ?? NULL; $label = strtolower($label); $value = strtolower(trim($formatted[$key])); if (($value == $label) || ($value == strtolower($val))) { @@ -926,7 +926,7 @@ public function formatCommonData($params, &$formatted, &$contactFields) { if (empty($formatted['custom'][$customKey][-1]['is_required'])) { $formatted['custom'][$customKey][-1]['is_required'] = $customFields[$customKey]['is_required']; } - $emptyValue = CRM_Utils_Array::value('value', $customvalue[-1]); + $emptyValue = $customvalue[-1]['value'] ?? NULL; if (!isset($emptyValue)) { unset($formatted['custom'][$customKey]); } @@ -937,7 +937,7 @@ public function formatCommonData($params, &$formatted, &$contactFields) { if ($this->_parseStreetAddress) { if (array_key_exists('address', $formatted) && is_array($formatted['address'])) { foreach ($formatted['address'] as $instance => & $address) { - $streetAddress = CRM_Utils_Array::value('street_address', $address); + $streetAddress = $address['street_address'] ?? NULL; if (empty($streetAddress)) { continue; } @@ -1237,7 +1237,7 @@ protected function formatLocationBlock(&$values, &$params) { $customFieldID = CRM_Core_BAO_CustomField::getKeyID($key); if ($customFieldID && array_key_exists($customFieldID, $customFields)) { - $htmlType = CRM_Utils_Array::value('html_type', $customFields[$customFieldID]); + $htmlType = $customFields[$customFieldID]['html_type'] ?? NULL; switch ($htmlType) { case 'CheckBox': case 'Multi-Select': diff --git a/CRM/Contact/Import/Parser/Contact.php b/CRM/Contact/Import/Parser/Contact.php index 7b4356fba2c7..6cec3b8bb18c 100644 --- a/CRM/Contact/Import/Parser/Contact.php +++ b/CRM/Contact/Import/Parser/Contact.php @@ -301,7 +301,7 @@ public function summary(&$values) { } } - $email = CRM_Utils_Array::value($this->_emailIndex, $values); + $email = $values[$this->_emailIndex] ?? NULL; if ($email) { /* If the email address isn't valid, bail */ @@ -339,7 +339,7 @@ public function summary(&$values) { } //check for duplicate external Identifier - $externalID = CRM_Utils_Array::value($this->_externalIdentifierIndex, $values); + $externalID = $values[$this->_externalIdentifierIndex] ?? NULL; if ($externalID) { /* If it's a dupe,external Identifier */ @@ -1121,7 +1121,7 @@ public static function isErrorInCustomData($params, &$errorMessage, $csType = NU $dateType = CRM_Core_Session::singleton()->get("dateTypes"); if (!empty($params['contact_sub_type'])) { - $csType = CRM_Utils_Array::value('contact_sub_type', $params); + $csType = $params['contact_sub_type'] ?? NULL; } if (empty($params['contact_type'])) { @@ -1908,7 +1908,7 @@ public function checkRelatedContactFields($relKey, $params) { if (!empty($relatedContactFields[$name]) && !is_array($relatedContactFields[$name])) { $relatedContactFields[$name] = []; } - $fldName = CRM_Utils_Array::value($key, $this->_mapperRelatedContactDetails); + $fldName = $this->_mapperRelatedContactDetails[$key] ?? NULL; if ($fldName == 'url') { $fldName = 'website'; } diff --git a/CRM/Contact/Page/AJAX.php b/CRM/Contact/Page/AJAX.php index 334925e6af93..7403e22f286e 100644 --- a/CRM/Contact/Page/AJAX.php +++ b/CRM/Contact/Page/AJAX.php @@ -37,7 +37,7 @@ class CRM_Contact_Page_AJAX { * Todo: Migrate contact reference fields to use EntityRef */ public static function contactReference() { - $name = CRM_Utils_Array::value('term', $_GET); + $name = $_GET['term'] ?? NULL; $name = CRM_Utils_Type::escape($name, 'String'); $cfID = CRM_Utils_Type::escape($_GET['id'], 'Positive'); @@ -54,7 +54,7 @@ public static function contactReference() { $filterParams = []; parse_str($cf['filter'], $filterParams); - $action = CRM_Utils_Array::value('action', $filterParams); + $action = $filterParams['action'] ?? NULL; if (!empty($action) && !in_array($action, ['get', 'lookup'])) { CRM_Utils_System::civiExit(1); } @@ -146,7 +146,7 @@ public static function contactReference() { * Fetch PCP ID by PCP Supporter sort_name, also displays PCP title and associated Contribution Page title */ public static function getPCPList() { - $name = CRM_Utils_Array::value('term', $_GET); + $name = $_GET['term'] ?? NULL; $name = CRM_Utils_Type::escape($name, 'String'); $limit = $max = Civi::settings()->get('search_autocomplete_count'); @@ -347,7 +347,7 @@ public static function checkUserName() { */ public static function getContactEmail() { $queryStrings = []; - $name = CRM_Utils_Array::value('name', $_GET); + $name = $_GET['name'] ?? NULL; if ($name) { $name = CRM_Utils_Type::escape($name, 'String'); $wildCard = Civi::settings()->get('includeWildCardInName') ? '%' : ''; @@ -401,7 +401,7 @@ public static function getContactPhone() { $sqlParmas = []; //check for mobile type $phoneTypes = CRM_Core_OptionGroup::values('phone_type', TRUE, FALSE, FALSE, NULL, 'name'); - $mobileType = CRM_Utils_Array::value('Mobile', $phoneTypes); + $mobileType = $phoneTypes['Mobile'] ?? NULL; $name = CRM_Utils_Request::retrieveValue('name', 'String', NULL, FALSE, 'GET'); if ($name) { @@ -651,7 +651,7 @@ public static function getDedupes() { $dir = CRM_Utils_Type::escape($orderInfo['dir'], 'MysqlOrderByDirection', FALSE); } } - $columnDetails = CRM_Utils_Array::value($orderColumnNumber, $_REQUEST['columns']); + $columnDetails = $_REQUEST['columns'][$orderColumnNumber] ?? NULL; } if (!empty($columnDetails)) { switch ($columnDetails['data']) { @@ -699,8 +699,8 @@ public static function getDedupes() { $count = 0; foreach ($dupePairs as $key => $pairInfo) { $pair = $pairInfo['data']; - $srcContactSubType = CRM_Utils_Array::value('src_contact_sub_type', $pairInfo); - $dstContactSubType = CRM_Utils_Array::value('dst_contact_sub_type', $pairInfo); + $srcContactSubType = $pairInfo['src_contact_sub_type'] ?? NULL; + $dstContactSubType = $pairInfo['dst_contact_sub_type'] ?? NULL; $srcTypeImage = CRM_Contact_BAO_Contact_Utils::getImage($srcContactSubType ? $srcContactSubType : $pairInfo['src_contact_type'], FALSE, @@ -716,16 +716,16 @@ public static function getDedupes() { $searchRows[$count]['is_selected_input'] = ""; $searchRows[$count]['src_image'] = $srcTypeImage; $searchRows[$count]['src'] = CRM_Utils_System::href($pair['srcName'], 'civicrm/contact/view', "reset=1&cid={$pairInfo['entity_id2']}"); - $searchRows[$count]['src_email'] = CRM_Utils_Array::value('src_email', $pairInfo); - $searchRows[$count]['src_street'] = CRM_Utils_Array::value('src_street', $pairInfo); - $searchRows[$count]['src_postcode'] = CRM_Utils_Array::value('src_postcode', $pairInfo); + $searchRows[$count]['src_email'] = $pairInfo['src_email'] ?? NULL; + $searchRows[$count]['src_street'] = $pairInfo['src_street'] ?? NULL; + $searchRows[$count]['src_postcode'] = $pairInfo['src_postcode'] ?? NULL; $searchRows[$count]['dst_image'] = $dstTypeImage; $searchRows[$count]['dst'] = CRM_Utils_System::href($pair['dstName'], 'civicrm/contact/view', "reset=1&cid={$pairInfo['entity_id1']}"); - $searchRows[$count]['dst_email'] = CRM_Utils_Array::value('dst_email', $pairInfo); - $searchRows[$count]['dst_street'] = CRM_Utils_Array::value('dst_street', $pairInfo); - $searchRows[$count]['dst_postcode'] = CRM_Utils_Array::value('dst_postcode', $pairInfo); + $searchRows[$count]['dst_email'] = $pairInfo['dst_email'] ?? NULL; + $searchRows[$count]['dst_street'] = $pairInfo['dst_street'] ?? NULL; + $searchRows[$count]['dst_postcode'] = $pairInfo['dst_postcode'] ?? NULL; $searchRows[$count]['conflicts'] = str_replace("',", "',
", CRM_Utils_Array::value('conflicts', $pair)); - $searchRows[$count]['weight'] = CRM_Utils_Array::value('weight', $pair); + $searchRows[$count]['weight'] = $pair['weight'] ?? NULL; if (!empty($pairInfo['data']['canMerge'])) { $mergeParams = [ @@ -769,7 +769,7 @@ public static function getDedupes() { */ public static function getSearchOptionsFromRequest() { $searchParams = []; - $searchData = CRM_Utils_Array::value('search', $_REQUEST); + $searchData = $_REQUEST['search'] ?? NULL; $searchData['value'] = CRM_Utils_Type::escape($searchData['value'], 'String'); $selectorElements = [ 'is_selected', @@ -814,7 +814,7 @@ public static function getSearchOptionsFromRequest() { * @return bool */ public static function isOrQuery() { - $searchData = CRM_Utils_Array::value('search', $_REQUEST); + $searchData = $_REQUEST['search'] ?? NULL; return !empty($searchData['value']); } @@ -909,8 +909,8 @@ public static function flipDupePairs($prevNextId = NULL) { * Used to store selected contacts across multiple pages in advanced search. */ public static function selectUnselectContacts() { - $name = CRM_Utils_Array::value('name', $_REQUEST); - $cacheKey = CRM_Utils_Array::value('qfKey', $_REQUEST); + $name = $_REQUEST['name'] ?? NULL; + $cacheKey = $_REQUEST['qfKey'] ?? NULL; $state = CRM_Utils_Array::value('state', $_REQUEST, 'checked'); $variableType = CRM_Utils_Array::value('variableType', $_REQUEST, 'single'); diff --git a/CRM/Contact/Page/Inline/CustomData.php b/CRM/Contact/Page/Inline/CustomData.php index cc31ea1aa950..a2ffabdfd78d 100644 --- a/CRM/Contact/Page/Inline/CustomData.php +++ b/CRM/Contact/Page/Inline/CustomData.php @@ -44,7 +44,7 @@ public function run() { $fields = reset($details[$cgId]); } else { - $fields = CRM_Utils_Array::value($customRecId, $details[$cgId]); + $fields = $details[$cgId][$customRecId] ?? NULL; } $this->assign('cgcount', $cgcount); $this->assign('customRecId', $customRecId); diff --git a/CRM/Contact/Page/View.php b/CRM/Contact/Page/View.php index 8b0ddf934826..faeb0cb8cfcf 100644 --- a/CRM/Contact/Page/View.php +++ b/CRM/Contact/Page/View.php @@ -119,7 +119,7 @@ public function preProcess() { $found = TRUE; } - $context = CRM_Utils_Array::value('context', $_GET); + $context = $_GET['context'] ?? NULL; if (!$found) { // seems like we did not find any contacts // maybe due to bug CRM-9096 diff --git a/CRM/Contact/Page/View/Vcard.php b/CRM/Contact/Page/View/Vcard.php index ac13a802fe3a..a730ddb18f39 100644 --- a/CRM/Contact/Page/View/Vcard.php +++ b/CRM/Contact/Page/View/Vcard.php @@ -50,7 +50,7 @@ public function run() { CRM_Utils_Array::value('prefix', $defaults), CRM_Utils_Array::value('suffix', $defaults) ); - $organizationName = CRM_Utils_Array::value('organization_name', $defaults); + $organizationName = $defaults['organization_name'] ?? NULL; if ($organizationName !== NULL) { $vcard->addOrganization($organizationName); } @@ -87,15 +87,15 @@ public function run() { foreach ($defaults['address'] as $location) { // we don't keep PO boxes in separate fields $pob = ''; - $extend = CRM_Utils_Array::value('supplemental_address_1', $location); + $extend = $location['supplemental_address_1'] ?? NULL; if (!empty($location['supplemental_address_2'])) { $extend .= ', ' . $location['supplemental_address_2']; } if (!empty($location['supplemental_address_3'])) { $extend .= ', ' . $location['supplemental_address_3']; } - $street = CRM_Utils_Array::value('street_address', $location); - $locality = CRM_Utils_Array::value('city', $location); + $street = $location['street_address'] ?? NULL; + $locality = $location['city'] ?? NULL; $region = NULL; if (!empty($location['state_province_id'])) { $region = $stateProvices[CRM_Utils_Array::value('state_province_id', $location)]; @@ -105,7 +105,7 @@ public function run() { $country = $countries[CRM_Utils_Array::value('country_id', $location)]; } - $postcode = CRM_Utils_Array::value('postal_code', $location); + $postcode = $location['postal_code'] ?? NULL; if (!empty($location['postal_code_suffix'])) { $postcode .= '-' . $location['postal_code_suffix']; } diff --git a/CRM/Contact/Selector.php b/CRM/Contact/Selector.php index c0faf5b46331..88bedaa65419 100644 --- a/CRM/Contact/Selector.php +++ b/CRM/Contact/Selector.php @@ -179,7 +179,7 @@ public function __construct( $this->_searchContext = $searchContext; - $this->_ufGroupID = CRM_Utils_Array::value('uf_group_id', $this->_formValues); + $this->_ufGroupID = $this->_formValues['uf_group_id'] ?? NULL; if ($this->_ufGroupID) { $this->_fields = CRM_Core_BAO_UFGroup::getListingFields(CRM_Core_Action::VIEW, @@ -204,7 +204,7 @@ public function __construct( } } - $displayRelationshipType = CRM_Utils_Array::value('display_relationship_type', $this->_formValues); + $displayRelationshipType = $this->_formValues['display_relationship_type'] ?? NULL; $operator = CRM_Utils_Array::value('operator', $this->_formValues, 'AND'); // rectify params to what proximity search expects if there is a value for prox_distance @@ -612,7 +612,7 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { $locationTypeName = "website-{$id}"; } else { - $locationTypeName = CRM_Utils_Array::value($id, $locationTypes); + $locationTypeName = $locationTypes[$id] ?? NULL; if (!$locationTypeName) { continue; } @@ -653,7 +653,7 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { $links = self::links($this->_context, $this->_contextMenu, $this->_key); //check explicitly added contact to a Smart Group. - $groupID = CRM_Utils_Array::value('group', $this->_formValues); + $groupID = $this->_formValues['group'] ?? NULL; $pseudoconstants = []; // for CRM-3157 purposes diff --git a/CRM/Contact/StateMachine/Search.php b/CRM/Contact/StateMachine/Search.php index c2d7bea1f1a7..83c60dea7d97 100644 --- a/CRM/Contact/StateMachine/Search.php +++ b/CRM/Contact/StateMachine/Search.php @@ -81,7 +81,7 @@ public function __construct($controller, $action = CRM_Core_Action::NONE) { */ public function taskName($controller, $formName = 'Search') { // total hack, check POST vars and then session to determine stuff - $value = CRM_Utils_Array::value('task', $_POST); + $value = $_POST['task'] ?? NULL; if (!isset($value)) { $value = $this->_controller->get('task'); } diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index 6a39286c5130..7f7d535f2bb9 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -215,8 +215,8 @@ public static function add(&$params, $ids = []) { $result = $contribution->save(); // Add financial_trxn details as part of fix for CRM-4724 - $contribution->trxn_result_code = CRM_Utils_Array::value('trxn_result_code', $params); - $contribution->payment_processor = CRM_Utils_Array::value('payment_processor', $params); + $contribution->trxn_result_code = $params['trxn_result_code'] ?? NULL; + $contribution->payment_processor = $params['payment_processor'] ?? NULL; //add Account details $params['contribution'] = $contribution; @@ -417,13 +417,13 @@ protected static function getBillingAddressParams($params, $billingLocationTypeI $addressParams['location_type_id'] = $billingLocationTypeID; $addressParams['is_billing'] = 1; - $billingFirstName = CRM_Utils_Array::value('billing_first_name', $params); - $billingMiddleName = CRM_Utils_Array::value('billing_middle_name', $params); - $billingLastName = CRM_Utils_Array::value('billing_last_name', $params); + $billingFirstName = $params['billing_first_name'] ?? NULL; + $billingMiddleName = $params['billing_middle_name'] ?? NULL; + $billingLastName = $params['billing_last_name'] ?? NULL; $addressParams['address_name'] = "{$billingFirstName}" . CRM_Core_DAO::VALUE_SEPARATOR . "{$billingMiddleName}" . CRM_Core_DAO::VALUE_SEPARATOR . "{$billingLastName}"; foreach ($billingFields as $value) { - $addressParams[$value] = CRM_Utils_Array::value("billing_{$value}-{$billingLocationTypeID}", $params); + $addressParams[$value] = $params["billing_{$value}-{$billingLocationTypeID}"] ?? NULL; if (!empty($addressParams[$value])) { $hasBillingField = TRUE; } @@ -1587,10 +1587,10 @@ public static function failPayment($contributionID, $contactID, $message) { */ public static function checkDuplicate($input, &$duplicates, $id = NULL) { if (!$id) { - $id = CRM_Utils_Array::value('id', $input); + $id = $input['id'] ?? NULL; } - $trxn_id = CRM_Utils_Array::value('trxn_id', $input); - $invoice_id = CRM_Utils_Array::value('invoice_id', $input); + $trxn_id = $input['trxn_id'] ?? NULL; + $invoice_id = $input['invoice_id'] ?? NULL; $clause = []; $input = []; @@ -2088,14 +2088,14 @@ public static function checkOnlinePendingContribution($componentId, $componentNa */ public static function transitionComponents($params, $processContributionObject = FALSE) { // get minimum required values. - $contactId = CRM_Utils_Array::value('contact_id', $params); - $componentId = CRM_Utils_Array::value('component_id', $params); - $componentName = CRM_Utils_Array::value('componentName', $params); - $contributionId = CRM_Utils_Array::value('contribution_id', $params); - $contributionStatusId = CRM_Utils_Array::value('contribution_status_id', $params); + $contactId = $params['contact_id'] ?? NULL; + $componentId = $params['component_id'] ?? NULL; + $componentName = $params['componentName'] ?? NULL; + $contributionId = $params['contribution_id'] ?? NULL; + $contributionStatusId = $params['contribution_status_id'] ?? NULL; // if we already processed contribution object pass previous status id. - $previousContriStatusId = CRM_Utils_Array::value('previous_contribution_status_id', $params); + $previousContriStatusId = $params['previous_contribution_status_id'] ?? NULL; $updateResult = []; @@ -2146,13 +2146,13 @@ public static function transitionComponents($params, $processContributionObject $input = $ids = $objects = []; - $input['component'] = CRM_Utils_Array::value('component', $componentDetails); + $input['component'] = $componentDetails['component'] ?? NULL; $ids['contribution'] = $contributionId; - $ids['contact'] = CRM_Utils_Array::value('contact_id', $componentDetails); - $ids['membership'] = CRM_Utils_Array::value('membership', $componentDetails); - $ids['participant'] = CRM_Utils_Array::value('participant', $componentDetails); - $ids['event'] = CRM_Utils_Array::value('event', $componentDetails); - $ids['pledge_payment'] = CRM_Utils_Array::value('pledge_payment', $componentDetails); + $ids['contact'] = $componentDetails['contact_id'] ?? NULL; + $ids['membership'] = $componentDetails['membership'] ?? NULL; + $ids['participant'] = $componentDetails['participant'] ?? NULL; + $ids['event'] = $componentDetails['event'] ?? NULL; + $ids['pledge_payment'] = $componentDetails['pledge_payment'] ?? NULL; $ids['contributionRecur'] = NULL; $ids['contributionPage'] = NULL; @@ -2290,7 +2290,7 @@ public static function transitionComponents($params, $processContributionObject $lineitems = CRM_Price_BAO_LineItem::getLineItemsByContributionID($contributionId); foreach ($lineitems as $lineitem) { if ($membership->membership_type_id == CRM_Utils_Array::value('membership_type_id', $lineitem)) { - $numterms = CRM_Utils_Array::value('membership_num_terms', $lineitem); + $numterms = $lineitem['membership_num_terms'] ?? NULL; // in case membership_num_terms comes through as null or zero $numterms = $numterms >= 1 ? $numterms : 1; @@ -2948,7 +2948,7 @@ public function composeMessageArray(&$input, &$ids, &$values, $returnMessageText $this->loadRelatedObjects($input, $ids); if (empty($this->_component)) { - $this->_component = CRM_Utils_Array::value('component', $input); + $this->_component = $input['component'] ?? NULL; } //not really sure what params might be passed in but lets merge em into values @@ -3208,7 +3208,7 @@ public function _gatherMessageValues($input, &$values, $ids = []) { $groupLabel = $group['title']; if (!empty($customField['customValue'])) { foreach ($customField['customValue'] as $customFieldValues) { - $customGroup[$groupLabel][$customField['label']] = CRM_Utils_Array::value('data', $customFieldValues); + $customGroup[$groupLabel][$customField['label']] = $customFieldValues['data'] ?? NULL; } } } @@ -3579,15 +3579,15 @@ public static function recordFinancialAccounts(&$params, $financialTrxnValues = $balanceTrxnParams['to_financial_account_id'] = $toFinancialAccount; $balanceTrxnParams['contribution_id'] = $params['contribution']->id; $balanceTrxnParams['trxn_date'] = !empty($params['contribution']->receive_date) ? $params['contribution']->receive_date : date('YmdHis'); - $balanceTrxnParams['fee_amount'] = CRM_Utils_Array::value('fee_amount', $params); - $balanceTrxnParams['net_amount'] = CRM_Utils_Array::value('net_amount', $params); + $balanceTrxnParams['fee_amount'] = $params['fee_amount'] ?? NULL; + $balanceTrxnParams['net_amount'] = $params['net_amount'] ?? NULL; $balanceTrxnParams['currency'] = $params['contribution']->currency; $balanceTrxnParams['trxn_id'] = $params['contribution']->trxn_id; $balanceTrxnParams['status_id'] = $statusId; $balanceTrxnParams['payment_instrument_id'] = $params['contribution']->payment_instrument_id; - $balanceTrxnParams['check_number'] = CRM_Utils_Array::value('check_number', $params); - $balanceTrxnParams['pan_truncation'] = CRM_Utils_Array::value('pan_truncation', $params); - $balanceTrxnParams['card_type_id'] = CRM_Utils_Array::value('card_type_id', $params); + $balanceTrxnParams['check_number'] = $params['check_number'] ?? NULL; + $balanceTrxnParams['pan_truncation'] = $params['pan_truncation'] ?? NULL; + $balanceTrxnParams['card_type_id'] = $params['card_type_id'] ?? NULL; if (!empty($balanceTrxnParams['from_financial_account_id']) && ($statusId == array_search('Completed', $contributionStatuses) || $statusId == array_search('Partially paid', $contributionStatuses)) ) { @@ -3635,7 +3635,7 @@ public static function recordFinancialAccounts(&$params, $financialTrxnValues = $params['to_financial_account_id'] = CRM_Core_DAO::singleValueQuery("SELECT id FROM civicrm_financial_account WHERE is_default = 1 AND financial_account_type_id = %1", $queryParams); } - $totalAmount = CRM_Utils_Array::value('total_amount', $params); + $totalAmount = $params['total_amount'] ?? NULL; if (!isset($totalAmount) && !empty($params['prevContribution'])) { $totalAmount = $params['total_amount'] = $params['prevContribution']->total_amount; } @@ -3777,15 +3777,15 @@ public static function recordFinancialAccounts(&$params, $financialTrxnValues = $params['contribution']->find(TRUE); } $params['trxnParams']['payment_instrument_id'] = $params['contribution']->payment_instrument_id; - $params['trxnParams']['check_number'] = CRM_Utils_Array::value('check_number', $params); + $params['trxnParams']['check_number'] = $params['check_number'] ?? NULL; if (self::isPaymentInstrumentChange($params, $pendingStatus)) { $updated = CRM_Core_BAO_FinancialTrxn::updateFinancialAccountsOnPaymentInstrumentChange($params); } //if Change contribution amount - $params['trxnParams']['fee_amount'] = CRM_Utils_Array::value('fee_amount', $params); - $params['trxnParams']['net_amount'] = CRM_Utils_Array::value('net_amount', $params); + $params['trxnParams']['fee_amount'] = $params['fee_amount'] ?? NULL; + $params['trxnParams']['net_amount'] = $params['net_amount'] ?? NULL; $params['trxnParams']['total_amount'] = $trxnParams['total_amount'] = $params['total_amount'] = $totalAmount; $params['trxnParams']['trxn_id'] = $params['contribution']->trxn_id; if (isset($totalAmount) && @@ -3814,8 +3814,8 @@ public static function recordFinancialAccounts(&$params, $financialTrxnValues = ]); } } - $cardType = CRM_Utils_Array::value('card_type_id', $params); - $panTruncation = CRM_Utils_Array::value('pan_truncation', $params); + $cardType = $params['card_type_id'] ?? NULL; + $panTruncation = $params['pan_truncation'] ?? NULL; CRM_Core_BAO_FinancialTrxn::updateCreditCardDetails($params['contribution']->id, $panTruncation, $cardType); } } @@ -3824,8 +3824,8 @@ public static function recordFinancialAccounts(&$params, $financialTrxnValues = // records finanical trxn and entity financial trxn // also make it available as return value self::recordAlwaysAccountsReceivable($trxnParams, $params); - $trxnParams['pan_truncation'] = CRM_Utils_Array::value('pan_truncation', $params); - $trxnParams['card_type_id'] = CRM_Utils_Array::value('card_type_id', $params); + $trxnParams['pan_truncation'] = $params['pan_truncation'] ?? NULL; + $trxnParams['card_type_id'] = $params['card_type_id'] ?? NULL; $return = $financialTxn = CRM_Core_BAO_FinancialTrxn::create($trxnParams); $params['entity_id'] = $financialTxn->id; if (empty($params['partial_payment_total']) && empty($params['partial_amount_to_pay'])) { @@ -4463,10 +4463,10 @@ public static function completeOrder($input, &$ids, $objects, $transaction, $con $inputContributionWhiteList[] = 'financial_type_id'; } - $participant = CRM_Utils_Array::value('participant', $objects); - $recurContrib = CRM_Utils_Array::value('contributionRecur', $objects); + $participant = $objects['participant'] ?? NULL; + $recurContrib = $objects['contributionRecur'] ?? NULL; $recurringContributionID = (empty($recurContrib->id)) ? NULL : $recurContrib->id; - $event = CRM_Utils_Array::value('event', $objects); + $event = $objects['event'] ?? NULL; $paymentProcessorId = ''; if (isset($objects['paymentProcessor'])) { @@ -4579,7 +4579,7 @@ public static function completeOrder($input, &$ids, $objects, $transaction, $con // @fixme Can we remove this if altogether? - we removed the participant if / else and left relatedObjects['participant'] to ensure behaviour didn't change but it is probably not required. // @todo - use getRelatedMemberships instead $contribution->contribution_status_id = $contributionParams['contribution_status_id']; - $contribution->trxn_id = CRM_Utils_Array::value('trxn_id', $input); + $contribution->trxn_id = $input['trxn_id'] ?? NULL; $contribution->receive_date = CRM_Utils_Date::isoToMysql($contribution->receive_date); } @@ -4764,13 +4764,13 @@ public static function recordPartialPayment($contribution, $params) { $balanceTrxnParams['total_amount'] = $params['total_amount']; $balanceTrxnParams['contribution_id'] = $params['contribution_id']; $balanceTrxnParams['trxn_date'] = CRM_Utils_Array::value('trxn_date', $params, CRM_Utils_Array::value('contribution_receive_date', $params, date('YmdHis'))); - $balanceTrxnParams['fee_amount'] = CRM_Utils_Array::value('fee_amount', $params); - $balanceTrxnParams['net_amount'] = CRM_Utils_Array::value('total_amount', $params); + $balanceTrxnParams['fee_amount'] = $params['fee_amount'] ?? NULL; + $balanceTrxnParams['net_amount'] = $params['total_amount'] ?? NULL; $balanceTrxnParams['currency'] = $contribution['currency']; - $balanceTrxnParams['trxn_id'] = CRM_Utils_Array::value('contribution_trxn_id', $params, NULL); + $balanceTrxnParams['trxn_id'] = $params['contribution_trxn_id'] ?? NULL; $balanceTrxnParams['status_id'] = CRM_Core_PseudoConstant::getKey('CRM_Core_BAO_FinancialTrxn', 'status_id', 'Completed'); $balanceTrxnParams['payment_instrument_id'] = CRM_Utils_Array::value('payment_instrument_id', $params, $contribution['payment_instrument_id']); - $balanceTrxnParams['check_number'] = CRM_Utils_Array::value('check_number', $params); + $balanceTrxnParams['check_number'] = $params['check_number'] ?? NULL; $balanceTrxnParams['is_payment'] = 1; if (!empty($params['payment_processor'])) { @@ -4846,7 +4846,7 @@ public static function assignProportionalLineItems($trxnParams, $trxnId, $contri * @throws \API_Exception */ public static function checkLineItems(&$params) { - $totalAmount = CRM_Utils_Array::value('total_amount', $params); + $totalAmount = $params['total_amount'] ?? NULL; $lineItemAmount = 0; foreach ($params['line_items'] as &$lineItems) { @@ -5861,7 +5861,7 @@ protected function loadEventMessageTemplateParams(int $eventID, int $participant $groupLabel = $group['title']; if (!empty($customField['customValue'])) { foreach ($customField['customValue'] as $customFieldValues) { - $eventCustomGroup[$groupLabel][$customField['label']] = CRM_Utils_Array::value('data', $customFieldValues); + $eventCustomGroup[$groupLabel][$customField['label']] = $customFieldValues['data'] ?? NULL; } } } @@ -5888,7 +5888,7 @@ protected function loadEventMessageTemplateParams(int $eventID, int $participant $groupLabel = $group['title']; if (!empty($customField['customValue'])) { foreach ($customField['customValue'] as $customFieldValues) { - $participantCustomGroup[$groupLabel][$customField['label']] = CRM_Utils_Array::value('data', $customFieldValues); + $participantCustomGroup[$groupLabel][$customField['label']] = $customFieldValues['data'] ?? NULL; } } } diff --git a/CRM/Contribute/BAO/Contribution/Utils.php b/CRM/Contribute/BAO/Contribution/Utils.php index 7b3edc1076b3..b6621b519000 100644 --- a/CRM/Contribute/BAO/Contribution/Utils.php +++ b/CRM/Contribute/BAO/Contribution/Utils.php @@ -574,7 +574,7 @@ public static function getContributionStatuses($usedFor = 'contribution', $id = } else { $contributionStatus = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $id, 'contribution_status_id'); - $name = CRM_Utils_Array::value($contributionStatus, $statusNames); + $name = $statusNames[$contributionStatus] ?? NULL; switch ($name) { case 'Completed': // [CRM-17498] Removing unsupported status change options. diff --git a/CRM/Contribute/BAO/ContributionPage.php b/CRM/Contribute/BAO/ContributionPage.php index 8d575ad2d2e7..99b9b8d12497 100644 --- a/CRM/Contribute/BAO/ContributionPage.php +++ b/CRM/Contribute/BAO/ContributionPage.php @@ -314,7 +314,7 @@ public static function sendMail($contactID, $values, $isTest = FALSE, $returnMes $preProfileTypes = CRM_Core_BAO_UFGroup::profileGroups($preID); if (in_array('Individual', $preProfileTypes) || in_array('Contact', $preProfileTypes)) { //Take Individual contact ID - $userID = CRM_Utils_Array::value('related_contact', $values); + $userID = $values['related_contact'] ?? NULL; } } list($values['customPre_grouptitle'], $values['customPre']) = self::getProfileNameAndFields($preID, $userID, $params['custom_pre_id']); @@ -325,7 +325,7 @@ public static function sendMail($contactID, $values, $isTest = FALSE, $returnMes $postProfileTypes = CRM_Core_BAO_UFGroup::profileGroups($postID); if (in_array('Individual', $postProfileTypes) || in_array('Contact', $postProfileTypes)) { //Take Individual contact ID - $userID = CRM_Utils_Array::value('related_contact', $values); + $userID = $values['related_contact'] ?? NULL; } } list($values['customPost_grouptitle'], $values['customPost']) = self::getProfileNameAndFields($postID, $userID, $params['custom_post_id']); @@ -391,7 +391,7 @@ public static function sendMail($contactID, $values, $isTest = FALSE, $returnMes } // CRM-6976 - $originalCCReceipt = CRM_Utils_Array::value('cc_receipt', $values); + $originalCCReceipt = $values['cc_receipt'] ?? NULL; // cc to related contacts of contributor OR the one who // signs up. Is used for cases like - on behalf of @@ -442,13 +442,13 @@ public static function sendMail($contactID, $values, $isTest = FALSE, $returnMes $sendTemplateParams['from'] = CRM_Utils_Array::value('receipt_from_name', $values) . ' <' . $values['receipt_from_email'] . '>'; $sendTemplateParams['toName'] = $displayName; $sendTemplateParams['toEmail'] = $email; - $sendTemplateParams['cc'] = CRM_Utils_Array::value('cc_receipt', $values); - $sendTemplateParams['bcc'] = CRM_Utils_Array::value('bcc_receipt', $values); + $sendTemplateParams['cc'] = $values['cc_receipt'] ?? NULL; + $sendTemplateParams['bcc'] = $values['bcc_receipt'] ?? NULL; //send email with pdf invoice $template = CRM_Core_Smarty::singleton(); $taxAmt = $template->get_template_vars('dataArray'); $prefixValue = Civi::settings()->get('contribution_invoice_settings'); - $invoicing = CRM_Utils_Array::value('invoicing', $prefixValue); + $invoicing = $prefixValue['invoicing'] ?? NULL; if (isset($invoicing) && isset($prefixValue['is_email_pdf'])) { $sendTemplateParams['isEmailPdf'] = TRUE; $sendTemplateParams['contributionId'] = $values['contribution_id']; @@ -461,8 +461,8 @@ public static function sendMail($contactID, $values, $isTest = FALSE, $returnMes $sendTemplateParams['groupName'] = 'msg_tpl_workflow_contribution'; $sendTemplateParams['valueName'] = 'contribution_dupalert'; $sendTemplateParams['from'] = ts('Automatically Generated') . " <{$values['receipt_from_email']}>"; - $sendTemplateParams['toName'] = CRM_Utils_Array::value('receipt_from_name', $values); - $sendTemplateParams['toEmail'] = CRM_Utils_Array::value('receipt_from_email', $values); + $sendTemplateParams['toName'] = $values['receipt_from_name'] ?? NULL; + $sendTemplateParams['toEmail'] = $values['receipt_from_email'] ?? NULL; $sendTemplateParams['tplParams']['onBehalfID'] = $contactID; $sendTemplateParams['tplParams']['receiptMessage'] = $message; @@ -539,7 +539,7 @@ public static function recurringNotify($type, $contactID, $pageID, $recur, $auto 'cc_receipt', 'bcc_receipt', ]); - $isEmailReceipt = CRM_Utils_Array::value('is_email_receipt', $value[$pageID]); + $isEmailReceipt = $value[$pageID]['is_email_receipt'] ?? NULL; } elseif ($recur->id) { // This means we are coming from back-office - ie. no page ID, but recurring. @@ -585,8 +585,8 @@ public static function recurringNotify($type, $contactID, $pageID, $recur, $auto ]; //CRM-13811 if ($pageID) { - $templatesParams['cc'] = CRM_Utils_Array::value('cc_receipt', $value[$pageID]); - $templatesParams['bcc'] = CRM_Utils_Array::value('bcc_receipt', $value[$pageID]); + $templatesParams['cc'] = $value[$pageID]['cc_receipt'] ?? NULL; + $templatesParams['bcc'] = $value[$pageID]['bcc_receipt'] ?? NULL; } if ($recur->id) { // in some cases its just recurringNotify() thats called for the first time and these urls don't get set. diff --git a/CRM/Contribute/BAO/ContributionRecur.php b/CRM/Contribute/BAO/ContributionRecur.php index 3a9a441c5d04..ca665cc12d53 100644 --- a/CRM/Contribute/BAO/ContributionRecur.php +++ b/CRM/Contribute/BAO/ContributionRecur.php @@ -66,7 +66,7 @@ public static function add(&$params) { $recurring = new CRM_Contribute_BAO_ContributionRecur(); $recurring->copyValues($params); - $recurring->id = CRM_Utils_Array::value('id', $params); + $recurring->id = $params['id'] ?? NULL; // set currency for CRM-1496 if (empty($params['id']) && !isset($recurring->currency)) { @@ -103,9 +103,9 @@ public static function add(&$params) { * true if duplicate, false otherwise */ public static function checkDuplicate($params, &$duplicates) { - $id = CRM_Utils_Array::value('id', $params); - $trxn_id = CRM_Utils_Array::value('trxn_id', $params); - $invoice_id = CRM_Utils_Array::value('invoice_id', $params); + $id = $params['id'] ?? NULL; + $trxn_id = $params['trxn_id'] ?? NULL; + $invoice_id = $params['invoice_id'] ?? NULL; $clause = []; $params = []; @@ -264,19 +264,19 @@ public static function cancelRecurContribution($params) { $recur->start_date = CRM_Utils_Date::isoToMysql($recur->start_date); $recur->create_date = CRM_Utils_Date::isoToMysql($recur->create_date); $recur->modified_date = CRM_Utils_Date::isoToMysql($recur->modified_date); - $recur->cancel_reason = CRM_Utils_Array::value('cancel_reason', $params); + $recur->cancel_reason = $params['cancel_reason'] ?? NULL; $recur->cancel_date = date('YmdHis'); $recur->save(); // @fixme https://lab.civicrm.org/dev/core/issues/927 Cancelling membership etc is not desirable for all use-cases and we should be able to disable it $dao = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($recurId); if ($dao && $dao->recur_id) { - $details = CRM_Utils_Array::value('details', $activityParams); + $details = $activityParams['details'] ?? NULL; if ($dao->auto_renew && $dao->membership_id) { // its auto-renewal membership mode $membershipTypes = CRM_Member_PseudoConstant::membershipType(); $membershipType = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $dao->membership_id, 'membership_type_id'); - $membershipType = CRM_Utils_Array::value($membershipType, $membershipTypes); + $membershipType = $membershipTypes[$membershipType] ?? NULL; $details .= '
' . ts('Automatic renewal of %1 membership cancelled.', [1 => $membershipType]); } diff --git a/CRM/Contribute/BAO/ContributionSoft.php b/CRM/Contribute/BAO/ContributionSoft.php index 45f82ec257e1..24174e9135d4 100644 --- a/CRM/Contribute/BAO/ContributionSoft.php +++ b/CRM/Contribute/BAO/ContributionSoft.php @@ -71,9 +71,9 @@ public static function processSoftContribution($params, $contribution) { ); $softParams['currency'] = $contribution->currency; $softParams['amount'] = $contribution->total_amount; - $softParams['pcp_display_in_roll'] = CRM_Utils_Array::value('pcp_display_in_roll', $pcp); - $softParams['pcp_roll_nickname'] = CRM_Utils_Array::value('pcp_roll_nickname', $pcp); - $softParams['pcp_personal_note'] = CRM_Utils_Array::value('pcp_personal_note', $pcp); + $softParams['pcp_display_in_roll'] = $pcp['pcp_display_in_roll'] ?? NULL; + $softParams['pcp_roll_nickname'] = $pcp['pcp_roll_nickname'] ?? NULL; + $softParams['pcp_personal_note'] = $pcp['pcp_personal_note'] ?? NULL; $softParams['soft_credit_type_id'] = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_ContributionSoft', 'soft_credit_type_id', 'pcp'); $contributionSoft = self::add($softParams); //Send notification to owner for PCP @@ -130,7 +130,7 @@ public static function formatSoftCreditParams(&$params, &$form) { 'pcp_personal_note', ]; foreach ($fields as $f) { - $pcp[$f] = CRM_Utils_Array::value($f, $params); + $pcp[$f] = $params[$f] ?? NULL; } } @@ -154,7 +154,7 @@ public static function formatSoftCreditParams(&$params, &$form) { FALSE ); if (count($ids)) { - $honorId = CRM_Utils_Array::value(0, $ids); + $honorId = $ids[0] ?? NULL; } $null = []; @@ -399,7 +399,7 @@ public static function getSoftContributionSelector($params) { // Format the params. $params['offset'] = ($params['page'] - 1) * $params['rp']; $params['rowCount'] = $params['rp']; - $params['sort'] = CRM_Utils_Array::value('sortBy', $params); + $params['sort'] = $params['sortBy'] ?? NULL; $contactId = $params['cid']; $filter = NULL; diff --git a/CRM/Contribute/BAO/Product.php b/CRM/Contribute/BAO/Product.php index da9414465375..eb79c86d7b10 100644 --- a/CRM/Contribute/BAO/Product.php +++ b/CRM/Contribute/BAO/Product.php @@ -78,7 +78,7 @@ public static function setIsActive($id, $is_active) { * @return CRM_Contribute_DAO_Product */ public static function create($params) { - $id = CRM_Utils_Array::value('id', $params); + $id = $params['id'] ?? NULL; if (empty($id)) { $defaultParams = [ 'id' => $id, diff --git a/CRM/Contribute/Form/AbstractEditPayment.php b/CRM/Contribute/Form/AbstractEditPayment.php index ee65f5336e9b..7601dda2efd5 100644 --- a/CRM/Contribute/Form/AbstractEditPayment.php +++ b/CRM/Contribute/Form/AbstractEditPayment.php @@ -276,7 +276,7 @@ public function buildValuesAndAssignOnline_Note_Type($id, &$values) { // Also don't allow user to update some fields for recurring contributions. if (!$this->_online) { - $this->_online = CRM_Utils_Array::value('contribution_recur_id', $values); + $this->_online = $values['contribution_recur_id'] ?? NULL; } $this->assign('isOnline', $this->_online ? TRUE : FALSE); @@ -415,9 +415,9 @@ public function preProcessPledge() { $payParams = ['id' => $this->_ppID]; CRM_Pledge_BAO_PledgePayment::retrieve($payParams, $this->_pledgeValues['pledgePayment']); - $this->_pledgeID = CRM_Utils_Array::value('pledge_id', $this->_pledgeValues['pledgePayment']); - $paymentStatusID = CRM_Utils_Array::value('status_id', $this->_pledgeValues['pledgePayment']); - $this->_id = CRM_Utils_Array::value('contribution_id', $this->_pledgeValues['pledgePayment']); + $this->_pledgeID = $this->_pledgeValues['pledgePayment']['pledge_id'] ?? NULL; + $paymentStatusID = $this->_pledgeValues['pledgePayment']['status_id'] ?? NULL; + $this->_id = $this->_pledgeValues['pledgePayment']['contribution_id'] ?? NULL; //get all status $allStatus = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name'); diff --git a/CRM/Contribute/Form/AdditionalInfo.php b/CRM/Contribute/Form/AdditionalInfo.php index 706a3508b49d..41ba9fba2762 100644 --- a/CRM/Contribute/Form/AdditionalInfo.php +++ b/CRM/Contribute/Form/AdditionalInfo.php @@ -171,7 +171,7 @@ public static function buildPaymentReminders(&$form) { */ public static function processPremium($params, $contributionID, $premiumID = NULL, $options = []) { $selectedProductID = $params['product_name'][0]; - $selectedProductOptionID = CRM_Utils_Array::value(1, $params['product_name']); + $selectedProductOptionID = $params['product_name'][1] ?? NULL; $dao = new CRM_Contribute_DAO_ContributionProduct(); $dao->contribution_id = $contributionID; @@ -186,7 +186,7 @@ public static function processPremium($params, $contributionID, $premiumID = NUL $productDetails = []; CRM_Contribute_BAO_Product::retrieve($premiumParams, $productDetails); - $dao->financial_type_id = CRM_Utils_Array::value('financial_type_id', $productDetails); + $dao->financial_type_id = $productDetails['financial_type_id'] ?? NULL; if (!empty($options[$selectedProductID])) { $dao->product_option = $options[$selectedProductID][$selectedProductOptionID]; } @@ -268,7 +268,7 @@ public static function postProcessCommon(&$params, &$formatted, &$form) { 'contribution_page_id', ]; foreach ($fields as $f) { - $formatted[$f] = CRM_Utils_Array::value($f, $params); + $formatted[$f] = $params[$f] ?? NULL; } if (!empty($params['thankyou_date']) && !CRM_Utils_System::isNull($params['thankyou_date'])) { @@ -437,7 +437,7 @@ public static function emailReceipt(&$form, &$params, $ccContribution = FALSE) { $taxAmt = $template->get_template_vars('dataArray'); $eventTaxAmt = $template->get_template_vars('totalTaxAmount'); $prefixValue = Civi::settings()->get('contribution_invoice_settings'); - $invoicing = CRM_Utils_Array::value('invoicing', $prefixValue); + $invoicing = $prefixValue['invoicing'] ?? NULL; if ((!empty($taxAmt) || isset($eventTaxAmt)) && (isset($invoicing) && isset($prefixValue['is_email_pdf']))) { $isEmailPdf = TRUE; } diff --git a/CRM/Contribute/Form/Contribution.php b/CRM/Contribute/Form/Contribution.php index 027c1690cb2d..ec594639f09c 100644 --- a/CRM/Contribute/Form/Contribution.php +++ b/CRM/Contribute/Form/Contribution.php @@ -223,10 +223,10 @@ public function preProcess() { parent::preProcess(); - $this->_formType = CRM_Utils_Array::value('formType', $_GET); + $this->_formType = $_GET['formType'] ?? NULL; // Get price set id. - $this->_priceSetId = CRM_Utils_Array::value('priceSetId', $_GET); + $this->_priceSetId = $_GET['priceSetId'] ?? NULL; $this->set('priceSetId', $this->_priceSetId); $this->assign('priceSetId', $this->_priceSetId); @@ -321,9 +321,9 @@ public function setDefaultValues() { // Set defaults for pledge payment. if ($this->_ppID) { - $defaults['total_amount'] = CRM_Utils_Array::value('scheduled_amount', $this->_pledgeValues['pledgePayment']); - $defaults['financial_type_id'] = CRM_Utils_Array::value('financial_type_id', $this->_pledgeValues); - $defaults['currency'] = CRM_Utils_Array::value('currency', $this->_pledgeValues); + $defaults['total_amount'] = $this->_pledgeValues['pledgePayment']['scheduled_amount'] ?? NULL; + $defaults['financial_type_id'] = $this->_pledgeValues['financial_type_id'] ?? NULL; + $defaults['currency'] = $this->_pledgeValues['currency'] ?? NULL; $defaults['option_type'] = 1; } @@ -437,7 +437,7 @@ public function setDefaultValues() { $defaults['receive_date'] = date('Y-m-d H:i:s'); } - $currency = CRM_Utils_Array::value('currency', $defaults); + $currency = $defaults['currency'] ?? NULL; $this->assign('currency', $currency); // Hack to get currency info to the js layer. CRM-11440. CRM_Utils_Money::format(1); @@ -1069,9 +1069,9 @@ protected function processCreditCard($submittedValues, $lineItem, $contactID) { CRM_Core_Config::singleton()->defaultCurrency ); - $this->_params['pcp_display_in_roll'] = CRM_Utils_Array::value('pcp_display_in_roll', $params); - $this->_params['pcp_roll_nickname'] = CRM_Utils_Array::value('pcp_roll_nickname', $params); - $this->_params['pcp_personal_note'] = CRM_Utils_Array::value('pcp_personal_note', $params); + $this->_params['pcp_display_in_roll'] = $params['pcp_display_in_roll'] ?? NULL; + $this->_params['pcp_roll_nickname'] = $params['pcp_roll_nickname'] ?? NULL; + $this->_params['pcp_personal_note'] = $params['pcp_personal_note'] ?? NULL; //Add common data to formatted params CRM_Contribute_Form_AdditionalInfo::postProcessCommon($params, $this->_params, $this); @@ -1205,7 +1205,7 @@ protected function processCreditCard($submittedValues, $lineItem, $contactID) { // Send receipt mail. array_unshift($this->statusMessage, ts('The contribution record has been saved.')); if ($contribution->id && !empty($this->_params['is_email_receipt'])) { - $this->_params['trxn_id'] = CRM_Utils_Array::value('trxn_id', $result); + $this->_params['trxn_id'] = $result['trxn_id'] ?? NULL; $this->_params['contact_id'] = $contactID; $this->_params['contribution_id'] = $contribution->id; if (CRM_Contribute_Form_AdditionalInfo::emailReceipt($this, $this->_params, TRUE)) { @@ -1372,7 +1372,7 @@ protected function submit($submittedValues, $action, $pledgePaymentID) { // Process price set and get total amount and line items. $lineItem = []; - $priceSetId = CRM_Utils_Array::value('price_set_id', $submittedValues); + $priceSetId = $submittedValues['price_set_id'] ?? NULL; if (empty($priceSetId) && !$this->_id) { $this->_priceSetId = $priceSetId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', 'default_contribution_amount', 'id', 'name'); $this->_priceSet = current(CRM_Price_BAO_PriceSet::getSetDetail($priceSetId)); @@ -1396,7 +1396,7 @@ protected function submit($submittedValues, $action, $pledgePaymentID) { ) { unset($submittedValues['tax_amount']); } - $submittedValues['total_amount'] = CRM_Utils_Array::value('amount', $submittedValues); + $submittedValues['total_amount'] = $submittedValues['amount'] ?? NULL; } if ($this->_id) { @@ -1507,7 +1507,7 @@ protected function submit($submittedValues, $action, $pledgePaymentID) { } if (!isset($submittedValues['total_amount'])) { - $submittedValues['total_amount'] = CRM_Utils_Array::value('total_amount', $this->_values); + $submittedValues['total_amount'] = $this->_values['total_amount'] ?? NULL; // Avoid tax amount deduction on edit form and keep it original, because this will lead to error described in CRM-20676 if (!$this->_id) { $submittedValues['total_amount'] -= CRM_Utils_Array::value('tax_amount', $this->_values, 0); @@ -1574,7 +1574,7 @@ protected function submit($submittedValues, $action, $pledgePaymentID) { 'pan_truncation', ]; foreach ($fields as $f) { - $params[$f] = CRM_Utils_Array::value($f, $formValues); + $params[$f] = $formValues[$f] ?? NULL; } $params['revenue_recognition_date'] = NULL; @@ -1620,7 +1620,7 @@ protected function submit($submittedValues, $action, $pledgePaymentID) { $params['contribution_mode'] = 'membership'; } $params['line_item'] = $lineItem; - $params['payment_processor_id'] = $params['payment_processor'] = CRM_Utils_Array::value('id', $this->_paymentProcessor); + $params['payment_processor_id'] = $params['payment_processor'] = $this->_paymentProcessor['id'] ?? NULL; $params['tax_amount'] = CRM_Utils_Array::value('tax_amount', $submittedValues, CRM_Utils_Array::value('tax_amount', $this->_values)); //create contribution. if ($isQuickConfig) { @@ -1657,7 +1657,7 @@ protected function submit($submittedValues, $action, $pledgePaymentID) { $formValues += CRM_Contribute_BAO_ContributionSoft::getSoftContribution($contribution->id); // to get 'from email id' for send receipt - $this->fromEmailId = CRM_Utils_Array::value('from_email_address', $formValues); + $this->fromEmailId = $formValues['from_email_address'] ?? NULL; if (CRM_Contribute_Form_AdditionalInfo::emailReceipt($this, $formValues)) { $this->statusMessage[] = ts('A receipt has been emailed to the contributor.'); } @@ -1711,11 +1711,11 @@ protected function invoicingPostProcessHook($submittedValues, $action, $lineItem foreach ($lineItem as $key => $value) { foreach ($value as $v) { if (isset($taxRate[(string) CRM_Utils_Array::value('tax_rate', $v)])) { - $taxRate[(string) $v['tax_rate']] = $taxRate[(string) $v['tax_rate']] + CRM_Utils_Array::value('tax_amount', $v); + $taxRate[(string) $v['tax_rate']] = $taxRate[(string) $v['tax_rate']] + $v['tax_amount'] ?? NULL; } else { if (isset($v['tax_rate'])) { - $taxRate[(string) $v['tax_rate']] = CRM_Utils_Array::value('tax_amount', $v); + $taxRate[(string) $v['tax_rate']] = $v['tax_amount'] ?? NULL; $getTaxDetails = TRUE; } } @@ -1763,7 +1763,7 @@ protected function calculateNonDeductibleAmount($params, $formValues) { return $params['non_deductible_amount']; } - $priceSetId = CRM_Utils_Array::value('price_set_id', $params); + $priceSetId = $params['price_set_id'] ?? NULL; // return non-deductible amount if it is set at the price field option level if ($priceSetId && !empty($params['line_item'])) { $nonDeductibleAmount = CRM_Price_BAO_PriceSet::getNonDeductibleAmountFromPriceSet($priceSetId, $params['line_item']); diff --git a/CRM/Contribute/Form/Contribution/Confirm.php b/CRM/Contribute/Form/Contribution/Confirm.php index 1f3737da9c0e..56250d0ce841 100644 --- a/CRM/Contribute/Form/Contribution/Confirm.php +++ b/CRM/Contribute/Form/Contribution/Confirm.php @@ -113,7 +113,7 @@ public static function handlePledge(&$form, $params, $contributionParams, $pledg $pledgeParams['original_installment_amount'] = $pledgeParams['installment_amount']; //inherit campaign from contirb page. - $pledgeParams['campaign_id'] = CRM_Utils_Array::value('campaign_id', $contributionParams); + $pledgeParams['campaign_id'] = $contributionParams['campaign_id'] ?? NULL; $pledge = CRM_Pledge_BAO_Pledge::create($pledgeParams); @@ -171,7 +171,7 @@ public static function getContributionParams( ]; if ($paymentProcessorOutcome) { - $contributionParams['payment_processor'] = CRM_Utils_Array::value('payment_processor', $paymentProcessorOutcome); + $contributionParams['payment_processor'] = $paymentProcessorOutcome['payment_processor'] ?? NULL; } if (!empty($params["is_email_receipt"])) { $contributionParams += [ @@ -216,7 +216,7 @@ protected static function getNonDeductibleAmount($params, $financialType, $onlin if (isset($params['non_deductible_amount']) && (!empty($params['non_deductible_amount']))) { return $params['non_deductible_amount']; } - $priceSetId = CRM_Utils_Array::value('priceSetId', $params); + $priceSetId = $params['priceSetId'] ?? NULL; // return non-deductible amount if it is set at the price field option level if ($priceSetId && !empty($form->_lineItem)) { $nonDeductibleAmount = CRM_Price_BAO_PriceSet::getNonDeductibleAmountFromPriceSet($priceSetId, $form->_lineItem); @@ -228,7 +228,7 @@ protected static function getNonDeductibleAmount($params, $financialType, $onlin else { if ($financialType->is_deductible) { if ($online && isset($params['selectProduct'])) { - $selectProduct = CRM_Utils_Array::value('selectProduct', $params); + $selectProduct = $params['selectProduct'] ?? NULL; } if (!$online && isset($params['product_name'][0])) { $selectProduct = $params['product_name'][0]; @@ -309,7 +309,7 @@ public function preProcess() { // if onbehalf-of-organization if (!empty($this->_values['onbehalf_profile_id']) && !empty($this->_params['onbehalf']['organization_name'])) { if (empty($this->_params['org_option']) && empty($this->_params['organization_id'])) { - $this->_params['organization_id'] = CRM_Utils_Array::value('onbehalfof_id', $this->_params); + $this->_params['organization_id'] = $this->_params['onbehalfof_id'] ?? NULL; } $this->_params['organization_name'] = $this->_params['onbehalf']['organization_name']; $addressBlocks = [ @@ -514,7 +514,7 @@ public function buildQuickForm() { } if (!empty($params['selectProduct']) && $params['selectProduct'] != 'no_thanks') { - $option = CRM_Utils_Array::value('options_' . $params['selectProduct'], $params); + $option = $params['options_' . $params['selectProduct']] ?? NULL; $productID = $params['selectProduct']; CRM_Contribute_BAO_Premium::buildPremiumBlock($this, $this->_id, FALSE, $productID, $option @@ -733,7 +733,7 @@ public function wrangleFinancialTypeID($financialTypeID) { protected function postProcessPremium($premiumParams, $contribution) { $hour = $minute = $second = 0; // assigning Premium information to receipt tpl - $selectProduct = CRM_Utils_Array::value('selectProduct', $premiumParams); + $selectProduct = $premiumParams['selectProduct'] ?? NULL; if ($selectProduct && $selectProduct != 'no_thanks' ) { @@ -894,7 +894,7 @@ public static function processFormContribution( $isEmailReceipt = !empty($form->_values['is_email_receipt']); $isSeparateMembershipPayment = empty($params['separate_membership_payment']) ? FALSE : TRUE; - $pledgeID = !empty($params['pledge_id']) ? $params['pledge_id'] : CRM_Utils_Array::value('pledge_id', $form->_values); + $pledgeID = !empty($params['pledge_id']) ? $params['pledge_id'] : $form->_values['pledge_id'] ?? NULL; if (!$isSeparateMembershipPayment && !empty($form->_values['pledge_block_id']) && (!empty($params['is_pledge']) || $pledgeID)) { $isPledge = TRUE; @@ -918,11 +918,11 @@ public static function processFormContribution( $params['is_email_receipt'] = $isEmailReceipt; } $params['is_recur'] = $isRecur; - $params['payment_instrument_id'] = CRM_Utils_Array::value('payment_instrument_id', $contributionParams); + $params['payment_instrument_id'] = $contributionParams['payment_instrument_id'] ?? NULL; $recurringContributionID = self::processRecurringContribution($form, $params, $contactID, $financialType); $now = date('YmdHis'); - $receiptDate = CRM_Utils_Array::value('receipt_date', $params); + $receiptDate = $params['receipt_date'] ?? NULL; if ($isEmailReceipt) { $receiptDate = $now; } @@ -942,7 +942,7 @@ public static function processFormContribution( $contribution = CRM_Contribute_BAO_Contribution::add($contributionParams); $invoiceSettings = Civi::settings()->get('contribution_invoice_settings'); - $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings); + $invoicing = $invoiceSettings['invoicing'] ?? NULL; if ($invoicing) { $dataArray = []; // @todo - interrogate the line items passed in on the params array. @@ -951,10 +951,10 @@ public static function processFormContribution( foreach ($lineItemValue as $key => $value) { if (isset($value['tax_amount']) && isset($value['tax_rate'])) { if (isset($dataArray[$value['tax_rate']])) { - $dataArray[$value['tax_rate']] = $dataArray[$value['tax_rate']] + CRM_Utils_Array::value('tax_amount', $value); + $dataArray[$value['tax_rate']] = $dataArray[$value['tax_rate']] + $value['tax_amount'] ?? NULL; } else { - $dataArray[$value['tax_rate']] = CRM_Utils_Array::value('tax_amount', $value); + $dataArray[$value['tax_rate']] = $value['tax_amount'] ?? NULL; } } } @@ -1053,13 +1053,13 @@ public static function processRecurringContribution(&$form, &$params, $contactID } $recurParams = ['contact_id' => $contactID]; - $recurParams['amount'] = CRM_Utils_Array::value('amount', $params); - $recurParams['auto_renew'] = CRM_Utils_Array::value('auto_renew', $params); - $recurParams['frequency_unit'] = CRM_Utils_Array::value('frequency_unit', $params); - $recurParams['frequency_interval'] = CRM_Utils_Array::value('frequency_interval', $params); - $recurParams['installments'] = CRM_Utils_Array::value('installments', $params); - $recurParams['financial_type_id'] = CRM_Utils_Array::value('financial_type_id', $params); - $recurParams['currency'] = CRM_Utils_Array::value('currency', $params); + $recurParams['amount'] = $params['amount'] ?? NULL; + $recurParams['auto_renew'] = $params['auto_renew'] ?? NULL; + $recurParams['frequency_unit'] = $params['frequency_unit'] ?? NULL; + $recurParams['frequency_interval'] = $params['frequency_interval'] ?? NULL; + $recurParams['installments'] = $params['installments'] ?? NULL; + $recurParams['financial_type_id'] = $params['financial_type_id'] ?? NULL; + $recurParams['currency'] = $params['currency'] ?? NULL; $recurParams['payment_instrument_id'] = $params['payment_instrument_id']; // CRM-14354: For an auto-renewing membership with an additional contribution, @@ -1086,10 +1086,10 @@ public static function processRecurringContribution(&$form, &$params, $contactID if (!empty($params['receive_date'])) { $recurParams['start_date'] = date('YmdHis', strtotime($params['receive_date'])); } - $recurParams['invoice_id'] = CRM_Utils_Array::value('invoiceID', $params); + $recurParams['invoice_id'] = $params['invoiceID'] ?? NULL; $recurParams['contribution_status_id'] = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Pending'); - $recurParams['payment_processor_id'] = CRM_Utils_Array::value('payment_processor_id', $params); - $recurParams['is_email_receipt'] = CRM_Utils_Array::value('is_email_receipt', $params); + $recurParams['payment_processor_id'] = $params['payment_processor_id'] ?? NULL; + $recurParams['is_email_receipt'] = $params['is_email_receipt'] ?? NULL; // we need to add a unique trxn_id to avoid a unique key error // in paypal IPN we reset this when paypal sends us the real trxn id, CRM-2991 $recurParams['trxn_id'] = CRM_Utils_Array::value('trxn_id', $params, $params['invoiceID']); @@ -1347,7 +1347,7 @@ protected function processMembership($membershipParams, $contactID, $customField $membershipType = empty($membershipTypes) ? [] : reset($membershipTypes); $this->assign('membership_name', CRM_Utils_Array::value('name', $membershipType)); - $this->_values['membership_name'] = CRM_Utils_Array::value('name', $membershipType); + $this->_values['membership_name'] = $membershipType['name'] ?? NULL; $isPaidMembership = FALSE; if ($this->_amount >= 0.0 && isset($membershipParams['amount'])) { @@ -1525,13 +1525,13 @@ protected function postProcessMembership( } $isPayLater = NULL; if (isset($form->_params)) { - $isPayLater = CRM_Utils_Array::value('is_pay_later', $form->_params); + $isPayLater = $form->_params['is_pay_later'] ?? NULL; } $campaignId = NULL; if (isset($form->_values) && is_array($form->_values) && !empty($form->_values)) { - $campaignId = CRM_Utils_Array::value('campaign_id', $form->_params); + $campaignId = $form->_params['campaign_id'] ?? NULL; if (!array_key_exists('campaign_id', $form->_params)) { - $campaignId = CRM_Utils_Array::value('campaign_id', $form->_values); + $campaignId = $form->_values['campaign_id'] ?? NULL; } } @@ -1706,7 +1706,7 @@ protected function processSecondaryFinancialTransaction($contactID, &$form, $tem $financialType->find(TRUE); $tempParams['amount'] = $minimumFee; $tempParams['invoiceID'] = md5(uniqid(rand(), TRUE)); - $isRecur = CRM_Utils_Array::value('is_recur', $tempParams); + $isRecur = $tempParams['is_recur'] ?? NULL; //assign receive date when separate membership payment //and contribution amount not selected. @@ -1926,7 +1926,7 @@ public static function submit($params) { $form->_fields['billing_last_name'] = 1; // CRM-18854 - Set form values to allow pledge to be created for api test. if (!empty($params['pledge_block_id'])) { - $form->_values['pledge_id'] = CRM_Utils_Array::value('pledge_id', $params, NULL); + $form->_values['pledge_id'] = $params['pledge_id'] ?? NULL; $form->_values['pledge_block_id'] = $params['pledge_block_id']; $pledgeBlock = CRM_Pledge_BAO_PledgeBlock::getPledgeBlock($params['id']); $form->_values['max_reminders'] = $pledgeBlock['max_reminders']; @@ -2046,7 +2046,7 @@ protected function processFormSubmission($contactID) { $title = !empty($this->_values['frontend_title']) ? $this->_values['frontend_title'] : $this->_values['title']; $this->_params['description'] = ts('Online Contribution') . ': ' . (!empty($this->_pcpInfo['title']) ? $this->_pcpInfo['title'] : $title); - $this->_params['accountingCode'] = CRM_Utils_Array::value('accountingCode', $this->_values); + $this->_params['accountingCode'] = $this->_values['accountingCode'] ?? NULL; // fix currency ID $this->_params['currencyID'] = CRM_Core_Config::singleton()->defaultCurrency; @@ -2058,7 +2058,7 @@ protected function processFormSubmission($contactID) { $pledgeBlock = CRM_Pledge_BAO_PledgeBlock::getPledgeBlock($this->_id); if (CRM_Utils_Array::value('start_date', $this->_params) || !CRM_Utils_Array::value('is_pledge_start_date_visible', $pledgeBlock) || !CRM_Utils_Array::value('is_pledge_start_date_editable', $pledgeBlock)) { - $pledgeStartDate = CRM_Utils_Array::value('start_date', $this->_params, NULL); + $pledgeStartDate = $this->_params['start_date'] ?? NULL; $this->_params['receive_date'] = CRM_Pledge_BAO_Pledge::getPledgeStartDate($pledgeStartDate, $pledgeBlock); $recurParams = CRM_Pledge_BAO_Pledge::buildRecurParams($this->_params); $this->_params = array_merge($this->_params, $recurParams); @@ -2213,7 +2213,7 @@ protected function processFormSubmission($contactID) { //get email primary first if exist $subscriptionEmail = ['email' => CRM_Utils_Array::value('email-Primary', $params)]; if (!$subscriptionEmail['email']) { - $subscriptionEmail['email'] = CRM_Utils_Array::value("email-{$this->_bltID}", $params); + $subscriptionEmail['email'] = $params["email-{$this->_bltID}"] ?? NULL; } // subscribing contact to groups if (!empty($subscribeGroupIds) && $subscriptionEmail['email']) { @@ -2276,7 +2276,7 @@ protected function processFormSubmission($contactID) { } //inherit campaign from contribution page. if (!array_key_exists('campaign_id', $membershipParams)) { - $membershipParams['campaign_id'] = CRM_Utils_Array::value('campaign_id', $this->_values); + $membershipParams['campaign_id'] = $this->_values['campaign_id'] ?? NULL; } $this->_params = CRM_Core_Payment_Form::mapParams($this->_bltID, $this->_params, $membershipParams, TRUE); diff --git a/CRM/Contribute/Form/Contribution/Main.php b/CRM/Contribute/Form/Contribution/Main.php index 416bc561f123..fa10c7d221c3 100644 --- a/CRM/Contribute/Form/Contribution/Main.php +++ b/CRM/Contribute/Form/Contribution/Main.php @@ -205,7 +205,7 @@ public function setDefaultValues() { $selectedCurrentMemTypes = []; foreach ($this->_priceSet['fields'] as $key => $val) { foreach ($val['options'] as $keys => $values) { - $opMemTypeId = CRM_Utils_Array::value('membership_type_id', $values); + $opMemTypeId = $values['membership_type_id'] ?? NULL; $priceFieldName = 'price_' . $values['price_field_id']; $priceFieldValue = CRM_Price_BAO_PriceSet::getPriceFieldValueFromURL($this, $priceFieldName); if (!empty($priceFieldValue)) { @@ -241,7 +241,7 @@ public function setDefaultValues() { if (!empty($this->_fields)) { //load default campaign from page. if (array_key_exists('contribution_campaign_id', $this->_fields)) { - $this->_defaults['contribution_campaign_id'] = CRM_Utils_Array::value('campaign_id', $this->_values); + $this->_defaults['contribution_campaign_id'] = $this->_values['campaign_id'] ?? NULL; } //set custom field defaults @@ -528,7 +528,7 @@ public static function buildRecur(&$form) { $form->add('hidden', 'frequency_interval', 1); } - $frUnits = CRM_Utils_Array::value('recur_frequency_unit', $form->_values); + $frUnits = $form->_values['recur_frequency_unit'] ?? NULL; if (empty($frUnits) && $className == 'CRM_Contribute_Form_Contribution' ) { @@ -639,8 +639,8 @@ public static function formRule($fields, $files, $self) { } elseif (!empty($fields["price_{$priceField->id}"])) { $otherAmountVal = CRM_Utils_Rule::cleanMoney($fields["price_{$priceField->id}"]); - $min = CRM_Utils_Array::value('min_amount', $self->_values); - $max = CRM_Utils_Array::value('max_amount', $self->_values); + $min = $self->_values['min_amount'] ?? NULL; + $max = $self->_values['max_amount'] ?? NULL; if ($min && $otherAmountVal < $min) { $errors["price_{$priceField->id}"] = ts('Contribution amount must be at least %1', [1 => $min] @@ -954,15 +954,15 @@ public static function computeAmount($params, $formValues) { } else { if (!empty($formValues['amount'])) { - $amountID = CRM_Utils_Array::value('amount', $params); + $amountID = $params['amount'] ?? NULL; if ($amountID) { // @todo - stop setting amount level in this function & call the CRM_Price_BAO_PriceSet::getAmountLevel // function to get correct amount level consistently. Remove setting of the amount level in // CRM_Price_BAO_PriceSet::processAmount. Extend the unit tests in CRM_Price_BAO_PriceSetTest // to cover all variants. - $params['amount_level'] = CRM_Utils_Array::value('label', $formValues[$amountID]); - $amount = CRM_Utils_Array::value('value', $formValues[$amountID]); + $params['amount_level'] = $formValues[$amountID]['label'] ?? NULL; + $amount = $formValues[$amountID]['value'] ?? NULL; } } } @@ -1019,7 +1019,7 @@ public function submit($params) { if (($selectedPriceOptionID = CRM_Utils_Array::value("price_{$priceField->id}", $params)) != FALSE && $selectedPriceOptionID > 0) { switch ($priceField->name) { case 'membership_amount': - $this->_params['selectMembership'] = $params['selectMembership'] = CRM_Utils_Array::value('membership_type_id', $priceOptions[$selectedPriceOptionID]); + $this->_params['selectMembership'] = $params['selectMembership'] = $priceOptions[$selectedPriceOptionID]['membership_type_id'] ?? NULL; $this->set('selectMembership', $params['selectMembership']); case 'contribution_amount': @@ -1028,12 +1028,12 @@ public function submit($params) { ($priceField->name == 'membership_amount' && CRM_Utils_Array::value('is_separate_payment', $this->_membershipBlock) == 0) ) { - $this->_values['amount'] = CRM_Utils_Array::value('amount', $priceOptions[$selectedPriceOptionID]); + $this->_values['amount'] = $priceOptions[$selectedPriceOptionID]['amount'] ?? NULL; } - $this->_values[$selectedPriceOptionID]['value'] = CRM_Utils_Array::value('amount', $priceOptions[$selectedPriceOptionID]); - $this->_values[$selectedPriceOptionID]['label'] = CRM_Utils_Array::value('label', $priceOptions[$selectedPriceOptionID]); - $this->_values[$selectedPriceOptionID]['amount_id'] = CRM_Utils_Array::value('id', $priceOptions[$selectedPriceOptionID]); - $this->_values[$selectedPriceOptionID]['weight'] = CRM_Utils_Array::value('weight', $priceOptions[$selectedPriceOptionID]); + $this->_values[$selectedPriceOptionID]['value'] = $priceOptions[$selectedPriceOptionID]['amount'] ?? NULL; + $this->_values[$selectedPriceOptionID]['label'] = $priceOptions[$selectedPriceOptionID]['label'] ?? NULL; + $this->_values[$selectedPriceOptionID]['amount_id'] = $priceOptions[$selectedPriceOptionID]['id'] ?? NULL; + $this->_values[$selectedPriceOptionID]['weight'] = $priceOptions[$selectedPriceOptionID]['weight'] ?? NULL; break; case 'other_amount': @@ -1104,7 +1104,7 @@ public function submit($params) { $params['price_' . $key] = CRM_Utils_Rule::cleanMoney($params['price_' . $key]); if ($params['price_' . $key] != 0) { foreach ($val['options'] as $optionKey => & $options) { - $options['amount'] = CRM_Utils_Array::value('price_' . $key, $params); + $options['amount'] = $params['price_' . $key] ?? NULL; break; } } diff --git a/CRM/Contribute/Form/Contribution/ThankYou.php b/CRM/Contribute/Form/Contribution/ThankYou.php index deb0d26bcee1..41d8077543ae 100644 --- a/CRM/Contribute/Form/Contribution/ThankYou.php +++ b/CRM/Contribute/Form/Contribution/ThankYou.php @@ -204,7 +204,7 @@ public function buildQuickForm() { $this->buildCustom($this->_values['onbehalf_profile_id'], 'onbehalfProfile', TRUE, 'onbehalf', $fieldTypes); } - $this->_trxnId = CRM_Utils_Array::value('trxn_id', $this->_params); + $this->_trxnId = $this->_params['trxn_id'] ?? NULL; $this->assign('trxn_id', $this->_trxnId); diff --git a/CRM/Contribute/Form/ContributionBase.php b/CRM/Contribute/Form/ContributionBase.php index e3acbd7cb3dc..bf6167d6e101 100644 --- a/CRM/Contribute/Form/ContributionBase.php +++ b/CRM/Contribute/Form/ContributionBase.php @@ -316,8 +316,8 @@ public function preProcess() { $this->assignBillingType(); // check for is_monetary status - $isMonetary = CRM_Utils_Array::value('is_monetary', $this->_values); - $isPayLater = CRM_Utils_Array::value('is_pay_later', $this->_values); + $isMonetary = $this->_values['is_monetary'] ?? NULL; + $isPayLater = $this->_values['is_pay_later'] ?? NULL; if (!empty($this->_ccid)) { $this->_values['financial_type_id'] = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $this->_ccid, @@ -382,10 +382,10 @@ public function preProcess() { $pledgeBlock = CRM_Pledge_BAO_PledgeBlock::getPledgeBlock($this->_id); if ($pledgeBlock) { - $this->_values['pledge_block_id'] = CRM_Utils_Array::value('id', $pledgeBlock); - $this->_values['max_reminders'] = CRM_Utils_Array::value('max_reminders', $pledgeBlock); - $this->_values['initial_reminder_day'] = CRM_Utils_Array::value('initial_reminder_day', $pledgeBlock); - $this->_values['additional_reminder_day'] = CRM_Utils_Array::value('additional_reminder_day', $pledgeBlock); + $this->_values['pledge_block_id'] = $pledgeBlock['id'] ?? NULL; + $this->_values['max_reminders'] = $pledgeBlock['max_reminders'] ?? NULL; + $this->_values['initial_reminder_day'] = $pledgeBlock['initial_reminder_day'] ?? NULL; + $this->_values['additional_reminder_day'] = $pledgeBlock['additional_reminder_day'] ?? NULL; //set pledge id in values $pledgeId = CRM_Utils_Request::retrieve('pledgeId', 'Positive', $this); @@ -482,7 +482,7 @@ public function preProcess() { // check if billing block is required for pay later if (!empty($this->_values['is_pay_later'])) { - $this->_isBillingAddressRequiredForPayLater = CRM_Utils_Array::value('is_billing_required', $this->_values); + $this->_isBillingAddressRequiredForPayLater = $this->_values['is_billing_required'] ?? NULL; $this->assign('isBillingAddressRequiredForPayLater', $this->_isBillingAddressRequiredForPayLater); } } @@ -656,14 +656,14 @@ public function buildCustom($id, $name, $viewOnly = FALSE, $profileContactType = $field['data_type'] == 'File' || ($viewOnly && $field['name'] == 'image_URL') ) { //retrieve file value from submitted values on basis of $profileContactType - $fileValue = CRM_Utils_Array::value($key, $this->_params); + $fileValue = $this->_params[$key] ?? NULL; if (!empty($profileContactType) && !empty($this->_params[$profileContactType])) { - $fileValue = CRM_Utils_Array::value($key, $this->_params[$profileContactType]); + $fileValue = $this->_params[$profileContactType][$key] ?? NULL; } if ($fileValue) { - $path = CRM_Utils_Array::value('name', $fileValue); - $fileType = CRM_Utils_Array::value('type', $fileValue); + $path = $fileValue['name'] ?? NULL; + $fileType = $fileValue['type'] ?? NULL; $fileValue = CRM_Utils_File::getFileURL($path, $fileType); } @@ -1154,7 +1154,7 @@ protected function buildMembershipBlock( $allowAutoRenewMembership = $autoRenewOption = FALSE; $autoRenewMembershipTypeOptions = []; - $separateMembershipPayment = CRM_Utils_Array::value('is_separate_payment', $this->_membershipBlock); + $separateMembershipPayment = $this->_membershipBlock['is_separate_payment'] ?? NULL; if ($membershipPriceset) { foreach ($this->_priceSet['fields'] as $pField) { @@ -1346,7 +1346,7 @@ protected function buildMembershipBlock( * Arguably the form should start to build $this->_params in the pre-process main page & use that array consistently throughout. */ protected function setRecurringMembershipParams() { - $selectedMembershipTypeID = CRM_Utils_Array::value('selectMembership', $this->_params); + $selectedMembershipTypeID = $this->_params['selectMembership'] ?? NULL; if ($selectedMembershipTypeID) { // @todo the price_x fields will ALWAYS allow us to determine the membership - so we should ignore // 'selectMembership' and calculate from the price_x fields so we have one method that always works diff --git a/CRM/Contribute/Form/ContributionCharts.php b/CRM/Contribute/Form/ContributionCharts.php index 3b498b6b1abf..bdddaa2616bf 100644 --- a/CRM/Contribute/Form/ContributionCharts.php +++ b/CRM/Contribute/Form/ContributionCharts.php @@ -139,7 +139,7 @@ public function postProcess() { $monthlyChart = $yearlyChart = FALSE; foreach ($chartData as $chartKey => & $values) { - $chartValues = CRM_Utils_Array::value('values', $values); + $chartValues = $values['values'] ?? NULL; if (!is_array($chartValues) || empty($chartValues)) { continue; diff --git a/CRM/Contribute/Form/ContributionPage.php b/CRM/Contribute/Form/ContributionPage.php index 1373abedca2d..ba8bb64ec087 100644 --- a/CRM/Contribute/Form/ContributionPage.php +++ b/CRM/Contribute/Form/ContributionPage.php @@ -156,7 +156,7 @@ public function buildQuickForm() { $this->applyFilter('__ALL__', 'trim'); $session = CRM_Core_Session::singleton(); - $this->_cancelURL = CRM_Utils_Array::value('cancelURL', $_POST); + $this->_cancelURL = $_POST['cancelURL'] ?? NULL; if (!$this->_cancelURL) { $this->_cancelURL = CRM_Utils_System::url('civicrm/admin/contribute', 'reset=1'); @@ -289,7 +289,7 @@ public function setDefaultValues() { 'is_pledge_start_date_editable', ]; foreach ($pledgeBlock as $key) { - $defaults[$key] = CRM_Utils_Array::value($key, $pledgeBlockDefaults); + $defaults[$key] = $pledgeBlockDefaults[$key] ?? NULL; if ($key == 'pledge_start_date' && !empty($pledgeBlockDefaults[$key])) { $defaultPledgeDate = (array) json_decode($pledgeBlockDefaults['pledge_start_date']); $pledgeDateFields = [ diff --git a/CRM/Contribute/Form/ContributionPage/Amount.php b/CRM/Contribute/Form/ContributionPage/Amount.php index 7963d3354846..ff32d83fa6d1 100644 --- a/CRM/Contribute/Form/ContributionPage/Amount.php +++ b/CRM/Contribute/Form/ContributionPage/Amount.php @@ -226,8 +226,8 @@ public function setDefaultValues() { foreach ($options as $optionId => $optionValue) { $countRow++; $defaults['value'][$countRow] = $optionValue['amount']; - $defaults['label'][$countRow] = CRM_Utils_Array::value('label', $optionValue); - $defaults['name'][$countRow] = CRM_Utils_Array::value('name', $optionValue); + $defaults['label'][$countRow] = $optionValue['label'] ?? NULL; + $defaults['name'][$countRow] = $optionValue['name'] ?? NULL; $defaults['weight'][$countRow] = $optionValue['weight']; $defaults["price_field_value"][$countRow] = $optionValue['id']; @@ -339,8 +339,8 @@ public static function formRule($fields, $files, $self) { if (!empty($fields['amount_block_is_active']) && empty($fields['price_set_id']) && empty($fields['amount_label'])) { $errors['amount_label'] = ts('Please enter the contribution amount label.'); } - $minAmount = CRM_Utils_Array::value('min_amount', $fields); - $maxAmount = CRM_Utils_Array::value('max_amount', $fields); + $minAmount = $fields['min_amount'] ?? NULL; + $maxAmount = $fields['max_amount'] ?? NULL; if (!empty($minAmount) && !empty($maxAmount)) { $minAmount = CRM_Utils_Rule::cleanMoney($minAmount); $maxAmount = CRM_Utils_Rule::cleanMoney($maxAmount); @@ -395,7 +395,7 @@ public static function formRule($fields, $files, $self) { !$priceSetId ) { //get the values of amount block - $values = CRM_Utils_Array::value('value', $fields); + $values = $fields['value'] ?? NULL; $isSetRow = FALSE; for ($i = 1; $i < self::NUM_OPTION; $i++) { if ((isset($values[$i]) && (strlen(trim($values[$i])) > 0))) { @@ -439,7 +439,7 @@ public function postProcess() { } // check for price set. - $priceSetID = CRM_Utils_Array::value('price_set_id', $params); + $priceSetID = $params['price_set_id'] ?? NULL; // get required fields. $fields = [ @@ -565,9 +565,9 @@ public function postProcess() { // process contribution amount block $deleteAmountBlk = FALSE; - $labels = CRM_Utils_Array::value('label', $params); - $values = CRM_Utils_Array::value('value', $params); - $default = CRM_Utils_Array::value('default', $params); + $labels = $params['label'] ?? NULL; + $values = $params['value'] ?? NULL; + $default = $params['default'] ?? NULL; $options = []; for ($i = 1; $i < self::NUM_OPTION; $i++) { @@ -603,7 +603,7 @@ public function postProcess() { $setParams['name'] = $pageTitle . '_' . date('is', $timeSec[0]) . $timeSec[1]; } $setParams['is_quick_config'] = 1; - $setParams['financial_type_id'] = CRM_Utils_Array::value('financial_type_id', $this->_values); + $setParams['financial_type_id'] = $this->_values['financial_type_id'] ?? NULL; $setParams['extends'] = CRM_Core_Component::getComponentID('CiviContribute'); $priceSet = CRM_Price_BAO_PriceSet::create($setParams); $priceSetId = $priceSet->id; @@ -620,7 +620,7 @@ public function postProcess() { } } if (implode('', $params['price_field_value'])) { - $fieldParams['id'] = CRM_Utils_Array::value('price_field_id', $params); + $fieldParams['id'] = $params['price_field_id'] ?? NULL; $fieldParams['option_id'] = $params['price_field_value']; } else { @@ -629,7 +629,7 @@ public function postProcess() { } } else { - $priceFieldId = CRM_Utils_Array::value('price_field_other', $params); + $priceFieldId = $params['price_field_other'] ?? NULL; } $priceSetId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', $priceFieldId, 'price_set_id'); } @@ -646,7 +646,7 @@ public function postProcess() { $fieldParams['name'] = strtolower(CRM_Utils_String::munge("Contribution Amount", '_', 245)); } else { - $fieldParams['id'] = CRM_Utils_Array::value('id', $editedResults); + $fieldParams['id'] = $editedResults['id'] ?? NULL; } $fieldParams['price_set_id'] = $priceSetId; @@ -663,7 +663,7 @@ public function postProcess() { $fieldParams['html_type'] = 'Radio'; $fieldParams['option_label'] = $params['label']; $fieldParams['option_amount'] = $params['value']; - $fieldParams['financial_type_id'] = CRM_Utils_Array::value('financial_type_id', $this->_values); + $fieldParams['financial_type_id'] = $this->_values['financial_type_id'] ?? NULL; foreach ($options as $value) { $fieldParams['option_weight'][$value['weight']] = $value['weight']; } @@ -759,7 +759,7 @@ public function postProcess() { 'is_pledge_start_date_editable', ]; foreach ($pledgeBlock as $key) { - $pledgeBlockParams[$key] = CRM_Utils_Array::value($key, $params); + $pledgeBlockParams[$key] = $params[$key] ?? NULL; } $pledgeBlockParams['is_pledge_interval'] = CRM_Utils_Array::value('is_pledge_interval', $params, FALSE @@ -801,7 +801,7 @@ public function postProcess() { } if ($deleteAmountBlk) { - $priceField = !empty($params['price_field_id']) ? $params['price_field_id'] : CRM_Utils_Array::value('price_field_other', $params); + $priceField = !empty($params['price_field_id']) ? $params['price_field_id'] : $params['price_field_other'] ?? NULL; if ($priceField) { $priceSetID = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', $priceField, 'price_set_id'); CRM_Price_BAO_PriceSet::setIsQuickConfig($priceSetID, 0); diff --git a/CRM/Contribute/Form/Search.php b/CRM/Contribute/Form/Search.php index abe1b633160b..3eef9ebb6e39 100644 --- a/CRM/Contribute/Form/Search.php +++ b/CRM/Contribute/Form/Search.php @@ -276,7 +276,7 @@ public function postProcess() { CRM_Contact_BAO_Query::processSpecialFormValue($this->_formValues, $specialParams); // @todo - stop changing formValues - respect submitted form values, change a working array. - $tags = CRM_Utils_Array::value('contact_tags', $this->_formValues); + $tags = $this->_formValues['contact_tags'] ?? NULL; if ($tags && !is_array($tags)) { // @todo - stop changing formValues - respect submitted form values, change a working array. unset($this->_formValues['contact_tags']); @@ -291,7 +291,7 @@ public function postProcess() { } } - $group = CRM_Utils_Array::value('group', $this->_formValues); + $group = $this->_formValues['group'] ?? NULL; if ($group && !is_array($group)) { // @todo - stop changing formValues - respect submitted form values, change a working array. unset($this->_formValues['group']); diff --git a/CRM/Contribute/Form/SoftCredit.php b/CRM/Contribute/Form/SoftCredit.php index 5b5d9c802f0f..d8c7bfa8de9f 100644 --- a/CRM/Contribute/Form/SoftCredit.php +++ b/CRM/Contribute/Form/SoftCredit.php @@ -148,14 +148,14 @@ public static function setDefaultValues(&$defaults, &$form) { if (!empty($form->_softCreditInfo['pcp_id'])) { $noPCP = FALSE; $pcpInfo = $form->_softCreditInfo; - $pcpId = CRM_Utils_Array::value('pcp_id', $pcpInfo); + $pcpId = $pcpInfo['pcp_id'] ?? NULL; $pcpTitle = CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCP', $pcpId, 'title'); $contributionPageTitle = CRM_PCP_BAO_PCP::getPcpPageTitle($pcpId, 'contribute'); $defaults['pcp_made_through'] = CRM_Utils_Array::value('sort_name', $pcpInfo) . " :: " . $pcpTitle . " :: " . $contributionPageTitle; - $defaults['pcp_made_through_id'] = CRM_Utils_Array::value('pcp_id', $pcpInfo); - $defaults['pcp_display_in_roll'] = CRM_Utils_Array::value('pcp_display_in_roll', $pcpInfo); - $defaults['pcp_roll_nickname'] = CRM_Utils_Array::value('pcp_roll_nickname', $pcpInfo); - $defaults['pcp_personal_note'] = CRM_Utils_Array::value('pcp_personal_note', $pcpInfo); + $defaults['pcp_made_through_id'] = $pcpInfo['pcp_id'] ?? NULL; + $defaults['pcp_display_in_roll'] = $pcpInfo['pcp_display_in_roll'] ?? NULL; + $defaults['pcp_roll_nickname'] = $pcpInfo['pcp_roll_nickname'] ?? NULL; + $defaults['pcp_personal_note'] = $pcpInfo['pcp_personal_note'] ?? NULL; } $form->assign('noSoftCredit', $noSoftCredit); diff --git a/CRM/Contribute/Form/Task.php b/CRM/Contribute/Form/Task.php index e77b575fe452..16d61166670f 100644 --- a/CRM/Contribute/Form/Task.php +++ b/CRM/Contribute/Form/Task.php @@ -57,7 +57,7 @@ public static function preProcessCommon(&$form) { $values = $form->controller->exportValues($form->get('searchFormName')); - $form->_task = CRM_Utils_Array::value('task', $values); + $form->_task = $values['task'] ?? NULL; $contributeTasks = CRM_Contribute_Task::tasks(); $form->assign('taskName', CRM_Utils_Array::value($form->_task, $contributeTasks)); diff --git a/CRM/Contribute/Form/Task/Batch.php b/CRM/Contribute/Form/Task/Batch.php index 4a35044f4324..a22383623e0a 100644 --- a/CRM/Contribute/Form/Task/Batch.php +++ b/CRM/Contribute/Form/Task/Batch.php @@ -135,7 +135,7 @@ public function buildQuickForm() { foreach ($this->_fields as $name => $field) { $entityColumnValue = []; if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($name)) { - $customValue = CRM_Utils_Array::value($customFieldID, $customFields); + $customValue = $customFields[$customFieldID] ?? NULL; if (!empty($customValue['extends_entity_column_value'])) { $entityColumnValue = explode(CRM_Core_DAO::VALUE_SEPARATOR, $customValue['extends_entity_column_value'] diff --git a/CRM/Contribute/Form/Task/Invoice.php b/CRM/Contribute/Form/Task/Invoice.php index f2a0298655ff..059191b119e4 100644 --- a/CRM/Contribute/Form/Task/Invoice.php +++ b/CRM/Contribute/Form/Task/Invoice.php @@ -227,9 +227,9 @@ public static function printPDF($contribIDs, &$params, $contactIds) { $ids['contribution'] = $contribID; $ids['contributionRecur'] = NULL; $ids['contributionPage'] = NULL; - $ids['membership'] = CRM_Utils_Array::value('membership', $detail); - $ids['participant'] = CRM_Utils_Array::value('participant', $detail); - $ids['event'] = CRM_Utils_Array::value('event', $detail); + $ids['membership'] = $detail['membership'] ?? NULL; + $ids['participant'] = $detail['participant'] ?? NULL; + $ids['event'] = $detail['event'] ?? NULL; if (!$invoiceElements['baseIPN']->validateData($input, $ids, $objects, FALSE)) { CRM_Core_Error::fatal(); @@ -279,12 +279,12 @@ public static function printPDF($contribIDs, &$params, $contactIds) { $lineItem = CRM_Price_BAO_LineItem::getLineItemsByContributionID($contribID); foreach ($lineItem as $taxRate) { if (isset($dataArray[(string) $taxRate['tax_rate']])) { - $dataArray[(string) $taxRate['tax_rate']] = $dataArray[(string) $taxRate['tax_rate']] + CRM_Utils_Array::value('tax_amount', $taxRate); + $dataArray[(string) $taxRate['tax_rate']] = $dataArray[(string) $taxRate['tax_rate']] + $taxRate['tax_amount'] ?? NULL; } else { - $dataArray[(string) $taxRate['tax_rate']] = CRM_Utils_Array::value('tax_amount', $taxRate); + $dataArray[(string) $taxRate['tax_rate']] = $taxRate['tax_amount'] ?? NULL; } - $subTotal += CRM_Utils_Array::value('subTotal', $taxRate); + $subTotal += $taxRate['subTotal'] ?? NULL; } // to email the invoice @@ -299,11 +299,11 @@ public static function printPDF($contribIDs, &$params, $contactIds) { 'confirm_from_email', ]; CRM_Core_DAO::commonRetrieveAll($daoName, 'id', $pageId, $mailDetails, $mailElements); - $values['title'] = CRM_Utils_Array::value('title', $mailDetails[$contribution->_relatedObjects['event']->id]); - $values['confirm_from_name'] = CRM_Utils_Array::value('confirm_from_name', $mailDetails[$contribution->_relatedObjects['event']->id]); - $values['confirm_from_email'] = CRM_Utils_Array::value('confirm_from_email', $mailDetails[$contribution->_relatedObjects['event']->id]); + $values['title'] = $mailDetails[$contribution->_relatedObjects['event']->id]['title'] ?? NULL; + $values['confirm_from_name'] = $mailDetails[$contribution->_relatedObjects['event']->id]['confirm_from_name'] ?? NULL; + $values['confirm_from_email'] = $mailDetails[$contribution->_relatedObjects['event']->id]['confirm_from_email'] ?? NULL; - $title = CRM_Utils_Array::value('title', $mailDetails[$contribution->_relatedObjects['event']->id]); + $title = $mailDetails[$contribution->_relatedObjects['event']->id]['title'] ?? NULL; } elseif ($contribution->_component == 'contribute') { $daoName = 'CRM_Contribute_DAO_ContributionPage'; @@ -414,7 +414,7 @@ public static function printPDF($contribIDs, &$params, $contactIds) { ]; // from email address - $fromEmailAddress = CRM_Utils_Array::value('from_email_address', $params); + $fromEmailAddress = $params['from_email_address'] ?? NULL; // condition to check for download PDF Invoice or email Invoice if ($invoiceElements['createPdf']) { @@ -442,8 +442,8 @@ public static function printPDF($contribIDs, &$params, $contactIds) { $sendTemplateParams['tplParams'] = array_merge($tplParams, ['email_comment' => $invoiceElements['params']['email_comment']]); $sendTemplateParams['from'] = $fromEmailAddress; $sendTemplateParams['toEmail'] = $email; - $sendTemplateParams['cc'] = CRM_Utils_Array::value('cc_receipt', $values); - $sendTemplateParams['bcc'] = CRM_Utils_Array::value('bcc_receipt', $values); + $sendTemplateParams['cc'] = $values['cc_receipt'] ?? NULL; + $sendTemplateParams['bcc'] = $values['bcc_receipt'] ?? NULL; list($sent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams); // functions call for adding activity with attachment @@ -456,8 +456,8 @@ public static function printPDF($contribIDs, &$params, $contactIds) { $sendTemplateParams['tplParams'] = array_merge($tplParams, ['email_comment' => $invoiceElements['params']['email_comment']]); $sendTemplateParams['from'] = $fromEmailAddress; $sendTemplateParams['toEmail'] = $email; - $sendTemplateParams['cc'] = CRM_Utils_Array::value('cc_confirm', $values); - $sendTemplateParams['bcc'] = CRM_Utils_Array::value('bcc_confirm', $values); + $sendTemplateParams['cc'] = $values['cc_confirm'] ?? NULL; + $sendTemplateParams['bcc'] = $values['bcc_confirm'] ?? NULL; list($sent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams); // functions call for adding activity with attachment diff --git a/CRM/Contribute/Form/Task/PDF.php b/CRM/Contribute/Form/Task/PDF.php index 9eea32cd4b44..871aea530bda 100644 --- a/CRM/Contribute/Form/Task/PDF.php +++ b/CRM/Contribute/Form/Task/PDF.php @@ -154,9 +154,9 @@ public function postProcess() { $ids['contribution'] = $contribID; $ids['contributionRecur'] = NULL; $ids['contributionPage'] = NULL; - $ids['membership'] = CRM_Utils_Array::value('membership', $detail); - $ids['participant'] = CRM_Utils_Array::value('participant', $detail); - $ids['event'] = CRM_Utils_Array::value('event', $detail); + $ids['membership'] = $detail['membership'] ?? NULL; + $ids['participant'] = $detail['participant'] ?? NULL; + $ids['event'] = $detail['event'] ?? NULL; if (!$elements['baseIPN']->validateData($input, $ids, $objects, FALSE)) { throw new CRM_Core_Exception('invalid data'); diff --git a/CRM/Contribute/Form/Task/PDFLetter.php b/CRM/Contribute/Form/Task/PDFLetter.php index 5348321f8780..fe602c7fd53c 100644 --- a/CRM/Contribute/Form/Task/PDFLetter.php +++ b/CRM/Contribute/Form/Task/PDFLetter.php @@ -77,7 +77,7 @@ public function setDefaultValues() { if (isset($this->_activityId)) { $params = ['id' => $this->_activityId]; CRM_Activity_BAO_Activity::retrieve($params, $defaults); - $defaults['html_message'] = CRM_Utils_Array::value('details', $defaults); + $defaults['html_message'] = $defaults['details'] ?? NULL; } else { $defaults['thankyou_update'] = 1; diff --git a/CRM/Contribute/Form/Task/PDFLetterCommon.php b/CRM/Contribute/Form/Task/PDFLetterCommon.php index bf30652232ef..8be7d6a80f11 100644 --- a/CRM/Contribute/Form/Task/PDFLetterCommon.php +++ b/CRM/Contribute/Form/Task/PDFLetterCommon.php @@ -258,7 +258,7 @@ public static function buildContributionArray($groupBy, $contributionIDs, $retur $contributions = $contacts = []; foreach ($contributionIDs as $item => $contributionId) { $contribution = CRM_Contribute_BAO_Contribution::getContributionTokenValues($contributionId, $messageToken)['values'][$contributionId]; - $contribution['campaign'] = CRM_Utils_Array::value('contribution_campaign_title', $contribution); + $contribution['campaign'] = $contribution['contribution_campaign_title'] ?? NULL; $contributions[$contributionId] = $contribution; if ($isIncludeSoftCredits) { diff --git a/CRM/Contribute/Form/Task/Status.php b/CRM/Contribute/Form/Task/Status.php index 225d17470b57..816fa6a485bf 100644 --- a/CRM/Contribute/Form/Task/Status.php +++ b/CRM/Contribute/Form/Task/Status.php @@ -210,7 +210,7 @@ public function postProcess() { * @throws \Exception */ public static function processForm($form, $params) { - $statusID = CRM_Utils_Array::value('contribution_status_id', $params); + $statusID = $params['contribution_status_id'] ?? NULL; $baseIPN = new CRM_Core_Payment_BaseIPN(); $transaction = new CRM_Core_Transaction(); @@ -229,9 +229,9 @@ public static function processForm($form, $params) { $ids['contribution'] = $row['contribution_id']; $ids['contributionRecur'] = NULL; $ids['contributionPage'] = NULL; - $ids['membership'] = CRM_Utils_Array::value('membership', $details[$row['contribution_id']]); - $ids['participant'] = CRM_Utils_Array::value('participant', $details[$row['contribution_id']]); - $ids['event'] = CRM_Utils_Array::value('event', $details[$row['contribution_id']]); + $ids['membership'] = $details[$row['contribution_id']]['membership'] ?? NULL; + $ids['participant'] = $details[$row['contribution_id']]['participant'] ?? NULL; + $ids['event'] = $details[$row['contribution_id']]['event'] ?? NULL; if (!$baseIPN->validateData($input, $ids, $objects, FALSE)) { CRM_Core_Error::fatal(); diff --git a/CRM/Contribute/Form/UpdateBilling.php b/CRM/Contribute/Form/UpdateBilling.php index 5b5d97aa8bf3..1370802e5494 100644 --- a/CRM/Contribute/Form/UpdateBilling.php +++ b/CRM/Contribute/Form/UpdateBilling.php @@ -252,7 +252,7 @@ public function postProcess() { // format new address for display $addressParts = array("street_address", "city", "postal_code", "state_province", "country"); foreach ($addressParts as $part) { - $addressParts[$part] = CRM_Utils_Array::value($part, $processorParams); + $addressParts[$part] = $processorParams[$part] ?? NULL; } $tplParams['address'] = CRM_Utils_Address::format($addressParts); @@ -262,7 +262,7 @@ public function postProcess() { $addressParts = array("street_address", "city", "postal_code", "state_province", "country"); foreach ($addressParts as $part) { $key = "{$part}-{$this->_bltID}"; - $addressParts[$part] = CRM_Utils_Array::value($key, $this->_defaults); + $addressParts[$part] = $this->_defaults[$key] ?? NULL; } $this->_defaults['address'] = CRM_Utils_Address::format($addressParts); diff --git a/CRM/Contribute/Import/Form/MapField.php b/CRM/Contribute/Import/Form/MapField.php index 18fd55e9a433..ab286bb7a2ef 100644 --- a/CRM/Contribute/Import/Form/MapField.php +++ b/CRM/Contribute/Import/Form/MapField.php @@ -384,7 +384,7 @@ public static function formRule($fields, $files, $self) { } if (!empty($fields['saveMapping'])) { - $nameField = CRM_Utils_Array::value('saveMappingName', $fields); + $nameField = $fields['saveMappingName'] ?? NULL; if (empty($nameField)) { $errors['saveMappingName'] = ts('Name is required to save Import Mapping'); } diff --git a/CRM/Contribute/Import/Parser/Contribution.php b/CRM/Contribute/Import/Parser/Contribution.php index 9f2bfe6d0d07..cda0249e6564 100644 --- a/CRM/Contribute/Import/Parser/Contribution.php +++ b/CRM/Contribute/Import/Parser/Contribution.php @@ -679,8 +679,8 @@ private function deprecatedFormatParams($params, &$values, $create = FALSE, $onD ) { $customOption = CRM_Core_BAO_CustomOption::getCustomOption($customFieldID, TRUE); foreach ($customOption as $customFldID => $customValue) { - $val = CRM_Utils_Array::value('value', $customValue); - $label = CRM_Utils_Array::value('label', $customValue); + $val = $customValue['value'] ?? NULL; + $label = $customValue['label'] ?? NULL; $label = strtolower($label); $value = strtolower(trim($value)); if (($value == $label) || ($value == strtolower($val))) { @@ -715,9 +715,9 @@ private function deprecatedFormatParams($params, &$values, $create = FALSE, $onD // import contribution record according to select contact type require_once 'CRM/Contact/DAO/Contact.php'; $contactType = new CRM_Contact_DAO_Contact(); - $contactId = CRM_Utils_Array::value('contribution_contact_id', $params); - $externalId = CRM_Utils_Array::value('external_identifier', $params); - $email = CRM_Utils_Array::value('email', $params); + $contactId = $params['contribution_contact_id'] ?? NULL; + $externalId = $params['external_identifier'] ?? NULL; + $email = $params['email'] ?? NULL; //when insert mode check contact id or external identifier if ($contactId || $externalId) { $contactType->id = $contactId; @@ -825,9 +825,9 @@ private function deprecatedFormatParams($params, &$values, $create = FALSE, $onD $value[$key] = $mismatchContactType = $softCreditContactIds = ''; if (isset($params[$key]) && is_array($params[$key])) { foreach ($params[$key] as $softKey => $softParam) { - $contactId = CRM_Utils_Array::value('contact_id', $softParam); - $externalId = CRM_Utils_Array::value('external_identifier', $softParam); - $email = CRM_Utils_Array::value('email', $softParam); + $contactId = $softParam['contact_id'] ?? NULL; + $externalId = $softParam['external_identifier'] ?? NULL; + $email = $softParam['email'] ?? NULL; if ($contactId || $externalId) { require_once 'CRM/Contact/DAO/Contact.php'; $contact = new CRM_Contact_DAO_Contact(); @@ -885,9 +885,9 @@ private function deprecatedFormatParams($params, &$values, $create = FALSE, $onD } // get total amount of from import fields - $totalAmount = CRM_Utils_Array::value('total_amount', $params); + $totalAmount = $params['total_amount'] ?? NULL; - $onDuplicate = CRM_Utils_Array::value('onDuplicate', $params); + $onDuplicate = $params['onDuplicate'] ?? NULL; // we need to get contact id $contributionContactID to // retrieve pledge details as well as to validate pledge ID diff --git a/CRM/Contribute/Page/ContributionPage.php b/CRM/Contribute/Page/ContributionPage.php index 407debb1f52f..8a96c97c4154 100644 --- a/CRM/Contribute/Page/ContributionPage.php +++ b/CRM/Contribute/Page/ContributionPage.php @@ -530,7 +530,7 @@ public function browse($action = NULL) { ); //show campaigns on selector. - $contribution[$dao->id]['campaign'] = CRM_Utils_Array::value($dao->campaign_id, $allCampaigns); + $contribution[$dao->id]['campaign'] = $allCampaigns[$dao->campaign_id] ?? NULL; } if (isset($contribution)) { @@ -689,7 +689,7 @@ public function formatConfigureLinks($sectionsInfo) { // build the formatted configure links. $formattedConfLinks = self::configureActionLinks(); foreach ($formattedConfLinks as $act => & $link) { - $sectionName = CRM_Utils_Array::value('uniqueName', $link); + $sectionName = $link['uniqueName'] ?? NULL; if (!$sectionName) { continue; } diff --git a/CRM/Contribute/Page/Tab.php b/CRM/Contribute/Page/Tab.php index c84e1198b808..0a5a4f67e505 100644 --- a/CRM/Contribute/Page/Tab.php +++ b/CRM/Contribute/Page/Tab.php @@ -194,7 +194,7 @@ private function getActiveRecurringContributions() { 'contribution_status_id' => ['NOT IN' => CRM_Contribute_BAO_ContributionRecur::getInactiveStatuses()], 'options' => ['limit' => 0, 'sort' => 'is_test, start_date DESC'], ]); - $recurContributions = CRM_Utils_Array::value('values', $contributionRecurResult); + $recurContributions = $contributionRecurResult['values'] ?? NULL; } catch (Exception $e) { $recurContributions = []; @@ -216,7 +216,7 @@ private function getInactiveRecurringContributions() { 'contribution_status_id' => ['IN' => CRM_Contribute_BAO_ContributionRecur::getInactiveStatuses()], 'options' => ['limit' => 0, 'sort' => 'is_test, start_date DESC'], ]); - $recurContributions = CRM_Utils_Array::value('values', $contributionRecurResult); + $recurContributions = $contributionRecurResult['values'] ?? NULL; } catch (Exception $e) { $recurContributions = NULL; diff --git a/CRM/Contribute/PseudoConstant.php b/CRM/Contribute/PseudoConstant.php index 1e274e0b7c08..22056cc40abb 100644 --- a/CRM/Contribute/PseudoConstant.php +++ b/CRM/Contribute/PseudoConstant.php @@ -108,7 +108,7 @@ public static function &financialType($id = NULL, $includeDisabled = FALSE) { } if ($id) { - $result = CRM_Utils_Array::value($id, self::$financialType); + $result = self::$financialType[$id] ?? NULL; return $result; } return self::$financialType; @@ -149,7 +149,7 @@ public static function &financialAccount($id = NULL, $financialAccountTypeId = N } if ($id) { - $result = CRM_Utils_Array::value($id, self::$financialAccount[$cacheKey]); + $result = self::$financialAccount[$cacheKey][$id] ?? NULL; return $result; } return self::$financialAccount[$cacheKey]; @@ -197,7 +197,7 @@ public static function &contributionPage($id = NULL, $all = FALSE) { ); } if ($id) { - $pageTitle = CRM_Utils_Array::value($id, $cacheVarToUse); + $pageTitle = $cacheVarToUse[$id] ?? NULL; return $pageTitle; } return $cacheVarToUse; @@ -300,7 +300,7 @@ public static function &contributionStatus($id = NULL, $columnName = 'label') { } $result = self::$contributionStatus[$cacheKey]; if ($id) { - $result = CRM_Utils_Array::value($id, $result); + $result = $result[$id] ?? NULL; } return $result; @@ -331,7 +331,7 @@ public static function &pcPage($pageType = NULL, $id = NULL) { } $result = self::$pcPage[$pageType]; if ($id) { - return $result = CRM_Utils_Array::value($id, $result); + return $result = $result[$id] ?? NULL; } return $result; @@ -412,7 +412,7 @@ public static function &batch($id = NULL) { } if ($id) { - $result = CRM_Utils_Array::value($id, self::$batch); + $result = self::$batch[$id] ?? NULL; return $result; } return self::$batch; diff --git a/CRM/Contribute/Selector/Search.php b/CRM/Contribute/Selector/Search.php index 91e65fbfa125..010d05116d85 100644 --- a/CRM/Contribute/Selector/Search.php +++ b/CRM/Contribute/Selector/Search.php @@ -390,7 +390,7 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { //carry campaign on selectors. // @todo - I can't find any evidence that 'carrying' the campaign on selectors actually // results in it being displayed anywhere so why do we do this??? - $row['campaign'] = CRM_Utils_Array::value($result->contribution_campaign_id, $allCampaigns); + $row['campaign'] = $allCampaigns[$result->contribution_campaign_id] ?? NULL; $row['campaign_id'] = $result->contribution_campaign_id; // add contribution status name diff --git a/CRM/Contribute/StateMachine/Search.php b/CRM/Contribute/StateMachine/Search.php index f73e871b0f4f..86b60a97e0a8 100644 --- a/CRM/Contribute/StateMachine/Search.php +++ b/CRM/Contribute/StateMachine/Search.php @@ -68,7 +68,7 @@ public function __construct($controller, $action = CRM_Core_Action::NONE) { */ public function taskName($controller, $formName = 'Search') { // total hack, check POST vars and then session to determine stuff - $value = CRM_Utils_Array::value('task', $_POST); + $value = $_POST['task'] ?? NULL; if (!isset($value)) { $value = $this->_controller->get('task'); } diff --git a/CRM/Contribute/Task.php b/CRM/Contribute/Task.php index 12c097c0e51b..144768eab72b 100644 --- a/CRM/Contribute/Task.php +++ b/CRM/Contribute/Task.php @@ -113,7 +113,7 @@ public static function tasks() { // remove action "Invoices - print or email" $invoiceSettings = Civi::settings()->get('contribution_invoice_settings'); - $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings); + $invoicing = $invoiceSettings['invoicing'] ?? NULL; if (!$invoicing) { unset(self::$_tasks[self::PDF_INVOICE]); } diff --git a/CRM/Core/Action.php b/CRM/Core/Action.php index 8495b4cea28a..52f7c78cf27b 100644 --- a/CRM/Core/Action.php +++ b/CRM/Core/Action.php @@ -140,7 +140,7 @@ public static function map($item) { * the action mask corresponding to the input string */ public static function mapItem($item) { - $mask = CRM_Utils_Array::value(trim($item), self::$_names); + $mask = self::$_names[trim($item)] ?? NULL; return $mask ? $mask : 0; } diff --git a/CRM/Core/BAO/ActionSchedule.php b/CRM/Core/BAO/ActionSchedule.php index c3d43ac96dc0..976baf3f2368 100644 --- a/CRM/Core/BAO/ActionSchedule.php +++ b/CRM/Core/BAO/ActionSchedule.php @@ -673,7 +673,7 @@ protected static function pickSmsPhoneNumber($smsToContactId) { //to get primary mobile ph,if not get a first mobile phONE if (!empty($toPhoneNumbers)) { $toPhoneNumberDetails = reset($toPhoneNumbers); - $toPhoneNumber = CRM_Utils_Array::value('phone', $toPhoneNumberDetails); + $toPhoneNumber = $toPhoneNumberDetails['phone'] ?? NULL; return $toPhoneNumber; } return NULL; diff --git a/CRM/Core/BAO/Address.php b/CRM/Core/BAO/Address.php index 933d1886826b..47c40fe08df6 100644 --- a/CRM/Core/BAO/Address.php +++ b/CRM/Core/BAO/Address.php @@ -353,7 +353,7 @@ public static function fixAddress(&$params) { unset($params[$fld]); } // main parse string. - $parseString = CRM_Utils_Array::value('street_address', $params); + $parseString = $params['street_address'] ?? NULL; $parsedFields = CRM_Core_BAO_Address::parseStreetAddress($parseString); // merge parse address in to main address block. @@ -450,7 +450,7 @@ public static function &getValues($entityBlock, $microformat = FALSE, $fieldName $address = new CRM_Core_BAO_Address(); if (empty($entityBlock['entity_table'])) { - $address->$fieldName = CRM_Utils_Array::value($fieldName, $entityBlock); + $address->$fieldName = $entityBlock[$fieldName] ?? NULL; } else { $addressIds = []; @@ -490,7 +490,7 @@ public static function &getValues($entityBlock, $microformat = FALSE, $fieldName // add state and country information: CRM-369 if (!empty($address->location_type_id)) { - $values['location_type'] = CRM_Utils_Array::value($address->location_type_id, $locationTypes); + $values['location_type'] = $locationTypes[$address->location_type_id] ?? NULL; } if (!empty($address->state_province_id)) { $address->state = CRM_Core_PseudoConstant::stateProvinceAbbreviation($address->state_province_id, FALSE); @@ -978,8 +978,8 @@ public static function checkContactSharedAddressFields(&$fields, $contactId) { } $nameVal = explode('-', $values['name']); - $fldName = CRM_Utils_Array::value(0, $nameVal); - $locType = CRM_Utils_Array::value(1, $nameVal); + $fldName = $nameVal[0] ?? NULL; + $locType = $nameVal[1] ?? NULL; if (!empty($values['location_type_id'])) { $locType = $values['location_type_id']; } diff --git a/CRM/Core/BAO/Block.php b/CRM/Core/BAO/Block.php index edee3b3d8a4e..49763f282aa7 100644 --- a/CRM/Core/BAO/Block.php +++ b/CRM/Core/BAO/Block.php @@ -231,7 +231,7 @@ public static function create($blockName, &$params, $entity = NULL, $contactId = //get existing block ids. $blockIds = self::getBlockIds($blockName, $contactId, $entityElements); foreach ($params[$blockName] as $count => $value) { - $blockId = CRM_Utils_Array::value('id', $value); + $blockId = $value['id'] ?? NULL; if ($blockId) { if (is_array($blockIds) && array_key_exists($blockId, $blockIds)) { unset($blockIds[$blockId]); @@ -275,13 +275,13 @@ public static function create($blockName, &$params, $entity = NULL, $contactId = if (empty($value['id']) && $blockValue['locationTypeId'] == CRM_Utils_Array::value('location_type_id', $value) && !$isIdSet) { $valueId = FALSE; if ($blockName == 'phone') { - $phoneTypeBlockValue = CRM_Utils_Array::value('phoneTypeId', $blockValue); + $phoneTypeBlockValue = $blockValue['phoneTypeId'] ?? NULL; if ($phoneTypeBlockValue == CRM_Utils_Array::value('phone_type_id', $value)) { $valueId = TRUE; } } elseif ($blockName == 'im') { - $providerBlockValue = CRM_Utils_Array::value('providerId', $blockValue); + $providerBlockValue = $blockValue['providerId'] ?? NULL; if (!empty($value['provider_id']) && $providerBlockValue == $value['provider_id']) { $valueId = TRUE; } @@ -399,7 +399,7 @@ public static function handlePrimary(&$params, $class) { } // contact_id in params might be empty or the string 'null' so cast to integer - $contactId = (int) CRM_Utils_Array::value('contact_id', $params); + $contactId = (int) $params['contact_id'] ?? NULL; // If id is set & we haven't been passed a contact_id, retrieve it if (!empty($params['id']) && !isset($params['contact_id'])) { $entity = new $class(); @@ -474,8 +474,8 @@ public static function sortPrimaryFirst(&$locations) { * @return int */ public static function primaryComparison($location1, $location2) { - $l1 = CRM_Utils_Array::value('is_primary', $location1); - $l2 = CRM_Utils_Array::value('is_primary', $location2); + $l1 = $location1['is_primary'] ?? NULL; + $l2 = $location2['is_primary'] ?? NULL; if ($l1 == $l2) { return 0; } diff --git a/CRM/Core/BAO/CustomField.php b/CRM/Core/BAO/CustomField.php index b0e96ea6654f..bd50263945e3 100644 --- a/CRM/Core/BAO/CustomField.php +++ b/CRM/Core/BAO/CustomField.php @@ -1113,7 +1113,7 @@ private static function formatDisplayValue($value, $field, $entityId = NULL) { elseif (is_array($value)) { $v = []; foreach ($value as $key => $val) { - $v[] = CRM_Utils_Array::value($val, $field['options']); + $v[] = $field['options'][$val] ?? NULL; } $display = implode(', ', $v); } @@ -1130,7 +1130,7 @@ private static function formatDisplayValue($value, $field, $entityId = NULL) { $value = is_array($value) ? CRM_Utils_Array::first($value) : $value; $actualPHPFormats = CRM_Utils_Date::datePluginToPHPFormats(); - $format = CRM_Utils_Array::value('date_format', $field); + $format = $field['date_format'] ?? NULL; if ($format) { if (array_key_exists($format, $actualPHPFormats)) { @@ -1966,8 +1966,8 @@ protected static function prepareCreate($params) { break; } - $htmlType = CRM_Utils_Array::value('html_type', $params); - $dataType = CRM_Utils_Array::value('data_type', $params); + $htmlType = $params['html_type'] ?? NULL; + $dataType = $params['data_type'] ?? NULL; $allowedOptionTypes = ['String', 'Int', 'Float', 'Money']; // create any option group & values if required @@ -2450,7 +2450,7 @@ public static function validateCustomData($params) { //pick up profile fields. $profileFields = []; - $ufGroupId = CRM_Utils_Array::value('ufGroupId', $params); + $ufGroupId = $params['ufGroupId'] ?? NULL; if ($ufGroupId) { $profileFields = CRM_Core_BAO_UFGroup::getFields($ufGroupId, FALSE, @@ -2474,8 +2474,8 @@ public static function validateCustomData($params) { $dataType = $field->data_type; $profileField = CRM_Utils_Array::value($key, $profileFields, []); - $fieldTitle = CRM_Utils_Array::value('title', $profileField); - $isRequired = CRM_Utils_Array::value('is_required', $profileField); + $fieldTitle = $profileField['title'] ?? NULL; + $isRequired = $profileField['is_required'] ?? NULL; if (!$fieldTitle) { $fieldTitle = $field->label; } diff --git a/CRM/Core/BAO/CustomGroup.php b/CRM/Core/BAO/CustomGroup.php index 84144bb16677..bf77e2510680 100644 --- a/CRM/Core/BAO/CustomGroup.php +++ b/CRM/Core/BAO/CustomGroup.php @@ -46,7 +46,7 @@ public static function create(&$params) { } $extends = CRM_Utils_Array::value('extends', $params, []); - $extendsEntity = CRM_Utils_Array::value(0, $extends); + $extendsEntity = $extends[0] ?? NULL; $participantEntities = [ 'ParticipantRole', @@ -68,7 +68,7 @@ public static function create(&$params) { } // this is format when form get submit. - $extendsChildType = CRM_Utils_Array::value(1, $extends); + $extendsChildType = $extends[1] ?? NULL; // lets allow user to pass direct child type value, CRM-6893 if (!empty($params['extends_entity_column_value'])) { $extendsChildType = $params['extends_entity_column_value']; @@ -144,8 +144,8 @@ public static function create(&$params) { } } else { - $group->created_id = CRM_Utils_Array::value('created_id', $params); - $group->created_date = CRM_Utils_Array::value('created_date', $params); + $group->created_id = $params['created_id'] ?? NULL; + $group->created_date = $params['created_date'] ?? NULL; // we do this only once, so name never changes if (isset($params['name'])) { @@ -1556,7 +1556,7 @@ public static function buildQuickForm(&$form, &$groupTree, $inactiveNeeded = FAL foreach ($groupTree as $id => $group) { CRM_Core_ShowHideBlocks::links($form, $group['title'], '', ''); foreach ($group['fields'] as $field) { - $required = CRM_Utils_Array::value('is_required', $field); + $required = $field['is_required'] ?? NULL; //fix for CRM-1620 if ($field['data_type'] == 'File') { if (!empty($field['element_value']['data'])) { @@ -1815,21 +1815,21 @@ public static function formatGroupTree(&$groupTree, $groupCount = 1, &$form = NU } // add group information - $formattedGroupTree[$key]['name'] = CRM_Utils_Array::value('name', $value); - $formattedGroupTree[$key]['title'] = CRM_Utils_Array::value('title', $value); - $formattedGroupTree[$key]['help_pre'] = CRM_Utils_Array::value('help_pre', $value); - $formattedGroupTree[$key]['help_post'] = CRM_Utils_Array::value('help_post', $value); - $formattedGroupTree[$key]['collapse_display'] = CRM_Utils_Array::value('collapse_display', $value); - $formattedGroupTree[$key]['collapse_adv_display'] = CRM_Utils_Array::value('collapse_adv_display', $value); - $formattedGroupTree[$key]['style'] = CRM_Utils_Array::value('style', $value); + $formattedGroupTree[$key]['name'] = $value['name'] ?? NULL; + $formattedGroupTree[$key]['title'] = $value['title'] ?? NULL; + $formattedGroupTree[$key]['help_pre'] = $value['help_pre'] ?? NULL; + $formattedGroupTree[$key]['help_post'] = $value['help_post'] ?? NULL; + $formattedGroupTree[$key]['collapse_display'] = $value['collapse_display'] ?? NULL; + $formattedGroupTree[$key]['collapse_adv_display'] = $value['collapse_adv_display'] ?? NULL; + $formattedGroupTree[$key]['style'] = $value['style'] ?? NULL; // this params needed of bulding multiple values - $formattedGroupTree[$key]['is_multiple'] = CRM_Utils_Array::value('is_multiple', $value); - $formattedGroupTree[$key]['extends'] = CRM_Utils_Array::value('extends', $value); - $formattedGroupTree[$key]['extends_entity_column_id'] = CRM_Utils_Array::value('extends_entity_column_id', $value); - $formattedGroupTree[$key]['extends_entity_column_value'] = CRM_Utils_Array::value('extends_entity_column_value', $value); - $formattedGroupTree[$key]['subtype'] = CRM_Utils_Array::value('subtype', $value); - $formattedGroupTree[$key]['max_multiple'] = CRM_Utils_Array::value('max_multiple', $value); + $formattedGroupTree[$key]['is_multiple'] = $value['is_multiple'] ?? NULL; + $formattedGroupTree[$key]['extends'] = $value['extends'] ?? NULL; + $formattedGroupTree[$key]['extends_entity_column_id'] = $value['extends_entity_column_id'] ?? NULL; + $formattedGroupTree[$key]['extends_entity_column_value'] = $value['extends_entity_column_value'] ?? NULL; + $formattedGroupTree[$key]['subtype'] = $value['subtype'] ?? NULL; + $formattedGroupTree[$key]['max_multiple'] = $value['max_multiple'] ?? NULL; // add field information foreach ($value['fields'] as $k => $properties) { @@ -1910,13 +1910,13 @@ public static function buildCustomDataView(&$form, &$groupTree, $returnCount = F if (!empty($customValueId) && $customValueId != $values['id']) { continue; } - $details[$groupID][$values['id']]['title'] = CRM_Utils_Array::value('title', $group); - $details[$groupID][$values['id']]['name'] = CRM_Utils_Array::value('name', $group); - $details[$groupID][$values['id']]['help_pre'] = CRM_Utils_Array::value('help_pre', $group); - $details[$groupID][$values['id']]['help_post'] = CRM_Utils_Array::value('help_post', $group); - $details[$groupID][$values['id']]['collapse_display'] = CRM_Utils_Array::value('collapse_display', $group); - $details[$groupID][$values['id']]['collapse_adv_display'] = CRM_Utils_Array::value('collapse_adv_display', $group); - $details[$groupID][$values['id']]['style'] = CRM_Utils_Array::value('style', $group); + $details[$groupID][$values['id']]['title'] = $group['title'] ?? NULL; + $details[$groupID][$values['id']]['name'] = $group['name'] ?? NULL; + $details[$groupID][$values['id']]['help_pre'] = $group['help_pre'] ?? NULL; + $details[$groupID][$values['id']]['help_post'] = $group['help_post'] ?? NULL; + $details[$groupID][$values['id']]['collapse_display'] = $group['collapse_display'] ?? NULL; + $details[$groupID][$values['id']]['collapse_adv_display'] = $group['collapse_adv_display'] ?? NULL; + $details[$groupID][$values['id']]['style'] = $group['style'] ?? NULL; $details[$groupID][$values['id']]['fields'][$k] = [ 'field_title' => $properties['label'] ?? NULL, 'field_type' => $properties['html_type'] ?? NULL, @@ -1938,18 +1938,18 @@ public static function buildCustomDataView(&$form, &$groupTree, $returnCount = F $details[$groupID][$values['id']]['fields'][$k]['field_data_type'] == 'ContactReference' ) { - $details[$groupID][$values['id']]['fields'][$k]['contact_ref_id'] = CRM_Utils_Array::value('data', $values); + $details[$groupID][$values['id']]['fields'][$k]['contact_ref_id'] = $values['data'] ?? NULL; } } } else { - $details[$groupID][0]['title'] = CRM_Utils_Array::value('title', $group); - $details[$groupID][0]['name'] = CRM_Utils_Array::value('name', $group); - $details[$groupID][0]['help_pre'] = CRM_Utils_Array::value('help_pre', $group); - $details[$groupID][0]['help_post'] = CRM_Utils_Array::value('help_post', $group); - $details[$groupID][0]['collapse_display'] = CRM_Utils_Array::value('collapse_display', $group); - $details[$groupID][0]['collapse_adv_display'] = CRM_Utils_Array::value('collapse_adv_display', $group); - $details[$groupID][0]['style'] = CRM_Utils_Array::value('style', $group); + $details[$groupID][0]['title'] = $group['title'] ?? NULL; + $details[$groupID][0]['name'] = $group['name'] ?? NULL; + $details[$groupID][0]['help_pre'] = $group['help_pre'] ?? NULL; + $details[$groupID][0]['help_post'] = $group['help_post'] ?? NULL; + $details[$groupID][0]['collapse_display'] = $group['collapse_display'] ?? NULL; + $details[$groupID][0]['collapse_adv_display'] = $group['collapse_adv_display'] ?? NULL; + $details[$groupID][0]['style'] = $group['style'] ?? NULL; $details[$groupID][0]['fields'][$k] = ['field_title' => CRM_Utils_Array::value('label', $properties)]; } } diff --git a/CRM/Core/BAO/CustomValueTable.php b/CRM/Core/BAO/CustomValueTable.php index 6eed0a67f7c0..a34c49784baa 100644 --- a/CRM/Core/BAO/CustomValueTable.php +++ b/CRM/Core/BAO/CustomValueTable.php @@ -92,7 +92,7 @@ public static function create($customParams, $parentOperation = NULL) { CRM_Core_PseudoConstant::stateProvinceAbbreviation(), TRUE ); } - $validStates[] = CRM_Utils_Array::value('state_province_id', $states); + $validStates[] = $states['state_province_id'] ?? NULL; } $value = implode(CRM_Core_DAO::VALUE_SEPARATOR, $validStates @@ -132,7 +132,7 @@ public static function create($customParams, $parentOperation = NULL) { CRM_Core_PseudoConstant::countryIsoCode(), TRUE ); } - $validCountries[] = CRM_Utils_Array::value('country_id', $countries); + $validCountries[] = $countries['country_id'] ?? NULL; } $value = implode(CRM_Core_DAO::VALUE_SEPARATOR, $validCountries @@ -217,7 +217,7 @@ public static function create($customParams, $parentOperation = NULL) { $count++; } - $fieldExtends = CRM_Utils_Array::value('extends', $field); + $fieldExtends = $field['extends'] ?? NULL; if ( CRM_Utils_Array::value('entity_table', $field) == 'civicrm_contact' || $fieldExtends == 'Contact' @@ -225,7 +225,7 @@ public static function create($customParams, $parentOperation = NULL) { || $fieldExtends == 'Organization' || $fieldExtends == 'Household' ) { - $paramFieldsExtendContactForEntities[$entityID]['custom_' . CRM_Utils_Array::value('custom_field_id', $field)] = CRM_Utils_Array::value('custom_field_id', $field); + $paramFieldsExtendContactForEntities[$entityID]['custom_' . CRM_Utils_Array::value('custom_field_id', $field)] = $field['custom_field_id'] ?? NULL; } } diff --git a/CRM/Core/BAO/Dashboard.php b/CRM/Core/BAO/Dashboard.php index a6388e15c24a..e11e507ef46b 100644 --- a/CRM/Core/BAO/Dashboard.php +++ b/CRM/Core/BAO/Dashboard.php @@ -387,7 +387,7 @@ public static function saveDashletChanges($columns, $contactID = NULL) { public static function addDashlet(&$params) { // special case to handle duplicate entries for report instances - $dashboardID = CRM_Utils_Array::value('id', $params); + $dashboardID = $params['id'] ?? NULL; if (!empty($params['instanceURL'])) { $query = "SELECT id @@ -405,16 +405,16 @@ public static function addDashlet(&$params) { $dashlet->domain_id = CRM_Core_Config::domainID(); } else { - $dashlet->domain_id = CRM_Utils_Array::value('domain_id', $params); + $dashlet->domain_id = $params['domain_id'] ?? NULL; } // Try and find an existing dashlet - it will be updated if found. if (!empty($params['name'])) { - $dashlet->name = CRM_Utils_Array::value('name', $params); + $dashlet->name = $params['name'] ?? NULL; $dashlet->find(TRUE); } else { - $dashlet->url = CRM_Utils_Array::value('url', $params); + $dashlet->url = $params['url'] ?? NULL; $dashlet->find(TRUE); } @@ -494,8 +494,8 @@ public static function addContactDashletToDashboard(&$params) { $valuesString = NULL; $columns = []; foreach ($params as $dashboardIDs) { - $contactID = CRM_Utils_Array::value('contact_id', $dashboardIDs); - $dashboardID = CRM_Utils_Array::value('dashboard_id', $dashboardIDs); + $contactID = $dashboardIDs['contact_id'] ?? NULL; + $dashboardID = $dashboardIDs['dashboard_id'] ?? NULL; $column = CRM_Utils_Array::value('column_no', $dashboardIDs, 0); $columns[$column][$dashboardID] = 0; } diff --git a/CRM/Core/BAO/Domain.php b/CRM/Core/BAO/Domain.php index 8cf1de41a122..c9bdb689ea9c 100644 --- a/CRM/Core/BAO/Domain.php +++ b/CRM/Core/BAO/Domain.php @@ -170,7 +170,7 @@ public static function getNameAndEmail($skipFatal = FALSE, $returnString = FALSE foreach ($fromEmailAddress as $key => $value) { $email = CRM_Utils_Mail::pluckEmailFromHeader($value); $fromArray = explode('"', $value); - $fromName = CRM_Utils_Array::value(1, $fromArray); + $fromName = $fromArray[1] ?? NULL; break; } return [$fromName, $email]; diff --git a/CRM/Core/BAO/File.php b/CRM/Core/BAO/File.php index 0d34aaaf0029..3e78e3ffeaa9 100644 --- a/CRM/Core/BAO/File.php +++ b/CRM/Core/BAO/File.php @@ -805,8 +805,8 @@ public static function generateFileHash($entityId = NULL, $fileId = NULL, $genTs */ public static function validateFileHash($hash, $entityId, $fileId) { $input = CRM_Utils_System::explode('_', $hash, 3); - $inputTs = CRM_Utils_Array::value(1, $input); - $inputLF = CRM_Utils_Array::value(2, $input); + $inputTs = $input[1] ?? NULL; + $inputLF = $input[2] ?? NULL; $testHash = CRM_Core_BAO_File::generateFileHash($entityId, $fileId, $inputTs, $inputLF); if (hash_equals($testHash, $hash)) { $now = time(); diff --git a/CRM/Core/BAO/FinancialTrxn.php b/CRM/Core/BAO/FinancialTrxn.php index 4ab15a1d23e2..49c165cf3f85 100644 --- a/CRM/Core/BAO/FinancialTrxn.php +++ b/CRM/Core/BAO/FinancialTrxn.php @@ -667,7 +667,7 @@ public static function updateCreditCardDetails($contributionID, $panTruncation, } $financialTrxn = $financialTrxn['values'][$financialTrxn['id']]; - $paymentProcessorID = CRM_Utils_Array::value('financial_trxn_id.payment_processor_id', $financialTrxn); + $paymentProcessorID = $financialTrxn['financial_trxn_id.payment_processor_id'] ?? NULL; if ($paymentProcessorID) { return NULL; @@ -696,7 +696,7 @@ public static function updateFinancialAccountsOnPaymentInstrumentChange($inputPa // ensure that there are all the information in updated contribution object identified by $currentContribution $currentContribution->find(TRUE); - $deferredFinancialAccount = CRM_Utils_Array::value('deferred_financial_account_id', $inputParams); + $deferredFinancialAccount = $inputParams['deferred_financial_account_id'] ?? NULL; if (empty($deferredFinancialAccount)) { $deferredFinancialAccount = CRM_Contribute_PseudoConstant::getRelationalFinancialAccount($prevContribution->financial_type_id, 'Deferred Revenue Account is'); } diff --git a/CRM/Core/BAO/Mapping.php b/CRM/Core/BAO/Mapping.php index b82a0c5dbb34..cb5f89a6cdfb 100644 --- a/CRM/Core/BAO/Mapping.php +++ b/CRM/Core/BAO/Mapping.php @@ -795,16 +795,16 @@ public static function getMappingParams($defaults, $v) { $locationTypeId = NULL; $saveMappingFields = $defaults; - $saveMappingFields['name'] = CRM_Utils_Array::value('1', $v); - $saveMappingFields['contact_type'] = CRM_Utils_Array::value('0', $v); - $locationId = CRM_Utils_Array::value('2', $v); + $saveMappingFields['name'] = $v['1'] ?? NULL; + $saveMappingFields['contact_type'] = $v['0'] ?? NULL; + $locationId = $v['2'] ?? NULL; $saveMappingFields['location_type_id'] = is_numeric($locationId) ? $locationId : NULL; if ($v[1] == 'phone') { - $saveMappingFields['phone_type_id'] = CRM_Utils_Array::value('3', $v); + $saveMappingFields['phone_type_id'] = $v['3'] ?? NULL; } elseif ($v[1] == 'im') { - $saveMappingFields['im_provider_id'] = CRM_Utils_Array::value('3', $v); + $saveMappingFields['im_provider_id'] = $v['3'] ?? NULL; } // Handle mapping for 'related contact' fields @@ -813,17 +813,17 @@ public static function getMappingParams($defaults, $v) { if (($first == 'a' && $second == 'b') || ($first == 'b' && $second == 'a')) { if (!empty($v['2'])) { - $saveMappingFields['name'] = CRM_Utils_Array::value('2', $v); + $saveMappingFields['name'] = $v['2'] ?? NULL; } elseif (!empty($v['4'])) { - $saveMappingFields['name'] = CRM_Utils_Array::value('4', $v); + $saveMappingFields['name'] = $v['4'] ?? NULL; } if (is_numeric(CRM_Utils_Array::value('3', $v))) { - $locationTypeId = CRM_Utils_Array::value('3', $v); + $locationTypeId = $v['3'] ?? NULL; } elseif (is_numeric(CRM_Utils_Array::value('5', $v))) { - $locationTypeId = CRM_Utils_Array::value('5', $v); + $locationTypeId = $v['5'] ?? NULL; } if (is_numeric(CRM_Utils_Array::value('4', $v))) { @@ -831,11 +831,11 @@ public static function getMappingParams($defaults, $v) { $saveMappingFields['im_provider_id'] = $v[4]; } else { - $saveMappingFields['phone_type_id'] = CRM_Utils_Array::value('4', $v); + $saveMappingFields['phone_type_id'] = $v['4'] ?? NULL; } } elseif (is_numeric(CRM_Utils_Array::value('6', $v))) { - $saveMappingFields['phone_type_id'] = CRM_Utils_Array::value('6', $v); + $saveMappingFields['phone_type_id'] = $v['6'] ?? NULL; } $saveMappingFields['location_type_id'] = is_numeric($locationTypeId) ? $locationTypeId : NULL; @@ -940,11 +940,11 @@ protected static function loadSavedMapping($mappingLocation, int $x, int $i, $ma $jsSet = TRUE; if (CRM_Utils_Array::value($i, CRM_Utils_Array::value($x, $mappingOperator))) { - $defaults["operator[$x][$i]"] = CRM_Utils_Array::value($i, $mappingOperator[$x]); + $defaults["operator[$x][$i]"] = $mappingOperator[$x][$i] ?? NULL; } if (CRM_Utils_Array::value($i, CRM_Utils_Array::value($x, $mappingValue))) { - $defaults["value[$x][$i]"] = CRM_Utils_Array::value($i, $mappingValue[$x]); + $defaults["value[$x][$i]"] = $mappingValue[$x][$i] ?? NULL; } } } @@ -1024,12 +1024,12 @@ public static function formattedFields(&$params, $row = FALSE) { } if (!empty($v['1'])) { $fldName = $v[1]; - $v2 = CRM_Utils_Array::value('2', $v); + $v2 = $v['2'] ?? NULL; if ($v2 && trim($v2)) { $fldName .= "-{$v[2]}"; } - $v3 = CRM_Utils_Array::value('3', $v); + $v3 = $v['3'] ?? NULL; if ($v3 && trim($v3)) { $fldName .= "-{$v[3]}"; } diff --git a/CRM/Core/BAO/MessageTemplate.php b/CRM/Core/BAO/MessageTemplate.php index 7f9ca16c5a89..97db7c3bb677 100644 --- a/CRM/Core/BAO/MessageTemplate.php +++ b/CRM/Core/BAO/MessageTemplate.php @@ -453,7 +453,7 @@ public static function sendTemplate($params) { CRM_Utils_Hook::tokens($hookTokens); $categories = array_keys($hookTokens); - $contactID = CRM_Utils_Array::value('contactId', $params); + $contactID = $params['contactId'] ?? NULL; if ($contactID) { $contactParams = ['contact_id' => $contactID]; diff --git a/CRM/Core/BAO/Navigation.php b/CRM/Core/BAO/Navigation.php index 755d70826706..43391cf4d89c 100644 --- a/CRM/Core/BAO/Navigation.php +++ b/CRM/Core/BAO/Navigation.php @@ -366,7 +366,7 @@ private static function _fixNavigationMenu(&$nodes, &$maxNavID, $parentID) { public static function checkPermission($item) { if (!empty($item['permission'])) { $permissions = explode(',', $item['permission']); - $operator = CRM_Utils_Array::value('operator', $item); + $operator = $item['operator'] ?? NULL; $hasPermission = FALSE; foreach ($permissions as $key) { $key = trim($key); @@ -486,7 +486,7 @@ public static function processNavigation(&$params) { $referenceID = (int) str_replace("node_", "", $params['ref_id']); $position = $params['ps']; $type = $params['type']; - $label = CRM_Utils_Array::value('data', $params); + $label = $params['data'] ?? NULL; switch ($type) { case "move": diff --git a/CRM/Core/BAO/RecurringEntity.php b/CRM/Core/BAO/RecurringEntity.php index 3d4f823a3c77..9c6a73513af4 100644 --- a/CRM/Core/BAO/RecurringEntity.php +++ b/CRM/Core/BAO/RecurringEntity.php @@ -319,7 +319,7 @@ public function generateRecursiveDates() { $recursionDates = []; if (is_a($this->recursion, 'When\When')) { - $initialCount = CRM_Utils_Array::value('start_action_offset', $this->schedule); + $initialCount = $this->schedule['start_action_offset'] ?? NULL; $exRangeStart = $exRangeEnd = NULL; if (!empty($this->excludeDateRangeColumns)) { @@ -894,7 +894,7 @@ public function mapFormValuesToDB($formParams = []) { //For Repeats on:(weekly case) if ($formParams['repetition_frequency_unit'] == 'week') { if (!empty($formParams['start_action_condition'])) { - $repeats_on = CRM_Utils_Array::value('start_action_condition', $formParams); + $repeats_on = $formParams['start_action_condition'] ?? NULL; $dbParams['start_action_condition'] = implode(",", array_keys($repeats_on)); } } diff --git a/CRM/Core/BAO/SchemaHandler.php b/CRM/Core/BAO/SchemaHandler.php index 2f3f70241e07..5182085640dc 100644 --- a/CRM/Core/BAO/SchemaHandler.php +++ b/CRM/Core/BAO/SchemaHandler.php @@ -266,7 +266,7 @@ public static function buildForeignKeySQL($params, $separator, $prefix, $tableNa } $sql .= "CONSTRAINT FK_$fkName FOREIGN KEY ( `{$params['name']}` ) REFERENCES {$params['fk_table_name']} ( {$params['fk_field_name']} ) "; - $sql .= CRM_Utils_Array::value('fk_attributes', $params); + $sql .= $params['fk_attributes'] ?? NULL; } return $sql; } diff --git a/CRM/Core/BAO/Setting.php b/CRM/Core/BAO/Setting.php index 225f44926af3..7518e37dc2fd 100644 --- a/CRM/Core/BAO/Setting.php +++ b/CRM/Core/BAO/Setting.php @@ -110,7 +110,7 @@ public static function getItems(&$params, $domains = NULL, $settingsToReturn) { foreach ($domains as $domainID) { $result[$domainID] = []; foreach ($fieldsToGet as $name => $value) { - $contactID = CRM_Utils_Array::value('contact_id', $params); + $contactID = $params['contact_id'] ?? NULL; $setting = CRM_Core_BAO_Setting::getItem(NULL, $name, NULL, NULL, $contactID, $domainID); if (!is_null($setting)) { // we won't return if not set - helps in return all scenario - otherwise we can't indentify the missing ones diff --git a/CRM/Core/BAO/UFField.php b/CRM/Core/BAO/UFField.php index aaec9715eca4..2e1a4dc56d8a 100644 --- a/CRM/Core/BAO/UFField.php +++ b/CRM/Core/BAO/UFField.php @@ -37,7 +37,7 @@ class CRM_Core_BAO_UFField extends CRM_Core_DAO_UFField { * @throws \API_Exception */ public static function create($params) { - $id = CRM_Utils_Array::value('id', $params); + $id = $params['id'] ?? NULL; $op = empty($id) ? 'create' : 'edit'; CRM_Utils_Hook::pre('UFField', $op, $id, $params); @@ -180,18 +180,18 @@ public static function del($id) { */ public static function duplicateField($params) { $ufField = new CRM_Core_DAO_UFField(); - $ufField->uf_group_id = CRM_Utils_Array::value('uf_group_id', $params); - $ufField->field_type = CRM_Utils_Array::value('field_type', $params); - $ufField->field_name = CRM_Utils_Array::value('field_name', $params); - $ufField->website_type_id = CRM_Utils_Array::value('website_type_id', $params); + $ufField->uf_group_id = $params['uf_group_id'] ?? NULL; + $ufField->field_type = $params['field_type'] ?? NULL; + $ufField->field_name = $params['field_name'] ?? NULL; + $ufField->website_type_id = $params['website_type_id'] ?? NULL; if (is_null(CRM_Utils_Array::value('location_type_id', $params, ''))) { // primary location type have NULL value in DB $ufField->whereAdd("location_type_id IS NULL"); } else { - $ufField->location_type_id = CRM_Utils_Array::value('location_type_id', $params); + $ufField->location_type_id = $params['location_type_id'] ?? NULL; } - $ufField->phone_type_id = CRM_Utils_Array::value('phone_type_id', $params); + $ufField->phone_type_id = $params['phone_type_id'] ?? NULL; if (!empty($params['id'])) { $ufField->whereAdd("id <> " . $params['id']); diff --git a/CRM/Core/BAO/UFGroup.php b/CRM/Core/BAO/UFGroup.php index 4fad6876a891..e885dbcb232d 100644 --- a/CRM/Core/BAO/UFGroup.php +++ b/CRM/Core/BAO/UFGroup.php @@ -69,7 +69,7 @@ public static function getContactType($id) { $cType = $type; } elseif (array_key_exists($type, $validSubTypes)) { - $cType = CRM_Utils_Array::value('parent', $validSubTypes[$type]); + $cType = $validSubTypes[$type]['parent'] ?? NULL; } if ($cType) { break; @@ -932,7 +932,7 @@ public static function getEditHTML( if (!empty($_POST)) { // get the new email $config = CRM_Core_Config::singleton(); - $email = CRM_Utils_Array::value('mail', $_POST); + $email = $_POST['mail'] ?? NULL; if (CRM_Utils_Rule::email($email) && ($email != $userEmail[1])) { CRM_Core_BAO_UFMatch::updateContactEmail($userID, $email); @@ -1115,7 +1115,7 @@ public static function getValues( // field_type is only set when we are retrieving profile values // when sending email, we call the same function to get custom field // values etc, i.e. emulating a profile - $fieldType = CRM_Utils_Array::value('field_type', $field); + $fieldType = $field['field_type'] ?? NULL; if ($htmlType == 'File') { $entityId = $cid; @@ -1218,7 +1218,7 @@ public static function getValues( $locationTypeName = 1; } else { - $locationTypeName = CRM_Utils_Array::value($id, $locationTypes); + $locationTypeName = $locationTypes[$id] ?? NULL; } if (!$locationTypeName) { @@ -1448,8 +1448,8 @@ public static function add(&$params, $ids = []) { $params[$field] = CRM_Utils_Array::value($field, $params, FALSE); } - $params['limit_listings_group_id'] = CRM_Utils_Array::value('group', $params); - $params['add_to_group_id'] = CRM_Utils_Array::value('add_contact_to_group', $params); + $params['limit_listings_group_id'] = $params['group'] ?? NULL; + $params['add_to_group_id'] = $params['add_contact_to_group'] ?? NULL; //CRM-15427 if (!empty($params['group_type']) && is_array($params['group_type'])) { @@ -1965,7 +1965,7 @@ public static function buildProfile( ], $required); } elseif ($fieldName === 'contact_sub_type') { - $gId = $form->get('gid') ? $form->get('gid') : CRM_Utils_Array::value('group_id', $field); + $gId = $form->get('gid') ? $form->get('gid') : $field['group_id'] ?? NULL; if ($usedFor == 'onbehalf') { $profileType = 'Organization'; } @@ -1999,7 +1999,7 @@ public static function buildProfile( } elseif (in_array($fieldName, CRM_Contact_BAO_Contact::$_greetingTypes)) { // Get contact type for greeting selector - $gId = $form->get('gid') ?: CRM_Utils_Array::value('group_id', $field); + $gId = $form->get('gid') ?: $field['group_id'] ?? NULL; $profileType = CRM_Core_BAO_UFField::getProfileType($gId, TRUE, FALSE, TRUE); if (!$profileType || in_array($profileType, ['Contact', 'Contribution', 'Participant', 'Membership'])) { @@ -2288,7 +2288,7 @@ public static function setProfileDefaults( if (!$componentId) { //get the contact details $contactDetails = CRM_Contact_BAO_Contact::getHierContactDetails($contactId, $fields); - $details = CRM_Utils_Array::value($contactId, $contactDetails); + $details = $contactDetails[$contactId] ?? NULL; $multipleFields = ['website' => 'url']; //start of code to set the default values @@ -2397,7 +2397,7 @@ public static function setProfileDefaults( } } else { - $phoneDefault = CRM_Utils_Array::value('phone', $value); + $phoneDefault = $value['phone'] ?? NULL; // CRM-9216 if (!is_array($phoneDefault)) { $defaults[$fldName] = $phoneDefault; @@ -2440,7 +2440,7 @@ public static function setProfileDefaults( && !empty($details['website']) && !empty($details['website'][$locTypeId]) ) { - $defaults[$fldName] = CRM_Utils_Array::value('url', $details['website'][$locTypeId]); + $defaults[$fldName] = $details['website'][$locTypeId]['url'] ?? NULL; } } } diff --git a/CRM/Core/BAO/UFJoin.php b/CRM/Core/BAO/UFJoin.php index caffd2c500cd..f9850e515a02 100644 --- a/CRM/Core/BAO/UFJoin.php +++ b/CRM/Core/BAO/UFJoin.php @@ -53,9 +53,9 @@ public static function &create($params) { * @param array $params */ public static function deleteAll(&$params) { - $module = CRM_Utils_Array::value('module', $params); - $entityTable = CRM_Utils_Array::value('entity_table', $params); - $entityID = CRM_Utils_Array::value('entity_id', $params); + $module = $params['module'] ?? NULL; + $entityTable = $params['entity_table'] ?? NULL; + $entityID = $params['entity_id'] ?? NULL; if (empty($entityTable) || empty($entityID) || @@ -90,10 +90,10 @@ public static function findJoinEntryId(&$params) { // CRM-4377 (ab)uses the module column if (isset($params['module'])) { - $dao->module = CRM_Utils_Array::value('module', $params); + $dao->module = $params['module'] ?? NULL; } - $dao->entity_table = CRM_Utils_Array::value('entity_table', $params); - $dao->entity_id = CRM_Utils_Array::value('entity_id', $params); + $dao->entity_table = $params['entity_table'] ?? NULL; + $dao->entity_id = $params['entity_id'] ?? NULL; // user reg / my account can have multiple entries, so we return if thats // the case. (since entity_table/id is empty in those cases if (!$dao->entity_table || @@ -101,7 +101,7 @@ public static function findJoinEntryId(&$params) { ) { return NULL; } - $dao->weight = CRM_Utils_Array::value('weight', $params); + $dao->weight = $params['weight'] ?? NULL; if ($dao->find(TRUE)) { return $dao->id; } @@ -122,10 +122,10 @@ public static function findUFGroupId(&$params) { $dao = new CRM_Core_DAO_UFJoin(); - $dao->entity_table = CRM_Utils_Array::value('entity_table', $params); - $dao->entity_id = CRM_Utils_Array::value('entity_id', $params); - $dao->weight = CRM_Utils_Array::value('weight', $params); - $dao->module = CRM_Utils_Array::value('module', $params); + $dao->entity_table = $params['entity_table'] ?? NULL; + $dao->entity_id = $params['entity_id'] ?? NULL; + $dao->weight = $params['weight'] ?? NULL; + $dao->module = $params['module'] ?? NULL; if ($dao->find(TRUE)) { return $dao->uf_group_id; } @@ -143,10 +143,10 @@ public static function getUFGroupIds(&$params) { // CRM-4377 (ab)uses the module column if (isset($params['module'])) { - $dao->module = CRM_Utils_Array::value('module', $params); + $dao->module = $params['module'] ?? NULL; } - $dao->entity_table = CRM_Utils_Array::value('entity_table', $params); - $dao->entity_id = CRM_Utils_Array::value('entity_id', $params); + $dao->entity_table = $params['entity_table'] ?? NULL; + $dao->entity_id = $params['entity_id'] ?? NULL; $dao->orderBy('weight asc'); $dao->find(); $first = $firstActive = NULL; diff --git a/CRM/Core/BAO/Website.php b/CRM/Core/BAO/Website.php index 4c008b4b38b1..dadea5710cc2 100644 --- a/CRM/Core/BAO/Website.php +++ b/CRM/Core/BAO/Website.php @@ -83,7 +83,7 @@ public static function process($params, $contactID, $skipDelete) { $ids = self::allWebsites($contactID); foreach ($params as $key => $values) { - $id = CRM_Utils_Array::value('id', $values); + $id = $values['id'] ?? NULL; if (array_key_exists($id, $ids)) { unset($ids[$id]); } diff --git a/CRM/Core/Block.php b/CRM/Core/Block.php index f624810dda16..74aaa4a97e02 100644 --- a/CRM/Core/Block.php +++ b/CRM/Core/Block.php @@ -477,7 +477,7 @@ private static function setTemplateDashboardValues() { $value['url'] = CRM_Utils_System::url($dash['path'], $dash['query'], FALSE); } $value['title'] = $dash['title']; - $value['key'] = CRM_Utils_Array::value('key', $dash); + $value['key'] = $dash['key'] ?? NULL; $values[] = $value; } self::setProperty(self::DASHBOARD, 'templateValues', array('dashboardLinks' => $values)); diff --git a/CRM/Core/Config.php b/CRM/Core/Config.php index 4025c5d5ac86..2b4623ef5128 100644 --- a/CRM/Core/Config.php +++ b/CRM/Core/Config.php @@ -421,7 +421,7 @@ public static function isUpgradeMode($path = NULL) { $urlVar = 'task'; } - $path = CRM_Utils_Array::value($urlVar, $_GET); + $path = $_GET[$urlVar] ?? NULL; } if ($path && preg_match('/^civicrm\/upgrade(\/.*)?$/', $path)) { diff --git a/CRM/Core/Controller.php b/CRM/Core/Controller.php index 8cdb5a2d5226..8bfbc6de4c60 100644 --- a/CRM/Core/Controller.php +++ b/CRM/Core/Controller.php @@ -208,7 +208,7 @@ public function __construct( parent::__construct($name, $modal); - $snippet = CRM_Utils_Array::value('snippet', $_REQUEST); + $snippet = $_REQUEST['snippet'] ?? NULL; if ($snippet) { if ($snippet == 3) { $this->_print = CRM_Core_Smarty::PRINT_PDF; @@ -284,7 +284,7 @@ public function key($name, $addSequence = FALSE, $ignoreKey = FALSE) { return NULL; } - $key = CRM_Utils_Array::value('qfKey', $_REQUEST, NULL); + $key = $_REQUEST['qfKey'] ?? NULL; if (!$key && $_SERVER['REQUEST_METHOD'] === 'GET') { $key = CRM_Core_Key::get($name, $addSequence); } @@ -417,8 +417,8 @@ public function addPages(&$stateMachine, $action = CRM_Core_Action::NONE) { $pages = $stateMachine->getPages(); foreach ($pages as $name => $value) { $className = CRM_Utils_Array::value('className', $value, $name); - $title = CRM_Utils_Array::value('title', $value); - $options = CRM_Utils_Array::value('options', $value); + $title = $value['title'] ?? NULL; + $options = $value['options'] ?? NULL; $stateName = CRM_Utils_String::getClassName($className); if (!empty($value['className'])) { $formName = $name; diff --git a/CRM/Core/DAO.php b/CRM/Core/DAO.php index 2e08801f69f5..0075a2536161 100644 --- a/CRM/Core/DAO.php +++ b/CRM/Core/DAO.php @@ -202,8 +202,8 @@ public static function reenableFullGroupByMode() { * @param array $params */ protected function assignTestFK($fieldName, $fieldDef, $params) { - $required = CRM_Utils_Array::value('required', $fieldDef); - $FKClassName = CRM_Utils_Array::value('FKClassName', $fieldDef); + $required = $fieldDef['required'] ?? NULL; + $FKClassName = $fieldDef['FKClassName'] ?? NULL; $dbName = $fieldDef['name']; $daoName = str_replace('_BAO_', '_DAO_', get_class($this)); @@ -343,7 +343,7 @@ protected function assignTestValue($fieldName, &$fieldDef, $counter) { } else { $this->$dbName = $dbName . '_' . $counter; - $maxlength = CRM_Utils_Array::value('maxlength', $fieldDef); + $maxlength = $fieldDef['maxlength'] ?? NULL; if ($maxlength > 0 && strlen($this->$dbName) > $maxlength) { $this->$dbName = substr($this->$dbName, 0, $fieldDef['maxlength']); } @@ -672,7 +672,7 @@ public function copyValues($params) { $allNull = FALSE; } else { - $maxLength = CRM_Utils_Array::value('maxlength', $field); + $maxLength = $field['maxlength'] ?? NULL; if (!is_array($value) && $maxLength && mb_strlen($value) > $maxLength && empty($field['pseudoconstant'])) { Civi::log()->warning(ts('A string for field $dbName has been truncated. The original string was %1', [CRM_Utils_Type::escape($value, 'String')])); // The string is too long - what to do what to do? Well losing data is generally bad so lets' truncate @@ -721,8 +721,8 @@ public static function storeValues(&$object, &$values) { public static function makeAttribute($field) { if ($field) { if (CRM_Utils_Array::value('type', $field) == CRM_Utils_Type::T_STRING) { - $maxLength = CRM_Utils_Array::value('maxlength', $field); - $size = CRM_Utils_Array::value('size', $field); + $maxLength = $field['maxlength'] ?? NULL; + $size = $field['size'] ?? NULL; if ($maxLength || $size) { $attributes = []; if ($maxLength) { @@ -735,11 +735,11 @@ public static function makeAttribute($field) { } } elseif (CRM_Utils_Array::value('type', $field) == CRM_Utils_Type::T_TEXT) { - $rows = CRM_Utils_Array::value('rows', $field); + $rows = $field['rows'] ?? NULL; if (!isset($rows)) { $rows = 2; } - $cols = CRM_Utils_Array::value('cols', $field); + $cols = $field['cols'] ?? NULL; if (!isset($cols)) { $cols = 80; } @@ -775,7 +775,7 @@ public static function getAttribute($class, $fieldName = NULL) { $object = new $class(); $fields = $object->fields(); if ($fieldName != NULL) { - $field = CRM_Utils_Array::value($fieldName, $fields); + $field = $fields[$fieldName] ?? NULL; return self::makeAttribute($field); } else { @@ -1993,8 +1993,8 @@ public static function createTestObject( $fields = $object->fields(); foreach ($fields as $fieldName => $fieldDef) { $dbName = $fieldDef['name']; - $FKClassName = CRM_Utils_Array::value('FKClassName', $fieldDef); - $required = CRM_Utils_Array::value('required', $fieldDef); + $FKClassName = $fieldDef['FKClassName'] ?? NULL; + $required = $fieldDef['required'] ?? NULL; if (CRM_Utils_Array::value($dbName, $params) !== NULL && !is_array($params[$dbName])) { $object->$dbName = $params[$dbName]; @@ -2046,7 +2046,7 @@ public static function deleteTestObjects($daoName, $params = []) { $config->backtrace = TRUE; $object = new $daoName(); - $object->id = CRM_Utils_Array::value('id', $params); + $object->id = $params['id'] ?? NULL; // array(array(0 => $daoName, 1 => $daoParams)) $deletions = []; @@ -2057,8 +2057,8 @@ public static function deleteTestObjects($daoName, $params = []) { $dbName = $value['name']; - $FKClassName = CRM_Utils_Array::value('FKClassName', $value); - $required = CRM_Utils_Array::value('required', $value); + $FKClassName = $value['FKClassName'] ?? NULL; + $required = $value['required'] ?? NULL; if ($FKClassName != NULL && $object->$dbName && !in_array($FKClassName, CRM_Core_DAO::$_testEntitiesToSkip) @@ -2526,7 +2526,7 @@ public function getOptionLabels() { throw new Exception('Cannot call getOptionLabels on CRM_Core_DAO'); } foreach ($fields as $field) { - $name = CRM_Utils_Array::value('name', $field); + $name = $field['name'] ?? NULL; if ($name && isset($this->$name)) { $label = CRM_Core_PseudoConstant::getLabel(get_class($this), $name, $this->$name); if ($label !== FALSE) { @@ -2573,7 +2573,7 @@ public function getFieldSpec($fieldName) { // Support "unique names" as well as sql names $fieldKey = $fieldName; if (empty($fields[$fieldKey])) { - $fieldKey = CRM_Utils_Array::value($fieldName, $fieldKeys); + $fieldKey = $fieldKeys[$fieldName] ?? NULL; } // If neither worked then this field doesn't exist. Return false. if (empty($fields[$fieldKey])) { diff --git a/CRM/Core/DAO/Factory.php b/CRM/Core/DAO/Factory.php index 519f4c4341aa..66dd5a9d7495 100644 --- a/CRM/Core/DAO/Factory.php +++ b/CRM/Core/DAO/Factory.php @@ -27,7 +27,7 @@ class CRM_Core_DAO_Factory { * @throws Exception */ public static function create($className) { - $type = CRM_Utils_Array::value($className, self::$_classes); + $type = self::$_classes[$className] ?? NULL; if (!$type) { CRM_Core_Error::fatal("class $className not found"); } diff --git a/CRM/Core/Error.php b/CRM/Core/Error.php index 1f0b4d40dbf2..e09455db56dc 100644 --- a/CRM/Core/Error.php +++ b/CRM/Core/Error.php @@ -726,7 +726,7 @@ public static function parseBacktrace($backTrace, $showArgs = TRUE, $maxArgLen = $ret = []; foreach ($backTrace as $trace) { $args = []; - $fnName = CRM_Utils_Array::value('function', $trace); + $fnName = $trace['function'] ?? NULL; $className = isset($trace['class']) ? ($trace['class'] . $trace['type']) : ''; // Do not show args for a few password related functions diff --git a/CRM/Core/Form.php b/CRM/Core/Form.php index 97d9649639f0..1af66632579e 100644 --- a/CRM/Core/Form.php +++ b/CRM/Core/Form.php @@ -638,7 +638,7 @@ public function addButtons($params) { $this->submitOnce = TRUE; } - $attrs = ['class' => 'crm-form-submit'] + (array) CRM_Utils_Array::value('js', $button); + $attrs = ['class' => 'crm-form-submit'] + (array) $button['js'] ?? NULL; if (!empty($button['class'])) { $attrs['class'] .= ' ' . $button['class']; @@ -828,7 +828,7 @@ protected function formatParamsForPaymentProcessor($fields) { */ protected function prepareParamsForPaymentProcessor($params) { // also add location name to the array - $params["address_name-{$this->_bltID}"] = CRM_Utils_Array::value('billing_first_name', $params) . ' ' . CRM_Utils_Array::value('billing_middle_name', $params) . ' ' . CRM_Utils_Array::value('billing_last_name', $params); + $params["address_name-{$this->_bltID}"] = CRM_Utils_Array::value('billing_first_name', $params) . ' ' . CRM_Utils_Array::value('billing_middle_name', $params) . ' ' . $params['billing_last_name'] ?? NULL; $params["address_name-{$this->_bltID}"] = trim($params["address_name-{$this->_bltID}"]); // Add additional parameters that the payment processors are used to receiving. if (!empty($params["billing_state_province_id-{$this->_bltID}"])) { @@ -878,8 +878,8 @@ protected function preProcessPaymentOptions() { $this->_paymentProcessorID = NULL; if ($this->_paymentProcessors) { if (!empty($this->_submitValues)) { - $this->_paymentProcessorID = CRM_Utils_Array::value('payment_processor_id', $this->_submitValues); - $this->_paymentProcessor = CRM_Utils_Array::value($this->_paymentProcessorID, $this->_paymentProcessors); + $this->_paymentProcessorID = $this->_submitValues['payment_processor_id'] ?? NULL; + $this->_paymentProcessor = $this->_paymentProcessors[$this->_paymentProcessorID] ?? NULL; $this->set('type', $this->_paymentProcessorID); $this->set('mode', $this->_mode); $this->set('paymentProcessor', $this->_paymentProcessor); @@ -1525,7 +1525,7 @@ public function addField($name, $props = [], $required = FALSE, $legacyDate = TR // Core field - get metadata. $fieldSpec = civicrm_api3($props['entity'], 'getfield', $props); $fieldSpec = $fieldSpec['values']; - $fieldSpecLabel = isset($fieldSpec['html']['label']) ? $fieldSpec['html']['label'] : CRM_Utils_Array::value('title', $fieldSpec); + $fieldSpecLabel = isset($fieldSpec['html']['label']) ? $fieldSpec['html']['label'] : $fieldSpec['title'] ?? NULL; $label = CRM_Utils_Array::value('label', $props, $fieldSpecLabel); $widget = isset($props['type']) ? $props['type'] : $fieldSpec['html']['type']; @@ -2522,7 +2522,7 @@ public function assignBillingName($params = []) { * @return string */ public function getCurrency($submittedValues = []) { - $currency = CRM_Utils_Array::value('currency', $this->_values); + $currency = $this->_values['currency'] ?? NULL; // For event forms, currency is in a different spot if (empty($currency)) { $currency = CRM_Utils_Array::value('currency', CRM_Utils_Array::value('event', $this->_values)); diff --git a/CRM/Core/Form/Renderer.php b/CRM/Core/Form/Renderer.php index c6161b0fade4..8a4f16c02ec8 100644 --- a/CRM/Core/Form/Renderer.php +++ b/CRM/Core/Form/Renderer.php @@ -172,7 +172,7 @@ public static function updateAttributes(&$element, $required, $error) { if ($type == 'text' || $type == 'password') { $size = $element->getAttribute('size'); if (!empty($size)) { - $class = CRM_Utils_Array::value($size, self::$_sizeMapper); + $class = self::$_sizeMapper[$size] ?? NULL; } } } diff --git a/CRM/Core/Form/Task/Batch.php b/CRM/Core/Form/Task/Batch.php index 655622639e37..9e65231ceb81 100644 --- a/CRM/Core/Form/Task/Batch.php +++ b/CRM/Core/Form/Task/Batch.php @@ -134,7 +134,7 @@ public function buildQuickForm() { $typeId = CRM_Core_DAO::getFieldValue('CRM_' . ucfirst($this::$entityShortname) . '_DAO_' . ucfirst($this::$entityShortname), $entityId, $this::$entityShortname . '_type_id'); foreach ($this->_fields as $name => $field) { if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($name)) { - $customValue = CRM_Utils_Array::value($customFieldID, $customFields); + $customValue = $customFields[$customFieldID] ?? NULL; $entityColumnValue = []; if (!empty($customValue['extends_entity_column_value'])) { $entityColumnValue = explode(CRM_Core_DAO::VALUE_SEPARATOR, diff --git a/CRM/Core/Form/Task/PDFLetterCommon.php b/CRM/Core/Form/Task/PDFLetterCommon.php index 0ec70a5b1b1b..14e19c7a8c2d 100644 --- a/CRM/Core/Form/Task/PDFLetterCommon.php +++ b/CRM/Core/Form/Task/PDFLetterCommon.php @@ -225,7 +225,7 @@ public static function formRule($fields, $files, $self) { * @return string $html_message */ public static function processTemplate(&$formValues) { - $html_message = CRM_Utils_Array::value('html_message', $formValues); + $html_message = $formValues['html_message'] ?? NULL; // process message template if (!empty($formValues['saveTemplate']) || !empty($formValues['updateTemplate'])) { diff --git a/CRM/Core/Invoke.php b/CRM/Core/Invoke.php index 1ea5fa8b1620..2b95574e5abb 100644 --- a/CRM/Core/Invoke.php +++ b/CRM/Core/Invoke.php @@ -248,7 +248,7 @@ public static function runItem($item) { $mode = $pageArgs['mode']; unset($pageArgs['mode']); } - $title = CRM_Utils_Array::value('title', $item); + $title = $item['title'] ?? NULL; if (strstr($item['page_callback'], '_Page') || strstr($item['page_callback'], '\\Page\\')) { $object = new $item['page_callback']($title, $mode); $object->urlPath = explode('/', $_GET[$config->userFrameworkURLVar]); diff --git a/CRM/Core/ManagedEntities.php b/CRM/Core/ManagedEntities.php index cf47fa6918bd..0f098699669b 100644 --- a/CRM/Core/ManagedEntities.php +++ b/CRM/Core/ManagedEntities.php @@ -246,7 +246,7 @@ public function insertNewEntity($todo) { $dao->name = $todo['name']; $dao->entity_type = $todo['entity']; $dao->entity_id = $result['id']; - $dao->cleanup = CRM_Utils_Array::value('cleanup', $todo); + $dao->cleanup = $todo['cleanup'] ?? NULL; $dao->save(); } diff --git a/CRM/Core/OptionGroup.php b/CRM/Core/OptionGroup.php index 97af275ded05..2540c1547138 100644 --- a/CRM/Core/OptionGroup.php +++ b/CRM/Core/OptionGroup.php @@ -478,11 +478,11 @@ public static function createAssoc($groupName, &$values, &$defaultID, $groupTitl $value->option_group_id = $group->id; $value->label = $v['label']; $value->value = $v['value']; - $value->name = CRM_Utils_Array::value('name', $v); - $value->description = CRM_Utils_Array::value('description', $v); - $value->weight = CRM_Utils_Array::value('weight', $v); - $value->is_default = CRM_Utils_Array::value('is_default', $v); - $value->is_active = CRM_Utils_Array::value('is_active', $v); + $value->name = $v['name'] ?? NULL; + $value->description = $v['description'] ?? NULL; + $value->weight = $v['weight'] ?? NULL; + $value->is_default = $v['is_default'] ?? NULL; + $value->is_active = $v['is_active'] ?? NULL; $value->save(); if ($value->is_default) { diff --git a/CRM/Core/OptionValue.php b/CRM/Core/OptionValue.php index a241619dd5ef..b7cabfa8e508 100644 --- a/CRM/Core/OptionValue.php +++ b/CRM/Core/OptionValue.php @@ -70,7 +70,7 @@ public static function getRows($groupParams, $links, $orderBy = 'weight', $skipE $optionGroupID = $groupParams['id']; } - $groupName = CRM_Utils_Array::value('name', $groupParams); + $groupName = $groupParams['name'] ?? NULL; if (!$groupName && $optionGroupID) { $groupName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', $optionGroupID, 'name', 'id' @@ -418,8 +418,8 @@ public static function getValues($groupParams, &$values, $orderBy = 'weight', $i $order = " ORDER BY " . $orderBy; - $groupId = CRM_Utils_Array::value('id', $groupParams); - $groupName = CRM_Utils_Array::value('name', $groupParams); + $groupId = $groupParams['id'] ?? NULL; + $groupName = $groupParams['name'] ?? NULL; if ($groupId) { $where .= " AND option_group.id = %1"; diff --git a/CRM/Core/Page/AJAX/Location.php b/CRM/Core/Page/AJAX/Location.php index 60a11fdd6789..2e1988c61bcb 100644 --- a/CRM/Core/Page/AJAX/Location.php +++ b/CRM/Core/Page/AJAX/Location.php @@ -145,7 +145,7 @@ public static function getPermissionedLocation() { if (!empty($defaults)) { foreach ($profileFields as $key => $val) { if (array_key_exists($key, $defaults)) { - $htmlType = CRM_Utils_Array::value('html_type', $val); + $htmlType = $val['html_type'] ?? NULL; if ($htmlType == 'Radio') { $elements["onbehalf_{$key}"]['type'] = $htmlType; $elements["onbehalf_{$key}"]['value'] = $defaults[$key]; @@ -226,7 +226,7 @@ public static function getLocBlock() { $element = 'name'; } $fld = "address[1][{$element}]"; - $value = CRM_Utils_Array::value($element, $location['address'][1]); + $value = $location['address'][1][$element] ?? NULL; $value = $value ? $value : ""; $result[str_replace([ '][', @@ -244,7 +244,7 @@ public static function getLocBlock() { $block = ($element == 'phone_type_id') ? 'phone' : $element; for ($i = 1; $i < 3; $i++) { $fld = "{$block}[{$i}][{$element}]"; - $value = CRM_Utils_Array::value($element, $location[$block][$i]); + $value = $location[$block][$i][$element] ?? NULL; $value = $value ? $value : ""; $result[str_replace([ '][', diff --git a/CRM/Core/Payment/BaseIPN.php b/CRM/Core/Payment/BaseIPN.php index 9ebe28db8d30..c3b05b62263e 100644 --- a/CRM/Core/Payment/BaseIPN.php +++ b/CRM/Core/Payment/BaseIPN.php @@ -175,7 +175,7 @@ public function loadObjects(&$input, &$ids, &$objects, $required, $paymentProces else { //legacy support - functions are 'used' to be able to pass in a DAO $contribution = new CRM_Contribute_BAO_Contribution(); - $contribution->id = CRM_Utils_Array::value('contribution', $ids); + $contribution->id = $ids['contribution'] ?? NULL; $contribution->find(TRUE); $objects['contribution'] = &$contribution; } @@ -322,7 +322,7 @@ public function cancelled(&$objects, &$transaction, $input = []) { $contribution->receipt_date = CRM_Utils_Date::isoToMysql($contribution->receipt_date); $contribution->thankyou_date = CRM_Utils_Date::isoToMysql($contribution->thankyou_date); $contribution->cancel_date = self::$_now; - $contribution->cancel_reason = CRM_Utils_Array::value('reasonCode', $input); + $contribution->cancel_reason = $input['reasonCode'] ?? NULL; $contribution->save(); // Add line items for recurring payments. diff --git a/CRM/Core/Payment/Elavon.php b/CRM/Core/Payment/Elavon.php index ad955a0efc37..71ca4d5af1dd 100644 --- a/CRM/Core/Payment/Elavon.php +++ b/CRM/Core/Payment/Elavon.php @@ -133,8 +133,8 @@ public function doDirectPayment(&$params) { // define variables for connecting with the gateway $requestFields['ssl_merchant_id'] = $this->_paymentProcessor['user_name']; - $requestFields['ssl_user_id'] = CRM_Utils_Array::value('password', $this->_paymentProcessor); - $requestFields['ssl_pin'] = CRM_Utils_Array::value('signature', $this->_paymentProcessor); + $requestFields['ssl_user_id'] = $this->_paymentProcessor['password'] ?? NULL; + $requestFields['ssl_pin'] = $this->_paymentProcessor['signature'] ?? NULL; $host = $this->_paymentProcessor['url_site']; if ($this->_mode == "test") { diff --git a/CRM/Core/Payment/PayPalImpl.php b/CRM/Core/Payment/PayPalImpl.php index cb71dbd438d3..4247af10d9a9 100644 --- a/CRM/Core/Payment/PayPalImpl.php +++ b/CRM/Core/Payment/PayPalImpl.php @@ -236,7 +236,7 @@ protected function setExpressCheckOut(&$params) { $args['paymentAction'] = 'Sale'; $args['amt'] = $params['amount']; $args['currencyCode'] = $params['currencyID']; - $args['desc'] = CRM_Utils_Array::value('description', $params); + $args['desc'] = $params['description'] ?? NULL; $args['invnum'] = $params['invoiceID']; $args['returnURL'] = $this->getReturnSuccessUrl($params['qfKey']); $args['cancelURL'] = $this->getCancelUrl($params['qfKey'], NULL); @@ -354,7 +354,7 @@ public function doExpressCheckout(&$params) { $params['trxn_id'] = $result['transactionid']; $params['gross_amount'] = $result['amt']; $params['fee_amount'] = $result['feeamt']; - $params['net_amount'] = CRM_Utils_Array::value('settleamt', $result); + $params['net_amount'] = $result['settleamt'] ?? NULL; if ($params['net_amount'] == 0 && $params['fee_amount'] != 0) { $params['net_amount'] = number_format(($params['gross_amount'] - $params['fee_amount']), 2); } @@ -399,7 +399,7 @@ public function createRecurringPayments(&$params) { $args['billingfrequency'] = $params['frequency_interval']; $args['billingperiod'] = ucwords($params['frequency_unit']); $args['desc'] = $params['amount'] . " Per " . $params['frequency_interval'] . " " . $params['frequency_unit']; - $args['totalbillingcycles'] = CRM_Utils_Array::value('installments', $params); + $args['totalbillingcycles'] = $params['installments'] ?? NULL; $args['version'] = '56.0'; $args['profilereference'] = "i={$params['invoiceID']}" . "&m=" . @@ -440,7 +440,7 @@ public function initialize(&$args, $method) { $args['pwd'] = $this->_paymentProcessor['password']; $args['version'] = 3.0; $args['signature'] = $this->_paymentProcessor['signature']; - $args['subject'] = CRM_Utils_Array::value('subject', $this->_paymentProcessor); + $args['subject'] = $this->_paymentProcessor['subject'] ?? NULL; $args['method'] = $method; } @@ -506,14 +506,14 @@ public function doDirectPayment(&$params, $component = 'contribute') { $args['cvv2'] = $params['cvv2']; $args['firstName'] = $params['first_name']; $args['lastName'] = $params['last_name']; - $args['email'] = CRM_Utils_Array::value('email', $params); + $args['email'] = $params['email'] ?? NULL; $args['street'] = $params['street_address']; $args['city'] = $params['city']; $args['state'] = $params['state_province']; $args['countryCode'] = $params['country']; $args['zip'] = $params['postal_code']; $args['desc'] = substr(CRM_Utils_Array::value('description', $params), 0, 127); - $args['custom'] = CRM_Utils_Array::value('accountingCode', $params); + $args['custom'] = $params['accountingCode'] ?? NULL; // add CiviCRM BN code $args['BUTTONSOURCE'] = 'CiviCRM_SP'; @@ -533,7 +533,7 @@ public function doDirectPayment(&$params, $component = 'contribute') { $params['frequency_interval'] . " " . $params['frequency_unit']; $args['amt'] = $this->getAmount($params); - $args['totalbillingcycles'] = CRM_Utils_Array::value('installments', $params); + $args['totalbillingcycles'] = $params['installments'] ?? NULL; $args['version'] = 56.0; $args['PROFILEREFERENCE'] = "" . "i=" . $params['invoiceID'] . "&m=" . $component . @@ -554,8 +554,8 @@ public function doDirectPayment(&$params, $component = 'contribute') { /* Success */ - $params['trxn_id'] = CRM_Utils_Array::value('transactionid', $result); - $params['gross_amount'] = CRM_Utils_Array::value('amt', $result); + $params['trxn_id'] = $result['transactionid'] ?? NULL; + $params['gross_amount'] = $result['amt'] ?? NULL; $params = array_merge($params, $this->doQuery($params)); return $params; } @@ -685,9 +685,9 @@ public function cancelSubscription(&$message = '', $params = []) { $args = []; $this->initialize($args, 'ManageRecurringPaymentsProfileStatus'); - $args['PROFILEID'] = CRM_Utils_Array::value('subscriptionId', $params); + $args['PROFILEID'] = $params['subscriptionId'] ?? NULL; $args['ACTION'] = 'Cancel'; - $args['NOTE'] = CRM_Utils_Array::value('reason', $params); + $args['NOTE'] = $params['reason'] ?? NULL; $result = $this->invokeAPI($args); @@ -719,7 +719,7 @@ public static function handlePaymentNotification() { throw new CRM_Core_Exception("Could not find a processor with the given processor_id value '{$params['processor_id']}'."); } - $paymentProcessorType = CRM_Utils_Array::value('api.PaymentProcessorType.getvalue', $result['values'][0]); + $paymentProcessorType = $result['values'][0]['api.PaymentProcessorType.getvalue'] ?? NULL; switch ($paymentProcessorType) { case 'PayPal': // "PayPal - Website Payments Pro" diff --git a/CRM/Core/Payment/PaymentExpress.php b/CRM/Core/Payment/PaymentExpress.php index 47db6a690ca1..2f40ea054f08 100644 --- a/CRM/Core/Payment/PaymentExpress.php +++ b/CRM/Core/Payment/PaymentExpress.php @@ -151,7 +151,7 @@ public function doTransferCheckout(&$params, $component) { $privateData .= ",f={$params['participantID']},g={$params['eventID']}"; } elseif ($component == 'contribute') { - $membershipID = CRM_Utils_Array::value('membershipID', $params); + $membershipID = $params['membershipID'] ?? NULL; if ($membershipID) { $privateData .= ",e=$membershipID"; } diff --git a/CRM/Core/Payment/PaymentExpressIPN.php b/CRM/Core/Payment/PaymentExpressIPN.php index 207bc59a9b9c..ab34ea13f1e5 100644 --- a/CRM/Core/Payment/PaymentExpressIPN.php +++ b/CRM/Core/Payment/PaymentExpressIPN.php @@ -62,7 +62,7 @@ class CRM_Core_Payment_PaymentExpressIPN extends CRM_Core_Payment_BaseIPN { * @return mixed */ public static function retrieve($name, $type, $object, $abort = TRUE) { - $value = CRM_Utils_Array::value($name, $object); + $value = $object[$name] ?? NULL; if ($abort && $value === NULL) { CRM_Core_Error::debug_log_message("Could not find an entry for $name"); echo "Failure: Missing Parameter - " . $name . "

"; diff --git a/CRM/Core/Permission.php b/CRM/Core/Permission.php index d560d734f9eb..5c3bf571e862 100644 --- a/CRM/Core/Permission.php +++ b/CRM/Core/Permission.php @@ -465,7 +465,7 @@ public static function checkActionPermission($module, $action) { 'CiviMail' => 'access CiviMail', 'CiviAuction' => 'add auction items', ]; - $permissionName = CRM_Utils_Array::value($module, $editPermissions); + $permissionName = $editPermissions[$module] ?? NULL; } if ($module == 'CiviCase' && !$permissionName) { diff --git a/CRM/Core/PseudoConstant.php b/CRM/Core/PseudoConstant.php index 773194a1aea1..c179a8a4a957 100644 --- a/CRM/Core/PseudoConstant.php +++ b/CRM/Core/PseudoConstant.php @@ -824,7 +824,7 @@ public static function country($id = FALSE, $applyLimit = TRUE) { $countryIsoCodes = self::countryIsoCode(); $defaultID = array_search(CRM_Core_BAO_Country::defaultContactCountry(), $countryIsoCodes); if ($defaultID !== FALSE) { - $default[$defaultID] = CRM_Utils_Array::value($defaultID, self::$country); + $default[$defaultID] = self::$country[$defaultID] ?? NULL; self::$country = $default + self::$country; } } @@ -1393,7 +1393,7 @@ public static function greeting($filter, $columnName = 'label') { $index = $filter['greeting_type'] . '_' . $columnName; // also add contactType to the array - $contactType = CRM_Utils_Array::value('contact_type', $filter); + $contactType = $filter['contact_type'] ?? NULL; if ($contactType) { $index .= '_' . $contactType; } diff --git a/CRM/Core/Smarty/plugins/function.crmAPI.php b/CRM/Core/Smarty/plugins/function.crmAPI.php index 57c8efe178be..c1eae333e22a 100644 --- a/CRM/Core/Smarty/plugins/function.crmAPI.php +++ b/CRM/Core/Smarty/plugins/function.crmAPI.php @@ -31,7 +31,7 @@ function smarty_function_crmAPI($params, &$smarty) { $entity = $params['entity']; $action = CRM_Utils_Array::value('action', $params, 'get'); $params['sequential'] = CRM_Utils_Array::value('sequential', $params, 1); - $var = CRM_Utils_Array::value('var', $params); + $var = $params['var'] ?? NULL; CRM_Utils_Array::remove($params, 'entity', 'action', 'var'); $params['version'] = 3; require_once 'api/api.php'; diff --git a/CRM/Custom/Form/DeleteField.php b/CRM/Custom/Form/DeleteField.php index 492a5847a13e..8298ec966065 100644 --- a/CRM/Custom/Form/DeleteField.php +++ b/CRM/Custom/Form/DeleteField.php @@ -49,7 +49,7 @@ public function preProcess() { $params = ['id' => $this->_id]; CRM_Core_BAO_CustomField::retrieve($params, $defaults); - $this->_title = CRM_Utils_Array::value('label', $defaults); + $this->_title = $defaults['label'] ?? NULL; $this->assign('title', $this->_title); CRM_Utils_System::setTitle(ts('Delete %1', [1 => $this->_title])); } diff --git a/CRM/Custom/Form/Field.php b/CRM/Custom/Form/Field.php index 0aeb046607e3..3881c1d98085 100644 --- a/CRM/Custom/Form/Field.php +++ b/CRM/Custom/Form/Field.php @@ -90,7 +90,7 @@ public function preProcess() { $params = ['id' => $this->_id]; CRM_Core_BAO_CustomField::retrieve($params, $this->_values); // note_length is an alias for the text_length field - $this->_values['note_length'] = CRM_Utils_Array::value('text_length', $this->_values); + $this->_values['note_length'] = $this->_values['text_length'] ?? NULL; // custom group id $this->_gid = $this->_values['custom_group_id']; } @@ -571,7 +571,7 @@ public function buildQuickForm() { * true otherwise */ public static function formRule($fields, $files, $self) { - $default = CRM_Utils_Array::value('default_value', $fields); + $default = $fields['default_value'] ?? NULL; $errors = []; diff --git a/CRM/Custom/Form/Group.php b/CRM/Custom/Form/Group.php index e21c34fe5ae3..10c582c32053 100644 --- a/CRM/Custom/Form/Group.php +++ b/CRM/Custom/Form/Group.php @@ -73,7 +73,7 @@ public function preProcess() { $params = ['id' => $this->_id]; CRM_Core_BAO_CustomGroup::retrieve($params, $this->_defaults); - $subExtends = CRM_Utils_Array::value('extends_entity_column_value', $this->_defaults); + $subExtends = $this->_defaults['extends_entity_column_value'] ?? NULL; if (!empty($subExtends)) { $this->_subtypes = explode(CRM_Core_DAO::VALUE_SEPARATOR, substr($subExtends, 1, -1)); } @@ -255,7 +255,7 @@ public function buildQuickForm() { $sel->_elements[1]->setSize(5); } if ($this->_action == CRM_Core_Action::UPDATE) { - $subName = CRM_Utils_Array::value('extends_entity_column_id', $this->_defaults); + $subName = $this->_defaults['extends_entity_column_id'] ?? NULL; if ($this->_defaults['extends'] == 'Participant') { if ($subName == 1) { $this->_defaults['extends'] = 'ParticipantRole'; diff --git a/CRM/Custom/Import/Form/MapField.php b/CRM/Custom/Import/Form/MapField.php index b7a42335c242..30db99f01f13 100644 --- a/CRM/Custom/Import/Form/MapField.php +++ b/CRM/Custom/Import/Form/MapField.php @@ -83,7 +83,7 @@ public static function formRule($fields) { } if (!empty($fields['saveMapping'])) { - $nameField = CRM_Utils_Array::value('saveMappingName', $fields); + $nameField = $fields['saveMappingName'] ?? NULL; if (empty($nameField)) { $errors['saveMappingName'] = ts('Name is required to save Import Mapping'); } @@ -96,7 +96,7 @@ public static function formRule($fields) { //display Error if loaded mapping is not selected if (array_key_exists('loadMapping', $fields)) { - $getMapName = CRM_Utils_Array::value('savedMapping', $fields); + $getMapName = $fields['savedMapping'] ?? NULL; if (empty($getMapName)) { $errors['savedMapping'] = ts('Select saved mapping'); } @@ -172,9 +172,9 @@ public function postProcess() { $updateMappingFields->column_number = $i; $explodedValues = explode('_', $mapperKeys[$i][0]); - $id = CRM_Utils_Array::value(0, $explodedValues); - $first = CRM_Utils_Array::value(1, $explodedValues); - $second = CRM_Utils_Array::value(2, $explodedValues); + $id = $explodedValues[0] ?? NULL; + $first = $explodedValues[1] ?? NULL; + $second = $explodedValues[2] ?? NULL; $updateMappingFields->name = $mapper[$i]; $updateMappingFields->save(); @@ -196,9 +196,9 @@ public function postProcess() { $saveMappingFields->column_number = $i; $explodedValues = explode('_', $mapperKeys[$i][0]); - $id = CRM_Utils_Array::value(0, $explodedValues); - $first = CRM_Utils_Array::value(1, $explodedValues); - $second = CRM_Utils_Array::value(2, $explodedValues); + $id = $explodedValues[0] ?? NULL; + $first = $explodedValues[1] ?? NULL; + $second = $explodedValues[2] ?? NULL; $saveMappingFields->name = $mapper[$i]; $saveMappingFields->save(); diff --git a/CRM/Custom/Import/Parser/Api.php b/CRM/Custom/Import/Parser/Api.php index da2eb78f098b..db3180adb737 100644 --- a/CRM/Custom/Import/Parser/Api.php +++ b/CRM/Custom/Import/Parser/Api.php @@ -242,7 +242,7 @@ public function getGroupFieldsForImport($id) { $allFields = civicrm_api3('custom_field', 'get', $params); $fields = $allFields['values']; foreach ($fields as $id => $values) { - $datatype = CRM_Utils_Array::value('data_type', $values); + $datatype = $values['data_type'] ?? NULL; if ($datatype == 'File') { continue; } @@ -261,8 +261,8 @@ public function getGroupFieldsForImport($id) { 'is_search_range' => $values['is_search_range'] ?? NULL, ]; if (CRM_Utils_Array::value('html_type', $values) == 'Select Date') { - $importableFields[$key]['date_format'] = CRM_Utils_Array::value('date_format', $values); - $importableFields[$key]['time_format'] = CRM_Utils_Array::value('time_format', $values); + $importableFields[$key]['date_format'] = $values['date_format'] ?? NULL; + $importableFields[$key]['time_format'] = $values['time_format'] ?? NULL; $this->_dateFields[] = $key; } } diff --git a/CRM/Custom/Page/Group.php b/CRM/Custom/Page/Group.php index e0bb74ac159c..76fa828ea7a6 100644 --- a/CRM/Custom/Page/Group.php +++ b/CRM/Custom/Page/Group.php @@ -268,9 +268,9 @@ public function browse($action = NULL) { CRM_Core_BAO_CustomGroup::getExtendedObjectTypes($subTypes); foreach ($customGroup as $key => $values) { - $subValue = CRM_Utils_Array::value('extends_entity_column_value', $customGroup[$key]); - $subName = CRM_Utils_Array::value('extends_entity_column_id', $customGroup[$key]); - $type = CRM_Utils_Array::value('extends', $customGroup[$key]); + $subValue = $customGroup[$key]['extends_entity_column_value'] ?? NULL; + $subName = $customGroup[$key]['extends_entity_column_id'] ?? NULL; + $type = $customGroup[$key]['extends'] ?? NULL; if ($subValue) { $subValue = explode(CRM_Core_DAO::VALUE_SEPARATOR, substr($subValue, 1, -1) diff --git a/CRM/Dedupe/BAO/Exception.php b/CRM/Dedupe/BAO/Exception.php index 3c4c783cfcd7..6097887055a5 100644 --- a/CRM/Dedupe/BAO/Exception.php +++ b/CRM/Dedupe/BAO/Exception.php @@ -30,13 +30,13 @@ class CRM_Dedupe_BAO_Exception extends CRM_Dedupe_DAO_Exception { public static function create($params) { $hook = empty($params['id']) ? 'create' : 'edit'; CRM_Utils_Hook::pre($hook, 'Exception', CRM_Utils_Array::value('id', $params), $params); - $contact1 = CRM_Utils_Array::value('contact_id1', $params); - $contact2 = CRM_Utils_Array::value('contact_id2', $params); + $contact1 = $params['contact_id1'] ?? NULL; + $contact2 = $params['contact_id2'] ?? NULL; $dao = new CRM_Dedupe_BAO_Exception(); $dao->copyValues($params); if ($contact1 && $contact2) { CRM_Core_DAO::singleValueQuery(" - DELETE FROM civicrm_prevnext_cache + DELETE FROM civicrm_prevnext_cache WHERE (entity_id1 = %1 AND entity_id2 = %2) OR (entity_id1 = %2 AND entity_id2 = %2)", [1 => [$contact1, 'Integer'], 2 => [$contact2, 'Integer']] diff --git a/CRM/Dedupe/BAO/QueryBuilder/IndividualGeneral.php b/CRM/Dedupe/BAO/QueryBuilder/IndividualGeneral.php index 373866f7a868..4a4b93d618d4 100644 --- a/CRM/Dedupe/BAO/QueryBuilder/IndividualGeneral.php +++ b/CRM/Dedupe/BAO/QueryBuilder/IndividualGeneral.php @@ -12,8 +12,8 @@ class CRM_Dedupe_BAO_QueryBuilder_IndividualGeneral extends CRM_Dedupe_BAO_Query * @return array */ public static function record($rg) { - $civicrm_contact = CRM_Utils_Array::value('civicrm_contact', $rg->params); - $civicrm_address = CRM_Utils_Array::value('civicrm_address', $rg->params); + $civicrm_contact = $rg->params['civicrm_contact'] ?? NULL; + $civicrm_address = $rg->params['civicrm_address'] ?? NULL; // Since definitely have first and last name, escape them upfront. $first_name = CRM_Core_DAO::escapeString(CRM_Utils_Array::value('first_name', $civicrm_contact, '')); diff --git a/CRM/Dedupe/Finder.php b/CRM/Dedupe/Finder.php index 06863a2afabd..97e8abcf51bc 100644 --- a/CRM/Dedupe/Finder.php +++ b/CRM/Dedupe/Finder.php @@ -230,7 +230,7 @@ public static function formatParams($fields, $ctype) { continue; } foreach ($cg['fields'] as $cf) { - $flat[$cf['column_name']] = CRM_Utils_Array::value('data', $cf['customValue']); + $flat[$cf['column_name']] = $cf['customValue']['data'] ?? NULL; } } diff --git a/CRM/Dedupe/Merger.php b/CRM/Dedupe/Merger.php index 6c1d7d6bfd21..d5d1c5a132d4 100644 --- a/CRM/Dedupe/Merger.php +++ b/CRM/Dedupe/Merger.php @@ -637,8 +637,8 @@ public static function retrieveFields($main, $other) { if (strpos($key, '_')) { continue; } - $key1 = CRM_Utils_Array::value($key, $mainEvs); - $key2 = CRM_Utils_Array::value($key, $otherEvs); + $key1 = $mainEvs[$key] ?? NULL; + $key2 = $otherEvs[$key] ?? NULL; // We wish to retain '0' as it has a different meaning than NULL on a checkbox. // However I can't think of a case where an empty string is more meaningful than null // or where it would be FALSE or something else nullish. @@ -859,7 +859,7 @@ public static function getMergeStatsMsg($stats) { public static function merge($dupePairs = [], $cacheParams = [], $mode = 'safe', $redirectForPerformance = FALSE, $checkPermissions = TRUE ) { - $cacheKeyString = CRM_Utils_Array::value('cache_key_string', $cacheParams); + $cacheKeyString = $cacheParams['cache_key_string'] ?? NULL; $resultStats = ['merged' => [], 'skipped' => []]; // we don't want dupe caching to get reset after every-merge, and therefore set the @@ -1716,7 +1716,7 @@ public static function mergeLocations($mainId, $otherId, $migrationInfo) { // @todo Tidy this up $operation = 0; if ($fieldName != 'website') { - $operation = CRM_Utils_Array::value('operation', $migrationInfo['location_blocks'][$fieldName][$fieldCount]); + $operation = $migrationInfo['location_blocks'][$fieldName][$fieldCount]['operation'] ?? NULL; } // default operation is overwrite. if (!$operation) { @@ -1744,7 +1744,7 @@ public static function mergeLocations($mainId, $otherId, $migrationInfo) { $billingDAOId = (array_key_exists($name, $billingBlockIds)) ? array_pop($billingBlockIds[$name]) : NULL; foreach ($block as $blkCount => $values) { - $otherBlockId = CRM_Utils_Array::value('id', $migrationInfo['other_details']['location_blocks'][$name][$blkCount]); + $otherBlockId = $migrationInfo['other_details']['location_blocks'][$name][$blkCount]['id'] ?? NULL; $mainBlockId = CRM_Utils_Array::value('mainContactBlockId', $migrationInfo['location_blocks'][$name][$blkCount], 0); if (!$otherBlockId) { continue; @@ -1759,18 +1759,18 @@ public static function mergeLocations($mainId, $otherId, $migrationInfo) { // Add/update location and type information from the form, if applicable if ($locationBlocks[$name]['hasLocation']) { - $locTypeId = CRM_Utils_Array::value('locTypeId', $migrationInfo['location_blocks'][$name][$blkCount]); + $locTypeId = $migrationInfo['location_blocks'][$name][$blkCount]['locTypeId'] ?? NULL; $otherBlockDAO->location_type_id = $locTypeId; } if ($locationBlocks[$name]['hasType']) { - $typeTypeId = CRM_Utils_Array::value('typeTypeId', $migrationInfo['location_blocks'][$name][$blkCount]); + $typeTypeId = $migrationInfo['location_blocks'][$name][$blkCount]['typeTypeId'] ?? NULL; $otherBlockDAO->{$locationBlocks[$name]['hasType']} = $typeTypeId; } // If we're deliberately setting this as primary then add the flag // and remove it from the current primary location (if there is one). // But only once for each entity. - $set_primary = CRM_Utils_Array::value('set_other_primary', $migrationInfo['location_blocks'][$name][$blkCount]); + $set_primary = $migrationInfo['location_blocks'][$name][$blkCount]['set_other_primary'] ?? NULL; if (!$changePrimary && $set_primary == "1") { $otherBlockDAO->is_primary = 1; if ($primaryDAOId) { @@ -2125,7 +2125,7 @@ public static function getConflicts(&$migrationInfo, $mainId, $otherId, $mode) { // Load the address we're inspecting from the 'other' contact $addressRecord = $migrationInfo['other_details']['location_blocks'][$fieldName][$fieldCount]; - $addressRecordLocTypeId = CRM_Utils_Array::value('location_type_id', $addressRecord); + $addressRecordLocTypeId = $addressRecord['location_type_id'] ?? NULL; // If it exists on the 'main' contact already, skip it. Otherwise // if the location type exists already, log a conflict. @@ -2217,7 +2217,7 @@ protected static function formatConflictArray($conflicts, $migrationInfo, $toKee if (in_array($fieldName, self::ignoredFields())) { continue; } - $toRemoveValue = CRM_Utils_Array::value($fieldName, $toRemoveContactLocationBlocks[$entity][$blockIndex]); + $toRemoveValue = $toRemoveContactLocationBlocks[$entity][$blockIndex][$fieldName] ?? NULL; if ($fieldValue !== $toRemoveValue) { $entityConflicts[$fieldName] = [ $toKeepID => $fieldValue, @@ -2296,7 +2296,7 @@ protected static function ignoredFields(): array { */ private static function getFieldValueAndLabel($field, $contact): array { $fields = self::getMergeFieldsMetadata(); - $value = $label = CRM_Utils_Array::value($field, $contact); + $value = $label = $contact[$field] ?? NULL; $fieldSpec = $fields[$field]; if (!empty($fieldSpec['serialize']) && is_array($value)) { // In practice this only applies to preferred_communication_method as the sub types are skipped above @@ -2475,7 +2475,7 @@ protected static function addLocationFieldInfo($mainId, $otherId, $blockInfo, $b $lookupType = FALSE; if ($blockInfo['hasType']) { - $lookupType = CRM_Utils_Array::value($blockInfo['hasType'], $value); + $lookupType = $value[$blockInfo['hasType']] ?? NULL; } // Hold ID of main contact's matching block @@ -2571,7 +2571,7 @@ protected static function addLocationFieldInfo($mainId, $otherId, $blockInfo, $b // Load the type options for this entity $typeOptions = civicrm_api3($blockName, 'getoptions', ['field' => $blockInfo['hasType']]); - $thisTypeId = CRM_Utils_Array::value($blockInfo['hasType'], $value); + $thisTypeId = $value[$blockInfo['hasType']] ?? NULL; // Put this field's location type at the top of the list $tmpIdList = $typeOptions['values']; diff --git a/CRM/Event/BAO/Event.php b/CRM/Event/BAO/Event.php index 29252fc27ef9..1e178acae2a7 100644 --- a/CRM/Event/BAO/Event.php +++ b/CRM/Event/BAO/Event.php @@ -134,7 +134,7 @@ public static function create(&$params) { $contactId = CRM_Core_Session::getLoggedInContactID(); if (!$contactId) { - $contactId = CRM_Utils_Array::value('contact_id', $params); + $contactId = $params['contact_id'] ?? NULL; } // Log the information on successful add/edit of Event @@ -1104,8 +1104,8 @@ public static function sendMail($contactID, $values, $participantId, $isTest = F //send email only when email is present if (isset($email) || $returnMessageText) { - $preProfileID = CRM_Utils_Array::value('custom_pre_id', $values); - $postProfileID = CRM_Utils_Array::value('custom_post_id', $values); + $preProfileID = $values['custom_pre_id'] ?? NULL; + $postProfileID = $values['custom_post_id'] ?? NULL; if (!empty($values['params']['additionalParticipant'])) { $preProfileID = CRM_Utils_Array::value('additional_custom_pre_id', $values, $preProfileID); @@ -1233,7 +1233,7 @@ public static function sendMail($contactID, $values, $participantId, $isTest = F ); // append invoice pdf to email $prefixValue = Civi::settings()->get('contribution_invoice_settings'); - $invoicing = CRM_Utils_Array::value('invoicing', $prefixValue); + $invoicing = $prefixValue['invoicing'] ?? NULL; if (isset($invoicing) && isset($prefixValue['is_email_pdf']) && !empty($values['contributionId'])) { $sendTemplateParams['isEmailPdf'] = TRUE; $sendTemplateParams['contributionId'] = $values['contributionId']; @@ -1581,7 +1581,7 @@ public static function displayProfile(&$params, $gid, &$groupTitle, &$values, &$ } elseif (substr($name, -11) == 'campaign_id') { $campaigns = CRM_Campaign_BAO_Campaign::getCampaigns($params[$name]); - $values[$index] = CRM_Utils_Array::value($params[$name], $campaigns); + $values[$index] = $campaigns[$params[$name]] ?? NULL; } elseif (strpos($name, '-') !== FALSE) { list($fieldName, $id) = CRM_Utils_System::explode('-', $name, 2); @@ -1598,7 +1598,7 @@ public static function displayProfile(&$params, $gid, &$groupTitle, &$values, &$ elseif ($fieldName == 'im') { $providerName = NULL; if ($providerId = $detailName . '-provider_id') { - $providerName = CRM_Utils_Array::value($params[$providerId], $imProviders); + $providerName = $imProviders[$params[$providerId]] ?? NULL; } if ($providerName) { $values[$index] = $params[$detailName] . " (" . $providerName . ")"; @@ -1638,8 +1638,8 @@ public static function displayProfile(&$params, $gid, &$groupTitle, &$values, &$ $htmlType = $dao->html_type; if ($htmlType == 'File') { - $path = CRM_Utils_Array::value('name', $params[$name]); - $fileType = CRM_Utils_Array::value('type', $params[$name]); + $path = $params[$name]['name'] ?? NULL; + $fileType = $params[$name]['type'] ?? NULL; $values[$index] = CRM_Utils_File::getFileURL($path, $fileType); } else { @@ -1710,7 +1710,7 @@ public static function displayProfile(&$params, $gid, &$groupTitle, &$values, &$ $values[$index] = CRM_Utils_Date::customFormat(CRM_Utils_Date::format($params[$name])); } else { - $values[$index] = CRM_Utils_Array::value($name, $params); + $values[$index] = $params[$name] ?? NULL; } } } @@ -1780,8 +1780,8 @@ public static function buildCustomProfile( return $additionalIDs; } - $preProfileID = CRM_Utils_Array::value('additional_custom_pre_id', $values); - $postProfileID = CRM_Utils_Array::value('additional_custom_post_id', $values); + $preProfileID = $values['additional_custom_pre_id'] ?? NULL; + $postProfileID = $values['additional_custom_post_id'] ?? NULL; //else build array of Additional participant's information. if (count($additionalIDs)) { if ($preProfileID || $postProfileID) { diff --git a/CRM/Event/BAO/Participant.php b/CRM/Event/BAO/Participant.php index ed598bd5ce86..8117991b406f 100644 --- a/CRM/Event/BAO/Participant.php +++ b/CRM/Event/BAO/Participant.php @@ -97,7 +97,7 @@ public static function &add(&$params) { $participantBAO = new CRM_Event_BAO_Participant(); if (!empty($params['id'])) { - $participantBAO->id = CRM_Utils_Array::value('id', $params); + $participantBAO->id = $params['id'] ?? NULL; $participantBAO->find(TRUE); $participantBAO->register_date = CRM_Utils_Date::isoToMysql($participantBAO->register_date); } @@ -203,7 +203,7 @@ public static function create(&$params) { $session = CRM_Core_Session::singleton(); $id = $session->get('userID'); if (!$id) { - $id = CRM_Utils_Array::value('contact_id', $params); + $id = $params['contact_id'] ?? NULL; } // add custom field values @@ -666,7 +666,7 @@ public static function &importableFields($contactType = 'Individual', $status = 'column_name' ); $value = $customFieldId ? 'custom_' . $customFieldId : $value; - $tmpContactField[trim($value)] = CRM_Utils_Array::value(trim($value), $contactFields); + $tmpContactField[trim($value)] = $contactFields[trim($value)] ?? NULL; if (!$status) { $title = $tmpContactField[trim($value)]['title'] . ' (match to contact)'; } @@ -678,7 +678,7 @@ public static function &importableFields($contactType = 'Individual', $status = } } } - $extIdentifier = CRM_Utils_Array::value('external_identifier', $contactFields); + $extIdentifier = $contactFields['external_identifier'] ?? NULL; if ($extIdentifier) { $tmpContactField['external_identifier'] = $extIdentifier; $tmpContactField['external_identifier']['title'] = CRM_Utils_Array::value('title', $extIdentifier) . ' (match to contact)'; @@ -904,8 +904,8 @@ public static function deleteParticipant($id) { * @return CRM_Contribute_BAO_Contribution */ public static function checkDuplicate($input, &$duplicates) { - $eventId = CRM_Utils_Array::value('event_id', $input); - $contactId = CRM_Utils_Array::value('contact_id', $input); + $eventId = $input['event_id'] ?? NULL; + $contactId = $input['contact_id'] ?? NULL; $clause = []; $input = []; @@ -1283,7 +1283,7 @@ public static function transitionParticipants( CRM_Event_BAO_Event::retrieve($eventParams, $eventDetails[$eventId]); //get default participant role. - $eventDetails[$eventId]['participant_role'] = CRM_Utils_Array::value($eventDetails[$eventId]['default_role_id'], $participantRoles); + $eventDetails[$eventId]['participant_role'] = $participantRoles[$eventDetails[$eventId]['default_role_id']] ?? NULL; //get the location info $locParams = ['entity_id' => $eventId, 'entity_table' => 'civicrm_event']; @@ -1296,7 +1296,7 @@ public static function transitionParticipants( $emailType = NULL; $toStatus = $statusTypes[$toStatusId]; - $fromStatus = CRM_Utils_Array::value($fromStatusId, $statusTypes); + $fromStatus = $statusTypes[$fromStatusId] ?? NULL; switch ($toStatus) { case 'Pending from waitlist': @@ -1432,7 +1432,7 @@ public static function sendTransitionParticipantMail( ) { return $mailSent; } - $toEmail = CRM_Utils_Array::value('email', $contactDetails); + $toEmail = $contactDetails['email'] ?? NULL; if ($toEmail) { $contactId = $participantValues['contact_id']; @@ -1442,7 +1442,7 @@ public static function sendTransitionParticipantMail( $checksumValue = NULL; if ($mailType == 'Confirm' && !$participantValues['registered_by_id']) { $checksumLife = 'inf'; - $endDate = CRM_Utils_Array::value('end_date', $eventDetails); + $endDate = $eventDetails['end_date'] ?? NULL; if ($endDate) { $checksumLife = (CRM_Utils_Date::unixTime($endDate) - time()) / (60 * 60); } diff --git a/CRM/Event/BAO/ParticipantStatusType.php b/CRM/Event/BAO/ParticipantStatusType.php index 51be2dfd3e0a..b0166dbff2f1 100644 --- a/CRM/Event/BAO/ParticipantStatusType.php +++ b/CRM/Event/BAO/ParticipantStatusType.php @@ -168,7 +168,7 @@ public static function process($params) { continue; } - $expirationTime = CRM_Utils_Array::value('expiration_time', $values); + $expirationTime = $values['expiration_time'] ?? NULL; if ($expirationTime && array_key_exists($values['status_id'], $pendingStatuses)) { //get the expiration and registration pending time. diff --git a/CRM/Event/Cart/BAO/MerParticipant.php b/CRM/Event/Cart/BAO/MerParticipant.php index 0b672a168901..553ab9578b08 100644 --- a/CRM/Event/Cart/BAO/MerParticipant.php +++ b/CRM/Event/Cart/BAO/MerParticipant.php @@ -38,7 +38,7 @@ public function __construct($participant = NULL) { $a = (array) $participant; $this->copyValues($a); - $this->email = CRM_Utils_Array::value('email', $participant); + $this->email = $participant['email'] ?? NULL; } /** diff --git a/CRM/Event/Cart/Form/Checkout/ConferenceEvents.php b/CRM/Event/Cart/Form/Checkout/ConferenceEvents.php index 57e28b704550..8f68053a1df0 100644 --- a/CRM/Event/Cart/Form/Checkout/ConferenceEvents.php +++ b/CRM/Event/Cart/Form/Checkout/ConferenceEvents.php @@ -128,7 +128,7 @@ public function postProcess() { foreach ($this->events_by_slot as $slot_name => $events) { $slot_index++; $field_name = "slot_$slot_index"; - $session_event_id = CRM_Utils_Array::value($field_name, $params, NULL); + $session_event_id = $params[$field_name] ?? NULL; if (!$session_event_id) { continue; } diff --git a/CRM/Event/Cart/Form/Checkout/ParticipantsAndPrices.php b/CRM/Event/Cart/Form/Checkout/ParticipantsAndPrices.php index c9b2d90ea587..5067ccf33d0a 100644 --- a/CRM/Event/Cart/Form/Checkout/ParticipantsAndPrices.php +++ b/CRM/Event/Cart/Form/Checkout/ParticipantsAndPrices.php @@ -220,7 +220,7 @@ public function setDefaultValues() { $price_sets = CRM_Price_BAO_PriceSet::getSetDetail($price_set_id, TRUE, TRUE); $price_set = $price_sets[$price_set_id]; foreach ($price_set['fields'] as $field) { - $options = CRM_Utils_Array::value('options', $field); + $options = $field['options'] ?? NULL; if (!is_array($options)) { continue; } diff --git a/CRM/Event/Cart/Form/Checkout/Payment.php b/CRM/Event/Cart/Form/Checkout/Payment.php index 96a64ead5633..df500acf96f1 100644 --- a/CRM/Event/Cart/Form/Checkout/Payment.php +++ b/CRM/Event/Cart/Form/Checkout/Payment.php @@ -439,7 +439,7 @@ public function postProcess() { "email-{$this->_bltID}" => 1, ]; - $params["address_name-{$this->_bltID}"] = CRM_Utils_Array::value('billing_first_name', $params) . ' ' . CRM_Utils_Array::value('billing_middle_name', $params) . ' ' . CRM_Utils_Array::value('billing_last_name', $params); + $params["address_name-{$this->_bltID}"] = CRM_Utils_Array::value('billing_first_name', $params) . ' ' . CRM_Utils_Array::value('billing_middle_name', $params) . ' ' . $params['billing_last_name'] ?? NULL; $params["email-{$this->_bltID}"] = $params['billing_contact_email']; CRM_Contact_BAO_Contact::createProfileContact( @@ -712,7 +712,7 @@ protected function apply_discount($discountCode, &$price_set_amount, &$cost, $ev $stat = FALSE; foreach ($discounts as $key => $discountValue) { if ($key == $discountCode) { - $events = CRM_Utils_Array::value('events', $discountValue); + $events = $discountValue['events'] ?? NULL; $evt_ids = implode(",", $events); if ($evt_ids == "0" || strpos($evt_ids, $event_id)) { $event_match = TRUE; diff --git a/CRM/Event/Form/EventFees.php b/CRM/Event/Form/EventFees.php index 192e54008e2e..14be8ec5f6e8 100644 --- a/CRM/Event/Form/EventFees.php +++ b/CRM/Event/Form/EventFees.php @@ -254,8 +254,8 @@ public static function setDefaultPriceSet($participantID, $eventID = NULL, $incl $priceFields = $htmlTypes = $optionValues = []; foreach ($lineItems[$participantID] as $lineId => $items) { - $priceFieldId = CRM_Utils_Array::value('price_field_id', $items); - $priceOptionId = CRM_Utils_Array::value('price_field_value_id', $items); + $priceFieldId = $items['price_field_id'] ?? NULL; + $priceOptionId = $items['price_field_value_id'] ?? NULL; if ($priceFieldId && $priceOptionId) { $priceFields[$priceFieldId][] = $priceOptionId; } @@ -277,7 +277,7 @@ public static function setDefaultPriceSet($participantID, $eventID = NULL, $incl foreach ($lineItems[$participantID] as $lineId => $items) { $fieldId = $items['price_field_id']; - $htmlType = CRM_Utils_Array::value($fieldId, $htmlTypes); + $htmlType = $htmlTypes[$fieldId] ?? NULL; if (!$htmlType) { continue; } @@ -286,7 +286,7 @@ public static function setDefaultPriceSet($participantID, $eventID = NULL, $incl $defaults["price_{$fieldId}"] = $items['qty']; } else { - $fieldOptValues = CRM_Utils_Array::value($fieldId, $priceFields); + $fieldOptValues = $priceFields[$fieldId] ?? NULL; if (!is_array($fieldOptValues)) { continue; } diff --git a/CRM/Event/Form/ManageEvent.php b/CRM/Event/Form/ManageEvent.php index 19d2c816a16b..dda88ca5ec59 100644 --- a/CRM/Event/Form/ManageEvent.php +++ b/CRM/Event/Form/ManageEvent.php @@ -130,7 +130,7 @@ public function preProcess() { CRM_Core_Error::statusBounce(ts('You do not have permission to access this page.')); } - $participantListingID = CRM_Utils_Array::value('participant_listing_id', $eventInfo); + $participantListingID = $eventInfo['participant_listing_id'] ?? NULL; //CRM_Core_DAO::getFieldValue( 'CRM_Event_DAO_Event', $this->_id, 'participant_listing_id' ); if ($participantListingID) { $participantListingURL = CRM_Utils_System::url('civicrm/event/participant', @@ -147,7 +147,7 @@ public function preProcess() { // figure out whether we’re handling an event or an event template if ($this->_id) { - $this->_isTemplate = CRM_Utils_Array::value('is_template', $eventInfo); + $this->_isTemplate = $eventInfo['is_template'] ?? NULL; } elseif ($this->_action & CRM_Core_Action::ADD) { $this->_isTemplate = CRM_Utils_Request::retrieve('is_template', 'Boolean', $this); @@ -159,11 +159,11 @@ public function preProcess() { $title = NULL; if ($this->_id) { if ($this->_isTemplate) { - $title = ts('Edit Event Template') . ' - ' . CRM_Utils_Array::value('template_title', $eventInfo); + $title = ts('Edit Event Template') . ' - ' . $eventInfo['template_title'] ?? NULL; } else { $configureText = $this->_isRepeatingEvent ? ts('Configure Repeating Event') : ts('Configure Event'); - $title = $configureText . ' - ' . CRM_Utils_Array::value('title', $eventInfo); + $title = $configureText . ' - ' . $eventInfo['title'] ?? NULL; } } elseif ($this->_action & CRM_Core_Action::ADD) { @@ -250,7 +250,7 @@ public function setDefaultValues() { $params = ['id' => $this->_id]; CRM_Event_BAO_Event::retrieve($params, $defaults); - $this->_campaignID = CRM_Utils_Array::value('campaign_id', $defaults); + $this->_campaignID = $defaults['campaign_id'] ?? NULL; } elseif ($this->_templateId) { $params = ['id' => $this->_templateId]; @@ -275,7 +275,7 @@ public function setDefaultValues() { public function buildQuickForm() { $session = CRM_Core_Session::singleton(); - $this->_cancelURL = CRM_Utils_Array::value('cancelURL', $_POST); + $this->_cancelURL = $_POST['cancelURL'] ?? NULL; if (!$this->_cancelURL) { if ($this->_isTemplate) { @@ -372,8 +372,8 @@ public function endPostProcess() { $config = CRM_Core_Config::singleton(); if (in_array('CiviCampaign', $config->enableComponents)) { $values = $this->controller->exportValues($this->_name); - $newCampaignID = CRM_Utils_Array::value('campaign_id', $values); - $eventID = CRM_Utils_Array::value('id', $values); + $newCampaignID = $values['campaign_id'] ?? NULL; + $eventID = $values['id'] ?? NULL; if ($eventID && $this->_campaignID != $newCampaignID) { CRM_Event_BAO_Event::updateParticipantCampaignID($eventID, $newCampaignID); } diff --git a/CRM/Event/Form/ManageEvent/EventInfo.php b/CRM/Event/Form/ManageEvent/EventInfo.php index c72fc7e27a24..a820295fa163 100644 --- a/CRM/Event/Form/ManageEvent/EventInfo.php +++ b/CRM/Event/Form/ManageEvent/EventInfo.php @@ -215,8 +215,8 @@ public function postProcess() { $params = array_merge($this->controller->exportValues($this->_name), $this->_submitValues); //format params - $params['start_date'] = CRM_Utils_Array::value('start_date', $params); - $params['end_date'] = CRM_Utils_Array::value('end_date', $params); + $params['start_date'] = $params['start_date'] ?? NULL; + $params['end_date'] = $params['end_date'] ?? NULL; $params['has_waitlist'] = CRM_Utils_Array::value('has_waitlist', $params, FALSE); $params['is_map'] = CRM_Utils_Array::value('is_map', $params, FALSE); $params['is_active'] = CRM_Utils_Array::value('is_active', $params, FALSE); diff --git a/CRM/Event/Form/ManageEvent/Fee.php b/CRM/Event/Form/ManageEvent/Fee.php index c09d9c91992d..1462a3697c73 100644 --- a/CRM/Event/Form/ManageEvent/Fee.php +++ b/CRM/Event/Form/ManageEvent/Fee.php @@ -476,7 +476,7 @@ public static function formRule($values) { } } - $default = CRM_Utils_Array::value('default', $values); + $default = $values['default'] ?? NULL; if ($default && !in_array($default, $optionKeys)) { $errors['default'] = ts('Please select an appropriate option as default.'); } @@ -577,9 +577,9 @@ public function postProcess() { } else { // if there are label / values, create custom options for them - $labels = CRM_Utils_Array::value('label', $params); - $values = CRM_Utils_Array::value('value', $params); - $default = CRM_Utils_Array::value('default', $params); + $labels = $params['label'] ?? NULL; + $values = $params['value'] ?? NULL; + $default = $params['default'] ?? NULL; $options = []; if (!CRM_Utils_System::isNull($labels) && !CRM_Utils_System::isNull($values)) { for ($i = 1; $i < self::NUM_OPTION; $i++) { @@ -624,7 +624,7 @@ public function postProcess() { unset($params['price_field_value'][$arrayID]); } } - $fieldParams['id'] = CRM_Utils_Array::value('price_field_id', $params); + $fieldParams['id'] = $params['price_field_id'] ?? NULL; $fieldParams['option_id'] = $params['price_field_value']; $priceSet = new CRM_Price_BAO_PriceSet(); @@ -654,9 +654,9 @@ public function postProcess() { if (CRM_Utils_Array::value('is_discount', $params) == 1) { // if there are discounted set of label / values, // create custom options for them - $labels = CRM_Utils_Array::value('discounted_label', $params); - $values = CRM_Utils_Array::value('discounted_value', $params); - $default = CRM_Utils_Array::value('discounted_default', $params); + $labels = $params['discounted_label'] ?? NULL; + $values = $params['discounted_value'] ?? NULL; + $default = $params['discounted_default'] ?? NULL; if (!CRM_Utils_System::isNull($labels) && !CRM_Utils_System::isNull($values)) { for ($j = 1; $j <= self::NUM_DISCOUNT; $j++) { diff --git a/CRM/Event/Form/ManageEvent/Registration.php b/CRM/Event/Form/ManageEvent/Registration.php index f3244105e58b..9cbf60c8aac1 100644 --- a/CRM/Event/Form/ManageEvent/Registration.php +++ b/CRM/Event/Form/ManageEvent/Registration.php @@ -102,7 +102,7 @@ public function setDefaultValues() { // Set event registration as the default profile if none selected if (!$defaults['custom_pre_id'] && count($defaults['custom_post']) == 0) { - $defaults['custom_pre_id'] = CRM_Utils_Array::value('id', $eventRegistrationIdDefaults); + $defaults['custom_pre_id'] = $eventRegistrationIdDefaults['id'] ?? NULL; } if (isset($defaults['custom_post']) && is_numeric($defaults['custom_post'])) { $defaults['custom_post_id'] = $defaults['custom_post']; @@ -499,7 +499,7 @@ public static function formRule($values, $files, $form) { $profiles = CRM_Core_BAO_UFGroup::getProfiles($types); //check for additional custom pre profile - $additionalCustomPreId = CRM_Utils_Array::value('additional_custom_pre_id', $values); + $additionalCustomPreId = $values['additional_custom_pre_id'] ?? NULL; if (!empty($additionalCustomPreId)) { if (!($additionalCustomPreId == 'none')) { $customPreId = $additionalCustomPreId; @@ -527,7 +527,7 @@ public static function formRule($values, $files, $form) { // We don't have required Individual fields in the pre-custom profile, so now check the post-custom profile if ($isPreError) { - $additionalCustomPostId = CRM_Utils_Array::value('additional_custom_post_id', $values); + $additionalCustomPostId = $values['additional_custom_post_id'] ?? NULL; if (!empty($additionalCustomPostId)) { if (!($additionalCustomPostId == 'none')) { $customPostId = $additionalCustomPostId; diff --git a/CRM/Event/Form/Participant.php b/CRM/Event/Form/Participant.php index 9a955b3cba99..3e022e477e41 100644 --- a/CRM/Event/Form/Participant.php +++ b/CRM/Event/Form/Participant.php @@ -266,7 +266,7 @@ public function getDefaultContext() { */ public function preProcess() { parent::preProcess(); - $this->_showFeeBlock = CRM_Utils_Array::value('eventId', $_GET); + $this->_showFeeBlock = $_GET['eventId'] ?? NULL; $this->assign('showFeeBlock', FALSE); $this->assign('feeBlockPaid', FALSE); @@ -421,7 +421,7 @@ public function preProcess() { // when custom data is included in this page if (!empty($_POST['hidden_custom'])) { - $eventId = (int) CRM_Utils_Array::value('event_id', $_POST); + $eventId = (int) $_POST['event_id'] ?? NULL; // Custom data of type participant role // Note: Some earlier commits imply $_POST['role_id'] could be a comma separated string, // not sure if that ever really happens @@ -522,7 +522,7 @@ public function setDefaultValues() { //setting default register date if ($this->_action == CRM_Core_Action::ADD) { $statuses = array_flip(CRM_Event_PseudoConstant::participantStatus()); - $defaults[$this->_id]['status_id'] = CRM_Utils_Array::value('Registered', $statuses); + $defaults[$this->_id]['status_id'] = $statuses['Registered'] ?? NULL; if (!empty($defaults[$this->_id]['event_id'])) { $contributionTypeId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $defaults[$this->_id]['event_id'], @@ -893,13 +893,13 @@ public static function formRule($values, $files, $self) { // for this event. if ($self->_single && ($self->_action & CRM_Core_Action::ADD)) { if ($self->_context == 'standalone') { - $contactId = CRM_Utils_Array::value('contact_id', $values); + $contactId = $values['contact_id'] ?? NULL; } else { $contactId = $self->_contactId; } - $eventId = CRM_Utils_Array::value('event_id', $values); + $eventId = $values['event_id'] ?? NULL; $event = new CRM_Event_DAO_Event(); $event->id = $eventId; @@ -1061,7 +1061,7 @@ public function submit($params) { // overwrite actual payment amount if entered if (!empty($params['total_amount'])) { - $contributionParams['total_amount'] = CRM_Utils_Array::value('total_amount', $params); + $contributionParams['total_amount'] = $params['total_amount'] ?? NULL; } // Retrieve the name and email of the current user - this will be the FROM for the receipt email @@ -1110,7 +1110,7 @@ public function submit($params) { $params["address_name-{$this->_bltID}"] = CRM_Utils_Array::value('billing_first_name', $params) . ' ' . CRM_Utils_Array::value('billing_middle_name', $params) . ' ' . - CRM_Utils_Array::value('billing_last_name', $params); + $params['billing_last_name'] ?? NULL; $params["address_name-{$this->_bltID}"] = trim($params["address_name-{$this->_bltID}"]); $fields["address_name-{$this->_bltID}"] = 1; @@ -1337,7 +1337,7 @@ public function submit($params) { ]; foreach ($recordContribution as $f) { - $contributionParams[$f] = CRM_Utils_Array::value($f, $this->_params); + $contributionParams[$f] = $this->_params[$f] ?? NULL; if ($f == 'trxn_id') { $this->assign('trxn_id', $contributionParams[$f]); } @@ -1548,7 +1548,7 @@ public function submit($params) { // fix amount for each of participants ( for bulk mode ) $eventAmount = []; $invoiceSettings = Civi::settings()->get('contribution_invoice_settings'); - $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings); + $invoicing = $invoiceSettings['invoicing'] ?? NULL; $totalTaxAmount = 0; //add dataArray in the receipts in ADD and UPDATE condition @@ -1564,10 +1564,10 @@ public function submit($params) { if (isset($value['tax_amount'])) { $totalTaxAmount += $value['tax_amount']; if (isset($dataArray[(string) $value['tax_rate']])) { - $dataArray[(string) $value['tax_rate']] = $dataArray[(string) $value['tax_rate']] + CRM_Utils_Array::value('tax_amount', $value); + $dataArray[(string) $value['tax_rate']] = $dataArray[(string) $value['tax_rate']] + $value['tax_amount'] ?? NULL; } else { - $dataArray[(string) $value['tax_rate']] = CRM_Utils_Array::value('tax_amount', $value); + $dataArray[(string) $value['tax_rate']] = $value['tax_amount'] ?? NULL; } } } @@ -1606,8 +1606,8 @@ public function submit($params) { $sendTemplateParams['from'] = $receiptFrom; $sendTemplateParams['toName'] = $this->_contributorDisplayName; $sendTemplateParams['toEmail'] = $this->_contributorEmail; - $sendTemplateParams['cc'] = CRM_Utils_Array::value('cc', $this->_fromEmails); - $sendTemplateParams['bcc'] = CRM_Utils_Array::value('bcc', $this->_fromEmails); + $sendTemplateParams['cc'] = $this->_fromEmails['cc'] ?? NULL; + $sendTemplateParams['bcc'] = $this->_fromEmails['bcc'] ?? NULL; } //send email with pdf invoice @@ -1617,7 +1617,7 @@ public function submit($params) { $this->_id, 'contribution_id', 'participant_id' ); $prefixValue = Civi::settings()->get('contribution_invoice_settings'); - $invoicing = CRM_Utils_Array::value('invoicing', $prefixValue); + $invoicing = $prefixValue['invoicing'] ?? NULL; if (!empty($taxAmt) && (isset($invoicing) && isset($prefixValue['is_email_pdf']))) { $sendTemplateParams['isEmailPdf'] = TRUE; $sendTemplateParams['contributionId'] = $contributionId; @@ -1627,7 +1627,7 @@ public function submit($params) { $sent[] = $contactID; foreach ($participants as $ids => $values) { if ($values->contact_id == $contactID) { - $values->details = CRM_Utils_Array::value('receipt_text', $params); + $values->details = $params['receipt_text'] ?? NULL; CRM_Activity_BAO_Activity::addActivity($values, 'Email'); break; } @@ -1732,7 +1732,7 @@ public function buildEventFeeForm($form) { CRM_Event_Form_Registration_Register::buildAmount($form, TRUE, $form->_discountId); $lineItem = []; $invoiceSettings = Civi::settings()->get('contribution_invoice_settings'); - $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings); + $invoicing = $invoiceSettings['invoicing'] ?? NULL; $totalTaxAmount = 0; if (!CRM_Utils_System::isNull(CRM_Utils_Array::value('line_items', $form->_values))) { $lineItem[] = $form->_values['line_items']; @@ -1907,8 +1907,8 @@ protected function preparePaidEventProcessing($params): array { //CRM-11529 for quick config backoffice transactions //when financial_type_id is passed in form, update the //lineitems with the financial type selected in form - $submittedFinancialType = CRM_Utils_Array::value('financial_type_id', $params); - $isPaymentRecorded = CRM_Utils_Array::value('record_contribution', $params); + $submittedFinancialType = $params['financial_type_id'] ?? NULL; + $isPaymentRecorded = $params['record_contribution'] ?? NULL; if ($isPaymentRecorded && $this->_quickConfig && $submittedFinancialType) { foreach ($lineItem[0] as &$values) { $values['financial_type_id'] = $submittedFinancialType; @@ -1984,7 +1984,7 @@ protected function assignEventDetailsToTpl($eventID, $participantRoles, $receipt $event['participant_role'] = implode(', ', $selectedRoles); } else { - $event['participant_role'] = CRM_Utils_Array::value($participantRoles, $role); + $event['participant_role'] = $role[$participantRoles] ?? NULL; } $event['is_monetary'] = $isPaidEvent; diff --git a/CRM/Event/Form/ParticipantFeeSelection.php b/CRM/Event/Form/ParticipantFeeSelection.php index bc604dbbc2f9..9cfa7ce2dab2 100644 --- a/CRM/Event/Form/ParticipantFeeSelection.php +++ b/CRM/Event/Form/ParticipantFeeSelection.php @@ -296,7 +296,7 @@ public function emailReceipt(&$params) { unset($event['end_date']); $role = CRM_Event_PseudoConstant::participantRole(); - $participantRoles = CRM_Utils_Array::value('role_id', $params); + $participantRoles = $params['role_id'] ?? NULL; if (is_array($participantRoles)) { $selectedRoles = []; foreach (array_keys($participantRoles) as $roleId) { @@ -305,7 +305,7 @@ public function emailReceipt(&$params) { $event['participant_role'] = implode(', ', $selectedRoles); } else { - $event['participant_role'] = CRM_Utils_Array::value($participantRoles, $role); + $event['participant_role'] = $role[$participantRoles] ?? NULL; } $event['is_monetary'] = $this->_isPaidEvent; @@ -374,8 +374,8 @@ public function emailReceipt(&$params) { $sendTemplateParams['from'] = $receiptFrom; $sendTemplateParams['toName'] = $this->_contributorDisplayName; $sendTemplateParams['toEmail'] = $this->_contributorEmail; - $sendTemplateParams['cc'] = CRM_Utils_Array::value('cc', $this->_fromEmails); - $sendTemplateParams['bcc'] = CRM_Utils_Array::value('bcc', $this->_fromEmails); + $sendTemplateParams['cc'] = $this->_fromEmails['cc'] ?? NULL; + $sendTemplateParams['bcc'] = $this->_fromEmails['bcc'] ?? NULL; } list($mailSent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams); diff --git a/CRM/Event/Form/ParticipantView.php b/CRM/Event/Form/ParticipantView.php index 0d67d1033edc..efe72c2e7872 100644 --- a/CRM/Event/Form/ParticipantView.php +++ b/CRM/Event/Form/ParticipantView.php @@ -117,7 +117,7 @@ public function preProcess() { $values[$participantID]['lineItem'][] = $lineItem; } - $values[$participantID]['totalAmount'] = CRM_Utils_Array::value('fee_amount', $values[$participantID]); + $values[$participantID]['totalAmount'] = $values[$participantID]['fee_amount'] ?? NULL; // Get registered_by contact ID and display_name if participant was registered by someone else (CRM-4859) if (!empty($values[$participantID]['participant_registered_by_id'])) { @@ -193,7 +193,7 @@ public function preProcess() { $participantCount = []; $invoiceSettings = Civi::settings()->get('contribution_invoice_settings'); - $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings); + $invoicing = $invoiceSettings['invoicing'] ?? NULL; $totalTaxAmount = 0; foreach ($lineItem as $k => $v) { if (CRM_Utils_Array::value('participant_count', $lineItem[$k]) > 0) { @@ -211,7 +211,7 @@ public function preProcess() { // omitting contactImage from title for now since the summary overlay css doesn't work outside of our crm-container CRM_Utils_System::setTitle(ts('View Event Registration for') . ' ' . $displayName); - $roleId = CRM_Utils_Array::value('role_id', $values[$participantID]); + $roleId = $values[$participantID]['role_id'] ?? NULL; $title = $displayName . ' (' . CRM_Utils_Array::value($roleId, $participantRoles) . ' - ' . $eventTitle . ')'; $sep = CRM_Core_DAO::VALUE_SEPARATOR; diff --git a/CRM/Event/Form/Registration.php b/CRM/Event/Form/Registration.php index 007e9b40176e..efa71d460556 100644 --- a/CRM/Event/Form/Registration.php +++ b/CRM/Event/Form/Registration.php @@ -238,7 +238,7 @@ public function preProcess() { $params = array('id' => $this->_eventId); CRM_Event_BAO_Event::retrieve($params, $this->_values['event']); // check for is_monetary status - $isMonetary = CRM_Utils_Array::value('is_monetary', $this->_values['event']); + $isMonetary = $this->_values['event']['is_monetary'] ?? NULL; // check for ability to add contributions of type if ($isMonetary && CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus() @@ -272,7 +272,7 @@ public function preProcess() { if ($eventFull && !$this->_allowConfirmation) { $this->_isEventFull = TRUE; //lets redirecting to info only when to waiting list. - $this->_allowWaitlist = CRM_Utils_Array::value('has_waitlist', $this->_values['event']); + $this->_allowWaitlist = $this->_values['event']['has_waitlist'] ?? NULL; if (!$this->_allowWaitlist) { CRM_Utils_System::redirect($infoUrl); } @@ -380,21 +380,21 @@ public function preProcess() { // we do not want to display recently viewed items on Registration pages $this->assign('displayRecent', FALSE); - $isShowLocation = CRM_Utils_Array::value('is_show_location', $this->_values['event']); + $isShowLocation = $this->_values['event']['is_show_location'] ?? NULL; $this->assign('isShowLocation', $isShowLocation); // Handle PCP $pcpId = CRM_Utils_Request::retrieve('pcpId', 'Positive', $this); if ($pcpId) { $pcp = CRM_PCP_BAO_PCP::handlePcp($pcpId, 'event', $this->_values['event']); $this->_pcpId = $pcp['pcpId']; - $this->_values['event']['intro_text'] = CRM_Utils_Array::value('intro_text', $pcp['pcpInfo']); + $this->_values['event']['intro_text'] = $pcp['pcpInfo']['intro_text'] ?? NULL; } // assign all event properties so wizard templates can display event info. $this->assign('event', $this->_values['event']); $this->assign('location', $this->_values['location']); $this->assign('bltID', $this->_bltID); - $isShowLocation = CRM_Utils_Array::value('is_show_location', $this->_values['event']); + $isShowLocation = $this->_values['event']['is_show_location'] ?? NULL; $this->assign('isShowLocation', $isShowLocation); CRM_Contribute_BAO_Contribution_Utils::overrideDefaultCurrency($this->_values['event']); @@ -405,13 +405,13 @@ public function preProcess() { } // Set the same value for is_billing_required as contribution page so code can be shared. - $this->_values['is_billing_required'] = CRM_Utils_Array::value('is_billing_required', $this->_values['event']); + $this->_values['is_billing_required'] = $this->_values['event']['is_billing_required'] ?? NULL; // check if billing block is required for pay later // note that I have started removing the use of isBillingAddressRequiredForPayLater in favour of letting // the CRM_Core_Payment_Manual class handle it - but there are ~300 references to it in the code base so only // removing in very limited cases. if (!empty($this->_values['event']['is_pay_later'])) { - $this->_isBillingAddressRequiredForPayLater = CRM_Utils_Array::value('is_billing_required', $this->_values['event']); + $this->_isBillingAddressRequiredForPayLater = $this->_values['event']['is_billing_required'] ?? NULL; $this->assign('isBillingAddressRequiredForPayLater', $this->_isBillingAddressRequiredForPayLater); } } @@ -630,8 +630,8 @@ public static function initEventFee(&$form, $eventID, $includeExpiredFields = TR if (is_array($discountedEvent)) { foreach ($discountedEvent as $key => $priceSetId) { $priceSet = CRM_Price_BAO_PriceSet::getSetDetail($priceSetId); - $priceSet = CRM_Utils_Array::value($priceSetId, $priceSet); - $form->_values['discount'][$key] = CRM_Utils_Array::value('fields', $priceSet); + $priceSet = $priceSet[$priceSetId] ?? NULL; + $form->_values['discount'][$key] = $priceSet['fields'] ?? NULL; $fieldID = key($form->_values['discount'][$key]); $form->_values['discount'][$key][$fieldID]['name'] = CRM_Core_DAO::getFieldValue( 'CRM_Price_DAO_PriceSet', @@ -641,7 +641,7 @@ public static function initEventFee(&$form, $eventID, $includeExpiredFields = TR } } } - $eventFee = CRM_Utils_Array::value('fee', $form->_values); + $eventFee = $form->_values['fee'] ?? NULL; if (!is_array($eventFee) || empty($eventFee)) { $form->_values['fee'] = array(); } @@ -651,7 +651,7 @@ public static function initEventFee(&$form, $eventID, $includeExpiredFields = TR $isPaidEvent = $form->_isPaidEvent; } else { - $isPaidEvent = CRM_Utils_Array::value('is_monetary', $form->_values['event']); + $isPaidEvent = $form->_values['event']['is_monetary'] ?? NULL; } if (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus() && !empty($form->_values['fee']) @@ -912,7 +912,7 @@ public static function getParticipantCount(&$form, $params, $skipCurrent = FALSE $count = 1; $usedCache = FALSE; - $cacheCount = CRM_Utils_Array::value($key, $form->_lineItemParticipantsCount); + $cacheCount = $form->_lineItemParticipantsCount[$key] ?? NULL; if ($cacheCount && is_numeric($cacheCount)) { $count = $cacheCount; $usedCache = TRUE; @@ -1212,7 +1212,7 @@ public static function resetSubmittedValue($elementName, $optionIds = array(), & if (!is_array($values) || empty($values)) { continue; } - $eleVal = CRM_Utils_Array::value($elementName, $values); + $eleVal = $values[$elementName] ?? NULL; if (empty($eleVal)) { continue; } @@ -1567,7 +1567,7 @@ public function processRegistration($params, $contactID = NULL) { //lets get additional participant id to cancel. if ($this->_allowConfirmation && is_array($cancelledIds)) { - $additonalId = CRM_Utils_Array::value('participant_id', $value); + $additonalId = $value['participant_id'] ?? NULL; if ($additonalId && $key = array_search($additonalId, $cancelledIds)) { unset($cancelledIds[$key]); } diff --git a/CRM/Event/Form/Registration/AdditionalParticipant.php b/CRM/Event/Form/Registration/AdditionalParticipant.php index 679139f75726..c29163ef0a73 100644 --- a/CRM/Event/Form/Registration/AdditionalParticipant.php +++ b/CRM/Event/Form/Registration/AdditionalParticipant.php @@ -39,7 +39,7 @@ public function preProcess() { //lets process in-queue participants. if ($this->_participantId && $this->_additionalParticipantIds) { - $this->_additionalParticipantId = CRM_Utils_Array::value($participantNo, $this->_additionalParticipantIds); + $this->_additionalParticipantId = $this->_additionalParticipantIds[$participantNo] ?? NULL; } $participantCnt = $participantNo + 1; @@ -130,7 +130,7 @@ public function setDefaultValues() { //load default campaign from page. if (array_key_exists('participant_campaign_id', $this->_fields)) { - $defaults['participant_campaign_id'] = CRM_Utils_Array::value('campaign_id', $this->_values['event']); + $defaults['participant_campaign_id'] = $this->_values['event']['campaign_id'] ?? NULL; } //CRM-17865 set custom field defaults @@ -215,7 +215,7 @@ public function buildQuickForm() { //lets allow to become a part of runtime waiting list, if primary selected pay later. $realPayLater = FALSE; if (!empty($this->_values['event']['is_monetary']) && !empty($this->_values['event']['is_pay_later'])) { - $realPayLater = CRM_Utils_Array::value('is_pay_later', $this->_params[0]); + $realPayLater = $this->_params[0]['is_pay_later'] ?? NULL; } //truly spaces are greater than required. @@ -360,7 +360,7 @@ public static function formRule($fields, $files, $self) { $realPayLater = FALSE; if (!empty($self->_values['event']['is_monetary']) && !empty($self->_values['event']['is_pay_later'])) { - $realPayLater = CRM_Utils_Array::value('is_pay_later', $self->_params[0]); + $realPayLater = $self->_params[0]['is_pay_later'] ?? NULL; } if ($button != 'skip') { @@ -579,7 +579,7 @@ public function postProcess() { $params['campaign_id'] = $params['participant_campaign_id']; } else { - $params['campaign_id'] = CRM_Utils_Array::value('campaign_id', $this->_values['event']); + $params['campaign_id'] = $this->_values['event']['campaign_id'] ?? NULL; } // if waiting is enabled diff --git a/CRM/Event/Form/Registration/Confirm.php b/CRM/Event/Form/Registration/Confirm.php index 060df998c8c8..4eb2a005972d 100644 --- a/CRM/Event/Form/Registration/Confirm.php +++ b/CRM/Event/Form/Registration/Confirm.php @@ -227,7 +227,7 @@ public function buildQuickForm() { } $this->_amount[$k]['label'] = preg_replace('//', '', $v['amount_level']) . ' - ' . $append; - $this->_part[$k]['info'] = CRM_Utils_Array::value('first_name', $v) . ' ' . CRM_Utils_Array::value('last_name', $v); + $this->_part[$k]['info'] = CRM_Utils_Array::value('first_name', $v) . ' ' . $v['last_name'] ?? NULL; if (empty($v['first_name'])) { $this->_part[$k]['info'] = $append; } @@ -391,7 +391,7 @@ public function postProcess() { foreach ($this->_params as $k => $v) { if (CRM_Utils_Array::value('amount', $this->_params[$k]) > 0 && !empty($this->_params[$k]['discountAmount'])) { $this->_params[$k]['amount'] -= $this->_params[$k]['discountAmount']; - $this->_params[$k]['amount_level'] .= CRM_Utils_Array::value('discountMessage', $this->_params[$k]); + $this->_params[$k]['amount_level'] .= $this->_params[$k]['discountMessage'] ?? NULL; } } $this->set('params', $this->_params); @@ -426,7 +426,7 @@ public function postProcess() { } //lets get additional participant id to cancel. if ($this->_allowConfirmation && is_array($cancelledIds)) { - $additonalId = CRM_Utils_Array::value('participant_id', $record); + $additonalId = $record['participant_id'] ?? NULL; if ($additonalId && $key = array_search($additonalId, $cancelledIds)) { unset($cancelledIds[$key]); } @@ -473,7 +473,7 @@ public function postProcess() { //Unset ContactID for additional participants and set RegisterBy Id. if (empty($value['is_primary'])) { - $contactID = CRM_Utils_Array::value('contact_id', $value); + $contactID = $value['contact_id'] ?? NULL; $registerByID = $this->get('registerByID'); if ($registerByID) { $value['registered_by_id'] = $registerByID; @@ -600,7 +600,7 @@ public function postProcess() { //CRM-4453. if (!empty($value['is_primary'])) { - $primaryCurrencyID = CRM_Utils_Array::value('currencyID', $value); + $primaryCurrencyID = $value['currencyID'] ?? NULL; } if (empty($value['currencyID'])) { $value['currencyID'] = $primaryCurrencyID; @@ -619,12 +619,12 @@ public function postProcess() { } } - $value['fee_amount'] = CRM_Utils_Array::value('amount', $value); + $value['fee_amount'] = $value['amount'] ?? NULL; $this->set('value', $value); // handle register date CRM-4320 if ($this->_allowConfirmation) { - $registerDate = CRM_Utils_Array::value('participant_register_date', $params); + $registerDate = $params['participant_register_date'] ?? NULL; } elseif (!empty($params['participant_register_date']) && is_array($params['participant_register_date']) @@ -680,10 +680,10 @@ public function postProcess() { if (isset($line['tax_amount']) && isset($line['tax_rate'])) { $totalTaxAmount = $line['tax_amount'] + $totalTaxAmount; if (isset($dataArray[$line['tax_rate']])) { - $dataArray[$line['tax_rate']] = $dataArray[$line['tax_rate']] + CRM_Utils_Array::value('tax_amount', $line); + $dataArray[$line['tax_rate']] = $dataArray[$line['tax_rate']] + $line['tax_amount'] ?? NULL; } else { - $dataArray[$line['tax_rate']] = CRM_Utils_Array::value('tax_amount', $line); + $dataArray[$line['tax_rate']] = $line['tax_amount'] ?? NULL; } } } @@ -1049,7 +1049,7 @@ public static function fixLocationFields(&$params, &$fields, &$form) { // Add the billing names to the billing address, if a billing name is set if (!empty($params['billing_first_name'])) { - $params["address_name-{$form->_bltID}"] = CRM_Utils_Array::value('billing_first_name', $params) . ' ' . CRM_Utils_Array::value('billing_middle_name', $params) . ' ' . CRM_Utils_Array::value('billing_last_name', $params); + $params["address_name-{$form->_bltID}"] = CRM_Utils_Array::value('billing_first_name', $params) . ' ' . CRM_Utils_Array::value('billing_middle_name', $params) . ' ' . $params['billing_last_name'] ?? NULL; $fields["address_name-{$form->_bltID}"] = 1; } @@ -1156,7 +1156,7 @@ public static function updateContactFields($contactID, $params, $fields, &$form) //get email primary first if exist $subscriptionEmail = ['email' => CRM_Utils_Array::value('email-Primary', $params)]; if (!$subscriptionEmail['email']) { - $subscriptionEmail['email'] = CRM_Utils_Array::value("email-{$form->_bltID}", $params); + $subscriptionEmail['email'] = $params["email-{$form->_bltID}"] ?? NULL; } // subscribing contact to groups if (!empty($subscribeGroupIds) && $subscriptionEmail['email']) { @@ -1200,7 +1200,7 @@ public static function assignProfiles($form) { if (count($values)) { $formattedValues[$count][$prefix1 . 'CustomPre'] = $values; } - $formattedValues[$count][$prefix1 . 'CustomPreGroupTitle'] = CRM_Utils_Array::value('groupTitle', $groupName); + $formattedValues[$count][$prefix1 . 'CustomPreGroupTitle'] = $groupName['groupTitle'] ?? NULL; } //get the customPost profile info if (!empty($form->_values[$prefix2 . 'custom_post_id'])) { @@ -1259,9 +1259,9 @@ public static function testSubmit($params) { // This happens in buildQuickForm so emulate here. $form->_amount = $form->_totalAmount = CRM_Utils_Rule::cleanMoney(CRM_Utils_Array::value('totalAmount', $params)); $form->set('params', $params['params']); - $form->_values['custom_pre_id'] = CRM_Utils_Array::value('custom_pre_id', $params); - $form->_values['custom_post_id'] = CRM_Utils_Array::value('custom_post_id', $params); - $form->_values['event'] = CRM_Utils_Array::value('event', $params); + $form->_values['custom_pre_id'] = $params['custom_pre_id'] ?? NULL; + $form->_values['custom_post_id'] = $params['custom_post_id'] ?? NULL; + $form->_values['event'] = $params['event'] ?? NULL; $form->_contributeMode = $params['contributeMode']; $eventParams = ['id' => $params['id']]; CRM_Event_BAO_Event::retrieve($eventParams, $form->_values['event']); diff --git a/CRM/Event/Form/Registration/ParticipantConfirm.php b/CRM/Event/Form/Registration/ParticipantConfirm.php index 6c23fce62082..4a4b95b5c0c5 100644 --- a/CRM/Event/Form/Registration/ParticipantConfirm.php +++ b/CRM/Event/Form/Registration/ParticipantConfirm.php @@ -50,9 +50,9 @@ public function preProcess() { ); } - $this->_participantStatusId = CRM_Utils_Array::value('status_id', $values); - $this->_eventId = CRM_Utils_Array::value('event_id', $values); - $csContactId = CRM_Utils_Array::value('contact_id', $values); + $this->_participantStatusId = $values['status_id'] ?? NULL; + $this->_eventId = $values['event_id'] ?? NULL; + $csContactId = $values['contact_id'] ?? NULL; // make sure we have right permission to edit this user $this->_csContactID = NULL; diff --git a/CRM/Event/Form/Registration/Register.php b/CRM/Event/Form/Registration/Register.php index acbc6afed2f6..1d326b88eaa6 100644 --- a/CRM/Event/Form/Registration/Register.php +++ b/CRM/Event/Form/Registration/Register.php @@ -152,7 +152,7 @@ public function preProcess() { $this->_allowWaitlist = FALSE; if ($eventFull && !$this->_allowConfirmation && !empty($this->_values['event']['has_waitlist'])) { $this->_allowWaitlist = TRUE; - $this->_waitlistMsg = CRM_Utils_Array::value('waitlist_text', $this->_values['event']); + $this->_waitlistMsg = $this->_values['event']['waitlist_text'] ?? NULL; if (!$this->_waitlistMsg) { $this->_waitlistMsg = ts('This event is currently full. However you can register now and get added to a waiting list. You will be notified if spaces become available.'); } @@ -523,14 +523,14 @@ public static function buildAmount(&$form, $required = TRUE, $discountId = NULL) return; } - $feeFields = CRM_Utils_Array::value('fee', $form->_values); + $feeFields = $form->_values['fee'] ?? NULL; if (is_array($feeFields)) { $form->_feeBlock = &$form->_values['fee']; } //check for discount. - $discountedFee = CRM_Utils_Array::value('discount', $form->_values); + $discountedFee = $form->_values['discount'] ?? NULL; if (is_array($discountedFee) && !empty($discountedFee)) { if (!$discountId) { $form->_discountId = $discountId = CRM_Core_BAO_Discount::findSet($form->_eventId, 'civicrm_event'); @@ -586,13 +586,13 @@ public static function buildAmount(&$form, $required = TRUE, $discountId = NULL) $fieldId = $field['id']; $elementName = 'price_' . $fieldId; - $isRequire = CRM_Utils_Array::value('is_required', $field); + $isRequire = $field['is_required'] ?? NULL; if ($button == 'skip') { $isRequire = FALSE; } //user might modified w/ hook. - $options = CRM_Utils_Array::value('options', $field); + $options = $field['options'] ?? NULL; $formClasses = ['CRM_Event_Form_Participant', 'CRM_Event_Form_ParticipantFeeSelection']; if (!is_array($options)) { @@ -654,7 +654,7 @@ public static function buildAmount(&$form, $required = TRUE, $discountId = NULL) } $form->assign('eventFeeBlockValues', json_encode($eventFeeBlockValues)); - $form->_defaults['amount'] = CRM_Utils_Array::value('default_fee_id', $form->_values['event']); + $form->_defaults['amount'] = $form->_values['event']['default_fee_id'] ?? NULL; $element = &$form->addGroup($elements, 'amount', ts('Event Fee(s)'), '
'); if (isset($form->_online) && $form->_online) { $element->freeze(); @@ -731,7 +731,7 @@ public static function formatFieldsForOptionFull(&$form) { $optionFullIds[$optId] = $optId; if ($field['html_type'] != 'Select') { if (in_array($optId, $defaultPricefieldIds)) { - $optionFullTotalAmount += CRM_Utils_Array::value('amount', $option); + $optionFullTotalAmount += $option['amount'] ?? NULL; } } else { @@ -967,7 +967,7 @@ public function postProcess() { $params['campaign_id'] = $params['participant_campaign_id']; } else { - $params['campaign_id'] = CRM_Utils_Array::value('campaign_id', $this->_values['event']); + $params['campaign_id'] = $this->_values['event']['campaign_id'] ?? NULL; } //hack to allow group to register w/ waiting diff --git a/CRM/Event/Form/SelfSvcTransfer.php b/CRM/Event/Form/SelfSvcTransfer.php index 6dc21ffd9924..d44012ff4185 100644 --- a/CRM/Event/Form/SelfSvcTransfer.php +++ b/CRM/Event/Form/SelfSvcTransfer.php @@ -432,14 +432,14 @@ public function participantTransfer($participant) { $eventParams = ['id' => $participant->event_id]; CRM_Event_BAO_Event::retrieve($eventParams, $eventDetails); //get default participant role. - $eventDetails['participant_role'] = CRM_Utils_Array::value($eventDetails['default_role_id'], $participantRoles); + $eventDetails['participant_role'] = $participantRoles[$eventDetails['default_role_id']] ?? NULL; //get the location info $locParams = [ 'entity_id' => $participant->event_id, 'entity_table' => 'civicrm_event', ]; $eventDetails['location'] = CRM_Core_BAO_Location::getValues($locParams, TRUE); - $toEmail = CRM_Utils_Array::value('email', $contactDetails[$participant->contact_id]); + $toEmail = $contactDetails[$participant->contact_id]['email'] ?? NULL; if ($toEmail) { //take a receipt from as event else domain. $receiptFrom = $domainValues['name'] . ' <' . $domainValues['email'] . '>'; @@ -512,7 +512,7 @@ public function sendCancellation() { $eventParams = ['id' => $this->_event_id]; CRM_Event_BAO_Event::retrieve($eventParams, $eventDetails[$this->_event_id]); //get default participant role. - $eventDetails[$this->_event_id]['participant_role'] = CRM_Utils_Array::value($eventDetails[$this->_event_id]['default_role_id'], $participantRoles); + $eventDetails[$this->_event_id]['participant_role'] = $participantRoles[$eventDetails[$this->_event_id]['default_role_id']] ?? NULL; //get the location info $locParams = ['entity_id' => $this->_event_id, 'entity_table' => 'civicrm_event']; $eventDetails[$this->_event_id]['location'] = CRM_Core_BAO_Location::getValues($locParams, TRUE); diff --git a/CRM/Event/Form/SelfSvcUpdate.php b/CRM/Event/Form/SelfSvcUpdate.php index 760478a0588d..33b9f7f3f878 100644 --- a/CRM/Event/Form/SelfSvcUpdate.php +++ b/CRM/Event/Form/SelfSvcUpdate.php @@ -289,7 +289,7 @@ public function cancelParticipant($params) { $eventParams = ['id' => $this->_event_id]; CRM_Event_BAO_Event::retrieve($eventParams, $eventDetails[$this->_event_id]); //get default participant role. - $eventDetails[$this->_event_id]['participant_role'] = CRM_Utils_Array::value($eventDetails[$this->_event_id]['default_role_id'], $participantRoles); + $eventDetails[$this->_event_id]['participant_role'] = $participantRoles[$eventDetails[$this->_event_id]['default_role_id']] ?? NULL; //get the location info $locParams = ['entity_id' => $this->_event_id, 'entity_table' => 'civicrm_event']; $eventDetails[$this->_event_id]['location'] = CRM_Core_BAO_Location::getValues($locParams, TRUE); diff --git a/CRM/Event/Form/Task/AddToGroup.php b/CRM/Event/Form/Task/AddToGroup.php index 69d7f6a5ddd5..87c47c3fa6ee 100644 --- a/CRM/Event/Form/Task/AddToGroup.php +++ b/CRM/Event/Form/Task/AddToGroup.php @@ -189,7 +189,7 @@ public static function formRule($params) { */ public function postProcess() { $params = $this->controller->exportValues(); - $groupOption = CRM_Utils_Array::value('group_option', $params, NULL); + $groupOption = $params['group_option'] ?? NULL; if ($groupOption) { $groupParams = []; $groupParams['title'] = $params['title']; diff --git a/CRM/Event/Form/Task/Batch.php b/CRM/Event/Form/Task/Batch.php index 2bd7321de6bd..3979b29edd7e 100644 --- a/CRM/Event/Form/Task/Batch.php +++ b/CRM/Event/Form/Task/Batch.php @@ -165,14 +165,14 @@ public function buildQuickForm() { $eventTypeId = CRM_Core_DAO::getFieldValue("CRM_Event_DAO_Event", $eventId, 'event_type_id'); foreach ($this->_fields as $name => $field) { if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($name)) { - $customValue = CRM_Utils_Array::value($customFieldID, $this->_customFields); + $customValue = $this->_customFields[$customFieldID] ?? NULL; $entityColumnValue = []; if (!empty($customValue['extends_entity_column_value'])) { $entityColumnValue = explode(CRM_Core_DAO::VALUE_SEPARATOR, $customValue['extends_entity_column_value'] ); } - $entityColumnValueRole = CRM_Utils_Array::value($roleId, $entityColumnValue); + $entityColumnValueRole = $entityColumnValue[$roleId] ?? NULL; $entityColumnValueEventType = in_array($eventTypeId, $entityColumnValue) ? $eventTypeId : NULL; if (($this->_roleCustomDataTypeID == $customValue['extends_entity_column_id']) && ($entityColumnValueRole) @@ -235,7 +235,7 @@ public function setDefaultValues() { //get the from status ids, CRM-4323 if (array_key_exists('participant_status', $this->_fields)) { - $this->_fromStatusIds[$participantId] = CRM_Utils_Array::value("field[$participantId][participant_status]", $defaults); + $this->_fromStatusIds[$participantId] = $defaults["field[$participantId][participant_status]"] ?? NULL; } if (array_key_exists('participant_role', $this->_fields)) { if ($defaults["field[{$participantId}][participant_role]"]) { @@ -325,10 +325,10 @@ public static function updatePendingOnlineContribution($participantId, $statusId */ public static function updateContributionStatus($params) { // get minimum required values. - $statusId = CRM_Utils_Array::value('contribution_status_id', $params); - $componentId = CRM_Utils_Array::value('component_id', $params); - $componentName = CRM_Utils_Array::value('componentName', $params); - $contributionId = CRM_Utils_Array::value('contribution_id', $params); + $statusId = $params['contribution_status_id'] ?? NULL; + $componentId = $params['component_id'] ?? NULL; + $componentName = $params['componentName'] ?? NULL; + $contributionId = $params['contribution_id'] ?? NULL; if (!$contributionId || !$componentId || !$componentName || !$statusId) { return NULL; @@ -383,7 +383,7 @@ public static function updateContributionStatus($params) { 'labelColumn' => 'name', 'flip' => 1, ]); - $input['IAmAHorribleNastyBeyondExcusableHackInTheCRMEventFORMTaskClassThatNeedsToBERemoved'] = CRM_Utils_Array::value('IAmAHorribleNastyBeyondExcusableHackInTheCRMEventFORMTaskClassThatNeedsToBERemoved', $params); + $input['IAmAHorribleNastyBeyondExcusableHackInTheCRMEventFORMTaskClassThatNeedsToBERemoved'] = $params['IAmAHorribleNastyBeyondExcusableHackInTheCRMEventFORMTaskClassThatNeedsToBERemoved'] ?? NULL; if ($statusId == $contributionStatuses['Cancelled']) { $baseIPN->cancelled($objects, $transaction, $input); $transaction->commit(); @@ -487,7 +487,7 @@ public function submit($params) { $relatedStatusChange = FALSE; if (!empty($value['participant_status'])) { $value['status_id'] = $value['participant_status']; - $fromStatusId = CRM_Utils_Array::value($key, $this->_fromStatusIds); + $fromStatusId = $this->_fromStatusIds[$key] ?? NULL; if (!$fromStatusId) { $fromStatusId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $key, 'status_id'); } diff --git a/CRM/Event/Import/Form/MapField.php b/CRM/Event/Import/Form/MapField.php index 6e0f51c1e0a6..b418566f2b28 100644 --- a/CRM/Event/Import/Form/MapField.php +++ b/CRM/Event/Import/Form/MapField.php @@ -100,9 +100,9 @@ public function buildQuickForm() { $mappingName = $mappingName[1]; $mappingContactType = $mappingContactType[1]; - $mappingLocation = CRM_Utils_Array::value('1', $mappingLocation); - $mappingPhoneType = CRM_Utils_Array::value('1', $mappingPhoneType); - $mappingRelation = CRM_Utils_Array::value('1', $mappingRelation); + $mappingLocation = $mappingLocation['1'] ?? NULL; + $mappingPhoneType = $mappingPhoneType['1'] ?? NULL; + $mappingRelation = $mappingRelation['1'] ?? NULL; //mapping is to be loaded from database @@ -339,7 +339,7 @@ public static function formRule($fields, $files, $self) { } if (!empty($fields['saveMapping'])) { - $nameField = CRM_Utils_Array::value('saveMappingName', $fields); + $nameField = $fields['saveMappingName'] ?? NULL; if (empty($nameField)) { $errors['saveMappingName'] = ts('Name is required to save Import Mapping'); } @@ -352,7 +352,7 @@ public static function formRule($fields, $files, $self) { //display Error if loaded mapping is not selected if (array_key_exists('loadMapping', $fields)) { - $getMapName = CRM_Utils_Array::value('savedMapping', $fields); + $getMapName = $fields['savedMapping'] ?? NULL; if (empty($getMapName)) { $errors['savedMapping'] = ts('Select saved mapping'); } @@ -428,9 +428,9 @@ public function postProcess() { $updateMappingFields->column_number = $i; $explodedValues = explode('_', $mapperKeys[$i][0]); - $id = CRM_Utils_Array::value(0, $explodedValues); - $first = CRM_Utils_Array::value(1, $explodedValues); - $second = CRM_Utils_Array::value(2, $explodedValues); + $id = $explodedValues[0] ?? NULL; + $first = $explodedValues[1] ?? NULL; + $second = $explodedValues[2] ?? NULL; $updateMappingFields->name = $mapper[$i]; $updateMappingFields->save(); @@ -452,9 +452,9 @@ public function postProcess() { $saveMappingFields->column_number = $i; $explodedValues = explode('_', $mapperKeys[$i][0]); - $id = CRM_Utils_Array::value(0, $explodedValues); - $first = CRM_Utils_Array::value(1, $explodedValues); - $second = CRM_Utils_Array::value(2, $explodedValues); + $id = $explodedValues[0] ?? NULL; + $first = $explodedValues[1] ?? NULL; + $second = $explodedValues[2] ?? NULL; $saveMappingFields->name = $mapper[$i]; $saveMappingFields->save(); diff --git a/CRM/Event/Import/Parser/Participant.php b/CRM/Event/Import/Parser/Participant.php index 7e362d540a9a..c5c47da4c6d8 100644 --- a/CRM/Event/Import/Parser/Participant.php +++ b/CRM/Event/Import/Parser/Participant.php @@ -443,8 +443,8 @@ public function import($onDuplicate, &$values) { if (is_array($newParticipant) && civicrm_error($newParticipant)) { if ($onDuplicate == CRM_Import_Parser::DUPLICATE_SKIP) { - $contactID = CRM_Utils_Array::value('contactID', $newParticipant); - $participantID = CRM_Utils_Array::value('participantID', $newParticipant); + $contactID = $newParticipant['contactID'] ?? NULL; + $participantID = $newParticipant['participantID'] ?? NULL; $url = CRM_Utils_System::url('civicrm/contact/view/participant', "reset=1&id={$participantID}&cid={$contactID}&action=view", TRUE ); @@ -463,7 +463,7 @@ public function import($onDuplicate, &$values) { } if (!(is_array($newParticipant) && civicrm_error($newParticipant))) { - $this->_newParticipants[] = CRM_Utils_Array::value('id', $newParticipant); + $this->_newParticipants[] = $newParticipant['id'] ?? NULL; } return CRM_Import_Parser::VALID; @@ -535,8 +535,8 @@ protected function formatValues(&$values, $params) { elseif ($type == 'Select' || $type == 'Radio') { $customOption = CRM_Core_BAO_CustomOption::getCustomOption($customFieldID, TRUE); foreach ($customOption as $customFldID => $customValue) { - $val = CRM_Utils_Array::value('value', $customValue); - $label = CRM_Utils_Array::value('label', $customValue); + $val = $customValue['value'] ?? NULL; + $label = $customValue['label'] ?? NULL; $label = strtolower($label); $value = strtolower(trim($value)); if (($value == $label) || ($value == strtolower($val))) { diff --git a/CRM/Event/Page/EventInfo.php b/CRM/Event/Page/EventInfo.php index e78686c32510..c07681da8bbc 100644 --- a/CRM/Event/Page/EventInfo.php +++ b/CRM/Event/Page/EventInfo.php @@ -117,7 +117,7 @@ public function run() { $values['feeBlock']['value'][$fieldCnt] = ''; $values['feeBlock']['label'][$fieldCnt] = $fieldValues['label']; $values['feeBlock']['lClass'][$fieldCnt] = 'price_set_option_group-label'; - $values['feeBlock']['isDisplayAmount'][$fieldCnt] = CRM_Utils_Array::value('is_display_amounts', $fieldValues); + $values['feeBlock']['isDisplayAmount'][$fieldCnt] = $fieldValues['is_display_amounts'] ?? NULL; $fieldCnt++; $labelClass = 'price_set_option-label'; } @@ -126,9 +126,9 @@ public function run() { } // show tax rate with amount $invoiceSettings = Civi::settings()->get('contribution_invoice_settings'); - $taxTerm = CRM_Utils_Array::value('tax_term', $invoiceSettings); - $displayOpt = CRM_Utils_Array::value('tax_display_settings', $invoiceSettings); - $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings); + $taxTerm = $invoiceSettings['tax_term'] ?? NULL; + $displayOpt = $invoiceSettings['tax_display_settings'] ?? NULL; + $invoicing = $invoiceSettings['invoicing'] ?? NULL; foreach ($fieldValues['options'] as $optionId => $optionVal) { if (CRM_Utils_Array::value('visibility_id', $optionVal) != array_search('public', $visibility) && $adminFieldVisible == FALSE @@ -136,7 +136,7 @@ public function run() { continue; } - $values['feeBlock']['isDisplayAmount'][$fieldCnt] = CRM_Utils_Array::value('is_display_amounts', $fieldValues); + $values['feeBlock']['isDisplayAmount'][$fieldCnt] = $fieldValues['is_display_amounts'] ?? NULL; if ($invoicing && isset($optionVal['tax_amount'])) { $values['feeBlock']['value'][$fieldCnt] = CRM_Price_BAO_PriceField::getTaxLabel($optionVal, 'amount', $displayOpt, $taxTerm); $values['feeBlock']['tax_amount'][$fieldCnt] = $optionVal['tax_amount']; @@ -238,7 +238,7 @@ public function run() { $this->assign('findParticipants', $findParticipants); } - $participantListingID = CRM_Utils_Array::value('participant_listing_id', $values['event']); + $participantListingID = $values['event']['participant_listing_id'] ?? NULL; if ($participantListingID) { $participantListingURL = CRM_Utils_System::url('civicrm/event/participant', "reset=1&id={$this->_id}", @@ -247,7 +247,7 @@ public function run() { $this->assign('participantListingURL', $participantListingURL); } - $hasWaitingList = CRM_Utils_Array::value('has_waitlist', $values['event']); + $hasWaitingList = $values['event']['has_waitlist'] ?? NULL; $eventFullMessage = CRM_Event_BAO_Participant::eventFull($this->_id, FALSE, $hasWaitingList @@ -317,7 +317,7 @@ public function run() { } } elseif ($hasWaitingList) { - $statusMessage = CRM_Utils_Array::value('waitlist_text', $values['event']); + $statusMessage = $values['event']['waitlist_text'] ?? NULL; if (!$statusMessage) { $statusMessage = ts('Event is currently full, but you can register and be a part of waiting list.'); } diff --git a/CRM/Event/Page/ManageEvent.php b/CRM/Event/Page/ManageEvent.php index a0b7c3b2836c..20b4ed5e86e0 100644 --- a/CRM/Event/Page/ManageEvent.php +++ b/CRM/Event/Page/ManageEvent.php @@ -416,10 +416,10 @@ public function browse() { } //show campaigns on selector. - $manageEvent[$dao->id]['campaign'] = CRM_Utils_Array::value($dao->campaign_id, $allCampaigns); + $manageEvent[$dao->id]['campaign'] = $allCampaigns[$dao->campaign_id] ?? NULL; $manageEvent[$dao->id]['reminder'] = CRM_Core_BAO_ActionSchedule::isConfigured($dao->id, $mapping->getId()); - $manageEvent[$dao->id]['is_pcp_enabled'] = CRM_Utils_Array::value($dao->id, $eventPCPS); - $manageEvent[$dao->id]['event_type'] = CRM_Utils_Array::value($manageEvent[$dao->id]['event_type_id'], $eventType); + $manageEvent[$dao->id]['is_pcp_enabled'] = $eventPCPS[$dao->id] ?? NULL; + $manageEvent[$dao->id]['event_type'] = $eventType[$manageEvent[$dao->id]['event_type_id']] ?? NULL; $manageEvent[$dao->id]['is_repeating_event'] = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_RecurringEntity', $dao->id, 'parent_id', 'entity_id'); // allow hooks to set 'field' value which allows configuration pop-up to show a tab as enabled/disabled CRM_Utils_Hook::tabset('civicrm/event/manage/rows', $manageEvent, ['event_id' => $dao->id]); diff --git a/CRM/Event/Page/ParticipantListing/NameStatusAndDate.php b/CRM/Event/Page/ParticipantListing/NameStatusAndDate.php index fef5ae7b12e1..8277180b5243 100644 --- a/CRM/Event/Page/ParticipantListing/NameStatusAndDate.php +++ b/CRM/Event/Page/ParticipantListing/NameStatusAndDate.php @@ -86,7 +86,7 @@ public function run() { $object = CRM_Core_DAO::executeQuery($query, $params); $statusLookup = CRM_Event_PseudoConstant::participantStatus(NULL, NULL, 'label'); while ($object->fetch()) { - $status = CRM_Utils_Array::value($object->status_id, $statusLookup); + $status = $statusLookup[$object->status_id] ?? NULL; $row = [ 'id' => $object->contact_id, 'participantID' => $object->participant_id, diff --git a/CRM/Event/Selector/Search.php b/CRM/Event/Selector/Search.php index 1c5f4b027a65..46dcfeb2e2c8 100644 --- a/CRM/Event/Selector/Search.php +++ b/CRM/Event/Selector/Search.php @@ -333,7 +333,7 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { } //carry campaign on selectors. - $row['campaign'] = CRM_Utils_Array::value($result->participant_campaign_id, $allCampaigns); + $row['campaign'] = $allCampaigns[$result->participant_campaign_id] ?? NULL; $row['campaign_id'] = $result->participant_campaign_id; // gross hack to show extra information for pending status diff --git a/CRM/Event/StateMachine/Search.php b/CRM/Event/StateMachine/Search.php index 0c76eb6cdef3..f98de49db6e3 100644 --- a/CRM/Event/StateMachine/Search.php +++ b/CRM/Event/StateMachine/Search.php @@ -71,7 +71,7 @@ public function __construct($controller, $action = CRM_Core_Action::NONE) { */ public function taskName($controller, $formName = 'Search') { // total hack, check POST vars and then session to determine stuff - $value = CRM_Utils_Array::value('task', $_POST); + $value = $_POST['task'] ?? NULL; if (!isset($value)) { $value = $this->_controller->get('task'); } diff --git a/CRM/Export/BAO/ExportProcessor.php b/CRM/Export/BAO/ExportProcessor.php index 8453d02475b4..9dded52787a2 100644 --- a/CRM/Export/BAO/ExportProcessor.php +++ b/CRM/Export/BAO/ExportProcessor.php @@ -1006,7 +1006,7 @@ public function buildRow($query, $iterationDAO, $outputColumns, $metadata, $paym $fieldValue = $phoneTypes[$fieldValue]; } elseif ($field == 'provider_id' || $field == 'im_provider') { - $fieldValue = CRM_Utils_Array::value($fieldValue, $imProviders); + $fieldValue = $imProviders[$fieldValue] ?? NULL; } elseif (strstr($field, 'master_id')) { // @todo - why not just $field === 'master_id' - what else would it be? @@ -1031,7 +1031,7 @@ public function buildRow($query, $iterationDAO, $outputColumns, $metadata, $paym if (!$this->isExportSpecifiedPaymentFields()) { $nullContributionDetails = array_fill_keys(array_keys($this->getPaymentHeaders()), NULL); if ($this->isExportPaymentFields()) { - $paymentData = CRM_Utils_Array::value($row[$paymentTableId], $paymentDetails); + $paymentData = $paymentDetails[$row[$paymentTableId]] ?? NULL; if (!is_array($paymentData) || empty($paymentData)) { $paymentData = $nullContributionDetails; } @@ -1170,7 +1170,7 @@ public function getTransformedFieldValue($field, $iterationDAO, $fieldValue, $me } elseif ($this->isExportSpecifiedPaymentFields() && array_key_exists($field, $this->getcomponentPaymentFields())) { $paymentTableId = $this->getPaymentTableID(); - $paymentData = CRM_Utils_Array::value($iterationDAO->$paymentTableId, $paymentDetails); + $paymentData = $paymentDetails[$iterationDAO->$paymentTableId] ?? NULL; $payFieldMapper = [ 'componentPaymentField_total_amount' => 'total_amount', 'componentPaymentField_contribution_status' => 'contribution_status', @@ -1357,7 +1357,7 @@ public function getDefaultReturnProperties() { public function setRelationshipReturnProperties($value, $relationshipKey) { $relationField = $value['name']; $relIMProviderId = NULL; - $relLocTypeId = CRM_Utils_Array::value('location_type_id', $value); + $relLocTypeId = $value['location_type_id'] ?? NULL; $locationName = CRM_Core_PseudoConstant::getName('CRM_Core_BAO_Address', 'location_type_id', $relLocTypeId); $relPhoneTypeId = CRM_Utils_Array::value('phone_type_id', $value, ($locationName ? 'Primary' : NULL)); $relIMProviderId = CRM_Utils_Array::value('im_provider_id', $value, ($locationName ? 'Primary' : NULL)); @@ -2104,7 +2104,7 @@ protected function setGreetingStringsForSameAddressMerge($formValues) { if (!empty($greetingOptions)) { // Greeting options is keyed by 'postal_greeting' or 'addressee'. foreach ($greetingOptions as $key => $value) { - $option = CRM_Utils_Array::value($key, $formValues); + $option = $formValues[$key] ?? NULL; if ($option) { if ($greetingOptions[$key][$option] == ts('Other')) { $formValues[$key] = $formValues["{$key}_other"]; @@ -2185,7 +2185,7 @@ public function fetchRelationshipDetails($relDAO, $value, $field, &$row) { $fieldValue = $phoneTypes[$relationValue]; } elseif ($relationField == 'provider_id') { - $fieldValue = CRM_Utils_Array::value($relationValue, $imProviders); + $fieldValue = $imProviders[$relationValue] ?? NULL; } // CRM-13995 elseif (is_object($relDAO) && in_array($relationField, [ diff --git a/CRM/Export/Form/Select.php b/CRM/Export/Form/Select.php index 043c277154ae..af4b2bba7f5e 100644 --- a/CRM/Export/Form/Select.php +++ b/CRM/Export/Form/Select.php @@ -340,7 +340,7 @@ public static function formRule($params, $files, $self) { ]; foreach ($greetings as $key => $value) { - $otherOption = CRM_Utils_Array::value($key, $params); + $otherOption = $params[$key] ?? NULL; if ((CRM_Utils_Array::value($otherOption, $self->_greetingOptions[$key]) == ts('Other')) && empty($params[$value])) { @@ -372,7 +372,7 @@ public function postProcess() { // all submitted options or any other argument $exportParams = $params; - $mappingId = CRM_Utils_Array::value('mapping', $params); + $mappingId = $params['mapping'] ?? NULL; if ($mappingId) { $this->set('mappingId', $mappingId); } diff --git a/CRM/Financial/BAO/FinancialAccount.php b/CRM/Financial/BAO/FinancialAccount.php index 0b235a72ef69..9048d99028a8 100644 --- a/CRM/Financial/BAO/FinancialAccount.php +++ b/CRM/Financial/BAO/FinancialAccount.php @@ -379,7 +379,7 @@ public static function checkFinancialTypeHasDeferred($params, $contributionID = if (!Civi::settings()->get('deferred_revenue_enabled')) { return FALSE; } - $recognitionDate = CRM_Utils_Array::value('revenue_recognition_date', $params); + $recognitionDate = $params['revenue_recognition_date'] ?? NULL; if (!(!CRM_Utils_System::isNull($recognitionDate) || ($contributionID && isset($params['prevContribution']) && !CRM_Utils_System::isNull($params['prevContribution']->revenue_recognition_date))) @@ -387,8 +387,8 @@ public static function checkFinancialTypeHasDeferred($params, $contributionID = return FALSE; } - $lineItems = CRM_Utils_Array::value('line_item', $params); - $financialTypeID = CRM_Utils_Array::value('financial_type_id', $params); + $lineItems = $params['line_item'] ?? NULL; + $financialTypeID = $params['financial_type_id'] ?? NULL; if (!$financialTypeID) { $financialTypeID = $params['prevContribution']->financial_type_id; } diff --git a/CRM/Financial/BAO/FinancialItem.php b/CRM/Financial/BAO/FinancialItem.php index 378f98eff628..60c6332f6c32 100644 --- a/CRM/Financial/BAO/FinancialItem.php +++ b/CRM/Financial/BAO/FinancialItem.php @@ -86,7 +86,7 @@ public static function add($lineItem, $contribution, $taxTrxnID = FALSE, $trxnId if ($taxTrxnID) { $invoiceSettings = Civi::settings()->get('contribution_invoice_settings'); - $taxTerm = CRM_Utils_Array::value('tax_term', $invoiceSettings); + $taxTerm = $invoiceSettings['tax_term'] ?? NULL; $params['amount'] = $lineItem->tax_amount; $params['description'] = $taxTerm; $accountRelName = 'Sales Tax Account is'; @@ -142,7 +142,7 @@ public static function create(&$params, $ids = NULL, $trxnIds = NULL) { } $financialItem->save(); - $financialtrxnIDS = CRM_Utils_Array::value('id', $trxnIds); + $financialtrxnIDS = $trxnIds['id'] ?? NULL; if (!empty($financialtrxnIDS)) { if (!is_array($financialtrxnIDS)) { $financialtrxnIDS = [$financialtrxnIDS]; diff --git a/CRM/Financial/BAO/FinancialType.php b/CRM/Financial/BAO/FinancialType.php index c551d6752987..65c20c022105 100644 --- a/CRM/Financial/BAO/FinancialType.php +++ b/CRM/Financial/BAO/FinancialType.php @@ -90,7 +90,7 @@ public static function add(&$params, &$ids = []) { $financialType = new CRM_Financial_DAO_FinancialType(); $financialType->copyValues($params); if (!empty($ids['financialType'])) { - $financialType->id = CRM_Utils_Array::value('financialType', $ids); + $financialType->id = $ids['financialType'] ?? NULL; if (self::isACLFinancialTypeStatus()) { $prevName = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialType', $financialType->id, 'name'); if ($prevName != $params['name']) { diff --git a/CRM/Financial/BAO/Payment.php b/CRM/Financial/BAO/Payment.php index 9f5e0ad55032..8a06f7f26cc3 100644 --- a/CRM/Financial/BAO/Payment.php +++ b/CRM/Financial/BAO/Payment.php @@ -450,7 +450,7 @@ protected static function getPayableLineItems($params): array { $lineItems[$lineItemID]['balance'] = $lineItem['subTotal'] - $lineItems[$lineItemID]['paid']; if (!empty($lineItemOverrides)) { - $lineItems[$lineItemID]['allocation'] = CRM_Utils_Array::value($lineItemID, $lineItemOverrides); + $lineItems[$lineItemID]['allocation'] = $lineItemOverrides[$lineItemID] ?? NULL; } else { $lineItems[$lineItemID]['allocation'] = $lineItems[$lineItemID]['balance'] * $ratio; diff --git a/CRM/Financial/BAO/PaymentProcessor.php b/CRM/Financial/BAO/PaymentProcessor.php index b577a7fca64a..ef1f7ec3a421 100644 --- a/CRM/Financial/BAO/PaymentProcessor.php +++ b/CRM/Financial/BAO/PaymentProcessor.php @@ -262,8 +262,8 @@ public static function getTestProcessorId($id) { * @return int */ public static function defaultComparison($processor1, $processor2) { - $p1 = CRM_Utils_Array::value('is_default', $processor1); - $p2 = CRM_Utils_Array::value('is_default', $processor2); + $p1 = $processor1['is_default'] ?? NULL; + $p2 = $processor2['is_default'] ?? NULL; if ($p1 == $p2) { return 0; } diff --git a/CRM/Financial/Form/BatchTransaction.php b/CRM/Financial/Form/BatchTransaction.php index 408a84e72911..7b2cf8abbf62 100644 --- a/CRM/Financial/Form/BatchTransaction.php +++ b/CRM/Financial/Form/BatchTransaction.php @@ -38,7 +38,7 @@ public function preProcess() { // This reuses some styles from search forms CRM_Core_Resources::singleton()->addStyleFile('civicrm', 'css/searchForm.css', 1, 'html-header'); - self::$_entityID = CRM_Utils_Request::retrieve('bid', 'Positive') ? CRM_Utils_Request::retrieve('bid', 'Positive') : CRM_Utils_Array::value('batch_id', $_POST); + self::$_entityID = CRM_Utils_Request::retrieve('bid', 'Positive') ? CRM_Utils_Request::retrieve('bid', 'Positive') : $_POST['batch_id'] ?? NULL; $this->assign('entityID', self::$_entityID); if (isset(self::$_entityID)) { $this->_batchStatusId = CRM_Core_DAO::getFieldValue('CRM_Batch_BAO_Batch', self::$_entityID, 'status_id'); diff --git a/CRM/Financial/Form/FinancialTypeAccount.php b/CRM/Financial/Form/FinancialTypeAccount.php index 4058a29efe6e..9f406563d71a 100644 --- a/CRM/Financial/Form/FinancialTypeAccount.php +++ b/CRM/Financial/Form/FinancialTypeAccount.php @@ -143,7 +143,7 @@ public function buildQuickForm() { if ($this->_action == CRM_Core_Action::ADD) { if (!empty($this->_submitValues['account_relationship']) || !empty($this->_submitValues['financial_account_id'])) { $financialAccountType = CRM_Financial_BAO_FinancialAccount::getfinancialAccountRelations(); - $financialAccountType = CRM_Utils_Array::value($this->_submitValues['account_relationship'], $financialAccountType); + $financialAccountType = $financialAccountType[$this->_submitValues['account_relationship']] ?? NULL; $result = CRM_Contribute_PseudoConstant::financialAccount(NULL, $financialAccountType); $financialAccountSelect = ['' => ts('- select -')] + $result; diff --git a/CRM/Financial/Form/PaymentEdit.php b/CRM/Financial/Form/PaymentEdit.php index 06acbd9521b9..f131ef76776b 100644 --- a/CRM/Financial/Form/PaymentEdit.php +++ b/CRM/Financial/Form/PaymentEdit.php @@ -156,11 +156,11 @@ public function postProcess() { $paymentInstrumentName = CRM_Core_PseudoConstant::getName('CRM_Financial_DAO_FinancialTrxn', 'payment_instrument_id', $params['payment_instrument_id']); if ($paymentInstrumentName == 'Credit Card') { - $params['card_type_id'] = CRM_Utils_Array::value('card_type_id', $this->_submitValues); - $params['pan_truncation'] = CRM_Utils_Array::value('pan_truncation', $this->_submitValues); + $params['card_type_id'] = $this->_submitValues['card_type_id'] ?? NULL; + $params['pan_truncation'] = $this->_submitValues['pan_truncation'] ?? NULL; } elseif ($paymentInstrumentName == 'Check') { - $params['check_number'] = CRM_Utils_Array::value('check_number', $this->_submitValues); + $params['check_number'] = $this->_submitValues['check_number'] ?? NULL; } $this->submit($params); diff --git a/CRM/Financial/Form/SalesTaxTrait.php b/CRM/Financial/Form/SalesTaxTrait.php index 888ac75f9760..45710bd06499 100644 --- a/CRM/Financial/Form/SalesTaxTrait.php +++ b/CRM/Financial/Form/SalesTaxTrait.php @@ -37,7 +37,7 @@ public function assignSalesTaxRates() { */ public function getSalesTaxTerm() { $invoiceSettings = Civi::settings()->get('contribution_invoice_settings'); - $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings); + $invoicing = $invoiceSettings['invoicing'] ?? NULL; if (!$invoicing) { return ''; } diff --git a/CRM/Financial/Page/AJAX.php b/CRM/Financial/Page/AJAX.php index 25d1b262bf63..5eaae27c1cbf 100644 --- a/CRM/Financial/Page/AJAX.php +++ b/CRM/Financial/Page/AJAX.php @@ -38,7 +38,7 @@ public static function jqFinancial($config) { } else { $financialAccountType = CRM_Financial_BAO_FinancialAccount::getfinancialAccountRelations(); - $financialAccountType = CRM_Utils_Array::value($_GET['_value'], $financialAccountType); + $financialAccountType = $financialAccountType[$_GET['_value']] ?? NULL; $result = CRM_Contribute_PseudoConstant::financialAccount(NULL, $financialAccountType); if ($financialAccountType) { $defaultId = CRM_Core_DAO::singleValueQuery("SELECT id FROM civicrm_financial_account WHERE is_default = 1 AND financial_account_type_id = $financialAccountType"); @@ -303,7 +303,7 @@ public static function getFinancialTransactionsList() { $params['context'] = $context; $params['offset'] = ($params['page'] - 1) * $params['rp']; $params['rowCount'] = $params['rp']; - $params['sort'] = CRM_Utils_Array::value('sortBy', $params); + $params['sort'] = $params['sortBy'] ?? NULL; $params['total'] = 0; // get batch list diff --git a/CRM/Financial/Page/FinancialType.php b/CRM/Financial/Page/FinancialType.php index 7a1480d52472..38bde7596431 100644 --- a/CRM/Financial/Page/FinancialType.php +++ b/CRM/Financial/Page/FinancialType.php @@ -110,8 +110,8 @@ public function browse() { foreach ($financialAccountIds as $key => $values) { if (!empty($financialAccounts[$values['financial_account_id']])) { - $financialAccountId[$values['financial_account_id']] = CRM_Utils_Array::value( - $values['financial_account_id'], $financialAccounts); + $financialAccountId[$values['financial_account_id']] = $financialAccounts[ + $values['financial_account_id']] ?? NULL; } } diff --git a/CRM/Financial/Page/FinancialTypeAccount.php b/CRM/Financial/Page/FinancialTypeAccount.php index b01b944b72d5..9a3552cc61d7 100644 --- a/CRM/Financial/Page/FinancialTypeAccount.php +++ b/CRM/Financial/Page/FinancialTypeAccount.php @@ -133,12 +133,12 @@ public function browse() { } if (!empty($financialAccount->financial_account_type_id)) { $optionGroupName = 'financial_account_type'; - $financialType[$dao->id]['financial_account_type'] = CRM_Utils_Array::value($financialAccount->financial_account_type_id, $financialAccountType); + $financialType[$dao->id]['financial_account_type'] = $financialAccountType[$financialAccount->financial_account_type_id] ?? NULL; } if (!empty($dao->account_relationship)) { $optionGroupName = 'account_relationship'; - $financialType[$dao->id]['account_relationship'] = CRM_Utils_Array::value($dao->account_relationship, $accountRelationship); + $financialType[$dao->id]['account_relationship'] = $accountRelationship[$dao->account_relationship] ?? NULL; } } // form all action links diff --git a/CRM/Friend/BAO/Friend.php b/CRM/Friend/BAO/Friend.php index 2d140e782656..49cb7b9d8827 100644 --- a/CRM/Friend/BAO/Friend.php +++ b/CRM/Friend/BAO/Friend.php @@ -157,9 +157,9 @@ public static function create(&$params) { $transaction->commit(); // Process sending of mails - $mailParams['title'] = CRM_Utils_Array::value('title', $params); - $mailParams['general_link'] = CRM_Utils_Array::value('general_link', $friendParams); - $mailParams['message'] = CRM_Utils_Array::value('suggested_message', $params); + $mailParams['title'] = $params['title'] ?? NULL; + $mailParams['general_link'] = $friendParams['general_link'] ?? NULL; + $mailParams['message'] = $params['suggested_message'] ?? NULL; // Default "from email address" is default domain address. list($_, $mailParams['email_from']) = CRM_Core_BAO_Domain::getNameAndEmail(); diff --git a/CRM/Friend/Form.php b/CRM/Friend/Form.php index e1e03c3576b4..2af78a571a9a 100644 --- a/CRM/Friend/Form.php +++ b/CRM/Friend/Form.php @@ -73,8 +73,8 @@ public function preProcess() { CRM_Core_DAO::commonRetrieve('CRM_Contribute_DAO_ContributionPage', $params, $values, ['title', 'campaign_id', 'is_share'] ); - $this->_title = CRM_Utils_Array::value('title', $values); - $this->_campaignId = CRM_Utils_Array::value('campaign_id', $values); + $this->_title = $values['title'] ?? NULL; + $this->_campaignId = $values['campaign_id'] ?? NULL; $this->_entityTable = 'civicrm_contribution_page'; if ($pcomponent == 'event') { $this->_entityTable = 'civicrm_event'; @@ -82,7 +82,7 @@ public function preProcess() { $this->_title = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_entityId, 'title'); } else { - $isShare = CRM_Utils_Array::value('is_share', $values); + $isShare = $values['is_share'] ?? NULL; } // Tell Form.tpl whether to include SocialNetwork.tpl for social media sharing $this->assign('isShare', $isShare); diff --git a/CRM/Friend/Form/Contribute.php b/CRM/Friend/Form/Contribute.php index 67e35a989de1..56dac3ce18c2 100644 --- a/CRM/Friend/Form/Contribute.php +++ b/CRM/Friend/Form/Contribute.php @@ -48,11 +48,11 @@ public function setDefaultValues() { $defaults['entity_table'] = 'civicrm_contribution_page'; $defaults['entity_id'] = $this->_id; CRM_Friend_BAO_Friend::getValues($defaults); - $this->_friendId = CRM_Utils_Array::value('id', $defaults); - $defaults['tf_title'] = CRM_Utils_Array::value('title', $defaults); - $defaults['tf_is_active'] = CRM_Utils_Array::value('is_active', $defaults); - $defaults['tf_thankyou_title'] = CRM_Utils_Array::value('thankyou_title', $defaults); - $defaults['tf_thankyou_text'] = CRM_Utils_Array::value('thankyou_text', $defaults); + $this->_friendId = $defaults['id'] ?? NULL; + $defaults['tf_title'] = $defaults['title'] ?? NULL; + $defaults['tf_is_active'] = $defaults['is_active'] ?? NULL; + $defaults['tf_thankyou_title'] = $defaults['thankyou_title'] ?? NULL; + $defaults['tf_thankyou_text'] = $defaults['thankyou_text'] ?? NULL; } if (!$this->_friendId) { @@ -76,7 +76,7 @@ public function buildQuickForm() { $defaults['entity_table'] = 'civicrm_contribution_page'; $defaults['entity_id'] = $this->_id; CRM_Friend_BAO_Friend::getValues($defaults); - $this->_friendId = CRM_Utils_Array::value('id', $defaults); + $this->_friendId = $defaults['id'] ?? NULL; } CRM_Friend_BAO_Friend::buildFriendForm($this); @@ -97,8 +97,8 @@ public function postProcess() { $formValues['entity_id'] = $this->_id; $formValues['title'] = $formValues['tf_title']; $formValues['is_active'] = CRM_Utils_Array::value('tf_is_active', $formValues, FALSE); - $formValues['thankyou_title'] = CRM_Utils_Array::value('tf_thankyou_title', $formValues); - $formValues['thankyou_text'] = CRM_Utils_Array::value('tf_thankyou_text', $formValues); + $formValues['thankyou_title'] = $formValues['tf_thankyou_title'] ?? NULL; + $formValues['thankyou_text'] = $formValues['tf_thankyou_text'] ?? NULL; if (($this->_action & CRM_Core_Action::UPDATE) && $this->_friendId) { $formValues['id'] = $this->_friendId; diff --git a/CRM/Friend/Form/Event.php b/CRM/Friend/Form/Event.php index 871ed9df58a5..a40c68e87440 100644 --- a/CRM/Friend/Form/Event.php +++ b/CRM/Friend/Form/Event.php @@ -49,16 +49,16 @@ public function setDefaultValues() { $defaults['entity_id'] = $this->_id; CRM_Friend_BAO_Friend::getValues($defaults); if (!empty($defaults['id'])) { - $defaults['tf_id'] = CRM_Utils_Array::value('id', $defaults); + $defaults['tf_id'] = $defaults['id'] ?? NULL; $this->_friendId = $defaults['tf_id']; // lets unset the 'id' since it conflicts with eventID (or contribID) // CRM-12667 unset($defaults['id']); } - $defaults['tf_title'] = CRM_Utils_Array::value('title', $defaults); - $defaults['tf_is_active'] = CRM_Utils_Array::value('is_active', $defaults); - $defaults['tf_thankyou_title'] = CRM_Utils_Array::value('thankyou_title', $defaults); - $defaults['tf_thankyou_text'] = CRM_Utils_Array::value('thankyou_text', $defaults); + $defaults['tf_title'] = $defaults['title'] ?? NULL; + $defaults['tf_is_active'] = $defaults['is_active'] ?? NULL; + $defaults['tf_thankyou_title'] = $defaults['thankyou_title'] ?? NULL; + $defaults['tf_thankyou_text'] = $defaults['thankyou_text'] ?? NULL; } if (!$this->_friendId) { @@ -82,7 +82,7 @@ public function buildQuickForm() { $defaults['entity_table'] = 'civicrm_event'; $defaults['entity_id'] = $this->_id; CRM_Friend_BAO_Friend::getValues($defaults); - $this->_friendId = CRM_Utils_Array::value('id', $defaults); + $this->_friendId = $defaults['id'] ?? NULL; } CRM_Friend_BAO_Friend::buildFriendForm($this); @@ -106,8 +106,8 @@ public function postProcess() { $formValues['entity_id'] = $this->_id; $formValues['title'] = $formValues['tf_title']; $formValues['is_active'] = CRM_Utils_Array::value('tf_is_active', $formValues, FALSE); - $formValues['thankyou_title'] = CRM_Utils_Array::value('tf_thankyou_title', $formValues); - $formValues['thankyou_text'] = CRM_Utils_Array::value('tf_thankyou_text', $formValues); + $formValues['thankyou_title'] = $formValues['tf_thankyou_title'] ?? NULL; + $formValues['thankyou_text'] = $formValues['tf_thankyou_text'] ?? NULL; if (($this->_action & CRM_Core_Action::UPDATE) && $this->_friendId) { $formValues['id'] = $this->_friendId; diff --git a/CRM/Grant/BAO/Grant.php b/CRM/Grant/BAO/Grant.php index 58f035100de9..3d5fa8e1aca8 100644 --- a/CRM/Grant/BAO/Grant.php +++ b/CRM/Grant/BAO/Grant.php @@ -154,7 +154,7 @@ public static function add(&$params, &$ids) { } } $grant = new CRM_Grant_DAO_Grant(); - $grant->id = CRM_Utils_Array::value('grant_id', $ids); + $grant->id = $ids['grant_id'] ?? NULL; $grant->copyValues($params); @@ -233,7 +233,7 @@ public static function create(&$params, &$ids) { $session = CRM_Core_Session::singleton(); $id = $session->get('userID'); if (!$id) { - $id = CRM_Utils_Array::value('contact_id', $params); + $id = $params['contact_id'] ?? NULL; } if (!empty($params['note']) || CRM_Utils_Array::value('id', CRM_Utils_Array::value('note', $ids))) { $noteParams = [ diff --git a/CRM/Grant/StateMachine/Search.php b/CRM/Grant/StateMachine/Search.php index 88f6c267c6cb..eade9bb5b4f5 100644 --- a/CRM/Grant/StateMachine/Search.php +++ b/CRM/Grant/StateMachine/Search.php @@ -71,7 +71,7 @@ public function __construct($controller, $action = CRM_Core_Action::NONE) { */ public function taskName($controller, $formName = 'Search') { // total hack, check POST vars and then session to determine stuff - $value = CRM_Utils_Array::value('task', $_POST); + $value = $_POST['task'] ?? NULL; if (!isset($value)) { $value = $this->_controller->get('task'); } diff --git a/CRM/Group/Page/AJAX.php b/CRM/Group/Page/AJAX.php index 493994720d73..55428b5ef665 100644 --- a/CRM/Group/Page/AJAX.php +++ b/CRM/Group/Page/AJAX.php @@ -55,7 +55,7 @@ public static function getGroupList() { // go ahead with flat hierarchy, CRM-12225 if (empty($groups)) { $groupsAccessible = CRM_Core_PseudoConstant::group(); - $parentsOnly = CRM_Utils_Array::value('parentsOnly', $params); + $parentsOnly = $params['parentsOnly'] ?? NULL; if (!empty($groupsAccessible) && $parentsOnly) { // recompute group list with flat hierarchy $params['parentsOnly'] = 0; diff --git a/CRM/Logging/Differ.php b/CRM/Logging/Differ.php index 6767b8f3ccc3..2e05cf1d709a 100644 --- a/CRM/Logging/Differ.php +++ b/CRM/Logging/Differ.php @@ -231,7 +231,7 @@ private function diffsInTableForId($table, $id) { if (!empty(${$var[$diff]})) { $holder =& $$var; $val = explode(CRM_Case_BAO_Case::VALUE_SEPARATOR, $holder[$diff]); - $holder[$diff] = CRM_Utils_Array::value(1, $val); + $holder[$diff] = $val[1] ?? NULL; } } } @@ -306,7 +306,7 @@ public function titlesAndValuesForTable($table, $referenceDate) { $dao = new $tableDAO(); foreach ($dao->fields() as $field) { - $titles[$table][$field['name']] = CRM_Utils_Array::value('title', $field); + $titles[$table][$field['name']] = $field['title'] ?? NULL; if ($field['type'] == CRM_Utils_Type::T_BOOLEAN) { $values[$table][$field['name']] = ['0' => ts('false'), '1' => ts('true')]; diff --git a/CRM/Logging/ReportDetail.php b/CRM/Logging/ReportDetail.php index d239a602da27..d5822b183d51 100644 --- a/CRM/Logging/ReportDetail.php +++ b/CRM/Logging/ReportDetail.php @@ -203,10 +203,10 @@ protected function convertDiffsToRows() { ) { $froms = $tos = []; foreach (explode(CRM_Core_DAO::VALUE_SEPARATOR, trim($from, CRM_Core_DAO::VALUE_SEPARATOR)) as $val) { - $froms[] = CRM_Utils_Array::value($val, $values[$field]); + $froms[] = $values[$field][$val] ?? NULL; } foreach (explode(CRM_Core_DAO::VALUE_SEPARATOR, trim($to, CRM_Core_DAO::VALUE_SEPARATOR)) as $val) { - $tos[] = CRM_Utils_Array::value($val, $values[$field]); + $tos[] = $values[$field][$val] ?? NULL; } $from = implode(', ', array_filter($froms)); $to = implode(', ', array_filter($tos)); diff --git a/CRM/Logging/ReportSummary.php b/CRM/Logging/ReportSummary.php index 364474b199da..f7e93eeb24b3 100644 --- a/CRM/Logging/ReportSummary.php +++ b/CRM/Logging/ReportSummary.php @@ -342,7 +342,7 @@ protected function buildTemporaryTables() { $this->addToDeveloperTab($this->temporaryTable->getCreateSql()); $this->temporaryTableName = $this->temporaryTable->getName(); - $logTypes = CRM_Utils_Array::value('log_type_value', $this->_params); + $logTypes = $this->_params['log_type_value'] ?? NULL; unset($this->_params['log_type_value']); if (empty($logTypes)) { foreach (array_keys($this->_logTables) as $table) { diff --git a/CRM/Logging/Schema.php b/CRM/Logging/Schema.php index cd8ee48acb9a..3b09e9bbf321 100644 --- a/CRM/Logging/Schema.php +++ b/CRM/Logging/Schema.php @@ -321,7 +321,7 @@ public function updateLogTableSchema($params) { $engineChanged = isset($tableSpec['engine']) && (strtoupper($tableSpec['engine']) != $currentEngine); $engineConfigChanged = isset($tableSpec['engine_config']) && (strtoupper($tableSpec['engine_config']) != $this->getEngineConfigForLogTable($logTable)); if ($engineChanged || ($engineConfigChanged && $params['updateChangedEngineConfig'])) { - $alterSql[] = "ENGINE=" . $tableSpec['engine'] . " " . CRM_Utils_Array::value('engine_config', $tableSpec); + $alterSql[] = "ENGINE=" . $tableSpec['engine'] . " " . $tableSpec['engine_config'] ?? NULL; } if (!empty($tableSpec['indexes'])) { $indexes = $this->getIndexesForTable($logTable); @@ -805,7 +805,7 @@ private function createLogTableFor($table) { $query = preg_replace("/ AUTO_INCREMENT/i", '', $query); $query = preg_replace("/^ [^`].*$/m", '', $query); $engine = strtoupper(CRM_Utils_Array::value('engine', $this->logTableSpec[$table], self::ENGINE)); - $engine .= " " . CRM_Utils_Array::value('engine_config', $this->logTableSpec[$table]); + $engine .= " " . $this->logTableSpec[$table]['engine_config'] ?? NULL; $query = preg_replace("/^\) ENGINE=[^ ]+ /im", ') ENGINE=' . $engine . ' ', $query); // log_civicrm_contact.modified_date for example would always be copied from civicrm_contact.modified_date, diff --git a/CRM/Mailing/BAO/Mailing.php b/CRM/Mailing/BAO/Mailing.php index 57fca1a971a3..98e2741e3be7 100644 --- a/CRM/Mailing/BAO/Mailing.php +++ b/CRM/Mailing/BAO/Mailing.php @@ -1191,7 +1191,7 @@ public function compose( $mailParams['attachments'] = $attachments; - $mailParams['Subject'] = CRM_Utils_Array::value('subject', $pEmails); + $mailParams['Subject'] = $pEmails['subject'] ?? NULL; if (is_array($mailParams['Subject'])) { $mailParams['Subject'] = implode('', $mailParams['Subject']); } @@ -1396,7 +1396,7 @@ private function getTokenData(&$token_a, $html = FALSE, &$contact, &$verp, &$url } } else { - $data = CRM_Utils_Array::value("{$type}.{$token}", $contact); + $data = $contact["{$type}.{$token}"] ?? NULL; } return $data; } @@ -2858,7 +2858,7 @@ public static function getContactMailingSelector(&$params) { // format the params $params['offset'] = ($params['page'] - 1) * $params['rp']; $params['rowCount'] = $params['rp']; - $params['sort'] = CRM_Utils_Array::value('sortBy', $params); + $params['sort'] = $params['sortBy'] ?? NULL; $params['caseId'] = NULL; // get contact mailings @@ -2951,7 +2951,7 @@ public static function getContactMailings(&$params) { $params['version'] = 3; $params['offset'] = ($params['page'] - 1) * $params['rp']; $params['limit'] = $params['rp']; - $params['sort'] = CRM_Utils_Array::value('sortBy', $params); + $params['sort'] = $params['sortBy'] ?? NULL; $result = civicrm_api('MailingContact', 'get', $params); return $result['values']; diff --git a/CRM/Mailing/Form/Task.php b/CRM/Mailing/Form/Task.php index d0ba253d82e8..4a84746aaaba 100644 --- a/CRM/Mailing/Form/Task.php +++ b/CRM/Mailing/Form/Task.php @@ -34,7 +34,7 @@ public function preProcess() { public static function preProcessCommon(&$form) { $values = $form->controller->exportValues($form->get('searchFormName')); - $form->_task = CRM_Utils_Array::value('task', $values); + $form->_task = $values['task'] ?? NULL; $mailingTasks = CRM_Mailing_Task::tasks(); $form->assign('taskName', CRM_Utils_Array::value('task', $values)); diff --git a/CRM/Mailing/Page/Preview.php b/CRM/Mailing/Page/Preview.php index 85daed2ee3a0..97a15798c4c1 100644 --- a/CRM/Mailing/Page/Preview.php +++ b/CRM/Mailing/Page/Preview.php @@ -44,7 +44,7 @@ public function run() { $mailing = new CRM_Mailing_BAO_Mailing(); if (!empty($options)) { $mailing->id = $options['mailing_id']; - $fromEmail = CRM_Utils_Array::value('from_email', $options); + $fromEmail = $options['from_email'] ?? NULL; } $mailing->find(TRUE); diff --git a/CRM/Member/BAO/Membership.php b/CRM/Member/BAO/Membership.php index a8265b8a67b6..98f29389f5f0 100644 --- a/CRM/Member/BAO/Membership.php +++ b/CRM/Member/BAO/Membership.php @@ -89,7 +89,7 @@ public static function add(&$params) { //get the log start date. //it is set during renewal of membership. - $logStartDate = CRM_Utils_Array::value('log_start_date', $params); + $logStartDate = $params['log_start_date'] ?? NULL; $logStartDate = ($logStartDate) ? CRM_Utils_Date::isoToMysql($logStartDate) : CRM_Utils_Date::isoToMysql($membership->start_date); $values = self::getStatusANDTypeValues($membership->id); @@ -131,7 +131,7 @@ public static function add(&$params) { $targetContactID = $membership->contact_id; if (!empty($params['is_for_organization'])) { // @todo - deprecate is_for_organization, require modified_id - $targetContactID = CRM_Utils_Array::value('modified_id', $params); + $targetContactID = $params['modified_id'] ?? NULL; } // add custom field values @@ -293,7 +293,7 @@ public static function create(&$params, &$ids = []) { if (!array_key_exists('max_related', $params) && !empty($params['membership_type_id'])) { $membershipType = CRM_Member_BAO_MembershipType::getMembershipTypeDetails($params['membership_type_id']); if (isset($membershipType['relationship_type_id'])) { - $params['max_related'] = CRM_Utils_Array::value('max_related', $membershipType); + $params['max_related'] = $membershipType['max_related'] ?? NULL; } } } @@ -365,7 +365,7 @@ public static function create(&$params, &$ids = []) { foreach ($params['line_item'] as $priceSetId => $lineItems) { foreach ($lineItems as $lineIndex => $lineItem) { - $lineMembershipType = CRM_Utils_Array::value('membership_type_id', $lineItem); + $lineMembershipType = $lineItem['membership_type_id'] ?? NULL; if (!empty($params['contribution'])) { $params['line_item'][$priceSetId][$lineIndex]['contribution_id'] = $params['contribution']->id; } @@ -520,7 +520,7 @@ public static function retrieve(&$params, &$defaults) { //get the membership status and type values. $statusANDType = self::getStatusANDTypeValues($membership->id); foreach (['status', 'membership_type'] as $fld) { - $defaults[$fld] = CRM_Utils_Array::value($fld, $statusANDType[$membership->id]); + $defaults[$fld] = $statusANDType[$membership->id][$fld] ?? NULL; } if (!empty($statusANDType[$membership->id]['is_current_member'])) { $defaults['active'] = TRUE; @@ -929,7 +929,7 @@ public static function &importableFields($contactType = 'Individual', $status = 'column_name' ); $value = $customFieldId ? 'custom_' . $customFieldId : $value; - $tmpContactField[trim($value)] = CRM_Utils_Array::value(trim($value), $contactFields); + $tmpContactField[trim($value)] = $contactFields[trim($value)] ?? NULL; if (!$status) { $title = $tmpContactField[trim($value)]['title'] . " " . ts('(match to contact)'); } @@ -1849,9 +1849,9 @@ public static function processMembership($contactID, $membershipTypeID, $is_test $currentMembership['join_date'] = CRM_Utils_Date::customFormat($currentMembership['join_date'], $format); foreach (['start_date', 'end_date'] as $dateType) { - $currentMembership[$dateType] = CRM_Utils_Array::value($dateType, $formDates); + $currentMembership[$dateType] = $formDates[$dateType] ?? NULL; if (empty($currentMembership[$dateType])) { - $currentMembership[$dateType] = CRM_Utils_Array::value($dateType, $dates); + $currentMembership[$dateType] = $dates[$dateType] ?? NULL; } } $currentMembership['is_test'] = $is_test; @@ -1892,9 +1892,9 @@ public static function processMembership($contactID, $membershipTypeID, $is_test $memParams = []; $memParams['join_date'] = CRM_Utils_Date::isoToMysql($membership->join_date); $memParams['start_date'] = CRM_Utils_Array::value('start_date', $formDates, CRM_Utils_Date::isoToMysql($membership->start_date)); - $memParams['end_date'] = CRM_Utils_Array::value('end_date', $formDates); + $memParams['end_date'] = $formDates['end_date'] ?? NULL; if (empty($memParams['end_date'])) { - $memParams['end_date'] = CRM_Utils_Array::value('end_date', $dates); + $memParams['end_date'] = $dates['end_date'] ?? NULL; } $memParams['membership_type_id'] = $membershipTypeID; @@ -1933,9 +1933,9 @@ public static function processMembership($contactID, $membershipTypeID, $is_test $dates = CRM_Member_BAO_MembershipType::getDatesForMembershipType($membershipTypeID, NULL, NULL, NULL, $numRenewTerms); foreach (['join_date', 'start_date', 'end_date'] as $dateType) { - $memParams[$dateType] = CRM_Utils_Array::value($dateType, $formDates); + $memParams[$dateType] = $formDates[$dateType] ?? NULL; if (empty($memParams[$dateType])) { - $memParams[$dateType] = CRM_Utils_Array::value($dateType, $dates); + $memParams[$dateType] = $dates[$dateType] ?? NULL; } } @@ -1953,7 +1953,7 @@ public static function processMembership($contactID, $membershipTypeID, $is_test $membershipTypeID, $memParams ); - $updateStatusId = CRM_Utils_Array::value('id', $status); + $updateStatusId = $status['id'] ?? NULL; } else { // if IPN/Pay-Later set status to: PENDING @@ -2268,7 +2268,7 @@ public static function updateAllMembershipStatus() { 'ignore_admin_only' => TRUE, ], TRUE ); - $statusId = CRM_Utils_Array::value('id', $newStatus); + $statusId = $newStatus['id'] ?? NULL; //process only when status change. if ($statusId && @@ -2405,11 +2405,11 @@ public static function recordMembershipContribution(&$params, $ids = []) { $config = CRM_Core_Config::singleton(); $contributionParams['currency'] = $config->defaultCurrency; $contributionParams['receipt_date'] = (CRM_Utils_Array::value('receipt_date', $params)) ? $params['receipt_date'] : 'null'; - $contributionParams['source'] = CRM_Utils_Array::value('contribution_source', $params); + $contributionParams['source'] = $params['contribution_source'] ?? NULL; $contributionParams['non_deductible_amount'] = 'null'; $contributionParams['skipCleanMoney'] = TRUE; - $contributionParams['payment_processor'] = CRM_Utils_Array::value('payment_processor_id', $params); - $contributionSoftParams = CRM_Utils_Array::value('soft_credit', $params); + $contributionParams['payment_processor'] = $params['payment_processor_id'] ?? NULL; + $contributionSoftParams = $params['soft_credit'] ?? NULL; $recordContribution = [ 'contact_id', 'fee_amount', @@ -2432,7 +2432,7 @@ public static function recordMembershipContribution(&$params, $ids = []) { 'card_type_id', ]; foreach ($recordContribution as $f) { - $contributionParams[$f] = CRM_Utils_Array::value($f, $params); + $contributionParams[$f] = $params[$f] ?? NULL; } if (!empty($params['contribution_id'])) { @@ -2451,7 +2451,7 @@ public static function recordMembershipContribution(&$params, $ids = []) { if (!empty($params['processPriceSet']) && !empty($params['lineItems']) ) { - $contributionParams['line_item'] = CRM_Utils_Array::value('lineItems', $params, NULL); + $contributionParams['line_item'] = $params['lineItems'] ?? NULL; } $contribution = CRM_Contribute_BAO_Contribution::create($contributionParams); @@ -2685,8 +2685,8 @@ public static function mergeMemberships($mainContactID, $otherContactID, &$sqlQu */ public static function updateMembershipStatus($deceasedParams, $contactType) { $updateMembershipMsg = NULL; - $contactId = CRM_Utils_Array::value('contact_id', $deceasedParams); - $deceasedDate = CRM_Utils_Array::value('deceased_date', $deceasedParams); + $contactId = $deceasedParams['contact_id'] ?? NULL; + $deceasedDate = $deceasedParams['deceased_date'] ?? NULL; // process to set membership status to deceased for both active/inactive membership if ($contactId && diff --git a/CRM/Member/BAO/MembershipBlock.php b/CRM/Member/BAO/MembershipBlock.php index f70ef619d3bc..cc11ae37b1d2 100644 --- a/CRM/Member/BAO/MembershipBlock.php +++ b/CRM/Member/BAO/MembershipBlock.php @@ -39,7 +39,7 @@ public static function create(&$params) { CRM_Utils_Hook::pre($hook, 'MembershipBlock', CRM_Utils_Array::value('id', $params), $params); $dao = new CRM_Member_DAO_MembershipBlock(); $dao->copyValues($params); - $dao->id = CRM_Utils_Array::value('id', $params); + $dao->id = $params['id'] ?? NULL; $dao->save(); CRM_Utils_Hook::post($hook, 'MembershipBlock', $dao->id, $dao); return $dao; diff --git a/CRM/Member/BAO/MembershipType.php b/CRM/Member/BAO/MembershipType.php index add9aacac30a..e3d1fb89667c 100644 --- a/CRM/Member/BAO/MembershipType.php +++ b/CRM/Member/BAO/MembershipType.php @@ -85,13 +85,13 @@ public static function add(&$params, $ids = []) { if (isset($ids['membershipType'])) { Civi::log()->warning('Deprecated: Passing membershipType by $ids array in CRM_Member_BAO_MembershipType::add'); } - $params['id'] = CRM_Utils_Array::value('membershipType', $ids); + $params['id'] = $ids['membershipType'] ?? NULL; } $hook = empty($params['id']) ? 'create' : 'edit'; CRM_Utils_Hook::pre($hook, 'MembershipType', CRM_Utils_Array::value('id', $params), $params); - $membershipTypeId = CRM_Utils_Array::value('id', $params); + $membershipTypeId = $params['id'] ?? NULL; if (!$membershipTypeId) { if (!isset($params['is_active'])) { @@ -717,15 +717,15 @@ public static function createMembershipPriceField($params, $previousID, $members $fieldParams['is_display_amounts'] = $fieldParams['is_required'] = 0; $fieldParams['weight'] = $fieldParams['option_weight'][1] = 1; $fieldParams['option_label'][1] = $params['name']; - $fieldParams['option_description'][1] = CRM_Utils_Array::value('description', $params); + $fieldParams['option_description'][1] = $params['description'] ?? NULL; $fieldParams['membership_type_id'][1] = $membershipTypeId; $fieldParams['option_amount'][1] = empty($params['minimum_fee']) ? 0 : $params['minimum_fee']; - $fieldParams['financial_type_id'] = CRM_Utils_Array::value('financial_type_id', $params); + $fieldParams['financial_type_id'] = $params['financial_type_id'] ?? NULL; if ($previousID) { CRM_Member_Form_MembershipType::checkPreviousPriceField($previousID, $priceSetId, $membershipTypeId, $optionsIds); - $fieldParams['option_id'] = CRM_Utils_Array::value('option_id', $optionsIds); + $fieldParams['option_id'] = $optionsIds['option_id'] ?? NULL; } CRM_Price_BAO_PriceField::create($fieldParams); } @@ -759,8 +759,8 @@ public static function createMembershipPriceField($params, $previousID, $members $optionsIds['id'] = current(CRM_Utils_Array::value('option_id', $optionsIds)); } } - $results['financial_type_id'] = CRM_Utils_Array::value('financial_type_id', $params); - $results['description'] = CRM_Utils_Array::value('description', $params); + $results['financial_type_id'] = $params['financial_type_id'] ?? NULL; + $results['description'] = $params['description'] ?? NULL; CRM_Price_BAO_PriceFieldValue::add($results, $optionsIds); } } @@ -801,7 +801,7 @@ public static function updateAllPriceFieldValue($membershipTypeId, $params) { $updateParams['visibility_id'] = CRM_Price_BAO_PriceField::getVisibilityOptionID(strtolower($params['visibility'])); } else { - $updateParams[$value] = CRM_Utils_Array::value($key, $params); + $updateParams[$value] = $params[$key] ?? NULL; } } CRM_Price_BAO_PriceFieldValue::add($updateParams); diff --git a/CRM/Member/Form.php b/CRM/Member/Form.php index 1408396dafdd..dc8ca97f16d6 100644 --- a/CRM/Member/Form.php +++ b/CRM/Member/Form.php @@ -430,7 +430,7 @@ protected function ensurePriceParamsAreSet(&$formValues) { * @return array */ protected static function getPriceSetDetails($params) { - $priceSetID = CRM_Utils_Array::value('price_set_id', $params); + $priceSetID = $params['price_set_id'] ?? NULL; if ($priceSetID) { return CRM_Price_BAO_PriceSet::getSetDetail($priceSetID); } @@ -450,7 +450,7 @@ protected static function getPriceSetDetails($params) { * @return int */ protected static function getPriceSetID($params) { - $priceSetID = CRM_Utils_Array::value('price_set_id', $params); + $priceSetID = $params['price_set_id'] ?? NULL; if (!$priceSetID) { $priceSetDetails = self::getPriceSetDetails($params); return key($priceSetDetails); diff --git a/CRM/Member/Form/Membership.php b/CRM/Member/Form/Membership.php index bf26de3d4eef..e77afd4313b3 100644 --- a/CRM/Member/Form/Membership.php +++ b/CRM/Member/Form/Membership.php @@ -201,7 +201,7 @@ public function preProcess() { parent::preProcess(); // get price set id. - $this->_priceSetId = CRM_Utils_Array::value('priceSetId', $_GET); + $this->_priceSetId = $_GET['priceSetId'] ?? NULL; $this->set('priceSetId', $this->_priceSetId); $this->assign('priceSetId', $this->_priceSetId); @@ -227,7 +227,7 @@ public function preProcess() { $memberorgs = CRM_Member_BAO_MembershipType::getMemberOfContactByMemTypes($cMemTypes); $mems_by_org = []; foreach ($contactMemberships as $mem) { - $mem['member_of_contact_id'] = CRM_Utils_Array::value($mem['membership_type_id'], $memberorgs); + $mem['member_of_contact_id'] = $memberorgs[$mem['membership_type_id']] ?? NULL; if (!empty($mem['membership_end_date'])) { $mem['membership_end_date'] = CRM_Utils_Date::customFormat($mem['membership_end_date']); } @@ -487,7 +487,7 @@ public function buildQuickForm() { continue; } else { - $memberOfContactId = CRM_Utils_Array::value('member_of_contact_id', $values); + $memberOfContactId = $values['member_of_contact_id'] ?? NULL; if (empty($selMemTypeOrg[$memberOfContactId])) { $selMemTypeOrg[$memberOfContactId] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $memberOfContactId, @@ -498,10 +498,10 @@ public function buildQuickForm() { $selOrgMemType[$memberOfContactId][0] = ts('- select -'); } if (empty($selOrgMemType[$memberOfContactId][$key])) { - $selOrgMemType[$memberOfContactId][$key] = CRM_Utils_Array::value('name', $values); + $selOrgMemType[$memberOfContactId][$key] = $values['name'] ?? NULL; } } - $totalAmount = CRM_Utils_Array::value('minimum_fee', $values); + $totalAmount = $values['minimum_fee'] ?? NULL; //CRM-18827 - override the default value if total_amount is submitted if (!empty($this->_submitValues['total_amount'])) { $totalAmount = $this->_submitValues['total_amount']; @@ -710,7 +710,7 @@ public static function formRule($params, $files, $self) { if (empty($params['membership_type_id'][1])) { $errors['membership_type_id'] = ts('Please select a membership type.'); } - $numterms = CRM_Utils_Array::value('num_terms', $params); + $numterms = $params['num_terms'] ?? NULL; if ($numterms && intval($numterms) != $numterms) { $errors['num_terms'] = ts('Please enter an integer for the number of terms.'); } @@ -947,7 +947,7 @@ private function convertIsOverrideValue() { */ public static function emailReceipt(&$form, &$formValues, &$membership, $customValues = NULL) { // retrieve 'from email id' for acknowledgement - $receiptFrom = CRM_Utils_Array::value('from_email_address', $formValues); + $receiptFrom = $formValues['from_email_address'] ?? NULL; // @todo figure out how much of the stuff below is genuinely shared with the batch form & a logical shared place. if (!empty($formValues['payment_instrument_id'])) { @@ -1030,7 +1030,7 @@ public static function emailReceipt(&$form, &$formValues, &$membership, $customV $taxAmt = $template->get_template_vars('dataArray'); $eventTaxAmt = $template->get_template_vars('totalTaxAmount'); $prefixValue = Civi::settings()->get('contribution_invoice_settings'); - $invoicing = CRM_Utils_Array::value('invoicing', $prefixValue); + $invoicing = $prefixValue['invoicing'] ?? NULL; if ((!empty($taxAmt) || isset($eventTaxAmt)) && (isset($invoicing) && isset($prefixValue['is_email_pdf']))) { $isEmailPdf = TRUE; } @@ -1149,7 +1149,7 @@ public function submit() { if (!empty($formValues['tax_amount'])) { $params['tax_amount'] = $formValues['tax_amount']; } - $params['total_amount'] = CRM_Utils_Array::value('amount', $formValues); + $params['total_amount'] = $formValues['amount'] ?? NULL; if (!empty($lineItem[$this->_priceSetId])) { foreach ($lineItem[$this->_priceSetId] as &$li) { if (!empty($li['membership_type_id'])) { @@ -1161,7 +1161,7 @@ public function submit() { ///CRM-11529 for quick config backoffice transactions //when financial_type_id is passed in form, update the //lineitems with the financial type selected in form - $submittedFinancialType = CRM_Utils_Array::value('financial_type_id', $formValues); + $submittedFinancialType = $formValues['financial_type_id'] ?? NULL; if ($isQuickConfig && $submittedFinancialType) { $li['financial_type_id'] = $submittedFinancialType; } @@ -1179,7 +1179,7 @@ public function submit() { ]; foreach ($fields as $f) { - $params[$f] = CRM_Utils_Array::value($f, $formValues); + $params[$f] = $formValues[$f] ?? NULL; } // fix for CRM-3724 @@ -1214,9 +1214,9 @@ public function submit() { foreach ($calcDates as $memType => $calcDate) { foreach (array_keys($dateTypes) as $d) { //first give priority to form values then calDates. - $date = CRM_Utils_Array::value($d, $formValues); + $date = $formValues[$d] ?? NULL; if (!$date) { - $date = CRM_Utils_Array::value($d, $calcDate); + $date = $calcDate[$d] ?? NULL; } $membershipTypeValues[$memType][$d] = CRM_Utils_Date::processDate($date); @@ -1226,7 +1226,7 @@ public function submit() { foreach ($this->_memTypeSelected as $memType) { if (array_key_exists('max_related', $formValues)) { // max related memberships - take from form or inherit from membership type - $membershipTypeValues[$memType]['max_related'] = CRM_Utils_Array::value('max_related', $formValues); + $membershipTypeValues[$memType]['max_related'] = $formValues['max_related'] ?? NULL; } $membershipTypeValues[$memType]['custom'] = CRM_Core_BAO_CustomField::postProcess($formValues, $this->_id, @@ -1268,7 +1268,7 @@ public function submit() { ]; foreach ($recordContribution as $f) { - $params[$f] = CRM_Utils_Array::value($f, $formValues); + $params[$f] = $formValues[$f] ?? NULL; } if (!$this->_onlinePendingContributionId) { @@ -1294,7 +1294,7 @@ public function submit() { } if (!empty($formValues['send_receipt'])) { - $params['receipt_date'] = CRM_Utils_Array::value('receive_date', $formValues); + $params['receipt_date'] = $formValues['receive_date'] ?? NULL; } //insert financial type name in receipt. @@ -1313,8 +1313,8 @@ public function submit() { $params['total_amount'] = CRM_Utils_Array::value('total_amount', $formValues, 0); //CRM-20264 : Store CC type and number (last 4 digit) during backoffice or online payment - $params['card_type_id'] = CRM_Utils_Array::value('card_type_id', $this->_params); - $params['pan_truncation'] = CRM_Utils_Array::value('pan_truncation', $this->_params); + $params['card_type_id'] = $this->_params['card_type_id'] ?? NULL; + $params['pan_truncation'] = $this->_params['pan_truncation'] ?? NULL; if (!$isQuickConfig) { $params['financial_type_id'] = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', @@ -1323,7 +1323,7 @@ public function submit() { ); } else { - $params['financial_type_id'] = CRM_Utils_Array::value('financial_type_id', $formValues); + $params['financial_type_id'] = $formValues['financial_type_id'] ?? NULL; } //get the payment processor id as per mode. Try removing in favour of beginPostProcess. @@ -1455,7 +1455,7 @@ public function submit() { [1 => $membershipType, 2 => $userName] ); $params['source'] = $formValues['source'] ? $formValues['source'] : $params['contribution_source']; - $params['trxn_id'] = CRM_Utils_Array::value('trxn_id', $result); + $params['trxn_id'] = $result['trxn_id'] ?? NULL; $params['is_test'] = ($this->_mode === 'live') ? 0 : 1; if (!empty($formValues['send_receipt'])) { $params['receipt_date'] = $now; @@ -1496,7 +1496,7 @@ public function submit() { // appropriate as part of our 2-step always create the pending contribution & then finally add the payment // process - // @see http://wiki.civicrm.org/confluence/pages/viewpage.action?pageId=261062657#Payments&AccountsRoadmap-Movetowardsalwaysusinga2-steppaymentprocess - $membershipParams['contribution_status_id'] = CRM_Utils_Array::value('payment_status_id', $result); + $membershipParams['contribution_status_id'] = $result['payment_status_id'] ?? NULL; if (!empty($paymentParams['is_recur'])) { // The earlier process created the line items (although we want to get rid of the earlier one in favour // of a single path! @@ -1505,7 +1505,7 @@ public function submit() { $membershipParams['payment_instrument_id'] = $paymentInstrumentID; // @todo stop passing $ids (membership and userId only are set above) $membership = CRM_Member_BAO_Membership::create($membershipParams, $ids); - $params['contribution'] = CRM_Utils_Array::value('contribution', $membershipParams); + $params['contribution'] = $membershipParams['contribution'] ?? NULL; unset($params['lineItems']); $this->_membershipIDs[] = $membership->id; $createdMemberships[$memType] = $membership; @@ -1602,7 +1602,7 @@ public function submit() { } // @todo stop passing $ids (membership and userId only are set above) $membership = CRM_Member_BAO_Membership::create($membershipParams, $ids); - $params['contribution'] = CRM_Utils_Array::value('contribution', $membershipParams); + $params['contribution'] = $membershipParams['contribution'] ?? NULL; unset($params['lineItems']); // skip line item creation for next interation since line item(s) are already created. $params['skipLineItem'] = TRUE; @@ -1613,7 +1613,7 @@ public function submit() { } } } - $isRecur = CRM_Utils_Array::value('is_recur', $params); + $isRecur = $params['is_recur'] ?? NULL; if (($this->_action & CRM_Core_Action::UPDATE)) { $this->addStatusMessage($this->getStatusMessageForUpdate($membership, $endDate)); } @@ -1624,7 +1624,7 @@ public function submit() { if (!empty($lineItem[$this->_priceSetId])) { $invoiceSettings = Civi::settings()->get('contribution_invoice_settings'); - $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings); + $invoicing = $invoiceSettings['invoicing'] ?? NULL; $taxAmount = FALSE; $totalTaxAmount = 0; foreach ($lineItem[$this->_priceSetId] as & $priceFieldOp) { @@ -1645,10 +1645,10 @@ public function submit() { foreach ($lineItem[$this->_priceSetId] as $key => $value) { if (isset($value['tax_amount']) && isset($value['tax_rate'])) { if (isset($dataArray[$value['tax_rate']])) { - $dataArray[$value['tax_rate']] = $dataArray[$value['tax_rate']] + CRM_Utils_Array::value('tax_amount', $value); + $dataArray[$value['tax_rate']] = $dataArray[$value['tax_rate']] + $value['tax_amount'] ?? NULL; } else { - $dataArray[$value['tax_rate']] = CRM_Utils_Array::value('tax_amount', $value); + $dataArray[$value['tax_rate']] = $value['tax_amount'] ?? NULL; } } } @@ -1857,7 +1857,7 @@ protected function getStatusMessageForCreate($endDate, $membershipTypes, $create //get the end date from calculated dates. if (!$memEndDate && !$isRecur) { - $memEndDate = CRM_Utils_Array::value('end_date', $calcDates[$memType]); + $memEndDate = $calcDates[$memType]['end_date'] ?? NULL; } if ($memEndDate && $memEndDate !== 'null') { diff --git a/CRM/Member/Form/MembershipBlock.php b/CRM/Member/Form/MembershipBlock.php index 90d5a63a2e83..9f6b4ea0119c 100644 --- a/CRM/Member/Form/MembershipBlock.php +++ b/CRM/Member/Form/MembershipBlock.php @@ -337,7 +337,7 @@ public function postProcess() { if (is_array($params['membership_type'])) { foreach ($params['membership_type'] as $k => $v) { if ($v) { - $membershipTypes[$k] = CRM_Utils_Array::value("auto_renew_$k", $params); + $membershipTypes[$k] = $params["auto_renew_$k"] ?? NULL; } } } @@ -347,7 +347,7 @@ public function postProcess() { } // check for price set. - $priceSetID = CRM_Utils_Array::value('member_price_set_id', $params); + $priceSetID = $params['member_price_set_id'] ?? NULL; if (!empty($params['member_is_active']) && is_array($membershipTypes) && !$priceSetID) { $usedPriceSetId = CRM_Price_BAO_PriceSet::getFor('civicrm_contribution_page', $this->_id, 2); if (empty($params['mem_price_field_id']) && !$usedPriceSetId) { @@ -365,21 +365,21 @@ public function postProcess() { } $setParams['is_quick_config'] = 1; $setParams['extends'] = CRM_Core_Component::getComponentID('CiviMember'); - $setParams['financial_type_id'] = CRM_Utils_Array::value('financial_type_id', $this->_values); + $setParams['financial_type_id'] = $this->_values['financial_type_id'] ?? NULL; $priceSet = CRM_Price_BAO_PriceSet::create($setParams); $priceSetID = $priceSet->id; $fieldParams['price_set_id'] = $priceSet->id; } elseif ($usedPriceSetId) { $setParams['extends'] = CRM_Core_Component::getComponentID('CiviMember'); - $setParams['financial_type_id'] = CRM_Utils_Array::value('financial_type_id', $this->_values); + $setParams['financial_type_id'] = $this->_values['financial_type_id'] ?? NULL; $setParams['id'] = $usedPriceSetId; $priceSet = CRM_Price_BAO_PriceSet::create($setParams); $priceSetID = $priceSet->id; $fieldParams['price_set_id'] = $priceSet->id; } else { - $fieldParams['id'] = CRM_Utils_Array::value('mem_price_field_id', $params); + $fieldParams['id'] = $params['mem_price_field_id'] ?? NULL; $priceSetID = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', CRM_Utils_Array::value('mem_price_field_id', $params), 'price_set_id'); } $editedFieldParams = [ @@ -396,7 +396,7 @@ public function postProcess() { $fieldParams['weight'] = 1; } else { - $fieldParams['id'] = CRM_Utils_Array::value('id', $editedResults); + $fieldParams['id'] = $editedResults['id'] ?? NULL; } $fieldParams['label'] = !empty($params['membership_type_label']) ? $params['membership_type_label'] : ts('Membership'); @@ -416,12 +416,12 @@ public function postProcess() { unset($options[$priceFieldID]); } $membetype = CRM_Member_BAO_MembershipType::getMembershipTypeDetails($memType); - $fieldParams['option_label'][$rowCount] = CRM_Utils_Array::value('name', $membetype); + $fieldParams['option_label'][$rowCount] = $membetype['name'] ?? NULL; $fieldParams['option_amount'][$rowCount] = CRM_Utils_Array::value('minimum_fee', $membetype, 0); - $fieldParams['option_weight'][$rowCount] = CRM_Utils_Array::value('weight', $membetype); - $fieldParams['option_description'][$rowCount] = CRM_Utils_Array::value('description', $membetype); - $fieldParams['default_option'] = CRM_Utils_Array::value('membership_type_default', $params); - $fieldParams['option_financial_type_id'][$rowCount] = CRM_Utils_Array::value('financial_type_id', $membetype); + $fieldParams['option_weight'][$rowCount] = $membetype['weight'] ?? NULL; + $fieldParams['option_description'][$rowCount] = $membetype['description'] ?? NULL; + $fieldParams['default_option'] = $params['membership_type_default'] ?? NULL; + $fieldParams['option_financial_type_id'][$rowCount] = $membetype['financial_type_id'] ?? NULL; $fieldParams['membership_type_id'][$rowCount] = $memType; // [$rowCount] = $membetype['']; diff --git a/CRM/Member/Form/MembershipRenewal.php b/CRM/Member/Form/MembershipRenewal.php index 9b4f1d749125..667221b05f11 100644 --- a/CRM/Member/Form/MembershipRenewal.php +++ b/CRM/Member/Form/MembershipRenewal.php @@ -214,7 +214,7 @@ public function setDefaultValues() { $scTypes = CRM_Core_OptionGroup::values("soft_credit_type"); $defaults['soft_credit_type_id'] = CRM_Utils_Array::value(ts('Gift'), array_flip($scTypes)); - $renewalDate = CRM_Utils_Array::value('renewal_date', $defaults); + $renewalDate = $defaults['renewal_date'] ?? NULL; $this->assign('renewalDate', $renewalDate); $this->assign('member_is_test', CRM_Utils_Array::value('member_is_test', $defaults)); @@ -259,7 +259,7 @@ public function buildQuickForm() { continue; } else { - $memberOfContactId = CRM_Utils_Array::value('member_of_contact_id', $values); + $memberOfContactId = $values['member_of_contact_id'] ?? NULL; if (empty($selMemTypeOrg[$memberOfContactId])) { $selMemTypeOrg[$memberOfContactId] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $memberOfContactId, @@ -270,16 +270,16 @@ public function buildQuickForm() { $selOrgMemType[$memberOfContactId][0] = ts('- select -'); } if (empty($selOrgMemType[$memberOfContactId][$key])) { - $selOrgMemType[$memberOfContactId][$key] = CRM_Utils_Array::value('name', $values); + $selOrgMemType[$memberOfContactId][$key] = $values['name'] ?? NULL; } } //CRM-16950 $taxAmount = NULL; - $totalAmount = CRM_Utils_Array::value('minimum_fee', $values); + $totalAmount = $values['minimum_fee'] ?? NULL; // @todo - feels a bug - we use taxRate from the form default rather than from the specified type?!? if ($this->getTaxRateForFinancialType($values['financial_type_id'])) { - $taxAmount = ($taxRate / 100) * CRM_Utils_Array::value('minimum_fee', $values); + $taxAmount = ($taxRate / 100) * $values['minimum_fee'] ?? NULL; $totalAmount = $totalAmount + $taxAmount; } diff --git a/CRM/Member/Form/MembershipType.php b/CRM/Member/Form/MembershipType.php index 152680491f44..096aa786e084 100644 --- a/CRM/Member/Form/MembershipType.php +++ b/CRM/Member/Form/MembershipType.php @@ -502,7 +502,7 @@ public static function checkPreviousPriceField($previousID, $priceSetId, $member ]; $editedResults = []; CRM_Price_BAO_PriceFieldValue::retrieve($editedFieldParams, $editedResults); - $optionsIds['option_id'][1] = CRM_Utils_Array::value('id', $editedResults); + $optionsIds['option_id'][1] = $editedResults['id'] ?? NULL; } } } diff --git a/CRM/Member/Form/Task/Batch.php b/CRM/Member/Form/Task/Batch.php index 04c7bbb0c7b9..0d25822fee23 100644 --- a/CRM/Member/Form/Task/Batch.php +++ b/CRM/Member/Form/Task/Batch.php @@ -133,7 +133,7 @@ public function buildQuickForm() { $typeId = CRM_Core_DAO::getFieldValue("CRM_Member_DAO_Membership", $memberId, 'membership_type_id'); foreach ($this->_fields as $name => $field) { if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($name)) { - $customValue = CRM_Utils_Array::value($customFieldID, $customFields); + $customValue = $customFields[$customFieldID] ?? NULL; $entityColumnValue = []; if (!empty($customValue['extends_entity_column_value'])) { $entityColumnValue = explode(CRM_Core_DAO::VALUE_SEPARATOR, diff --git a/CRM/Member/Form/Task/Label.php b/CRM/Member/Form/Task/Label.php index 2068aeec0276..df6aa2d3b0aa 100644 --- a/CRM/Member/Form/Task/Label.php +++ b/CRM/Member/Form/Task/Label.php @@ -54,7 +54,7 @@ public function buildQuickForm() { public function setDefaultValues() { $defaults = []; $format = CRM_Core_BAO_LabelFormat::getDefaultValues(); - $defaults['label_name'] = CRM_Utils_Array::value('name', $format); + $defaults['label_name'] = $format['name'] ?? NULL; $defaults['merge_same_address'] = 0; $defaults['merge_same_household'] = 0; $defaults['do_not_mail'] = 1; @@ -70,11 +70,11 @@ public function setDefaultValues() { public function postProcess() { $formValues = $this->controller->exportValues($this->_name); $locationTypeID = $formValues['location_type_id']; - $respectDoNotMail = CRM_Utils_Array::value('do_not_mail', $formValues); + $respectDoNotMail = $formValues['do_not_mail'] ?? NULL; $labelName = $formValues['label_name']; - $mergeSameAddress = CRM_Utils_Array::value('merge_same_address', $formValues); - $mergeSameHousehold = CRM_Utils_Array::value('merge_same_household', $formValues); - $isPerMembership = CRM_Utils_Array::value('per_membership', $formValues); + $mergeSameAddress = $formValues['merge_same_address'] ?? NULL; + $mergeSameHousehold = $formValues['merge_same_household'] ?? NULL; + $isPerMembership = $formValues['per_membership'] ?? NULL; if ($isPerMembership && ($mergeSameAddress || $mergeSameHousehold)) { // this shouldn't happen - perhaps is could if JS is disabled CRM_Core_Session::setStatus(ts('As you are printing one label per membership your merge settings are being ignored')); diff --git a/CRM/Member/Import/Form/MapField.php b/CRM/Member/Import/Form/MapField.php index a991c85bcfef..57728384f8af 100644 --- a/CRM/Member/Import/Form/MapField.php +++ b/CRM/Member/Import/Form/MapField.php @@ -113,9 +113,9 @@ public function buildQuickForm() { $mappingName = $mappingName[1]; $mappingContactType = $mappingContactType[1]; - $mappingLocation = CRM_Utils_Array::value('1', $mappingLocation); - $mappingPhoneType = CRM_Utils_Array::value('1', $mappingPhoneType); - $mappingRelation = CRM_Utils_Array::value('1', $mappingRelation); + $mappingLocation = $mappingLocation['1'] ?? NULL; + $mappingPhoneType = $mappingPhoneType['1'] ?? NULL; + $mappingRelation = $mappingRelation['1'] ?? NULL; //mapping is to be loaded from database @@ -361,7 +361,7 @@ public static function formRule($fields, $files, $self) { } if (!empty($fields['saveMapping'])) { - $nameField = CRM_Utils_Array::value('saveMappingName', $fields); + $nameField = $fields['saveMappingName'] ?? NULL; if (empty($nameField)) { $errors['saveMappingName'] = ts('Name is required to save Import Mapping'); } diff --git a/CRM/Member/Import/Parser/Membership.php b/CRM/Member/Import/Parser/Membership.php index fcf45519cda3..0a1bd220ab4e 100644 --- a/CRM/Member/Import/Parser/Membership.php +++ b/CRM/Member/Import/Parser/Membership.php @@ -524,7 +524,7 @@ public function import($onDuplicate, &$values) { $formatted ); if (empty($formatted['status_id'])) { - $formatted['status_id'] = CRM_Utils_Array::value('id', $calcStatus); + $formatted['status_id'] = $calcStatus['id'] ?? NULL; } elseif (empty($formatted['member_is_override'])) { if (empty($calcStatus)) { diff --git a/CRM/Member/Page/AJAX.php b/CRM/Member/Page/AJAX.php index 4f44feaed876..85dd65416675 100644 --- a/CRM/Member/Page/AJAX.php +++ b/CRM/Member/Page/AJAX.php @@ -50,7 +50,7 @@ public static function getMemberTypeDefaults() { // fix the display of the monetary value, CRM-4038 $details['total_amount'] = CRM_Utils_Money::format($details['total_amount'], NULL, '%a'); $options = CRM_Core_SelectValues::memberAutoRenew(); - $details['auto_renew'] = CRM_Utils_Array::value('auto_renew', $options[$details]); + $details['auto_renew'] = $options[$details]['auto_renew'] ?? NULL; CRM_Utils_JSON::output($details); } diff --git a/CRM/Member/Page/DashBoard.php b/CRM/Member/Page/DashBoard.php index d44ce85c25fb..be08a4c5aedd 100644 --- a/CRM/Member/Page/DashBoard.php +++ b/CRM/Member/Page/DashBoard.php @@ -51,7 +51,7 @@ public function preProcess() { $isCurrentMonth = 0; // You can force the dashboard to display based upon a certain date - $ym = CRM_Utils_Array::value('date', $_GET); + $ym = $_GET['date'] ?? NULL; if ($ym) { if (preg_match('/^\d{6}$/', $ym) == 0 || diff --git a/CRM/Member/Page/MembershipType.php b/CRM/Member/Page/MembershipType.php index 6f2810aae014..1012cd28c64b 100644 --- a/CRM/Member/Page/MembershipType.php +++ b/CRM/Member/Page/MembershipType.php @@ -125,7 +125,7 @@ public function browse() { $value, $relationshipName ); } - $membershipType[$dao->id]['maxRelated'] = CRM_Utils_Array::value('max_related', $membershipType[$dao->id]); + $membershipType[$dao->id]['maxRelated'] = $membershipType[$dao->id]['max_related'] ?? NULL; } if (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus() && !CRM_Core_Permission::check('edit contributions of type ' . CRM_Contribute_PseudoConstant::financialType($dao->financial_type_id))) { unset($links[CRM_Core_Action::UPDATE], $links[CRM_Core_Action::ENABLE], $links[CRM_Core_Action::DISABLE]); diff --git a/CRM/Member/Page/RecurringContributions.php b/CRM/Member/Page/RecurringContributions.php index 546350457f15..aac582c3892e 100644 --- a/CRM/Member/Page/RecurringContributions.php +++ b/CRM/Member/Page/RecurringContributions.php @@ -96,7 +96,7 @@ private function getRecurContributions($membershipID) { $recurringContributions[$recurringContributionID]['id'] = $recurringContributionID; $recurringContributions[$recurringContributionID]['contactId'] = $contactID; - $recurringContributions[$recurringContributionID]['contribution_status'] = CRM_Utils_Array::value($contributionStatusID, $contributionStatuses); + $recurringContributions[$recurringContributionID]['contribution_status'] = $contributionStatuses[$contributionStatusID] ?? NULL; $this->setActionsForRecurringContribution($recurringContributionID, $recurringContributions[$recurringContributionID]); } diff --git a/CRM/Member/Page/Tab.php b/CRM/Member/Page/Tab.php index fb937edd24dc..8301a964a757 100644 --- a/CRM/Member/Page/Tab.php +++ b/CRM/Member/Page/Tab.php @@ -69,12 +69,12 @@ public function browse() { CRM_Core_DAO::storeValues($dao, $membership[$dao->id]); //carry campaign. - $membership[$dao->id]['campaign'] = CRM_Utils_Array::value($dao->campaign_id, $allCampaigns); + $membership[$dao->id]['campaign'] = $allCampaigns[$dao->campaign_id] ?? NULL; //get the membership status and type values. $statusANDType = CRM_Member_BAO_Membership::getStatusANDTypeValues($dao->id); foreach (['status', 'membership_type'] as $fld) { - $membership[$dao->id][$fld] = CRM_Utils_Array::value($fld, $statusANDType[$dao->id]); + $membership[$dao->id][$fld] = $statusANDType[$dao->id][$fld] ?? NULL; } if (!empty($statusANDType[$dao->id]['is_current_member'])) { $membership[$dao->id]['active'] = TRUE; @@ -162,7 +162,7 @@ public function browse() { LEFT JOIN civicrm_contact ct ON ct.id = m.contact_id WHERE m.owner_membership_id = {$dao->id} AND m.is_test = 0 AND ms.is_current_member = 1 AND ct.is_deleted = 0"; $num_related = CRM_Core_DAO::singleValueQuery($query); - $max_related = CRM_Utils_Array::value('max_related', $membership[$dao->id]); + $max_related = $membership[$dao->id]['max_related'] ?? NULL; $membership[$dao->id]['related_count'] = ($max_related == '' ? ts('%1 created', [1 => $num_related]) : ts('%1 out of %2', [ 1 => $num_related, 2 => $max_related, @@ -181,7 +181,7 @@ public function browse() { 'limit' => 0, ], ]); - $membershipTypes = CRM_Utils_Array::value('values', $membershipTypesResult, NULL); + $membershipTypes = $membershipTypesResult['values'] ?? NULL; foreach ($membershipTypes as $key => $value) { $membershipTypes[$key]['action'] = CRM_Core_Action::formLink(self::membershipTypeslinks(), diff --git a/CRM/Member/Page/UserDashboard.php b/CRM/Member/Page/UserDashboard.php index 95759377f519..7ac24c15ff92 100644 --- a/CRM/Member/Page/UserDashboard.php +++ b/CRM/Member/Page/UserDashboard.php @@ -43,7 +43,7 @@ public function listMemberships() { 'status', 'membership_type', ] as $fld) { - $membership[$dao->id][$fld] = CRM_Utils_Array::value($fld, $statusANDType[$dao->id]); + $membership[$dao->id][$fld] = $statusANDType[$dao->id][$fld] ?? NULL; } if (!empty($statusANDType[$dao->id]['is_current_member'])) { $membership[$dao->id]['active'] = TRUE; diff --git a/CRM/Member/PseudoConstant.php b/CRM/Member/PseudoConstant.php index dad1efc157aa..455ff98c9e09 100644 --- a/CRM/Member/PseudoConstant.php +++ b/CRM/Member/PseudoConstant.php @@ -96,7 +96,7 @@ public static function &membershipStatus($id = NULL, $cond = NULL, $column = 'na $value = NULL; if ($id) { - $value = CRM_Utils_Array::value($id, self::$membershipStatus[$cacheKey]); + $value = self::$membershipStatus[$cacheKey][$id] ?? NULL; } else { $value = self::$membershipStatus[$cacheKey]; diff --git a/CRM/Member/Selector/Search.php b/CRM/Member/Selector/Search.php index eed017706da9..45ccf5099270 100644 --- a/CRM/Member/Selector/Search.php +++ b/CRM/Member/Selector/Search.php @@ -357,7 +357,7 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { } //carry campaign on selectors. - $row['campaign'] = CRM_Utils_Array::value($result->member_campaign_id, $allCampaigns); + $row['campaign'] = $allCampaigns[$result->member_campaign_id] ?? NULL; $row['campaign_id'] = $result->member_campaign_id; if (!empty($row['member_is_test'])) { diff --git a/CRM/Member/StateMachine/Search.php b/CRM/Member/StateMachine/Search.php index 9f9a9514935e..8d3ea7a3c3e1 100644 --- a/CRM/Member/StateMachine/Search.php +++ b/CRM/Member/StateMachine/Search.php @@ -69,7 +69,7 @@ public function __construct($controller, $action = CRM_Core_Action::NONE) { */ public function taskName($controller, $formName = 'Search') { // total hack, check POST vars and then session to determine stuff - $value = CRM_Utils_Array::value('task', $_POST); + $value = $_POST['task'] ?? NULL; if (!isset($value)) { $value = $this->_controller->get('task'); } diff --git a/CRM/PCP/BAO/PCP.php b/CRM/PCP/BAO/PCP.php index 6b4660548e3e..3817a3e30d89 100644 --- a/CRM/PCP/BAO/PCP.php +++ b/CRM/PCP/BAO/PCP.php @@ -138,7 +138,7 @@ public static function getPcpDashboardInfo($contactId) { $action = CRM_Core_Action::formLink($pcpLink, $mask, $replace, ts('more'), FALSE, 'pcp.dashboard.active', 'PCP', $pcpInfoDao->id); $component = $pcpInfoDao->page_type; - $pageTitle = CRM_Utils_Array::value($pcpInfoDao->page_id, $$component); + $pageTitle = $$component[$pcpInfoDao->page_id] ?? NULL; $pcpInfo[] = [ 'pageTitle' => $pageTitle, diff --git a/CRM/PCP/Form/Campaign.php b/CRM/PCP/Form/Campaign.php index 44d7d872f8ce..a3037bcd35c6 100644 --- a/CRM/PCP/Form/Campaign.php +++ b/CRM/PCP/Form/Campaign.php @@ -68,8 +68,8 @@ public function setDefaultValues() { $defaults['goal_amount'] = CRM_Utils_Money::format($defaults['goal_amount'], NULL, '%a'); } - $defaults['pcp_title'] = CRM_Utils_Array::value('title', $defaults); - $defaults['pcp_intro_text'] = CRM_Utils_Array::value('intro_text', $defaults); + $defaults['pcp_title'] = $defaults['title'] ?? NULL; + $defaults['pcp_intro_text'] = $defaults['intro_text'] ?? NULL; } if ($this->get('action') & CRM_Core_Action::ADD) { @@ -79,8 +79,8 @@ public function setDefaultValues() { $defaults['is_notify'] = 1; } - $this->_contactID = CRM_Utils_Array::value('contact_id', $defaults); - $this->_contriPageId = CRM_Utils_Array::value('page_id', $defaults); + $this->_contactID = $defaults['contact_id'] ?? NULL; + $this->_contriPageId = $defaults['page_id'] ?? NULL; return $defaults; } diff --git a/CRM/PCP/Form/Contribute.php b/CRM/PCP/Form/Contribute.php index 124bbcf1fee0..bbe080e1e46b 100644 --- a/CRM/PCP/Form/Contribute.php +++ b/CRM/PCP/Form/Contribute.php @@ -47,7 +47,7 @@ public function setDefaultValues() { if (isset($this->_id)) { $params = ['entity_id' => $this->_id, 'entity_table' => 'civicrm_contribution_page']; CRM_Core_DAO::commonRetrieve('CRM_PCP_DAO_PCPBlock', $params, $defaults); - $defaults['pcp_active'] = CRM_Utils_Array::value('is_active', $defaults); + $defaults['pcp_active'] = $defaults['is_active'] ?? NULL; // Assign contribution page ID to pageId for referencing in PCP.hlp - since $id is overwritten there. dgg $this->assign('pageId', $this->_id); } diff --git a/CRM/PCP/Form/Event.php b/CRM/PCP/Form/Event.php index 5ea57f4686ee..004282d38358 100644 --- a/CRM/PCP/Form/Event.php +++ b/CRM/PCP/Form/Event.php @@ -48,7 +48,7 @@ public function setDefaultValues() { $params = ['entity_id' => $this->_id, 'entity_table' => 'civicrm_event']; CRM_Core_DAO::commonRetrieve('CRM_PCP_DAO_PCPBlock', $params, $defaults); - $defaults['pcp_active'] = CRM_Utils_Array::value('is_active', $defaults); + $defaults['pcp_active'] = $defaults['is_active'] ?? NULL; // Assign contribution page ID to pageId for referencing in PCP.hlp - since $id is overwritten there. dgg $this->assign('pageId', $this->_id); } diff --git a/CRM/PCP/Form/PCP.php b/CRM/PCP/Form/PCP.php index cb7482a3ffb3..d9fbcb7c6975 100644 --- a/CRM/PCP/Form/PCP.php +++ b/CRM/PCP/Form/PCP.php @@ -43,8 +43,8 @@ public function preProcess() { } if (!$this->_action) { - $this->_action = CRM_Utils_Array::value('action', $_GET); - $this->_id = CRM_Utils_Array::value('id', $_GET); + $this->_action = $_GET['action'] ?? NULL; + $this->_id = $_GET['id'] ?? NULL; } else { $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this); diff --git a/CRM/PCP/Page/PCPInfo.php b/CRM/PCP/Page/PCPInfo.php index 8468710369d7..de831f3b2479 100644 --- a/CRM/PCP/Page/PCPInfo.php +++ b/CRM/PCP/Page/PCPInfo.php @@ -139,7 +139,7 @@ public function run() { if ($pcpInfo['contact_id'] == $session->get('userID')) { $owner = $pageInfo; - $owner['status'] = CRM_Utils_Array::value($pcpInfo['status_id'], $pcpStatus); + $owner['status'] = $pcpStatus[$pcpInfo['status_id']] ?? NULL; $this->assign('owner', $owner); diff --git a/CRM/Pledge/BAO/Pledge.php b/CRM/Pledge/BAO/Pledge.php index fbe7a757d0fb..4fdc3ec5f656 100644 --- a/CRM/Pledge/BAO/Pledge.php +++ b/CRM/Pledge/BAO/Pledge.php @@ -157,7 +157,7 @@ public static function create(&$params) { } } } - $paymentParams['status_id'] = CRM_Utils_Array::value('status_id', $params); + $paymentParams['status_id'] = $params['status_id'] ?? NULL; $pledge = self::add($params); if (is_a($pledge, 'CRM_Core_Error')) { @@ -195,7 +195,7 @@ public static function create(&$params) { 'actual_amount', ); foreach ($paymentKeys as $key) { - $paymentParams[$key] = CRM_Utils_Array::value($key, $params, NULL); + $paymentParams[$key] = $params[$key] ?? NULL; } CRM_Pledge_BAO_PledgePayment::create($paymentParams); } @@ -626,8 +626,8 @@ public static function sendAcknowledgment(&$form, $params) { // check for online pledge. if (!empty($params['receipt_from_email'])) { - $userName = CRM_Utils_Array::value('receipt_from_name', $params); - $userEmail = CRM_Utils_Array::value('receipt_from_email', $params); + $userName = $params['receipt_from_name'] ?? NULL; + $userEmail = $params['receipt_from_email'] ?? NULL; } elseif (!empty($params['from_email_id'])) { $receiptFrom = $params['from_email_id']; @@ -638,8 +638,8 @@ public static function sendAcknowledgment(&$form, $params) { } else { // set the domain values. - $userName = CRM_Utils_Array::value('name', $domainValues); - $userEmail = CRM_Utils_Array::value('email', $domainValues); + $userName = $domainValues['name'] ?? NULL; + $userEmail = $domainValues['email'] ?? NULL; } if (!isset($receiptFrom)) { diff --git a/CRM/Pledge/BAO/PledgeBlock.php b/CRM/Pledge/BAO/PledgeBlock.php index 1ac0016cda07..8d363e06f9ac 100644 --- a/CRM/Pledge/BAO/PledgeBlock.php +++ b/CRM/Pledge/BAO/PledgeBlock.php @@ -90,7 +90,7 @@ public static function add(&$params) { $pledgeBlock = new CRM_Pledge_DAO_PledgeBlock(); // fix for pledge_frequency_unit - $freqUnits = CRM_Utils_Array::value('pledge_frequency_unit', $params); + $freqUnits = $params['pledge_frequency_unit'] ?? NULL; if ($freqUnits && is_array($freqUnits)) { unset($params['pledge_frequency_unit']); @@ -231,7 +231,7 @@ public static function buildPledgeBlock($form) { 1 => CRM_Utils_Money::format(CRM_Utils_Array::value('scheduled_amount', $payment), CRM_Utils_Array::value('scheduled_amount_currency', $payment)), 2 => $payment['scheduled_date'] ?? NULL, )); - $paymentID = CRM_Utils_Array::value('id', $payment); + $paymentID = $payment['id'] ?? NULL; $payments[] = $form->createElement('checkbox', $paymentID, NULL, $label, array('amount' => CRM_Utils_Array::value('scheduled_amount', $payment))); } } @@ -241,7 +241,7 @@ public static function buildPledgeBlock($form) { 1 => CRM_Utils_Money::format(CRM_Utils_Array::value('scheduled_amount', $nextPayment), CRM_Utils_Array::value('scheduled_amount_currency', $nextPayment)), 2 => $nextPayment['scheduled_date'] ?? NULL, )); - $paymentID = CRM_Utils_Array::value('id', $nextPayment); + $paymentID = $nextPayment['id'] ?? NULL; $payments[] = $form->createElement('checkbox', $paymentID, NULL, $label, array('amount' => CRM_Utils_Array::value('scheduled_amount', $nextPayment))); } // give error if empty or build form for payment. diff --git a/CRM/Pledge/Form/Pledge.php b/CRM/Pledge/Form/Pledge.php index 010335cddd14..a4418c1813ba 100644 --- a/CRM/Pledge/Form/Pledge.php +++ b/CRM/Pledge/Form/Pledge.php @@ -205,7 +205,7 @@ public function buildQuickForm() { } $showAdditionalInfo = FALSE; - $this->_formType = CRM_Utils_Array::value('formType', $_GET); + $this->_formType = $_GET['formType'] ?? NULL; $defaults = []; @@ -446,12 +446,12 @@ public function postProcess() { 'campaign_id', ]; foreach ($fields as $f) { - $params[$f] = CRM_Utils_Array::value($f, $formValues); + $params[$f] = $formValues[$f] ?? NULL; } // format amount $params['amount'] = CRM_Utils_Rule::cleanMoney(CRM_Utils_Array::value('amount', $formValues)); - $params['currency'] = CRM_Utils_Array::value('currency', $formValues); + $params['currency'] = $formValues['currency'] ?? NULL; $params['original_installment_amount'] = ($params['amount'] / $params['installments']); $dates = ['create_date', 'start_date', 'acknowledge_date', 'cancel_date']; diff --git a/CRM/Pledge/Selector/Search.php b/CRM/Pledge/Selector/Search.php index fa142004dcf2..aef07fbcfa99 100644 --- a/CRM/Pledge/Selector/Search.php +++ b/CRM/Pledge/Selector/Search.php @@ -167,8 +167,8 @@ public function __construct( */ public static function &links() { $args = func_get_args(); - $hideOption = CRM_Utils_Array::value(0, $args); - $key = CRM_Utils_Array::value(1, $args); + $hideOption = $args[0] ?? NULL; + $key = $args[1] ?? NULL; $extraParams = ($key) ? "&key={$key}" : NULL; @@ -299,7 +299,7 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { } // carry campaign on selectors. - $row['campaign'] = CRM_Utils_Array::value($result->pledge_campaign_id, $allCampaigns); + $row['campaign'] = $allCampaigns[$result->pledge_campaign_id] ?? NULL; $row['campaign_id'] = $result->pledge_campaign_id; // add pledge status name diff --git a/CRM/Pledge/StateMachine/Search.php b/CRM/Pledge/StateMachine/Search.php index 9b8eb4a85a70..b47ba015f97c 100644 --- a/CRM/Pledge/StateMachine/Search.php +++ b/CRM/Pledge/StateMachine/Search.php @@ -69,7 +69,7 @@ public function __construct($controller, $action = CRM_Core_Action::NONE) { */ public function taskName($controller, $formName = 'Search') { // total hack, check POST vars and then session to determine stuff - $value = CRM_Utils_Array::value('task', $_POST); + $value = $_POST['task'] ?? NULL; if (!isset($value)) { $value = $this->_controller->get('task'); } diff --git a/CRM/Price/BAO/LineItem.php b/CRM/Price/BAO/LineItem.php index 9c5b9bd58c0c..516b2c84ec23 100644 --- a/CRM/Price/BAO/LineItem.php +++ b/CRM/Price/BAO/LineItem.php @@ -32,7 +32,7 @@ class CRM_Price_BAO_LineItem extends CRM_Price_DAO_LineItem { * @throws \Exception */ public static function create(&$params) { - $id = CRM_Utils_Array::value('id', $params); + $id = $params['id'] ?? NULL; if ($id) { CRM_Utils_Hook::pre('edit', 'LineItem', $id, $params); $op = CRM_Core_Action::UPDATE; @@ -45,8 +45,8 @@ public static function create(&$params) { // unset entity table and entity id in $params // we never update the entity table and entity id during update mode if ($id) { - $entity_id = CRM_Utils_Array::value('entity_id', $params); - $entity_table = CRM_Utils_Array::value('entity_table', $params); + $entity_id = $params['entity_id'] ?? NULL; + $entity_table = $params['entity_table'] ?? NULL; unset($params['entity_id'], $params['entity_table']); } else { @@ -242,7 +242,7 @@ public static function getLineItems($entityId, $entity = 'participant', $isQuick $getTaxDetails = FALSE; $invoiceSettings = Civi::settings()->get('contribution_invoice_settings'); - $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings); + $invoicing = $invoiceSettings['invoicing'] ?? NULL; $dao = CRM_Core_DAO::executeQuery("$selectClause $fromClause $whereClause $orderByClause", $params); while ($dao->fetch()) { @@ -286,7 +286,7 @@ public static function getLineItems($entityId, $entity = 'participant', $isQuick } if ($invoicing) { // @todo - this is an inappropriate place to be doing form level assignments. - $taxTerm = CRM_Utils_Array::value('tax_term', $invoiceSettings); + $taxTerm = $invoiceSettings['tax_term'] ?? NULL; $smarty = CRM_Core_Smarty::singleton(); $smarty->assign('taxTerm', $taxTerm); $smarty->assign('getTaxDetails', $getTaxDetails); @@ -329,7 +329,7 @@ public static function format($fid, $params, $fields, &$values, $amount_override else { CRM_Price_BAO_PriceFieldValue::getValues($fid, $options, 'weight', TRUE); } - $fieldTitle = CRM_Utils_Array::value('label', $fields); + $fieldTitle = $fields['label'] ?? NULL; if (!$fieldTitle) { $fieldTitle = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', $fid, 'label'); } @@ -533,7 +533,7 @@ public static function getLineItemArray(&$params, $entityId = NULL, $entityTable if (!$entityId) { $priceSetDetails = CRM_Price_BAO_PriceSet::getDefaultPriceSet($entityTable); $totalAmount = CRM_Utils_Array::value('partial_payment_total', $params, CRM_Utils_Array::value('total_amount', $params)); - $financialType = CRM_Utils_Array::value('financial_type_id', $params); + $financialType = $params['financial_type_id'] ?? NULL; foreach ($priceSetDetails as $values) { if ($entityTable == 'membership') { if ($isRelatedID != $values['membership_type_id']) { diff --git a/CRM/Price/BAO/PriceField.php b/CRM/Price/BAO/PriceField.php index a65ec27c09af..411d11ede55b 100644 --- a/CRM/Price/BAO/PriceField.php +++ b/CRM/Price/BAO/PriceField.php @@ -294,7 +294,7 @@ public static function addQuickFormElement( $is_pay_later = 1; } elseif (isset($qf->_values)) { - $is_pay_later = CRM_Utils_Array::value('is_pay_later', $qf->_values); + $is_pay_later = $qf->_values['is_pay_later'] ?? NULL; } $otherAmount = $qf->get('values'); @@ -325,15 +325,15 @@ public static function addQuickFormElement( $valueFieldName = 'amount'; $seperator = '|'; $invoiceSettings = Civi::settings()->get('contribution_invoice_settings'); - $taxTerm = CRM_Utils_Array::value('tax_term', $invoiceSettings); - $displayOpt = CRM_Utils_Array::value('tax_display_settings', $invoiceSettings); - $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings); + $taxTerm = $invoiceSettings['tax_term'] ?? NULL; + $displayOpt = $invoiceSettings['tax_display_settings'] ?? NULL; + $invoicing = $invoiceSettings['invoicing'] ?? NULL; switch ($field->html_type) { case 'Text': $optionKey = key($customOption); $count = CRM_Utils_Array::value('count', $customOption[$optionKey], ''); $max_value = CRM_Utils_Array::value('max_value', $customOption[$optionKey], ''); - $taxAmount = CRM_Utils_Array::value('tax_amount', $customOption[$optionKey]); + $taxAmount = $customOption[$optionKey]['tax_amount'] ?? NULL; if (isset($taxAmount) && $displayOpt && $invoicing) { $qf->assign('displayOpt', $displayOpt); $qf->assign('taxTerm', $taxTerm); @@ -400,7 +400,7 @@ public static function addQuickFormElement( } foreach ($customOption as $opId => $opt) { - $taxAmount = CRM_Utils_Array::value('tax_amount', $opt); + $taxAmount = $opt['tax_amount'] ?? NULL; if ($field->is_display_amounts) { $opt['label'] = !empty($opt['label']) ? $opt['label'] . ' - ' : ''; $preHelpText = $postHelpText = ''; @@ -512,7 +512,7 @@ public static function addQuickFormElement( $selectOption = $allowedOptions = $priceVal = []; foreach ($customOption as $opt) { - $taxAmount = CRM_Utils_Array::value('tax_amount', $opt); + $taxAmount = $opt['tax_amount'] ?? NULL; $count = CRM_Utils_Array::value('count', $opt, ''); $max_value = CRM_Utils_Array::value('max_value', $opt, ''); @@ -568,7 +568,7 @@ public static function addQuickFormElement( $check = []; foreach ($customOption as $opId => $opt) { - $taxAmount = CRM_Utils_Array::value('tax_amount', $opt); + $taxAmount = $opt['tax_amount'] ?? NULL; $count = CRM_Utils_Array::value('count', $opt, ''); $max_value = CRM_Utils_Array::value('max_value', $opt, ''); diff --git a/CRM/Price/BAO/PriceFieldValue.php b/CRM/Price/BAO/PriceFieldValue.php index a8cfdb9eff06..34d431210a9b 100644 --- a/CRM/Price/BAO/PriceFieldValue.php +++ b/CRM/Price/BAO/PriceFieldValue.php @@ -39,7 +39,7 @@ public static function add(&$params, $ids = []) { $fieldValueBAO->copyValues($params); // CRM-16189 - $priceFieldID = CRM_Utils_Array::value('price_field_id', $params); + $priceFieldID = $params['price_field_id'] ?? NULL; $id = CRM_Utils_Array::value('id', $ids, CRM_Utils_Array::value('id', $params)); @@ -102,7 +102,7 @@ public static function create(&$params, $ids = []) { } } - $financialType = CRM_Utils_Array::value('financial_type_id', $params, NULL); + $financialType = $params['financial_type_id'] ?? NULL; if (!$financialType && $id) { $financialType = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceFieldValue', $id, 'financial_type_id', 'id'); } diff --git a/CRM/Price/BAO/PriceSet.php b/CRM/Price/BAO/PriceSet.php index f9e24c14d942..c2878d80db38 100644 --- a/CRM/Price/BAO/PriceSet.php +++ b/CRM/Price/BAO/PriceSet.php @@ -61,7 +61,7 @@ public static function create(&$params) { $params['extends'] = CRM_Utils_Array::implodePadded($params['extends']); } else { - $priceSetID = CRM_Utils_Array::value('id', $params); + $priceSetID = $params['id'] ?? NULL; } $priceSetBAO = new CRM_Price_BAO_PriceSet(); $priceSetBAO->copyValues($params); @@ -340,7 +340,7 @@ public static function getSetId(&$params) { } } else { - $fid = CRM_Utils_Array::value('fid', $params); + $fid = $params['fid'] ?? NULL; } if (isset($fid)) { @@ -603,8 +603,8 @@ public static function initSet(&$form, $entityTable = 'civicrm_event', $validOnl $form->_priceSetId = $priceSetId; $priceSet = self::getSetDetail($priceSetId, $required, $validOnly); - $form->_priceSet = CRM_Utils_Array::value($priceSetId, $priceSet); - $form->_values['fee'] = CRM_Utils_Array::value('fields', $form->_priceSet); + $form->_priceSet = $priceSet[$priceSetId] ?? NULL; + $form->_values['fee'] = $form->_priceSet['fields'] ?? NULL; //get the price set fields participant count. if ($entityTable == 'civicrm_event') { @@ -829,7 +829,7 @@ public static function buildPriceSet(&$form) { } $priceSet = self::getSetDetail($priceSetId, TRUE, $validFieldsOnly); - $form->_priceSet = CRM_Utils_Array::value($priceSetId, $priceSet); + $form->_priceSet = $priceSet[$priceSetId] ?? NULL; $validPriceFieldIds = array_keys($form->_priceSet['fields']); $form->_quickConfig = $quickConfig = 0; if (CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $priceSetId, 'is_quick_config')) { @@ -900,7 +900,7 @@ public static function buildPriceSet(&$form) { (CRM_Utils_Array::value('visibility', $field) == 'admin' && $adminFieldVisible == TRUE) || !$validFieldsOnly ) { - $options = CRM_Utils_Array::value('options', $field); + $options = $field['options'] ?? NULL; if ($className == 'CRM_Contribute_Form_Contribution_Main' && $component = 'membership') { $userid = $form->getVar('_membershipContactID'); $checklifetime = self::checkCurrentMembership($options, $userid); @@ -1743,7 +1743,7 @@ protected static function getLine(&$params, &$lineItem, $priceSetID, $field, $id $lineItem[$optionValueId]['line_total'] = $lineItem[$optionValueId]['unit_price'] = CRM_Utils_Rule::cleanMoney($lineItem[$optionValueId]['line_total'] - $lineItem[$optionValueId]['tax_amount']); } } - $totalPrice += $lineItem[$optionValueId]['line_total'] + CRM_Utils_Array::value('tax_amount', $lineItem[$optionValueId]); + $totalPrice += $lineItem[$optionValueId]['line_total'] + $lineItem[$optionValueId]['tax_amount'] ?? NULL; break; case 'Select': @@ -1754,7 +1754,7 @@ protected static function getLine(&$params, &$lineItem, $priceSetID, $field, $id if (!empty($field['options'][$optionValueId]['tax_rate'])) { $lineItem = self::setLineItem($field, $lineItem, $optionValueId, $totalTax); } - $totalPrice += $lineItem[$optionValueId]['line_total'] + CRM_Utils_Array::value('tax_amount', $lineItem[$optionValueId]); + $totalPrice += $lineItem[$optionValueId]['line_total'] + $lineItem[$optionValueId]['tax_amount'] ?? NULL; break; case 'CheckBox': @@ -1764,7 +1764,7 @@ protected static function getLine(&$params, &$lineItem, $priceSetID, $field, $id if (!empty($field['options'][$optionId]['tax_rate'])) { $lineItem = self::setLineItem($field, $lineItem, $optionId, $totalTax); } - $totalPrice += $lineItem[$optionId]['line_total'] + CRM_Utils_Array::value('tax_amount', $lineItem[$optionId]); + $totalPrice += $lineItem[$optionId]['line_total'] + $lineItem[$optionId]['tax_amount'] ?? NULL; } break; } diff --git a/CRM/Price/Form/Field.php b/CRM/Price/Form/Field.php index 5e4a5c4e8d25..c8e0f2a7b7da 100644 --- a/CRM/Price/Form/Field.php +++ b/CRM/Price/Form/Field.php @@ -574,7 +574,7 @@ public static function formRule($fields, $files, $form) { for ($index = 1; $index <= self::NUM_OPTION; $index++) { $isOptionSet = !empty($fields['option_label'][$index]) || !empty($fields['option_amount'][$index]); - $currentOptionVisibility = CRM_Utils_Array::value($fields['option_visibility_id'][$index], $visibilityOptions); + $currentOptionVisibility = $visibilityOptions[$fields['option_visibility_id'][$index]] ?? NULL; if ($isOptionSet && $currentOptionVisibility == 'public') { $errors["option_visibility_id[{$index}]"] = ts('\'Admin\' field should only have \'Admin\' visibility options.'); diff --git a/CRM/Price/Form/Set.php b/CRM/Price/Form/Set.php index 47f45516f22c..96a5b53cb349 100644 --- a/CRM/Price/Form/Set.php +++ b/CRM/Price/Form/Set.php @@ -269,7 +269,7 @@ public function postProcess() { $params['financial_type_id'] = CRM_Utils_Array::value('financial_type_id', $params, FALSE); $compIds = []; - $extends = CRM_Utils_Array::value('extends', $params); + $extends = $params['extends'] ?? NULL; if (is_array($extends)) { foreach ($extends as $compId => $selected) { if ($selected) { diff --git a/CRM/Price/Page/Field.php b/CRM/Price/Page/Field.php index 8279fc310a7b..141670e4d10b 100644 --- a/CRM/Price/Page/Field.php +++ b/CRM/Price/Page/Field.php @@ -111,8 +111,8 @@ public function browse() { // display taxTerm for priceFields $invoiceSettings = Civi::settings()->get('contribution_invoice_settings'); - $taxTerm = CRM_Utils_Array::value('tax_term', $invoiceSettings); - $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings); + $taxTerm = $invoiceSettings['tax_term'] ?? NULL; + $invoicing = $invoiceSettings['invoicing'] ?? NULL; $getTaxDetails = FALSE; $taxRate = CRM_Core_PseudoConstant::getTaxRates(); CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($financialTypes); @@ -126,7 +126,7 @@ public function browse() { $params = ['price_field_id' => $priceFieldBAO->id]; CRM_Price_BAO_PriceFieldValue::retrieve($params, $optionValues); - $priceField[$priceFieldBAO->id]['price'] = CRM_Utils_Array::value('amount', $optionValues); + $priceField[$priceFieldBAO->id]['price'] = $optionValues['amount'] ?? NULL; $financialTypeId = $optionValues['financial_type_id']; if ($invoicing && isset($taxRate[$financialTypeId])) { $priceField[$priceFieldBAO->id]['tax_rate'] = $taxRate[$financialTypeId]; diff --git a/CRM/Price/Page/Option.php b/CRM/Price/Page/Option.php index f7b46ab6893b..df3b6a3fc99a 100644 --- a/CRM/Price/Page/Option.php +++ b/CRM/Price/Page/Option.php @@ -130,8 +130,8 @@ public function browse() { $taxRate = CRM_Core_PseudoConstant::getTaxRates(); // display taxTerm for priceFields $invoiceSettings = Civi::settings()->get('contribution_invoice_settings'); - $taxTerm = CRM_Utils_Array::value('tax_term', $invoiceSettings); - $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings); + $taxTerm = $invoiceSettings['tax_term'] ?? NULL; + $invoicing = $invoiceSettings['invoicing'] ?? NULL; $getTaxDetails = FALSE; foreach ($customOption as $id => $values) { $action = array_sum(array_keys(self::actionLinks())); diff --git a/CRM/Profile/Form.php b/CRM/Profile/Form.php index f8f7f01b9b48..39fae8b8f6ca 100644 --- a/CRM/Profile/Form.php +++ b/CRM/Profile/Form.php @@ -994,7 +994,7 @@ public static function formRule($fields, $files, $form) { if (!$register && empty($fields['_qf_Edit_upload_duplicate'])) { // fix for CRM-3240 if (!empty($fields['email-Primary'])) { - $fields['email'] = CRM_Utils_Array::value('email-Primary', $fields); + $fields['email'] = $fields['email-Primary'] ?? NULL; } // fix for CRM-6141 @@ -1187,7 +1187,7 @@ public function postProcess() { } } - $addToGroupId = CRM_Utils_Array::value('add_to_group_id', $this->_ufGroup); + $addToGroupId = $this->_ufGroup['add_to_group_id'] ?? NULL; if (!empty($addToGroupId)) { //run same check whether group is a mailing list $groupTypes = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', diff --git a/CRM/Profile/Form/Edit.php b/CRM/Profile/Form/Edit.php index 29c350841ada..57f51cc3c22b 100644 --- a/CRM/Profile/Form/Edit.php +++ b/CRM/Profile/Form/Edit.php @@ -188,7 +188,7 @@ public function buildQuickForm() { $this->_cancelURL = str_replace('&', '&', $this->_cancelURL); // also retain error URL if set - $this->_errorURL = CRM_Utils_Array::value('errorURL', $_POST); + $this->_errorURL = $_POST['errorURL'] ?? NULL; if ($this->_errorURL) { // we do this gross hack since qf also does entity replacement $this->_errorURL = str_replace('&', '&', $this->_errorURL); @@ -252,7 +252,7 @@ public function postProcess() { ]); foreach (explode(',', $this->returnExtra) as $field) { $field = trim($field); - $this->ajaxResponse['extra'][$field] = CRM_Utils_Array::value($field, $contact); + $this->ajaxResponse['extra'][$field] = $contact[$field] ?? NULL; } } diff --git a/CRM/Profile/Page/Listings.php b/CRM/Profile/Page/Listings.php index 0b84b8753e91..46807507ce54 100644 --- a/CRM/Profile/Page/Listings.php +++ b/CRM/Profile/Page/Listings.php @@ -205,7 +205,7 @@ public function preProcess() { } } - $customField = CRM_Utils_Array::value($name, $this->_customFields); + $customField = $this->_customFields[$name] ?? NULL; if (!empty($_POST) && empty($_POST[$name])) { if ($customField) { @@ -410,7 +410,7 @@ public static function getProfileContact($gid) { CRM_Core_Error::statusBounce(ts('This profile does not have the map feature turned on.')); } - $groupId = CRM_Utils_Array::value('limit_listings_group_id', $details); + $groupId = $details['limit_listings_group_id'] ?? NULL; // add group id to params if a uf group belong to a any group if ($groupId) { diff --git a/CRM/Profile/Page/MultipleRecordFieldsListing.php b/CRM/Profile/Page/MultipleRecordFieldsListing.php index 0593c82c3d04..8fecd4ae05aa 100644 --- a/CRM/Profile/Page/MultipleRecordFieldsListing.php +++ b/CRM/Profile/Page/MultipleRecordFieldsListing.php @@ -219,8 +219,8 @@ public function browse() { if ($returnValues['data_type'] == 'Date') { $dateFields[$fieldIDs[$key]] = 1; $actualPHPFormats = CRM_Utils_Date::datePluginToPHPFormats(); - $dateFormat = (array) CRM_Utils_Array::value($returnValues['date_format'], $actualPHPFormats); - $timeFormat = CRM_Utils_Array::value('time_format', $returnValues); + $dateFormat = (array) $actualPHPFormats[$returnValues['date_format']] ?? NULL; + $timeFormat = $returnValues['time_format'] ?? NULL; } $optionValuePairs = CRM_Core_BAO_CustomOption::getCustomOption($fieldIDs[$key]); @@ -233,12 +233,12 @@ public function browse() { $options[$fieldIDs[$key]]['attributes']['html_type'] = $returnValues['html_type']; $options[$fieldIDs[$key]]['attributes']['data_type'] = $returnValues['data_type']; $options[$fieldIDs[$key]]['attributes']['is_required'] = !empty($returnValues['is_required']); - $options[$fieldIDs[$key]]['attributes']['default_value'] = CRM_Utils_Array::value('default_value', $returnValues); - $options[$fieldIDs[$key]]['attributes']['is_view'] = CRM_Utils_Array::value('is_view', $returnValues); + $options[$fieldIDs[$key]]['attributes']['default_value'] = $returnValues['default_value'] ?? NULL; + $options[$fieldIDs[$key]]['attributes']['is_view'] = $returnValues['is_view'] ?? NULL; $options[$fieldIDs[$key]]['attributes']['format'] - = $options[$fieldIDs[$key]]['attributes']['date_format'] = CRM_Utils_Array::value('date_format', $returnValues); - $options[$fieldIDs[$key]]['attributes']['time_format'] = CRM_Utils_Array::value('time_format', $returnValues); + = $options[$fieldIDs[$key]]['attributes']['date_format'] = $returnValues['date_format'] ?? NULL; + $options[$fieldIDs[$key]]['attributes']['time_format'] = $returnValues['time_format'] ?? NULL; } $linkAction = array_sum(array_keys($this->links())); } diff --git a/CRM/Profile/Selector/Listings.php b/CRM/Profile/Selector/Listings.php index 09eb0a6e98e9..8c7cd1995991 100644 --- a/CRM/Profile/Selector/Listings.php +++ b/CRM/Profile/Selector/Listings.php @@ -307,9 +307,9 @@ public function &getColumnHeaders($action = NULL, $output = NULL) { if (strpos($name, '-') !== FALSE) { $value = explode('-', $name); - $fieldName = CRM_Utils_Array::value(0, $value); - $lType = CRM_Utils_Array::value(1, $value); - $type = CRM_Utils_Array::value(2, $value); + $fieldName = $value[0] ?? NULL; + $lType = $value[1] ?? NULL; + $type = $value[2] ?? NULL; if (!in_array($fieldName, $multipleFields)) { if ($lType == 'Primary') { @@ -380,7 +380,7 @@ public function getTotalCount($action) { if ($this->_multiRecordTableName && !array_key_exists($this->_multiRecordTableName, $this->_query->_whereTables) ) { - $additionalFromClause = CRM_Utils_Array::value($this->_multiRecordTableName, $this->_query->_tables); + $additionalFromClause = $this->_query->_tables[$this->_multiRecordTableName] ?? NULL; $returnQuery = TRUE; } @@ -436,7 +436,7 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL, $ex foreach ($vars as $key => $field) { $field = $vars[$key]; $fieldArray = explode('-', $field['name']); - $fieldType = CRM_Utils_Array::value('2', $fieldArray); + $fieldType = $fieldArray['2'] ?? NULL; if (is_numeric(CRM_Utils_Array::value('1', $fieldArray))) { if (!in_array($fieldType, $multipleFields)) { $locationType = new CRM_Core_DAO_LocationType(); @@ -513,14 +513,14 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL, $ex ) { if (strpos($key, '-') !== FALSE) { $value = explode('-', $key); - $fieldName = CRM_Utils_Array::value(0, $value); - $id = CRM_Utils_Array::value(1, $value); - $type = CRM_Utils_Array::value(2, $value); + $fieldName = $value[0] ?? NULL; + $id = $value[1] ?? NULL; + $type = $value[2] ?? NULL; if (!in_array($fieldName, $multipleFields)) { $locationTypeName = NULL; if (is_numeric($id)) { - $locationTypeName = CRM_Utils_Array::value($id, $locationTypes); + $locationTypeName = $locationTypes[$id] ?? NULL; } else { if ($id == 'Primary') { diff --git a/CRM/Queue/Runner.php b/CRM/Queue/Runner.php index d44a073b5232..36588d5aeb9a 100644 --- a/CRM/Queue/Runner.php +++ b/CRM/Queue/Runner.php @@ -97,8 +97,8 @@ public function __construct($runnerSpec) { $this->queue = $runnerSpec['queue']; $this->errorMode = CRM_Utils_Array::value('errorMode', $runnerSpec, self::ERROR_ABORT); $this->isMinimal = CRM_Utils_Array::value('isMinimal', $runnerSpec, FALSE); - $this->onEnd = CRM_Utils_Array::value('onEnd', $runnerSpec, NULL); - $this->onEndUrl = CRM_Utils_Array::value('onEndUrl', $runnerSpec, NULL); + $this->onEnd = $runnerSpec['onEnd'] ?? NULL; + $this->onEndUrl = $runnerSpec['onEndUrl'] ?? NULL; $this->pathPrefix = CRM_Utils_Array::value('pathPrefix', $runnerSpec, 'civicrm/queue'); $this->buttons = CRM_Utils_Array::value('buttons', $runnerSpec, ['retry' => TRUE, 'skip' => TRUE]); // perhaps this value should be randomized? diff --git a/CRM/Report/BAO/ReportInstance.php b/CRM/Report/BAO/ReportInstance.php index 2c7f1034288d..c396235d405f 100644 --- a/CRM/Report/BAO/ReportInstance.php +++ b/CRM/Report/BAO/ReportInstance.php @@ -114,10 +114,10 @@ public static function add(&$params) { */ public static function &create(&$params) { if (isset($params['report_header'])) { - $params['header'] = CRM_Utils_Array::value('report_header', $params); + $params['header'] = $params['report_header'] ?? NULL; } if (isset($params['report_footer'])) { - $params['footer'] = CRM_Utils_Array::value('report_footer', $params); + $params['footer'] = $params['report_footer'] ?? NULL; } // build navigation parameters @@ -131,8 +131,8 @@ public static function &create(&$params) { $navigationParams['label'] = $params['title']; $navigationParams['name'] = $params['title']; - $navigationParams['current_parent_id'] = CRM_Utils_Array::value('parent_id', $navigationParams); - $navigationParams['parent_id'] = CRM_Utils_Array::value('parent_id', $params); + $navigationParams['current_parent_id'] = $navigationParams['parent_id'] ?? NULL; + $navigationParams['parent_id'] = $params['parent_id'] ?? NULL; $navigationParams['is_active'] = 1; if ($permission = CRM_Utils_Array::value('permission', $params)) { diff --git a/CRM/Report/Form.php b/CRM/Report/Form.php index cf099a3debbe..8a20be0abd06 100644 --- a/CRM/Report/Form.php +++ b/CRM/Report/Form.php @@ -614,7 +614,7 @@ public function preProcessCommon() { CRM_Utils_System::civiExit(); } - $formValues = CRM_Utils_Array::value('form_values', $this->_instanceValues); + $formValues = $this->_instanceValues['form_values'] ?? NULL; if ($formValues) { $this->_formValues = CRM_Utils_String::unserialize($formValues); } @@ -947,8 +947,8 @@ public function setDefaultValues($freeze = TRUE) { if (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE ) { if (is_array($field['default'])) { - $this->_defaults["{$fieldName}_from"] = CRM_Utils_Array::value('from', $field['default']); - $this->_defaults["{$fieldName}_to"] = CRM_Utils_Array::value('to', $field['default']); + $this->_defaults["{$fieldName}_from"] = $field['default']['from'] ?? NULL; + $this->_defaults["{$fieldName}_to"] = $field['default']['to'] ?? NULL; $this->_defaults["{$fieldName}_relative"] = 0; } else { @@ -957,8 +957,8 @@ public function setDefaultValues($freeze = TRUE) { } else { if ((CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_INT) && is_array($field['default'])) { - $this->_defaults["{$fieldName}_min"] = CRM_Utils_Array::value('min', $field['default']); - $this->_defaults["{$fieldName}_max"] = CRM_Utils_Array::value('max', $field['default']); + $this->_defaults["{$fieldName}_min"] = $field['default']['min'] ?? NULL; + $this->_defaults["{$fieldName}_max"] = $field['default']['max'] ?? NULL; } $this->_defaults["{$fieldName}_value"] = $field['default']; } @@ -1216,11 +1216,11 @@ public function addColumns() { $colGroups[$tableName]['use_accordian_for_field_selection'] = TRUE; } - $colGroups[$tableName]['fields'][$fieldName] = CRM_Utils_Array::value('title', $field); + $colGroups[$tableName]['fields'][$fieldName] = $field['title'] ?? NULL; if ($groupTitle && empty($colGroups[$tableName]['group_title'])) { $colGroups[$tableName]['group_title'] = $groupTitle; } - $options[$fieldName] = CRM_Utils_Array::value('title', $field); + $options[$fieldName] = $field['title'] ?? NULL; } } } @@ -2741,9 +2741,9 @@ public function select() { public function selectClause(&$tableName, $tableKey, &$fieldName, &$field) { if (!empty($field['pseudofield'])) { $alias = "{$tableName}_{$fieldName}"; - $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array::value('title', $field); - $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field); - $this->_columnHeaders["{$tableName}_{$fieldName}"]['dbAlias'] = CRM_Utils_Array::value('dbAlias', $field); + $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = $field['title'] ?? NULL; + $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = $field['type'] ?? NULL; + $this->_columnHeaders["{$tableName}_{$fieldName}"]['dbAlias'] = $field['dbAlias'] ?? NULL; $this->_selectAliases[] = $alias; return ' 1 as ' . $alias; } @@ -3031,7 +3031,7 @@ public function storeOrderByArray() { // Record any section headers for assignment to the template if (!empty($orderBy['section'])) { - $orderByField['pageBreak'] = CRM_Utils_Array::value('pageBreak', $orderBy); + $orderByField['pageBreak'] = $orderBy['pageBreak'] ?? NULL; $this->_sections[$orderByField['tplField']] = $orderByField; } } @@ -3326,16 +3326,16 @@ public function filterStat(&$statistics) { } } else { - $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params); + $op = $this->_params["{$fieldName}_op"] ?? NULL; $value = NULL; if ($op) { $pair = $this->getOperationPair( CRM_Utils_Array::value('operatorType', $field), $fieldName ); - $min = CRM_Utils_Array::value("{$fieldName}_min", $this->_params); - $max = CRM_Utils_Array::value("{$fieldName}_max", $this->_params); - $val = CRM_Utils_Array::value("{$fieldName}_value", $this->_params); + $min = $this->_params["{$fieldName}_min"] ?? NULL; + $max = $this->_params["{$fieldName}_max"] ?? NULL; + $val = $this->_params["{$fieldName}_value"] ?? NULL; if (in_array($op, ['bw', 'nbw']) && ($min || $max)) { $value = "{$pair[$op]} $min " . ts('and') . " $max"; } @@ -3361,7 +3361,7 @@ public function filterStat(&$statistics) { } } $pair[$op] = (count($val) == 1) ? (($op == 'notin' || $op == - 'mnot') ? ts('Is Not') : ts('Is')) : CRM_Utils_Array::value($op, $pair); + 'mnot') ? ts('Is Not') : ts('Is')) : $pair[$op] ?? NULL; $val = implode(', ', $val); $value = "{$pair[$op]} " . $val; } @@ -3545,7 +3545,7 @@ public function compileContent() { $templateFile = $this->getHookedTemplateFileName(); return CRM_Utils_Array::value('report_header', $this->_formValues) . CRM_Core_Form::$_template->fetch($templateFile) . - CRM_Utils_Array::value('report_footer', $this->_formValues); + $this->_formValues['report_footer'] ?? NULL; } /** @@ -5317,8 +5317,8 @@ protected function addStatisticsToSelect($field, $tableName, $fieldName, $select protected function addBasicFieldToSelect($tableName, $fieldName, $field, $select) { $alias = "{$tableName}_{$fieldName}"; $select[] = "{$field['dbAlias']} as $alias"; - $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array::value('title', $field); - $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field); + $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = $field['title'] ?? NULL; + $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = $field['type'] ?? NULL; $this->_selectAliases[] = $alias; return $select; } @@ -5955,7 +5955,7 @@ protected function getDefaultsFromOptions($options) { protected function getSelectClauseWithGroupConcatIfNotGroupedBy($tableName, &$fieldName, &$field) { if ($this->groupConcatTested && (!empty($this->_groupByArray) || $this->isForceGroupBy)) { if ((empty($field['statistics']) || in_array('GROUP_CONCAT', $field['statistics']))) { - $label = CRM_Utils_Array::value('title', $field); + $label = $field['title'] ?? NULL; $alias = $field['tplField'] ?? "{$tableName}_{$fieldName}"; $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = $label; $this->_selectAliases[] = $alias; @@ -5983,24 +5983,24 @@ protected function generateFilterClause($field, $fieldName) { if (CRM_Utils_Array::value('operatorType', $field) == CRM_Report_Form::OP_MONTH ) { - $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params); - $value = CRM_Utils_Array::value("{$fieldName}_value", $this->_params); + $op = $this->_params["{$fieldName}_op"] ?? NULL; + $value = $this->_params["{$fieldName}_value"] ?? NULL; if (is_array($value) && !empty($value)) { return "(month({$field['dbAlias']}) $op (" . implode(', ', $value) . '))'; } } else { - $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params); - $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); - $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); - $fromTime = CRM_Utils_Array::value("{$fieldName}_from_time", $this->_params); - $toTime = CRM_Utils_Array::value("{$fieldName}_to_time", $this->_params); + $relative = $this->_params["{$fieldName}_relative"] ?? NULL; + $from = $this->_params["{$fieldName}_from"] ?? NULL; + $to = $this->_params["{$fieldName}_to"] ?? NULL; + $fromTime = $this->_params["{$fieldName}_from_time"] ?? NULL; + $toTime = $this->_params["{$fieldName}_to_time"] ?? NULL; return $this->dateClause($field['dbAlias'], $relative, $from, $to, $field['type'], $fromTime, $toTime); } } else { - $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params); + $op = $this->_params["{$fieldName}_op"] ?? NULL; if ($op) { return $this->whereClause($field, $op, diff --git a/CRM/Report/Form/Activity.php b/CRM/Report/Form/Activity.php index fa98ce2afda7..6bd904d4d73b 100644 --- a/CRM/Report/Form/Activity.php +++ b/CRM/Report/Form/Activity.php @@ -536,14 +536,14 @@ public function where($recordType = NULL) { continue; } if (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE) { - $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params); - $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); - $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); + $relative = $this->_params["{$fieldName}_relative"] ?? NULL; + $from = $this->_params["{$fieldName}_from"] ?? NULL; + $to = $this->_params["{$fieldName}_to"] ?? NULL; $clause = $this->dateClause($field['dbAlias'], $relative, $from, $to, $field['type']); } else { - $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params); + $op = $this->_params["{$fieldName}_op"] ?? NULL; if ($op && !($fieldName == "contact_{$recordType}" && ($op != 'nnll' || $op != 'nll'))) { $clause = $this->whereClause($field, $op, diff --git a/CRM/Report/Form/ActivitySummary.php b/CRM/Report/Form/ActivitySummary.php index e607a8b70fb7..0e7e780f9159 100644 --- a/CRM/Report/Form/ActivitySummary.php +++ b/CRM/Report/Form/ActivitySummary.php @@ -260,15 +260,15 @@ public function select() { else { $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}"; } - $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field); - $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array::value('title', $field); - $this->_columnHeaders["{$tableName}_{$fieldName}"]['no_display'] = CRM_Utils_Array::value('no_display', $field); + $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = $field['type'] ?? NULL; + $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = $field['title'] ?? NULL; + $this->_columnHeaders["{$tableName}_{$fieldName}"]['no_display'] = $field['no_display'] ?? NULL; } else { $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}"; - $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field); - $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array::value('title', $field); - $this->_columnHeaders["{$tableName}_{$fieldName}"]['no_display'] = CRM_Utils_Array::value('no_display', $field); + $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = $field['type'] ?? NULL; + $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = $field['title'] ?? NULL; + $this->_columnHeaders["{$tableName}_{$fieldName}"]['no_display'] = $field['no_display'] ?? NULL; } } } @@ -364,14 +364,14 @@ public function where($durationMode = FALSE) { foreach ($table['filters'] as $fieldName => $field) { $clause = NULL; if (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE) { - $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params); - $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); - $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); + $relative = $this->_params["{$fieldName}_relative"] ?? NULL; + $from = $this->_params["{$fieldName}_from"] ?? NULL; + $to = $this->_params["{$fieldName}_to"] ?? NULL; $clause = $this->dateClause($field['dbAlias'], $relative, $from, $to, $field['type']); } else { - $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params); + $op = $this->_params["{$fieldName}_op"] ?? NULL; if ($op) { $clause = $this->whereClause($field, $op, diff --git a/CRM/Report/Form/Campaign/SurveyDetails.php b/CRM/Report/Form/Campaign/SurveyDetails.php index 8b524e07b3a1..3ab6dd59964e 100644 --- a/CRM/Report/Form/Campaign/SurveyDetails.php +++ b/CRM/Report/Form/Campaign/SurveyDetails.php @@ -250,7 +250,7 @@ public function select() { $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}"; // Set default title - $title = CRM_Utils_Array::value('title', $field); + $title = $field['title'] ?? NULL; // Check for an override. if (!empty($this->_columnTitleOverrides["{$tableName}_{$fieldName}"])) { $title = $this->_columnTitleOverrides["{$tableName}_{$fieldName}"]; @@ -309,14 +309,14 @@ public function where() { $clause = NULL; if (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE) { - $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params); - $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); - $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); + $relative = $this->_params["{$fieldName}_relative"] ?? NULL; + $from = $this->_params["{$fieldName}_from"] ?? NULL; + $to = $this->_params["{$fieldName}_to"] ?? NULL; $clause = $this->dateClause($field['name'], $relative, $from, $to, $field['type']); } else { - $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params); + $op = $this->_params["{$fieldName}_op"] ?? NULL; if ($op) { $clause = $this->whereClause($field, $op, @@ -363,7 +363,7 @@ public function compileContent() { $templateFile = $this->getHookedTemplateFileName(); return $coverSheet . CRM_Core_Form::$_template->fetch($templateFile) . - CRM_Utils_Array::value('report_footer', $this->_formValues); + $this->_formValues['report_footer'] ?? NULL; } /** @@ -371,7 +371,7 @@ public function compileContent() { */ private function _surveyCoverSheet() { $coverSheet = NULL; - $surveyIds = CRM_Utils_Array::value('survey_id_value', $this->_params); + $surveyIds = $this->_params['survey_id_value'] ?? NULL; if (CRM_Utils_System::isNull($surveyIds)) { return $coverSheet; } @@ -498,7 +498,7 @@ public function alterDisplay(&$rows) { * @param $rows */ private function _formatSurveyResult(&$rows) { - $surveyIds = CRM_Utils_Array::value('survey_id_value', $this->_params); + $surveyIds = $this->_params['survey_id_value'] ?? NULL; if (CRM_Utils_System::isNull($surveyIds) || empty($this->_params['fields']['result']) || !in_array($this->_outputMode, array('print', 'pdf')) @@ -523,16 +523,16 @@ private function _formatSurveyResult(&$rows) { $resultSet[$result->id][$result->value] = $result->label; } - $statusId = CRM_Utils_Array::value('status_id_value', $this->_params); - $respondentStatus = CRM_Utils_Array::value($statusId, self::$_surveyRespondentStatus); + $statusId = $this->_params['status_id_value'] ?? NULL; + $respondentStatus = self::$_surveyRespondentStatus[$statusId] ?? NULL; - $surveyId = CRM_Utils_Array::value(0, $surveyIds); + $surveyId = $surveyIds[0] ?? NULL; foreach ($rows as & $row) { if (!empty($row['civicrm_activity_survey_id'])) { $surveyId = $row['civicrm_activity_survey_id']; } $result = CRM_Utils_Array::value($surveyId, $resultSet, array()); - $resultLabel = CRM_Utils_Array::value('civicrm_activity_result', $row); + $resultLabel = $row['civicrm_activity_result'] ?? NULL; if ($respondentStatus == 'Reserved') { $row['civicrm_activity_result'] = implode(' | ', array_keys($result)); } @@ -549,7 +549,7 @@ private function _formatSurveyResult(&$rows) { * @param $rows */ private function _formatSurveyResponseData(&$rows) { - $surveyIds = CRM_Utils_Array::value('survey_id_value', $this->_params); + $surveyIds = $this->_params['survey_id_value'] ?? NULL; if (CRM_Utils_System::isNull($surveyIds) || empty($this->_params['fields']['survey_response']) ) { @@ -586,8 +586,8 @@ private function _formatSurveyResponseData(&$rows) { } //do check respondent status. - $statusId = CRM_Utils_Array::value('status_id_value', $this->_params); - $respondentStatus = CRM_Utils_Array::value($statusId, self::$_surveyRespondentStatus); + $statusId = $this->_params['status_id_value'] ?? NULL; + $respondentStatus = self::$_surveyRespondentStatus[$statusId] ?? NULL; if (!$hasResponseData && ($respondentStatus != 'Reserved') @@ -655,7 +655,7 @@ private function _formatSurveyResponseData(&$rows) { if ($respondentStatus == 'Reserved' && in_array($this->_outputMode, array('print', 'pdf')) ) { - $optGrpId = CRM_Utils_Array::value('option_group_id', $responseFields[$name]); + $optGrpId = $responseFields[$name]['option_group_id'] ?? NULL; $options = CRM_Utils_Array::value($optGrpId, $fieldValueMap, array()); $value = implode(' | ', array_keys($options)); } @@ -671,7 +671,7 @@ private function _formatSurveyResponseData(&$rows) { } private function _addSurveyResponseColumns() { - $surveyIds = CRM_Utils_Array::value('survey_id_value', $this->_params); + $surveyIds = $this->_params['survey_id_value'] ?? NULL; if (CRM_Utils_System::isNull($surveyIds) || empty($this->_params['fields']['survey_response']) ) { diff --git a/CRM/Report/Form/Case/Demographics.php b/CRM/Report/Form/Case/Demographics.php index 8115604f0209..6c9f105f8596 100644 --- a/CRM/Report/Form/Case/Demographics.php +++ b/CRM/Report/Form/Case/Demographics.php @@ -250,7 +250,7 @@ public function select() { } $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}"; - $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field); + $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = $field['type'] ?? NULL; $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = $field['title']; } } @@ -308,18 +308,18 @@ public function where() { foreach ($table['filters'] as $fieldName => $field) { $clause = NULL; if ($field['operatorType'] & CRM_Report_Form::OP_DATE) { - $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params); - $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); - $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); + $relative = $this->_params["{$fieldName}_relative"] ?? NULL; + $from = $this->_params["{$fieldName}_from"] ?? NULL; + $to = $this->_params["{$fieldName}_to"] ?? NULL; $clause = $this->dateClause($field['dbAlias'], $relative, $from, $to, CRM_Utils_Type::T_DATE); } else { - $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params); + $op = $this->_params["{$fieldName}_op"] ?? NULL; if ($op) { // handle special case if ($fieldName == 'case_id_filter') { - $choice = CRM_Utils_Array::value("{$fieldName}_value", $this->_params); + $choice = $this->_params["{$fieldName}_value"] ?? NULL; if ($choice == 1) { $clause = "({$this->_aliases['civicrm_case']}.id Is Not Null)"; } diff --git a/CRM/Report/Form/Case/Detail.php b/CRM/Report/Form/Case/Detail.php index 64d8952e714a..95a91ff9b313 100644 --- a/CRM/Report/Form/Case/Detail.php +++ b/CRM/Report/Form/Case/Detail.php @@ -350,7 +350,7 @@ public function select() { $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}"; } - $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field); + $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = $field['type'] ?? NULL; $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = $field['title']; } } @@ -417,15 +417,15 @@ public function where() { $clause = NULL; if (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE) { - $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params); - $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); - $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); + $relative = $this->_params["{$fieldName}_relative"] ?? NULL; + $from = $this->_params["{$fieldName}_from"] ?? NULL; + $to = $this->_params["{$fieldName}_to"] ?? NULL; $clause = $this->dateClause($field['dbAlias'], $relative, $from, $to, $field['type']); } else { - $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params); + $op = $this->_params["{$fieldName}_op"] ?? NULL; if ($fieldName == 'case_type_id' && !empty($this->_params['case_type_id_value']) ) { diff --git a/CRM/Report/Form/Case/Summary.php b/CRM/Report/Form/Case/Summary.php index ab089194bb27..52fb291cc17d 100644 --- a/CRM/Report/Form/Case/Summary.php +++ b/CRM/Report/Form/Case/Summary.php @@ -209,7 +209,7 @@ public function select() { else { $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}"; } - $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field); + $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = $field['type'] ?? NULL; $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = $field['title']; } } diff --git a/CRM/Report/Form/Case/TimeSpent.php b/CRM/Report/Form/Case/TimeSpent.php index 5e3d04bca839..117b342aa458 100644 --- a/CRM/Report/Form/Case/TimeSpent.php +++ b/CRM/Report/Form/Case/TimeSpent.php @@ -183,9 +183,9 @@ public function select() { ) ) { - $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field); - $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array::value('title', $field); - $this->_columnHeaders["{$tableName}_{$fieldName}"]['no_display'] = CRM_Utils_Array::value('no_display', $field); + $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = $field['type'] ?? NULL; + $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = $field['title'] ?? NULL; + $this->_columnHeaders["{$tableName}_{$fieldName}"]['no_display'] = $field['no_display'] ?? NULL; if ($fieldName == 'activity_type_id') { $this->has_activity_type = TRUE; @@ -240,18 +240,18 @@ public function where() { foreach ($table['filters'] as $fieldName => $field) { $clause = NULL; if (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE) { - $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params); - $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); - $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); + $relative = $this->_params["{$fieldName}_relative"] ?? NULL; + $from = $this->_params["{$fieldName}_from"] ?? NULL; + $to = $this->_params["{$fieldName}_to"] ?? NULL; $clause = $this->dateClause($field['dbAlias'], $relative, $from, $to); } else { - $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params); + $op = $this->_params["{$fieldName}_op"] ?? NULL; if ($op) { // handle special case if ($fieldName == 'case_id_filter') { - $choice = CRM_Utils_Array::value("{$fieldName}_value", $this->_params); + $choice = $this->_params["{$fieldName}_value"] ?? NULL; if ($choice == 1) { $clause = "({$this->_aliases['civicrm_case_activity']}.id Is Not Null)"; } diff --git a/CRM/Report/Form/Contact/CurrentEmployer.php b/CRM/Report/Form/Contact/CurrentEmployer.php index 80e033a0704c..5a2479b14b64 100644 --- a/CRM/Report/Form/Contact/CurrentEmployer.php +++ b/CRM/Report/Form/Contact/CurrentEmployer.php @@ -196,8 +196,8 @@ public function select() { ) { $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}"; - $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field); - $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array::value('title', $field); + $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = $field['type'] ?? NULL; + $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = $field['title'] ?? NULL; } } } @@ -239,14 +239,14 @@ public function where() { $clause = NULL; if (CRM_Utils_Array::value('operatorType', $field) & CRM_Report_Form::OP_DATE ) { - $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params); - $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); - $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); + $relative = $this->_params["{$fieldName}_relative"] ?? NULL; + $from = $this->_params["{$fieldName}_from"] ?? NULL; + $to = $this->_params["{$fieldName}_to"] ?? NULL; $clause = $this->dateClause($field['dbAlias'], $relative, $from, $to, $field['type']); } else { - $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params); + $op = $this->_params["{$fieldName}_op"] ?? NULL; if ($op) { $clause = $this->whereClause($field, $op, diff --git a/CRM/Report/Form/Contact/Detail.php b/CRM/Report/Form/Contact/Detail.php index 56acf7e33478..c44891b94ca0 100644 --- a/CRM/Report/Form/Contact/Detail.php +++ b/CRM/Report/Form/Contact/Detail.php @@ -389,8 +389,8 @@ public function select() { //isolate the select clause compoenent wise if (in_array($table['alias'], $this->_component)) { $select[$table['alias']][] = "{$field['dbAlias']} as {$tableName}_{$fieldName}"; - $this->_columnHeadersComponent[$table['alias']]["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field); - $this->_columnHeadersComponent[$table['alias']]["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array::value('title', $field); + $this->_columnHeadersComponent[$table['alias']]["{$tableName}_{$fieldName}"]['type'] = $field['type'] ?? NULL; + $this->_columnHeadersComponent[$table['alias']]["{$tableName}_{$fieldName}"]['title'] = $field['title'] ?? NULL; } elseif ($table['alias'] == $this->_aliases['civicrm_activity_target'] || @@ -413,12 +413,12 @@ public function select() { $tableName = $table['alias']; $select['activity_civireport'][] = "$tableName.display_name as {$tableName}_{$fieldName}, $addContactId "; - $this->_columnHeadersComponent['activity_civireport']["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field); - $this->_columnHeadersComponent['activity_civireport']["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array::value('title', $field); + $this->_columnHeadersComponent['activity_civireport']["{$tableName}_{$fieldName}"]['type'] = $field['type'] ?? NULL; + $this->_columnHeadersComponent['activity_civireport']["{$tableName}_{$fieldName}"]['title'] = $field['title'] ?? NULL; } else { $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}"; - $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field); + $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = $field['type'] ?? NULL; $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = $field['title']; } } @@ -606,14 +606,14 @@ public function where() { $clause = NULL; if (CRM_Utils_Array::value('operatorType', $field) & CRM_Report_Form::OP_DATE ) { - $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params); - $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); - $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); + $relative = $this->_params["{$fieldName}_relative"] ?? NULL; + $from = $this->_params["{$fieldName}_from"] ?? NULL; + $to = $this->_params["{$fieldName}_to"] ?? NULL; $clause = $this->dateClause($field['dbAlias'], $relative, $from, $to); } else { - $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params); + $op = $this->_params["{$fieldName}_op"] ?? NULL; $clause = $this->whereClause($field, $op, CRM_Utils_Array::value("{$fieldName}_value", $this->_params), diff --git a/CRM/Report/Form/Contact/Log.php b/CRM/Report/Form/Contact/Log.php index e846ca577550..3fbec1121264 100644 --- a/CRM/Report/Form/Contact/Log.php +++ b/CRM/Report/Form/Contact/Log.php @@ -136,7 +136,7 @@ public function select() { ) { $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}"; - $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field); + $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = $field['type'] ?? NULL; $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = $field['title']; } } @@ -181,14 +181,14 @@ public function where() { $clause = NULL; if (CRM_Utils_Array::value('operatorType', $field) & CRM_Report_Form::OP_DATE ) { - $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params); - $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); - $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); + $relative = $this->_params["{$fieldName}_relative"] ?? NULL; + $from = $this->_params["{$fieldName}_from"] ?? NULL; + $to = $this->_params["{$fieldName}_to"] ?? NULL; $clause = $this->dateClause($field['dbAlias'], $relative, $from, $to); } else { - $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params); + $op = $this->_params["{$fieldName}_op"] ?? NULL; if ($op) { $clause = $this->whereClause($field, $op, diff --git a/CRM/Report/Form/Contact/LoggingSummary.php b/CRM/Report/Form/Contact/LoggingSummary.php index 751a00eb913a..c3ed3f542922 100644 --- a/CRM/Report/Form/Contact/LoggingSummary.php +++ b/CRM/Report/Form/Contact/LoggingSummary.php @@ -294,7 +294,7 @@ public function from() { $detail = $this->_logTables[$entity]; $tableName = CRM_Utils_Array::value('table_name', $detail, $entity); - $clause = CRM_Utils_Array::value('entity_table', $detail); + $clause = $detail['entity_table'] ?? NULL; $clause = $clause ? "AND entity_log_civireport.entity_table = 'civicrm_contact'" : NULL; $joinClause = " @@ -302,7 +302,7 @@ public function from() { ON (entity_log_civireport.{$detail['fk']} = modified_contact_civireport.id {$clause})"; if (!empty($detail['joins'])) { - $clause = CRM_Utils_Array::value('entity_table', $detail); + $clause = $detail['entity_table'] ?? NULL; $clause = $clause ? "AND fk_table.entity_table = 'civicrm_contact'" : NULL; $joinClause = " INNER JOIN `{$this->loggingDB}`.{$detail['joins']['table']} fk_table ON {$detail['joins']['join']} diff --git a/CRM/Report/Form/Contact/Relationship.php b/CRM/Report/Form/Contact/Relationship.php index 4807844732a6..1b122fe7e2e6 100644 --- a/CRM/Report/Form/Contact/Relationship.php +++ b/CRM/Report/Form/Contact/Relationship.php @@ -372,8 +372,8 @@ public function select() { $this->_phoneField_b = TRUE; } $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}"; - $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field); - $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array::value('title', $field); + $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = $field['type'] ?? NULL; + $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = $field['title'] ?? NULL; } } } @@ -454,9 +454,9 @@ public function where() { $clause = NULL; if (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE) { - $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params); - $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); - $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); + $relative = $this->_params["{$fieldName}_relative"] ?? NULL; + $from = $this->_params["{$fieldName}_from"] ?? NULL; + $to = $this->_params["{$fieldName}_to"] ?? NULL; if ($fieldName == 'active_period_date') { $clause = $this->activeClause($field['name'], $relative, $from, $to, $field['type']); @@ -466,14 +466,14 @@ public function where() { } } else { - $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params); + $op = $this->_params["{$fieldName}_op"] ?? NULL; if ($op) { if (($tableName == 'civicrm_contact' || $tableName == 'civicrm_contact_b') && ($fieldName == 'contact_type_a' || $fieldName == 'contact_type_b') ) { - $cTypes = CRM_Utils_Array::value("{$fieldName}_value", $this->_params); + $cTypes = $this->_params["{$fieldName}_value"] ?? NULL; $contactTypes = $contactSubTypes = []; if (!empty($cTypes)) { foreach ($cTypes as $ctype) { @@ -630,7 +630,7 @@ public function groupBy() { } public function beginPostProcessCommon() { - $originalRelationshipTypeIdValue = CRM_Utils_Array::value('relationship_type_id_value', $this->_params); + $originalRelationshipTypeIdValue = $this->_params['relationship_type_id_value'] ?? NULL; if ($originalRelationshipTypeIdValue) { $relationshipTypes = []; $direction = []; diff --git a/CRM/Report/Form/Contribute/Bookkeeping.php b/CRM/Report/Form/Contribute/Bookkeeping.php index 24dc5ba2b067..1da37dac5680 100644 --- a/CRM/Report/Form/Contribute/Bookkeeping.php +++ b/CRM/Report/Form/Contribute/Bookkeeping.php @@ -450,7 +450,7 @@ public function select() { break; } $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = $field['title']; - $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field); + $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = $field['type'] ?? NULL; } } } @@ -533,14 +533,14 @@ public function where() { END"; } if (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE) { - $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params); - $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); - $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); + $relative = $this->_params["{$fieldName}_relative"] ?? NULL; + $from = $this->_params["{$fieldName}_from"] ?? NULL; + $to = $this->_params["{$fieldName}_to"] ?? NULL; $clause = $this->dateClause($field['name'], $relative, $from, $to, $field['type']); } else { - $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params); + $op = $this->_params["{$fieldName}_op"] ?? NULL; if ($op) { $clause = $this->whereClause($field, $op, @@ -674,7 +674,7 @@ public function alterDisplay(&$rows) { } if (!empty($row['civicrm_financial_trxn_card_type_id'])) { - $rows[$rowNum]['civicrm_financial_trxn_card_type_id'] = CRM_Utils_Array::value($row['civicrm_financial_trxn_card_type_id'], $creditCardTypes); + $rows[$rowNum]['civicrm_financial_trxn_card_type_id'] = $creditCardTypes[$row['civicrm_financial_trxn_card_type_id']] ?? NULL; $entryFound = TRUE; } diff --git a/CRM/Report/Form/Contribute/Detail.php b/CRM/Report/Form/Contribute/Detail.php index 294c40ecdd50..2fb0325d9846 100644 --- a/CRM/Report/Form/Contribute/Detail.php +++ b/CRM/Report/Form/Contribute/Detail.php @@ -697,7 +697,7 @@ public function alterDisplay(&$rows) { $entryFound = TRUE; } if (!empty($row['civicrm_batch_batch_id'])) { - $rows[$rowNum]['civicrm_batch_batch_id'] = CRM_Utils_Array::value($row['civicrm_batch_batch_id'], $batches); + $rows[$rowNum]['civicrm_batch_batch_id'] = $batches[$row['civicrm_batch_batch_id']] ?? NULL; $entryFound = TRUE; } if (!empty($row['civicrm_financial_trxn_card_type_id'])) { diff --git a/CRM/Report/Form/Contribute/History.php b/CRM/Report/Form/Contribute/History.php index 99983fcf3f07..ecb52f68ece8 100644 --- a/CRM/Report/Form/Contribute/History.php +++ b/CRM/Report/Form/Contribute/History.php @@ -326,7 +326,7 @@ public function select() { ) { if ($tableName == 'civicrm_relationship') { $this->_relationshipColumns["{$tableName}_{$fieldName}"] = "{$field['dbAlias']} as {$tableName}_{$fieldName}"; - $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field); + $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = $field['type'] ?? NULL; $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = $field['title']; continue; } @@ -355,7 +355,7 @@ public function select() { } else { $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}"; - $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field); + $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = $field['type'] ?? NULL; $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = $field['title']; } if (!empty($field['no_display'])) { @@ -403,14 +403,14 @@ public function where() { } elseif (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE ) { - $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params); - $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); - $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); + $relative = $this->_params["{$fieldName}_relative"] ?? NULL; + $from = $this->_params["{$fieldName}_from"] ?? NULL; + $to = $this->_params["{$fieldName}_to"] ?? NULL; $clause = $this->dateClause($field['name'], $relative, $from, $to, $field['type']); } else { - $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params); + $op = $this->_params["{$fieldName}_op"] ?? NULL; if ($op) { $clause = $this->whereClause($field, $op, diff --git a/CRM/Report/Form/Contribute/HouseholdSummary.php b/CRM/Report/Form/Contribute/HouseholdSummary.php index 1789bcd33a12..8e0c9a242206 100644 --- a/CRM/Report/Form/Contribute/HouseholdSummary.php +++ b/CRM/Report/Form/Contribute/HouseholdSummary.php @@ -214,8 +214,8 @@ public function select() { else { $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}"; - $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array::value('title', $field); - $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field); + $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = $field['title'] ?? NULL; + $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = $field['type'] ?? NULL; } } } @@ -250,13 +250,13 @@ public function where() { foreach ($table['filters'] as $fieldName => $field) { $clause = NULL; if (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE) { - $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params); - $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); - $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); + $relative = $this->_params["{$fieldName}_relative"] ?? NULL; + $from = $this->_params["{$fieldName}_from"] ?? NULL; + $to = $this->_params["{$fieldName}_to"] ?? NULL; $clause = $this->dateClause($field['name'], $relative, $from, $to, $field['type']); } else { - $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params); + $op = $this->_params["{$fieldName}_op"] ?? NULL; if ($op) { if ($fieldName == 'relationship_type_id') { $clause = "{$this->_aliases['civicrm_relationship']}.relationship_type_id=" . $this->relationshipId; diff --git a/CRM/Report/Form/Contribute/OrganizationSummary.php b/CRM/Report/Form/Contribute/OrganizationSummary.php index 80880b15d710..78d7d6282327 100644 --- a/CRM/Report/Form/Contribute/OrganizationSummary.php +++ b/CRM/Report/Form/Contribute/OrganizationSummary.php @@ -219,8 +219,8 @@ public function select() { else { $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}"; - $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array::value('title', $field); - $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field); + $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = $field['title'] ?? NULL; + $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = $field['type'] ?? NULL; } } } @@ -257,14 +257,14 @@ public function where() { foreach ($table['filters'] as $fieldName => $field) { $clause = NULL; if (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE) { - $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params); - $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); - $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); + $relative = $this->_params["{$fieldName}_relative"] ?? NULL; + $from = $this->_params["{$fieldName}_from"] ?? NULL; + $to = $this->_params["{$fieldName}_to"] ?? NULL; $clause = $this->dateClause($field['name'], $relative, $from, $to, $field['type']); } else { - $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params); + $op = $this->_params["{$fieldName}_op"] ?? NULL; if ($op) { if ($fieldName == 'relationship_type_id') { $clause = "{$this->_aliases['civicrm_relationship']}.relationship_type_id=" . $this->relationshipId; diff --git a/CRM/Report/Form/Contribute/PCP.php b/CRM/Report/Form/Contribute/PCP.php index 8b0ec5f5e59a..3b640a8d6dc8 100644 --- a/CRM/Report/Form/Contribute/PCP.php +++ b/CRM/Report/Form/Contribute/PCP.php @@ -250,13 +250,13 @@ public function where() { $clause = NULL; if (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE) { - $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params); - $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); - $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); + $relative = $this->_params["{$fieldName}_relative"] ?? NULL; + $from = $this->_params["{$fieldName}_from"] ?? NULL; + $to = $this->_params["{$fieldName}_to"] ?? NULL; $clause = $this->dateClause($field['name'], $relative, $from, $to, $field['type']); } else { - $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params); + $op = $this->_params["{$fieldName}_op"] ?? NULL; if ($op) { $clause = $this->whereClause($field, diff --git a/CRM/Report/Form/Contribute/Recur.php b/CRM/Report/Form/Contribute/Recur.php index bf79da024452..4dac3ad8f942 100644 --- a/CRM/Report/Form/Contribute/Recur.php +++ b/CRM/Report/Form/Contribute/Recur.php @@ -293,9 +293,9 @@ public function where() { if (!empty($this->_params['calculated_end_date_' . $suffix])) { // The calculated date field is in use - spring into action // Gather values - $relative = CRM_Utils_Array::value("calculated_end_date_relative", $this->_params); - $from = CRM_Utils_Array::value("calculated_end_date_from", $this->_params); - $to = CRM_Utils_Array::value("calculated_end_date_to", $this->_params); + $relative = $this->_params["calculated_end_date_relative"] ?? NULL; + $from = $this->_params["calculated_end_date_from"] ?? NULL; + $to = $this->_params["calculated_end_date_to"] ?? NULL; $end_date_db_alias = $this->_columns['civicrm_contribution_recur']['filters']['end_date']['dbAlias']; $end_date_type = $this->_columns['civicrm_contribution_recur']['filters']['end_date']['type']; $start_date_type = $this->_columns['civicrm_contribution_recur']['filters']['start_date']['type']; diff --git a/CRM/Report/Form/Contribute/RecurSummary.php b/CRM/Report/Form/Contribute/RecurSummary.php index 677890e14439..9599ddb5d143 100644 --- a/CRM/Report/Form/Contribute/RecurSummary.php +++ b/CRM/Report/Form/Contribute/RecurSummary.php @@ -166,8 +166,8 @@ public function select() { } else { $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}"; - $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field); - $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array::value('title', $field); + $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = $field['type'] ?? NULL; + $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = $field['title'] ?? NULL; } } } @@ -222,9 +222,9 @@ public function alterDisplay(&$rows) { $entryFound = FALSE; - $startDateFrom = CRM_Utils_Array::value("start_date_to", $this->_params); - $startDateTo = CRM_Utils_Array::value("start_date_from", $this->_params); - $startDateRelative = CRM_Utils_Array::value("start_date_relative", $this->_params); + $startDateFrom = $this->_params["start_date_to"] ?? NULL; + $startDateTo = $this->_params["start_date_from"] ?? NULL; + $startDateRelative = $this->_params["start_date_relative"] ?? NULL; $startedDateSql = $this->dateClause('start_date', $startDateRelative, $startDateFrom, $startDateTo); $startedDateSql = $startedDateSql ? $startedDateSql : " ( 1 ) "; @@ -236,7 +236,7 @@ public function alterDisplay(&$rows) { foreach ($rows as $rowNum => $row) { - $paymentInstrumentId = CRM_Utils_Array::value('civicrm_contribution_recur_payment_instrument_id', $row); + $paymentInstrumentId = $row['civicrm_contribution_recur_payment_instrument_id'] ?? NULL; $rows[$rowNum]['civicrm_contribution_recur_start_date'] = 0; $rows[$rowNum]['civicrm_contribution_recur_cancel_date'] = 0; diff --git a/CRM/Report/Form/Contribute/Repeat.php b/CRM/Report/Form/Contribute/Repeat.php index 4062c0090e9c..7b66f28d6d32 100644 --- a/CRM/Report/Form/Contribute/Repeat.php +++ b/CRM/Report/Form/Contribute/Repeat.php @@ -263,17 +263,17 @@ public function select() { $select[] = $field['clause']; // FIXME: dirty hack for setting columnHeaders - $this->_columnHeaders["{$field['alias']}_{$field['name']}_sum"]['type'] = CRM_Utils_Array::value('type', $field); + $this->_columnHeaders["{$field['alias']}_{$field['name']}_sum"]['type'] = $field['type'] ?? NULL; $this->_columnHeaders["{$field['alias']}_{$field['name']}_sum"]['title'] = $field['title']; - $this->_columnHeaders["{$field['alias']}_{$field['name']}_count"]['type'] = CRM_Utils_Array::value('type', $field); + $this->_columnHeaders["{$field['alias']}_{$field['name']}_count"]['type'] = $field['type'] ?? NULL; $this->_columnHeaders["{$field['alias']}_{$field['name']}_count"]['title'] = $field['title']; continue; } // only include statistics columns if set $select[] = "{$field['dbAlias']} as {$field['alias']}_{$field['name']}"; - $this->_columnHeaders["{$field['alias']}_{$field['name']}"]['type'] = CRM_Utils_Array::value('type', $field); - $this->_columnHeaders["{$field['alias']}_{$field['name']}"]['title'] = CRM_Utils_Array::value('title', $field); + $this->_columnHeaders["{$field['alias']}_{$field['name']}"]['type'] = $field['type'] ?? NULL; + $this->_columnHeaders["{$field['alias']}_{$field['name']}"]['title'] = $field['title'] ?? NULL; if (!empty($field['no_display'])) { $this->_columnHeaders["{$field['alias']}_{$field['name']}"]['no_display'] = TRUE; } @@ -386,14 +386,14 @@ public function whereContribution($replaceAliasWith = 'contribution1') { foreach ($this->_columns['civicrm_contribution']['filters'] as $fieldName => $field) { $clause = NULL; if (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE) { - $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params); - $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); - $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); + $relative = $this->_params["{$fieldName}_relative"] ?? NULL; + $from = $this->_params["{$fieldName}_from"] ?? NULL; + $to = $this->_params["{$fieldName}_to"] ?? NULL; $clause = $this->dateClause($field['dbAlias'], $relative, $from, $to, $field['type']); } else { - $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params); + $op = $this->_params["{$fieldName}_op"] ?? NULL; if ($op) { $clause = $this->whereClause($field, $op, @@ -450,7 +450,7 @@ public function where() { ) { foreach ($table['filters'] as $fieldName => $field) { $clause = NULL; - $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params); + $op = $this->_params["{$fieldName}_op"] ?? NULL; if ($op) { $clause = $this->whereClause($field, $op, diff --git a/CRM/Report/Form/Contribute/SoftCredit.php b/CRM/Report/Form/Contribute/SoftCredit.php index b50437689089..c4c2d371486d 100644 --- a/CRM/Report/Form/Contribute/SoftCredit.php +++ b/CRM/Report/Form/Contribute/SoftCredit.php @@ -369,7 +369,7 @@ public function select() { } else { $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}"; - $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field); + $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = $field['type'] ?? NULL; $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = $field['title']; } } diff --git a/CRM/Report/Form/Contribute/Summary.php b/CRM/Report/Form/Contribute/Summary.php index 5a4de704343b..35df8417748e 100644 --- a/CRM/Report/Form/Contribute/Summary.php +++ b/CRM/Report/Form/Contribute/Summary.php @@ -423,8 +423,8 @@ public function select() { } else { $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}"; - $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field); - $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array::value('title', $field); + $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = $field['type'] ?? NULL; + $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = $field['title'] ?? NULL; } } } @@ -580,7 +580,7 @@ public function storeWhereHavingClauseArray() { public function statistics(&$rows) { $statistics = parent::statistics($rows); - $softCredit = CRM_Utils_Array::value('soft_amount', $this->_params['fields']); + $softCredit = $this->_params['fields']['soft_amount'] ?? NULL; $onlySoftCredit = $softCredit && !CRM_Utils_Array::value('total_amount', $this->_params['fields']); if (!isset($this->_groupByArray['civicrm_contribution_currency'])) { $this->_groupByArray['civicrm_contribution_currency'] = 'currency'; diff --git a/CRM/Report/Form/Contribute/Sybunt.php b/CRM/Report/Form/Contribute/Sybunt.php index 37c1385be4dd..83b6f673f822 100644 --- a/CRM/Report/Form/Contribute/Sybunt.php +++ b/CRM/Report/Form/Contribute/Sybunt.php @@ -294,7 +294,7 @@ public function select() { } else { $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}"; - $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field); + $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = $field['type'] ?? NULL; $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = $field['title']; } if (!empty($field['no_display'])) { @@ -341,16 +341,16 @@ public function where() { } elseif (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE ) { - $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params); - $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); - $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); + $relative = $this->_params["{$fieldName}_relative"] ?? NULL; + $from = $this->_params["{$fieldName}_from"] ?? NULL; + $to = $this->_params["{$fieldName}_to"] ?? NULL; if ($relative || $from || $to) { $clause = $this->dateClause($field['name'], $relative, $from, $to, $field['type']); } } else { - $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params); + $op = $this->_params["{$fieldName}_op"] ?? NULL; if ($op) { $clause = $this->whereClause($field, $op, @@ -510,13 +510,13 @@ public function buildChart(&$rows) { foreach ($rows as $key => $row) { $display["upto_{$upto}"] - = CRM_Utils_Array::value("upto_{$upto}", $display) + CRM_Utils_Array::value("civicrm_upto_{$upto}", $row); + = CRM_Utils_Array::value("upto_{$upto}", $display) + $row["civicrm_upto_{$upto}"] ?? NULL; $display[$previous_year] - = CRM_Utils_Array::value($previous_year, $display) + CRM_Utils_Array::value($previous_year, $row); + = CRM_Utils_Array::value($previous_year, $display) + $row[$previous_year] ?? NULL; $display[$previous_two_year] - = CRM_Utils_Array::value($previous_two_year, $display) + CRM_Utils_Array::value($previous_two_year, $row); + = CRM_Utils_Array::value($previous_two_year, $display) + $row[$previous_two_year] ?? NULL; $display[$previous_three_year] - = CRM_Utils_Array::value($previous_three_year, $display) + CRM_Utils_Array::value($previous_three_year, $row); + = CRM_Utils_Array::value($previous_three_year, $display) + $row[$previous_three_year] ?? NULL; } $graphRows['value'] = $display; diff --git a/CRM/Report/Form/Contribute/TopDonor.php b/CRM/Report/Form/Contribute/TopDonor.php index a73a3e42e88b..a3329a928f00 100644 --- a/CRM/Report/Form/Contribute/TopDonor.php +++ b/CRM/Report/Form/Contribute/TopDonor.php @@ -204,8 +204,8 @@ public function __construct() { public static function formRule($fields, $files, $self) { $errors = []; - $op = CRM_Utils_Array::value('total_range_op', $fields); - $val = CRM_Utils_Array::value('total_range_value', $fields); + $op = $fields['total_range_op'] ?? NULL; + $val = $fields['total_range_value'] ?? NULL; if (!in_array($op, [ 'eq', @@ -244,16 +244,16 @@ public function where() { foreach ($table['filters'] as $fieldName => $field) { $clause = NULL; if (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE) { - $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params); - $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); - $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); + $relative = $this->_params["{$fieldName}_relative"] ?? NULL; + $from = $this->_params["{$fieldName}_from"] ?? NULL; + $to = $this->_params["{$fieldName}_to"] ?? NULL; if ($relative || $from || $to) { $clause = $this->dateClause($field['name'], $relative, $from, $to, $field['type']); } } else { - $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params); + $op = $this->_params["{$fieldName}_op"] ?? NULL; if ($op) { $clause = $this->whereClause($field, $op, @@ -266,7 +266,7 @@ public function where() { if (!empty($clause)) { if ($fieldName == 'total_range') { - $value = CRM_Utils_Array::value("total_range_value", $this->_params); + $value = $this->_params["total_range_value"] ?? NULL; $this->_outerCluase = " WHERE (( @rows := @rows + 1) <= {$value}) "; $this->_groupLimit = " LIMIT {$value}"; } diff --git a/CRM/Report/Form/Event/IncomeCountSummary.php b/CRM/Report/Form/Event/IncomeCountSummary.php index a6b154d5cbb8..fea8a0de4b16 100644 --- a/CRM/Report/Form/Event/IncomeCountSummary.php +++ b/CRM/Report/Form/Event/IncomeCountSummary.php @@ -179,7 +179,7 @@ public function select() { } else { $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}"; - $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field); + $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = $field['type'] ?? NULL; $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = $field['title']; } } @@ -210,16 +210,16 @@ public function where() { foreach ($table['filters'] as $fieldName => $field) { $clause = NULL; if (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE) { - $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params); - $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); - $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); + $relative = $this->_params["{$fieldName}_relative"] ?? NULL; + $from = $this->_params["{$fieldName}_from"] ?? NULL; + $to = $this->_params["{$fieldName}_to"] ?? NULL; if ($relative || $from || $to) { $clause = $this->dateClause($field['name'], $relative, $from, $to, $field['type']); } } else { - $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params); + $op = $this->_params["{$fieldName}_op"] ?? NULL; if ($op) { $clause = $this->whereClause($field, $op, diff --git a/CRM/Report/Form/Event/ParticipantListCount.php b/CRM/Report/Form/Event/ParticipantListCount.php index f1ea17adec16..31a0f70ab16e 100644 --- a/CRM/Report/Form/Event/ParticipantListCount.php +++ b/CRM/Report/Form/Event/ParticipantListCount.php @@ -406,7 +406,7 @@ public function select() { } else { $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}"; - $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field); + $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = $field['type'] ?? NULL; $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = $field['title']; } } diff --git a/CRM/Report/Form/Event/ParticipantListing.php b/CRM/Report/Form/Event/ParticipantListing.php index 9b4c6f719dab..50175c9aaf5b 100644 --- a/CRM/Report/Form/Event/ParticipantListing.php +++ b/CRM/Report/Form/Event/ParticipantListing.php @@ -446,16 +446,16 @@ public function select() { } $alias = "{$tableName}_{$fieldName}"; $select[] = "{$field['dbAlias']} as $alias"; - $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field); - $this->_columnHeaders["{$tableName}_{$fieldName}"]['no_display'] = CRM_Utils_Array::value('no_display', $field); - $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array::value('title', $field); + $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = $field['type'] ?? NULL; + $this->_columnHeaders["{$tableName}_{$fieldName}"]['no_display'] = $field['no_display'] ?? NULL; + $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = $field['title'] ?? NULL; $this->_selectAliases[] = $alias; } } } } //add blank column at the end - $blankcols = CRM_Utils_Array::value('blank_column_end', $this->_params); + $blankcols = $this->_params['blank_column_end'] ?? NULL; if ($blankcols) { for ($i = 1; $i <= $blankcols; $i++) { $select[] = " '' as blankColumnEnd_{$i}"; @@ -537,19 +537,19 @@ public function where() { $clause = NULL; if (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE) { - $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params); - $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); - $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); + $relative = $this->_params["{$fieldName}_relative"] ?? NULL; + $from = $this->_params["{$fieldName}_from"] ?? NULL; + $to = $this->_params["{$fieldName}_to"] ?? NULL; if ($relative || $from || $to) { $clause = $this->dateClause($field['name'], $relative, $from, $to, $field['type']); } } else { - $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params); + $op = $this->_params["{$fieldName}_op"] ?? NULL; if ($fieldName == 'rid') { - $value = CRM_Utils_Array::value("{$fieldName}_value", $this->_params); + $value = $this->_params["{$fieldName}_value"] ?? NULL; if (!empty($value)) { $operator = ''; if ($op == 'notin') { @@ -704,9 +704,9 @@ public function alterDisplay(&$rows) { } // Convert display name to link - $displayName = CRM_Utils_Array::value('civicrm_contact_sort_name_linked', $row); - $cid = CRM_Utils_Array::value('civicrm_contact_id', $row); - $id = CRM_Utils_Array::value('civicrm_participant_participant_record', $row); + $displayName = $row['civicrm_contact_sort_name_linked'] ?? NULL; + $cid = $row['civicrm_contact_id'] ?? NULL; + $id = $row['civicrm_participant_participant_record'] ?? NULL; if ($displayName && $cid && $id) { $url = CRM_Report_Utils_Report::getNextUrl('contact/detail', diff --git a/CRM/Report/Form/Event/Summary.php b/CRM/Report/Form/Event/Summary.php index f2dd872e5180..11af2ed73a54 100644 --- a/CRM/Report/Form/Event/Summary.php +++ b/CRM/Report/Form/Event/Summary.php @@ -125,16 +125,16 @@ public function where() { foreach ($table['filters'] as $fieldName => $field) { $clause = NULL; if (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE) { - $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params); - $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); - $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); + $relative = $this->_params["{$fieldName}_relative"] ?? NULL; + $from = $this->_params["{$fieldName}_from"] ?? NULL; + $to = $this->_params["{$fieldName}_to"] ?? NULL; if ($relative || $from || $to) { $clause = $this->dateClause($field['name'], $relative, $from, $to, $field['type']); } } else { - $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params); + $op = $this->_params["{$fieldName}_op"] ?? NULL; if ($op) { $clause = $this->whereClause($field, $op, @@ -239,8 +239,8 @@ public function buildColumnHeaders() { !empty($this->_params['fields'][$fieldName]) ) { - $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field); - $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array::value('title', $field); + $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = $field['type'] ?? NULL; + $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = $field['title'] ?? NULL; } } } @@ -328,7 +328,7 @@ public function buildChart(&$rows) { $countEvent = NULL; if (!empty($this->_params['charts'])) { foreach ($rows as $key => $value) { - $graphRows['totalAmount'][] = $graphRows['value'][] = CRM_Utils_Array::value('totalAmount', $rows[$key]); + $graphRows['totalAmount'][] = $graphRows['value'][] = $rows[$key]['totalAmount'] ?? NULL; $graphRows[$this->_interval][] = substr($rows[$key]['civicrm_event_title'], 0, 12) . "..(" . $rows[$key]['civicrm_event_id'] . ") "; } diff --git a/CRM/Report/Form/Grant/Statistics.php b/CRM/Report/Form/Grant/Statistics.php index da70f8df1f15..c78048f9f60b 100644 --- a/CRM/Report/Form/Grant/Statistics.php +++ b/CRM/Report/Form/Grant/Statistics.php @@ -200,8 +200,8 @@ public function select() { $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}"; - $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array::value('title', $field); - $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field); + $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = $field['title'] ?? NULL; + $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = $field['type'] ?? NULL; } } } @@ -239,16 +239,16 @@ public function where() { $clause = NULL; if (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE) { - $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params); - $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); - $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); + $relative = $this->_params["{$fieldName}_relative"] ?? NULL; + $from = $this->_params["{$fieldName}_from"] ?? NULL; + $to = $this->_params["{$fieldName}_to"] ?? NULL; if ($relative || $from || $to) { $clause = $this->dateClause($field['name'], $relative, $from, $to, $field['type']); } } else { - $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params); + $op = $this->_params["{$fieldName}_op"] ?? NULL; if (($fieldName == 'grant_report_received') && (CRM_Utils_Array::value("{$fieldName}_value", $this->_params) === 0) @@ -380,7 +380,7 @@ public function alterDisplay(&$rows) { } if (!empty($values['civicrm_grant_grant_type_id'])) { - $grantType = CRM_Utils_Array::value($values['civicrm_grant_grant_type_id'], $grantTypes); + $grantType = $grantTypes[$values['civicrm_grant_grant_type_id']] ?? NULL; $grantStatistics['civicrm_grant_grant_type_id']['title'] = ts('By Grant Type'); self::getStatistics($grantStatistics['civicrm_grant_grant_type_id'], $grantType, $values, $awardedGrants, $awardedGrantsAmount @@ -388,7 +388,7 @@ public function alterDisplay(&$rows) { } if (array_key_exists('civicrm_worldregion_name', $values)) { - $region = CRM_Utils_Array::value('civicrm_worldregion_name', $values); + $region = $values['civicrm_worldregion_name'] ?? NULL; $region = ($region) ? $region : 'Unassigned'; $grantStatistics['civicrm_worldregion_name']['title'] = ts('By Region'); self::getStatistics($grantStatistics['civicrm_worldregion_name'], $region, $values, @@ -397,7 +397,7 @@ public function alterDisplay(&$rows) { } if (array_key_exists('civicrm_address_country_id', $values)) { - $country = CRM_Utils_Array::value($values['civicrm_address_country_id'], $countries); + $country = $countries[$values['civicrm_address_country_id']] ?? NULL; $country = ($country) ? $country : 'Unassigned'; $grantStatistics['civicrm_address_country_id']['title'] = ts('By Country'); self::getStatistics($grantStatistics['civicrm_address_country_id'], $country, $values, @@ -414,7 +414,7 @@ public function alterDisplay(&$rows) { } if (array_key_exists('civicrm_contact_gender_id', $values)) { - $genderLabel = CRM_Utils_Array::value($values['civicrm_contact_gender_id'], $gender); + $genderLabel = $gender[$values['civicrm_contact_gender_id']] ?? NULL; $genderLabel = ($genderLabel) ? $genderLabel : 'Unassigned'; $grantStatistics['civicrm_contact_gender_id']['title'] = ts('By Gender'); self::getStatistics($grantStatistics['civicrm_contact_gender_id'], $genderLabel, $values, @@ -424,7 +424,7 @@ public function alterDisplay(&$rows) { foreach ($values as $customField => $customValue) { if (strstr($customField, 'civicrm_value_')) { - $customFieldTitle = CRM_Utils_Array::value('title', $this->_columnHeaders[$customField]); + $customFieldTitle = $this->_columnHeaders[$customField]['title'] ?? NULL; $customGroupTitle = explode('_custom', strstr($customField, 'civicrm_value_')); $customGroupTitle = $this->_columns[$customGroupTitle[0]]['group_title']; $grantStatistics[$customGroupTitle]['title'] = ts('By %1', [1 => $customGroupTitle]); diff --git a/CRM/Report/Form/Instance.php b/CRM/Report/Form/Instance.php index 4ca1b81ad2e1..8aa9d4674ca3 100644 --- a/CRM/Report/Form/Instance.php +++ b/CRM/Report/Form/Instance.php @@ -239,7 +239,7 @@ public static function setDefaultValues(&$form, &$defaults) { if ($instanceID) { // this is already retrieved via Form.php - $defaults['description'] = CRM_Utils_Array::value('description', $defaults); + $defaults['description'] = $defaults['description'] ?? NULL; if (!empty($defaults['header'])) { $defaults['report_header'] = $defaults['header']; } @@ -258,7 +258,7 @@ public static function setDefaultValues(&$form, &$defaults) { $params = ['id' => $defaults['navigation_id']]; CRM_Core_BAO_Navigation::retrieve($params, $navigationDefaults); $defaults['is_navigation'] = 1; - $defaults['parent_id'] = CRM_Utils_Array::value('parent_id', $navigationDefaults); + $defaults['parent_id'] = $navigationDefaults['parent_id'] ?? NULL; if (!empty($navigationDefaults['is_active'])) { $form->assign('is_navigation', TRUE); } diff --git a/CRM/Report/Form/Mailing/Bounce.php b/CRM/Report/Form/Mailing/Bounce.php index 5a16a9d90f16..cfb798c179f9 100644 --- a/CRM/Report/Form/Mailing/Bounce.php +++ b/CRM/Report/Form/Mailing/Bounce.php @@ -271,9 +271,9 @@ public function select() { } $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}"; - $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field); - $this->_columnHeaders["{$tableName}_{$fieldName}"]['no_display'] = CRM_Utils_Array::value('no_display', $field); - $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array::value('title', $field); + $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = $field['type'] ?? NULL; + $this->_columnHeaders["{$tableName}_{$fieldName}"]['no_display'] = $field['no_display'] ?? NULL; + $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = $field['title'] ?? NULL; } } } @@ -337,14 +337,14 @@ public function where() { foreach ($table['filters'] as $fieldName => $field) { $clause = NULL; if (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE) { - $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params); - $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); - $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); + $relative = $this->_params["{$fieldName}_relative"] ?? NULL; + $from = $this->_params["{$fieldName}_from"] ?? NULL; + $to = $this->_params["{$fieldName}_to"] ?? NULL; $clause = $this->dateClause($this->_aliases[$tableName] . '.' . $field['name'], $relative, $from, $to, $field['type']); } else { - $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params); + $op = $this->_params["{$fieldName}_op"] ?? NULL; if ($op) { $clause = $this->whereClause($field, diff --git a/CRM/Report/Form/Mailing/Clicks.php b/CRM/Report/Form/Mailing/Clicks.php index e8cf3258f583..bc96f7f9e35a 100644 --- a/CRM/Report/Form/Mailing/Clicks.php +++ b/CRM/Report/Form/Mailing/Clicks.php @@ -229,9 +229,9 @@ public function select() { } $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}"; - $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field); - $this->_columnHeaders["{$tableName}_{$fieldName}"]['no_display'] = CRM_Utils_Array::value('no_display', $field); - $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array::value('title', $field); + $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = $field['type'] ?? NULL; + $this->_columnHeaders["{$tableName}_{$fieldName}"]['no_display'] = $field['no_display'] ?? NULL; + $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = $field['title'] ?? NULL; } } } diff --git a/CRM/Report/Form/Mailing/Detail.php b/CRM/Report/Form/Mailing/Detail.php index 55b97ffef4d8..5eab237061e2 100644 --- a/CRM/Report/Form/Mailing/Detail.php +++ b/CRM/Report/Form/Mailing/Detail.php @@ -279,17 +279,17 @@ public function select() { 'reply_id', ])) { $select[] = "IF({$field['dbAlias']} IS NULL, 'No', 'Yes') as {$tableName}_{$fieldName}"; - $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field); - $this->_columnHeaders["{$tableName}_{$fieldName}"]['no_display'] = CRM_Utils_Array::value('no_display', $field); - $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array::value('title', $field); + $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = $field['type'] ?? NULL; + $this->_columnHeaders["{$tableName}_{$fieldName}"]['no_display'] = $field['no_display'] ?? NULL; + $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = $field['title'] ?? NULL; unset($this->_columns[$tableName]['fields'][$fieldName]); $columns[$tableName][$fieldName] = $field; } elseif ($fieldName == 'delivery_id') { $select[] = "IF(mailing_event_bounce_civireport.id IS NOT NULL, 'Bounced', IF(mailing_event_delivered_civireport.id IS NOT NULL, 'Successful', 'Unknown')) as {$tableName}_{$fieldName}"; - $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field); - $this->_columnHeaders["{$tableName}_{$fieldName}"]['no_display'] = CRM_Utils_Array::value('no_display', $field); - $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array::value('title', $field); + $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = $field['type'] ?? NULL; + $this->_columnHeaders["{$tableName}_{$fieldName}"]['no_display'] = $field['no_display'] ?? NULL; + $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = $field['title'] ?? NULL; unset($this->_columns[$tableName]['fields'][$fieldName]); $columns[$tableName][$fieldName] = $field; } diff --git a/CRM/Report/Form/Mailing/Opened.php b/CRM/Report/Form/Mailing/Opened.php index 3bbba7bcd846..5db163b7eb4c 100644 --- a/CRM/Report/Form/Mailing/Opened.php +++ b/CRM/Report/Form/Mailing/Opened.php @@ -218,9 +218,9 @@ public function select() { } $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}"; - $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field); - $this->_columnHeaders["{$tableName}_{$fieldName}"]['no_display'] = CRM_Utils_Array::value('no_display', $field); - $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array::value('title', $field); + $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = $field['type'] ?? NULL; + $this->_columnHeaders["{$tableName}_{$fieldName}"]['no_display'] = $field['no_display'] ?? NULL; + $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = $field['title'] ?? NULL; } } } diff --git a/CRM/Report/Form/Mailing/Summary.php b/CRM/Report/Form/Mailing/Summary.php index 7d9fdc621511..4289f9020bea 100644 --- a/CRM/Report/Form/Mailing/Summary.php +++ b/CRM/Report/Form/Mailing/Summary.php @@ -356,7 +356,7 @@ public function select() { $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}"; } } - $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field); + $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = $field['type'] ?? NULL; $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = $field['title']; } } @@ -410,14 +410,14 @@ public function where() { foreach ($table['filters'] as $fieldName => $field) { $clause = NULL; if (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE) { - $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params); - $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); - $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); + $relative = $this->_params["{$fieldName}_relative"] ?? NULL; + $from = $this->_params["{$fieldName}_from"] ?? NULL; + $to = $this->_params["{$fieldName}_to"] ?? NULL; $clause = $this->dateClause($this->_aliases[$tableName] . '.' . $field['name'], $relative, $from, $to, $field['type']); } else { - $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params); + $op = $this->_params["{$fieldName}_op"] ?? NULL; if ($op) { if ($fieldName == 'relationship_type_id') { diff --git a/CRM/Report/Form/Member/ContributionDetail.php b/CRM/Report/Form/Member/ContributionDetail.php index 6b4ae72b4f0b..ff38b8cdf61f 100644 --- a/CRM/Report/Form/Member/ContributionDetail.php +++ b/CRM/Report/Form/Member/ContributionDetail.php @@ -406,15 +406,15 @@ public function select() { elseif ($fieldName == 'first_donation_date' || $fieldName == 'first_donation_amount' ) { - $baseField = CRM_Utils_Array::value('base_field', $field); + $baseField = $field['base_field'] ?? NULL; $select[] = "{$this->_aliases['civicrm_contribution']}.{$baseField} as {$tableName}_{$fieldName}"; - $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array::value('title', $field); - $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field); + $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = $field['title'] ?? NULL; + $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = $field['type'] ?? NULL; } else { $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}"; - $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array::value('title', $field); - $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field); + $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = $field['title'] ?? NULL; + $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = $field['type'] ?? NULL; } } } @@ -640,8 +640,8 @@ public function alterDisplay(&$rows) { if (array_key_exists('fields', $table)) { foreach ($table['fields'] as $fieldName => $field) { if (!empty($field['csv_display']) && !empty($field['no_display'])) { - $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array::value('title', $field); - $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field); + $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = $field['title'] ?? NULL; + $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = $field['type'] ?? NULL; } } } @@ -716,7 +716,7 @@ public function alterDisplay(&$rows) { } if (!empty($row['civicrm_batch_batch_id'])) { - $rows[$rowNum]['civicrm_batch_batch_id'] = CRM_Utils_Array::value($row['civicrm_batch_batch_id'], $batches); + $rows[$rowNum]['civicrm_batch_batch_id'] = $batches[$row['civicrm_batch_batch_id']] ?? NULL; $entryFound = TRUE; } diff --git a/CRM/Report/Form/Member/Lapse.php b/CRM/Report/Form/Member/Lapse.php index 5f1c54e5c6ef..acdb9a16b0a9 100644 --- a/CRM/Report/Form/Member/Lapse.php +++ b/CRM/Report/Form/Member/Lapse.php @@ -173,7 +173,7 @@ public function select() { !empty($this->_params['fields'][$fieldName]) ) { $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}"; - $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field); + $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = $field['type'] ?? NULL; $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = $field['title']; } } @@ -223,16 +223,16 @@ public function where() { $clause = NULL; if ($field['operatorType'] & CRM_Utils_Type::T_DATE) { - $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params); - $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); - $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); + $relative = $this->_params["{$fieldName}_relative"] ?? NULL; + $from = $this->_params["{$fieldName}_from"] ?? NULL; + $to = $this->_params["{$fieldName}_to"] ?? NULL; if ($relative || $from || $to) { $clause = $this->dateClause($field['name'], $relative, $from, $to, $field['type']); } } else { - $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params); + $op = $this->_params["{$fieldName}_op"] ?? NULL; if ($op) { $clause = $this->whereClause($field, $op, diff --git a/CRM/Report/Form/Member/Summary.php b/CRM/Report/Form/Member/Summary.php index 936b68493c70..1bd21077b7ca 100644 --- a/CRM/Report/Form/Member/Summary.php +++ b/CRM/Report/Form/Member/Summary.php @@ -272,12 +272,12 @@ public function select() { $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}"; } $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = $field['title']; - $this->_columnHeaders["{$tableName}_{$fieldName}"]['operatorType'] = CRM_Utils_Array::value('operatorType', $field); + $this->_columnHeaders["{$tableName}_{$fieldName}"]['operatorType'] = $field['operatorType'] ?? NULL; } else { $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}"; $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = $field['title']; - $this->_columnHeaders["{$tableName}_{$fieldName}"]['operatorType'] = CRM_Utils_Array::value('operatorType', $field); + $this->_columnHeaders["{$tableName}_{$fieldName}"]['operatorType'] = $field['operatorType'] ?? NULL; } } } @@ -446,8 +446,8 @@ public function buildChart(&$rows) { $graphRows = []; $count = 0; $membershipTypeValues = CRM_Member_PseudoConstant::membershipType(); - $isMembershipType = CRM_Utils_Array::value('membership_type_id', $this->_params['group_bys']); - $isJoiningDate = CRM_Utils_Array::value('join_date', $this->_params['group_bys']); + $isMembershipType = $this->_params['group_bys']['membership_type_id'] ?? NULL; + $isJoiningDate = $this->_params['group_bys']['join_date'] ?? NULL; if (!empty($this->_params['charts'])) { foreach ($rows as $key => $row) { if (!($row['civicrm_membership_join_date_subtotal'] && @@ -457,8 +457,8 @@ public function buildChart(&$rows) { continue; } if ($isMembershipType) { - $join_date = CRM_Utils_Array::value('civicrm_membership_join_date_start', $row); - $displayInterval = CRM_Utils_Array::value('civicrm_membership_join_date_interval', $row); + $join_date = $row['civicrm_membership_join_date_start'] ?? NULL; + $displayInterval = $row['civicrm_membership_join_date_interval'] ?? NULL; if ($join_date) { list($year, $month) = explode('-', $join_date); } @@ -493,8 +493,8 @@ public function buildChart(&$rows) { $display[$membershipType] = $row['civicrm_contribution_total_amount_sum']; } else { - $graphRows['receive_date'][] = CRM_Utils_Array::value('civicrm_membership_join_date_start', $row); - $graphRows[$this->_interval][] = CRM_Utils_Array::value('civicrm_membership_join_date_interval', $row); + $graphRows['receive_date'][] = $row['civicrm_membership_join_date_start'] ?? NULL; + $graphRows[$this->_interval][] = $row['civicrm_membership_join_date_interval'] ?? NULL; $graphRows['value'][] = $row['civicrm_contribution_total_amount_sum']; $count++; } diff --git a/CRM/Report/Form/Membership/Summary.php b/CRM/Report/Form/Membership/Summary.php index 25a5417448af..ddceca33870d 100644 --- a/CRM/Report/Form/Membership/Summary.php +++ b/CRM/Report/Form/Membership/Summary.php @@ -182,16 +182,16 @@ public function where() { foreach ($table['filters'] as $fieldName => $field) { $clause = NULL; if ($field['type'] & CRM_Utils_Type::T_DATE) { - $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params); - $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); - $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); + $relative = $this->_params["{$fieldName}_relative"] ?? NULL; + $from = $this->_params["{$fieldName}_from"] ?? NULL; + $to = $this->_params["{$fieldName}_to"] ?? NULL; if ($relative || $from || $to) { $clause = $this->dateClause($field['name'], $relative, $from, $to); } } else { - $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params); + $op = $this->_params["{$fieldName}_op"] ?? NULL; if ($op) { $clause = $this->whereClause($field, $op, diff --git a/CRM/Report/Form/Pledge/Detail.php b/CRM/Report/Form/Pledge/Detail.php index cb015c8123fc..d8e66c78e5ea 100644 --- a/CRM/Report/Form/Pledge/Detail.php +++ b/CRM/Report/Form/Pledge/Detail.php @@ -331,16 +331,16 @@ public function where() { foreach ($table['filters'] as $fieldName => $field) { $clause = NULL; if (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE) { - $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params); - $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); - $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); + $relative = $this->_params["{$fieldName}_relative"] ?? NULL; + $from = $this->_params["{$fieldName}_from"] ?? NULL; + $to = $this->_params["{$fieldName}_to"] ?? NULL; if ($relative || $from || $to) { $clause = $this->dateClause($field['name'], $relative, $from, $to, $field['type']); } } else { - $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params); + $op = $this->_params["{$fieldName}_op"] ?? NULL; if ($op) { $clause = $this->whereClause($field, $op, diff --git a/CRM/Report/Form/Pledge/Pbnp.php b/CRM/Report/Form/Pledge/Pbnp.php index 66eb610655a5..e9b97fbf07be 100644 --- a/CRM/Report/Form/Pledge/Pbnp.php +++ b/CRM/Report/Form/Pledge/Pbnp.php @@ -181,8 +181,8 @@ public function select() { !empty($this->_params['fields'][$fieldName]) ) { $select[] = "{$field['dbAlias']} as {$tableName}_{$fieldName}"; - $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = CRM_Utils_Array::value('type', $field); - $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = CRM_Utils_Array::value('title', $field); + $this->_columnHeaders["{$tableName}_{$fieldName}"]['type'] = $field['type'] ?? NULL; + $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = $field['title'] ?? NULL; } } } diff --git a/CRM/Report/Form/Pledge/Summary.php b/CRM/Report/Form/Pledge/Summary.php index 10ae20e55011..0adf1b860cd3 100644 --- a/CRM/Report/Form/Pledge/Summary.php +++ b/CRM/Report/Form/Pledge/Summary.php @@ -309,16 +309,16 @@ public function where() { foreach ($table['filters'] as $fieldName => $field) { $clause = NULL; if (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE) { - $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params); - $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); - $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); + $relative = $this->_params["{$fieldName}_relative"] ?? NULL; + $from = $this->_params["{$fieldName}_from"] ?? NULL; + $to = $this->_params["{$fieldName}_to"] ?? NULL; if ($relative || $from || $to) { $clause = $this->dateClause($field['name'], $relative, $from, $to, $field['type']); } } else { - $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params); + $op = $this->_params["{$fieldName}_op"] ?? NULL; if ($op) { $clause = $this->whereClause($field, $op, diff --git a/CRM/Report/Form/Walklist/Walklist.php b/CRM/Report/Form/Walklist/Walklist.php index 152799859e6a..14b40773b37a 100644 --- a/CRM/Report/Form/Walklist/Walklist.php +++ b/CRM/Report/Form/Walklist/Walklist.php @@ -119,14 +119,14 @@ public function where() { $clause = NULL; if ($field['type'] & CRM_Utils_Type::T_DATE) { - $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params); - $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params); - $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params); + $relative = $this->_params["{$fieldName}_relative"] ?? NULL; + $from = $this->_params["{$fieldName}_from"] ?? NULL; + $to = $this->_params["{$fieldName}_to"] ?? NULL; $clause = $this->dateClause($field['name'], $relative, $from, $to, $field['type']); } else { - $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params); + $op = $this->_params["{$fieldName}_op"] ?? NULL; if ($op) { $clause = $this->whereClause($field, $op, diff --git a/CRM/Report/Utils/Get.php b/CRM/Report/Utils/Get.php index e0498dbab766..59cfbf7c4e95 100644 --- a/CRM/Report/Utils/Get.php +++ b/CRM/Report/Utils/Get.php @@ -25,7 +25,7 @@ class CRM_Report_Utils_Get { * @return mixed|null */ public static function getTypedValue($name, $type) { - $value = CRM_Utils_Array::value($name, $_GET); + $value = $_GET[$name] ?? NULL; if ($value === NULL) { return NULL; } @@ -188,7 +188,7 @@ public static function intParam($fieldName, &$field, &$defaults) { * @param $defaults */ public static function processChart(&$defaults) { - $chartType = CRM_Utils_Array::value("charts", $_GET); + $chartType = $_GET["charts"] ?? NULL; if (in_array($chartType, [ 'barChart', 'pieChart', diff --git a/CRM/Report/Utils/Report.php b/CRM/Report/Utils/Report.php index 329bf0f83575..1cc6cc7d1879 100644 --- a/CRM/Report/Utils/Report.php +++ b/CRM/Report/Utils/Report.php @@ -188,9 +188,9 @@ public static function mailReport($fileContent, $instanceID = NULL, $outputMode $params['from'] = '"' . $domainEmailName . '" <' . $domainEmailAddress . '>'; //$domainEmailName; $params['toName'] = ""; - $params['toEmail'] = CRM_Utils_Array::value('email_to', $instanceInfo); - $params['cc'] = CRM_Utils_Array::value('email_cc', $instanceInfo); - $params['subject'] = CRM_Utils_Array::value('email_subject', $instanceInfo); + $params['toEmail'] = $instanceInfo['email_to'] ?? NULL; + $params['cc'] = $instanceInfo['email_cc'] ?? NULL; + $params['subject'] = $instanceInfo['email_subject'] ?? NULL; if (empty($instanceInfo['attachments'])) { $instanceInfo['attachments'] = []; } @@ -251,7 +251,7 @@ public static function makeCsv(&$form, &$rows) { $value = NULL; foreach ($rows as $row) { foreach ($columnHeaders as $k => $v) { - $value = CRM_Utils_Array::value($v, $row); + $value = $row[$v] ?? NULL; if (isset($value)) { // Remove HTML, unencode entities, and escape quotation marks. $value = str_replace('"', '""', html_entity_decode(strip_tags($value))); @@ -395,7 +395,7 @@ public static function isInstanceGroupRoleAllowed($instanceId) { * @return array */ public static function processReport($params) { - $instanceId = CRM_Utils_Array::value('instanceId', $params); + $instanceId = $params['instanceId'] ?? NULL; // hack for now, CRM-8358 $_REQUEST['instanceId'] = $instanceId; @@ -502,7 +502,7 @@ public static function getPreviewCriteriaQueryParams($defaults = [], $params = [ // (e.g., values for 'nll' and 'nnll' ops are blank), // so store them temporarily and examine below. $string_values[$basename] = $field_value; - $op_values[$basename] = CRM_Utils_Array::value("{$basename}_op", $params); + $op_values[$basename] = $params["{$basename}_op"] ?? NULL; } elseif ($suffix == '_op') { // These filters can have an effect even without a value diff --git a/CRM/SMS/BAO/Provider.php b/CRM/SMS/BAO/Provider.php index 4e046f743390..b2c2e45e2267 100644 --- a/CRM/SMS/BAO/Provider.php +++ b/CRM/SMS/BAO/Provider.php @@ -78,7 +78,7 @@ public static function getProviders($selectArr = NULL, $filter = NULL, $getActiv * @return array saved values */ public static function create(&$params) { - $id = CRM_Utils_Array::value('id', $params); + $id = $params['id'] ?? NULL; if ($id) { CRM_Utils_Hook::pre('edit', 'SmsProvider', $id, $params); diff --git a/CRM/SMS/Form/Group.php b/CRM/SMS/Form/Group.php index 7aae52fb1b97..4a53b78852a8 100644 --- a/CRM/SMS/Form/Group.php +++ b/CRM/SMS/Form/Group.php @@ -71,7 +71,7 @@ public function setDefaultValues() { } $defaults['includeGroups'] = $mailingGroups['civicrm_group']['Include']; - $defaults['excludeGroups'] = CRM_Utils_Array::value('Exclude', $mailingGroups['civicrm_group']); + $defaults['excludeGroups'] = $mailingGroups['civicrm_group']['Exclude'] ?? NULL; $defaults['includeMailings'] = CRM_Utils_Array::value('Include', CRM_Utils_Array::value('civicrm_mailing', $mailingGroups)); $defaults['excludeMailings'] = CRM_Utils_Array::value('Exclude', CRM_Utils_Array::value('civicrm_mailing', $mailingGroups)); diff --git a/CRM/SMS/Form/Upload.php b/CRM/SMS/Form/Upload.php index 922b2812257e..e9d2efb31143 100644 --- a/CRM/SMS/Form/Upload.php +++ b/CRM/SMS/Form/Upload.php @@ -227,7 +227,7 @@ public function postProcess() { $params['msg_template_id'] = $msgTemplate->id; } else { - $params['msg_template_id'] = CRM_Utils_Array::value('SMStemplate', $formValues); + $params['msg_template_id'] = $formValues['SMStemplate'] ?? NULL; } $this->set('template', $params['msg_template_id']); } @@ -299,7 +299,7 @@ public static function formRule($params, $files, $self) { } else { if (!empty($params['text_message'])) { - $messageCheck = CRM_Utils_Array::value('text_message', $params); + $messageCheck = $params['text_message'] ?? NULL; if ($messageCheck && (strlen($messageCheck) > CRM_SMS_Provider::MAX_SMS_CHAR)) { $errors['text_message'] = ts("You can configure the SMS message body up to %1 characters", [1 => CRM_SMS_Provider::MAX_SMS_CHAR]); } diff --git a/CRM/SMS/Provider.php b/CRM/SMS/Provider.php index 18976e184865..387092876d51 100644 --- a/CRM/SMS/Provider.php +++ b/CRM/SMS/Provider.php @@ -35,9 +35,9 @@ abstract class CRM_SMS_Provider { * @throws CRM_Core_Exception */ public static function &singleton($providerParams = array(), $force = FALSE) { - $mailingID = CRM_Utils_Array::value('mailing_id', $providerParams); - $providerID = CRM_Utils_Array::value('provider_id', $providerParams); - $providerName = CRM_Utils_Array::value('provider', $providerParams); + $mailingID = $providerParams['mailing_id'] ?? NULL; + $providerID = $providerParams['provider_id'] ?? NULL; + $providerName = $providerParams['provider'] ?? NULL; if (!$providerID && $mailingID) { $providerID = CRM_Core_DAO::getFieldValue('CRM_Mailing_DAO_Mailing', $mailingID, 'sms_provider_id', 'id'); @@ -141,7 +141,7 @@ public function createActivity($apiMsgID, $message, $headers = array(), $jobID = } if (!$sourceContactID) { - $sourceContactID = CRM_Utils_Array::value('Contact', $headers); + $sourceContactID = $headers['Contact'] ?? NULL; } if (!$sourceContactID) { return FALSE; diff --git a/CRM/UF/Form/Field.php b/CRM/UF/Form/Field.php index 5e7247049cb1..4476ef73038f 100644 --- a/CRM/UF/Form/Field.php +++ b/CRM/UF/Form/Field.php @@ -140,7 +140,7 @@ public function preProcess() { continue; } $this->_selectFields[$name] = $field['title']; - $this->_hasLocationTypes[$name] = CRM_Utils_Array::value('hasLocationType', $field); + $this->_hasLocationTypes[$name] = $field['hasLocationType'] ?? NULL; } // lets add group, tag and current_employer to this list @@ -187,7 +187,7 @@ public function buildQuickForm() { CRM_Core_BAO_UFField::retrieve($params, $defaults); // set it to null if so (avoids crappy E_NOTICE errors below - $defaults['location_type_id'] = CRM_Utils_Array::value('location_type_id', $defaults); + $defaults['location_type_id'] = $defaults['location_type_id'] ?? NULL; //CRM-20861 - Include custom fields defined for address to set its default location type to 0. $specialFields = array_merge(CRM_Core_BAO_UFGroup::getLocationFields(), $addressCustomFields); @@ -245,8 +245,8 @@ public function buildQuickForm() { else { $this->_mapperFields[$key][$key1] = $value1['title']; } - $hasLocationTypes[$key][$key1] = CRM_Utils_Array::value('hasLocationType', $value1); - $hasWebsiteTypes[$key][$key1] = CRM_Utils_Array::value('hasWebsiteType', $value1); + $hasLocationTypes[$key][$key1] = $value1['hasLocationType'] ?? NULL; + $hasWebsiteTypes[$key][$key1] = $value1['hasWebsiteType'] ?? NULL; // hide the 'is searchable' field for 'File' custom data if (isset($value1['data_type']) && isset($value1['html_type']) && @@ -700,7 +700,7 @@ public static function formRulePrimaryCheck($fields, $profileFieldName, $groupFi if (array_key_exists($profileFieldName, $checkPrimary)) { $whereCheck = $checkPrimary[$profileFieldName]; } - $potentialLocationType = CRM_Utils_Array::value(2, $fields['field_name']); + $potentialLocationType = $fields['field_name'][2] ?? NULL; if ($whereCheck && $potentialLocationType == 0) { $primaryOfSameTypeFound = ''; @@ -761,7 +761,7 @@ public static function formRule($fields, $files, $self) { } $isCustomField = FALSE; - $profileFieldName = CRM_Utils_Array::value(1, $fields['field_name']); + $profileFieldName = $fields['field_name'][1] ?? NULL; if ($profileFieldName) { //get custom field id $customFieldId = explode('_', $profileFieldName); diff --git a/CRM/UF/Form/Group.php b/CRM/UF/Form/Group.php index 90f7528c4973..4aba5aea9745 100644 --- a/CRM/UF/Form/Group.php +++ b/CRM/UF/Form/Group.php @@ -264,8 +264,8 @@ public function setDefaultValues() { $params = ['id' => $this->_id]; CRM_Core_BAO_UFGroup::retrieve($params, $defaults); - $defaults['group'] = CRM_Utils_Array::value('limit_listings_group_id', $defaults); - $defaults['add_contact_to_group'] = CRM_Utils_Array::value('add_to_group_id', $defaults); + $defaults['group'] = $defaults['limit_listings_group_id'] ?? NULL; + $defaults['add_contact_to_group'] = $defaults['add_to_group_id'] ?? NULL; //get the uf join records for current uf group $ufJoinRecords = CRM_Core_BAO_UFGroup::getUFJoinRecord($this->_id); foreach ($ufJoinRecords as $key => $value) { diff --git a/CRM/UF/Page/Group.php b/CRM/UF/Page/Group.php index 6e74e8d79b65..764e5355e832 100644 --- a/CRM/UF/Page/Group.php +++ b/CRM/UF/Page/Group.php @@ -464,7 +464,7 @@ public static function extractGroupTypes($groupType) { foreach ($valueParts as $val) { if (CRM_Utils_Rule::integer($val)) { - $groupTypeValues[$val] = CRM_Utils_Array::value($val, $valueLabels); + $groupTypeValues[$val] = $valueLabels[$val] ?? NULL; } } diff --git a/CRM/Upgrade/Incremental/php/FourFive.php b/CRM/Upgrade/Incremental/php/FourFive.php index 4925552c20ea..d905ea536b06 100644 --- a/CRM/Upgrade/Incremental/php/FourFive.php +++ b/CRM/Upgrade/Incremental/php/FourFive.php @@ -331,7 +331,7 @@ public static function updateSavedSearch(CRM_Queue_TaskContext $ctx) { if (count($data_value) == 0 && $op == 'or') { $customOption = CRM_Core_BAO_CustomOption::getCustomOption($fieldID); foreach ($customOption as $option) { - $data_value[] = CRM_Utils_Array::value('value', $option); + $data_value[] = $option['value'] ?? NULL; } } diff --git a/CRM/Utils/Address.php b/CRM/Utils/Address.php index 6e1eb1c61bde..90163f011747 100644 --- a/CRM/Utils/Address.php +++ b/CRM/Utils/Address.php @@ -59,7 +59,7 @@ public static function format( $formatted = $format; - $fullPostalCode = CRM_Utils_Array::value('postal_code', $fields); + $fullPostalCode = $fields['postal_code'] ?? NULL; if (!empty($fields['postal_code_suffix'])) { $fullPostalCode .= "-$fields[postal_code_suffix]"; } @@ -194,7 +194,7 @@ public static function format( // also sub all token fields if ($tokenFields) { foreach ($tokenFields as $token) { - $replacements["{$token}"] = CRM_Utils_Array::value("{$token}", $fields); + $replacements["{$token}"] = $fields["{$token}"] ?? NULL; } } @@ -320,7 +320,7 @@ public static function getFormattedBillingAddressFieldsFromParameters($params, $ $addressFields = []; foreach ($addressParts as $name => $field) { - $value = CRM_Utils_Array::value($field, $params); + $value = $params[$field] ?? NULL; $alternateName = 'billing_' . $name . '_id-' . $billingLocationTypeID; $alternate2 = 'billing_' . $name . '-' . $billingLocationTypeID; if (isset($params[$alternate2]) && !isset($params[$alternateName])) { diff --git a/CRM/Utils/Array.php b/CRM/Utils/Array.php index 1a3d8a002072..a35d321a31eb 100644 --- a/CRM/Utils/Array.php +++ b/CRM/Utils/Array.php @@ -915,7 +915,7 @@ public static function filterColumns($matrix, $columns) { foreach ($matrix as $pos => $oldRow) { $newRow = []; foreach ($columns as $column) { - $newRow[$column] = CRM_Utils_Array::value($column, $oldRow); + $newRow[$column] = $oldRow[$column] ?? NULL; } $newRows[$pos] = $newRow; } diff --git a/CRM/Utils/Chart.php b/CRM/Utils/Chart.php index c8745fa0a5f0..fa20158b9605 100644 --- a/CRM/Utils/Chart.php +++ b/CRM/Utils/Chart.php @@ -211,8 +211,8 @@ public static function chart($rows, $chart, $interval) { } // legend - $chartData['xname'] = CRM_Utils_Array::value('xname', $rows); - $chartData['yname'] = CRM_Utils_Array::value('yname', $rows); + $chartData['xname'] = $rows['xname'] ?? NULL; + $chartData['yname'] = $rows['yname'] ?? NULL; // carry some chart params if pass. foreach ([ diff --git a/CRM/Utils/Date.php b/CRM/Utils/Date.php index df20858d5b7e..6f597a4401c4 100644 --- a/CRM/Utils/Date.php +++ b/CRM/Utils/Date.php @@ -950,12 +950,12 @@ public static function calculateAge($birthDate) { */ public static function intervalAdd($unit, $interval, $date, $dontCareTime = FALSE) { if (is_array($date)) { - $hour = CRM_Utils_Array::value('H', $date); - $minute = CRM_Utils_Array::value('i', $date); - $second = CRM_Utils_Array::value('s', $date); - $month = CRM_Utils_Array::value('M', $date); - $day = CRM_Utils_Array::value('d', $date); - $year = CRM_Utils_Array::value('Y', $date); + $hour = $date['H'] ?? NULL; + $minute = $date['i'] ?? NULL; + $second = $date['s'] ?? NULL; + $month = $date['M'] ?? NULL; + $day = $date['d'] ?? NULL; + $year = $date['Y'] ?? NULL; } else { extract(date_parse($date)); diff --git a/CRM/Utils/DeprecatedUtils.php b/CRM/Utils/DeprecatedUtils.php index 8e62e1e17b21..b6da19bb686f 100644 --- a/CRM/Utils/DeprecatedUtils.php +++ b/CRM/Utils/DeprecatedUtils.php @@ -157,8 +157,8 @@ function _civicrm_api3_deprecated_activity_formatted_param(&$params, &$values, $ elseif ($type == 'Select' || $type == 'Radio') { $customOption = CRM_Core_BAO_CustomOption::getCustomOption($customFieldID, TRUE); foreach ($customOption as $customFldID => $customValue) { - $val = CRM_Utils_Array::value('value', $customValue); - $label = CRM_Utils_Array::value('label', $customValue); + $val = $customValue['value'] ?? NULL; + $label = $customValue['label'] ?? NULL; $label = strtolower($label); $value = strtolower(trim($value)); if (($value == $label) || ($value == strtolower($val))) { @@ -434,7 +434,7 @@ function _civicrm_api3_deprecated_add_formatted_param(&$values, &$params) { // mark an entry in fields array since we want the value of custom field to be copied $fields['Address'][$key] = NULL; - $htmlType = CRM_Utils_Array::value('html_type', $customFields[$customFieldID]); + $htmlType = $customFields[$customFieldID]['html_type'] ?? NULL; switch ($htmlType) { case 'CheckBox': case 'Multi-Select': @@ -548,8 +548,8 @@ function _civicrm_api3_deprecated_add_formatted_param(&$values, &$params) { * */ function _civicrm_api3_deprecated_duplicate_formatted_contact($params) { - $id = CRM_Utils_Array::value('id', $params); - $externalId = CRM_Utils_Array::value('external_identifier', $params); + $id = $params['id'] ?? NULL; + $externalId = $params['external_identifier'] ?? NULL; if ($id || $externalId) { $contact = new CRM_Contact_DAO_Contact(); @@ -755,7 +755,7 @@ function _civicrm_api3_deprecated_contact_check_params( if (empty($params['contact_type'])) { return civicrm_api3_create_error("No Contact Type"); } - $fields = CRM_Utils_Array::value($params['contact_type'], $required); + $fields = $required[$params['contact_type']] ?? NULL; if ($fields == NULL) { return civicrm_api3_create_error("Invalid Contact Type: {$params['contact_type']}"); } diff --git a/CRM/Utils/File.php b/CRM/Utils/File.php index 98eb7f274a47..2835b1658cfb 100644 --- a/CRM/Utils/File.php +++ b/CRM/Utils/File.php @@ -455,7 +455,7 @@ public static function makeFileName($name) { return CRM_Utils_String::munge("{$basename}_" . CRM_Utils_Array::value('extension', $info) . "_{$uniqID}", '_', 240) . ".unknown"; } else { - return CRM_Utils_String::munge("{$basename}_{$uniqID}", '_', 240) . "." . CRM_Utils_Array::value('extension', $info); + return CRM_Utils_String::munge("{$basename}_{$uniqID}", '_', 240) . "." . $info['extension'] ?? NULL; } } diff --git a/CRM/Utils/Geocode/Google.php b/CRM/Utils/Geocode/Google.php index f8db5f4e6b0e..1cb0c847ca56 100644 --- a/CRM/Utils/Geocode/Google.php +++ b/CRM/Utils/Geocode/Google.php @@ -60,7 +60,7 @@ public static function format(&$values, $stateName = FALSE) { $add .= ',+'; } - $city = CRM_Utils_Array::value('city', $values); + $city = $values['city'] ?? NULL; if ($city) { $add .= '+' . urlencode(str_replace('', '+', $city)); $add .= ',+'; diff --git a/CRM/Utils/GlobalStack.php b/CRM/Utils/GlobalStack.php index 44fc1c6bdc5e..047de04c3c7d 100644 --- a/CRM/Utils/GlobalStack.php +++ b/CRM/Utils/GlobalStack.php @@ -76,11 +76,11 @@ public function createBackup($new) { foreach ($new as $globalKey => $values) { if (is_array($values)) { foreach ($values as $key => $value) { - $frame[$globalKey][$key] = CRM_Utils_Array::value($key, $GLOBALS[$globalKey]); + $frame[$globalKey][$key] = $GLOBALS[$globalKey][$key] ?? NULL; } } else { - $frame[$globalKey] = CRM_Utils_Array::value($globalKey, $GLOBALS); + $frame[$globalKey] = $GLOBALS[$globalKey] ?? NULL; } } return $frame; diff --git a/CRM/Utils/Mail.php b/CRM/Utils/Mail.php index 696ed860d272..2b6e5120a74a 100644 --- a/CRM/Utils/Mail.php +++ b/CRM/Utils/Mail.php @@ -167,7 +167,7 @@ public static function send(&$params) { $defaultReturnPath = CRM_Core_BAO_MailSettings::defaultReturnPath(); $includeMessageId = CRM_Core_BAO_MailSettings::includeMessageId(); $emailDomain = CRM_Core_BAO_MailSettings::defaultDomain(); - $from = CRM_Utils_Array::value('from', $params); + $from = $params['from'] ?? NULL; if (!$defaultReturnPath) { $defaultReturnPath = self::pluckEmailFromHeader($from); } @@ -180,9 +180,9 @@ public static function send(&$params) { return FALSE; } - $textMessage = CRM_Utils_Array::value('text', $params); - $htmlMessage = CRM_Utils_Array::value('html', $params); - $attachments = CRM_Utils_Array::value('attachments', $params); + $textMessage = $params['text'] ?? NULL; + $htmlMessage = $params['html'] ?? NULL; + $attachments = $params['attachments'] ?? NULL; // CRM-6224 if (trim(CRM_Utils_String::htmlToText($htmlMessage)) == '') { @@ -203,13 +203,13 @@ public static function send(&$params) { // On some servers mail() fails when 'Cc' or 'Bcc' headers are defined but empty. foreach (['Cc', 'Bcc'] as $optionalHeader) { - $headers[$optionalHeader] = CRM_Utils_Array::value(strtolower($optionalHeader), $params); + $headers[$optionalHeader] = $params[strtolower($optionalHeader)] ?? NULL; if (empty($headers[$optionalHeader])) { unset($headers[$optionalHeader]); } } - $headers['Subject'] = CRM_Utils_Array::value('subject', $params); + $headers['Subject'] = $params['subject'] ?? NULL; $headers['Content-Type'] = $htmlMessage ? 'multipart/mixed; charset=utf-8' : 'text/plain; charset=utf-8'; $headers['Content-Disposition'] = 'inline'; $headers['Content-Transfer-Encoding'] = '8bit'; @@ -286,10 +286,10 @@ public static function send(&$params) { // get emails from headers, since these are // combination of name and email addresses. if (!empty($headers['Cc'])) { - $to[] = CRM_Utils_Array::value('Cc', $headers); + $to[] = $headers['Cc'] ?? NULL; } if (!empty($headers['Bcc'])) { - $to[] = CRM_Utils_Array::value('Bcc', $headers); + $to[] = $headers['Bcc'] ?? NULL; unset($headers['Bcc']); } } diff --git a/CRM/Utils/PDF/Label.php b/CRM/Utils/PDF/Label.php index 3094335223f4..c0b5d02b97ee 100644 --- a/CRM/Utils/PDF/Label.php +++ b/CRM/Utils/PDF/Label.php @@ -190,7 +190,7 @@ public function getFormatValue($name, $convert = FALSE) { $metric = $this->format['metric']; } else { - $value = CRM_Utils_Array::value($name, $this->defaults); + $value = $this->defaults[$name] ?? NULL; $metric = $this->defaults['metric']; } if ($convert) { diff --git a/CRM/Utils/Pager.php b/CRM/Utils/Pager.php index e2c4c26e7a81..a5bc97b85044 100644 --- a/CRM/Utils/Pager.php +++ b/CRM/Utils/Pager.php @@ -240,7 +240,7 @@ public function getOffsetAndRowCount() { */ public function getCurrentLocation() { $config = CRM_Core_Config::singleton(); - $path = CRM_Utils_Array::value($config->userFrameworkURLVar, $_GET); + $path = $_GET[$config->userFrameworkURLVar] ?? NULL; return CRM_Utils_System::url($path, CRM_Utils_System::getLinksUrl(self::PAGE_ID, FALSE, TRUE), FALSE, NULL, FALSE) . $this->getCurrentPageID(); } diff --git a/CRM/Utils/PagerAToZ.php b/CRM/Utils/PagerAToZ.php index 51a1d5250814..c9e15a636acb 100644 --- a/CRM/Utils/PagerAToZ.php +++ b/CRM/Utils/PagerAToZ.php @@ -132,7 +132,7 @@ public static function createLinks(&$query, $sortByCharacter, $isDAO) { $qfKey = NULL; if (isset($query->_formValues)) { - $qfKey = CRM_Utils_Array::value('qfKey', $query->_formValues); + $qfKey = $query->_formValues['qfKey'] ?? NULL; } if (empty($qfKey)) { // CRM-20943 Can only pass variables by reference and also cannot use $this so using $empty setting to NULL which is default. diff --git a/CRM/Utils/REST.php b/CRM/Utils/REST.php index a20ea58d2834..5b436c0f2016 100644 --- a/CRM/Utils/REST.php +++ b/CRM/Utils/REST.php @@ -175,13 +175,13 @@ public static function handle() { $requestParams = CRM_Utils_Request::exportValues(); // Get the function name being called from the q parameter in the query string - $q = CRM_Utils_Array::value('q', $requestParams); + $q = $requestParams['q'] ?? NULL; // or for the rest interface, from fnName - $r = CRM_Utils_Array::value('fnName', $requestParams); + $r = $requestParams['fnName'] ?? NULL; if (!empty($r)) { $q = $r; } - $entity = CRM_Utils_Array::value('entity', $requestParams); + $entity = $requestParams['entity'] ?? NULL; if (empty($entity) && !empty($q)) { $args = explode('/', $q); // If the function isn't in the civicrm namespace, reject the request. @@ -204,8 +204,8 @@ public static function handle() { // or the api format (entity+action) $args = []; $args[0] = 'civicrm'; - $args[1] = CRM_Utils_Array::value('entity', $requestParams); - $args[2] = CRM_Utils_Array::value('action', $requestParams); + $args[1] = $requestParams['entity'] ?? NULL; + $args[2] = $requestParams['action'] ?? NULL; } // Everyone should be required to provide the server key, so the whole @@ -213,7 +213,7 @@ public static function handle() { // first check for civicrm site key if (!CRM_Utils_System::authenticateKey(FALSE)) { $docLink = CRM_Utils_System::docURL2("Managing Scheduled Jobs", TRUE, NULL, NULL, NULL, "wiki"); - $key = CRM_Utils_Array::value('key', $requestParams); + $key = $requestParams['key'] ?? NULL; if (empty($key)) { return self::error("FATAL: mandatory param 'key' missing. More info at: " . $docLink); } @@ -516,10 +516,10 @@ public static function ajax() { CRM_Utils_JSON::output($error); } - $q = CRM_Utils_Array::value('fnName', $requestParams); + $q = $requestParams['fnName'] ?? NULL; if (!$q) { - $entity = CRM_Utils_Array::value('entity', $requestParams); - $action = CRM_Utils_Array::value('action', $requestParams); + $entity = $requestParams['entity'] ?? NULL; + $action = $requestParams['action'] ?? NULL; if (!$entity || !$action) { $err = [ 'error_message' => 'missing mandatory params "entity=" or "action="', @@ -535,7 +535,7 @@ public static function ajax() { } // get the class name, since all ajax functions pass className - $className = CRM_Utils_Array::value('className', $requestParams); + $className = $requestParams['className'] ?? NULL; // If the function isn't in the civicrm namespace, reject the request. if (($args[0] != 'civicrm' && count($args) != 3) && !$className) { @@ -578,7 +578,7 @@ public static function processMultiple() { */ public function loadCMSBootstrap() { $requestParams = CRM_Utils_Request::exportValues(); - $q = CRM_Utils_Array::value('q', $requestParams); + $q = $requestParams['q'] ?? NULL; $args = explode('/', $q); // Proceed with bootstrap for "?entity=X&action=Y" diff --git a/CRM/Utils/Request.php b/CRM/Utils/Request.php index 731e43ffafe4..643646c2ed62 100644 --- a/CRM/Utils/Request.php +++ b/CRM/Utils/Request.php @@ -222,7 +222,7 @@ public static function retrieveValue($name, $type, $defaultValue = NULL, $isRequ * The desired value. */ public static function retrieveComponent($attributes) { - $url = CRM_Utils_Array::value('action', $attributes); + $url = $attributes['action'] ?? NULL; // Whilst the following is a fallible universal test for urlencoded URLs, // thankfully the "action" URL has a limited and predictable form and // therefore this comparison is sufficient for our purposes. diff --git a/CRM/Utils/Rule.php b/CRM/Utils/Rule.php index e7f890b3efe6..cbe4ed8f8291 100644 --- a/CRM/Utils/Rule.php +++ b/CRM/Utils/Rule.php @@ -308,9 +308,9 @@ public static function dateTime($value, $default = NULL) { public static function currentDate($date, $monthRequired = TRUE) { $config = CRM_Core_Config::singleton(); - $d = CRM_Utils_Array::value('d', $date); - $m = CRM_Utils_Array::value('M', $date); - $y = CRM_Utils_Array::value('Y', $date); + $d = $date['d'] ?? NULL; + $m = $date['M'] ?? NULL; + $y = $date['Y'] ?? NULL; if (!$d && !$m && !$y) { return TRUE; @@ -318,7 +318,7 @@ public static function currentDate($date, $monthRequired = TRUE) { // CRM-9017 CiviContribute/CiviMember form with expiration date format 'm Y' if (!$m && !empty($date['m'])) { - $m = CRM_Utils_Array::value('m', $date); + $m = $date['m'] ?? NULL; } $day = $mon = 1; @@ -889,13 +889,13 @@ public static function validContact($value, $actualElementValue = NULL) { public static function qfDate($date) { $config = CRM_Core_Config::singleton(); - $d = CRM_Utils_Array::value('d', $date); - $m = CRM_Utils_Array::value('M', $date); - $y = CRM_Utils_Array::value('Y', $date); + $d = $date['d'] ?? NULL; + $m = $date['M'] ?? NULL; + $y = $date['Y'] ?? NULL; if (isset($date['h']) || isset($date['g']) ) { - $m = CRM_Utils_Array::value('M', $date); + $m = $date['M'] ?? NULL; } if (!$d && !$m && !$y) { diff --git a/CRM/Utils/System.php b/CRM/Utils/System.php index 9f71dab6d638..43a6e22c06eb 100644 --- a/CRM/Utils/System.php +++ b/CRM/Utils/System.php @@ -83,7 +83,7 @@ public static function __callStatic($name, $arguments) { public static function makeURL($urlVar, $includeReset = FALSE, $includeForce = TRUE, $path = NULL, $absolute = FALSE) { if (empty($path)) { $config = CRM_Core_Config::singleton(); - $path = CRM_Utils_Array::value($config->userFrameworkURLVar, $_GET); + $path = $_GET[$config->userFrameworkURLVar] ?? NULL; if (empty($path)) { return ''; } @@ -376,7 +376,7 @@ public static function currentPath() { * url */ public static function crmURL($params) { - $p = CRM_Utils_Array::value('p', $params); + $p = $params['p'] ?? NULL; if (!isset($p)) { $p = self::currentPath(); } @@ -420,7 +420,7 @@ public static function setUserContext($names, $default = NULL) { $url = $default; $session = CRM_Core_Session::singleton(); - $referer = CRM_Utils_Array::value('HTTP_REFERER', $_SERVER); + $referer = $_SERVER['HTTP_REFERER'] ?? NULL; if ($referer && !empty($names)) { foreach ($names as $name) { @@ -465,7 +465,7 @@ public static function redirect($url = NULL, $context = []) { // this is kinda hackish but not sure how to do it right $url = str_replace('&', '&', $url); - $context['output'] = CRM_Utils_Array::value('snippet', $_GET); + $context['output'] = $_GET['snippet'] ?? NULL; $parsedUrl = CRM_Utils_Url::parseUrl($url); CRM_Utils_Hook::alterRedirect($parsedUrl, $context); @@ -1245,7 +1245,7 @@ public static function redirectToSSL($abort = FALSE) { * IP address of logged in user. */ public static function ipAddress($strictIPV4 = TRUE) { - $address = CRM_Utils_Array::value('REMOTE_ADDR', $_SERVER); + $address = $_SERVER['REMOTE_ADDR'] ?? NULL; $config = CRM_Core_Config::singleton(); if ($config->userSystem->is_drupal && function_exists('ip_address')) { diff --git a/CRM/Utils/System/Backdrop.php b/CRM/Utils/System/Backdrop.php index 111db129c6d8..d46e56146ce8 100644 --- a/CRM/Utils/System/Backdrop.php +++ b/CRM/Utils/System/Backdrop.php @@ -564,7 +564,7 @@ public function loadBootStrap($params = [], $loadUser = TRUE, $throwError = TRUE return TRUE; } - $uid = CRM_Utils_Array::value('uid', $params); + $uid = $params['uid'] ?? NULL; if (!$uid) { // Load the user we need to check Backdrop permissions. $name = CRM_Utils_Array::value('name', $params, FALSE) ? $params['name'] : trim(CRM_Utils_Array::value('name', $_REQUEST)); diff --git a/CRM/Utils/System/Drupal.php b/CRM/Utils/System/Drupal.php index 0e05bf2bd5e7..f0c8cdbc7de2 100644 --- a/CRM/Utils/System/Drupal.php +++ b/CRM/Utils/System/Drupal.php @@ -511,7 +511,7 @@ public function loadBootStrap($params = [], $loadUser = TRUE, $throwError = TRUE return TRUE; } - $uid = CRM_Utils_Array::value('uid', $params); + $uid = $params['uid'] ?? NULL; if (!$uid) { //load user, we need to check drupal permissions. $name = CRM_Utils_Array::value('name', $params, FALSE) ? $params['name'] : trim(CRM_Utils_Array::value('name', $_REQUEST)); diff --git a/CRM/Utils/System/Drupal6.php b/CRM/Utils/System/Drupal6.php index cca991289e27..26167f93dc3e 100644 --- a/CRM/Utils/System/Drupal6.php +++ b/CRM/Utils/System/Drupal6.php @@ -165,8 +165,8 @@ public function checkUserNameEmailExists(&$params, &$errors, $emailName = 'email $user = NULL; if (!empty($row)) { - $dbName = CRM_Utils_Array::value('name', $row); - $dbEmail = CRM_Utils_Array::value('mail', $row); + $dbName = $row['name'] ?? NULL; + $dbEmail = $row['mail'] ?? NULL; if (strtolower($dbName) == strtolower($name)) { $errors['cms_name'] = ts('The username %1 is already taken. Please select another username.', [1 => $name] @@ -460,7 +460,7 @@ public function loadBootStrap($params = [], $loadUser = TRUE, $throwError = TRUE } global $user; // If $uid is passed in, authentication has been done already. - $uid = CRM_Utils_Array::value('uid', $params); + $uid = $params['uid'] ?? NULL; if (!$uid) { //load user, we need to check drupal permissions. $name = CRM_Utils_Array::value('name', $params, FALSE) ? $params['name'] : trim(CRM_Utils_Array::value('name', $_REQUEST)); diff --git a/CRM/Utils/System/Joomla.php b/CRM/Utils/System/Joomla.php index 380fb3774bfb..9d24ba0ef1a7 100644 --- a/CRM/Utils/System/Joomla.php +++ b/CRM/Utils/System/Joomla.php @@ -133,8 +133,8 @@ public function checkUserNameEmailExists(&$params, &$errors, $emailName = 'email } if (!empty($row)) { - $dbName = CRM_Utils_Array::value('username', $row); - $dbEmail = CRM_Utils_Array::value('email', $row); + $dbName = $row['username'] ?? NULL; + $dbEmail = $row['email'] ?? NULL; if (strtolower($dbName) == strtolower($name)) { $errors['cms_name'] = ts('The username %1 is already taken. Please select another username.', [1 => $name] diff --git a/CRM/Utils/System/WordPress.php b/CRM/Utils/System/WordPress.php index 6c215d2954f8..d29202bc5eae 100644 --- a/CRM/Utils/System/WordPress.php +++ b/CRM/Utils/System/WordPress.php @@ -456,8 +456,8 @@ public function setUFLocale($civicrm_language) { public function loadBootStrap($params = [], $loadUser = TRUE, $throwError = TRUE, $realPath = NULL) { global $wp, $wp_rewrite, $wp_the_query, $wp_query, $wpdb, $current_site, $current_blog, $current_user; - $name = CRM_Utils_Array::value('name', $params); - $pass = CRM_Utils_Array::value('pass', $params); + $name = $params['name'] ?? NULL; + $pass = $params['pass'] ?? NULL; if (!defined('WP_USE_THEMES')) { define('WP_USE_THEMES', FALSE); @@ -483,7 +483,7 @@ public function loadBootStrap($params = [], $loadUser = TRUE, $throwError = TRUE CRM_Core_Config::singleton()->userSystem->setMySQLTimeZone(); } require_once $cmsRootPath . DIRECTORY_SEPARATOR . 'wp-includes/pluggable.php'; - $uid = CRM_Utils_Array::value('uid', $params); + $uid = $params['uid'] ?? NULL; if (!$uid) { $name = $name ? $name : trim(CRM_Utils_Array::value('name', $_REQUEST)); $pass = $pass ? $pass : trim(CRM_Utils_Array::value('pass', $_REQUEST)); diff --git a/CRM/Utils/Token.php b/CRM/Utils/Token.php index 156f87a279d7..6dd024553fa0 100644 --- a/CRM/Utils/Token.php +++ b/CRM/Utils/Token.php @@ -601,10 +601,10 @@ public static function getActionTokenReplacement( $value = "{action.$token}"; } else { - $value = CRM_Utils_Array::value($token, $addresses); + $value = $addresses[$token] ?? NULL; if ($value == NULL) { - $value = CRM_Utils_Array::value($token, $urls); + $value = $urls[$token] ?? NULL; } if ($value && $html) { @@ -722,7 +722,7 @@ public static function getContactTokenReplacement( $noReplace = TRUE; } elseif ($token == 'checksum') { - $hash = CRM_Utils_Array::value('hash', $contact); + $hash = $contact['hash'] ?? NULL; $contactID = CRM_Utils_Array::retrieveValueRecursive($contact, 'contact_id'); $cs = CRM_Contact_BAO_Contact_Utils::generateChecksum($contactID, NULL, @@ -844,7 +844,7 @@ public static function getHookTokenReplacement( $html = FALSE, $escapeSmarty = FALSE ) { - $value = CRM_Utils_Array::value("{$category}.{$token}", $contact); + $value = $contact["{$category}.{$token}"] ?? NULL; if ($value && !$html) { $value = str_replace('&', '&', $value); @@ -1641,7 +1641,7 @@ public static function getApiTokenReplacement($entity, $token, $entityArray) { } $field = civicrm_api3($entity, 'getfield', ['action' => 'get', 'name' => $token, 'get_options' => 'get']); $field = $field['values']; - $fieldType = CRM_Utils_Array::value('type', $field); + $fieldType = $field['type'] ?? NULL; // Boolean fields if ($fieldType == CRM_Utils_Type::T_BOOLEAN && empty($field['options'])) { $field['options'] = [ts('No'), ts('Yes')]; diff --git a/CRM/Utils/Verp.php b/CRM/Utils/Verp.php index 91bca0d282ef..133a8bde38a2 100644 --- a/CRM/Utils/Verp.php +++ b/CRM/Utils/Verp.php @@ -64,8 +64,8 @@ public static function encode($sender, $recipient) { $sdomain = $match[2]; preg_match('/(.+)\@([^\@]+)$/', $recipient, $match); - $rlocal = CRM_Utils_Array::value(1, $match); - $rdomain = CRM_Utils_Array::value(2, $match); + $rlocal = $match[1] ?? NULL; + $rdomain = $match[2] ?? NULL; foreach (self::$encodeMap as $char => $code) { $rlocal = preg_replace('/' . preg_quote($char) . '/i', "+$code", $rlocal); diff --git a/CRM/Utils/Wrapper.php b/CRM/Utils/Wrapper.php index 4c3a41c68092..5efe9a89b66b 100644 --- a/CRM/Utils/Wrapper.php +++ b/CRM/Utils/Wrapper.php @@ -46,7 +46,7 @@ class CRM_Utils_Wrapper { */ public function run($formName, $formLabel = NULL, $arguments = NULL) { if (is_array($arguments)) { - $mode = CRM_Utils_Array::value('mode', $arguments); + $mode = $arguments['mode'] ?? NULL; $imageUpload = !empty($arguments['imageUpload']); $addSequence = !empty($arguments['addSequence']); $attachUpload = !empty($arguments['attachUpload']); @@ -71,10 +71,10 @@ public function run($formName, $formLabel = NULL, $arguments = NULL) { if (array_key_exists('urlToSession', $arguments)) { if (is_array($arguments['urlToSession'])) { foreach ($arguments['urlToSession'] as $params) { - $urlVar = CRM_Utils_Array::value('urlVar', $params); - $sessionVar = CRM_Utils_Array::value('sessionVar', $params); - $type = CRM_Utils_Array::value('type', $params); - $default = CRM_Utils_Array::value('default', $params); + $urlVar = $params['urlVar'] ?? NULL; + $sessionVar = $params['sessionVar'] ?? NULL; + $type = $params['type'] ?? NULL; + $default = $params['default'] ?? NULL; $abort = CRM_Utils_Array::value('abort', $params, FALSE); $value = NULL; diff --git a/api/api.php b/api/api.php index 7cbc5d180dcb..85edf1a32670 100644 --- a/api/api.php +++ b/api/api.php @@ -267,7 +267,7 @@ function _civicrm_api_replace_variable($value, $parentResult, $separator) { if (array_key_exists($fieldname, $parentResult) && is_array($parentResult[$fieldname])) { $arrayLocation = $parentResult[$fieldname]; foreach ($stringParts as $key => $innerValue) { - $arrayLocation = CRM_Utils_Array::value($innerValue, $arrayLocation); + $arrayLocation = $arrayLocation[$innerValue] ?? NULL; } $value = $arrayLocation; } diff --git a/api/v3/Activity.php b/api/v3/Activity.php index 73f43f05a424..f6734a371c26 100644 --- a/api/v3/Activity.php +++ b/api/v3/Activity.php @@ -556,7 +556,7 @@ function _civicrm_api3_activity_get_formatResult($params, $activities, $options) ]); foreach ($activities as &$activity) { if (!empty($activity['case_id'])) { - $case = CRM_Utils_Array::value($activity['case_id'][0], $cases['values']); + $case = $cases['values'][$activity['case_id'][0]] ?? NULL; if ($case) { foreach ($case as $key => $value) { if ($key != 'id') { @@ -705,14 +705,14 @@ function _civicrm_api3_activity_check_params(&$params) { //correctly by doing pseudoconstant validation // needs testing $activityTypes = CRM_Activity_BAO_Activity::buildOptions('activity_type_id', 'validate'); - $activityName = CRM_Utils_Array::value('activity_name', $params); + $activityName = $params['activity_name'] ?? NULL; $activityName = ucfirst($activityName); - $activityLabel = CRM_Utils_Array::value('activity_label', $params); + $activityLabel = $params['activity_label'] ?? NULL; if ($activityLabel) { $activityTypes = CRM_Activity_BAO_Activity::buildOptions('activity_type_id', 'create'); } - $activityTypeId = CRM_Utils_Array::value('activity_type_id', $params); + $activityTypeId = $params['activity_type_id'] ?? NULL; if ($activityName || $activityLabel) { $activityTypeIdInList = array_search(($activityName ? $activityName : $activityLabel), $activityTypes); diff --git a/api/v3/Attachment.php b/api/v3/Attachment.php index b2834091f8d3..c29d63bd34fc 100644 --- a/api/v3/Attachment.php +++ b/api/v3/Attachment.php @@ -338,7 +338,7 @@ function __civicrm_api3_attachment_find($params, $id, $file, $entityFile, $isTru * @throws API_Exception validation errors */ function _civicrm_api3_attachment_parse_params($params) { - $id = CRM_Utils_Array::value('id', $params, NULL); + $id = $params['id'] ?? NULL; if ($id && !is_numeric($id)) { throw new API_Exception("Malformed id"); } diff --git a/api/v3/Contact.php b/api/v3/Contact.php index 9fd042bf3324..a0a54539bf8b 100644 --- a/api/v3/Contact.php +++ b/api/v3/Contact.php @@ -449,7 +449,7 @@ function _civicrm_api3_contact_get_supportanomalies(&$params, &$options) { * API Result Array */ function civicrm_api3_contact_delete($params) { - $contactID = CRM_Utils_Array::value('id', $params); + $contactID = $params['id'] ?? NULL; if (!empty($params['check_permissions']) && !CRM_Contact_BAO_Contact_Permission::allow($contactID, CRM_Core_Permission::DELETE)) { throw new \Civi\API\Exception\UnauthorizedException('Permission denied to modify contact record'); @@ -607,9 +607,9 @@ function _civicrm_api3_greeting_format_params($params) { ]; $greetings = CRM_Core_PseudoConstant::greeting($filter); - $greetingId = CRM_Utils_Array::value("{$key}{$greeting}_id", $params); - $greetingVal = CRM_Utils_Array::value("{$key}{$greeting}", $params); - $customGreeting = CRM_Utils_Array::value("{$key}{$greeting}_custom", $params); + $greetingId = $params["{$key}{$greeting}_id"] ?? NULL; + $greetingVal = $params["{$key}{$greeting}"] ?? NULL; + $customGreeting = $params["{$key}{$greeting}_custom"] ?? NULL; if (!$greetingId && $greetingVal) { $params["{$key}{$greeting}_id"] = CRM_Utils_Array::key($params["{$key}{$greeting}"], $greetings); @@ -858,7 +858,7 @@ function civicrm_api3_contact_getquick($params) { } $actualSelectElements = implode(', ', $actualSelectElements); $from = implode(' ', $from); - $limit = (int) CRM_Utils_Array::value('limit', $params); + $limit = (int) $params['limit'] ?? NULL; $limit = $limit > 0 ? $limit : Civi::settings()->get('search_autocomplete_count'); // add acl clause here @@ -1419,11 +1419,11 @@ function _civicrm_api3_contact_proximity_spec(&$params) { * @throws Exception */ function civicrm_api3_contact_proximity($params) { - $latitude = CRM_Utils_Array::value('latitude', $params); - $longitude = CRM_Utils_Array::value('longitude', $params); - $distance = CRM_Utils_Array::value('distance', $params); + $latitude = $params['latitude'] ?? NULL; + $longitude = $params['longitude'] ?? NULL; + $distance = $params['distance'] ?? NULL; - $unit = CRM_Utils_Array::value('unit', $params); + $unit = $params['unit'] ?? NULL; // check and ensure that lat/long and distance are floats if ( diff --git a/api/v3/Contribution.php b/api/v3/Contribution.php index 66dc25a66f06..b9e633a03a6d 100644 --- a/api/v3/Contribution.php +++ b/api/v3/Contribution.php @@ -356,7 +356,7 @@ function _civicrm_api3_contribution_get_spec(&$params) { $params['financial_type_id']['api.aliases'] = ['contribution_type_id']; $params['payment_instrument_id']['api.aliases'] = ['contribution_payment_instrument', 'payment_instrument']; - $params['contact_id'] = CRM_Utils_Array::value('contribution_contact_id', $params); + $params['contact_id'] = $params['contribution_contact_id'] ?? NULL; $params['contact_id']['api.aliases'] = ['contribution_contact_id']; $params['is_template']['api.default'] = 0; unset($params['contribution_contact_id']); @@ -672,8 +672,8 @@ function _ipn_process_transaction(&$params, $contribution, $input, $ids, $firstC $input['receipt_from_name'] = CRM_Utils_Array::value('receipt_from_name', $params, $domainFromName); $input['receipt_from_email'] = CRM_Utils_Array::value('receipt_from_email', $params, $domainFromEmail); } - $input['card_type_id'] = CRM_Utils_Array::value('card_type_id', $params); - $input['pan_truncation'] = CRM_Utils_Array::value('pan_truncation', $params); + $input['card_type_id'] = $params['card_type_id'] ?? NULL; + $input['pan_truncation'] = $params['pan_truncation'] ?? NULL; $transaction = new CRM_Core_Transaction(); return CRM_Contribute_BAO_Contribution::completeOrder($input, $ids, $objects, $transaction, $contribution, CRM_Utils_Array::value('is_post_payment_create', $params)); diff --git a/api/v3/ContributionPage.php b/api/v3/ContributionPage.php index 4202987d176f..d744043f7122 100644 --- a/api/v3/ContributionPage.php +++ b/api/v3/ContributionPage.php @@ -102,7 +102,7 @@ function civicrm_api3_contribution_page_validate($params) { // authorization from a payment processor like Paypal checkout) the lack of a qfKey will not result in a valid // one being generated so we generate one first. $originalRequest = $_REQUEST; - $qfKey = CRM_Utils_Array::value('qfKey', $_REQUEST); + $qfKey = $_REQUEST['qfKey'] ?? NULL; if (!$qfKey) { $_REQUEST['qfKey'] = CRM_Core_Key::get('CRM_Core_Controller', TRUE); } diff --git a/api/v3/CustomValue.php b/api/v3/CustomValue.php index a524d6157159..0711224f0021 100644 --- a/api/v3/CustomValue.php +++ b/api/v3/CustomValue.php @@ -347,14 +347,14 @@ function civicrm_api3_custom_value_gettree($params) { $result[$group['name']] = []; $groupToReturn = $toReturn['custom_group'] ? $toReturn['custom_group'] : array_keys($group); foreach ($groupToReturn as $item) { - $result[$group['name']][$item] = CRM_Utils_Array::value($item, $group); + $result[$group['name']][$item] = $group[$item] ?? NULL; } $result[$group['name']]['fields'] = []; foreach ($group['fields'] as $fieldInfo) { $field = ['value' => NULL]; $fieldToReturn = $toReturn['custom_field'] ? $toReturn['custom_field'] : array_keys($fieldInfo); foreach ($fieldToReturn as $item) { - $field[$item] = CRM_Utils_Array::value($item, $fieldInfo); + $field[$item] = $fieldInfo[$item] ?? NULL; } unset($field['customValue']); if (!empty($fieldInfo['customValue'])) { diff --git a/api/v3/DashboardContact.php b/api/v3/DashboardContact.php index e867a9bf4824..84853e5477da 100644 --- a/api/v3/DashboardContact.php +++ b/api/v3/DashboardContact.php @@ -71,7 +71,7 @@ function _civicrm_api3_dashboard_contact_create_spec(&$params) { * @return array|null */ function _civicrm_api3_dashboard_contact_check_params(&$params) { - $dashboard_id = CRM_Utils_Array::value('dashboard_id', $params); + $dashboard_id = $params['dashboard_id'] ?? NULL; if ($dashboard_id) { $allDashlets = CRM_Core_BAO_Dashboard::getDashlets(TRUE, CRM_Utils_Array::value('check_permissions', $params, 0)); if (!isset($allDashlets[$dashboard_id])) { diff --git a/api/v3/Domain.php b/api/v3/Domain.php index de3f425b76f5..166179f88fa1 100644 --- a/api/v3/Domain.php +++ b/api/v3/Domain.php @@ -25,7 +25,7 @@ */ function civicrm_api3_domain_get($params) { - $params['version'] = CRM_Utils_Array::value('domain_version', $params); + $params['version'] = $params['domain_version'] ?? NULL; unset($params['version']); $bao = new CRM_Core_BAO_Domain(); @@ -54,7 +54,7 @@ function civicrm_api3_domain_get($params) { ]; if (!empty($values['location']['email'])) { - $domain['domain_email'] = CRM_Utils_Array::value('email', $values['location']['email'][1]); + $domain['domain_email'] = $values['location']['email'][1]['email'] ?? NULL; } if (!empty($values['location']['phone'])) { diff --git a/api/v3/Generic.php b/api/v3/Generic.php index 549ed2a42070..fe355becf2f9 100644 --- a/api/v3/Generic.php +++ b/api/v3/Generic.php @@ -60,8 +60,8 @@ function civicrm_api3_generic_getfields($apiRequest, $unique = TRUE) { } $entity = $apiRequest['entity']; $lowercase_entity = _civicrm_api_get_entity_name_from_camel($entity); - $subentity = CRM_Utils_Array::value('contact_type', $apiRequest['params']); - $action = CRM_Utils_Array::value('action', $apiRequest['params']); + $subentity = $apiRequest['params']['contact_type'] ?? NULL; + $action = $apiRequest['params']['action'] ?? NULL; $sequential = empty($apiRequest['params']['sequential']) ? 0 : 1; $apiRequest['params']['options'] = CRM_Utils_Array::value('options', $apiRequest['params'], []); $optionsToResolve = (array) CRM_Utils_Array::value('get_options', $apiRequest['params']['options'], []); @@ -414,7 +414,7 @@ function civicrm_api3_generic_getoptions($apiRequest) { return civicrm_api3_create_error("The field '{$apiRequest['params']['field']}' doesn't exist."); } // Validate 'context' from params - $context = CRM_Utils_Array::value('context', $apiRequest['params']); + $context = $apiRequest['params']['context'] ?? NULL; CRM_Core_DAO::buildOptionsContext($context); unset($apiRequest['params']['context'], $apiRequest['params']['field'], $apiRequest['params']['condition']); @@ -502,10 +502,10 @@ function _civicrm_api3_generic_get_metadata_options(&$metadata, $apiRequest, $fi } // Allow caller to specify context - $context = CRM_Utils_Array::value('get_options_context', $apiRequest['params']['options']); + $context = $apiRequest['params']['options']['get_options_context'] ?? NULL; // Default to api action if it is a supported context. if (!$context) { - $action = CRM_Utils_Array::value('action', $apiRequest['params']); + $action = $apiRequest['params']['action'] ?? NULL; $contexts = CRM_Core_DAO::buildOptionsContext(); if (isset($contexts[$action])) { $context = $action; diff --git a/api/v3/GroupContact.php b/api/v3/GroupContact.php index 116ec298a6b3..250438378f77 100644 --- a/api/v3/GroupContact.php +++ b/api/v3/GroupContact.php @@ -52,7 +52,7 @@ function civicrm_api3_group_contact_get($params) { } $status = CRM_Utils_Array::value('status', $params, 'Added'); - $groupId = CRM_Utils_Array::value('group_id', $params); + $groupId = $params['group_id'] ?? NULL; $values = CRM_Contact_BAO_GroupContact::getContactGroup($params['contact_id'], $status, NULL, FALSE, TRUE, FALSE, TRUE, $groupId); return civicrm_api3_create_success($values, $params, 'GroupContact'); } @@ -219,7 +219,7 @@ function _civicrm_api3_group_contact_common($params, $op = 'Added') { $method = CRM_Utils_Array::value('method', $params, 'API'); $status = CRM_Utils_Array::value('status', $params, $op); - $tracking = CRM_Utils_Array::value('tracking', $params); + $tracking = $params['tracking'] ?? NULL; if ($op == 'Added' || $op == 'Pending') { $extraReturnValues = [ diff --git a/api/v3/Job.php b/api/v3/Job.php index 20a1e15d1f36..7c9f1495e39b 100644 --- a/api/v3/Job.php +++ b/api/v3/Job.php @@ -512,7 +512,7 @@ function civicrm_api3_job_process_respondent($params) { * @throws \CiviCRM_API3_Exception */ function civicrm_api3_job_process_batch_merge($params) { - $rule_group_id = CRM_Utils_Array::value('rule_group_id', $params); + $rule_group_id = $params['rule_group_id'] ?? NULL; if (!$rule_group_id) { $rule_group_id = civicrm_api3('RuleGroup', 'getvalue', [ 'contact_type' => 'Individual', @@ -521,8 +521,8 @@ function civicrm_api3_job_process_batch_merge($params) { 'options' => ['limit' => 1], ]); } - $rgid = CRM_Utils_Array::value('rgid', $params); - $gid = CRM_Utils_Array::value('gid', $params); + $rgid = $params['rgid'] ?? NULL; + $gid = $params['gid'] ?? NULL; $mode = CRM_Utils_Array::value('mode', $params, 'safe'); $result = CRM_Dedupe_Merger::batchMerge($rule_group_id, $gid, $mode, 1, 2, CRM_Utils_Array::value('criteria', $params, []), CRM_Utils_Array::value('check_permissions', $params), NULL, $params['search_limit']); diff --git a/api/v3/Mailing.php b/api/v3/Mailing.php index fc7645a049c8..185b3cd374ad 100644 --- a/api/v3/Mailing.php +++ b/api/v3/Mailing.php @@ -192,7 +192,7 @@ function civicrm_api3_mailing_clone($params) { $get = civicrm_api3('Mailing', 'getsingle', ['id' => $params['id']]); $newParams = []; - $newParams['debug'] = CRM_Utils_Array::value('debug', $params); + $newParams['debug'] = $params['debug'] ?? NULL; $newParams['groups']['include'] = []; $newParams['groups']['exclude'] = []; $newParams['mailings']['include'] = []; @@ -393,9 +393,9 @@ function civicrm_api3_mailing_event_reply($params) { $queue = $params['event_queue_id']; $hash = $params['hash']; $replyto = $params['replyTo']; - $bodyTxt = CRM_Utils_Array::value('bodyTxt', $params); - $bodyHTML = CRM_Utils_Array::value('bodyHTML', $params); - $fullEmail = CRM_Utils_Array::value('fullEmail', $params); + $bodyTxt = $params['bodyTxt'] ?? NULL; + $bodyHTML = $params['bodyHTML'] ?? NULL; + $fullEmail = $params['fullEmail'] ?? NULL; $mailing = CRM_Mailing_Event_BAO_Reply::reply($job, $queue, $hash, $replyto); @@ -440,8 +440,8 @@ function civicrm_api3_mailing_event_forward($params) { $queue = $params['event_queue_id']; $hash = $params['hash']; $email = $params['email']; - $fromEmail = CRM_Utils_Array::value('fromEmail', $params); - $params = CRM_Utils_Array::value('params', $params); + $fromEmail = $params['fromEmail'] ?? NULL; + $params = $params['params'] ?? NULL; $forward = CRM_Mailing_Event_BAO_Forward::forward($job, $queue, $hash, $email, $fromEmail, $params); @@ -538,7 +538,7 @@ function civicrm_api3_mailing_preview($params) { } $mailing = new CRM_Mailing_BAO_Mailing(); - $mailingID = CRM_Utils_Array::value('id', $params); + $mailingID = $params['id'] ?? NULL; if ($mailingID) { $mailing->id = $mailingID; $mailing->find(TRUE); @@ -555,7 +555,7 @@ function civicrm_api3_mailing_preview($params) { $attachments = CRM_Core_BAO_File::getEntityFile('civicrm_mailing', $mailing->id); $returnProperties = $mailing->getReturnProperties(); - $contactID = CRM_Utils_Array::value('contact_id', $params); + $contactID = $params['contact_id'] ?? NULL; if (!$contactID) { // If we still don't have a userID in a session because we are annon then set contactID to be 0 $contactID = empty($session->get('userID')) ? 0 : $session->get('userID'); @@ -564,7 +564,7 @@ function civicrm_api3_mailing_preview($params) { if (!$contactID) { $details = CRM_Utils_Token::getAnonymousTokenDetails($mailingParams, $returnProperties, TRUE, TRUE, NULL, $mailing->getFlattenedTokens()); - $details = CRM_Utils_Array::value(0, $details[0]); + $details = $details[0][0] ?? NULL; } else { $details = CRM_Utils_Token::getTokenDetails($mailingParams, $returnProperties, TRUE, TRUE, NULL, $mailing->getFlattenedTokens()); diff --git a/api/v3/MailingEventSubscribe.php b/api/v3/MailingEventSubscribe.php index b594d772ac60..92a8795bdb20 100644 --- a/api/v3/MailingEventSubscribe.php +++ b/api/v3/MailingEventSubscribe.php @@ -29,7 +29,7 @@ function civicrm_api3_mailing_event_subscribe_create($params) { $email = $params['email']; $group_id = $params['group_id']; - $contact_id = CRM_Utils_Array::value('contact_id', $params); + $contact_id = $params['contact_id'] ?? NULL; $group = new CRM_Contact_DAO_Group(); $group->is_active = 1; diff --git a/api/v3/Membership.php b/api/v3/Membership.php index 879aeb80ad1f..8e935373d1a1 100644 --- a/api/v3/Membership.php +++ b/api/v3/Membership.php @@ -208,7 +208,7 @@ function _civicrm_api3_membership_get_spec(&$params) { function civicrm_api3_membership_get($params) { $activeOnly = $membershipTypeId = $membershipType = NULL; - $contactID = CRM_Utils_Array::value('contact_id', $params); + $contactID = $params['contact_id'] ?? NULL; if (!empty($params['filters']) && is_array($params['filters']) && isset($params['filters']['is_current'])) { $activeOnly = $params['filters']['is_current']; unset($params['filters']['is_current']); @@ -291,7 +291,7 @@ function _civicrm_api3_membership_relationsship_get_customv2behaviour(&$params, // populating relationship type name. $relationshipType = new CRM_Contact_BAO_RelationshipType(); - $relationshipType->id = CRM_Utils_Array::value('relationship_type_id', $membershipType); + $relationshipType->id = $membershipType['relationship_type_id'] ?? NULL; if ($relationshipType->find(TRUE)) { $membershipValues[$membershipId]['relationship_name'] = $relationshipType->name_a_b; } diff --git a/api/v3/MembershipStatus.php b/api/v3/MembershipStatus.php index 97421d09d9bf..f49c269435f8 100644 --- a/api/v3/MembershipStatus.php +++ b/api/v3/MembershipStatus.php @@ -72,7 +72,7 @@ function civicrm_api3_membership_status_update($params) { civicrm_api3_verify_mandatory($params, NULL, ['id']); //don't allow duplicate names. - $name = CRM_Utils_Array::value('name', $params); + $name = $params['name'] ?? NULL; if ($name) { $status = new CRM_Member_DAO_MembershipStatus(); $status->name = $params['name']; diff --git a/api/v3/Order.php b/api/v3/Order.php index 464dcd427058..99b270ec2975 100644 --- a/api/v3/Order.php +++ b/api/v3/Order.php @@ -74,7 +74,7 @@ function civicrm_api3_order_create($params) { civicrm_api3_verify_one_mandatory($params, NULL, ['line_items', 'total_amount']); $entity = NULL; $entityIds = []; - $contributionStatus = CRM_Utils_Array::value('contribution_status_id', $params); + $contributionStatus = $params['contribution_status_id'] ?? NULL; if ($contributionStatus !== 'Pending' && 'Pending' !== CRM_Core_PseudoConstant::getName('CRM_Contribute_BAO_Contribution', 'contribution_status_id', $contributionStatus)) { CRM_Core_Error::deprecatedFunctionWarning("Creating a Order with a status other than pending is deprecated. Currently empty defaults to 'Completed' so as a transition not passing in 'Pending' is deprecated. You can chain payment creation e.g civicrm_api3('Order', 'create', ['blah' => 'blah', 'contribution_status_id' => 'Pending', 'api.Payment.create => ['total_amount' => 5]]"); } diff --git a/api/v3/Payment.php b/api/v3/Payment.php index cab15b3f3cd7..32cff589fd9b 100644 --- a/api/v3/Payment.php +++ b/api/v3/Payment.php @@ -30,7 +30,7 @@ function civicrm_api3_payment_get($params) { $financialTrxn = []; $limit = ''; if (isset($params['options']) && !empty($params['options']['limit'])) { - $limit = CRM_Utils_Array::value('limit', $params['options']); + $limit = $params['options']['limit'] ?? NULL; } $params['options']['limit'] = 0; if (isset($params['trxn_id'])) { diff --git a/api/v3/Setting.php b/api/v3/Setting.php index dc5fc1d6e969..9d8fce5e6c30 100644 --- a/api/v3/Setting.php +++ b/api/v3/Setting.php @@ -132,7 +132,7 @@ function _civicrm_api3_setting_getdefaults_spec(&$params) { * @throws \API_Exception */ function civicrm_api3_setting_getoptions($params) { - $domainId = CRM_Utils_Array::value('domain_id', $params); + $domainId = $params['domain_id'] ?? NULL; $specs = \Civi\Core\SettingsMetadata::getMetadata(['name' => $params['field']], $domainId, TRUE); if (empty($specs[$params['field']]) || !is_array(CRM_Utils_Array::value('options', $specs[$params['field']]))) { diff --git a/api/v3/utils.php b/api/v3/utils.php index 65fe0128da64..609af1fba09f 100644 --- a/api/v3/utils.php +++ b/api/v3/utils.php @@ -539,10 +539,10 @@ function _civicrm_api3_get_using_query_object($entity, $params, $additional_opti } } $options = array_merge($options, $additional_options); - $sort = CRM_Utils_Array::value('sort', $options, NULL); - $offset = CRM_Utils_Array::value('offset', $options, NULL); - $limit = CRM_Utils_Array::value('limit', $options, NULL); - $smartGroupCache = CRM_Utils_Array::value('smartGroupCache', $params); + $sort = $options['sort'] ?? NULL; + $offset = $options['offset'] ?? NULL; + $limit = $options['limit'] ?? NULL; + $smartGroupCache = $params['smartGroupCache'] ?? NULL; if ($getCount) { $limit = NULL; @@ -590,11 +590,11 @@ function _civicrm_api3_get_using_query_object($entity, $params, $additional_opti */ function _civicrm_api3_get_query_object($params, $mode, $entity) { $options = _civicrm_api3_get_options_from_params($params, TRUE, $entity, 'get'); - $sort = CRM_Utils_Array::value('sort', $options, NULL); - $offset = CRM_Utils_Array::value('offset', $options); - $rowCount = CRM_Utils_Array::value('limit', $options); + $sort = $options['sort'] ?? NULL; + $offset = $options['offset'] ?? NULL; + $rowCount = $options['limit'] ?? NULL; $inputParams = CRM_Utils_Array::value('input_params', $options, []); - $returnProperties = CRM_Utils_Array::value('return', $options, NULL); + $returnProperties = $options['return'] ?? NULL; if (empty($returnProperties)) { $returnProperties = CRM_Contribute_BAO_Query::defaultReturnProperties($mode); } @@ -791,7 +791,7 @@ function _civicrm_api3_get_options_from_params($params, $queryObject = FALSE, $e if (is_array(CRM_Utils_Array::value('options', $params))) { // is count is set by generic getcount not user - $is_count = CRM_Utils_Array::value('is_count', $params['options']); + $is_count = $params['options']['is_count'] ?? NULL; $offset = CRM_Utils_Array::value('offset', $params['options'], $offset); $limit = CRM_Utils_Array::value('limit', $params['options'], $limit); $sort = CRM_Utils_Array::value('sort', $params['options'], $sort); @@ -1975,7 +1975,7 @@ function _civicrm_api_get_custom_fields($entity, &$params) { $entity = _civicrm_api_get_camel_name($entity); if ($entity == 'Contact') { // Use sub-type if available, otherwise "NULL" to fetch from all contact types - $entity = CRM_Utils_Array::value('contact_type', $params); + $entity = $params['contact_type'] ?? NULL; } $customfields = CRM_Core_BAO_CustomField::getFields($entity, FALSE, @@ -2015,7 +2015,7 @@ function _civicrm_api_get_custom_fields($entity, &$params) { */ function _civicrm_api3_swap_out_aliases(&$apiRequest, $fields) { foreach ($fields as $field => $values) { - $uniqueName = CRM_Utils_Array::value('uniqueName', $values); + $uniqueName = $values['uniqueName'] ?? NULL; if (!empty($values['api.aliases'])) { // if aliased field is not set we try to use field alias if (!isset($apiRequest['params'][$field])) { @@ -2043,7 +2043,7 @@ function _civicrm_api3_swap_out_aliases(&$apiRequest, $fields) { && $field != $uniqueName && array_key_exists($uniqueName, $apiRequest['params']) ) { - $apiRequest['params'][$field] = CRM_Utils_Array::value($values['uniqueName'], $apiRequest['params']); + $apiRequest['params'][$field] = $apiRequest['params'][$values['uniqueName']] ?? NULL; // note that it would make sense to unset the original field here but tests need to be in place first } } @@ -2292,7 +2292,7 @@ function _civicrm_api3_api_match_pseudoconstant(&$fieldValue, $entity, $fieldNam return; } - $options = CRM_Utils_Array::value('options', $fieldInfo); + $options = $fieldInfo['options'] ?? NULL; if (!$options) { if (strtolower($entity) == 'profile' && !empty($fieldInfo['entity'])) { @@ -2463,7 +2463,7 @@ function _civicrm_api3_deprecation_check($entity, $result = []) { * @return mixed */ function _civicrm_api3_field_value_check(&$params, $fieldName, $type = NULL) { - $fieldValue = CRM_Utils_Array::value($fieldName, $params); + $fieldValue = $params[$fieldName] ?? NULL; $op = NULL; if (!empty($fieldValue) && is_array($fieldValue) && @@ -2471,7 +2471,7 @@ function _civicrm_api3_field_value_check(&$params, $fieldName, $type = NULL) { $type == 'String' && strstr(key($fieldValue), 'EMPTY')) ) { $op = key($fieldValue); - $fieldValue = CRM_Utils_Array::value($op, $fieldValue); + $fieldValue = $fieldValue[$op] ?? NULL; } return [$fieldValue, $op]; } @@ -2497,8 +2497,8 @@ function _civicrm_api3_field_value_check(&$params, $fieldName, $type = NULL) { function _civicrm_api3_basic_array_get($entity, $params, $records, $idCol, $filterableFields) { $options = _civicrm_api3_get_options_from_params($params, TRUE, $entity, 'get'); // TODO // $sort = CRM_Utils_Array::value('sort', $options, NULL); - $offset = CRM_Utils_Array::value('offset', $options); - $limit = CRM_Utils_Array::value('limit', $options); + $offset = $options['offset'] ?? NULL; + $limit = $options['limit'] ?? NULL; $matches = []; diff --git a/extern/url.php b/extern/url.php index 4c89886e4e61..cafbf7ee9c13 100644 --- a/extern/url.php +++ b/extern/url.php @@ -9,12 +9,12 @@ // To keep backward compatibility for URLs generated // by CiviCRM < 1.7, we check for the q variable as well. if (isset($_GET['qid'])) { - $queue_id = CRM_Utils_Array::value('qid', $_GET); + $queue_id = $_GET['qid'] ?? NULL; } else { - $queue_id = CRM_Utils_Array::value('q', $_GET); + $queue_id = $_GET['q'] ?? NULL; } -$url_id = CRM_Utils_Array::value('u', $_GET); +$url_id = $_GET['u'] ?? NULL; if (!$url_id) { echo "Missing input parameters\n"; diff --git a/tests/phpunit/CRM/Contact/BAO/ContactTest.php b/tests/phpunit/CRM/Contact/BAO/ContactTest.php index 77e6020f6a96..f5b75760fadc 100644 --- a/tests/phpunit/CRM/Contact/BAO/ContactTest.php +++ b/tests/phpunit/CRM/Contact/BAO/ContactTest.php @@ -611,7 +611,7 @@ public function testRetrieve() { $this->assertEquals(1, $values['noteTotalCount'], 'Check for total note count'); foreach ($values['note'] as $key => $val) { - $retrieveNote = CRM_Utils_Array::value('note', $val); + $retrieveNote = $val['note'] ?? NULL; //check the note value $this->assertEquals($params['note'], $retrieveNote, 'Check for note'); } diff --git a/tests/phpunit/CRM/Contribute/Form/SearchTest.php b/tests/phpunit/CRM/Contribute/Form/SearchTest.php index 15a693267b60..e60c4c0ec16a 100644 --- a/tests/phpunit/CRM/Contribute/Form/SearchTest.php +++ b/tests/phpunit/CRM/Contribute/Form/SearchTest.php @@ -401,7 +401,7 @@ public function testContributionRecurSearchFilters($formValues, $expectedCount, $this->assertEquals($expectedCount, count($contacts)); // get and assert qill string $qill = $query->qill(); - $qillString = !empty($qill[1]) ? $qill[1] : CRM_Utils_Array::value(0, $qill); + $qillString = !empty($qill[1]) ? $qill[1] : $qill[0] ?? NULL; $qill = trim(implode($query->getOperator(), $qillString)); $this->assertEquals($expectedQill, $qill); diff --git a/tests/phpunit/CRM/Core/BAO/AddressTest.php b/tests/phpunit/CRM/Core/BAO/AddressTest.php index 6509776640ab..b8264bbb7dab 100644 --- a/tests/phpunit/CRM/Core/BAO/AddressTest.php +++ b/tests/phpunit/CRM/Core/BAO/AddressTest.php @@ -312,14 +312,14 @@ public function testParseStreetAddressIfEnabled() { $result = civicrm_api3('Address', 'create', $params); $value = array_pop($result['values']); - $street_number = CRM_Utils_Array::value('street_number', $value); + $street_number = $value['street_number'] ?? NULL; $this->assertEquals($street_number, '54'); // Ensure street parsing does not happen if disabled. $this->setStreetAddressParsing(FALSE); $result = civicrm_api3('Address', 'create', $params); $value = array_pop($result['values']); - $street_number = CRM_Utils_Array::value('street_number', $value); + $street_number = $value['street_number'] ?? NULL; $this->assertEmpty($street_number); } diff --git a/tests/phpunit/CRM/Core/Page/AJAXTest.php b/tests/phpunit/CRM/Core/Page/AJAXTest.php index 330f0daa9eb7..6855a6dbf977 100644 --- a/tests/phpunit/CRM/Core/Page/AJAXTest.php +++ b/tests/phpunit/CRM/Core/Page/AJAXTest.php @@ -49,7 +49,7 @@ public function testCheckAuthz() { foreach ($cases as $case) { list ($type, $className, $expectedResult) = $case; - $methodName = CRM_Utils_Array::value(3, $case); + $methodName = $case[3] ?? NULL; $actualResult = CRM_Core_Page_AJAX::checkAuthz($type, $className, $methodName); if ($methodName) { $this->assertEquals($expectedResult, $actualResult, diff --git a/tests/phpunit/CRM/Event/BAO/AdditionalPaymentTest.php b/tests/phpunit/CRM/Event/BAO/AdditionalPaymentTest.php index 6d8aa1492115..b5dcf0133a56 100644 --- a/tests/phpunit/CRM/Event/BAO/AdditionalPaymentTest.php +++ b/tests/phpunit/CRM/Event/BAO/AdditionalPaymentTest.php @@ -75,8 +75,8 @@ protected function addParticipantWithPayment($feeTotal, $actualPaidAmt, $partici // -- processing priceSet using the BAO $lineItems = []; $priceSet = CRM_Price_BAO_PriceSet::getSetDetail($priceSetId, TRUE, FALSE); - $priceSet = CRM_Utils_Array::value($priceSetId, $priceSet); - $feeBlock = CRM_Utils_Array::value('fields', $priceSet); + $priceSet = $priceSet[$priceSetId] ?? NULL; + $feeBlock = $priceSet['fields'] ?? NULL; $params['price_2'] = $feeTotal; $tempParams = $params; diff --git a/tests/phpunit/CRM/Event/BAO/ChangeFeeSelectionTest.php b/tests/phpunit/CRM/Event/BAO/ChangeFeeSelectionTest.php index 50311c0166e3..894ea803dd14 100644 --- a/tests/phpunit/CRM/Event/BAO/ChangeFeeSelectionTest.php +++ b/tests/phpunit/CRM/Event/BAO/ChangeFeeSelectionTest.php @@ -71,8 +71,8 @@ public function setUp() { $this->_priceSetID = $this->priceSetCreate(); CRM_Price_BAO_PriceSet::addTo('civicrm_event', $this->_eventId, $this->_priceSetID); $priceSet = CRM_Price_BAO_PriceSet::getSetDetail($this->_priceSetID, TRUE, FALSE); - $priceSet = CRM_Utils_Array::value($this->_priceSetID, $priceSet); - $this->_feeBlock = CRM_Utils_Array::value('fields', $priceSet); + $priceSet = $priceSet[$this->_priceSetID] ?? NULL; + $this->_feeBlock = $priceSet['fields'] ?? NULL; } /** @@ -376,8 +376,8 @@ public function testCRM21513() { $this->_priceSetID = $this->priceSetCreate('Text'); CRM_Price_BAO_PriceSet::addTo('civicrm_event', $this->_eventId, $this->_priceSetID); $priceSet = CRM_Price_BAO_PriceSet::getSetDetail($this->_priceSetID, TRUE, FALSE); - $priceSet = CRM_Utils_Array::value($this->_priceSetID, $priceSet); - $this->_feeBlock = CRM_Utils_Array::value('fields', $priceSet); + $priceSet = $priceSet[$this->_priceSetID] ?? NULL; + $this->_feeBlock = $priceSet['fields'] ?? NULL; $params = [ 'send_receipt' => 1, diff --git a/tests/phpunit/CRM/Member/BAO/MembershipTypeTest.php b/tests/phpunit/CRM/Member/BAO/MembershipTypeTest.php index cbe95e1db889..ab848b86512c 100644 --- a/tests/phpunit/CRM/Member/BAO/MembershipTypeTest.php +++ b/tests/phpunit/CRM/Member/BAO/MembershipTypeTest.php @@ -348,7 +348,7 @@ public function testGetMembershipTypesByOrg() { 'limit' => 0, ], ]); - $result = CRM_Utils_Array::value('values', $membershipTypesResult, NULL); + $result = $membershipTypesResult['values'] ?? NULL; $this->assertEquals(empty($result), FALSE, 'Verify membership types for organization.'); $membershipTypesResult = civicrm_api3('MembershipType', 'get', [ @@ -357,7 +357,7 @@ public function testGetMembershipTypesByOrg() { 'limit' => 0, ], ]); - $result = CRM_Utils_Array::value('values', $membershipTypesResult, NULL); + $result = $membershipTypesResult['values'] ?? NULL; $this->assertEquals(empty($result), TRUE, 'Verify membership types for organization.'); $this->membershipTypeDelete(['id' => $membershipType->id]); diff --git a/tests/phpunit/CiviTest/CiviTestSMSProvider.php b/tests/phpunit/CiviTest/CiviTestSMSProvider.php index e687ac411b8b..db73e2a5ad19 100644 --- a/tests/phpunit/CiviTest/CiviTestSMSProvider.php +++ b/tests/phpunit/CiviTest/CiviTestSMSProvider.php @@ -28,7 +28,7 @@ public static function &singleton($providerParams = array(), $force = FALSE) { $providerID = $provider['id']; } else { - $providerID = CRM_Utils_Array::value('provider_id', $providerParams); + $providerID = $providerParams['provider_id'] ?? NULL; } $skipAuth = $providerID ? FALSE : TRUE; $cacheKey = (int) $providerID; diff --git a/tests/phpunit/CiviTest/CiviUnitTestCase.php b/tests/phpunit/CiviTest/CiviUnitTestCase.php index 173c06e6e1eb..74e1675b7f1c 100644 --- a/tests/phpunit/CiviTest/CiviUnitTestCase.php +++ b/tests/phpunit/CiviTest/CiviUnitTestCase.php @@ -1064,8 +1064,8 @@ protected function eventCreatePaid($params, $options = [['name' => 'hundy', 'amo $this->priceSetID = $this->ids['PriceSet'][] = $this->eventPriceSetCreate(55, 0, 'Radio', $options); CRM_Price_BAO_PriceSet::addTo('civicrm_event', $event['id'], $this->priceSetID); $priceSet = CRM_Price_BAO_PriceSet::getSetDetail($this->priceSetID, TRUE, FALSE); - $priceSet = CRM_Utils_Array::value($this->priceSetID, $priceSet); - $this->eventFeeBlock = CRM_Utils_Array::value('fields', $priceSet); + $priceSet = $priceSet[$this->priceSetID] ?? NULL; + $this->eventFeeBlock = $priceSet['fields'] ?? NULL; return $event; } @@ -1927,7 +1927,7 @@ public function getAndCheck($params, $id, $entity, $delete = 1, $errorText = '') else { $keys[CRM_Utils_Array::value('name', $settings, $field)] = CRM_Utils_Array::value('name', $settings, $field); } - $type = CRM_Utils_Array::value('type', $settings); + $type = $settings['type'] ?? NULL; if ($type == CRM_Utils_Type::T_DATE) { $dateFields[] = $settings['name']; // we should identify both real names & unique names as dates diff --git a/tests/phpunit/api/v3/ContributionPageTest.php b/tests/phpunit/api/v3/ContributionPageTest.php index b35c227b0c87..5d4b4a8a1073 100644 --- a/tests/phpunit/api/v3/ContributionPageTest.php +++ b/tests/phpunit/api/v3/ContributionPageTest.php @@ -2049,8 +2049,8 @@ public function testValidateOutputOnMissingRecurFields() { */ public function hook_civicrm_alterPaymentProcessorParams($paymentObj, &$rawParams, &$cookedParams) { // Ensure total_amount are the same if they're both given. - $total_amount = CRM_Utils_Array::value('total_amount', $rawParams); - $amount = CRM_Utils_Array::value('amount', $rawParams); + $total_amount = $rawParams['total_amount'] ?? NULL; + $amount = $rawParams['amount'] ?? NULL; if (!empty($total_amount) && !empty($amount) && $total_amount != $amount) { throw new Exception("total_amount '$total_amount' and amount '$amount' differ."); } diff --git a/tests/phpunit/api/v3/MembershipTypeTest.php b/tests/phpunit/api/v3/MembershipTypeTest.php index bd47aa24c01d..2931757e1666 100644 --- a/tests/phpunit/api/v3/MembershipTypeTest.php +++ b/tests/phpunit/api/v3/MembershipTypeTest.php @@ -286,11 +286,11 @@ public function testEnableMembershipTypeOnContributionPage() { foreach ($memType as $rowCount => $type) { $membetype = CRM_Member_BAO_MembershipType::getMembershipTypeDetails($type); $fieldParams['option_id'] = [1 => $priceFieldValue['id']]; - $fieldParams['option_label'][$rowCount] = CRM_Utils_Array::value('name', $membetype); + $fieldParams['option_label'][$rowCount] = $membetype['name'] ?? NULL; $fieldParams['option_amount'][$rowCount] = CRM_Utils_Array::value('minimum_fee', $membetype, 0); - $fieldParams['option_weight'][$rowCount] = CRM_Utils_Array::value('weight', $membetype); - $fieldParams['option_description'][$rowCount] = CRM_Utils_Array::value('description', $membetype); - $fieldParams['option_financial_type_id'][$rowCount] = CRM_Utils_Array::value('financial_type_id', $membetype); + $fieldParams['option_weight'][$rowCount] = $membetype['weight'] ?? NULL; + $fieldParams['option_description'][$rowCount] = $membetype['description'] ?? NULL; + $fieldParams['option_financial_type_id'][$rowCount] = $membetype['financial_type_id'] ?? NULL; $fieldParams['membership_type_id'][$rowCount] = $type; } $priceField = CRM_Price_BAO_PriceField::create($fieldParams); diff --git a/tools/bin/scripts/NormalizePhone.php b/tools/bin/scripts/NormalizePhone.php index dc7894dbf886..795f1296292d 100644 --- a/tools/bin/scripts/NormalizePhone.php +++ b/tools/bin/scripts/NormalizePhone.php @@ -52,7 +52,7 @@ function run() { } } if (!$$var) { - $$var = CRM_Utils_Array::value($var, $_REQUEST); + $$var = $_REQUEST[$var] ?? NULL; } $_REQUEST[$var] = $$var; }