From: Coleman Watts Date: Tue, 3 Mar 2015 14:38:50 +0000 (-0500) Subject: CRM-15932 - Cleanup unnecessary use of CRM_Utils_Array X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=b53cbfbc892449258a2477216e17d199f3f6174c;p=civicrm-core.git CRM-15932 - Cleanup unnecessary use of CRM_Utils_Array --- diff --git a/CRM/Activity/BAO/Activity.php b/CRM/Activity/BAO/Activity.php index 61fdb3c53f..446e661f24 100644 --- a/CRM/Activity/BAO/Activity.php +++ b/CRM/Activity/BAO/Activity.php @@ -2697,7 +2697,7 @@ INNER JOIN civicrm_option_group grp ON ( grp.id = val.option_group_id AND grp.n * @param array $params */ public function setApiFilter(&$params) { - if (CRM_Utils_Array::value('target_contact_id', $params)) { + if (!empty($params['target_contact_id'])) { $this->selectAdd(); $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts); diff --git a/CRM/Activity/Page/AJAX.php b/CRM/Activity/Page/AJAX.php index 6f657edeee..dc6b5323ba 100644 --- a/CRM/Activity/Page/AJAX.php +++ b/CRM/Activity/Page/AJAX.php @@ -486,7 +486,7 @@ class CRM_Activity_Page_AJAX { foreach ($activities as $key => $value) { //Check if recurring activity - if (CRM_Utils_Array::value('is_recurring_activity', $value)) { + if (!empty($value['is_recurring_activity'])) { if ($key == $value['is_recurring_activity']) { $activities[$key]['activity_type'] = $activities[$key]['activity_type'] . '
Recurring Activity - (Parent)'; } diff --git a/CRM/Badge/BAO/Badge.php b/CRM/Badge/BAO/Badge.php index 1576e34728..21972d5493 100644 --- a/CRM/Badge/BAO/Badge.php +++ b/CRM/Badge/BAO/Badge.php @@ -208,7 +208,7 @@ class CRM_Badge_BAO_Badge { $startOffset = CRM_Utils_Array::value('height_image_2', $formattedRow); } - if (CRM_Utils_Array::value('participant_image', $formattedRow)) { + if (!empty($formattedRow['participant_image'])) { $imageAlign = 0; switch (CRM_Utils_Array::value('alignment_participant_image', $formattedRow)) { case 'R': diff --git a/CRM/Contribute/Form/Contribution.php b/CRM/Contribute/Form/Contribution.php index 8dbf488261..1abeefd2f9 100644 --- a/CRM/Contribute/Form/Contribution.php +++ b/CRM/Contribute/Form/Contribution.php @@ -1357,7 +1357,7 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP $this->assign('dataArray', $taxRate); } else { - if (CRM_Utils_Array::value('price_set_id', $submittedValues)) { + if (!empty($submittedValues['price_set_id'])) { $this->assign('totalTaxAmount', $submittedValues['tax_amount']); $this->assign('getTaxDetails', $getTaxDetails); $this->assign('dataArray', $taxRate); diff --git a/CRM/Core/BAO/Dashboard.php b/CRM/Core/BAO/Dashboard.php index 9d589d8988..c65fa536dc 100644 --- a/CRM/Core/BAO/Dashboard.php +++ b/CRM/Core/BAO/Dashboard.php @@ -164,7 +164,7 @@ class CRM_Core_BAO_Dashboard extends CRM_Core_DAO_Dashboard { $contactID = CRM_Core_Session::singleton()->get('userID'); $allDashlets = CRM_Utils_Array::index(array('name'), $getDashlets['values']); $defaultDashlets = array(); - if (CRM_Utils_Array::value('blog', $allDashlets)) { + if (!empty($allDashlets['blog'])) { $defaultDashlets['blog'] = array( 'dashboard_id' => $allDashlets['blog']['id'], 'is_active' => 1, diff --git a/CRM/Core/BAO/RecurringEntity.php b/CRM/Core/BAO/RecurringEntity.php index cf5ee41829..31853c8845 100644 --- a/CRM/Core/BAO/RecurringEntity.php +++ b/CRM/Core/BAO/RecurringEntity.php @@ -155,7 +155,7 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { * @return object */ public static function add(&$params) { - if (CRM_Utils_Array::value('id', $params)) { + if (!empty($params['id'])) { CRM_Utils_Hook::pre('edit', 'RecurringEntity', $params['id'], $params); } else { @@ -167,7 +167,7 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { $daoRecurringEntity->find(TRUE); $result = $daoRecurringEntity->save(); - if (CRM_Utils_Array::value('id', $params)) { + if (!empty($params['id'])) { CRM_Utils_Hook::post('edit', 'RecurringEntity', $daoRecurringEntity->id, $daoRecurringEntity); } else { @@ -843,39 +843,39 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { */ public function mapFormValuesToDB($formParams = array()) { $dbParams = array(); - if (CRM_Utils_Array::value('used_for', $formParams)) { + if (!empty($formParams['used_for'])) { $dbParams['used_for'] = $formParams['used_for']; } - if (CRM_Utils_Array::value('entity_id', $formParams)) { + if (!empty($formParams['entity_id'])) { $dbParams['entity_value'] = $formParams['entity_id']; } - if (CRM_Utils_Array::value('repetition_start_date', $formParams)) { - if (CRM_Utils_Array::value('repetition_start_date_display', $formParams)) { + if (!empty($formParams['repetition_start_date'])) { + if (!empty($formParams['repetition_start_date_display'])) { $repetitionStartDate = $formParams['repetition_start_date_display']; } else { $repetitionStartDate = $formParams['repetition_start_date']; } - if (CRM_Utils_Array::value('repetition_start_date_time', $formParams)) { + if (!empty($formParams['repetition_start_date_time'])) { $repetitionStartDate = $repetitionStartDate . " " . $formParams['repetition_start_date_time']; } $repetition_start_date = new DateTime($repetitionStartDate); $dbParams['start_action_date'] = CRM_Utils_Date::processDate($repetition_start_date->format('Y-m-d H:i:s')); } - if (CRM_Utils_Array::value('repetition_frequency_unit', $formParams)) { + if (!empty($formParams['repetition_frequency_unit'])) { $dbParams['repetition_frequency_unit'] = $formParams['repetition_frequency_unit']; } - if (CRM_Utils_Array::value('repetition_frequency_interval', $formParams)) { + if (!empty($formParams['repetition_frequency_interval'])) { $dbParams['repetition_frequency_interval'] = $formParams['repetition_frequency_interval']; } //For Repeats on:(weekly case) if ($formParams['repetition_frequency_unit'] == 'week') { - if (CRM_Utils_Array::value('start_action_condition', $formParams)) { + if (!empty($formParams['start_action_condition'])) { $repeats_on = CRM_Utils_Array::value('start_action_condition', $formParams); $dbParams['start_action_condition'] = implode(",", array_keys($repeats_on)); } @@ -884,7 +884,7 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { //For Repeats By:(monthly case) if ($formParams['repetition_frequency_unit'] == 'month') { if ($formParams['repeats_by'] == 1) { - if (CRM_Utils_Array::value('limit_to', $formParams)) { + if (!empty($formParams['limit_to'])) { $dbParams['limit_to'] = $formParams['limit_to']; } } @@ -897,14 +897,14 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { //For "Ends" - After: if ($formParams['ends'] == 1) { - if (CRM_Utils_Array::value('start_action_offset', $formParams)) { + if (!empty($formParams['start_action_offset'])) { $dbParams['start_action_offset'] = $formParams['start_action_offset']; } } //For "Ends" - On: if ($formParams['ends'] == 2) { - if (CRM_Utils_Array::value('repeat_absolute_date', $formParams)) { + if (!empty($formParams['repeat_absolute_date'])) { $dbParams['absolute_date'] = CRM_Utils_Date::processDate($formParams['repeat_absolute_date']); } } @@ -1046,7 +1046,7 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { $r->count($scheduleReminderDetails['start_action_offset']); } - if (CRM_Utils_Array::value('absolute_date', $scheduleReminderDetails)) { + if (!empty($scheduleReminderDetails['absolute_date'])) { $absoluteDate = CRM_Utils_Date::setDateDefaults($scheduleReminderDetails['absolute_date']); $endDate = new DateTime($absoluteDate[0] . ' ' . $absoluteDate[1]); $endDate->modify('+1 day'); @@ -1140,7 +1140,7 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { ); $defaults = array(); CRM_Core_DAO::commonRetrieve($dao, $params, $defaults); - if (CRM_Utils_Array::value('id', $defaults)) { + if (!empty($defaults['id'])) { $result['entityId'] = $defaults['id']; $result['entityTable'] = $entityTable; } diff --git a/CRM/Core/Form/RecurringEntity.php b/CRM/Core/Form/RecurringEntity.php index ab9a3f466c..f3247fe269 100644 --- a/CRM/Core/Form/RecurringEntity.php +++ b/CRM/Core/Form/RecurringEntity.php @@ -250,15 +250,15 @@ class CRM_Core_Form_RecurringEntity { if ($values['allowRepeatConfigToSubmit'] == 1) { $dayOfTheWeek = array('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'); //Repeats - if (!CRM_Utils_Array::value('repetition_frequency_unit', $values)) { + if (empty($values['repetition_frequency_unit'])) { $errors['repetition_frequency_unit'] = ts('This is a required field'); } //Repeats every - if (!CRM_Utils_Array::value('repetition_frequency_interval', $values)) { + if (empty($values['repetition_frequency_interval'])) { $errors['repetition_frequency_interval'] = ts('This is a required field'); } //Ends - if (CRM_Utils_Array::value('ends', $values)) { + if (!empty($values['ends'])) { if ($values['ends'] == 1) { if (empty($values['start_action_offset'])) { $errors['start_action_offset'] = ts('This is a required field'); @@ -268,7 +268,7 @@ class CRM_Core_Form_RecurringEntity { } } if ($values['ends'] == 2) { - if (CRM_Utils_Array::value('repeat_absolute_date', $values)) { + if (!empty($values['repeat_absolute_date'])) { $entityStartDate = CRM_Utils_Date::processDate($values['repetition_start_date']); $end = CRM_Utils_Date::processDate($values['repeat_absolute_date']); if (($end < $entityStartDate) && ($end != 0)) { @@ -285,9 +285,9 @@ class CRM_Core_Form_RecurringEntity { } //Repeats BY - if (CRM_Utils_Array::value('repeats_by', $values)) { + if (!empty($values['repeats_by'])) { if ($values['repeats_by'] == 1) { - if (CRM_Utils_Array::value('limit_to', $values)) { + if (!empty($values['limit_to'])) { if ($values['limit_to'] < 1 && $values['limit_to'] > 31) { $errors['limit_to'] = ts('Invalid day of the month'); } @@ -297,7 +297,7 @@ class CRM_Core_Form_RecurringEntity { } } if ($values['repeats_by'] == 2) { - if (CRM_Utils_Array::value('entity_status_1', $values)) { + if (!empty($values['entity_status_1'])) { $dayOfTheWeekNo = array('first', 'second', 'third', 'fourth', 'last'); if (!in_array($values['entity_status_1'], $dayOfTheWeekNo)) { $errors['entity_status_1'] = ts('Invalid option'); @@ -306,7 +306,7 @@ class CRM_Core_Form_RecurringEntity { else { $errors['entity_status_1'] = ts('Invalid option'); } - if (CRM_Utils_Array::value('entity_status_2', $values)) { + if (!empty($values['entity_status_2'])) { if (!in_array($values['entity_status_2'], $dayOfTheWeek)) { $errors['entity_status_2'] = ts('Invalid day name'); } @@ -328,17 +328,17 @@ class CRM_Core_Form_RecurringEntity { */ public static function postProcess($params = array(), $type, $linkedEntities = array()) { //Check entity_id not present in params take it from class variable - if (!CRM_Utils_Array::value('entity_id', $params)) { + if (empty($params['entity_id'])) { $params['entity_id'] = self::$_entityId; } //Process this function only when you get this variable if ($params['allowRepeatConfigToSubmit'] == 1) { if (CRM_Utils_Array::value('entity_table', $params) && CRM_Utils_Array::value('entity_id', $params) && $type) { $params['used_for'] = $type; - if (!CRM_Utils_Array::value('parent_entity_id', $params)) { + if (empty($params['parent_entity_id'])) { $params['parent_entity_id'] = self::$_parentEntityId; } - if (CRM_Utils_Array::value('schedule_reminder_id', $params)) { + if (!empty($params['schedule_reminder_id'])) { $params['id'] = $params['schedule_reminder_id']; } else { @@ -350,7 +350,7 @@ class CRM_Core_Form_RecurringEntity { $dbParams = $recurobj->mapFormValuesToDB($params); //Delete repeat configuration and rebuild - if (CRM_Utils_Array::value('id', $params)) { + if (!empty($params['id'])) { CRM_Core_BAO_ActionSchedule::del($params['id']); unset($params['id']); } @@ -468,7 +468,7 @@ class CRM_Core_Form_RecurringEntity { $recursion->excludeDates = $excludeDateList; $recursion->excludeDateRangeColumns = $params['excludeDateRangeColumns']; } - if (CRM_Utils_Array::value('intervalDateColumns', $params)) { + if (!empty($params['intervalDateColumns'])) { $recursion->intervalDateColumns = $params['intervalDateColumns']; } $recursion->entity_id = $params['entity_id']; diff --git a/CRM/Core/Page/AJAX/RecurringEntity.php b/CRM/Core/Page/AJAX/RecurringEntity.php index 726fcc0ddd..7265eeda26 100644 --- a/CRM/Core/Page/AJAX/RecurringEntity.php +++ b/CRM/Core/Page/AJAX/RecurringEntity.php @@ -20,7 +20,7 @@ class CRM_Core_Page_AJAX_RecurringEntity { $entityId = CRM_Utils_Type::escape($_REQUEST['entityId'], 'Integer'); $entityTable = CRM_Utils_Type::escape($_REQUEST['entityTable'], 'String'); - if (CRM_Utils_Array::value('linkedEntityTable', $_REQUEST)) { + if (!empty($_REQUEST['linkedEntityTable'])) { $result = CRM_Core_BAO_RecurringEntity::updateModeLinkedEntity($entityId, $_REQUEST['linkedEntityTable'], $entityTable); } diff --git a/CRM/Dedupe/BAO/RuleGroup.php b/CRM/Dedupe/BAO/RuleGroup.php index f8dca07695..32befd8c0a 100644 --- a/CRM/Dedupe/BAO/RuleGroup.php +++ b/CRM/Dedupe/BAO/RuleGroup.php @@ -390,7 +390,7 @@ class CRM_Dedupe_BAO_RuleGroup extends CRM_Dedupe_DAO_RuleGroup { public static function dedupeRuleFieldsWeight($params) { $rgBao = new CRM_Dedupe_BAO_RuleGroup(); $rgBao->contact_type = $params['contact_type']; - if (CRM_Utils_Array::value('id', $params)) { + if (!empty($params['id'])) { // accept an ID if provided $rgBao->id = $params['id']; } diff --git a/CRM/Event/Form/ParticipantFeeSelection.php b/CRM/Event/Form/ParticipantFeeSelection.php index 178fbea43e..7aa096163b 100644 --- a/CRM/Event/Form/ParticipantFeeSelection.php +++ b/CRM/Event/Form/ParticipantFeeSelection.php @@ -241,7 +241,7 @@ class CRM_Event_Form_ParticipantFeeSelection extends CRM_Core_Form { CRM_Event_BAO_Participant::changeFeeSelections($params, $this->_participantId, $this->_contributionId, $feeBlock, $lineItems, $this->_paidAmount, $params['priceSetId']); $this->contributionAmt = CRM_Core_DAO::getFieldValue('CRM_Contribute_BAO_Contribution', $this->_contributionId, 'total_amount'); // email sending - if (CRM_Utils_Array::value('send_receipt', $params)) { + if (!empty($params['send_receipt'])) { $fetchParticipantVals = array('id' => $this->_participantId); CRM_Event_BAO_Participant::getValues($fetchParticipantVals, $participantDetails, CRM_Core_DAO::$_nullArray); $participantParams = array_merge($params, $participantDetails[$this->_participantId]); diff --git a/CRM/Price/BAO/PriceSet.php b/CRM/Price/BAO/PriceSet.php index 577105ed32..e0a6e90f06 100644 --- a/CRM/Price/BAO/PriceSet.php +++ b/CRM/Price/BAO/PriceSet.php @@ -1068,7 +1068,7 @@ WHERE id = %1"; foreach ($params['price_set_id'] as $priceSetID) { CRM_Price_BAO_PriceSet::addTo('civicrm_' . $entityName, $entity->id, $priceSetID); //@todo - how should we do this - copied from form - //if (CRM_Utils_Array::value('price_field_id', $params)) { + //if (!empty($params['price_field_id'])) { // $priceSetID = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', $params['price_field_id'], 'price_set_id'); // CRM_Price_BAO_PriceSet::setIsQuickConfig($priceSetID, 0); //} diff --git a/CRM/Report/BAO/ReportInstance.php b/CRM/Report/BAO/ReportInstance.php index 3e184f5945..dbd180330e 100644 --- a/CRM/Report/BAO/ReportInstance.php +++ b/CRM/Report/BAO/ReportInstance.php @@ -209,7 +209,7 @@ class CRM_Report_BAO_ReportInstance extends CRM_Report_DAO_ReportInstance { $chart = "&charts=" . $params['charts']; } $limitResult = NULL; - if (CRM_Utils_Array::value('row_count', $params)) { + if (!empty($params['row_count'])) { $limitResult = '&rowCount=' . $params['row_count']; } $dashletParams['name'] = "report/{$instance->id}";