From af131476bacabc2187ddeae2efdd15124c73cae9 Mon Sep 17 00:00:00 2001 From: Omar abu hussein Date: Fri, 27 Jul 2018 17:32:49 +0100 Subject: [PATCH 001/121] dev/core#288 : Use membership actuall end date on pending payment completion --- CRM/Contribute/BAO/Contribution.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index bd1d1d452ef5..ac2068dfcd70 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -2008,7 +2008,7 @@ public static function transitionComponents($params, $processContributionObject ); } - $updateResult['membership_end_date'] = CRM_Utils_Date::customFormat($dates['end_date'], + $updateResult['membership_end_date'] = CRM_Utils_Date::customFormat($membership->end_date, '%B %E%f, %Y' ); $updateResult['updatedComponents']['CiviMember'] = $membership->status_id; From 6bc9b1f60b82eaf6267f6c708d4cf1408de13662 Mon Sep 17 00:00:00 2001 From: Francis Whittle Date: Fri, 12 Oct 2018 16:36:14 +1100 Subject: [PATCH 002/121] CIVICRM-990: Quote fee levels for regular expression in Participant search. --- CRM/Event/BAO/Query.php | 4 +++- CRM/Event/Form/Search.php | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CRM/Event/BAO/Query.php b/CRM/Event/BAO/Query.php index 1f96e40b1924..7d90935bc61f 100644 --- a/CRM/Event/BAO/Query.php +++ b/CRM/Event/BAO/Query.php @@ -340,11 +340,13 @@ public static function whereClauseSingle(&$values, &$query) { return; case 'participant_fee_id': + $val_regexp = []; foreach ($value as $k => &$val) { $val = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceFieldValue', $val, 'label'); + $val_regexp[$k] = CRM_Core_DAO::escapeString(preg_quote(trim($val))); $val = CRM_Core_DAO::escapeString(trim($val)); } - $feeLabel = implode('|', $value); + $feeLabel = implode('|', $val_regexp); $query->_where[$grouping][] = "civicrm_participant.fee_level REGEXP '{$feeLabel}'"; $query->_qill[$grouping][] = ts("Fee level") . " IN " . implode(', ', $value); $query->_tables['civicrm_participant'] = $query->_whereTables['civicrm_participant'] = 1; diff --git a/CRM/Event/Form/Search.php b/CRM/Event/Form/Search.php index c5b73d81403b..a1421cbe3a9f 100644 --- a/CRM/Event/Form/Search.php +++ b/CRM/Event/Form/Search.php @@ -209,11 +209,13 @@ public function buildQuickForm() { // CRM-15379 if (!empty($this->_formValues['participant_fee_id'])) { $participant_fee_id = $this->_formValues['participant_fee_id']; + $val_regexp = []; foreach ($participant_fee_id as $k => &$val) { $val = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceFieldValue', $val, 'label'); + $val_regexp[$k] = CRM_Core_DAO::escapeString(preg_quote(trim($val))); $val = CRM_Core_DAO::escapeString(trim($val)); } - $feeLabel = implode('|', $participant_fee_id); + $feeLabel = implode('|', $val_regexp); $seatClause[] = "( participant.fee_level REGEXP '{$feeLabel}' )"; } From 2e40be0a16fb3f741a28d8caea030fd7322eb81a Mon Sep 17 00:00:00 2001 From: Omar abu hussein Date: Thu, 15 Nov 2018 23:48:44 +0200 Subject: [PATCH 003/121] dev/core#288: Move membership end date notification format to transitionComponentWithReturnMessage method --- CRM/Contribute/BAO/Contribution.php | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index ac2068dfcd70..c0c2916fabb5 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -2008,9 +2008,6 @@ public static function transitionComponents($params, $processContributionObject ); } - $updateResult['membership_end_date'] = CRM_Utils_Date::customFormat($membership->end_date, - '%B %E%f, %Y' - ); $updateResult['updatedComponents']['CiviMember'] = $membership->status_id; if ($processContributionObject) { $processContribution = TRUE; @@ -5223,7 +5220,7 @@ public static function transitionComponentWithReturnMessage($contributionId, $st $statusMsg .= "
" . ts("Membership for %1 has been Expired.", array(1 => $userDisplayName)); } else { - $endDate = CRM_Utils_Array::value('membership_end_date', $updateResult); + $endDate = self::getFormattedMembershipEndDateFromContributionId($contributionId); if ($endDate) { $statusMsg .= "
" . ts("Membership for %1 has been updated. The membership End Date is %2.", array( @@ -5266,6 +5263,25 @@ public static function transitionComponentWithReturnMessage($contributionId, $st return $statusMsg; } + private static function getFormattedMembershipEndDateFromContributionId($contributionId) { + $endDateResponse = civicrm_api3('MembershipPayment', 'get', [ + 'sequential' => 1, + 'contribution_id' => $contributionId, + 'api.Membership.get' => ['id' => '$value.id', 'return' => ['end_date']], + 'options' => ['limit' => 1, 'sort' => 'id DESC'], + ]); + + $endDate = NULL; + if (!empty($endDateResponse['values'][0]['api.Membership.get']['count'])) { + $endDate = $endDateResponse['values'][0]['api.Membership.get']['values'][0]['end_date']; + $endDate = CRM_Utils_Date::customFormat($endDate, + '%B %E%f, %Y' + ); + } + + return $endDate; + } + /** * Get the contribution as it is in the database before being updated. * From ec5480d9f0ed2fbce2ecb38723a3067da81b7bde Mon Sep 17 00:00:00 2001 From: Omar abu hussein Date: Fri, 16 Nov 2018 12:09:55 +0000 Subject: [PATCH 004/121] dev/core#288 Removing the date from the membership update notification --- CRM/Contribute/BAO/Contribution.php | 44 ++++++----------------------- 1 file changed, 9 insertions(+), 35 deletions(-) diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index c0c2916fabb5..854f73c24e1a 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -5213,23 +5213,16 @@ public static function transitionComponentWithReturnMessage($contributionId, $st $updatedStatusName = CRM_Utils_Array::value($updatedStatusId, CRM_Member_PseudoConstant::membershipStatus() ); - if ($updatedStatusName == 'Cancelled') { - $statusMsg .= "
" . ts("Membership for %1 has been Cancelled.", array(1 => $userDisplayName)); - } - elseif ($updatedStatusName == 'Expired') { - $statusMsg .= "
" . ts("Membership for %1 has been Expired.", array(1 => $userDisplayName)); - } - else { - $endDate = self::getFormattedMembershipEndDateFromContributionId($contributionId); - if ($endDate) { - $statusMsg .= "
" . ts("Membership for %1 has been updated. The membership End Date is %2.", - array( - 1 => $userDisplayName, - 2 => $endDate, - ) - ); - } + + $statusNameMsgPart = 'updated'; + switch ($updatedStatusName) { + case 'Cancelled': + case 'Expired': + $statusNameMsgPart = $updatedStatusName; + break; } + + $statusMsg .= "
" . ts("Membership for %1 has been %2.", array(1 => $userDisplayName, 2 => $statusNameMsgPart)); } if ($componentName == 'CiviEvent') { @@ -5263,25 +5256,6 @@ public static function transitionComponentWithReturnMessage($contributionId, $st return $statusMsg; } - private static function getFormattedMembershipEndDateFromContributionId($contributionId) { - $endDateResponse = civicrm_api3('MembershipPayment', 'get', [ - 'sequential' => 1, - 'contribution_id' => $contributionId, - 'api.Membership.get' => ['id' => '$value.id', 'return' => ['end_date']], - 'options' => ['limit' => 1, 'sort' => 'id DESC'], - ]); - - $endDate = NULL; - if (!empty($endDateResponse['values'][0]['api.Membership.get']['count'])) { - $endDate = $endDateResponse['values'][0]['api.Membership.get']['values'][0]['end_date']; - $endDate = CRM_Utils_Date::customFormat($endDate, - '%B %E%f, %Y' - ); - } - - return $endDate; - } - /** * Get the contribution as it is in the database before being updated. * From 882bd8cb3d845f5545248662a1a031ac506eca35 Mon Sep 17 00:00:00 2001 From: "Matthew Wire (MJW Consulting)" Date: Mon, 4 Mar 2019 14:11:44 +0000 Subject: [PATCH 005/121] Add billingblock region to event registration confirm/thankyou to match contribution confirm/thankyou --- templates/CRM/Event/Form/Registration/Confirm.tpl | 14 ++++++++------ templates/CRM/Event/Form/Registration/ThankYou.tpl | 14 ++++++++------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/templates/CRM/Event/Form/Registration/Confirm.tpl b/templates/CRM/Event/Form/Registration/Confirm.tpl index f5d857828616..26398922f981 100644 --- a/templates/CRM/Event/Form/Registration/Confirm.tpl +++ b/templates/CRM/Event/Form/Registration/Confirm.tpl @@ -168,17 +168,19 @@ {/if} {if $contributeMode eq 'direct' and ! $is_pay_later and !$isAmountzero and !$isOnWaitlist and !$isRequireApproval} + {crmRegion name="event-confirm-billing-block"}
-
- {ts}Credit Card Information{/ts} -
-
-
{$credit_card_type}
+
+ {ts}Credit Card Information{/ts} +
+
+
{$credit_card_type}
{$credit_card_number}
-
{ts}Expires{/ts}: {$credit_card_exp_date|truncate:7:''|crmDate}
+
{if $credit_card_exp_date}{ts}Expires{/ts}: {$credit_card_exp_date|truncate:7:''|crmDate}{/if}
+ {/crmRegion} {/if} {if $contributeMode NEQ 'notify'} {* In 'notify mode, contributor is taken to processor payment forms next *} diff --git a/templates/CRM/Event/Form/Registration/ThankYou.tpl b/templates/CRM/Event/Form/Registration/ThankYou.tpl index cdf500de279f..72d6aa06b28b 100644 --- a/templates/CRM/Event/Form/Registration/ThankYou.tpl +++ b/templates/CRM/Event/Form/Registration/ThankYou.tpl @@ -189,17 +189,19 @@ {/if} {if $contributeMode eq 'direct' and $paidEvent and ! $is_pay_later and !$isAmountzero and !$isOnWaitlist and !$isRequireApproval} + {crmRegion name="event-thankyou-billing-block"}
-
- {ts}Credit Card Information{/ts} -
-
-
{$credit_card_type}
+
+ {ts}Credit Card Information{/ts} +
+
+
{$credit_card_type}
{$credit_card_number}
-
{ts}Expires{/ts}: {$credit_card_exp_date|truncate:7:''|crmDate}
+
{if $credit_card_exp_date}{ts}Expires{/ts}: {$credit_card_exp_date|truncate:7:''|crmDate}{/if}
+ {/crmRegion} {/if} {if $event.thankyou_footer_text} From a4b6430d72c4324839e26211841047c26f28afd8 Mon Sep 17 00:00:00 2001 From: "Matthew Wire (MJW Consulting)" Date: Thu, 7 Mar 2019 19:43:28 +0000 Subject: [PATCH 006/121] Minor cleanup to contribution confirm billingblock for consistency --- templates/CRM/Contribute/Form/Contribution/Confirm.tpl | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/templates/CRM/Contribute/Form/Contribution/Confirm.tpl b/templates/CRM/Contribute/Form/Contribution/Confirm.tpl index bb48dddede92..ca76503344cf 100644 --- a/templates/CRM/Contribute/Form/Contribution/Confirm.tpl +++ b/templates/CRM/Contribute/Form/Contribution/Confirm.tpl @@ -281,10 +281,9 @@ {/if} {else}
-
{$credit_card_type|escape}
-
{$credit_card_number|escape}
-
{if $credit_card_exp_date}{ts}Expires{/ts}: {$credit_card_exp_date|truncate:7:''|crmDate}{/if}
+
{$credit_card_type}
+
{$credit_card_number}
+
{if $credit_card_exp_date}{ts}Expires{/ts}: {$credit_card_exp_date|truncate:7:''|crmDate}{/if}
{/if} From 28cfbff70d436446c348fefdf37b64ef8c47d0c7 Mon Sep 17 00:00:00 2001 From: Pradeep Nayak Date: Mon, 18 Mar 2019 12:17:47 +0000 Subject: [PATCH 007/121] dev/core/issues/806, Fixed DB error already exist when recording recurring payment having tax --- CRM/Contribute/BAO/ContributionRecur.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CRM/Contribute/BAO/ContributionRecur.php b/CRM/Contribute/BAO/ContributionRecur.php index 126cf8f67d95..af0dc48824a3 100644 --- a/CRM/Contribute/BAO/ContributionRecur.php +++ b/CRM/Contribute/BAO/ContributionRecur.php @@ -901,7 +901,7 @@ public static function updateOnNewPayment($recurringContributionID, $paymentStat */ protected static function isComplete($recurringContributionID, $installments) { $paidInstallments = CRM_Core_DAO::singleValueQuery( - 'SELECT count(*) FROM civicrm_contribution + 'SELECT count(*) FROM civicrm_contribution WHERE contribution_recur_id = %1 AND contribution_status_id = ' . CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed'), array(1 => array($recurringContributionID, 'Integer')) @@ -949,13 +949,13 @@ public static function calculateRecurLineItems($recurId, $total_amount, $financi $priceField = new CRM_Price_DAO_PriceField(); $priceField->id = $lineItem['price_field_id']; $priceField->find(TRUE); - $lineSets[$priceField->price_set_id][] = $lineItem; + $lineSets[$priceField->price_set_id][$lineItem['price_field_id']] = $lineItem; } } // CRM-19309 if more than one then just pass them through: elseif (count($lineItems) > 1) { foreach ($lineItems as $index => $lineItem) { - $lineSets[$index][] = $lineItem; + $lineSets[$index][$lineItem['price_field_id']] = $lineItem; } } From db04bdc9d5761df04dd4110e8394a1db4baefca2 Mon Sep 17 00:00:00 2001 From: Andrew Hunt Date: Mon, 18 Mar 2019 13:46:49 -0400 Subject: [PATCH 008/121] 5.12.0 release notes: raw from script --- release-notes/5.12.0.md | 387 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 387 insertions(+) create mode 100644 release-notes/5.12.0.md diff --git a/release-notes/5.12.0.md b/release-notes/5.12.0.md new file mode 100644 index 000000000000..608bed73e8f5 --- /dev/null +++ b/release-notes/5.12.0.md @@ -0,0 +1,387 @@ +# CiviCRM 5.12.0 + +Released April 3, 2019; + +- **[Features](#features)** +- **[Bugs resolved](#bugs)** +- **[Miscellany](#misc)** +- **[Credits](#credits)** + +## Features + +### Core CiviCRM + +- **CRM-21643 Missing Summary ([12337](https://github.com/civicrm/civicrm-core/pull/12337))** + +## Bugs resolved + +### Core CiviCRM + +- **dev/core#801 Fix from email on PDF Letters, such as Thank You Letters. ([13825](https://github.com/civicrm/civicrm-core/pull/13825))** + +- **dev/core#790 - Exclue menubar on frontend pages ([13820](https://github.com/civicrm/civicrm-core/pull/13820))** + +- **dev/core#659 Catch payment processor exceptions, log, hide, do not return 500 error ([13796](https://github.com/civicrm/civicrm-core/pull/13796))** + +- **Fix unrelased regression where activity date relative filters are ingnored in the rc ([13801](https://github.com/civicrm/civicrm-core/pull/13801))** + +- **(ops#878) (Fast)ArrayDecorator - Emit expected exception when using WP and strict PSR-16 ([13808](https://github.com/civicrm/civicrm-core/pull/13808))** + +- **Merge forward 5.11 => master ([13777](https://github.com/civicrm/civicrm-core/pull/13777))** + +- **Remove mcrypt system status check ([13770](https://github.com/civicrm/civicrm-core/pull/13770))** + +- **Fix api bug whereby 0 & '0' are not accepted as range parameters for BETWEEN ([13766](https://github.com/civicrm/civicrm-core/pull/13766))** + +- **Render Note field tokens correctly - they are already HTML. ([13283](https://github.com/civicrm/civicrm-core/pull/13283))** + +- **dev/core#644 fix from address before calling hook ([13776](https://github.com/civicrm/civicrm-core/pull/13776))** + +- **[REF] separate financial handling & component transitioning in Payment.create ([13756](https://github.com/civicrm/civicrm-core/pull/13756))** + +- **Fix typo in comments ([13771](https://github.com/civicrm/civicrm-core/pull/13771))** + +- **Removes redundant IF ([13769](https://github.com/civicrm/civicrm-core/pull/13769))** + +- **[REF] towards cleanup of update membership code ([13759](https://github.com/civicrm/civicrm-core/pull/13759))** + +- **Extract getSearchSQLParts function ([13735](https://github.com/civicrm/civicrm-core/pull/13735))** + +- **Convert activity_date_time field to datepicker and add support for url input ([13746](https://github.com/civicrm/civicrm-core/pull/13746))** + +- **Speed up contribution results by removing join on civicrm_financial_type table when rendering search results. ([13720](https://github.com/civicrm/civicrm-core/pull/13720))** + +- **Try and add data set example where email_on_hold / on_hold is NULL in… ([13765](https://github.com/civicrm/civicrm-core/pull/13765))** + +- **Upgrade Karma version to latest version ([13751](https://github.com/civicrm/civicrm-core/pull/13751))** + +- **Rationalise Activity api ACLs for consistency, to respect the hook & improve performance ([13664](https://github.com/civicrm/civicrm-core/pull/13664))** + +- **report clean up - remove redundant code ([13761](https://github.com/civicrm/civicrm-core/pull/13761))** + +- **dev/core#767 Add 'Cancelled / Refunded Date' and 'Cancellation / Refund Reason' ([13726](https://github.com/civicrm/civicrm-core/pull/13726))** + +- **5.11 ([13760](https://github.com/civicrm/civicrm-core/pull/13760))** + +- **reporting#8 - add thank-you dates to Contribution Summary/Detail reports ([13653](https://github.com/civicrm/civicrm-core/pull/13653))** + +- **[REF] extract getToFinancialAccount from CRM_Contribute_PseudoConstantt::contributionStatus ([13757](https://github.com/civicrm/civicrm-core/pull/13757))** + +- **[ref] Extract activity payment creation ([13695](https://github.com/civicrm/civicrm-core/pull/13695))** + +- **Fix Custom post outer div class on event registration form ([13753](https://github.com/civicrm/civicrm-core/pull/13753))** + +- **dev/core#770 - View Case Activity page displays disabled custom fields ([13741](https://github.com/civicrm/civicrm-core/pull/13741))** + +- **Clean up Payment.create function ([13690](https://github.com/civicrm/civicrm-core/pull/13690))** + +- **fix broken logic in CRM_Utils_System_DrupalBase::formatResourceUrl() ([13400](https://github.com/civicrm/civicrm-core/pull/13400))** + +- **5.11 ([13750](https://github.com/civicrm/civicrm-core/pull/13750))** + +- **merge 5.11 to master ([13747](https://github.com/civicrm/civicrm-core/pull/13747))** + +- **Allow viewing of cancelled recurring contributions ([13745](https://github.com/civicrm/civicrm-core/pull/13745))** + +- **Upgrader: Don't abort if state_province already exists ([13744](https://github.com/civicrm/civicrm-core/pull/13744))** + +- **dev/core#708, Fix Qill for Added by and Modified By ([13566](https://github.com/civicrm/civicrm-core/pull/13566))** + +- **Fix the invocation of post hook for ParticipantPayment ensuring that … ([13739](https://github.com/civicrm/civicrm-core/pull/13739))** + +- **Decommision getPartialPaymentTrxn function ([13718](https://github.com/civicrm/civicrm-core/pull/13718))** + +- **5.11 ([13740](https://github.com/civicrm/civicrm-core/pull/13740))** + +- **Status of test contribution is not fetched on ThankYou page. ([13724](https://github.com/civicrm/civicrm-core/pull/13724))** + +- **CiviCRM Membership Detail report, add column to display if membership is Primary or Inherited ([13736](https://github.com/civicrm/civicrm-core/pull/13736))** + +- **dev/core#769 - Fix for ZipArchive->open() PHP bug ([13728](https://github.com/civicrm/civicrm-core/pull/13728))** + +- **dev/core#748 Move UPPER() from sql to php domain ([13732](https://github.com/civicrm/civicrm-core/pull/13732))** + +- **5.11 ([13730](https://github.com/civicrm/civicrm-core/pull/13730))** + +- **[REF] Extract lines to add the pseudoconstant to the select ([13717](https://github.com/civicrm/civicrm-core/pull/13717))** + +- **Mark de.systopia.recentitems obsolete ([13729](https://github.com/civicrm/civicrm-core/pull/13729))** + +- **5.11 to master ([13722](https://github.com/civicrm/civicrm-core/pull/13722))** + +- **dev/core#561 Upgrade age_asof_date to datepicker in search ([13704](https://github.com/civicrm/civicrm-core/pull/13704))** + +- **Upgrade PHPWord ([13686](https://github.com/civicrm/civicrm-core/pull/13686))** + +- **[minor cleanup] reduce params passed to searchQuery ([13715](https://github.com/civicrm/civicrm-core/pull/13715))** + +- **Migrate date field to datepicker on ChangeCaseType form ([13701](https://github.com/civicrm/civicrm-core/pull/13701))** + +- **[REF] Extract recordPayment portion ([13692](https://github.com/civicrm/civicrm-core/pull/13692))** + +- **Merge 5.11 to master ([13710](https://github.com/civicrm/civicrm-core/pull/13710))** + +- **Move assign of currency for entityForm outside of foreach so order of fields don't matter ([13696](https://github.com/civicrm/civicrm-core/pull/13696))** + +- **[TEST FIX] Increase uniqueness in testSingleNowDates ([13705](https://github.com/civicrm/civicrm-core/pull/13705))** + +- **dev/core#735 Do not include product in search results if site has none ([13638](https://github.com/civicrm/civicrm-core/pull/13638))** + +- **Code cleanup - remove extraneous permissions clause ([13645](https://github.com/civicrm/civicrm-core/pull/13645))** + +- **Fix & test searchQuery order by to be less dependent on what is selected for search ([13680](https://github.com/civicrm/civicrm-core/pull/13680))** + +- **Add pseudoconstant for payment_processor_id to contributionrecur ([13702](https://github.com/civicrm/civicrm-core/pull/13702))** + +- **dev/core#739 Fix case detail report breaking when sorted by case type. ([13666](https://github.com/civicrm/civicrm-core/pull/13666))** + +- **Phase out CIVICRM_TEMP_FORCE_UTF8 ([13658](https://github.com/civicrm/civicrm-core/pull/13658))** + +- **[REF] minor refactor around retrieving processor id for recur ([13643](https://github.com/civicrm/civicrm-core/pull/13643))** + +- **Extract record refund function ([13694](https://github.com/civicrm/civicrm-core/pull/13694))** + +- **Migrate KAM smartmenus to core ([13582](https://github.com/civicrm/civicrm-core/pull/13582))** + +- **Revert "[REF] Extract record refund function" ([13693](https://github.com/civicrm/civicrm-core/pull/13693))** + +- **[REF] Extract record refund function ([13691](https://github.com/civicrm/civicrm-core/pull/13691))** + +- **Move pear/mail from packages to composer.json ([13289](https://github.com/civicrm/civicrm-core/pull/13289))** + +- **Do not attempt to store out-of-range street number ([13340](https://github.com/civicrm/civicrm-core/pull/13340))** + +- **[REF] Extract getSearchSQL from getSearchQuery. ([13668](https://github.com/civicrm/civicrm-core/pull/13668))** + +- **Use CRM_Utils_SQL_TempTable to drop and create table. ([13688](https://github.com/civicrm/civicrm-core/pull/13688))** + +- **Record change log entry when contact is moved to or restored from trash ([13276](https://github.com/civicrm/civicrm-core/pull/13276))** + +- **geocode job: Do not return more messages than can fit in the log data column ([13346](https://github.com/civicrm/civicrm-core/pull/13346))** + +- **Towards supporting EntityForm for 'View Action' ([13578](https://github.com/civicrm/civicrm-core/pull/13578))** + +- **dev/core#631 - Enable 'add new' by default on merge screen ([13588](https://github.com/civicrm/civicrm-core/pull/13588))** + +- **reporting#9: parity between getContactFields and getBasicContactFields ([13657](https://github.com/civicrm/civicrm-core/pull/13657))** + +- **dev/core#742 Fix XML parasing by swapping & for , ([13654](https://github.com/civicrm/civicrm-core/pull/13654))** + +- **only set custom field to null if it is really null, not string 'null' ([13042](https://github.com/civicrm/civicrm-core/pull/13042))** + +- **CiviMail: Fix reply forwarding for mailers with From: and Return-path: limitations ([12641](https://github.com/civicrm/civicrm-core/pull/12641))** + +- **CRM/Logging - Fix various bugs in schema parsing ([13441](https://github.com/civicrm/civicrm-core/pull/13441))** + +- **Force utf8mb4 query to throw exception as the check expects ([13682](https://github.com/civicrm/civicrm-core/pull/13682))** + +- **Minor code cleanup ([13687](https://github.com/civicrm/civicrm-core/pull/13687))** + +- **[NFC, test class] formatting, remove unused variables ([13634](https://github.com/civicrm/civicrm-core/pull/13634))** + +- **Refactor CRM_Utils_SQL_TempTable::build()->createWithQuery($sql) interface to support MEMORY tabls ([13644](https://github.com/civicrm/civicrm-core/pull/13644))** + +- **dev/core#746 Add in unit tests to ensure that where clause is as is w… ([13685](https://github.com/civicrm/civicrm-core/pull/13685))** + +- **5.11 ([13684](https://github.com/civicrm/civicrm-core/pull/13684))** + +- **Payment notification formatting, move greeting into table ([13669](https://github.com/civicrm/civicrm-core/pull/13669))** + +- **CRM/Logging - Fix log table exceptions ([13675](https://github.com/civicrm/civicrm-core/pull/13675))** + +- **test for reporting#10 ([13678](https://github.com/civicrm/civicrm-core/pull/13678))** + +- **reporting-11 - fix Soft Credit report with full group by ([13671](https://github.com/civicrm/civicrm-core/pull/13671))** + +- **5.11 to master ([13676](https://github.com/civicrm/civicrm-core/pull/13676))** + +- **REF Convert deprecated functions to buildOptions for case ([13364](https://github.com/civicrm/civicrm-core/pull/13364))** + +- **Switch additional payment form to use Payment.sendconfirmation api ([13649](https://github.com/civicrm/civicrm-core/pull/13649))** + +- **5.11 to master ([13661](https://github.com/civicrm/civicrm-core/pull/13661))** + +- **/dev/core#716 - Add decimals in Contribution Amount on Repeat Contrib… ([13659](https://github.com/civicrm/civicrm-core/pull/13659))** + +- **[REF] minor code cleanup - do not build order var just to hurt brains ([13650](https://github.com/civicrm/civicrm-core/pull/13650))** + +- **[REF] minor cleanup of groupBy definition. ([13656](https://github.com/civicrm/civicrm-core/pull/13656))** + +- **Update Payment Notification to use greeting, remove text to 'Please print this confirmation for your records. ([13655](https://github.com/civicrm/civicrm-core/pull/13655))** + +- **Payment.sendconfirmation api - add further tpl variables. ([13610](https://github.com/civicrm/civicrm-core/pull/13610))** + +- **Authorizenet test - reduce chance of intermittent fails ([13642](https://github.com/civicrm/civicrm-core/pull/13642))** + +- **[unused code cleanup] Remove unused 'signupType' url support ([13620](https://github.com/civicrm/civicrm-core/pull/13620))** + +- **Payment.sendconfirmation api - add further tpl variables. ([13609](https://github.com/civicrm/civicrm-core/pull/13609))** + +- **(dev/core#696) Changes to copied event phone and email reflects in or… ([13534](https://github.com/civicrm/civicrm-core/pull/13534))** + +- **5.11 ([13639](https://github.com/civicrm/civicrm-core/pull/13639))** + +- **Remove another instance of 'lower' ([13636](https://github.com/civicrm/civicrm-core/pull/13636))** + +- **dev/core#720 Remove median & mode stats from contribution summary in order to improve performance ([13630](https://github.com/civicrm/civicrm-core/pull/13630))** + +- **[Test changes] Mailing job test use ([13629](https://github.com/civicrm/civicrm-core/pull/13629))** + +- **Fix html2pdf default PDF format when multiple pdf_format are available. ([13543](https://github.com/civicrm/civicrm-core/pull/13543))** + +- ** EntityRef - standardize on PascalCase for entity name and fix minor bug ([13631](https://github.com/civicrm/civicrm-core/pull/13631))** + +- **[REF] Remove useless class CRM_Report_Form_Event ([13632](https://github.com/civicrm/civicrm-core/pull/13632))** + +- **Contribution/ContributionRecur metadata updates for EntityForm ([13579](https://github.com/civicrm/civicrm-core/pull/13579))** + +- **dev/core#720 [REF] refactor out components of contributionSummary function ([13607](https://github.com/civicrm/civicrm-core/pull/13607))** + +- **Standardize format for entityRef create links ([13628](https://github.com/civicrm/civicrm-core/pull/13628))** + +- **[Code cleanup] Remove unused $stationery_path parameter ([13624](https://github.com/civicrm/civicrm-core/pull/13624))** + +- **[REF] extract cancelled stats to own function ([13626](https://github.com/civicrm/civicrm-core/pull/13626))** + +- **[REF] Move entityRef filters into their respective BAOs ([13625](https://github.com/civicrm/civicrm-core/pull/13625))** + +- **[REF] extract basic soft credit stats to separate function ([13622](https://github.com/civicrm/civicrm-core/pull/13622))** + +- **[code cleanup] Default wrong declared ([13621](https://github.com/civicrm/civicrm-core/pull/13621))** + +- **[REF] Remove unused function parameter ([13619](https://github.com/civicrm/civicrm-core/pull/13619))** + +- **Remove long block of commented out code from 4 years ago ([13623](https://github.com/civicrm/civicrm-core/pull/13623))** + +- **Always load recaptcha JS over HTTPS ([13601](https://github.com/civicrm/civicrm-core/pull/13601))** + +- **If a profile is used to create a contact with a subtype the contact will not have any existing subtypes ([13499](https://github.com/civicrm/civicrm-core/pull/13499))** + +- **[Test support] Add extra output info when getsingle fails as this seems to be common in intermittant fails ([13618](https://github.com/civicrm/civicrm-core/pull/13618))** + +- **[REF] extract add median to stats ([13616](https://github.com/civicrm/civicrm-core/pull/13616))** + +- **Remove tests that no longer work due to dead service ([13617](https://github.com/civicrm/civicrm-core/pull/13617))** + +- **Fix (sometimes serious) performance problem on submitting profiles for specified contacts ([13606](https://github.com/civicrm/civicrm-core/pull/13606))** + +- **[REF] extract calculation of mode stat ([13614](https://github.com/civicrm/civicrm-core/pull/13614))** + +- **5.11 to master ([13615](https://github.com/civicrm/civicrm-core/pull/13615))** + +- **fixes core#580 - view all groups when appropriately permissioned ([13373](https://github.com/civicrm/civicrm-core/pull/13373))** + +- **Move l10n.js to coreResourcesList ([13612](https://github.com/civicrm/civicrm-core/pull/13612))** + +- **Add install and runtime status warnings if MySQL utf8mb4 is not supported ([13425](https://github.com/civicrm/civicrm-core/pull/13425))** + +- **[REF] extract calculation of basic stats ([13608](https://github.com/civicrm/civicrm-core/pull/13608))** + +- **[REF] Move addSelectWhere-like function to be located on BAO_Contribution ([13587](https://github.com/civicrm/civicrm-core/pull/13587))** + +- **[REF] Fix silly function to do less handling of non-existent scenarios ([13563](https://github.com/civicrm/civicrm-core/pull/13563))** + +- **Add in Exception API to support the refactor of Dedupe Exception Page ([13611](https://github.com/civicrm/civicrm-core/pull/13611))** + +- **fixes dev/core#683 Incorrectly encoded state and country names ([13591](https://github.com/civicrm/civicrm-core/pull/13591))** + +- **dev/core#720 add unit test, remove legacy code style. ([13605](https://github.com/civicrm/civicrm-core/pull/13605))** + +- **[REF] extract chunk of code to a separate function ([13600](https://github.com/civicrm/civicrm-core/pull/13600))** + +- **dev/core#657 - Add filter for country on Repeat Contributions Report ([13432](https://github.com/civicrm/civicrm-core/pull/13432))** + +- **5.11 to master ([13602](https://github.com/civicrm/civicrm-core/pull/13602))** + +- **(dev/core#705) Disabling Alphabetical Pager is not respected for cont… ([13592](https://github.com/civicrm/civicrm-core/pull/13592))** + +- **Add new Payment.sendconfirmation api ([13561](https://github.com/civicrm/civicrm-core/pull/13561))** + +- **Find Contributions columns/headers not aligned when "Contributions OR Soft Credits?" filter set to "Soft Credits Only" ([13517](https://github.com/civicrm/civicrm-core/pull/13517))** + +- **dev/report#7 fix trxn_date on bookkeeping report ([13571](https://github.com/civicrm/civicrm-core/pull/13571))** + +- **dev/core#684 - Case Manager not updating correctly ([13528](https://github.com/civicrm/civicrm-core/pull/13528))** + +- **dev/core#469 Fix Error on action 'Email - schedule/send via CiviMail' with multiple event names filter ([13539](https://github.com/civicrm/civicrm-core/pull/13539))** + +- **[REF} User api rather than selector for rendering contributions on user dashboard ([13584](https://github.com/civicrm/civicrm-core/pull/13584))** + +- **dev/core#397 Dedupe for Individual Birth Date Results in Error ([13538](https://github.com/civicrm/civicrm-core/pull/13538))** + +- **Improves styling on Joomla! upgrade screen ([13557](https://github.com/civicrm/civicrm-core/pull/13557))** + +- **dev/core/issues/714, Inline edit should be disabled if user doesn't have edit group permission ([13573](https://github.com/civicrm/civicrm-core/pull/13573))** + +- **dev/core#691 Make default country optional on setting form ([13523](https://github.com/civicrm/civicrm-core/pull/13523))** + +- **[REF] switch from (undeclared) class property to local variable. ([13583](https://github.com/civicrm/civicrm-core/pull/13583))** + +- **[REF] Minor readability cleanup ([13562](https://github.com/civicrm/civicrm-core/pull/13562))** + +- **Remove activitystatus js. Add submitOnce handler for activity create ([13342](https://github.com/civicrm/civicrm-core/pull/13342))** + +- **Bump minimum upgradable ver to 4.2.9 ([13580](https://github.com/civicrm/civicrm-core/pull/13580))** + +- **5.11 to master ([13585](https://github.com/civicrm/civicrm-core/pull/13585))** + +- **Fix typo and space ([13577](https://github.com/civicrm/civicrm-core/pull/13577))** + +- **5.11 to master ([13576](https://github.com/civicrm/civicrm-core/pull/13576))** + +- **Remove hurty free calls from campaign and case ([13564](https://github.com/civicrm/civicrm-core/pull/13564))** + +- **Fix contact ID help on advanced search ([13569](https://github.com/civicrm/civicrm-core/pull/13569))** + +- **Add unit test on getContributionBalance fn (#13187) ([13558](https://github.com/civicrm/civicrm-core/pull/13558))** + +- **dev/core#562 Remove free calls from Activity and Member sections of CRM ([13560](https://github.com/civicrm/civicrm-core/pull/13560))** + +- **Used buildoptions function to get all groups ([13327](https://github.com/civicrm/civicrm-core/pull/13327))** + +- **Show Add to group on create new report after refresh of result ([13404](https://github.com/civicrm/civicrm-core/pull/13404))** + +- **(REF) Rename variables and adjust variable definitions for Event Register form ([13287](https://github.com/civicrm/civicrm-core/pull/13287))** + +- **Optimize CRM_Core_BAO_FinancialTrxn::getTotalPayment ([13187](https://github.com/civicrm/civicrm-core/pull/13187))** + +- **CRM.loadScript improvements ([13555](https://github.com/civicrm/civicrm-core/pull/13555))** + +- **dev/core/issues/700, Show Qill when searched using contact id ([13549](https://github.com/civicrm/civicrm-core/pull/13549))** + +- **Make submitOnce() button js into a button parameter ([13333](https://github.com/civicrm/civicrm-core/pull/13333))** + +- **dev/core#690 - Civi\API - Fix entity permission check for trusted calls ([13529](https://github.com/civicrm/civicrm-core/pull/13529))** + +- **6.x-5.10 ([566](https://github.com/civicrm/civicrm-drupal/pull/566))** + +- **Port fix for dev/core#381 to custom file field handler file ([564](https://github.com/civicrm/civicrm-drupal/pull/564))** + +- **7.x 5.11 ([565](https://github.com/civicrm/civicrm-drupal/pull/565))** + +- **7.x 5.11 to master (no changes in here - just admin) ([562](https://github.com/civicrm/civicrm-drupal/pull/562))** + +- **Make address Supplemental line 3 available to views ([551](https://github.com/civicrm/civicrm-drupal/pull/551))** + +- **CMS path fix in wp-cli ([147](https://github.com/civicrm/civicrm-wordpress/pull/147))** + +- **(NFC) formatting changes ([148](https://github.com/civicrm/civicrm-wordpress/pull/148))** + +- **Merge forward: 1.x-5.11 => 1.x-master ([66](https://github.com/civicrm/civicrm-backdrop/pull/66))** + +- **Remove old menu plugin ([240](https://github.com/civicrm/civicrm-packages/pull/240))** + +- **"Only variable references should be returned by reference" notice in Mail_smtp ([220](https://github.com/civicrm/civicrm-packages/pull/220))** + +## Miscellany + +## Credits + +This release was developed by the following code authors: + +AGH Strategies - Alice Frumin, Andrew Hunt; Agileware - Alok Patel; alexymik; Australian Greens - Seamus Lee; avall-llovera; CiviCRM - Coleman Watts, Tim Otten; CiviDesk - Yashodha Chaku; Coop SymbioTIC - Mathieu Lutfy; Electronic Frontier Foundation - Mark Burdett; Francesc Bassas i Bullich; Fuzion - Jitendra Purohit; GreenPeace Central and Eastern Europe - Patrick Figel; JMA Consulting - Edsel Lopez, Monish Deb; Ken West; Lighthouse Design and Consulting - Brian Shaughnessy; Megaphone Technology Consulting - Jon Goldberg; MJW Consulting - Matthew Wire; Nicol Wistreich; Pradeep Nayak; Skvare - Mark Hanna; Squiffle Consulting - Aidan Saunders; Wikimedia Foundation - Eileen McNaughton + +Most authors also reviewed code for this release; in addition, the following +reviewers contributed their comments: + +AGH Strategies - Alice Frumin, Andrew Hunt; Agileware - Alok Patel, Justin Freeman; Australian Greens - Seamus Lee; awasson; Circle Interactive - Dave Jenkins; civibot[bot]; civicrm-builder; CiviCRM - Coleman Watts, Tim Otten; CiviDesk - Sunil Pawar, Yashodha Chaku; Coop SymbioTIC - Mathieu Lutfy; Dave D; Electronic Frontier Foundation - Mark Burdett; Francesc Bassas i Bullich; Fuzion - Jitendra Purohit, Peter Davis; GreenPeace Central and Eastern Europe - Patrick Figel; JMA Consulting - Joe Murray, Monish Deb; Lighthouse Design and Consulting - Brian Shaughnessy; Megaphone Technology Consulting - Jon Goldberg; MJCO - Mikey O'Toole; MJW Consulting - Matthew Wire; mwestergaard; Nicol Wistreich; Pradeep Nayak; Progressive Technology Project - Jamie McClelland; reecebenson; Richard van Oosterhout; Skvare - Mark Hanna; Squiffle Consulting - Aidan Saunders; Tadpole Collective - Kevin Cristiano; Third Sector Design - Michael McAndrew; Wikimedia Foundation - Eileen McNaughton \ No newline at end of file From 766b558fe6dbcaec89e2cc6ddfb78ba02f06d8e0 Mon Sep 17 00:00:00 2001 From: Andrew Hunt Date: Mon, 18 Mar 2019 13:57:16 -0400 Subject: [PATCH 009/121] 5.12.0 release notes: added boilerplate --- release-notes.md | 13 ++++++++++++- release-notes/5.12.0.md | 12 ++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/release-notes.md b/release-notes.md index 16a4767f91d6..9d85e58ec898 100644 --- a/release-notes.md +++ b/release-notes.md @@ -14,7 +14,18 @@ Other resources for identifying changes are: * https://github.com/civicrm/civicrm-joomla * https://github.com/civicrm/civicrm-wordpress -# CiviCRM 5.11.0 +## CiviCRM 5.12.0 + +Released April 3, 2019 + +- **[Synopsis](release-notes/5.12.0.md#synopsis)** +- **[Features](release-notes/5.12.0.md#features)** +- **[Bugs resolved](release-notes/5.12.0.md#bugs)** +- **[Miscellany](release-notes/5.12.0.md#misc)** +- **[Credits](release-notes/5.12.0.md#credits)** +- **[Feedback](release-notes/5.12.0.md#feedback)** + +## CiviCRM 5.11.0 Released March 6, 2019 diff --git a/release-notes/5.12.0.md b/release-notes/5.12.0.md index 608bed73e8f5..aa87553f8a92 100644 --- a/release-notes/5.12.0.md +++ b/release-notes/5.12.0.md @@ -1,11 +1,13 @@ # CiviCRM 5.12.0 -Released April 3, 2019; +Released April 3, 2019 +- **[Synopsis](#synopsis)** - **[Features](#features)** - **[Bugs resolved](#bugs)** - **[Miscellany](#misc)** - **[Credits](#credits)** +- **[Feedback](#feedback)** ## Features @@ -384,4 +386,10 @@ AGH Strategies - Alice Frumin, Andrew Hunt; Agileware - Alok Patel; alexymik; Au Most authors also reviewed code for this release; in addition, the following reviewers contributed their comments: -AGH Strategies - Alice Frumin, Andrew Hunt; Agileware - Alok Patel, Justin Freeman; Australian Greens - Seamus Lee; awasson; Circle Interactive - Dave Jenkins; civibot[bot]; civicrm-builder; CiviCRM - Coleman Watts, Tim Otten; CiviDesk - Sunil Pawar, Yashodha Chaku; Coop SymbioTIC - Mathieu Lutfy; Dave D; Electronic Frontier Foundation - Mark Burdett; Francesc Bassas i Bullich; Fuzion - Jitendra Purohit, Peter Davis; GreenPeace Central and Eastern Europe - Patrick Figel; JMA Consulting - Joe Murray, Monish Deb; Lighthouse Design and Consulting - Brian Shaughnessy; Megaphone Technology Consulting - Jon Goldberg; MJCO - Mikey O'Toole; MJW Consulting - Matthew Wire; mwestergaard; Nicol Wistreich; Pradeep Nayak; Progressive Technology Project - Jamie McClelland; reecebenson; Richard van Oosterhout; Skvare - Mark Hanna; Squiffle Consulting - Aidan Saunders; Tadpole Collective - Kevin Cristiano; Third Sector Design - Michael McAndrew; Wikimedia Foundation - Eileen McNaughton \ No newline at end of file +AGH Strategies - Alice Frumin, Andrew Hunt; Agileware - Alok Patel, Justin Freeman; Australian Greens - Seamus Lee; awasson; Circle Interactive - Dave Jenkins; civibot[bot]; civicrm-builder; CiviCRM - Coleman Watts, Tim Otten; CiviDesk - Sunil Pawar, Yashodha Chaku; Coop SymbioTIC - Mathieu Lutfy; Dave D; Electronic Frontier Foundation - Mark Burdett; Francesc Bassas i Bullich; Fuzion - Jitendra Purohit, Peter Davis; GreenPeace Central and Eastern Europe - Patrick Figel; JMA Consulting - Joe Murray, Monish Deb; Lighthouse Design and Consulting - Brian Shaughnessy; Megaphone Technology Consulting - Jon Goldberg; MJCO - Mikey O'Toole; MJW Consulting - Matthew Wire; mwestergaard; Nicol Wistreich; Pradeep Nayak; Progressive Technology Project - Jamie McClelland; reecebenson; Richard van Oosterhout; Skvare - Mark Hanna; Squiffle Consulting - Aidan Saunders; Tadpole Collective - Kevin Cristiano; Third Sector Design - Michael McAndrew; Wikimedia Foundation - Eileen McNaughton + +## Feedback + +These release notes are edited by Alice Frumin and Andrew Hunt. If you'd like +to provide feedback on them, please log in to https://chat.civicrm.org/civicrm +and contact `@agh1`. From d8bd20072f92df4e9bd7c8709c941364cba6fbd2 Mon Sep 17 00:00:00 2001 From: Pradeep Nayak Date: Mon, 18 Mar 2019 21:32:02 +0000 Subject: [PATCH 010/121] added unit test --- tests/phpunit/api/v3/ContributionTest.php | 27 +++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/phpunit/api/v3/ContributionTest.php b/tests/phpunit/api/v3/ContributionTest.php index b6df822f75e8..9b99b42f9fd6 100644 --- a/tests/phpunit/api/v3/ContributionTest.php +++ b/tests/phpunit/api/v3/ContributionTest.php @@ -4299,4 +4299,31 @@ public function testContributionGetUnique() { $this->assertEquals(array('invoice_id'), $result['values']['UI_contrib_invoice_id']); } + /** + * Test Repeat Transaction Contribution with Tax amount. + * https://lab.civicrm.org/dev/core/issues/806 + */ + public function testRepeatContributionWithTaxAmount() { + $this->enableTaxAndInvoicing(); + $financialType = $this->callAPISuccess('financial_type', 'create', [ + 'name' => 'Test taxable financial Type', + 'is_reserved' => 0, + 'is_active' => 1, + ]); + $this->relationForFinancialTypeWithFinancialAccount($financialType['id']); + $contribution = $this->setUpRepeatTransaction( + [], + 'single', + [ + 'financial_type_id' => $financialType['id'], + ] + ); + $this->callAPISuccess('contribution', 'repeattransaction', array( + 'original_contribution_id' => $contribution['id'], + 'contribution_status_id' => 'Completed', + 'trxn_id' => uniqid(), + )); + $this->callAPISuccessGetCount('Contribution', [], 2); + } + } From b9bb2511cc00cdcd052504df847f17b0c2174c7c Mon Sep 17 00:00:00 2001 From: Jitendra Purohit Date: Wed, 20 Mar 2019 11:32:22 +0530 Subject: [PATCH 011/121] Possible paypal fix to avoid sending 500 errors from ipn triggerred by one-off payment --- CRM/Core/Payment/PayPalProIPN.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CRM/Core/Payment/PayPalProIPN.php b/CRM/Core/Payment/PayPalProIPN.php index 369f7f0b3958..f93bac71d5d1 100644 --- a/CRM/Core/Payment/PayPalProIPN.php +++ b/CRM/Core/Payment/PayPalProIPN.php @@ -426,7 +426,7 @@ public function main() { CRM_Core_Error::debug_var('POST', $_POST, TRUE, TRUE); if ($this->_isPaymentExpress) { $this->handlePaymentExpress(); - return FALSE; + return; } $objects = $ids = $input = array(); $this->_component = $input['component'] = self::getValue('m'); @@ -557,6 +557,9 @@ public function handlePaymentExpress() { $objects = $ids = $input = array(); $isFirst = FALSE; $input['invoice'] = self::getValue('i', FALSE); + if (empty($input['invoice'])) { + return; + } $input['txnType'] = $this->retrieve('txn_type', 'String'); $contributionRecur = civicrm_api3('contribution_recur', 'getsingle', array( 'return' => 'contact_id, id, payment_processor_id', From 67aad585f38ba65b9d1d172a5857a5b23fa611ba Mon Sep 17 00:00:00 2001 From: Andrew Hunt Date: Wed, 27 Mar 2019 16:18:26 -0400 Subject: [PATCH 012/121] dev/core#655 Contribution detail report: don't sum on total amount --- CRM/Report/Form/Contribute/Detail.php | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/CRM/Report/Form/Contribute/Detail.php b/CRM/Report/Form/Contribute/Detail.php index 9796c52599b8..0923e68ab992 100644 --- a/CRM/Report/Form/Contribute/Detail.php +++ b/CRM/Report/Form/Contribute/Detail.php @@ -160,7 +160,6 @@ public function __construct() { 'total_amount' => array( 'title' => ts('Amount'), 'required' => TRUE, - 'statistics' => array('sum' => ts('Amount')), ), 'non_deductible_amount' => array( 'title' => ts('Non-deductible Amount'), @@ -697,7 +696,7 @@ public function alterDisplay(&$rows) { } // Contribution amount links to viewing contribution - if (($value = CRM_Utils_Array::value('civicrm_contribution_total_amount_sum', $row)) && + if (($value = CRM_Utils_Array::value('civicrm_contribution_total_amount', $row)) && CRM_Core_Permission::check('access CiviContribute') ) { $url = CRM_Utils_System::url("civicrm/contact/view/contribution", @@ -706,8 +705,8 @@ public function alterDisplay(&$rows) { "&action=view&context=contribution&selectedChild=contribute", $this->_absoluteUrl ); - $rows[$rowNum]['civicrm_contribution_total_amount_sum_link'] = $url; - $rows[$rowNum]['civicrm_contribution_total_amount_sum_hover'] = ts("View Details of this Contribution."); + $rows[$rowNum]['civicrm_contribution_total_amount_link'] = $url; + $rows[$rowNum]['civicrm_contribution_total_amount_hover'] = ts("View Details of this Contribution."); $entryFound = TRUE; } @@ -726,7 +725,7 @@ public function alterDisplay(&$rows) { array_key_exists('civicrm_contribution_contribution_id', $row) ) { $query = " -SELECT civicrm_contact_id, civicrm_contact_sort_name, civicrm_contribution_total_amount_sum, civicrm_contribution_currency +SELECT civicrm_contact_id, civicrm_contact_sort_name, civicrm_contribution_total_amount, civicrm_contribution_currency FROM {$this->temporaryTables['civireport_contribution_detail_temp2']['name']} WHERE civicrm_contribution_contribution_id={$row['civicrm_contribution_contribution_id']}"; $dao = CRM_Core_DAO::executeQuery($query); @@ -737,7 +736,7 @@ public function alterDisplay(&$rows) { $dao->civicrm_contact_id); $string = $string . ($string ? $separator : '') . "{$dao->civicrm_contact_sort_name} " . - CRM_Utils_Money::format($dao->civicrm_contribution_total_amount_sum, $dao->civicrm_contribution_currency); + CRM_Utils_Money::format($dao->civicrm_contribution_total_amount, $dao->civicrm_contribution_currency); } $rows[$rowNum]['civicrm_contribution_soft_credits'] = $string; } @@ -803,12 +802,6 @@ public function sectionTotals() { // pull section aliases out of $this->_sections $sectionAliases = array_keys($this->_sections); - // hack alert - but it's tested so go forth & make pretty, or whack the new mole that popped up with gay abandon. - if (in_array('civicrm_contribution_total_amount', $this->_selectAliases)) { - $keyToHack = array_search('civicrm_contribution_total_amount', $this->_selectAliases); - $this->_selectAliases[$keyToHack] = 'civicrm_contribution_total_amount_sum'; - } - $ifnulls = array(); foreach (array_merge($sectionAliases, $this->_selectAliases) as $alias) { $ifnulls[] = "ifnull($alias, '') as $alias"; @@ -823,10 +816,10 @@ public function sectionTotals() { $addtotals = ''; - if (array_search("civicrm_contribution_total_amount_sum", $this->_selectAliases) !== + if (array_search("civicrm_contribution_total_amount", $this->_selectAliases) !== FALSE ) { - $addtotals = ", sum(civicrm_contribution_total_amount_sum) as sumcontribs"; + $addtotals = ", sum(civicrm_contribution_total_amount) as sumcontribs"; $showsumcontribs = TRUE; } From cdc61ccc40cabb365098f23b2527ff812426c1c8 Mon Sep 17 00:00:00 2001 From: Andrew Hunt Date: Thu, 28 Mar 2019 10:18:05 -0400 Subject: [PATCH 013/121] dev/core#655 Contrib detail report: format amount now that not sum --- CRM/Report/Form/Contribute/Detail.php | 29 +++++++++++++++++---------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/CRM/Report/Form/Contribute/Detail.php b/CRM/Report/Form/Contribute/Detail.php index 0923e68ab992..929d8a5bc07a 100644 --- a/CRM/Report/Form/Contribute/Detail.php +++ b/CRM/Report/Form/Contribute/Detail.php @@ -696,17 +696,24 @@ public function alterDisplay(&$rows) { } // Contribution amount links to viewing contribution - if (($value = CRM_Utils_Array::value('civicrm_contribution_total_amount', $row)) && - CRM_Core_Permission::check('access CiviContribute') - ) { - $url = CRM_Utils_System::url("civicrm/contact/view/contribution", - "reset=1&id=" . $row['civicrm_contribution_contribution_id'] . - "&cid=" . $row['civicrm_contact_id'] . - "&action=view&context=contribution&selectedChild=contribute", - $this->_absoluteUrl - ); - $rows[$rowNum]['civicrm_contribution_total_amount_link'] = $url; - $rows[$rowNum]['civicrm_contribution_total_amount_hover'] = ts("View Details of this Contribution."); + if ($value = CRM_Utils_Array::value('civicrm_contribution_total_amount', $row)) { + $rows[$rowNum]['civicrm_contribution_total_amount'] = CRM_Utils_Money::format($value, $row['civicrm_contribution_currency']); + if (CRM_Core_Permission::check('access CiviContribute')) { + $url = CRM_Utils_System::url( + "civicrm/contact/view/contribution", + [ + 'reset' => 1, + 'id' => $row['civicrm_contribution_contribution_id'], + 'cid' => $row['civicrm_contact_id'], + 'action' => 'view', + 'context' => 'contribution', + 'selectedChild' => 'contribute', + ], + $this->_absoluteUrl + ); + $rows[$rowNum]['civicrm_contribution_total_amount_link'] = $url; + $rows[$rowNum]['civicrm_contribution_total_amount_hover'] = ts("View Details of this Contribution."); + } $entryFound = TRUE; } From 76faaa00c8c74b64ee43dbacecbccbc5c827b130 Mon Sep 17 00:00:00 2001 From: Andrew Hunt Date: Thu, 28 Mar 2019 10:45:05 -0400 Subject: [PATCH 014/121] dev/core#655 contrib detail report: no soft credit join if contribs only The `contribution_or_soft_value` always has a value, so the soft credit table was always joined. --- CRM/Report/Form/Contribute/Detail.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CRM/Report/Form/Contribute/Detail.php b/CRM/Report/Form/Contribute/Detail.php index 929d8a5bc07a..1106772d81f5 100644 --- a/CRM/Report/Form/Contribute/Detail.php +++ b/CRM/Report/Form/Contribute/Detail.php @@ -961,7 +961,8 @@ public function appendAdditionalFromJoins() { * Add join to the soft credit table. */ protected function joinContributionToSoftCredit() { - if (!CRM_Utils_Array::value('contribution_or_soft_value', $this->_params) && !$this->isTableSelected('civicrm_contribution_soft')) { + if (CRM_Utils_Array::value('contribution_or_soft_value', $this->_params) == 'contributions_only' + && !$this->isTableSelected('civicrm_contribution_soft')) { return; } $joinType = ' LEFT '; From 8acea9546f8c4d1f75d3705069d236147ddbbdf3 Mon Sep 17 00:00:00 2001 From: Andrew Hunt Date: Thu, 28 Mar 2019 12:20:33 -0400 Subject: [PATCH 015/121] dev/core#655 contrib detail report: test total w/ multiple soft credits --- .../CRM/Report/Form/Contribute/DetailTest.php | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/tests/phpunit/CRM/Report/Form/Contribute/DetailTest.php b/tests/phpunit/CRM/Report/Form/Contribute/DetailTest.php index 835f37462d10..acea3ddb8845 100644 --- a/tests/phpunit/CRM/Report/Form/Contribute/DetailTest.php +++ b/tests/phpunit/CRM/Report/Form/Contribute/DetailTest.php @@ -152,4 +152,64 @@ public function testPostalCodeSearchReportOutput($reportClass, $inputParams, $da $this->assertCsvArraysEqual($expectedOutputCsvArray, $reportCsvArray); } + /** + * Make sure the total amount of a contribution doesn't multiply by the number + * of soft credits. + */ + public function testMultipleSoftCredits() { + $this->quickCleanup($this->_tablesToTruncate); + + $solParams = array( + 'first_name' => 'Solicitor 1', + 'last_name' => 'User ' . rand(), + 'contact_type' => 'Individual', + ); + $solicitor1Id = $this->individualCreate($solParams); + $solParams['first_name'] = 'Solicitor 2'; + $solicitor2Id = $this->individualCreate($solParams); + $solParams['first_name'] = 'Donor'; + $donorId = $this->individualCreate($solParams); + + $contribParams = [ + 'total_amount' => 150, + 'contact_id' => $donorId, + // TODO: We're getting a "DB Error: already exists" when inserting a line + // item, but that's beside the point for this test, so skipping. + 'skipLineItem' => 1, + ]; + $contribId = $this->contributionCreate($contribParams); + + // Add two soft credits on the same contribution. + $softParams = [ + 'contribution_id' => $contribId, + 'amount' => 150, + 'contact_id' => $solicitor1Id, + 'soft_credit_type_id' => 1, + ]; + $this->callAPISuccess('ContributionSoft', 'create', $softParams); + $softParams['contact_id'] = $solicitor2Id; + $softParams['amount'] = 100; + $this->callAPISuccess('ContributionSoft', 'create', $softParams); + + $input = [ + 'filters' => [ + 'contribution_or_soft_op' => 'eq', + 'contribution_or_soft_value' => 'contributions_only', + ], + 'fields' => [ + 'sort_name', + 'email', + 'phone', + 'financial_type_id', + 'receive_date', + 'total_amount', + 'soft_credits', + ], + ]; + $obj = $this->getReportObject('CRM_Report_Form_Contribute_Detail', $input); + $rows = $obj->getResultSet(); + $this->assertEquals(1, count($rows)); + $this->assertEquals('$ 150.00', $rows[0]['civicrm_contribution_total_amount']); + } + } From 477be9cc9b981b98f90098c41f8906b3e5b932d0 Mon Sep 17 00:00:00 2001 From: Andrew Hunt Date: Thu, 28 Mar 2019 13:02:37 -0400 Subject: [PATCH 016/121] dev/core#655 contrib detail report: validation for soft credit params Grouping by soft credit when displaying contributions only used to just be stupid--now it results in a DB error. --- CRM/Report/Form/Contribute/Detail.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/CRM/Report/Form/Contribute/Detail.php b/CRM/Report/Form/Contribute/Detail.php index 1106772d81f5..accac0c1e195 100644 --- a/CRM/Report/Form/Contribute/Detail.php +++ b/CRM/Report/Form/Contribute/Detail.php @@ -367,6 +367,25 @@ public function __construct() { parent::__construct(); } + /** + * Validate incompatible report settings. + * + * @return bool + * true if no error found + */ + public function validate() { + // If you're displaying Contributions Only, you can't group by soft credit. + $contributionOrSoftVal = $this->getElementValue('contribution_or_soft_value'); + if ($contributionOrSoftVal[0] == 'contributions_only') { + $groupBySoft = $this->getElementValue('group_bys'); + if (CRM_Utils_Array::value('soft_credit_id', $groupBySoft)) { + $this->setElementError('group_bys', ts('You cannot group by soft credit when displaying contributions only. Please uncheck "Soft Credit" in the Grouping tab.')); + } + } + + return parent::validate(); + } + /** * Set the FROM clause for the report. */ From 79ee443c74b9984eaab3840ff5700b0d796c4178 Mon Sep 17 00:00:00 2001 From: eileen Date: Mon, 26 Feb 2018 15:38:29 +1300 Subject: [PATCH 017/121] CRM-18011 improve lock handling for mysql 5.7.5+ 5.7.5+ supports multiple mysql threads in a process. We can be non-hacky once that is in play --- CRM/Core/Lock.php | 2 +- CRM/Utils/SQL.php | 40 ++++++++++++++++++- .../CRM/common/civicrm.settings.php.template | 14 +++++++ 3 files changed, 54 insertions(+), 2 deletions(-) diff --git a/CRM/Core/Lock.php b/CRM/Core/Lock.php index 40b94ae7b162..460475e4183f 100644 --- a/CRM/Core/Lock.php +++ b/CRM/Core/Lock.php @@ -177,7 +177,7 @@ public function __destruct() { */ public function acquire($timeout = NULL) { if (!$this->_hasLock) { - if (self::$jobLog && CRM_Core_DAO::singleValueQuery("SELECT IS_USED_LOCK( '" . self::$jobLog . "')")) { + if (!CRM_Utils_SQL::supportsMultipleLocks() && self::$jobLog && CRM_Core_DAO::singleValueQuery("SELECT IS_USED_LOCK( '" . self::$jobLog . "')")) { return $this->hackyHandleBrokenCode(self::$jobLog); } diff --git a/CRM/Utils/SQL.php b/CRM/Utils/SQL.php index a20dc3800bd4..22f06d51642a 100644 --- a/CRM/Utils/SQL.php +++ b/CRM/Utils/SQL.php @@ -78,7 +78,7 @@ public static function getSqlModes() { */ public static function supportsFullGroupBy() { // CRM-21455 MariaDB 10.2 does not support ANY_VALUE - $version = CRM_Core_DAO::singleValueQuery('SELECT VERSION()'); + $version = self::getDatabaseVersion(); if (stripos($version, 'mariadb') !== FALSE) { return FALSE; @@ -134,4 +134,42 @@ public static function supportStorageOfAccents() { return FALSE; } + /** + * Does the DB version support mutliple locks per + * + * https://dev.mysql.com/doc/refman/5.7/en/miscellaneous-functions.html#function_get-lock + * + * As an interim measure we ALSO require CIVICRM_SUPPORT_MULTIPLE_LOCKS to be defined. + * + * This is a conservative measure to introduce the change which we expect to deprecate later. + * + * @todo we only check mariadb & mysql right now but maybe can add percona. + */ + public static function supportsMultipleLocks() { + if (!defined('CIVICRM_SUPPORT_MULTIPLE_LOCKS')) { + return FALSE; + } + static $isSupportLocks = NULL; + if (!isset($isSupportLocks)) { + $version = self::getDatabaseVersion(); + if (stripos($version, 'mariadb') !== FALSE) { + $isSupportLocks = version_compare($version, '10.0.2', '>='); + } + else { + $isSupportLocks = version_compare($version, '5.7.5', '>='); + } + } + + return $isSupportLocks; + } + + /** + * Get the version string for the database. + * + * @return string + */ + public static function getDatabaseVersion() { + return CRM_Core_DAO::singleValueQuery('SELECT VERSION()'); + } + } diff --git a/templates/CRM/common/civicrm.settings.php.template b/templates/CRM/common/civicrm.settings.php.template index 0600dc6e33c1..ec2fabbeb26c 100644 --- a/templates/CRM/common/civicrm.settings.php.template +++ b/templates/CRM/common/civicrm.settings.php.template @@ -447,6 +447,20 @@ if (!defined('CIVICRM_PSR16_STRICT')) { */ define('CIVICRM_DEADLOCK_RETRIES', 3); +/** + * Enable support for multiple locks. + * + * This is a transitional setting. When enabled sites with mysql 5.7.5+ or equivalent + * MariaDB can improve their DB conflict management. + * + * There is no known or expected downside or enabling this (and definite upside). + * The setting only exists to allow sites to manage change in their environment + * conservatively for the first 3 months. + * + * See https://github.com/civicrm/civicrm-core/pull/13854 + */ + // define('CIVICRM_SUPPORT_MULTIPLE_LOCKS', TRUE); + /** * Configure MySQL to throw more errors when encountering unusual SQL expressions. * From ed1cdf0e9f4b7857c50638c3ff88c6dcbe518b8d Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Sat, 30 Mar 2019 07:48:06 +1100 Subject: [PATCH 018/121] Covert the CRM_Core_Error::fatal calls to exceptions when trying to access Contact Photos --- CRM/Contact/Page/ImageFile.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CRM/Contact/Page/ImageFile.php b/CRM/Contact/Page/ImageFile.php index f5ec151d0dee..50e740edf435 100644 --- a/CRM/Contact/Page/ImageFile.php +++ b/CRM/Contact/Page/ImageFile.php @@ -45,7 +45,7 @@ class CRM_Contact_Page_ImageFile extends CRM_Core_Page { */ public function run() { if (!preg_match('/^[^\/]+\.(jpg|jpeg|png|gif)$/i', $_GET['photo'])) { - CRM_Core_Error::fatal('Malformed photo name'); + throw new CRM_Core_Exception(ts('Malformed photo name')); } // FIXME Optimize performance of image_url query @@ -69,7 +69,7 @@ public function run() { CRM_Utils_System::civiExit(); } else { - CRM_Core_Error::fatal('Photo does not exist'); + throw new CRM_Core_Exception(ts('Photo does not exist')); } } From b082b03b0bfe847aa962bdba8b995a53f26ef442 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Sat, 30 Mar 2019 07:56:00 +1100 Subject: [PATCH 019/121] Convert trxn_date field in the Update Pending Status task option from find contributions to datepicker from jcalendar --- CRM/Contribute/Form/Task/Status.php | 6 +++--- templates/CRM/Contribute/Form/Task/Status.tpl | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CRM/Contribute/Form/Task/Status.php b/CRM/Contribute/Form/Task/Status.php index f32c9e489da3..94bc70f1d805 100644 --- a/CRM/Contribute/Form/Task/Status.php +++ b/CRM/Contribute/Form/Task/Status.php @@ -118,7 +118,7 @@ public function buildQuickForm() { $this->_rows = array(); $attributes = CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Contribution'); $defaults = array(); - $now = date("m/d/Y"); + $now = date("Y-m-d"); $paidByOptions = array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(); while ($dao->fetch()) { @@ -140,8 +140,8 @@ public function buildQuickForm() { $this->addRule("fee_amount_{$row['contribution_id']}", ts('Please enter a valid amount.'), 'money'); $defaults["fee_amount_{$row['contribution_id']}"] = 0.0; - $row['trxn_date'] = $this->addDate("trxn_date_{$row['contribution_id']}", FALSE, - ts('Receipt Date'), array('formatType' => 'activityDate') + $row['trxn_date'] = $this->add('datepicker', "trxn_date_{$row['contribution_id']}", [], FALSE, + ts('Receipt Date'), array('time' => FALSE) ); $defaults["trxn_date_{$row['contribution_id']}"] = $now; diff --git a/templates/CRM/Contribute/Form/Task/Status.tpl b/templates/CRM/Contribute/Form/Task/Status.tpl index 7b6407945263..42baa59e8b1d 100644 --- a/templates/CRM/Contribute/Form/Task/Status.tpl +++ b/templates/CRM/Contribute/Form/Task/Status.tpl @@ -59,7 +59,7 @@ {assign var="element_name" value="trxn_id_"|cat:$row.contribution_id} {$form.$element_name.html|crmAddClass:eight} {assign var="element_name" value="trxn_date_"|cat:$row.contribution_id} - {include file="CRM/common/jcalendar.tpl" elementName=$element_name} + {$form.$element_name.html} {/foreach} From a60e32080a37d1c1b11e27244e7b488148eec04f Mon Sep 17 00:00:00 2001 From: Alok Patel Date: Thu, 13 Dec 2018 16:14:22 +0530 Subject: [PATCH 020/121] GREENS-199: Added paginations on Dedupe Exceptions page --- CRM/Contact/Page/DedupeException.php | 97 ++++++++----- .../CRM/Contact/Page/DedupeException.tpl | 130 ++++++++++++++---- 2 files changed, 159 insertions(+), 68 deletions(-) diff --git a/CRM/Contact/Page/DedupeException.php b/CRM/Contact/Page/DedupeException.php index 8ce168fa9f91..4dbaf3cbf114 100644 --- a/CRM/Contact/Page/DedupeException.php +++ b/CRM/Contact/Page/DedupeException.php @@ -35,53 +35,74 @@ * Main page for viewing contact. */ class CRM_Contact_Page_DedupeException extends CRM_Core_Page { - /** - * Heart of the viewing process. + * the main function that is called when the page loads, + * it decides the which action has to be taken for the page. * - * The runner gets all the meta data for the contact and calls the appropriate type of page to view. + * @return null */ - public function preProcess() { - //fetch the dedupe exception contacts. - $dedupeExceptions = array(); + public function run() { + $this->initializePager(); + $this->assign('exceptions', $this->getExceptions()); + return parent::run(); + } - $exception = new CRM_Dedupe_DAO_Exception(); - $exception->find(); - $contactIds = array(); - while ($exception->fetch()) { - $key = "{$exception->contact_id1}_{$exception->contact_id2}"; - $contactIds[$exception->contact_id1] = $exception->contact_id1; - $contactIds[$exception->contact_id2] = $exception->contact_id2; - $dedupeExceptions[$key] = array( - 'main' => array('id' => $exception->contact_id1), - 'other' => array('id' => $exception->contact_id2), - ); - } - //get the dupe contacts display names. - if (!empty($dedupeExceptions)) { - $sql = 'select id, display_name from civicrm_contact where id IN ( ' . implode(', ', $contactIds) . ' )'; - $contact = CRM_Core_DAO::executeQuery($sql); - $displayNames = array(); - while ($contact->fetch()) { - $displayNames[$contact->id] = $contact->display_name; - } - foreach ($dedupeExceptions as $key => & $values) { - $values['main']['name'] = CRM_Utils_Array::value($values['main']['id'], $displayNames); - $values['other']['name'] = CRM_Utils_Array::value($values['other']['id'], $displayNames); - } - } - $this->assign('dedupeExceptions', $dedupeExceptions); + /** + * Method to initialize pager + * + * @access protected + */ + protected function initializePager() { + $totalitems = civicrm_api3('Exception', "getcount", array()); + $params = array( + 'total' => $totalitems, + 'rowCount' => CRM_Utils_Pager::ROWCOUNT, + 'status' => ts('Dedupe Exceptions %%StatusMessage%%'), + 'buttonBottom' => 'PagerBottomButton', + 'buttonTop' => 'PagerTopButton', + 'pageID' => $this->get(CRM_Utils_Pager::PAGE_ID), + ); + $this->_pager = new CRM_Utils_Pager($params); + $this->assign_by_ref('pager', $this->_pager); } /** - * the main function that is called when the page loads, - * it decides the which action has to be taken for the page. + * Function to get the exceptions * - * @return null + * @return array $exceptions + * @access protected */ - public function run() { - $this->preProcess(); - return parent::run(); + protected function getExceptions() { + list($offset, $limit) = $this->_pager->getOffsetAndRowCount(); + $contactOneQ = CRM_Utils_Request::retrieve('crmContact1Q', 'String'); + $contactTwoQ = CRM_Utils_Request::retrieve('crmContact2Q', 'String'); + + if (!$contactOneQ) { + $contactOneQ = ''; + } + if (!$contactTwoQ) { + $contactTwoQ = ''; + } + + $this->assign('searchcontact1', $contactOneQ); + $this->assign('searchcontact2', $contactTwoQ); + + $params = array( + "options" => array('limit' => $limit, 'offset' => $offset), + 'return' => ["contact_id1.display_name", "contact_id2.display_name", "contact_id1", "contact_id2"], + ); + + if ($contactOneQ != '') { + $params['contact_id1.display_name'] = array('LIKE' => '%' . $contactOneQ . '%'); + } + + if ($contactTwoQ != '') { + $params['contact_id2.display_name'] = array('LIKE' => '%' . $contactTwoQ . '%'); + } + + $exceptions = civicrm_api3("Exception", "get", $params); + $exceptions = $exceptions["values"]; + return $exceptions; } } diff --git a/templates/CRM/Contact/Page/DedupeException.tpl b/templates/CRM/Contact/Page/DedupeException.tpl index 0cff17ca8d50..ec358547ad21 100644 --- a/templates/CRM/Contact/Page/DedupeException.tpl +++ b/templates/CRM/Contact/Page/DedupeException.tpl @@ -30,52 +30,122 @@
-
- +
+
-
- +
+
- - - - - - - - - - {foreach from=$dedupeExceptions item=exception key=id} - - - - + + +
+ {include file="CRM/common/pager.tpl" location="top"} + {include file='CRM/common/jsortable.tpl'} + +
+
{ts}Contact 1{/ts}{ts}Contact 2 (Duplicate){/ts}
{$exception.main.name}{$exception.other.name}» {ts}Remove Exception{/ts}
+ + + + - {/foreach} - -
{ts}Contact 1{/ts}{ts}Contact 2 (Duplicate){/ts}
+ + + {assign var="rowClass" value="odd-row"} + {assign var="rowCount" value=0} + + {foreach from=$exceptions key=errorId item=exception} + {assign var="rowCount" value=$rowCount+1} + + + + + {assign var="contact1name" value="contact_id1.display_name"} + { $exception.$contact1name } + + + {assign var="contact2name" value="contact_id2.display_name"} + { $exception.$contact2name } + + + + + {if $rowClass eq "odd-row"} + {assign var="rowClass" value="even-row"} + {else} + {assign var="rowClass" value="odd-row"} + {/if} + + {/foreach} + + +
+ {include file="CRM/common/pager.tpl" location="bottom"} + + + +

{* process the dupe contacts *} -{include file="CRM/common/dedupe.tpl"} {literal} {/literal} From 916a35771371704dfabaea3a0e06da9914c2f019 Mon Sep 17 00:00:00 2001 From: Alok Patel Date: Tue, 18 Dec 2018 10:56:16 +0530 Subject: [PATCH 021/121] GREENS-200: Updating pagination when list is filtered. --- CRM/Contact/Page/DedupeException.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/CRM/Contact/Page/DedupeException.php b/CRM/Contact/Page/DedupeException.php index 4dbaf3cbf114..ec8b4f60bd1a 100644 --- a/CRM/Contact/Page/DedupeException.php +++ b/CRM/Contact/Page/DedupeException.php @@ -53,7 +53,20 @@ public function run() { * @access protected */ protected function initializePager() { - $totalitems = civicrm_api3('Exception', "getcount", array()); + $params = array(); + + $contactOneQ = CRM_Utils_Request::retrieve('crmContact1Q', 'String'); + $contactTwoQ = CRM_Utils_Request::retrieve('crmContact2Q', 'String'); + + if ($contactOneQ) { + $params['contact_id1.display_name'] = array('LIKE' => '%' . $contactOneQ . '%'); + } + + if ($contactTwoQ) { + $params['contact_id2.display_name'] = array('LIKE' => '%' . $contactTwoQ . '%'); + } + + $totalitems = civicrm_api3('Exception', "getcount", $params); $params = array( 'total' => $totalitems, 'rowCount' => CRM_Utils_Pager::ROWCOUNT, From cf3d3207f9079a0508f03935faa8724c5a0115fe Mon Sep 17 00:00:00 2001 From: Alok Patel Date: Thu, 20 Dec 2018 14:58:22 +0530 Subject: [PATCH 022/121] GREENS-201: Added Find contacts button. GREENS-202: Removed second contact filter field. --- CRM/Contact/Page/DedupeException.php | 16 ++------ .../CRM/Contact/Page/DedupeException.tpl | 37 ++++++++----------- 2 files changed, 20 insertions(+), 33 deletions(-) diff --git a/CRM/Contact/Page/DedupeException.php b/CRM/Contact/Page/DedupeException.php index ec8b4f60bd1a..8b47b516e450 100644 --- a/CRM/Contact/Page/DedupeException.php +++ b/CRM/Contact/Page/DedupeException.php @@ -56,14 +56,12 @@ protected function initializePager() { $params = array(); $contactOneQ = CRM_Utils_Request::retrieve('crmContact1Q', 'String'); - $contactTwoQ = CRM_Utils_Request::retrieve('crmContact2Q', 'String'); if ($contactOneQ) { $params['contact_id1.display_name'] = array('LIKE' => '%' . $contactOneQ . '%'); - } + $params['contact_id2.display_name'] = array('LIKE' => '%' . $contactOneQ . '%'); - if ($contactTwoQ) { - $params['contact_id2.display_name'] = array('LIKE' => '%' . $contactTwoQ . '%'); + $params['options']['or'] = [["contact_id1.display_name", "contact_id2.display_name"]]; } $totalitems = civicrm_api3('Exception', "getcount", $params); @@ -88,17 +86,12 @@ protected function initializePager() { protected function getExceptions() { list($offset, $limit) = $this->_pager->getOffsetAndRowCount(); $contactOneQ = CRM_Utils_Request::retrieve('crmContact1Q', 'String'); - $contactTwoQ = CRM_Utils_Request::retrieve('crmContact2Q', 'String'); if (!$contactOneQ) { $contactOneQ = ''; } - if (!$contactTwoQ) { - $contactTwoQ = ''; - } $this->assign('searchcontact1', $contactOneQ); - $this->assign('searchcontact2', $contactTwoQ); $params = array( "options" => array('limit' => $limit, 'offset' => $offset), @@ -107,10 +100,9 @@ protected function getExceptions() { if ($contactOneQ != '') { $params['contact_id1.display_name'] = array('LIKE' => '%' . $contactOneQ . '%'); - } + $params['contact_id2.display_name'] = array('LIKE' => '%' . $contactOneQ . '%'); - if ($contactTwoQ != '') { - $params['contact_id2.display_name'] = array('LIKE' => '%' . $contactTwoQ . '%'); + $params['options']['or'] = [["contact_id1.display_name", "contact_id2.display_name"]]; } $exceptions = civicrm_api3("Exception", "get", $params); diff --git a/templates/CRM/Contact/Page/DedupeException.tpl b/templates/CRM/Contact/Page/DedupeException.tpl index ec358547ad21..2b4c34627606 100644 --- a/templates/CRM/Contact/Page/DedupeException.tpl +++ b/templates/CRM/Contact/Page/DedupeException.tpl @@ -27,18 +27,20 @@ {ts}Filter Contacts{/ts}
- - - - - -
-
- -
-
- -
+
+ + + + + +
+
+ +
+
@@ -108,7 +110,8 @@ var timer = null; // apply the search - $('#searchOptions input').on( 'keydown', function () { + $('.filtercontacts').on( 'click', function (e) { + e.preventDefault(); clearTimeout(timer); timer = setTimeout(updateTable, 500) }); @@ -116,7 +119,6 @@ function updateTable() { var contact1term = $('#search-contact1').val(); - var contact2term = $('#search-contact2').val(); currentLocation = currentLocation.replace(/crmPID=\d+/, 'crmPID=' + 0); @@ -127,13 +129,6 @@ currentLocation += '&crmContact1Q='+contact1term; } - if (currentLocation.indexOf('crmContact2Q') !== -1) { - currentLocation = currentLocation.replace(/crmContact2Q=\w*/, 'crmContact2Q=' + contact2term); - } - else { - currentLocation += '&crmContact2Q='+contact2term; - } - refresh(currentLocation); } From b5c67323525efad16abfe4ad2e0639d0e3a12bc5 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Sat, 12 Jan 2019 07:59:54 +1100 Subject: [PATCH 023/121] Re-add in the remove Exception function --- api/v3/Exception.php | 1 + .../CRM/Contact/Page/DedupeException.tpl | 22 +++++++++++-------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/api/v3/Exception.php b/api/v3/Exception.php index 9c50d4a35c1b..8ed2ada6aca6 100644 --- a/api/v3/Exception.php +++ b/api/v3/Exception.php @@ -47,6 +47,7 @@ function civicrm_api3_exception_get($params) { function civicrm_api3_exception_create($params) { return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'Exception'); } + /** * Delete an existing Exception. * diff --git a/templates/CRM/Contact/Page/DedupeException.tpl b/templates/CRM/Contact/Page/DedupeException.tpl index 2b4c34627606..378de8b0d627 100644 --- a/templates/CRM/Contact/Page/DedupeException.tpl +++ b/templates/CRM/Contact/Page/DedupeException.tpl @@ -23,6 +23,7 @@ | see the CiviCRM license FAQ at http://civicrm.org/licensing | +--------------------------------------------------------------------+ *} +{include file="CRM/common/dedupe.tpl"}
{ts}Filter Contacts{/ts}
@@ -32,7 +33,7 @@
- +
@@ -51,16 +52,17 @@
- - - - + + + + + - {assign var="rowClass" value="odd-row"} - {assign var="rowCount" value=0} + {assign var="rowClass" value="odd-row"} + {assign var="rowCount" value=0} - {foreach from=$exceptions key=errorId item=exception} + {foreach from=$exceptions key=errorId item=exception} {assign var="rowCount" value=$rowCount+1} @@ -73,7 +75,9 @@ {assign var="contact2name" value="contact_id2.display_name"} { $exception.$contact2name } - + {if $rowClass eq "odd-row"} From 73409b5bc66af241dae50a0b6753f8018619c083 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Sat, 30 Mar 2019 13:42:30 +1100 Subject: [PATCH 024/121] Fix label of trxn_date field and also fix post processing of trxn_date --- CRM/Contribute/Form/Task/Status.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/CRM/Contribute/Form/Task/Status.php b/CRM/Contribute/Form/Task/Status.php index 94bc70f1d805..c3f4e9d9e631 100644 --- a/CRM/Contribute/Form/Task/Status.php +++ b/CRM/Contribute/Form/Task/Status.php @@ -140,9 +140,7 @@ public function buildQuickForm() { $this->addRule("fee_amount_{$row['contribution_id']}", ts('Please enter a valid amount.'), 'money'); $defaults["fee_amount_{$row['contribution_id']}"] = 0.0; - $row['trxn_date'] = $this->add('datepicker', "trxn_date_{$row['contribution_id']}", [], FALSE, - ts('Receipt Date'), array('time' => FALSE) - ); + $row['trxn_date'] = $this->add('datepicker', "trxn_date_{$row['contribution_id']}", ts('Transaction Date'), [], FALSE, ['time' => FALSE]); $defaults["trxn_date_{$row['contribution_id']}"] = $now; $this->add("text", "check_number_{$row['contribution_id']}", ts('Check Number')); @@ -294,7 +292,7 @@ public static function processForm($form, $params) { else { $input['trxn_id'] = $contribution->invoice_id; } - $input['trxn_date'] = CRM_Utils_Date::processDate($params["trxn_date_{$row['contribution_id']}"], date('H:i:s')); + $input['trxn_date'] = $params["trxn_date_{$row['contribution_id']}"] . ' ' . date('H:i:s'); // @todo calling baseIPN like this is a pattern in it's last gasps. Call contribute.completetransaction api. $baseIPN->completeTransaction($input, $ids, $objects, $transaction, FALSE); From 94efb43078f07020d75bd0fead804e468f3e972f Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Sat, 30 Mar 2019 15:17:27 +1100 Subject: [PATCH 025/121] dev/core#836 Do not track CSS urls when added as link urls --- CRM/Mailing/BAO/Mailing.php | 9 ++++++--- tests/phpunit/api/v3/MailingTest.php | 6 +++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CRM/Mailing/BAO/Mailing.php b/CRM/Mailing/BAO/Mailing.php index 927fdeec4413..ce320a9b2683 100644 --- a/CRM/Mailing/BAO/Mailing.php +++ b/CRM/Mailing/BAO/Mailing.php @@ -1367,9 +1367,12 @@ private function getTokenData(&$token_a, $html = FALSE, &$contact, &$verp, &$url } elseif ($type == 'url') { if ($this->url_tracking) { - $data = CRM_Mailing_BAO_TrackableURL::getTrackerURL($token, $this->id, $event_queue_id); - if (!empty($html)) { - $data = htmlentities($data, ENT_NOQUOTES); + // ensure that Google CSS and any .css files are not tracked. + if (!(strpos($token, 'css?family') || strpos($token, '.css'))) { + $data = CRM_Mailing_BAO_TrackableURL::getTrackerURL($token, $this->id, $event_queue_id); + if (!empty($html)) { + $data = htmlentities($data, ENT_NOQUOTES); + } } } else { diff --git a/tests/phpunit/api/v3/MailingTest.php b/tests/phpunit/api/v3/MailingTest.php index 5c7a16f9410c..f208df94b023 100644 --- a/tests/phpunit/api/v3/MailingTest.php +++ b/tests/phpunit/api/v3/MailingTest.php @@ -54,7 +54,7 @@ public function setUp() { $this->_params = array( 'subject' => 'Hello {contact.display_name}', 'body_text' => "This is {contact.display_name}.\nhttps://civicrm.org\n{domain.address}{action.optOutUrl}", - 'body_html' => "

This is {contact.display_name}.

CiviCRM.org

{domain.address}{action.optOutUrl}

", + 'body_html' => "

This is {contact.display_name}.

CiviCRM.org

{domain.address}{action.optOutUrl}

", 'name' => 'mailing name', 'created_id' => $this->_contactID, 'header_id' => '', @@ -897,6 +897,10 @@ public function testUrlWithMissingTrackingHash() { $url = CRM_Mailing_Event_BAO_TrackableURLOpen::track($dao->queue_id, $dao->url_id); $this->assertContains('https://civicrm.org', $url); + + // Ensure that Google CSS link is not tracked. + $sql = "SELECT id FROM civicrm_mailing_trackable_url where url = 'https://fonts.googleapis.com/css?family=Roboto+Condensed:400,700|Zilla+Slab:500,700'"; + $this->assertEquals([], CRM_Core_DAO::executeQuery($sql)->fetchAll()); } /** From fe1446f1a4e622fc759056ca637087237d84a8b8 Mon Sep 17 00:00:00 2001 From: Pradeep Nayak Date: Sat, 30 Mar 2019 19:14:36 +0000 Subject: [PATCH 026/121] dev/core/issues/837, Fixed notice error on Contribution Agrreagate custom search. --- .../Form/Search/Custom/ContributionAggregate.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/CRM/Contact/Form/Search/Custom/ContributionAggregate.php b/CRM/Contact/Form/Search/Custom/ContributionAggregate.php index 2692dad23f59..65b1c859dca4 100644 --- a/CRM/Contact/Form/Search/Custom/ContributionAggregate.php +++ b/CRM/Contact/Form/Search/Custom/ContributionAggregate.php @@ -200,11 +200,17 @@ public function where($includeContactIDs = FALSE) { "contrib.is_test = 0", ); - $dateParams = array( - 'contribution_date_relative' => $this->_formValues['contribution_date_relative'], - 'contribution_date_low' => $this->_formValues['contribution_date_low'], - 'contribution_date_high' => $this->_formValues['contribution_date_high'], - ); + foreach ([ + 'contribution_date_relative', + 'contribution_date_low', + 'contribution_date_high', + ] as $dateFieldName) { + $dateParams[$dateFieldName] = CRM_Utils_Array::value( + $dateFieldName, + $this->_formValues + ); + } + foreach (CRM_Contact_BAO_Query::convertFormValues($dateParams) as $values) { list($name, $op, $value) = $values; if (strstr($name, '_low')) { From e7e5ef2b6c549d87ef23755f512c2fc2fd515413 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Sun, 31 Mar 2019 09:29:28 -0400 Subject: [PATCH 027/121] [NFC] Cleanup DAO factory classes for code standards --- CRM/Contact/DAO/Factory.php | 24 ++++++++++-------------- CRM/Core/DAO/Factory.php | 24 ++++++++++-------------- 2 files changed, 20 insertions(+), 28 deletions(-) diff --git a/CRM/Contact/DAO/Factory.php b/CRM/Contact/DAO/Factory.php index 5f4432c2b50f..8af2fc1ac416 100644 --- a/CRM/Contact/DAO/Factory.php +++ b/CRM/Contact/DAO/Factory.php @@ -5,7 +5,7 @@ */ class CRM_Contact_DAO_Factory { - static $_classes = array( + public static $_classes = [ 'Address' => 'data', 'Contact' => 'data', 'Email' => 'data', @@ -17,39 +17,35 @@ class CRM_Contact_DAO_Factory { 'Organization' => 'data', 'Phone' => 'data', 'Relationship' => 'data', - ); + ]; - static $_prefix = array( - 'business' => 'CRM/Contact/BAO/', - 'data' => 'CRM/Contact/DAO/', - ); - - static $_suffix = '.php'; + public static $_prefix = [ + 'business' => 'CRM_Contact_BAO_', + 'data' => 'CRM_Contact_DAO_', + ]; /** * @param string $className * * @return mixed */ - static function &create($className) { + public static function create($className) { $type = CRM_Utils_Array::value($className, self::$_classes); if (!$type) { return CRM_Core_DAO_Factory::create($className); } - $file = self::$_prefix[$type] . $className; - $class = str_replace('/', '_', $file); - - require_once($file . self::$_suffix); + $class = self::$_prefix[$type] . $className; if ($type == 'singleton') { $newObj = $class::singleton(); } else { // this is either 'business' or 'data' - $newObj = new $class; + $newObj = new $class(); } return $newObj; } + } diff --git a/CRM/Core/DAO/Factory.php b/CRM/Core/DAO/Factory.php index 99242f9d38df..519f4c4341aa 100644 --- a/CRM/Core/DAO/Factory.php +++ b/CRM/Core/DAO/Factory.php @@ -5,7 +5,7 @@ */ class CRM_Core_DAO_Factory { - static $_classes = array( + public static $_classes = [ 'Domain' => 'data', 'Country' => 'singleton', 'County' => 'singleton', @@ -13,14 +13,12 @@ class CRM_Core_DAO_Factory { 'GeoCoord' => 'singleton', 'IMProvider' => 'singleton', 'MobileProvider' => 'singleton', - ); + ]; - static $_prefix = array( - 'business' => 'CRM/Core/BAO/', - 'data' => 'CRM/Core/DAO/', - ); - - static $_suffix = '.php'; + public static $_prefix = [ + 'business' => 'CRM_Core_BAO_', + 'data' => 'CRM_Core_DAO_', + ]; /** * @param string $className @@ -28,25 +26,23 @@ class CRM_Core_DAO_Factory { * @return mixed * @throws Exception */ - static function &create($className) { + public static function create($className) { $type = CRM_Utils_Array::value($className, self::$_classes); if (!$type) { CRM_Core_Error::fatal("class $className not found"); } - $file = self::$_prefix[$type] . $className; - $class = str_replace('/', '_', $file); - - require_once($file . self::$_suffix); + $class = self::$_prefix[$type] . $className; if ($type == 'singleton') { $newObj = $class::singleton(); } else { // this is either 'business' or 'data' - $newObj = new $class; + $newObj = new $class(); } return $newObj; } + } From 6d8785b974d4207da0c6f31b54b26aad86005562 Mon Sep 17 00:00:00 2001 From: Jitendra Purohit Date: Sun, 31 Mar 2019 21:31:45 +0530 Subject: [PATCH 028/121] Fix unit test --- CRM/Core/Payment/PayPalProIPN.php | 3 ++- tests/phpunit/CRM/Core/Payment/PayPalProIPNTest.php | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CRM/Core/Payment/PayPalProIPN.php b/CRM/Core/Payment/PayPalProIPN.php index f93bac71d5d1..9fd23b8d5e96 100644 --- a/CRM/Core/Payment/PayPalProIPN.php +++ b/CRM/Core/Payment/PayPalProIPN.php @@ -557,7 +557,8 @@ public function handlePaymentExpress() { $objects = $ids = $input = array(); $isFirst = FALSE; $input['invoice'] = self::getValue('i', FALSE); - if (empty($input['invoice'])) { + //Avoid return in case of unit test. + if (empty($input['invoice']) && empty($this->_inputParameters['is_unit_test'])) { return; } $input['txnType'] = $this->retrieve('txn_type', 'String'); diff --git a/tests/phpunit/CRM/Core/Payment/PayPalProIPNTest.php b/tests/phpunit/CRM/Core/Payment/PayPalProIPNTest.php index 68ede1d3dfe7..949d3aa35c89 100644 --- a/tests/phpunit/CRM/Core/Payment/PayPalProIPNTest.php +++ b/tests/phpunit/CRM/Core/Payment/PayPalProIPNTest.php @@ -250,6 +250,7 @@ public function getPaypalExpressTransactionIPN() { 'payment_gross' => '200.00', 'shipping' => '0.00', 'ipn_track_id' => '5r27c2e31rl7c', + 'is_unit_test' => TRUE, ); } From 3f69fc38667b918d8d2815c08b66c196152eb7ee Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Mon, 1 Apr 2019 08:27:01 +1100 Subject: [PATCH 029/121] Update PHPWord Patches to match the latest versions of their code --- .../phpoffice-common-xml-entity-fix.patch | 7 +++--- .../phpword-libxml-fix-global-handling.patch | 22 ++++++++++--------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/tools/scripts/composer/patches/phpoffice-common-xml-entity-fix.patch b/tools/scripts/composer/patches/phpoffice-common-xml-entity-fix.patch index c3da55e120a1..47b211ee8456 100644 --- a/tools/scripts/composer/patches/phpoffice-common-xml-entity-fix.patch +++ b/tools/scripts/composer/patches/phpoffice-common-xml-entity-fix.patch @@ -4,12 +4,13 @@ */ public function getDomFromString($content) { -+ $original = libxml_disable_entity_loader(); - libxml_disable_entity_loader(true); +- libxml_disable_entity_loader(true); ++ $originalLibXMLEntityValue = libxml_disable_entity_loader(true); $this->dom = new \DOMDocument(); $this->dom->loadXML($content); - -+ libxml_disable_entity_loader($original); ++ libxml_disable_entity_loader($originalLibXMLEntityValue); ++ return $this->dom; } diff --git a/tools/scripts/composer/patches/phpword-libxml-fix-global-handling.patch b/tools/scripts/composer/patches/phpword-libxml-fix-global-handling.patch index da6f8f0c4cc3..cc3673fd0bfd 100644 --- a/tools/scripts/composer/patches/phpword-libxml-fix-global-handling.patch +++ b/tools/scripts/composer/patches/phpword-libxml-fix-global-handling.patch @@ -10,18 +10,19 @@ Subject: [PATCH] Ensure that entity_loader disable variable is re-set back to 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/PhpWord/Shared/Html.php b/src/PhpWord/Shared/Html.php -index 89881822ca..f25cf5f4a6 100644 +index 89881822ca..f2710ea168 100644 --- a/src/PhpWord/Shared/Html.php +++ b/src/PhpWord/Shared/Html.php -@@ -72,6 +72,7 @@ public static function addHtml($element, $html, $fullHTML = false, $preserveWhit +@@ -72,7 +72,7 @@ public static function addHtml($element, $html, $fullHTML = false, $preserveWhit } // Load DOM -+ $orignalLibEntityLoader = libxml_disable_entity_loader(); - libxml_disable_entity_loader(true); +- libxml_disable_entity_loader(true); ++ $orignalLibEntityLoader = libxml_disable_entity_loader(true); $dom = new \DOMDocument(); $dom->preserveWhiteSpace = $preserveWhiteSpace; -@@ -80,6 +81,7 @@ public static function addHtml($element, $html, $fullHTML = false, $preserveWhit + $dom->loadXML($html); +@@ -80,6 +80,7 @@ public static function addHtml($element, $html, $fullHTML = false, $preserveWhit $node = $dom->getElementsByTagName('body'); self::parseNode($node->item(0), $element); @@ -30,18 +31,19 @@ index 89881822ca..f25cf5f4a6 100644 /** diff --git a/src/PhpWord/TemplateProcessor.php b/src/PhpWord/TemplateProcessor.php -index 0f685bc45b..fa605b19c5 100644 +index 0f685bc45b..7efc0f1ac8 100644 --- a/src/PhpWord/TemplateProcessor.php +++ b/src/PhpWord/TemplateProcessor.php -@@ -170,6 +170,7 @@ protected function readPartWithRels($fileName) +@@ -170,7 +170,7 @@ protected function readPartWithRels($fileName) */ protected function transformSingleXml($xml, $xsltProcessor) { -+ $orignalLibEntityLoader = libxml_disable_entity_loader(); - libxml_disable_entity_loader(true); +- libxml_disable_entity_loader(true); ++ $orignalLibEntityLoader = libxml_disable_entity_loader(true); $domDocument = new \DOMDocument(); if (false === $domDocument->loadXML($xml)) { -@@ -180,6 +181,7 @@ protected function transformSingleXml($xml, $xsltProcessor) + throw new Exception('Could not load the given XML document.'); +@@ -180,6 +180,7 @@ protected function transformSingleXml($xml, $xsltProcessor) if (false === $transformedXml) { throw new Exception('Could not transform the given XML document.'); } From 807cb25281116fe955c9fd8f085a310d5cc3beb5 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Mon, 1 Apr 2019 12:55:39 +1100 Subject: [PATCH 030/121] Fix mode on files --- CRM/Upgrade/Incremental/sql/5.13.alpha1.mysql.tpl | 0 xml/templates/civicrm_country.tpl | 0 xml/templates/civicrm_currency.tpl | 0 3 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 CRM/Upgrade/Incremental/sql/5.13.alpha1.mysql.tpl mode change 100755 => 100644 xml/templates/civicrm_country.tpl mode change 100755 => 100644 xml/templates/civicrm_currency.tpl diff --git a/CRM/Upgrade/Incremental/sql/5.13.alpha1.mysql.tpl b/CRM/Upgrade/Incremental/sql/5.13.alpha1.mysql.tpl old mode 100755 new mode 100644 diff --git a/xml/templates/civicrm_country.tpl b/xml/templates/civicrm_country.tpl old mode 100755 new mode 100644 diff --git a/xml/templates/civicrm_currency.tpl b/xml/templates/civicrm_currency.tpl old mode 100755 new mode 100644 From a69cf1d18691a805b1d8c9f104d4a00ed4f1cdc4 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Sat, 30 Mar 2019 08:13:34 +1100 Subject: [PATCH 031/121] Convert the Fullfilled Date field in preimum section on backoffice contribution from from jcalendar to datepicker Fix up defaults --- CRM/Contribute/DAO/ContributionProduct.php | 6 +- CRM/Contribute/Form/AdditionalInfo.php | 7 +- CRM/Contribute/Form/Contribution.php | 2 +- .../Form/AdditionalInfo/Premium.tpl | 115 +++++++++--------- xml/schema/Contribute/ContributionProduct.xml | 4 + 5 files changed, 68 insertions(+), 66 deletions(-) diff --git a/CRM/Contribute/DAO/ContributionProduct.php b/CRM/Contribute/DAO/ContributionProduct.php index 398db85756ea..a8e344185c10 100644 --- a/CRM/Contribute/DAO/ContributionProduct.php +++ b/CRM/Contribute/DAO/ContributionProduct.php @@ -6,7 +6,7 @@ * * Generated from xml/schema/CRM/Contribute/ContributionProduct.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:82892e993d78273218096926fa04282e) + * (GenCodeChecksum:b5a1b3fa2819c4dfe99635fef8583a42) */ /** @@ -193,6 +193,10 @@ public static function &fields() { 'entity' => 'ContributionProduct', 'bao' => 'CRM_Contribute_DAO_ContributionProduct', 'localizable' => 0, + 'html' => [ + 'type' => 'Select Date', + 'formatType' => 'activityDate', + ], ], 'contribution_start_date' => [ 'name' => 'start_date', diff --git a/CRM/Contribute/Form/AdditionalInfo.php b/CRM/Contribute/Form/AdditionalInfo.php index ec27855294ba..8eedeaa8d998 100644 --- a/CRM/Contribute/Form/AdditionalInfo.php +++ b/CRM/Contribute/Form/AdditionalInfo.php @@ -81,7 +81,7 @@ public static function buildPremium(&$form) { $js .= "\n"; $form->assign('initHideBoxes', $js); - $form->addDate('fulfilled_date', ts('Fulfilled'), FALSE, array('formatType' => 'activityDate')); + $form->add('datepicker', 'fulfilled_date', ts('Fulfilled'), [], FALSE, array('time' => FALSE)); $form->addElement('text', 'min_amount', ts('Minimum Contribution Amount')); } @@ -192,7 +192,7 @@ public static function processPremium($params, $contributionID, $premiumID = NUL $dao = new CRM_Contribute_DAO_ContributionProduct(); $dao->contribution_id = $contributionID; $dao->product_id = $selectedProductID; - $dao->fulfilled_date = CRM_Utils_Date::processDate($params['fulfilled_date'], NULL, TRUE); + $dao->fulfilled_date = $params['fulfilled_date']; $isDeleted = FALSE; //CRM-11106 @@ -369,9 +369,8 @@ public static function emailReceipt(&$form, &$params, $ccContribution = FALSE) { $params['product_option'] = $form->_options[$productDAO->id][$productOptionID]; } } - if (!empty($params['fulfilled_date'])) { - $form->assign('fulfilled_date', CRM_Utils_Date::processDate($params['fulfilled_date'])); + $form->assign('fulfilled_date', $params['fulfilled_date']); } } diff --git a/CRM/Contribute/Form/Contribution.php b/CRM/Contribute/Form/Contribution.php index cc1f6247e74f..8326d73c03ce 100644 --- a/CRM/Contribute/Form/Contribution.php +++ b/CRM/Contribute/Form/Contribution.php @@ -412,7 +412,7 @@ public function setDefaultValues() { $defaults['product_name'] = array($this->_productDAO->product_id); } if ($this->_productDAO->fulfilled_date) { - list($defaults['fulfilled_date']) = CRM_Utils_Date::setDateDefaults($this->_productDAO->fulfilled_date); + $defaults['fulfilled_date'] = $this->_productDAO->fulfilled_date; } } diff --git a/templates/CRM/Contribute/Form/AdditionalInfo/Premium.tpl b/templates/CRM/Contribute/Form/AdditionalInfo/Premium.tpl index c5ab2ac88785..351e5805c9f4 100644 --- a/templates/CRM/Contribute/Form/AdditionalInfo/Premium.tpl +++ b/templates/CRM/Contribute/Form/AdditionalInfo/Premium.tpl @@ -24,71 +24,66 @@ +--------------------------------------------------------------------+ *} {* this template is used for adding/editing Premium Information *} -
-
{ts}Contact 1{/ts}{ts}Contact 2 (Duplicate){/ts}
{ts}Contact 1{/ts}{ts}Contact 2 (Duplicate){/ts}
+ » {ts}Remove Exception{/ts} +
- - - - -
{$form.product_name.label}{$form.product_name.html}
+
+ + + + + +
{$form.product_name.label}{$form.product_name.html}
-
- - - - - -
{$form.min_amount.label}{$form.min_amount.html|crmAddClass:'no-border'|crmMoney:$currency}
-
-
+
+ + + + +
{$form.min_amount.label}{$form.min_amount.html|crmAddClass:'no-border'|crmMoney:$currency}
+
+
+ - - - -
{$form.fulfilled_date.label}{include file="CRM/common/jcalendar.tpl" elementName=fulfilled_date}
+ {$form.fulfilled_date.label} + {$form.fulfilled_date.html} + +
- {literal} - - {/literal} -{if $action eq 1 or $action eq 2 or $action eq null } - +{literal} + +{/literal} +{if $action eq 1 or $action eq 2 or $action eq null} + {/if} {if $action ne 2 or $showOption eq true} - {$initHideBoxes} + {$initHideBoxes} {/if} diff --git a/xml/schema/Contribute/ContributionProduct.xml b/xml/schema/Contribute/ContributionProduct.xml index ce6865ec5d3c..d5ff804a1009 100644 --- a/xml/schema/Contribute/ContributionProduct.xml +++ b/xml/schema/Contribute/ContributionProduct.xml @@ -73,6 +73,10 @@ true Optional. Can be used to record the date this product was fulfilled or shipped. 1.4 + + Select Date + activityDate + start_date From 52746f6a3a229e8020e63cc70f109b759f43d3d0 Mon Sep 17 00:00:00 2001 From: eileen Date: Mon, 1 Apr 2019 17:31:21 +1300 Subject: [PATCH 032/121] Simply test, checkPaymentResult adds no value calling the checkPaymentResult function is actually decreasing readability here as the simple array comparison is being made to look complex --- tests/phpunit/api/v3/PaymentTest.php | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/tests/phpunit/api/v3/PaymentTest.php b/tests/phpunit/api/v3/PaymentTest.php index fbb5261cfc30..0c49ce88f486 100644 --- a/tests/phpunit/api/v3/PaymentTest.php +++ b/tests/phpunit/api/v3/PaymentTest.php @@ -197,17 +197,19 @@ public function testRefundEmailReceipt($thousandSeparator) { 'contribution_id' => $contribution['id'], 'total_amount' => -30, 'trxn_date' => '2018-11-13 12:01:56', - ]); + 'sequential' => TRUE, + ])['values'][0]; - $this->checkPaymentResult($payment, [ - $payment['id'] => [ - 'from_financial_account_id' => 7, - 'to_financial_account_id' => 6, - 'total_amount' => -30, - 'status_id' => 1, - 'is_payment' => 1, - ], - ]); + $expected = [ + 'from_financial_account_id' => 7, + 'to_financial_account_id' => 6, + 'total_amount' => -30, + 'status_id' => 1, + 'is_payment' => 1, + ]; + foreach ($expected as $key => $value) { + $this->assertEquals($expected[$key], $payment[$key], 'mismatch on key ' . $key); + } $this->callAPISuccess('Payment', 'sendconfirmation', ['id' => $payment['id']]); $mut->assertSubjects(['Refund Notification - Annual CiviCRM meet']); From 1b4a049e3b916216ed13a91d873d23c391340c90 Mon Sep 17 00:00:00 2001 From: Alok Patel Date: Mon, 1 Apr 2019 15:14:30 +0530 Subject: [PATCH 033/121] CIVICRM-1140: Added a DB check to prevent deleting exisiting CiviCRM data from datbase. --- install/index.php | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/install/index.php b/install/index.php index 1bded4d2bb2f..c70c1c1648a2 100644 --- a/install/index.php +++ b/install/index.php @@ -517,6 +517,17 @@ public function checkdatabase($databaseConfig, $dbName) { $onlyRequire ); if ($dbName != 'Drupal' && $dbName != 'Backdrop') { + $this->requireNoExistingData( + $databaseConfig['server'], + $databaseConfig['username'], + $databaseConfig['password'], + $databaseConfig['database'], + array( + ts("MySQL %1 Configuration", array(1 => $dbName)), + ts("Does database has data from previous installation?"), + ts("CiviCRM data from previous installation exists in '%1'.", array(1 => $databaseConfig['database'])), + ) + ); $this->requireMySQLInnoDB($databaseConfig['server'], $databaseConfig['username'], $databaseConfig['password'], @@ -1277,6 +1288,37 @@ public function requireMySQLThreadStack($server, $username, $password, $database } } + /** + * @param $server + * @param $username + * @param $password + * @param $database + * @param $testDetails + */ + public function requireNoExistingData( + $server, + $username, + $password, + $database, + $testDetails + ) { + $this->testing($testDetails); + $conn = $this->connect($server, $username, $password); + + @mysqli_select_db($conn, $database); + $contactRecords = mysqli_query($conn, "SELECT count(*) as contactscount FROM civicrm_contact"); + if ($contactRecords) { + $contactRecords = mysqli_fetch_object($contactRecords); + if ($contactRecords->contactscount > 0) { + $this->error($testDetails); + return; + } + } + + $testDetails[3] = ts('CiviCRM data from previous installation does not exists in %1.', array(1 => $database)); + $this->testing($testDetails); + } + /** * @param $server * @param string $username From 154975ba472c70fa7f43c1970fc0662d3d1a4d38 Mon Sep 17 00:00:00 2001 From: Pradeep Nayak Date: Mon, 1 Apr 2019 12:33:58 +0100 Subject: [PATCH 034/121] dev/core/issues/840, fixed notice error --- CRM/UF/Form/Group.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CRM/UF/Form/Group.php b/CRM/UF/Form/Group.php index 7c4735b712a7..43555dbc18ec 100644 --- a/CRM/UF/Form/Group.php +++ b/CRM/UF/Form/Group.php @@ -56,6 +56,13 @@ class CRM_UF_Form_Group extends CRM_Core_Form { */ protected $entityFields = []; + /** + * Deletion message to be assigned to the form. + * + * @var string + */ + protected $deleteMessage; + /** * Set entity fields to be assigned to the form. */ From 12cda498263f0a258db31865173b5df967dc6669 Mon Sep 17 00:00:00 2001 From: Alok Patel Date: Mon, 1 Apr 2019 17:50:18 +0530 Subject: [PATCH 035/121] CIVICRM-990: Unit test to make sure regular expression in Participant search works. --- CRM/Event/Form/Search.php | 75 +++++++++++++-------- tests/phpunit/CRM/Event/Form/SearchTest.php | 57 ++++++++++++++++ 2 files changed, 104 insertions(+), 28 deletions(-) create mode 100644 tests/phpunit/CRM/Event/Form/SearchTest.php diff --git a/CRM/Event/Form/Search.php b/CRM/Event/Form/Search.php index a1421cbe3a9f..78232e7ee4bb 100644 --- a/CRM/Event/Form/Search.php +++ b/CRM/Event/Form/Search.php @@ -295,36 +295,19 @@ protected function getContactTypeLabel() { } /** - * The post processing of the form gets done here. - * - * Key things done during post processing are - * - check for reset or next request. if present, skip post procesing. - * - now check if user requested running a saved search, if so, then - * the form values associated with the saved search are used for searching. - * - if user has done a submit with new values the regular post submissing is - * done. - * The processing consists of using a Selector / Controller framework for getting the - * search results. - * - * @param - * - * @return void + * Test submit the form. + * @param $formValues */ - public function postProcess() { - if ($this->_done) { - return; - } - - $this->_done = TRUE; - - if (!empty($_POST)) { - $this->_formValues = $this->controller->exportValues($this->_name); - CRM_Contact_BAO_Query::processSpecialFormValue($this->_formValues, array('participant_status_id')); - } + public function testSubmit($formValues) { + $this->submit($formValues); + } - if (empty($this->_formValues)) { - $this->_formValues = $this->controller->exportValues($this->_name); - } + /** + * Submit the search form with given values. + * @param $formValues + */ + private function submit($formValues) { + $this->_formValues = $formValues; $this->fixFormValues(); @@ -400,6 +383,42 @@ public function postProcess() { $controller->run(); } + /** + * The post processing of the form gets done here. + * + * Key things done during post processing are + * - check for reset or next request. if present, skip post procesing. + * - now check if user requested running a saved search, if so, then + * the form values associated with the saved search are used for searching. + * - if user has done a submit with new values the regular post submissing is + * done. + * The processing consists of using a Selector / Controller framework for getting the + * search results. + * + * @param + * + * @return void + */ + public function postProcess() { + if ($this->_done) { + return; + } + + $this->_done = TRUE; + $formValues = array(); + + if (!empty($_POST)) { + $formValues = $this->controller->exportValues($this->_name); + CRM_Contact_BAO_Query::processSpecialFormValue($this->_formValues, array('participant_status_id')); + } + + if (empty($this->_formValues)) { + $formValues = $this->controller->exportValues($this->_name); + } + + $this->submit($formValues); + } + /** * add the rules (mainly global rules) for form. * All local rules are added near the element diff --git a/tests/phpunit/CRM/Event/Form/SearchTest.php b/tests/phpunit/CRM/Event/Form/SearchTest.php new file mode 100644 index 000000000000..d6b22fd4390b --- /dev/null +++ b/tests/phpunit/CRM/Event/Form/SearchTest.php @@ -0,0 +1,57 @@ +individualID = $this->individualCreate(); + } + + /** + * Test that search form returns correct number of rows for complex regex filters. + */ + public function testSearch() { + $priceFieldValues = $this->createPriceSet('event', NULL, array( + 'html_type' => 'Radio', + 'option_label' => array('1' => 'Radio Label A (inc. GST)', '2' => 'Radio Label B (inc. GST)'), + 'option_name' => array('1' => 'Radio Label A', '2' => 'Radio Label B'), + )); + + $priceFieldValues = $priceFieldValues['values']; + $participantPrice = NULL; + foreach ($priceFieldValues as $priceFieldValue) { + $participantPrice = $priceFieldValue; + break; + } + + $event = $this->eventCreate(); + $individualID = $this->individualCreate(); + $today = new DateTime(); + $this->participantCreate(array( + 'event_id' => $event['id'], + 'contact_id' => $individualID, + 'status_id' => 1, + 'fee_level' => $participantPrice['label'], + 'fee_amount' => $participantPrice['amount'], + 'fee_currency' => 'USD', + 'register_date' => $today->format('YmdHis'), + )); + + $form = new CRM_Event_Form_Search(); + $form->controller = new CRM_Event_Controller_Search(); + $form->preProcess(); + $form->testSubmit(array( + 'participant_test' => 0, + 'participant_fee_id' => array( + $participantPrice['id'], + ), + 'radio_ts' => 'ts_all', + )); + $rows = $form->controller->get('rows'); + $this->assertEquals(1, count($rows), 'Exactly one row should be returned for given price field value.'); + } + +} From ac7a239e2050ecd8e7b48ed43138be046b073de0 Mon Sep 17 00:00:00 2001 From: eileen Date: Tue, 2 Apr 2019 10:39:21 +1300 Subject: [PATCH 036/121] Add cancel_reason field --- CRM/Contribute/DAO/ContributionRecur.php | 22 ++++++++++++++++- CRM/Upgrade/Incremental/php/FiveThirteen.php | 26 ++++++++------------ xml/schema/Contribute/ContributionRecur.xml | 12 +++++++++ 3 files changed, 43 insertions(+), 17 deletions(-) diff --git a/CRM/Contribute/DAO/ContributionRecur.php b/CRM/Contribute/DAO/ContributionRecur.php index c87f48afa0e2..e4642341d8cf 100644 --- a/CRM/Contribute/DAO/ContributionRecur.php +++ b/CRM/Contribute/DAO/ContributionRecur.php @@ -6,7 +6,7 @@ * * Generated from xml/schema/CRM/Contribute/ContributionRecur.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:e69f645ae471e887f56e95ee10a8678d) + * (GenCodeChecksum:2ccc42487b9e4e5774fcfcde7db9c5ae) */ /** @@ -105,6 +105,13 @@ class CRM_Contribute_DAO_ContributionRecur extends CRM_Core_DAO { */ public $cancel_date; + /** + * Free text field for a reason for cancelling + * + * @var text + */ + public $cancel_reason; + /** * Date this recurring contribution finished successfully * @@ -427,6 +434,19 @@ public static function &fields() { 'formatType' => 'activityDate', ], ], + 'contribution_recur_cancel_reason' => [ + 'name' => 'cancel_reason', + 'type' => CRM_Utils_Type::T_TEXT, + 'title' => ts('Cancellation Reason'), + 'description' => ts('Free text field for a reason for cancelling'), + 'table_name' => 'civicrm_contribution_recur', + 'entity' => 'ContributionRecur', + 'bao' => 'CRM_Contribute_BAO_ContributionRecur', + 'localizable' => 0, + 'html' => [ + 'type' => 'Text', + ], + ], 'end_date' => [ 'name' => 'end_date', 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME, diff --git a/CRM/Upgrade/Incremental/php/FiveThirteen.php b/CRM/Upgrade/Incremental/php/FiveThirteen.php index 81dc3c42fae6..d3c74f06a5f7 100644 --- a/CRM/Upgrade/Incremental/php/FiveThirteen.php +++ b/CRM/Upgrade/Incremental/php/FiveThirteen.php @@ -68,21 +68,15 @@ public function setPostUpgradeMessage(&$postUpgradeMessage, $rev) { * (change the x in the function name): */ - // /** - // * Upgrade function. - // * - // * @param string $rev - // */ - // public function upgrade_5_0_x($rev) { - // $this->addTask(ts('Upgrade DB to %1: SQL', array(1 => $rev)), 'runSql', $rev); - // $this->addTask('Do the foo change', 'taskFoo', ...); - // // Additional tasks here... - // // Note: do not use ts() in the addTask description because it adds unnecessary strings to transifex. - // // The above is an exception because 'Upgrade DB to %1: SQL' is generic & reusable. - // } - - // public static function taskFoo(CRM_Queue_TaskContext $ctx, ...) { - // return TRUE; - // } + /** + * Upgrade function. + * + * @param string $rev + */ + public function upgrade_5_13_alpha1($rev) { + $this->addTask('Add cancel reason column to civicrm_contribution_recur', 'addColumn', + 'civicrm_contribution_recur', 'cancel_reason', "text COMMENT 'Free text field for a reason for cancelling'", FALSE + ); + } } diff --git a/xml/schema/Contribute/ContributionRecur.xml b/xml/schema/Contribute/ContributionRecur.xml index 9e9145cf8a72..b492bd945305 100644 --- a/xml/schema/Contribute/ContributionRecur.xml +++ b/xml/schema/Contribute/ContributionRecur.xml @@ -147,6 +147,18 @@ activityDate + + cancel_reason + text + Cancellation Reason + contribution_recur_cancel_reason + Free text field for a reason for cancelling + + Text + 40 + + 5.13 + end_date Recurring Contribution End Date From ca809bb63e728a8a3e980a05c438310c7779804c Mon Sep 17 00:00:00 2001 From: eileen Date: Tue, 2 Apr 2019 12:24:56 +1300 Subject: [PATCH 037/121] Add shared parent for ContributionRecur forms --- CRM/Contribute/Form/CancelSubscription.php | 6 +-- CRM/Contribute/Form/ContributionRecur.php | 63 ++++++++++++++++++++++ CRM/Contribute/Form/UpdateBilling.php | 4 +- CRM/Contribute/Form/UpdateSubscription.php | 11 +--- 4 files changed, 66 insertions(+), 18 deletions(-) create mode 100644 CRM/Contribute/Form/ContributionRecur.php diff --git a/CRM/Contribute/Form/CancelSubscription.php b/CRM/Contribute/Form/CancelSubscription.php index c904f7fa9462..e596ad54ee36 100644 --- a/CRM/Contribute/Form/CancelSubscription.php +++ b/CRM/Contribute/Form/CancelSubscription.php @@ -34,7 +34,7 @@ /** * This class provides support for canceling recurring subscriptions. */ -class CRM_Contribute_Form_CancelSubscription extends CRM_Core_Form { +class CRM_Contribute_Form_CancelSubscription extends CRM_Contribute_Form_ContributionRecur { protected $_paymentProcessorObj = NULL; protected $_userContext = NULL; @@ -43,10 +43,6 @@ class CRM_Contribute_Form_CancelSubscription extends CRM_Core_Form { protected $_mid = NULL; - protected $_coid = NULL; - - protected $_crid = NULL; - protected $_selfService = FALSE; /** diff --git a/CRM/Contribute/Form/ContributionRecur.php b/CRM/Contribute/Form/ContributionRecur.php new file mode 100644 index 000000000000..8363ab5b5a05 --- /dev/null +++ b/CRM/Contribute/Form/ContributionRecur.php @@ -0,0 +1,63 @@ + Date: Tue, 2 Apr 2019 11:15:36 +1100 Subject: [PATCH 038/121] Unfork Zetacomponents mail and use patch to apply differences --- composer.json | 11 +++----- composer.lock | 28 +++++++++++++------ ...rm-custom-patches-zetacompoents-mail.patch | 25 +++++++++++++++++ 3 files changed, 49 insertions(+), 15 deletions(-) create mode 100644 tools/scripts/composer/patches/civicrm-custom-patches-zetacompoents-mail.patch diff --git a/composer.json b/composer.json index b3798a1bdb9a..fb0a9154945f 100644 --- a/composer.json +++ b/composer.json @@ -47,7 +47,7 @@ "tecnickcom/tcpdf" : "6.2.*", "totten/ca-config": "~17.05", "zetacomponents/base": "1.9.*", - "zetacomponents/mail": "dev-1.8-civi", + "zetacomponents/mail": "dev-master", "marcj/topsort": "~1.1", "phpoffice/phpword": "^0.15.0", "pear/validate_finance_creditcard": "dev-master", @@ -63,12 +63,6 @@ "pear/log": "1.13.1", "ezyang/htmlpurifier": "4.10" }, - "repositories": [ - { - "type": "git", - "url": "https://github.com/civicrm/zetacomponents-mail.git" - } - ], "scripts": { "post-install-cmd": [ "bash tools/scripts/composer/dompdf-cleanup.sh", @@ -94,6 +88,9 @@ }, "phpoffice/phpword": { "Fix handling of libxml_disable_entity_loader": "tools/scripts/composer/patches/phpword-libxml-fix-global-handling.patch" + }, + "zetacomponents/mail": { + "CiviCRM Custom Patches for ZetaCompoents mail": "tools/scripts/composer/patches/civicrm-custom-patches-zetacompoents-mail.patch" } } } diff --git a/composer.lock b/composer.lock index 15c13094c470..4e2fd42aa8fe 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "bf8e79e6741fa30ccbc5bd59416f9f16", + "content-hash": "93a9f686f7eb00fb9d766d262eedb09b", "packages": [ { "name": "civicrm/civicrm-cxn-rpc", @@ -2308,11 +2308,17 @@ }, { "name": "zetacomponents/mail", - "version": "dev-1.8-civi", + "version": "dev-master", "source": { "type": "git", - "url": "https://github.com/civicrm/zetacomponents-mail.git", - "reference": "7286a167a4ec3199ab3c69a361967d853ffbcd90" + "url": "https://github.com/zetacomponents/Mail.git", + "reference": "b60e9a543f6c3d9a9ec74452d4ff5736a1c63a77" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/zetacomponents/Mail/zipball/b60e9a543f6c3d9a9ec74452d4ff5736a1c63a77", + "reference": "b60e9a543f6c3d9a9ec74452d4ff5736a1c63a77", + "shasum": "" }, "require": { "zetacomponents/base": "~1.8" @@ -2321,11 +2327,17 @@ "zetacomponents/unit-test": "*" }, "type": "library", + "extra": { + "patches_applied": { + "CiviCRM Custom Patches for ZetaCompoents mail": "tools/scripts/composer/patches/civicrm-custom-patches-zetacompoents-mail.patch" + } + }, "autoload": { "classmap": [ "src" ] }, + "notification-url": "https://packagist.org/downloads/", "license": [ "Apache-2.0" ], @@ -2361,18 +2373,18 @@ "name": "Alexandru Stanoi" }, { - "name": "Sinisa Dukaric" + "name": "Christian Michel" }, { - "name": "Mikko Koppanen" + "name": "Sinisa Dukaric" }, { - "name": "Christian Michel" + "name": "Mikko Koppanen" } ], "description": "The component allows you construct and/or parse Mail messages conforming to the mail standard. It has support for attachments, multipart messages and HTML mail. It also interfaces with SMTP to send mail or IMAP, POP3 or mbox to retrieve e-mail.", "homepage": "https://github.com/zetacomponents", - "time": "2019-03-14T11:29:52+00:00" + "time": "2019-02-13T11:33:09+00:00" } ], "packages-dev": [], diff --git a/tools/scripts/composer/patches/civicrm-custom-patches-zetacompoents-mail.patch b/tools/scripts/composer/patches/civicrm-custom-patches-zetacompoents-mail.patch new file mode 100644 index 000000000000..effecbdbb02e --- /dev/null +++ b/tools/scripts/composer/patches/civicrm-custom-patches-zetacompoents-mail.patch @@ -0,0 +1,25 @@ +diff --git a/src/transports/imap/imap_transport.php b/src/transports/imap/imap_transport.php +index 94837cd..1542673 100644 +--- a/src/transports/imap/imap_transport.php ++++ b/src/transports/imap/imap_transport.php +@@ -1012,7 +1012,9 @@ class ezcMailImapTransport + { + // get the sizes of the messages + $tag = $this->getNextTag(); +- $query = trim( implode( ',', $messageList ) ); ++ $mailBatchSize = defined('MAIL_BATCH_SIZE') ? MAIL_BATCH_SIZE : 1000; ++ $truncatedMessageList = array_slice($messageList, 0, $mailBatchSize); ++ $query = trim( implode( ',', $truncatedMessageList ) ); + $this->connection->sendData( "{$tag} FETCH {$query} RFC822.SIZE" ); + $response = $this->getResponse( 'FETCH (' ); + $currentMessage = trim( reset( $messageList ) ); +diff --git a/tests/tutorial_examples.php b/tests/tutorial_examples.php +index 3acadc3..06f1e71 100644 +--- a/tests/tutorial_examples.php ++++ b/tests/tutorial_examples.php +@@ -1,5 +1,4 @@ + Date: Thu, 1 Nov 2018 14:40:47 -0400 Subject: [PATCH 039/121] dev/core#499 Fix CustomField Checkbox display when values are non-sorted. --- CRM/Core/BAO/CustomField.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CRM/Core/BAO/CustomField.php b/CRM/Core/BAO/CustomField.php index 1434ead03e6e..4f01a8cc9024 100644 --- a/CRM/Core/BAO/CustomField.php +++ b/CRM/Core/BAO/CustomField.php @@ -1199,8 +1199,8 @@ private static function formatDisplayValue($value, $field, $entityId = NULL) { $value = CRM_Utils_Array::explodePadded($value); } // CRM-12989 fix - if ($field['html_type'] == 'CheckBox') { - CRM_Utils_Array::formatArrayKeys($value); + if ($field['html_type'] == 'CheckBox' && $value) { + $value = CRM_Utils_Array::convertCheckboxFormatToArray($value); } $display = is_array($value) ? implode(', ', $value) : (string) $value; From 870111537e92dd563b23f8fe6607b9477a101f67 Mon Sep 17 00:00:00 2001 From: eileen Date: Tue, 2 Apr 2019 15:05:59 +1300 Subject: [PATCH 040/121] dev/core#704 Fix loss of links for recurrings with no payment_processor_id In 5.8 changes were made that remove the cancel links from recurring payments where the payment processor object doesn't load. This is appropriate for cases where there IS a processor but it's disabled. However, it is not unknown for sites to import contribution_recur records from elsewhere as data records rather than 'functional records' & it is appropriate to be able to edit those. We already have a relevant patter - loading payment processor 0 loads the manual processor (class is CRM_Core_Manual) which has functionality appropriate to non-automated flows (also known as the paylater processor). This PR switches to the function CRM_Contribute_BAO_ContributionRecur::getPaymentProcessorObject which is a skinny wrapper on CRM_Contribute_BAO_ContributionRecur::getPaymentProcessor - which itself was not actually called from core prior to this change (we didn't remove it as it was better than functions in play & hence intended to start using it again). No processor is loaded for an inactive processor so links do not appear there. --- CRM/Contribute/BAO/ContributionRecur.php | 24 +++++++++++++++++------- CRM/Contribute/Page/Tab.php | 4 ++-- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/CRM/Contribute/BAO/ContributionRecur.php b/CRM/Contribute/BAO/ContributionRecur.php index bd97845661c6..25e79ce86e0b 100644 --- a/CRM/Contribute/BAO/ContributionRecur.php +++ b/CRM/Contribute/BAO/ContributionRecur.php @@ -167,18 +167,28 @@ public static function checkDuplicate($params, &$duplicates) { * Get the payment processor (array) for a recurring processor. * * @param int $id - * @param string $mode - * - Test or NULL - all other variants are ignored. * * @return array|null */ - public static function getPaymentProcessor($id, $mode = NULL) { + public static function getPaymentProcessor($id) { $paymentProcessorID = self::getPaymentProcessorID($id); - if (!$paymentProcessorID) { - return NULL; - } + return CRM_Financial_BAO_PaymentProcessor::getPayment($paymentProcessorID); + } - return CRM_Financial_BAO_PaymentProcessor::getPayment($paymentProcessorID, $mode); + + /** + * Get the processor object for the recurring contribution record. + * + * @param int $id + * + * @return CRM_Core_Payment|NULL + * Returns a processor object or NULL if the processor is disabled. + * Note this returns the 'Manual' processor object if no processor is attached + * (since it still makes sense to update / cancel + */ + public static function getPaymentProcessorObject($id) { + $processor = self::getPaymentProcessor($id); + return is_array($processor) ? $processor['object'] : NULL; } /** diff --git a/CRM/Contribute/Page/Tab.php b/CRM/Contribute/Page/Tab.php index 2a08ede086e7..e055d79e7913 100644 --- a/CRM/Contribute/Page/Tab.php +++ b/CRM/Contribute/Page/Tab.php @@ -80,8 +80,8 @@ public static function &recurLinks($recurID = FALSE, $context = 'contribution') if ($recurID) { $links = self::$_links; - $paymentProcessorObj = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($recurID, 'recur', 'obj'); - if (!is_object($paymentProcessorObj)) { + $paymentProcessorObj = CRM_Contribute_BAO_ContributionRecur::getPaymentProcessorObject($recurID); + if (!$paymentProcessorObj) { unset($links[CRM_Core_Action::DISABLE]); unset($links[CRM_Core_Action::UPDATE]); return $links; From ebc8dcbc5a4121a68fd04048bfc78429f6689207 Mon Sep 17 00:00:00 2001 From: yashodha Date: Tue, 2 Apr 2019 13:53:58 +0530 Subject: [PATCH 041/121] (dev/core#835) Expose Registered by Participant Name field to participant report --- CRM/Report/Form/Event/ParticipantListing.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/CRM/Report/Form/Event/ParticipantListing.php b/CRM/Report/Form/Event/ParticipantListing.php index c9be9e8143de..2becb22fcef9 100644 --- a/CRM/Report/Form/Event/ParticipantListing.php +++ b/CRM/Report/Form/Event/ParticipantListing.php @@ -155,6 +155,10 @@ public function __construct() { 'registered_by_id' => array( 'title' => ts('Registered by Participant ID'), ), + 'registered_by_name' => array( + 'title' => ts('Registered by Participant Name'), + 'name' => 'registered_by_id' + ), 'source' => array( 'title' => ts('Source'), ), @@ -645,7 +649,6 @@ private function _initBasicRow(&$rows, &$entryFound, $row, $rowId, $rowNum, $typ public function alterDisplay(&$rows) { $entryFound = FALSE; $eventType = CRM_Core_OptionGroup::values('event_type'); - $financialTypes = CRM_Contribute_PseudoConstant::financialType(); $contributionStatus = CRM_Contribute_PseudoConstant::contributionStatus(); $paymentInstruments = CRM_Contribute_PseudoConstant::paymentInstrument(); @@ -694,7 +697,18 @@ public function alterDisplay(&$rows) { $entryFound = TRUE; } - // Handel value seperator in Fee Level + // Handle registered by name + if (array_key_exists('civicrm_participant_registered_by_name', $row)) { + $registeredById = $row['civicrm_participant_registered_by_name']; + if ($registeredById) { + $registeredByContactId = CRM_Core_DAO::getFieldValue("CRM_Event_DAO_Participant", $registeredById, 'contact_id', 'id'); + $rows[$rowNum]['civicrm_participant_registered_by_name'] = CRM_Contact_BAO_Contact::displayName($registeredByContactId); + $rows[$rowNum]['civicrm_participant_registered_by_name_link'] = CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $registeredByContactId, $this->_absoluteUrl); + $rows[$rowNum]['civicrm_participant_registered_by_name_hover'] = ts('View Contact Summary for Contact that registered the participant.'); + } + } + + // Handle value seperator in Fee Level if (array_key_exists('civicrm_participant_participant_fee_level', $row)) { $feeLevel = $row['civicrm_participant_participant_fee_level']; if ($feeLevel) { From d1737d2c89e1967973604c852e6230eed6e76b11 Mon Sep 17 00:00:00 2001 From: yashodha Date: Tue, 2 Apr 2019 13:58:34 +0530 Subject: [PATCH 042/121] minor fix --- CRM/Report/Form/Event/ParticipantListing.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CRM/Report/Form/Event/ParticipantListing.php b/CRM/Report/Form/Event/ParticipantListing.php index 2becb22fcef9..5524f1bb5057 100644 --- a/CRM/Report/Form/Event/ParticipantListing.php +++ b/CRM/Report/Form/Event/ParticipantListing.php @@ -157,7 +157,7 @@ public function __construct() { ), 'registered_by_name' => array( 'title' => ts('Registered by Participant Name'), - 'name' => 'registered_by_id' + 'name' => 'registered_by_id', ), 'source' => array( 'title' => ts('Source'), From 374b47a776c43afd9bd570b29f9feb120b56e469 Mon Sep 17 00:00:00 2001 From: Pradeep Nayak Date: Mon, 1 Apr 2019 21:40:19 +0100 Subject: [PATCH 043/121] dev/core/issues/842, Fixed code to update website rather delete --- CRM/Core/BAO/Website.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CRM/Core/BAO/Website.php b/CRM/Core/BAO/Website.php index bc82b73da0b0..29e118b95848 100644 --- a/CRM/Core/BAO/Website.php +++ b/CRM/Core/BAO/Website.php @@ -99,10 +99,15 @@ public static function process($params, $contactID, $skipDelete) { $ids = self::allWebsites($contactID); foreach ($params as $key => $values) { + $id = CRM_Utils_Array::value('id', $values); + if (array_key_exists($id, $ids)) { + unset($ids[$id]); + } if (empty($values['id']) && is_array($ids) && !empty($ids)) { foreach ($ids as $id => $value) { if (($value['website_type_id'] == $values['website_type_id'])) { $values['id'] = $id; + unset($ids[$id]); } } } From 1f17c8ef2789ce8124490854454f38fa9bc812ab Mon Sep 17 00:00:00 2001 From: eileen Date: Tue, 2 Apr 2019 12:37:36 +1300 Subject: [PATCH 044/121] Rationalise url variables onto shared parent for recurring contribution forms --- CRM/Contribute/Form/CancelSubscription.php | 7 +----- CRM/Contribute/Form/ContributionRecur.php | 25 ++++++++++++++++++++++ CRM/Contribute/Form/UpdateBilling.php | 4 +--- CRM/Contribute/Form/UpdateSubscription.php | 10 +-------- 4 files changed, 28 insertions(+), 18 deletions(-) diff --git a/CRM/Contribute/Form/CancelSubscription.php b/CRM/Contribute/Form/CancelSubscription.php index e596ad54ee36..1ac38e03e3ea 100644 --- a/CRM/Contribute/Form/CancelSubscription.php +++ b/CRM/Contribute/Form/CancelSubscription.php @@ -41,17 +41,13 @@ class CRM_Contribute_Form_CancelSubscription extends CRM_Contribute_Form_Contrib protected $_mode = NULL; - protected $_mid = NULL; - protected $_selfService = FALSE; /** * Set variables up before form is built. */ public function preProcess() { - $this->_mid = CRM_Utils_Request::retrieve('mid', 'Integer', $this, FALSE); - - $this->_crid = CRM_Utils_Request::retrieve('crid', 'Integer', $this, FALSE); + parent::preProcess(); if ($this->_crid) { $this->_paymentProcessorObj = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_crid, 'recur', 'obj'); $this->_subscriptionDetails = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($this->_crid); @@ -80,7 +76,6 @@ public function preProcess() { $this->assign('membershipType', CRM_Utils_Array::value($membershipTypeId, $membershipTypes)); } - $this->_coid = CRM_Utils_Request::retrieve('coid', 'Integer', $this, FALSE); if ($this->_coid) { if (CRM_Contribute_BAO_Contribution::isSubscriptionCancelled($this->_coid)) { CRM_Core_Error::fatal(ts('The recurring contribution looks to have been cancelled already.')); diff --git a/CRM/Contribute/Form/ContributionRecur.php b/CRM/Contribute/Form/ContributionRecur.php index 8363ab5b5a05..d0b1ee2873ad 100644 --- a/CRM/Contribute/Form/ContributionRecur.php +++ b/CRM/Contribute/Form/ContributionRecur.php @@ -46,6 +46,21 @@ class CRM_Contribute_Form_ContributionRecur extends CRM_Core_Form { */ protected $_crid = NULL; + /** + * The recurring contribution id, used when editing the recurring contribution. + * + * For historical reasons this duplicates _crid & since the name is more meaningful + * we should probably deprecate $_crid. + * + * @var int + */ + protected $contributionRecurID = NULL; + + /** + * @var int Membership ID + */ + protected $_mid = NULL; + /** * Explicitly declare the entity api name. */ @@ -60,4 +75,14 @@ public function getDefaultContext() { return 'create'; } + /** + * Set variables up before form is built. + */ + public function preProcess() { + $this->_mid = CRM_Utils_Request::retrieve('mid', 'Integer', $this, FALSE); + $this->_crid = CRM_Utils_Request::retrieve('crid', 'Integer', $this, FALSE); + $this->contributionRecurID = $this->_crid; + $this->_coid = CRM_Utils_Request::retrieve('coid', 'Integer', $this, FALSE); + } + } diff --git a/CRM/Contribute/Form/UpdateBilling.php b/CRM/Contribute/Form/UpdateBilling.php index eab578a3725c..03c3b80c7172 100644 --- a/CRM/Contribute/Form/UpdateBilling.php +++ b/CRM/Contribute/Form/UpdateBilling.php @@ -52,8 +52,7 @@ class CRM_Contribute_Form_UpdateBilling extends CRM_Contribute_Form_Contribution * Set variables up before form is built. */ public function preProcess() { - $this->_mid = CRM_Utils_Request::retrieve('mid', 'Integer', $this, FALSE); - $this->_crid = CRM_Utils_Request::retrieve('crid', 'Integer', $this, FALSE); + parent::preProcess(); if ($this->_crid) { $this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_crid, 'recur', 'info'); $this->_paymentProcessor['object'] = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_crid, 'recur', 'obj'); @@ -65,7 +64,6 @@ public function preProcess() { } } - $this->_coid = CRM_Utils_Request::retrieve('coid', 'Integer', $this, FALSE); if ($this->_coid) { $this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_coid, 'contribute', 'info'); $this->_paymentProcessor['object'] = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_coid, 'contribute', 'obj'); diff --git a/CRM/Contribute/Form/UpdateSubscription.php b/CRM/Contribute/Form/UpdateSubscription.php index 2b713af9206b..c1a092e53cbe 100644 --- a/CRM/Contribute/Form/UpdateSubscription.php +++ b/CRM/Contribute/Form/UpdateSubscription.php @@ -39,13 +39,6 @@ */ class CRM_Contribute_Form_UpdateSubscription extends CRM_Contribute_Form_ContributionRecur { - /** - * The recurring contribution id, used when editing the recurring contribution. - * - * @var int - */ - protected $contributionRecurID = NULL; - protected $_subscriptionDetails = NULL; protected $_selfService = FALSE; @@ -75,9 +68,9 @@ class CRM_Contribute_Form_UpdateSubscription extends CRM_Contribute_Form_Contrib */ public function preProcess() { + parent::preProcess(); $this->setAction(CRM_Core_Action::UPDATE); - $this->contributionRecurID = CRM_Utils_Request::retrieve('crid', 'Integer', $this, FALSE); if ($this->contributionRecurID) { try { $this->_paymentProcessorObj = CRM_Financial_BAO_PaymentProcessor::getPaymentProcessorForRecurringContribution($this->contributionRecurID); @@ -91,7 +84,6 @@ public function preProcess() { $this->_subscriptionDetails = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($this->contributionRecurID); } - $this->_coid = CRM_Utils_Request::retrieve('coid', 'Integer', $this, FALSE); if ($this->_coid) { $this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_coid, 'contribute', 'info'); // @todo test & replace with $this->_paymentProcessorObj = Civi\Payment\System::singleton()->getById($this->_paymentProcessor['id']); From c00a5ba42a924e05f33718391c45875604e680ad Mon Sep 17 00:00:00 2001 From: Mathieu Lutfy Date: Mon, 1 Apr 2019 10:39:57 -0400 Subject: [PATCH 045/121] Event Cart: Fix PHP 7.2 fatal error (pass by ref). --- CRM/Event/Cart/Form/Cart.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CRM/Event/Cart/Form/Cart.php b/CRM/Event/Cart/Form/Cart.php index 3f4f23a31930..8b7fc363269b 100644 --- a/CRM/Event/Cart/Form/Cart.php +++ b/CRM/Event/Cart/Form/Cart.php @@ -152,7 +152,7 @@ public static function find_or_create_contact($registeringContactID = NULL, $fie $no_fields = array(); $contact_id = CRM_Contact_BAO_Contact::createProfileContact($contact_params, $no_fields, NULL); if (!$contact_id) { - CRM_Core_Error::displaySessionError("Could not create or match a contact with that email address. Please contact the webmaster."); + CRM_Core_Session::setStatus(ts("Could not create or match a contact with that email address. Please contact the webmaster."), '', 'error'); } return $contact_id; } From 0563bca39f9bab15f9465ffc3ecf62a3e71da50d Mon Sep 17 00:00:00 2001 From: Mathieu Lutfy Date: Tue, 2 Apr 2019 16:59:04 -0400 Subject: [PATCH 046/121] Fix status type (error, not fail) for CRM_Core_Session::setStatus --- CRM/Mailing/Form/Optout.php | 3 +-- CRM/Mailing/Form/Unsubscribe.php | 7 +++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/CRM/Mailing/Form/Optout.php b/CRM/Mailing/Form/Optout.php index 91c667d0b12f..97c951cc40e5 100644 --- a/CRM/Mailing/Form/Optout.php +++ b/CRM/Mailing/Form/Optout.php @@ -113,12 +113,11 @@ public function postProcess() { } elseif ($result == FALSE) { // Email address not verified - $statusMsg = ts('The email address: %1 you have entered does not match the email associated with this opt out request.', array(1 => $values['email_confirm']) ); - CRM_Core_Session::setStatus($statusMsg, '', 'fail'); + CRM_Core_Session::setStatus($statusMsg, '', 'error'); } } diff --git a/CRM/Mailing/Form/Unsubscribe.php b/CRM/Mailing/Form/Unsubscribe.php index 6ca1525b7e8a..a348b4076072 100644 --- a/CRM/Mailing/Form/Unsubscribe.php +++ b/CRM/Mailing/Form/Unsubscribe.php @@ -72,7 +72,7 @@ public function preProcess() { $statusMsg = ts('Email: %1 has been successfully unsubscribed from this Mailing List/Group.', array(1 => $email) ); - CRM_Core_Session::setStatus($statusMsg, '', 'fail'); + CRM_Core_Session::setStatus($statusMsg, '', 'error'); } $this->assign('groupExist', $groupExist); @@ -116,8 +116,8 @@ public function postProcess() { if ($result == TRUE) { // Email address verified - $groups = CRM_Mailing_Event_BAO_Unsubscribe::unsub_from_mailing($job_id, $queue_id, $hash); + if (count($groups)) { CRM_Mailing_Event_BAO_Unsubscribe::send_unsub_response($queue_id, $groups, FALSE, $job_id); } @@ -130,12 +130,11 @@ public function postProcess() { } elseif ($result == FALSE) { // Email address not verified - $statusMsg = ts('The email address: %1 you have entered does not match the email associated with this unsubscribe request.', array(1 => $values['email_confirm']) ); - CRM_Core_Session::setStatus($statusMsg, '', 'fail'); + CRM_Core_Session::setStatus($statusMsg, '', 'error'); } From 19381641748a22f13d0ba1acd4b18b54cbb84ab4 Mon Sep 17 00:00:00 2001 From: Mark Hanna Date: Tue, 2 Apr 2019 10:19:47 -0500 Subject: [PATCH 047/121] get state_province_id given non numeric country_id or country parameter for APIv3 Address --- api/v3/utils.php | 51 ++++++++++++++++++++++++++-- tests/phpunit/api/v3/AddressTest.php | 39 +++++++++++++++++++++ 2 files changed, 88 insertions(+), 2 deletions(-) diff --git a/api/v3/utils.php b/api/v3/utils.php index b13b31aa9dcc..de3253668a41 100644 --- a/api/v3/utils.php +++ b/api/v3/utils.php @@ -2070,8 +2070,11 @@ function _civicrm_api3_validate_integer(&$params, $fieldName, &$fieldInfo, $enti } if (!empty($fieldInfo['pseudoconstant']) || !empty($fieldInfo['options'])) { $additional_lookup_params = []; - if (strtolower($entity) == 'address' && $fieldName == 'state_province_id' && !empty($params['country_id'])) { - $additional_lookup_params = ['country_id' => $params['country_id']]; + if (strtolower($entity) == 'address' && $fieldName == 'state_province_id') { + $country_id = _civicrm_api3_resolve_country_id($params); + if (!empty($country_id)) { + $additional_lookup_params = ['country_id' => $country_id]; + } } _civicrm_api3_api_match_pseudoconstant($fieldValue, $entity, $fieldName, $fieldInfo, $op, $additional_lookup_params); } @@ -2100,6 +2103,50 @@ function _civicrm_api3_validate_integer(&$params, $fieldName, &$fieldInfo, $enti } } +/** + * Helper function to determine country_id given the myriad of values for country_id or country that are supported + * @param $params + * + * @return int|null + */ +function _civicrm_api3_resolve_country_id($params) { + if (!empty($params['country_id'])) { + if (is_numeric($params['country_id'])) { + $country_id = $params['country_id']; + } + else { + $country = new CRM_Core_DAO_Country(); + $country->name = $params['country_id']; + if (!$country->find(TRUE)) { + $country->name = NULL; + $country->iso_code = $params['country_id']; + $country->find(TRUE); + } + if (!empty($country->id)) { + $country_id = $country->id; + } + } + } + elseif (!empty($params['country'])) { + if (is_numeric($params['country'])) { + $country_id = $params['country']; + } + else { + $country = new CRM_Core_DAO_Country(); + $country->name = $params['country']; + if (!$country->find(TRUE)) { + $country->name = NULL; + $country->iso_code = $params['country']; + $country->find(TRUE); + } + if (!empty($country->id)) { + $country_id = $country->id; + } + } + } + return !empty($country_id) ? $country_id : NULL; +} + /** * Determine a contact ID using a string expression. * diff --git a/tests/phpunit/api/v3/AddressTest.php b/tests/phpunit/api/v3/AddressTest.php index 31d1cb6207ff..0307114cccf1 100644 --- a/tests/phpunit/api/v3/AddressTest.php +++ b/tests/phpunit/api/v3/AddressTest.php @@ -436,4 +436,43 @@ public function testCreateAddressStateProvinceIDCorrectForCountry() { $this->assertEquals('3497', $address2['values'][0]['state_province_id']); } + public function getSymbolicCountryStateExamples() { + return [ + // [mixed $inputCountry, mixed $inputState, int $expectCountry, int $expectState] + [1228, 1004, 1228, 1004], + //['US', 'CA', 1228, 1004], + //['US', 'TX', 1228, 1042], + ['US', 'California', 1228, 1004], + [1228, 'Texas', 1228, 1042], + // Don't think these have been supported? + // ['United States', 1004, 1228, 1004] , + // ['United States', 'TX', 1228, 1042], + ]; + } + + /** + * @param mixed $inputCountry + * Ex: 1228 or 'US' + * @param mixed $inputState + * Ex: 1004 or 'CA' + * @param int $expectCountry + * @param int $expectState + * @dataProvider getSymbolicCountryStateExamples + */ + public function testCreateAddressSymbolicCountryAndState($inputCountry, $inputState, $expectCountry, $expectState) { + $cid = $this->individualCreate(); + $r = $this->callAPISuccess('Address', 'create', [ + 'contact_id' => $cid, + 'location_type_id' => 1, + 'street_address' => '123 Some St', + 'city' => 'Hereville', + 'country_id' => $inputCountry, //'US', + 'state_province_id' => $inputState, // 'California', + 'postal_code' => '94100', + ]); + $created = CRM_Utils_Array::first($r['values']); + $this->assertEquals($expectCountry, $created['country_id']); + $this->assertEquals($expectState, $created['state_province_id']); + } + } From bd491b4cbf9b72aae650e20374b416f28d5e8ede Mon Sep 17 00:00:00 2001 From: Pradeep Nayak Date: Wed, 3 Apr 2019 17:41:16 +0100 Subject: [PATCH 048/121] dev/core/issues/823, fixed code to set contact type correctly --- CRM/Profile/Form.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/CRM/Profile/Form.php b/CRM/Profile/Form.php index 9b5beb25cff9..ac050c485da1 100644 --- a/CRM/Profile/Form.php +++ b/CRM/Profile/Form.php @@ -678,14 +678,6 @@ public function setDefaultsValues() { $this->removeFileRequiredRules('image_URL'); } - if (array_key_exists('contact_sub_type', $this->_defaults) && - !empty($this->_defaults['contact_sub_type']) - ) { - $this->_defaults['contact_sub_type'] = explode(CRM_Core_DAO::VALUE_SEPARATOR, - trim($this->_defaults['contact_sub_type'], CRM_Core_DAO::VALUE_SEPARATOR) - ); - } - $this->setDefaults($this->_defaults); } From b7327f073b11752a8b607028c982b258e059d647 Mon Sep 17 00:00:00 2001 From: "Matthew Wire (MJW Consulting)" Date: Mon, 25 Feb 2019 14:42:33 +0000 Subject: [PATCH 049/121] Add payment_processor_id to recurring contribution report --- CRM/Report/Form/Contribute/Recur.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/CRM/Report/Form/Contribute/Recur.php b/CRM/Report/Form/Contribute/Recur.php index 8e966772f2e9..7d1f6309c56c 100644 --- a/CRM/Report/Form/Contribute/Recur.php +++ b/CRM/Report/Form/Contribute/Recur.php @@ -179,6 +179,9 @@ public function __construct() { 'failure_retry_date' => array( 'title' => ts('Failure Retry Date'), ), + 'payment_processor_id' => array( + 'title' => ts('Payment Processor'), + ), ), 'filters' => array( 'contribution_status_id' => array( @@ -245,6 +248,13 @@ public function __construct() { 'operatorType' => CRM_Report_Form::OP_DATE, 'pseudofield' => TRUE, ), + 'payment_processor_id' => array( + 'title' => ts('Payment Processor'), + 'operatorType' => CRM_Report_Form::OP_MULTISELECT, + 'options' => CRM_Contribute_BAO_ContributionRecur::buildOptions('payment_processor_id', 'get'), + 'default' => NULL, + 'type' => CRM_Utils_Type::T_INT, + ), ), ), ); @@ -390,6 +400,10 @@ public function alterDisplay(&$rows) { if (!empty($row['civicrm_financial_trxn_card_type_id'])) { $rows[$rowNum]['civicrm_financial_trxn_card_type_id'] = $this->getLabels($row['civicrm_financial_trxn_card_type_id'], 'CRM_Financial_DAO_FinancialTrxn', 'card_type_id'); } + + if (!empty($row['civicrm_contribution_recur_payment_processor_id'])) { + $rows[$rowNum]['civicrm_contribution_recur_payment_processor_id'] = $this->getLabels($row['civicrm_contribution_recur_payment_processor_id'], 'CRM_Contribute_BAO_ContributionRecur', 'payment_processor_id'); + } } } From 342f3ec4619a6d7ab2eba484fe45e236ee6b97df Mon Sep 17 00:00:00 2001 From: Alice Frumin Date: Tue, 19 Mar 2019 13:57:20 -0400 Subject: [PATCH 050/121] 5.12.0 release notes: reorganizing --- release-notes/5.12.0.md | 375 ++++++++++++++++++++-------------------- 1 file changed, 191 insertions(+), 184 deletions(-) diff --git a/release-notes/5.12.0.md b/release-notes/5.12.0.md index aa87553f8a92..dec8b3508a9a 100644 --- a/release-notes/5.12.0.md +++ b/release-notes/5.12.0.md @@ -19,142 +19,140 @@ Released April 3, 2019 ### Core CiviCRM -- **dev/core#801 Fix from email on PDF Letters, such as Thank You Letters. ([13825](https://github.com/civicrm/civicrm-core/pull/13825))** +- **dev/report#7 fix trxn_date on bookkeeping report ([13571](https://github.com/civicrm/civicrm-core/pull/13571))** -- **dev/core#790 - Exclue menubar on frontend pages ([13820](https://github.com/civicrm/civicrm-core/pull/13820))** +- **reporting#8 - add thank-you dates to Contribution Summary/Detail reports ([13653](https://github.com/civicrm/civicrm-core/pull/13653))** -- **dev/core#659 Catch payment processor exceptions, log, hide, do not return 500 error ([13796](https://github.com/civicrm/civicrm-core/pull/13796))** +- **reporting#9: parity between getContactFields and getBasicContactFields ([13657](https://github.com/civicrm/civicrm-core/pull/13657))** -- **Fix unrelased regression where activity date relative filters are ingnored in the rc ([13801](https://github.com/civicrm/civicrm-core/pull/13801))** +- **test for reporting#10 ([13678](https://github.com/civicrm/civicrm-core/pull/13678))** -- **(ops#878) (Fast)ArrayDecorator - Emit expected exception when using WP and strict PSR-16 ([13808](https://github.com/civicrm/civicrm-core/pull/13808))** +- **reporting-11 - fix Soft Credit report with full group by ([13671](https://github.com/civicrm/civicrm-core/pull/13671))** -- **Merge forward 5.11 => master ([13777](https://github.com/civicrm/civicrm-core/pull/13777))** +- **dev/core#397 Dedupe for Individual Birth Date Results in Error ([13538](https://github.com/civicrm/civicrm-core/pull/13538))** -- **Remove mcrypt system status check ([13770](https://github.com/civicrm/civicrm-core/pull/13770))** +- **dev/core#469 Fix Error on action 'Email - schedule/send via CiviMail' with multiple event names filter ([13539](https://github.com/civicrm/civicrm-core/pull/13539))** -- **Fix api bug whereby 0 & '0' are not accepted as range parameters for BETWEEN ([13766](https://github.com/civicrm/civicrm-core/pull/13766))** +- **dev/core#561 Upgrade age_asof_date to datepicker in search ([13704](https://github.com/civicrm/civicrm-core/pull/13704))** -- **Render Note field tokens correctly - they are already HTML. ([13283](https://github.com/civicrm/civicrm-core/pull/13283))** +- **dev/core#562 Remove free calls from Activity and Member sections of CRM ([13560](https://github.com/civicrm/civicrm-core/pull/13560))** + +- **fixes core#580 - view all groups when appropriately permissioned ([13373](https://github.com/civicrm/civicrm-core/pull/13373))** + +- **dev/core#631 - Enable 'add new' by default on merge screen ([13588](https://github.com/civicrm/civicrm-core/pull/13588))** - **dev/core#644 fix from address before calling hook ([13776](https://github.com/civicrm/civicrm-core/pull/13776))** -- **[REF] separate financial handling & component transitioning in Payment.create ([13756](https://github.com/civicrm/civicrm-core/pull/13756))** +- **dev/core#657 - Add filter for country on Repeat Contributions Report ([13432](https://github.com/civicrm/civicrm-core/pull/13432))** -- **Fix typo in comments ([13771](https://github.com/civicrm/civicrm-core/pull/13771))** +- **dev/core#659 Catch payment processor exceptions, log, hide, do not return 500 error ([13796](https://github.com/civicrm/civicrm-core/pull/13796))** -- **Removes redundant IF ([13769](https://github.com/civicrm/civicrm-core/pull/13769))** +- **fixes dev/core#683 Incorrectly encoded state and country names ([13591](https://github.com/civicrm/civicrm-core/pull/13591))** -- **[REF] towards cleanup of update membership code ([13759](https://github.com/civicrm/civicrm-core/pull/13759))** +- **dev/core#684 - Case Manager not updating correctly ([13528](https://github.com/civicrm/civicrm-core/pull/13528))** -- **Extract getSearchSQLParts function ([13735](https://github.com/civicrm/civicrm-core/pull/13735))** +- **dev/core#690 - Civi\API - Fix entity permission check for trusted calls ([13529](https://github.com/civicrm/civicrm-core/pull/13529))** -- **Convert activity_date_time field to datepicker and add support for url input ([13746](https://github.com/civicrm/civicrm-core/pull/13746))** +- **dev/core#691 Make default country optional on setting form ([13523](https://github.com/civicrm/civicrm-core/pull/13523))** -- **Speed up contribution results by removing join on civicrm_financial_type table when rendering search results. ([13720](https://github.com/civicrm/civicrm-core/pull/13720))** +- **(dev/core#696) Changes to copied event phone and email reflects in or… ([13534](https://github.com/civicrm/civicrm-core/pull/13534))** -- **Try and add data set example where email_on_hold / on_hold is NULL in… ([13765](https://github.com/civicrm/civicrm-core/pull/13765))** +- **dev/core/issues/700, Show Qill when searched using contact id ([13549](https://github.com/civicrm/civicrm-core/pull/13549))** -- **Upgrade Karma version to latest version ([13751](https://github.com/civicrm/civicrm-core/pull/13751))** +- **(dev/core#705) Disabling Alphabetical Pager is not respected for cont… ([13592](https://github.com/civicrm/civicrm-core/pull/13592))** -- **Rationalise Activity api ACLs for consistency, to respect the hook & improve performance ([13664](https://github.com/civicrm/civicrm-core/pull/13664))** +- **dev/core#708, Fix Qill for Added by and Modified By ([13566](https://github.com/civicrm/civicrm-core/pull/13566))** -- **report clean up - remove redundant code ([13761](https://github.com/civicrm/civicrm-core/pull/13761))** +- **dev/core/issues/714, Inline edit should be disabled if user doesn't have edit group permission ([13573](https://github.com/civicrm/civicrm-core/pull/13573))** -- **dev/core#767 Add 'Cancelled / Refunded Date' and 'Cancellation / Refund Reason' ([13726](https://github.com/civicrm/civicrm-core/pull/13726))** +- **/dev/core#716 - Add decimals in Contribution Amount on Repeat Contrib… ([13659](https://github.com/civicrm/civicrm-core/pull/13659))** -- **5.11 ([13760](https://github.com/civicrm/civicrm-core/pull/13760))** +- **dev/core#720 [REF] refactor out components of contributionSummary function ([13607](https://github.com/civicrm/civicrm-core/pull/13607))** -- **reporting#8 - add thank-you dates to Contribution Summary/Detail reports ([13653](https://github.com/civicrm/civicrm-core/pull/13653))** +- **dev/core#720 Remove median & mode stats from contribution summary in order to improve performance ([13630](https://github.com/civicrm/civicrm-core/pull/13630))** -- **[REF] extract getToFinancialAccount from CRM_Contribute_PseudoConstantt::contributionStatus ([13757](https://github.com/civicrm/civicrm-core/pull/13757))** +- **dev/core#720 add unit test, remove legacy code style. ([13605](https://github.com/civicrm/civicrm-core/pull/13605))** -- **[ref] Extract activity payment creation ([13695](https://github.com/civicrm/civicrm-core/pull/13695))** +- **dev/core#735 Do not include product in search results if site has none ([13638](https://github.com/civicrm/civicrm-core/pull/13638))** -- **Fix Custom post outer div class on event registration form ([13753](https://github.com/civicrm/civicrm-core/pull/13753))** +- **dev/core#739 Fix case detail report breaking when sorted by case type. ([13666](https://github.com/civicrm/civicrm-core/pull/13666))** -- **dev/core#770 - View Case Activity page displays disabled custom fields ([13741](https://github.com/civicrm/civicrm-core/pull/13741))** +- **dev/core#742 Fix XML parasing by swapping & for , ([13654](https://github.com/civicrm/civicrm-core/pull/13654))** -- **Clean up Payment.create function ([13690](https://github.com/civicrm/civicrm-core/pull/13690))** +- **dev/core#746 Add in unit tests to ensure that where clause is as is w… ([13685](https://github.com/civicrm/civicrm-core/pull/13685))** -- **fix broken logic in CRM_Utils_System_DrupalBase::formatResourceUrl() ([13400](https://github.com/civicrm/civicrm-core/pull/13400))** +- **dev/core#748 Move UPPER() from sql to php domain ([13732](https://github.com/civicrm/civicrm-core/pull/13732))** -- **5.11 ([13750](https://github.com/civicrm/civicrm-core/pull/13750))** +- **dev/core#767 Add 'Cancelled / Refunded Date' and 'Cancellation / Refund Reason' ([13726](https://github.com/civicrm/civicrm-core/pull/13726))** -- **merge 5.11 to master ([13747](https://github.com/civicrm/civicrm-core/pull/13747))** +- **dev/core#769 - Fix for ZipArchive->open() PHP bug ([13728](https://github.com/civicrm/civicrm-core/pull/13728))** -- **Allow viewing of cancelled recurring contributions ([13745](https://github.com/civicrm/civicrm-core/pull/13745))** +- **dev/core#770 - View Case Activity page displays disabled custom fields ([13741](https://github.com/civicrm/civicrm-core/pull/13741))** -- **Upgrader: Don't abort if state_province already exists ([13744](https://github.com/civicrm/civicrm-core/pull/13744))** +- **dev/core#790 - Exclue menubar on frontend pages ([13820](https://github.com/civicrm/civicrm-core/pull/13820))** -- **dev/core#708, Fix Qill for Added by and Modified By ([13566](https://github.com/civicrm/civicrm-core/pull/13566))** +- **dev/core#801 Fix from email on PDF Letters, such as Thank You Letters. ([13825](https://github.com/civicrm/civicrm-core/pull/13825))** -- **Fix the invocation of post hook for ParticipantPayment ensuring that … ([13739](https://github.com/civicrm/civicrm-core/pull/13739))** +- **(ops#878) (Fast)ArrayDecorator - Emit expected exception when using WP and strict PSR-16 ([13808](https://github.com/civicrm/civicrm-core/pull/13808))** -- **Decommision getPartialPaymentTrxn function ([13718](https://github.com/civicrm/civicrm-core/pull/13718))** +- **Remove mcrypt system status check ([13770](https://github.com/civicrm/civicrm-core/pull/13770))** -- **5.11 ([13740](https://github.com/civicrm/civicrm-core/pull/13740))** +- **Fix api bug whereby 0 & '0' are not accepted as range parameters for BETWEEN ([13766](https://github.com/civicrm/civicrm-core/pull/13766))** -- **Status of test contribution is not fetched on ThankYou page. ([13724](https://github.com/civicrm/civicrm-core/pull/13724))** +- **Render Note field tokens correctly - they are already HTML. ([13283](https://github.com/civicrm/civicrm-core/pull/13283))** -- **CiviCRM Membership Detail report, add column to display if membership is Primary or Inherited ([13736](https://github.com/civicrm/civicrm-core/pull/13736))** +- **Extract getSearchSQLParts function ([13735](https://github.com/civicrm/civicrm-core/pull/13735))** -- **dev/core#769 - Fix for ZipArchive->open() PHP bug ([13728](https://github.com/civicrm/civicrm-core/pull/13728))** +- **Convert activity_date_time field to datepicker and add support for url input ([13746](https://github.com/civicrm/civicrm-core/pull/13746))** -- **dev/core#748 Move UPPER() from sql to php domain ([13732](https://github.com/civicrm/civicrm-core/pull/13732))** +- **Speed up contribution results by removing join on civicrm_financial_type table when rendering search results. ([13720](https://github.com/civicrm/civicrm-core/pull/13720))** -- **5.11 ([13730](https://github.com/civicrm/civicrm-core/pull/13730))** +- **Try and add data set example where email_on_hold / on_hold is NULL in… ([13765](https://github.com/civicrm/civicrm-core/pull/13765))** -- **[REF] Extract lines to add the pseudoconstant to the select ([13717](https://github.com/civicrm/civicrm-core/pull/13717))** +- **Upgrade Karma version to latest version ([13751](https://github.com/civicrm/civicrm-core/pull/13751))** -- **Mark de.systopia.recentitems obsolete ([13729](https://github.com/civicrm/civicrm-core/pull/13729))** +- **Rationalise Activity api ACLs for consistency, to respect the hook & improve performance ([13664](https://github.com/civicrm/civicrm-core/pull/13664))** -- **5.11 to master ([13722](https://github.com/civicrm/civicrm-core/pull/13722))** +- **Fix Custom post outer div class on event registration form ([13753](https://github.com/civicrm/civicrm-core/pull/13753))** -- **dev/core#561 Upgrade age_asof_date to datepicker in search ([13704](https://github.com/civicrm/civicrm-core/pull/13704))** +- **Clean up Payment.create function ([13690](https://github.com/civicrm/civicrm-core/pull/13690))** -- **Upgrade PHPWord ([13686](https://github.com/civicrm/civicrm-core/pull/13686))** +- **fix broken logic in CRM_Utils_System_DrupalBase::formatResourceUrl() ([13400](https://github.com/civicrm/civicrm-core/pull/13400))** -- **[minor cleanup] reduce params passed to searchQuery ([13715](https://github.com/civicrm/civicrm-core/pull/13715))** +- **Allow viewing of cancelled recurring contributions ([13745](https://github.com/civicrm/civicrm-core/pull/13745))** -- **Migrate date field to datepicker on ChangeCaseType form ([13701](https://github.com/civicrm/civicrm-core/pull/13701))** +- **Upgrader: Don't abort if state_province already exists ([13744](https://github.com/civicrm/civicrm-core/pull/13744))** -- **[REF] Extract recordPayment portion ([13692](https://github.com/civicrm/civicrm-core/pull/13692))** +- **Fix the invocation of post hook for ParticipantPayment ensuring that … ([13739](https://github.com/civicrm/civicrm-core/pull/13739))** -- **Merge 5.11 to master ([13710](https://github.com/civicrm/civicrm-core/pull/13710))** +- **Decommision getPartialPaymentTrxn function ([13718](https://github.com/civicrm/civicrm-core/pull/13718))** -- **Move assign of currency for entityForm outside of foreach so order of fields don't matter ([13696](https://github.com/civicrm/civicrm-core/pull/13696))** +- **Status of test contribution is not fetched on ThankYou page. ([13724](https://github.com/civicrm/civicrm-core/pull/13724))** -- **[TEST FIX] Increase uniqueness in testSingleNowDates ([13705](https://github.com/civicrm/civicrm-core/pull/13705))** +- **CiviCRM Membership Detail report, add column to display if membership is Primary or Inherited ([13736](https://github.com/civicrm/civicrm-core/pull/13736))** -- **dev/core#735 Do not include product in search results if site has none ([13638](https://github.com/civicrm/civicrm-core/pull/13638))** +- **Mark de.systopia.recentitems obsolete ([13729](https://github.com/civicrm/civicrm-core/pull/13729))** + +- **Upgrade PHPWord ([13686](https://github.com/civicrm/civicrm-core/pull/13686))** + +- **Migrate date field to datepicker on ChangeCaseType form ([13701](https://github.com/civicrm/civicrm-core/pull/13701))** -- **Code cleanup - remove extraneous permissions clause ([13645](https://github.com/civicrm/civicrm-core/pull/13645))** +- **Move assign of currency for entityForm outside of foreach so order of fields don't matter ([13696](https://github.com/civicrm/civicrm-core/pull/13696))** - **Fix & test searchQuery order by to be less dependent on what is selected for search ([13680](https://github.com/civicrm/civicrm-core/pull/13680))** - **Add pseudoconstant for payment_processor_id to contributionrecur ([13702](https://github.com/civicrm/civicrm-core/pull/13702))** -- **dev/core#739 Fix case detail report breaking when sorted by case type. ([13666](https://github.com/civicrm/civicrm-core/pull/13666))** - - **Phase out CIVICRM_TEMP_FORCE_UTF8 ([13658](https://github.com/civicrm/civicrm-core/pull/13658))** -- **[REF] minor refactor around retrieving processor id for recur ([13643](https://github.com/civicrm/civicrm-core/pull/13643))** - - **Extract record refund function ([13694](https://github.com/civicrm/civicrm-core/pull/13694))** - **Migrate KAM smartmenus to core ([13582](https://github.com/civicrm/civicrm-core/pull/13582))** -- **Revert "[REF] Extract record refund function" ([13693](https://github.com/civicrm/civicrm-core/pull/13693))** - -- **[REF] Extract record refund function ([13691](https://github.com/civicrm/civicrm-core/pull/13691))** - - **Move pear/mail from packages to composer.json ([13289](https://github.com/civicrm/civicrm-core/pull/13289))** - **Do not attempt to store out-of-range street number ([13340](https://github.com/civicrm/civicrm-core/pull/13340))** -- **[REF] Extract getSearchSQL from getSearchQuery. ([13668](https://github.com/civicrm/civicrm-core/pull/13668))** - - **Use CRM_Utils_SQL_TempTable to drop and create table. ([13688](https://github.com/civicrm/civicrm-core/pull/13688))** - **Record change log entry when contact is moved to or restored from trash ([13276](https://github.com/civicrm/civicrm-core/pull/13276))** @@ -163,12 +161,6 @@ Released April 3, 2019 - **Towards supporting EntityForm for 'View Action' ([13578](https://github.com/civicrm/civicrm-core/pull/13578))** -- **dev/core#631 - Enable 'add new' by default on merge screen ([13588](https://github.com/civicrm/civicrm-core/pull/13588))** - -- **reporting#9: parity between getContactFields and getBasicContactFields ([13657](https://github.com/civicrm/civicrm-core/pull/13657))** - -- **dev/core#742 Fix XML parasing by swapping & for , ([13654](https://github.com/civicrm/civicrm-core/pull/13654))** - - **only set custom field to null if it is really null, not string 'null' ([13042](https://github.com/civicrm/civicrm-core/pull/13042))** - **CiviMail: Fix reply forwarding for mailers with From: and Return-path: limitations ([12641](https://github.com/civicrm/civicrm-core/pull/12641))** @@ -177,205 +169,220 @@ Released April 3, 2019 - **Force utf8mb4 query to throw exception as the check expects ([13682](https://github.com/civicrm/civicrm-core/pull/13682))** -- **Minor code cleanup ([13687](https://github.com/civicrm/civicrm-core/pull/13687))** - -- **[NFC, test class] formatting, remove unused variables ([13634](https://github.com/civicrm/civicrm-core/pull/13634))** - -- **Refactor CRM_Utils_SQL_TempTable::build()->createWithQuery($sql) interface to support MEMORY tabls ([13644](https://github.com/civicrm/civicrm-core/pull/13644))** - -- **dev/core#746 Add in unit tests to ensure that where clause is as is w… ([13685](https://github.com/civicrm/civicrm-core/pull/13685))** - -- **5.11 ([13684](https://github.com/civicrm/civicrm-core/pull/13684))** - - **Payment notification formatting, move greeting into table ([13669](https://github.com/civicrm/civicrm-core/pull/13669))** - **CRM/Logging - Fix log table exceptions ([13675](https://github.com/civicrm/civicrm-core/pull/13675))** -- **test for reporting#10 ([13678](https://github.com/civicrm/civicrm-core/pull/13678))** - -- **reporting-11 - fix Soft Credit report with full group by ([13671](https://github.com/civicrm/civicrm-core/pull/13671))** - -- **5.11 to master ([13676](https://github.com/civicrm/civicrm-core/pull/13676))** - -- **REF Convert deprecated functions to buildOptions for case ([13364](https://github.com/civicrm/civicrm-core/pull/13364))** - - **Switch additional payment form to use Payment.sendconfirmation api ([13649](https://github.com/civicrm/civicrm-core/pull/13649))** -- **5.11 to master ([13661](https://github.com/civicrm/civicrm-core/pull/13661))** - -- **/dev/core#716 - Add decimals in Contribution Amount on Repeat Contrib… ([13659](https://github.com/civicrm/civicrm-core/pull/13659))** - -- **[REF] minor code cleanup - do not build order var just to hurt brains ([13650](https://github.com/civicrm/civicrm-core/pull/13650))** - -- **[REF] minor cleanup of groupBy definition. ([13656](https://github.com/civicrm/civicrm-core/pull/13656))** - - **Update Payment Notification to use greeting, remove text to 'Please print this confirmation for your records. ([13655](https://github.com/civicrm/civicrm-core/pull/13655))** -- **Payment.sendconfirmation api - add further tpl variables. ([13610](https://github.com/civicrm/civicrm-core/pull/13610))** - -- **Authorizenet test - reduce chance of intermittent fails ([13642](https://github.com/civicrm/civicrm-core/pull/13642))** - -- **[unused code cleanup] Remove unused 'signupType' url support ([13620](https://github.com/civicrm/civicrm-core/pull/13620))** - -- **Payment.sendconfirmation api - add further tpl variables. ([13609](https://github.com/civicrm/civicrm-core/pull/13609))** - -- **(dev/core#696) Changes to copied event phone and email reflects in or… ([13534](https://github.com/civicrm/civicrm-core/pull/13534))** - -- **5.11 ([13639](https://github.com/civicrm/civicrm-core/pull/13639))** +- **Payment.sendconfirmation api - add further tpl variables. ([13610](https://github.com/civicrm/civicrm-core/pull/13610) and [13609](https://github.com/civicrm/civicrm-core/pull/13609))** - **Remove another instance of 'lower' ([13636](https://github.com/civicrm/civicrm-core/pull/13636))** -- **dev/core#720 Remove median & mode stats from contribution summary in order to improve performance ([13630](https://github.com/civicrm/civicrm-core/pull/13630))** - -- **[Test changes] Mailing job test use ([13629](https://github.com/civicrm/civicrm-core/pull/13629))** - - **Fix html2pdf default PDF format when multiple pdf_format are available. ([13543](https://github.com/civicrm/civicrm-core/pull/13543))** - ** EntityRef - standardize on PascalCase for entity name and fix minor bug ([13631](https://github.com/civicrm/civicrm-core/pull/13631))** -- **[REF] Remove useless class CRM_Report_Form_Event ([13632](https://github.com/civicrm/civicrm-core/pull/13632))** - - **Contribution/ContributionRecur metadata updates for EntityForm ([13579](https://github.com/civicrm/civicrm-core/pull/13579))** -- **dev/core#720 [REF] refactor out components of contributionSummary function ([13607](https://github.com/civicrm/civicrm-core/pull/13607))** - - **Standardize format for entityRef create links ([13628](https://github.com/civicrm/civicrm-core/pull/13628))** -- **[Code cleanup] Remove unused $stationery_path parameter ([13624](https://github.com/civicrm/civicrm-core/pull/13624))** +- **Always load recaptcha JS over HTTPS ([13601](https://github.com/civicrm/civicrm-core/pull/13601))** -- **[REF] extract cancelled stats to own function ([13626](https://github.com/civicrm/civicrm-core/pull/13626))** +- **If a profile is used to create a contact with a subtype the contact will not have any existing subtypes ([13499](https://github.com/civicrm/civicrm-core/pull/13499))** -- **[REF] Move entityRef filters into their respective BAOs ([13625](https://github.com/civicrm/civicrm-core/pull/13625))** +- **Fix (sometimes serious) performance problem on submitting profiles for specified contacts ([13606](https://github.com/civicrm/civicrm-core/pull/13606))** -- **[REF] extract basic soft credit stats to separate function ([13622](https://github.com/civicrm/civicrm-core/pull/13622))** +- **Move l10n.js to coreResourcesList ([13612](https://github.com/civicrm/civicrm-core/pull/13612))** -- **[code cleanup] Default wrong declared ([13621](https://github.com/civicrm/civicrm-core/pull/13621))** +- **Add install and runtime status warnings if MySQL utf8mb4 is not supported ([13425](https://github.com/civicrm/civicrm-core/pull/13425))** -- **[REF] Remove unused function parameter ([13619](https://github.com/civicrm/civicrm-core/pull/13619))** +- **Add in Exception API to support the refactor of Dedupe Exception Page ([13611](https://github.com/civicrm/civicrm-core/pull/13611))** -- **Remove long block of commented out code from 4 years ago ([13623](https://github.com/civicrm/civicrm-core/pull/13623))** +- **Add new Payment.sendconfirmation api ([13561](https://github.com/civicrm/civicrm-core/pull/13561))** -- **Always load recaptcha JS over HTTPS ([13601](https://github.com/civicrm/civicrm-core/pull/13601))** +- **Find Contributions columns/headers not aligned when "Contributions OR Soft Credits?" filter set to "Soft Credits Only" ([13517](https://github.com/civicrm/civicrm-core/pull/13517))** -- **If a profile is used to create a contact with a subtype the contact will not have any existing subtypes ([13499](https://github.com/civicrm/civicrm-core/pull/13499))** +- **Improves styling on Joomla! upgrade screen ([13557](https://github.com/civicrm/civicrm-core/pull/13557))** -- **[Test support] Add extra output info when getsingle fails as this seems to be common in intermittant fails ([13618](https://github.com/civicrm/civicrm-core/pull/13618))** +- **Remove activitystatus js. Add submitOnce handler for activity create ([13342](https://github.com/civicrm/civicrm-core/pull/13342))** -- **[REF] extract add median to stats ([13616](https://github.com/civicrm/civicrm-core/pull/13616))** +- **Bump minimum upgradable ver to 4.2.9 ([13580](https://github.com/civicrm/civicrm-core/pull/13580))** -- **Remove tests that no longer work due to dead service ([13617](https://github.com/civicrm/civicrm-core/pull/13617))** +- **Remove hurty free calls from campaign and case ([13564](https://github.com/civicrm/civicrm-core/pull/13564))** -- **Fix (sometimes serious) performance problem on submitting profiles for specified contacts ([13606](https://github.com/civicrm/civicrm-core/pull/13606))** +- **Fix contact ID help on advanced search ([13569](https://github.com/civicrm/civicrm-core/pull/13569))** -- **[REF] extract calculation of mode stat ([13614](https://github.com/civicrm/civicrm-core/pull/13614))** +- **Used buildoptions function to get all groups ([13327](https://github.com/civicrm/civicrm-core/pull/13327))** -- **5.11 to master ([13615](https://github.com/civicrm/civicrm-core/pull/13615))** +- **Show Add to group on create new report after refresh of result ([13404](https://github.com/civicrm/civicrm-core/pull/13404))** -- **fixes core#580 - view all groups when appropriately permissioned ([13373](https://github.com/civicrm/civicrm-core/pull/13373))** +- **Optimize CRM_Core_BAO_FinancialTrxn::getTotalPayment ([13187](https://github.com/civicrm/civicrm-core/pull/13187))** -- **Move l10n.js to coreResourcesList ([13612](https://github.com/civicrm/civicrm-core/pull/13612))** +- **CRM.loadScript improvements ([13555](https://github.com/civicrm/civicrm-core/pull/13555))** -- **Add install and runtime status warnings if MySQL utf8mb4 is not supported ([13425](https://github.com/civicrm/civicrm-core/pull/13425))** +- **Make submitOnce() button js into a button parameter ([13333](https://github.com/civicrm/civicrm-core/pull/13333))** -- **[REF] extract calculation of basic stats ([13608](https://github.com/civicrm/civicrm-core/pull/13608))** +- **Port fix for dev/core#381 to custom file field handler file ([564](https://github.com/civicrm/civicrm-drupal/pull/564))** -- **[REF] Move addSelectWhere-like function to be located on BAO_Contribution ([13587](https://github.com/civicrm/civicrm-core/pull/13587))** +- **Make address Supplemental line 3 available to views ([551](https://github.com/civicrm/civicrm-drupal/pull/551))** -- **[REF] Fix silly function to do less handling of non-existent scenarios ([13563](https://github.com/civicrm/civicrm-core/pull/13563))** +- **CMS path fix in wp-cli ([147](https://github.com/civicrm/civicrm-wordpress/pull/147))** -- **Add in Exception API to support the refactor of Dedupe Exception Page ([13611](https://github.com/civicrm/civicrm-core/pull/13611))** +- **Remove old menu plugin ([240](https://github.com/civicrm/civicrm-packages/pull/240))** -- **fixes dev/core#683 Incorrectly encoded state and country names ([13591](https://github.com/civicrm/civicrm-core/pull/13591))** +- **"Only variable references should be returned by reference" notice in Mail_smtp ([220](https://github.com/civicrm/civicrm-packages/pull/220))** -- **dev/core#720 add unit test, remove legacy code style. ([13605](https://github.com/civicrm/civicrm-core/pull/13605))** +## Miscellany -- **[REF] extract chunk of code to a separate function ([13600](https://github.com/civicrm/civicrm-core/pull/13600))** +- **[Test changes] Mailing job test use + ([13629](https://github.com/civicrm/civicrm-core/pull/13629))** -- **dev/core#657 - Add filter for country on Repeat Contributions Report ([13432](https://github.com/civicrm/civicrm-core/pull/13432))** +- **Code cleanup - remove extraneous permissions clause + ([13645](https://github.com/civicrm/civicrm-core/pull/13645))** -- **5.11 to master ([13602](https://github.com/civicrm/civicrm-core/pull/13602))** +- **Fix typo in comments + ([13771](https://github.com/civicrm/civicrm-core/pull/13771))** -- **(dev/core#705) Disabling Alphabetical Pager is not respected for cont… ([13592](https://github.com/civicrm/civicrm-core/pull/13592))** +- **Removes redundant IF + ([13769](https://github.com/civicrm/civicrm-core/pull/13769))** -- **Add new Payment.sendconfirmation api ([13561](https://github.com/civicrm/civicrm-core/pull/13561))** +- **(NFC) formatting changes + ([148](https://github.com/civicrm/civicrm-wordpress/pull/148))** -- **Find Contributions columns/headers not aligned when "Contributions OR Soft Credits?" filter set to "Soft Credits Only" ([13517](https://github.com/civicrm/civicrm-core/pull/13517))** +- **report clean up - remove redundant code + ([13761](https://github.com/civicrm/civicrm-core/pull/13761))** -- **dev/report#7 fix trxn_date on bookkeeping report ([13571](https://github.com/civicrm/civicrm-core/pull/13571))** +- **Fix typo and space + ([13577](https://github.com/civicrm/civicrm-core/pull/13577))** -- **dev/core#684 - Case Manager not updating correctly ([13528](https://github.com/civicrm/civicrm-core/pull/13528))** +- **[minor cleanup] reduce params passed to searchQuery + ([13715](https://github.com/civicrm/civicrm-core/pull/13715))** -- **dev/core#469 Fix Error on action 'Email - schedule/send via CiviMail' with multiple event names filter ([13539](https://github.com/civicrm/civicrm-core/pull/13539))** +- **[TEST FIX] Increase uniqueness in testSingleNowDates + ([13705](https://github.com/civicrm/civicrm-core/pull/13705))** -- **[REF} User api rather than selector for rendering contributions on user dashboard ([13584](https://github.com/civicrm/civicrm-core/pull/13584))** +- **Revert "[REF] Extract record refund function" + ([13693](https://github.com/civicrm/civicrm-core/pull/13693))** -- **dev/core#397 Dedupe for Individual Birth Date Results in Error ([13538](https://github.com/civicrm/civicrm-core/pull/13538))** +- **Minor code cleanup + ([13687](https://github.com/civicrm/civicrm-core/pull/13687))** -- **Improves styling on Joomla! upgrade screen ([13557](https://github.com/civicrm/civicrm-core/pull/13557))** +- **[NFC, test class] formatting, remove unused variables + ([13634](https://github.com/civicrm/civicrm-core/pull/13634))** -- **dev/core/issues/714, Inline edit should be disabled if user doesn't have edit group permission ([13573](https://github.com/civicrm/civicrm-core/pull/13573))** +- **Authorizenet test - reduce chance of intermittent fails + ([13642](https://github.com/civicrm/civicrm-core/pull/13642))** -- **dev/core#691 Make default country optional on setting form ([13523](https://github.com/civicrm/civicrm-core/pull/13523))** +- **[unused code cleanup] Remove unused 'signupType' url support + ([13620](https://github.com/civicrm/civicrm-core/pull/13620))** -- **[REF] switch from (undeclared) class property to local variable. ([13583](https://github.com/civicrm/civicrm-core/pull/13583))** +- **[Test support] Add extra output info when getsingle fails as this seems to + be common in intermittant fails + ([13618](https://github.com/civicrm/civicrm-core/pull/13618))** -- **[REF] Minor readability cleanup ([13562](https://github.com/civicrm/civicrm-core/pull/13562))** +- **Remove tests that no longer work due to dead service + ([13617](https://github.com/civicrm/civicrm-core/pull/13617))** -- **Remove activitystatus js. Add submitOnce handler for activity create ([13342](https://github.com/civicrm/civicrm-core/pull/13342))** +- **Refactor CRM_Utils_SQL_TempTable::build()->createWithQuery($sql) interface + to support MEMORY tabls + ([13644](https://github.com/civicrm/civicrm-core/pull/13644))** -- **Bump minimum upgradable ver to 4.2.9 ([13580](https://github.com/civicrm/civicrm-core/pull/13580))** +- **REF Convert deprecated functions to buildOptions for case + ([13364](https://github.com/civicrm/civicrm-core/pull/13364))** -- **5.11 to master ([13585](https://github.com/civicrm/civicrm-core/pull/13585))** +- **[REF] Extract record refund function + ([13691](https://github.com/civicrm/civicrm-core/pull/13691))** -- **Fix typo and space ([13577](https://github.com/civicrm/civicrm-core/pull/13577))** +- **[REF] Extract getSearchSQL from getSearchQuery. + ([13668](https://github.com/civicrm/civicrm-core/pull/13668))** -- **5.11 to master ([13576](https://github.com/civicrm/civicrm-core/pull/13576))** +- **[REF] minor code cleanup - do not build order var just to hurt brains + ([13650](https://github.com/civicrm/civicrm-core/pull/13650))** -- **Remove hurty free calls from campaign and case ([13564](https://github.com/civicrm/civicrm-core/pull/13564))** +- **[REF] minor cleanup of groupBy definition. + ([13656](https://github.com/civicrm/civicrm-core/pull/13656))** -- **Fix contact ID help on advanced search ([13569](https://github.com/civicrm/civicrm-core/pull/13569))** +- **[REF] extract add median to stats + ([13616](https://github.com/civicrm/civicrm-core/pull/13616))** -- **Add unit test on getContributionBalance fn (#13187) ([13558](https://github.com/civicrm/civicrm-core/pull/13558))** +- **[REF] extract cancelled stats to own function + ([13626](https://github.com/civicrm/civicrm-core/pull/13626))** -- **dev/core#562 Remove free calls from Activity and Member sections of CRM ([13560](https://github.com/civicrm/civicrm-core/pull/13560))** +- **[REF] Move entityRef filters into their respective BAOs + ([13625](https://github.com/civicrm/civicrm-core/pull/13625))** -- **Used buildoptions function to get all groups ([13327](https://github.com/civicrm/civicrm-core/pull/13327))** +- **[REF] extract basic soft credit stats to separate function + ([13622](https://github.com/civicrm/civicrm-core/pull/13622))** -- **Show Add to group on create new report after refresh of result ([13404](https://github.com/civicrm/civicrm-core/pull/13404))** +- **[REF] Remove unused function parameter + ([13619](https://github.com/civicrm/civicrm-core/pull/13619))** -- **(REF) Rename variables and adjust variable definitions for Event Register form ([13287](https://github.com/civicrm/civicrm-core/pull/13287))** +- **[REF] Extract lines to add the pseudoconstant to the select + ([13717](https://github.com/civicrm/civicrm-core/pull/13717))** -- **Optimize CRM_Core_BAO_FinancialTrxn::getTotalPayment ([13187](https://github.com/civicrm/civicrm-core/pull/13187))** +- **[REF] extract calculation of mode stat + ([13614](https://github.com/civicrm/civicrm-core/pull/13614))** -- **CRM.loadScript improvements ([13555](https://github.com/civicrm/civicrm-core/pull/13555))** +- **[REF] extract calculation of basic stats + ([13608](https://github.com/civicrm/civicrm-core/pull/13608))** -- **dev/core/issues/700, Show Qill when searched using contact id ([13549](https://github.com/civicrm/civicrm-core/pull/13549))** +- **[REF] Move addSelectWhere-like function to be located on BAO_Contribution + ([13587](https://github.com/civicrm/civicrm-core/pull/13587))** -- **Make submitOnce() button js into a button parameter ([13333](https://github.com/civicrm/civicrm-core/pull/13333))** +- **[REF] Fix silly function to do less handling of non-existent scenarios + ([13563](https://github.com/civicrm/civicrm-core/pull/13563))** -- **dev/core#690 - Civi\API - Fix entity permission check for trusted calls ([13529](https://github.com/civicrm/civicrm-core/pull/13529))** +- **[REF] extract chunk of code to a separate function + ([13600](https://github.com/civicrm/civicrm-core/pull/13600))** -- **6.x-5.10 ([566](https://github.com/civicrm/civicrm-drupal/pull/566))** +- **[REF} User api rather than selector for rendering contributions on user + dashboard ([13584](https://github.com/civicrm/civicrm-core/pull/13584))** -- **Port fix for dev/core#381 to custom file field handler file ([564](https://github.com/civicrm/civicrm-drupal/pull/564))** +- **[REF] switch from (undeclared) class property to local variable. + ([13583](https://github.com/civicrm/civicrm-core/pull/13583))** -- **7.x 5.11 ([565](https://github.com/civicrm/civicrm-drupal/pull/565))** +- **[REF] Minor readability cleanup + ([13562](https://github.com/civicrm/civicrm-core/pull/13562))** -- **7.x 5.11 to master (no changes in here - just admin) ([562](https://github.com/civicrm/civicrm-drupal/pull/562))** +- **[REF] Remove useless class CRM_Report_Form_Event + ([13632](https://github.com/civicrm/civicrm-core/pull/13632))** -- **Make address Supplemental line 3 available to views ([551](https://github.com/civicrm/civicrm-drupal/pull/551))** +- **[REF] extract getToFinancialAccount from + CRM_Contribute_PseudoConstantt::contributionStatus + ([13757](https://github.com/civicrm/civicrm-core/pull/13757))** -- **CMS path fix in wp-cli ([147](https://github.com/civicrm/civicrm-wordpress/pull/147))** +- **[ref] Extract activity payment creation + ([13695](https://github.com/civicrm/civicrm-core/pull/13695))** -- **(NFC) formatting changes ([148](https://github.com/civicrm/civicrm-wordpress/pull/148))** + - **[REF] separate financial handling & component transitioning in + Payment.create ([13756](https://github.com/civicrm/civicrm-core/pull/13756))** -- **Merge forward: 1.x-5.11 => 1.x-master ([66](https://github.com/civicrm/civicrm-backdrop/pull/66))** +- **[REF] towards cleanup of update membership code + ([13759](https://github.com/civicrm/civicrm-core/pull/13759))** -- **Remove old menu plugin ([240](https://github.com/civicrm/civicrm-packages/pull/240))** +- **(REF) Rename variables and adjust variable definitions for Event Register + form ([13287](https://github.com/civicrm/civicrm-core/pull/13287))** -- **"Only variable references should be returned by reference" notice in Mail_smtp ([220](https://github.com/civicrm/civicrm-packages/pull/220))** +- **[REF] Extract recordPayment portion + ([13692](https://github.com/civicrm/civicrm-core/pull/13692))** -## Miscellany +- **[REF] minor refactor around retrieving processor id for recur + ([13643](https://github.com/civicrm/civicrm-core/pull/13643))** + +- **[code cleanup] Default wrong declared + ([13621](https://github.com/civicrm/civicrm-core/pull/13621))** + +- **[Code cleanup] Remove unused $stationery_path parameter + ([13624](https://github.com/civicrm/civicrm-core/pull/13624))** + +- **Remove long block of commented out code from 4 years ago + ([13623](https://github.com/civicrm/civicrm-core/pull/13623))** + +- **Add unit test on getContributionBalance fn (#13187) + ([13558](https://github.com/civicrm/civicrm-core/pull/13558))** ## Credits From ef56d7325949f368fd5b83d1a6052184256a28a7 Mon Sep 17 00:00:00 2001 From: Alice Frumin Date: Tue, 19 Mar 2019 14:15:34 -0400 Subject: [PATCH 051/121] 5.12.0 release notes: contributors --- contributor-key.yml | 7 +++++++ release-notes/5.12.0.md | 17 +++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/contributor-key.yml b/contributor-key.yml index 4fb87597ac4c..98b8a186aa8d 100644 --- a/contributor-key.yml +++ b/contributor-key.yml @@ -56,6 +56,9 @@ - github : alexmarketaccess name : Alex Block +- github : alexymik + name : Alexy Mikhailichenko + - github : alifrumin name : Alice Frumin organization: AGH Strategies @@ -131,6 +134,10 @@ name : Dave Rolsky jira : autarch +- github : awasson + name : Andrew Wasson + organization: Luna Design + - github : awzilkie name : Adam Zilkie jira : adzil diff --git a/release-notes/5.12.0.md b/release-notes/5.12.0.md index dec8b3508a9a..47ee5c140158 100644 --- a/release-notes/5.12.0.md +++ b/release-notes/5.12.0.md @@ -9,6 +9,19 @@ Released April 3, 2019 - **[Credits](#credits)** - **[Feedback](#feedback)** + +## Synopsis + +| *Does this version...?* | | +|:--------------------------------------------------------------- |:-------:| +| Fix security vulnerabilities? | | +| Change the database schema? | | +| Alter the API? | **yes** | +| Require attention to configuration options? | | +| Fix problems installing or upgrading to a previous version? | **yes** | +| Introduce features? | **yes** | +| Fix bugs? | **yes** | + ## Features ### Core CiviCRM @@ -388,12 +401,12 @@ Released April 3, 2019 This release was developed by the following code authors: -AGH Strategies - Alice Frumin, Andrew Hunt; Agileware - Alok Patel; alexymik; Australian Greens - Seamus Lee; avall-llovera; CiviCRM - Coleman Watts, Tim Otten; CiviDesk - Yashodha Chaku; Coop SymbioTIC - Mathieu Lutfy; Electronic Frontier Foundation - Mark Burdett; Francesc Bassas i Bullich; Fuzion - Jitendra Purohit; GreenPeace Central and Eastern Europe - Patrick Figel; JMA Consulting - Edsel Lopez, Monish Deb; Ken West; Lighthouse Design and Consulting - Brian Shaughnessy; Megaphone Technology Consulting - Jon Goldberg; MJW Consulting - Matthew Wire; Nicol Wistreich; Pradeep Nayak; Skvare - Mark Hanna; Squiffle Consulting - Aidan Saunders; Wikimedia Foundation - Eileen McNaughton +AGH Strategies - Alice Frumin, Andrew Hunt; Agileware - Alok Patel; Alexy Mikhailichenko; Australian Greens - Seamus Lee; avall-llovera; CiviCRM - Coleman Watts, Tim Otten; CiviDesk - Yashodha Chaku; Coop SymbioTIC - Mathieu Lutfy; Electronic Frontier Foundation - Mark Burdett; Francesc Bassas i Bullich; Fuzion - Jitendra Purohit; GreenPeace Central and Eastern Europe - Patrick Figel; JMA Consulting - Edsel Lopez, Monish Deb; Ken West; Lighthouse Design and Consulting - Brian Shaughnessy; Megaphone Technology Consulting - Jon Goldberg; MJW Consulting - Matthew Wire; Nicol Wistreich; Pradeep Nayak; Skvare - Mark Hanna; Squiffle Consulting - Aidan Saunders; Wikimedia Foundation - Eileen McNaughton Most authors also reviewed code for this release; in addition, the following reviewers contributed their comments: -AGH Strategies - Alice Frumin, Andrew Hunt; Agileware - Alok Patel, Justin Freeman; Australian Greens - Seamus Lee; awasson; Circle Interactive - Dave Jenkins; civibot[bot]; civicrm-builder; CiviCRM - Coleman Watts, Tim Otten; CiviDesk - Sunil Pawar, Yashodha Chaku; Coop SymbioTIC - Mathieu Lutfy; Dave D; Electronic Frontier Foundation - Mark Burdett; Francesc Bassas i Bullich; Fuzion - Jitendra Purohit, Peter Davis; GreenPeace Central and Eastern Europe - Patrick Figel; JMA Consulting - Joe Murray, Monish Deb; Lighthouse Design and Consulting - Brian Shaughnessy; Megaphone Technology Consulting - Jon Goldberg; MJCO - Mikey O'Toole; MJW Consulting - Matthew Wire; mwestergaard; Nicol Wistreich; Pradeep Nayak; Progressive Technology Project - Jamie McClelland; reecebenson; Richard van Oosterhout; Skvare - Mark Hanna; Squiffle Consulting - Aidan Saunders; Tadpole Collective - Kevin Cristiano; Third Sector Design - Michael McAndrew; Wikimedia Foundation - Eileen McNaughton +Justin Freeman; Circle Interactive - Dave Jenkins; CiviDesk - Sunil Pawar; Dave D; Fuzion - Peter Davis; JMA Consulting - Joe Murray; Luna Design - Andrew Wasson; MJCO - Mikey O'Toole; mwestergaard; Progressive Technology Project - Jamie McClelland; reecebenson; Richard van Oosterhout; Tadpole Collective - Kevin Cristiano; Third Sector Design - Michael McAndrew ## Feedback From 2e9bc3a4c26b562c230877cb8db802f286cac328 Mon Sep 17 00:00:00 2001 From: Alice Frumin Date: Tue, 19 Mar 2019 14:45:13 -0400 Subject: [PATCH 052/121] 5.12.0 release notes: bulk of work --- release-notes/5.12.0.md | 663 +++++++++++++++++++++++++++++++++------- 1 file changed, 551 insertions(+), 112 deletions(-) diff --git a/release-notes/5.12.0.md b/release-notes/5.12.0.md index 47ee5c140158..13d9a054df6e 100644 --- a/release-notes/5.12.0.md +++ b/release-notes/5.12.0.md @@ -15,7 +15,7 @@ Released April 3, 2019 | *Does this version...?* | | |:--------------------------------------------------------------- |:-------:| | Fix security vulnerabilities? | | -| Change the database schema? | | +| Change the database schema? | **yes** | | Alter the API? | **yes** | | Require attention to configuration options? | | | Fix problems installing or upgrading to a previous version? | **yes** | @@ -26,229 +26,650 @@ Released April 3, 2019 ### Core CiviCRM -- **CRM-21643 Missing Summary ([12337](https://github.com/civicrm/civicrm-core/pull/12337))** +- **Migrate KAM smartmenus to core + ([13582](https://github.com/civicrm/civicrm-core/pull/13582), + [240](https://github.com/civicrm/civicrm-packages/pull/240), + [13612](https://github.com/civicrm/civicrm-core/pull/13612), + [13729](https://github.com/civicrm/civicrm-core/pull/13729) and + [13820](https://github.com/civicrm/civicrm-core/pull/13820))** + + These changes update the CiviCRM Administration menu to use KAM smartmenus + this makes the menu mobile responsive. Additionally, these changes remove the + old menu plugin as it is no longer needed, add l10n.js within + coreResourcesList and fix an unreleased regression for wordpress users where + the CiviCRM Admin Bar was visible on the 'Front End' + [dev/core#790](https://lab.civicrm.org/dev/core/issues/790). + +- **[dev/core#657](https://lab.civicrm.org/dev/core/issues/657) Add filter for + country on Repeat Contributions Report + ([13432](https://github.com/civicrm/civicrm-core/pull/13432))** + + This change adds a filter for Country to the Repeat Contributions Report. + +- **[dev/core#690](https://lab.civicrm.org/dev/core/issues/690) Support more + entities in Attachment API by short-circuiting permission check + ([13529](https://github.com/civicrm/civicrm-core/pull/13529))** + + This change makes it so one can use the Attachment API to update attachment + custom fields on Memberships and several other entities. + +- **[dev/core#561](https://lab.civicrm.org/dev/core/issues/561) Replace + jcalendar instances with datepicker + ([13704](https://github.com/civicrm/civicrm-core/pull/13704), + [13701](https://github.com/civicrm/civicrm-core/pull/13701) and + [13746](https://github.com/civicrm/civicrm-core/pull/13746)) Continued Work** + + These changes update the following places to use the datepicker instead of the + jcalendar widget: the age field on the Advanced Search form in the + Demographics section, the activity date time field on the find activites form, + and the date field on the Change Case Type Form. Additionally on the Find + Activities form these changes make it possible to pass the activity_date_time + criteria in the url. + +- **Add install and runtime status warnings if MySQL utf8mb4 is not supported + ([13425](https://github.com/civicrm/civicrm-core/pull/13425))** + + This change adds a warning to the system status page, as well as at install + time, if utf8mb4 is not supported by the stack. + +- **Record change log entry when contact is moved to or restored from trash + ([13276](https://github.com/civicrm/civicrm-core/pull/13276))** + + This change makes it so that a Change Log entry is created when a contact is + moved to the trash or restored from the trash. + +- **Towards supporting EntityForm for 'View Action' + ([13578](https://github.com/civicrm/civicrm-core/pull/13578))** + + This change enhances support for EntityForm in the "View" context. + +- **Standardize format for entityRef create links + ([13628](https://github.com/civicrm/civicrm-core/pull/13628))** + + This change standardizes entityRef create links so that they are pre-loaded to + the clientside and so that they work equally well with all entities. + +- **Fix (sometimes serious) performance problem on submitting profiles for + specified contacts + ([13606](https://github.com/civicrm/civicrm-core/pull/13606))** + + This change improves performance when submitting profiles for specified + contacts. + +- **Add in Exception API to support the refactor of Dedupe Exception Page + ([13611](https://github.com/civicrm/civicrm-core/pull/13611))** + + This change adds an API to Query Dedupe Exceptions. + +- **CRM.loadScript improvements + ([13555](https://github.com/civicrm/civicrm-core/pull/13555))** + + This change makes it so that dynamically loaded scripts are not served from + stale browser caches and allows angular apps to dynamically load scripts. + +- **Make submitOnce() button js into a button parameter + ([13333](https://github.com/civicrm/civicrm-core/pull/13333))** + + This change makes it so that developers can set a button as submit only once + using the parameter `submitOnce = TRUE`. + +- **[dev/core#562](https://lab.civicrm.org/dev/core/issues/562) Remove instances + of $dao->free ([13560](https://github.com/civicrm/civicrm-core/pull/13560) and + [13564](https://github.com/civicrm/civicrm-core/pull/13564)) Continued Work** + + These changes improve performance by removing instances of $dao->free. + +- **[infra/ops#878](https://lab.civicrm.org/infra/ops/issues/878) Add a test + matrix for E2E tests on each CMS + ([13808](https://github.com/civicrm/civicrm-core/pull/13808))** + + This change improves reliability by increasing test coverage. + +- **Try and add data set example where email_on_hold / on_hold is NULL in the + formValues ([13765](https://github.com/civicrm/civicrm-core/pull/13765))** + + This change adds test coverage. + +- **[dev/core#746](https://lab.civicrm.org/dev/core/issues/746) Search Builder + searches using > 1 smart group where operator is equals is broken from 5.10.0 + ([13685](https://github.com/civicrm/civicrm-core/pull/13685)) Continued work** + + This change adds test coverage for Search Builder searches using > 1 smart + group. + +- **[dev/report#10](https://lab.civicrm.org/dev/report/issues/10) No pagination + on Contribution Detail report + ([13678](https://github.com/civicrm/civicrm-core/pull/13678)) Continued Work** + + This change adds a unit test for pagination on the Contribution Detail report. + +- **[dev/core#720](https://lab.civicrm.org/dev/core/issues/720) Performance + change approved - remove mode & median slow queries + ([13607](https://github.com/civicrm/civicrm-core/pull/13607), + [13630](https://github.com/civicrm/civicrm-core/pull/13630) and + [13605](https://github.com/civicrm/civicrm-core/pull/13605))** + + This change removes the mode and median stats on the contribution search + summary and contribution tab on contacts to improve performance. + +- **[dev/core#748](https://lab.civicrm.org/dev/core/issues/748) Deadlocks and + performance issues when using smartgroups / ACLs extensively + ([13732](https://github.com/civicrm/civicrm-core/pull/13732))** + + This change improves performance for smart groups and ACLs. + +- **Upgrade Karma version to latest version + ([13751](https://github.com/civicrm/civicrm-core/pull/13751))** + +- **Upgrade PHPWord + ([13686](https://github.com/civicrm/civicrm-core/pull/13686))** + +### CiviContribute + +- **Add pseudoconstant for payment_processor_id to contributionrecur + ([13702](https://github.com/civicrm/civicrm-core/pull/13702)) Continued Work** + + This change alters the schema to add support for payment_processor_id as a + pseudoconstant for Recurring Contributions. + +- **[dev/core#767](https://lab.civicrm.org/dev/core/issues/767) Add 'Cancelled / + Refunded Date' and 'Cancellation / Refund Reason' in the Detail Contributions + Report ([13726](https://github.com/civicrm/civicrm-core/pull/13726))** + + This change adds the fields and filters 'Cancelled / Refunded Date' and + 'Cancellation / Refund Reason' to the Detail Contributions Report. + +- **[dev/report#8](https://lab.civicrm.org/dev/report/issues/8) Contribution + reports don't include thank-you date + ([13653](https://github.com/civicrm/civicrm-core/pull/13653))** + + This change adds the "thank you date" field to the Contribution Summary and + Detail reports. + +- **[dev/core#735](https://lab.civicrm.org/dev/core/issues/735) Query + performance - suppress 'product' and related fields where products are not in + the database ([13638](https://github.com/civicrm/civicrm-core/pull/13638))** + + This change removes the "Premium" column from the Contribution tab for sites + that do not use products and improves performance on those sites by not + searching for product related fields. + +- **Speed up contribution results by removing join on civicrm_financial_type + table when rendering search results. + ([13720](https://github.com/civicrm/civicrm-core/pull/13720))** + + This change improves performance when searching contributions. + +- **Allow viewing of cancelled recurring contributions + ([13745](https://github.com/civicrm/civicrm-core/pull/13745))** + + This change makes it possible to view canceled recurring contributions thru + the user interface. + +- **Add new Payment.sendconfirmation api + ([13610](https://github.com/civicrm/civicrm-core/pull/13610), + [13561](https://github.com/civicrm/civicrm-core/pull/13561) and + [13609](https://github.com/civicrm/civicrm-core/pull/13609))** + + These changes add a Payment.sendconfirmation API. + +- **Switch additional payment form to use Payment.sendconfirmation api + ([13649](https://github.com/civicrm/civicrm-core/pull/13649))** + + This change switches the additional payment form to use the new + Payment.sendconfirmation api. + +- **Payment notification formatting, move greeting into table + ([13669](https://github.com/civicrm/civicrm-core/pull/13669))** + + This change improves the Payment Notification Email formatting by aligning the + greeting with the table. + +- **Update Payment Notification to use greeting, remove text to 'Please print + this confirmation for your records. + ([13655](https://github.com/civicrm/civicrm-core/pull/13655))** + + This change improves the Payment Notification email by removing the 'Please + print this confirmation for your records.' text and switching to use the + email_greeting instead of the display_name for the greeting. + +- **Remove another instance of 'lower' + ([13636](https://github.com/civicrm/civicrm-core/pull/13636))** + + This change improves performance when searching notes fields on a + contribution. + +- **Contribution/ContributionRecur metadata updates for EntityForm + ([13579](https://github.com/civicrm/civicrm-core/pull/13579))** + + These changes update the metadata for Contribution and ContributionRecur so + that they can be used to autogenerate forms with EntityForm. + +### CiviMember + +- **CiviCRM Membership Detail report, add column to display if membership is + Primary or Inherited + ([13736](https://github.com/civicrm/civicrm-core/pull/13736))** + + This change adds a column "Primary/Inherited?" to the Membership Detail + report. + +### Drupal Integration + +- **Make address Supplemental line 3 available to views + ([551](https://github.com/civicrm/civicrm-drupal/pull/551))** + + This change makes it so that one can use the address field "Supplemental + Address 3" in a view. + +### Joomla Integration + +- **Improves styling on Joomla! upgrade screen + ([13557](https://github.com/civicrm/civicrm-core/pull/13557))** + + This change improves the styling of the Joomla upgrade screen. ## Bugs resolved ### Core CiviCRM -- **dev/report#7 fix trxn_date on bookkeeping report ([13571](https://github.com/civicrm/civicrm-core/pull/13571))** +- **[dev/core#190](https://lab.civicrm.org/dev/core/issues/190) custom data with + multiple records profile: after submission, profile view shows first record + instead of most recent + ([12337](https://github.com/civicrm/civicrm-core/pull/12337))** -- **reporting#8 - add thank-you dates to Contribution Summary/Detail reports ([13653](https://github.com/civicrm/civicrm-core/pull/13653))** + This change ensures when submitting a multi data profile, the most recently + created record is retrieved on the confirmation page, before this change the + first record was retrieved. -- **reporting#9: parity between getContactFields and getBasicContactFields ([13657](https://github.com/civicrm/civicrm-core/pull/13657))** +- **[dev/core#397](https://lab.civicrm.org/dev/core/issues/397) Dedupe for + Individual Birth Date Results in Error + ([13538](https://github.com/civicrm/civicrm-core/pull/13538))** -- **test for reporting#10 ([13678](https://github.com/civicrm/civicrm-core/pull/13678))** + This change fixes a fatal error when using a dedupe rule with the field birth + date. -- **reporting-11 - fix Soft Credit report with full group by ([13671](https://github.com/civicrm/civicrm-core/pull/13671))** +- **[dev/core#580](https://lab.civicrm.org/dev/core/issues/580) No groups + displayed on Manage Groups when "All Groups" is selected + ([13373](https://github.com/civicrm/civicrm-core/pull/13373))** -- **dev/core#397 Dedupe for Individual Birth Date Results in Error ([13538](https://github.com/civicrm/civicrm-core/pull/13538))** + Before this change if a user had an ACL that gave them permission to Edit + "All Groups" but did not have the permission "View All Contacts" then on the + "Manage Groups" screen no groups would appear, this change makes it so that + groups appear for these users. -- **dev/core#469 Fix Error on action 'Email - schedule/send via CiviMail' with multiple event names filter ([13539](https://github.com/civicrm/civicrm-core/pull/13539))** +- **[dev/core#642](https://lab.civicrm.org/dev/core/issues/642) New Contact + Report: New report isn't created automatically when the user selects the + "Create Report" action + ([13404](https://github.com/civicrm/civicrm-core/pull/13404))** -- **dev/core#561 Upgrade age_asof_date to datepicker in search ([13704](https://github.com/civicrm/civicrm-core/pull/13704))** + This change ensures that when one selects the action "Create Report" on the + "Constituent Report (Summary)" report a new report is created, before this + change a js error was thrown and no report was created. -- **dev/core#562 Remove free calls from Activity and Member sections of CRM ([13560](https://github.com/civicrm/civicrm-core/pull/13560))** +- **[dev/core#683](https://lab.civicrm.org/dev/core/issues/683) Incorrectly + encoded state and country names + ([13591](https://github.com/civicrm/civicrm-core/pull/13591))** -- **fixes core#580 - view all groups when appropriately permissioned ([13373](https://github.com/civicrm/civicrm-core/pull/13373))** + This change ensures that when countries and state/provinces are added they use + proper character encoding. -- **dev/core#631 - Enable 'add new' by default on merge screen ([13588](https://github.com/civicrm/civicrm-core/pull/13588))** +- **[dev/core#691](https://lab.civicrm.org/dev/core/issues/691) It is no longer + possible to have the default country not set + ([13523](https://github.com/civicrm/civicrm-core/pull/13523))** -- **dev/core#644 fix from address before calling hook ([13776](https://github.com/civicrm/civicrm-core/pull/13776))** + This change makes the default country field on the settings form optional, + before this change it was required. -- **dev/core#657 - Add filter for country on Repeat Contributions Report ([13432](https://github.com/civicrm/civicrm-core/pull/13432))** +- **[dev/core#700](https://lab.civicrm.org/dev/core/issues/700) Advanced Search: + The reason of failed search result is not displayed, when a contact with the + matching Contact ID was not found + ([13549](https://github.com/civicrm/civicrm-core/pull/13549))** -- **dev/core#659 Catch payment processor exceptions, log, hide, do not return 500 error ([13796](https://github.com/civicrm/civicrm-core/pull/13796))** + When using the Advanced Search form to search by contact ID, this change + ensures if no matching contact is found the Qill states the search criteria + for which no matches were found. -- **fixes dev/core#683 Incorrectly encoded state and country names ([13591](https://github.com/civicrm/civicrm-core/pull/13591))** +- **[dev/core#708](https://lab.civicrm.org/dev/core/issues/708) Advanced Search: + The "Modified By" option was set instead of "Added by" + ([13566](https://github.com/civicrm/civicrm-core/pull/13566))** -- **dev/core#684 - Case Manager not updating correctly ([13528](https://github.com/civicrm/civicrm-core/pull/13528))** + When using the Advanced Search form to search by "Added by", this change + ensures if no matching contacts are found the Qill states the search criteria + for which no matches were found accurately, before this change the qill said + "No Matches Found Modified by..." instead of "No Matches Found Added by..." . -- **dev/core#690 - Civi\API - Fix entity permission check for trusted calls ([13529](https://github.com/civicrm/civicrm-core/pull/13529))** +- **[dev/core#705](https://lab.civicrm.org/dev/core/issues/705) Disabling + Alphabetical Pager is not respected for events and contribution pages. + ([13592](https://github.com/civicrm/civicrm-core/pull/13592))** -- **dev/core#691 Make default country optional on setting form ([13523](https://github.com/civicrm/civicrm-core/pull/13523))** + This change ensures if in the Admin -> Search preferences "include + Alphabetical Pager" is turned off, that the A to Z pager is off for Manage + Events and Manage Contributions. -- **(dev/core#696) Changes to copied event phone and email reflects in or… ([13534](https://github.com/civicrm/civicrm-core/pull/13534))** +- **[dev/core#714](https://lab.civicrm.org/dev/core/issues/714) Manage groups: + Error: "API permission check failed for Group/create call; insufficient + permission" when the user tries to edit some group's details + ([13573](https://github.com/civicrm/civicrm-core/pull/13573))** -- **dev/core/issues/700, Show Qill when searched using contact id ([13549](https://github.com/civicrm/civicrm-core/pull/13549))** + This change ensures that on the Manage Groups form, if a user does not have + permissions to edit a group inline edit is disabled. -- **(dev/core#705) Disabling Alphabetical Pager is not respected for cont… ([13592](https://github.com/civicrm/civicrm-core/pull/13592))** +- **[dev/core#742](https://lab.civicrm.org/dev/core/issues/742) Repeated + warning: "simplexml_load_file(): I/O warning : failed to load external entity + ".../xml/Menu/Activity.xml" + ([13654](https://github.com/civicrm/civicrm-core/pull/13654))** -- **dev/core#708, Fix Qill for Added by and Modified By ([13566](https://github.com/civicrm/civicrm-core/pull/13566))** + This change fixes warnings regarding failing to parse the XML file when + clearing the CiviCRM caches. -- **dev/core/issues/714, Inline edit should be disabled if user doesn't have edit group permission ([13573](https://github.com/civicrm/civicrm-core/pull/13573))** +- **[dev/core#749](https://lab.civicrm.org/dev/core/issues/749) MySQL utf8mb4 + check causes fatal error on some systems + ([13682](https://github.com/civicrm/civicrm-core/pull/13682))** -- **/dev/core#716 - Add decimals in Contribution Amount on Repeat Contrib… ([13659](https://github.com/civicrm/civicrm-core/pull/13659))** + This fixes a bug where on some systems the MySQL utf8mb4 compatibility check + would cause a fatal error so that an exception is thrown instead of a fatal + error. -- **dev/core#720 [REF] refactor out components of contributionSummary function ([13607](https://github.com/civicrm/civicrm-core/pull/13607))** +- **[dev/core#769](https://lab.civicrm.org/dev/core/issues/769) ZIP Archive for + multiple batch exports fail + ([13728](https://github.com/civicrm/civicrm-core/pull/13728))** -- **dev/core#720 Remove median & mode stats from contribution summary in order to improve performance ([13630](https://github.com/civicrm/civicrm-core/pull/13630))** + This change fixes ZIP Archives for multiple batch exports for instances with + any PHP version greater than 5.6. -- **dev/core#720 add unit test, remove legacy code style. ([13605](https://github.com/civicrm/civicrm-core/pull/13605))** +- **[dev/report#7](https://lab.civicrm.org/dev/report/issues/7) Transaction Date + filter in Bookkeeping Transactions report + ([13571](https://github.com/civicrm/civicrm-core/pull/13571))** -- **dev/core#735 Do not include product in search results if site has none ([13638](https://github.com/civicrm/civicrm-core/pull/13638))** + This change ensures that the trxn_date field on the Bookkeeping Report filter + respects the times designated in the filter, before this change it would only + return transactions that occurred at midnight. -- **dev/core#739 Fix case detail report breaking when sorted by case type. ([13666](https://github.com/civicrm/civicrm-core/pull/13666))** +- **[dev/report#11](https://lab.civicrm.org/dev/report/issues/11) Soft Credit + report fails when Only Full Group By is enabled + ([13671](https://github.com/civicrm/civicrm-core/pull/13671))** -- **dev/core#742 Fix XML parasing by swapping & for , ([13654](https://github.com/civicrm/civicrm-core/pull/13654))** +- **Remove mcrypt system status check + ([13770](https://github.com/civicrm/civicrm-core/pull/13770))** -- **dev/core#746 Add in unit tests to ensure that where clause is as is w… ([13685](https://github.com/civicrm/civicrm-core/pull/13685))** + This change removes the mcrypt system status check becacuse PHP 7.2 does not + support mcrypt and it is being deprecated. Before this change the status check + would respond with the error "mcrypt not present & smtp encryption in place" + after this change no error is thrown. -- **dev/core#748 Move UPPER() from sql to php domain ([13732](https://github.com/civicrm/civicrm-core/pull/13732))** +- **Fix api bug whereby 0 & '0' are not accepted as range parameters for BETWEEN + ([13766](https://github.com/civicrm/civicrm-core/pull/13766))** -- **dev/core#767 Add 'Cancelled / Refunded Date' and 'Cancellation / Refund Reason' ([13726](https://github.com/civicrm/civicrm-core/pull/13726))** + This change fixes a bug when using the api and a filter "Between" with one of + the parameters set to 0 or '0' would result in an error so that one can use a + between range with 0 as the beginning or the end of the range. -- **dev/core#769 - Fix for ZipArchive->open() PHP bug ([13728](https://github.com/civicrm/civicrm-core/pull/13728))** +- **Render Note field tokens correctly - they are already HTML. + ([13283](https://github.com/civicrm/civicrm-core/pull/13283))** -- **dev/core#770 - View Case Activity page displays disabled custom fields ([13741](https://github.com/civicrm/civicrm-core/pull/13741))** + This change ensures that tokens of Note fields are rendered correctly. -- **dev/core#790 - Exclue menubar on frontend pages ([13820](https://github.com/civicrm/civicrm-core/pull/13820))** +- **Rationalise Activity api ACLs for consistency, to respect the hook & improve + performance ([13664](https://github.com/civicrm/civicrm-core/pull/13664))** -- **dev/core#801 Fix from email on PDF Letters, such as Thank You Letters. ([13825](https://github.com/civicrm/civicrm-core/pull/13825))** + This change alters the way permissions are handled on sites that use ACLs when + the activity.get api is called with the 'check_permissions' flag set to TRUE. + This would usually be the case for js calls. -- **(ops#878) (Fast)ArrayDecorator - Emit expected exception when using WP and strict PSR-16 ([13808](https://github.com/civicrm/civicrm-core/pull/13808))** +- **Fix Custom post outer div class on event registration form + ([13753](https://github.com/civicrm/civicrm-core/pull/13753))** -- **Remove mcrypt system status check ([13770](https://github.com/civicrm/civicrm-core/pull/13770))** + This change updates the class applied to the outer div around a custom profile + in the post section of the form to use 1 custom_pre-section and 1 + custom_post-section instead of two custom_pre-sections. -- **Fix api bug whereby 0 & '0' are not accepted as range parameters for BETWEEN ([13766](https://github.com/civicrm/civicrm-core/pull/13766))** +- **Upgrader: Don't abort if state_province already exists + ([13744](https://github.com/civicrm/civicrm-core/pull/13744))** -- **Render Note field tokens correctly - they are already HTML. ([13283](https://github.com/civicrm/civicrm-core/pull/13283))** + This change fixes a fatal error when upgrading from 4.7.30 and 4.7.32 if + state_province values already exists so that sites with state_province values + can safely upgrade from 4.7.30 t0 4.7.32. -- **Extract getSearchSQLParts function ([13735](https://github.com/civicrm/civicrm-core/pull/13735))** +- **Do not attempt to store out-of-range street number + ([13340](https://github.com/civicrm/civicrm-core/pull/13340))** -- **Convert activity_date_time field to datepicker and add support for url input ([13746](https://github.com/civicrm/civicrm-core/pull/13746))** + Before this change attempting to geocode an address with a long street number + would result in a fatal error "DB Error Out of range value for column + 'street_number'", This change makes it so that for addresses with long street + numbers address arsing is aborted without a fatal error. -- **Speed up contribution results by removing join on civicrm_financial_type table when rendering search results. ([13720](https://github.com/civicrm/civicrm-core/pull/13720))** +- **geocode job: Do not return more messages than can fit in the log data column + ([13346](https://github.com/civicrm/civicrm-core/pull/13346))** -- **Try and add data set example where email_on_hold / on_hold is NULL in… ([13765](https://github.com/civicrm/civicrm-core/pull/13765))** + This change fixes an error: "DB Error: Data too long for column 'data' at row + 1" when running the geocoder job on a site with over 500 unparseable + addresses. This error was being thrown because the message in the job log was + too big to be saved, this change makes it so that the message is shortened to + fit in the database. -- **Upgrade Karma version to latest version ([13751](https://github.com/civicrm/civicrm-core/pull/13751))** +- **only set custom field to null if it is really null, not string 'null' + ([13042](https://github.com/civicrm/civicrm-core/pull/13042))** -- **Rationalise Activity api ACLs for consistency, to respect the hook & improve performance ([13664](https://github.com/civicrm/civicrm-core/pull/13664))** +- **CRM/Logging - Fix various bugs in schema parsing + ([13441](https://github.com/civicrm/civicrm-core/pull/13441))** -- **Fix Custom post outer div class on event registration form ([13753](https://github.com/civicrm/civicrm-core/pull/13753))** + This change improves logging so that logs return constraints as well as + indexes (before this change indexes were not returned), and returns column + lengths without surrounding parenthesis and returns arrays using ['index1', + 'index2'] syntax instead of [0 => ['constraint_name' => 'foo']] syntax. -- **Clean up Payment.create function ([13690](https://github.com/civicrm/civicrm-core/pull/13690))** +- **CRM/Logging - Fix log table exceptions + ([13675](https://github.com/civicrm/civicrm-core/pull/13675))** -- **fix broken logic in CRM_Utils_System_DrupalBase::formatResourceUrl() ([13400](https://github.com/civicrm/civicrm-core/pull/13400))** + This change ensures that log table exceptions are applied for columns + regardless of whether or not they have backticks. -- **Allow viewing of cancelled recurring contributions ([13745](https://github.com/civicrm/civicrm-core/pull/13745))** +- **Fix html2pdf default PDF format when multiple pdf_format are available. + ([13543](https://github.com/civicrm/civicrm-core/pull/13543))** -- **Upgrader: Don't abort if state_province already exists ([13744](https://github.com/civicrm/civicrm-core/pull/13744))** + This change ensures that the correct PDF format is selected when multiple pdf + format options are available. -- **Fix the invocation of post hook for ParticipantPayment ensuring that … ([13739](https://github.com/civicrm/civicrm-core/pull/13739))** +- **Always load recaptcha JS over HTTPS + ([13601](https://github.com/civicrm/civicrm-core/pull/13601))** -- **Decommision getPartialPaymentTrxn function ([13718](https://github.com/civicrm/civicrm-core/pull/13718))** + This change ensures that recaptcha is loaded regardless of whether the site is + being served over http or https. -- **Status of test contribution is not fetched on ThankYou page. ([13724](https://github.com/civicrm/civicrm-core/pull/13724))** +- **If a profile is used to create a contact with a subtype the contact will not + have any existing subtypes + ([13499](https://github.com/civicrm/civicrm-core/pull/13499))** -- **CiviCRM Membership Detail report, add column to display if membership is Primary or Inherited ([13736](https://github.com/civicrm/civicrm-core/pull/13736))** + This change fixes PHP notices being thrown when creating a contact with a + subtype via a profile. -- **Mark de.systopia.recentitems obsolete ([13729](https://github.com/civicrm/civicrm-core/pull/13729))** +- **Remove activitystatus js. Add submitOnce handler for activity create + ([13342](https://github.com/civicrm/civicrm-core/pull/13342))** -- **Upgrade PHPWord ([13686](https://github.com/civicrm/civicrm-core/pull/13686))** + This change makes it so users can only click "save" once when creating an + activity to prevent users from accidentally creating multiple activities by + clicking save multiple times. -- **Migrate date field to datepicker on ChangeCaseType form ([13701](https://github.com/civicrm/civicrm-core/pull/13701))** +- **Fix contact ID help on advanced search + ([13569](https://github.com/civicrm/civicrm-core/pull/13569))** -- **Move assign of currency for entityForm outside of foreach so order of fields don't matter ([13696](https://github.com/civicrm/civicrm-core/pull/13696))** + This change ensures the help text appears when one clicks the help icon next + to Contact ID on the Advanced Search form. -- **Fix & test searchQuery order by to be less dependent on what is selected for search ([13680](https://github.com/civicrm/civicrm-core/pull/13680))** +- **Used buildoptions function to get all groups + ([13327](https://github.com/civicrm/civicrm-core/pull/13327))** -- **Add pseudoconstant for payment_processor_id to contributionrecur ([13702](https://github.com/civicrm/civicrm-core/pull/13702))** + This change fixes a "DB Error: no such field" when using the Contact API to + get contacts from a group where the group name and group title are different + so that no error is thrown. -- **Phase out CIVICRM_TEMP_FORCE_UTF8 ([13658](https://github.com/civicrm/civicrm-core/pull/13658))** +### CiviCase -- **Extract record refund function ([13694](https://github.com/civicrm/civicrm-core/pull/13694))** +- **[dev/core#684](https://lab.civicrm.org/dev/core/issues/684) Case Manager not + updating correctly (CiviCRM 5.8.2) + ([13528](https://github.com/civicrm/civicrm-core/pull/13528))** -- **Migrate KAM smartmenus to core ([13582](https://github.com/civicrm/civicrm-core/pull/13582))** + This change ensures that if the Case Manager is changed on the Manage Case + screen the "(Case Manager)" tag appears correctly. -- **Move pear/mail from packages to composer.json ([13289](https://github.com/civicrm/civicrm-core/pull/13289))** +- **[dev/core#739](https://lab.civicrm.org/dev/core/issues/739) Field not found + when sorting report by Case Type as a section header + ([13666](https://github.com/civicrm/civicrm-core/pull/13666))** -- **Do not attempt to store out-of-range street number ([13340](https://github.com/civicrm/civicrm-core/pull/13340))** + This change fixes the "Unknown column 'case_civireport.case_type_name' in + 'field list'" error thrown on a Case Detail report sorted by the field Case + Type with the option "Section Header" checked. -- **Use CRM_Utils_SQL_TempTable to drop and create table. ([13688](https://github.com/civicrm/civicrm-core/pull/13688))** +- **[dev/core#770](https://lab.civicrm.org/dev/core/issues/770) View Case + Activity page displays disabled custom fields + ([13741](https://github.com/civicrm/civicrm-core/pull/13741))** -- **Record change log entry when contact is moved to or restored from trash ([13276](https://github.com/civicrm/civicrm-core/pull/13276))** + This change ensures that disabled custom fields do not appear on Case + Activities. -- **geocode job: Do not return more messages than can fit in the log data column ([13346](https://github.com/civicrm/civicrm-core/pull/13346))** +### CiviContribute -- **Towards supporting EntityForm for 'View Action' ([13578](https://github.com/civicrm/civicrm-core/pull/13578))** +- **[dev/core#659](https://lab.civicrm.org/dev/core/issues/659) Civi returning + 500 errors to Paypal Pro request to civicrm/extern/ipn.php + ([13796](https://github.com/civicrm/civicrm-core/pull/13796))** -- **only set custom field to null if it is really null, not string 'null' ([13042](https://github.com/civicrm/civicrm-core/pull/13042))** + This change ensures that 500 http errors returned from payment processors are + caught and logged but do not affect the processor response. This fixes a bug + with Paypal Pro recurring transactions. -- **CiviMail: Fix reply forwarding for mailers with From: and Return-path: limitations ([12641](https://github.com/civicrm/civicrm-core/pull/12641))** +- **[dev/core#716](https://lab.civicrm.org/dev/core/issues/716) Add decimals in + Contribution Amount on Repeat Contributions Report + ([13659](https://github.com/civicrm/civicrm-core/pull/13659))** -- **CRM/Logging - Fix various bugs in schema parsing ([13441](https://github.com/civicrm/civicrm-core/pull/13441))** + This change ensures that the Repeat Contributions Report does not truncate the + decimals of contributions. -- **Force utf8mb4 query to throw exception as the check expects ([13682](https://github.com/civicrm/civicrm-core/pull/13682))** +- **[dev/core#801](https://lab.civicrm.org/dev/core/issues/801) Thank You + letters have an invalid 'from' when sending from the contact's email address + ([13825](https://github.com/civicrm/civicrm-core/pull/13825))** -- **Payment notification formatting, move greeting into table ([13669](https://github.com/civicrm/civicrm-core/pull/13669))** + This change fixes an error when attempting to send Thank you letters by email. -- **CRM/Logging - Fix log table exceptions ([13675](https://github.com/civicrm/civicrm-core/pull/13675))** +- **Status of test contribution is not fetched on ThankYou page. + ([13724](https://github.com/civicrm/civicrm-core/pull/13724))** -- **Switch additional payment form to use Payment.sendconfirmation api ([13649](https://github.com/civicrm/civicrm-core/pull/13649))** + This change ensures that on a Contribution page with a payment processor that + captures payment instantly and does not use the confirmation page that the + Confirmation message on the Thank You page states the status of the + transaction instead of "Your contribution has been submitted...". -- **Update Payment Notification to use greeting, remove text to 'Please print this confirmation for your records. ([13655](https://github.com/civicrm/civicrm-core/pull/13655))** +- **Move assign of currency for entityForm outside of foreach so order of fields + don't matter ([13696](https://github.com/civicrm/civicrm-core/pull/13696))** -- **Payment.sendconfirmation api - add further tpl variables. ([13610](https://github.com/civicrm/civicrm-core/pull/13610) and [13609](https://github.com/civicrm/civicrm-core/pull/13609))** + This change ensures assign currency works regardless of whether currency is + before or after the money fields. -- **Remove another instance of 'lower' ([13636](https://github.com/civicrm/civicrm-core/pull/13636))** +- **Find Contributions columns/headers not aligned when "Contributions OR Soft + Credits?" filter set to "Soft Credits Only" + ([13517](https://github.com/civicrm/civicrm-core/pull/13517))** -- **Fix html2pdf default PDF format when multiple pdf_format are available. ([13543](https://github.com/civicrm/civicrm-core/pull/13543))** + This change ensures that when running a Find Contributions search with the + "Contributions OR Soft Credits?" filter set to "Soft Credits Only" the headers + line up with the correct columns. -- ** EntityRef - standardize on PascalCase for entity name and fix minor bug ([13631](https://github.com/civicrm/civicrm-core/pull/13631))** +### CiviEvent -- **Contribution/ContributionRecur metadata updates for EntityForm ([13579](https://github.com/civicrm/civicrm-core/pull/13579))** +- **[dev/core#696](https://lab.civicrm.org/dev/core/issues/696) Changes to + copied event phone and email reflects in original event phone and email + ([13534](https://github.com/civicrm/civicrm-core/pull/13534))** -- **Standardize format for entityRef create links ([13628](https://github.com/civicrm/civicrm-core/pull/13628))** + This change fixes a bug where if a user copied an event and then edited the + copied events email and or phone number, the changes would be applied to the + original event and the copied event, this change makes it so that the changes + only apply to the copy. -- **Always load recaptcha JS over HTTPS ([13601](https://github.com/civicrm/civicrm-core/pull/13601))** +- **Fix the invocation of post hook for ParticipantPayment ensuring that an id + is passed in post hook + ([13739](https://github.com/civicrm/civicrm-core/pull/13739))** -- **If a profile is used to create a contact with a subtype the contact will not have any existing subtypes ([13499](https://github.com/civicrm/civicrm-core/pull/13499))** +### CiviMail -- **Fix (sometimes serious) performance problem on submitting profiles for specified contacts ([13606](https://github.com/civicrm/civicrm-core/pull/13606))** +- **[dev/core#469](https://lab.civicrm.org/dev/core/issues/469) Error on action + "Email - schedule/send via CiviMail" with multiple event names filter + ([13539](https://github.com/civicrm/civicrm-core/pull/13539))** -- **Move l10n.js to coreResourcesList ([13612](https://github.com/civicrm/civicrm-core/pull/13612))** +- **CiviMail: Fix reply forwarding for mailers with From: and Return-path: + limitations ([12641](https://github.com/civicrm/civicrm-core/pull/12641))** -- **Add install and runtime status warnings if MySQL utf8mb4 is not supported ([13425](https://github.com/civicrm/civicrm-core/pull/13425))** +- **"Only variable references should be returned by reference" notice in + Mail_smtp ([220](https://github.com/civicrm/civicrm-packages/pull/220))** -- **Add in Exception API to support the refactor of Dedupe Exception Page ([13611](https://github.com/civicrm/civicrm-core/pull/13611))** + This change fixes a "Only variable references should be returned by reference" + PHP notice under various SMTP error conditions. -- **Add new Payment.sendconfirmation api ([13561](https://github.com/civicrm/civicrm-core/pull/13561))** +### CiviMember -- **Find Contributions columns/headers not aligned when "Contributions OR Soft Credits?" filter set to "Soft Credits Only" ([13517](https://github.com/civicrm/civicrm-core/pull/13517))** +- **[dev/core#631](https://lab.civicrm.org/dev/core/issues/631) Problem when + merging contacts which have membership records + ([13588](https://github.com/civicrm/civicrm-core/pull/13588))** -- **Improves styling on Joomla! upgrade screen ([13557](https://github.com/civicrm/civicrm-core/pull/13557))** + On the merge screen, when merging Memberships, this change enables the "add + new" membership checkbox by default if no membership in the main contact + matches the membership of the other contact so that a new membership is + created. Before this change if one selected merge memberships but no matching + membership was found the other contacts Membership was not moved to the main + contact. -- **Remove activitystatus js. Add submitOnce handler for activity create ([13342](https://github.com/civicrm/civicrm-core/pull/13342))** +- **[dev/core#644](https://lab.civicrm.org/dev/core/issues/644) "From" address + on membership renewal notices is wrong + ([13776](https://github.com/civicrm/civicrm-core/pull/13776))** -- **Bump minimum upgradable ver to 4.2.9 ([13580](https://github.com/civicrm/civicrm-core/pull/13580))** + This change ensures that the "From" address on membership renewal notices is + the display name of the contact selected in the "Receipt From" field not the + contact id. -- **Remove hurty free calls from campaign and case ([13564](https://github.com/civicrm/civicrm-core/pull/13564))** +### Drupal Integration -- **Fix contact ID help on advanced search ([13569](https://github.com/civicrm/civicrm-core/pull/13569))** +- **fix broken logic in CRM_Utils_System_DrupalBase::formatResourceUrl() + ([13400](https://github.com/civicrm/civicrm-core/pull/13400))** -- **Used buildoptions function to get all groups ([13327](https://github.com/civicrm/civicrm-core/pull/13327))** + This change fixes a bug where Drupal sites were not processing absolute URLs + containing the $base_url passed in from extensions (like Shoreditch) + correctly. -- **Show Add to group on create new report after refresh of result ([13404](https://github.com/civicrm/civicrm-core/pull/13404))** +- **[dev/core#381](https://lab.civicrm.org/dev/core/issues/381) + civicrm/file/imagefile serving up wrong images + ([564](https://github.com/civicrm/civicrm-drupal/pull/564)) Extends work** -- **Optimize CRM_Core_BAO_FinancialTrxn::getTotalPayment ([13187](https://github.com/civicrm/civicrm-core/pull/13187))** + This change fixes how civicrm/file/imagefiles are served in the Drupal custom + file field handler file. -- **CRM.loadScript improvements ([13555](https://github.com/civicrm/civicrm-core/pull/13555))** +### Wordpress Integration -- **Make submitOnce() button js into a button parameter ([13333](https://github.com/civicrm/civicrm-core/pull/13333))** +- **[dev/wordpress#18](https://lab.civicrm.org/dev/wordpress/issues/18) wp-cli + sometimes fails to find cms path + ([147](https://github.com/civicrm/civicrm-wordpress/pull/147))** -- **Port fix for dev/core#381 to custom file field handler file ([564](https://github.com/civicrm/civicrm-drupal/pull/564))** + This change ensures that the path specified to wp-cli as `--path` is passed to + CiviCRM which fixes some URL errors specifically but not limited to when + sending bulk mailings with trackable urls. -- **Make address Supplemental line 3 available to views ([551](https://github.com/civicrm/civicrm-drupal/pull/551))** +## Miscellany -- **CMS path fix in wp-cli ([147](https://github.com/civicrm/civicrm-wordpress/pull/147))** +- **Optimize CRM_Core_BAO_FinancialTrxn::getTotalPayment + ([13187](https://github.com/civicrm/civicrm-core/pull/13187))** -- **Remove old menu plugin ([240](https://github.com/civicrm/civicrm-packages/pull/240))** +- **Bump minimum upgradable ver to 4.2.9 + ([13580](https://github.com/civicrm/civicrm-core/pull/13580))** -- **"Only variable references should be returned by reference" notice in Mail_smtp ([220](https://github.com/civicrm/civicrm-packages/pull/220))** +- **Use CRM_Utils_SQL_TempTable to drop and create table. + ([13688](https://github.com/civicrm/civicrm-core/pull/13688))** -## Miscellany +- **Clean up Payment.create function + ([13690](https://github.com/civicrm/civicrm-core/pull/13690))** + +- **[dev/report#9](https://lab.civicrm.org/dev/report/issues/9) Deprecate + `getBasicContactFields` in favor of `getColumns('Contact')` + ([13657](https://github.com/civicrm/civicrm-core/pull/13657))** + +- **Extract getSearchSQLParts function + ([13735](https://github.com/civicrm/civicrm-core/pull/13735))** - **[Test changes] Mailing job test use ([13629](https://github.com/civicrm/civicrm-core/pull/13629))** @@ -370,7 +791,7 @@ Released April 3, 2019 - **[ref] Extract activity payment creation ([13695](https://github.com/civicrm/civicrm-core/pull/13695))** - - **[REF] separate financial handling & component transitioning in +- **[REF] separate financial handling & component transitioning in Payment.create ([13756](https://github.com/civicrm/civicrm-core/pull/13756))** - **[REF] towards cleanup of update membership code @@ -397,6 +818,24 @@ Released April 3, 2019 - **Add unit test on getContributionBalance fn (#13187) ([13558](https://github.com/civicrm/civicrm-core/pull/13558))** +- **Phase out CIVICRM_TEMP_FORCE_UTF8 + ([13658](https://github.com/civicrm/civicrm-core/pull/13658))** + +- **Extract record refund function + ([13694](https://github.com/civicrm/civicrm-core/pull/13694))** + +- **Move pear/mail from packages to composer.json + ([13289](https://github.com/civicrm/civicrm-core/pull/13289))** + +- **Decommision getPartialPaymentTrxn function + ([13718](https://github.com/civicrm/civicrm-core/pull/13718))** + +- **Fix & test searchQuery order by to be less dependent on what is selected for + search ([13680](https://github.com/civicrm/civicrm-core/pull/13680))** + +- **EntityRef - standardize on PascalCase for entity name and fix minor bug + ([13631](https://github.com/civicrm/civicrm-core/pull/13631))** + ## Credits This release was developed by the following code authors: From fce2540cd7930930bf9a17195caad9365364a6fa Mon Sep 17 00:00:00 2001 From: Andrew Hunt Date: Wed, 3 Apr 2019 15:59:02 -0400 Subject: [PATCH 053/121] 5.12.0 release notes: late changes --- release-notes/5.12.0.md | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/release-notes/5.12.0.md b/release-notes/5.12.0.md index 13d9a054df6e..7d746cf4bdd3 100644 --- a/release-notes/5.12.0.md +++ b/release-notes/5.12.0.md @@ -273,6 +273,13 @@ Released April 3, 2019 ### Core CiviCRM +- **[dev/core#842](https://lab.civicrm.org/dev/core/issues/842) Regression?? + Inline editing of website field deletes it + ([13939](https://github.com/civicrm/civicrm-core/pull/13939))** + + This resolves a bug where editing a website field inline sometimes would + delete the field entirely. + - **[dev/core#190](https://lab.civicrm.org/dev/core/issues/190) custom data with multiple records profile: after submission, profile view shows first record instead of most recent @@ -289,6 +296,13 @@ Released April 3, 2019 This change fixes a fatal error when using a dedupe rule with the field birth date. +- **[dev/core#821](https://lab.civicrm.org/dev/core/issues/821) Activity: + Assigned to: It is not possible to search by the "refine search" drop-down + ([13893](https://github.com/civicrm/civicrm-core/pull/13893))** + + When setting an activity assignee, a bug prevented using the filters in the + contact reference field. + - **[dev/core#580](https://lab.civicrm.org/dev/core/issues/580) No groups displayed on Manage Groups when "All Groups" is selected ([13373](https://github.com/civicrm/civicrm-core/pull/13373))** @@ -551,6 +565,10 @@ Released April 3, 2019 This change fixes an error when attempting to send Thank you letters by email. +- **[dev/core#812](https://lab.civicrm.org/dev/core/issues/812) Contribution row + displayed even if contact has 0 contributions. + ([13881](https://github.com/civicrm/civicrm-core/pull/13881))** + - **Status of test contribution is not fetched on ThankYou page. ([13724](https://github.com/civicrm/civicrm-core/pull/13724))** @@ -772,8 +790,9 @@ Released April 3, 2019 - **[REF] extract chunk of code to a separate function ([13600](https://github.com/civicrm/civicrm-core/pull/13600))** -- **[REF} User api rather than selector for rendering contributions on user - dashboard ([13584](https://github.com/civicrm/civicrm-core/pull/13584))** +- **[REF] Use api rather than selector for rendering contributions on user + dashboard ([13584](https://github.com/civicrm/civicrm-core/pull/13584) and + [13903](https://github.com/civicrm/civicrm-core/pull/13903))** - **[REF] switch from (undeclared) class property to local variable. ([13583](https://github.com/civicrm/civicrm-core/pull/13583))** From 918777e9fc78b91b72c043af34b797bea2f7b56b Mon Sep 17 00:00:00 2001 From: Andrew Hunt Date: Wed, 3 Apr 2019 17:42:56 -0400 Subject: [PATCH 054/121] 5.12.0 release notes: final edits --- contributor-key.yml | 7 + release-notes/5.12.0.md | 386 +++++++++++++++++++--------------------- 2 files changed, 194 insertions(+), 199 deletions(-) diff --git a/contributor-key.yml b/contributor-key.yml index 98b8a186aa8d..04f67c359e1d 100644 --- a/contributor-key.yml +++ b/contributor-key.yml @@ -998,6 +998,9 @@ organization: CompuCorp jira : mukesh +- github : mwestergaard + name : Mark Westergaard + - github : nbrettell name : Nathan Brettell jira : nathan_b @@ -1149,6 +1152,10 @@ - github : ray-wright name : Ray Wright +- github : reecebenson + name : Reece Benson + organization: Circle Interactive + - name : Renaee Churches organization: Play Australia jira : Renz56c.o diff --git a/release-notes/5.12.0.md b/release-notes/5.12.0.md index 7d746cf4bdd3..2b7a90effe54 100644 --- a/release-notes/5.12.0.md +++ b/release-notes/5.12.0.md @@ -14,13 +14,13 @@ Released April 3, 2019 | *Does this version...?* | | |:--------------------------------------------------------------- |:-------:| -| Fix security vulnerabilities? | | -| Change the database schema? | **yes** | -| Alter the API? | **yes** | -| Require attention to configuration options? | | -| Fix problems installing or upgrading to a previous version? | **yes** | -| Introduce features? | **yes** | -| Fix bugs? | **yes** | +| Fix security vulnerabilities? | no | +| **Change the database schema?** | **yes** | +| **Alter the API?** | **yes** | +| **Require attention to configuration options?** | **yes** | +| **Fix problems installing or upgrading to a previous version?** | **yes** | +| **Introduce features?** | **yes** | +| **Fix bugs?** | **yes** | ## Features @@ -30,15 +30,13 @@ Released April 3, 2019 ([13582](https://github.com/civicrm/civicrm-core/pull/13582), [240](https://github.com/civicrm/civicrm-packages/pull/240), [13612](https://github.com/civicrm/civicrm-core/pull/13612), - [13729](https://github.com/civicrm/civicrm-core/pull/13729) and - [13820](https://github.com/civicrm/civicrm-core/pull/13820))** + [13729](https://github.com/civicrm/civicrm-core/pull/13729), + [13820](https://github.com/civicrm/civicrm-core/pull/13820), and + [13876](https://github.com/civicrm/civicrm-core/pull/13876))** - These changes update the CiviCRM Administration menu to use KAM smartmenus - this makes the menu mobile responsive. Additionally, these changes remove the - old menu plugin as it is no longer needed, add l10n.js within - coreResourcesList and fix an unreleased regression for wordpress users where - the CiviCRM Admin Bar was visible on the 'Front End' - [dev/core#790](https://lab.civicrm.org/dev/core/issues/790). + The Keyboard Accessible Menus extension is now moved to core, replacing the + CiviCRM navigation menu with a grey one provided by the SmartMenus jQuery + plugin. The new menu is mobile-responsive and more accessible. - **[dev/core#657](https://lab.civicrm.org/dev/core/issues/657) Add filter for country on Repeat Contributions Report @@ -50,8 +48,8 @@ Released April 3, 2019 entities in Attachment API by short-circuiting permission check ([13529](https://github.com/civicrm/civicrm-core/pull/13529))** - This change makes it so one can use the Attachment API to update attachment - custom fields on Memberships and several other entities. + You can now use the Attachment API to update attachment custom fields on + Memberships and several other entities. - **[dev/core#561](https://lab.civicrm.org/dev/core/issues/561) Replace jcalendar instances with datepicker @@ -67,39 +65,38 @@ Released April 3, 2019 criteria in the url. - **Add install and runtime status warnings if MySQL utf8mb4 is not supported - ([13425](https://github.com/civicrm/civicrm-core/pull/13425))** + ([13425](https://github.com/civicrm/civicrm-core/pull/13425) and + [13682](https://github.com/civicrm/civicrm-core/pull/13682))** This change adds a warning to the system status page, as well as at install - time, if utf8mb4 is not supported by the stack. + time, if a site's MySQL server does not support the utf8mb4 character set. See + also [dev/core#749](https://lab.civicrm.org/dev/core/issues/749) for an + intra-release regression related to this. - **Record change log entry when contact is moved to or restored from trash ([13276](https://github.com/civicrm/civicrm-core/pull/13276))** - This change makes it so that a Change Log entry is created when a contact is + This change makes it so that a change log entry is created when a contact is moved to the trash or restored from the trash. - **Towards supporting EntityForm for 'View Action' ([13578](https://github.com/civicrm/civicrm-core/pull/13578))** - This change enhances support for EntityForm in the "View" context. + This change enhances support for viewing entities in the abstracted + "EntityForm" code. This may be used in the future to standardize viewing and + editing CiviCRM entities. - **Standardize format for entityRef create links ([13628](https://github.com/civicrm/civicrm-core/pull/13628))** - This change standardizes entityRef create links so that they are pre-loaded to - the clientside and so that they work equally well with all entities. - -- **Fix (sometimes serious) performance problem on submitting profiles for - specified contacts - ([13606](https://github.com/civicrm/civicrm-core/pull/13606))** - - This change improves performance when submitting profiles for specified - contacts. + This change standardizes the creation links in entity reference fields so that + they are pre-loaded for the client and so that they work equally well with all + entities. - **Add in Exception API to support the refactor of Dedupe Exception Page ([13611](https://github.com/civicrm/civicrm-core/pull/13611))** - This change adds an API to Query Dedupe Exceptions. + This change adds an API to create, get, and delete dedupe exceptions. - **CRM.loadScript improvements ([13555](https://github.com/civicrm/civicrm-core/pull/13555))** @@ -119,65 +116,26 @@ Released April 3, 2019 These changes improve performance by removing instances of $dao->free. -- **[infra/ops#878](https://lab.civicrm.org/infra/ops/issues/878) Add a test - matrix for E2E tests on each CMS - ([13808](https://github.com/civicrm/civicrm-core/pull/13808))** - - This change improves reliability by increasing test coverage. - -- **Try and add data set example where email_on_hold / on_hold is NULL in the - formValues ([13765](https://github.com/civicrm/civicrm-core/pull/13765))** - - This change adds test coverage. - -- **[dev/core#746](https://lab.civicrm.org/dev/core/issues/746) Search Builder - searches using > 1 smart group where operator is equals is broken from 5.10.0 - ([13685](https://github.com/civicrm/civicrm-core/pull/13685)) Continued work** - - This change adds test coverage for Search Builder searches using > 1 smart - group. - -- **[dev/report#10](https://lab.civicrm.org/dev/report/issues/10) No pagination - on Contribution Detail report - ([13678](https://github.com/civicrm/civicrm-core/pull/13678)) Continued Work** - - This change adds a unit test for pagination on the Contribution Detail report. - -- **[dev/core#720](https://lab.civicrm.org/dev/core/issues/720) Performance - change approved - remove mode & median slow queries - ([13607](https://github.com/civicrm/civicrm-core/pull/13607), - [13630](https://github.com/civicrm/civicrm-core/pull/13630) and - [13605](https://github.com/civicrm/civicrm-core/pull/13605))** - - This change removes the mode and median stats on the contribution search - summary and contribution tab on contacts to improve performance. - -- **[dev/core#748](https://lab.civicrm.org/dev/core/issues/748) Deadlocks and - performance issues when using smartgroups / ACLs extensively - ([13732](https://github.com/civicrm/civicrm-core/pull/13732))** - - This change improves performance for smart groups and ACLs. - -- **Upgrade Karma version to latest version - ([13751](https://github.com/civicrm/civicrm-core/pull/13751))** - - **Upgrade PHPWord ([13686](https://github.com/civicrm/civicrm-core/pull/13686))** + CiviCRM now contains an updated version of the code library for generating + Word documents. + ### CiviContribute - **Add pseudoconstant for payment_processor_id to contributionrecur ([13702](https://github.com/civicrm/civicrm-core/pull/13702)) Continued Work** This change alters the schema to add support for payment_processor_id as a - pseudoconstant for Recurring Contributions. + pseudoconstant for recurring contributions. - **[dev/core#767](https://lab.civicrm.org/dev/core/issues/767) Add 'Cancelled / Refunded Date' and 'Cancellation / Refund Reason' in the Detail Contributions Report ([13726](https://github.com/civicrm/civicrm-core/pull/13726))** This change adds the fields and filters 'Cancelled / Refunded Date' and - 'Cancellation / Refund Reason' to the Detail Contributions Report. + 'Cancellation / Refund Reason' to the Contribution Detail report. - **[dev/report#8](https://lab.civicrm.org/dev/report/issues/8) Contribution reports don't include thank-you date @@ -203,41 +161,36 @@ Released April 3, 2019 - **Allow viewing of cancelled recurring contributions ([13745](https://github.com/civicrm/civicrm-core/pull/13745))** - This change makes it possible to view canceled recurring contributions thru - the user interface. + It is now possible to view canceled recurring contributions through the user + interface. - **Add new Payment.sendconfirmation api ([13610](https://github.com/civicrm/civicrm-core/pull/13610), [13561](https://github.com/civicrm/civicrm-core/pull/13561) and [13609](https://github.com/civicrm/civicrm-core/pull/13609))** - These changes add a Payment.sendconfirmation API. + A new Payment.sendconfirmation API method is available for generating payment + confirmation emails. - **Switch additional payment form to use Payment.sendconfirmation api ([13649](https://github.com/civicrm/civicrm-core/pull/13649))** - This change switches the additional payment form to use the new - Payment.sendconfirmation api. + The additional payment form now generates confirmation emails using the new + Payment.sendconfirmation API. - **Payment notification formatting, move greeting into table ([13669](https://github.com/civicrm/civicrm-core/pull/13669))** - This change improves the Payment Notification Email formatting by aligning the - greeting with the table. + The greeting in the payment notification email is now aligned with the table + of payment information. - **Update Payment Notification to use greeting, remove text to 'Please print this confirmation for your records. ([13655](https://github.com/civicrm/civicrm-core/pull/13655))** - This change improves the Payment Notification email by removing the 'Please - print this confirmation for your records.' text and switching to use the - email_greeting instead of the display_name for the greeting. - -- **Remove another instance of 'lower' - ([13636](https://github.com/civicrm/civicrm-core/pull/13636))** - - This change improves performance when searching notes fields on a - contribution. + The Payment Notification email no longer asks recipients to "Please print this + confirmation for your records." It also is updated to use the email_greeting + instead of the display_name for the greeting. - **Contribution/ContributionRecur metadata updates for EntityForm ([13579](https://github.com/civicrm/civicrm-core/pull/13579))** @@ -277,24 +230,35 @@ Released April 3, 2019 Inline editing of website field deletes it ([13939](https://github.com/civicrm/civicrm-core/pull/13939))** - This resolves a bug where editing a website field inline sometimes would - delete the field entirely. + This resolves a bug where editing a website field inline on the contact + summary tab sometimes would delete the field entirely. - **[dev/core#190](https://lab.civicrm.org/dev/core/issues/190) custom data with multiple records profile: after submission, profile view shows first record instead of most recent ([12337](https://github.com/civicrm/civicrm-core/pull/12337))** - This change ensures when submitting a multi data profile, the most recently - created record is retrieved on the confirmation page, before this change the - first record was retrieved. + When submitting a profile with files that allow multiple records, the most + recently created record is now retrieved on the confirmation page. Before + this change, the first record was retrieved. + +- **Fix (sometimes serious) performance problem on submitting profiles for + specified contacts + ([13606](https://github.com/civicrm/civicrm-core/pull/13606))** + +- **[dev/core#748](https://lab.civicrm.org/dev/core/issues/748) Deadlocks and + performance issues when using smartgroups / ACLs extensively + ([13732](https://github.com/civicrm/civicrm-core/pull/13732))** + + This change improves performance of many queries by no longer using the + `UPPER()` and `LOWER()` MySQL functions. - **[dev/core#397](https://lab.civicrm.org/dev/core/issues/397) Dedupe for Individual Birth Date Results in Error ([13538](https://github.com/civicrm/civicrm-core/pull/13538))** - This change fixes a fatal error when using a dedupe rule with the field birth - date. + This change fixes a fatal error when using a dedupe rule with the birth date + field. - **[dev/core#821](https://lab.civicrm.org/dev/core/issues/821) Activity: Assigned to: It is not possible to search by the "refine search" drop-down @@ -307,19 +271,17 @@ Released April 3, 2019 displayed on Manage Groups when "All Groups" is selected ([13373](https://github.com/civicrm/civicrm-core/pull/13373))** - Before this change if a user had an ACL that gave them permission to Edit - "All Groups" but did not have the permission "View All Contacts" then on the - "Manage Groups" screen no groups would appear, this change makes it so that - groups appear for these users. + This resolves a bug where if a user had an ACL that gave them permission to + Edit "All Groups" but did not have the permission "View All Contacts", on the + "Manage Groups" screen no groups would appear. - **[dev/core#642](https://lab.civicrm.org/dev/core/issues/642) New Contact Report: New report isn't created automatically when the user selects the "Create Report" action ([13404](https://github.com/civicrm/civicrm-core/pull/13404))** - This change ensures that when one selects the action "Create Report" on the - "Constituent Report (Summary)" report a new report is created, before this - change a js error was thrown and no report was created. + This resolves a Javascript error when attempting to create a new report from + the Constituent Report (Summary) template. - **[dev/core#683](https://lab.civicrm.org/dev/core/issues/683) Incorrectly encoded state and country names @@ -341,33 +303,27 @@ Released April 3, 2019 ([13549](https://github.com/civicrm/civicrm-core/pull/13549))** When using the Advanced Search form to search by contact ID, this change - ensures if no matching contact is found the Qill states the search criteria - for which no matches were found. + ensures that if there is no matching contact the message states the search + criteria. - **[dev/core#708](https://lab.civicrm.org/dev/core/issues/708) Advanced Search: The "Modified By" option was set instead of "Added by" ([13566](https://github.com/civicrm/civicrm-core/pull/13566))** - When using the Advanced Search form to search by "Added by", this change - ensures if no matching contacts are found the Qill states the search criteria - for which no matches were found accurately, before this change the qill said - "No Matches Found Modified by..." instead of "No Matches Found Added by..." . + In Advanced Search, the listing of search criteria for searches yielding no + results would display "modified by" when "added by" was a criterion. - **[dev/core#705](https://lab.civicrm.org/dev/core/issues/705) Disabling Alphabetical Pager is not respected for events and contribution pages. ([13592](https://github.com/civicrm/civicrm-core/pull/13592))** - This change ensures if in the Admin -> Search preferences "include - Alphabetical Pager" is turned off, that the A to Z pager is off for Manage - Events and Manage Contributions. - - **[dev/core#714](https://lab.civicrm.org/dev/core/issues/714) Manage groups: Error: "API permission check failed for Group/create call; insufficient permission" when the user tries to edit some group's details ([13573](https://github.com/civicrm/civicrm-core/pull/13573))** - This change ensures that on the Manage Groups form, if a user does not have - permissions to edit a group inline edit is disabled. + On the Manage Groups form, if a user does not have permissions to edit a + group, the edit link is disabled. - **[dev/core#742](https://lab.civicrm.org/dev/core/issues/742) Repeated warning: "simplexml_load_file(): I/O warning : failed to load external entity @@ -377,29 +333,6 @@ Released April 3, 2019 This change fixes warnings regarding failing to parse the XML file when clearing the CiviCRM caches. -- **[dev/core#749](https://lab.civicrm.org/dev/core/issues/749) MySQL utf8mb4 - check causes fatal error on some systems - ([13682](https://github.com/civicrm/civicrm-core/pull/13682))** - - This fixes a bug where on some systems the MySQL utf8mb4 compatibility check - would cause a fatal error so that an exception is thrown instead of a fatal - error. - -- **[dev/core#769](https://lab.civicrm.org/dev/core/issues/769) ZIP Archive for - multiple batch exports fail - ([13728](https://github.com/civicrm/civicrm-core/pull/13728))** - - This change fixes ZIP Archives for multiple batch exports for instances with - any PHP version greater than 5.6. - -- **[dev/report#7](https://lab.civicrm.org/dev/report/issues/7) Transaction Date - filter in Bookkeeping Transactions report - ([13571](https://github.com/civicrm/civicrm-core/pull/13571))** - - This change ensures that the trxn_date field on the Bookkeeping Report filter - respects the times designated in the filter, before this change it would only - return transactions that occurred at midnight. - - **[dev/report#11](https://lab.civicrm.org/dev/report/issues/11) Soft Credit report fails when Only Full Group By is enabled ([13671](https://github.com/civicrm/civicrm-core/pull/13671))** @@ -407,36 +340,21 @@ Released April 3, 2019 - **Remove mcrypt system status check ([13770](https://github.com/civicrm/civicrm-core/pull/13770))** - This change removes the mcrypt system status check becacuse PHP 7.2 does not - support mcrypt and it is being deprecated. Before this change the status check - would respond with the error "mcrypt not present & smtp encryption in place" - after this change no error is thrown. + PHP 7.2 does not support mcrypt, which is being deprecated. This removes the + status check that would notify administrators if mcrypt is not installed. - **Fix api bug whereby 0 & '0' are not accepted as range parameters for BETWEEN ([13766](https://github.com/civicrm/civicrm-core/pull/13766))** - This change fixes a bug when using the api and a filter "Between" with one of - the parameters set to 0 or '0' would result in an error so that one can use a - between range with 0 as the beginning or the end of the range. - - **Render Note field tokens correctly - they are already HTML. ([13283](https://github.com/civicrm/civicrm-core/pull/13283))** - This change ensures that tokens of Note fields are rendered correctly. - - **Rationalise Activity api ACLs for consistency, to respect the hook & improve performance ([13664](https://github.com/civicrm/civicrm-core/pull/13664))** This change alters the way permissions are handled on sites that use ACLs when the activity.get api is called with the 'check_permissions' flag set to TRUE. - This would usually be the case for js calls. - -- **Fix Custom post outer div class on event registration form - ([13753](https://github.com/civicrm/civicrm-core/pull/13753))** - - This change updates the class applied to the outer div around a custom profile - in the post section of the form to use 1 custom_pre-section and 1 - custom_post-section instead of two custom_pre-sections. + This would usually be the case for Javascript calls. - **Upgrader: Don't abort if state_province already exists ([13744](https://github.com/civicrm/civicrm-core/pull/13744))** @@ -450,8 +368,8 @@ Released April 3, 2019 Before this change attempting to geocode an address with a long street number would result in a fatal error "DB Error Out of range value for column - 'street_number'", This change makes it so that for addresses with long street - numbers address arsing is aborted without a fatal error. + 'street_number'". This change aborts parsing for addresses with long street + numbers. - **geocode job: Do not return more messages than can fit in the log data column ([13346](https://github.com/civicrm/civicrm-core/pull/13346))** @@ -459,12 +377,15 @@ Released April 3, 2019 This change fixes an error: "DB Error: Data too long for column 'data' at row 1" when running the geocoder job on a site with over 500 unparseable addresses. This error was being thrown because the message in the job log was - too big to be saved, this change makes it so that the message is shortened to + too big to be saved, and this change makes it so that the message is shortened to fit in the database. - **only set custom field to null if it is really null, not string 'null' ([13042](https://github.com/civicrm/civicrm-core/pull/13042))** + Custom fields saved with `NULL`, `Null`, or any value other than `null` will + be saved as-is. A value of `null`, however, still saves a null value. + - **CRM/Logging - Fix various bugs in schema parsing ([13441](https://github.com/civicrm/civicrm-core/pull/13441))** @@ -482,14 +403,14 @@ Released April 3, 2019 - **Fix html2pdf default PDF format when multiple pdf_format are available. ([13543](https://github.com/civicrm/civicrm-core/pull/13543))** - This change ensures that the correct PDF format is selected when multiple pdf - format options are available. + This change ensures that the correct default PDF format is selected when + multiple pdf format options are available. - **Always load recaptcha JS over HTTPS ([13601](https://github.com/civicrm/civicrm-core/pull/13601))** - This change ensures that recaptcha is loaded regardless of whether the site is - being served over http or https. + This change ensures that reCAPTCHA is loaded regardless of whether the site is + being served over HTTP or HTTPS. - **If a profile is used to create a contact with a subtype the contact will not have any existing subtypes @@ -514,9 +435,9 @@ Released April 3, 2019 - **Used buildoptions function to get all groups ([13327](https://github.com/civicrm/civicrm-core/pull/13327))** - This change fixes a "DB Error: no such field" when using the Contact API to - get contacts from a group where the group name and group title are different - so that no error is thrown. + This change fixes a "DB Error: no such field" message when using the Contact + API to get contacts from a group where the group name and group title are + different so that no error is thrown. ### CiviCase @@ -539,18 +460,22 @@ Released April 3, 2019 Activity page displays disabled custom fields ([13741](https://github.com/civicrm/civicrm-core/pull/13741))** - This change ensures that disabled custom fields do not appear on Case - Activities. - ### CiviContribute +- **[dev/core#644](https://lab.civicrm.org/dev/core/issues/644) "From" address + on membership renewal notices is wrong + ([13776](https://github.com/civicrm/civicrm-core/pull/13776))** + + In some configurations, contribution receipts would be sent with a contact ID + as the "From" address rather than an actual address. + - **[dev/core#659](https://lab.civicrm.org/dev/core/issues/659) Civi returning 500 errors to Paypal Pro request to civicrm/extern/ipn.php ([13796](https://github.com/civicrm/civicrm-core/pull/13796))** - This change ensures that 500 http errors returned from payment processors are - caught and logged but do not affect the processor response. This fixes a bug - with Paypal Pro recurring transactions. + When CiviCRM encounters an error in processing an instant payment + notification, it no longer returns HTTP status of 500. PayPal would disable + IPN after too many 500 errors, assuming the site is broken. - **[dev/core#716](https://lab.civicrm.org/dev/core/issues/716) Add decimals in Contribution Amount on Repeat Contributions Report @@ -563,7 +488,35 @@ Released April 3, 2019 letters have an invalid 'from' when sending from the contact's email address ([13825](https://github.com/civicrm/civicrm-core/pull/13825))** - This change fixes an error when attempting to send Thank you letters by email. +- **[dev/core#720](https://lab.civicrm.org/dev/core/issues/720) Performance + change approved - remove mode & median slow queries + ([13607](https://github.com/civicrm/civicrm-core/pull/13607), + [13630](https://github.com/civicrm/civicrm-core/pull/13630) and + [13605](https://github.com/civicrm/civicrm-core/pull/13605))** + + This change removes the mode and median stats on the contribution search + summary and contribution tab on contacts to improve performance. + +- **Remove another instance of 'lower' + ([13636](https://github.com/civicrm/civicrm-core/pull/13636))** + + This change improves performance when searching notes fields on a + contribution. + +- **[dev/core#769](https://lab.civicrm.org/dev/core/issues/769) ZIP Archive for + multiple batch exports fail + ([13728](https://github.com/civicrm/civicrm-core/pull/13728))** + + This change fixes ZIP Archives for multiple batch exports for instances with + any PHP version greater than 5.6. + +- **[dev/report#7](https://lab.civicrm.org/dev/report/issues/7) Transaction Date + filter in Bookkeeping Transactions report + ([13571](https://github.com/civicrm/civicrm-core/pull/13571))** + + This change ensures that the trxn_date field on the Bookkeeping Report filter + respects the times designated in the filter. Before this change it would only + return transactions that occurred at midnight. - **[dev/core#812](https://lab.civicrm.org/dev/core/issues/812) Contribution row displayed even if contact has 0 contributions. @@ -573,8 +526,8 @@ Released April 3, 2019 ([13724](https://github.com/civicrm/civicrm-core/pull/13724))** This change ensures that on a Contribution page with a payment processor that - captures payment instantly and does not use the confirmation page that the - Confirmation message on the Thank You page states the status of the + captures payment instantly and does not use the confirmation page, the + confirmation message on the Thank You page states the status of the transaction instead of "Your contribution has been submitted...". - **Move assign of currency for entityForm outside of foreach so order of fields @@ -598,9 +551,15 @@ Released April 3, 2019 ([13534](https://github.com/civicrm/civicrm-core/pull/13534))** This change fixes a bug where if a user copied an event and then edited the - copied events email and or phone number, the changes would be applied to the - original event and the copied event, this change makes it so that the changes - only apply to the copy. + email and or phone number on the copy, the changes would be applied to the + original event. + +- **Fix Custom post outer div class on event registration form + ([13753](https://github.com/civicrm/civicrm-core/pull/13753))** + + This change updates the class applied to the outer div around a custom profile + in the post section of the form to use 1 custom_pre-section and 1 + custom_post-section instead of two custom_pre-sections. - **Fix the invocation of post hook for ParticipantPayment ensuring that an id is passed in post hook @@ -627,20 +586,10 @@ Released April 3, 2019 merging contacts which have membership records ([13588](https://github.com/civicrm/civicrm-core/pull/13588))** - On the merge screen, when merging Memberships, this change enables the "add - new" membership checkbox by default if no membership in the main contact - matches the membership of the other contact so that a new membership is - created. Before this change if one selected merge memberships but no matching - membership was found the other contacts Membership was not moved to the main - contact. - -- **[dev/core#644](https://lab.civicrm.org/dev/core/issues/644) "From" address - on membership renewal notices is wrong - ([13776](https://github.com/civicrm/civicrm-core/pull/13776))** - - This change ensures that the "From" address on membership renewal notices is - the display name of the contact selected in the "Receipt From" field not the - contact id. + When merging contacts with memberships, the default is now that the "add new" + box is checked. This brings memberships over from the left-hand contact + without attempting to merge memberships. Merging memberships from the contact + merge interface can result in data loss. ### Drupal Integration @@ -655,8 +604,8 @@ Released April 3, 2019 civicrm/file/imagefile serving up wrong images ([564](https://github.com/civicrm/civicrm-drupal/pull/564)) Extends work** - This change fixes how civicrm/file/imagefiles are served in the Drupal custom - file field handler file. + This change fixes a problem with the Views file field handler displaying + incorrect uploaded images. ### Wordpress Integration @@ -666,10 +615,37 @@ Released April 3, 2019 This change ensures that the path specified to wp-cli as `--path` is passed to CiviCRM which fixes some URL errors specifically but not limited to when - sending bulk mailings with trackable urls. + sending bulk mailings with trackable URLs. ## Miscellany +- **Upgrade Karma version to latest version + ([13751](https://github.com/civicrm/civicrm-core/pull/13751))** + +- **[infra/ops#878](https://lab.civicrm.org/infra/ops/issues/878) Add a test + matrix for E2E tests on each CMS + ([13808](https://github.com/civicrm/civicrm-core/pull/13808))** + + This change improves reliability by increasing test coverage. + +- **Try and add data set example where email_on_hold / on_hold is NULL in the + formValues ([13765](https://github.com/civicrm/civicrm-core/pull/13765))** + + This change adds test coverage for certain smart group criteria. + +- **[dev/core#746](https://lab.civicrm.org/dev/core/issues/746) Search Builder + searches using > 1 smart group where operator is equals is broken from 5.10.0 + ([13685](https://github.com/civicrm/civicrm-core/pull/13685)) Continued work** + + This change adds test coverage for Search Builder searches using > 1 smart + group. + +- **[dev/report#10](https://lab.civicrm.org/dev/report/issues/10) No pagination + on Contribution Detail report + ([13678](https://github.com/civicrm/civicrm-core/pull/13678)) Continued Work** + + This change adds a unit test for pagination on the Contribution Detail report. + - **Optimize CRM_Core_BAO_FinancialTrxn::getTotalPayment ([13187](https://github.com/civicrm/civicrm-core/pull/13187))** @@ -859,12 +835,24 @@ Released April 3, 2019 This release was developed by the following code authors: -AGH Strategies - Alice Frumin, Andrew Hunt; Agileware - Alok Patel; Alexy Mikhailichenko; Australian Greens - Seamus Lee; avall-llovera; CiviCRM - Coleman Watts, Tim Otten; CiviDesk - Yashodha Chaku; Coop SymbioTIC - Mathieu Lutfy; Electronic Frontier Foundation - Mark Burdett; Francesc Bassas i Bullich; Fuzion - Jitendra Purohit; GreenPeace Central and Eastern Europe - Patrick Figel; JMA Consulting - Edsel Lopez, Monish Deb; Ken West; Lighthouse Design and Consulting - Brian Shaughnessy; Megaphone Technology Consulting - Jon Goldberg; MJW Consulting - Matthew Wire; Nicol Wistreich; Pradeep Nayak; Skvare - Mark Hanna; Squiffle Consulting - Aidan Saunders; Wikimedia Foundation - Eileen McNaughton +AGH Strategies - Alice Frumin, Andrew Hunt; Agileware - Alok Patel; Alexy +Mikhailichenko; Australian Greens - Seamus Lee; avall-llovera; CiviCRM - Coleman +Watts, Tim Otten; CiviDesk - Yashodha Chaku; Coop SymbioTIC - Mathieu Lutfy; +Electronic Frontier Foundation - Mark Burdett; Francesc Bassas i Bullich; Fuzion +- Jitendra Purohit; GreenPeace Central and Eastern Europe - Patrick Figel; JMA +Consulting - Edsel Lopez, Monish Deb; Ken West; Lighthouse Design and Consulting +- Brian Shaughnessy; Megaphone Technology Consulting - Jon Goldberg; MJW +Consulting - Matthew Wire; Nicol Wistreich; Pradeep Nayak; Skvare - Mark Hanna; +Squiffle Consulting - Aidan Saunders; Wikimedia Foundation - Eileen McNaughton Most authors also reviewed code for this release; in addition, the following reviewers contributed their comments: -Justin Freeman; Circle Interactive - Dave Jenkins; CiviDesk - Sunil Pawar; Dave D; Fuzion - Peter Davis; JMA Consulting - Joe Murray; Luna Design - Andrew Wasson; MJCO - Mikey O'Toole; mwestergaard; Progressive Technology Project - Jamie McClelland; reecebenson; Richard van Oosterhout; Tadpole Collective - Kevin Cristiano; Third Sector Design - Michael McAndrew +Agileware - Justin Freeman; Circle Interactive - Dave Jenkins, Reece Benson; +CiviDesk - Sunil Pawar; Dave D; Fuzion - Peter Davis; JMA Consulting - Joe +Murray; Luna Design - Andrew Wasson; Mark Westergaard; MJCO - Mikey O'Toole; +Progressive Technology Project - Jamie McClelland; Richard van Oosterhout; +Tadpole Collective - Kevin Cristiano; Third Sector Design - Michael McAndrew ## Feedback From 1fb8540d8b8853801f9033d5a71189f3b3a9d613 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Wed, 3 Apr 2019 14:53:26 -0700 Subject: [PATCH 055/121] Update 5.12.0.md --- release-notes/5.12.0.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/release-notes/5.12.0.md b/release-notes/5.12.0.md index 2b7a90effe54..8133f09ce182 100644 --- a/release-notes/5.12.0.md +++ b/release-notes/5.12.0.md @@ -828,7 +828,7 @@ Released April 3, 2019 - **Fix & test searchQuery order by to be less dependent on what is selected for search ([13680](https://github.com/civicrm/civicrm-core/pull/13680))** -- **EntityRef - standardize on PascalCase for entity name and fix minor bug +- **EntityRef - Standardize on PascalCase for entity name and fix minor bug ([13631](https://github.com/civicrm/civicrm-core/pull/13631))** ## Credits @@ -838,10 +838,10 @@ This release was developed by the following code authors: AGH Strategies - Alice Frumin, Andrew Hunt; Agileware - Alok Patel; Alexy Mikhailichenko; Australian Greens - Seamus Lee; avall-llovera; CiviCRM - Coleman Watts, Tim Otten; CiviDesk - Yashodha Chaku; Coop SymbioTIC - Mathieu Lutfy; -Electronic Frontier Foundation - Mark Burdett; Francesc Bassas i Bullich; Fuzion -- Jitendra Purohit; GreenPeace Central and Eastern Europe - Patrick Figel; JMA -Consulting - Edsel Lopez, Monish Deb; Ken West; Lighthouse Design and Consulting -- Brian Shaughnessy; Megaphone Technology Consulting - Jon Goldberg; MJW +Electronic Frontier Foundation - Mark Burdett; Francesc Bassas i Bullich; Fuzion - +Jitendra Purohit; GreenPeace Central and Eastern Europe - Patrick Figel; JMA +Consulting - Edsel Lopez, Monish Deb; Ken West; Lighthouse Design and Consulting - +Brian Shaughnessy; Megaphone Technology Consulting - Jon Goldberg; MJW Consulting - Matthew Wire; Nicol Wistreich; Pradeep Nayak; Skvare - Mark Hanna; Squiffle Consulting - Aidan Saunders; Wikimedia Foundation - Eileen McNaughton From 5997245238f42e83c3cfb5757333d5d663b3b22b Mon Sep 17 00:00:00 2001 From: eileen Date: Thu, 4 Apr 2019 11:11:25 +1300 Subject: [PATCH 056/121] Add error handling for when no test procesor row exists. This is not really a valid config but for sites that have processors without test rows recent changes will make that problematic. We can be nice --- CRM/Admin/Page/PaymentProcessor.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CRM/Admin/Page/PaymentProcessor.php b/CRM/Admin/Page/PaymentProcessor.php index e3b64b6339b7..b79a3d4eedce 100644 --- a/CRM/Admin/Page/PaymentProcessor.php +++ b/CRM/Admin/Page/PaymentProcessor.php @@ -158,7 +158,13 @@ public function browse($action = NULL) { $dao->id ); $paymentProcessor[$dao->id]['financialAccount'] = CRM_Contribute_PseudoConstant::getRelationalFinancialAccount($dao->id, NULL, 'civicrm_payment_processor', 'financial_account_id.name'); - $paymentProcessor[$dao->id]['test_id'] = CRM_Financial_BAO_PaymentProcessor::getTestProcessorId($dao->id); + + try { + $paymentProcessor[$dao->id]['test_id'] = CRM_Financial_BAO_PaymentProcessor::getTestProcessorId($dao->id); + } + catch (CiviCRM_API3_Exception $e) { + CRM_Core_Session::setStatus(ts('No test processor entry exists for %1. Not having a test entry for each processor could cause problems', [$dao->name])); + } } $this->assign('rows', $paymentProcessor); From 20437afe0ec265f6aad8bcfc5f82de2075358dd6 Mon Sep 17 00:00:00 2001 From: eileen Date: Thu, 4 Apr 2019 11:20:51 +1300 Subject: [PATCH 057/121] Test fix --- tests/phpunit/api/v3/LoggingTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/phpunit/api/v3/LoggingTest.php b/tests/phpunit/api/v3/LoggingTest.php index 8fad24a084b9..23ff335dab78 100644 --- a/tests/phpunit/api/v3/LoggingTest.php +++ b/tests/phpunit/api/v3/LoggingTest.php @@ -414,6 +414,8 @@ public function testGet() { $contactId = $this->individualCreate(); $this->callAPISuccess('Setting', 'create', array('logging' => TRUE)); CRM_Core_DAO::executeQuery("SET @uniqueID = 'wooty woot'"); + // Add delay so the update is actually enough after the create that the timestamps differ + sleep(1); $timeStamp = date('Y-m-d H:i:s'); $this->callAPISuccess('Contact', 'create', array( 'id' => $contactId, From 6bc775cf0493f74b018580d4ddef48bd1a395cca Mon Sep 17 00:00:00 2001 From: Monish Deb Date: Fri, 8 Mar 2019 18:18:33 +0530 Subject: [PATCH 058/121] dev/financial#38 : Support refund payment using payment processor --- CRM/Core/Payment.php | 20 +++++++++++++++++++ CRM/Core/Payment/Dummy.php | 19 +++++++++++++++++++ api/v3/PaymentProcessor.php | 38 +++++++++++++++++++++++++++++++++++++ 3 files changed, 77 insertions(+) diff --git a/CRM/Core/Payment.php b/CRM/Core/Payment.php index fb465033e8a5..1aaa4aa5f5c3 100644 --- a/CRM/Core/Payment.php +++ b/CRM/Core/Payment.php @@ -336,6 +336,15 @@ protected function supportsTestMode() { return TRUE; } + /** + * Does this payment processor support refund? + * + * @return bool + */ + public function supportsRefund() { + return FALSE; + } + /** * Should the first payment date be configurable when setting up back office recurring payments. * @@ -1258,6 +1267,17 @@ public function doPayment(&$params, $component = 'contribute') { return $result; } + /** + * Refunds payment + * + * Payment processors should set payment_status_id if it set the status to Refunded in case the transaction is successful + * + * @param array $params + * + * @throws \Civi\Payment\Exception\PaymentProcessorException + */ + public function doRefund(&$params) {} + /** * Query payment processor for details about a transaction. * diff --git a/CRM/Core/Payment/Dummy.php b/CRM/Core/Payment/Dummy.php index 08b548643397..92f932c273cc 100644 --- a/CRM/Core/Payment/Dummy.php +++ b/CRM/Core/Payment/Dummy.php @@ -137,6 +137,25 @@ protected function supportsLiveMode() { return TRUE; } + /** + * Does this payment processor support refund? + * + * @return bool + */ + public function supportsRefund() { + return TRUE; + } + + /** + * Submit a refund payment + * + * @throws \Civi\Payment\Exception\PaymentProcessorException + * + * @param array $params + * Assoc array of input parameters for this transaction. + */ + public function doRefund(&$params) {} + /** * Generate error object. * diff --git a/api/v3/PaymentProcessor.php b/api/v3/PaymentProcessor.php index 5faa1318f478..d2c5b0ec2959 100644 --- a/api/v3/PaymentProcessor.php +++ b/api/v3/PaymentProcessor.php @@ -115,3 +115,41 @@ function _civicrm_api3_payment_processor_getlist_defaults(&$request) { ], ]; } + +/** + * Action refund. + * + * @param array $params + * + * @return array + * API result array. + * @throws CiviCRM_API3_Exception + */ +function civicrm_api3_payment_processor_refund($params) { + $processor = Civi\Payment\System::singleton()->getById($params['payment_processor_id']); + $processor->setPaymentProcessor(civicrm_api3('PaymentProcessor', 'getsingle', array('id' => $params['payment_processor_id']))); + if (!$processor->supportsRefund()) { + throw API_Exception('Payment Processor does not support refund'); + } + $result = $processor->doRefund($params); + return civicrm_api3_create_success(array($result), $params); +} + +/** + * Action Refund. + * + * @param array $params + * + */ +function _civicrm_api3_payment_processor_refund_spec(&$params) { + $params['payment_processor_id'] = [ + 'api.required' => 1, + 'title' => ts('Payment processor'), + 'type' => CRM_Utils_Type::T_INT, + ]; + $params['amount'] = [ + 'api.required' => TRUE, + 'title' => ts('Amount to refund'), + 'type' => CRM_Utils_Type::T_MONEY, + ]; +} From 63b162c6abeffe5ff3981d6351fc00cf59bef080 Mon Sep 17 00:00:00 2001 From: eileen Date: Thu, 4 Apr 2019 14:39:17 +1300 Subject: [PATCH 059/121] dev/financial#2 add PaymentProcessor.title field There was a long discussion a while back about adding a label or title field to the civicrm_payment_processor table. It kinda died but since 5.13 adds another field (contribution_recur.cancel_reason) which is kinda rare I thought we should probably add this field in the same release as we can better keep most releases to no schema changes that way. At this stage the field is not in use - but I figure getting it added will make the next steps of exposing it easier & there is general agreement we need something of this nature. (the cancel reason field will also take further commits to expose in the UI) --- CRM/Financial/DAO/PaymentProcessor.php | 24 +++++++++++++++++++- CRM/Upgrade/Incremental/php/FiveThirteen.php | 3 +++ xml/schema/Financial/PaymentProcessor.xml | 11 +++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/CRM/Financial/DAO/PaymentProcessor.php b/CRM/Financial/DAO/PaymentProcessor.php index 0cca1db687b3..311fe33b96d6 100644 --- a/CRM/Financial/DAO/PaymentProcessor.php +++ b/CRM/Financial/DAO/PaymentProcessor.php @@ -6,7 +6,7 @@ * * Generated from xml/schema/CRM/Financial/PaymentProcessor.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:10649ac7d8d06b411aa6e800484f459b) + * (GenCodeChecksum:42c6dc8a71daeb67aaa687156121ebf4) */ /** @@ -49,6 +49,13 @@ class CRM_Financial_DAO_PaymentProcessor extends CRM_Core_DAO { */ public $name; + /** + * Payment Processor Descriptive Name. + * + * @var string + */ + public $title; + /** * Payment Processor Description. * @@ -237,6 +244,21 @@ public static function &fields() { 'type' => 'Text', ], ], + 'title' => [ + 'name' => 'title', + 'type' => CRM_Utils_Type::T_STRING, + 'title' => ts('Payment Processor Title'), + 'description' => ts('Payment Processor Descriptive Name.'), + 'maxlength' => 127, + 'size' => CRM_Utils_Type::HUGE, + 'table_name' => 'civicrm_payment_processor', + 'entity' => 'PaymentProcessor', + 'bao' => 'CRM_Financial_BAO_PaymentProcessor', + 'localizable' => 0, + 'html' => [ + 'type' => 'Text', + ], + ], 'description' => [ 'name' => 'description', 'type' => CRM_Utils_Type::T_STRING, diff --git a/CRM/Upgrade/Incremental/php/FiveThirteen.php b/CRM/Upgrade/Incremental/php/FiveThirteen.php index d3c74f06a5f7..5bfafc9e970c 100644 --- a/CRM/Upgrade/Incremental/php/FiveThirteen.php +++ b/CRM/Upgrade/Incremental/php/FiveThirteen.php @@ -77,6 +77,9 @@ public function upgrade_5_13_alpha1($rev) { $this->addTask('Add cancel reason column to civicrm_contribution_recur', 'addColumn', 'civicrm_contribution_recur', 'cancel_reason', "text COMMENT 'Free text field for a reason for cancelling'", FALSE ); + $this->addTask('Add title to civicrm_payment_processor', 'addColumn', + 'civicrm_payment_processor', 'title', "text COMMENT 'Payment Processor Descriptive Name.'", FALSE + ); } } diff --git a/xml/schema/Financial/PaymentProcessor.xml b/xml/schema/Financial/PaymentProcessor.xml index 0538fcc6983d..ceeba6b0ad71 100644 --- a/xml/schema/Financial/PaymentProcessor.xml +++ b/xml/schema/Financial/PaymentProcessor.xml @@ -47,6 +47,17 @@ Text + + title + Payment Processor Title + varchar + 127 + + Text + + Payment Processor Descriptive Name. + 5.13 + description Processor Description From 71b4fdf9e2ce11b74a722f29040db01b4d110072 Mon Sep 17 00:00:00 2001 From: eileen Date: Thu, 4 Apr 2019 14:06:29 +1300 Subject: [PATCH 060/121] Add basic Pay api --- api/v3/PaymentProcessor.php | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/api/v3/PaymentProcessor.php b/api/v3/PaymentProcessor.php index d2c5b0ec2959..658b51aae3fc 100644 --- a/api/v3/PaymentProcessor.php +++ b/api/v3/PaymentProcessor.php @@ -116,6 +116,40 @@ function _civicrm_api3_payment_processor_getlist_defaults(&$request) { ]; } +/** + * Action payment. + * + * @param array $params + * + * @return array + * API result array. + * @throws CiviCRM_API3_Exception + */ +function civicrm_api3_payment_processor_pay($params) { + $processor = Civi\Payment\System::singleton()->getById($params['payment_processor_id']); + $processor->setPaymentProcessor(civicrm_api3('PaymentProcessor', 'getsingle', ['id' => $params['payment_processor_id']])); + $result = $processor->doPayment($params); + return civicrm_api3_create_success(array($result), $params); +} + +/** + * Action payment. + * + * @param array $params + */ +function _civicrm_api3_payment_processor_pay_spec(&$params) { + $params['payment_processor_id'] = [ + 'api.required' => 1, + 'title' => ts('Payment processor'), + 'type' => CRM_Utils_Type::T_INT, + ]; + $params['amount'] = [ + 'api.required' => TRUE, + 'title' => ts('Amount to refund'), + 'type' => CRM_Utils_Type::T_MONEY, + ]; +} + /** * Action refund. * From 4094935aeace33eb8caf8fdcd7a76d992bdc6682 Mon Sep 17 00:00:00 2001 From: Alok Patel Date: Thu, 4 Apr 2019 08:32:09 +0530 Subject: [PATCH 061/121] CIVICRM-1163: Replaced get_headers functions call with Guzzle HTTP request. --- CRM/Utils/Check/Component.php | 24 +++++++++++++ CRM/Utils/Check/Component/Env.php | 34 +++++++++---------- CRM/Utils/Check/Component/Security.php | 12 +++---- .../CRM/Utils/Check/Component/EnvTest.php | 29 ++++++++++++++++ 4 files changed, 74 insertions(+), 25 deletions(-) create mode 100644 tests/phpunit/CRM/Utils/Check/Component/EnvTest.php diff --git a/CRM/Utils/Check/Component.php b/CRM/Utils/Check/Component.php index 74c9a836ee1f..f1a8b35a6274 100644 --- a/CRM/Utils/Check/Component.php +++ b/CRM/Utils/Check/Component.php @@ -25,6 +25,8 @@ +--------------------------------------------------------------------+ */ +use GuzzleHttp\Client; + /** * * @package CRM @@ -57,4 +59,26 @@ public function checkAll() { return $messages; } + /** + * Check if file exists on given URL. + * + * @param $url + * @return bool + * @throws \GuzzleHttp\Exception\GuzzleException + */ + public function fileExists($url, $timeout = 0.25) { + $fileExists = FALSE; + try { + $guzzleClient = new GuzzleHttp\Client(); + $guzzleResponse = $guzzleClient->request('GET', $url, array( + 'timeout' => $timeout, + )); + $fileExists = ($guzzleResponse->getStatusCode() == 200); + } + catch (Exception $e) { + echo $e->getMessage(); + } + return $fileExists; + } + } diff --git a/CRM/Utils/Check/Component/Env.php b/CRM/Utils/Check/Component/Env.php index 6ebef2febf97..8d75242fb55e 100644 --- a/CRM/Utils/Check/Component/Env.php +++ b/CRM/Utils/Check/Component/Env.php @@ -47,9 +47,9 @@ public function checkPhpVersion() { 1 => $phpVersion, 2 => CRM_Upgrade_Incremental_General::RECOMMENDED_PHP_VER, )), - ts('PHP Up-to-Date'), - \Psr\Log\LogLevel::INFO, - 'fa-server' + ts('PHP Up-to-Date'), + \Psr\Log\LogLevel::INFO, + 'fa-server' ); } elseif (version_compare($phpVersion, CRM_Upgrade_Incremental_General::MIN_RECOMMENDED_PHP_VER) >= 0) { @@ -60,9 +60,9 @@ public function checkPhpVersion() { 1 => $phpVersion, 2 => CRM_Upgrade_Incremental_General::RECOMMENDED_PHP_VER, )), - ts('PHP Out-of-Date'), - \Psr\Log\LogLevel::NOTICE, - 'fa-server' + ts('PHP Out-of-Date'), + \Psr\Log\LogLevel::NOTICE, + 'fa-server' ); } elseif (version_compare($phpVersion, CRM_Upgrade_Incremental_General::MIN_INSTALL_PHP_VER) >= 0) { @@ -74,9 +74,9 @@ public function checkPhpVersion() { 2 => CRM_Upgrade_Incremental_General::MIN_RECOMMENDED_PHP_VER, 3 => CRM_Upgrade_Incremental_General::RECOMMENDED_PHP_VER, )), - ts('PHP Out-of-Date'), - \Psr\Log\LogLevel::WARNING, - 'fa-server' + ts('PHP Out-of-Date'), + \Psr\Log\LogLevel::WARNING, + 'fa-server' ); } else { @@ -88,9 +88,9 @@ public function checkPhpVersion() { 2 => CRM_Upgrade_Incremental_General::MIN_RECOMMENDED_PHP_VER, 3 => CRM_Upgrade_Incremental_General::RECOMMENDED_PHP_VER, )), - ts('PHP Out-of-Date'), - \Psr\Log\LogLevel::ERROR, - 'fa-server' + ts('PHP Out-of-Date'), + \Psr\Log\LogLevel::ERROR, + 'fa-server' ); } @@ -111,9 +111,9 @@ public function checkPhpMysqli() { 1 => 'https://civicrm.org/blog/totten/psa-please-verify-php-extension-mysqli', 2 => 'mysqli', )), - ts('Forward Compatibility: Enable "mysqli"'), - \Psr\Log\LogLevel::WARNING, - 'fa-server' + ts('Forward Compatibility: Enable "mysqli"'), + \Psr\Log\LogLevel::WARNING, + 'fa-server' ); } @@ -883,9 +883,7 @@ public function checkResourceUrl() { // Does arrow.png exist where we expect it? $arrowUrl = CRM_Core_Config::singleton()->userFrameworkResourceURL . 'packages/jquery/css/images/arrow.png'; - $headers = get_headers($arrowUrl); - $fileExists = stripos($headers[0], "200 OK") ? 1 : 0; - if ($fileExists === FALSE) { + if ($this->fileExists($arrowUrl) === FALSE) { $messages[] = new CRM_Utils_Check_Message( __FUNCTION__, ts('The Resource URL is not set correctly. Please set the CiviCRM Resource URL.', diff --git a/CRM/Utils/Check/Component/Security.php b/CRM/Utils/Check/Component/Security.php index 262b36ac166f..caf32ddbae44 100644 --- a/CRM/Utils/Check/Component/Security.php +++ b/CRM/Utils/Check/Component/Security.php @@ -86,8 +86,7 @@ public function checkLogFileIsNotAccessible() { if (count($log_path) > 1) { $url[] = $log_path[1]; $log_url = implode($filePathMarker, $url); - $headers = @get_headers($log_url); - if (stripos($headers[0], '200')) { + if ($this->fileExists($log_url)) { $docs_url = $this->createDocUrl('checkLogFileIsNotAccessible'); $msg = 'The CiviCRM debug log should not be downloadable.' . '
' . @@ -145,9 +144,9 @@ public function checkUploadsAreNotAccessible() { 2 => $privateDir, 3 => $heuristicUrl, )), - ts('Private Files Readable'), - \Psr\Log\LogLevel::WARNING, - 'fa-lock' + ts('Private Files Readable'), + \Psr\Log\LogLevel::WARNING, + 'fa-lock' ); } } @@ -365,8 +364,7 @@ public function isDirAccessible($dir, $url) { return FALSE; } - $headers = @get_headers("$url/$file"); - if (stripos($headers[0], '200')) { + if ($this->fileExists("$url/$file")) { $content = @file_get_contents("$url/$file"); if (preg_match('/delete me/', $content)) { $result = TRUE; diff --git a/tests/phpunit/CRM/Utils/Check/Component/EnvTest.php b/tests/phpunit/CRM/Utils/Check/Component/EnvTest.php new file mode 100644 index 000000000000..cb9a3201c3aa --- /dev/null +++ b/tests/phpunit/CRM/Utils/Check/Component/EnvTest.php @@ -0,0 +1,29 @@ +fileExists('https://civicrm.org', 0.001); + $successRequest = $check->fileExists('https://civicrm.org', 0); + + $this->assertEquals(FALSE, $failRequest, 'Request should fail for minimum timeout.'); + $this->assertEquals(TRUE, $successRequest, 'Request should not fail for infinite timeout.'); + + } + +} From 9eb6085dfe35821a3caeab02738d65edca183a87 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Thu, 4 Apr 2019 11:07:29 +1100 Subject: [PATCH 062/121] Convert recieve_date and renewal_date on membership forms to use datepicker rather than jcalendar --- CRM/Member/Form/Membership.php | 27 +++-------------- CRM/Member/Form/MembershipRenewal.php | 30 +++++-------------- .../CRM/Member/Form/MembershipCommon.tpl | 2 +- .../CRM/Member/Form/MembershipRenewal.tpl | 2 +- 4 files changed, 14 insertions(+), 47 deletions(-) diff --git a/CRM/Member/Form/Membership.php b/CRM/Member/Form/Membership.php index b246aedb8534..0f6555a26a3b 100644 --- a/CRM/Member/Form/Membership.php +++ b/CRM/Member/Form/Membership.php @@ -101,16 +101,6 @@ class CRM_Member_Form_Membership extends CRM_Member_Form { */ protected $_membershipIDs = array(); - /** - * An array to hold a list of date fields on the form - * so that they can be converted to ISO in a consistent manner - * - * @var array - */ - protected $_dateFields = array( - 'receive_date' => array('default' => 'now'), - ); - /** * Set entity fields to be assigned to the form. */ @@ -323,10 +313,8 @@ public function setDefaultValues() { $defaults = parent::setDefaultValues(); //setting default join date and receive date - list($now, $currentTime) = CRM_Utils_Date::setDateDefaults(); if ($this->_action == CRM_Core_Action::ADD) { - $defaults['receive_date'] = $now; - $defaults['receive_date_time'] = $currentTime; + $defaults['receive_date'] = date('Y-m-d H:i:s'); } $defaults['num_terms'] = 1; @@ -365,10 +353,6 @@ public function setDefaultValues() { //get back original object campaign id. $defaults['campaign_id'] = $memberCampaignId; - if (!empty($defaults['receive_date'])) { - list($defaults['receive_date']) = CRM_Utils_Date::setDateDefaults($defaults['receive_date']); - } - // Contribution::getValues() over-writes the membership record's source field value - so we need to restore it. if (!empty($defaults['membership_source'])) { $defaults['source'] = $defaults['membership_source']; @@ -633,7 +617,7 @@ public function buildQuickForm() { $this->add('text', 'total_amount', ts('Amount')); $this->addRule('total_amount', ts('Please enter a valid amount.'), 'money'); - $this->addDate('receive_date', ts('Received'), FALSE, array('formatType' => 'activityDateTime')); + $this->add('datepicker', 'receive_date', ts('Received'), [], FALSE, ['time' => TRUE]); $this->add('select', 'payment_instrument_id', ts('Payment Method'), @@ -1043,7 +1027,7 @@ public static function emailReceipt(&$form, &$formValues, &$membership, $customV else { $form->assign('receiptType', 'membership signup'); } - $form->assign('receive_date', CRM_Utils_Date::processDate(CRM_Utils_Array::value('receive_date', $formValues))); + $form->assign('receive_date', CRM_Utils_Array::value('receive_date', $formValues)); $form->assign('formValues', $formValues); if (empty($lineItem)) { @@ -1139,9 +1123,6 @@ public function submit() { $config = CRM_Core_Config::singleton(); - // @todo this is no longer required if we convert some date fields. - $this->convertDateFieldsToMySQL($formValues); - $membershipTypeValues = array(); foreach ($this->_memTypeSelected as $memType) { $membershipTypeValues[$memType]['membership_type_id'] = $memType; @@ -1486,7 +1467,7 @@ public function submit() { } } $now = date('YmdHis'); - $params['receive_date'] = date('YmdHis'); + $params['receive_date'] = $now; $params['invoice_id'] = $formValues['invoiceID']; $params['contribution_source'] = ts('%1 Membership Signup: Credit card or direct debit (by %2)', array(1 => $membershipType, 2 => $userName) diff --git a/CRM/Member/Form/MembershipRenewal.php b/CRM/Member/Form/MembershipRenewal.php index 7d711b134dd7..d90ea044e77b 100644 --- a/CRM/Member/Form/MembershipRenewal.php +++ b/CRM/Member/Form/MembershipRenewal.php @@ -109,16 +109,6 @@ class CRM_Member_Form_MembershipRenewal extends CRM_Member_Form { */ protected $membershipTypeName = ''; - /** - * An array to hold a list of datefields on the form - * so that they can be converted to ISO in a consistent manner - * - * @var array - */ - protected $_dateFields = array( - 'receive_date' => array('default' => 'now'), - ); - /** * Set entity fields to be assigned to the form. */ @@ -190,10 +180,9 @@ public function setDefaultValues() { $defaults = parent::setDefaultValues(); // set renewal_date and receive_date to today in correct input format (setDateDefaults uses today if no value passed) - list($now, $currentTime) = CRM_Utils_Date::setDateDefaults(); + $now = date('Y-m-d'); $defaults['renewal_date'] = $now; - $defaults['receive_date'] = $now; - $defaults['receive_date_time'] = $currentTime; + $defaults['receive_date'] = $now . ' ' . date('H:i:s'); if ($defaults['id']) { $defaults['record_contribution'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipPayment', @@ -223,9 +212,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_Date::processDate(CRM_Utils_Array::value('renewal_date', $defaults), - NULL, NULL, 'Y-m-d' - ); + $renewalDate = CRM_Utils_Array::value('renewal_date', $defaults); $this->assign('renewalDate', $renewalDate); $this->assign('member_is_test', CRM_Utils_Array::value('member_is_test', $defaults)); @@ -339,7 +326,7 @@ public function buildQuickForm() { $this->applyFilter('__ALL__', 'trim'); - $this->addDate('renewal_date', ts('Date Renewal Entered'), FALSE, array('formatType' => 'activityDate')); + $this->add('datepicker', 'renewal_date', ts('Date Renewal Entered'), [], FALSE, ['time' => FALSE]); $this->add('select', 'financial_type_id', ts('Financial Type'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::financialType() @@ -354,7 +341,7 @@ public function buildQuickForm() { $this->add('text', 'total_amount', ts('Amount')); $this->addRule('total_amount', ts('Please enter a valid amount.'), 'money'); - $this->addDate('receive_date', ts('Received'), FALSE, array('formatType' => 'activityDateTime')); + $this->add('datepicker', 'receive_date', ts('Received'), [], FALSE, ['time' => TRUE]); $this->add('select', 'payment_instrument_id', ts('Payment Method'), array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(), @@ -436,7 +423,7 @@ public static function formRule($params, $files, $self) { // The fields in Renewal form come into this routine in $params array. 'renewal_date' is in the form // We process both the dates before comparison using CRM utils so that they are in same date format if (isset($params['renewal_date'])) { - if (CRM_Utils_Date::processDate($params['renewal_date']) < CRM_Utils_Date::processDate($joinDate)) { + if ($params['renewal_date'] < $joinDate) { $errors['renewal_date'] = ts('Renewal date must be the same or later than Member since (Join Date).'); } } @@ -502,8 +489,7 @@ protected function submit() { $this->storeContactFields($this->_params); $this->beginPostProcess(); $now = CRM_Utils_Date::getToday(NULL, 'YmdHis'); - $this->convertDateFieldsToMySQL($this->_params); - $this->assign('receive_date', $this->_params['receive_date']); + $this->assign('receive_date', CRM_Utils_Array::value('receive_date', $this->_params, date('Y-m-d H:i:s'))); $this->processBillingAddress(); list($userName) = CRM_Contact_BAO_Contact_Location::getEmailDetails(CRM_Core_Session::singleton()->get('userID')); $this->_params['total_amount'] = CRM_Utils_Array::value('total_amount', $this->_params, @@ -570,7 +556,7 @@ protected function submit() { $this->assign('trxn_id', $result['trxn_id']); } - $renewalDate = !empty($this->_params['renewal_date']) ? $renewalDate = CRM_Utils_Date::processDate($this->_params['renewal_date']) : NULL; + $renewalDate = !empty($this->_params['renewal_date']) ? $renewalDate = $this->_params['renewal_date'] : NULL; // check for test membership. $isTestMembership = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $this->_membershipId, 'is_test'); diff --git a/templates/CRM/Member/Form/MembershipCommon.tpl b/templates/CRM/Member/Form/MembershipCommon.tpl index bb4bd0702144..d47aa3f5905c 100644 --- a/templates/CRM/Member/Form/MembershipCommon.tpl +++ b/templates/CRM/Member/Form/MembershipCommon.tpl @@ -28,7 +28,7 @@ {$form.receive_date.label} - {include file="CRM/common/jcalendar.tpl" elementName=receive_date} + {$form.receive_date.html} {$form.financial_type_id.label} diff --git a/templates/CRM/Member/Form/MembershipRenewal.tpl b/templates/CRM/Member/Form/MembershipRenewal.tpl index 81013ec4445c..02f7b0d2e6b3 100644 --- a/templates/CRM/Member/Form/MembershipRenewal.tpl +++ b/templates/CRM/Member/Form/MembershipRenewal.tpl @@ -84,7 +84,7 @@ {$form.renewal_date.label} - {include file="CRM/common/jcalendar.tpl" elementName=renewal_date} + {$form.renewal_date.html} From 553842bec06fa11821ea085bbc61643e91053d4a Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Thu, 4 Apr 2019 17:16:58 +1100 Subject: [PATCH 063/121] Fix tests and ensure that receive_date is always set --- CRM/Member/Form/Membership.php | 6 +++++- tests/phpunit/CRM/Member/Form/MembershipTest.php | 15 +++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/CRM/Member/Form/Membership.php b/CRM/Member/Form/Membership.php index 0f6555a26a3b..c7df8f5bf1ff 100644 --- a/CRM/Member/Form/Membership.php +++ b/CRM/Member/Form/Membership.php @@ -1467,7 +1467,7 @@ public function submit() { } } $now = date('YmdHis'); - $params['receive_date'] = $now; + $params['receive_date'] = date('Y-m-d H:i:s'); $params['invoice_id'] = $formValues['invoiceID']; $params['contribution_source'] = ts('%1 Membership Signup: Credit card or direct debit (by %2)', array(1 => $membershipType, 2 => $userName) @@ -1599,6 +1599,10 @@ public function submit() { $membershipTypeValues[$memType]['relate_contribution_id'] = $relateContribution; } + // @todo figure out why recieve_date isn't being set right here. + if (empty($params['receive_date'])) { + $params['receive_date'] = date('Y-m-d H:i:s'); + } $membershipParams = array_merge($params, $membershipTypeValues[$memType]); if (!empty($formValues['int_amount'])) { $init_amount = array(); diff --git a/tests/phpunit/CRM/Member/Form/MembershipTest.php b/tests/phpunit/CRM/Member/Form/MembershipTest.php index 4348bc26adc9..f540759a3e90 100644 --- a/tests/phpunit/CRM/Member/Form/MembershipTest.php +++ b/tests/phpunit/CRM/Member/Form/MembershipTest.php @@ -571,8 +571,7 @@ public function testContributionUpdateOnMembershipTypeChange() { 'membership_type_id' => array(23, $this->membershipTypeAnnualFixedID), 'record_contribution' => 1, 'total_amount' => 50, - 'receive_date' => date('m/d/Y', time()), - 'receive_date_time' => '08:36PM', + 'receive_date' => date('Y-m-d', time()) . ' 20:36:00', 'payment_instrument_id' => array_search('Check', $this->paymentInstruments), 'contribution_status_id' => CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed'), 'financial_type_id' => '2', //Member dues, see data.xml @@ -621,8 +620,7 @@ public function testContributionUpdateOnMembershipTypeChange() { 'record_contribution' => 1, 'status_id' => 1, 'total_amount' => 25, - 'receive_date' => date('m/d/Y', time()), - 'receive_date_time' => '08:36PM', + 'receive_date' => date('Y-m-d', time()) . ' 20:36:00', 'payment_instrument_id' => array_search('Check', $this->paymentInstruments), 'financial_type_id' => '2', //Member dues, see data.xml 'payment_processor_id' => $this->_paymentProcessorID, @@ -669,10 +667,9 @@ public function testSubmitPartialPayment($thousandSeparator) { 'end_date' => '', // This format reflects the 23 being the organisation & the 25 being the type. 'membership_type_id' => array(23, $this->membershipTypeAnnualFixedID), + 'receive_date' => date('Y-m-d', time()) . ' 20:36:00', 'record_contribution' => 1, 'total_amount' => $this->formatMoneyInput($partiallyPaidAmount), - 'receive_date' => date('m/d/Y', time()), - 'receive_date_time' => '08:36PM', 'payment_instrument_id' => array_search('Check', $this->paymentInstruments), 'contribution_status_id' => CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Partially paid'), 'financial_type_id' => '2', //Member dues, see data.xml @@ -699,8 +696,7 @@ public function testSubmitPartialPayment($thousandSeparator) { 'total_amount' => $this->formatMoneyInput($partiallyPaidAmount), 'currency' => 'USD', 'financial_type_id' => 2, - 'receive_date' => '04/21/2015', - 'receive_date_time' => '11:27PM', + 'receive_date' => '2015-04-21 23:27:00', 'trxn_date' => '2017-04-11 13:05:11', 'payment_processor_id' => 0, 'payment_instrument_id' => array_search('Check', $this->paymentInstruments), @@ -1325,8 +1321,7 @@ public function testLineItemAmountOnSalesTax() { 'membership_type_id' => array(23, $this->membershipTypeAnnualFixedID), 'record_contribution' => 1, 'total_amount' => 55, - 'receive_date' => date('m/d/Y', time()), - 'receive_date_time' => '08:36PM', + 'receive_date' => date('Y-m-d', time()) . ' 20:36:00', 'payment_instrument_id' => array_search('Check', $this->paymentInstruments), 'contribution_status_id' => CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed'), 'financial_type_id' => 2, //Member dues, see data.xml From 5b987d844d69464aaab58bab93cf76468fa3d673 Mon Sep 17 00:00:00 2001 From: Alok Patel Date: Thu, 4 Apr 2019 13:58:09 +0530 Subject: [PATCH 064/121] Updated the timeout to 500ms. --- CRM/Utils/Check/Component.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CRM/Utils/Check/Component.php b/CRM/Utils/Check/Component.php index f1a8b35a6274..4133d7efc362 100644 --- a/CRM/Utils/Check/Component.php +++ b/CRM/Utils/Check/Component.php @@ -66,7 +66,7 @@ public function checkAll() { * @return bool * @throws \GuzzleHttp\Exception\GuzzleException */ - public function fileExists($url, $timeout = 0.25) { + public function fileExists($url, $timeout = 0.50) { $fileExists = FALSE; try { $guzzleClient = new GuzzleHttp\Client(); From a050fa6b37b83de4eccdfe1d98f910cc6a660f4d Mon Sep 17 00:00:00 2001 From: "Matthew Wire (MJW Consulting)" Date: Thu, 4 Apr 2019 11:05:21 +0100 Subject: [PATCH 065/121] Extract assignPaymentFields --- CRM/Contribute/Form/ContributionBase.php | 103 ++++++++++++----------- 1 file changed, 53 insertions(+), 50 deletions(-) diff --git a/CRM/Contribute/Form/ContributionBase.php b/CRM/Contribute/Form/ContributionBase.php index c8e488f34b92..3e40cafd8faa 100644 --- a/CRM/Contribute/Form/ContributionBase.php +++ b/CRM/Contribute/Form/ContributionBase.php @@ -580,56 +580,7 @@ public function assignToTemplate() { $locTypeId = array_keys($this->_params['onbehalf_location']['email']); $this->assign('onBehalfEmail', $this->_params['onbehalf_location']['email'][$locTypeId[0]]['email']); } - - //fix for CRM-3767 - $isMonetary = FALSE; - if ($this->_amount > 0.0) { - $isMonetary = TRUE; - } - elseif (!empty($this->_params['selectMembership'])) { - $memFee = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $this->_params['selectMembership'], 'minimum_fee'); - if ($memFee > 0.0) { - $isMonetary = TRUE; - } - } - - // The concept of contributeMode is deprecated. - // The payment processor object can provide info about the fields it shows. - if ($isMonetary && is_a($this->_paymentProcessor['object'], 'CRM_Core_Payment')) { - /** @var $paymentProcessorObject \CRM_Core_Payment */ - $paymentProcessorObject = $this->_paymentProcessor['object']; - - $paymentFields = $paymentProcessorObject->getPaymentFormFields(); - foreach ($paymentFields as $index => $paymentField) { - if (!isset($this->_params[$paymentField])) { - unset($paymentFields[$index]); - continue; - } - if ($paymentField === 'credit_card_exp_date') { - $date = CRM_Utils_Date::format(CRM_Utils_Array::value('credit_card_exp_date', $this->_params)); - $date = CRM_Utils_Date::mysqlToIso($date); - $this->assign('credit_card_exp_date', $date); - } - elseif ($paymentField === 'credit_card_number') { - $this->assign('credit_card_number', - CRM_Utils_System::mungeCreditCard(CRM_Utils_Array::value('credit_card_number', $this->_params)) - ); - } - elseif ($paymentField === 'credit_card_type') { - $this->assign('credit_card_type', CRM_Core_PseudoConstant::getLabel( - 'CRM_Core_BAO_FinancialTrxn', - 'card_type_id', - CRM_Core_PseudoConstant::getKey('CRM_Core_BAO_FinancialTrxn', 'card_type_id', $this->_params['credit_card_type']) - )); - } - else { - $this->assign($paymentField, $this->_params[$paymentField]); - } - } - $this->assign('paymentFieldsetLabel', CRM_Core_Payment_Form::getPaymentLabel($paymentProcessorObject)); - $this->assign('paymentFields', $paymentFields); - - } + $this->assignPaymentFields(); $this->assign('email', $this->controller->exportValue('Main', "email-{$this->_bltID}") @@ -806,6 +757,58 @@ protected function enableCaptchaOnForm() { } } + public function assignPaymentFields() { + //fix for CRM-3767 + $isMonetary = FALSE; + if ($this->_amount > 0.0) { + $isMonetary = TRUE; + } + elseif (!empty($this->_params['selectMembership'])) { + $memFee = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $this->_params['selectMembership'], 'minimum_fee'); + if ($memFee > 0.0) { + $isMonetary = TRUE; + } + } + + // The concept of contributeMode is deprecated. + // The payment processor object can provide info about the fields it shows. + if ($isMonetary && is_a($this->_paymentProcessor['object'], 'CRM_Core_Payment')) { + /** @var $paymentProcessorObject \CRM_Core_Payment */ + $paymentProcessorObject = $this->_paymentProcessor['object']; + + $paymentFields = $paymentProcessorObject->getPaymentFormFields(); + foreach ($paymentFields as $index => $paymentField) { + if (!isset($this->_params[$paymentField])) { + unset($paymentFields[$index]); + continue; + } + if ($paymentField === 'credit_card_exp_date') { + $date = CRM_Utils_Date::format(CRM_Utils_Array::value('credit_card_exp_date', $this->_params)); + $date = CRM_Utils_Date::mysqlToIso($date); + $this->assign('credit_card_exp_date', $date); + } + elseif ($paymentField === 'credit_card_number') { + $this->assign('credit_card_number', + CRM_Utils_System::mungeCreditCard(CRM_Utils_Array::value('credit_card_number', $this->_params)) + ); + } + elseif ($paymentField === 'credit_card_type') { + $this->assign('credit_card_type', CRM_Core_PseudoConstant::getLabel( + 'CRM_Core_BAO_FinancialTrxn', + 'card_type_id', + CRM_Core_PseudoConstant::getKey('CRM_Core_BAO_FinancialTrxn', 'card_type_id', $this->_params['credit_card_type']) + )); + } + else { + $this->assign($paymentField, $this->_params[$paymentField]); + } + } + $this->assign('paymentFieldsetLabel', CRM_Core_Payment_Form::getPaymentLabel($paymentProcessorObject)); + $this->assign('paymentFields', $paymentFields); + + } + } + /** * Display ReCAPTCHA warning on Contribution form */ From ff5663969fba9d92f42985167681818e49a01192 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Wed, 3 Apr 2019 21:52:15 -0400 Subject: [PATCH 066/121] Promise Polyfill for older browsers --- bower.json | 3 ++- templates/CRM/common/l10n.js.tpl | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/bower.json b/bower.json index e40429345d85..b970b3e9ada7 100644 --- a/bower.json +++ b/bower.json @@ -31,7 +31,8 @@ "angular-bootstrap": "^2.5.0", "angular-sanitize": "~1.5.0", "smartmenus": "~1.1", - "phantomjs-polyfill": "^0.0.2" + "phantomjs-polyfill": "^0.0.2", + "es6-promise": "^4.2.4" }, "resolutions": { "angular": "~1.5.11" diff --git a/templates/CRM/common/l10n.js.tpl b/templates/CRM/common/l10n.js.tpl index 27338c8dfc9a..f2047652cc8a 100644 --- a/templates/CRM/common/l10n.js.tpl +++ b/templates/CRM/common/l10n.js.tpl @@ -128,5 +128,11 @@ params: {}, functions: [] }; + + // Load polyfill + if (!('Promise' in window)) { + CRM.loadScript(CRM.config.resourceBase + 'bower_components/es6-promise/es6-promise.auto.min.js'); + } + })(jQuery); {/literal} From c66b58c9b2e3d21b9806454fea872cf9dea26f50 Mon Sep 17 00:00:00 2001 From: eileen Date: Fri, 5 Apr 2019 10:28:12 +1300 Subject: [PATCH 067/121] Grammar fixes --- install/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install/index.php b/install/index.php index c70c1c1648a2..f0aa01eafa6b 100644 --- a/install/index.php +++ b/install/index.php @@ -524,7 +524,7 @@ public function checkdatabase($databaseConfig, $dbName) { $databaseConfig['database'], array( ts("MySQL %1 Configuration", array(1 => $dbName)), - ts("Does database has data from previous installation?"), + ts("Does the database have data from a previous installation?"), ts("CiviCRM data from previous installation exists in '%1'.", array(1 => $databaseConfig['database'])), ) ); @@ -1315,7 +1315,7 @@ public function requireNoExistingData( } } - $testDetails[3] = ts('CiviCRM data from previous installation does not exists in %1.', array(1 => $database)); + $testDetails[3] = ts('CiviCRM data from previous installation does not exist in %1.', array(1 => $database)); $this->testing($testDetails); } From f1b56c483e5892dba81257362e55f29cc0800bd1 Mon Sep 17 00:00:00 2001 From: eileen Date: Wed, 27 Mar 2019 19:23:28 +1300 Subject: [PATCH 068/121] Move code to assign tax information into shared parent --- CRM/Contribute/Form/Contribution/Confirm.php | 24 +++++++------ .../Form/FrontEndPaymentFormTrait.php | 35 +++++++++++++------ .../Contribute/Form/Contribution/Confirm.tpl | 6 ++-- 3 files changed, 42 insertions(+), 23 deletions(-) diff --git a/CRM/Contribute/Form/Contribution/Confirm.php b/CRM/Contribute/Form/Contribution/Confirm.php index f6841fc13675..24f3edc2e464 100644 --- a/CRM/Contribute/Form/Contribution/Confirm.php +++ b/CRM/Contribute/Form/Contribution/Confirm.php @@ -412,7 +412,7 @@ public function preProcess() { } $isPrimary = 1; - if (isset ($this->_params['onbehalf_location'][$blockName]) + if (isset($this->_params['onbehalf_location'][$blockName]) && count($this->_params['onbehalf_location'][$blockName]) > 0 ) { $isPrimary = 0; @@ -511,15 +511,20 @@ public function buildQuickForm() { // Make a copy of line items array to use for display only $tplLineItems = $this->_lineItem; if (CRM_Invoicing_Utils::isInvoicingEnabled()) { - list($getTaxDetails, $tplLineItems) = $this->alterLineItemsForTemplate($tplLineItems); - $this->assign('getTaxDetails', $getTaxDetails); - $this->assign('taxTerm', CRM_Invoicing_Utils::getTaxTerm()); + // @todo $params seems like exactly the wrong place to get totalTaxAmount from + // this is a calculated variable so we it should be transparent how we + // calculated it rather than coming from 'params' $this->assign('totalTaxAmount', $params['tax_amount']); } - if ($this->_priceSetId && !CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId, 'is_quick_config')) { - $this->assign('lineItem', $tplLineItems); - } - else { + $this->assignLineItemsToTemplate($tplLineItems); + + $isDisplayLineItems = $this->_priceSetId && !CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId, 'is_quick_config'); + + $this->assign('isDisplayLineItems', $isDisplayLineItems); + + if (!$isDisplayLineItems) { + // quickConfig is deprecated in favour of isDisplayLineItems. Lots of logic has been harnessed to quick config + // whereas isDisplayLineItems is specific & clear. $this->assign('is_quick_config', 1); $this->_params['is_quick_config'] = 1; } @@ -1811,8 +1816,7 @@ protected function getIsPending() { // The concept of contributeMode is deprecated. // the is_monetary concept probably should be too as it can be calculated from // the existence of 'amount' & seems fragile. - if (((isset($this->_contributeMode)) || !empty - ($this->_params['is_pay_later']) + if (((isset($this->_contributeMode)) || !empty($this->_params['is_pay_later']) ) && (($this->_values['is_monetary'] && $this->_amount > 0.0)) ) { diff --git a/CRM/Financial/Form/FrontEndPaymentFormTrait.php b/CRM/Financial/Form/FrontEndPaymentFormTrait.php index c65d8898ed44..7380cdd857be 100644 --- a/CRM/Financial/Form/FrontEndPaymentFormTrait.php +++ b/CRM/Financial/Form/FrontEndPaymentFormTrait.php @@ -43,25 +43,40 @@ trait CRM_Financial_Form_FrontEndPaymentFormTrait { * CRM_Invoicing_Utils class with a potential end goal of moving this handling to an extension. * * @param $tplLineItems - * - * @return array */ - protected function alterLineItemsForTemplate($tplLineItems) { - $getTaxDetails = FALSE; + protected function alterLineItemsForTemplate(&$tplLineItems) { + if (!CRM_Invoicing_Utils::isInvoicingEnabled()) { + return; + } + // @todo this should really be the first time we are determining + // the tax rates - we can calculate them from the financial_type_id + // & amount here so we didn't need a deeper function to semi-get + // them but not be able to 'format them right' because they are + // potentially being used for 'something else'. + // @todo invoicing code - please feel the hate. Also move this 'hook-like-bit' + // to the CRM_Invoicing_Utils class. foreach ($tplLineItems as $key => $value) { foreach ($value as $k => $v) { if (isset($v['tax_rate']) && $v['tax_rate'] != '') { - $getTaxDetails = TRUE; + // These only need assigning once, but code is more readable with them here + $this->assign('getTaxDetails', TRUE); + $this->assign('taxTerm', CRM_Invoicing_Utils::getTaxTerm()); // Cast to float to display without trailing zero decimals $tplLineItems[$key][$k]['tax_rate'] = (float) $v['tax_rate']; } } } - // @todo fix this to only return $tplLineItems. Calling function can check for tax rate and - // do all invoicing related assigns - // another discrete function (it's just one more iteration through a an array with only a handful of - // lines so the separation of concerns is more important than 'efficiency' - return [$getTaxDetails, $tplLineItems]; + } + + /** + * Assign line items to the template. + * + * @param $tplLineItems + */ + protected function assignLineItemsToTemplate($tplLineItems) { + // @todo this should be a hook that invoicing code hooks into rather than a call to it. + $this->alterLineItemsForTemplate($tplLineItems); + $this->assign('lineItem', $tplLineItems); } } diff --git a/templates/CRM/Contribute/Form/Contribution/Confirm.tpl b/templates/CRM/Contribute/Form/Contribution/Confirm.tpl index 22cb177dcca1..3fdb9310659e 100644 --- a/templates/CRM/Contribute/Form/Contribution/Confirm.tpl +++ b/templates/CRM/Contribute/Form/Contribution/Confirm.tpl @@ -44,16 +44,16 @@ {include file="CRM/Contribute/Form/Contribution/MembershipBlock.tpl" context="confirmContribution"} - {if $amount GTE 0 OR $minimum_fee GTE 0 OR ( $priceSetID and $lineItem ) } + {if $amount GTE 0 OR $minimum_fee GTE 0 OR ( $isDisplayLineItems and $lineItem ) }
{if !$useForMember}
- {if !$membershipBlock AND $amount OR ( $priceSetID and $lineItem ) }{ts}Contribution Amount{/ts}{else}{ts}Membership Fee{/ts} {/if} + {if !$membershipBlock AND $amount OR ( $isDisplayLineItems and $lineItem ) }{ts}Contribution Amount{/ts}{else}{ts}Membership Fee{/ts} {/if}
{/if}
{if !$useForMember} - {if $lineItem and $priceSetID} + {if $lineItem and $isDisplayLineItems} {if !$amount}{assign var="amount" value=0}{/if} {assign var="totalAmount" value=$amount} {include file="CRM/Price/Page/LineItem.tpl" context="Contribution"} From d7d7dde7b73714afc4e063b7f07edd6a5abb65a0 Mon Sep 17 00:00:00 2001 From: eileen Date: Fri, 5 Apr 2019 12:10:45 +1300 Subject: [PATCH 069/121] Allow payment processors to enable validate.tpl From https://github.com/eileenmcnaughton/nz.co.fuzion.omnipaymultiprocessor/issues/106 I found that I couldn't enable our validation from the payment processor currently. It's a bit immature in that our front end presentation is poor,but this allows us to start improving that --- templates/CRM/Contribute/Form/Contribution/Main.tpl | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/templates/CRM/Contribute/Form/Contribution/Main.tpl b/templates/CRM/Contribute/Form/Contribution/Main.tpl index 2ac32e12774e..838743a21760 100644 --- a/templates/CRM/Contribute/Form/Contribution/Main.tpl +++ b/templates/CRM/Contribute/Form/Contribution/Main.tpl @@ -415,5 +415,9 @@ {/if} {* jQuery validate *} -{* disabled because more work needs to be done to conditionally require credit card fields *} -{*include file="CRM/Form/validate.tpl"*} +{* disabled because originally this caused problems with some credit cards. +Likely it no longer has an problems but allowing conditional + inclusion by extensions / payment processors for now in order to add in a conservative way *} +{if $isJsValidate} + {include file="CRM/Form/validate.tpl"} +{/if} From b04bcc45f979b729ff5e1e2c2ce18f0c7a40501a Mon Sep 17 00:00:00 2001 From: eileen Date: Fri, 5 Apr 2019 13:40:11 +1300 Subject: [PATCH 070/121] Flush ContributionRecur static cache when flushing processors When creating a processor in a unit test it may not be available to use when creating a recurring in the same test without flushing the static cache here --- Civi/Payment/System.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Civi/Payment/System.php b/Civi/Payment/System.php index ed207143ad9b..536ed5204889 100644 --- a/Civi/Payment/System.php +++ b/Civi/Payment/System.php @@ -134,6 +134,9 @@ public function getByName($name, $is_test) { */ public function flushProcessors() { $this->cache = []; + if (isset(\Civi::$statics['CRM_Contribute_BAO_ContributionRecur'])) { + unset(\Civi::$statics['CRM_Contribute_BAO_ContributionRecur']); + } \CRM_Financial_BAO_PaymentProcessor::getAllPaymentProcessors('all', TRUE); \CRM_Financial_BAO_PaymentProcessor::getAllPaymentProcessors('live', TRUE); \CRM_Financial_BAO_PaymentProcessor::getAllPaymentProcessors('test', TRUE); From 350f28f731223c22e858fef7ed47e52736c8fbb7 Mon Sep 17 00:00:00 2001 From: eileen Date: Fri, 5 Apr 2019 14:38:50 +1300 Subject: [PATCH 071/121] Improve data when known time-dependent-failing test fails --- tests/phpunit/CRM/Report/FormTest.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/phpunit/CRM/Report/FormTest.php b/tests/phpunit/CRM/Report/FormTest.php index 61b70b18a479..bed5587d5924 100644 --- a/tests/phpunit/CRM/Report/FormTest.php +++ b/tests/phpunit/CRM/Report/FormTest.php @@ -83,8 +83,7 @@ public function fromToData() { public function testGetFromTo($expectedFrom, $expectedTo, $relative, $from, $to) { $obj = new CRM_Report_Form(); list($calculatedFrom, $calculatedTo) = $obj->getFromTo($relative, $from, $to); - $this->assertEquals($expectedFrom, $calculatedFrom); - $this->assertEquals($expectedTo, $calculatedTo); + $this->assertEquals([$expectedFrom, $expectedTo], [$calculatedFrom, $calculatedTo], "fail on data set [ $relative , $from , $to ]. Local php time is " . date('Y-m-d H:i:s') . ' and mysql time is ' . CRM_Core_DAO::singleValueQuery('SELECT NOW()')); } } From 8b408447dc0d649941ac448d0407a646dd5ba266 Mon Sep 17 00:00:00 2001 From: eileen Date: Fri, 5 Apr 2019 15:51:37 +1300 Subject: [PATCH 072/121] Remove reference to non-iso date format from membership form tests The date format wrangling is not handled by datepicker on the js layer so the php layer no longer needs to test for this --- .../CRM/Member/Form/MembershipTest.php | 60 +++++++++---------- 1 file changed, 28 insertions(+), 32 deletions(-) diff --git a/tests/phpunit/CRM/Member/Form/MembershipTest.php b/tests/phpunit/CRM/Member/Form/MembershipTest.php index f540759a3e90..c6b52dedfdba 100644 --- a/tests/phpunit/CRM/Member/Form/MembershipTest.php +++ b/tests/phpunit/CRM/Member/Form/MembershipTest.php @@ -174,11 +174,10 @@ public function testFormRuleEmptyContact() { */ public function testFormRuleRollingEarlyStart() { $unixNow = time(); - $ymdNow = date('m/d/Y', $unixNow); $unixYesterday = $unixNow - (24 * 60 * 60); - $ymdYesterday = date('m/d/Y', $unixYesterday); + $ymdYesterday = date('Y-m-d', $unixYesterday); $params = array( - 'join_date' => $ymdNow, + 'join_date' => date('Y-m-d'), 'start_date' => $ymdYesterday, 'end_date' => '', 'membership_type_id' => array('23', '15'), @@ -199,12 +198,11 @@ public function testFormRuleRollingEarlyStart() { */ public function testFormRuleRollingEarlyEnd() { $unixNow = time(); - $ymdNow = date('m/d/Y', $unixNow); $unixYesterday = $unixNow - (24 * 60 * 60); - $ymdYesterday = date('m/d/Y', $unixYesterday); + $ymdYesterday = date('Y-m-d', $unixYesterday); $params = array( - 'join_date' => $ymdNow, - 'start_date' => $ymdNow, + 'join_date' => date('Y-m-d'), + 'start_date' => date('Y-m-d'), 'end_date' => $ymdYesterday, 'membership_type_id' => array('23', '15'), ); @@ -220,11 +218,10 @@ public function testFormRuleRollingEarlyEnd() { */ public function testFormRuleRollingEndNoStart() { $unixNow = time(); - $ymdNow = date('m/d/Y', $unixNow); $unixYearFromNow = $unixNow + (365 * 24 * 60 * 60); - $ymdYearFromNow = date('m/d/Y', $unixYearFromNow); + $ymdYearFromNow = date('Y-m-d', $unixYearFromNow); $params = array( - 'join_date' => $ymdNow, + 'join_date' => date('Y-m-d'), 'start_date' => '', 'end_date' => $ymdYearFromNow, 'membership_type_id' => array('23', '15'), @@ -244,9 +241,9 @@ public function testFormRuleRollingLifetimeEnd() { $unixNow = time(); $unixYearFromNow = $unixNow + (365 * 24 * 60 * 60); $params = array( - 'join_date' => date('m/d/Y', $unixNow), - 'start_date' => date('m/d/Y', $unixNow), - 'end_date' => date('m/d/Y', + 'join_date' => date('Y-m-d'), + 'start_date' => date('Y-m-d'), + 'end_date' => date('Y-m-d', $unixYearFromNow ), 'membership_type_id' => array('23', '25'), @@ -265,7 +262,7 @@ public function testFormRuleRollingLifetimeEnd() { public function testFormRulePermanentOverrideWithNoStatus() { $unixNow = time(); $params = array( - 'join_date' => date('m/d/Y', $unixNow), + 'join_date' => date('Y-m-d'), 'membership_type_id' => array('23', '25'), 'is_override' => TRUE, ); @@ -278,11 +275,11 @@ public function testFormRulePermanentOverrideWithNoStatus() { public function testFormRuleUntilDateOverrideWithValidOverrideEndDate() { $params = array( - 'join_date' => date('m/d/Y', time()), + 'join_date' => date('Y-m-d'), 'membership_type_id' => array('23', '25'), 'is_override' => TRUE, 'status_id' => 1, - 'status_override_end_date' => date('m/d/Y', time()), + 'status_override_end_date' => date('Y-m-d'), ); $files = array(); $membershipForm = new CRM_Member_Form_Membership(); @@ -292,7 +289,7 @@ public function testFormRuleUntilDateOverrideWithValidOverrideEndDate() { public function testFormRuleUntilDateOverrideWithNoOverrideEndDate() { $params = array( - 'join_date' => date('m/d/Y', time()), + 'join_date' => date('Y-m-d'), 'membership_type_id' => array('23', '25'), 'is_override' => CRM_Member_StatusOverrideTypes::UNTIL_DATE, 'status_id' => 1, @@ -312,7 +309,7 @@ public function testFormRuleRollingJoin1MonthFromNow() { $unixNow = time(); $unix1MFmNow = $unixNow + (31 * 24 * 60 * 60); $params = array( - 'join_date' => date('m/d/Y', $unix1MFmNow), + 'join_date' => date('Y-m-d', $unix1MFmNow), 'start_date' => '', 'end_date' => '', 'membership_type_id' => array('23', '15'), @@ -330,9 +327,8 @@ public function testFormRuleRollingJoin1MonthFromNow() { * Test CRM_Member_Form_Membership::formRule() with a join date of today and a rolling membership type. */ public function testFormRuleRollingJoinToday() { - $unixNow = time(); $params = array( - 'join_date' => date('m/d/Y', $unixNow), + 'join_date' => date('Y-m-d'), 'start_date' => '', 'end_date' => '', 'membership_type_id' => array('23', '15'), @@ -353,7 +349,7 @@ public function testFormRuleRollingJoin1MonthAgo() { $unixNow = time(); $unix1MAgo = $unixNow - (31 * 24 * 60 * 60); $params = array( - 'join_date' => date('m/d/Y', $unix1MAgo), + 'join_date' => date('Y-m-d', $unix1MAgo), 'start_date' => '', 'end_date' => '', 'membership_type_id' => array('23', '15'), @@ -373,7 +369,7 @@ public function testFormRuleRollingJoin6MonthsAgo() { $unixNow = time(); $unix6MAgo = $unixNow - (180 * 24 * 60 * 60); $params = array( - 'join_date' => date('m/d/Y', $unix6MAgo), + 'join_date' => date('Y-m-d', $unix6MAgo), 'start_date' => '', 'end_date' => '', 'membership_type_id' => array('23', '15'), @@ -394,7 +390,7 @@ public function testFormRuleRollingJoin1YearAgo() { $unixNow = time(); $unix1YAgo = $unixNow - (370 * 24 * 60 * 60); $params = array( - 'join_date' => date('m/d/Y', $unix1YAgo), + 'join_date' => date('Y-m-d', $unix1YAgo), 'start_date' => '', 'end_date' => '', 'membership_type_id' => array('23', '15'), @@ -415,7 +411,7 @@ public function testFormRuleRollingJoin2YearsAgo() { $unixNow = time(); $unix2YAgo = $unixNow - (2 * 365 * 24 * 60 * 60); $params = array( - 'join_date' => date('m/d/Y', $unix2YAgo), + 'join_date' => date('Y-m-d', $unix2YAgo), 'start_date' => '', 'end_date' => '', 'membership_type_id' => array('23', '15'), @@ -436,7 +432,7 @@ public function testFormRuleFixedJoin6MonthsAgo() { $unixNow = time(); $unix6MAgo = $unixNow - (180 * 24 * 60 * 60); $params = array( - 'join_date' => date('m/d/Y', $unix6MAgo), + 'join_date' => date('Y-m-d', $unix6MAgo), 'start_date' => '', 'end_date' => '', 'membership_type_id' => array('23', '7'), @@ -564,7 +560,7 @@ public function testContributionUpdateOnMembershipTypeChange() { CRM_Price_BAO_PriceSet::buildPriceSet($form); $params = array( 'cid' => $this->_individualId, - 'join_date' => date('m/d/Y', time()), + 'join_date' => date('Y-m-d'), 'start_date' => '', 'end_date' => '', // This format reflects the 23 being the organisation & the 25 being the type. @@ -612,7 +608,7 @@ public function testContributionUpdateOnMembershipTypeChange() { $form->_action = CRM_Core_Action::UPDATE; $params = array( 'cid' => $this->_individualId, - 'join_date' => date('m/d/Y', time()), + 'join_date' => date('Y-m-d'), 'start_date' => '', 'end_date' => '', // This format reflects the 23 being the organisation & the 25 being the type. @@ -662,7 +658,7 @@ public function testSubmitPartialPayment($thousandSeparator) { CRM_Price_BAO_PriceSet::buildPriceSet($form); $params = array( 'cid' => $this->_individualId, - 'join_date' => date('m/d/Y', time()), + 'join_date' => date('Y-m-d'), 'start_date' => '', 'end_date' => '', // This format reflects the 23 being the organisation & the 25 being the type. @@ -829,7 +825,7 @@ public function testSubmitPayLaterWithBilling() { $this->createLoggedInUser(); $params = array( 'cid' => $this->_individualId, - 'join_date' => date('m/d/Y', time()), + 'join_date' => date('Y-m-d'), 'start_date' => '', 'end_date' => '', // This format reflects the 23 being the organisation & the 25 being the type. @@ -1116,7 +1112,7 @@ protected function getBaseSubmitParams() { $params = array( 'cid' => $this->_individualId, 'price_set_id' => 0, - 'join_date' => date('m/d/Y', time()), + 'join_date' => date('Y-m-d'), 'start_date' => '', 'end_date' => '', 'campaign_id' => '', @@ -1206,7 +1202,7 @@ protected function createTwoMembershipsViaPriceSetInBackEnd($contactId) { // register for both of these memberships via backoffice membership form submission $params = array( 'cid' => $contactId, - 'join_date' => date('m/d/Y', time()), + 'join_date' => date('Y-m-d'), 'start_date' => '', 'end_date' => '', // This format reflects the 23 being the organisation & the 25 being the type. @@ -1314,7 +1310,7 @@ public function testLineItemAmountOnSalesTax() { $form->_priceSet = current(CRM_Price_BAO_PriceSet::getSetDetail($priceSet['id'])); $params = array( 'cid' => $this->_individualId, - 'join_date' => date('m/d/Y', time()), + 'join_date' => date('Y-m-d'), 'start_date' => '', 'end_date' => '', // This format reflects the 23 being the organisation & the 25 being the type. From 86420016f525d680803b3f36850faa7373485567 Mon Sep 17 00:00:00 2001 From: eileen Date: Fri, 5 Apr 2019 16:13:51 +1300 Subject: [PATCH 073/121] [REF] extract token functions This is an reviewer's commit from https://github.com/civicrm/civicrm-core/pull/12012/files We are about to merge array formatting changes that will make lots of PRs go stale. I couldn't get this reviewed & merged before the change but I thought if I could do it through a sub-commit it would be better than just making it go stale. This is a simple extraction & I will add merge on pass as it is a reviewer's commit --- CRM/Activity/Tokens.php | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/CRM/Activity/Tokens.php b/CRM/Activity/Tokens.php index 8730ada82b3d..4bd22e2dd95a 100644 --- a/CRM/Activity/Tokens.php +++ b/CRM/Activity/Tokens.php @@ -50,14 +50,8 @@ class CRM_Activity_Tokens extends \Civi\Token\AbstractTokenSubscriber { */ public function __construct() { parent::__construct('activity', array_merge( - array( - 'activity_id' => ts('Activity ID'), - 'activity_type' => ts('Activity Type'), - 'subject' => ts('Activity Subject'), - 'details' => ts('Activity Details'), - 'activity_date_time' => ts('Activity Date-Time'), - ), - CRM_Utils_Token::getCustomFieldTokens('Activity') + $this->getBasicTokens(), + $this->getCustomFieldTokens() )); } @@ -118,4 +112,27 @@ public function evaluateToken(\Civi\Token\TokenRow $row, $entity, $field, $prefe } } + /** + * Get the basic tokens provided. + * + * @return array token name => token label + */ + protected function getBasicTokens() { + return [ + 'activity_id' => ts('Activity ID'), + 'activity_type' => ts('Activity Type'), + 'subject' => ts('Activity Subject'), + 'details' => ts('Activity Details'), + 'activity_date_time' => ts('Activity Date-Time'), + ]; + } + + /** + * Get the tokens for custom fields + * @return array token name => token label + */ + protected function getCustomFieldTokens() { + return CRM_Utils_Token::getCustomFieldTokens('Activity'); + } + } From cf0d1c08135c8b97ab513fd3da5f76dabe74baab Mon Sep 17 00:00:00 2001 From: eileen Date: Fri, 5 Apr 2019 17:21:19 +1300 Subject: [PATCH 074/121] Autoformat - just CRM/ACL dir --- CRM/ACL/API.php | 16 +++--- CRM/ACL/BAO/ACL.php | 54 +++++++++---------- CRM/ACL/BAO/Cache.php | 15 ++++-- CRM/ACL/BAO/EntityRole.php | 4 +- CRM/ACL/DAO/ACL.php | 4 +- CRM/ACL/DAO/Cache.php | 2 +- CRM/ACL/DAO/EntityRole.php | 2 +- CRM/ACL/Form/ACL.php | 52 +++++++++---------- CRM/ACL/Form/ACLBasic.php | 22 ++++---- CRM/ACL/Form/EntityRole.php | 6 +-- CRM/ACL/Form/WordPress/Permissions.php | 32 ++++++------ CRM/ACL/Page/ACL.php | 72 +++++++++++++------------- CRM/ACL/Page/ACLBasic.php | 26 +++++----- CRM/ACL/Page/EntityRole.php | 38 +++++++------- 14 files changed, 171 insertions(+), 174 deletions(-) diff --git a/CRM/ACL/API.php b/CRM/ACL/API.php index cff9541c4957..80855ac01b65 100644 --- a/CRM/ACL/API.php +++ b/CRM/ACL/API.php @@ -125,16 +125,12 @@ public static function whereClause( return $deleteClause; } - $where = implode(' AND ', - array( - CRM_ACL_BAO_ACL::whereClause($type, - $tables, - $whereTables, - $contactID - ), - $deleteClause, - ) + $whereClause = CRM_ACL_BAO_ACL::whereClause($type, + $tables, + $whereTables, + $contactID ); + $where = implode(' AND ', [$whereClause, $deleteClause]); // Add permission on self if we really hate our server or have hardly any contacts. if (!$skipOwnContactClause && $contactID && (CRM_Core_Permission::check('edit my contact') || @@ -203,7 +199,7 @@ public static function groupPermission( ) { if (!isset(Civi::$statics[__CLASS__]) || !isset(Civi::$statics[__CLASS__]['group_permission'])) { - Civi::$statics[__CLASS__]['group_permission'] = array(); + Civi::$statics[__CLASS__]['group_permission'] = []; } if (!$contactID) { diff --git a/CRM/ACL/BAO/ACL.php b/CRM/ACL/BAO/ACL.php index 7c0eb1af7cd0..64ee29b15dc9 100644 --- a/CRM/ACL/BAO/ACL.php +++ b/CRM/ACL/BAO/ACL.php @@ -51,10 +51,10 @@ class CRM_ACL_BAO_ACL extends CRM_ACL_DAO_ACL { */ public static function entityTable() { if (!self::$_entityTable) { - self::$_entityTable = array( + self::$_entityTable = [ 'civicrm_contact' => ts('Contact'), 'civicrm_acl_role' => ts('ACL Role'), - ); + ]; } return self::$_entityTable; } @@ -64,12 +64,12 @@ public static function entityTable() { */ public static function objectTable() { if (!self::$_objectTable) { - self::$_objectTable = array( + self::$_objectTable = [ 'civicrm_contact' => ts('Contact'), 'civicrm_group' => ts('Group'), 'civicrm_saved_search' => ts('Contact Group'), 'civicrm_admin' => ts('Import'), - ); + ]; } return self::$_objectTable; } @@ -79,14 +79,14 @@ public static function objectTable() { */ public static function operation() { if (!self::$_operation) { - self::$_operation = array( + self::$_operation = [ 'View' => ts('View'), 'Edit' => ts('Edit'), 'Create' => ts('Create'), 'Delete' => ts('Delete'), 'Search' => ts('Search'), 'All' => ts('All'), - ); + ]; } return self::$_operation; } @@ -120,14 +120,14 @@ public static function permissionClause( CRM_Core_Error::deprecatedFunctionWarning('unknown - this is really old & not used in core'); $dao = new CRM_ACL_DAO_ACL(); - $t = array( + $t = [ 'ACL' => self::getTableName(), 'ACLRole' => 'civicrm_acl_role', 'ACLEntityRole' => CRM_ACL_DAO_EntityRole::getTableName(), 'Contact' => CRM_Contact_DAO_Contact::getTableName(), 'Group' => CRM_Contact_DAO_Group::getTableName(), 'GroupContact' => CRM_Contact_DAO_GroupContact::getTableName(), - ); + ]; $contact_id = CRM_Core_Session::getLoggedInContactID(); @@ -158,7 +158,7 @@ public static function permissionClause( } } - $query = array(); + $query = []; /* Query for permissions granted to all contacts in the domain */ @@ -261,9 +261,9 @@ public static function permissionClause( $dao->query($union); - $allow = array(0); - $deny = array(0); - $override = array(); + $allow = [0]; + $deny = [0]; + $override = []; while ($dao->fetch()) { /* Instant bypass for the following cases: @@ -338,7 +338,7 @@ public static function permissionClause( public static function getClause($table, $id, &$tables) { $table = CRM_Utils_Type::escape($table, 'String'); $id = CRM_Utils_Type::escape($id, 'Integer'); - $whereTables = array(); + $whereTables = []; $ssTable = CRM_Contact_BAO_SavedSearch::getTableName(); @@ -367,7 +367,7 @@ public static function getClause($table, $id, &$tables) { * Assoc. array of the ACL rule's properties */ public function toArray($format = '%s', $hideEmpty = FALSE) { - $result = array(); + $result = []; if (!self::$_fieldKeys) { $fields = CRM_ACL_DAO_ACL::fields(); @@ -397,7 +397,7 @@ public function toArray($format = '%s', $hideEmpty = FALSE) { * Array of assoc. arrays of ACL rules */ public static function &getACLs($contact_id = NULL, $group_id = NULL, $aclRoles = FALSE) { - $results = array(); + $results = []; if (empty($contact_id)) { return $results; @@ -505,7 +505,7 @@ public static function &getACLRoles($contact_id = NULL, $group_id = NULL) { } } - $results = array(); + $results = []; $rule->query($query); @@ -535,7 +535,7 @@ public static function &getGroupACLs($contact_id, $aclRoles = FALSE) { $acl = self::getTableName(); $c2g = CRM_Contact_BAO_GroupContact::getTableName(); $group = CRM_Contact_BAO_Group::getTableName(); - $results = array(); + $results = []; if ($contact_id) { $query = " @@ -603,7 +603,7 @@ public static function &getGroupACLRoles($contact_id) { AND $c2g.contact_id = $contact_id AND $c2g.status = 'Added'"; - $results = array(); + $results = []; $rule->query($query); @@ -644,7 +644,7 @@ public static function &getGroupACLRoles($contact_id) { * Assoc array of ACL rules */ public static function &getAllByContact($contact_id) { - $result = array(); + $result = []; /* First, the contact-specific ACLs, including ACL Roles */ $result += self::getACLs($contact_id, NULL, TRUE); @@ -718,7 +718,7 @@ public static function check($str, $contactID) { AND a.object_table = %1 AND a.id IN ( $aclKeys ) "; - $params = array(1 => array($str, 'String')); + $params = [1 => [$str, 'String']]; $count = CRM_Core_DAO::singleValueQuery($query, $params); return ($count) ? TRUE : FALSE; @@ -736,7 +736,7 @@ public static function whereClause($type, &$tables, &$whereTables, $contactID = $acls = CRM_ACL_BAO_Cache::build($contactID); $whereClause = NULL; - $clauses = array(); + $clauses = []; if (!empty($acls)) { $aclKeys = array_keys($acls); @@ -755,12 +755,12 @@ public static function whereClause($type, &$tables, &$whereTables, $contactID = $dao = CRM_Core_DAO::executeQuery($query); // do an or of all the where clauses u see - $ids = array(); + $ids = []; while ($dao->fetch()) { // make sure operation matches the type TODO if (self::matchType($type, $dao->operation)) { if (!$dao->object_id) { - $ids = array(); + $ids = []; $whereClause = ' ( 1 ) '; break; } @@ -834,7 +834,7 @@ public static function group( ) { $userCacheKey = "{$contactID}_{$type}_{$tableName}_" . CRM_Core_Config::domainID() . '_' . md5(implode(',', array_merge((array) $allGroups, (array) $includedGroups))); if (empty(Civi::$statics[__CLASS__]['permissioned_groups'])) { - Civi::$statics[__CLASS__]['permissioned_groups'] = array(); + Civi::$statics[__CLASS__]['permissioned_groups'] = []; } if (!empty(Civi::$statics[__CLASS__]['permissioned_groups'][$userCacheKey])) { return Civi::$statics[__CLASS__]['permissioned_groups'][$userCacheKey]; @@ -846,7 +846,7 @@ public static function group( $acls = CRM_ACL_BAO_Cache::build($contactID); - $ids = array(); + $ids = []; if (!empty($acls)) { $aclKeys = array_keys($acls); $aclKeys = implode(',', $aclKeys); @@ -855,7 +855,7 @@ public static function group( $cache = CRM_Utils_Cache::singleton(); $ids = $cache->get($cacheKey); if (!$ids) { - $ids = array(); + $ids = []; $query = " SELECT a.operation, a.object_id FROM civicrm_acl_cache c, civicrm_acl a @@ -866,7 +866,7 @@ public static function group( GROUP BY a.operation,a.object_id ORDER BY a.object_id "; - $params = array(1 => array($tableName, 'String')); + $params = [1 => [$tableName, 'String']]; $dao = CRM_Core_DAO::executeQuery($query, $params); while ($dao->fetch()) { if ($dao->object_id) { diff --git a/CRM/ACL/BAO/Cache.php b/CRM/ACL/BAO/Cache.php index 2884ce8d6827..f5ca81226949 100644 --- a/CRM/ACL/BAO/Cache.php +++ b/CRM/ACL/BAO/Cache.php @@ -45,7 +45,7 @@ class CRM_ACL_BAO_Cache extends CRM_ACL_DAO_Cache { */ public static function &build($id) { if (!self::$_cache) { - self::$_cache = array(); + self::$_cache = []; } if (array_key_exists($id, self::$_cache)) { @@ -75,7 +75,7 @@ public static function retrieve($id) { FROM civicrm_acl_cache WHERE contact_id = %1 "; - $params = array(1 => array($id, 'Integer')); + $params = [1 => [$id, 'Integer']]; if ($id == 0) { $query .= " OR contact_id IS NULL"; @@ -83,7 +83,7 @@ public static function retrieve($id) { $dao = CRM_Core_DAO::executeQuery($query, $params); - $cache = array(); + $cache = []; while ($dao->fetch()) { $cache[$dao->acl_id] = 1; } @@ -122,7 +122,7 @@ public static function deleteEntry($id) { DELETE FROM civicrm_acl_cache WHERE contact_id = %1 "; - $params = array(1 => array($id, 'Integer')); + $params = [1 => [$id, 'Integer']]; CRM_Core_DAO::executeQuery($query, $params); } @@ -154,7 +154,12 @@ public static function resetCache() { WHERE modified_date IS NULL OR (modified_date <= %1) "; - $params = array(1 => array(CRM_Contact_BAO_GroupContactCache::getCacheInvalidDateTime(), 'String')); + $params = [ + 1 => [ + CRM_Contact_BAO_GroupContactCache::getCacheInvalidDateTime(), + 'String', + ], + ]; CRM_Core_DAO::singleValueQuery($query, $params); // CRM_Core_DAO::singleValueQuery("TRUNCATE TABLE civicrm_acl_contact_cache"); // No, force-commits transaction diff --git a/CRM/ACL/BAO/EntityRole.php b/CRM/ACL/BAO/EntityRole.php index eb12167be429..a329052b80a0 100644 --- a/CRM/ACL/BAO/EntityRole.php +++ b/CRM/ACL/BAO/EntityRole.php @@ -44,10 +44,10 @@ class CRM_ACL_BAO_EntityRole extends CRM_ACL_DAO_EntityRole { */ public static function entityTable() { if (!self::$_entityTable) { - self::$_entityTable = array( + self::$_entityTable = [ 'civicrm_contact' => ts('Contact'), 'civicrm_group' => ts('Group'), - ); + ]; } return self::$_entityTable; } diff --git a/CRM/ACL/DAO/ACL.php b/CRM/ACL/DAO/ACL.php index 68ae1b22d8b0..a1d1b72bd399 100644 --- a/CRM/ACL/DAO/ACL.php +++ b/CRM/ACL/DAO/ACL.php @@ -121,7 +121,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName(), 'entity_id', NULL, 'id', 'entity_table'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); } @@ -217,7 +217,7 @@ public static function &fields() { ], 'pseudoconstant' => [ 'callback' => 'CRM_ACL_BAO_ACL::operation', - ] + ], ], 'object_table' => [ 'name' => 'object_table', diff --git a/CRM/ACL/DAO/Cache.php b/CRM/ACL/DAO/Cache.php index 9808031b4868..208dce728f8b 100644 --- a/CRM/ACL/DAO/Cache.php +++ b/CRM/ACL/DAO/Cache.php @@ -72,7 +72,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'acl_id', 'civicrm_acl', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); diff --git a/CRM/ACL/DAO/EntityRole.php b/CRM/ACL/DAO/EntityRole.php index afc385006899..a4dda46a3960 100644 --- a/CRM/ACL/DAO/EntityRole.php +++ b/CRM/ACL/DAO/EntityRole.php @@ -79,7 +79,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName(), 'entity_id', NULL, 'id', 'entity_table'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); } diff --git a/CRM/ACL/Form/ACL.php b/CRM/ACL/Form/ACL.php index b66122ea709b..76e54265621a 100644 --- a/CRM/ACL/Form/ACL.php +++ b/CRM/ACL/Form/ACL.php @@ -114,24 +114,24 @@ public function buildQuickForm() { $this->add('text', 'name', ts('Description'), CRM_Core_DAO::getAttribute('CRM_ACL_DAO_ACL', 'name'), TRUE); - $operations = array('' => ts('- select -')) + CRM_ACL_BAO_ACL::operation(); + $operations = ['' => ts('- select -')] + CRM_ACL_BAO_ACL::operation(); $this->add('select', 'operation', ts('Operation'), $operations, TRUE ); - $objTypes = array( + $objTypes = [ '1' => ts('A group of contacts'), '2' => ts('A profile'), '3' => ts('A set of custom data fields'), - ); + ]; if (CRM_Core_Permission::access('CiviEvent')) { $objTypes['4'] = ts('Events'); } - $extra = array('onclick' => "showObjectSelect();"); + $extra = ['onclick' => "showObjectSelect();"]; $this->addRadio('object_type', ts('Type of Data'), $objTypes, @@ -140,31 +140,31 @@ public function buildQuickForm() { ); $label = ts('Role'); - $role = array( - '-1' => ts('- select role -'), - '0' => ts('Everyone'), - ) + CRM_Core_OptionGroup::values('acl_role'); + $role = [ + '-1' => ts('- select role -'), + '0' => ts('Everyone'), + ] + CRM_Core_OptionGroup::values('acl_role'); $this->add('select', 'entity_id', $label, $role, TRUE); - $group = array( - '-1' => ts('- select -'), - '0' => ts('All Groups'), - ) + CRM_Core_PseudoConstant::group(); + $group = [ + '-1' => ts('- select -'), + '0' => ts('All Groups'), + ] + CRM_Core_PseudoConstant::group(); - $customGroup = array( - '-1' => ts('- select -'), - '0' => ts('All Custom Groups'), - ) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_CustomField', 'custom_group_id'); + $customGroup = [ + '-1' => ts('- select -'), + '0' => ts('All Custom Groups'), + ] + CRM_Core_PseudoConstant::get('CRM_Core_DAO_CustomField', 'custom_group_id'); - $ufGroup = array( - '-1' => ts('- select -'), - '0' => ts('All Profiles'), - ) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_UFField', 'uf_group_id'); + $ufGroup = [ + '-1' => ts('- select -'), + '0' => ts('All Profiles'), + ] + CRM_Core_PseudoConstant::get('CRM_Core_DAO_UFField', 'uf_group_id'); - $event = array( - '-1' => ts('- select -'), - '0' => ts('All Events'), - ) + CRM_Event_PseudoConstant::event(NULL, FALSE, "( is_template IS NULL OR is_template != 1 )"); + $event = [ + '-1' => ts('- select -'), + '0' => ts('All Events'), + ] + CRM_Event_PseudoConstant::event(NULL, FALSE, "( is_template IS NULL OR is_template != 1 )"); $this->add('select', 'group_id', ts('Group'), $group); $this->add('select', 'custom_group_id', ts('Custom Data'), $customGroup); @@ -173,7 +173,7 @@ public function buildQuickForm() { $this->add('checkbox', 'is_active', ts('Enabled?')); - $this->addFormRule(array('CRM_ACL_Form_ACL', 'formRule')); + $this->addFormRule(['CRM_ACL_Form_ACL', 'formRule']); } /** @@ -189,7 +189,7 @@ public static function formRule($params) { $errors['entity_id'] = ts('Please assign this permission to a Role.'); } - $validOperations = array('View', 'Edit'); + $validOperations = ['View', 'Edit']; $operationMessage = ts("Only 'View' and 'Edit' operations are valid for this type of data"); // Figure out which type of object we're permissioning on and make sure user has selected a value. diff --git a/CRM/ACL/Form/ACLBasic.php b/CRM/ACL/Form/ACLBasic.php index da7c2c78684f..af902384fdfd 100644 --- a/CRM/ACL/Form/ACLBasic.php +++ b/CRM/ACL/Form/ACLBasic.php @@ -36,7 +36,7 @@ class CRM_ACL_Form_ACLBasic extends CRM_Admin_Form { * Set default values for the form. */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; if ($this->_id || $this->_id === '0' @@ -49,9 +49,9 @@ public function setDefaultValues() { WHERE entity_id = %1 AND ( object_table NOT IN ( 'civicrm_saved_search', 'civicrm_uf_group', 'civicrm_custom_group' ) ) "; - $params = array(1 => array($this->_id, 'Integer')); + $params = [1 => [$this->_id, 'Integer']]; $dao = CRM_Core_DAO::executeQuery($query, $params); - $defaults['object_table'] = array(); + $defaults['object_table'] = []; while ($dao->fetch()) { $defaults['object_table'][$dao->object_table] = 1; } @@ -75,14 +75,14 @@ public function buildQuickForm() { ts('ACL Type'), $permissions, NULL, NULL, TRUE, NULL, - array('', '') + ['', ''] ); $label = ts('Role'); - $role = array( - '-1' => ts('- select role -'), - '0' => ts('Everyone'), - ) + CRM_Core_OptionGroup::values('acl_role'); + $role = [ + '-1' => ts('- select role -'), + '0' => ts('Everyone'), + ] + CRM_Core_OptionGroup::values('acl_role'); $entityID = &$this->add('select', 'entity_id', $label, $role, TRUE); if ($this->_id) { @@ -90,7 +90,7 @@ public function buildQuickForm() { } $this->add('checkbox', 'is_active', ts('Enabled?')); - $this->addFormRule(array('CRM_ACL_Form_ACLBasic', 'formRule')); + $this->addFormRule(['CRM_ACL_Form_ACLBasic', 'formRule']); } /** @@ -100,7 +100,7 @@ public function buildQuickForm() { */ public static function formRule($params) { if ($params['entity_id'] == -1) { - $errors = array('entity_id' => ts('Role is a required field')); + $errors = ['entity_id' => ts('Role is a required field')]; return $errors; } @@ -123,7 +123,7 @@ public function postProcess() { WHERE entity_id = %1 AND ( object_table NOT IN ( 'civicrm_saved_search', 'civicrm_uf_group', 'civicrm_custom_group' ) ) "; - $deleteParams = array(1 => array($this->_id, 'Integer')); + $deleteParams = [1 => [$this->_id, 'Integer']]; CRM_Core_DAO::executeQuery($query, $deleteParams); if ($this->_action & CRM_Core_Action::DELETE) { diff --git a/CRM/ACL/Form/EntityRole.php b/CRM/ACL/Form/EntityRole.php index 4cfb17b1b8f7..1da21f89ea2f 100644 --- a/CRM/ACL/Form/EntityRole.php +++ b/CRM/ACL/Form/EntityRole.php @@ -42,14 +42,14 @@ public function buildQuickForm() { return; } - $aclRoles = array('' => ts('- select -')) + CRM_Core_OptionGroup::values('acl_role'); + $aclRoles = ['' => ts('- select -')] + CRM_Core_OptionGroup::values('acl_role'); $this->add('select', 'acl_role_id', ts('ACL Role'), $aclRoles, TRUE ); $label = ts('Assigned to'); - $group = array('' => ts('- select group -')) + CRM_Core_PseudoConstant::staticGroup(FALSE, 'Access'); - $this->add('select', 'entity_id', $label, $group, TRUE, array('class' => 'crm-select2 huge')); + $group = ['' => ts('- select group -')] + CRM_Core_PseudoConstant::staticGroup(FALSE, 'Access'); + $this->add('select', 'entity_id', $label, $group, TRUE, ['class' => 'crm-select2 huge']); $this->add('checkbox', 'is_active', ts('Enabled?')); } diff --git a/CRM/ACL/Form/WordPress/Permissions.php b/CRM/ACL/Form/WordPress/Permissions.php index 24e63eaa6082..65191fb9793a 100644 --- a/CRM/ACL/Form/WordPress/Permissions.php +++ b/CRM/ACL/Form/WordPress/Permissions.php @@ -77,7 +77,7 @@ public function buildQuickForm() { $this->setDefaults($defaults); - $descArray = array(); + $descArray = []; foreach ($permissionsDesc as $perm => $attr) { if (count($attr) > 1) { $descArray[$perm] = $attr[1]; @@ -85,7 +85,7 @@ public function buildQuickForm() { } // build table rows by merging role perms - $rows = array(); + $rows = []; foreach ($rolePerms as $role => $perms) { foreach ($perms as $name => $title) { $rows[$name] = $title; @@ -93,14 +93,14 @@ public function buildQuickForm() { } // Build array keyed by permission - $table = array(); + $table = []; foreach ($rows as $perm => $label) { // Init row with permission label - $table[$perm] = array( + $table[$perm] = [ 'label' => $label, - 'roles' => array(), - ); + 'roles' => [], + ]; // Add permission description and role names foreach ($roles as $key => $label) { @@ -117,14 +117,14 @@ public function buildQuickForm() { $this->assign('roles', $roles); $this->addButtons( - array( - array( + [ + [ 'type' => 'next', 'name' => ts('Save'), 'spacing' => '', 'isDefault' => FALSE, - ), - ) + ], + ] ); } @@ -165,16 +165,16 @@ public function postProcess() { $allWarningPermissions[$key] = CRM_Utils_String::munge(strtolower($permission)); } $warningPermissions = array_intersect($allWarningPermissions, array_keys($rolePermissions)); - $warningPermissionNames = array(); + $warningPermissionNames = []; foreach ($warningPermissions as $permission) { $warningPermissionNames[$permission] = $permissionsArray[$permission]; } if (!empty($warningPermissionNames)) { CRM_Core_Session::setStatus( - ts('The %1 role was assigned one or more permissions that may prove dangerous for users of that role to have. Please reconsider assigning %2 to them.', array( - 1 => $wp_roles->role_names[$role], - 2 => implode(', ', $warningPermissionNames), - )), + ts('The %1 role was assigned one or more permissions that may prove dangerous for users of that role to have. Please reconsider assigning %2 to them.', [ + 1 => $wp_roles->role_names[$role], + 2 => implode(', ', $warningPermissionNames), + ]), ts('Unsafe Permission Settings') ); } @@ -214,7 +214,7 @@ public static function getPermissionArray($descriptions = FALSE) { $permissions = CRM_Core_Permission::basicPermissions(FALSE, $descriptions); - $perms_array = array(); + $perms_array = []; foreach ($permissions as $perm => $title) { //order matters here, but we deal with that later $perms_array[CRM_Utils_String::munge(strtolower($perm))] = $title; diff --git a/CRM/ACL/Page/ACL.php b/CRM/ACL/Page/ACL.php index 4b45a0b5025e..f056c675ce7c 100644 --- a/CRM/ACL/Page/ACL.php +++ b/CRM/ACL/Page/ACL.php @@ -59,30 +59,30 @@ public function getBAOName() { */ public function &links() { if (!(self::$_links)) { - self::$_links = array( - CRM_Core_Action::UPDATE => array( + self::$_links = [ + CRM_Core_Action::UPDATE => [ 'name' => ts('Edit'), 'url' => 'civicrm/acl', 'qs' => 'reset=1&action=update&id=%%id%%', 'title' => ts('Edit ACL'), - ), - CRM_Core_Action::DISABLE => array( + ], + CRM_Core_Action::DISABLE => [ 'name' => ts('Disable'), 'ref' => 'crm-enable-disable', 'title' => ts('Disable ACL'), - ), - CRM_Core_Action::ENABLE => array( + ], + CRM_Core_Action::ENABLE => [ 'name' => ts('Enable'), 'ref' => 'crm-enable-disable', 'title' => ts('Enable ACL'), - ), - CRM_Core_Action::DELETE => array( + ], + CRM_Core_Action::DELETE => [ 'name' => ts('Delete'), 'url' => 'civicrm/acl', 'qs' => 'reset=1&action=delete&id=%%id%%', 'title' => ts('Delete ACL'), - ), - ); + ], + ]; } return self::$_links; } @@ -94,14 +94,12 @@ public function &links() { */ public function run() { // set breadcrumb to append to admin/access - $breadCrumb = array( - array( + $breadCrumb = [ + [ 'title' => ts('Access Control'), - 'url' => CRM_Utils_System::url('civicrm/admin/access', - 'reset=1' - ), - ), - ); + 'url' => CRM_Utils_System::url('civicrm/admin/access', 'reset=1'), + ], + ]; CRM_Utils_System::appendBreadCrumb($breadCrumb); // parent run @@ -113,7 +111,7 @@ public function run() { */ public function browse() { // get all acl's sorted by weight - $acl = array(); + $acl = []; $query = " SELECT * FROM civicrm_acl @@ -124,26 +122,26 @@ public function browse() { $roles = CRM_Core_OptionGroup::values('acl_role'); - $group = array( - '-1' => ts('- select -'), - '0' => ts('All Groups'), - ) + CRM_Core_PseudoConstant::group(); - $customGroup = array( - '-1' => ts('- select -'), - '0' => ts('All Custom Groups'), - ) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_CustomField', 'custom_group_id'); - $ufGroup = array( - '-1' => ts('- select -'), - '0' => ts('All Profiles'), - ) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_UFField', 'uf_group_id'); + $group = [ + '-1' => ts('- select -'), + '0' => ts('All Groups'), + ] + CRM_Core_PseudoConstant::group(); + $customGroup = [ + '-1' => ts('- select -'), + '0' => ts('All Custom Groups'), + ] + CRM_Core_PseudoConstant::get('CRM_Core_DAO_CustomField', 'custom_group_id'); + $ufGroup = [ + '-1' => ts('- select -'), + '0' => ts('All Profiles'), + ] + CRM_Core_PseudoConstant::get('CRM_Core_DAO_UFField', 'uf_group_id'); - $event = array( - '-1' => ts('- select -'), - '0' => ts('All Events'), - ) + CRM_Event_PseudoConstant::event(); + $event = [ + '-1' => ts('- select -'), + '0' => ts('All Events'), + ] + CRM_Event_PseudoConstant::event(); while ($dao->fetch()) { - $acl[$dao->id] = array(); + $acl[$dao->id] = []; $acl[$dao->id]['name'] = $dao->name; $acl[$dao->id]['operation'] = $dao->operation; $acl[$dao->id]['entity_id'] = $dao->entity_id; @@ -194,7 +192,7 @@ public function browse() { $acl[$dao->id]['action'] = CRM_Core_Action::formLink( self::links(), $action, - array('id' => $dao->id), + ['id' => $dao->id], ts('more'), FALSE, 'ACL.manage.action', @@ -253,7 +251,7 @@ public function edit($mode, $id = NULL, $imageUpload = FALSE, $pushUserContext = if ($mode & (CRM_Core_Action::UPDATE)) { if (isset($id)) { $aclName = CRM_Core_DAO::getFieldValue('CRM_ACL_DAO_ACL', $id); - CRM_Utils_System::setTitle(ts('Edit ACL – %1', array(1 => $aclName))); + CRM_Utils_System::setTitle(ts('Edit ACL – %1', [1 => $aclName])); } } parent::edit($mode, $id, $imageUpload, $pushUserContext); diff --git a/CRM/ACL/Page/ACLBasic.php b/CRM/ACL/Page/ACLBasic.php index 113d6117b3aa..2d03da6c9640 100644 --- a/CRM/ACL/Page/ACLBasic.php +++ b/CRM/ACL/Page/ACLBasic.php @@ -57,20 +57,20 @@ public function getBAOName() { */ public function &links() { if (!(self::$_links)) { - self::$_links = array( - CRM_Core_Action::UPDATE => array( + self::$_links = [ + CRM_Core_Action::UPDATE => [ 'name' => ts('Edit'), 'url' => 'civicrm/acl/basic', 'qs' => 'reset=1&action=update&id=%%id%%', 'title' => ts('Edit ACL'), - ), - CRM_Core_Action::DELETE => array( + ], + CRM_Core_Action::DELETE => [ 'name' => ts('Delete'), 'url' => 'civicrm/acl/basic', 'qs' => 'reset=1&action=delete&id=%%id%%', 'title' => ts('Delete ACL'), - ), - ); + ], + ]; } return self::$_links; } @@ -86,12 +86,12 @@ public function run() { $id = $this->getIdAndAction(); // set breadcrumb to append to admin/access - $breadCrumb = array( - array( + $breadCrumb = [ + [ 'title' => ts('Access Control'), 'url' => CRM_Utils_System::url('civicrm/admin/access', 'reset=1'), - ), - ); + ], + ]; CRM_Utils_System::appendBreadCrumb($breadCrumb); // what action to take ? @@ -112,7 +112,7 @@ public function run() { public function browse() { // get all acl's sorted by weight - $acl = array(); + $acl = []; $query = " SELECT * FROM civicrm_acl @@ -126,7 +126,7 @@ public function browse() { $permissions = CRM_Core_Permission::basicPermissions(); while ($dao->fetch()) { if (!array_key_exists($dao->entity_id, $acl)) { - $acl[$dao->entity_id] = array(); + $acl[$dao->entity_id] = []; $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; @@ -146,7 +146,7 @@ public function browse() { $acl[$dao->entity_id]['action'] = CRM_Core_Action::formLink( self::links(), $action, - array('id' => $dao->entity_id), + ['id' => $dao->entity_id], ts('more'), FALSE, 'aclRole.manage.action', diff --git a/CRM/ACL/Page/EntityRole.php b/CRM/ACL/Page/EntityRole.php index 963f65e93a4f..947e7d78ef1e 100644 --- a/CRM/ACL/Page/EntityRole.php +++ b/CRM/ACL/Page/EntityRole.php @@ -59,30 +59,30 @@ public function getBAOName() { */ public function &links() { if (!(self::$_links)) { - self::$_links = array( - CRM_Core_Action::UPDATE => array( + self::$_links = [ + CRM_Core_Action::UPDATE => [ 'name' => ts('Edit'), 'url' => 'civicrm/acl/entityrole', 'qs' => 'action=update&id=%%id%%', 'title' => ts('Edit ACL Role Assignment'), - ), - CRM_Core_Action::DISABLE => array( + ], + CRM_Core_Action::DISABLE => [ 'name' => ts('Disable'), 'ref' => 'crm-enable-disable', 'title' => ts('Disable ACL Role Assignment'), - ), - CRM_Core_Action::ENABLE => array( + ], + CRM_Core_Action::ENABLE => [ 'name' => ts('Enable'), 'ref' => 'crm-enable-disable', 'title' => ts('Enable ACL Role Assignment'), - ), - CRM_Core_Action::DELETE => array( + ], + CRM_Core_Action::DELETE => [ 'name' => ts('Delete'), 'url' => 'civicrm/acl/entityrole', 'qs' => 'action=delete&id=%%id%%', 'title' => ts('Delete ACL Role Assignment'), - ), - ); + ], + ]; } return self::$_links; } @@ -98,14 +98,12 @@ public function run() { $id = $this->getIdAndAction(); // set breadcrumb to append to admin/access - $breadCrumb = array( - array( + $breadCrumb = [ + [ 'title' => ts('Access Control'), - 'url' => CRM_Utils_System::url('civicrm/admin/access', - 'reset=1' - ), - ), - ); + 'url' => CRM_Utils_System::url('civicrm/admin/access', 'reset=1'), + ], + ]; CRM_Utils_System::appendBreadCrumb($breadCrumb); CRM_Utils_System::setTitle(ts('Assign Users to Roles')); @@ -134,7 +132,7 @@ public function run() { public function browse() { // get all acl's sorted by weight - $entityRoles = array(); + $entityRoles = []; $dao = new CRM_ACL_DAO_EntityRole(); $dao->find(); @@ -142,7 +140,7 @@ public function browse() { $groups = CRM_Core_PseudoConstant::staticGroup(); while ($dao->fetch()) { - $entityRoles[$dao->id] = array(); + $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); @@ -160,7 +158,7 @@ public function browse() { $entityRoles[$dao->id]['action'] = CRM_Core_Action::formLink( self::links(), $action, - array('id' => $dao->id), + ['id' => $dao->id], ts('more'), FALSE, 'entityRole.manage.action', From 96f94695beed8bd791c57278e7b72e3f96e03a62 Mon Sep 17 00:00:00 2001 From: eileen Date: Fri, 5 Apr 2019 17:48:30 +1300 Subject: [PATCH 075/121] Array syntax reformat on activity files --- CRM/Activity/ActionMapping.php | 4 +- CRM/Activity/BAO/Activity.php | 297 +++++++++++++----------- CRM/Activity/BAO/ActivityAssignment.php | 11 +- CRM/Activity/BAO/ActivityContact.php | 28 +-- CRM/Activity/BAO/ActivityTarget.php | 13 +- CRM/Activity/BAO/ICalendar.php | 8 +- CRM/Activity/BAO/Query.php | 126 ++++++---- CRM/Activity/Form/Activity.php | 213 +++++++++-------- CRM/Activity/Import/Form/MapField.php | 104 ++++----- 9 files changed, 444 insertions(+), 360 deletions(-) diff --git a/CRM/Activity/ActionMapping.php b/CRM/Activity/ActionMapping.php index e0577f97e394..9f5dccb1f63a 100644 --- a/CRM/Activity/ActionMapping.php +++ b/CRM/Activity/ActionMapping.php @@ -56,7 +56,7 @@ class CRM_Activity_ActionMapping extends \Civi\ActionSchedule\Mapping { * @param \Civi\ActionSchedule\Event\MappingRegisterEvent $registrations */ public static function onRegisterActionMappings(\Civi\ActionSchedule\Event\MappingRegisterEvent $registrations) { - $registrations->register(CRM_Activity_ActionMapping::create(array( + $registrations->register(CRM_Activity_ActionMapping::create([ 'id' => CRM_Activity_ActionMapping::ACTIVITY_MAPPING_ID, 'entity' => 'civicrm_activity', 'entity_label' => ts('Activity'), @@ -65,7 +65,7 @@ public static function onRegisterActionMappings(\Civi\ActionSchedule\Event\Mappi 'entity_status' => 'activity_status', 'entity_status_label' => ts('Activity Status'), 'entity_date_start' => 'activity_date_time', - ))); + ])); } /** diff --git a/CRM/Activity/BAO/Activity.php b/CRM/Activity/BAO/Activity.php index 9fdcf31deac4..dc66751ca4fa 100644 --- a/CRM/Activity/BAO/Activity.php +++ b/CRM/Activity/BAO/Activity.php @@ -207,7 +207,7 @@ public static function deleteActivity(&$params, $moveToTrash = FALSE) { // CRM-4525 log activity delete $logMsg = 'Case Activity deleted for'; - $msgs = array(); + $msgs = []; $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts); @@ -236,10 +236,10 @@ public static function deleteActivity(&$params, $moveToTrash = FALSE) { // delete the recently created Activity if ($result) { - $activityRecent = array( + $activityRecent = [ 'id' => $activity->id, 'type' => 'Activity', - ); + ]; CRM_Utils_Recent::del($activityRecent); } @@ -361,11 +361,11 @@ public static function create(&$params) { $targetID = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_ActivityContact', 'record_type_id', 'Activity Targets'); if (isset($params['source_contact_id'])) { - $acParams = array( + $acParams = [ 'activity_id' => $activityId, 'contact_id' => $params['source_contact_id'], 'record_type_id' => $sourceID, - ); + ]; self::deleteActivityContact($activityId, $sourceID); CRM_Activity_BAO_ActivityContact::create($acParams); } @@ -377,7 +377,7 @@ public static function create(&$params) { $resultAssignment = NULL; if (!empty($params['assignee_contact_id'])) { - $assignmentParams = array('activity_id' => $activityId); + $assignmentParams = ['activity_id' => $activityId]; if (is_array($params['assignee_contact_id'])) { if (CRM_Utils_Array::value('deleteActivityAssignment', $params, TRUE)) { @@ -387,11 +387,11 @@ public static function create(&$params) { foreach ($params['assignee_contact_id'] as $acID) { if ($acID) { - $assigneeParams = array( + $assigneeParams = [ 'activity_id' => $activityId, 'contact_id' => $acID, 'record_type_id' => $assigneeID, - ); + ]; CRM_Activity_BAO_ActivityContact::create($assigneeParams); } } @@ -430,8 +430,8 @@ public static function create(&$params) { $resultTarget = NULL; if (!empty($params['target_contact_id'])) { - $targetParams = array('activity_id' => $activityId); - $resultTarget = array(); + $targetParams = ['activity_id' => $activityId]; + $resultTarget = []; if (is_array($params['target_contact_id'])) { if (CRM_Utils_Array::value('deleteActivityTarget', $params, TRUE)) { // first delete existing targets if any @@ -440,11 +440,11 @@ public static function create(&$params) { foreach ($params['target_contact_id'] as $tid) { if ($tid) { - $targetContactParams = array( + $targetContactParams = [ 'activity_id' => $activityId, 'contact_id' => $tid, 'record_type_id' => $targetID, - ); + ]; CRM_Activity_BAO_ActivityContact::create($targetContactParams); } } @@ -483,7 +483,7 @@ public static function create(&$params) { $logMsg = "Activity created for "; } - $msgs = array(); + $msgs = []; if (isset($params['source_contact_id'])) { $msgs[] = "source={$params['source_contact_id']}"; } @@ -529,7 +529,7 @@ public static function create(&$params) { $transaction->commit(); if (empty($params['skipRecentView'])) { - $recentOther = array(); + $recentOther = []; if (!empty($params['case_id'])) { $caseContactID = CRM_Core_DAO::getFieldValue('CRM_Case_DAO_CaseContact', $params['case_id'], 'contact_id', 'case_id'); $url = CRM_Utils_System::url('civicrm/case/activity/view', @@ -597,7 +597,7 @@ public static function create(&$params) { CRM_Contact_BAO_GroupContactCache::opportunisticCacheFlush(); // if the subject contains a ‘[case #…]’ string, file that activity on the related case (CRM-5916) - $matches = array(); + $matches = []; $subjectToMatch = CRM_Utils_Array::value('subject', $params); if (preg_match('/\[case #([0-9a-h]{7})\]/', $subjectToMatch, $matches)) { $key = CRM_Core_DAO::escapeString(CIVICRM_SITE_KEY); @@ -608,10 +608,10 @@ public static function create(&$params) { $query = "SELECT id FROM civicrm_case WHERE id = '" . CRM_Core_DAO::escapeString($matches[1]) . "'"; } if (!empty($matches)) { - $caseParams = array( + $caseParams = [ 'activity_id' => $activity->id, 'case_id' => CRM_Core_DAO::singleValueQuery($query), - ); + ]; if ($caseParams['case_id']) { CRM_Case_BAO_Case::processCaseActivity($caseParams); } @@ -646,13 +646,13 @@ public static function logActivityAction($activity, $logMessage = NULL) { $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts); $id = self::getActivityContact($activity->id, $sourceID); } - $logParams = array( + $logParams = [ 'entity_table' => 'civicrm_activity', 'entity_id' => $activity->id, 'modified_id' => $id, 'modified_date' => date('YmdHis'), 'data' => $logMessage, - ); + ]; CRM_Core_BAO_Log::add($logParams); return TRUE; } @@ -677,7 +677,7 @@ public static function logActivityAction($activity, $logMessage = NULL) { * @throws \CiviCRM_API3_Exception */ public static function getActivities($params) { - $activities = array(); + $activities = []; // Activity.Get API params $activityParams = self::getActivityParamsForDashboardFunctions($params); @@ -730,7 +730,7 @@ public static function getActivities($params) { (CRM_Mailing_Info::workflowEnabled() && CRM_Core_Permission::check('create mailings')) ); - $mappingParams = array( + $mappingParams = [ 'id' => 'activity_id', 'source_record_id' => 'source_record_id', 'activity_type_id' => 'activity_type_id', @@ -742,11 +742,11 @@ public static function getActivities($params) { 'source_contact_id' => 'source_contact_id', 'source_contact_name' => 'source_contact_name', 'case_id' => 'case_id', - ); + ]; foreach ($result['values'] as $id => $activity) { - $activities[$id] = array(); + $activities[$id] = []; $isBulkActivity = (!$bulkActivityTypeID || ($bulkActivityTypeID === $activity['activity_type_id'])); $activities[$id]['target_contact_counter'] = count($activity['target_contact_id']); @@ -760,11 +760,14 @@ public static function getActivities($params) { } } foreach ($mappingParams as $apiKey => $expectedName) { - if (in_array($apiKey, array('assignee_contact_name', 'target_contact_name'))) { - $activities[$id][$expectedName] = CRM_Utils_Array::value($apiKey, $activity, array()); + if (in_array($apiKey, [ + 'assignee_contact_name', + 'target_contact_name', + ])) { + $activities[$id][$expectedName] = CRM_Utils_Array::value($apiKey, $activity, []); if ($isBulkActivity) { - $activities[$id]['recipients'] = ts('(%1 recipients)', array(1 => count($activity['target_contact_name']))); + $activities[$id]['recipients'] = ts('(%1 recipients)', [1 => count($activity['target_contact_name'])]); $activities[$id]['mailingId'] = FALSE; if ($accessCiviMail && ($mailingIDs === TRUE || in_array($activity['source_record_id'], $mailingIDs)) @@ -812,7 +815,7 @@ public static function getActivities($params) { * @return array|null (Use in Activity.get API activity_type_id) */ public static function filterActivityTypes($params) { - $activityTypes = array(); + $activityTypes = []; // If no activity types are specified, get all the active ones if (empty($params['activity_type_id'])) { @@ -822,7 +825,7 @@ public static function filterActivityTypes($params) { // If no activity types are specified or excluded, return the list of all active ones if (empty($params['activity_type_id']) && empty($params['activity_type_exclude_id'])) { if (!empty($activityTypes)) { - return array('IN' => array_keys($activityTypes)); + return ['IN' => array_keys($activityTypes)]; } return NULL; } @@ -831,7 +834,7 @@ public static function filterActivityTypes($params) { if (!empty($params['activity_type_id'])) { if (!is_array($params['activity_type_id'])) { // Turn it into array if only one specified, so we don't duplicate processing below - $params['activity_type_id'] = array($params['activity_type_id'] => $params['activity_type_id']); + $params['activity_type_id'] = [$params['activity_type_id'] => $params['activity_type_id']]; } foreach ($params['activity_type_id'] as $value) { // Add each activity type that was specified to list @@ -844,7 +847,7 @@ public static function filterActivityTypes($params) { if (!empty($params['activity_type_exclude_id'])) { if (!is_array($params['activity_type_exclude_id'])) { // Turn it into array if only one specified, so we don't duplicate processing below - $params['activity_type_exclude_id'] = array($params['activity_type_exclude_id'] => $params['activity_type_exclude_id']); + $params['activity_type_exclude_id'] = [$params['activity_type_exclude_id'] => $params['activity_type_exclude_id']]; } foreach ($params['activity_type_exclude_id'] as $value) { // Remove each activity type from list if it should be excluded @@ -855,7 +858,7 @@ public static function filterActivityTypes($params) { } } - return array('IN' => array_keys($activityTypes)); + return ['IN' => array_keys($activityTypes)]; } /** @@ -902,7 +905,7 @@ public function addSelectWhereClause() { * Array of component id and name. */ public static function activityComponents($excludeComponentHandledActivities = TRUE) { - $components = array(); + $components = []; $compInfo = CRM_Core_Component::getEnabledComponents(); foreach ($compInfo as $compObj) { $includeComponent = !$excludeComponentHandledActivities || !empty($compObj->info['showActivitiesInCore']); @@ -1002,7 +1005,7 @@ public static function sendEmail( list($fromDisplayName, $fromEmail, $fromDoNotEmail) = CRM_Contact_BAO_Contact::getContactDetails($userID); if (!$fromEmail) { - return array(count($contactDetails), 0, count($contactDetails)); + return [count($contactDetails), 0, count($contactDetails)]; } if (!trim($fromDisplayName)) { $fromDisplayName = $fromEmail; @@ -1032,7 +1035,7 @@ public static function sendEmail( $details .= $additionalDetails; } - $activityParams = array( + $activityParams = [ 'source_contact_id' => $userID, 'activity_type_id' => $activityTypeID, 'activity_date_time' => date('YmdHis'), @@ -1041,7 +1044,7 @@ public static function sendEmail( // FIXME: check for name Completed and get ID from that lookup 'status_id' => CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'status_id', 'Completed'), 'campaign_id' => $campaignId, - ); + ]; // CRM-5916: strip [case #…] before saving the activity (if present in subject) $activityParams['subject'] = preg_replace('/\[case #([0-9a-h]{7})\] /', '', $activityParams['subject']); @@ -1060,7 +1063,7 @@ public static function sendEmail( $attachments = CRM_Core_BAO_File::getEntityFile('civicrm_activity', $activity->id ); - $returnProperties = array(); + $returnProperties = []; if (isset($messageToken['contact'])) { foreach ($messageToken['contact'] as $key => $value) { $returnProperties[$value] = 1; @@ -1076,7 +1079,7 @@ public static function sendEmail( } // get token details for contacts, call only if tokens are used - $details = array(); + $details = []; if (!empty($returnProperties) || !empty($tokens) || !empty($allTokens)) { list($details) = CRM_Utils_Token::getTokenDetails( $contactIds, @@ -1088,7 +1091,7 @@ public static function sendEmail( } // call token hook - $tokens = array(); + $tokens = []; CRM_Utils_Hook::tokens($tokens); $categories = array_keys($tokens); @@ -1098,7 +1101,7 @@ public static function sendEmail( $escapeSmarty = TRUE; } - $contributionDetails = array(); + $contributionDetails = []; if (!empty($contributionIds)) { $contributionDetails = CRM_Contribute_BAO_Contribution::replaceContributionTokens( $contributionIds, @@ -1111,7 +1114,7 @@ public static function sendEmail( ); } - $sent = $notSent = array(); + $sent = $notSent = []; foreach ($contactDetails as $values) { $contactId = $values['contact_id']; $emailAddress = $values['email']; @@ -1177,7 +1180,7 @@ public static function sendEmail( } } - return array($sent, $activity->id); + return [$sent, $activity->id]; } /** @@ -1195,7 +1198,7 @@ public static function sendEmail( public static function sendSMS( &$contactDetails = NULL, &$activityParams, - &$smsProviderParams = array(), + &$smsProviderParams = [], &$contactIds = NULL, $sourceContactId = NULL ) { @@ -1210,7 +1213,7 @@ public static function sendSMS( if (is_array($contactIds) && !empty($contactIds) && empty($contactDetails)) { foreach ($contactIds as $id) { try { - $contactDetails[] = civicrm_api3('Contact', 'getsingle', array('contact_id' => $id)); + $contactDetails[] = civicrm_api3('Contact', 'getsingle', ['contact_id' => $id]); } catch (Exception $e) { // Contact Id doesn't exist @@ -1231,14 +1234,14 @@ public static function sendSMS( $text = &$activityParams['sms_text_message']; // Create the meta level record first ( sms activity ) - $activityParams = array( + $activityParams = [ 'source_contact_id' => $sourceContactId, 'activity_type_id' => CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'SMS'), 'activity_date_time' => date('YmdHis'), 'subject' => $activityParams['activity_subject'], 'details' => $text, 'status_id' => CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'status_id', 'Completed'), - ); + ]; $activity = self::create($activityParams); $activityID = $activity->id; @@ -1246,18 +1249,18 @@ public static function sendSMS( // token replacement of addressee/email/postal greetings // get the tokens added in subject and message $messageToken = CRM_Utils_Token::getTokens($text); - $returnProperties = array(); + $returnProperties = []; if (isset($messageToken['contact'])) { foreach ($messageToken['contact'] as $key => $value) { $returnProperties[$value] = 1; } } // Call tokens hook - $tokens = array(); + $tokens = []; CRM_Utils_Hook::tokens($tokens); $categories = array_keys($tokens); // get token details for contacts, call only if tokens are used - $tokenDetails = array(); + $tokenDetails = []; if (!empty($returnProperties) || !empty($tokens)) { list($tokenDetails) = CRM_Utils_Token::getTokenDetails($contactIds, $returnProperties, @@ -1268,7 +1271,7 @@ public static function sendSMS( } $success = 0; - $errMsgs = array(); + $errMsgs = []; foreach ($contactDetails as $contact) { $contactId = $contact['contact_id']; @@ -1326,7 +1329,7 @@ public static function sendSMS( $sent = $errMsgs; } - return array($sent, $activity->id, $success); + return [$sent, $activity->id, $success]; } /** @@ -1347,7 +1350,7 @@ public static function sendSMS( public static function sendSMSMessage( $toID, &$tokenText, - $smsProviderParams = array(), + $smsProviderParams = [], $activityID, $sourceContactID = NULL ) { @@ -1358,7 +1361,7 @@ public static function sendSMSMessage( } elseif ($toID) { // No phone number specified, so find a suitable one for the contact - $filters = array('is_deceased' => 0, 'is_deleted' => 0, 'do_not_sms' => 0); + $filters = ['is_deceased' => 0, 'is_deleted' => 0, 'do_not_sms' => 0]; $toPhoneNumbers = CRM_Core_BAO_Phone::allPhones($toID, FALSE, 'Mobile', $filters); // To get primary mobile phonenumber, if not get the first mobile phonenumber if (!empty($toPhoneNumbers)) { @@ -1382,7 +1385,7 @@ public static function sendSMSMessage( $smsProviderParams['contact_id'] = $toID; $smsProviderParams['parent_activity_id'] = $activityID; - $providerObj = CRM_SMS_Provider::singleton(array('provider_id' => $smsProviderParams['provider_id'])); + $providerObj = CRM_SMS_Provider::singleton(['provider_id' => $smsProviderParams['provider_id']]); $sendResult = $providerObj->send($recipient, $smsProviderParams, $tokenText, NULL, $sourceContactID); if (PEAR::isError($sendResult)) { return $sendResult; @@ -1390,11 +1393,11 @@ public static function sendSMSMessage( // add activity target record for every sms that is sent $targetID = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_ActivityContact', 'record_type_id', 'Activity Targets'); - $activityTargetParams = array( + $activityTargetParams = [ 'activity_id' => $activityID, 'contact_id' => $toID, 'record_type_id' => $targetID, - ); + ]; CRM_Activity_BAO_ActivityContact::create($activityTargetParams); return TRUE; @@ -1454,7 +1457,7 @@ public static function sendMessage( $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts); // create the params array - $mailParams = array( + $mailParams = [ 'groupName' => 'Activity Email Sender', 'from' => $from, 'toName' => $toDisplayName, @@ -1465,18 +1468,18 @@ public static function sendMessage( 'text' => $text_message, 'html' => $html_message, 'attachments' => $attachments, - ); + ]; if (!CRM_Utils_Mail::send($mailParams)) { return FALSE; } // add activity target record for every mail that is send - $activityTargetParams = array( + $activityTargetParams = [ 'activity_id' => $activityID, 'contact_id' => $toID, 'record_type_id' => $targetID, - ); + ]; CRM_Activity_BAO_ActivityContact::create($activityTargetParams); return TRUE; } @@ -1496,26 +1499,26 @@ public static function sendMessage( public static function &importableFields($status = FALSE) { if (!self::$_importableFields) { if (!self::$_importableFields) { - self::$_importableFields = array(); + self::$_importableFields = []; } if (!$status) { - $fields = array('' => array('title' => ts('- do not import -'))); + $fields = ['' => ['title' => ts('- do not import -')]]; } else { - $fields = array('' => array('title' => ts('- Activity Fields -'))); + $fields = ['' => ['title' => ts('- Activity Fields -')]]; } $tmpFields = CRM_Activity_DAO_Activity::import(); $contactFields = CRM_Contact_BAO_Contact::importableFields('Individual', NULL); // Using new Dedupe rule. - $ruleParams = array( + $ruleParams = [ 'contact_type' => 'Individual', 'used' => 'Unsupervised', - ); + ]; $fieldsArray = CRM_Dedupe_BAO_Rule::dedupeRuleFields($ruleParams); - $tmpConatctField = array(); + $tmpConatctField = []; if (is_array($fieldsArray)) { foreach ($fieldsArray as $value) { $customFieldId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', @@ -1551,7 +1554,7 @@ public static function &importableFields($status = FALSE) { */ public static function getContactActivity($contactId) { // @todo remove this function entirely. - $activities = array(); + $activities = []; $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts); $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts); @@ -1579,7 +1582,7 @@ public static function getContactActivity($contactId) { $activityIds = array_keys($activities); if (count($activityIds) < 1) { - return array(); + return []; } $activityIds = implode(',', $activityIds); @@ -1628,7 +1631,7 @@ public static function addActivity( &$activity, $activityType = 'Membership Signup', $targetContactID = NULL, - $params = array() + $params = [] ) { $date = date('YmdHis'); if ($activity->__table == 'civicrm_membership') { @@ -1650,10 +1653,10 @@ public static function addActivity( // retrieve existing activity based on source_record_id and activity_type if (empty($params['id'])) { - $params['id'] = CRM_Utils_Array::value('id', civicrm_api3('Activity', 'Get', array( + $params['id'] = CRM_Utils_Array::value('id', civicrm_api3('Activity', 'Get', [ 'source_record_id' => $activity->id, 'activity_type_id' => $activityType, - ))); + ])); } if (!empty($params['id'])) { // CRM-13237 : if activity record found, update it with campaign id of contribution @@ -1663,7 +1666,7 @@ public static function addActivity( $date = CRM_Utils_Date::isoToMysql($activity->receive_date); } - $activityParams = array( + $activityParams = [ 'source_contact_id' => $activity->contact_id, 'source_record_id' => $activity->id, 'activity_type_id' => CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', $activityType), @@ -1672,7 +1675,7 @@ public static function addActivity( 'status_id' => CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_status_id', 'Completed'), 'skipRecentView' => TRUE, 'campaign_id' => $activity->campaign_id, - ); + ]; $activityParams = array_merge($activityParams, $params); if (empty($activityParams['subject'])) { @@ -1771,12 +1774,12 @@ public static function getActivitySubject($entityObj) { * Id of parent activity otherwise false. */ public static function getParentActivity($activityId) { - static $parentActivities = array(); + static $parentActivities = []; $activityId = CRM_Utils_Type::escape($activityId, 'Integer'); if (!array_key_exists($activityId, $parentActivities)) { - $parentActivities[$activityId] = array(); + $parentActivities[$activityId] = []; $parentId = CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $activityId, @@ -1799,12 +1802,12 @@ public static function getParentActivity($activityId) { * $params count of prior activities otherwise false. */ public static function getPriorCount($activityID) { - static $priorCounts = array(); + static $priorCounts = []; $activityID = CRM_Utils_Type::escape($activityID, 'Integer'); if (!array_key_exists($activityID, $priorCounts)) { - $priorCounts[$activityID] = array(); + $priorCounts[$activityID] = []; $originalID = CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $activityID, 'original_id' @@ -1818,7 +1821,7 @@ public static function getPriorCount($activityID) { AND is_current_revision = 0 AND id < {$activityID} "; - $params = array(1 => array($originalID, 'Integer')); + $params = [1 => [$originalID, 'Integer']]; $count = CRM_Core_DAO::singleValueQuery($query, $params); } $priorCounts[$activityID] = $count ? $count : 0; @@ -1838,13 +1841,13 @@ public static function getPriorCount($activityID) { * prior activities info. */ public static function getPriorAcitivities($activityID, $onlyPriorRevisions = FALSE) { - static $priorActivities = array(); + static $priorActivities = []; $activityID = CRM_Utils_Type::escape($activityID, 'Integer'); $index = $activityID . '_' . (int) $onlyPriorRevisions; if (!array_key_exists($index, $priorActivities)) { - $priorActivities[$index] = array(); + $priorActivities[$index] = []; $originalID = CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $activityID, @@ -1867,7 +1870,7 @@ public static function getPriorAcitivities($activityID, $onlyPriorRevisions = FA } $query .= " ORDER BY ca.id DESC"; - $params = array(1 => array($originalID, 'Integer')); + $params = [1 => [$originalID, 'Integer']]; $dao = CRM_Core_DAO::executeQuery($query, $params); while ($dao->fetch()) { @@ -1890,12 +1893,12 @@ public static function getPriorAcitivities($activityID, $onlyPriorRevisions = FA * current activity id. */ public static function getLatestActivityId($activityID) { - static $latestActivityIds = array(); + static $latestActivityIds = []; $activityID = CRM_Utils_Type::escape($activityID, 'Integer'); if (!array_key_exists($activityID, $latestActivityIds)) { - $latestActivityIds[$activityID] = array(); + $latestActivityIds[$activityID] = []; $originalID = CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $activityID, @@ -1904,7 +1907,7 @@ public static function getLatestActivityId($activityID) { if ($originalID) { $activityID = $originalID; } - $params = array(1 => array($activityID, 'Integer')); + $params = [1 => [$activityID, 'Integer']]; $query = "SELECT id from civicrm_activity where original_id = %1 and is_current_revision = 1"; $latestActivityIds[$activityID] = CRM_Core_DAO::singleValueQuery($query, $params); @@ -1927,7 +1930,7 @@ public static function createFollowupActivity($activityId, $params) { return NULL; } - $followupParams = array(); + $followupParams = []; $followupParams['parent_id'] = $activityId; $followupParams['source_contact_id'] = CRM_Core_Session::getLoggedInContactID(); $followupParams['status_id'] = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_status_id', 'Scheduled'); @@ -2011,14 +2014,14 @@ public static function restoreActivity(&$params) { */ public static function getStatusesByType($type) { if (!isset(Civi::$statics[__CLASS__][__FUNCTION__])) { - $statuses = civicrm_api3('OptionValue', 'get', array( + $statuses = civicrm_api3('OptionValue', 'get', [ 'option_group_id' => 'activity_status', - 'return' => array('value', 'name', 'filter'), - 'options' => array('limit' => 0), - )); + 'return' => ['value', 'name', 'filter'], + 'options' => ['limit' => 0], + ]); Civi::$statics[__CLASS__][__FUNCTION__] = $statuses['values']; } - $ret = array(); + $ret = []; foreach (Civi::$statics[__CLASS__][__FUNCTION__] as $status) { if ($status['filter'] == $type) { $ret[$status['value']] = $status['name']; @@ -2048,7 +2051,7 @@ public static function isOverdue($activity) { * array of exportable Fields */ public static function exportableFields($name = 'Activity') { - self::$_exportableFields[$name] = array(); + self::$_exportableFields[$name] = []; // TODO: ideally we should retrieve all fields from xml, in this case since activity processing is done // my case hence we have defined fields as case_* @@ -2058,53 +2061,77 @@ public static function exportableFields($name = 'Activity') { 'title' => ts('Source Contact ID'), 'type' => CRM_Utils_Type::T_INT, ]; - $exportableFields['source_contact'] = array( + $exportableFields['source_contact'] = [ 'title' => ts('Source Contact'), 'type' => CRM_Utils_Type::T_STRING, - ); + ]; - $Activityfields = array( - 'activity_type' => array( + $Activityfields = [ + 'activity_type' => [ 'title' => ts('Activity Type'), 'name' => 'activity_type', 'type' => CRM_Utils_Type::T_STRING, 'searchByLabel' => TRUE, - ), - 'activity_status' => array( + ], + 'activity_status' => [ 'title' => ts('Activity Status'), 'name' => 'activity_status', 'type' => CRM_Utils_Type::T_STRING, 'searchByLabel' => TRUE, - ), - 'activity_priority' => array( + ], + 'activity_priority' => [ 'title' => ts('Activity Priority'), 'name' => 'activity_priority', 'type' => CRM_Utils_Type::T_STRING, 'searchByLabel' => TRUE, - ), - ); + ], + ]; $fields = array_merge($Activityfields, $exportableFields); } else { // Set title to activity fields. - $fields = array( - 'case_activity_subject' => array('title' => ts('Activity Subject'), 'type' => CRM_Utils_Type::T_STRING), - 'case_source_contact_id' => array('title' => ts('Activity Reporter'), 'type' => CRM_Utils_Type::T_STRING), - 'case_recent_activity_date' => array('title' => ts('Activity Actual Date'), 'type' => CRM_Utils_Type::T_DATE), - 'case_scheduled_activity_date' => array( + $fields = [ + 'case_activity_subject' => [ + 'title' => ts('Activity Subject'), + 'type' => CRM_Utils_Type::T_STRING, + ], + 'case_source_contact_id' => [ + 'title' => ts('Activity Reporter'), + 'type' => CRM_Utils_Type::T_STRING, + ], + 'case_recent_activity_date' => [ + 'title' => ts('Activity Actual Date'), + 'type' => CRM_Utils_Type::T_DATE, + ], + 'case_scheduled_activity_date' => [ 'title' => ts('Activity Scheduled Date'), 'type' => CRM_Utils_Type::T_DATE, - ), - 'case_recent_activity_type' => array('title' => ts('Activity Type'), 'type' => CRM_Utils_Type::T_STRING), - 'case_activity_status' => array('title' => ts('Activity Status'), 'type' => CRM_Utils_Type::T_STRING), - 'case_activity_duration' => array('title' => ts('Activity Duration'), 'type' => CRM_Utils_Type::T_INT), - 'case_activity_medium_id' => array('title' => ts('Activity Medium'), 'type' => CRM_Utils_Type::T_INT), - 'case_activity_details' => array('title' => ts('Activity Details'), 'type' => CRM_Utils_Type::T_TEXT), - 'case_activity_is_auto' => array( + ], + 'case_recent_activity_type' => [ + 'title' => ts('Activity Type'), + 'type' => CRM_Utils_Type::T_STRING, + ], + 'case_activity_status' => [ + 'title' => ts('Activity Status'), + 'type' => CRM_Utils_Type::T_STRING, + ], + 'case_activity_duration' => [ + 'title' => ts('Activity Duration'), + 'type' => CRM_Utils_Type::T_INT, + ], + 'case_activity_medium_id' => [ + 'title' => ts('Activity Medium'), + 'type' => CRM_Utils_Type::T_INT, + ], + 'case_activity_details' => [ + 'title' => ts('Activity Details'), + 'type' => CRM_Utils_Type::T_TEXT, + ], + 'case_activity_is_auto' => [ 'title' => ts('Activity Auto-generated?'), 'type' => CRM_Utils_Type::T_BOOLEAN, - ), - ); + ], + ]; } // add custom data for case activities @@ -2122,7 +2149,7 @@ public static function exportableFields($name = 'Activity') { */ public static function getProfileFields() { $exportableFields = self::exportableFields('Activity'); - $skipFields = array( + $skipFields = [ 'activity_id', 'activity_type', 'source_contact_id', @@ -2131,7 +2158,7 @@ public static function getProfileFields() { 'activity_is_test', 'is_current_revision', 'activity_is_deleted', - ); + ]; $config = CRM_Core_Config::singleton(); if (!in_array('CiviCampaign', $config->enableComponents)) { $skipFields[] = 'activity_engagement_level'; @@ -2187,7 +2214,7 @@ public static function cleanupActivity($contactId) { // delete activity only if no other contacts connected if (!$activityContactOther->find(TRUE)) { - $activityParams = array('id' => $activityContact->activity_id); + $activityParams = ['id' => $activityContact->activity_id]; $result = self::deleteActivity($activityParams); } @@ -2211,7 +2238,7 @@ public static function cleanupActivity($contactId) { public static function checkPermission($activityId, $action) { if (!$activityId || - !in_array($action, array(CRM_Core_Action::UPDATE, CRM_Core_Action::VIEW)) + !in_array($action, [CRM_Core_Action::UPDATE, CRM_Core_Action::VIEW]) ) { return FALSE; } @@ -2377,7 +2404,7 @@ protected static function getActivityParamsForDashboardFunctions($params) { // @todo - should we move this to activity get api. foreach ([ 'case_id' => 'CiviCase', - 'campaign_id' => 'CiviCampaign' + 'campaign_id' => 'CiviCampaign', ] as $attr => $component) { if (!in_array($component, $enabledComponents)) { $activityParams[$attr] = ['IS NULL' => 1]; @@ -2419,11 +2446,11 @@ public static function getContactActivitySelector(&$params) { $params['caseId'] = NULL; $context = CRM_Utils_Array::value('context', $params); $showContactOverlay = !CRM_Utils_String::startsWith($context, "dashlet"); - $activityTypeInfo = civicrm_api3('OptionValue', 'get', array( + $activityTypeInfo = civicrm_api3('OptionValue', 'get', [ 'option_group_id' => "activity_type", - 'options' => array('limit' => 0), - )); - $activityIcons = array(); + 'options' => ['limit' => 0], + ]); + $activityIcons = []; foreach ($activityTypeInfo['values'] as $type) { if (!empty($type['icon'])) { $activityIcons[$type['value']] = $type['icon']; @@ -2438,7 +2465,7 @@ public static function getContactActivitySelector(&$params) { $params['total'] = CRM_Activity_BAO_Activity::getActivitiesCount($params); // Format params and add links. - $contactActivities = array(); + $contactActivities = []; if (!empty($activities)) { $activityStatus = CRM_Core_PseudoConstant::activityStatus(); @@ -2446,7 +2473,7 @@ public static function getContactActivitySelector(&$params) { // Check logged in user for permission. $page = new CRM_Core_Page(); CRM_Contact_Page_View::checkUserPermission($page, $params['contact_id']); - $permissions = array($page->_permission); + $permissions = [$page->_permission]; if (CRM_Core_Permission::check('delete activities')) { $permissions[] = CRM_Core_Permission::DELETE; } @@ -2465,7 +2492,7 @@ public static function getContactActivitySelector(&$params) { $activity['DT_RowClass'] .= ' status-ontime'; } - $activity['DT_RowAttr'] = array(); + $activity['DT_RowAttr'] = []; $activity['DT_RowAttr']['data-entity'] = 'activity'; $activity['DT_RowAttr']['data-id'] = $activityId; @@ -2484,7 +2511,7 @@ public static function getContactActivitySelector(&$params) { $values['source_contact_id']); } $activity['source_contact_name'] = $srcTypeImage . CRM_Utils_System::href($values['source_contact_name'], - 'civicrm/contact/view', "reset=1&cid={$values['source_contact_id']}"); + 'civicrm/contact/view', "reset=1&cid={$values['source_contact_id']}"); } else { $activity['source_contact_name'] = 'n/a'; @@ -2516,7 +2543,7 @@ public static function getContactActivitySelector(&$params) { } if ($extraCount = $values['target_contact_counter'] - 1) { - $activity['target_contact_name'] .= ";
" . "(" . ts('%1 more', array(1 => $extraCount)) . ")"; + $activity['target_contact_name'] .= ";
" . "(" . ts('%1 more', [1 => $extraCount]) . ")"; } if ($showContactOverlay) { $activity['target_contact_name'] .= "
"; @@ -2585,12 +2612,12 @@ public static function getContactActivitySelector(&$params) { $activity['links'] = CRM_Core_Action::formLink($actionLinks, $actionMask, - array( + [ 'id' => $values['activity_id'], 'cid' => $params['contact_id'], 'cxt' => $context, 'caseid' => CRM_Utils_Array::value('case_id', $values), - ), + ], ts('more'), FALSE, 'activity.tab.row', @@ -2606,7 +2633,7 @@ public static function getContactActivitySelector(&$params) { } } - $activitiesDT = array(); + $activitiesDT = []; $activitiesDT['data'] = $contactActivities; $activitiesDT['recordsTotal'] = $params['total']; $activitiesDT['recordsFiltered'] = $params['total']; @@ -2623,7 +2650,7 @@ public static function getContactActivitySelector(&$params) { */ public static function copyExtendedActivityData($params) { // attach custom data to the new activity - $customParams = $htmlType = array(); + $customParams = $htmlType = []; $customValues = CRM_Core_BAO_CustomValueTable::getEntityValues($params['activityID'], 'Activity'); if (!empty($customValues)) { @@ -2640,10 +2667,10 @@ public static function copyExtendedActivityData($params) { // CRM-10542 if (in_array($key, $htmlType)) { $fileValues = CRM_Core_BAO_File::path($value, $params['activityID']); - $customParams["custom_{$key}_-1"] = array( + $customParams["custom_{$key}_-1"] = [ 'name' => $fileValues[0], 'type' => $fileValues[1], - ); + ]; } else { $customParams["custom_{$key}_-1"] = $value; @@ -2726,7 +2753,7 @@ public function setApiFilter(&$params) { * * @return bool */ - public static function sendToAssignee($activity, $mailToContacts, $params = array()) { + 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); diff --git a/CRM/Activity/BAO/ActivityAssignment.php b/CRM/Activity/BAO/ActivityAssignment.php index dab57c94e60a..87420a3dc79f 100644 --- a/CRM/Activity/BAO/ActivityAssignment.php +++ b/CRM/Activity/BAO/ActivityAssignment.php @@ -71,7 +71,7 @@ public static function create(&$params) { * @return array */ public static function retrieveAssigneeIdsByActivityId($activity_id) { - $assigneeArray = array(); + $assigneeArray = []; if (!CRM_Utils_Rule::positiveInteger($activity_id)) { return $assigneeArray; } @@ -87,7 +87,12 @@ public static function retrieveAssigneeIdsByActivityId($activity_id) { AND record_type_id = $assigneeID AND civicrm_contact.is_deleted = 0 "; - $assignment = CRM_Core_DAO::executeQuery($sql, array(1 => array($activity_id, 'Integer'))); + $assignment = CRM_Core_DAO::executeQuery($sql, [ + 1 => [ + $activity_id, + 'Integer', + ], + ]); while ($assignment->fetch()) { $assigneeArray[] = $assignment->contact_id; } @@ -108,7 +113,7 @@ public static function retrieveAssigneeIdsByActivityId($activity_id) { * @return array */ public static function getAssigneeNames($activityIDs, $isDisplayName = FALSE, $skipDetails = TRUE) { - $assigneeNames = array(); + $assigneeNames = []; if (empty($activityIDs)) { return $assigneeNames; } diff --git a/CRM/Activity/BAO/ActivityContact.php b/CRM/Activity/BAO/ActivityContact.php index 393f3bbb48c6..f12a86b20520 100644 --- a/CRM/Activity/BAO/ActivityContact.php +++ b/CRM/Activity/BAO/ActivityContact.php @@ -72,11 +72,11 @@ public static function create(&$params) { * @return array */ public static function getNames($activityID, $recordTypeID, $alsoIDs = FALSE) { - $names = array(); - $ids = array(); + $names = []; + $ids = []; if (empty($activityID)) { - return $alsoIDs ? array($names, $ids) : $names; + return $alsoIDs ? [$names, $ids] : $names; } $query = " @@ -87,10 +87,10 @@ public static function getNames($activityID, $recordTypeID, $alsoIDs = FALSE) { AND civicrm_activity_contact.record_type_id = %2 AND contact_a.is_deleted = 0 "; - $params = array( - 1 => array($activityID, 'Integer'), - 2 => array($recordTypeID, 'Integer'), - ); + $params = [ + 1 => [$activityID, 'Integer'], + 2 => [$recordTypeID, 'Integer'], + ]; $dao = CRM_Core_DAO::executeQuery($query, $params); while ($dao->fetch()) { @@ -98,7 +98,7 @@ public static function getNames($activityID, $recordTypeID, $alsoIDs = FALSE) { $ids[] = $dao->id; } - return $alsoIDs ? array($names, $ids) : $names; + return $alsoIDs ? [$names, $ids] : $names; } /** @@ -110,7 +110,7 @@ public static function getNames($activityID, $recordTypeID, $alsoIDs = FALSE) { * @return mixed */ public static function retrieveContactIdsByActivityId($activityID, $recordTypeID) { - $activityContact = array(); + $activityContact = []; if (!CRM_Utils_Rule::positiveInteger($activityID) || !CRM_Utils_Rule::positiveInteger($recordTypeID) ) { @@ -124,10 +124,10 @@ public static function retrieveContactIdsByActivityId($activityID, $recordTypeID AND record_type_id = %2 AND civicrm_contact.is_deleted = 0 "; - $params = array( - 1 => array($activityID, 'Integer'), - 2 => array($recordTypeID, 'Integer'), - ); + $params = [ + 1 => [$activityID, 'Integer'], + 2 => [$recordTypeID, 'Integer'], + ]; $dao = CRM_Core_DAO::executeQuery($sql, $params); while ($dao->fetch()) { @@ -152,7 +152,7 @@ public static function retrieveContactIdsByActivityId($activityID, $recordTypeID * null - if no links.ini exists for this database (hence try auto_links). */ public function links() { - $link = array('activity_id' => 'civicrm_activity:id'); + $link = ['activity_id' => 'civicrm_activity:id']; return $link; } diff --git a/CRM/Activity/BAO/ActivityTarget.php b/CRM/Activity/BAO/ActivityTarget.php index 7aba449f7800..167857d1c33d 100644 --- a/CRM/Activity/BAO/ActivityTarget.php +++ b/CRM/Activity/BAO/ActivityTarget.php @@ -69,7 +69,7 @@ public static function create(&$params) { * @return mixed */ public static function retrieveTargetIdsByActivityId($activity_id) { - $targetArray = array(); + $targetArray = []; if (!CRM_Utils_Rule::positiveInteger($activity_id)) { return $targetArray; } @@ -85,7 +85,12 @@ public static function retrieveTargetIdsByActivityId($activity_id) { AND record_type_id = $targetID AND civicrm_contact.is_deleted = 0 "; - $target = CRM_Core_DAO::executeQuery($sql, array(1 => array($activity_id, 'Integer'))); + $target = CRM_Core_DAO::executeQuery($sql, [ + 1 => [ + $activity_id, + 'Integer', + ], + ]); while ($target->fetch()) { $targetArray[] = $target->contact_id; } @@ -100,7 +105,7 @@ public static function retrieveTargetIdsByActivityId($activity_id) { * @return array */ public static function getTargetNames($activityID) { - $targetNames = array(); + $targetNames = []; if (empty($activityID)) { return $targetNames; @@ -116,7 +121,7 @@ public static function getTargetNames($activityID) { AND civicrm_activity_contact.record_type_id = $targetID AND contact_a.is_deleted = 0 "; - $queryParam = array(1 => array($activityID, 'Integer')); + $queryParam = [1 => [$activityID, 'Integer']]; $dao = CRM_Core_DAO::executeQuery($query, $queryParam); while ($dao->fetch()) { diff --git a/CRM/Activity/BAO/ICalendar.php b/CRM/Activity/BAO/ICalendar.php index 41b5698c3217..4ebc2b0b54bd 100644 --- a/CRM/Activity/BAO/ICalendar.php +++ b/CRM/Activity/BAO/ICalendar.php @@ -86,14 +86,14 @@ public function addAttachment(&$attachments, $contacts) { $calendar = $template->fetch('CRM/Activity/Calendar/ICal.tpl'); if (file_put_contents($this->icsfile, $calendar) !== FALSE) { if (empty($attachments)) { - $attachments = array(); + $attachments = []; } - $attachments['activity_ics'] = array( + $attachments['activity_ics'] = [ 'mime_type' => 'text/calendar', 'fileName' => $icsFileName, 'cleanName' => $icsFileName, 'fullPath' => $this->icsfile, - ); + ]; return 'activity_ics'; } } @@ -105,7 +105,7 @@ public function addAttachment(&$attachments, $contacts) { * Remove temp file. */ public function cleanup() { - if (!empty ($this->icsfile)) { + if (!empty($this->icsfile)) { @unlink($this->icsfile); } } diff --git a/CRM/Activity/BAO/Query.php b/CRM/Activity/BAO/Query.php index 3477ffef6ac6..8851d2fe351d 100644 --- a/CRM/Activity/BAO/Query.php +++ b/CRM/Activity/BAO/Query.php @@ -211,22 +211,30 @@ public static function whereClauseSingle(&$values, &$query) { case 'activity_subject': $qillName = $name; - if (in_array($name, array('activity_engagement_level', 'activity_id'))) { + if (in_array($name, ['activity_engagement_level', 'activity_id'])) { $name = $qillName = str_replace('activity_', '', $name); } - if (in_array($name, array('activity_status_id', 'activity_subject', 'activity_priority_id'))) { + if (in_array($name, [ + 'activity_status_id', + 'activity_subject', + 'activity_priority_id', + ])) { $name = str_replace('activity_', '', $name); $qillName = str_replace('_id', '', $qillName); } if ($name == 'activity_campaign_id') { - $name = 'campaign_id'; + $name = 'campaign_id'; } $dataType = !empty($fields[$qillName]['type']) ? CRM_Utils_Type::typeToString($fields[$qillName]['type']) : 'String'; $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_activity.$name", $op, $value, $dataType); list($op, $value) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Activity_DAO_Activity', $name, $value, $op); - $query->_qill[$grouping][] = ts('%1 %2 %3', array(1 => $fields[$qillName]['title'], 2 => $op, 3 => $value)); + $query->_qill[$grouping][] = ts('%1 %2 %3', [ + 1 => $fields[$qillName]['title'], + 2 => $op, + 3 => $value, + ]); break; case 'activity_text': @@ -238,7 +246,11 @@ public static function whereClauseSingle(&$values, &$query) { case 'activity_priority': $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("$name.label", $op, $value, 'String'); list($op, $value) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Activity_DAO_Activity', $name, $value, $op); - $query->_qill[$grouping][] = ts('%1 %2 %3', array(1 => $fields[$name]['title'], 2 => $op, 3 => $value)); + $query->_qill[$grouping][] = ts('%1 %2 %3', [ + 1 => $fields[$name]['title'], + 2 => $op, + 3 => $value, + ]); $query->_tables[$name] = $query->_whereTables[$name] = 1; break; @@ -291,13 +303,16 @@ public static function whereClauseSingle(&$values, &$query) { case 'activity_date_time_low': case 'activity_date_time_high': $query->dateQueryBuilder($values, - 'civicrm_activity', str_replace(['_high', '_low'], '', $name), 'activity_date_time', ts('Activity Date') + 'civicrm_activity', str_replace([ + '_high', + '_low', + ], '', $name), 'activity_date_time', ts('Activity Date') ); break; case 'activity_taglist': $taglist = $value; - $value = array(); + $value = []; foreach ($taglist as $val) { if ($val) { $val = explode(',', $val); @@ -311,16 +326,16 @@ public static function whereClauseSingle(&$values, &$query) { case 'activity_tags': $value = array_keys($value); - $activityTags = CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE)); + $activityTags = CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', ['onlyActive' => FALSE]); - $names = array(); + $names = []; if (is_array($value)) { foreach ($value as $k => $v) { $names[] = $activityTags[$v]; } } $query->_where[$grouping][] = "civicrm_activity_tag.tag_id IN (" . implode(",", $value) . ")"; - $query->_qill[$grouping][] = ts('Activity Tag %1', array(1 => $op)) . ' ' . implode(' ' . ts('OR') . ' ', $names); + $query->_qill[$grouping][] = ts('Activity Tag %1', [1 => $op]) . ' ' . implode(' ' . ts('OR') . ' ', $names); $query->_tables['civicrm_activity_tag'] = $query->_whereTables['civicrm_activity_tag'] = 1; break; @@ -331,7 +346,7 @@ public static function whereClauseSingle(&$values, &$query) { $safe[] = "'" . CRM_Utils_Type::escape($k, 'String') . "'"; } $query->_where[$grouping][] = "civicrm_activity.result IN (" . implode(',', $safe) . ")"; - $query->_qill[$grouping][] = ts("Activity Result - %1", array(1 => implode(' or ', $safe))); + $query->_qill[$grouping][] = ts("Activity Result - %1", [1 => implode(' or ', $safe)]); } break; @@ -362,7 +377,11 @@ public static function whereClauseSingle(&$values, &$query) { $columnName = strstr($name, '_id') ? 'id' : 'sort_name'; $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("source_contact.{$columnName}", $op, $value, CRM_Utils_Type::typeToString($fields[$name]['type'])); list($op, $value) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Contact_DAO_Contact', $columnName, $value, $op); - $query->_qill[$grouping][] = ts('%1 %2 %3', array(1 => $fields[$name]['title'], 2 => $op, 3 => $value)); + $query->_qill[$grouping][] = ts('%1 %2 %3', [ + 1 => $fields[$name]['title'], + 2 => $op, + 3 => $value, + ]); break; } } @@ -456,39 +475,53 @@ public static function buildSearchForm(&$form) { $form->addSearchFieldMetadata(['Activity' => self::getSearchFieldMetadata()]); $form->addFormFieldsFromMetadata(); - $followUpActivity = array( + $followUpActivity = [ 1 => ts('Yes'), 2 => ts('No'), - ); - $form->addRadio('parent_id', NULL, $followUpActivity, array('allowClear' => TRUE)); - $form->addRadio('followup_parent_id', NULL, $followUpActivity, array('allowClear' => TRUE)); - $activityRoles = array( + ]; + $form->addRadio('parent_id', NULL, $followUpActivity, ['allowClear' => TRUE]); + $form->addRadio('followup_parent_id', NULL, $followUpActivity, ['allowClear' => TRUE]); + $activityRoles = [ 3 => ts('With'), 2 => ts('Assigned to'), 1 => ts('Added by'), - ); - $form->addRadio('activity_role', NULL, $activityRoles, array('allowClear' => TRUE)); - $form->setDefaults(array('activity_role' => 3)); - $activityStatus = CRM_Core_PseudoConstant::get('CRM_Activity_DAO_Activity', 'status_id', array('flip' => 1, 'labelColumn' => 'name')); + ]; + $form->addRadio('activity_role', NULL, $activityRoles, ['allowClear' => TRUE]); + $form->setDefaults(['activity_role' => 3]); + $activityStatus = CRM_Core_PseudoConstant::get('CRM_Activity_DAO_Activity', 'status_id', [ + 'flip' => 1, + 'labelColumn' => 'name', + ]); $form->addSelect('status_id', - array('entity' => 'activity', 'multiple' => 'multiple', 'option_url' => NULL, 'placeholder' => ts('- any -')) + [ + 'entity' => 'activity', + 'multiple' => 'multiple', + 'option_url' => NULL, + 'placeholder' => ts('- any -'), + ] ); $ssID = $form->get('ssID'); - $status = array($activityStatus['Completed'], $activityStatus['Scheduled']); + $status = [$activityStatus['Completed'], $activityStatus['Scheduled']]; //If status is saved in smart group. if (!empty($ssID) && !empty($form->_formValues['activity_status_id'])) { $status = $form->_formValues['activity_status_id']; } - $form->setDefaults(array('status_id' => $status)); + $form->setDefaults(['status_id' => $status]); $form->addElement('text', 'activity_text', ts('Activity Text'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name')); $form->addRadio('activity_option', '', CRM_Core_SelectValues::activityTextOptions()); - $form->setDefaults(array('activity_option' => 'both')); + $form->setDefaults(['activity_option' => 'both']); $priority = CRM_Core_PseudoConstant::get('CRM_Activity_DAO_Activity', 'priority_id'); $form->addSelect('priority_id', - array('entity' => 'activity', 'label' => ts('Priority'), 'multiple' => 'multiple', 'option_url' => NULL, 'placeholder' => ts('- any -')) + [ + 'entity' => 'activity', + 'label' => ts('Priority'), + 'multiple' => 'multiple', + 'option_url' => NULL, + 'placeholder' => ts('- any -'), + ] ); $form->addYesNo('activity_test', ts('Activity is a Test?')); @@ -507,12 +540,12 @@ public static function buildSearchForm(&$form) { $surveys = CRM_Campaign_BAO_Survey::getSurveys(TRUE, FALSE, FALSE, TRUE); if ($surveys) { $form->add('select', 'activity_survey_id', ts('Survey / Petition'), - array('' => ts('- none -')) + $surveys, FALSE, - array('class' => 'crm-select2') - ); + ['' => ts('- none -')] + $surveys, FALSE, + ['class' => 'crm-select2'] + ); } - CRM_Core_BAO_Query::addCustomFormFields($form, array('Activity')); + CRM_Core_BAO_Query::addCustomFormFields($form, ['Activity']); CRM_Campaign_BAO_Campaign::addCampaignInComponentSearch($form, 'activity_campaign_id'); @@ -523,11 +556,14 @@ public static function buildSearchForm(&$form) { CRM_Campaign_BAO_Campaign::accessCampaign() ) { $buildEngagementLevel = TRUE; - $form->addSelect('activity_engagement_level', array('entity' => 'activity', 'context' => 'search')); + $form->addSelect('activity_engagement_level', [ + 'entity' => 'activity', + 'context' => 'search', + ]); // Add survey result field. $optionGroups = CRM_Campaign_BAO_Survey::getResultSets('name'); - $resultOptions = array(); + $resultOptions = []; foreach ($optionGroups as $gid => $name) { if ($name) { $value = CRM_Core_OptionGroup::values($name); @@ -545,14 +581,18 @@ public static function buildSearchForm(&$form) { asort($resultOptions); $form->add('select', 'activity_result', ts("Survey Result"), $resultOptions, FALSE, - array('id' => 'activity_result', 'multiple' => 'multiple', 'class' => 'crm-select2') + [ + 'id' => 'activity_result', + 'multiple' => 'multiple', + 'class' => 'crm-select2', + ] ); } } $form->assign('buildEngagementLevel', $buildEngagementLevel); $form->assign('buildSurveyResult', $buildSurveyResult); - $form->setDefaults(array('activity_test' => 0)); + $form->setDefaults(['activity_test' => 0]); } /** @@ -564,7 +604,7 @@ public static function buildSearchForm(&$form) { public static function defaultReturnProperties($mode, $includeCustomFields = TRUE) { $properties = NULL; if ($mode & CRM_Contact_BAO_Query::MODE_ACTIVITY) { - $properties = array( + $properties = [ 'activity_id' => 1, 'contact_type' => 1, 'contact_sub_type' => 1, @@ -586,7 +626,7 @@ public static function defaultReturnProperties($mode, $includeCustomFields = TRU 'result' => 1, 'activity_engagement_level' => 1, 'parent_id' => 1, - ); + ]; if ($includeCustomFields) { // also get all the custom activity properties @@ -609,7 +649,7 @@ public static function defaultReturnProperties($mode, $includeCustomFields = TRU * kills a small kitten so add carefully. */ public static function selectorReturnProperties() { - $properties = array( + $properties = [ 'activity_id' => 1, 'contact_type' => 1, 'contact_sub_type' => 1, @@ -624,7 +664,7 @@ public static function selectorReturnProperties() { 'activity_is_test' => 1, 'activity_campaign_id' => 1, 'activity_engagement_level' => 1, - ); + ]; return $properties; } @@ -641,8 +681,8 @@ public static function whereClauseSingleActivityText(&$values, &$query) { $query->_useDistinct = TRUE; - $label = ts('Activity Text (%1)', array(1 => CRM_Utils_Array::value($activityOption, CRM_Core_SelectValues::activityTextOptions()))); - $clauses = array(); + $label = ts('Activity Text (%1)', [1 => CRM_Utils_Array::value($activityOption, CRM_Core_SelectValues::activityTextOptions())]); + $clauses = []; if ($activityOption % 2 == 0) { $clauses[] = $query->buildClause('civicrm_activity.details', $op, $value, 'String'); } @@ -652,7 +692,11 @@ public static function whereClauseSingleActivityText(&$values, &$query) { $query->_where[$grouping][] = "( " . implode(' OR ', $clauses) . " )"; list($qillOp, $qillVal) = $query->buildQillForFieldValue(NULL, $name, $value, $op); - $query->_qill[$grouping][] = ts("%1 %2 '%3'", array(1 => $label, 2 => $qillOp, 3 => $qillVal)); + $query->_qill[$grouping][] = ts("%1 %2 '%3'", [ + 1 => $label, + 2 => $qillOp, + 3 => $qillVal, + ]); } } diff --git a/CRM/Activity/Form/Activity.php b/CRM/Activity/Form/Activity.php index 94f68c1203e8..b3e65e0c8732 100644 --- a/CRM/Activity/Form/Activity.php +++ b/CRM/Activity/Form/Activity.php @@ -48,7 +48,7 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task { * * @var int */ - public $_activityIds = array(); + public $_activityIds = []; /** * The id of activity type. @@ -115,7 +115,7 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task { */ protected $_isSurveyActivity; - protected $_values = array(); + protected $_values = []; protected $unsavedWarn = TRUE; @@ -154,88 +154,84 @@ public function setFields() { $unwanted = CRM_Core_OptionGroup::values('activity_type', FALSE, FALSE, FALSE, "AND v.name = 'Print PDF Letter'"); $activityTypes = array_diff_key(CRM_Core_PseudoConstant::ActivityType(FALSE), $unwanted); - $this->_fields = array( - 'subject' => array( + $this->_fields = [ + 'subject' => [ 'type' => 'text', 'label' => ts('Subject'), - 'attributes' => CRM_Core_DAO::getAttribute('CRM_Activity_DAO_Activity', - 'activity_subject' - ), - ), - 'duration' => array( + 'attributes' => CRM_Core_DAO::getAttribute('CRM_Activity_DAO_Activity', 'activity_subject'), + ], + 'duration' => [ 'type' => 'number', 'label' => ts('Duration'), - 'attributes' => array('class' => 'four', 'min' => 1), + 'attributes' => ['class' => 'four', 'min' => 1], 'required' => FALSE, - ), - 'location' => array( + ], + 'location' => [ 'type' => 'text', 'label' => ts('Location'), 'attributes' => CRM_Core_DAO::getAttribute('CRM_Activity_DAO_Activity', 'location'), 'required' => FALSE, - ), - 'details' => array( + ], + 'details' => [ 'type' => 'wysiwyg', 'label' => ts('Details'), - 'attributes' => array('class' => 'huge'), + 'attributes' => ['class' => 'huge'], 'required' => FALSE, - ), - 'status_id' => array( + ], + 'status_id' => [ 'type' => 'select', 'required' => TRUE, - ), - 'priority_id' => array( + ], + 'priority_id' => [ 'type' => 'select', 'required' => TRUE, - ), - 'source_contact_id' => array( + ], + 'source_contact_id' => [ 'type' => 'entityRef', 'label' => ts('Added By'), 'required' => FALSE, - ), - 'target_contact_id' => array( + ], + 'target_contact_id' => [ 'type' => 'entityRef', 'label' => ts('With Contact'), - 'attributes' => array('multiple' => TRUE, 'create' => TRUE), - ), - 'assignee_contact_id' => array( + 'attributes' => ['multiple' => TRUE, 'create' => TRUE], + ], + 'assignee_contact_id' => [ 'type' => 'entityRef', 'label' => ts('Assigned to'), - 'attributes' => array( + 'attributes' => [ 'multiple' => TRUE, 'create' => TRUE, - 'api' => array('params' => array('is_deceased' => 0)), - ), - ), - 'activity_date_time' => array( + 'api' => ['params' => ['is_deceased' => 0]], + ], + ], + 'activity_date_time' => [ 'type' => 'datepicker', 'label' => ts('Date'), 'required' => TRUE, - ), - 'followup_assignee_contact_id' => array( + ], + 'followup_assignee_contact_id' => [ 'type' => 'entityRef', 'label' => ts('Assigned to'), - 'attributes' => array( + 'attributes' => [ 'multiple' => TRUE, 'create' => TRUE, - 'api' => array('params' => array('is_deceased' => 0)), - ), - ), - 'followup_activity_type_id' => array( + 'api' => ['params' => ['is_deceased' => 0]], + ], + ], + 'followup_activity_type_id' => [ 'type' => 'select', 'label' => ts('Followup Activity'), - 'attributes' => array('' => '- ' . ts('select activity') . ' -') + $activityTypes, - 'extra' => array('class' => 'crm-select2'), - ), + 'attributes' => ['' => '- ' . ts('select activity') . ' -'] + $activityTypes, + 'extra' => ['class' => 'crm-select2'], + ], // Add optional 'Subject' field for the Follow-up Activiity, CRM-4491 - 'followup_activity_subject' => array( + 'followup_activity_subject' => [ 'type' => 'text', 'label' => ts('Subject'), - 'attributes' => CRM_Core_DAO::getAttribute('CRM_Activity_DAO_Activity', - 'subject' - ), - ), - ); + 'attributes' => CRM_Core_DAO::getAttribute('CRM_Activity_DAO_Activity', 'subject'), + ], + ]; } /** @@ -264,7 +260,11 @@ public function preProcess() { if (CRM_Contact_Form_Search::isSearchContext($this->_context)) { $this->_context = 'search'; } - elseif (!in_array($this->_context, array('dashlet', 'case', 'dashletFullscreen')) + elseif (!in_array($this->_context, [ + 'dashlet', + 'case', + 'dashletFullscreen', + ]) && $this->_currentlyViewedContactId ) { $this->_context = 'activity'; @@ -301,10 +301,10 @@ public function preProcess() { // Check for required permissions, CRM-6264. if ($this->_activityId && - in_array($this->_action, array( + in_array($this->_action, [ CRM_Core_Action::UPDATE, CRM_Core_Action::VIEW, - )) && + ]) && !CRM_Activity_BAO_Activity::checkPermission($this->_activityId, $this->_action) ) { CRM_Core_Error::fatal(ts('You do not have permission to access this page.')); @@ -345,7 +345,7 @@ public function preProcess() { CRM_Utils_System::setTitle($displayName . ' - ' . $activityName); } else { - CRM_Utils_System::setTitle(ts('%1 Activity', array(1 => $activityName))); + CRM_Utils_System::setTitle(ts('%1 Activity', [1 => $activityName])); } } @@ -437,12 +437,12 @@ public function preProcess() { } $this->assign('searchKey', $qfKey); } - elseif (in_array($this->_context, array( + elseif (in_array($this->_context, [ 'standalone', 'home', 'dashlet', 'dashletFullscreen', - )) + ]) ) { $urlParams = 'reset=1'; $urlString = 'civicrm/dashboard'; @@ -516,9 +516,9 @@ public function preProcess() { $this->_values = $this->get('values'); if (!is_array($this->_values)) { - $this->_values = array(); + $this->_values = []; if (isset($this->_activityId) && $this->_activityId) { - $params = array('id' => $this->_activityId); + $params = ['id' => $this->_activityId]; CRM_Activity_BAO_Activity::retrieve($params, $this->_values); } @@ -606,7 +606,7 @@ public function setDefaultValues() { if ($this->_action == 2 && !empty($defaults['target_contact_id'])) { $count = count(is_array($defaults['target_contact_id']) ? $defaults['target_contact_id'] : explode(',', $defaults['target_contact_id'])); if ($count > 50) { - $this->freeze(array('target_contact_id')); + $this->freeze(['target_contact_id']); } } @@ -637,18 +637,18 @@ public function buildQuickForm() { if ($this->_action & CRM_Core_Action::RENEW) { $button = ts('Restore'); } - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => $button, 'spacing' => '         ', 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - )); + ], + ]); return; } @@ -659,11 +659,11 @@ public function buildQuickForm() { $this->assign('suppressForm', FALSE); $element = &$this->add('select', 'activity_type_id', ts('Activity Type'), - array('' => '- ' . ts('select') . ' -') + $this->_fields['followup_activity_type_id']['attributes'], - FALSE, array( + ['' => '- ' . ts('select') . ' -'] + $this->_fields['followup_activity_type_id']['attributes'], + FALSE, [ 'onchange' => "CRM.buildCustomData( 'Activity', this.value );", 'class' => 'crm-select2 required', - ) + ] ); // Freeze for update mode. @@ -682,7 +682,7 @@ public function buildQuickForm() { $required = !empty($values['required']); if ($values['type'] == 'select' && empty($attribute)) { - $this->addSelect($field, array('entity' => 'activity'), $required); + $this->addSelect($field, ['entity' => 'activity'], $required); } elseif ($values['type'] == 'entityRef') { $this->addEntityRef($field, $values['label'], $attribute, $required); @@ -702,7 +702,7 @@ public function buildQuickForm() { CRM_Campaign_BAO_Campaign::accessCampaign() ) { $buildEngagementLevel = TRUE; - $this->addSelect('engagement_level', array('entity' => 'activity')); + $this->addSelect('engagement_level', ['entity' => 'activity']); $this->addRule('engagement_level', ts('Please enter the engagement index as a number (integers only).'), 'positiveInteger' @@ -726,7 +726,7 @@ public function buildQuickForm() { $responseOptions = CRM_Campaign_BAO_Survey::getResponsesOptions($surveyId); if ($responseOptions) { $this->add('select', 'result', ts('Result'), - array('' => ts('- select -')) + array_combine($responseOptions, $responseOptions) + ['' => ts('- select -')] + array_combine($responseOptions, $responseOptions) ); } $surveyTitle = NULL; @@ -745,10 +745,10 @@ public function buildQuickForm() { $this->addRadio( 'separation', ts('Activity Separation'), - array( + [ 'separate' => ts('Create separate activities for each contact'), 'combined' => ts('Create one activity with all contacts together'), - ) + ] ); } @@ -772,11 +772,15 @@ public function buildQuickForm() { $tags = CRM_Core_BAO_Tag::getColorTags('civicrm_activity'); if (!empty($tags)) { - $this->add('select2', 'tag', ts('Tags'), $tags, FALSE, array('class' => 'huge', 'placeholder' => ts('- select -'), 'multiple' => TRUE)); + $this->add('select2', 'tag', ts('Tags'), $tags, FALSE, [ + 'class' => 'huge', + 'placeholder' => ts('- select -'), + 'multiple' => TRUE, + ]); } // we need to hide activity tagset for special activities - $specialActivities = array('Open Case'); + $specialActivities = ['Open Case']; if (!in_array($this->_activityTypeName, $specialActivities)) { // build tag widget @@ -818,13 +822,15 @@ public function buildQuickForm() { $className = "CRM_{$this->_crmDir}_Form_Activity_{$this->_activityTypeFile}"; $className::buildQuickForm($this); - $this->addFormRule(array($className, 'formRule'), $this); + $this->addFormRule([$className, 'formRule'], $this); } - $this->addFormRule(array('CRM_Activity_Form_Activity', 'formRule'), $this); + $this->addFormRule(['CRM_Activity_Form_Activity', 'formRule'], $this); - $doNotNotifyAssigneeFor = (array) Civi::settings()->get('do_not_notify_assignees_for'); - if (($this->_activityTypeId && in_array($this->_activityTypeId, $doNotNotifyAssigneeFor)) || !Civi::settings()->get('activity_assignee_notification')) { + $doNotNotifyAssigneeFor = (array) Civi::settings() + ->get('do_not_notify_assignees_for'); + if (($this->_activityTypeId && in_array($this->_activityTypeId, $doNotNotifyAssigneeFor)) || !Civi::settings() + ->get('activity_assignee_notification')) { $this->assign('activityAssigneeNotification', FALSE); } else { @@ -850,7 +856,7 @@ public static function formRule($fields, $files, $self) { if (CRM_Utils_Array::value('_qf_Activity_next_', $fields) == 'Delete') { return TRUE; } - $errors = array(); + $errors = []; if ((array_key_exists('activity_type_id', $fields) || !$self->_single) && empty($fields['activity_type_id'])) { $errors['activity_type_id'] = ts('Activity Type is a required field'); } @@ -895,15 +901,15 @@ public static function formRule($fields, $files, $self) { */ public function postProcess($params = NULL) { if ($this->_action & CRM_Core_Action::DELETE) { - $deleteParams = array('id' => $this->_activityId); + $deleteParams = ['id' => $this->_activityId]; $moveToTrash = CRM_Case_BAO_Case::isCaseActivity($this->_activityId); CRM_Activity_BAO_Activity::deleteActivity($deleteParams, $moveToTrash); // delete tags for the entity - $tagParams = array( + $tagParams = [ 'entity_table' => 'civicrm_activity', 'entity_id' => $this->_activityId, - ); + ]; CRM_Core_BAO_EntityTag::del($tagParams); @@ -939,12 +945,12 @@ public function postProcess($params = NULL) { } // format params as arrays - foreach (array('target', 'assignee', 'followup_assignee') as $name) { + foreach (['target', 'assignee', 'followup_assignee'] as $name) { if (!empty($params["{$name}_contact_id"])) { $params["{$name}_contact_id"] = explode(',', $params["{$name}_contact_id"]); } else { - $params["{$name}_contact_id"] = array(); + $params["{$name}_contact_id"] = []; } } @@ -966,13 +972,13 @@ public function postProcess($params = NULL) { $params['is_multi_activity'] = CRM_Utils_Array::value('separation', $params) == 'separate'; - $activity = array(); + $activity = []; if (!empty($params['is_multi_activity']) && !CRM_Utils_Array::crmIsEmptyArray($params['target_contact_id']) ) { $targetContacts = $params['target_contact_id']; foreach ($targetContacts as $targetContactId) { - $params['target_contact_id'] = array($targetContactId); + $params['target_contact_id'] = [$targetContactId]; // save activity $activity[] = $this->processActivity($params); } @@ -982,7 +988,7 @@ public function postProcess($params = NULL) { $activity = $this->processActivity($params); } - $activityIds = empty($this->_activityIds) ? array($this->_activityId) : $this->_activityIds; + $activityIds = empty($this->_activityIds) ? [$this->_activityId] : $this->_activityIds; foreach ($activityIds as $activityId) { // set params for repeat configuration in create mode $params['entity_id'] = $activityId; @@ -1001,7 +1007,7 @@ public function postProcess($params = NULL) { $params['schedule_reminder_id'] = $scheduleReminderDetails->id; } } - $params['dateColumns'] = array('activity_date_time'); + $params['dateColumns'] = ['activity_date_time']; // Set default repetition start if it was not provided. if (empty($params['repetition_start_date'])) { @@ -1010,20 +1016,20 @@ public function postProcess($params = NULL) { // unset activity id unset($params['id']); - $linkedEntities = array( - array( + $linkedEntities = [ + [ 'table' => 'civicrm_activity_contact', - 'findCriteria' => array( + 'findCriteria' => [ 'activity_id' => $activityId, - ), - 'linkedColumns' => array('activity_id'), + ], + 'linkedColumns' => ['activity_id'], 'isRecurringEntityRecord' => FALSE, - ), - ); + ], + ]; CRM_Core_Form_RecurringEntity::postProcess($params, 'civicrm_activity', $linkedEntities); } - return array('activity' => $activity); + return ['activity' => $activity]; } /** @@ -1035,7 +1041,7 @@ public function postProcess($params = NULL) { * @return self|null|object */ protected function processActivity(&$params) { - $activityAssigned = array(); + $activityAssigned = []; $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts); // format assignee params @@ -1056,7 +1062,7 @@ protected function processActivity(&$params) { $activity = CRM_Activity_BAO_Activity::create($params); // add tags if exists - $tagParams = array(); + $tagParams = []; if (!empty($params['tag'])) { if (!is_array($params['tag'])) { $params['tag'] = explode(',', $params['tag']); @@ -1097,15 +1103,16 @@ protected function processActivity(&$params) { $mailStatus = ''; if (Civi::settings()->get('activity_assignee_notification') - && !in_array($activity->activity_type_id, Civi::settings()->get('do_not_notify_assignees_for'))) { - $activityIDs = array($activity->id); + && !in_array($activity->activity_type_id, Civi::settings() + ->get('do_not_notify_assignees_for'))) { + $activityIDs = [$activity->id]; if ($followupActivity) { - $activityIDs = array_merge($activityIDs, array($followupActivity->id)); + $activityIDs = array_merge($activityIDs, [$followupActivity->id]); } $assigneeContacts = CRM_Activity_BAO_ActivityAssignment::getAssigneeNames($activityIDs, TRUE, FALSE); if (!CRM_Utils_Array::crmIsEmptyArray($params['assignee_contact_id'])) { - $mailToContacts = array(); + $mailToContacts = []; // Build an associative array with unique email addresses. foreach ($activityAssigned as $id => $dnc) { @@ -1122,7 +1129,7 @@ protected function processActivity(&$params) { // Also send email to follow-up activity assignees if set if ($followupActivity) { - $mailToFollowupContacts = array(); + $mailToFollowupContacts = []; foreach ($assigneeContacts as $values) { if ($values['activity_id'] == $followupActivity->id) { $mailToFollowupContacts[$values['email']] = $values; @@ -1143,11 +1150,11 @@ protected function processActivity(&$params) { } CRM_Core_Session::setStatus(ts('Activity %1 has been saved. %2 %3', - array( + [ 1 => $subject, 2 => $followupStatus, 3 => $mailStatus, - ) + ] ), ts('Saved'), 'success'); return $activity; diff --git a/CRM/Activity/Import/Form/MapField.php b/CRM/Activity/Import/Form/MapField.php index aa97c4dc15f1..9cbb7d7e27ca 100644 --- a/CRM/Activity/Import/Form/MapField.php +++ b/CRM/Activity/Import/Form/MapField.php @@ -62,14 +62,14 @@ public function preProcess() { else { $this->assign('rowDisplayCount', 2); } - $highlightedFields = array(); - $requiredFields = array( + $highlightedFields = []; + $requiredFields = [ 'activity_date_time', 'activity_type_id', 'activity_label', 'target_contact_id', 'activity_subject', - ); + ]; foreach ($requiredFields as $val) { $highlightedFields[] = $val; } @@ -103,8 +103,8 @@ public function buildQuickForm() { $this->assign('loadedMapping', $savedMapping); $this->set('loadedMapping', $savedMapping); - $params = array('id' => $savedMapping); - $temp = array(); + $params = ['id' => $savedMapping]; + $temp = []; $mappingDetails = CRM_Core_BAO_Mapping::retrieve($params, $temp); $this->assign('savedName', $mappingDetails->name); @@ -117,13 +117,13 @@ public function buildQuickForm() { $this->add('text', 'saveMappingDesc', ts('Description')); } - $this->addElement('checkbox', 'saveMapping', $saveDetailsName, NULL, array('onclick' => "showSaveDetails(this)")); + $this->addElement('checkbox', 'saveMapping', $saveDetailsName, NULL, ['onclick' => "showSaveDetails(this)"]); - $this->addFormRule(array('CRM_Activity_Import_Form_MapField', 'formRule')); + $this->addFormRule(['CRM_Activity_Import_Form_MapField', 'formRule']); //-------- end of saved mapping stuff --------- - $defaults = array(); + $defaults = []; $mapperKeys = array_keys($this->_mapperFields); $hasHeaders = !empty($this->_columnHeaders); @@ -148,7 +148,7 @@ public function buildQuickForm() { $warning = 0; for ($i = 0; $i < $this->_columnCount; $i++) { - $sel = &$this->addElement('hierselect', "mapper[$i]", ts('Mapper for Field %1', array(1 => $i)), NULL); + $sel = &$this->addElement('hierselect', "mapper[$i]", ts('Mapper for Field %1', [1 => $i]), NULL); $jsSet = FALSE; if ($this->get('savedMapping')) { if (isset($mappingName[$i])) { @@ -165,15 +165,15 @@ public function buildQuickForm() { } $js .= "{$formName}['mapper[$i][3]'].style.display = 'none';\n"; - $defaults["mapper[$i]"] = array( + $defaults["mapper[$i]"] = [ $mappingHeader[0], (isset($locationId)) ? $locationId : "", (isset($phoneType)) ? $phoneType : "", - ); + ]; $jsSet = TRUE; } else { - $defaults["mapper[$i]"] = array(); + $defaults["mapper[$i]"] = []; } if (!$jsSet) { for ($k = 1; $k < 4; $k++) { @@ -186,14 +186,10 @@ public function buildQuickForm() { $js .= "swapOptions($formName, 'mapper[$i]', 0, 3, 'hs_mapper_" . $i . "_');\n"; if ($hasHeaders) { - $defaults["mapper[$i]"] = array( - $this->defaultFromHeader($this->_columnHeaders[$i], - $headerPatterns - ), - ); + $defaults["mapper[$i]"] = [$this->defaultFromHeader($this->_columnHeaders[$i], $headerPatterns)]; } else { - $defaults["mapper[$i]"] = array($this->defaultFromData($dataPatterns, $i)); + $defaults["mapper[$i]"] = [$this->defaultFromData($dataPatterns, $i)]; } } // End of load mapping. @@ -202,23 +198,23 @@ public function buildQuickForm() { $js .= "swapOptions($formName, 'mapper[$i]', 0, 3, 'hs_mapper_" . $i . "_');\n"; if ($hasHeaders) { // Infer the default from the skipped headers if we have them - $defaults["mapper[$i]"] = array( - $this->defaultFromHeader($this->_columnHeaders[$i], - $headerPatterns - ), + $defaults["mapper[$i]"] = [ + $this->defaultFromHeader($this->_columnHeaders[$i], $headerPatterns), 0, - ); + ]; } else { // Otherwise guess the default from the form of the data - $defaults["mapper[$i]"] = array( - $this->defaultFromData($dataPatterns, $i), - 0, - ); + $defaults["mapper[$i]"] = [$this->defaultFromData($dataPatterns, $i), 0]; } } - $sel->setOptions(array($sel1, $sel2, (isset($sel3)) ? $sel3 : "", (isset($sel4)) ? $sel4 : "")); + $sel->setOptions([ + $sel1, + $sel2, + (isset($sel3)) ? $sel3 : "", + (isset($sel4)) ? $sel4 : "", + ]); } $js .= "\n"; $this->assign('initHideBoxes', $js); @@ -240,22 +236,22 @@ public function buildQuickForm() { $this->setDefaults($defaults); - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'back', 'name' => ts('Previous'), - ), - array( + ], + [ 'type' => 'next', 'name' => ts('Continue'), 'spacing' => '          ', 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); } @@ -269,28 +265,28 @@ public function buildQuickForm() { * list of errors to be posted back to the form */ public static function formRule($fields) { - $errors = array(); + $errors = []; // define so we avoid notices below $errors['_qf_default'] = ''; $fieldMessage = NULL; if (!array_key_exists('savedMapping', $fields)) { - $importKeys = array(); + $importKeys = []; foreach ($fields['mapper'] as $mapperPart) { $importKeys[] = $mapperPart[0]; } // FIXME: should use the schema titles, not redeclare them - $requiredFields = array( + $requiredFields = [ 'target_contact_id' => ts('Contact ID'), 'activity_date_time' => ts('Activity Date'), 'activity_subject' => ts('Activity Subject'), 'activity_type_id' => ts('Activity Type ID'), - ); + ]; - $params = array( + $params = [ 'used' => 'Unsupervised', 'contact_type' => 'Individual', - ); + ]; list($ruleFields, $threshold) = CRM_Dedupe_BAO_RuleGroup::dedupeRuleFieldsWeight($params); $weightSum = 0; foreach ($importKeys as $key => $val) { @@ -310,7 +306,7 @@ public static function formRule($fields) { else { $errors['_qf_default'] .= ts('Missing required contact matching fields.') . $fieldMessage . ' ' - . ts('(Sum of all weights should be greater than or equal to threshold: %1).', array(1 => $threshold)) + . ts('(Sum of all weights should be greater than or equal to threshold: %1).', [1 => $threshold]) . '
'; } } @@ -320,14 +316,14 @@ public static function formRule($fields) { } else { $errors['_qf_default'] .= ts('Missing required field: Provide %1 or %2', - array( + [ 1 => $title, 2 => 'Activity Type Label', - )) . '
'; + ]) . '
'; } } else { - $errors['_qf_default'] .= ts('Missing required field: %1', array(1 => $title)) . '
'; + $errors['_qf_default'] .= ts('Missing required field: %1', [1 => $title]) . '
'; } } } @@ -378,12 +374,12 @@ public function postProcess() { $seperator = $this->controller->exportValue('DataSource', 'fieldSeparator'); $skipColumnHeader = $this->controller->exportValue('DataSource', 'skipColumnHeader'); - $mapperKeys = array(); - $mapper = array(); + $mapperKeys = []; + $mapper = []; $mapperKeys = $this->controller->exportValue($this->_name, 'mapper'); - $mapperKeysMain = array(); - $mapperLocType = array(); - $mapperPhoneType = array(); + $mapperKeysMain = []; + $mapperLocType = []; + $mapperPhoneType = []; for ($i = 0; $i < $this->_columnCount; $i++) { $mapper[$i] = $this->_mapperFields[$mapperKeys[$i][0]]; @@ -417,7 +413,7 @@ public function postProcess() { $mappingFields->mapping_id = $params['mappingId']; $mappingFields->find(); - $mappingFieldsId = array(); + $mappingFieldsId = []; while ($mappingFields->fetch()) { if ($mappingFields->id) { $mappingFieldsId[$mappingFields->column_number] = $mappingFields->id; @@ -437,11 +433,11 @@ public function postProcess() { // Saving Mapping Details and Records. if (!empty($params['saveMapping'])) { - $mappingParams = array( + $mappingParams = [ 'name' => $params['saveMappingName'], 'description' => $params['saveMappingDesc'], 'mapping_type_id' => CRM_Core_PseudoConstant::getKey('CRM_Core_BAO_Mapping', 'mapping_type_id', 'Import Activity'), - ); + ]; $saveMapping = CRM_Core_BAO_Mapping::add($mappingParams); for ($i = 0; $i < $this->_columnCount; $i++) { From 9f462279be2081a09d36b73d6bd1c2b5a2effd93 Mon Sep 17 00:00:00 2001 From: eileen Date: Fri, 5 Apr 2019 18:46:09 +1300 Subject: [PATCH 076/121] [NFC] array format tricksie file --- CRM/Admin/Form/MessageTemplates.php | 50 ++++++++++++++--------------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/CRM/Admin/Form/MessageTemplates.php b/CRM/Admin/Form/MessageTemplates.php index 6e37b7517a0c..b3dab487318b 100644 --- a/CRM/Admin/Form/MessageTemplates.php +++ b/CRM/Admin/Form/MessageTemplates.php @@ -94,14 +94,14 @@ public function buildQuickForm() { // currently, the above action is used solely for previewing default workflow templates $cancelURL = CRM_Utils_System::url('civicrm/admin/messageTemplates', 'selectedChild=workflow&reset=1'); $cancelURL = str_replace('&', '&', $cancelURL); - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'cancel', 'name' => ts('Done'), - 'js' => array('onclick' => "location.href='{$cancelURL}'; return false;"), + 'js' => ['onclick' => "location.href='{$cancelURL}'; return false;"], 'isDefault' => TRUE, - ), - ) + ], + ] ); } else { @@ -118,23 +118,23 @@ public function buildQuickForm() { $cancelURL = CRM_Utils_System::url('civicrm/admin/messageTemplates', "selectedChild={$selectedChild}&reset=1"); $cancelURL = str_replace('&', '&', $cancelURL); - $buttons[] = array( + $buttons[] = [ 'type' => 'upload', 'name' => $this->_action & CRM_Core_Action::DELETE ? ts('Delete') : ts('Save'), 'isDefault' => TRUE, - ); + ]; if (!($this->_action & CRM_Core_Action::DELETE)) { - $buttons[] = array( + $buttons[] = [ 'type' => 'submit', 'name' => ts('Save and Done'), 'subName' => 'done', - ); + ]; } - $buttons[] = array( + $buttons[] = [ 'type' => 'cancel', 'name' => ts('Cancel'), - 'js' => array('onclick' => "location.href='{$cancelURL}'; return false;"), - ); + 'js' => ['onclick' => "location.href='{$cancelURL}'; return false;"], + ]; $this->addButtons($buttons); } @@ -143,20 +143,18 @@ public function buildQuickForm() { return; } - $breadCrumb = array( - array( + $breadCrumb = [ + [ 'title' => ts('Message Templates'), - 'url' => CRM_Utils_System::url('civicrm/admin/messageTemplates', - 'action=browse&reset=1' - ), - ), - ); + 'url' => CRM_Utils_System::url('civicrm/admin/messageTemplates', 'action=browse&reset=1'), + ], + ]; CRM_Utils_System::appendBreadCrumb($breadCrumb); $this->applyFilter('__ALL__', 'trim'); $this->add('text', 'msg_title', ts('Message Title'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_MessageTemplate', 'msg_title'), TRUE); - $options = array(ts('Compose On-screen'), ts('Upload Document')); + $options = [ts('Compose On-screen'), ts('Upload Document')]; $element = $this->addRadio('file_type', ts('Source'), $options); if ($this->_id) { $element->freeze(); @@ -188,12 +186,12 @@ public function buildQuickForm() { } else { $this->add('wysiwyg', 'msg_html', ts('HTML Message'), - array( + [ 'cols' => '80', 'rows' => '8', 'onkeyup' => "return verify(this)", 'preset' => 'civimail', - ) + ] ); } @@ -202,13 +200,13 @@ public function buildQuickForm() { ); $this->add('select', 'pdf_format_id', ts('PDF Page Format'), - array( + [ 'null' => ts('- default -'), - ) + CRM_Core_BAO_PdfFormat::getList(TRUE), FALSE + ] + CRM_Core_BAO_PdfFormat::getList(TRUE), FALSE ); $this->add('checkbox', 'is_active', ts('Enabled?')); - $this->addFormRule(array(__CLASS__, 'formRule'), $this); + $this->addFormRule([__CLASS__, 'formRule'], $this); if ($this->_action & CRM_Core_Action::VIEW) { $this->freeze(); @@ -309,7 +307,7 @@ public function postProcess() { } $messageTemplate = CRM_Core_BAO_MessageTemplate::add($params); - CRM_Core_Session::setStatus(ts('The Message Template \'%1\' has been saved.', array(1 => $messageTemplate->msg_title)), ts('Saved'), 'success'); + CRM_Core_Session::setStatus(ts('The Message Template \'%1\' has been saved.', [1 => $messageTemplate->msg_title]), ts('Saved'), 'success'); if (isset($this->_submitValues['_qf_MessageTemplates_upload'])) { // Save button was pressed From b33253395514054af01ae34d5201022d4a6a2422 Mon Sep 17 00:00:00 2001 From: eileen Date: Fri, 5 Apr 2019 19:28:11 +1300 Subject: [PATCH 077/121] [NFC] array formatting tricksy tricksie file --- CRM/Utils/REST.php | 95 ++++++++++++++++++++++++++-------------------- 1 file changed, 54 insertions(+), 41 deletions(-) diff --git a/CRM/Utils/REST.php b/CRM/Utils/REST.php index eee1fc28d96b..52e7e5296484 100644 --- a/CRM/Utils/REST.php +++ b/CRM/Utils/REST.php @@ -68,7 +68,7 @@ public static function ping($var = NULL) { $session = CRM_Core_Session::singleton(); $key = $session->get('key'); // $session->set( 'key', $var ); - return self::simple(array('message' => "PONG: $key")); + return self::simple(['message' => "PONG: $key"]); } /** @@ -78,10 +78,10 @@ public static function ping($var = NULL) { * @return array */ public static function error($message = 'Unknown Error') { - $values = array( + $values = [ 'error_message' => $message, 'is_error' => 1, - ); + ]; return $values; } @@ -92,7 +92,7 @@ public static function error($message = 'Unknown Error') { * @return array */ public static function simple($params) { - $values = array('is_error' => 0); + $values = ['is_error' => 0]; $values += $params; return $values; } @@ -129,7 +129,7 @@ public static function output(&$result) { if (!$result) { $result = 0; } - $result = self::simple(array('result' => $result)); + $result = self::simple(['result' => $result]); } elseif (is_array($result)) { if (CRM_Utils_Array::isHierarchical($result)) { @@ -216,7 +216,7 @@ public static function handle() { } else { // or the api format (entity+action) - $args = array(); + $args = []; $args[0] = 'civicrm'; $args[1] = CRM_Utils_Array::value('entity', $requestParams); $args[2] = CRM_Utils_Array::value('action', $requestParams); @@ -277,7 +277,7 @@ public static function process(&$args, $params) { return self::error('Unknown function invocation.'); } - return call_user_func(array($params['className'], $params['fnName']), $params); + return call_user_func([$params['className'], $params['fnName']], $params); } if (!array_key_exists('version', $params)) { @@ -292,22 +292,25 @@ public static function process(&$args, $params) { } if ($_SERVER['REQUEST_METHOD'] == 'GET' && - strtolower(substr($args[2], 0, 3)) != 'get' && - strtolower($args[2] != 'check')) { + strtolower(substr($args[2], 0, 3)) != 'get' && + strtolower($args[2] != 'check')) { // get only valid for non destructive methods require_once 'api/v3/utils.php'; return civicrm_api3_create_error("SECURITY: All requests that modify the database must be http POST, not GET.", - array( + [ 'IP' => $_SERVER['REMOTE_ADDR'], 'level' => 'security', 'referer' => $_SERVER['HTTP_REFERER'], 'reason' => 'Destructive HTTP GET', - ) + ] ); } // trap all fatal errors - $errorScope = CRM_Core_TemporaryErrorScope::create(array('CRM_Utils_REST', 'fatal')); + $errorScope = CRM_Core_TemporaryErrorScope::create([ + 'CRM_Utils_REST', + 'fatal', + ]); $result = civicrm_api($args[1], $args[2], $params); unset($errorScope); @@ -322,21 +325,25 @@ public static function process(&$args, $params) { */ public static function &buildParamList() { $requestParams = CRM_Utils_Request::exportValues(); - $params = array(); + $params = []; - $skipVars = array( + $skipVars = [ 'q' => 1, 'json' => 1, 'key' => 1, 'api_key' => 1, 'entity' => 1, 'action' => 1, - ); + ]; if (array_key_exists('json', $requestParams) && $requestParams['json'][0] == "{") { $params = json_decode($requestParams['json'], TRUE); if ($params === NULL) { - CRM_Utils_JSON::output(array('is_error' => 1, 'error_message', 'Unable to decode supplied JSON.')); + CRM_Utils_JSON::output([ + 'is_error' => 1, + 0 => 'error_message', + 1 => 'Unable to decode supplied JSON.', + ]); } } foreach ($requestParams as $n => $v) { @@ -357,7 +364,7 @@ public static function &buildParamList() { */ public static function fatal($pearError) { CRM_Utils_System::setHttpHeader('Content-Type', 'text/xml'); - $error = array(); + $error = []; $error['code'] = $pearError->getCode(); $error['error_message'] = $pearError->getMessage(); $error['mode'] = $pearError->getMode(); @@ -378,7 +385,7 @@ public static function fatal($pearError) { public static function loadTemplate() { $request = CRM_Utils_Request::retrieve('q', 'String'); if (FALSE !== strpos($request, '..')) { - die ("SECURITY FATAL: the url can't contain '..'. Please report the issue on the forum at civicrm.org"); + die("SECURITY FATAL: the url can't contain '..'. Please report the issue on the forum at civicrm.org"); } $request = explode('/', $request); @@ -390,7 +397,7 @@ public static function loadTemplate() { CRM_Utils_System::setTitle("$entity::$tplfile inline $tpl"); if (!$smarty->template_exists($tpl)) { CRM_Utils_System::setHttpHeader("Status", "404 Not Found"); - die ("Can't find the requested template file templates/$tpl"); + die("Can't find the requested template file templates/$tpl"); } if (array_key_exists('id', $_GET)) {// special treatmenent, because it's often used $smarty->assign('id', (int) $_GET['id']);// an id is always positive @@ -398,7 +405,7 @@ public static function loadTemplate() { $pos = strpos(implode(array_keys($_GET)), '<'); if ($pos !== FALSE) { - die ("SECURITY FATAL: one of the param names contains <"); + die("SECURITY FATAL: one of the param names contains <"); } $param = array_map('htmlentities', $_GET); unset($param['q']); @@ -444,12 +451,12 @@ public static function ajaxJson() { ) ) { $error = civicrm_api3_create_error("SECURITY ALERT: Ajax requests can only be issued by javascript clients, eg. CRM.api3().", - array( + [ 'IP' => $_SERVER['REMOTE_ADDR'], 'level' => 'security', 'referer' => $_SERVER['HTTP_REFERER'], 'reason' => 'CSRF suspected', - ) + ] ); CRM_Utils_JSON::output($error); } @@ -465,10 +472,10 @@ public static function ajaxJson() { $entity = CRM_Utils_String::munge(CRM_Utils_Array::value('entity', $requestParams)); $action = CRM_Utils_String::munge(CRM_Utils_Array::value('action', $requestParams)); if (!is_array($params)) { - CRM_Utils_JSON::output(array( - 'is_error' => 1, - 'error_message' => 'invalid json format: ?{"param_with_double_quote":"value"}', - )); + CRM_Utils_JSON::output([ + 'is_error' => 1, + 'error_message' => 'invalid json format: ?{"param_with_double_quote":"value"}', + ]); } $params['check_permissions'] = TRUE; @@ -479,7 +486,10 @@ public static function ajaxJson() { } // trap all fatal errors - $errorScope = CRM_Core_TemporaryErrorScope::create(array('CRM_Utils_REST', 'fatal')); + $errorScope = CRM_Core_TemporaryErrorScope::create([ + 'CRM_Utils_REST', + 'fatal', + ]); $result = civicrm_api($entity, $action, $params); unset($errorScope); @@ -507,12 +517,12 @@ public static function ajax() { ) { require_once 'api/v3/utils.php'; $error = civicrm_api3_create_error("SECURITY ALERT: Ajax requests can only be issued by javascript clients, eg. CRM.api3().", - array( + [ 'IP' => $_SERVER['REMOTE_ADDR'], 'level' => 'security', 'referer' => $_SERVER['HTTP_REFERER'], 'reason' => 'CSRF suspected', - ) + ] ); CRM_Utils_JSON::output($error); } @@ -522,11 +532,14 @@ public static function ajax() { $entity = CRM_Utils_Array::value('entity', $requestParams); $action = CRM_Utils_Array::value('action', $requestParams); if (!$entity || !$action) { - $err = array('error_message' => 'missing mandatory params "entity=" or "action="', 'is_error' => 1); + $err = [ + 'error_message' => 'missing mandatory params "entity=" or "action="', + 'is_error' => 1, + ]; echo self::output($err); CRM_Utils_System::civiExit(); } - $args = array('civicrm', $entity, $action); + $args = ['civicrm', $entity, $action]; } else { $args = explode('/', $q); @@ -558,14 +571,14 @@ public static function ajax() { * @return array */ public static function processMultiple() { - $output = array(); + $output = []; foreach (json_decode($_REQUEST['json'], TRUE) as $key => $call) { - $args = array( + $args = [ 'civicrm', $call[0], $call[1], - ); - $output[$key] = self::process($args, CRM_Utils_Array::value(2, $call, array())); + ]; + $output[$key] = self::process($args, CRM_Utils_Array::value(2, $call, [])); } return $output; } @@ -583,7 +596,7 @@ public function loadCMSBootstrap() { // Proceed with bootstrap for "?q=civicrm/X/Y" but not "?q=civicrm/ping" if (!empty($q)) { if (count($args) == 2 && $args[1] == 'ping') { - CRM_Utils_System::loadBootStrap(array(), FALSE, FALSE); + CRM_Utils_System::loadBootStrap([], FALSE, FALSE); return NULL; // this is pretty wonky but maybe there's some reason I can't see } if (count($args) != 3) { @@ -599,7 +612,7 @@ public function loadCMSBootstrap() { // FIXME: At time of writing, this doesn't actually do anything because // authenticateKey abends, but that's a bad behavior which sends a // malformed response. - CRM_Utils_System::loadBootStrap(array(), FALSE, FALSE); + CRM_Utils_System::loadBootStrap([], FALSE, FALSE); return self::error('Failed to authenticate key'); } @@ -608,7 +621,7 @@ public function loadCMSBootstrap() { $store = NULL; $api_key = CRM_Utils_Request::retrieve('api_key', 'String', $store, FALSE, NULL, 'REQUEST'); if (empty($api_key)) { - CRM_Utils_System::loadBootStrap(array(), FALSE, FALSE); + CRM_Utils_System::loadBootStrap([], FALSE, FALSE); return self::error("FATAL: mandatory param 'api_key' (user key) missing"); } $contact_id = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $api_key, 'id', 'api_key'); @@ -618,17 +631,17 @@ public function loadCMSBootstrap() { } if ($uid && $contact_id) { - CRM_Utils_System::loadBootStrap(array('uid' => $uid), TRUE, FALSE); + CRM_Utils_System::loadBootStrap(['uid' => $uid], TRUE, FALSE); $session = CRM_Core_Session::singleton(); $session->set('ufID', $uid); $session->set('userID', $contact_id); CRM_Core_DAO::executeQuery('SET @civicrm_user_id = %1', - array(1 => array($contact_id, 'Integer')) + [1 => [$contact_id, 'Integer']] ); return NULL; } else { - CRM_Utils_System::loadBootStrap(array(), FALSE, FALSE); + CRM_Utils_System::loadBootStrap([], FALSE, FALSE); return self::error('ERROR: No CMS user associated with given api-key'); } } From 927f5956ea1b92df78bd9e8422c7231e3c1a0c7d Mon Sep 17 00:00:00 2001 From: eileen Date: Fri, 5 Apr 2019 19:41:22 +1300 Subject: [PATCH 078/121] [NFC] array formatting tricksy tricksie file (another) --- CRM/UF/Form/Group.php | 105 +++++++++++++++++++++++++----------------- 1 file changed, 63 insertions(+), 42 deletions(-) diff --git a/CRM/UF/Form/Group.php b/CRM/UF/Form/Group.php index 43555dbc18ec..9a5dfbec8ab8 100644 --- a/CRM/UF/Form/Group.php +++ b/CRM/UF/Form/Group.php @@ -70,10 +70,32 @@ protected function setEntityFields() { $this->entityFields = [ 'title' => ['name' => 'title'], 'frontend_title' => ['name' => 'frontend_title'], - 'description' => ['name' => 'description', 'help' => ['id' => 'id-description', 'file' => 'CRM/UF/Form/Group.hlp']], - 'uf_group_type' => ['name' => 'uf_group_type', 'not-auto-addable' => TRUE, 'help' => ['id' => 'id-used_for', 'file' => 'CRM/UF/Form/Group.hlp'], 'post_html_text' => ' ' . $this->getOtherModuleString()], - 'cancel_button_text' => ['name' => 'cancel_button_text', 'help' => ['id' => 'id-cancel_button_text', 'file' => 'CRM/UF/Form/Group.hlp'], 'class' => 'cancel_button_section'], - 'submit_button_text' => ['name' => 'submit_button_text', 'help' => ['id' => 'id-submit_button_text', 'file' => 'CRM/UF/Form/Group.hlp'], 'class' => ''], + 'description' => [ + 'name' => 'description', + 'help' => ['id' => 'id-description', 'file' => 'CRM/UF/Form/Group.hlp'], + ], + 'uf_group_type' => [ + 'name' => 'uf_group_type', + 'not-auto-addable' => TRUE, + 'help' => ['id' => 'id-used_for', 'file' => 'CRM/UF/Form/Group.hlp'], + 'post_html_text' => ' ' . $this->getOtherModuleString(), + ], + 'cancel_button_text' => [ + 'name' => 'cancel_button_text', + 'help' => [ + 'id' => 'id-cancel_button_text', + 'file' => 'CRM/UF/Form/Group.hlp', + ], + 'class' => 'cancel_button_section', + ], + 'submit_button_text' => [ + 'name' => 'submit_button_text', + 'help' => [ + 'id' => 'id-submit_button_text', + 'file' => 'CRM/UF/Form/Group.hlp', + ], + 'class' => '', + ], ]; } @@ -163,23 +185,23 @@ public function buildQuickForm() { else { $display = 'Delete Profile'; } - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => $display, 'spacing' => '         ', 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - )); + ], + ]); return; } //add checkboxes - $uf_group_type = array(); + $uf_group_type = []; $UFGroupType = CRM_Core_SelectValues::ufGroupTypes(); foreach ($UFGroupType as $key => $value) { $uf_group_type[] = $this->createElement('checkbox', $key, NULL, $value); @@ -197,7 +219,7 @@ public function buildQuickForm() { // is this group active ? $this->addElement('checkbox', 'is_active', ts('Is this CiviCRM Profile active?')); - $paneNames = array('Advanced Settings' => 'buildAdvanceSetting'); + $paneNames = ['Advanced Settings' => 'buildAdvanceSetting']; foreach ($paneNames as $name => $type) { if ($this->_id) { @@ -207,37 +229,35 @@ public function buildQuickForm() { $dataURL = "&reset=1&action=add&snippet=4&formType={$type}"; } - $allPanes[$name] = array( - 'url' => CRM_Utils_System::url('civicrm/admin/uf/group/setting', - $dataURL - ), + $allPanes[$name] = [ + 'url' => CRM_Utils_System::url('civicrm/admin/uf/group/setting', $dataURL), 'open' => 'false', 'id' => $type, - ); + ]; CRM_UF_Form_AdvanceSetting::$type($this); } - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => ts('Save'), 'spacing' => '         ', 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - )); + ], + ]); // views are implemented as frozen form if ($this->_action & CRM_Core_Action::VIEW) { $this->freeze(); - $this->addElement('button', 'done', ts('Done'), array('onclick' => "location.href='civicrm/admin/uf/group?reset=1&action=browse'")); + $this->addElement('button', 'done', ts('Done'), ['onclick' => "location.href='civicrm/admin/uf/group?reset=1&action=browse'"]); } - $this->addFormRule(array('CRM_UF_Form_Group', 'formRule'), $this); + $this->addFormRule(['CRM_UF_Form_Group', 'formRule'], $this); } /** @@ -248,7 +268,7 @@ public function buildQuickForm() { * @return void */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; $showHide = new CRM_Core_ShowHideBlocks(); if ($this->_action == CRM_Core_Action::ADD) { @@ -265,7 +285,7 @@ public function setDefaultValues() { $defaults['weight'] = CRM_Core_BAO_UFGroup::getWeight($this->_id); - $params = array('id' => $this->_id); + $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); @@ -277,7 +297,7 @@ public function setDefaultValues() { $defaults['uf_group_type'] = isset($checked) ? $checked : ""; $showAdvanced = 0; - $advFields = array( + $advFields = [ 'group', 'post_URL', 'cancel_URL', @@ -288,7 +308,7 @@ public function setDefaultValues() { 'is_update_dupe', 'is_cms_user', 'is_proximity_search', - ); + ]; foreach ($advFields as $key) { if (!empty($defaults[$key])) { $showAdvanced = 1; @@ -326,19 +346,19 @@ public function setDefaultValues() { * true if no errors, else array of errors */ public static function formRule($fields, $files, $self) { - $errors = array(); + $errors = []; //validate profile title as well as name. $title = $fields['title']; $name = CRM_Utils_String::munge($title, '_', 56); $name .= $self->_id ? '_' . $self->_id : ''; $query = 'select count(*) from civicrm_uf_group where ( name like %1 ) and id != %2'; - $pCnt = CRM_Core_DAO::singleValueQuery($query, array( - 1 => array($name, 'String'), - 2 => array((int) $self->_id, 'Integer'), - )); + $pCnt = CRM_Core_DAO::singleValueQuery($query, [ + 1 => [$name, 'String'], + 2 => [(int) $self->_id, 'Integer'], + ]); if ($pCnt) { - $errors['title'] = ts('Profile \'%1\' already exists in Database.', array(1 => $title)); + $errors['title'] = ts('Profile \'%1\' already exists in Database.', [1 => $title]); } return empty($errors) ? TRUE : $errors; @@ -353,17 +373,17 @@ public function postProcess() { if ($this->_action & CRM_Core_Action::DELETE) { $title = CRM_Core_BAO_UFGroup::getTitle($this->_id); CRM_Core_BAO_UFGroup::del($this->_id); - CRM_Core_Session::setStatus(ts("Your CiviCRM Profile '%1' has been deleted.", array(1 => $title)), ts('Profile Deleted'), 'success'); + CRM_Core_Session::setStatus(ts("Your CiviCRM Profile '%1' has been deleted.", [1 => $title]), ts('Profile Deleted'), 'success'); } elseif ($this->_action & CRM_Core_Action::DISABLE) { - $ufJoinParams = array('uf_group_id' => $this->_id); + $ufJoinParams = ['uf_group_id' => $this->_id]; CRM_Core_BAO_UFGroup::delUFJoin($ufJoinParams); CRM_Core_BAO_UFGroup::setIsActive($this->_id, 0); } else { // get the submitted form values. - $ids = array(); + $ids = []; $params = $this->controller->exportValues($this->_name); if (!array_key_exists('is_active', $params)) { @@ -390,20 +410,20 @@ public function postProcess() { } elseif ($this->_id) { // this profile has been set to inactive, delete all corresponding UF Join's - $ufJoinParams = array('uf_group_id' => $this->_id); + $ufJoinParams = ['uf_group_id' => $this->_id]; CRM_Core_BAO_UFGroup::delUFJoin($ufJoinParams); } if ($this->_action & CRM_Core_Action::UPDATE) { $url = CRM_Utils_System::url('civicrm/admin/uf/group', 'reset=1&action=browse'); - CRM_Core_Session::setStatus(ts("Your CiviCRM Profile '%1' has been saved.", array(1 => $ufGroup->title)), ts('Profile Saved'), 'success'); + CRM_Core_Session::setStatus(ts("Your CiviCRM Profile '%1' has been saved.", [1 => $ufGroup->title]), ts('Profile Saved'), 'success'); } else { // Jump directly to adding a field if popups are disabled $action = CRM_Core_Resources::singleton()->ajaxPopupsEnabled ? '' : '/add'; $url = CRM_Utils_System::url("civicrm/admin/uf/group/field$action", 'reset=1&new=1&gid=' . $ufGroup->id . '&action=' . ($action ? 'add' : 'browse')); CRM_Core_Session::setStatus(ts('Your CiviCRM Profile \'%1\' has been added. You can add fields to this profile now.', - array(1 => $ufGroup->title) + [1 => $ufGroup->title] ), ts('Profile Added'), 'success'); } $session = CRM_Core_Session::singleton(); @@ -419,7 +439,8 @@ public function postProcess() { * * We do this from the constructor in order to do a translation. */ - public function setDeleteMessage() {} + public function setDeleteMessage() { + } /** * Get the string to display next to the used for field indicating unchangeable uses. From be2fb01f90f5f299dd07402a41fed7c7c7567f00 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Fri, 29 Mar 2019 14:33:40 -0400 Subject: [PATCH 079/121] Short array syntax - auto-format CRM directory --- CRM/Activity/Form/ActivityFilter.php | 4 +- CRM/Activity/Form/ActivityLinks.php | 22 +- CRM/Activity/Form/ActivityView.php | 16 +- CRM/Activity/Form/Search.php | 8 +- CRM/Activity/Form/Task.php | 18 +- CRM/Activity/Form/Task/AddToTag.php | 16 +- CRM/Activity/Form/Task/Batch.php | 24 +- CRM/Activity/Form/Task/Delete.php | 4 +- CRM/Activity/Form/Task/FileOnCase.php | 16 +- CRM/Activity/Form/Task/PickOption.php | 12 +- CRM/Activity/Form/Task/PickProfile.php | 18 +- CRM/Activity/Form/Task/Print.php | 14 +- CRM/Activity/Form/Task/RemoveFromTag.php | 22 +- .../Form/Task/SearchTaskHookSample.php | 14 +- CRM/Activity/Import/Controller.php | 2 +- CRM/Activity/Import/Form/DataSource.php | 6 +- CRM/Activity/Import/Form/Preview.php | 14 +- CRM/Activity/Import/Form/Summary.php | 4 +- CRM/Activity/Import/Parser.php | 24 +- CRM/Activity/Import/Parser/Activity.php | 20 +- CRM/Activity/Page/AJAX.php | 84 +- CRM/Activity/Page/Tab.php | 10 +- CRM/Activity/Page/UserDashboard.php | 2 +- CRM/Activity/Selector/Activity.php | 88 +- CRM/Activity/Selector/Search.php | 48 +- CRM/Activity/StateMachine/Search.php | 2 +- CRM/Activity/Task.php | 66 +- CRM/Admin/Form.php | 28 +- CRM/Admin/Form/CMSUser.php | 24 +- CRM/Admin/Form/ContactType.php | 6 +- CRM/Admin/Form/Extensions.php | 48 +- CRM/Admin/Form/Generic.php | 14 +- CRM/Admin/Form/Job.php | 20 +- CRM/Admin/Form/LabelFormats.php | 56 +- CRM/Admin/Form/LocationType.php | 8 +- CRM/Admin/Form/MailSettings.php | 26 +- CRM/Admin/Form/Mapping.php | 4 +- CRM/Admin/Form/Navigation.php | 18 +- CRM/Admin/Form/OptionGroup.php | 12 +- CRM/Admin/Form/Options.php | 82 +- CRM/Admin/Form/ParticipantStatusType.php | 10 +- CRM/Admin/Form/PaymentProcessor.php | 76 +- CRM/Admin/Form/PaymentProcessorType.php | 74 +- CRM/Admin/Form/PdfFormats.php | 28 +- CRM/Admin/Form/Persistent.php | 20 +- CRM/Admin/Form/Preferences.php | 32 +- CRM/Admin/Form/Preferences/Address.php | 4 +- CRM/Admin/Form/Preferences/Contribute.php | 4 +- CRM/Admin/Form/Preferences/Display.php | 6 +- CRM/Admin/Form/PreferencesDate.php | 10 +- CRM/Admin/Form/RelationshipType.php | 12 +- CRM/Admin/Form/ScheduleReminders.php | 126 +-- CRM/Admin/Form/Setting.php | 26 +- CRM/Admin/Form/Setting/Case.php | 4 +- CRM/Admin/Form/Setting/Component.php | 14 +- CRM/Admin/Form/Setting/Date.php | 4 +- CRM/Admin/Form/Setting/Debugging.php | 4 +- CRM/Admin/Form/Setting/Localization.php | 48 +- CRM/Admin/Form/Setting/Mail.php | 8 +- CRM/Admin/Form/Setting/Mapping.php | 8 +- CRM/Admin/Form/Setting/Miscellaneous.php | 14 +- CRM/Admin/Form/Setting/Path.php | 10 +- CRM/Admin/Form/Setting/Search.php | 8 +- CRM/Admin/Form/Setting/Smtp.php | 28 +- CRM/Admin/Form/Setting/UF.php | 4 +- .../Form/Setting/UpdateConfigBackend.php | 4 +- CRM/Admin/Form/Setting/Url.php | 14 +- CRM/Admin/Form/SettingTrait.php | 2 +- CRM/Admin/Form/WordReplacements.php | 42 +- CRM/Admin/Page/AJAX.php | 58 +- CRM/Admin/Page/APIExplorer.php | 22 +- CRM/Admin/Page/Admin.php | 6 +- CRM/Admin/Page/CKEditorConfig.php | 26 +- CRM/Admin/Page/ContactType.php | 22 +- CRM/Admin/Page/EventTemplate.php | 16 +- CRM/Admin/Page/Extensions.php | 40 +- CRM/Admin/Page/ExtensionsUpgrade.php | 6 +- CRM/Admin/Page/LabelFormats.php | 18 +- CRM/Admin/Page/LocationType.php | 20 +- CRM/Admin/Page/MailSettings.php | 16 +- CRM/Admin/Page/Mapping.php | 12 +- CRM/Admin/Page/MessageTemplates.php | 46 +- CRM/Admin/Page/ParticipantStatusType.php | 28 +- CRM/Admin/Page/PaymentProcessorType.php | 20 +- CRM/Admin/Page/PdfFormats.php | 14 +- CRM/Admin/Page/Persistent.php | 28 +- CRM/Admin/Page/PreferencesDate.php | 8 +- CRM/Admin/Page/RelationshipType.php | 24 +- CRM/Admin/Page/ScheduleReminders.php | 22 +- CRM/Badge/BAO/Badge.php | 38 +- CRM/Badge/BAO/Layout.php | 4 +- CRM/Badge/Form/Layout.php | 48 +- CRM/Badge/Page/AJAX.php | 2 +- CRM/Badge/Page/Layout.php | 20 +- CRM/Batch/BAO/Batch.php | 120 +- CRM/Batch/BAO/EntityBatch.php | 2 +- CRM/Batch/Form/Batch.php | 2 +- CRM/Batch/Form/Entry.php | 140 +-- CRM/Batch/Form/Search.php | 10 +- CRM/Batch/Page/AJAX.php | 18 +- CRM/Bridge/OG/Drupal.php | 22 +- CRM/Bridge/OG/Utils.php | 4 +- CRM/Campaign/BAO/Campaign.php | 76 +- CRM/Campaign/BAO/Petition.php | 112 +- CRM/Campaign/BAO/Query.php | 48 +- CRM/Campaign/BAO/Survey.php | 146 +-- CRM/Campaign/Form/Campaign.php | 40 +- CRM/Campaign/Form/Gotv.php | 10 +- CRM/Campaign/Form/Petition.php | 76 +- CRM/Campaign/Form/Petition/Signature.php | 22 +- CRM/Campaign/Form/Search/Campaign.php | 18 +- CRM/Campaign/Form/Search/Petition.php | 4 +- CRM/Campaign/Form/Search/Survey.php | 8 +- CRM/Campaign/Form/Survey.php | 36 +- CRM/Campaign/Form/Survey/Delete.php | 16 +- CRM/Campaign/Form/Survey/Main.php | 18 +- CRM/Campaign/Form/Survey/Questions.php | 30 +- CRM/Campaign/Form/Survey/Results.php | 86 +- CRM/Campaign/Form/Survey/TabHeader.php | 24 +- CRM/Campaign/Form/SurveyType.php | 10 +- CRM/Campaign/Form/Task.php | 14 +- CRM/Campaign/Form/Task/Interview.php | 132 +-- CRM/Campaign/Form/Task/Print.php | 14 +- CRM/Campaign/Form/Task/Release.php | 26 +- CRM/Campaign/Form/Task/Reserve.php | 74 +- CRM/Campaign/Form/Task/Result.php | 8 +- CRM/Campaign/Info.php | 48 +- CRM/Campaign/Page/AJAX.php | 202 ++-- CRM/Campaign/Page/DashBoard.php | 106 +- CRM/Campaign/Page/Petition/Confirm.php | 4 +- CRM/Campaign/Page/Petition/ThankYou.php | 2 +- CRM/Campaign/Page/SurveyType.php | 34 +- CRM/Campaign/Page/Vote.php | 26 +- CRM/Campaign/PseudoConstant.php | 4 +- CRM/Campaign/Selector/Search.php | 48 +- CRM/Campaign/StateMachine/Search.php | 2 +- CRM/Campaign/Task.php | 34 +- CRM/Case/Audit/Audit.php | 26 +- CRM/Case/Audit/AuditConfig.php | 14 +- CRM/Case/BAO/CaseContact.php | 8 +- CRM/Case/BAO/CaseType.php | 16 +- CRM/Case/BAO/Query.php | 68 +- CRM/Case/Form/Activity.php | 66 +- .../Form/Activity/ChangeCaseStartDate.php | 26 +- CRM/Case/Form/Activity/ChangeCaseStatus.php | 24 +- CRM/Case/Form/Activity/ChangeCaseType.php | 12 +- CRM/Case/Form/Activity/LinkCases.php | 24 +- CRM/Case/Form/Activity/OpenCase.php | 48 +- CRM/Case/Form/ActivityToCase.php | 42 +- CRM/Case/Form/ActivityView.php | 14 +- CRM/Case/Form/AddToCaseAsRole.php | 28 +- CRM/Case/Form/Case.php | 48 +- CRM/Case/Form/CaseView.php | 124 +- CRM/Case/Form/CustomData.php | 24 +- CRM/Case/Form/EditClient.php | 22 +- CRM/Case/Form/Report.php | 16 +- CRM/Case/Form/Search.php | 6 +- CRM/Case/Form/Task/Batch.php | 6 +- CRM/Case/Form/Task/Delete.php | 6 +- CRM/Case/Form/Task/Print.php | 14 +- CRM/Case/Form/Task/Restore.php | 6 +- CRM/Case/Form/Task/Result.php | 8 +- CRM/Case/Form/Task/SearchTaskHookSample.php | 14 +- CRM/Case/Info.php | 70 +- CRM/Case/ManagedEntities.php | 32 +- CRM/Case/Page/AJAX.php | 38 +- CRM/Case/Page/DashBoard.php | 4 +- CRM/Case/Page/Tab.php | 14 +- CRM/Case/PseudoConstant.php | 8 +- CRM/Case/Selector/Search.php | 84 +- CRM/Case/StateMachine/Search.php | 2 +- CRM/Case/Task.php | 46 +- CRM/Case/XMLProcessor.php | 2 +- CRM/Case/XMLProcessor/Process.php | 50 +- CRM/Case/XMLProcessor/Settings.php | 2 +- CRM/Case/XMLRepository.php | 26 +- CRM/Contact/ActionMapping.php | 24 +- CRM/Contact/BAO/Contact/Location.php | 34 +- CRM/Contact/BAO/Contact/Permission.php | 42 +- CRM/Contact/BAO/Contact/Utils.php | 100 +- CRM/Contact/BAO/ContactType.php | 90 +- CRM/Contact/BAO/Group.php | 156 +-- CRM/Contact/BAO/GroupContact.php | 84 +- CRM/Contact/BAO/GroupContactCache.php | 54 +- CRM/Contact/BAO/GroupNesting.php | 14 +- CRM/Contact/BAO/GroupNestingCache.php | 24 +- CRM/Contact/BAO/Household.php | 6 +- CRM/Contact/BAO/Individual.php | 56 +- CRM/Contact/BAO/ProximityQuery.php | 30 +- CRM/Contact/BAO/Query.php | 456 ++++---- CRM/Contact/BAO/Query/Hook.php | 4 +- CRM/Contact/BAO/RelationshipType.php | 8 +- CRM/Contact/BAO/SavedSearch.php | 32 +- CRM/Contact/BAO/SearchCustom.php | 14 +- CRM/Contact/Form/Contact.php | 158 +-- CRM/Contact/Form/CustomData.php | 36 +- CRM/Contact/Form/DedupeFind.php | 16 +- CRM/Contact/Form/DedupeRules.php | 54 +- CRM/Contact/Form/Domain.php | 36 +- CRM/Contact/Form/Edit/Address.php | 76 +- .../Form/Edit/CommunicationPreferences.php | 48 +- CRM/Contact/Form/Edit/Demographics.php | 8 +- CRM/Contact/Form/Edit/Email.php | 18 +- CRM/Contact/Form/Edit/Household.php | 8 +- CRM/Contact/Form/Edit/IM.php | 8 +- CRM/Contact/Form/Edit/Individual.php | 20 +- CRM/Contact/Form/Edit/Lock.php | 4 +- CRM/Contact/Form/Edit/Notes.php | 4 +- CRM/Contact/Form/Edit/OpenID.php | 2 +- CRM/Contact/Form/Edit/Organization.php | 6 +- CRM/Contact/Form/Edit/Phone.php | 14 +- CRM/Contact/Form/Edit/TagsAndGroups.php | 14 +- CRM/Contact/Form/Edit/Website.php | 4 +- CRM/Contact/Form/GroupContact.php | 18 +- CRM/Contact/Form/Inline.php | 20 +- CRM/Contact/Form/Inline/Address.php | 6 +- .../Form/Inline/CommunicationPreferences.php | 2 +- CRM/Contact/Form/Inline/ContactInfo.php | 4 +- CRM/Contact/Form/Inline/ContactName.php | 4 +- CRM/Contact/Form/Inline/Email.php | 10 +- CRM/Contact/Form/Inline/IM.php | 8 +- CRM/Contact/Form/Inline/Lock.php | 8 +- CRM/Contact/Form/Inline/OpenID.php | 8 +- CRM/Contact/Form/Inline/Phone.php | 8 +- CRM/Contact/Form/Inline/Website.php | 14 +- CRM/Contact/Form/Location.php | 8 +- CRM/Contact/Form/Merge.php | 54 +- CRM/Contact/Form/RelatedContact.php | 24 +- CRM/Contact/Form/Relationship.php | 136 +-- CRM/Contact/Form/Search.php | 82 +- CRM/Contact/Form/Search/Basic.php | 22 +- CRM/Contact/Form/Search/Builder.php | 46 +- CRM/Contact/Form/Search/Criteria.php | 148 +-- .../Form/Search/Custom/ActivitySearch.php | 24 +- CRM/Contact/Form/Search/Custom/Base.php | 12 +- CRM/Contact/Form/Search/Custom/Basic.php | 24 +- .../Form/Search/Custom/ContribSYBNT.php | 40 +- .../Search/Custom/ContributionAggregate.php | 16 +- CRM/Contact/Form/Search/Custom/DateAdded.php | 28 +- .../Form/Search/Custom/EventAggregate.php | 22 +- CRM/Contact/Form/Search/Custom/FullText.php | 40 +- .../Custom/FullText/AbstractPartialQuery.php | 42 +- .../Form/Search/Custom/FullText/Activity.php | 18 +- .../Form/Search/Custom/FullText/Case.php | 14 +- .../Form/Search/Custom/FullText/Contact.php | 48 +- .../Search/Custom/FullText/Contribution.php | 28 +- .../Search/Custom/FullText/Membership.php | 18 +- .../Search/Custom/FullText/Participant.php | 28 +- CRM/Contact/Form/Search/Custom/Group.php | 34 +- .../Form/Search/Custom/MultipleValues.php | 32 +- .../Form/Search/Custom/PostalMailing.php | 16 +- CRM/Contact/Form/Search/Custom/PriceSet.php | 24 +- CRM/Contact/Form/Search/Custom/Proximity.php | 26 +- .../Form/Search/Custom/RandomSegment.php | 12 +- CRM/Contact/Form/Search/Custom/Sample.php | 22 +- .../Form/Search/Custom/TagContributions.php | 20 +- .../Form/Search/Custom/ZipCodeRange.php | 18 +- CRM/Contact/Form/Task.php | 70 +- CRM/Contact/Form/Task/AddToGroup.php | 38 +- CRM/Contact/Form/Task/AddToParentClass.php | 68 +- CRM/Contact/Form/Task/AddToTag.php | 16 +- CRM/Contact/Form/Task/AlterPreferences.php | 16 +- CRM/Contact/Form/Task/Batch.php | 34 +- CRM/Contact/Form/Task/Delete.php | 40 +- CRM/Contact/Form/Task/Email.php | 14 +- CRM/Contact/Form/Task/HookSample.php | 6 +- CRM/Contact/Form/Task/Label.php | 60 +- CRM/Contact/Form/Task/LabelCommon.php | 38 +- CRM/Contact/Form/Task/Map.php | 18 +- CRM/Contact/Form/Task/Merge.php | 4 +- CRM/Contact/Form/Task/PDF.php | 4 +- CRM/Contact/Form/Task/PDFLetterCommon.php | 52 +- CRM/Contact/Form/Task/PickProfile.php | 10 +- CRM/Contact/Form/Task/Print.php | 18 +- CRM/Contact/Form/Task/ProximityCommon.php | 12 +- CRM/Contact/Form/Task/RemoveFromGroup.php | 22 +- CRM/Contact/Form/Task/RemoveFromTag.php | 22 +- CRM/Contact/Form/Task/Result.php | 12 +- CRM/Contact/Form/Task/SMSCommon.php | 72 +- CRM/Contact/Form/Task/SaveSearch.php | 16 +- CRM/Contact/Form/Task/SaveSearch/Update.php | 6 +- CRM/Contact/Form/Task/Unhold.php | 8 +- CRM/Contact/Form/Task/Useradd.php | 38 +- CRM/Contact/Import/Controller.php | 2 +- CRM/Contact/Import/Form/DataSource.php | 48 +- CRM/Contact/Import/Form/Summary.php | 4 +- CRM/Contact/Import/Page/AJAX.php | 2 +- CRM/Contact/Import/Parser.php | 126 +-- CRM/Contact/Import/Parser/Contact.php | 248 ++-- CRM/Contact/Page/AJAX.php | 114 +- CRM/Contact/Page/CustomSearch.php | 2 +- CRM/Contact/Page/Dashlet.php | 10 +- CRM/Contact/Page/DedupeException.php | 20 +- CRM/Contact/Page/DedupeFind.php | 14 +- CRM/Contact/Page/DedupeMerge.php | 16 +- CRM/Contact/Page/DedupeRules.php | 22 +- CRM/Contact/Page/ImageFile.php | 6 +- CRM/Contact/Page/Inline/Address.php | 14 +- .../Page/Inline/CommunicationPreferences.php | 4 +- CRM/Contact/Page/Inline/ContactInfo.php | 4 +- CRM/Contact/Page/Inline/Demographics.php | 4 +- CRM/Contact/Page/Inline/Email.php | 6 +- CRM/Contact/Page/Inline/IM.php | 4 +- CRM/Contact/Page/Inline/OpenID.php | 4 +- CRM/Contact/Page/Inline/Phone.php | 6 +- CRM/Contact/Page/Inline/Website.php | 2 +- CRM/Contact/Page/SavedSearch.php | 20 +- CRM/Contact/Page/View.php | 28 +- CRM/Contact/Page/View/ContactSmartGroup.php | 4 +- CRM/Contact/Page/View/CustomData.php | 2 +- CRM/Contact/Page/View/GroupContact.php | 4 +- CRM/Contact/Page/View/Log.php | 6 +- CRM/Contact/Page/View/Note.php | 50 +- CRM/Contact/Page/View/Print.php | 6 +- CRM/Contact/Page/View/UserDashBoard.php | 40 +- CRM/Contact/Page/View/Vcard.php | 8 +- CRM/Contact/Selector.php | 196 ++-- CRM/Contact/Selector/Custom.php | 40 +- CRM/Contact/StateMachine/Search.php | 2 +- CRM/Contribute/ActionMapping/ByPage.php | 14 +- CRM/Contribute/ActionMapping/ByType.php | 16 +- CRM/Contribute/BAO/Contribution/Utils.php | 82 +- CRM/Contribute/BAO/ContributionPage.php | 218 ++-- CRM/Contribute/BAO/ContributionRecur.php | 92 +- CRM/Contribute/BAO/Premium.php | 18 +- CRM/Contribute/BAO/Query.php | 124 +- CRM/Contribute/BAO/Widget.php | 30 +- CRM/Contribute/Form.php | 4 +- CRM/Contribute/Form/AbstractEditPayment.php | 56 +- CRM/Contribute/Form/AdditionalInfo.php | 68 +- CRM/Contribute/Form/AdditionalPayment.php | 66 +- CRM/Contribute/Form/CancelSubscription.php | 44 +- CRM/Contribute/Form/Contribution.php | 162 +-- CRM/Contribute/Form/Contribution/Confirm.php | 184 +-- CRM/Contribute/Form/Contribution/Main.php | 82 +- CRM/Contribute/Form/Contribution/ThankYou.php | 24 +- CRM/Contribute/Form/ContributionBase.php | 100 +- CRM/Contribute/Form/ContributionCharts.php | 18 +- CRM/Contribute/Form/ContributionPage.php | 72 +- .../Form/ContributionPage/AddProduct.php | 44 +- .../Form/ContributionPage/Amount.php | 128 +-- .../Form/ContributionPage/Custom.php | 26 +- .../Form/ContributionPage/Delete.php | 16 +- .../Form/ContributionPage/Premium.php | 8 +- .../Form/ContributionPage/Settings.php | 92 +- .../Form/ContributionPage/TabHeader.php | 52 +- .../Form/ContributionPage/ThankYou.php | 8 +- .../Form/ContributionPage/Widget.php | 66 +- CRM/Contribute/Form/ContributionView.php | 26 +- CRM/Contribute/Form/ManagePremiums.php | 46 +- CRM/Contribute/Form/Search.php | 12 +- CRM/Contribute/Form/SearchContribution.php | 10 +- CRM/Contribute/Form/SoftCredit.php | 14 +- CRM/Contribute/Form/Task.php | 28 +- CRM/Contribute/Form/Task/Batch.php | 30 +- CRM/Contribute/Form/Task/Delete.php | 16 +- CRM/Contribute/Form/Task/Invoice.php | 96 +- CRM/Contribute/Form/Task/PDF.php | 54 +- CRM/Contribute/Form/Task/PDFLetter.php | 30 +- CRM/Contribute/Form/Task/PDFLetterCommon.php | 52 +- CRM/Contribute/Form/Task/PickProfile.php | 14 +- CRM/Contribute/Form/Task/Print.php | 14 +- CRM/Contribute/Form/Task/Result.php | 8 +- .../Form/Task/SearchTaskHookSample.php | 14 +- CRM/Contribute/Form/Task/Status.php | 32 +- CRM/Contribute/Form/UpdateSubscription.php | 62 +- CRM/Contribute/Import/Controller.php | 2 +- CRM/Contribute/Import/Field.php | 2 +- CRM/Contribute/Import/Form/DataSource.php | 10 +- CRM/Contribute/Import/Form/Preview.php | 14 +- CRM/Contribute/Import/Form/Summary.php | 4 +- CRM/Contribute/Import/Parser.php | 38 +- CRM/Contribute/Import/Parser/Contribution.php | 52 +- CRM/Contribute/Info.php | 50 +- CRM/Contribute/Page/AJAX.php | 8 +- CRM/Contribute/Page/ContributionRecur.php | 10 +- .../Page/ContributionRecurPayments.php | 32 +- CRM/Contribute/Page/DashBoard.php | 10 +- CRM/Contribute/Page/ManagePremiums.php | 30 +- CRM/Contribute/Page/Premium.php | 22 +- CRM/Contribute/Page/Tab.php | 46 +- CRM/Contribute/Page/UserDashboard.php | 8 +- CRM/Contribute/PseudoConstant.php | 16 +- CRM/Contribute/Selector/Search.php | 112 +- CRM/Contribute/StateMachine/Contribution.php | 4 +- .../StateMachine/ContributionPage.php | 4 +- CRM/Contribute/StateMachine/Search.php | 2 +- CRM/Contribute/Task.php | 58 +- CRM/Contribute/Tokens.php | 10 +- CRM/Core/Action.php | 8 +- CRM/Core/BAO/ActionSchedule.php | 106 +- CRM/Core/BAO/Address.php | 120 +- CRM/Core/BAO/Block.php | 34 +- CRM/Core/BAO/CMSUser.php | 12 +- CRM/Core/BAO/Cache.php | 28 +- CRM/Core/BAO/Cache/Psr16.php | 2 +- CRM/Core/BAO/ConfigSetting.php | 26 +- CRM/Core/BAO/Country.php | 8 +- CRM/Core/BAO/CustomGroup.php | 206 ++-- CRM/Core/BAO/CustomOption.php | 72 +- CRM/Core/BAO/CustomQuery.php | 58 +- CRM/Core/BAO/CustomValue.php | 10 +- CRM/Core/BAO/CustomValueTable.php | 86 +- CRM/Core/BAO/Dashboard.php | 58 +- CRM/Core/BAO/Discount.php | 2 +- CRM/Core/BAO/Domain.php | 26 +- CRM/Core/BAO/Email.php | 32 +- CRM/Core/BAO/EntityTag.php | 64 +- CRM/Core/BAO/Extension.php | 14 +- CRM/Core/BAO/File.php | 64 +- CRM/Core/BAO/FinancialTrxn.php | 92 +- CRM/Core/BAO/IM.php | 16 +- CRM/Core/BAO/Job.php | 12 +- CRM/Core/BAO/LabelFormat.php | 104 +- CRM/Core/BAO/Location.php | 66 +- CRM/Core/BAO/LocationType.php | 8 +- CRM/Core/BAO/Log.php | 12 +- CRM/Core/BAO/MailSettings.php | 4 +- CRM/Core/BAO/Mapping.php | 188 +-- CRM/Core/BAO/MessageTemplate.php | 70 +- CRM/Core/BAO/Navigation.php | 60 +- CRM/Core/BAO/OpenID.php | 8 +- CRM/Core/BAO/OptionGroup.php | 16 +- CRM/Core/BAO/OptionValue.php | 38 +- CRM/Core/BAO/PaperSize.php | 32 +- CRM/Core/BAO/PdfFormat.php | 60 +- CRM/Core/BAO/Persistent.php | 4 +- CRM/Core/BAO/Phone.php | 42 +- CRM/Core/BAO/PreferencesDate.php | 2 +- CRM/Core/BAO/PrevNextCache.php | 96 +- CRM/Core/BAO/RecurringEntity.php | 186 +-- CRM/Core/BAO/SchemaHandler.php | 60 +- CRM/Core/BAO/Setting.php | 34 +- CRM/Core/BAO/Tag.php | 92 +- CRM/Core/BAO/UFField.php | 168 +-- CRM/Core/BAO/UFJoin.php | 8 +- CRM/Core/BAO/UFMatch.php | 50 +- CRM/Core/BAO/Website.php | 12 +- CRM/Core/BAO/WordReplacement.php | 44 +- CRM/Core/ClassLoader.php | 14 +- CRM/Core/CodeGen/Config.php | 6 +- CRM/Core/CodeGen/DAO.php | 6 +- CRM/Core/CodeGen/I18n.php | 14 +- CRM/Core/CodeGen/Main.php | 12 +- CRM/Core/CodeGen/Schema.php | 10 +- CRM/Core/CodeGen/Specification.php | 56 +- .../CodeGen/Util/ArraySyntaxConverter.php | 10 +- CRM/Core/CodeGen/Util/File.php | 2 +- CRM/Core/CodeGen/Util/Smarty.php | 2 +- CRM/Core/CommunityMessages.php | 16 +- CRM/Core/Component.php | 20 +- CRM/Core/Component/Info.php | 8 +- CRM/Core/Config.php | 24 +- CRM/Core/Config/MagicMerge.php | 216 ++-- CRM/Core/Config/Runtime.php | 8 +- CRM/Core/Controller.php | 30 +- CRM/Core/Controller/Simple.php | 4 +- CRM/Core/DAO.php | 140 +-- CRM/Core/DAO/AllCoreTables.php | 26 +- CRM/Core/DAO/permissions.php | 2 +- CRM/Core/Error.php | 64 +- CRM/Core/Error/Log.php | 6 +- CRM/Core/Exception.php | 6 +- CRM/Core/Form.php | 248 ++-- CRM/Core/Form/Date.php | 14 +- CRM/Core/Form/EntityFormTrait.php | 20 +- CRM/Core/Form/RecurringEntity.php | 96 +- CRM/Core/Form/Renderer.php | 34 +- CRM/Core/Form/Search.php | 32 +- CRM/Core/Form/ShortCode.php | 118 +- CRM/Core/Form/Tag.php | 20 +- CRM/Core/Form/Task.php | 16 +- CRM/Core/Form/Task/Batch.php | 26 +- CRM/Core/Form/Task/PDFLetterCommon.php | 60 +- CRM/Core/Form/Task/PickProfile.php | 16 +- CRM/Core/I18n.php | 34 +- CRM/Core/I18n/Form.php | 10 +- CRM/Core/I18n/PseudoConstant.php | 10 +- CRM/Core/I18n/Schema.php | 56 +- CRM/Core/I18n/SchemaStructure_4_2_alpha1.php | 144 +-- CRM/Core/I18n/SchemaStructure_4_3_1.php | 144 +-- CRM/Core/I18n/SchemaStructure_4_5_alpha1.php | 144 +-- CRM/Core/I18n/SchemaStructure_4_5_beta2.php | 148 +-- CRM/Core/I18n/SchemaStructure_4_7_alpha1.php | 152 +-- CRM/Core/IDS.php | 36 +- CRM/Core/InnoDBIndexer.php | 78 +- CRM/Core/Invoke.php | 6 +- CRM/Core/JobManager.php | 12 +- CRM/Core/Joomla.php | 6 +- CRM/Core/Lock.php | 12 +- CRM/Core/ManagedEntities.php | 48 +- CRM/Core/Module.php | 2 +- CRM/Core/OptionGroup.php | 80 +- CRM/Core/OptionValue.php | 56 +- CRM/Core/Page.php | 20 +- CRM/Core/Page/AJAX.php | 26 +- CRM/Core/Page/AJAX/Attachment.php | 26 +- CRM/Core/Page/AJAX/Location.php | 66 +- CRM/Core/Page/AJAX/RecurringEntity.php | 2 +- CRM/Core/Page/Basic.php | 14 +- CRM/Core/Page/QUnit.php | 8 +- CRM/Core/Page/RecurringEntityPreview.php | 6 +- CRM/Core/Page/Redirect.php | 4 +- CRM/Core/Payment/AuthorizeNet.php | 38 +- CRM/Core/Payment/AuthorizeNetIPN.php | 22 +- CRM/Core/Payment/BaseIPN.php | 42 +- CRM/Core/Payment/Dummy.php | 14 +- CRM/Core/Payment/Elavon.php | 6 +- CRM/Core/Payment/FirstData.php | 4 +- CRM/Core/Payment/Form.php | 10 +- CRM/Core/Payment/Manual.php | 14 +- CRM/Core/Payment/PayJunction.php | 14 +- CRM/Core/Payment/PayPalIPN.php | 14 +- CRM/Core/Payment/PayPalImpl.php | 98 +- CRM/Core/Payment/PayPalProIPN.php | 54 +- CRM/Core/Payment/PayflowPro.php | 10 +- CRM/Core/Payment/PaymentExpress.php | 6 +- CRM/Core/Payment/PaymentExpressIPN.php | 14 +- CRM/Core/Payment/ProcessorForm.php | 6 +- CRM/Core/Payment/Realex.php | 24 +- CRM/Core/Payment/eWAY.php | 2 +- CRM/Core/Permission.php | 796 ++++++------- CRM/Core/Permission/Backdrop.php | 8 +- CRM/Core/Permission/Base.php | 8 +- CRM/Core/Permission/Drupal.php | 8 +- CRM/Core/Permission/Drupal6.php | 16 +- CRM/Core/Permission/Drupal8.php | 8 +- CRM/Core/Permission/DrupalBase.php | 14 +- CRM/Core/Permission/Joomla.php | 6 +- CRM/Core/Permission/Temp.php | 2 +- CRM/Core/Permission/WordPress.php | 4 +- CRM/Core/PrevNextCache/Redis.php | 2 +- CRM/Core/PrevNextCache/Sql.php | 24 +- CRM/Core/PseudoConstant.php | 132 +-- CRM/Core/QuickForm/Action/Display.php | 4 +- CRM/Core/QuickForm/Action/Upload.php | 8 +- CRM/Core/QuickForm/GroupMultiSelect.php | 50 +- CRM/Core/QuickForm/NestedAdvMultiSelect.php | 2 +- CRM/Core/Reference/Basic.php | 18 +- CRM/Core/Reference/Dynamic.php | 22 +- CRM/Core/Region.php | 16 +- CRM/Core/Resources.php | 84 +- CRM/Core/Resources/Strings.php | 4 +- CRM/Core/ScheduledJob.php | 12 +- CRM/Core/SelectValues.php | 236 ++-- CRM/Core/Selector/Base.php | 2 +- CRM/Core/Selector/Controller.php | 10 +- CRM/Core/Session.php | 24 +- CRM/Core/ShowHideBlocks.php | 16 +- CRM/Core/Smarty.php | 14 +- CRM/Core/Smarty/plugins/block.crmButton.php | 2 +- CRM/Core/Smarty/plugins/block.localize.php | 2 +- CRM/Core/Smarty/plugins/function.crmAPI.php | 2 +- .../Smarty/plugins/function.crmAttributes.php | 2 +- .../Smarty/plugins/function.crmCrudLink.php | 4 +- .../Smarty/plugins/function.crmScript.php | 4 +- .../Smarty/plugins/function.crmSetting.php | 2 +- CRM/Core/Smarty/plugins/function.help.php | 4 +- .../Smarty/plugins/function.isValueChange.php | 2 +- .../Smarty/plugins/function.sectionTotal.php | 2 +- .../function.simpleActivityContacts.php | 16 +- .../Smarty/plugins/modifier.crmAddClass.php | 2 +- CRM/Core/Smarty/resources/String.php | 4 +- CRM/Core/StateMachine.php | 4 +- CRM/Core/TableHierarchy.php | 4 +- CRM/Core/Task.php | 10 +- CRM/Core/TemporaryErrorScope.php | 12 +- CRM/Custom/Form/ChangeFieldType.php | 70 +- CRM/Custom/Form/CustomData.php | 6 +- CRM/Custom/Form/CustomDataByType.php | 2 +- CRM/Custom/Form/DeleteField.php | 20 +- CRM/Custom/Form/DeleteGroup.php | 20 +- CRM/Custom/Form/Field.php | 140 +-- CRM/Custom/Form/Group.php | 74 +- CRM/Custom/Form/MoveField.php | 26 +- CRM/Custom/Form/Option.php | 100 +- CRM/Custom/Form/Preview.php | 18 +- CRM/Custom/Import/Controller.php | 2 +- CRM/Custom/Import/Form/DataSource.php | 10 +- CRM/Custom/Import/Form/MapField.php | 22 +- CRM/Custom/Import/Form/Preview.php | 10 +- CRM/Custom/Import/Parser.php | 22 +- CRM/Custom/Import/Parser/Api.php | 36 +- CRM/Custom/Page/AJAX.php | 22 +- CRM/Custom/Page/Field.php | 46 +- CRM/Custom/Page/Group.php | 42 +- CRM/Custom/Page/Option.php | 54 +- CRM/Cxn/ApiRouter.php | 2 +- CRM/Cxn/BAO/Cxn.php | 10 +- CRM/Cxn/CiviCxnHttp.php | 16 +- CRM/Cxn/CiviCxnStore.php | 20 +- CRM/Dashlet/Page/AllCases.php | 2 +- CRM/Dashlet/Page/Blog.php | 10 +- CRM/Dashlet/Page/GettingStarted.php | 8 +- CRM/Dashlet/Page/MyCases.php | 2 +- .../BAO/QueryBuilder/IndividualGeneral.php | 4 +- .../BAO/QueryBuilder/IndividualSupervised.php | 28 +- .../QueryBuilder/IndividualUnsupervised.php | 16 +- CRM/Dedupe/BAO/Rule.php | 12 +- CRM/Dedupe/BAO/RuleGroup.php | 50 +- CRM/Dedupe/Finder.php | 54 +- CRM/Event/ActionMapping.php | 18 +- CRM/Event/BAO/Event.php | 276 ++--- CRM/Event/BAO/Participant.php | 254 ++--- CRM/Event/BAO/ParticipantPayment.php | 16 +- CRM/Event/BAO/ParticipantStatusType.php | 16 +- CRM/Event/BAO/Query.php | 80 +- CRM/Event/Badge.php | 20 +- CRM/Event/Badge/Logo.php | 10 +- CRM/Event/Badge/Logo5395.php | 10 +- CRM/Event/Badge/NameTent.php | 4 +- CRM/Event/Cart/BAO/Cart.php | 34 +- CRM/Event/Cart/BAO/Conference.php | 4 +- CRM/Event/Cart/BAO/EventInCart.php | 36 +- CRM/Event/Cart/BAO/MerParticipant.php | 12 +- CRM/Event/Cart/Form/Cart.php | 20 +- .../Cart/Form/Checkout/ConferenceEvents.php | 30 +- .../Form/Checkout/ParticipantsAndPrices.php | 40 +- CRM/Event/Cart/Form/Checkout/Payment.php | 124 +- CRM/Event/Cart/Form/Checkout/ThankYou.php | 20 +- CRM/Event/Cart/Form/MerParticipant.php | 22 +- CRM/Event/Cart/Page/AddToCart.php | 4 +- CRM/Event/Cart/Page/CheckoutAJAX.php | 4 +- CRM/Event/Cart/Page/RemoveFromCart.php | 2 +- CRM/Event/Cart/StateMachine/Checkout.php | 6 +- CRM/Event/Form/EventFees.php | 54 +- CRM/Event/Form/ManageEvent.php | 68 +- CRM/Event/Form/ManageEvent/Conference.php | 10 +- CRM/Event/Form/ManageEvent/Delete.php | 18 +- CRM/Event/Form/ManageEvent/EventInfo.php | 24 +- CRM/Event/Form/ManageEvent/Fee.php | 86 +- CRM/Event/Form/ManageEvent/Location.php | 26 +- CRM/Event/Form/ManageEvent/Registration.php | 136 +-- CRM/Event/Form/ManageEvent/Repeat.php | 70 +- .../Form/ManageEvent/ScheduleReminders.php | 6 +- CRM/Event/Form/ManageEvent/TabHeader.php | 46 +- CRM/Event/Form/Participant.php | 186 +-- CRM/Event/Form/ParticipantFeeSelection.php | 54 +- CRM/Event/Form/ParticipantView.php | 28 +- .../Registration/AdditionalParticipant.php | 84 +- CRM/Event/Form/Registration/Confirm.php | 96 +- .../Form/Registration/ParticipantConfirm.php | 52 +- CRM/Event/Form/Registration/Register.php | 84 +- CRM/Event/Form/Registration/ThankYou.php | 8 +- CRM/Event/Form/Search.php | 24 +- CRM/Event/Form/SearchEvent.php | 22 +- CRM/Event/Form/SelfSvcTransfer.php | 125 +- CRM/Event/Form/SelfSvcUpdate.php | 66 +- CRM/Event/Form/Task.php | 16 +- CRM/Event/Form/Task/AddToGroup.php | 36 +- CRM/Event/Form/Task/Badge.php | 6 +- CRM/Event/Form/Task/Batch.php | 44 +- CRM/Event/Form/Task/Cancel.php | 2 +- CRM/Event/Form/Task/Delete.php | 10 +- CRM/Event/Form/Task/ParticipantStatus.php | 4 +- CRM/Event/Form/Task/PickProfile.php | 8 +- CRM/Event/Form/Task/Print.php | 14 +- CRM/Event/Form/Task/SaveSearch.php | 8 +- CRM/Event/Form/Task/SaveSearch/Update.php | 6 +- CRM/Event/Form/Task/SearchTaskHookSample.php | 14 +- CRM/Event/Import/Controller.php | 2 +- CRM/Event/Import/Form/DataSource.php | 8 +- CRM/Event/Import/Form/Preview.php | 10 +- CRM/Event/Import/Form/Summary.php | 4 +- CRM/Event/Import/Parser.php | 24 +- CRM/Event/Import/Parser/Participant.php | 30 +- CRM/Event/Info.php | 72 +- CRM/Event/Page/AJAX.php | 4 +- CRM/Event/Page/EventInfo.php | 18 +- CRM/Event/Page/ManageEvent.php | 108 +- .../ParticipantListing/NameStatusAndDate.php | 26 +- CRM/Event/Page/ParticipantListing/Simple.php | 22 +- CRM/Event/Page/Tab.php | 4 +- CRM/Event/PseudoConstant.php | 16 +- CRM/Event/Selector/Search.php | 94 +- CRM/Event/StateMachine/Registration.php | 6 +- CRM/Event/StateMachine/Search.php | 2 +- CRM/Event/Task.php | 70 +- CRM/Event/Tokens.php | 8 +- CRM/Export/BAO/Export.php | 94 +- CRM/Export/BAO/ExportProcessor.php | 14 +- CRM/Export/Controller/Standalone.php | 8 +- CRM/Export/Form/Map.php | 22 +- CRM/Export/Form/Select.php | 66 +- CRM/Export/StateMachine/Standalone.php | 4 +- CRM/Extension/Container/Basic.php | 22 +- CRM/Extension/Container/Collection.php | 4 +- CRM/Extension/Container/Static.php | 2 +- CRM/Extension/Info.php | 14 +- CRM/Extension/Manager.php | 34 +- CRM/Extension/Manager/Payment.php | 22 +- CRM/Extension/Manager/Report.php | 8 +- CRM/Extension/Manager/Search.php | 8 +- CRM/Extension/Mapper.php | 22 +- CRM/Extension/System.php | 16 +- CRM/Extension/Upgrades.php | 4 +- CRM/Financial/BAO/ExportFormat.php | 16 +- CRM/Financial/BAO/ExportFormat/CSV.php | 16 +- CRM/Financial/BAO/ExportFormat/IIF.php | 56 +- CRM/Financial/BAO/FinancialItem.php | 24 +- CRM/Financial/BAO/FinancialType.php | 34 +- CRM/Financial/BAO/FinancialTypeAccount.php | 56 +- CRM/Financial/BAO/Payment.php | 6 +- CRM/Financial/BAO/PaymentProcessor.php | 62 +- CRM/Financial/BAO/PaymentProcessorType.php | 8 +- CRM/Financial/Form/BatchTransaction.php | 52 +- CRM/Financial/Form/Export.php | 22 +- CRM/Financial/Form/FinancialAccount.php | 26 +- CRM/Financial/Form/FinancialBatch.php | 56 +- CRM/Financial/Form/FinancialTypeAccount.php | 48 +- CRM/Financial/Form/Payment.php | 4 +- CRM/Financial/Form/PaymentEdit.php | 78 +- CRM/Financial/Form/Search.php | 34 +- CRM/Financial/Page/AJAX.php | 106 +- CRM/Financial/Page/BatchTransaction.php | 20 +- CRM/Financial/Page/FinancialAccount.php | 26 +- CRM/Financial/Page/FinancialBatch.php | 2 +- CRM/Financial/Page/FinancialType.php | 34 +- CRM/Financial/Page/FinancialTypeAccount.php | 26 +- CRM/Friend/BAO/Friend.php | 40 +- CRM/Friend/Form.php | 40 +- CRM/Friend/Form/Contribute.php | 2 +- CRM/Friend/Form/Event.php | 2 +- CRM/Grant/BAO/Grant.php | 46 +- CRM/Grant/BAO/Query.php | 24 +- CRM/Grant/Form/Grant.php | 38 +- CRM/Grant/Form/GrantView.php | 16 +- CRM/Grant/Form/Task.php | 16 +- CRM/Grant/Form/Task/Delete.php | 4 +- CRM/Grant/Form/Task/Print.php | 14 +- CRM/Grant/Form/Task/Result.php | 8 +- CRM/Grant/Form/Task/SearchTaskHookSample.php | 14 +- CRM/Grant/Form/Task/Update.php | 6 +- CRM/Grant/Info.php | 36 +- CRM/Grant/Selector/Search.php | 78 +- CRM/Grant/StateMachine/Search.php | 2 +- CRM/Grant/Task.php | 30 +- CRM/Group/Form/Search.php | 18 +- CRM/Group/Page/AJAX.php | 6 +- CRM/Group/StateMachine.php | 4 +- CRM/Import/DataSource/CSV.php | 12 +- CRM/Import/DataSource/SQL.php | 14 +- CRM/Import/Form/DataSource.php | 32 +- CRM/Import/Form/Preview.php | 16 +- CRM/Import/Parser.php | 16 +- CRM/Import/StateMachine.php | 4 +- CRM/Logging/Differ.php | 88 +- CRM/Logging/ReportDetail.php | 46 +- CRM/Logging/ReportSummary.php | 138 +-- CRM/Logging/Reverter.php | 24 +- CRM/Logging/Schema.php | 110 +- CRM/Mailing/ActionTokens.php | 4 +- CRM/Mailing/BAO/BouncePattern.php | 10 +- CRM/Mailing/BAO/MailingAB.php | 12 +- CRM/Mailing/BAO/MailingComponent.php | 16 +- CRM/Mailing/BAO/MailingJob.php | 88 +- CRM/Mailing/BAO/Query.php | 48 +- CRM/Mailing/BAO/Recipients.php | 4 +- CRM/Mailing/BAO/Spool.php | 10 +- CRM/Mailing/BAO/TrackableURL.php | 2 +- CRM/Mailing/Controller/Send.php | 2 +- CRM/Mailing/Event/BAO/Confirm.php | 6 +- CRM/Mailing/Event/BAO/Delivered.php | 8 +- CRM/Mailing/Event/BAO/Forward.php | 26 +- CRM/Mailing/Event/BAO/Opened.php | 14 +- CRM/Mailing/Event/BAO/Queue.php | 10 +- CRM/Mailing/Event/BAO/Reply.php | 20 +- CRM/Mailing/Event/BAO/Resubscribe.php | 12 +- CRM/Mailing/Event/BAO/Subscribe.php | 48 +- CRM/Mailing/Event/BAO/TrackableURLOpen.php | 30 +- CRM/Mailing/Event/BAO/Unsubscribe.php | 42 +- CRM/Mailing/Form/Approve.php | 20 +- CRM/Mailing/Form/Browse.php | 12 +- CRM/Mailing/Form/Component.php | 54 +- CRM/Mailing/Form/ForwardMailing.php | 36 +- CRM/Mailing/Form/Optout.php | 16 +- CRM/Mailing/Form/Search.php | 20 +- CRM/Mailing/Form/Subscribe.php | 24 +- CRM/Mailing/Form/Task.php | 14 +- CRM/Mailing/Form/Task/AdhocMailing.php | 24 +- CRM/Mailing/Form/Task/Print.php | 14 +- CRM/Mailing/Form/Unsubscribe.php | 18 +- CRM/Mailing/Info.php | 118 +- CRM/Mailing/MailStore.php | 8 +- CRM/Mailing/MailStore/Imap.php | 6 +- CRM/Mailing/MailStore/Localdir.php | 14 +- CRM/Mailing/MailStore/Maildir.php | 16 +- CRM/Mailing/MailStore/Mbox.php | 8 +- CRM/Mailing/MailStore/Pop3.php | 10 +- CRM/Mailing/Page/AJAX.php | 6 +- CRM/Mailing/Page/Browse.php | 12 +- CRM/Mailing/Page/Component.php | 16 +- CRM/Mailing/Page/Preview.php | 4 +- CRM/Mailing/Page/Report.php | 2 +- CRM/Mailing/Page/Tab.php | 2 +- CRM/Mailing/Page/View.php | 4 +- CRM/Mailing/PseudoConstant.php | 46 +- CRM/Mailing/Selector/Browse.php | 140 +-- CRM/Mailing/Selector/Event.php | 78 +- CRM/Mailing/Selector/Search.php | 66 +- CRM/Mailing/Task.php | 16 +- CRM/Mailing/Tokens.php | 8 +- CRM/Member/ActionMapping.php | 8 +- CRM/Member/BAO/MembershipLog.php | 2 +- CRM/Member/BAO/MembershipPayment.php | 16 +- CRM/Member/BAO/MembershipStatus.php | 26 +- CRM/Member/BAO/MembershipType.php | 98 +- CRM/Member/BAO/Query.php | 44 +- CRM/Member/Form.php | 78 +- CRM/Member/Form/Membership.php | 172 +-- CRM/Member/Form/MembershipBlock.php | 58 +- CRM/Member/Form/MembershipConfig.php | 44 +- CRM/Member/Form/MembershipRenewal.php | 66 +- CRM/Member/Form/MembershipStatus.php | 10 +- CRM/Member/Form/MembershipType.php | 52 +- CRM/Member/Form/MembershipView.php | 60 +- CRM/Member/Form/Search.php | 8 +- CRM/Member/Form/Task.php | 16 +- CRM/Member/Form/Task/Batch.php | 30 +- CRM/Member/Form/Task/Delete.php | 4 +- CRM/Member/Form/Task/Label.php | 14 +- CRM/Member/Form/Task/PDFLetterCommon.php | 4 +- CRM/Member/Form/Task/PickProfile.php | 14 +- CRM/Member/Form/Task/Print.php | 14 +- CRM/Member/Form/Task/Result.php | 8 +- CRM/Member/Form/Task/SearchTaskHookSample.php | 14 +- CRM/Member/Import/Controller.php | 2 +- CRM/Member/Import/Field.php | 2 +- CRM/Member/Import/Form/DataSource.php | 10 +- CRM/Member/Import/Form/Preview.php | 14 +- CRM/Member/Import/Form/Summary.php | 4 +- CRM/Member/Import/Parser.php | 24 +- CRM/Member/Import/Parser/Membership.php | 32 +- CRM/Member/Info.php | 42 +- CRM/Member/Page/AJAX.php | 4 +- CRM/Member/Page/MembershipStatus.php | 26 +- CRM/Member/Page/MembershipType.php | 26 +- CRM/Member/Page/RecurringContributions.php | 16 +- CRM/Member/Page/Tab.php | 84 +- CRM/Member/Page/UserDashboard.php | 8 +- CRM/Member/PseudoConstant.php | 2 +- CRM/Member/Selector/Search.php | 94 +- CRM/Member/StateMachine/Search.php | 2 +- CRM/Member/StatusOverrideTypes.php | 4 +- CRM/Member/Task.php | 62 +- CRM/Member/Tokens.php | 6 +- CRM/Note/Form/Note.php | 28 +- CRM/PCP/BAO/PCP.php | 160 +-- CRM/PCP/Form/Campaign.php | 46 +- CRM/PCP/Form/Contribute.php | 10 +- CRM/PCP/Form/Event.php | 24 +- CRM/PCP/Form/PCP.php | 42 +- CRM/PCP/Form/PCPAccount.php | 28 +- CRM/PCP/Page/PCPInfo.php | 20 +- CRM/PCP/StateMachine/PCP.php | 4 +- CRM/Pledge/BAO/PledgePayment.php | 58 +- CRM/Pledge/BAO/Query.php | 54 +- CRM/Pledge/Form/Payment.php | 24 +- CRM/Pledge/Form/Pledge.php | 96 +- CRM/Pledge/Form/PledgeView.php | 16 +- CRM/Pledge/Form/Search.php | 12 +- CRM/Pledge/Form/Task.php | 16 +- CRM/Pledge/Form/Task/Delete.php | 4 +- CRM/Pledge/Form/Task/Print.php | 14 +- CRM/Pledge/Form/Task/Result.php | 8 +- CRM/Pledge/Form/Task/SearchTaskHookSample.php | 14 +- CRM/Pledge/Info.php | 42 +- CRM/Pledge/Page/AJAX.php | 2 +- CRM/Pledge/Page/DashBoard.php | 14 +- CRM/Pledge/Page/Tab.php | 4 +- CRM/Pledge/Page/UserDashboard.php | 2 +- CRM/Pledge/Selector/Search.php | 84 +- CRM/Pledge/StateMachine/Search.php | 2 +- CRM/Pledge/Task.php | 26 +- CRM/Price/BAO/LineItem.php | 138 +-- CRM/Price/BAO/PriceField.php | 124 +- CRM/Price/BAO/PriceFieldValue.php | 30 +- CRM/Price/BAO/PriceSet.php | 138 +-- CRM/Price/Form/DeleteField.php | 14 +- CRM/Price/Form/DeleteSet.php | 16 +- CRM/Price/Form/Field.php | 72 +- CRM/Price/Form/Option.php | 62 +- CRM/Price/Form/Preview.php | 26 +- CRM/Price/Form/Set.php | 44 +- CRM/Price/Page/Field.php | 44 +- CRM/Price/Page/Option.php | 56 +- CRM/Price/Page/Set.php | 50 +- CRM/Profile/Form.php | 76 +- CRM/Profile/Form/Dynamic.php | 12 +- CRM/Profile/Form/Edit.php | 18 +- CRM/Profile/Form/Search.php | 18 +- CRM/Profile/Page/Dynamic.php | 22 +- CRM/Profile/Page/Listings.php | 24 +- .../Page/MultipleRecordFieldsListing.php | 62 +- CRM/Profile/Page/Router.php | 4 +- CRM/Profile/Page/View.php | 8 +- CRM/Profile/Selector/Listings.php | 86 +- CRM/Queue/ErrorPolicy.php | 22 +- CRM/Queue/Menu.php | 14 +- CRM/Queue/Page/Runner.php | 4 +- CRM/Queue/Queue.php | 2 +- CRM/Queue/Queue/Memory.php | 6 +- CRM/Queue/Queue/Sql.php | 48 +- CRM/Queue/Runner.php | 10 +- CRM/Queue/Service.php | 2 +- CRM/Report/BAO/Hook.php | 4 +- CRM/Report/BAO/HookInterface.php | 2 +- CRM/Report/BAO/ReportInstance.php | 54 +- CRM/Report/Form.php | 1004 ++++++++--------- CRM/Report/Form/Activity.php | 268 ++--- CRM/Report/Form/ActivitySummary.php | 200 ++-- CRM/Report/Form/Case/Demographics.php | 188 +-- CRM/Report/Form/Case/Summary.php | 180 +-- CRM/Report/Form/Case/TimeSpent.php | 166 +-- CRM/Report/Form/Contact/CurrentEmployer.php | 178 +-- CRM/Report/Form/Contact/Detail.php | 368 +++--- CRM/Report/Form/Contact/Log.php | 116 +- CRM/Report/Form/Contact/LoggingSummary.php | 134 +-- CRM/Report/Form/Contact/Relationship.php | 320 +++--- CRM/Report/Form/Contribute/Bookkeeping.php | 398 +++---- .../Form/Contribute/DeferredRevenue.php | 254 ++--- CRM/Report/Form/Contribute/Detail.php | 352 +++--- CRM/Report/Form/Contribute/History.php | 310 ++--- .../Form/Contribute/HouseholdSummary.php | 202 ++-- CRM/Report/Form/Contribute/Lybunt.php | 236 ++-- .../Form/Contribute/OrganizationSummary.php | 190 ++-- CRM/Report/Form/Contribute/PCP.php | 204 ++-- CRM/Report/Form/Contribute/Recur.php | 224 ++-- CRM/Report/Form/Contribute/RecurSummary.php | 58 +- CRM/Report/Form/Contribute/SoftCredit.php | 284 ++--- CRM/Report/Form/Contribute/Sybunt.php | 250 ++-- CRM/Report/Form/Contribute/TopDonor.php | 172 +-- CRM/Report/Form/Event/Income.php | 38 +- CRM/Report/Form/Event/IncomeCountSummary.php | 142 +-- .../Form/Event/ParticipantListCount.php | 346 +++--- CRM/Report/Form/Event/Summary.php | 98 +- CRM/Report/Form/Extended.php | 770 ++++++------- CRM/Report/Form/Grant/Detail.php | 180 +-- CRM/Report/Form/Grant/Statistics.php | 210 ++-- CRM/Report/Form/Instance.php | 56 +- CRM/Report/Form/Mailing/Bounce.php | 240 ++-- CRM/Report/Form/Mailing/Clicks.php | 180 +-- CRM/Report/Form/Mailing/Detail.php | 220 ++-- CRM/Report/Form/Mailing/Opened.php | 172 +-- CRM/Report/Form/Mailing/Summary.php | 304 ++--- CRM/Report/Form/Member/ContributionDetail.php | 348 +++--- CRM/Report/Form/Member/Detail.php | 196 ++-- CRM/Report/Form/Member/Lapse.php | 138 +-- CRM/Report/Form/Member/Summary.php | 160 +-- CRM/Report/Form/Membership/Summary.php | 134 +-- CRM/Report/Form/Pledge/Detail.php | 184 +-- CRM/Report/Form/Pledge/Pbnp.php | 154 +-- CRM/Report/Form/Pledge/Summary.php | 172 +-- CRM/Report/Form/Register.php | 60 +- CRM/Report/Form/Walklist/Walklist.php | 60 +- CRM/Report/Info.php | 36 +- CRM/Report/Page/Instance.php | 4 +- CRM/Report/Page/InstanceList.php | 52 +- CRM/Report/Page/Options.php | 30 +- CRM/Report/Page/Report.php | 2 +- CRM/Report/Page/TemplateList.php | 2 +- CRM/Report/Utils/Get.php | 6 +- CRM/Report/Utils/Report.php | 66 +- CRM/SMS/BAO/Provider.php | 12 +- CRM/SMS/Controller/Send.php | 2 +- CRM/SMS/Form/Group.php | 48 +- CRM/SMS/Form/Provider.php | 22 +- CRM/SMS/Form/Schedule.php | 30 +- CRM/SMS/Form/Upload.php | 64 +- CRM/SMS/StateMachine/Send.php | 4 +- CRM/Tag/Form/Edit.php | 24 +- CRM/Tag/Form/Merge.php | 24 +- CRM/Tag/Form/Tag.php | 8 +- CRM/Tag/Page/Tag.php | 18 +- CRM/UF/Form/AbstractPreview.php | 2 +- CRM/UF/Form/AdvanceSetting.php | 12 +- CRM/UF/Form/Field.php | 130 +-- CRM/UF/Form/Inline/Preview.php | 10 +- CRM/UF/Form/Preview.php | 12 +- CRM/UF/Page/AJAX.php | 2 +- CRM/UF/Page/Field.php | 38 +- CRM/UF/Page/Group.php | 64 +- CRM/UF/Page/ProfileEditor.php | 66 +- CRM/Upgrade/Form.php | 70 +- CRM/Upgrade/Headless.php | 8 +- CRM/Upgrade/Incremental/Base.php | 24 +- CRM/Upgrade/Incremental/General.php | 34 +- CRM/Upgrade/Incremental/php/FiveEleven.php | 2 +- CRM/Upgrade/Incremental/php/FiveFour.php | 24 +- CRM/Upgrade/Incremental/php/FiveNine.php | 6 +- CRM/Upgrade/Incremental/php/FiveSix.php | 2 +- CRM/Upgrade/Incremental/php/FiveThree.php | 6 +- CRM/Upgrade/Incremental/php/FiveZero.php | 2 +- CRM/Upgrade/Incremental/php/FourFive.php | 56 +- CRM/Upgrade/Incremental/php/FourFour.php | 122 +- CRM/Upgrade/Incremental/php/FourSeven.php | 246 ++-- CRM/Upgrade/Incremental/php/FourSix.php | 6 +- CRM/Upgrade/Incremental/php/FourThree.php | 176 +-- CRM/Upgrade/Page/Cleanup.php | 8 +- CRM/Upgrade/Page/Upgrade.php | 12 +- CRM/Utils/API/AbstractFieldCoder.php | 6 +- CRM/Utils/API/HTMLInputCoder.php | 8 +- CRM/Utils/API/MatchOption.php | 4 +- CRM/Utils/API/ReloadOption.php | 10 +- CRM/Utils/Address.php | 30 +- CRM/Utils/Address/BatchUpdate.php | 32 +- CRM/Utils/Address/USPS.php | 2 +- CRM/Utils/Array.php | 54 +- CRM/Utils/AutoClean.php | 6 +- CRM/Utils/Cache.php | 18 +- CRM/Utils/Cache/ArrayCache.php | 6 +- CRM/Utils/Cache/SerializeCache.php | 4 +- CRM/Utils/Cache/SqlGroup.php | 26 +- CRM/Utils/Check.php | 12 +- CRM/Utils/Check/Component.php | 2 +- CRM/Utils/Check/Component/Case.php | 20 +- CRM/Utils/Check/Component/Env.php | 186 +-- .../Check/Component/FinancialTypeAcls.php | 8 +- CRM/Utils/Check/Component/OptionGroups.php | 20 +- CRM/Utils/Check/Component/PriceFields.php | 6 +- CRM/Utils/Check/Component/Schema.php | 8 +- CRM/Utils/Check/Component/Security.php | 62 +- CRM/Utils/Check/Component/Source.php | 18 +- CRM/Utils/Check/Component/Timestamps.php | 58 +- CRM/Utils/Check/Message.php | 16 +- CRM/Utils/ConsoleTee.php | 2 +- CRM/Utils/Date.php | 56 +- CRM/Utils/DeprecatedUtils.php | 100 +- CRM/Utils/EnglishNumber.php | 8 +- CRM/Utils/File.php | 26 +- CRM/Utils/GlobalStack.php | 4 +- CRM/Utils/Hook.php | 244 ++-- CRM/Utils/Hook/DrupalBase.php | 2 +- CRM/Utils/Hook/Joomla.php | 4 +- CRM/Utils/Hook/UnitTests.php | 12 +- CRM/Utils/Hook/WordPress.php | 8 +- CRM/Utils/Http.php | 2 +- CRM/Utils/HttpClient.php | 22 +- CRM/Utils/ICalendar.php | 2 +- CRM/Utils/JS.php | 2 +- CRM/Utils/JSON.php | 2 +- CRM/Utils/Mail.php | 50 +- CRM/Utils/Mail/EmailProcessor.php | 30 +- CRM/Utils/Mail/Incoming.php | 36 +- CRM/Utils/Migrate/Export.php | 168 +-- CRM/Utils/Migrate/ExportJSON.php | 60 +- CRM/Utils/Migrate/Import.php | 52 +- CRM/Utils/Migrate/ImportJSON.php | 48 +- CRM/Utils/Money.php | 12 +- CRM/Utils/Number.php | 2 +- CRM/Utils/OpenFlashChart.php | 50 +- CRM/Utils/OptionBag.php | 4 +- CRM/Utils/PDF/Document.php | 28 +- CRM/Utils/PDF/Label.php | 12 +- CRM/Utils/PDF/Utils.php | 8 +- CRM/Utils/Pager.php | 20 +- CRM/Utils/PagerAToZ.php | 12 +- CRM/Utils/PseudoConstant.php | 6 +- CRM/Utils/QueryFormatter.php | 20 +- CRM/Utils/Recent.php | 18 +- CRM/Utils/Request.php | 6 +- CRM/Utils/Rule.php | 10 +- CRM/Utils/SQL.php | 2 +- CRM/Utils/SQL/BaseParamQuery.php | 6 +- CRM/Utils/SQL/Delete.php | 16 +- CRM/Utils/SQL/Insert.php | 8 +- CRM/Utils/SQL/Select.php | 40 +- CRM/Utils/SQL/TempTable.php | 6 +- CRM/Utils/Signer.php | 4 +- CRM/Utils/SoapServer.php | 32 +- CRM/Utils/Sort.php | 14 +- CRM/Utils/String.php | 30 +- CRM/Utils/System.php | 52 +- CRM/Utils/System/Backdrop.php | 72 +- CRM/Utils/System/Base.php | 28 +- CRM/Utils/System/Drupal.php | 62 +- CRM/Utils/System/Drupal6.php | 56 +- CRM/Utils/System/Drupal8.php | 36 +- CRM/Utils/System/DrupalBase.php | 22 +- CRM/Utils/System/Joomla.php | 38 +- CRM/Utils/System/Soap.php | 2 +- CRM/Utils/System/UnitTests.php | 4 +- CRM/Utils/System/WordPress.php | 44 +- CRM/Utils/SystemLogger.php | 4 +- CRM/Utils/Token.php | 160 +-- CRM/Utils/Type.php | 14 +- CRM/Utils/Verp.php | 10 +- CRM/Utils/VersionCheck.php | 56 +- CRM/Utils/VisualBundle.php | 12 +- CRM/Utils/Weight.php | 52 +- CRM/Utils/Wrapper.php | 2 +- CRM/Utils/XML.php | 10 +- CRM/Utils/Zip.php | 2 +- CRM/Widget/Widget.php | 26 +- 1094 files changed, 23185 insertions(+), 23184 deletions(-) diff --git a/CRM/Activity/Form/ActivityFilter.php b/CRM/Activity/Form/ActivityFilter.php index 61eb0b281117..228a4c21f0ec 100644 --- a/CRM/Activity/Form/ActivityFilter.php +++ b/CRM/Activity/Form/ActivityFilter.php @@ -44,7 +44,7 @@ public function buildQuickForm() { $this->add('select', 'activity_type_exclude_filter_id', ts('Exclude'), $activityOptions, FALSE, ['class' => 'crm-select2', 'multiple' => TRUE, 'placeholder' => ts('- no types excluded -')]); $this->addDatePickerRange('activity_date_time', ts('Date')); $this->addSelect('status_id', - array('entity' => 'activity', 'multiple' => 'multiple', 'option_url' => NULL, 'placeholder' => ts('- any -')) + ['entity' => 'activity', 'multiple' => 'multiple', 'option_url' => NULL, 'placeholder' => ts('- any -')] ); $this->assign('suppressForm', TRUE); @@ -61,7 +61,7 @@ public function buildQuickForm() { */ public function setDefaultValues() { // CRM-11761 retrieve user's activity filter preferences - $defaults = array(); + $defaults = []; if (Civi::settings()->get('preserve_activity_tab_filter') && (CRM_Core_Session::getLoggedInContactID())) { $defaults = Civi::contactSettings()->get('activity_tab_filter'); } diff --git a/CRM/Activity/Form/ActivityLinks.php b/CRM/Activity/Form/ActivityLinks.php index 13028e47360e..1bbdd423f3bb 100644 --- a/CRM/Activity/Form/ActivityLinks.php +++ b/CRM/Activity/Form/ActivityLinks.php @@ -49,13 +49,13 @@ public static function commonBuildQuickForm($self) { } $urlParams = "action=add&reset=1&cid={$contactId}&selectedChild=activity&atype="; - $allTypes = CRM_Utils_Array::value('values', civicrm_api3('OptionValue', 'get', array( + $allTypes = CRM_Utils_Array::value('values', civicrm_api3('OptionValue', 'get', [ 'option_group_id' => 'activity_type', 'is_active' => 1, - 'options' => array('limit' => 0, 'sort' => 'weight'), - ))); + 'options' => ['limit' => 0, 'sort' => 'weight'], + ])); - $activityTypes = array(); + $activityTypes = []; foreach ($allTypes as $act) { $url = 'civicrm/activity/add'; @@ -78,16 +78,16 @@ public static function commonBuildQuickForm($self) { } // Check for existence of a mobile phone and ! do not SMS privacy setting try { - $phone = civicrm_api3('Phone', 'getsingle', array( + $phone = civicrm_api3('Phone', 'getsingle', [ 'contact_id' => $contactId, 'phone_type_id' => CRM_Core_PseudoConstant::getKey('CRM_Core_BAO_Phone', 'phone_type_id', 'Mobile'), - 'return' => array('phone', 'contact_id'), - 'options' => array('limit' => 1, 'sort' => "is_primary DESC"), - 'api.Contact.getsingle' => array( + 'return' => ['phone', 'contact_id'], + 'options' => ['limit' => 1, 'sort' => "is_primary DESC"], + 'api.Contact.getsingle' => [ 'id' => '$value.contact_id', 'return' => 'do_not_sms', - ), - )); + ], + ]); } catch (CiviCRM_API3_Exception $e) { continue; @@ -108,7 +108,7 @@ public static function commonBuildQuickForm($self) { $act['url'] = CRM_Utils_System::url($url, "{$urlParams}{$act['value']}", FALSE, NULL, FALSE ); - $act += array('icon' => 'fa-plus-square-o'); + $act += ['icon' => 'fa-plus-square-o']; $activityTypes[$act['value']] = $act; } diff --git a/CRM/Activity/Form/ActivityView.php b/CRM/Activity/Form/ActivityView.php index ddf67d763006..4a2ef88b3078 100644 --- a/CRM/Activity/Form/ActivityView.php +++ b/CRM/Activity/Form/ActivityView.php @@ -53,11 +53,11 @@ public function preProcess() { } $session = CRM_Core_Session::singleton(); - if (!in_array($context, array( + if (!in_array($context, [ 'home', 'dashlet', 'dashletFullscreen', - )) + ]) ) { $url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$cid}&selectedChild=activity"); } @@ -66,8 +66,8 @@ public function preProcess() { } $session->pushUserContext($url); - $defaults = array(); - $params = array('id' => $activityId); + $defaults = []; + $params = ['id' => $activityId]; CRM_Activity_BAO_Activity::retrieve($params, $defaults); // Set activity type name and description to template. @@ -123,14 +123,14 @@ public function preProcess() { * Build the form object. */ public function buildQuickForm() { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'cancel', 'name' => ts('Done'), 'spacing' => '         ', 'isDefault' => TRUE, - ), - ) + ], + ] ); } diff --git a/CRM/Activity/Form/Search.php b/CRM/Activity/Form/Search.php index d598dab992ab..a44b314c6c84 100644 --- a/CRM/Activity/Form/Search.php +++ b/CRM/Activity/Form/Search.php @@ -198,16 +198,16 @@ public function postProcess() { if (!empty($_POST)) { $this->_formValues = $this->controller->exportValues($this->_name); - $specialParams = array( + $specialParams = [ 'activity_type_id', 'status_id', 'priority_id', 'activity_text', - ); - $changeNames = array( + ]; + $changeNames = [ 'status_id' => 'activity_status_id', 'priority_id' => 'activity_priority_id', - ); + ]; CRM_Contact_BAO_Query::processSpecialFormValue($this->_formValues, $specialParams, $changeNames); } diff --git a/CRM/Activity/Form/Task.php b/CRM/Activity/Form/Task.php index 7cc1176a6bc0..d64c173297b1 100644 --- a/CRM/Activity/Form/Task.php +++ b/CRM/Activity/Form/Task.php @@ -57,7 +57,7 @@ public function preProcess() { * @param CRM_Core_Form $form */ public static function preProcessCommon(&$form) { - $form->_activityHolderIds = array(); + $form->_activityHolderIds = []; $values = $form->controller->exportValues($form->get('searchFormName')); @@ -65,7 +65,7 @@ public static function preProcessCommon(&$form) { $activityTasks = CRM_Activity_Task::tasks(); $form->assign('taskName', $activityTasks[$form->_task]); - $ids = array(); + $ids = []; if ($values['radio_ts'] == 'ts_sel') { foreach ($values as $name => $value) { if (substr($name, 0, CRM_Core_Form::CB_PREFIX_LEN) == CRM_Core_Form::CB_PREFIX) { @@ -85,7 +85,7 @@ public static function preProcessCommon(&$form) { $activityClause = NULL; $components = CRM_Core_Component::getNames(); - $componentClause = array(); + $componentClause = []; foreach ($components as $componentID => $componentName) { if ($componentName != 'CiviCase' && !CRM_Core_Permission::check("access $componentName")) { $componentClause[] = " (activity_type.component_id IS NULL OR activity_type.component_id <> {$componentID}) "; @@ -163,17 +163,17 @@ public function setContactIDs() { * @param bool $submitOnce */ public function addDefaultButtons($title, $nextType = 'next', $backType = 'back', $submitOnce = FALSE) { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => $nextType, 'name' => $title, 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => $backType, 'name' => ts('Cancel'), - ), - )); + ], + ]); } } diff --git a/CRM/Activity/Form/Task/AddToTag.php b/CRM/Activity/Form/Task/AddToTag.php index ef9e9f080a91..f712d449246d 100644 --- a/CRM/Activity/Form/Task/AddToTag.php +++ b/CRM/Activity/Form/Task/AddToTag.php @@ -71,7 +71,7 @@ public function buildQuickForm() { } public function addRules() { - $this->addFormRule(array('CRM_Activity_Form_Task_AddToTag', 'formRule')); + $this->addFormRule(['CRM_Activity_Form_Task_AddToTag', 'formRule']); } /** @@ -81,7 +81,7 @@ public function addRules() { * @return array */ public static function formRule($form, $rule) { - $errors = array(); + $errors = []; if (empty($form['tag']) && empty($form['activity_taglist'])) { $errors['_qf_default'] = ts("Please select at least one tag."); } @@ -94,7 +94,7 @@ public static function formRule($form, $rule) { public function postProcess() { // Get the submitted values in an array. $params = $this->controller->exportValues($this->_name); - $activityTags = $tagList = array(); + $activityTags = $tagList = []; // check if contact tags exists if (!empty($params['tag'])) { @@ -131,22 +131,22 @@ public function postProcess() { // merge activity and taglist tags $allTags = CRM_Utils_Array::crmArrayMerge($activityTags, $tagList); - $this->_name = array(); + $this->_name = []; foreach ($allTags as $key => $dnc) { $this->_name[] = $this->_tags[$key]; list($total, $added, $notAdded) = CRM_Core_BAO_EntityTag::addEntitiesToTag($this->_activityHolderIds, $key, 'civicrm_activity', FALSE); - $status = array(ts('Activity tagged', array('count' => $added, 'plural' => '%count activities tagged'))); + $status = [ts('Activity tagged', ['count' => $added, 'plural' => '%count activities tagged'])]; if ($notAdded) { - $status[] = ts('1 activity already had this tag', array( + $status[] = ts('1 activity already had this tag', [ 'count' => $notAdded, 'plural' => '%count activities already had this tag', - )); + ]); } $status = '
  • ' . implode('
  • ', $status) . '
'; - CRM_Core_Session::setStatus($status, ts("Added Tag %1", array(1 => $this->_tags[$key])), 'success', array('expires' => 0)); + CRM_Core_Session::setStatus($status, ts("Added Tag %1", [1 => $this->_tags[$key]]), 'success', ['expires' => 0]); } } diff --git a/CRM/Activity/Form/Task/Batch.php b/CRM/Activity/Form/Task/Batch.php index 69c72417d43c..b8cd458e100f 100644 --- a/CRM/Activity/Form/Task/Batch.php +++ b/CRM/Activity/Form/Task/Batch.php @@ -62,7 +62,7 @@ public function preProcess() { parent::preProcess(); // Get the contact read only fields to display. - $readOnlyFields = array_merge(array('sort_name' => ts('Added By'), 'target_sort_name' => ts('With Contact')), + $readOnlyFields = array_merge(['sort_name' => ts('Added By'), 'target_sort_name' => ts('With Contact')], CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_autocomplete_options', TRUE, NULL, FALSE, 'name', TRUE @@ -101,12 +101,12 @@ public function buildQuickForm() { CRM_Utils_System::setTitle($this->_title); $this->addDefaultButtons(ts('Save')); - $this->_fields = array(); + $this->_fields = []; $this->_fields = CRM_Core_BAO_UFGroup::getFields($ufGroupId, FALSE, CRM_Core_Action::VIEW); // remove file type field and then limit fields $suppressFields = FALSE; - $removehtmlTypes = array('File'); + $removehtmlTypes = ['File']; foreach ($this->_fields as $name => $field) { if (CRM_Core_BAO_CustomField::getKeyID($name) && in_array($this->_fields[$name]['html_type'], $removehtmlTypes) @@ -124,24 +124,24 @@ public function buildQuickForm() { $this->_fields = array_slice($this->_fields, 0, $this->_maxFields); - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'submit', 'name' => ts('Update Activities'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - )); + ], + ]); $this->assign('profileTitle', $this->_title); $this->assign('componentIds', $this->_activityHolderIds); // Load all campaigns. if (array_key_exists('activity_campaign_id', $this->_fields)) { - $this->_componentCampaigns = array(); + $this->_componentCampaigns = []; CRM_Core_PseudoConstant::populate($this->_componentCampaigns, 'CRM_Activity_DAO_Activity', TRUE, 'campaign_id', 'id', @@ -153,7 +153,7 @@ public function buildQuickForm() { // It is possible to have fields that are required in CiviCRM not be required in the // profile. Overriding that here. Perhaps a better approach would be to // make them required in the schema & read that up through getFields functionality. - $requiredFields = array('activity_date_time'); + $requiredFields = ['activity_date_time']; foreach ($this->_activityHolderIds as $activityId) { $typeId = CRM_Core_DAO::getFieldValue("CRM_Activity_DAO_Activity", $activityId, 'activity_type_id'); @@ -201,7 +201,7 @@ public function setDefaultValues() { return; } - $defaults = array(); + $defaults = []; foreach ($this->_activityHolderIds as $activityId) { CRM_Core_BAO_UFGroup::setProfileDefaults(NULL, $this->_fields, $defaults, FALSE, $activityId, 'Activity'); } diff --git a/CRM/Activity/Form/Task/Delete.php b/CRM/Activity/Form/Task/Delete.php index 6a46fba6dcf1..7fa2bef6ca80 100644 --- a/CRM/Activity/Form/Task/Delete.php +++ b/CRM/Activity/Form/Task/Delete.php @@ -76,12 +76,12 @@ public function postProcess() { } if ($deleted) { - $msg = ts('%count activity deleted.', array('plural' => '%count activities deleted.', 'count' => $deleted)); + $msg = ts('%count activity deleted.', ['plural' => '%count activities deleted.', 'count' => $deleted]); CRM_Core_Session::setStatus($msg, ts('Removed'), 'success'); } if ($failed) { - CRM_Core_Session::setStatus(ts('1 could not be deleted.', array('plural' => '%count could not be deleted.', 'count' => $failed)), ts('Error'), 'error'); + CRM_Core_Session::setStatus(ts('1 could not be deleted.', ['plural' => '%count could not be deleted.', 'count' => $failed]), ts('Error'), 'error'); } } diff --git a/CRM/Activity/Form/Task/FileOnCase.php b/CRM/Activity/Form/Task/FileOnCase.php index 72ee30ed2b0d..90225b18a61b 100644 --- a/CRM/Activity/Form/Task/FileOnCase.php +++ b/CRM/Activity/Form/Task/FileOnCase.php @@ -68,7 +68,7 @@ public function preProcess() { * Build the form object. */ public function buildQuickForm() { - $this->addEntityRef('unclosed_case_id', ts('Select Case'), array('entity' => 'Case'), TRUE); + $this->addEntityRef('unclosed_case_id', ts('Select Case'), ['entity' => 'Case'], TRUE); $this->addDefaultButtons(ts('Save')); } @@ -80,8 +80,8 @@ public function postProcess() { $caseId = $formparams['unclosed_case_id']; $filedActivities = 0; foreach ($this->_activityHolderIds as $key => $id) { - $targetContactValues = $defaults = array(); - $params = array('id' => $id); + $targetContactValues = $defaults = []; + $params = ['id' => $id]; CRM_Activity_BAO_Activity::retrieve($params, $defaults); if (CRM_Case_BAO_Case::checkPermission($id, 'File On Case', $defaults['activity_type_id'])) { @@ -92,13 +92,13 @@ public function postProcess() { $targetContactValues = implode(',', array_keys($targetContactValues)); } - $params = array( + $params = [ 'caseID' => $caseId, 'activityID' => $id, 'newSubject' => empty($defaults['subject']) ? '' : $defaults['subject'], 'targetContactIds' => $targetContactValues, 'mode' => 'file', - ); + ]; $error_msg = CRM_Activity_Page_AJAX::_convertToCaseActivity($params); if (empty($error_msg['error_msg'])) { @@ -109,16 +109,16 @@ public function postProcess() { } } else { - CRM_Core_Session::setStatus(ts('Not permitted to file activity %1 %2.', array( + CRM_Core_Session::setStatus(ts('Not permitted to file activity %1 %2.', [ 1 => empty($defaults['subject']) ? '' : $defaults['subject'], 2 => $defaults['activity_date_time'], - )), + ]), ts("Error"), "error"); } } CRM_Core_Session::setStatus($filedActivities, ts("Filed Activities"), "success"); - CRM_Core_Session::setStatus("", ts('Total Selected Activities: %1', array(1 => count($this->_activityHolderIds))), "info"); + CRM_Core_Session::setStatus("", ts('Total Selected Activities: %1', [1 => count($this->_activityHolderIds)]), "info"); } } diff --git a/CRM/Activity/Form/Task/PickOption.php b/CRM/Activity/Form/Task/PickOption.php index 9eb2c5dcb058..df4e59f5a42b 100644 --- a/CRM/Activity/Form/Task/PickOption.php +++ b/CRM/Activity/Form/Task/PickOption.php @@ -73,10 +73,10 @@ public function preProcess() { $validate = FALSE; //validations if (count($this->_activityHolderIds) > $this->_maxActivities) { - CRM_Core_Session::setStatus(ts("The maximum number of Activities you can select to send an email is %1. You have selected %2. Please select fewer Activities from your search results and try again.", array( + CRM_Core_Session::setStatus(ts("The maximum number of Activities you can select to send an email is %1. You have selected %2. Please select fewer Activities from your search results and try again.", [ 1 => $this->_maxActivities, 2 => count($this->_activityHolderIds), - )), ts("Maximum Exceeded"), "error"); + ]), ts("Maximum Exceeded"), "error"); $validate = TRUE; } // then redirect @@ -92,7 +92,7 @@ public function buildQuickForm() { $this->addElement('checkbox', 'with_contact', ts('With Contact')); $this->addElement('checkbox', 'assigned_to', ts('Assigned to Contact')); $this->addElement('checkbox', 'created_by', ts('Created by')); - $this->setDefaults(array('with_contact' => 1)); + $this->setDefaults(['with_contact' => 1]); $this->addDefaultButtons(ts('Continue')); } @@ -100,7 +100,7 @@ public function buildQuickForm() { * Add local and global form rules. */ public function addRules() { - $this->addFormRule(array('CRM_Activity_Form_Task_PickOption', 'formRule')); + $this->addFormRule(['CRM_Activity_Form_Task_PickOption', 'formRule']); } /** @@ -117,7 +117,7 @@ public static function formRule($fields) { !isset($fields['assigned_to']) && !isset($fields['created_by']) ) { - return array('with_contact' => ts('You must select at least one email recipient type.')); + return ['with_contact' => ts('You must select at least one email recipient type.')]; } return TRUE; } @@ -129,7 +129,7 @@ public function postProcess() { // Clear any formRule errors from Email form in case they came back here via Cancel button $this->controller->resetPage('Email'); $params = $this->exportValues(); - $this->_contacts = array(); + $this->_contacts = []; $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate'); $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts); diff --git a/CRM/Activity/Form/Task/PickProfile.php b/CRM/Activity/Form/Task/PickProfile.php index d6a0f40fb6ef..10f258837c5a 100644 --- a/CRM/Activity/Form/Task/PickProfile.php +++ b/CRM/Activity/Form/Task/PickProfile.php @@ -68,10 +68,10 @@ public function preProcess() { $validate = FALSE; // Validations. if (count($this->_activityHolderIds) > $this->_maxActivities) { - CRM_Core_Session::setStatus(ts("The maximum number of activities you can select for Update multiple activities is %1. You have selected %2. Please select fewer Activities from your search results and try again.", array( + CRM_Core_Session::setStatus(ts("The maximum number of activities you can select for Update multiple activities is %1. You have selected %2. Please select fewer Activities from your search results and try again.", [ 1 => $this->_maxActivities, 2 => count($this->_activityHolderIds), - )), ts('Maximum Exceeded'), 'error'); + ]), ts('Maximum Exceeded'), 'error'); $validate = TRUE; } @@ -85,11 +85,11 @@ public function preProcess() { * Build the form object. */ public function buildQuickForm() { - $types = array('Activity'); + $types = ['Activity']; $profiles = CRM_Core_BAO_UFGroup::getProfiles($types, TRUE); $activityTypeIds = array_flip(CRM_Core_PseudoConstant::activityType(TRUE, FALSE, FALSE, 'name')); - $nonEditableActivityTypeIds = array( + $nonEditableActivityTypeIds = [ $activityTypeIds['Email'], $activityTypeIds['Bulk Email'], $activityTypeIds['Contribution'], @@ -99,7 +99,7 @@ public function buildQuickForm() { $activityTypeIds['Membership Renewal'], $activityTypeIds['Event Registration'], $activityTypeIds['Pledge Acknowledgment'], - ); + ]; $notEditable = FALSE; foreach ($this->_activityHolderIds as $activityId) { $typeId = CRM_Core_DAO::getFieldValue("CRM_Activity_DAO_Activity", $activityId, 'activity_type_id'); @@ -110,7 +110,7 @@ public function buildQuickForm() { } if (empty($profiles)) { - CRM_Core_Session::setStatus(ts("You will need to create a Profile containing the %1 fields you want to edit before you can use Update multiple activities. Navigate to Administer > Customize Data and Screens > Profiles to configure a Profile. Consult the online Administrator documentation for more information.", array(1 => $types[0])), ts("No Profile Configured"), "alert"); + CRM_Core_Session::setStatus(ts("You will need to create a Profile containing the %1 fields you want to edit before you can use Update multiple activities. Navigate to Administer > Customize Data and Screens > Profiles to configure a Profile. Consult the online Administrator documentation for more information.", [1 => $types[0]]), ts("No Profile Configured"), "alert"); CRM_Utils_System::redirect($this->_userContext); } elseif ($notEditable) { @@ -119,9 +119,9 @@ public function buildQuickForm() { } $ufGroupElement = $this->add('select', 'uf_group_id', ts('Select Profile'), - array( + [ '' => ts('- select profile -'), - ) + $profiles, TRUE + ] + $profiles, TRUE ); $this->addDefaultButtons(ts('Continue')); } @@ -130,7 +130,7 @@ public function buildQuickForm() { * Add local and global form rules. */ public function addRules() { - $this->addFormRule(array('CRM_Activity_Form_Task_PickProfile', 'formRule')); + $this->addFormRule(['CRM_Activity_Form_Task_PickProfile', 'formRule']); } /** diff --git a/CRM/Activity/Form/Task/Print.php b/CRM/Activity/Form/Task/Print.php index 90893d6cb562..69f822bd74b7 100644 --- a/CRM/Activity/Form/Task/Print.php +++ b/CRM/Activity/Form/Task/Print.php @@ -71,18 +71,18 @@ public function preProcess() { public function buildQuickForm() { // just need to add a javacript to popup the window for printing - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => ts('Print Activities'), - 'js' => array('onclick' => 'window.print()'), + 'js' => ['onclick' => 'window.print()'], 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'back', 'name' => ts('Done'), - ), - )); + ], + ]); } } diff --git a/CRM/Activity/Form/Task/RemoveFromTag.php b/CRM/Activity/Form/Task/RemoveFromTag.php index 8d6c4d745614..2590ba073d73 100644 --- a/CRM/Activity/Form/Task/RemoveFromTag.php +++ b/CRM/Activity/Form/Task/RemoveFromTag.php @@ -67,7 +67,7 @@ public function buildQuickForm() { } public function addRules() { - $this->addFormRule(array('CRM_Activity_Form_Task_RemoveFromTag', 'formRule')); + $this->addFormRule(['CRM_Activity_Form_Task_RemoveFromTag', 'formRule']); } /** @@ -77,7 +77,7 @@ public function addRules() { * @return array */ public static function formRule($form, $rule) { - $errors = array(); + $errors = []; if (empty($form['tag']) && empty($form['activity_taglist'])) { $errors['_qf_default'] = "Please select atleast one tag."; } @@ -91,7 +91,7 @@ public function postProcess() { //get the submitted values in an array $params = $this->controller->exportValues($this->_name); - $activityTags = $tagList = array(); + $activityTags = $tagList = []; // check if contact tags exists if (!empty($params['tag'])) { @@ -120,27 +120,27 @@ public function postProcess() { // merge contact and taglist tags $allTags = CRM_Utils_Array::crmArrayMerge($activityTags, $tagList); - $this->_name = array(); + $this->_name = []; foreach ($allTags as $key => $dnc) { $this->_name[] = $this->_tags[$key]; list($total, $removed, $notRemoved) = CRM_Core_BAO_EntityTag::removeEntitiesFromTag($this->_activityHolderIds, $key, 'civicrm_activity', FALSE); - $status = array( - ts('%count activity un-tagged', array( + $status = [ + ts('%count activity un-tagged', [ 'count' => $removed, 'plural' => '%count activities un-tagged', - )), - ); + ]), + ]; if ($notRemoved) { - $status[] = ts('1 activity already did not have this tag', array( + $status[] = ts('1 activity already did not have this tag', [ 'count' => $notRemoved, 'plural' => '%count activities already did not have this tag', - )); + ]); } $status = '
  • ' . implode('
  • ', $status) . '
'; - CRM_Core_Session::setStatus($status, ts("Removed Tag %1", array(1 => $this->_tags[$key])), 'success', array('expires' => 0)); + CRM_Core_Session::setStatus($status, ts("Removed Tag %1", [1 => $this->_tags[$key]]), 'success', ['expires' => 0]); } } diff --git a/CRM/Activity/Form/Task/SearchTaskHookSample.php b/CRM/Activity/Form/Task/SearchTaskHookSample.php index 7c72776a956a..488842609a71 100644 --- a/CRM/Activity/Form/Task/SearchTaskHookSample.php +++ b/CRM/Activity/Form/Task/SearchTaskHookSample.php @@ -42,7 +42,7 @@ class CRM_Activity_Form_Task_SearchTaskHookSample extends CRM_Activity_Form_Task */ public function preProcess() { parent::preProcess(); - $rows = array(); + $rows = []; // display name and activity details of all selected contacts $activityIDs = implode(',', $this->_activityHolderIds); @@ -63,12 +63,12 @@ public function preProcess() { $dao = CRM_Core_DAO::executeQuery($query); while ($dao->fetch()) { - $rows[] = array( + $rows[] = [ 'subject' => $dao->subject, 'activity_type' => $dao->activity_type, 'activity_date' => $dao->activity_date, 'display_name' => $dao->display_name, - ); + ]; } $this->assign('rows', $rows); } @@ -77,13 +77,13 @@ public function preProcess() { * Build the form object. */ public function buildQuickForm() { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'done', 'name' => ts('Done'), 'isDefault' => TRUE, - ), - )); + ], + ]); } } diff --git a/CRM/Activity/Import/Controller.php b/CRM/Activity/Import/Controller.php index 6d69fc759ca1..9edc8e66b4e3 100644 --- a/CRM/Activity/Import/Controller.php +++ b/CRM/Activity/Import/Controller.php @@ -54,7 +54,7 @@ public function __construct($title = NULL, $action = CRM_Core_Action::NONE, $mod // add all the actions $config = CRM_Core_Config::singleton(); - $this->addActions($config->uploadDir, array('uploadFile')); + $this->addActions($config->uploadDir, ['uploadFile']); } } diff --git a/CRM/Activity/Import/Form/DataSource.php b/CRM/Activity/Import/Form/DataSource.php index f4c89e2eeb5c..1055aa3b13be 100644 --- a/CRM/Activity/Import/Form/DataSource.php +++ b/CRM/Activity/Import/Form/DataSource.php @@ -47,7 +47,7 @@ public function buildQuickForm() { parent::buildQuickForm(); // FIXME: This 'onDuplicate' form element is never used -- copy/paste error? - $duplicateOptions = array(); + $duplicateOptions = []; $duplicateOptions[] = $this->createElement('radio', NULL, NULL, ts('Skip'), CRM_Import_Parser::DUPLICATE_SKIP ); @@ -67,11 +67,11 @@ public function buildQuickForm() { * Process the uploaded file. */ public function postProcess() { - $this->storeFormValues(array( + $this->storeFormValues([ 'onDuplicate', 'dateFormats', 'savedMapping', - )); + ]); $this->submitFileForMapping('CRM_Activity_Import_Parser_Activity'); } diff --git a/CRM/Activity/Import/Form/Preview.php b/CRM/Activity/Import/Form/Preview.php index 8cb5204d598f..6a2352d06213 100644 --- a/CRM/Activity/Import/Form/Preview.php +++ b/CRM/Activity/Import/Form/Preview.php @@ -82,7 +82,7 @@ public function preProcess() { $this->set('downloadMismatchRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams)); } - $properties = array( + $properties = [ 'mapper', 'dataValues', 'columnCount', @@ -93,7 +93,7 @@ public function preProcess() { 'downloadErrorRecordsUrl', 'downloadConflictRecordsUrl', 'downloadMismatchRecordsUrl', - ); + ]; $this->setStatusUrl(); foreach ($properties as $property) { @@ -115,9 +115,9 @@ public function postProcess() { $onDuplicate = $this->get('onDuplicate'); $mapper = $this->controller->exportValue('MapField', 'mapper'); - $mapperKeys = array(); - $mapperLocType = array(); - $mapperPhoneType = array(); + $mapperKeys = []; + $mapperLocType = []; + $mapperPhoneType = []; foreach ($mapper as $key => $value) { $mapperKeys[$key] = $mapper[$key][0]; @@ -142,7 +142,7 @@ public function postProcess() { $mapFields = $this->get('fields'); foreach ($mapper as $key => $value) { - $header = array(); + $header = []; if (isset($mapFields[$mapper[$key][0]])) { $header[] = $mapFields[$mapper[$key][0]]; } @@ -164,7 +164,7 @@ public function postProcess() { $errorStack = CRM_Core_Error::singleton(); $errors = $errorStack->getErrors(); - $errorMessage = array(); + $errorMessage = []; if (is_array($errors)) { foreach ($errors as $key => $value) { diff --git a/CRM/Activity/Import/Form/Summary.php b/CRM/Activity/Import/Form/Summary.php index b2e74ab00fb5..5e263c5edbc7 100644 --- a/CRM/Activity/Import/Form/Summary.php +++ b/CRM/Activity/Import/Form/Summary.php @@ -89,7 +89,7 @@ public function preProcess() { } $this->assign('dupeActionString', $dupeActionString); - $properties = array( + $properties = [ 'totalRowCount', 'validRowCount', 'invalidRowCount', @@ -101,7 +101,7 @@ public function preProcess() { 'downloadMismatchRecordsUrl', 'groupAdditions', 'unMatchCount', - ); + ]; foreach ($properties as $property) { $this->assign($property, $this->get($property)); } diff --git a/CRM/Activity/Import/Parser.php b/CRM/Activity/Import/Parser.php index 1ac6dd30b18f..664e4a0deb78 100644 --- a/CRM/Activity/Import/Parser.php +++ b/CRM/Activity/Import/Parser.php @@ -97,14 +97,14 @@ public function run( $this->_invalidRowCount = $this->_validCount = 0; $this->_totalCount = $this->_conflictCount = 0; - $this->_errors = array(); - $this->_warnings = array(); - $this->_conflicts = array(); + $this->_errors = []; + $this->_warnings = []; + $this->_conflicts = []; $this->_fileSize = number_format(filesize($fileName) / 1024.0, 2); if ($mode == self::MODE_MAPFIELD) { - $this->_rows = array(); + $this->_rows = []; } else { $this->_activeFieldCount = count($this->_activeFields); @@ -240,30 +240,30 @@ public function run( } if ($this->_invalidRowCount) { // removed view url for invlaid contacts - $headers = array_merge(array( + $headers = array_merge([ ts('Line Number'), ts('Reason'), - ), + ], $customHeaders ); $this->_errorFileName = self::errorFileName(self::ERROR); self::exportCSV($this->_errorFileName, $headers, $this->_errors); } if ($this->_conflictCount) { - $headers = array_merge(array( + $headers = array_merge([ ts('Line Number'), ts('Reason'), - ), + ], $customHeaders ); $this->_conflictFileName = self::errorFileName(self::CONFLICT); self::exportCSV($this->_conflictFileName, $headers, $this->_conflicts); } if ($this->_duplicateCount) { - $headers = array_merge(array( + $headers = array_merge([ ts('Line Number'), ts('View Activity History URL'), - ), + ], $customHeaders ); @@ -298,7 +298,7 @@ public function setActiveFields($fieldKeys) { * (reference ) associative array of name/value pairs */ public function &getActiveFieldParams() { - $params = array(); + $params = []; for ($i = 0; $i < $this->_activeFieldCount; $i++) { if (isset($this->_activeFields[$i]->_value) && !isset($params[$this->_activeFields[$i]->_name]) @@ -383,7 +383,7 @@ public function set($store, $mode = self::MODE_SUMMARY) { * @param array $data */ public static function exportCSV($fileName, $header, $data) { - $output = array(); + $output = []; $fd = fopen($fileName, 'w'); foreach ($header as $key => $value) { diff --git a/CRM/Activity/Import/Parser/Activity.php b/CRM/Activity/Import/Parser/Activity.php index 83e358c77e6d..fbb3c6149737 100644 --- a/CRM/Activity/Import/Parser/Activity.php +++ b/CRM/Activity/Import/Parser/Activity.php @@ -78,16 +78,16 @@ public function init() { $activityTarget ); - $fields = array_merge($fields, array( - 'source_contact_id' => array( + $fields = array_merge($fields, [ + 'source_contact_id' => [ 'title' => ts('Source Contact'), 'headerPattern' => '/Source.Contact?/i', - ), - 'activity_label' => array( + ], + 'activity_label' => [ 'title' => ts('Activity Type Label'), 'headerPattern' => '/(activity.)?type label?/i', - ), - )); + ], + ]); foreach ($fields as $name => $field) { $field['type'] = CRM_Utils_Array::value('type', $field, CRM_Utils_Type::T_INT); @@ -96,7 +96,7 @@ public function init() { $this->addField($name, $field['title'], $field['type'], $field['headerPattern'], $field['dataPattern']); } - $this->_newActivity = array(); + $this->_newActivity = []; $this->setActiveFields($this->_mapperKeys); @@ -258,7 +258,7 @@ public function import($onDuplicate, &$values) { $params = &$this->getActiveFieldParams(); $activityLabel = array_search('activity_label', $this->_mapperKeys); if ($activityLabel) { - $params = array_merge($params, array('activity_label' => $values[$activityLabel])); + $params = array_merge($params, ['activity_label' => $values[$activityLabel]]); } // For date-Formats. $session = CRM_Core_Session::singleton(); @@ -332,10 +332,10 @@ public function import($onDuplicate, &$values) { } else { // Using new Dedupe rule. - $ruleParams = array( + $ruleParams = [ 'contact_type' => 'Individual', 'used' => 'Unsupervised', - ); + ]; $fieldsArray = CRM_Dedupe_BAO_Rule::dedupeRuleFields($ruleParams); $disp = NULL; diff --git a/CRM/Activity/Page/AJAX.php b/CRM/Activity/Page/AJAX.php index a840524af6e6..f96c4c0938d9 100644 --- a/CRM/Activity/Page/AJAX.php +++ b/CRM/Activity/Page/AJAX.php @@ -43,7 +43,7 @@ public static function getCaseActivity() { $userID = CRM_Utils_Type::validate($_GET['userID'], 'Integer'); $context = CRM_Utils_Type::validate(CRM_Utils_Array::value('context', $_GET), 'String'); - $optionalParameters = array( + $optionalParameters = [ 'source_contact_id' => 'Integer', 'status_id' => 'Integer', 'activity_deleted' => 'Boolean', @@ -51,10 +51,10 @@ public static function getCaseActivity() { // "Date" validation fails because it expects only numbers with no hyphens 'activity_date_low' => 'Alphanumeric', 'activity_date_high' => 'Alphanumeric', - ); + ]; $params = CRM_Core_Page_AJAX::defaultSortAndPagerParams(); - $params += CRM_Core_Page_AJAX::validateParams(array(), $optionalParameters); + $params += CRM_Core_Page_AJAX::validateParams([], $optionalParameters); // get the activities related to given case $activities = CRM_Case_BAO_Case::getCaseActivity($caseID, $params, $contactID, $context, $userID); @@ -66,17 +66,17 @@ public static function getCaseGlobalRelationships() { $params = CRM_Core_Page_AJAX::defaultSortAndPagerParams(); // get the activities related to given case - $globalGroupInfo = array(); + $globalGroupInfo = []; // get the total row count CRM_Case_BAO_Case::getGlobalContacts($globalGroupInfo, NULL, FALSE, TRUE, NULL, NULL); // limit the rows $relGlobal = CRM_Case_BAO_Case::getGlobalContacts($globalGroupInfo, $params['sortBy'], $showLinks = TRUE, FALSE, $params['offset'], $params['rp']); - $relationships = array(); + $relationships = []; // after sort we can update username fields to be a url foreach ($relGlobal as $key => $value) { - $relationship = array(); + $relationship = []; $relationship['sort_name'] = $value['sort_name']; $relationship['phone'] = $value['phone']; $relationship['email'] = $value['email']; @@ -84,7 +84,7 @@ public static function getCaseGlobalRelationships() { array_push($relationships, $relationship); } - $globalRelationshipsDT = array(); + $globalRelationshipsDT = []; $globalRelationshipsDT['data'] = $relationships; $globalRelationshipsDT['recordsTotal'] = count($relationships); $globalRelationshipsDT['recordsFiltered'] = count($relationships); @@ -108,7 +108,7 @@ public static function getCaseClientRelationships() { // Now build 'Other Relationships' array by removing relationships that are already listed under Case Roles // so they don't show up twice. - $clientRelationships = array(); + $clientRelationships = []; foreach ($relClient as $r) { if (!array_key_exists($r['id'], $caseRelationships)) { $clientRelationships[] = $r; @@ -122,10 +122,10 @@ public static function getCaseClientRelationships() { $sort_type = "SORT_" . strtoupper($params['_raw_values']['order'][0]); array_multisort($sortArray, constant($sort_type), $clientRelationships); - $relationships = array(); + $relationships = []; // after sort we can update username fields to be a url foreach ($clientRelationships as $key => $value) { - $relationship = array(); + $relationship = []; $relationship['relation'] = $value['relation']; $relationship['name'] = '' . $clientRelationships[$key]['name'] . ''; @@ -135,7 +135,7 @@ public static function getCaseClientRelationships() { array_push($relationships, $relationship); } - $clientRelationshipsDT = array(); + $clientRelationshipsDT = []; $clientRelationshipsDT['data'] = $relationships; $clientRelationshipsDT['recordsTotal'] = count($relationships); $clientRelationshipsDT['recordsFiltered'] = count($relationships); @@ -173,7 +173,7 @@ public static function getCaseRoles() { // CRM-14466 added cid to the non-client array to avoid php notice foreach ($caseRoles as $id => $value) { if ($id != "client") { - $rel = array(); + $rel = []; $rel['relation'] = $value; $rel['relation_type'] = $id; $rel['name'] = '(not assigned)'; @@ -184,7 +184,7 @@ public static function getCaseRoles() { } else { foreach ($value as $clientRole) { - $relClient = array(); + $relClient = []; $relClient['relation'] = 'Client'; $relClient['name'] = $clientRole['sort_name']; $relClient['phone'] = $clientRole['phone']; @@ -203,7 +203,7 @@ public static function getCaseRoles() { $sort_type = "SORT_" . strtoupper($params['_raw_values']['order'][0]); array_multisort($sortArray, constant($sort_type), $caseRelationships); - $relationships = array(); + $relationships = []; // set user name, email and edit columns links foreach ($caseRelationships as $key => &$row) { @@ -228,16 +228,16 @@ public static function getCaseRoles() { $contactType = $contactType == 'Contact' ? '' : $contactType; switch ($row['source']) { case 'caseRel': - $row['actions'] = '' . + $row['actions'] = '' . '' . '' . - '' . + '' . '' . ''; break; case 'caseRoles': - $row['actions'] = '' . + $row['actions'] = '' . '' . ''; break; @@ -252,7 +252,7 @@ public static function getCaseRoles() { } $params['total'] = count($relationships); - $caseRelationshipsDT = array(); + $caseRelationshipsDT = []; $caseRelationshipsDT['data'] = $relationships; $caseRelationshipsDT['recordsTotal'] = $params['total']; $caseRelationshipsDT['recordsFiltered'] = $params['total']; @@ -262,8 +262,8 @@ public static function getCaseRoles() { } public static function convertToCaseActivity() { - $params = array('caseID', 'activityID', 'contactID', 'newSubject', 'targetContactIds', 'mode'); - $vals = array(); + $params = ['caseID', 'activityID', 'contactID', 'newSubject', 'targetContactIds', 'mode']; + $vals = []; foreach ($params as $param) { $vals[$param] = CRM_Utils_Array::value($param, $_POST); } @@ -278,19 +278,19 @@ public static function convertToCaseActivity() { */ public static function _convertToCaseActivity($params) { if (!$params['activityID'] || !$params['caseID']) { - return (array('error_msg' => 'required params missing.')); + return (['error_msg' => 'required params missing.']); } $otherActivity = new CRM_Activity_DAO_Activity(); $otherActivity->id = $params['activityID']; if (!$otherActivity->find(TRUE)) { - return (array('error_msg' => 'activity record is missing.')); + return (['error_msg' => 'activity record is missing.']); } $actDateTime = CRM_Utils_Date::isoToMysql($otherActivity->activity_date_time); // Create new activity record. $mainActivity = new CRM_Activity_DAO_Activity(); - $mainActVals = array(); + $mainActVals = []; CRM_Core_DAO::storeValues($otherActivity, $mainActVals); // Get new activity subject. @@ -312,10 +312,10 @@ public static function _convertToCaseActivity($params) { // Mark previous activity as deleted. If it was a non-case activity // then just change the subject. - if (in_array($params['mode'], array( + if (in_array($params['mode'], [ 'move', 'file', - ))) { + ])) { $caseActivity = new CRM_Case_DAO_CaseActivity(); $caseActivity->case_id = $params['caseID']; $caseActivity->activity_id = $otherActivity->id; @@ -323,15 +323,15 @@ public static function _convertToCaseActivity($params) { $otherActivity->is_deleted = 1; } else { - $otherActivity->subject = ts('(Filed on case %1)', array( + $otherActivity->subject = ts('(Filed on case %1)', [ 1 => $params['caseID'], - )) . ' ' . $otherActivity->subject; + ]) . ' ' . $otherActivity->subject; } $otherActivity->save(); } - $targetContacts = array(); + $targetContacts = []; if (!empty($params['targetContactIds'])) { $targetContacts = array_unique(explode(',', $params['targetContactIds'])); } @@ -342,19 +342,19 @@ public static function _convertToCaseActivity($params) { $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts); $sourceContactID = CRM_Activity_BAO_Activity::getSourceContactID($params['activityID']); - $src_params = array( + $src_params = [ 'activity_id' => $mainActivityId, 'contact_id' => $sourceContactID, 'record_type_id' => $sourceID, - ); + ]; CRM_Activity_BAO_ActivityContact::create($src_params); foreach ($targetContacts as $key => $value) { - $targ_params = array( + $targ_params = [ 'activity_id' => $mainActivityId, 'contact_id' => $value, 'record_type_id' => $targetID, - ); + ]; CRM_Activity_BAO_ActivityContact::create($targ_params); } @@ -364,11 +364,11 @@ public static function _convertToCaseActivity($params) { $assigneeContacts = array_unique(explode(',', $params['assigneeContactIds'])); } foreach ($assigneeContacts as $key => $value) { - $assigneeParams = array( + $assigneeParams = [ 'activity_id' => $mainActivityId, 'contact_id' => $value, 'record_type_id' => $assigneeID, - ); + ]; CRM_Activity_BAO_ActivityContact::create($assigneeParams); } @@ -383,7 +383,7 @@ public static function _convertToCaseActivity($params) { CRM_Activity_BAO_Activity::copyExtendedActivityData($params); CRM_Utils_Hook::post('create', 'CaseActivity', $caseActivity->id, $caseActivity); - return (array('error_msg' => $error_msg, 'newId' => $mainActivity->id)); + return (['error_msg' => $error_msg, 'newId' => $mainActivity->id]); } /** @@ -392,11 +392,11 @@ public static function _convertToCaseActivity($params) { * @return array */ public static function getContactActivity() { - $requiredParameters = array( + $requiredParameters = [ 'cid' => 'Integer', - ); + ]; - $optionalParameters = array( + $optionalParameters = [ 'context' => 'String', 'activity_type_id' => 'Integer', 'activity_type_exclude_id' => 'Integer', @@ -404,7 +404,7 @@ public static function getContactActivity() { 'activity_date_time_relative' => 'String', 'activity_date_time_low' => 'String', 'activity_date_time_high' => 'String', - ); + ]; $params = CRM_Core_Page_AJAX::defaultSortAndPagerParams(); $params += CRM_Core_Page_AJAX::validateParams($requiredParameters, $optionalParameters); @@ -421,7 +421,7 @@ public static function getContactActivity() { // Check if recurring activity. if (!empty($value['is_recurring_activity'])) { $repeat = $value['is_recurring_activity']; - $activities['data'][$key]['activity_type'] .= '
' . ts('Repeating (%1 of %2)', array(1 => $repeat[0], 2 => $repeat[1])) . ''; + $activities['data'][$key]['activity_type'] .= '
' . ts('Repeating (%1 of %2)', [1 => $repeat[0], 2 => $repeat[1]]) . ''; } } @@ -438,7 +438,7 @@ public static function getContactActivity() { } if (!empty($params[$searchField])) { $activityFilter[$formSearchField] = $params[$searchField]; - if (in_array($searchField, array('activity_date_time_low', 'activity_date_time_high'))) { + if (in_array($searchField, ['activity_date_time_low', 'activity_date_time_high'])) { $activityFilter['activity_date_time_relative'] = 0; } elseif ($searchField == 'activity_status_id') { @@ -450,7 +450,7 @@ public static function getContactActivity() { Civi::contactSettings()->set('activity_tab_filter', $activityFilter); } if (!empty($_GET['is_unit_test'])) { - return array($activities, $activityFilter); + return [$activities, $activityFilter]; } CRM_Utils_JSON::output($activities); diff --git a/CRM/Activity/Page/Tab.php b/CRM/Activity/Page/Tab.php index 9e66e632dd16..4415618a7e2f 100644 --- a/CRM/Activity/Page/Tab.php +++ b/CRM/Activity/Page/Tab.php @@ -86,12 +86,12 @@ public function edit() { switch ($activityTypeId) { case $emailTypeValue: $wrapper = new CRM_Utils_Wrapper(); - $arguments = array('attachUpload' => 1); + $arguments = ['attachUpload' => 1]; return $wrapper->run('CRM_Contact_Form_Task_Email', ts('Email a Contact'), $arguments); case $letterTypeValue: $wrapper = new CRM_Utils_Wrapper(); - $arguments = array('attachUpload' => 1); + $arguments = ['attachUpload' => 1]; return $wrapper->run('CRM_Contact_Form_Task_PDF', ts('Create PDF Letter'), $arguments); default: @@ -167,7 +167,7 @@ public function run() { // Do check for view/edit operation. if ($this->_id && - in_array($action, array(CRM_Core_Action::UPDATE, CRM_Core_Action::VIEW)) + in_array($action, [CRM_Core_Action::UPDATE, CRM_Core_Action::VIEW]) ) { if (!CRM_Activity_BAO_Activity::checkPermission($this->_id, $action)) { CRM_Core_Error::fatal(ts('You are not authorized to access this page.')); @@ -200,10 +200,10 @@ public function run() { 'Print PDF Letter' ); - if (in_array($activityTypeId, array( + if (in_array($activityTypeId, [ $emailTypeValue, $letterTypeValue, - ))) { + ])) { return; } } diff --git a/CRM/Activity/Page/UserDashboard.php b/CRM/Activity/Page/UserDashboard.php index e6c9018ccd54..d16a23d32ef2 100644 --- a/CRM/Activity/Page/UserDashboard.php +++ b/CRM/Activity/Page/UserDashboard.php @@ -54,7 +54,7 @@ public function listActivities() { $controller->set('context', 'user'); $controller->set('cid', $this->_contactId); // Limit to status "Scheduled" and "Available" - $controller->set('status', array('IN' => array(1, 7))); + $controller->set('status', ['IN' => [1, 7]]); $controller->set('activity_role', 2); $controller->set('force', 1); $controller->process(); diff --git a/CRM/Activity/Selector/Activity.php b/CRM/Activity/Selector/Activity.php index 405fd50d02ef..befd1effda5b 100644 --- a/CRM/Activity/Selector/Activity.php +++ b/CRM/Activity/Selector/Activity.php @@ -214,18 +214,18 @@ public static function actionLinks( $qsDelete = "atype={$activityTypeId}&action=delete&reset=1&id=%%id%%&cid=%%cid%%&context=%%cxt%%{$extraParams}"; - $actionLinks = array(); + $actionLinks = []; if ($showView) { - $actionLinks += array( + $actionLinks += [ CRM_Core_Action:: - VIEW => array( + VIEW => [ 'name' => ts('View'), 'url' => $url, 'qs' => $qsView, 'title' => ts('View Activity'), - ), - ); + ], + ]; } if ($showUpdate) { @@ -237,15 +237,15 @@ public static function actionLinks( $updateUrl = 'civicrm/activity/pdf/add'; } if (CRM_Activity_BAO_Activity::checkPermission($activityId, CRM_Core_Action::UPDATE)) { - $actionLinks += array( + $actionLinks += [ CRM_Core_Action:: - UPDATE => array( + UPDATE => [ 'name' => ts('Edit'), 'url' => $updateUrl, 'qs' => $qsUpdate, 'title' => ts('Update Activity'), - ), - ); + ], + ]; } } @@ -253,42 +253,42 @@ public static function actionLinks( $activityTypeName && CRM_Case_BAO_Case::checkPermission($activityId, 'File On Case', $activityTypeId) ) { - $actionLinks += array( + $actionLinks += [ CRM_Core_Action:: - ADD => array( + ADD => [ 'name' => ts('File on Case'), 'url' => '#', 'extra' => 'onclick="javascript:fileOnCase( \'file\', \'%%id%%\', null, this ); return false;"', 'title' => ts('File on Case'), - ), - ); + ], + ]; } if ($showDelete) { if (!isset($delUrl) || !$delUrl) { $delUrl = $url; } - $actionLinks += array( + $actionLinks += [ CRM_Core_Action:: - DELETE => array( + DELETE => [ 'name' => ts('Delete'), 'url' => $delUrl, 'qs' => $qsDelete, 'title' => ts('Delete Activity'), - ), - ); + ], + ]; } if ($accessMailingReport) { - $actionLinks += array( + $actionLinks += [ CRM_Core_Action:: - BROWSE => array( + BROWSE => [ 'name' => ts('Mailing Report'), 'url' => 'civicrm/mailing/report', 'qs' => "mid={$sourceRecordId}&reset=1&cid=%%cid%%&context=activitySelector", 'title' => ts('View Mailing Report'), - ), - ); + ], + ]; } return $actionLinks; @@ -323,7 +323,7 @@ public function getPagerParams($action, &$params) { */ public function &getColumnHeaders($action = NULL, $output = NULL) { if ($output == CRM_Core_Selector_Controller::EXPORT || $output == CRM_Core_Selector_Controller::SCREEN) { - $csvHeaders = array(ts('Activity Type'), ts('Description'), ts('Activity Date')); + $csvHeaders = [ts('Activity Type'), ts('Description'), ts('Activity Date')]; foreach (self::_getColumnHeaders() as $column) { if (array_key_exists('name', $column)) { $csvHeaders[] = $column['name']; @@ -348,7 +348,7 @@ public function &getColumnHeaders($action = NULL, $output = NULL) { * Total number of rows */ public function getTotalCount($action, $case = NULL) { - $params = array( + $params = [ 'contact_id' => $this->_contactId, 'admin' => $this->_admin, 'caseId' => $case, @@ -357,7 +357,7 @@ public function getTotalCount($action, $case = NULL) { 'offset' => 0, 'rowCount' => 0, 'sort' => NULL, - ); + ]; return CRM_Activity_BAO_Activity::getActivitiesCount($params); } @@ -381,7 +381,7 @@ public function getTotalCount($action, $case = NULL) { * the total number of rows for this action */ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL, $case = NULL) { - $params = array( + $params = [ 'contact_id' => $this->_contactId, 'admin' => $this->_admin, 'caseId' => $case, @@ -390,7 +390,7 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL, $ca 'offset' => $offset, 'rowCount' => $rowCount, 'sort' => $sort, - ); + ]; $config = CRM_Core_Config::singleton(); $rows = CRM_Activity_BAO_Activity::getActivities($params); @@ -403,7 +403,7 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL, $ca $engagementLevels = CRM_Campaign_PseudoConstant::engagementLevel(); // CRM-4418 - $permissions = array($this->_permission); + $permissions = [$this->_permission]; if (CRM_Core_Permission::check('delete activities')) { $permissions[] = CRM_Core_Permission::DELETE; } @@ -473,12 +473,12 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL, $ca if ($output != CRM_Core_Selector_Controller::EXPORT && $output != CRM_Core_Selector_Controller::SCREEN) { $row['action'] = CRM_Core_Action::formLink($actionLinks, $actionMask, - array( + [ 'id' => $row['activity_id'], 'cid' => $this->_contactId, 'cxt' => $this->_context, 'caseid' => CRM_Utils_Array::value('case_id', $row), - ), + ], ts('more'), FALSE, 'activity.selector.action', @@ -514,36 +514,36 @@ public function getExportFileName($output = 'csv') { */ private static function &_getColumnHeaders() { if (!isset(self::$_columnHeaders)) { - self::$_columnHeaders = array( - array( + self::$_columnHeaders = [ + [ 'name' => ts('Type'), 'sort' => 'activity_type', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - array( + ], + [ 'name' => ts('Subject'), 'sort' => 'subject', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - array( + ], + [ 'name' => ts('Added By'), 'sort' => 'source_contact_name', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - array('name' => ts('With')), - array('name' => ts('Assigned')), - array( + ], + ['name' => ts('With')], + ['name' => ts('Assigned')], + [ 'name' => ts('Date'), 'sort' => 'activity_date_time', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - array( + ], + [ 'name' => ts('Status'), 'sort' => 'status_id', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - array('desc' => ts('Actions')), - ); + ], + ['desc' => ts('Actions')], + ]; } return self::$_columnHeaders; diff --git a/CRM/Activity/Selector/Search.php b/CRM/Activity/Selector/Search.php index f6de0e43dd50..f690f1bc534e 100644 --- a/CRM/Activity/Selector/Search.php +++ b/CRM/Activity/Selector/Search.php @@ -57,7 +57,7 @@ class CRM_Activity_Selector_Search extends CRM_Core_Selector_Base implements CRM * @var array */ - static $_properties = array( + static $_properties = [ 'contact_id', 'contact_type', 'contact_sub_type', @@ -74,7 +74,7 @@ class CRM_Activity_Selector_Search extends CRM_Core_Selector_Base implements CRM 'activity_is_test', 'activity_campaign_id', 'activity_engagement_level', - ); + ]; /** * Are we restricting ourselves to a single contact. @@ -172,7 +172,7 @@ public function __construct( // CRM-12675 $components = CRM_Core_Component::getNames(); - $componentClause = array(); + $componentClause = []; foreach ($components as $componentID => $componentName) { // CRM-19201: Add support for searching CiviCampaign and CiviCase // activities. For CiviCase, "access all cases and activities" is @@ -261,7 +261,7 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { FALSE, $this->_activityClause ); - $rows = array(); + $rows = []; $mailingIDs = CRM_Mailing_BAO_Mailing::mailingACLIDs(); $accessCiviMail = CRM_Core_Permission::check('access CiviMail'); @@ -276,7 +276,7 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { $bulkActivityTypeID = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Bulk Email'); while ($result->fetch()) { - $row = array(); + $row = []; // Ignore rows where we dont have an activity id. if (empty($result->activity_id)) { @@ -335,11 +335,11 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { $this->_compContext ); $row['action'] = CRM_Core_Action::formLink($actionLinks, NULL, - array( + [ 'id' => $result->activity_id, 'cid' => $contactId, 'cxt' => $this->_context, - ), + ], ts('more'), FALSE, 'activity.selector.row', @@ -361,7 +361,7 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { $repeat = CRM_Core_BAO_RecurringEntity::getPositionAndCount($row['activity_id'], 'civicrm_activity'); $row['repeat'] = ''; if ($repeat) { - $row['repeat'] = ts('Repeating (%1 of %2)', array(1 => $repeat[0], 2 => $repeat[1])); + $row['repeat'] = ts('Repeating (%1 of %2)', [1 => $repeat[0], 2 => $repeat[1]]); } $rows[] = $row; } @@ -391,38 +391,38 @@ public function getQILL() { */ public function &getColumnHeaders($action = NULL, $output = NULL) { if (!isset(self::$_columnHeaders)) { - self::$_columnHeaders = array( - array( + self::$_columnHeaders = [ + [ 'name' => ts('Type'), 'sort' => 'activity_type_id', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - array( + ], + [ 'name' => ts('Subject'), 'sort' => 'activity_subject', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - array( + ], + [ 'name' => ts('Added By'), 'sort' => 'source_contact', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - array('name' => ts('With')), - array('name' => ts('Assigned')), - array( + ], + ['name' => ts('With')], + ['name' => ts('Assigned')], + [ 'name' => ts('Date'), 'sort' => 'activity_date_time', 'direction' => CRM_Utils_Sort::DESCENDING, - ), - array( + ], + [ 'name' => ts('Status'), 'sort' => 'activity_status', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - array( + ], + [ 'desc' => ts('Actions'), - ), - ); + ], + ]; } return self::$_columnHeaders; } diff --git a/CRM/Activity/StateMachine/Search.php b/CRM/Activity/StateMachine/Search.php index 226744b997af..237e9704fdf3 100644 --- a/CRM/Activity/StateMachine/Search.php +++ b/CRM/Activity/StateMachine/Search.php @@ -48,7 +48,7 @@ class CRM_Activity_StateMachine_Search extends CRM_Core_StateMachine { public function __construct($controller, $action = CRM_Core_Action::NONE) { parent::__construct($controller, $action); - $this->_pages = array(); + $this->_pages = []; $this->_pages['CRM_Activity_Form_Search'] = NULL; list($task, $result) = $this->taskName($controller, 'Search'); diff --git a/CRM/Activity/Task.php b/CRM/Activity/Task.php index 7fd32d20789a..bcd4cc804e70 100644 --- a/CRM/Activity/Task.php +++ b/CRM/Activity/Task.php @@ -46,71 +46,71 @@ class CRM_Activity_Task extends CRM_Core_Task { */ public static function tasks() { if (!(self::$_tasks)) { - self::$_tasks = array( - self::TASK_DELETE => array( + self::$_tasks = [ + self::TASK_DELETE => [ 'title' => ts('Delete activities'), 'class' => 'CRM_Activity_Form_Task_Delete', 'result' => FALSE, - ), - self::TASK_PRINT => array( + ], + self::TASK_PRINT => [ 'title' => ts('Print selected rows'), 'class' => 'CRM_Activity_Form_Task_Print', 'result' => FALSE, - ), - self::TASK_EXPORT => array( + ], + self::TASK_EXPORT => [ 'title' => ts('Export activities'), - 'class' => array( + 'class' => [ 'CRM_Export_Form_Select', 'CRM_Export_Form_Map', - ), + ], 'result' => FALSE, - ), - self::BATCH_UPDATE => array( + ], + self::BATCH_UPDATE => [ 'title' => ts('Update multiple activities'), - 'class' => array( + 'class' => [ 'CRM_Activity_Form_Task_PickProfile', 'CRM_Activity_Form_Task_Batch', - ), + ], 'result' => FALSE, - ), - self::TASK_EMAIL => array( - 'title' => ts('Email - send now (to %1 or less)', array( + ], + self::TASK_EMAIL => [ + 'title' => ts('Email - send now (to %1 or less)', [ 1 => Civi::settings() ->get('simple_mail_limit'), - )), - 'class' => array( + ]), + 'class' => [ 'CRM_Activity_Form_Task_PickOption', 'CRM_Activity_Form_Task_Email', - ), + ], 'result' => FALSE, - ), - self::TASK_SMS => array( + ], + self::TASK_SMS => [ 'title' => ts('SMS - send reply'), 'class' => 'CRM_Activity_Form_Task_SMS', 'result' => FALSE, - ), - self::TAG_ADD => array( + ], + self::TAG_ADD => [ 'title' => ts('Tag - add to activities'), 'class' => 'CRM_Activity_Form_Task_AddToTag', 'result' => FALSE, - ), - self::TAG_REMOVE => array( + ], + self::TAG_REMOVE => [ 'title' => ts('Tag - remove from activities'), 'class' => 'CRM_Activity_Form_Task_RemoveFromTag', 'result' => FALSE, - ), - ); + ], + ]; $config = CRM_Core_Config::singleton(); if (in_array('CiviCase', $config->enableComponents)) { if (CRM_Core_Permission::check('access all cases and activities') || CRM_Core_Permission::check('access my cases and activities') ) { - self::$_tasks[self::TASK_SMS] = array( + self::$_tasks[self::TASK_SMS] = [ 'title' => ts('File on case'), 'class' => 'CRM_Activity_Form_Task_FileOnCase', 'result' => FALSE, - ); + ]; } } @@ -134,14 +134,14 @@ public static function tasks() { * @return array * set of tasks that are valid for the user */ - public static function permissionedTaskTitles($permission, $params = array()) { + public static function permissionedTaskTitles($permission, $params = []) { if ($permission == CRM_Core_Permission::EDIT) { $tasks = self::taskTitles(); } else { - $tasks = array( + $tasks = [ self::TASK_EXPORT => self::$_tasks[self::TASK_EXPORT]['title'], - ); + ]; //CRM-4418, if (CRM_Core_Permission::check('delete activities')) { @@ -168,10 +168,10 @@ public static function getTask($value) { $value = self::TASK_PRINT; } - return array( + return [ self::$_tasks[$value]['class'], self::$_tasks[$value]['result'], - ); + ]; } } diff --git a/CRM/Admin/Form.php b/CRM/Admin/Form.php index cf85181609fd..eae83336915e 100644 --- a/CRM/Admin/Form.php +++ b/CRM/Admin/Form.php @@ -73,9 +73,9 @@ public function preProcess() { $this->_id = $this->get('id'); $this->_BAOName = $this->get('BAOName'); - $this->_values = array(); + $this->_values = []; if (isset($this->_id)) { - $params = array('id' => $this->_id); + $params = ['id' => $this->_id]; // this is needed if the form is outside the CRM name space $baoName = $this->_BAOName; $baoName::retrieve($params, $this->_values); @@ -92,8 +92,8 @@ public function preProcess() { public function setDefaultValues() { // Fetch defaults from the db if (!empty($this->_id) && empty($this->_values) && CRM_Utils_Rule::positiveInteger($this->_id)) { - $this->_values = array(); - $params = array('id' => $this->_id); + $this->_values = []; + $params = ['id' => $this->_id]; $baoName = $this->_BAOName; $baoName::retrieve($params, $this->_values); } @@ -127,27 +127,27 @@ public function setDefaultValues() { */ public function buildQuickForm() { if ($this->_action & CRM_Core_Action::VIEW || $this->_action & CRM_Core_Action::PREVIEW) { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'cancel', 'name' => ts('Done'), 'isDefault' => TRUE, - ), - ) + ], + ] ); } else { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => $this->_action & CRM_Core_Action::DELETE ? ts('Delete') : ts('Save'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); } } diff --git a/CRM/Admin/Form/CMSUser.php b/CRM/Admin/Form/CMSUser.php index 7c5563a831eb..37ce38eb8dec 100644 --- a/CRM/Admin/Form/CMSUser.php +++ b/CRM/Admin/Form/CMSUser.php @@ -41,17 +41,17 @@ class CRM_Admin_Form_CMSUser extends CRM_Core_Form { */ public function buildQuickForm() { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => ts('OK'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); } @@ -62,25 +62,25 @@ public function postProcess() { $result = CRM_Utils_System::synchronizeUsers(); $status = ts('Checked one user record.', - array( + [ 'count' => $result['contactCount'], 'plural' => 'Checked %count user records.', - ) + ] ); if ($result['contactMatching']) { $status .= '
' . ts('Found one matching contact record.', - array( + [ 'count' => $result['contactMatching'], 'plural' => 'Found %count matching contact records.', - ) + ] ); } $status .= '
' . ts('Created one new contact record.', - array( + [ 'count' => $result['contactCreated'], 'plural' => 'Created %count new contact records.', - ) + ] ); CRM_Core_Session::setStatus($status, ts('Synchronize Complete'), 'success'); CRM_Core_Session::singleton()->pushUserContext(CRM_Utils_System::url('civicrm/admin', 'reset=1')); diff --git a/CRM/Admin/Form/ContactType.php b/CRM/Admin/Form/ContactType.php index e2032703fdf8..3e6f2a753646 100644 --- a/CRM/Admin/Form/ContactType.php +++ b/CRM/Admin/Form/ContactType.php @@ -73,7 +73,7 @@ public function buildQuickForm() { ); $this->assign('cid', $this->_id); - $this->addFormRule(array('CRM_Admin_Form_ContactType', 'formRule'), $this); + $this->addFormRule(['CRM_Admin_Form_ContactType', 'formRule'], $this); } /** @@ -90,7 +90,7 @@ public function buildQuickForm() { */ public static function formRule($fields, $files, $self) { - $errors = array(); + $errors = []; if ($self->_id) { $contactName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_ContactType', $self->_id, 'name'); @@ -142,7 +142,7 @@ public function postProcess() { } $contactType = CRM_Contact_BAO_ContactType::add($params); CRM_Core_Session::setStatus(ts("The Contact Type '%1' has been saved.", - array(1 => $contactType->label) + [1 => $contactType->label] ), ts('Saved'), 'success'); } diff --git a/CRM/Admin/Form/Extensions.php b/CRM/Admin/Form/Extensions.php index bd8dda913de6..35927326e994 100644 --- a/CRM/Admin/Form/Extensions.php +++ b/CRM/Admin/Form/Extensions.php @@ -90,7 +90,7 @@ public function preProcess() { * Set default values for the form. */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; return $defaults; } @@ -101,52 +101,52 @@ public function buildQuickForm() { switch ($this->_action) { case CRM_Core_Action::ADD: $buttonName = ts('Install'); - $title = ts('Install "%1"?', array( + $title = ts('Install "%1"?', [ 1 => $this->_key, - )); + ]); break; case CRM_Core_Action::UPDATE: $buttonName = ts('Download and Install'); - $title = ts('Download and Install "%1"?', array( + $title = ts('Download and Install "%1"?', [ 1 => $this->_key, - )); + ]); break; case CRM_Core_Action::DELETE: $buttonName = ts('Uninstall'); - $title = ts('Uninstall "%1"?', array( + $title = ts('Uninstall "%1"?', [ 1 => $this->_key, - )); + ]); break; case CRM_Core_Action::ENABLE: $buttonName = ts('Enable'); - $title = ts('Enable "%1"?', array( + $title = ts('Enable "%1"?', [ 1 => $this->_key, - )); + ]); break; case CRM_Core_Action::DISABLE: $buttonName = ts('Disable'); - $title = ts('Disable "%1"?', array( + $title = ts('Disable "%1"?', [ 1 => $this->_key, - )); + ]); break; } $this->assign('title', $title); - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => $buttonName, 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); } @@ -164,7 +164,7 @@ public function buildQuickForm() { * true if no errors, else an array of errors */ public static function formRule($fields, $files, $self) { - $errors = array(); + $errors = []; return empty($errors) ? TRUE : $errors; } @@ -177,7 +177,7 @@ public function postProcess() { if ($this->_action & CRM_Core_Action::DELETE) { try { - CRM_Extension_System::singleton()->getManager()->uninstall(array($this->_key)); + CRM_Extension_System::singleton()->getManager()->uninstall([$this->_key]); CRM_Core_Session::setStatus("", ts('Extension Uninstalled'), "success"); } catch (CRM_Extension_Exception_DependencyException $e) { @@ -187,25 +187,25 @@ public function postProcess() { } if ($this->_action & CRM_Core_Action::ADD) { - civicrm_api3('Extension', 'install', array('keys' => $this->_key)); + civicrm_api3('Extension', 'install', ['keys' => $this->_key]); CRM_Core_Session::setStatus("", ts('Extension Installed'), "success"); } if ($this->_action & CRM_Core_Action::ENABLE) { - civicrm_api3('Extension', 'enable', array('keys' => $this->_key)); + civicrm_api3('Extension', 'enable', ['keys' => $this->_key]); CRM_Core_Session::setStatus("", ts('Extension Enabled'), "success"); } if ($this->_action & CRM_Core_Action::DISABLE) { - CRM_Extension_System::singleton()->getManager()->disable(array($this->_key)); + CRM_Extension_System::singleton()->getManager()->disable([$this->_key]); CRM_Core_Session::setStatus("", ts('Extension Disabled'), "success"); } if ($this->_action & CRM_Core_Action::UPDATE) { - $result = civicrm_api('Extension', 'download', array( + $result = civicrm_api('Extension', 'download', [ 'version' => 3, 'key' => $this->_key, - )); + ]); if (!CRM_Utils_Array::value('is_error', $result, FALSE)) { CRM_Core_Session::setStatus("", ts('Extension Upgraded'), "success"); } diff --git a/CRM/Admin/Form/Generic.php b/CRM/Admin/Form/Generic.php index d18e4baacc64..9919469cba9e 100644 --- a/CRM/Admin/Form/Generic.php +++ b/CRM/Admin/Form/Generic.php @@ -78,22 +78,22 @@ public function buildQuickForm() { // @todo look at sharing the code below in the settings trait. if ($this->includesReadOnlyFields) { - CRM_Core_Session::setStatus(ts("Some fields are loaded as 'readonly' as they have been set (overridden) in civicrm.settings.php."), '', 'info', array('expires' => 0)); + CRM_Core_Session::setStatus(ts("Some fields are loaded as 'readonly' as they have been set (overridden) in civicrm.settings.php."), '', 'info', ['expires' => 0]); } // @todo - do we still like this redirect? CRM_Core_Session::singleton()->pushUserContext(CRM_Utils_System::url('civicrm/admin', 'reset=1')); - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => ts('Save'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); } diff --git a/CRM/Admin/Form/Job.php b/CRM/Admin/Form/Job.php index 73f9aad7b26f..624e03a70efb 100644 --- a/CRM/Admin/Form/Job.php +++ b/CRM/Admin/Form/Job.php @@ -77,10 +77,10 @@ public function buildQuickForm($check = FALSE) { $attributes['name'], TRUE ); - $this->addRule('name', ts('Name already exists in Database.'), 'objectExists', array( + $this->addRule('name', ts('Name already exists in Database.'), 'objectExists', [ 'CRM_Core_DAO_Job', $this->_id, - )); + ]); $this->add('text', 'description', ts('Description'), $attributes['description'] @@ -97,7 +97,7 @@ public function buildQuickForm($check = FALSE) { $this->add('select', 'run_frequency', ts('Run frequency'), CRM_Core_SelectValues::getJobFrequency()); // CRM-17686 - $this->add('datepicker', 'scheduled_run_date', ts('Scheduled Run Date'), NULL, FALSE, array('minDate' => time())); + $this->add('datepicker', 'scheduled_run_date', ts('Scheduled Run Date'), NULL, FALSE, ['minDate' => time()]); $this->add('textarea', 'parameters', ts('Command parameters'), "cols=50 rows=6" @@ -106,7 +106,7 @@ public function buildQuickForm($check = FALSE) { // is this job active ? $this->add('checkbox', 'is_active', ts('Is this Scheduled Job active?')); - $this->addFormRule(array('CRM_Admin_Form_Job', 'formRule')); + $this->addFormRule(['CRM_Admin_Form_Job', 'formRule']); } /** @@ -117,13 +117,13 @@ public function buildQuickForm($check = FALSE) { */ public static function formRule($fields) { - $errors = array(); + $errors = []; require_once 'api/api.php'; /** @var \Civi\API\Kernel $apiKernel */ $apiKernel = \Civi::service('civi_api_kernel'); - $apiRequest = \Civi\API\Request::create($fields['api_entity'], $fields['api_action'], array('version' => 3), NULL); + $apiRequest = \Civi\API\Request::create($fields['api_entity'], $fields['api_action'], ['version' => 3], NULL); try { $apiKernel->resolve($apiRequest); } @@ -142,7 +142,7 @@ public static function formRule($fields) { * @return array */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; if (!$this->_id) { $defaults['is_active'] = $defaults['is_default'] = 1; @@ -217,13 +217,13 @@ public function postProcess() { The result will land on the same day of the month except for days 29-31 when the target month contains fewer days than the previous month. For example, if a job is scheduled to run on August 31st, the following invocation will occur on October 1st, and then the 1st of every month thereafter. To avoid this issue, please schedule Monthly and Quarterly jobs to run within the first 28 days of the month.'), - ts('Warning'), 'info', array('expires' => 0)); + ts('Warning'), 'info', ['expires' => 0]); } } } // ...otherwise, if this isn't a new scheduled job, clear the next scheduled run elseif ($dao->id) { - $job = new CRM_Core_ScheduledJob(array('id' => $dao->id)); + $job = new CRM_Core_ScheduledJob(['id' => $dao->id]); $job->clearScheduledRunDate(); } @@ -233,7 +233,7 @@ public function postProcess() { if ($values['api_action'] == 'update_greeting' && CRM_Utils_Array::value('is_active', $values) == 1) { // pass "wiki" as 6th param to docURL2 if you are linking to a page in wiki.civicrm.org $docLink = CRM_Utils_System::docURL2("Managing Scheduled Jobs", NULL, NULL, NULL, NULL, "wiki"); - $msg = ts('The update greeting job can be very resource intensive and is typically not necessary to run on a regular basis. If you do choose to enable the job, we recommend you do not run it with the force=1 option, which would rebuild greetings on all records. Leaving that option absent, or setting it to force=0, will only rebuild greetings for contacts that do not currently have a value stored. %1', array(1 => $docLink)); + $msg = ts('The update greeting job can be very resource intensive and is typically not necessary to run on a regular basis. If you do choose to enable the job, we recommend you do not run it with the force=1 option, which would rebuild greetings on all records. Leaving that option absent, or setting it to force=0, will only rebuild greetings for contacts that do not currently have a value stored. %1', [1 => $docLink]); CRM_Core_Session::setStatus($msg, ts('Warning: Update Greeting job enabled'), 'alert'); } diff --git a/CRM/Admin/Form/LabelFormats.php b/CRM/Admin/Form/LabelFormats.php index 70e767395d3f..0a829c688999 100644 --- a/CRM/Admin/Form/LabelFormats.php +++ b/CRM/Admin/Form/LabelFormats.php @@ -50,9 +50,9 @@ class CRM_Admin_Form_LabelFormats extends CRM_Admin_Form { public function preProcess() { $this->_id = $this->get('id'); $this->_group = CRM_Utils_Request::retrieve('group', 'String', $this, FALSE, 'label_format'); - $this->_values = array(); + $this->_values = []; if (isset($this->_id)) { - $params = array('id' => $this->_id); + $params = ['id' => $this->_id]; CRM_Core_BAO_LabelFormat::retrieve($params, $this->_values, $this->_group); } } @@ -69,7 +69,7 @@ public function buildQuickForm() { return; } - $disabled = array(); + $disabled = []; $required = TRUE; $is_reserved = $this->_id ? CRM_Core_BAO_LabelFormat::getFieldValue('CRM_Core_BAO_LabelFormat', $this->_id, 'is_reserved') : FALSE; if ($is_reserved) { @@ -79,7 +79,7 @@ public function buildQuickForm() { $attributes = CRM_Core_DAO::getAttribute('CRM_Core_BAO_LabelFormat'); $this->add('text', 'label', ts('Name'), $attributes['label'] + $disabled, $required); - $this->add('text', 'description', ts('Description'), array('size' => CRM_Utils_Type::HUGE)); + $this->add('text', 'description', ts('Description'), ['size' => CRM_Utils_Type::HUGE]); $this->add('checkbox', 'is_default', ts('Is this Label Format the default?')); // currently we support only mailing label creation, hence comment below code @@ -97,18 +97,18 @@ public function buildQuickForm() { */ $this->add('select', 'paper_size', ts('Sheet Size'), - array( + [ 0 => ts('- default -'), - ) + CRM_Core_BAO_PaperSize::getList(TRUE), FALSE, - array( + ] + CRM_Core_BAO_PaperSize::getList(TRUE), FALSE, + [ 'onChange' => "selectPaper( this.value );", - ) + $disabled + ] + $disabled ); $this->add('static', 'paper_dimensions', NULL, ts('Sheet Size (w x h)')); $this->add('select', 'orientation', ts('Orientation'), CRM_Core_BAO_LabelFormat::getPageOrientations(), FALSE, - array( + [ 'onChange' => "updatePaperDimensions();", - ) + $disabled + ] + $disabled ); $this->add('select', 'font_name', ts('Font Name'), CRM_Core_BAO_LabelFormat::getFontNames($this->_group)); $this->add('select', 'font_size', ts('Font Size'), CRM_Core_BAO_LabelFormat::getFontSizes()); @@ -116,24 +116,24 @@ public function buildQuickForm() { $this->add('checkbox', 'bold', ts('Bold')); $this->add('checkbox', 'italic', ts('Italic')); $this->add('select', 'metric', ts('Unit of Measure'), CRM_Core_BAO_LabelFormat::getUnits(), FALSE, - array('onChange' => "selectMetric( this.value );") + ['onChange' => "selectMetric( this.value );"] ); - $this->add('text', 'width', ts('Label Width'), array('size' => 8, 'maxlength' => 8) + $disabled, $required); - $this->add('text', 'height', ts('Label Height'), array('size' => 8, 'maxlength' => 8) + $disabled, $required); - $this->add('text', 'NX', ts('Labels Per Row'), array('size' => 3, 'maxlength' => 3) + $disabled, $required); - $this->add('text', 'NY', ts('Labels Per Column'), array('size' => 3, 'maxlength' => 3) + $disabled, $required); - $this->add('text', 'tMargin', ts('Top Margin'), array('size' => 8, 'maxlength' => 8) + $disabled, $required); - $this->add('text', 'lMargin', ts('Left Margin'), array('size' => 8, 'maxlength' => 8) + $disabled, $required); - $this->add('text', 'SpaceX', ts('Horizontal Spacing'), array('size' => 8, 'maxlength' => 8) + $disabled, $required); - $this->add('text', 'SpaceY', ts('Vertical Spacing'), array('size' => 8, 'maxlength' => 8) + $disabled, $required); - $this->add('text', 'lPadding', ts('Left Padding'), array('size' => 8, 'maxlength' => 8), $required); - $this->add('text', 'tPadding', ts('Top Padding'), array('size' => 8, 'maxlength' => 8), $required); + $this->add('text', 'width', ts('Label Width'), ['size' => 8, 'maxlength' => 8] + $disabled, $required); + $this->add('text', 'height', ts('Label Height'), ['size' => 8, 'maxlength' => 8] + $disabled, $required); + $this->add('text', 'NX', ts('Labels Per Row'), ['size' => 3, 'maxlength' => 3] + $disabled, $required); + $this->add('text', 'NY', ts('Labels Per Column'), ['size' => 3, 'maxlength' => 3] + $disabled, $required); + $this->add('text', 'tMargin', ts('Top Margin'), ['size' => 8, 'maxlength' => 8] + $disabled, $required); + $this->add('text', 'lMargin', ts('Left Margin'), ['size' => 8, 'maxlength' => 8] + $disabled, $required); + $this->add('text', 'SpaceX', ts('Horizontal Spacing'), ['size' => 8, 'maxlength' => 8] + $disabled, $required); + $this->add('text', 'SpaceY', ts('Vertical Spacing'), ['size' => 8, 'maxlength' => 8] + $disabled, $required); + $this->add('text', 'lPadding', ts('Left Padding'), ['size' => 8, 'maxlength' => 8], $required); + $this->add('text', 'tPadding', ts('Top Padding'), ['size' => 8, 'maxlength' => 8], $required); $this->add('number', 'weight', ts('Order'), CRM_Core_DAO::getAttribute('CRM_Core_BAO_LabelFormat', 'weight'), TRUE); - $this->addRule('label', ts('Name already exists in Database.'), 'objectExists', array( + $this->addRule('label', ts('Name already exists in Database.'), 'objectExists', [ 'CRM_Core_BAO_LabelFormat', $this->_id, - )); + ]); $this->addRule('NX', ts('Please enter a valid integer.'), 'integer'); $this->addRule('NY', ts('Please enter a valid integer.'), 'integer'); $this->addRule('tMargin', ts('Please enter a valid number.'), 'numeric'); @@ -186,14 +186,14 @@ public function postProcess() { if ($this->_action & CRM_Core_Action::COPY) { // make a copy of the Label Format $labelFormat = CRM_Core_BAO_LabelFormat::getById($this->_id, $this->_group); - $newlabel = ts('Copy of %1', array(1 => $labelFormat['label'])); + $newlabel = ts('Copy of %1', [1 => $labelFormat['label']]); $list = CRM_Core_BAO_LabelFormat::getList(TRUE, $this->_group); $count = 1; while (in_array($newlabel, $list)) { $count++; - $newlabel = ts('Copy %1 of %2', array(1 => $count, 2 => $labelFormat['label'])); + $newlabel = ts('Copy %1 of %2', [1 => $count, 2 => $labelFormat['label']]); } $labelFormat['label'] = $newlabel; @@ -203,7 +203,7 @@ public function postProcess() { $bao = new CRM_Core_BAO_LabelFormat(); $bao->saveLabelFormat($labelFormat, NULL, $this->_group); - CRM_Core_Session::setStatus(ts('%1 has been created.', array(1 => $labelFormat['label'])), ts('Saved'), 'success'); + CRM_Core_Session::setStatus(ts('%1 has been created.', [1 => $labelFormat['label']]), ts('Saved'), 'success'); return; } @@ -240,9 +240,9 @@ public function postProcess() { $bao = new CRM_Core_BAO_LabelFormat(); $bao->saveLabelFormat($values, $this->_id, $values['label_type']); - $status = ts('Your new Label Format titled %1 has been saved.', array(1 => $values['label'])); + $status = ts('Your new Label Format titled %1 has been saved.', [1 => $values['label']]); if ($this->_action & CRM_Core_Action::UPDATE) { - $status = ts('Your Label Format titled %1 has been updated.', array(1 => $values['label'])); + $status = ts('Your Label Format titled %1 has been updated.', [1 => $values['label']]); } CRM_Core_Session::setStatus($status, ts('Saved'), 'success'); } diff --git a/CRM/Admin/Form/LocationType.php b/CRM/Admin/Form/LocationType.php index ae691e85611e..65e43aff0b12 100644 --- a/CRM/Admin/Form/LocationType.php +++ b/CRM/Admin/Form/LocationType.php @@ -57,7 +57,7 @@ public function buildQuickForm() { $this->addRule('name', ts('Name already exists in Database.'), 'objectExists', - array('CRM_Core_DAO_LocationType', $this->_id) + ['CRM_Core_DAO_LocationType', $this->_id] ); $this->addRule('name', ts('Name can only consist of alpha-numeric characters'), @@ -74,10 +74,10 @@ public function buildQuickForm() { if ($this->_action & CRM_Core_Action::UPDATE) { if (CRM_Core_DAO::getFieldValue('CRM_Core_DAO_LocationType', $this->_id, 'is_reserved')) { - $this->freeze(array('name', 'description', 'is_active')); + $this->freeze(['name', 'description', 'is_active']); } if (CRM_Core_DAO::getFieldValue('CRM_Core_DAO_LocationType', $this->_id, 'is_default')) { - $this->freeze(array('is_default')); + $this->freeze(['is_default']); } } } @@ -120,7 +120,7 @@ public function postProcess() { $locationType->save(); CRM_Core_Session::setStatus(ts("The location type '%1' has been saved.", - array(1 => $locationType->name) + [1 => $locationType->name] ), ts('Saved'), 'success'); } diff --git a/CRM/Admin/Form/MailSettings.php b/CRM/Admin/Form/MailSettings.php index 3644d9d9073f..b87ccd961047 100644 --- a/CRM/Admin/Form/MailSettings.php +++ b/CRM/Admin/Form/MailSettings.php @@ -66,33 +66,33 @@ public function buildQuickForm() { $this->add('select', 'protocol', ts('Protocol'), - array('' => ts('- select -')) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_MailSettings', 'protocol'), + ['' => ts('- select -')] + CRM_Core_PseudoConstant::get('CRM_Core_DAO_MailSettings', 'protocol'), TRUE ); $this->add('text', 'server', ts('Server'), $attributes['server']); - $this->add('text', 'username', ts('Username'), array('autocomplete' => 'off')); + $this->add('text', 'username', ts('Username'), ['autocomplete' => 'off']); - $this->add('password', 'password', ts('Password'), array('autocomplete' => 'off')); + $this->add('password', 'password', ts('Password'), ['autocomplete' => 'off']); $this->add('text', 'source', ts('Source'), $attributes['source']); $this->add('checkbox', 'is_ssl', ts('Use SSL?')); - $usedfor = array( + $usedfor = [ 1 => ts('Bounce Processing'), 0 => ts('Email-to-Activity Processing'), - ); + ]; $this->add('select', 'is_default', ts('Used For?'), $usedfor); - $this->addField('activity_status', array('placeholder' => FALSE)); + $this->addField('activity_status', ['placeholder' => FALSE]); } /** * Add local and global form rules. */ public function addRules() { - $this->addFormRule(array('CRM_Admin_Form_MailSettings', 'formRule')); + $this->addFormRule(['CRM_Admin_Form_MailSettings', 'formRule']); } public function getDefaultEntity() { @@ -125,7 +125,7 @@ public function setDefaultValues() { * list of errors to be posted back to the form */ public static function formRule($fields) { - $errors = array(); + $errors = []; // Check for default from email address and organization (domain) name. Force them to change it. if ($fields['domain'] == 'EXAMPLE.ORG') { $errors['domain'] = ts('Please enter a valid domain for this mailbox account (the part after @).'); @@ -148,7 +148,7 @@ public function postProcess() { $formValues = $this->controller->exportValues($this->_name); //form fields. - $fields = array( + $fields = [ 'name', 'domain', 'localpart', @@ -162,14 +162,14 @@ public function postProcess() { 'is_ssl', 'is_default', 'activity_status', - ); + ]; - $params = array(); + $params = []; foreach ($fields as $f) { - if (in_array($f, array( + if (in_array($f, [ 'is_default', 'is_ssl', - ))) { + ])) { $params[$f] = CRM_Utils_Array::value($f, $formValues, FALSE); } else { diff --git a/CRM/Admin/Form/Mapping.php b/CRM/Admin/Form/Mapping.php index e600b53f78fa..8dc369ae95bf 100644 --- a/CRM/Admin/Form/Mapping.php +++ b/CRM/Admin/Form/Mapping.php @@ -60,10 +60,10 @@ public function buildQuickForm() { $this->add('text', 'name', ts('Name'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Mapping', 'name'), TRUE ); - $this->addRule('name', ts('Name already exists in Database.'), 'objectExists', array( + $this->addRule('name', ts('Name already exists in Database.'), 'objectExists', [ 'CRM_Core_DAO_Mapping', $this->_id, - )); + ]); $this->addElement('text', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Mapping', 'description') diff --git a/CRM/Admin/Form/Navigation.php b/CRM/Admin/Form/Navigation.php index 2b286e5f8b34..370d0cdff772 100644 --- a/CRM/Admin/Form/Navigation.php +++ b/CRM/Admin/Form/Navigation.php @@ -54,7 +54,7 @@ public function buildQuickForm() { } if (isset($this->_id)) { - $params = array('id' => $this->_id); + $params = ['id' => $this->_id]; CRM_Core_BAO_Navigation::retrieve($params, $this->_defaults); } @@ -68,21 +68,21 @@ public function buildQuickForm() { $this->add('text', 'url', ts('Url'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Navigation', 'url')); - $this->add('text', 'icon', ts('Icon'), array('class' => 'crm-icon-picker', 'title' => ts('Choose Icon'), 'allowClear' => TRUE)); + $this->add('text', 'icon', ts('Icon'), ['class' => 'crm-icon-picker', 'title' => ts('Choose Icon'), 'allowClear' => TRUE]); - $permissions = array(); + $permissions = []; foreach (CRM_Core_Permission::basicPermissions(TRUE, TRUE) as $id => $vals) { - $permissions[] = array('id' => $id, 'label' => $vals[0], 'description' => (array) CRM_Utils_Array::value(1, $vals)); + $permissions[] = ['id' => $id, 'label' => $vals[0], 'description' => (array) CRM_Utils_Array::value(1, $vals)]; } $this->add('text', 'permission', ts('Permission'), - array('placeholder' => ts('Unrestricted'), 'class' => 'huge', 'data-select-params' => json_encode(array('data' => array('results' => $permissions, 'text' => 'label')))) + ['placeholder' => ts('Unrestricted'), 'class' => 'huge', 'data-select-params' => json_encode(['data' => ['results' => $permissions, 'text' => 'label']])] ); - $operators = array('AND' => ts('AND'), 'OR' => ts('OR')); + $operators = ['AND' => ts('AND'), 'OR' => ts('OR')]; $this->add('select', 'permission_operator', NULL, $operators); //make separator location configurable - $separator = array(ts('None'), ts('After menu element'), ts('Before menu element')); + $separator = [ts('None'), ts('After menu element'), ts('Before menu element')]; $this->add('select', 'has_separator', ts('Separator'), $separator); $active = $this->add('advcheckbox', 'is_active', ts('Enabled')); @@ -101,7 +101,7 @@ public function buildQuickForm() { $homeMenuId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Navigation', 'Home', 'id', 'name'); unset($parentMenu[$homeMenuId]); - $this->add('select', 'parent_id', ts('Parent'), array('' => ts('Top level')) + $parentMenu, FALSE, array('class' => 'crm-select2')); + $this->add('select', 'parent_id', ts('Parent'), ['' => ts('Top level')] + $parentMenu, FALSE, ['class' => 'crm-select2']); } } @@ -147,7 +147,7 @@ public function postProcess() { CRM_Core_BAO_Navigation::resetNavigation(); CRM_Core_Session::setStatus(ts('Menu \'%1\' has been saved.', - array(1 => $navigation->label) + [1 => $navigation->label] ), ts('Saved'), 'success'); } diff --git a/CRM/Admin/Form/OptionGroup.php b/CRM/Admin/Form/OptionGroup.php index 1a11de967413..8076680a6f81 100644 --- a/CRM/Admin/Form/OptionGroup.php +++ b/CRM/Admin/Form/OptionGroup.php @@ -63,7 +63,7 @@ public function buildQuickForm() { $this->addRule('name', ts('Name already exists in Database.'), 'objectExists', - array('CRM_Core_DAO_OptionGroup', $this->_id) + ['CRM_Core_DAO_OptionGroup', $this->_id] ); $this->add('text', @@ -78,15 +78,15 @@ public function buildQuickForm() { CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionGroup', 'description') ); - $this->addSelect('data_type', array('options' => CRM_Utils_Type::dataTypes()), empty($this->_values['is_reserved'])); + $this->addSelect('data_type', ['options' => CRM_Utils_Type::dataTypes()], empty($this->_values['is_reserved'])); $element = $this->add('checkbox', 'is_active', ts('Enabled?')); if ($this->_action & CRM_Core_Action::UPDATE) { - if (in_array($this->_values['name'], array( + if (in_array($this->_values['name'], [ 'encounter_medium', 'case_type', 'case_status', - ))) { + ])) { static $caseCount = NULL; if (!isset($caseCount)) { $caseCount = CRM_Case_BAO_Case::caseCount(NULL, FALSE); @@ -101,7 +101,7 @@ public function buildQuickForm() { $this->freeze('is_reserved'); if (!empty($this->_values['is_reserved'])) { - $this->freeze(array('name', 'is_active', 'data_type')); + $this->freeze(['name', 'is_active', 'data_type']); } } @@ -133,7 +133,7 @@ public function postProcess() { } $optionGroup = CRM_Core_BAO_OptionGroup::add($params); - CRM_Core_Session::setStatus(ts('The Option Group \'%1\' has been saved.', array(1 => $optionGroup->name)), ts('Saved'), 'success'); + CRM_Core_Session::setStatus(ts('The Option Group \'%1\' has been saved.', [1 => $optionGroup->name]), ts('Saved'), 'success'); } } diff --git a/CRM/Admin/Form/Options.php b/CRM/Admin/Form/Options.php index 0dfda0f1136a..b380feacf5ad 100644 --- a/CRM/Admin/Form/Options.php +++ b/CRM/Admin/Form/Options.php @@ -85,20 +85,20 @@ public function preProcess() { $params = "reset=1"; if (($this->_action & CRM_Core_Action::DELETE) && - in_array($this->_gName, array('email_greeting', 'postal_greeting', 'addressee')) + in_array($this->_gName, ['email_greeting', 'postal_greeting', 'addressee']) ) { // Don't allow delete if the option value belongs to addressee, postal or email greetings and is in use. $findValue = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', $this->_id, 'value'); - $queryParam = array(1 => array($findValue, 'Integer')); + $queryParam = [1 => [$findValue, 'Integer']]; $columnName = $this->_gName . "_id"; $sql = "SELECT count(id) FROM civicrm_contact WHERE " . $columnName . " = %1"; $isInUse = CRM_Core_DAO::singleValueQuery($sql, $queryParam); if ($isInUse) { $scriptURL = "" . ts('Learn more about a script that can automatically update contact addressee and greeting options.') . ""; - CRM_Core_Session::setStatus(ts('The selected %1 option has not been deleted because it is currently in use. Please update these contacts to use a different format before deleting this option. %2', array( + CRM_Core_Session::setStatus(ts('The selected %1 option has not been deleted because it is currently in use. Please update these contacts to use a different format before deleting this option. %2', [ 1 => $this->_gLabel, 2 => $scriptURL, - )), ts('Sorry'), 'error'); + ]), ts('Sorry'), 'error'); $redirect = CRM_Utils_System::url($url, $params); CRM_Utils_System::redirect($redirect); } @@ -122,19 +122,19 @@ public function setDefaultValues() { $defaults = parent::setDefaultValues(); // Default weight & value - $fieldValues = array('option_group_id' => $this->_gid); - foreach (array('weight', 'value') as $field) { + $fieldValues = ['option_group_id' => $this->_gid]; + foreach (['weight', 'value'] as $field) { if (empty($defaults[$field])) { $defaults[$field] = CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_OptionValue', $fieldValues, $field); } } // setDefault of contact types for email greeting, postal greeting, addressee, CRM-4575 - if (in_array($this->_gName, array( + if (in_array($this->_gName, [ 'email_greeting', 'postal_greeting', 'addressee', - ))) { + ])) { $defaults['contactOptions'] = (CRM_Utils_Array::value('filter', $defaults)) ? $defaults['filter'] : NULL; } // CRM-11516 @@ -152,7 +152,7 @@ public function setDefaultValues() { */ public function buildQuickForm() { parent::buildQuickForm(); - $this->setPageTitle(ts('%1 Option', array(1 => $this->_gLabel))); + $this->setPageTitle(ts('%1 Option', [1 => $this->_gLabel])); if ($this->_action & CRM_Core_Action::DELETE) { return; @@ -182,35 +182,35 @@ public function buildQuickForm() { $this->addRule('value', ts('This Value already exists in the database for this option group. Please select a different Value.'), 'optionExists', - array('CRM_Core_DAO_OptionValue', $this->_id, $this->_gid, 'value', $this->_domainSpecific) + ['CRM_Core_DAO_OptionValue', $this->_id, $this->_gid, 'value', $this->_domainSpecific] ); } else { - $this->add('text', 'icon', ts('Icon'), array('class' => 'crm-icon-picker', 'title' => ts('Choose Icon'), 'allowClear' => TRUE)); + $this->add('text', 'icon', ts('Icon'), ['class' => 'crm-icon-picker', 'title' => ts('Choose Icon'), 'allowClear' => TRUE]); } - if (in_array($this->_gName, array('activity_status', 'case_status'))) { + if (in_array($this->_gName, ['activity_status', 'case_status'])) { $this->add('color', 'color', ts('Color')); } - if (!in_array($this->_gName, array( + if (!in_array($this->_gName, [ 'email_greeting', 'postal_greeting', 'addressee', - )) && !$isReserved + ]) && !$isReserved ) { $this->addRule('label', ts('This Label already exists in the database for this option group. Please select a different Label.'), 'optionExists', - array('CRM_Core_DAO_OptionValue', $this->_id, $this->_gid, 'label', $this->_domainSpecific) + ['CRM_Core_DAO_OptionValue', $this->_id, $this->_gid, 'label', $this->_domainSpecific] ); } if ($this->_gName == 'case_status') { - $classes = array( + $classes = [ 'Opened' => ts('Opened'), 'Closed' => ts('Closed'), - ); + ]; $grouping = $this->add('select', 'grouping', @@ -227,7 +227,7 @@ public function buildQuickForm() { $financialAccount = CRM_Contribute_PseudoConstant::financialAccount(NULL, key($accountType)); $this->add('select', 'financial_account_id', ts('Financial Account'), - array('' => ts('- select -')) + $financialAccount, + ['' => ts('- select -')] + $financialAccount, TRUE ); } @@ -236,11 +236,11 @@ public function buildQuickForm() { $this->add('select', 'filter', ts('Status Type'), - array( + [ CRM_Activity_BAO_Activity::INCOMPLETE => ts('Incomplete'), CRM_Activity_BAO_Activity::COMPLETED => ts('Completed'), CRM_Activity_BAO_Activity::CANCELLED => ts('Cancelled'), - ) + ] ); } if ($this->_gName == 'redaction_rule') { @@ -260,7 +260,7 @@ public function buildQuickForm() { // Hard-coding attributes here since description is still stored as varchar and not text in the schema. dgg $this->add('wysiwyg', 'description', ts('Description'), - array('rows' => 4, 'cols' => 80), + ['rows' => 4, 'cols' => 80], $this->_gName == 'custom_search' ); } @@ -288,7 +288,7 @@ public function buildQuickForm() { (($this->_action & CRM_Core_Action::ADD) || !$isReserved) ) { $caseID = CRM_Core_Component::getComponentID('CiviCase'); - $components = array('' => ts('Contacts AND Cases'), $caseID => ts('Cases Only')); + $components = ['' => ts('Contacts AND Cases'), $caseID => ts('Cases Only')]; $this->add('select', 'component_id', ts('Component'), @@ -303,7 +303,7 @@ public function buildQuickForm() { } // fix for CRM-3552, CRM-4575 - $showIsDefaultGroups = array( + $showIsDefaultGroups = [ 'email_greeting', 'postal_greeting', 'addressee', @@ -315,7 +315,7 @@ public function buildQuickForm() { 'communication_style', 'soft_credit_type', 'website_type', - ); + ]; if (in_array($this->_gName, $showIsDefaultGroups)) { $this->assign('showDefault', TRUE); @@ -323,19 +323,19 @@ public function buildQuickForm() { } // get contact type for which user want to create a new greeting/addressee type, CRM-4575 - if (in_array($this->_gName, array( + if (in_array($this->_gName, [ 'email_greeting', 'postal_greeting', 'addressee', - )) && !$isReserved + ]) && !$isReserved ) { - $values = array( + $values = [ 1 => ts('Individual'), 2 => ts('Household'), 3 => ts('Organization'), 4 => ts('Multiple Contact Merge'), - ); - $this->add('select', 'contactOptions', ts('Contact Type'), array('' => '-select-') + $values, TRUE); + ]; + $this->add('select', 'contactOptions', ts('Contact Type'), ['' => '-select-'] + $values, TRUE); $this->assign('showContactFilter', TRUE); } @@ -349,7 +349,7 @@ public function buildQuickForm() { $this->add('checkbox', 'filter', ts('Counted?')); } - $this->addFormRule(array('CRM_Admin_Form_Options', 'formRule'), $this); + $this->addFormRule(['CRM_Admin_Form_Options', 'formRule'], $this); } /** @@ -367,16 +367,16 @@ public function buildQuickForm() { * @throws \CRM_Core_Exception */ public static function formRule($fields, $files, $self) { - $errors = array(); + $errors = []; if ($self->_gName == 'case_status' && empty($fields['grouping'])) { $errors['grouping'] = ts('Status class is a required field'); } - if (in_array($self->_gName, array( + if (in_array($self->_gName, [ 'email_greeting', 'postal_greeting', 'addressee', - )) && empty($self->_defaultValues['is_reserved']) + ]) && empty($self->_defaultValues['is_reserved']) ) { $label = $fields['label']; $condition = " AND v.label = '{$label}' "; @@ -435,7 +435,7 @@ public static function getOptionGroupDataType($optionGroupName) { */ public function postProcess() { if ($this->_action & CRM_Core_Action::DELETE) { - $fieldValues = array('option_group_id' => $this->_gid); + $fieldValues = ['option_group_id' => $this->_gid]; CRM_Utils_Weight::delWeight('CRM_Core_DAO_OptionValue', $this->_id, $fieldValues); if (CRM_Core_BAO_OptionValue::del($this->_id)) { @@ -443,10 +443,10 @@ public function postProcess() { CRM_Core_BAO_Phone::setOptionToNull(CRM_Utils_Array::value('value', $this->_defaultValues)); } - CRM_Core_Session::setStatus(ts('Selected %1 type has been deleted.', array(1 => $this->_gLabel)), ts('Record Deleted'), 'success'); + CRM_Core_Session::setStatus(ts('Selected %1 type has been deleted.', [1 => $this->_gLabel]), ts('Record Deleted'), 'success'); } else { - CRM_Core_Session::setStatus(ts('Selected %1 type has not been deleted.', array(1 => $this->_gLabel)), ts('Sorry'), 'error'); + CRM_Core_Session::setStatus(ts('Selected %1 type has not been deleted.', [1 => $this->_gLabel]), ts('Sorry'), 'error'); CRM_Utils_Weight::correctDuplicateWeights('CRM_Core_DAO_OptionValue', $fieldValues); } } @@ -454,14 +454,14 @@ public function postProcess() { $params = $this->exportValues(); // allow multiple defaults within group. - $allowMultiDefaults = array('email_greeting', 'postal_greeting', 'addressee', 'from_email_address'); + $allowMultiDefaults = ['email_greeting', 'postal_greeting', 'addressee', 'from_email_address']; if (in_array($this->_gName, $allowMultiDefaults)) { if ($this->_gName == 'from_email_address') { - $params['reset_default_for'] = array('domain_id' => CRM_Core_Config::domainID()); + $params['reset_default_for'] = ['domain_id' => CRM_Core_Config::domainID()]; } elseif ($filter = CRM_Utils_Array::value('contactOptions', $params)) { $params['filter'] = $filter; - $params['reset_default_for'] = array('filter' => "0, " . $params['filter']); + $params['reset_default_for'] = ['filter' => "0, " . $params['filter']]; } //make sure we only have a single space, CRM-6977 and dev/mail/15 @@ -486,10 +486,10 @@ public function postProcess() { $optionValue = CRM_Core_OptionValue::addOptionValue($params, $this->_gName, $this->_action, $this->_id); - CRM_Core_Session::setStatus(ts('The %1 \'%2\' has been saved.', array( + CRM_Core_Session::setStatus(ts('The %1 \'%2\' has been saved.', [ 1 => $this->_gLabel, 2 => $optionValue->label, - )), ts('Saved'), 'success'); + ]), ts('Saved'), 'success'); $this->ajaxResponse['optionValue'] = $optionValue->toArray(); } diff --git a/CRM/Admin/Form/ParticipantStatusType.php b/CRM/Admin/Form/ParticipantStatusType.php index 5fc9c7e5bad8..fcaac917b1af 100644 --- a/CRM/Admin/Form/ParticipantStatusType.php +++ b/CRM/Admin/Form/ParticipantStatusType.php @@ -59,14 +59,14 @@ public function buildQuickForm() { $this->add('text', 'label', ts('Label'), $attributes['label'], TRUE); - $this->addSelect('class', array('required' => TRUE)); + $this->addSelect('class', ['required' => TRUE]); $this->add('checkbox', 'is_active', ts('Active?')); $this->add('checkbox', 'is_counted', ts('Counted?')); $this->add('number', 'weight', ts('Order'), $attributes['weight'], TRUE); - $this->addSelect('visibility_id', array('label' => ts('Visibility'), 'required' => TRUE)); + $this->addSelect('visibility_id', ['label' => ts('Visibility'), 'required' => TRUE]); $this->assign('id', $this->_id); } @@ -83,7 +83,7 @@ public function setDefaultValues() { } $this->_isReserved = CRM_Utils_Array::value('is_reserved', $defaults); if ($this->_isReserved) { - $this->freeze(array('name', 'class', 'is_active')); + $this->freeze(['name', 'class', 'is_active']); } return $defaults; } @@ -101,7 +101,7 @@ public function postProcess() { $formValues = $this->controller->exportValues($this->_name); - $params = array( + $params = [ 'name' => CRM_Utils_Array::value('name', $formValues), 'label' => CRM_Utils_Array::value('label', $formValues), 'class' => CRM_Utils_Array::value('class', $formValues), @@ -109,7 +109,7 @@ public function postProcess() { 'is_counted' => CRM_Utils_Array::value('is_counted', $formValues, FALSE), 'weight' => CRM_Utils_Array::value('weight', $formValues), 'visibility_id' => CRM_Utils_Array::value('visibility_id', $formValues), - ); + ]; // make sure a malicious POST does not change these on reserved statuses if ($this->_isReserved) { diff --git a/CRM/Admin/Form/PaymentProcessor.php b/CRM/Admin/Form/PaymentProcessor.php index ecac6332abaf..84fdf07e7ded 100644 --- a/CRM/Admin/Form/PaymentProcessor.php +++ b/CRM/Admin/Form/PaymentProcessor.php @@ -111,56 +111,56 @@ public function preProcess() { $this->assign('is_recur', $this->_paymentProcessorDAO->is_recur); - $this->_fields = array( - array( + $this->_fields = [ + [ 'name' => 'user_name', 'label' => $this->_paymentProcessorDAO->user_name_label, - ), - array( + ], + [ 'name' => 'password', 'label' => $this->_paymentProcessorDAO->password_label, - ), - array( + ], + [ 'name' => 'signature', 'label' => $this->_paymentProcessorDAO->signature_label, - ), - array( + ], + [ 'name' => 'subject', 'label' => $this->_paymentProcessorDAO->subject_label, - ), - array( + ], + [ 'name' => 'url_site', 'label' => ts('Site URL'), 'rule' => 'url', 'msg' => ts('Enter a valid URL'), - ), - ); + ], + ]; if ($this->_paymentProcessorDAO->is_recur) { - $this->_fields[] = array( + $this->_fields[] = [ 'name' => 'url_recur', 'label' => ts('Recurring Payments URL'), 'rule' => 'url', 'msg' => ts('Enter a valid URL'), - ); + ]; } if (!empty($this->_paymentProcessorDAO->url_button_default)) { - $this->_fields[] = array( + $this->_fields[] = [ 'name' => 'url_button', 'label' => ts('Button URL'), 'rule' => 'url', 'msg' => ts('Enter a valid URL'), - ); + ]; } if (!empty($this->_paymentProcessorDAO->url_api_default)) { - $this->_fields[] = array( + $this->_fields[] = [ 'name' => 'url_api', 'label' => ts('API URL'), 'rule' => 'url', 'msg' => ts('Enter a valid URL'), - ); + ]; } } @@ -182,12 +182,12 @@ public function buildQuickForm($check = FALSE) { $attributes['name'], TRUE ); - $this->addRule('name', ts('Name already exists in Database.'), 'objectExists', array( + $this->addRule('name', ts('Name already exists in Database.'), 'objectExists', [ 'CRM_Financial_DAO_PaymentProcessor', $this->_id, 'name', CRM_Core_Config::domainID(), - )); + ]); $this->add('text', 'description', ts('Description'), $attributes['description'] @@ -198,7 +198,7 @@ public function buildQuickForm($check = FALSE) { ts('Payment Processor Type'), CRM_Financial_BAO_PaymentProcessor::buildOptions('payment_processor_type_id'), TRUE, - array('onchange' => "reload(true)") + ['onchange' => "reload(true)"] ); // Financial Account of account type asset CRM-11515 @@ -208,15 +208,15 @@ public function buildQuickForm($check = FALSE) { $this->assign('financialAccount', $fcount); } $this->add('select', 'financial_account_id', ts('Financial Account'), - array('' => ts('- select -')) + $financialAccount, + ['' => ts('- select -')] + $financialAccount, TRUE ); $this->addSelect('payment_instrument_id', - array( + [ 'entity' => 'contribution', 'label' => ts('Payment Method'), 'placeholder' => NULL, - ) + ] ); // is this processor active ? @@ -230,12 +230,12 @@ public function buildQuickForm($check = FALSE) { continue; } - $this->addField($field['name'], array('label' => $field['label'])); + $this->addField($field['name'], ['label' => $field['label']]); - $fieldSpec = civicrm_api3($this->getDefaultEntity(), 'getfield', array( + $fieldSpec = civicrm_api3($this->getDefaultEntity(), 'getfield', [ 'name' => $field['name'], 'action' => 'create', - )); + ]); $this->add($fieldSpec['values']['html']['type'], "test_{$field['name']}", $field['label'], $attributes[$field['name']] ); @@ -245,7 +245,7 @@ public function buildQuickForm($check = FALSE) { } } - $this->addFormRule(array('CRM_Admin_Form_PaymentProcessor', 'formRule')); + $this->addFormRule(['CRM_Admin_Form_PaymentProcessor', 'formRule']); } /** @@ -258,7 +258,7 @@ public static function formRule($fields) { // make sure that at least one of live or test is present // and we have at least name and url_site // would be good to make this processor specific - $errors = array(); + $errors = []; if (!(self::checkSection($fields, $errors) || self::checkSection($fields, $errors, 'test') @@ -282,7 +282,7 @@ public static function formRule($fields) { * @return bool */ public static function checkSection(&$fields, &$errors, $section = NULL) { - $names = array('user_name'); + $names = ['user_name']; $present = FALSE; $allPresent = TRUE; @@ -310,7 +310,7 @@ public static function checkSection(&$fields, &$errors, $section = NULL) { * @return array */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; if (!$this->_id) { $defaults['is_active'] = $defaults['is_default'] = 1; @@ -354,7 +354,7 @@ public function setDefaultValues() { $this->_id, 'accepted_credit_cards' ), TRUE); - $acceptedCards = array(); + $acceptedCards = []; if (!empty($cards)) { foreach ($cards as $card => $val) { $acceptedCards[$card] = 1; @@ -409,7 +409,7 @@ public function postProcess() { $this->updatePaymentProcessor($values, $domainID, FALSE); $this->updatePaymentProcessor($values, $domainID, TRUE); - $processor = civicrm_api3('payment_processor', 'getsingle', array('name' => $values['name'], 'is_test' => 0)); + $processor = civicrm_api3('payment_processor', 'getsingle', ['name' => $values['name'], 'is_test' => 0]); $errors = Civi\Payment\System::singleton()->checkProcessorConfig($processor); if ($errors) { CRM_Core_Session::setStatus($errors, 'Payment processor configuration invalid', 'error'); @@ -417,7 +417,7 @@ public function postProcess() { CRM_Core_Session::singleton()->pushUserContext($this->refreshURL); } else { - CRM_Core_Session::setStatus(ts('Payment processor %1 has been saved.', array(1 => "{$values['name']}")), ts('Saved'), 'success'); + CRM_Core_Session::setStatus(ts('Payment processor %1 has been saved.', [1 => "{$values['name']}"]), ts('Saved'), 'success'); } } @@ -430,12 +430,12 @@ public function postProcess() { */ public function updatePaymentProcessor(&$values, $domainID, $test) { if ($test) { - foreach (array('user_name', 'password', 'signature', 'url_site', 'url_recur', 'url_api', 'url_button', 'subject') as $field) { + foreach (['user_name', 'password', 'signature', 'url_site', 'url_recur', 'url_api', 'url_button', 'subject'] as $field) { $values[$field] = empty($values["test_{$field}"]) ? CRM_Utils_Array::value($field, $values) : $values["test_{$field}"]; } } if (!empty($values['accept_credit_cards'])) { - $creditCards = array(); + $creditCards = []; $accptedCards = array_keys($values['accept_credit_cards']); $creditCardTypes = CRM_Contribute_PseudoConstant::creditCard(); foreach ($creditCardTypes as $type => $val) { @@ -448,7 +448,7 @@ public function updatePaymentProcessor(&$values, $domainID, $test) { else { $creditCards = "NULL"; } - $params = array_merge(array( + $params = array_merge([ 'id' => $test ? $this->_testID : $this->_id, 'domain_id' => $domainID, 'is_test' => $test, @@ -461,7 +461,7 @@ public function updatePaymentProcessor(&$values, $domainID, $test) { 'payment_instrument_id' => $this->_paymentProcessorDAO->payment_instrument_id, 'financial_account_id' => $values['financial_account_id'], 'accepted_credit_cards' => $creditCards, - ), $values); + ], $values); civicrm_api3('PaymentProcessor', 'create', $params); } diff --git a/CRM/Admin/Form/PaymentProcessorType.php b/CRM/Admin/Form/PaymentProcessorType.php index 8627c89be77c..29c2e5fde6cc 100644 --- a/CRM/Admin/Form/PaymentProcessorType.php +++ b/CRM/Admin/Form/PaymentProcessorType.php @@ -42,104 +42,104 @@ class CRM_Admin_Form_PaymentProcessorType extends CRM_Admin_Form { public function preProcess() { parent::preProcess(); - $this->_fields = array( - array( + $this->_fields = [ + [ 'name' => 'name', 'label' => ts('Name'), 'required' => TRUE, - ), - array( + ], + [ 'name' => 'title', 'label' => ts('Title'), 'required' => TRUE, - ), - array( + ], + [ 'name' => 'billing_mode', 'label' => ts('Billing Mode'), 'required' => TRUE, 'rule' => 'positiveInteger', 'msg' => ts('Enter a positive integer'), - ), - array( + ], + [ 'name' => 'description', 'label' => ts('Description'), - ), - array( + ], + [ 'name' => 'user_name_label', 'label' => ts('User Name Label'), - ), - array( + ], + [ 'name' => 'password_label', 'label' => ts('Password Label'), - ), - array( + ], + [ 'name' => 'signature_label', 'label' => ts('Signature Label'), - ), - array( + ], + [ 'name' => 'subject_label', 'label' => ts('Subject Label'), - ), - array( + ], + [ 'name' => 'class_name', 'label' => ts('PHP class name'), 'required' => TRUE, - ), - array( + ], + [ 'name' => 'url_site_default', 'label' => ts('Live Site URL'), 'required' => TRUE, 'rule' => 'url', 'msg' => ts('Enter a valid URL'), - ), - array( + ], + [ 'name' => 'url_api_default', 'label' => ts('Live API URL'), 'required' => FALSE, 'rule' => 'url', 'msg' => ts('Enter a valid URL'), - ), - array( + ], + [ 'name' => 'url_recur_default', 'label' => ts('Live Recurring Payments URL'), 'required' => TRUE, 'rule' => 'url', 'msg' => ts('Enter a valid URL'), - ), - array( + ], + [ 'name' => 'url_button_default', 'label' => ts('Live Button URL'), 'rule' => 'url', 'msg' => ts('Enter a valid URL'), - ), - array( + ], + [ 'name' => 'url_site_test_default', 'label' => ts('Test Site URL'), 'required' => TRUE, 'rule' => 'url', 'msg' => ts('Enter a valid URL'), - ), - array( + ], + [ 'name' => 'url_api_test_default', 'label' => ts('Test API URL'), 'required' => FALSE, 'rule' => 'url', 'msg' => ts('Enter a valid URL'), - ), - array( + ], + [ 'name' => 'url_recur_test_default', 'label' => ts('Test Recurring Payments URL'), 'required' => TRUE, 'rule' => 'url', 'msg' => ts('Enter a valid URL'), - ), - array( + ], + [ 'name' => 'url_button_test_default', 'label' => ts('Test Button URL'), 'rule' => 'url', 'msg' => ts('Enter a valid URL'), - ), - ); + ], + ]; } /** @@ -176,7 +176,7 @@ public function buildQuickForm($check = FALSE) { * @return array */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; if (!$this->_id) { $defaults['is_active'] = $defaults['is_default'] = 1; diff --git a/CRM/Admin/Form/PdfFormats.php b/CRM/Admin/Form/PdfFormats.php index f8710643300c..c075b044bb8e 100644 --- a/CRM/Admin/Form/PdfFormats.php +++ b/CRM/Admin/Form/PdfFormats.php @@ -56,33 +56,33 @@ public function buildQuickForm() { $attributes = CRM_Core_DAO::getAttribute('CRM_Core_BAO_PdfFormat'); $this->add('text', 'name', ts('Name'), $attributes['name'], TRUE); - $this->add('text', 'description', ts('Description'), array('size' => CRM_Utils_Type::HUGE)); + $this->add('text', 'description', ts('Description'), ['size' => CRM_Utils_Type::HUGE]); $this->add('checkbox', 'is_default', ts('Is this PDF Page Format the default?')); $this->add('select', 'paper_size', ts('Paper Size'), - array( + [ 0 => ts('- default -'), - ) + CRM_Core_BAO_PaperSize::getList(TRUE), FALSE, - array('onChange' => "selectPaper( this.value );") + ] + CRM_Core_BAO_PaperSize::getList(TRUE), FALSE, + ['onChange' => "selectPaper( this.value );"] ); $this->add('static', 'paper_dimensions', NULL, ts('Width x Height')); $this->add('select', 'orientation', ts('Orientation'), CRM_Core_BAO_PdfFormat::getPageOrientations(), FALSE, - array('onChange' => "updatePaperDimensions();") + ['onChange' => "updatePaperDimensions();"] ); $this->add('select', 'metric', ts('Unit of Measure'), CRM_Core_BAO_PdfFormat::getUnits(), FALSE, - array('onChange' => "selectMetric( this.value );") + ['onChange' => "selectMetric( this.value );"] ); - $this->add('text', 'margin_left', ts('Left Margin'), array('size' => 8, 'maxlength' => 8), TRUE); - $this->add('text', 'margin_right', ts('Right Margin'), array('size' => 8, 'maxlength' => 8), TRUE); - $this->add('text', 'margin_top', ts('Top Margin'), array('size' => 8, 'maxlength' => 8), TRUE); - $this->add('text', 'margin_bottom', ts('Bottom Margin'), array('size' => 8, 'maxlength' => 8), TRUE); + $this->add('text', 'margin_left', ts('Left Margin'), ['size' => 8, 'maxlength' => 8], TRUE); + $this->add('text', 'margin_right', ts('Right Margin'), ['size' => 8, 'maxlength' => 8], TRUE); + $this->add('text', 'margin_top', ts('Top Margin'), ['size' => 8, 'maxlength' => 8], TRUE); + $this->add('text', 'margin_bottom', ts('Bottom Margin'), ['size' => 8, 'maxlength' => 8], TRUE); $this->add('number', 'weight', ts('Order'), CRM_Core_DAO::getAttribute('CRM_Core_BAO_PdfFormat', 'weight'), TRUE); - $this->addRule('name', ts('Name already exists in Database.'), 'objectExists', array( + $this->addRule('name', ts('Name already exists in Database.'), 'objectExists', [ 'CRM_Core_BAO_PdfFormat', $this->_id, - )); + ]); $this->addRule('margin_left', ts('Margin must be numeric'), 'numeric'); $this->addRule('margin_right', ts('Margin must be numeric'), 'numeric'); $this->addRule('margin_top', ts('Margin must be numeric'), 'numeric'); @@ -119,9 +119,9 @@ public function postProcess() { $bao = new CRM_Core_BAO_PdfFormat(); $bao->savePdfFormat($values, $this->_id); - $status = ts('Your new PDF Page Format titled %1 has been saved.', array(1 => $values['name']), ts('Saved'), 'success'); + $status = ts('Your new PDF Page Format titled %1 has been saved.', [1 => $values['name']], ts('Saved'), 'success'); if ($this->_action & CRM_Core_Action::UPDATE) { - $status = ts('Your PDF Page Format titled %1 has been updated.', array(1 => $values['name']), ts('Saved'), 'success'); + $status = ts('Your PDF Page Format titled %1 has been updated.', [1 => $values['name']], ts('Saved'), 'success'); } CRM_Core_Session::setStatus($status); } diff --git a/CRM/Admin/Form/Persistent.php b/CRM/Admin/Form/Persistent.php index b7b9ca334df5..3c44d8473770 100644 --- a/CRM/Admin/Form/Persistent.php +++ b/CRM/Admin/Form/Persistent.php @@ -56,10 +56,10 @@ public function preProcess() { * @return array */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; if ($this->_indexID && ($this->_action & (CRM_Core_Action::UPDATE))) { - $params = array('id' => $this->_indexID); + $params = ['id' => $this->_indexID]; CRM_Core_BAO_Persistent::retrieve($params, $defaults); if (CRM_Utils_Array::value('is_config', $defaults) == 1) { $defaults['data'] = implode(',', $defaults['data']); @@ -71,23 +71,23 @@ public function setDefaultValues() { public function buildQuickForm() { $this->add('text', 'context', ts('Context:'), NULL, TRUE); $this->add('text', 'name', ts('Name:'), NULL, TRUE); - $this->add('textarea', 'data', ts('Data:'), array('rows' => 4, 'cols' => 50), TRUE); - $this->addButtons(array( - array( + $this->add('textarea', 'data', ts('Data:'), ['rows' => 4, 'cols' => 50], TRUE); + $this->addButtons([ + [ 'type' => 'submit', 'name' => ts('Save'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); } public function postProcess() { - $params = $ids = array(); + $params = $ids = []; $params = $this->controller->exportValues($this->_name); $params['is_config'] = $this->_config; diff --git a/CRM/Admin/Form/Preferences.php b/CRM/Admin/Form/Preferences.php index 4585b4e926b5..6a6e8e2e7ab3 100644 --- a/CRM/Admin/Form/Preferences.php +++ b/CRM/Admin/Form/Preferences.php @@ -104,7 +104,7 @@ public function preProcess() { * @return array */ public function setDefaultValues() { - $this->_defaults = array(); + $this->_defaults = []; $this->setDefaultsForMetadataDefinedFields(); foreach ($this->_varNames as $groupName => $settings) { @@ -135,7 +135,7 @@ public function cbsDefaultValues(&$defaults) { substr($this->_config->$settingName, 1, -1) ); if (!empty($value)) { - $defaults[$settingName] = array(); + $defaults[$settingName] = []; foreach ($value as $n => $v) { $defaults[$settingName][$v] = 1; } @@ -157,7 +157,7 @@ public function buildQuickForm() { foreach ($this->_varNames as $groupName => $groupValues) { $formName = CRM_Utils_String::titleToVar($groupName); $this->assign('formName', $formName); - $fields = array(); + $fields = []; foreach ($groupValues as $fieldName => $fieldValue) { $fields[$fieldName] = $fieldValue; @@ -166,10 +166,10 @@ public function buildQuickForm() { $this->addElement('text', $fieldName, $fieldValue['title'], - array( + [ 'maxlength' => 64, 'size' => 32, - ) + ] ); break; @@ -187,12 +187,12 @@ public function buildQuickForm() { break; case 'YesNo': - $this->addRadio($fieldName, $fieldValue['title'], array(0 => 'No', 1 => 'Yes'), NULL, '  '); + $this->addRadio($fieldName, $fieldValue['title'], [0 => 'No', 1 => 'Yes'], NULL, '  '); break; case 'checkboxes': $options = array_flip(CRM_Core_OptionGroup::values($fieldName, FALSE, FALSE, TRUE)); - $newOptions = array(); + $newOptions = []; foreach ($options as $key => $val) { $newOptions[$key] = $val; } @@ -200,7 +200,7 @@ public function buildQuickForm() { $fieldValue['title'], $newOptions, NULL, NULL, NULL, NULL, - array('  ', '  ', '
') + ['  ', '  ', '
'] ); break; @@ -218,7 +218,7 @@ public function buildQuickForm() { break; case 'entity_reference': - $this->addEntityRef($fieldName, $fieldValue['title'], CRM_Utils_Array::value('options', $fieldValue, array())); + $this->addEntityRef($fieldName, $fieldValue['title'], CRM_Utils_Array::value('options', $fieldValue, [])); } } @@ -227,17 +227,17 @@ public function buildQuickForm() { } } - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => ts('Save'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); if ($this->_action == CRM_Core_Action::VIEW) { @@ -303,7 +303,7 @@ public function postProcessCommon() { $value = CRM_Utils_Array::value($settingName, $this->_params); if ($value) { $value = trim($value); - $value = str_replace(array("\r\n", "\r"), "\n", $value); + $value = str_replace(["\r\n", "\r"], "\n", $value); } $this->_config->$settingName = $value; break; diff --git a/CRM/Admin/Form/Preferences/Address.php b/CRM/Admin/Form/Preferences/Address.php index 0eb2b22faf0d..059b5bc6ff5f 100644 --- a/CRM/Admin/Form/Preferences/Address.php +++ b/CRM/Admin/Form/Preferences/Address.php @@ -52,7 +52,7 @@ class CRM_Admin_Form_Preferences_Address extends CRM_Admin_Form_Preferences { public function buildQuickForm() { $this->applyFilter('__ALL__', 'trim'); - $this->addFormRule(array('CRM_Admin_Form_Preferences_Address', 'formRule')); + $this->addFormRule(['CRM_Admin_Form_Preferences_Address', 'formRule']); //get the tokens for Mailing Label field $tokens = CRM_Core_SelectValues::contactTokens(); @@ -99,7 +99,7 @@ public function postProcess() { if (CRM_Utils_Array::value($addressOptions['County'], $this->_params['address_options'])) { $countyCount = CRM_Core_DAO::singleValueQuery("SELECT count(*) FROM civicrm_county"); if ($countyCount < 10) { - CRM_Core_Session::setStatus(ts('You have enabled the County option. Please ensure you populate the county table in your CiviCRM Database. You can find extensions to populate counties in the CiviCRM Extensions Directory.', array(1 => 'href="' . CRM_Utils_System::url('civicrm/admin/extensions', array('reset' => 1), TRUE, 'extensions-addnew') . '"')), + CRM_Core_Session::setStatus(ts('You have enabled the County option. Please ensure you populate the county table in your CiviCRM Database. You can find extensions to populate counties in the CiviCRM Extensions Directory.', [1 => 'href="' . CRM_Utils_System::url('civicrm/admin/extensions', ['reset' => 1], TRUE, 'extensions-addnew') . '"']), ts('Populate counties'), "info" ); diff --git a/CRM/Admin/Form/Preferences/Contribute.php b/CRM/Admin/Form/Preferences/Contribute.php index f7ce870fd450..7421754c7229 100644 --- a/CRM/Admin/Form/Preferences/Contribute.php +++ b/CRM/Admin/Form/Preferences/Contribute.php @@ -35,7 +35,7 @@ * This class generates form components for the display preferences. */ class CRM_Admin_Form_Preferences_Contribute extends CRM_Admin_Form_Preferences { - protected $_settings = array( + protected $_settings = [ 'cvv_backoffice_required' => CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'update_contribution_on_membership_type_change' => CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'acl_financial_type' => CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, @@ -43,7 +43,7 @@ class CRM_Admin_Form_Preferences_Contribute extends CRM_Admin_Form_Preferences { 'deferred_revenue_enabled' => CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'default_invoice_page' => CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, 'invoicing' => CRM_Core_BAO_Setting::CONTRIBUTE_PREFERENCES_NAME, - ); + ]; /** * Our standards for settings are to have a setting per value with defined metadata. diff --git a/CRM/Admin/Form/Preferences/Display.php b/CRM/Admin/Form/Preferences/Display.php index ea13835328fb..7cf91d240baa 100644 --- a/CRM/Admin/Form/Preferences/Display.php +++ b/CRM/Admin/Form/Preferences/Display.php @@ -36,7 +36,7 @@ */ class CRM_Admin_Form_Preferences_Display extends CRM_Admin_Form_Preferences { - protected $_settings = array( + protected $_settings = [ 'contact_view_options' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_smart_group_display' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_edit_options' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, @@ -52,7 +52,7 @@ class CRM_Admin_Form_Preferences_Display extends CRM_Admin_Form_Preferences { 'display_name_format' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'sort_name_format' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'menubar_position' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, - ); + ]; /** * Build the form object. @@ -74,7 +74,7 @@ public function buildQuickForm() { $nameFields = CRM_Core_OptionGroup::values('contact_edit_options', FALSE, FALSE, FALSE, 'AND v.filter = 2'); $this->assign('nameFields', $nameFields); - $this->addElement('hidden', 'contact_edit_preferences', NULL, array('id' => 'contact_edit_preferences')); + $this->addElement('hidden', 'contact_edit_preferences', NULL, ['id' => 'contact_edit_preferences']); $optionValues = CRM_Core_OptionGroup::values('user_dashboard_options', FALSE, FALSE, FALSE, NULL, 'name'); $invoicesKey = array_search('Invoices / Credit Notes', $optionValues); diff --git a/CRM/Admin/Form/PreferencesDate.php b/CRM/Admin/Form/PreferencesDate.php index 746f05dd1020..95940ff6f8f7 100644 --- a/CRM/Admin/Form/PreferencesDate.php +++ b/CRM/Admin/Form/PreferencesDate.php @@ -69,17 +69,17 @@ public function buildQuickForm() { } else { $this->add('select', 'date_format', ts('Format'), - array('' => ts('- default input format -')) + CRM_Core_SelectValues::getDatePluginInputFormats() + ['' => ts('- default input format -')] + CRM_Core_SelectValues::getDatePluginInputFormats() ); $this->add('select', 'time_format', ts('Time'), - array('' => ts('- none -')) + CRM_Core_SelectValues::getTimeFormats() + ['' => ts('- none -')] + CRM_Core_SelectValues::getTimeFormats() ); } $this->addRule('start', ts('Value must be an integer.'), 'integer'); $this->addRule('end', ts('Value must be an integer.'), 'integer'); // add a form rule - $this->addFormRule(array('CRM_Admin_Form_PreferencesDate', 'formRule')); + $this->addFormRule(['CRM_Admin_Form_PreferencesDate', 'formRule']); } /** @@ -93,7 +93,7 @@ public function buildQuickForm() { * true otherwise */ public static function formRule($fields) { - $errors = array(); + $errors = []; if ($fields['name'] == 'activityDateTime' && !$fields['time_format']) { $errors['time_format'] = ts('Time is required for this format.'); @@ -129,7 +129,7 @@ public function postProcess() { CRM_Core_Resources::singleton()->resetCacheCode(); CRM_Core_Session::setStatus(ts("The date type '%1' has been saved.", - array(1 => $params['name']) + [1 => $params['name']] ), ts('Saved'), 'success'); } diff --git a/CRM/Admin/Form/RelationshipType.php b/CRM/Admin/Form/RelationshipType.php index 968aa79dc421..8383ed28de56 100644 --- a/CRM/Admin/Form/RelationshipType.php +++ b/CRM/Admin/Form/RelationshipType.php @@ -119,18 +119,18 @@ public function buildQuickForm() { } $this->addRule('label_a_b', ts('Label already exists in Database.'), - 'objectExists', array('CRM_Contact_DAO_RelationshipType', $this->_id, 'label_a_b') + 'objectExists', ['CRM_Contact_DAO_RelationshipType', $this->_id, 'label_a_b'] ); $this->addRule('label_b_a', ts('Label already exists in Database.'), - 'objectExists', array('CRM_Contact_DAO_RelationshipType', $this->_id, 'label_b_a') + 'objectExists', ['CRM_Contact_DAO_RelationshipType', $this->_id, 'label_b_a'] ); $contactTypes = CRM_Contact_BAO_ContactType::getSelectElements(FALSE, TRUE, '__'); foreach (['contact_types_a' => ts('Contact Type A'), 'contact_types_b' => ts('Contact Type B')] as $name => $label) { $element = $this->add('select', $name, $label . ' ', - array( + [ '' => ts('All Contacts'), - ) + $contactTypes + ] + $contactTypes ); if ($isReserved) { $element->freeze(); @@ -150,8 +150,8 @@ public function setDefaultValues() { if ($this->_action != CRM_Core_Action::DELETE && isset($this->_id) ) { - $defaults = $params = array(); - $params = array('id' => $this->_id); + $defaults = $params = []; + $params = ['id' => $this->_id]; $baoName = $this->_BAOName; $baoName::retrieve($params, $defaults); $defaults['contact_types_a'] = CRM_Utils_Array::value('contact_type_a', $defaults); diff --git a/CRM/Admin/Form/ScheduleReminders.php b/CRM/Admin/Form/ScheduleReminders.php index 77ee1ad45036..c7c89716fdcc 100644 --- a/CRM/Admin/Form/ScheduleReminders.php +++ b/CRM/Admin/Form/ScheduleReminders.php @@ -89,9 +89,9 @@ public function buildQuickForm() { } if ($isEvent) { $isTemplate = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->getComponentID(), 'is_template'); - $mapping = CRM_Utils_Array::first(CRM_Core_BAO_ActionSchedule::getMappings(array( + $mapping = CRM_Utils_Array::first(CRM_Core_BAO_ActionSchedule::getMappings([ 'id' => $isTemplate ? CRM_Event_ActionMapping::EVENT_TPL_MAPPING_ID : CRM_Event_ActionMapping::EVENT_NAME_MAPPING_ID, - ))); + ])); if ($mapping) { $this->_mappingID = $mapping->getId(); } @@ -133,16 +133,16 @@ public function buildQuickForm() { 'hierselect', 'entity', ts('Entity'), - array( + [ 'name' => 'entity[0]', 'style' => 'vertical-align: top;', - ) + ] ); - $sel->setOptions(array( + $sel->setOptions([ CRM_Utils_Array::collectMethod('getLabel', $mappings), CRM_Core_BAO_ActionSchedule::getAllEntityValueLabels(), CRM_Core_BAO_ActionSchedule::getAllEntityStatusLabels(), - )); + ]); if (is_a($sel->_elements[1], 'HTML_QuickForm_select')) { // make second selector a multi-select - @@ -160,7 +160,7 @@ public function buildQuickForm() { // Dig deeper - this code is sublimely stupid. $allEntityStatusLabels = CRM_Core_BAO_ActionSchedule::getAllEntityStatusLabels(); $options = $allEntityStatusLabels[$this->_mappingID][0]; - $attributes = array('multiple' => 'multiple', 'class' => 'crm-select2 huge', 'placeholder' => $options[0]); + $attributes = ['multiple' => 'multiple', 'class' => 'crm-select2 huge', 'placeholder' => $options[0]]; unset($options[0]); $this->add('select', 'entity', ts('Recipient(s)'), $options, TRUE, $attributes); $this->assign('context', $this->getContext()); @@ -170,7 +170,7 @@ public function buildQuickForm() { $this->_freqUnits = CRM_Core_SelectValues::getRecurringFrequencyUnits(); //reminder_interval - $this->add('number', 'start_action_offset', ts('When'), array('class' => 'six', 'min' => 0)); + $this->add('number', 'start_action_offset', ts('When'), ['class' => 'six', 'min' => 0]); $this->addRule('start_action_offset', ts('Value should be a positive number'), 'positiveInteger'); $isActive = ts('Scheduled Reminder Active'); @@ -183,7 +183,7 @@ public function buildQuickForm() { $providers = CRM_SMS_BAO_Provider::getProviders(NULL, NULL, TRUE, 'is_default desc'); - $providerSelect = array(); + $providerSelect = []; foreach ($providers as $provider) { $providerSelect[$provider['id']] = $provider['title']; } @@ -191,18 +191,18 @@ public function buildQuickForm() { } foreach ($this->_freqUnits as $val => $label) { - $freqUnitsDisplay[$val] = ts('%1(s)', array(1 => $label)); + $freqUnitsDisplay[$val] = ts('%1(s)', [1 => $label]); } - $this->add('datepicker', 'absolute_date', ts('Start Date'), [], FALSE, array('time' => FALSE)); + $this->add('datepicker', 'absolute_date', ts('Start Date'), [], FALSE, ['time' => FALSE]); //reminder_frequency $this->add('select', 'start_action_unit', ts('Frequency'), $freqUnitsDisplay, TRUE); - $condition = array( + $condition = [ 'before' => ts('before'), 'after' => ts('after'), - ); + ]; //reminder_action $this->add('select', 'start_action_condition', ts('Action Condition'), $condition); @@ -211,15 +211,15 @@ public function buildQuickForm() { $this->addElement('checkbox', 'record_activity', $recordActivity); $this->addElement('checkbox', 'is_repeat', ts('Repeat'), - NULL, array('onchange' => "return showHideByValue('is_repeat',true,'repeatFields','table-row','radio',false);") + NULL, ['onchange' => "return showHideByValue('is_repeat',true,'repeatFields','table-row','radio',false);"] ); $this->add('select', 'repetition_frequency_unit', ts('every'), $freqUnitsDisplay); - $this->add('number', 'repetition_frequency_interval', ts('every'), array('class' => 'six', 'min' => 0)); + $this->add('number', 'repetition_frequency_interval', ts('every'), ['class' => 'six', 'min' => 0]); $this->addRule('repetition_frequency_interval', ts('Value should be a positive number'), 'positiveInteger'); $this->add('select', 'end_frequency_unit', ts('until'), $freqUnitsDisplay); - $this->add('number', 'end_frequency_interval', ts('until'), array('class' => 'six', 'min' => 0)); + $this->add('number', 'end_frequency_interval', ts('until'), ['class' => 'six', 'min' => 0]); $this->addRule('end_frequency_interval', ts('Value should be a positive number'), 'positiveInteger'); $this->add('select', 'end_action', ts('Repetition Condition'), $condition, TRUE); @@ -228,23 +228,23 @@ public function buildQuickForm() { $this->add('text', 'from_name', ts('From Name')); $this->add('text', 'from_email', ts('From Email')); - $recipientListingOptions = array(); + $recipientListingOptions = []; if ($mappingID) { - $mapping = CRM_Utils_Array::first(CRM_Core_BAO_ActionSchedule::getMappings(array( + $mapping = CRM_Utils_Array::first(CRM_Core_BAO_ActionSchedule::getMappings([ 'id' => $mappingID, - ))); + ])); } - $limitOptions = array('' => '-neither-', 1 => ts('Limit to'), 0 => ts('Also include')); + $limitOptions = ['' => '-neither-', 1 => ts('Limit to'), 0 => ts('Also include')]; - $recipientLabels = array('activity' => ts('Recipients'), 'other' => ts('Limit or Add Recipients')); + $recipientLabels = ['activity' => ts('Recipients'), 'other' => ts('Limit or Add Recipients')]; $this->assign('recipientLabels', $recipientLabels); - $this->add('select', 'limit_to', ts('Limit Options'), $limitOptions, FALSE, array('onChange' => "showHideByValue('limit_to','','recipient', 'select','select',true);")); + $this->add('select', 'limit_to', ts('Limit Options'), $limitOptions, FALSE, ['onChange' => "showHideByValue('limit_to','','recipient', 'select','select',true);"]); $this->add('select', 'recipient', $recipientLabels['other'], $entityRecipientLabels, - FALSE, array('onchange' => "showHideByValue('recipient','manual','recipientManual','table-row','select',false); showHideByValue('recipient','group','recipientGroup','table-row','select',false);") + FALSE, ['onchange' => "showHideByValue('recipient','manual','recipientManual','table-row','select',false); showHideByValue('recipient','group','recipientGroup','table-row','select',false);"] ); if (!empty($this->_submitValues['recipient_listing'])) { @@ -260,12 +260,12 @@ public function buildQuickForm() { } $this->add('select', 'recipient_listing', ts('Recipient Roles'), $recipientListingOptions, FALSE, - array('multiple' => TRUE, 'class' => 'crm-select2 huge', 'placeholder' => TRUE)); + ['multiple' => TRUE, 'class' => 'crm-select2 huge', 'placeholder' => TRUE]); - $this->addEntityRef('recipient_manual_id', ts('Manual Recipients'), array('multiple' => TRUE, 'create' => TRUE)); + $this->addEntityRef('recipient_manual_id', ts('Manual Recipients'), ['multiple' => TRUE, 'create' => TRUE]); $this->add('select', 'group_id', ts('Group'), - CRM_Core_PseudoConstant::nestedGroup('Mailing'), FALSE, array('class' => 'crm-select2 huge') + CRM_Core_PseudoConstant::nestedGroup('Mailing'), FALSE, ['class' => 'crm-select2 huge'] ); // multilingual only options @@ -275,14 +275,14 @@ public function buildQuickForm() { $smarty->assign('multilingual', $multilingual); $languages = CRM_Core_I18n::languages(TRUE); - $languageFilter = $languages + array(CRM_Core_I18n::NONE => ts('Contacts with no preferred language')); + $languageFilter = $languages + [CRM_Core_I18n::NONE => ts('Contacts with no preferred language')]; $element = $this->add('select', 'filter_contact_language', ts('Recipients language'), $languageFilter, FALSE, - array('multiple' => TRUE, 'class' => 'crm-select2', 'placeholder' => TRUE)); + ['multiple' => TRUE, 'class' => 'crm-select2', 'placeholder' => TRUE]); - $communicationLanguage = array( + $communicationLanguage = [ '' => ts('System default language'), CRM_Core_I18n::AUTO => ts('Follow recipient preferred language'), - ); + ]; $communicationLanguage = $communicationLanguage + $languages; $this->add('select', 'communication_language', ts('Communication language'), $communicationLanguage); } @@ -295,7 +295,7 @@ public function buildQuickForm() { $this->add('checkbox', 'is_active', $isActive); - $this->addFormRule(array('CRM_Admin_Form_ScheduleReminders', 'formRule'), $this); + $this->addFormRule(['CRM_Admin_Form_ScheduleReminders', 'formRule'], $this); $this->setPageTitle(ts('Scheduled Reminder')); } @@ -312,7 +312,7 @@ public function buildQuickForm() { * True if no errors, else array of errors */ public static function formRule($fields, $files, $self) { - $errors = array(); + $errors = []; if ((array_key_exists(1, $fields['entity']) && $fields['entity'][1][0] === 0) || (array_key_exists(2, $fields['entity']) && $fields['entity'][2][0] == 0) ) { @@ -354,18 +354,18 @@ public static function formRule($fields, $files, $self) { if (!CRM_Utils_Rule::email($fields['from_email']) && (!$mode || $mode != 'SMS')) { $errors['from_email'] = ts('Please enter a valid email address.'); } - $recipientKind = array( - 'participant_role' => array( + $recipientKind = [ + 'participant_role' => [ 'name' => 'participant role', 'target_id' => 'recipient_listing', - ), - 'manual' => array( + ], + 'manual' => [ 'name' => 'recipient', 'target_id' => 'recipient_manual_id', - ), - ); + ], + ]; if ($fields['limit_to'] != '' && array_key_exists($fields['recipient'], $recipientKind) && empty($fields[$recipientKind[$fields['recipient']]['target_id']])) { - $errors[$recipientKind[$fields['recipient']]['target_id']] = ts('If "Also include" or "Limit to" are selected, you must specify at least one %1', array(1 => $recipientKind[$fields['recipient']]['name'])); + $errors[$recipientKind[$fields['recipient']]['target_id']] = ts('If "Also include" or "Limit to" are selected, you must specify at least one %1', [1 => $recipientKind[$fields['recipient']]['name']]); } //CRM-21523 @@ -465,13 +465,13 @@ public function postProcess() { $bao->free(); $status = ts("Your new Reminder titled %1 has been saved.", - array(1 => "{$values['title']}") + [1 => "{$values['title']}"] ); if ($this->_action) { if ($this->_action & CRM_Core_Action::UPDATE) { $status = ts("Your Reminder titled %1 has been updated.", - array(1 => "{$values['title']}") + [1 => "{$values['title']}"] ); } @@ -490,9 +490,9 @@ public function postProcess() { * @return CRM_Core_DAO_ActionSchedule */ public function parseActionSchedule($values) { - $params = array(); + $params = []; - $keys = array( + $keys = [ 'title', 'subject', 'absolute_date', @@ -503,14 +503,14 @@ public function parseActionSchedule($values) { 'sms_provider_id', 'from_name', 'from_email', - ); + ]; foreach ($keys as $key) { $params[$key] = CRM_Utils_Array::value($key, $values); } $params['is_repeat'] = CRM_Utils_Array::value('is_repeat', $values, 0); - $moreKeys = array( + $moreKeys = [ 'start_action_offset', 'start_action_unit', 'start_action_condition', @@ -521,7 +521,7 @@ public function parseActionSchedule($values) { 'end_frequency_interval', 'end_action', 'end_date', - ); + ]; if (!CRM_Utils_Array::value('absolute_date', $params)) { $params['absolute_date'] = 'null'; @@ -569,8 +569,8 @@ public function parseActionSchedule($values) { $params['limit_to'] = 1; } - $entity_value = CRM_Utils_Array::value(1, $values['entity'], array()); - $entity_status = CRM_Utils_Array::value(2, $values['entity'], array()); + $entity_value = CRM_Utils_Array::value(1, $values['entity'], []); + $entity_status = CRM_Utils_Array::value(2, $values['entity'], []); $params['entity_value'] = implode(CRM_Core_DAO::VALUE_SEPARATOR, $entity_value); $params['entity_status'] = implode(CRM_Core_DAO::VALUE_SEPARATOR, $entity_status); } @@ -587,7 +587,7 @@ public function parseActionSchedule($values) { } // multilingual options - $params['filter_contact_language'] = CRM_Utils_Array::value('filter_contact_language', $values, array()); + $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); @@ -599,7 +599,7 @@ public function parseActionSchedule($values) { $params['name'] = CRM_Utils_String::munge($params['title'], '_', 64); } - $modePrefixes = array('Mail' => NULL, 'SMS' => 'SMS'); + $modePrefixes = ['Mail' => NULL, 'SMS' => 'SMS']; if ($params['mode'] == 'Email' || empty($params['sms_provider_id'])) { unset($modePrefixes['SMS']); @@ -610,17 +610,17 @@ public function parseActionSchedule($values) { //TODO: handle postprocessing of SMS and/or Email info based on $modePrefixes - $composeFields = array( + $composeFields = [ 'template', 'saveTemplate', 'updateTemplate', 'saveTemplateName', - ); + ]; $msgTemplate = NULL; //mail template is composed foreach ($modePrefixes as $prefix) { - $composeParams = array(); + $composeParams = []; foreach ($composeFields as $key) { $key = $prefix . $key; if (!empty($values[$key])) { @@ -629,19 +629,19 @@ public function parseActionSchedule($values) { } if (!empty($composeParams[$prefix . 'updateTemplate'])) { - $templateParams = array('is_active' => TRUE); + $templateParams = ['is_active' => TRUE]; if ($prefix == 'SMS') { - $templateParams += array( + $templateParams += [ 'msg_text' => $params['sms_body_text'], 'is_sms' => TRUE, - ); + ]; } else { - $templateParams += array( + $templateParams += [ 'msg_text' => $params['body_text'], 'msg_html' => $params['body_html'], 'msg_subject' => $params['subject'], - ); + ]; } $templateParams['id'] = $values[$prefix . 'template']; @@ -649,19 +649,19 @@ public function parseActionSchedule($values) { } if (!empty($composeParams[$prefix . 'saveTemplate'])) { - $templateParams = array('is_active' => TRUE); + $templateParams = ['is_active' => TRUE]; if ($prefix == 'SMS') { - $templateParams += array( + $templateParams += [ 'msg_text' => $params['sms_body_text'], 'is_sms' => TRUE, - ); + ]; } else { - $templateParams += array( + $templateParams += [ 'msg_text' => $params['body_text'], 'msg_html' => $params['body_html'], 'msg_subject' => $params['subject'], - ); + ]; } $templateParams['msg_title'] = $composeParams[$prefix . 'saveTemplateName']; diff --git a/CRM/Admin/Form/Setting.php b/CRM/Admin/Form/Setting.php index e03c04db507c..6f60a4c9333f 100644 --- a/CRM/Admin/Form/Setting.php +++ b/CRM/Admin/Form/Setting.php @@ -38,7 +38,7 @@ class CRM_Admin_Form_Setting extends CRM_Core_Form { use CRM_Admin_Form_SettingTrait; - protected $_settings = array(); + protected $_settings = []; protected $includesReadOnlyFields; @@ -49,8 +49,8 @@ class CRM_Admin_Form_Setting extends CRM_Core_Form { */ public function setDefaultValues() { if (!$this->_defaults) { - $this->_defaults = array(); - $formArray = array('Component', 'Localization'); + $this->_defaults = []; + $formArray = ['Component', 'Localization']; $formMode = FALSE; if (in_array($this->_name, $formArray)) { $formMode = TRUE; @@ -73,23 +73,23 @@ public function setDefaultValues() { */ public function buildQuickForm() { CRM_Core_Session::singleton()->pushUserContext(CRM_Utils_System::url('civicrm/admin', 'reset=1')); - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => ts('Save'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); $this->addFieldsDefinedInSettingsMetadata(); if ($this->includesReadOnlyFields) { - CRM_Core_Session::setStatus(ts("Some fields are loaded as 'readonly' as they have been set (overridden) in civicrm.settings.php."), '', 'info', array('expires' => 0)); + CRM_Core_Session::setStatus(ts("Some fields are loaded as 'readonly' as they have been set (overridden) in civicrm.settings.php."), '', 'info', ['expires' => 0]); } } @@ -115,13 +115,13 @@ public function commonProcess(&$params) { // save components to be enabled if (array_key_exists('enableComponents', $params)) { - civicrm_api3('setting', 'create', array( + civicrm_api3('setting', 'create', [ 'enable_components' => $params['enableComponents'], - )); + ]); unset($params['enableComponents']); } - foreach (array('verifySSL', 'enableSSL') as $name) { + foreach (['verifySSL', 'enableSSL'] as $name) { if (isset($params[$name])) { Civi::settings()->set($name, $params[$name]); unset($params[$name]); diff --git a/CRM/Admin/Form/Setting/Case.php b/CRM/Admin/Form/Setting/Case.php index f04d79625dcc..242c93adcdcd 100644 --- a/CRM/Admin/Form/Setting/Case.php +++ b/CRM/Admin/Form/Setting/Case.php @@ -36,12 +36,12 @@ */ class CRM_Admin_Form_Setting_Case extends CRM_Admin_Form_Setting { - protected $_settings = array( + protected $_settings = [ 'civicaseRedactActivityEmail' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'civicaseAllowMultipleClients' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'civicaseNaturalActivityTypeSort' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'civicaseActivityRevisions' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, - ); + ]; /** * Build the form object. diff --git a/CRM/Admin/Form/Setting/Component.php b/CRM/Admin/Form/Setting/Component.php index a49790848788..f64cf081e761 100644 --- a/CRM/Admin/Form/Setting/Component.php +++ b/CRM/Admin/Form/Setting/Component.php @@ -45,17 +45,17 @@ public function buildQuickForm() { $components = $this->_getComponentSelectValues(); $include = &$this->addElement('advmultiselect', 'enableComponents', ts('Components') . ' ', $components, - array( + [ 'size' => 5, 'style' => 'width:150px', 'class' => 'advmultiselect', - ) + ] ); - $include->setButtonAttributes('add', array('value' => ts('Enable >>'))); - $include->setButtonAttributes('remove', array('value' => ts('<< Disable'))); + $include->setButtonAttributes('add', ['value' => ts('Enable >>')]); + $include->setButtonAttributes('remove', ['value' => ts('<< Disable')]); - $this->addFormRule(array('CRM_Admin_Form_Setting_Component', 'formRule'), $this); + $this->addFormRule(['CRM_Admin_Form_Setting_Component', 'formRule'], $this); parent::buildQuickForm(); } @@ -74,7 +74,7 @@ public function buildQuickForm() { * true if no errors, else array of errors */ public static function formRule($fields, $files, $options) { - $errors = array(); + $errors = []; if (array_key_exists('enableComponents', $fields) && is_array($fields['enableComponents'])) { if (in_array('CiviPledge', $fields['enableComponents']) && @@ -96,7 +96,7 @@ public static function formRule($fields, $files, $options) { * @return array */ private function _getComponentSelectValues() { - $ret = array(); + $ret = []; $this->_components = CRM_Core_Component::getComponents(); foreach ($this->_components as $name => $object) { $ret[$name] = $object->info['translatedName']; diff --git a/CRM/Admin/Form/Setting/Date.php b/CRM/Admin/Form/Setting/Date.php index 9e5f74005626..cd8d5976e60b 100644 --- a/CRM/Admin/Form/Setting/Date.php +++ b/CRM/Admin/Form/Setting/Date.php @@ -36,7 +36,7 @@ */ class CRM_Admin_Form_Setting_Date extends CRM_Admin_Form_Setting { - public $_settings = array( + public $_settings = [ 'dateformatDatetime' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME, 'dateformatFull' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME, 'dateformatPartial' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME, @@ -48,7 +48,7 @@ class CRM_Admin_Form_Setting_Date extends CRM_Admin_Form_Setting { 'dateInputFormat' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME, 'timeInputFormat' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME, 'fiscalYearStart' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME, - ); + ]; /** * Build the form object. diff --git a/CRM/Admin/Form/Setting/Debugging.php b/CRM/Admin/Form/Setting/Debugging.php index 3129ba63db65..133ed57a9dc6 100644 --- a/CRM/Admin/Form/Setting/Debugging.php +++ b/CRM/Admin/Form/Setting/Debugging.php @@ -36,13 +36,13 @@ */ class CRM_Admin_Form_Setting_Debugging extends CRM_Admin_Form_Setting { - protected $_settings = array( + protected $_settings = [ 'debug_enabled' => CRM_Core_BAO_Setting::DEVELOPER_PREFERENCES_NAME, 'backtrace' => CRM_Core_BAO_Setting::DEVELOPER_PREFERENCES_NAME, 'fatalErrorHandler' => CRM_Core_BAO_Setting::DEVELOPER_PREFERENCES_NAME, 'assetCache' => CRM_Core_BAO_Setting::DEVELOPER_PREFERENCES_NAME, 'environment' => CRM_Core_BAO_Setting::DEVELOPER_PREFERENCES_NAME, - ); + ]; /** * Build the form object. diff --git a/CRM/Admin/Form/Setting/Localization.php b/CRM/Admin/Form/Setting/Localization.php index 7ac52ec02f99..44829d550439 100644 --- a/CRM/Admin/Form/Setting/Localization.php +++ b/CRM/Admin/Form/Setting/Localization.php @@ -36,7 +36,7 @@ */ class CRM_Admin_Form_Setting_Localization extends CRM_Admin_Form_Setting { - protected $_settings = array( + protected $_settings = [ 'contact_default_language' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME, 'countryLimit' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME, 'customTranslateFunction' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME, @@ -53,7 +53,7 @@ class CRM_Admin_Form_Setting_Localization extends CRM_Admin_Form_Setting { 'moneyvalueformat' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME, 'provinceLimit' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME, 'uiLanguages' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME, - ); + ]; public function preProcess() { if (!CRM_Core_I18n::isMultiLingual()) { @@ -76,14 +76,14 @@ public function buildQuickForm() { if (CRM_Core_I18n::isMultiLingual()) { // add language limiter and language adder $this->addCheckBox('languageLimit', ts('Available Languages'), array_flip($defaultLocaleOptions), NULL, NULL, NULL, NULL, '   '); - $this->addElement('select', 'addLanguage', ts('Add Language'), array_merge(array('' => ts('- select -')), array_diff(CRM_Core_I18n::languages(), $defaultLocaleOptions))); + $this->addElement('select', 'addLanguage', ts('Add Language'), array_merge(['' => ts('- select -')], array_diff(CRM_Core_I18n::languages(), $defaultLocaleOptions))); // add the ability to return to single language $warning = ts('This will make your CiviCRM installation a single-language one again. THIS WILL DELETE ALL DATA RELATED TO LANGUAGES OTHER THAN THE DEFAULT ONE SELECTED ABOVE (and only that language will be preserved).'); $this->assign('warning', $warning); $warning = json_encode($warning); $this->addElement('checkbox', 'makeSinglelingual', ts('Return to Single Language'), - NULL, array('onChange' => "if (this.checked) CRM.alert($warning, $warningTitle)") + NULL, ['onChange' => "if (this.checked) CRM.alert($warning, $warningTitle)"] ); } else { @@ -96,7 +96,7 @@ public function buildQuickForm() { !\Civi::settings()->get('logging') ) { $this->addElement('checkbox', 'makeMultilingual', ts('Enable Multiple Languages'), - NULL, array('onChange' => "if (this.checked) CRM.alert($warning, $warningTitle)") + NULL, ['onChange' => "if (this.checked) CRM.alert($warning, $warningTitle)"] ); } } @@ -105,17 +105,17 @@ public function buildQuickForm() { $includeCurrency = &$this->addElement('advmultiselect', 'currencyLimit', ts('Available Currencies') . ' ', self::getCurrencySymbols(), - array( + [ 'size' => 5, 'style' => 'width:150px', 'class' => 'advmultiselect', - ) + ] ); - $includeCurrency->setButtonAttributes('add', array('value' => ts('Add >>'))); - $includeCurrency->setButtonAttributes('remove', array('value' => ts('<< Remove'))); + $includeCurrency->setButtonAttributes('add', ['value' => ts('Add >>')]); + $includeCurrency->setButtonAttributes('remove', ['value' => ts('<< Remove')]); - $this->addFormRule(array('CRM_Admin_Form_Setting_Localization', 'formRule')); + $this->addFormRule(['CRM_Admin_Form_Setting_Localization', 'formRule']); parent::buildQuickForm(); } @@ -126,7 +126,7 @@ public function buildQuickForm() { * @return array|bool */ public static function formRule($fields) { - $errors = array(); + $errors = []; if (CRM_Utils_Array::value('monetaryThousandSeparator', $fields) == CRM_Utils_Array::value('monetaryDecimalPoint', $fields) ) { @@ -199,7 +199,7 @@ public function postProcess() { // save enabled currencies and default currency in option group 'currencies_enabled' // CRM-1496 if (empty($values['currencyLimit'])) { - $values['currencyLimit'] = array($values['defaultCurrency']); + $values['currencyLimit'] = [$values['defaultCurrency']]; } elseif (!in_array($values['defaultCurrency'], $values['currencyLimit'])) { $values['currencyLimit'][] = $values['defaultCurrency']; @@ -268,17 +268,17 @@ public static function updateEnabledCurrencies($currencies, $default) { sort($currencies); // get labels for all the currencies - $options = array(); + $options = []; $currencySymbols = CRM_Admin_Form_Setting_Localization::getCurrencySymbols(); for ($i = 0; $i < count($currencies); $i++) { - $options[] = array( + $options[] = [ 'label' => $currencySymbols[$currencies[$i]], 'value' => $currencies[$i], 'weight' => $i + 1, 'is_active' => 1, 'is_default' => $currencies[$i] == $default, - ); + ]; } $dontCare = NULL; @@ -292,9 +292,9 @@ public static function updateEnabledCurrencies($currencies, $default) { */ public static function getAvailableCountries() { $i18n = CRM_Core_I18n::singleton(); - $country = array(); + $country = []; CRM_Core_PseudoConstant::populate($country, 'CRM_Core_DAO_Country', TRUE, 'name', 'is_active'); - $i18n->localizeArray($country, array('context' => 'country')); + $i18n->localizeArray($country, ['context' => 'country']); asort($country); return $country; } @@ -310,7 +310,7 @@ public static function getDefaultLocaleOptions() { $locales = CRM_Core_I18n::languages(); if ($domain->locales) { // for multi-lingual sites, populate default language drop-down with available languages - $defaultLocaleOptions = array(); + $defaultLocaleOptions = []; foreach ($locales as $loc => $lang) { if (substr_count($domain->locales, $loc)) { $defaultLocaleOptions[$loc] = $lang; @@ -330,11 +330,11 @@ public static function getDefaultLocaleOptions() { * Array('USD' => 'USD ($)'). */ public static function getCurrencySymbols() { - $symbols = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'currency', array( + $symbols = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'currency', [ 'labelColumn' => 'symbol', 'orderColumn' => TRUE, - )); - $_currencySymbols = array(); + ]); + $_currencySymbols = []; foreach ($symbols as $key => $value) { $_currencySymbols[$key] = "$key"; if ($value) { @@ -378,7 +378,7 @@ public static function onChangeDefaultCurrency($oldCurrency, $newCurrency, $meta $currencies = array_keys(CRM_Core_OptionGroup::values('currencies_enabled')); if (!in_array($newCurrency, $currencies)) { if (empty($currencies)) { - $currencies = array($values['defaultCurrency']); + $currencies = [$values['defaultCurrency']]; } else { $currencies[] = $newCurrency; @@ -393,11 +393,11 @@ public static function onChangeDefaultCurrency($oldCurrency, $newCurrency, $meta * @return array */ public static function getDefaultLanguageOptions() { - return array( + return [ '*default*' => ts('Use default site language'), 'undefined' => ts('Leave undefined'), 'current_site_language' => ts('Use language in use at the time'), - ); + ]; } } diff --git a/CRM/Admin/Form/Setting/Mail.php b/CRM/Admin/Form/Setting/Mail.php index 1186b4c909e4..bd75e95a8381 100644 --- a/CRM/Admin/Form/Setting/Mail.php +++ b/CRM/Admin/Form/Setting/Mail.php @@ -36,21 +36,21 @@ */ class CRM_Admin_Form_Setting_Mail extends CRM_Admin_Form_Setting { - protected $_settings = array( + protected $_settings = [ 'mailerBatchLimit' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'mailThrottleTime' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'mailerJobSize' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'mailerJobsMax' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'verpSeparator' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'replyTo' => CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, - ); + ]; /** * Build the form object. */ public function buildQuickForm() { CRM_Utils_System::setTitle(ts('Settings - CiviMail')); - $this->addFormRule(array('CRM_Admin_Form_Setting_Mail', 'formRule')); + $this->addFormRule(['CRM_Admin_Form_Setting_Mail', 'formRule']); parent::buildQuickForm(); } @@ -61,7 +61,7 @@ public function buildQuickForm() { * @return array|bool */ public static function formRule($fields) { - $errors = array(); + $errors = []; if (CRM_Utils_Array::value('mailerJobSize', $fields) > 0) { if (CRM_Utils_Array::value('mailerJobSize', $fields) < 1000) { diff --git a/CRM/Admin/Form/Setting/Mapping.php b/CRM/Admin/Form/Setting/Mapping.php index cf4c0c50419a..2d71f739df02 100644 --- a/CRM/Admin/Form/Setting/Mapping.php +++ b/CRM/Admin/Form/Setting/Mapping.php @@ -36,12 +36,12 @@ */ class CRM_Admin_Form_Setting_Mapping extends CRM_Admin_Form_Setting { - protected $_settings = array( + protected $_settings = [ 'mapAPIKey' => CRM_Core_BAO_Setting::MAP_PREFERENCES_NAME, 'mapProvider' => CRM_Core_BAO_Setting::MAP_PREFERENCES_NAME, 'geoAPIKey' => CRM_Core_BAO_Setting::MAP_PREFERENCES_NAME, 'geoProvider' => CRM_Core_BAO_Setting::MAP_PREFERENCES_NAME, - ); + ]; /** * Build the form object. @@ -61,7 +61,7 @@ public function buildQuickForm() { * true if no errors, else array of errors */ public static function formRule($fields) { - $errors = array(); + $errors = []; if (!CRM_Utils_System::checkPHPVersion(5, FALSE)) { $errors['_qf_default'] = ts('Mapping features require PHP version 5 or greater'); @@ -84,7 +84,7 @@ public static function formRule($fields) { * All local rules are added near the element */ public function addRules() { - $this->addFormRule(array('CRM_Admin_Form_Setting_Mapping', 'formRule')); + $this->addFormRule(['CRM_Admin_Form_Setting_Mapping', 'formRule']); } } diff --git a/CRM/Admin/Form/Setting/Miscellaneous.php b/CRM/Admin/Form/Setting/Miscellaneous.php index 1da6fc363ef7..8b92a4b411f5 100644 --- a/CRM/Admin/Form/Setting/Miscellaneous.php +++ b/CRM/Admin/Form/Setting/Miscellaneous.php @@ -36,7 +36,7 @@ */ class CRM_Admin_Form_Setting_Miscellaneous extends CRM_Admin_Form_Setting { - protected $_settings = array( + protected $_settings = [ 'max_attachments' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_undelete' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'empoweredBy' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, @@ -57,7 +57,7 @@ class CRM_Admin_Form_Setting_Miscellaneous extends CRM_Admin_Form_Setting { 'remote_profile_submissions' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'allow_alert_autodismissal' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'prevNextBackend' => CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME, - ); + ]; public $_uploadMaxSize; @@ -70,7 +70,7 @@ public function preProcess() { CRM_Utils_Number::formatUnitSize(ini_get('post_max_size'), TRUE); // This is a temp hack for the fact we really don't need to hard-code each setting in the tpl but // we haven't worked through NOT doing that. These settings have been un-hardcoded. - $this->assign('pure_config_settings', array( + $this->assign('pure_config_settings', [ 'empoweredBy', 'max_attachments', 'maxFileSize', @@ -79,7 +79,7 @@ public function preProcess() { 'recentItemsProviders', 'dedupe_default_limit', 'prevNextBackend', - )); + ]); } /** @@ -90,7 +90,7 @@ public function buildQuickForm() { $this->assign('validTriggerPermission', CRM_Core_DAO::checkTriggerViewPermission(FALSE)); - $this->addFormRule(array('CRM_Admin_Form_Setting_Miscellaneous', 'formRule'), $this); + $this->addFormRule(['CRM_Admin_Form_Setting_Miscellaneous', 'formRule'], $this); parent::buildQuickForm(); $this->addRule('checksum_timeout', ts('Value should be a positive number'), 'positiveInteger'); @@ -110,7 +110,7 @@ public function buildQuickForm() { * true if no errors, else array of errors */ public static function formRule($fields, $files, $options) { - $errors = array(); + $errors = []; // validate max file size if ($fields['maxFileSize'] > $options->_uploadMaxSize) { @@ -119,7 +119,7 @@ public static function formRule($fields, $files, $options) { // validate recent items stack size if ($fields['recentItemsMaxCount'] && ($fields['recentItemsMaxCount'] < 1 || $fields['recentItemsMaxCount'] > CRM_Utils_Recent::MAX_ITEMS)) { - $errors['recentItemsMaxCount'] = ts("Illegal stack size. Use values between 1 and %1.", array(1 => CRM_Utils_Recent::MAX_ITEMS)); + $errors['recentItemsMaxCount'] = ts("Illegal stack size. Use values between 1 and %1.", [1 => CRM_Utils_Recent::MAX_ITEMS]); } if (!empty($fields['wkhtmltopdfPath'])) { diff --git a/CRM/Admin/Form/Setting/Path.php b/CRM/Admin/Form/Setting/Path.php index 546bfcfc9ede..b83c52706748 100644 --- a/CRM/Admin/Form/Setting/Path.php +++ b/CRM/Admin/Form/Setting/Path.php @@ -36,14 +36,14 @@ */ class CRM_Admin_Form_Setting_Path extends CRM_Admin_Form_Setting { - protected $_settings = array( + protected $_settings = [ 'uploadDir' => CRM_Core_BAO_Setting::DIRECTORY_PREFERENCES_NAME, 'imageUploadDir' => CRM_Core_BAO_Setting::DIRECTORY_PREFERENCES_NAME, 'customFileUploadDir' => CRM_Core_BAO_Setting::DIRECTORY_PREFERENCES_NAME, 'customTemplateDir' => CRM_Core_BAO_Setting::DIRECTORY_PREFERENCES_NAME, 'customPHPPathDir' => CRM_Core_BAO_Setting::DIRECTORY_PREFERENCES_NAME, 'extensionsDir' => CRM_Core_BAO_Setting::DIRECTORY_PREFERENCES_NAME, - ); + ]; /** * Build the form object. @@ -52,19 +52,19 @@ public function buildQuickForm() { CRM_Utils_System::setTitle(ts('Settings - Upload Directories')); parent::buildQuickForm(); - $directories = array( + $directories = [ 'uploadDir' => ts('Temporary Files'), 'imageUploadDir' => ts('Images'), 'customFileUploadDir' => ts('Custom Files'), 'customTemplateDir' => ts('Custom Templates'), 'customPHPPathDir' => ts('Custom PHP Path Directory'), 'extensionsDir' => ts('CiviCRM Extensions Directory'), - ); + ]; foreach ($directories as $name => $title) { //$this->add('text', $name, $title); $this->addRule($name, ts("'%1' directory does not exist", - array(1 => $title) + [1 => $title] ), 'settingPath' ); diff --git a/CRM/Admin/Form/Setting/Search.php b/CRM/Admin/Form/Setting/Search.php index 8c632e2a697a..95cab96824fe 100644 --- a/CRM/Admin/Form/Setting/Search.php +++ b/CRM/Admin/Form/Setting/Search.php @@ -37,7 +37,7 @@ */ class CRM_Admin_Form_Setting_Search extends CRM_Admin_Form_Setting { - protected $_settings = array( + protected $_settings = [ 'contact_reference_options' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_autocomplete_options' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'search_autocomplete_count' => CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME, @@ -51,7 +51,7 @@ class CRM_Admin_Form_Setting_Search extends CRM_Admin_Form_Setting { 'defaultSearchProfileID' => CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME, 'searchPrimaryDetailsOnly' => CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME, 'quicksearch_options' => CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME, - ); + ]; /** * Build the form object. @@ -87,12 +87,12 @@ public static function getContactAutocompleteOptions() { * @return array */ public static function getAvailableProfiles() { - return array('' => ts('- none -')) + CRM_Core_BAO_UFGroup::getProfiles(array( + return ['' => ts('- none -')] + CRM_Core_BAO_UFGroup::getProfiles([ 'Contact', 'Individual', 'Organization', 'Household', - )); + ]); } /** diff --git a/CRM/Admin/Form/Setting/Smtp.php b/CRM/Admin/Form/Setting/Smtp.php index bf1566239d13..e70260e63f77 100644 --- a/CRM/Admin/Form/Setting/Smtp.php +++ b/CRM/Admin/Form/Setting/Smtp.php @@ -42,13 +42,13 @@ class CRM_Admin_Form_Setting_Smtp extends CRM_Admin_Form_Setting { */ public function buildQuickForm() { - $outBoundOption = array( + $outBoundOption = [ CRM_Mailing_Config::OUTBOUND_OPTION_MAIL => ts('mail()'), CRM_Mailing_Config::OUTBOUND_OPTION_SMTP => ts('SMTP'), CRM_Mailing_Config::OUTBOUND_OPTION_SENDMAIL => ts('Sendmail'), CRM_Mailing_Config::OUTBOUND_OPTION_DISABLED => ts('Disable Outbound Email'), CRM_Mailing_Config::OUTBOUND_OPTION_REDIRECT_TO_DB => ts('Redirect to Database'), - ); + ]; $this->addRadio('outBound_option', ts('Select Mailer'), $outBoundOption); CRM_Utils_System::setTitle(ts('Settings - Outbound Mail')); @@ -63,10 +63,10 @@ public function buildQuickForm() { $this->_testButtonName = $this->getButtonName('refresh', 'test'); - $this->addFormRule(array('CRM_Admin_Form_Setting_Smtp', 'formRule')); + $this->addFormRule(['CRM_Admin_Form_Setting_Smtp', 'formRule']); parent::buildQuickForm(); $buttons = $this->getElement('buttons')->getElements(); - $buttons[] = $this->createElement('submit', $this->_testButtonName, ts('Save & Send Test Email'), array('crm-icon' => 'fa-envelope-o')); + $buttons[] = $this->createElement('submit', $this->_testButtonName, ts('Save & Send Test Email'), ['crm-icon' => 'fa-envelope-o']); $this->getElement('buttons')->setElements($buttons); } @@ -102,7 +102,7 @@ public function postProcess() { if (!$domainEmailAddress || $domainEmailAddress == 'info@EXAMPLE.ORG') { $fixUrl = CRM_Utils_System::url("civicrm/admin/domain", 'action=update&reset=1'); - CRM_Core_Error::fatal(ts('The site administrator needs to enter a valid \'FROM Email Address\' in Administer CiviCRM » Communications » FROM Email Addresses. The email address used may need to be a valid mail account with your email service provider.', array(1 => $fixUrl))); + CRM_Core_Error::fatal(ts('The site administrator needs to enter a valid \'FROM Email Address\' in Administer CiviCRM » Communications » FROM Email Addresses. The email address used may need to be a valid mail account with your email service provider.', [1 => $fixUrl])); } if (!$toEmail) { @@ -116,10 +116,10 @@ public function postProcess() { $to = '"' . $toDisplayName . '"' . "<$toEmail>"; $from = '"' . $domainEmailName . '" <' . $domainEmailAddress . '>'; $testMailStatusMsg = ts('Sending test email') . ':
' - . ts('From: %1', array(1 => $domainEmailAddress)) . '
' - . ts('To: %1', array(1 => $toEmail)) . '
'; + . ts('From: %1', [1 => $domainEmailAddress]) . '
' + . ts('To: %1', [1 => $toEmail]) . '
'; - $params = array(); + $params = []; if ($formValues['outBound_option'] == CRM_Mailing_Config::OUTBOUND_OPTION_SMTP) { $subject = "Test for SMTP settings"; $message = "SMTP settings are correct."; @@ -158,11 +158,11 @@ public function postProcess() { $mailerName = 'mail'; } - $headers = array( + $headers = [ 'From' => $from, 'To' => $to, 'Subject' => $subject, - ); + ]; $mailer = Mail::factory($mailerName, $params); @@ -173,14 +173,14 @@ public function postProcess() { $testMailStatusMsg .= '
' . ts('You have defined CIVICRM_MAIL_LOG_AND_SEND - mail will be logged.') . '

'; } if (defined('CIVICRM_MAIL_LOG') && !defined('CIVICRM_MAIL_LOG_AND_SEND')) { - CRM_Core_Session::setStatus($testMailStatusMsg . ts('You have defined CIVICRM_MAIL_LOG - no mail will be sent. Your %1 settings have not been tested.', array(1 => strtoupper($mailerName))), ts("Mail not sent"), "warning"); + CRM_Core_Session::setStatus($testMailStatusMsg . ts('You have defined CIVICRM_MAIL_LOG - no mail will be sent. Your %1 settings have not been tested.', [1 => strtoupper($mailerName)]), ts("Mail not sent"), "warning"); } elseif (!is_a($result, 'PEAR_Error')) { - CRM_Core_Session::setStatus($testMailStatusMsg . ts('Your %1 settings are correct. A test email has been sent to your email address.', array(1 => strtoupper($mailerName))), ts("Mail Sent"), "success"); + CRM_Core_Session::setStatus($testMailStatusMsg . ts('Your %1 settings are correct. A test email has been sent to your email address.', [1 => strtoupper($mailerName)]), ts("Mail Sent"), "success"); } else { $message = CRM_Utils_Mail::errorMessage($mailer, $result); - CRM_Core_Session::setStatus($testMailStatusMsg . ts('Oops. Your %1 settings are incorrect. No test mail has been sent.', array(1 => strtoupper($mailerName))) . $message, ts("Mail Not Sent"), "error"); + CRM_Core_Session::setStatus($testMailStatusMsg . ts('Oops. Your %1 settings are incorrect. No test mail has been sent.', [1 => strtoupper($mailerName)]) . $message, ts("Mail Not Sent"), "error"); } } } @@ -242,7 +242,7 @@ public static function formRule($fields) { */ public function setDefaultValues() { if (!$this->_defaults) { - $this->_defaults = array(); + $this->_defaults = []; $mailingBackend = Civi::settings()->get('mailing_backend'); if (!empty($mailingBackend)) { diff --git a/CRM/Admin/Form/Setting/UF.php b/CRM/Admin/Form/Setting/UF.php index 792136a8f331..7fa620428db3 100644 --- a/CRM/Admin/Form/Setting/UF.php +++ b/CRM/Admin/Form/Setting/UF.php @@ -36,7 +36,7 @@ */ class CRM_Admin_Form_Setting_UF extends CRM_Admin_Form_Setting { - protected $_settings = array(); + protected $_settings = []; protected $_uf = NULL; @@ -53,7 +53,7 @@ public function buildQuickForm() { } CRM_Utils_System::setTitle( - ts('Settings - %1 Integration', array(1 => $this->_uf)) + ts('Settings - %1 Integration', [1 => $this->_uf]) ); if ($config->userSystem->is_drupal) { diff --git a/CRM/Admin/Form/Setting/UpdateConfigBackend.php b/CRM/Admin/Form/Setting/UpdateConfigBackend.php index b16f242a1ed6..d1a258738c8b 100644 --- a/CRM/Admin/Form/Setting/UpdateConfigBackend.php +++ b/CRM/Admin/Form/Setting/UpdateConfigBackend.php @@ -44,12 +44,12 @@ public function buildQuickForm() { $this->addElement( 'submit', $this->getButtonName('next', 'cleanup'), 'Cleanup Caches', - array('class' => 'crm-form-submit', 'id' => 'cleanup-cache') + ['class' => 'crm-form-submit', 'id' => 'cleanup-cache'] ); $this->addElement( 'submit', $this->getButtonName('next', 'resetpaths'), 'Reset Paths', - array('class' => 'crm-form-submit', 'id' => 'resetpaths') + ['class' => 'crm-form-submit', 'id' => 'resetpaths'] ); //parent::buildQuickForm(); diff --git a/CRM/Admin/Form/Setting/Url.php b/CRM/Admin/Form/Setting/Url.php index 7a3e0a710bc0..9d6a62245553 100644 --- a/CRM/Admin/Form/Setting/Url.php +++ b/CRM/Admin/Form/Setting/Url.php @@ -35,29 +35,29 @@ * This class generates form components for Site Url. */ class CRM_Admin_Form_Setting_Url extends CRM_Admin_Form_Setting { - protected $_settings = array( + protected $_settings = [ 'disable_core_css' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'userFrameworkResourceURL' => CRM_Core_BAO_Setting::URL_PREFERENCES_NAME, 'imageUploadURL' => CRM_Core_BAO_Setting::URL_PREFERENCES_NAME, 'customCSSURL' => CRM_Core_BAO_Setting::URL_PREFERENCES_NAME, 'extensionsURL' => CRM_Core_BAO_Setting::URL_PREFERENCES_NAME, - ); + ]; /** * Build the form object. */ public function buildQuickForm() { CRM_Utils_System::setTitle(ts('Settings - Resource URLs')); - $settingFields = civicrm_api('setting', 'getfields', array( + $settingFields = civicrm_api('setting', 'getfields', [ 'version' => 3, - )); + ]); $this->addYesNo('enableSSL', ts('Force Secure URLs (SSL)')); $this->addYesNo('verifySSL', ts('Verify SSL Certs')); // FIXME: verifySSL should use $_settings instead of manually adding fields $this->assign('verifySSL_description', $settingFields['values']['verifySSL']['description']); - $this->addFormRule(array('CRM_Admin_Form_Setting_Url', 'formRule')); + $this->addFormRule(['CRM_Admin_Form_Setting_Url', 'formRule']); parent::buildQuickForm(); } @@ -78,9 +78,9 @@ public static function formRule($fields) { ) ); if (!CRM_Utils_System::checkURL($url, TRUE)) { - $errors = array( + $errors = [ 'enableSSL' => ts('You need to set up a secure server before you can use the Force Secure URLs option'), - ); + ]; return $errors; } } diff --git a/CRM/Admin/Form/SettingTrait.php b/CRM/Admin/Form/SettingTrait.php index 81fb55fa08c4..b1b1cd31a482 100644 --- a/CRM/Admin/Form/SettingTrait.php +++ b/CRM/Admin/Form/SettingTrait.php @@ -235,7 +235,7 @@ protected function addFieldsDefinedInSettingsMetadata() { $this->$add($setting, ts($props['title']), $props['entity_reference_options']); } elseif ($add === 'addYesNo' && ($props['type'] === 'Boolean')) { - $this->addRadio($setting, ts($props['title']), array(1 => 'Yes', 0 => 'No'), NULL, '  '); + $this->addRadio($setting, ts($props['title']), [1 => 'Yes', 0 => 'No'], NULL, '  '); } else { $this->$add($setting, ts($props['title']), $options); diff --git a/CRM/Admin/Form/WordReplacements.php b/CRM/Admin/Form/WordReplacements.php index 5f7489142a48..df67f04a2403 100644 --- a/CRM/Admin/Form/WordReplacements.php +++ b/CRM/Admin/Form/WordReplacements.php @@ -61,19 +61,19 @@ public function setDefaultValues() { return $this->_defaults; } - $this->_defaults = array(); + $this->_defaults = []; $config = CRM_Core_Config::singleton(); $values = CRM_Core_BAO_WordReplacement::getLocaleCustomStrings($config->lcMessages); $i = 1; - $enableDisable = array( + $enableDisable = [ 1 => 'enabled', 0 => 'disabled', - ); + ]; - $cardMatch = array('wildcardMatch', 'exactMatch'); + $cardMatch = ['wildcardMatch', 'exactMatch']; foreach ($enableDisable as $key => $val) { foreach ($cardMatch as $kc => $vc) { @@ -112,9 +112,9 @@ public function buildQuickForm() { } $soInstances = range(1, $this->_numStrings, 1); - $stringOverrideInstances = array(); + $stringOverrideInstances = []; if ($this->_soInstance) { - $soInstances = array($this->_soInstance); + $soInstances = [$this->_soInstance]; } elseif (!empty($_POST['old'])) { $soInstances = $stringOverrideInstances = array_keys($_POST['old']); @@ -138,19 +138,19 @@ public function buildQuickForm() { $this->assign('stringOverrideInstances', empty($stringOverrideInstances) ? FALSE : $stringOverrideInstances); - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => ts('Save'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); - $this->addFormRule(array('CRM_Admin_Form_WordReplacements', 'formRule'), $this); + $this->addFormRule(['CRM_Admin_Form_WordReplacements', 'formRule'], $this); } /** @@ -163,7 +163,7 @@ public function buildQuickForm() { * list of errors to be posted back to the form */ public static function formRule($values) { - $errors = array(); + $errors = []; $oldValues = CRM_Utils_Array::value('old', $values); $newValues = CRM_Utils_Array::value('new', $values); @@ -195,32 +195,32 @@ public function postProcess() { $params = $this->controller->exportValues($this->_name); $this->_numStrings = count($params['old']); - $enabled['exactMatch'] = $enabled['wildcardMatch'] = $disabled['exactMatch'] = $disabled['wildcardMatch'] = array(); + $enabled['exactMatch'] = $enabled['wildcardMatch'] = $disabled['exactMatch'] = $disabled['wildcardMatch'] = []; for ($i = 1; $i <= $this->_numStrings; $i++) { if (!empty($params['new'][$i]) && !empty($params['old'][$i])) { if (isset($params['enabled']) && !empty($params['enabled'][$i])) { if (!empty($params['cb']) && !empty($params['cb'][$i])) { - $enabled['exactMatch'] += array($params['old'][$i] => $params['new'][$i]); + $enabled['exactMatch'] += [$params['old'][$i] => $params['new'][$i]]; } else { - $enabled['wildcardMatch'] += array($params['old'][$i] => $params['new'][$i]); + $enabled['wildcardMatch'] += [$params['old'][$i] => $params['new'][$i]]; } } else { if (isset($params['cb']) && is_array($params['cb']) && array_key_exists($i, $params['cb'])) { - $disabled['exactMatch'] += array($params['old'][$i] => $params['new'][$i]); + $disabled['exactMatch'] += [$params['old'][$i] => $params['new'][$i]]; } else { - $disabled['wildcardMatch'] += array($params['old'][$i] => $params['new'][$i]); + $disabled['wildcardMatch'] += [$params['old'][$i] => $params['new'][$i]]; } } } } - $overrides = array( + $overrides = [ 'enabled' => $enabled, 'disabled' => $disabled, - ); + ]; $config = CRM_Core_Config::singleton(); CRM_Core_BAO_WordReplacement::setLocaleCustomStrings($config->lcMessages, $overrides); diff --git a/CRM/Admin/Page/AJAX.php b/CRM/Admin/Page/AJAX.php index dc1f06589604..02a9485e3bdc 100644 --- a/CRM/Admin/Page/AJAX.php +++ b/CRM/Admin/Page/AJAX.php @@ -123,16 +123,16 @@ public static function getStatusMsg() { require_once 'api/v3/utils.php'; $recordID = CRM_Utils_Type::escape($_GET['id'], 'Integer'); $entity = CRM_Utils_Type::escape($_GET['entity'], 'String'); - $ret = array(); + $ret = []; if ($recordID && $entity && $recordBAO = _civicrm_api3_get_BAO($entity)) { switch ($recordBAO) { case 'CRM_Core_BAO_UFGroup': $method = 'getUFJoinRecord'; - $result = array($recordBAO, $method); - $ufJoin = call_user_func_array(($result), array($recordID, TRUE)); + $result = [$recordBAO, $method]; + $ufJoin = call_user_func_array(($result), [$recordID, TRUE]); if (!empty($ufJoin)) { - $ret['content'] = ts('This profile is currently used for %1.', array(1 => implode(', ', $ufJoin))) . '

' . ts('If you disable the profile - it will be removed from these forms and/or modules. Do you want to continue?'); + $ret['content'] = ts('This profile is currently used for %1.', [1 => implode(', ', $ufJoin)]) . '

' . ts('If you disable the profile - it will be removed from these forms and/or modules. Do you want to continue?'); } else { $ret['content'] = ts('Are you sure you want to disable this profile?'); @@ -146,12 +146,12 @@ public static function getStatusMsg() { if (!CRM_Utils_System::isNull($usedBy)) { $template = CRM_Core_Smarty::singleton(); $template->assign('usedBy', $usedBy); - $comps = array( + $comps = [ 'Event' => 'civicrm_event', 'Contribution' => 'civicrm_contribution_page', 'EventTemplate' => 'civicrm_event_template', - ); - $contexts = array(); + ]; + $contexts = []; foreach ($comps as $name => $table) { if (array_key_exists($table, $usedBy)) { $contexts[] = $name; @@ -161,12 +161,12 @@ public static function getStatusMsg() { $ret['illegal'] = TRUE; $table = $template->fetch('CRM/Price/Page/table.tpl'); - $ret['content'] = ts('Unable to disable the \'%1\' price set - it is currently in use by one or more active events, contribution pages or contributions.', array( + $ret['content'] = ts('Unable to disable the \'%1\' price set - it is currently in use by one or more active events, contribution pages or contributions.', [ 1 => $priceSet, - )) . "
$table"; + ]) . "
$table"; } else { - $ret['content'] = ts('Are you sure you want to disable \'%1\' Price Set?', array(1 => $priceSet)); + $ret['content'] = ts('Are you sure you want to disable \'%1\' Price Set?', [1 => $priceSet]); } break; @@ -271,7 +271,7 @@ public static function getStatusMsg() { case 'CRM_Core_BAO_OptionValue': $label = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', $recordID, 'label'); - $ret['content'] = ts('Are you sure you want to disable the \'%1\' option ?', array(1 => $label)); + $ret['content'] = ts('Are you sure you want to disable the \'%1\' option ?', [1 => $label]); $ret['content'] .= '

' . ts('WARNING - Disabling an option which has been assigned to existing records will result in that option being cleared when the record is edited.'); break; @@ -290,7 +290,7 @@ public static function getStatusMsg() { } } else { - $ret = array('status' => 'error', 'content' => 'Error: Unknown entity type.', 'illegal' => TRUE); + $ret = ['status' => 'error', 'content' => 'Error: Unknown entity type.', 'illegal' => TRUE]; } CRM_Core_Page_AJAX::returnJsonResponse($ret); } @@ -302,29 +302,29 @@ public static function getStatusMsg() { */ static public function mappingList() { if (empty($_GET['mappingID'])) { - CRM_Utils_JSON::output(array('status' => 'error', 'error_msg' => 'required params missing.')); + CRM_Utils_JSON::output(['status' => 'error', 'error_msg' => 'required params missing.']); } $mapping = CRM_Core_BAO_ActionSchedule::getMapping($_GET['mappingID']); - $dateFieldLabels = $mapping ? $mapping->getDateFields() : array(); + $dateFieldLabels = $mapping ? $mapping->getDateFields() : []; // The UX here is quirky -- for "Activity" types, there's a simple drop "Recipients" // dropdown which is always displayed. For other types, the "Recipients" drop down is // conditional upon the weird isLimit ('Limit To / Also Include / Neither') dropdown. $noThanksJustKidding = !$_GET['isLimit']; if ($mapping instanceof CRM_Activity_ActionMapping || !$noThanksJustKidding) { - $entityRecipientLabels = $mapping ? ($mapping->getRecipientTypes() + CRM_Core_BAO_ActionSchedule::getAdditionalRecipients()) : array(); + $entityRecipientLabels = $mapping ? ($mapping->getRecipientTypes() + CRM_Core_BAO_ActionSchedule::getAdditionalRecipients()) : []; } else { $entityRecipientLabels = CRM_Core_BAO_ActionSchedule::getAdditionalRecipients(); } $recipientMapping = array_combine(array_keys($entityRecipientLabels), array_keys($entityRecipientLabels)); - $output = array( + $output = [ 'sel4' => CRM_Utils_Array::makeNonAssociative($dateFieldLabels), 'sel5' => CRM_Utils_Array::makeNonAssociative($entityRecipientLabels), 'recipientMapping' => $recipientMapping, - ); + ]; CRM_Utils_JSON::output($output); } @@ -335,20 +335,20 @@ static public function mappingList() { * Ex: GET /civicrm/ajax/recipientListing?mappingID=contribpage&recipientType= */ public static function recipientListing() { - $mappingID = filter_input(INPUT_GET, 'mappingID', FILTER_VALIDATE_REGEXP, array( - 'options' => array( + $mappingID = filter_input(INPUT_GET, 'mappingID', FILTER_VALIDATE_REGEXP, [ + 'options' => [ 'regexp' => '/^[a-zA-Z0-9_\-]+$/', - ), - )); - $recipientType = filter_input(INPUT_GET, 'recipientType', FILTER_VALIDATE_REGEXP, array( - 'options' => array( + ], + ]); + $recipientType = filter_input(INPUT_GET, 'recipientType', FILTER_VALIDATE_REGEXP, [ + 'options' => [ 'regexp' => '/^[a-zA-Z0-9_\-]+$/', - ), - )); + ], + ]); - CRM_Utils_JSON::output(array( + CRM_Utils_JSON::output([ 'recipients' => CRM_Utils_Array::makeNonAssociative(CRM_Core_BAO_ActionSchedule::getRecipientListing($mappingID, $recipientType)), - )); + ]); } /** @@ -359,9 +359,9 @@ public static function recipientListing() { public static function getTagTree() { $parent = CRM_Utils_Type::escape(CRM_Utils_Array::value('parent_id', $_GET, 0), 'Integer'); $substring = CRM_Utils_Type::escape(CRM_Utils_Array::value('str', $_GET), 'String'); - $result = array(); + $result = []; - $whereClauses = array('is_tagset <> 1'); + $whereClauses = ['is_tagset <> 1']; $orderColumn = 'name'; // fetch all child tags in Array('parent_tag' => array('child_tag_1', 'child_tag_2', ...)) format diff --git a/CRM/Admin/Page/APIExplorer.php b/CRM/Admin/Page/APIExplorer.php index aebc45bde319..8414ec8ab325 100644 --- a/CRM/Admin/Page/APIExplorer.php +++ b/CRM/Admin/Page/APIExplorer.php @@ -70,13 +70,13 @@ public function run() { ->addScriptFile('civicrm', 'templates/CRM/Admin/Page/APIExplorer.js') ->addScriptFile('civicrm', 'bower_components/google-code-prettify/bin/prettify.min.js', 99) ->addStyleFile('civicrm', 'bower_components/google-code-prettify/bin/prettify.min.css', 99) - ->addVars('explorer', array('max_joins' => \Civi\API\Api3SelectQuery::MAX_JOINS)); + ->addVars('explorer', ['max_joins' => \Civi\API\Api3SelectQuery::MAX_JOINS]); $this->assign('operators', CRM_Core_DAO::acceptedSQLOperators()); // List example directories // use get_include_path to ensure that extensions are captured. - $examples = array(); + $examples = []; $paths = self::uniquePaths(); foreach ($paths as $path) { $dir = \CRM_Utils_File::addTrailingSlash($path) . 'api' . DIRECTORY_SEPARATOR . 'v3' . DIRECTORY_SEPARATOR . 'examples'; @@ -109,7 +109,7 @@ public function userContext() { */ public static function getExampleFile() { if (!empty($_GET['entity']) && strpos($_GET['entity'], '.') === FALSE) { - $examples = array(); + $examples = []; $paths = self::uniquePaths(); foreach ($paths as $path) { $dir = \CRM_Utils_File::addTrailingSlash($path) . 'api' . DIRECTORY_SEPARATOR . 'v3' . DIRECTORY_SEPARATOR . 'examples' . DIRECTORY_SEPARATOR . $_GET['entity']; @@ -117,7 +117,7 @@ public static function getExampleFile() { foreach (scandir($dir) as $item) { $item = str_replace('.php', '', $item); if ($item && strpos($item, '.') === FALSE) { - $examples[] = array('key' => $item, 'value' => $item); + $examples[] = ['key' => $item, 'value' => $item]; } } } @@ -152,11 +152,11 @@ public static function getDoc() { if (!empty($entity) && in_array($entity, $entities['values']) && strpos($entity, '.') === FALSE) { $action = CRM_Utils_Array::value('action', $_GET); $doc = self::getDocblock($entity, $action); - $result = array( + $result = [ 'doc' => $doc ? self::formatDocBlock($doc[0]) : 'Not found.', 'code' => $doc ? $doc[1] : NULL, 'file' => $doc ? $doc[2] : NULL, - ); + ]; if (!$action) { $actions = civicrm_api3($entity, 'getactions'); $result['actions'] = CRM_Utils_Array::makeNonAssociative(array_combine($actions['values'], $actions['values'])); @@ -184,11 +184,11 @@ private static function getDocBlock($entity, $action) { // Api does not exist return FALSE; } - $docblock = $code = array(); + $docblock = $code = []; // Fetch docblock for the api file if (!$action) { if (preg_match('#/\*\*\n.*?\n \*/\n#s', $contents, $docblock)) { - return array($docblock[0], NULL, $file); + return [$docblock[0], NULL, $file]; } } // Fetch block for a specific action @@ -215,7 +215,7 @@ private static function getDocBlock($entity, $action) { if (preg_match('#(/\*\*(\n \*.*)*\n \*/\n)function[ ]+' . $fnName . '#i', $contents, $docblock)) { // Fetch the code in a separate regex to preserve sanity preg_match("#^function[ ]+$fnName.*?^}#ism", $contents, $code); - return array($docblock[1], $code[0], $file); + return [$docblock[1], $code[0], $file]; } } } @@ -234,13 +234,13 @@ public static function formatDocBlock($text) { $text = implode("\n", $lines); // Get rid of comment stars - $text = str_replace(array("\n * ", "\n *\n", "\n */\n", "/**\n"), array("\n", "\n\n", '', ''), $text); + $text = str_replace(["\n * ", "\n *\n", "\n */\n", "/**\n"], ["\n", "\n\n", '', ''], $text); // Format for html $text = htmlspecialchars($text); // Extract code blocks - save for later to skip html conversion - $code = array(); + $code = []; preg_match_all('#@code(.*?)@endcode#is', $text, $code); $text = preg_replace('#@code.*?@endcode#is', '
', $text);
 
diff --git a/CRM/Admin/Page/Admin.php b/CRM/Admin/Page/Admin.php
index 17d78e08ef70..eab28f37aad1 100644
--- a/CRM/Admin/Page/Admin.php
+++ b/CRM/Admin/Page/Admin.php
@@ -45,13 +45,13 @@ public function run() {
 
     $this->assign('registerSite', htmlspecialchars('https://civicrm.org/register-your-site?src=iam&sid=' . CRM_Utils_System::getSiteID()));
 
-    $groups = array(
+    $groups = [
       'Customize Data and Screens' => ts('Customize Data and Screens'),
       'Communications' => ts('Communications'),
       'Localization' => ts('Localization'),
       'Users and Permissions' => ts('Users and Permissions'),
       'System Settings' => ts('System Settings'),
-    );
+    ];
 
     $config = CRM_Core_Config::singleton();
     if (in_array('CiviContribute', $config->enableComponents)) {
@@ -98,7 +98,7 @@ public function run() {
         $adminPanel[$groupId]['title'] = $title;
       }
       else {
-        $adminPanel[$groupId] = array();
+        $adminPanel[$groupId] = [];
         $adminPanel[$groupId]['show'] = '';
         $adminPanel[$groupId]['hide'] = '';
         $adminPanel[$groupId]['title'] = $title;
diff --git a/CRM/Admin/Page/CKEditorConfig.php b/CRM/Admin/Page/CKEditorConfig.php
index d8ebfea5195d..ac157b423e4a 100644
--- a/CRM/Admin/Page/CKEditorConfig.php
+++ b/CRM/Admin/Page/CKEditorConfig.php
@@ -47,7 +47,7 @@ class CRM_Admin_Page_CKEditorConfig extends CRM_Core_Page {
    *
    * @var array
    */
-  public $blackList = array(
+  public $blackList = [
     'on',
     'skin',
     'extraPlugins',
@@ -59,7 +59,7 @@ class CRM_Admin_Page_CKEditorConfig extends CRM_Core_Page {
     'filebrowserUploadUrl',
     'filebrowserImageUploadUrl',
     'filebrowserFlashUploadUrl',
-  );
+  ];
 
   public $preset;
 
@@ -90,11 +90,11 @@ public function run() {
       ->addScriptFile('civicrm', 'js/wysiwyg/admin.ckeditor-configurator.js', 10)
       ->addStyleFile('civicrm', 'bower_components/ckeditor/samples/toolbarconfigurator/css/fontello.css')
       ->addStyleFile('civicrm', 'bower_components/ckeditor/samples/css/samples.css')
-      ->addVars('ckConfig', array(
+      ->addVars('ckConfig', [
         'plugins' => array_values($this->getCKPlugins()),
         'blacklist' => $this->blackList,
         'settings' => $settings,
-      ));
+      ]);
 
     $configUrl = self::getConfigUrl($this->preset) ?: self::getConfigUrl('default');
 
@@ -104,12 +104,12 @@ public function run() {
     $this->assign('skin', CRM_Utils_Array::value('skin', $settings));
     $this->assign('extraPlugins', CRM_Utils_Array::value('extraPlugins', $settings));
     $this->assign('configUrl', $configUrl);
-    $this->assign('revertConfirm', htmlspecialchars(ts('Are you sure you want to revert all changes?', array('escape' => 'js'))));
+    $this->assign('revertConfirm', htmlspecialchars(ts('Are you sure you want to revert all changes?', ['escape' => 'js'])));
 
-    CRM_Utils_System::appendBreadCrumb(array(array(
+    CRM_Utils_System::appendBreadCrumb([[
       'url' => CRM_Utils_System::url('civicrm/admin/setting/preferences/display', 'reset=1'),
       'title' => ts('Display Preferences'),
-    )));
+    ]]);
 
     return parent::run();
   }
@@ -155,7 +155,7 @@ public function save($params) {
    * @return array
    */
   private function getCKPlugins() {
-    $plugins = array();
+    $plugins = [];
     $pluginDir = Civi::paths()->getPath('[civicrm.root]/bower_components/ckeditor/plugins');
 
     foreach (glob($pluginDir . '/*', GLOB_ONLYDIR) as $dir) {
@@ -163,11 +163,11 @@ private function getCKPlugins() {
       $name = substr($dir, strrpos($dir, '/') + 1);
       $dir = CRM_Utils_file::addTrailingSlash($dir, '/');
       if (is_file($dir . 'plugin.js')) {
-        $plugins[$name] = array(
+        $plugins[$name] = [
           'id' => $name,
           'text' => ucfirst($name),
           'icon' => NULL,
-        );
+        ];
         if (is_dir($dir . "icons")) {
           if (is_file($dir . "icons/$name.png")) {
             $plugins[$name]['icon'] = "bower_components/ckeditor/plugins/$name/icons/$name.png";
@@ -190,7 +190,7 @@ private function getCKPlugins() {
    * @return array
    */
   private function getCKSkins() {
-    $skins = array();
+    $skins = [];
     $skinDir = Civi::paths()->getPath('[civicrm.root]/bower_components/ckeditor/skins');
     foreach (glob($skinDir . '/*', GLOB_ONLYDIR) as $dir) {
       $dir = rtrim(str_replace('\\', '/', $dir), '/');
@@ -203,7 +203,7 @@ private function getCKSkins() {
    * @return array
    */
   private function getConfigSettings() {
-    $matches = $result = array();
+    $matches = $result = [];
     $file = self::getConfigFile($this->preset) ?: self::getConfigFile('default');
     $result['skin'] = 'moono';
     if ($file) {
@@ -222,7 +222,7 @@ private function getConfigSettings() {
    * @return array|null|string
    */
   public static function getConfigUrl($preset = NULL) {
-    $items = array();
+    $items = [];
     $presets = CRM_Core_OptionGroup::values('wysiwyg_presets', FALSE, FALSE, FALSE, NULL, 'name');
     foreach ($presets as $key => $name) {
       if (self::getConfigFile($name)) {
diff --git a/CRM/Admin/Page/ContactType.php b/CRM/Admin/Page/ContactType.php
index b8355ec702d7..1cfc16a5add9 100644
--- a/CRM/Admin/Page/ContactType.php
+++ b/CRM/Admin/Page/ContactType.php
@@ -63,30 +63,30 @@ public function getBAOName() {
    */
   public function &links() {
     if (!(self::$_links)) {
-      self::$_links = array(
-        CRM_Core_Action::UPDATE => array(
+      self::$_links = [
+        CRM_Core_Action::UPDATE => [
           'name' => ts('Edit'),
           'url' => 'civicrm/admin/options/subtype',
           'qs' => 'action=update&id=%%id%%&reset=1',
           'title' => ts('Edit Contact Type'),
-        ),
-        CRM_Core_Action::DISABLE => array(
+        ],
+        CRM_Core_Action::DISABLE => [
           'name' => ts('Disable'),
           'ref' => 'crm-enable-disable',
           'title' => ts('Disable Contact Type'),
-        ),
-        CRM_Core_Action::ENABLE => array(
+        ],
+        CRM_Core_Action::ENABLE => [
           'name' => ts('Enable'),
           'ref' => 'crm-enable-disable',
           'title' => ts('Enable Contact Type'),
-        ),
-        CRM_Core_Action::DELETE => array(
+        ],
+        CRM_Core_Action::DELETE => [
           'name' => ts('Delete'),
           'url' => 'civicrm/admin/options/subtype',
           'qs' => 'action=delete&id=%%id%%',
           'title' => ts('Delete Contact Type'),
-        ),
-      );
+        ],
+      ];
     }
     return self::$_links;
   }
@@ -124,7 +124,7 @@ public function browse() {
         }
       }
       $rows[$key]['action'] = CRM_Core_Action::formLink(self::links(), $mask,
-        array('id' => $value['id']),
+        ['id' => $value['id']],
         ts('more'),
         FALSE,
         'contactType.manage.action',
diff --git a/CRM/Admin/Page/EventTemplate.php b/CRM/Admin/Page/EventTemplate.php
index 600702cba0cd..6c6ca7804fec 100644
--- a/CRM/Admin/Page/EventTemplate.php
+++ b/CRM/Admin/Page/EventTemplate.php
@@ -62,20 +62,20 @@ public function getBAOName() {
   public function &links() {
     if (!(self::$_links)) {
       // helper variable for nicer formatting
-      self::$_links = array(
-        CRM_Core_Action::UPDATE => array(
+      self::$_links = [
+        CRM_Core_Action::UPDATE => [
           'name' => ts('Edit'),
           'url' => 'civicrm/event/manage/settings',
           'qs' => 'action=update&id=%%id%%&reset=1',
           'title' => ts('Edit Event Template'),
-        ),
-        CRM_Core_Action::DELETE => array(
+        ],
+        CRM_Core_Action::DELETE => [
           'name' => ts('Delete'),
           'url' => 'civicrm/event/manage',
           'qs' => 'action=delete&id=%%id%%',
           'title' => ts('Delete Event Template'),
-        ),
-      );
+        ],
+      ];
     }
 
     return self::$_links;
@@ -86,7 +86,7 @@ public function &links() {
    */
   public function browse() {
     //get all event templates.
-    $allEventTemplates = array();
+    $allEventTemplates = [];
 
     $eventTemplate = new CRM_Event_DAO_Event();
 
@@ -120,7 +120,7 @@ public function browse() {
 
       //add action links.
       $allEventTemplates[$eventTemplate->id]['action'] = CRM_Core_Action::formLink(self::links(), $action,
-        array('id' => $eventTemplate->id),
+        ['id' => $eventTemplate->id],
         ts('more'),
         FALSE,
         'eventTemplate.manage.action',
diff --git a/CRM/Admin/Page/Extensions.php b/CRM/Admin/Page/Extensions.php
index 97da3d1755a3..9250536e5d9e 100644
--- a/CRM/Admin/Page/Extensions.php
+++ b/CRM/Admin/Page/Extensions.php
@@ -76,39 +76,39 @@ public function getBAOName() {
    */
   public function &links() {
     if (!(self::$_links)) {
-      self::$_links = array(
-        CRM_Core_Action::ADD => array(
+      self::$_links = [
+        CRM_Core_Action::ADD => [
           'name' => ts('Install'),
           'url' => 'civicrm/admin/extensions',
           'qs' => 'action=add&id=%%id%%&key=%%key%%',
           'title' => ts('Install'),
-        ),
-        CRM_Core_Action::ENABLE => array(
+        ],
+        CRM_Core_Action::ENABLE => [
           'name' => ts('Enable'),
           'url' => 'civicrm/admin/extensions',
           'qs' => 'action=enable&id=%%id%%&key=%%key%%',
           'ref' => 'enable-action',
           'title' => ts('Enable'),
-        ),
-        CRM_Core_Action::DISABLE => array(
+        ],
+        CRM_Core_Action::DISABLE => [
           'name' => ts('Disable'),
           'url' => 'civicrm/admin/extensions',
           'qs' => 'action=disable&id=%%id%%&key=%%key%%',
           'title' => ts('Disable'),
-        ),
-        CRM_Core_Action::DELETE => array(
+        ],
+        CRM_Core_Action::DELETE => [
           'name' => ts('Uninstall'),
           'url' => 'civicrm/admin/extensions',
           'qs' => 'action=delete&id=%%id%%&key=%%key%%',
           'title' => ts('Uninstall Extension'),
-        ),
-        CRM_Core_Action::UPDATE => array(
+        ],
+        CRM_Core_Action::UPDATE => [
           'name' => ts('Download'),
           'url' => 'civicrm/admin/extensions',
           'qs' => 'action=update&id=%%id%%&key=%%key%%',
           'title' => ts('Download Extension'),
-        ),
-      );
+        ],
+      ];
     }
     return self::$_links;
   }
@@ -160,7 +160,7 @@ public function formatLocalExtensionRows() {
     $mapper = CRM_Extension_System::singleton()->getMapper();
     $manager = CRM_Extension_System::singleton()->getManager();
 
-    $localExtensionRows = array(); // array($pseudo_id => extended_CRM_Extension_Info)
+    $localExtensionRows = []; // array($pseudo_id => extended_CRM_Extension_Info)
     $keys = array_keys($manager->getStatuses());
     sort($keys);
     foreach ($keys as $key) {
@@ -168,7 +168,7 @@ public function formatLocalExtensionRows() {
         $obj = $mapper->keyToInfo($key);
       }
       catch (CRM_Extension_Exception $ex) {
-        CRM_Core_Session::setStatus(ts('Failed to read extension (%1). Please refresh the extension list.', array(1 => $key)));
+        CRM_Core_Session::setStatus(ts('Failed to read extension (%1). Please refresh the extension list.', [1 => $key]));
         continue;
       }
 
@@ -202,10 +202,10 @@ public function formatLocalExtensionRows() {
       // then $action += CRM_Core_Action::UPDATE
       $row['action'] = CRM_Core_Action::formLink(self::links(),
         $action,
-        array(
+        [
           'id' => $row['id'],
           'key' => $obj->key,
-        ),
+        ],
         ts('more'),
         FALSE,
         'extension.local.action',
@@ -232,12 +232,12 @@ public function formatRemoteExtensionRows($localExtensionRows) {
       $remoteExtensions = CRM_Extension_System::singleton()->getBrowser()->getExtensions();
     }
     catch (CRM_Extension_Exception $e) {
-      $remoteExtensions = array();
+      $remoteExtensions = [];
       CRM_Core_Session::setStatus($e->getMessage(), ts('Extension download error'), 'error');
     }
 
     // build list of available downloads
-    $remoteExtensionRows = array();
+    $remoteExtensionRows = [];
     $compat = CRM_Extension_System::getCompatibilityInfo();
 
     foreach ($remoteExtensions as $info) {
@@ -249,10 +249,10 @@ public function formatRemoteExtensionRows($localExtensionRows) {
       $action = CRM_Core_Action::UPDATE;
       $row['action'] = CRM_Core_Action::formLink(self::links(),
         $action,
-        array(
+        [
           'id' => $row['id'],
           'key' => $row['key'],
-        ),
+        ],
         ts('more'),
         FALSE,
         'extension.remote.action',
diff --git a/CRM/Admin/Page/ExtensionsUpgrade.php b/CRM/Admin/Page/ExtensionsUpgrade.php
index b0a2a8e7ec15..fceb66ebb365 100644
--- a/CRM/Admin/Page/ExtensionsUpgrade.php
+++ b/CRM/Admin/Page/ExtensionsUpgrade.php
@@ -15,13 +15,13 @@ class CRM_Admin_Page_ExtensionsUpgrade extends CRM_Core_Page {
    */
   public function run() {
     $queue = CRM_Extension_Upgrades::createQueue();
-    $runner = new CRM_Queue_Runner(array(
+    $runner = new CRM_Queue_Runner([
       'title' => ts('Database Upgrades'),
       'queue' => $queue,
       'errorMode' => CRM_Queue_Runner::ERROR_ABORT,
-      'onEnd' => array('CRM_Admin_Page_ExtensionsUpgrade', 'onEnd'),
+      'onEnd' => ['CRM_Admin_Page_ExtensionsUpgrade', 'onEnd'],
       'onEndUrl' => !empty($_GET['destination']) ? $_GET['destination'] : CRM_Utils_System::url(self::END_URL, self::END_PARAMS),
-    ));
+    ]);
 
     CRM_Core_Error::debug_log_message('CRM_Admin_Page_ExtensionsUpgrade: Start upgrades');
     $runner->runAllViaWeb(); // does not return
diff --git a/CRM/Admin/Page/LabelFormats.php b/CRM/Admin/Page/LabelFormats.php
index 059a6b37351f..c90b5eba3d17 100644
--- a/CRM/Admin/Page/LabelFormats.php
+++ b/CRM/Admin/Page/LabelFormats.php
@@ -65,26 +65,26 @@ public function getBAOName() {
   public function &links() {
     if (!(self::$_links)) {
       // helper variable for nicer formatting
-      self::$_links = array(
-        CRM_Core_Action::UPDATE => array(
+      self::$_links = [
+        CRM_Core_Action::UPDATE => [
           'name' => ts('Edit'),
           'url' => 'civicrm/admin/labelFormats',
           'qs' => 'action=update&id=%%id%%&group=%%group%%&reset=1',
           'title' => ts('Edit Label Format'),
-        ),
-        CRM_Core_Action::COPY => array(
+        ],
+        CRM_Core_Action::COPY => [
           'name' => ts('Copy'),
           'url' => 'civicrm/admin/labelFormats',
           'qs' => 'action=copy&id=%%id%%&group=%%group%%&reset=1',
           'title' => ts('Copy Label Format'),
-        ),
-        CRM_Core_Action::DELETE => array(
+        ],
+        CRM_Core_Action::DELETE => [
           'name' => ts('Delete'),
           'url' => 'civicrm/admin/labelFormats',
           'qs' => 'action=delete&id=%%id%%&group=%%group%%&reset=1',
           'title' => ts('Delete Label Format'),
-        ),
-      );
+        ],
+      ];
     }
 
     return self::$_links;
@@ -141,7 +141,7 @@ public function browse($action = NULL) {
 
       $format['groupName'] = ts('Mailing Label');
       $format['action'] = CRM_Core_Action::formLink(self::links(), $action,
-        array('id' => $format['id'], 'group' => 'label_format'),
+        ['id' => $format['id'], 'group' => 'label_format'],
         ts('more'),
         FALSE,
         'labelFormat.manage.action',
diff --git a/CRM/Admin/Page/LocationType.php b/CRM/Admin/Page/LocationType.php
index 6ae5a62f4910..16b2b25df69f 100644
--- a/CRM/Admin/Page/LocationType.php
+++ b/CRM/Admin/Page/LocationType.php
@@ -63,30 +63,30 @@ public function getBAOName() {
    */
   public function &links() {
     if (!(self::$_links)) {
-      self::$_links = array(
-        CRM_Core_Action::UPDATE => array(
+      self::$_links = [
+        CRM_Core_Action::UPDATE => [
           'name' => ts('Edit'),
           'url' => 'civicrm/admin/locationType',
           'qs' => 'action=update&id=%%id%%&reset=1',
           'title' => ts('Edit Location Type'),
-        ),
-        CRM_Core_Action::DISABLE => array(
+        ],
+        CRM_Core_Action::DISABLE => [
           'name' => ts('Disable'),
           'ref' => 'crm-enable-disable',
           'title' => ts('Disable Location Type'),
-        ),
-        CRM_Core_Action::ENABLE => array(
+        ],
+        CRM_Core_Action::ENABLE => [
           'name' => ts('Enable'),
           'ref' => 'crm-enable-disable',
           'title' => ts('Enable Location Type'),
-        ),
-        CRM_Core_Action::DELETE => array(
+        ],
+        CRM_Core_Action::DELETE => [
           'name' => ts('Delete'),
           'url' => 'civicrm/admin/locationType',
           'qs' => 'action=delete&id=%%id%%',
           'title' => ts('Delete Location Type'),
-        ),
-      );
+        ],
+      ];
     }
     return self::$_links;
   }
diff --git a/CRM/Admin/Page/MailSettings.php b/CRM/Admin/Page/MailSettings.php
index 400288ef80b9..94b984a5e907 100644
--- a/CRM/Admin/Page/MailSettings.php
+++ b/CRM/Admin/Page/MailSettings.php
@@ -64,20 +64,20 @@ public function getBAOName() {
   public function &links() {
     if (!(self::$_links)) {
       // helper variable for nicer formatting
-      self::$_links = array(
-        CRM_Core_Action::UPDATE => array(
+      self::$_links = [
+        CRM_Core_Action::UPDATE => [
           'name' => ts('Edit'),
           'url' => 'civicrm/admin/mailSettings',
           'qs' => 'action=update&id=%%id%%&reset=1',
           'title' => ts('Edit Mail Settings'),
-        ),
-        CRM_Core_Action::DELETE => array(
+        ],
+        CRM_Core_Action::DELETE => [
           'name' => ts('Delete'),
           'url' => 'civicrm/admin/mailSettings',
           'qs' => 'action=delete&id=%%id%%',
           'title' => ts('Delete Mail Settings'),
-        ),
-      );
+        ],
+      ];
     }
 
     return self::$_links;
@@ -88,7 +88,7 @@ public function &links() {
    */
   public function browse() {
     //get all mail settings.
-    $allMailSettings = array();
+    $allMailSettings = [];
     $mailSetting = new CRM_Core_DAO_MailSettings();
 
     $allProtocols = CRM_Core_PseudoConstant::get('CRM_Core_DAO_MailSettings', 'protocol');
@@ -113,7 +113,7 @@ public function browse() {
 
       //add action links.
       $allMailSettings[$mailSetting->id]['action'] = CRM_Core_Action::formLink(self::links(), $action,
-        array('id' => $mailSetting->id),
+        ['id' => $mailSetting->id],
         ts('more'),
         FALSE,
         'mailSetting.manage.action',
diff --git a/CRM/Admin/Page/Mapping.php b/CRM/Admin/Page/Mapping.php
index d5b171749bef..33744306f0b5 100644
--- a/CRM/Admin/Page/Mapping.php
+++ b/CRM/Admin/Page/Mapping.php
@@ -65,20 +65,20 @@ public function &links() {
     if (!(self::$_links)) {
       // helper variable for nicer formatting
       $deleteExtra = ts('Are you sure you want to delete this mapping?') . ' ' . ts('This operation cannot be undone.');
-      self::$_links = array(
-        CRM_Core_Action::UPDATE => array(
+      self::$_links = [
+        CRM_Core_Action::UPDATE => [
           'name' => ts('Edit'),
           'url' => 'civicrm/admin/mapping',
           'qs' => 'action=update&id=%%id%%&reset=1',
           'title' => ts('Edit Mapping'),
-        ),
-        CRM_Core_Action::DELETE => array(
+        ],
+        CRM_Core_Action::DELETE => [
           'name' => ts('Delete'),
           'url' => 'civicrm/admin/mapping',
           'qs' => 'action=delete&id=%%id%%',
           'title' => ts('Delete Mapping'),
-        ),
-      );
+        ],
+      ];
     }
     return self::$_links;
   }
diff --git a/CRM/Admin/Page/MessageTemplates.php b/CRM/Admin/Page/MessageTemplates.php
index 43a7ba614536..ab21c4da1786 100644
--- a/CRM/Admin/Page/MessageTemplates.php
+++ b/CRM/Admin/Page/MessageTemplates.php
@@ -44,7 +44,7 @@ class CRM_Admin_Page_MessageTemplates extends CRM_Core_Page_Basic {
   static $_links = NULL;
 
   // ids of templates which diverted from the default ones and can be reverted
-  protected $_revertible = array();
+  protected $_revertible = [];
 
   // set to the id that we’re reverting at the given moment (if we are)
   protected $_revertedId;
@@ -93,44 +93,44 @@ public function getBAOName() {
    */
   public function &links() {
     if (!(self::$_links)) {
-      $confirm = ts('Are you sure you want to revert this template to the default for this workflow? You will lose any customizations you have made.', array('escape' => 'js')) . '\n\n' . ts('We recommend that you save a copy of the your customized Text and HTML message content to a text file before reverting so you can combine your changes with the system default messages as needed.', array('escape' => 'js'));
-      self::$_links = array(
-        CRM_Core_Action::UPDATE => array(
+      $confirm = ts('Are you sure you want to revert this template to the default for this workflow? You will lose any customizations you have made.', ['escape' => 'js']) . '\n\n' . ts('We recommend that you save a copy of the your customized Text and HTML message content to a text file before reverting so you can combine your changes with the system default messages as needed.', ['escape' => 'js']);
+      self::$_links = [
+        CRM_Core_Action::UPDATE => [
           'name' => ts('Edit'),
           'url' => 'civicrm/admin/messageTemplates/add',
           'qs' => 'action=update&id=%%id%%&reset=1',
           'title' => ts('Edit this message template'),
-        ),
-        CRM_Core_Action::DISABLE => array(
+        ],
+        CRM_Core_Action::DISABLE => [
           'name' => ts('Disable'),
           'ref' => 'crm-enable-disable',
           'title' => ts('Disable this message template'),
-        ),
-        CRM_Core_Action::ENABLE => array(
+        ],
+        CRM_Core_Action::ENABLE => [
           'name' => ts('Enable'),
           'ref' => 'crm-enable-disable',
           'title' => ts('Enable this message template'),
-        ),
-        CRM_Core_Action::DELETE => array(
+        ],
+        CRM_Core_Action::DELETE => [
           'name' => ts('Delete'),
           'url' => 'civicrm/admin/messageTemplates',
           'qs' => 'action=delete&id=%%id%%',
           'title' => ts('Delete this message template'),
-        ),
-        CRM_Core_Action::REVERT => array(
+        ],
+        CRM_Core_Action::REVERT => [
           'name' => ts('Revert to Default'),
           'extra' => "onclick = 'return confirm(\"$confirm\");'",
           'url' => 'civicrm/admin/messageTemplates',
           'qs' => 'action=revert&id=%%id%%&selectedChild=workflow',
           'title' => ts('Revert this workflow message template to the system default'),
-        ),
-        CRM_Core_Action::VIEW => array(
+        ],
+        CRM_Core_Action::VIEW => [
           'name' => ts('View Default'),
           'url' => 'civicrm/admin/messageTemplates',
           'qs' => 'action=view&id=%%orig_id%%&reset=1',
           'title' => ts('View the system default for this workflow message template'),
-        ),
-      );
+        ],
+      ];
     }
     return self::$_links;
   }
@@ -161,10 +161,10 @@ public function action(&$object, $action, &$values, &$links, $permission, $force
       }
 
       // rebuild the action links HTML, as we need to handle %%orig_id%% for revertible templates
-      $values['action'] = CRM_Core_Action::formLink($links, $action, array(
+      $values['action'] = CRM_Core_Action::formLink($links, $action, [
           'id' => $object->id,
           'orig_id' => CRM_Utils_Array::value($object->id, $this->_revertible),
-        ),
+        ],
         ts('more'),
         FALSE,
         'messageTemplate.manage.action',
@@ -255,13 +255,13 @@ public function browse() {
     $messageTemplate = new CRM_Core_BAO_MessageTemplate();
     $messageTemplate->orderBy('msg_title' . ' asc');
 
-    $userTemplates = array();
-    $workflowTemplates = array();
+    $userTemplates = [];
+    $workflowTemplates = [];
 
     // find all objects
     $messageTemplate->find();
     while ($messageTemplate->fetch()) {
-      $values[$messageTemplate->id] = array();
+      $values[$messageTemplate->id] = [];
       CRM_Core_DAO::storeValues($messageTemplate, $values[$messageTemplate->id]);
       // populate action links
       $this->action($messageTemplate, $action, $values[$messageTemplate->id], $links, CRM_Core_Permission::EDIT);
@@ -274,10 +274,10 @@ public function browse() {
       }
     }
 
-    $rows = array(
+    $rows = [
       'userTemplates' => $userTemplates,
       'workflowTemplates' => $workflowTemplates,
-    );
+    ];
 
     $this->assign('rows', $rows);
     $this->assign('canEditSystemTemplates', CRM_Core_Permission::check('edit system workflow message templates'));
diff --git a/CRM/Admin/Page/ParticipantStatusType.php b/CRM/Admin/Page/ParticipantStatusType.php
index 64422224a44b..7f0202c3a4a1 100644
--- a/CRM/Admin/Page/ParticipantStatusType.php
+++ b/CRM/Admin/Page/ParticipantStatusType.php
@@ -49,36 +49,36 @@ public function getBAOName() {
   public function &links() {
     static $links = NULL;
     if ($links === NULL) {
-      $links = array(
-        CRM_Core_Action::UPDATE => array(
+      $links = [
+        CRM_Core_Action::UPDATE => [
           'name' => ts('Edit'),
           'url' => 'civicrm/admin/participant_status',
           'qs' => 'action=update&id=%%id%%&reset=1',
           'title' => ts('Edit Status'),
-        ),
-        CRM_Core_Action::DELETE => array(
+        ],
+        CRM_Core_Action::DELETE => [
           'name' => ts('Delete'),
           'url' => 'civicrm/admin/participant_status',
           'qs' => 'action=delete&id=%%id%%',
           'title' => ts('Delete Status'),
-        ),
-        CRM_Core_Action::DISABLE => array(
+        ],
+        CRM_Core_Action::DISABLE => [
           'name' => ts('Disable'),
           'ref' => 'crm-enable-disable',
           'title' => ts('Disable Status'),
-        ),
-        CRM_Core_Action::ENABLE => array(
+        ],
+        CRM_Core_Action::ENABLE => [
           'name' => ts('Enable'),
           'ref' => 'crm-enable-disable',
           'title' => ts('Enable Status'),
-        ),
-      );
+        ],
+      ];
     }
     return $links;
   }
 
   public function browse() {
-    $statusTypes = array();
+    $statusTypes = [];
 
     $dao = new CRM_Event_DAO_ParticipantStatusType();
     $dao->orderBy('weight');
@@ -87,13 +87,13 @@ public function browse() {
     $visibilities = CRM_Core_PseudoConstant::visibility();
 
     // these statuses are reserved, but disabled by default - so should be disablable after being enabled
-    $disablable = array(
+    $disablable = [
       'On waitlist',
       'Awaiting approval',
       'Pending from waitlist',
       'Pending from approval',
       'Rejected',
-    );
+    ];
 
     while ($dao->fetch()) {
       CRM_Core_DAO::storeValues($dao, $statusTypes[$dao->id]);
@@ -108,7 +108,7 @@ public function browse() {
       $statusTypes[$dao->id]['action'] = CRM_Core_Action::formLink(
         self::links(),
         $action,
-        array('id' => $dao->id),
+        ['id' => $dao->id],
         ts('more'),
         FALSE,
         'participantStatusType.manage.action',
diff --git a/CRM/Admin/Page/PaymentProcessorType.php b/CRM/Admin/Page/PaymentProcessorType.php
index d750e1bb5420..212c60e42d41 100644
--- a/CRM/Admin/Page/PaymentProcessorType.php
+++ b/CRM/Admin/Page/PaymentProcessorType.php
@@ -61,30 +61,30 @@ public function getBAOName() {
    */
   public function &links() {
     if (!(self::$_links)) {
-      self::$_links = array(
-        CRM_Core_Action::UPDATE => array(
+      self::$_links = [
+        CRM_Core_Action::UPDATE => [
           'name' => ts('Edit'),
           'url' => 'civicrm/admin/paymentProcessorType',
           'qs' => 'action=update&id=%%id%%&reset=1',
           'title' => ts('Edit Payment ProcessorType'),
-        ),
-        CRM_Core_Action::DISABLE => array(
+        ],
+        CRM_Core_Action::DISABLE => [
           'name' => ts('Disable'),
           'ref' => 'crm-enable-disable',
           'title' => ts('Disable Payment ProcessorType'),
-        ),
-        CRM_Core_Action::ENABLE => array(
+        ],
+        CRM_Core_Action::ENABLE => [
           'name' => ts('Enable'),
           'ref' => 'crm-enable-disable',
           'title' => ts('Enable Payment ProcessorType'),
-        ),
-        CRM_Core_Action::DELETE => array(
+        ],
+        CRM_Core_Action::DELETE => [
           'name' => ts('Delete'),
           'url' => 'civicrm/admin/paymentProcessorType',
           'qs' => 'action=delete&id=%%id%%',
           'title' => ts('Delete Payment ProcessorType'),
-        ),
-      );
+        ],
+      ];
     }
     return self::$_links;
   }
diff --git a/CRM/Admin/Page/PdfFormats.php b/CRM/Admin/Page/PdfFormats.php
index c99cf4ad5cd8..ba7b0a2e48b0 100644
--- a/CRM/Admin/Page/PdfFormats.php
+++ b/CRM/Admin/Page/PdfFormats.php
@@ -65,20 +65,20 @@ public function getBAOName() {
   public function &links() {
     if (!(self::$_links)) {
       // helper variable for nicer formatting
-      self::$_links = array(
-        CRM_Core_Action::UPDATE => array(
+      self::$_links = [
+        CRM_Core_Action::UPDATE => [
           'name' => ts('Edit'),
           'url' => 'civicrm/admin/pdfFormats',
           'qs' => 'action=update&id=%%id%%&reset=1',
           'title' => ts('Edit PDF Page Format'),
-        ),
-        CRM_Core_Action::DELETE => array(
+        ],
+        CRM_Core_Action::DELETE => [
           'name' => ts('Delete'),
           'url' => 'civicrm/admin/pdfFormats',
           'qs' => 'action=delete&id=%%id%%',
           'title' => ts('Delete PDF Page Format'),
-        ),
-      );
+        ],
+      ];
     }
 
     return self::$_links;
@@ -131,7 +131,7 @@ public function browse($action = NULL) {
       $format['action'] = CRM_Core_Action::formLink(
         self::links(),
         $action,
-        array('id' => $format['id']),
+        ['id' => $format['id']],
         ts('more'),
         FALSE,
         'pdfFormat.manage.action',
diff --git a/CRM/Admin/Page/Persistent.php b/CRM/Admin/Page/Persistent.php
index ed4c07561ef2..4524da544492 100644
--- a/CRM/Admin/Page/Persistent.php
+++ b/CRM/Admin/Page/Persistent.php
@@ -54,14 +54,14 @@ public function &stringActionLinks() {
     // check if variable _actionsLinks is populated
     if (!isset(self::$_stringActionLinks)) {
 
-      self::$_stringActionLinks = array(
-        CRM_Core_Action::UPDATE => array(
+      self::$_stringActionLinks = [
+        CRM_Core_Action::UPDATE => [
           'name' => ts('Edit'),
           'url' => 'civicrm/admin/tplstrings/add',
           'qs' => 'reset=1&action=update&id=%%id%%',
           'title' => ts('Configure'),
-        ),
-      );
+        ],
+      ];
     }
     return self::$_stringActionLinks;
   }
@@ -73,14 +73,14 @@ public function &customizeActionLinks() {
     // check if variable _actionsLinks is populated
     if (!isset(self::$_customizeActionLinks)) {
 
-      self::$_customizeActionLinks = array(
-        CRM_Core_Action::UPDATE => array(
+      self::$_customizeActionLinks = [
+        CRM_Core_Action::UPDATE => [
           'name' => ts('Edit'),
           'url' => 'civicrm/admin/tplstrings/add',
           'qs' => 'reset=1&action=update&id=%%id%%&config=1',
           'title' => ts('Configure'),
-        ),
-      );
+        ],
+      ];
     }
     return self::$_customizeActionLinks;
   }
@@ -107,14 +107,14 @@ public function browse() {
 
     $daoResult = new CRM_Core_DAO_Persistent();
     $daoResult->find();
-    $schoolValues = array();
+    $schoolValues = [];
     while ($daoResult->fetch()) {
-      $values[$daoResult->id] = array();
+      $values[$daoResult->id] = [];
       CRM_Core_DAO::storeValues($daoResult, $values[$daoResult->id]);
       if ($daoResult->is_config == 1) {
         $values[$daoResult->id]['action'] = CRM_Core_Action::formLink(self::customizeActionLinks(),
           NULL,
-          array('id' => $daoResult->id),
+          ['id' => $daoResult->id],
           ts('more'),
           FALSE,
           'persistent.config.actions',
@@ -127,7 +127,7 @@ public function browse() {
       if ($daoResult->is_config == 0) {
         $values[$daoResult->id]['action'] = CRM_Core_Action::formLink(self::stringActionLinks(),
           NULL,
-          array('id' => $daoResult->id),
+          ['id' => $daoResult->id],
           ts('more'),
           FALSE,
           'persistent.row.actions',
@@ -137,10 +137,10 @@ public function browse() {
         $configStrings[$daoResult->id] = $values[$daoResult->id];
       }
     }
-    $rows = array(
+    $rows = [
       'configTemplates' => $configStrings,
       'customizeTemplates' => $configCustomization,
-    );
+    ];
     $this->assign('rows', $rows);
   }
 
diff --git a/CRM/Admin/Page/PreferencesDate.php b/CRM/Admin/Page/PreferencesDate.php
index c1e93463a757..f1a65a769859 100644
--- a/CRM/Admin/Page/PreferencesDate.php
+++ b/CRM/Admin/Page/PreferencesDate.php
@@ -63,14 +63,14 @@ public function getBAOName() {
    */
   public function &links() {
     if (!(self::$_links)) {
-      self::$_links = array(
-        CRM_Core_Action::UPDATE => array(
+      self::$_links = [
+        CRM_Core_Action::UPDATE => [
           'name' => ts('Edit'),
           'url' => 'civicrm/admin/setting/preferences/date',
           'qs' => 'action=update&id=%%id%%&reset=1',
           'title' => ts('Edit Date Type'),
-        ),
-      );
+        ],
+      ];
     }
     return self::$_links;
   }
diff --git a/CRM/Admin/Page/RelationshipType.php b/CRM/Admin/Page/RelationshipType.php
index a389b710069a..a93f8a70dab2 100644
--- a/CRM/Admin/Page/RelationshipType.php
+++ b/CRM/Admin/Page/RelationshipType.php
@@ -63,36 +63,36 @@ public function getBAOName() {
    */
   public function &links() {
     if (!(self::$_links)) {
-      self::$_links = array(
-        CRM_Core_Action::VIEW => array(
+      self::$_links = [
+        CRM_Core_Action::VIEW => [
           'name' => ts('View'),
           'url' => 'civicrm/admin/reltype',
           'qs' => 'action=view&id=%%id%%&reset=1',
           'title' => ts('View Relationship Type'),
-        ),
-        CRM_Core_Action::UPDATE => array(
+        ],
+        CRM_Core_Action::UPDATE => [
           'name' => ts('Edit'),
           'url' => 'civicrm/admin/reltype',
           'qs' => 'action=update&id=%%id%%&reset=1',
           'title' => ts('Edit Relationship Type'),
-        ),
-        CRM_Core_Action::DISABLE => array(
+        ],
+        CRM_Core_Action::DISABLE => [
           'name' => ts('Disable'),
           'ref' => 'crm-enable-disable',
           'title' => ts('Disable Relationship Type'),
-        ),
-        CRM_Core_Action::ENABLE => array(
+        ],
+        CRM_Core_Action::ENABLE => [
           'name' => ts('Enable'),
           'ref' => 'crm-enable-disable',
           'title' => ts('Enable Relationship Type'),
-        ),
-        CRM_Core_Action::DELETE => array(
+        ],
+        CRM_Core_Action::DELETE => [
           'name' => ts('Delete'),
           'url' => 'civicrm/admin/reltype',
           'qs' => 'action=delete&id=%%id%%',
           'title' => ts('Delete Reletionship Type'),
-        ),
-      );
+        ],
+      ];
     }
     return self::$_links;
   }
diff --git a/CRM/Admin/Page/ScheduleReminders.php b/CRM/Admin/Page/ScheduleReminders.php
index eea6c62e3a89..a4edd639585b 100644
--- a/CRM/Admin/Page/ScheduleReminders.php
+++ b/CRM/Admin/Page/ScheduleReminders.php
@@ -64,30 +64,30 @@ public function getBAOName() {
   public function &links() {
     if (!(self::$_links)) {
       // helper variable for nicer formatting
-      self::$_links = array(
-        CRM_Core_Action::UPDATE => array(
+      self::$_links = [
+        CRM_Core_Action::UPDATE => [
           'name' => ts('Edit'),
           'url' => 'civicrm/admin/scheduleReminders',
           'qs' => 'action=update&id=%%id%%&reset=1',
           'title' => ts('Edit Schedule Reminders'),
-        ),
-        CRM_Core_Action::ENABLE => array(
+        ],
+        CRM_Core_Action::ENABLE => [
           'name' => ts('Enable'),
           'ref' => 'crm-enable-disable',
           'title' => ts('Enable Label Format'),
-        ),
-        CRM_Core_Action::DISABLE => array(
+        ],
+        CRM_Core_Action::DISABLE => [
           'name' => ts('Disable'),
           'ref' => 'crm-enable-disable',
           'title' => ts('Disable Label Format'),
-        ),
-        CRM_Core_Action::DELETE => array(
+        ],
+        CRM_Core_Action::DELETE => [
           'name' => ts('Delete'),
           'url' => 'civicrm/admin/scheduleReminders',
           'qs' => 'action=delete&id=%%id%%',
           'title' => ts('Delete Schedule Reminders'),
-        ),
-      );
+        ],
+      ];
     }
 
     return self::$_links;
@@ -153,7 +153,7 @@ public function browse($action = NULL) {
         $format['action'] = CRM_Core_Action::formLink(
           self::links(),
           $action,
-          array('id' => $format['id']),
+          ['id' => $format['id']],
           ts('more'),
           FALSE,
           'actionSchedule.manage.action',
diff --git a/CRM/Badge/BAO/Badge.php b/CRM/Badge/BAO/Badge.php
index e3691a34f82f..7775cd4ae541 100644
--- a/CRM/Badge/BAO/Badge.php
+++ b/CRM/Badge/BAO/Badge.php
@@ -88,7 +88,7 @@ public function createLabels(&$participants, &$layoutInfo) {
    *   row with meta data
    */
   public static function formatLabel(&$row, &$layout) {
-    $formattedRow = array('labelFormat' => $layout['label_format_name']);
+    $formattedRow = ['labelFormat' => $layout['label_format_name']];
     $formattedRow['labelTitle'] = $layout['title'];
     $formattedRow['labelId'] = $layout['id'];
 
@@ -103,14 +103,14 @@ public static function formatLabel(&$row, &$layout) {
           }
         }
 
-        $formattedRow['token'][$key] = array(
+        $formattedRow['token'][$key] = [
           'value' => $value,
           'font_name' => $layout['data']['font_name'][$key],
           'font_size' => $layout['data']['font_size'][$key],
           'font_style' => $layout['data']['font_style'][$key],
           'text_alignment' => $layout['data']['text_alignment'][$key],
           'token' => $layout['data']['token'][$key],
-        );
+        ];
       }
     }
 
@@ -147,10 +147,10 @@ public static function formatLabel(&$row, &$layout) {
     }
 
     if (!empty($layout['data']['add_barcode'])) {
-      $formattedRow['barcode'] = array(
+      $formattedRow['barcode'] = [
         'alignment' => $layout['data']['barcode_alignment'],
         'type' => $layout['data']['barcode_type'],
-      );
+      ];
     }
 
     // finally assign all the row values, so that we can use it for barcode etc
@@ -230,13 +230,13 @@ public function labelCreator(&$formattedRow, $cellspacing = 0) {
       }
     }
 
-    $this->pdf->SetLineStyle(array(
+    $this->pdf->SetLineStyle([
       'width' => 0.1,
       'cap' => 'round',
       'join' => 'round',
       'dash' => '2,2',
-      'color' => array(0, 0, 200),
-    ));
+      'color' => [0, 0, 200],
+    ]);
 
     $rowCount = CRM_Badge_Form_Layout::FIELD_ROWCOUNT;
     for ($i = 1; $i <= $rowCount; $i++) {
@@ -304,7 +304,7 @@ public function labelCreator(&$formattedRow, $cellspacing = 0) {
             break;
         }
 
-        $style = array(
+        $style = [
           'position' => '',
           'align' => '',
           'stretch' => FALSE,
@@ -313,13 +313,13 @@ public function labelCreator(&$formattedRow, $cellspacing = 0) {
           'border' => FALSE,
           'hpadding' => 13.5,
           'vpadding' => 'auto',
-          'fgcolor' => array(0, 0, 0),
+          'fgcolor' => [0, 0, 0],
           'bgcolor' => FALSE,
           'text' => FALSE,
           'font' => 'helvetica',
           'fontsize' => 8,
           'stretchtext' => 0,
-        );
+        ];
 
         $this->pdf->write1DBarcode($data['current_value'], 'C128', $xAlign, $y + $this->pdf->height - 10, '70',
           12, 0.4, $style, 'B');
@@ -342,14 +342,14 @@ public function labelCreator(&$formattedRow, $cellspacing = 0) {
             break;
         }
 
-        $style = array(
+        $style = [
           'border' => FALSE,
           'hpadding' => 13.5,
           'vpadding' => 'auto',
-          'fgcolor' => array(0, 0, 0),
+          'fgcolor' => [0, 0, 0],
           'bgcolor' => FALSE,
           'position' => '',
-        );
+        ];
 
         $this->pdf->write2DBarcode($data['current_value'], 'QRCODE,H', $xAlign, $y + $this->pdf->height - 26, 30,
           30, $style, 'B');
@@ -400,7 +400,7 @@ public static function getImageProperties($img, $imgRes = 300, $w = NULL, $h = N
     $f = $imgRes / 25.4;
     $w = !empty($w) ? $w : $imgsize[0] / $f;
     $h = !empty($h) ? $h : $imgsize[1] / $f;
-    return array($w, $h);
+    return [$w, $h];
   }
 
   /**
@@ -415,7 +415,7 @@ public static function buildBadges(&$params, &$form) {
     $layoutInfo = CRM_Badge_BAO_Layout::buildLayout($params);
 
     // split/get actual field names from token and individual contact image URLs
-    $returnProperties = array();
+    $returnProperties = [];
     if (!empty($layoutInfo['data']['token'])) {
       foreach ($layoutInfo['data']['token'] as $index => $value) {
         $element = '';
@@ -445,7 +445,7 @@ public static function buildBadges(&$params, &$form) {
     }
 
     // add additional required fields for query execution
-    $additionalFields = array('participant_register_date', 'participant_id', 'event_id', 'contact_id', 'image_URL');
+    $additionalFields = ['participant_register_date', 'participant_id', 'event_id', 'contact_id', 'image_URL'];
     foreach ($additionalFields as $field) {
       $returnProperties[$field] = 1;
     }
@@ -479,10 +479,10 @@ public static function buildBadges(&$params, &$form) {
     $queryString = "$select $from $where $having $sortOrder";
 
     $dao = CRM_Core_DAO::executeQuery($queryString);
-    $rows = array();
+    $rows = [];
     while ($dao->fetch()) {
       $query->convertToPseudoNames($dao);
-      $rows[$dao->participant_id] = array();
+      $rows[$dao->participant_id] = [];
       foreach ($returnProperties as $key => $dontCare) {
         $value = isset($dao->$key) ? $dao->$key : NULL;
         // Format custom fields
diff --git a/CRM/Badge/BAO/Layout.php b/CRM/Badge/BAO/Layout.php
index c73b6be58783..fc60633e2372 100644
--- a/CRM/Badge/BAO/Layout.php
+++ b/CRM/Badge/BAO/Layout.php
@@ -141,7 +141,7 @@ public static function getList() {
     $printLabel = new CRM_Core_DAO_PrintLabel();
     $printLabel->find();
 
-    $labels = array();
+    $labels = [];
     while ($printLabel->fetch()) {
       $labels[$printLabel->id] = $printLabel->title;
     }
@@ -158,7 +158,7 @@ public static function getList() {
    *   array formatted array
    */
   public static function buildLayout(&$params) {
-    $layoutParams = array('id' => $params['badge_id']);
+    $layoutParams = ['id' => $params['badge_id']];
     CRM_Badge_BAO_Layout::retrieve($layoutParams, $layoutInfo);
 
     $formatProperties = CRM_Core_PseudoConstant::getKey('CRM_Core_DAO_PrintLabel', 'label_format_name', $layoutInfo['label_format_name']);
diff --git a/CRM/Badge/Form/Layout.php b/CRM/Badge/Form/Layout.php
index ec950bc0fae1..a34b5ebcc465 100644
--- a/CRM/Badge/Form/Layout.php
+++ b/CRM/Badge/Form/Layout.php
@@ -49,9 +49,9 @@ public function buildQuickForm() {
     $config = CRM_Core_Config::singleton();
     $resources = CRM_Core_Resources::singleton();
     $resources->addSetting(
-      array(
+      [
         'kcfinderPath' => $config->userFrameworkResourceURL . 'packages' . DIRECTORY_SEPARATOR,
-      )
+      ]
     );
     $resources->addScriptFile('civicrm', 'templates/CRM/Badge/Form/Layout.js', 1, 'html-header');
 
@@ -60,25 +60,25 @@ public function buildQuickForm() {
     $this->add('text', 'title', ts('Title'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_PrintLabel', 'title'), TRUE);
 
     $labelStyle = CRM_Core_BAO_LabelFormat::getList(TRUE, 'name_badge');
-    $this->add('select', 'label_format_name', ts('Label Format'), array('' => ts('- select -')) + $labelStyle, TRUE);
+    $this->add('select', 'label_format_name', ts('Label Format'), ['' => ts('- select -')] + $labelStyle, TRUE);
 
     $this->add('text', 'description', ts('Description'),
       CRM_Core_DAO::getAttribute('CRM_Core_DAO_PrintLabel', 'title'));
 
     // get the tokens
     $contactTokens = CRM_Core_SelectValues::contactTokens();
-    $eventTokens = array(
+    $eventTokens = [
       '{event.event_id}' => ts('Event ID'),
       '{event.title}' => ts('Event Title'),
       '{event.start_date}' => ts('Event Start Date'),
       '{event.end_date}' => ts('Event End Date'),
-    );
+    ];
     $participantTokens = CRM_Core_SelectValues::participantTokens();
 
     $tokens = array_merge($contactTokens, $eventTokens, $participantTokens);
     asort($tokens);
 
-    $tokens = array_merge(array('spacer' => ts('- spacer -')) + $tokens);
+    $tokens = array_merge(['spacer' => ts('- spacer -')] + $tokens);
 
     $fontSizes = CRM_Core_BAO_LabelFormat::getFontSizes();
     $fontStyles = CRM_Core_BAO_LabelFormat::getFontStyles();
@@ -89,7 +89,7 @@ public function buildQuickForm() {
 
     $rowCount = self::FIELD_ROWCOUNT;
     for ($i = 1; $i <= $rowCount; $i++) {
-      $this->add('select', "token[$i]", ts('Token'), array('' => ts('- skip -')) + $tokens);
+      $this->add('select', "token[$i]", ts('Token'), ['' => ts('- skip -')] + $tokens);
       $this->add('select', "font_name[$i]", ts('Font Name'), $fontNames);
       $this->add('select', "font_size[$i]", ts('Font Size'), $fontSizes);
       $this->add('select', "font_style[$i]", ts('Font Style'), $fontStyles);
@@ -103,20 +103,20 @@ public function buildQuickForm() {
     $this->add('select', "barcode_type", ts('Type'), $barcodeTypes);
     $this->add('select', "barcode_alignment", ts('Alignment'), $textAlignment);
 
-    $attributes = array('readonly' => TRUE);
+    $attributes = ['readonly' => TRUE];
     $this->add('text', 'image_1', ts('Image (top left)'),
       $attributes + CRM_Core_DAO::getAttribute('CRM_Core_DAO_PrintLabel', 'title'));
-    $this->add('text', 'width_image_1', ts('Width (mm)'), array('size' => 6));
-    $this->add('text', 'height_image_1', ts('Height (mm)'), array('size' => 6));
+    $this->add('text', 'width_image_1', ts('Width (mm)'), ['size' => 6]);
+    $this->add('text', 'height_image_1', ts('Height (mm)'), ['size' => 6]);
 
     $this->add('text', 'image_2', ts('Image (top right)'),
       $attributes + CRM_Core_DAO::getAttribute('CRM_Core_DAO_PrintLabel', 'title'));
-    $this->add('text', 'width_image_2', ts('Width (mm)'), array('size' => 6));
-    $this->add('text', 'height_image_2', ts('Height (mm)'), array('size' => 6));
+    $this->add('text', 'width_image_2', ts('Width (mm)'), ['size' => 6]);
+    $this->add('text', 'height_image_2', ts('Height (mm)'), ['size' => 6]);
 
     $this->add('checkbox', 'show_participant_image', ts('Use Participant Image?'));
-    $this->add('text', 'width_participant_image', ts('Width (mm)'), array('size' => 6));
-    $this->add('text', 'height_participant_image', ts('Height (mm)'), array('size' => 6));
+    $this->add('text', 'width_participant_image', ts('Width (mm)'), ['size' => 6]);
+    $this->add('text', 'height_participant_image', ts('Height (mm)'), ['size' => 6]);
     $this->add('select', "alignment_participant_image", ts('Image Alignment'), $imageAlignment);
 
     $this->add('checkbox', 'is_default', ts('Default?'));
@@ -130,21 +130,21 @@ public function buildQuickForm() {
     $this->addRule('height_participant_image', ts('Enter valid height'), 'positiveInteger');
     $this->addRule('width_participant_image', ts('Enter valid height'), 'positiveInteger');
 
-    $this->addButtons(array(
-        array(
+    $this->addButtons([
+        [
           'type' => 'next',
           'name' => ts('Save'),
           'isDefault' => TRUE,
-        ),
-        array(
+        ],
+        [
           'type' => 'refresh',
           'name' => ts('Save and Preview'),
-        ),
-        array(
+        ],
+        [
           'type' => 'cancel',
           'name' => ts('Cancel'),
-        ),
-      )
+        ],
+      ]
     );
   }
 
@@ -201,7 +201,7 @@ public function postProcess() {
     }
     else {
       CRM_Core_Session::setStatus(ts("The badge layout '%1' has been saved.",
-        array(1 => $params['title'])
+        [1 => $params['title']]
       ), ts('Saved'), 'success');
     }
   }
@@ -220,7 +220,7 @@ public function buildPreview(&$params) {
     }
 
     $this->_single = TRUE;
-    $this->_participantIds = array($participantID);
+    $this->_participantIds = [$participantID];
     $this->_componentClause = " civicrm_participant.id = $participantID ";
 
     CRM_Badge_BAO_Badge::buildBadges($params, $this);
diff --git a/CRM/Badge/Page/AJAX.php b/CRM/Badge/Page/AJAX.php
index 22fb6474d0b5..2918f14debda 100644
--- a/CRM/Badge/Page/AJAX.php
+++ b/CRM/Badge/Page/AJAX.php
@@ -35,7 +35,7 @@ class CRM_Badge_Page_AJAX {
   public static function getImageProp() {
     $img = $_GET['img'];
     list($w, $h) = CRM_Badge_BAO_Badge::getImageProperties($img);
-    CRM_Utils_JSON::output(array('width' => $w, 'height' => $h));
+    CRM_Utils_JSON::output(['width' => $w, 'height' => $h]);
   }
 
 }
diff --git a/CRM/Badge/Page/Layout.php b/CRM/Badge/Page/Layout.php
index eb9a8e666c26..da2e4ca1fa1c 100644
--- a/CRM/Badge/Page/Layout.php
+++ b/CRM/Badge/Page/Layout.php
@@ -61,30 +61,30 @@ public function getBAOName() {
    */
   public function &links() {
     if (!(self::$_links)) {
-      self::$_links = array(
-        CRM_Core_Action::UPDATE => array(
+      self::$_links = [
+        CRM_Core_Action::UPDATE => [
           'name' => ts('Edit'),
           'url' => 'civicrm/admin/badgelayout',
           'qs' => 'action=update&id=%%id%%&reset=1',
           'title' => ts('Edit Badge Layout'),
-        ),
-        CRM_Core_Action::DISABLE => array(
+        ],
+        CRM_Core_Action::DISABLE => [
           'name' => ts('Disable'),
           'ref' => 'crm-enable-disable',
           'title' => ts('Disable Badge Layout'),
-        ),
-        CRM_Core_Action::ENABLE => array(
+        ],
+        CRM_Core_Action::ENABLE => [
           'name' => ts('Enable'),
           'ref' => 'crm-enable-disable',
           'title' => ts('Enable Badge Layout'),
-        ),
-        CRM_Core_Action::DELETE => array(
+        ],
+        CRM_Core_Action::DELETE => [
           'name' => ts('Delete'),
           'url' => 'civicrm/admin/badgelayout',
           'qs' => 'action=delete&id=%%id%%',
           'title' => ts('Delete Badge Layout'),
-        ),
-      );
+        ],
+      ];
     }
     return self::$_links;
   }
diff --git a/CRM/Batch/BAO/Batch.php b/CRM/Batch/BAO/Batch.php
index 21d61188a182..fb8dd25c32f3 100644
--- a/CRM/Batch/BAO/Batch.php
+++ b/CRM/Batch/BAO/Batch.php
@@ -130,7 +130,7 @@ public static function getProfileId($batchTypeId) {
   public static function generateBatchName() {
     $sql = "SELECT max(id) FROM civicrm_batch";
     $batchNo = CRM_Core_DAO::singleValueQuery($sql) + 1;
-    return ts('Batch %1', array(1 => $batchNo)) . ': ' . date('Y-m-d');
+    return ts('Batch %1', [1 => $batchNo]) . ': ' . date('Y-m-d');
   }
 
   /**
@@ -170,12 +170,12 @@ public static function getBatchListSelector(&$params) {
     $batches = self::getBatchList($params);
 
     // get batch totals for open batches
-    $fetchTotals = array();
-    $batchStatus = CRM_Core_PseudoConstant::get('CRM_Batch_DAO_Batch', 'status_id', array('labelColumn' => 'name'));
-    $batchStatus = array(
+    $fetchTotals = [];
+    $batchStatus = CRM_Core_PseudoConstant::get('CRM_Batch_DAO_Batch', 'status_id', ['labelColumn' => 'name']);
+    $batchStatus = [
       array_search('Open', $batchStatus),
       array_search('Reopened', $batchStatus),
-    );
+    ];
     if ($params['context'] == 'financialBatch') {
       foreach ($batches as $id => $batch) {
         if (in_array($batch['status_id'], $batchStatus)) {
@@ -189,10 +189,10 @@ public static function getBatchListSelector(&$params) {
     $params['total'] = self::getBatchCount($params);
 
     // format params and add links
-    $batchList = array();
+    $batchList = [];
 
     foreach ($batches as $id => $value) {
-      $batch = array();
+      $batch = [];
       if ($params['context'] == 'financialBatch') {
         $batch['check'] = $value['check'];
       }
@@ -233,14 +233,14 @@ public static function getBatchList(&$params) {
     if (!empty($params['rowCount']) && is_numeric($params['rowCount'])
       && is_numeric($params['offset']) && $params['rowCount'] > 0
     ) {
-      $apiParams['options'] = array('offset' => $params['offset'], 'limit' => $params['rowCount']);
+      $apiParams['options'] = ['offset' => $params['offset'], 'limit' => $params['rowCount']];
     }
     $apiParams['options']['sort'] = 'id DESC';
     if (!empty($params['sort'])) {
       $apiParams['options']['sort'] = CRM_Utils_Type::escape($params['sort'], 'String');
     }
 
-    $return = array(
+    $return = [
       "id",
       "name",
       "title",
@@ -257,7 +257,7 @@ public static function getBatchList(&$params) {
       "payment_instrument_id",
       "created_id.sort_name",
       "created_id",
-    );
+    ];
     $apiParams['return'] = $return;
     $batches = civicrm_api3('Batch', 'get', $apiParams);
     $obj = new CRM_Batch_BAO_Batch();
@@ -270,16 +270,16 @@ public static function getBatchList(&$params) {
 
     $batchTypes = CRM_Core_PseudoConstant::get('CRM_Batch_DAO_Batch', 'type_id');
     $batchStatus = CRM_Core_PseudoConstant::get('CRM_Batch_DAO_Batch', 'status_id');
-    $batchStatusByName = CRM_Core_PseudoConstant::get('CRM_Batch_DAO_Batch', 'status_id', array('labelColumn' => 'name'));
+    $batchStatusByName = CRM_Core_PseudoConstant::get('CRM_Batch_DAO_Batch', 'status_id', ['labelColumn' => 'name']);
     $paymentInstrument = CRM_Contribute_PseudoConstant::paymentInstrument();
 
-    $results = array();
+    $results = [];
     foreach ($batches['values'] as $values) {
       $newLinks = $links;
       $action = array_sum(array_keys($newLinks));
 
       if ($values['status_id'] == array_search('Closed', $batchStatusByName) && $params['context'] != 'financialBatch') {
-        $newLinks = array();
+        $newLinks = [];
       }
       elseif ($params['context'] == 'financialBatch') {
         $values['check'] = " $values['id'], 'status' => $values['status_id']);
+      $tokens = ['id' => $values['id'], 'status' => $values['status_id']];
       if ($values['status_id'] == array_search('Exported', $batchStatusByName)) {
         $aid = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Export Accounting Batch');
-        $activityParams = array('source_record_id' => $values['id'], 'activity_type_id' => $aid);
+        $activityParams = ['source_record_id' => $values['id'], 'activity_type_id' => $aid];
         $exportActivity = CRM_Activity_BAO_Activity::retrieve($activityParams, $val);
         $fid = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_EntityFile', $exportActivity->id, 'file_id', 'entity_id');
         $fileHash = CRM_Core_BAO_File::generateFileHash($exportActivity->id, $fid);
-        $tokens = array_merge(array('eid' => $exportActivity->id, 'fid' => $fid, 'fcs' => $fileHash), $tokens);
+        $tokens = array_merge(['eid' => $exportActivity->id, 'fid' => $fid, 'fcs' => $fileHash], $tokens);
       }
       $values['action'] = CRM_Core_Action::formLink(
         $newLinks,
@@ -356,7 +356,7 @@ public static function getBatchList(&$params) {
           ON eb.entity_id = ft.id
         WHERE batch.id = %1
         GROUP BY batch.id
-      ", array(1 => array($values['id'], 'Positive')));
+      ", [1 => [$values['id'], 'Positive']]);
       $results[$values['id']] = $values;
     }
 
@@ -385,14 +385,14 @@ public static function getBatchCount(&$params) {
    * @return string
    */
   public static function whereClause($params) {
-    $clauses = array();
+    $clauses = [];
     // Exclude data-entry batches
-    $batchStatus = CRM_Core_PseudoConstant::get('CRM_Batch_DAO_Batch', 'status_id', array('labelColumn' => 'name'));
+    $batchStatus = CRM_Core_PseudoConstant::get('CRM_Batch_DAO_Batch', 'status_id', ['labelColumn' => 'name']);
     if (empty($params['status_id'])) {
-      $clauses['status_id'] = array('NOT IN' => array("Data Entry"));
+      $clauses['status_id'] = ['NOT IN' => ["Data Entry"]];
     }
 
-    $return = array(
+    $return = [
       "id",
       "name",
       "title",
@@ -409,7 +409,7 @@ public static function whereClause($params) {
       "payment_instrument_id",
       "created_id.sort_name",
       "created_id",
-    );
+    ];
     if (!CRM_Core_Permission::check("view all manual batches")) {
       if (CRM_Core_Permission::check("view own manual batches")) {
         $loggedInContactId = CRM_Core_Session::singleton()->get('userID');
@@ -424,11 +424,11 @@ public static function whereClause($params) {
         continue;
       }
       $value = CRM_Utils_Type::escape($params[$field], 'String', FALSE);
-      if (in_array($field, array('name', 'title', 'description', 'created_id.sort_name'))) {
-        $clauses[$field] = array('LIKE' => "%{$value}%");
+      if (in_array($field, ['name', 'title', 'description', 'created_id.sort_name'])) {
+        $clauses[$field] = ['LIKE' => "%{$value}%"];
       }
       elseif ($field == 'status_id' && $value == array_search('Open', $batchStatus)) {
-        $clauses['status_id'] = array('IN' => array("Open", 'Reopened'));
+        $clauses['status_id'] = ['IN' => ["Open", 'Reopened']];
       }
       else {
         $clauses[$field] = $value;
@@ -447,72 +447,72 @@ public static function whereClause($params) {
    */
   public function links($context = NULL) {
     if ($context == 'financialBatch') {
-      $links = array(
-        'transaction' => array(
+      $links = [
+        'transaction' => [
           'name' => ts('Transactions'),
           'url' => 'civicrm/batchtransaction',
           'qs' => 'reset=1&bid=%%id%%',
           'title' => ts('View/Add Transactions to Batch'),
-        ),
-        'edit' => array(
+        ],
+        'edit' => [
           'name' => ts('Edit'),
           'url' => 'civicrm/financial/batch',
           'qs' => 'reset=1&action=update&id=%%id%%&context=1',
           'title' => ts('Edit Batch'),
-        ),
-        'close' => array(
+        ],
+        'close' => [
           'name' => ts('Close'),
           'title' => ts('Close Batch'),
           'url' => '#',
           'extra' => 'rel="close"',
-        ),
-        'export' => array(
+        ],
+        'export' => [
           'name' => ts('Export'),
           'title' => ts('Export Batch'),
           'url' => '#',
           'extra' => 'rel="export"',
-        ),
-        'reopen' => array(
+        ],
+        'reopen' => [
           'name' => ts('Re-open'),
           'title' => ts('Re-open Batch'),
           'url' => '#',
           'extra' => 'rel="reopen"',
-        ),
-        'delete' => array(
+        ],
+        'delete' => [
           'name' => ts('Delete'),
           'title' => ts('Delete Batch'),
           'url' => '#',
           'extra' => 'rel="delete"',
-        ),
-        'download' => array(
+        ],
+        'download' => [
           'name' => ts('Download'),
           'url' => 'civicrm/file',
           'qs' => 'reset=1&id=%%fid%%&eid=%%eid%%&fcs=%%fcs%%',
           'title' => ts('Download Batch'),
-        ),
-      );
+        ],
+      ];
     }
     else {
-      $links = array(
-        CRM_Core_Action::COPY => array(
+      $links = [
+        CRM_Core_Action::COPY => [
           'name' => ts('Enter records'),
           'url' => 'civicrm/batch/entry',
           'qs' => 'id=%%id%%&reset=1',
           'title' => ts('Batch Data Entry'),
-        ),
-        CRM_Core_Action::UPDATE => array(
+        ],
+        CRM_Core_Action::UPDATE => [
           'name' => ts('Edit'),
           'url' => 'civicrm/batch',
           'qs' => 'action=update&id=%%id%%&reset=1',
           'title' => ts('Edit Batch'),
-        ),
-        CRM_Core_Action::DELETE => array(
+        ],
+        CRM_Core_Action::DELETE => [
           'name' => ts('Delete'),
           'url' => 'civicrm/batch',
           'qs' => 'action=delete&id=%%id%%',
           'title' => ts('Delete Batch'),
-        ),
-      );
+        ],
+      ];
     }
     return $links;
   }
@@ -531,7 +531,7 @@ public static function getBatches() {
       AND status_id != {$dataEntryStatusId}
       ORDER BY title";
 
-    $batches = array();
+    $batches = [];
     $dao = CRM_Core_DAO::executeQuery($query);
     while ($dao->fetch()) {
       $batches[$dao->id] = $dao->title;
@@ -548,7 +548,7 @@ public static function getBatches() {
    * @return array
    */
   public static function batchTotals($batchIds) {
-    $totals = array_fill_keys($batchIds, array('item_count' => 0, 'total' => 0));
+    $totals = array_fill_keys($batchIds, ['item_count' => 0, 'total' => 0]);
     if ($batchIds) {
       $sql = "SELECT eb.batch_id, COUNT(tx.id) AS item_count, SUM(tx.total_amount) AS total
       FROM civicrm_entity_batch eb
@@ -617,14 +617,14 @@ public static function exportFinancialBatch($batchIds, $exportFormat, $downloadF
     else {
       CRM_Core_Error::fatal("Could not locate exporter: $exporterClass");
     }
-    $export = array();
+    $export = [];
     $exporter->_isDownloadFile = $downloadFile;
     foreach ($batchIds as $batchId) {
       // export only batches whose status is set to Exported.
-      $result = civicrm_api3('Batch', 'getcount', array(
+      $result = civicrm_api3('Batch', 'getcount', [
         'id' => $batchId,
         'status_id' => "Exported",
-      ));
+      ]);
       if (!$result) {
         continue;
       }
@@ -639,7 +639,7 @@ public static function exportFinancialBatch($batchIds, $exportFormat, $downloadF
    * @param array $batchIds
    * @param $status
    */
-  public static function closeReOpen($batchIds = array(), $status) {
+  public static function closeReOpen($batchIds = [], $status) {
     $batchStatus = CRM_Core_PseudoConstant::get('CRM_Batch_DAO_Batch', 'status_id');
     $params['status_id'] = CRM_Utils_Array::key($status, $batchStatus);
     $session = CRM_Core_Session::singleton();
@@ -694,7 +694,7 @@ public static function getBatchFinancialItems($entityID, $returnValues, $notPres
 LEFT JOIN civicrm_contribution_soft ON civicrm_contribution_soft.contribution_id = civicrm_contribution.id
 ";
 
-    $searchFields = array(
+    $searchFields = [
       'sort_name',
       'financial_type_id',
       'contribution_page_id',
@@ -722,8 +722,8 @@ public static function getBatchFinancialItems($entityID, $returnValues, $notPres
       'contribution_status_id',
       'financial_trxn_card_type_id',
       'financial_trxn_pan_truncation',
-    );
-    $values = array();
+    ];
+    $values = [];
     foreach ($searchFields as $field) {
       if (isset($params[$field])) {
         $values[$field] = $params[$field];
@@ -812,7 +812,7 @@ public static function getBatchNames($batchIds) {
       FROM civicrm_batch
       WHERE id IN (' . $batchIds . ')';
 
-    $batches = array();
+    $batches = [];
     $dao = CRM_Core_DAO::executeQuery($query);
     while ($dao->fetch()) {
       $batches[$dao->id] = $dao->title;
@@ -833,7 +833,7 @@ public static function getBatchStatuses($batchIds) {
       FROM civicrm_batch
       WHERE id IN (' . $batchIds . ')';
 
-    $batches = array();
+    $batches = [];
     $dao = CRM_Core_DAO::executeQuery($query);
     while ($dao->fetch()) {
       $batches[$dao->id] = $dao->status_id;
diff --git a/CRM/Batch/BAO/EntityBatch.php b/CRM/Batch/BAO/EntityBatch.php
index fba50810ef59..426ce282622d 100644
--- a/CRM/Batch/BAO/EntityBatch.php
+++ b/CRM/Batch/BAO/EntityBatch.php
@@ -59,7 +59,7 @@ public static function create(&$params) {
    */
   public static function del($params) {
     if (!is_array($params)) {
-      $params = array('id' => $params);
+      $params = ['id' => $params];
     }
     $entityBatch = new CRM_Batch_DAO_EntityBatch();
     $entityId = CRM_Utils_Array::value('id', $params);
diff --git a/CRM/Batch/Form/Batch.php b/CRM/Batch/Form/Batch.php
index c1295fe1e6ac..4fb2753c19c5 100644
--- a/CRM/Batch/Form/Batch.php
+++ b/CRM/Batch/Form/Batch.php
@@ -71,7 +71,7 @@ public function buildQuickForm() {
    * Set default values for the form.
    */
   public function setDefaultValues() {
-    $defaults = array();
+    $defaults = [];
 
     if ($this->_action & CRM_Core_Action::ADD) {
       // Set batch name default.
diff --git a/CRM/Batch/Form/Entry.php b/CRM/Batch/Form/Entry.php
index 08b916d7dc41..ab4475da8196 100644
--- a/CRM/Batch/Form/Entry.php
+++ b/CRM/Batch/Form/Entry.php
@@ -49,7 +49,7 @@ class CRM_Batch_Form_Entry extends CRM_Core_Form {
   /**
    * Batch information.
    */
-  protected $_batchInfo = array();
+  protected $_batchInfo = [];
 
   /**
    * Store the profile id associated with the batch type.
@@ -70,7 +70,7 @@ class CRM_Batch_Form_Entry extends CRM_Core_Form {
   /**
    * Contact fields.
    */
-  protected $_contactFields = array();
+  protected $_contactFields = [];
 
   /**
    * Fields array of fields in the batch profile.
@@ -80,7 +80,7 @@ class CRM_Batch_Form_Entry extends CRM_Core_Form {
    * required
    * @var array
    */
-  public $_fields = array();
+  public $_fields = [];
 
   /**
    * Monetary fields that may be submitted.
@@ -100,7 +100,7 @@ public function preProcess() {
     $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'browse');
 
     if (empty($this->_batchInfo)) {
-      $params = array('id' => $this->_batchId);
+      $params = ['id' => $this->_batchId];
       CRM_Batch_BAO_Batch::retrieve($params, $this->_batchInfo);
 
       $this->assign('batchTotal', !empty($this->_batchInfo['total']) ? $this->_batchInfo['total'] : NULL);
@@ -111,9 +111,9 @@ public function preProcess() {
     }
     CRM_Core_Resources::singleton()
       ->addScriptFile('civicrm', 'templates/CRM/Batch/Form/Entry.js', 1, 'html-header')
-      ->addSetting(array('batch' => array('type_id' => $this->_batchInfo['type_id'])))
-      ->addSetting(array('setting' => array('monetaryThousandSeparator' => CRM_Core_Config::singleton()->monetaryThousandSeparator)))
-      ->addSetting(array('setting' => array('monetaryDecimalPoint' => CRM_Core_Config::singleton()->monetaryDecimalPoint)));
+      ->addSetting(['batch' => ['type_id' => $this->_batchInfo['type_id']]])
+      ->addSetting(['setting' => ['monetaryThousandSeparator' => CRM_Core_Config::singleton()->monetaryThousandSeparator]])
+      ->addSetting(['setting' => ['monetaryDecimalPoint' => CRM_Core_Config::singleton()->monetaryDecimalPoint]]);
 
   }
 
@@ -136,7 +136,7 @@ public function buildQuickForm() {
 
     $this->addElement('hidden', 'batch_id', $this->_batchId);
 
-    $batchTypes = CRM_Core_Pseudoconstant::get('CRM_Batch_DAO_Batch', 'type_id', array('flip' => 1), 'validate');
+    $batchTypes = CRM_Core_Pseudoconstant::get('CRM_Batch_DAO_Batch', 'type_id', ['flip' => 1], 'validate');
     // get the profile information
     if ($this->_batchInfo['type_id'] == $batchTypes['Contribution']) {
       CRM_Utils_System::setTitle(ts('Batch Data Entry for Contributions'));
@@ -148,7 +148,7 @@ public function buildQuickForm() {
     elseif ($this->_batchInfo['type_id'] == $batchTypes['Pledge Payment']) {
       CRM_Utils_System::setTitle(ts('Batch Data Entry for Pledge Payments'));
     }
-    $this->_fields = array();
+    $this->_fields = [];
     $this->_fields = CRM_Core_BAO_UFGroup::getFields($this->_profileId, FALSE, CRM_Core_Action::VIEW);
 
     // remove file type field and then limit fields
@@ -166,7 +166,7 @@ public function buildQuickForm() {
       }
     }
 
-    $this->addFormRule(array('CRM_Batch_Form_Entry', 'formRule'), $this);
+    $this->addFormRule(['CRM_Batch_Form_Entry', 'formRule'], $this);
 
     // add the force save button
     $forceSave = $this->getButtonName('upload', 'force');
@@ -176,52 +176,52 @@ public function buildQuickForm() {
       ts('Ignore Mismatch & Process the Batch?')
     );
 
-    $this->addButtons(array(
-        array(
+    $this->addButtons([
+        [
           'type' => 'upload',
           'name' => ts('Validate & Process the Batch'),
           'isDefault' => TRUE,
-        ),
-        array(
+        ],
+        [
           'type' => 'cancel',
           'name' => ts('Save & Continue Later'),
-        ),
-      )
+        ],
+      ]
     );
 
     $this->assign('rowCount', $this->_batchInfo['item_count'] + 1);
 
-    $preserveDefaultsArray = array(
+    $preserveDefaultsArray = [
       'first_name',
       'last_name',
       'middle_name',
       'organization_name',
       'household_name',
-    );
+    ];
 
-    $contactTypes = array('Contact', 'Individual', 'Household', 'Organization');
-    $contactReturnProperties = array();
+    $contactTypes = ['Contact', 'Individual', 'Household', 'Organization'];
+    $contactReturnProperties = [];
 
     for ($rowNumber = 1; $rowNumber <= $this->_batchInfo['item_count']; $rowNumber++) {
-      $this->addEntityRef("primary_contact_id[{$rowNumber}]", '', array(
+      $this->addEntityRef("primary_contact_id[{$rowNumber}]", '', [
           'create' => TRUE,
           'placeholder' => ts('- select -'),
-        ));
+        ]);
 
       // special field specific to membership batch udpate
       if ($this->_batchInfo['type_id'] == 2) {
-        $options = array(
+        $options = [
           1 => ts('Add Membership'),
           2 => ts('Renew Membership'),
-        );
+        ];
         $this->add('select', "member_option[$rowNumber]", '', $options);
       }
       if ($this->_batchInfo['type_id'] == $batchTypes['Pledge Payment']) {
-        $options = array('' => '-select-');
-        $optionTypes = array(
+        $options = ['' => '-select-'];
+        $optionTypes = [
           '1' => ts('Adjust Pledge Payment Schedule?'),
           '2' => ts('Adjust Total Pledge Amount?'),
-        );
+        ];
         $this->add('select', "option_type[$rowNumber]", NULL, $optionTypes);
         if (!empty($this->_batchId) && !empty($this->_batchInfo['data']) && !empty($rowNumber)) {
           $dataValues = json_decode($this->_batchInfo['data'], TRUE);
@@ -229,7 +229,7 @@ public function buildQuickForm() {
             $pledgeIDs = CRM_Pledge_BAO_Pledge::getContactPledges($dataValues['values']['primary_contact_id'][$rowNumber]);
             foreach ($pledgeIDs as $pledgeID) {
               $pledgePayment = CRM_Pledge_BAO_PledgePayment::getOldestPledgePayment($pledgeID);
-              $options += array($pledgeID => CRM_Utils_Date::customFormat($pledgePayment['schedule_date'], '%m/%d/%Y') . ', ' . $pledgePayment['amount'] . ' ' . $pledgePayment['currency']);
+              $options += [$pledgeID => CRM_Utils_Date::customFormat($pledgePayment['schedule_date'], '%m/%d/%Y') . ', ' . $pledgePayment['amount'] . ' ' . $pledgePayment['currency']];
             }
           }
         }
@@ -261,12 +261,12 @@ public function buildQuickForm() {
 
     $this->assign('fields', $this->_fields);
     CRM_Core_Resources::singleton()
-      ->addSetting(array(
-        'contact' => array(
+      ->addSetting([
+        'contact' => [
           'return' => implode(',', $contactReturnProperties),
           'fieldmap' => array_flip($contactReturnProperties),
-        ),
-      ));
+        ],
+      ]);
 
     // don't set the status message when form is submitted.
     $buttonName = $this->controller->getButtonName('submit');
@@ -290,24 +290,24 @@ public function buildQuickForm() {
    *   list of errors to be posted back to the form
    */
   public static function formRule($params, $files, $self) {
-    $errors = array();
-    $batchTypes = CRM_Core_Pseudoconstant::get('CRM_Batch_DAO_Batch', 'type_id', array('flip' => 1), 'validate');
-    $fields = array(
+    $errors = [];
+    $batchTypes = CRM_Core_Pseudoconstant::get('CRM_Batch_DAO_Batch', 'type_id', ['flip' => 1], 'validate');
+    $fields = [
       'total_amount' => ts('Amount'),
       'financial_type' => ts('Financial Type'),
       'payment_instrument' => ts('Payment Method'),
-    );
+    ];
 
     //CRM-16480 if contact is selected, validate financial type and amount field.
     foreach ($params['field'] as $key => $value) {
       if (isset($value['trxn_id'])) {
-        if (0 < CRM_Core_DAO::singleValueQuery('SELECT id FROM civicrm_contribution WHERE trxn_id = %1', array(1 => array($value['trxn_id'], 'String')))) {
+        if (0 < CRM_Core_DAO::singleValueQuery('SELECT id FROM civicrm_contribution WHERE trxn_id = %1', [1 => [$value['trxn_id'], 'String']])) {
           $errors["field[$key][trxn_id]"] = ts('Transaction ID must be unique within the database');
         }
       }
       foreach ($fields as $field => $label) {
         if (!empty($params['primary_contact_id'][$key]) && empty($value[$field])) {
-          $errors["field[$key][$field]"] = ts('%1 is a required field.', array(1 => $label));
+          $errors["field[$key][$field]"] = ts('%1 is a required field.', [1 => $label]);
         }
       }
     }
@@ -385,11 +385,11 @@ public function setDefaultValues() {
       $currentDate = date('Y-m-d H-i-s');
 
       $completeStatus = CRM_Contribute_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed');
-      $specialFields = array(
+      $specialFields = [
         'join_date' => date('Y-m-d'),
         'receive_date' => $currentDate,
         'contribution_status_id' => $completeStatus,
-      );
+      ];
 
       for ($rowNumber = 1; $rowNumber <= $this->_batchInfo['item_count']; $rowNumber++) {
         foreach ($specialFields as $key => $value) {
@@ -415,8 +415,8 @@ public function postProcess() {
     $params['actualBatchTotal'] = 0;
 
     // get the profile information
-    $batchTypes = CRM_Core_PseudoConstant::get('CRM_Batch_DAO_Batch', 'type_id', array('flip' => 1), 'validate');
-    if (in_array($this->_batchInfo['type_id'], array($batchTypes['Pledge Payment'], $batchTypes['Contribution']))) {
+    $batchTypes = CRM_Core_PseudoConstant::get('CRM_Batch_DAO_Batch', 'type_id', ['flip' => 1], 'validate');
+    if (in_array($this->_batchInfo['type_id'], [$batchTypes['Pledge Payment'], $batchTypes['Contribution']])) {
       $this->processContribution($params);
     }
     elseif ($this->_batchInfo['type_id'] == $batchTypes['Membership']) {
@@ -424,12 +424,12 @@ public function postProcess() {
     }
 
     // update batch to close status
-    $paramValues = array(
+    $paramValues = [
       'id' => $this->_batchId,
       // close status
       'status_id' => CRM_Core_PseudoConstant::getKey('CRM_Batch_BAO_Batch', 'status_id', 'Closed'),
       'total' => $params['actualBatchTotal'],
-    );
+    ];
 
     CRM_Batch_BAO_Batch::create($paramValues);
 
@@ -511,13 +511,13 @@ private function processContribution(&$params) {
           $value['receipt_date'] = date('Y-m-d His');
         }
         // these translations & date handling are required because we are calling BAO directly rather than the api
-        $fieldTranslations = array(
+        $fieldTranslations = [
           'financial_type' => 'financial_type_id',
           'payment_instrument' => 'payment_instrument_id',
           'contribution_source' => 'source',
           'contribution_note' => 'note',
 
-        );
+        ];
         foreach ($fieldTranslations as $formField => $baoField) {
           if (isset($value[$formField])) {
             $value[$baoField] = $value[$formField];
@@ -533,7 +533,7 @@ private function processContribution(&$params) {
         $this->_priceSet['fields'][$priceFieldID]['options'][$priceFieldValueID]['amount'] = $value['total_amount'];
         $value['price_' . $priceFieldID] = 1;
 
-        $lineItem = array();
+        $lineItem = [];
         CRM_Price_BAO_PriceSet::processAmount($this->_priceSet['fields'], $value, $lineItem[$priceSetId]);
 
         // @todo - stop setting amount level in this function & call the CRM_Price_BAO_PriceSet::getAmountLevel
@@ -557,7 +557,7 @@ private function processContribution(&$params) {
         $value['skipCleanMoney'] = TRUE;
         //finally call contribution create for all the magic
         $contribution = CRM_Contribute_BAO_Contribution::create($value);
-        $batchTypes = CRM_Core_Pseudoconstant::get('CRM_Batch_DAO_Batch', 'type_id', array('flip' => 1), 'validate');
+        $batchTypes = CRM_Core_Pseudoconstant::get('CRM_Batch_DAO_Batch', 'type_id', ['flip' => 1], 'validate');
         if (!empty($this->_batchInfo['type_id']) && ($this->_batchInfo['type_id'] == $batchTypes['Pledge Payment'])) {
           $adjustTotalAmount = FALSE;
           if (isset($params['option_type'][$key])) {
@@ -577,7 +577,7 @@ private function processContribution(&$params) {
             }
             CRM_Core_DAO::setFieldValue('CRM_Pledge_DAO_PledgePayment', $pledgePaymentId, 'contribution_id', $contribution->id);
             CRM_Pledge_BAO_PledgePayment::updatePledgePaymentStatus($pledgeId,
-              array($pledgePaymentId),
+              [$pledgePaymentId],
               $contribution->contribution_status_id,
               NULL,
               $contribution->total_amount,
@@ -597,12 +597,12 @@ private function processContribution(&$params) {
               $options[$value['product_name'][0]]
             );
 
-            $premiumParams = array(
+            $premiumParams = [
               'product_id' => $value['product_name'][0],
               'contribution_id' => $contribution->id,
               'product_option' => $value['product_option'],
               'quantity' => 1,
-            );
+            ];
             CRM_Contribute_BAO_Contribution::addPremium($premiumParams);
           }
         }
@@ -642,7 +642,7 @@ private function processMembership(&$params) {
 
     if (isset($params['field'])) {
       // @todo - most of the wrangling in this function is because the api is not being used, especially date stuff.
-      $customFields = array();
+      $customFields = [];
       foreach ($params['field'] as $key => $value) {
         foreach ($value as $fieldKey => $fieldValue) {
           if (isset($this->_fields[$fieldKey]) && $this->_fields[$fieldKey]['data_type'] === 'Money') {
@@ -731,12 +731,12 @@ private function processMembership(&$params) {
 
         // make entry in line item for contribution
 
-        $editedFieldParams = array(
+        $editedFieldParams = [
           'price_set_id' => $priceSetId,
           'name' => $value['membership_type'][0],
-        );
+        ];
 
-        $editedResults = array();
+        $editedResults = [];
         CRM_Price_BAO_PriceField::retrieve($editedFieldParams, $editedResults);
 
         if (!empty($editedResults)) {
@@ -744,12 +744,12 @@ private function processMembership(&$params) {
           $this->_priceSet['fields'][$editedResults['id']] = $priceSets['fields'][$editedResults['id']];
           unset($this->_priceSet['fields'][$editedResults['id']]['options']);
           $fid = $editedResults['id'];
-          $editedFieldParams = array(
+          $editedFieldParams = [
             'price_field_id' => $editedResults['id'],
             'membership_type_id' => $value['membership_type_id'],
-          );
+          ];
 
-          $editedResults = array();
+          $editedResults = [];
           CRM_Price_BAO_PriceFieldValue::retrieve($editedFieldParams, $editedResults);
           $this->_priceSet['fields'][$fid]['options'][$editedResults['id']] = $priceSets['fields'][$fid]['options'][$editedResults['id']];
           if (!empty($value['total_amount'])) {
@@ -759,7 +759,7 @@ private function processMembership(&$params) {
           $fieldID = key($this->_priceSet['fields']);
           $value['price_' . $fieldID] = $editedResults['id'];
 
-          $lineItem = array();
+          $lineItem = [];
           CRM_Price_BAO_PriceSet::processAmount($this->_priceSet['fields'],
             $value, $lineItem[$priceSetId]
           );
@@ -795,10 +795,10 @@ private function processMembership(&$params) {
             }
           }
 
-          $formDates = array(
+          $formDates = [
             'end_date' => CRM_Utils_Array::value('membership_end_date', $value),
             'start_date' => CRM_Utils_Array::value('membership_start_date', $value),
-          );
+          ];
           $membershipSource = CRM_Utils_Array::value('source', $value);
           list($membership) = CRM_Member_BAO_Membership::processMembership(
             $value['contact_id'], $value['membership_type_id'], FALSE,
@@ -808,31 +808,31 @@ private function processMembership(&$params) {
           );
 
           // make contribution entry
-          $contrbutionParams = array_merge($value, array('membership_id' => $membership->id));
+          $contrbutionParams = array_merge($value, ['membership_id' => $membership->id]);
           $contrbutionParams['skipCleanMoney'] = TRUE;
           // @todo - calling this from here is pretty hacky since it is called from membership.create anyway
           // This form should set the correct params & not call this fn directly.
           CRM_Member_BAO_Membership::recordMembershipContribution($contrbutionParams);
         }
         else {
-          $dateTypes = array(
+          $dateTypes = [
             'join_date' => 'joinDate',
             'membership_start_date' => 'startDate',
             'membership_end_date' => 'endDate',
-          );
+          ];
 
-          $dates = array(
+          $dates = [
             'join_date',
             'start_date',
             'end_date',
             'reminder_date',
-          );
+          ];
           foreach ($dateTypes as $dateField => $dateVariable) {
             $$dateVariable = CRM_Utils_Date::processDate($value[$dateField]);
             $fDate[$dateField] = CRM_Utils_Array::value($dateField, $value);
           }
 
-          $calcDates = array();
+          $calcDates = [];
           $calcDates[$membershipTypeId] = CRM_Member_BAO_MembershipType::getDatesForMembershipType($membershipTypeId,
             $joinDate, $startDate, $endDate
           );
@@ -851,7 +851,7 @@ private function processMembership(&$params) {
 
           unset($value['membership_start_date']);
           unset($value['membership_end_date']);
-          $ids = array();
+          $ids = [];
           $membership = CRM_Member_BAO_Membership::create($value, $ids);
         }
 
@@ -866,12 +866,12 @@ private function processMembership(&$params) {
               $options[$value['product_name'][0]]
             );
 
-            $premiumParams = array(
+            $premiumParams = [
               'product_id' => $value['product_name'][0],
               'contribution_id' => CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipPayment', $membership->id, 'contribution_id', 'membership_id'),
               'product_option' => $value['product_option'],
               'quantity' => 1,
-            );
+            ];
             CRM_Contribute_BAO_Contribution::addPremium($premiumParams);
           }
         }
diff --git a/CRM/Batch/Form/Search.php b/CRM/Batch/Form/Search.php
index 66ca38686bf4..daab61e9f82b 100644
--- a/CRM/Batch/Form/Search.php
+++ b/CRM/Batch/Form/Search.php
@@ -37,7 +37,7 @@ class CRM_Batch_Form_Search extends CRM_Core_Form {
    * @return array
    */
   public function setDefaultValues() {
-    $defaults = array();
+    $defaults = [];
 
     $status = CRM_Utils_Request::retrieve('status', 'Positive', CRM_Core_DAO::$_nullObject, FALSE, 1);
 
@@ -51,13 +51,13 @@ public function buildQuickForm() {
     );
 
     $this->addButtons(
-      array(
-        array(
+      [
+        [
           'type' => 'refresh',
           'name' => ts('Search'),
           'isDefault' => TRUE,
-        ),
-      )
+        ],
+      ]
     );
 
     parent::buildQuickForm();
diff --git a/CRM/Batch/Page/AJAX.php b/CRM/Batch/Page/AJAX.php
index 9dc0ad60a988..3d840a48cc09 100644
--- a/CRM/Batch/Page/AJAX.php
+++ b/CRM/Batch/Page/AJAX.php
@@ -44,7 +44,7 @@ public function batchSave() {
     $batchId = CRM_Utils_Type::escape($_POST['batch_id'], 'Positive');
 
     unset($_POST['qfKey']);
-    CRM_Core_DAO::setFieldValue('CRM_Batch_DAO_Batch', $batchId, 'data', json_encode(array('values' => $_POST)));
+    CRM_Core_DAO::setFieldValue('CRM_Batch_DAO_Batch', $batchId, 'data', json_encode(['values' => $_POST]));
 
     CRM_Utils_System::civiExit();
   }
@@ -56,24 +56,24 @@ public function batchSave() {
   public static function getBatchList() {
     $context = CRM_Utils_Request::retrieve('context', 'Alphanumeric');
     if ($context != 'financialBatch') {
-      $sortMapper = array(
+      $sortMapper = [
         0 => 'title',
         1 => 'type_id.label',
         2 => 'item_count',
         3 => 'total',
         4 => 'status_id.label',
         5 => 'created_id.sort_name',
-      );
+      ];
     }
     else {
-      $sortMapper = array(
+      $sortMapper = [
         1 => 'title',
         2 => 'payment_instrument_id.label',
         3 => 'item_count',
         4 => 'total',
         5 => 'status_id.label',
         6 => 'created_id.sort_name',
-      );
+      ];
     }
     $sEcho = CRM_Utils_Type::escape($_REQUEST['sEcho'], 'Integer');
     $offset = isset($_REQUEST['iDisplayStart']) ? CRM_Utils_Type::escape($_REQUEST['iDisplayStart'], 'Integer') : 0;
@@ -102,7 +102,7 @@ public static function getBatchList() {
     $iFilteredTotal = $iTotal = $params['total'];
 
     if ($context == 'financialBatch') {
-      $selectorElements = array(
+      $selectorElements = [
         'check',
         'batch_name',
         'payment_instrument',
@@ -111,10 +111,10 @@ public static function getBatchList() {
         'status',
         'created_by',
         'links',
-      );
+      ];
     }
     else {
-      $selectorElements = array(
+      $selectorElements = [
         'batch_name',
         'type',
         'item_count',
@@ -122,7 +122,7 @@ public static function getBatchList() {
         'status',
         'created_by',
         'links',
-      );
+      ];
     }
     CRM_Utils_System::setHttpHeader('Content-Type', 'application/json');
     echo CRM_Utils_JSON::encodeDataTableSelector($batches, $sEcho, $iTotal, $iFilteredTotal, $selectorElements);
diff --git a/CRM/Bridge/OG/Drupal.php b/CRM/Bridge/OG/Drupal.php
index e4dc66f43ab6..7d27c8580703 100644
--- a/CRM/Bridge/OG/Drupal.php
+++ b/CRM/Bridge/OG/Drupal.php
@@ -47,7 +47,7 @@ public static function nodeapi(&$params, $op) {
     // first create or update the CiviCRM group
     $groupParams = $params;
     $groupParams['source'] = CRM_Bridge_OG_Utils::ogSyncName($params['og_id']);
-    $groupParams['group_type'] = array('2' => 1);
+    $groupParams['group_type'] = ['2' => 1];
     self::updateCiviGroup($groupParams, $op);
 
     if (CRM_Bridge_OG_Utils::aclEnabled()) {
@@ -55,7 +55,7 @@ public static function nodeapi(&$params, $op) {
       $aclParams = $params;
       $aclParams['name'] = $aclParams['title'] = "{$aclParams['name']}: Administrator";
       $aclParams['source'] = CRM_Bridge_OG_Utils::ogSyncACLName($params['og_id']);
-      $aclParams['group_type'] = array('1');
+      $aclParams['group_type'] = ['1'];
       self::updateCiviGroup($aclParams, $op);
 
       $aclParams['acl_group_id'] = $aclParams['group_id'];
@@ -138,7 +138,7 @@ public static function updateCiviACLRole(&$params, $op) {
     $dao->label = $params['title'];
     $dao->is_active = 1;
 
-    $weightParams = array('option_group_id' => $optionGroupID);
+    $weightParams = ['option_group_id' => $optionGroupID];
     $dao->weight = CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_OptionValue',
       $weightParams
     );
@@ -153,10 +153,10 @@ public static function updateCiviACLRole(&$params, $op) {
  WHERE v.option_group_id = %1
    AND v.description     = %2
 ";
-    $queryParams = array(
-      1 => array($optionGroupID, 'Integer'),
-      2 => array($params['source'], 'String'),
-    );
+    $queryParams = [
+      1 => [$optionGroupID, 'Integer'],
+      2 => [$params['source'], 'String'],
+    ];
     $dao->id = CRM_Core_DAO::singleValueQuery($query, $queryParams);
     $dao->save();
     $params['acl_role_id'] = $dao->value;
@@ -228,11 +228,11 @@ public static function og(&$params, $op) {
       NULL, TRUE
     );
 
-    $groupParams = array(
+    $groupParams = [
       'contact_id' => $contactID,
       'group_id' => $groupID,
       'version' => 3,
-    );
+    ];
 
     if ($op == 'add') {
       $groupParams['status'] = $params['is_active'] ? 'Added' : 'Pending';
@@ -251,12 +251,12 @@ public static function og(&$params, $op) {
         NULL, TRUE
       );
 
-      $groupParams = array(
+      $groupParams = [
         'contact_id' => $contactID,
         'group_id' => $groupID,
         'status' => $params['is_admin'] ? 'Added' : 'Removed',
         'version' => 3,
-      );
+      ];
 
       if ($params['is_admin']) {
         civicrm_api('GroupContact', 'Create', $groupParams);
diff --git a/CRM/Bridge/OG/Utils.php b/CRM/Bridge/OG/Utils.php
index 931bd7e8e950..154bf833082e 100644
--- a/CRM/Bridge/OG/Utils.php
+++ b/CRM/Bridge/OG/Utils.php
@@ -131,11 +131,11 @@ public static function groupID($source, $title = NULL, $abort = FALSE) {
 SELECT id
   FROM civicrm_group
  WHERE source = %1";
-    $params = array(1 => array($source, 'String'));
+    $params = [1 => [$source, 'String']];
 
     if ($title) {
       $query .= " OR title = %2";
-      $params[2] = array($title, 'String');
+      $params[2] = [$title, 'String'];
     }
 
     $groupID = CRM_Core_DAO::singleValueQuery($query, $params);
diff --git a/CRM/Campaign/BAO/Campaign.php b/CRM/Campaign/BAO/Campaign.php
index 77440fa746e1..23c75b5c7948 100644
--- a/CRM/Campaign/BAO/Campaign.php
+++ b/CRM/Campaign/BAO/Campaign.php
@@ -181,14 +181,14 @@ public static function getCampaigns(
   ) {
     static $campaigns;
     $cacheKey = 0;
-    $cacheKeyParams = array(
+    $cacheKeyParams = [
       'includeId',
       'excludeId',
       'onlyActive',
       'onlyCurrent',
       'appendDatesToTitle',
       'forceAll',
-    );
+    ];
     foreach ($cacheKeyParams as $param) {
       $cacheParam = $$param;
       if (!$cacheParam) {
@@ -198,7 +198,7 @@ public static function getCampaigns(
     }
 
     if (!isset($campaigns[$cacheKey])) {
-      $where = array('( camp.title IS NOT NULL )');
+      $where = ['( camp.title IS NOT NULL )'];
       if ($excludeId) {
         $where[] = "( camp.id != $excludeId )";
       }
@@ -228,14 +228,14 @@ public static function getCampaigns(
 Order By  camp.title";
 
       $campaign = CRM_Core_DAO::executeQuery($query);
-      $campaigns[$cacheKey] = array();
+      $campaigns[$cacheKey] = [];
       $config = CRM_Core_Config::singleton();
 
       while ($campaign->fetch()) {
         $title = $campaign->title;
         if ($appendDatesToTitle) {
-          $dates = array();
-          foreach (array('start_date', 'end_date') as $date) {
+          $dates = [];
+          foreach (['start_date', 'end_date'] as $date) {
             if ($campaign->$date) {
               $dates[] = CRM_Utils_Date::customFormat($campaign->$date, $config->dateformatFull);
             }
@@ -277,7 +277,7 @@ public static function getPermissionedCampaigns(
     $doCheckForPermissions = TRUE
   ) {
     $cacheKey = 0;
-    $cachekeyParams = array(
+    $cachekeyParams = [
       'includeId',
       'excludeId',
       'onlyActive',
@@ -286,7 +286,7 @@ public static function getPermissionedCampaigns(
       'doCheckForComponent',
       'doCheckForPermissions',
       'forceAll',
-    );
+    ];
     foreach ($cachekeyParams as $param) {
       $cacheKeyParam = $$param;
       if (!$cacheKeyParam) {
@@ -298,11 +298,11 @@ public static function getPermissionedCampaigns(
     static $validCampaigns;
     if (!isset($validCampaigns[$cacheKey])) {
       $isValid = TRUE;
-      $campaigns = array(
-        'campaigns' => array(),
+      $campaigns = [
+        'campaigns' => [],
         'hasAccessCampaign' => FALSE,
         'isCampaignEnabled' => FALSE,
-      );
+      ];
 
       //do check for component.
       if ($doCheckForComponent) {
@@ -358,18 +358,18 @@ public static function isCampaignEnable() {
    *
    * @return array|int
    */
-  public static function getCampaignSummary($params = array(), $onlyCount = FALSE) {
-    $campaigns = array();
+  public static function getCampaignSummary($params = [], $onlyCount = FALSE) {
+    $campaigns = [];
 
     //build the limit and order clause.
     $limitClause = $orderByClause = $lookupTableJoins = NULL;
     if (!$onlyCount) {
-      $sortParams = array(
+      $sortParams = [
         'sort' => 'start_date',
         'offset' => 0,
         'rowCount' => 10,
         'sortOrder' => 'desc',
-      );
+      ];
       foreach ($sortParams as $name => $default) {
         if (!empty($params[$name])) {
           $sortParams[$name] = $params[$name];
@@ -403,32 +403,32 @@ public static function getCampaignSummary($params = array(), $onlyCount = FALSE)
     }
 
     //build the where clause.
-    $queryParams = $where = array();
+    $queryParams = $where = [];
     if (!empty($params['id'])) {
       $where[] = "( campaign.id = %1 )";
-      $queryParams[1] = array($params['id'], 'Positive');
+      $queryParams[1] = [$params['id'], 'Positive'];
     }
     if (!empty($params['name'])) {
       $where[] = "( campaign.name LIKE %2 )";
-      $queryParams[2] = array('%' . trim($params['name']) . '%', 'String');
+      $queryParams[2] = ['%' . trim($params['name']) . '%', 'String'];
     }
     if (!empty($params['title'])) {
       $where[] = "( campaign.title LIKE %3 )";
-      $queryParams[3] = array('%' . trim($params['title']) . '%', 'String');
+      $queryParams[3] = ['%' . trim($params['title']) . '%', 'String'];
     }
     if (!empty($params['start_date'])) {
       $startDate = CRM_Utils_Date::processDate($params['start_date']);
       $where[] = "( campaign.start_date >= %4 OR campaign.start_date IS NULL )";
-      $queryParams[4] = array($startDate, 'String');
+      $queryParams[4] = [$startDate, 'String'];
     }
     if (!empty($params['end_date'])) {
       $endDate = CRM_Utils_Date::processDate($params['end_date'], '235959');
       $where[] = "( campaign.end_date <= %5 OR campaign.end_date IS NULL )";
-      $queryParams[5] = array($endDate, 'String');
+      $queryParams[5] = [$endDate, 'String'];
     }
     if (!empty($params['description'])) {
       $where[] = "( campaign.description LIKE %6 )";
-      $queryParams[6] = array('%' . trim($params['description']) . '%', 'String');
+      $queryParams[6] = ['%' . trim($params['description']) . '%', 'String'];
     }
     if (!empty($params['campaign_type_id'])) {
       $typeId = $params['campaign_type_id'];
@@ -456,7 +456,7 @@ public static function getCampaignSummary($params = array(), $onlyCount = FALSE)
       $whereClause = ' WHERE ' . implode(" \nAND ", $where);
     }
 
-    $properties = array(
+    $properties = [
       'id',
       'name',
       'title',
@@ -466,7 +466,7 @@ public static function getCampaignSummary($params = array(), $onlyCount = FALSE)
       'is_active',
       'description',
       'campaign_type_id',
-    );
+    ];
 
     $selectClause = '
 SELECT  campaign.id               as id,
@@ -519,11 +519,11 @@ public static function getCampaignCount() {
   public static function getCampaignGroups($campaignId) {
     static $campaignGroups;
     if (!$campaignId) {
-      return array();
+      return [];
     }
 
     if (!isset($campaignGroups[$campaignId])) {
-      $campaignGroups[$campaignId] = array();
+      $campaignGroups[$campaignId] = [];
 
       $query = "
     SELECT  grp.title, grp.id
@@ -533,7 +533,7 @@ public static function getCampaignGroups($campaignId) {
        AND  campgrp.entity_table = 'civicrm_group'
        AND  campgrp.campaign_id = %1";
 
-      $groups = CRM_Core_DAO::executeQuery($query, array(1 => array($campaignId, 'Positive')));
+      $groups = CRM_Core_DAO::executeQuery($query, [1 => [$campaignId, 'Positive']]);
       while ($groups->fetch()) {
         $campaignGroups[$campaignId][$groups->id] = $groups->title;
       }
@@ -590,7 +590,7 @@ public static function addCampaign(&$form, $connectedCampaignId = NULL) {
     }
 
     $campaignDetails = self::getPermissionedCampaigns($connectedCampaignId, NULL, TRUE, TRUE, $appendDates);
-    $fields = array('campaigns', 'hasAccessCampaign', 'isCampaignEnabled');
+    $fields = ['campaigns', 'hasAccessCampaign', 'isCampaignEnabled'];
     foreach ($fields as $fld) {
       $$fld = CRM_Utils_Array::value($fld, $campaignDetails);
     }
@@ -610,11 +610,11 @@ public static function addCampaign(&$form, $connectedCampaignId = NULL) {
     }
 
     //carry this info to templates.
-    $infoFields = array(
+    $infoFields = [
       'showAddCampaign',
       'hasAccessCampaign',
       'isCampaignEnabled',
-    );
+    ];
     foreach ($infoFields as $fld) {
       $campaignInfo[$fld] = $$fld;
     }
@@ -629,9 +629,9 @@ public static function addCampaign(&$form, $connectedCampaignId = NULL) {
    * @param string $elementName
    */
   public static function addCampaignInComponentSearch(&$form, $elementName = 'campaign_id') {
-    $campaignInfo = array();
+    $campaignInfo = [];
     $campaignDetails = self::getPermissionedCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE);
-    $fields = array('campaigns', 'hasAccessCampaign', 'isCampaignEnabled');
+    $fields = ['campaigns', 'hasAccessCampaign', 'isCampaignEnabled'];
     foreach ($fields as $fld) {
       $$fld = CRM_Utils_Array::value($fld, $campaignDetails);
     }
@@ -640,25 +640,25 @@ public static function addCampaignInComponentSearch(&$form, $elementName = 'camp
       //get the current campaign only.
       $currentCampaigns = self::getCampaigns(NULL, NULL, FALSE);
       $pastCampaigns = array_diff($campaigns, $currentCampaigns);
-      $allCampaigns = array();
+      $allCampaigns = [];
       if (!empty($currentCampaigns)) {
-        $allCampaigns = array('crm_optgroup_current_campaign' => ts('Current Campaigns')) + $currentCampaigns;
+        $allCampaigns = ['crm_optgroup_current_campaign' => ts('Current Campaigns')] + $currentCampaigns;
       }
       if (!empty($pastCampaigns)) {
-        $allCampaigns += array('crm_optgroup_past_campaign' => ts('Past Campaigns')) + $pastCampaigns;
+        $allCampaigns += ['crm_optgroup_past_campaign' => ts('Past Campaigns')] + $pastCampaigns;
       }
 
       $showCampaignInSearch = TRUE;
       $form->add('select', $elementName, ts('Campaigns'), $allCampaigns, FALSE,
-        array('id' => 'campaigns', 'multiple' => 'multiple', 'class' => 'crm-select2')
+        ['id' => 'campaigns', 'multiple' => 'multiple', 'class' => 'crm-select2']
       );
     }
-    $infoFields = array(
+    $infoFields = [
       'elementName',
       'hasAccessCampaign',
       'isCampaignEnabled',
       'showCampaignInSearch',
-    );
+    ];
     foreach ($infoFields as $fld) {
       $campaignInfo[$fld] = $$fld;
     }
diff --git a/CRM/Campaign/BAO/Petition.php b/CRM/Campaign/BAO/Petition.php
index 19844003bd68..82573024e659 100644
--- a/CRM/Campaign/BAO/Petition.php
+++ b/CRM/Campaign/BAO/Petition.php
@@ -48,16 +48,16 @@ public function __construct() {
    *
    * @return array|int
    */
-  public static function getPetitionSummary($params = array(), $onlyCount = FALSE) {
+  public static function getPetitionSummary($params = [], $onlyCount = FALSE) {
     //build the limit and order clause.
     $limitClause = $orderByClause = $lookupTableJoins = NULL;
     if (!$onlyCount) {
-      $sortParams = array(
+      $sortParams = [
         'sort' => 'created_date',
         'offset' => 0,
         'rowCount' => 10,
         'sortOrder' => 'desc',
-      );
+      ];
       foreach ($sortParams as $name => $default) {
         if (!empty($params[$name])) {
           $sortParams[$name] = $params[$name];
@@ -90,22 +90,22 @@ public static function getPetitionSummary($params = array(), $onlyCount = FALSE)
     }
 
     //build the where clause.
-    $queryParams = $where = array();
+    $queryParams = $where = [];
 
     //we only have activity type as a
     //difference between survey and petition.
     $petitionTypeID = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Petition');
     if ($petitionTypeID) {
       $where[] = "( petition.activity_type_id = %1 )";
-      $queryParams[1] = array($petitionTypeID, 'Positive');
+      $queryParams[1] = [$petitionTypeID, 'Positive'];
     }
     if (!empty($params['title'])) {
       $where[] = "( petition.title LIKE %2 )";
-      $queryParams[2] = array('%' . trim($params['title']) . '%', 'String');
+      $queryParams[2] = ['%' . trim($params['title']) . '%', 'String'];
     }
     if (!empty($params['campaign_id'])) {
       $where[] = '( petition.campaign_id = %3 )';
-      $queryParams[3] = array($params['campaign_id'], 'Positive');
+      $queryParams[3] = [$params['campaign_id'], 'Positive'];
     }
     $whereClause = NULL;
     if (!empty($where)) {
@@ -132,8 +132,8 @@ public static function getPetitionSummary($params = array(), $onlyCount = FALSE)
       return (int) CRM_Core_DAO::singleValueQuery($query, $queryParams);
     }
 
-    $petitions = array();
-    $properties = array(
+    $petitions = [];
+    $properties = [
       'id',
       'title',
       'campaign_id',
@@ -141,7 +141,7 @@ public static function getPetitionSummary($params = array(), $onlyCount = FALSE)
       'is_default',
       'result_id',
       'activity_type_id',
-    );
+    ];
 
     $petition = CRM_Core_DAO::executeQuery($query, $queryParams);
     while ($petition->fetch()) {
@@ -159,11 +159,11 @@ public static function getPetitionSummary($params = array(), $onlyCount = FALSE)
    */
   public static function getPetitionCount() {
     $whereClause = 'WHERE ( 1 )';
-    $queryParams = array();
+    $queryParams = [];
     $petitionTypeID = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Petition');
     if ($petitionTypeID) {
       $whereClause = "WHERE ( petition.activity_type_id = %1 )";
-      $queryParams[1] = array($petitionTypeID, 'Positive');
+      $queryParams[1] = [$petitionTypeID, 'Positive'];
     }
     $query = "SELECT COUNT(*) FROM civicrm_survey petition {$whereClause}";
 
@@ -198,7 +198,7 @@ public function createSignature(&$params) {
       // create activity
       // 1-Schedule, 2-Completed
 
-      $activityParams = array(
+      $activityParams = [
         'source_contact_id' => $params['contactId'],
         'target_contact_id' => $params['contactId'],
         'source_record_id' => $params['sid'],
@@ -207,7 +207,7 @@ public function createSignature(&$params) {
         'activity_date_time' => date("YmdHis"),
         'status_id' => $params['statusId'],
         'activity_campaign_id' => $params['activity_campaign_id'],
-      );
+      ];
 
       //activity creation
       // *** check for activity using source id - if already signed
@@ -242,11 +242,11 @@ public function confirmSignature($activity_id, $contact_id, $petition_id) {
     $sql = 'UPDATE civicrm_activity SET status_id = 2 WHERE id = %1';
     $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate');
     $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
-    $params = array(
-      1 => array($activity_id, 'Integer'),
-      2 => array($contact_id, 'Integer'),
-      3 => array($sourceID, 'Integer'),
-    );
+    $params = [
+      1 => [$activity_id, 'Integer'],
+      2 => [$contact_id, 'Integer'],
+      3 => [$sourceID, 'Integer'],
+    ];
     CRM_Core_DAO::executeQuery($sql, $params);
 
     $sql = 'UPDATE civicrm_activity_contact SET contact_id = %2 WHERE activity_id = %1 AND record_type_id = %3';
@@ -259,10 +259,10 @@ public function confirmSignature($activity_id, $contact_id, $petition_id) {
 WHERE       entity_table = 'civicrm_contact'
 AND         entity_id = %1
 AND         tag_id = ( SELECT id FROM civicrm_tag WHERE name = %2 )";
-    $params = array(
-      1 => array($contact_id, 'Integer'),
-      2 => array($tag_name, 'String'),
-    );
+    $params = [
+      1 => [$contact_id, 'Integer'],
+      2 => [$tag_name, 'String'],
+    ];
     CRM_Core_DAO::executeQuery($sql, $params);
     // validate arguments to setcookie are numeric to prevent header manipulation
     if (isset($petition_id) && is_numeric($petition_id)
@@ -293,7 +293,7 @@ public function confirmSignature($activity_id, $contact_id, $petition_id) {
    * @return array
    */
   public static function getPetitionSignatureTotalbyCountry($surveyId) {
-    $countries = array();
+    $countries = [];
     $sql = "
             SELECT count(civicrm_address.country_id) as total,
                 IFNULL(country_id,'') as country_id,IFNULL(iso_code,'') as country_iso, IFNULL(civicrm_country.name,'') as country
@@ -309,16 +309,16 @@ public static function getPetitionSignatureTotalbyCountry($surveyId) {
 
     $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate');
     $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
-    $params = array(
-      1 => array($surveyId, 'Integer'),
-      2 => array($sourceID, 'Integer'),
-    );
+    $params = [
+      1 => [$surveyId, 'Integer'],
+      2 => [$sourceID, 'Integer'],
+    ];
     $sql .= " GROUP BY civicrm_address.country_id";
-    $fields = array('total', 'country_id', 'country_iso', 'country');
+    $fields = ['total', 'country_id', 'country_iso', 'country'];
 
     $dao = CRM_Core_DAO::executeQuery($sql, $params);
     while ($dao->fetch()) {
-      $row = array();
+      $row = [];
       foreach ($fields as $field) {
         $row[$field] = $dao->$field;
       }
@@ -344,7 +344,7 @@ public static function getPetitionSignatureTotal($surveyId) {
             WHERE
             source_record_id = " . (int) $surveyId . " AND activity_type_id = " . (int) $surveyInfo['activity_type_id'] . " GROUP BY status_id";
 
-    $statusTotal = array();
+    $statusTotal = [];
     $total = 0;
     $dao = CRM_Core_DAO::executeQuery($sql);
     while ($dao->fetch()) {
@@ -362,7 +362,7 @@ public static function getPetitionSignatureTotal($surveyId) {
    * @return array
    */
   public static function getSurveyInfo($surveyId = NULL) {
-    $surveyInfo = array();
+    $surveyInfo = [];
 
     $sql = "
             SELECT  activity_type_id,
@@ -399,7 +399,7 @@ public static function getPetitionSignature($surveyId, $status_id = NULL) {
 
     // sql injection protection
     $surveyId = (int) $surveyId;
-    $signature = array();
+    $signature = [];
 
     $sql = "
             SELECT  a.id,
@@ -424,19 +424,19 @@ public static function getPetitionSignature($surveyId, $status_id = NULL) {
             civicrm_survey.id =  %1 AND
             a.source_record_id =  %1 ";
 
-    $params = array(1 => array($surveyId, 'Integer'));
+    $params = [1 => [$surveyId, 'Integer']];
 
     if ($status_id) {
       $sql .= " AND status_id = %2";
-      $params[2] = array($status_id, 'Integer');
+      $params[2] = [$status_id, 'Integer'];
     }
     $sql .= " ORDER BY  a.activity_date_time";
 
     $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate');
     $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
-    $params[3] = array($sourceID, 'Integer');
+    $params[3] = [$sourceID, 'Integer'];
 
-    $fields = array(
+    $fields = [
       'id',
       'survey_id',
       'contact_id',
@@ -451,11 +451,11 @@ public static function getPetitionSignature($surveyId, $status_id = NULL) {
       'state_province_id',
       'country_iso',
       'country',
-    );
+    ];
 
     $dao = CRM_Core_DAO::executeQuery($sql, $params);
     while ($dao->fetch()) {
-      $row = array();
+      $row = [];
       foreach ($fields as $field) {
         $row[$field] = $dao->$field;
       }
@@ -474,7 +474,7 @@ public static function getPetitionSignature($surveyId, $status_id = NULL) {
    *   array of contact ids
    */
   public function getEntitiesByTag($tag) {
-    $contactIds = array();
+    $contactIds = [];
     $entityTagDAO = new CRM_Core_DAO_EntityTag();
     $entityTagDAO->tag_id = $tag['id'];
     $entityTagDAO->find();
@@ -496,7 +496,7 @@ public function getEntitiesByTag($tag) {
   public static function checkSignature($surveyId, $contactId) {
 
     $surveyInfo = CRM_Campaign_BAO_Petition::getSurveyInfo($surveyId);
-    $signature = array();
+    $signature = [];
     $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate');
     $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
 
@@ -514,13 +514,13 @@ public static function checkSignature($surveyId, $contactId) {
             AND a.activity_type_id = %3
             AND ac.contact_id = %4
 ";
-    $params = array(
-      1 => array($surveyInfo['title'], 'String'),
-      2 => array($surveyId, 'Integer'),
-      3 => array($surveyInfo['activity_type_id'], 'Integer'),
-      4 => array($contactId, 'Integer'),
-      5 => array($sourceID, 'Integer'),
-    );
+    $params = [
+      1 => [$surveyInfo['title'], 'String'],
+      2 => [$surveyId, 'Integer'],
+      3 => [$surveyInfo['activity_type_id'], 'Integer'],
+      4 => [$contactId, 'Integer'],
+      5 => [$sourceID, 'Integer'],
+    ];
 
     $dao = CRM_Core_DAO::executeQuery($sql, $params);
     while ($dao->fetch()) {
@@ -573,7 +573,7 @@ public static function sendEmail($params, $sendEmailMode) {
 
     // get petition info
     $petitionParams['id'] = $params['sid'];
-    $petitionInfo = array();
+    $petitionInfo = [];
     CRM_Campaign_BAO_Survey::retrieve($petitionParams, $petitionInfo);
     if (empty($petitionInfo)) {
       CRM_Core_Error::fatal('Petition doesn\'t exist.');
@@ -599,12 +599,12 @@ public static function sendEmail($params, $sendEmailMode) {
 
         // add this contact to the CIVICRM_PETITION_CONTACTS group
         // Cannot pass parameter 1 by reference
-        $p = array($params['contactId']);
+        $p = [$params['contactId']];
         CRM_Contact_BAO_GroupContact::addContactsToGroup($p, $group_id, 'API');
 
         if ($params['email-Primary']) {
           CRM_Core_BAO_MessageTemplate::sendTemplate(
-            array(
+            [
               'groupName' => 'msg_tpl_workflow_petition',
               'valueName' => 'petition_sign',
               'contactId' => $params['contactId'],
@@ -615,7 +615,7 @@ public static function sendEmail($params, $sendEmailMode) {
               'replyTo' => $replyTo,
               'petitionId' => $params['sid'],
               'petitionTitle' => $petitionInfo['title'],
-            )
+            ]
           );
         }
         break;
@@ -635,12 +635,12 @@ public static function sendEmail($params, $sendEmailMode) {
         $localpart = CRM_Core_BAO_MailSettings::defaultLocalpart();
 
         $replyTo = implode($config->verpSeparator,
-            array(
+            [
               $localpart . 'c',
               $se->contact_id,
               $se->id,
               $se->hash,
-            )
+            ]
           ) . "@$emailDomain";
 
         $confirmUrl = CRM_Utils_System::url('civicrm/petition/confirm',
@@ -661,7 +661,7 @@ public static function sendEmail($params, $sendEmailMode) {
 
         if ($params['email-Primary']) {
           CRM_Core_BAO_MessageTemplate::sendTemplate(
-            array(
+            [
               'groupName' => 'msg_tpl_workflow_petition',
               'valueName' => 'petition_confirmation_needed',
               'contactId' => $params['contactId'],
@@ -673,7 +673,7 @@ public static function sendEmail($params, $sendEmailMode) {
               'petitionId' => $params['sid'],
               'petitionTitle' => $petitionInfo['title'],
               'confirmUrl' => $confirmUrl,
-            )
+            ]
           );
         }
         break;
diff --git a/CRM/Campaign/BAO/Query.php b/CRM/Campaign/BAO/Query.php
index 5138915ae55e..4f2f0e09a7d9 100644
--- a/CRM/Campaign/BAO/Query.php
+++ b/CRM/Campaign/BAO/Query.php
@@ -54,7 +54,7 @@ class CRM_Campaign_BAO_Query {
    */
   public static function &getFields() {
     if (!isset(self::$_campaignFields)) {
-      self::$_campaignFields = array();
+      self::$_campaignFields = [];
     }
 
     return self::$_campaignFields;
@@ -86,11 +86,11 @@ public static function select(&$query) {
     if (is_array($query->_select) && $query->_mode == CRM_Contact_BAO_Query::MODE_CONTACTS) {
       foreach ($query->_select as $field => $queryString) {
         if (substr($field, -11) == 'campaign_id') {
-          $query->_pseudoConstantsSelect[$field] = array(
+          $query->_pseudoConstantsSelect[$field] = [
             'pseudoField' => 'campaign_id',
             'idCol' => $field,
             'bao' => 'CRM_Activity_BAO_Activity',
-          );
+          ];
         }
       }
     }
@@ -171,7 +171,7 @@ public static function whereClauseSingle(&$values, &$query) {
 
     switch ($name) {
       case 'campaign_survey_id':
-        $query->_qill[$grouping][] = ts('Survey - %1', array(1 => CRM_Core_DAO::getFieldValue('CRM_Campaign_DAO_Survey', $value, 'title')));
+        $query->_qill[$grouping][] = ts('Survey - %1', [1 => CRM_Core_DAO::getFieldValue('CRM_Campaign_DAO_Survey', $value, 'title')]);
 
         $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause('civicrm_activity.source_record_id',
           $op, $value, 'Integer'
@@ -184,21 +184,21 @@ public static function whereClauseSingle(&$values, &$query) {
       case 'survey_status_id':
         $activityStatus = CRM_Core_PseudoConstant::activityStatus();
 
-        $query->_qill[$grouping][] = ts('Survey Status - %1', array(1 => $activityStatus[$value]));
+        $query->_qill[$grouping][] = ts('Survey Status - %1', [1 => $activityStatus[$value]]);
         $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause('civicrm_activity.status_id',
           $op, $value, 'Integer'
         );
         return;
 
       case 'campaign_search_voter_for':
-        if (in_array($value, array('release', 'interview'))) {
+        if (in_array($value, ['release', 'interview'])) {
           $query->_where[$grouping][] = '(civicrm_activity.is_deleted = 0 OR civicrm_activity.is_deleted IS NULL)';
         }
         return;
 
       case 'survey_interviewer_id':
         $surveyInterviewerName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $value, 'sort_name');
-        $query->_qill[$grouping][] = ts('Survey Interviewer - %1', array(1 => $surveyInterviewerName));
+        $query->_qill[$grouping][] = ts('Survey Interviewer - %1', [1 => $surveyInterviewerName]);
         $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause('civicrm_activity_assignment.contact_id',
           $op, $value, 'Integer'
         );
@@ -269,7 +269,7 @@ public static function defaultReturnProperties(
   ) {
     $properties = NULL;
     if ($mode & CRM_Contact_BAO_Query::MODE_CAMPAIGN) {
-      $properties = array(
+      $properties = [
         'contact_id' => 1,
         'contact_type' => 1,
         'contact_sub_type' => 1,
@@ -292,7 +292,7 @@ public static function defaultReturnProperties(
         'campaign_id' => 1,
         'survey_interviewer_id' => 1,
         'survey_activity_target_contact_id' => 1,
-      );
+      ];
     }
 
     return $properties;
@@ -355,11 +355,11 @@ public static function buildSearchForm(&$form) {
     $separator = CRM_Core_DAO::VALUE_SEPARATOR;
     $contactTypes = CRM_Contact_BAO_ContactType::getSelectElements(FALSE, TRUE, $separator);
     $form->add('select', 'contact_type', ts('Contact Type(s)'), $contactTypes, FALSE,
-      array('id' => 'contact_type', 'multiple' => 'multiple', 'class' => 'crm-select2')
+      ['id' => 'contact_type', 'multiple' => 'multiple', 'class' => 'crm-select2']
     );
     $groups = CRM_Core_PseudoConstant::nestedGroup();
     $form->add('select', 'group', ts('Groups'), $groups, FALSE,
-      array('multiple' => 'multiple', 'class' => 'crm-select2')
+      ['multiple' => 'multiple', 'class' => 'crm-select2']
     );
 
     $showInterviewer = FALSE;
@@ -372,7 +372,7 @@ public static function buildSearchForm(&$form) {
       $className == 'CRM_Campaign_Form_Gotv'
     ) {
 
-      $form->addEntityRef('survey_interviewer_id', ts('Interviewer'), array('class' => 'big'));
+      $form->addEntityRef('survey_interviewer_id', ts('Interviewer'), ['class' => 'big']);
 
       $userId = NULL;
       if (isset($form->_interviewerId) && $form->_interviewerId) {
@@ -383,7 +383,7 @@ public static function buildSearchForm(&$form) {
         $userId = $session->get('userID');
       }
       if ($userId) {
-        $defaults = array();
+        $defaults = [];
         $defaults['survey_interviewer_id'] = $userId;
         $form->setDefaults($defaults);
       }
@@ -395,13 +395,13 @@ public static function buildSearchForm(&$form) {
       FROM  civicrm_custom_field fld
 INNER JOIN  civicrm_custom_group grp on fld.custom_group_id = grp.id
      WHERE  grp.name = %1';
-    $dao = CRM_Core_DAO::executeQuery($query, array(1 => array('Voter_Info', 'String')));
-    $customSearchFields = array();
+    $dao = CRM_Core_DAO::executeQuery($query, [1 => ['Voter_Info', 'String']]);
+    $customSearchFields = [];
     while ($dao->fetch()) {
-      foreach (array(
+      foreach ([
                  'ward',
                  'precinct',
-               ) as $name) {
+               ] as $name) {
         if (stripos($name, $dao->label) !== FALSE) {
           $fieldId = $dao->id;
           $fieldName = 'custom_' . $dao->id;
@@ -419,7 +419,7 @@ public static function buildSearchForm(&$form) {
       ($className == 'CRM_Campaign_Form_Search')
     ) {
       CRM_Core_Error::statusBounce(ts('Could not find survey for %1 respondents.',
-          array(1 => $form->get('op'))
+          [1 => $form->get('op')]
         ),
         CRM_Utils_System::url('civicrm/survey/add',
           'reset=1&action=add'
@@ -432,7 +432,7 @@ public static function buildSearchForm(&$form) {
     //campaign has some contact groups, don't
     //allow to search the contacts those are not
     //in given campaign groups ( ie not in constituents )
-    $props = array('class' => 'crm-select2');
+    $props = ['class' => 'crm-select2'];
     if ($form->get('searchVoterFor') == 'reserve') {
       $props['onChange'] = "buildCampaignGroups( );return false;";
     }
@@ -453,7 +453,7 @@ public static function buildSearchForm(&$form) {
    * @return array
    */
   static public function voterClause($params) {
-    $voterClause = array();
+    $voterClause = [];
     $fromClause = $whereClause = NULL;
     if (!is_array($params) || empty($params)) {
       return $voterClause;
@@ -463,7 +463,7 @@ static public function voterClause($params) {
 
     //get the survey activities.
     $activityStatus = CRM_Core_PseudoConstant::activityStatus('name');
-    $status = array('Scheduled');
+    $status = ['Scheduled'];
     if ($searchVoterFor == 'reserve') {
       $status[] = 'Completed';
     }
@@ -494,7 +494,7 @@ static public function voterClause($params) {
           is_array($recontactInterval) &&
           !empty($recontactInterval)
         ) {
-          $voterIds = array();
+          $voterIds = [];
           foreach ($voterActValues as $values) {
             $numOfDays = CRM_Utils_Array::value($values['result'], $recontactInterval);
             if ($numOfDays &&
@@ -554,10 +554,10 @@ static public function voterClause($params) {
         }
       }
     }
-    $voterClause = array(
+    $voterClause = [
       'fromClause' => $fromClause,
       'whereClause' => $whereClause,
-    );
+    ];
 
     return $voterClause;
   }
diff --git a/CRM/Campaign/BAO/Survey.php b/CRM/Campaign/BAO/Survey.php
index 58c45b25e234..7ec3ca0e4ad2 100644
--- a/CRM/Campaign/BAO/Survey.php
+++ b/CRM/Campaign/BAO/Survey.php
@@ -121,16 +121,16 @@ public static function create(&$params) {
    *
    * @return array|int
    */
-  public static function getSurveySummary($params = array(), $onlyCount = FALSE) {
+  public static function getSurveySummary($params = [], $onlyCount = FALSE) {
     //build the limit and order clause.
     $limitClause = $orderByClause = $lookupTableJoins = NULL;
     if (!$onlyCount) {
-      $sortParams = array(
+      $sortParams = [
         'sort' => 'created_date',
         'offset' => 0,
         'rowCount' => 10,
         'sortOrder' => 'desc',
-      );
+      ];
       foreach ($sortParams as $name => $default) {
         if (!empty($params[$name])) {
           $sortParams[$name] = $params[$name];
@@ -163,23 +163,23 @@ public static function getSurveySummary($params = array(), $onlyCount = FALSE) {
     }
 
     //build the where clause.
-    $queryParams = $where = array();
+    $queryParams = $where = [];
 
     //we only have activity type as a
     //difference between survey and petition.
     $petitionTypeID = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Petition');
     if ($petitionTypeID) {
       $where[] = "( survey.activity_type_id != %1 )";
-      $queryParams[1] = array($petitionTypeID, 'Positive');
+      $queryParams[1] = [$petitionTypeID, 'Positive'];
     }
 
     if (!empty($params['title'])) {
       $where[] = "( survey.title LIKE %2 )";
-      $queryParams[2] = array('%' . trim($params['title']) . '%', 'String');
+      $queryParams[2] = ['%' . trim($params['title']) . '%', 'String'];
     }
     if (!empty($params['campaign_id'])) {
       $where[] = '( survey.campaign_id = %3 )';
-      $queryParams[3] = array($params['campaign_id'], 'Positive');
+      $queryParams[3] = [$params['campaign_id'], 'Positive'];
     }
     if (!empty($params['activity_type_id'])) {
       $typeId = $params['activity_type_id'];
@@ -216,8 +216,8 @@ public static function getSurveySummary($params = array(), $onlyCount = FALSE) {
       return (int) CRM_Core_DAO::singleValueQuery($query, $queryParams);
     }
 
-    $surveys = array();
-    $properties = array(
+    $surveys = [];
+    $properties = [
       'id',
       'title',
       'campaign_id',
@@ -228,7 +228,7 @@ public static function getSurveySummary($params = array(), $onlyCount = FALSE) {
       'release_frequency',
       'max_number_of_contacts',
       'default_number_of_contacts',
-    );
+    ];
 
     $survey = CRM_Core_DAO::executeQuery($query, $queryParams);
     while ($survey->fetch()) {
@@ -263,7 +263,7 @@ public static function getSurveyCount() {
    */
   public static function getSurveys($onlyActive = TRUE, $onlyDefault = FALSE, $forceAll = FALSE, $includePetition = FALSE) {
     $cacheKey = 0;
-    $cacheKeyParams = array('onlyActive', 'onlyDefault', 'forceAll', 'includePetition');
+    $cacheKeyParams = ['onlyActive', 'onlyDefault', 'forceAll', 'includePetition'];
     foreach ($cacheKeyParams as $param) {
       $cacheParam = $$param;
       if (!$cacheParam) {
@@ -280,7 +280,7 @@ public static function getSurveys($onlyActive = TRUE, $onlyDefault = FALSE, $for
         //difference between survey and petition.
         $petitionTypeID = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'petition');
 
-        $where = array();
+        $where = [];
         if ($petitionTypeID) {
           $where[] = "( survey.activity_type_id != {$petitionTypeID} )";
         }
@@ -298,7 +298,7 @@ public static function getSurveys($onlyActive = TRUE, $onlyDefault = FALSE, $for
         survey.title as title
   FROM  civicrm_survey as survey
  WHERE  {$whereClause}";
-      $surveys[$cacheKey] = array();
+      $surveys[$cacheKey] = [];
       $survey = CRM_Core_DAO::executeQuery($query);
       while ($survey->fetch()) {
         $surveys[$cacheKey][$survey->id] = $survey->title;
@@ -321,7 +321,7 @@ public static function getSurveyActivityType($returnColumn = 'label', $includePe
     $cacheKey = "{$returnColumn}_{$includePetitionActivityType}";
 
     if (!isset($activityTypes[$cacheKey])) {
-      $activityTypes = array();
+      $activityTypes = [];
       $campaignCompId = CRM_Core_Component::getComponentID('CiviCampaign');
       if ($campaignCompId) {
         $condition = " AND v.component_id={$campaignCompId}";
@@ -351,10 +351,10 @@ public static function getSurveyActivityType($returnColumn = 'label', $includePe
    *
    * @return array
    */
-  public static function getSurveyCustomGroups($surveyTypes = array()) {
-    $customGroups = array();
+  public static function getSurveyCustomGroups($surveyTypes = []) {
+    $customGroups = [];
     if (!is_array($surveyTypes)) {
-      $surveyTypes = array($surveyTypes);
+      $surveyTypes = [$surveyTypes];
     }
 
     if (!empty($surveyTypes)) {
@@ -429,8 +429,8 @@ public static function del($id) {
    * @return array
    *   array of contact info.
    */
-  public static function voterDetails($voterIds, $returnProperties = array()) {
-    $voterDetails = array();
+  public static function voterDetails($voterIds, $returnProperties = []) {
+    $voterDetails = [];
     if (!is_array($voterIds) || empty($voterIds)) {
       return $voterDetails;
     }
@@ -439,21 +439,21 @@ public static function voterDetails($voterIds, $returnProperties = array()) {
       $autocompleteContactSearch = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
         'contact_autocomplete_options'
       );
-      $returnProperties = array_fill_keys(array_merge(array(
+      $returnProperties = array_fill_keys(array_merge([
           'contact_type',
           'contact_sub_type',
           'sort_name',
-        ),
+        ],
         array_keys($autocompleteContactSearch)
       ), 1);
     }
 
-    $select = $from = array();
+    $select = $from = [];
     foreach ($returnProperties as $property => $ignore) {
-      $value = (in_array($property, array(
+      $value = (in_array($property, [
         'city',
         'street_address',
-      ))) ? 'address' : $property;
+      ])) ? 'address' : $property;
       switch ($property) {
         case 'sort_name':
         case 'contact_type':
@@ -523,8 +523,8 @@ public static function voterDetails($voterIds, $returnProperties = array()) {
    * @return array
    *   array of survey activity.
    */
-  public static function voterActivityDetails($surveyId, $voterIds, $interviewerId = NULL, $statusIds = array()) {
-    $activityDetails = array();
+  public static function voterActivityDetails($surveyId, $voterIds, $interviewerId = NULL, $statusIds = []) {
+    $activityDetails = [];
     if (!$surveyId ||
       !is_array($voterIds) || empty($voterIds)
     ) {
@@ -541,7 +541,7 @@ public static function voterActivityDetails($surveyId, $voterIds, $interviewerId
     $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
     $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
 
-    $params[1] = array($surveyId, 'Integer');
+    $params[1] = [$surveyId, 'Integer'];
     $query = "
     SELECT  activity.id, activity.status_id,
             activityTarget.contact_id as voter_id,
@@ -555,18 +555,18 @@ public static function voterActivityDetails($surveyId, $voterIds, $interviewerId
      AND  ( activity.is_deleted IS NULL OR activity.is_deleted = 0 ) ";
     if (!empty($interviewerId)) {
       $query .= "AND activityAssignment.contact_id = %2 ";
-      $params[2] = array($interviewerId, 'Integer');
+      $params[2] = [$interviewerId, 'Integer'];
     }
     $query .= "AND  activityTarget.contact_id IN {$targetContactIds}
             $whereClause";
     $activity = CRM_Core_DAO::executeQuery($query, $params);
     while ($activity->fetch()) {
-      $activityDetails[$activity->voter_id] = array(
+      $activityDetails[$activity->voter_id] = [
         'voter_id' => $activity->voter_id,
         'status_id' => $activity->status_id,
         'activity_id' => $activity->id,
         'interviewer_id' => $activity->interviewer_id,
-      );
+      ];
     }
 
     return $activityDetails;
@@ -591,13 +591,13 @@ public static function getSurveyActivities(
     $voterIds = NULL,
     $onlyCount = FALSE
   ) {
-    $activities = array();
+    $activities = [];
     $surveyActivityCount = 0;
     if (!$surveyId) {
       return ($onlyCount) ? 0 : $activities;
     }
 
-    $where = array();
+    $where = [];
     if (!empty($statusIds)) {
       $where[] = '( activity.status_id IN ( ' . implode(',', array_values($statusIds)) . ' ) )';
     }
@@ -650,10 +650,10 @@ public static function getSurveyActivities(
        AND  ( activity.is_deleted IS NULL OR activity.is_deleted = 0 )
             $whereClause";
 
-    $params = array(
-      1 => array($surveyId, 'Integer'),
-      2 => array($actTypeId, 'Integer'),
-    );
+    $params = [
+      1 => [$surveyId, 'Integer'],
+      2 => [$actTypeId, 'Integer'],
+    ];
 
     if ($onlyCount) {
       $dbCount = CRM_Core_DAO::singleValueQuery($query, $params);
@@ -663,7 +663,7 @@ public static function getSurveyActivities(
     $activity = CRM_Core_DAO::executeQuery($query, $params);
 
     while ($activity->fetch()) {
-      $activities[$activity->id] = array(
+      $activities[$activity->id] = [
         'id' => $activity->id,
         'voter_id' => $activity->voter_id,
         'voter_name' => $activity->voter_name,
@@ -671,7 +671,7 @@ public static function getSurveyActivities(
         'interviewer_id' => $activity->interviewer_id,
         'result' => $activity->result,
         'activity_date_time' => $activity->activity_date_time,
-      );
+      ];
     }
 
     return $activities;
@@ -690,8 +690,8 @@ public static function getSurveyActivities(
    * @return array
    *   Survey related contact ids.
    */
-  public static function getSurveyVoterInfo($surveyId, $interviewerId = NULL, $statusIds = array()) {
-    $voterIds = array();
+  public static function getSurveyVoterInfo($surveyId, $interviewerId = NULL, $statusIds = []) {
+    $voterIds = [];
     if (!$surveyId) {
       return $voterIds;
     }
@@ -704,7 +704,7 @@ public static function getSurveyVoterInfo($surveyId, $interviewerId = NULL, $sta
       $cacheKey = "{$cacheKey}_" . implode('_', $statusIds);
     }
 
-    static $contactIds = array();
+    static $contactIds = [];
     if (!isset($contactIds[$cacheKey])) {
       $activities = self::getSurveyActivities($surveyId, $interviewerId, $statusIds);
       foreach ($activities as $values) {
@@ -724,7 +724,7 @@ public static function getSurveyVoterInfo($surveyId, $interviewerId = NULL, $sta
    *   an array of option groups.
    */
   public static function getResultSets($valueColumnName = 'title') {
-    $resultSets = array();
+    $resultSets = [];
     $valueColumnName = CRM_Utils_Type::escape($valueColumnName, 'String');
 
     $query = "SELECT id, {$valueColumnName} FROM civicrm_option_group WHERE name LIKE 'civicrm_survey_%' AND is_active=1";
@@ -773,7 +773,7 @@ public static function isSurveyActivity($activityId) {
    *   an array of option values
    */
   public static function getResponsesOptions($surveyId) {
-    $responseOptions = array();
+    $responseOptions = [];
     if (!$surveyId) {
       return $responseOptions;
     }
@@ -796,12 +796,12 @@ public static function getResponsesOptions($surveyId) {
    *   $url array of permissioned links
    */
   public static function buildPermissionLinks($surveyId, $enclosedInUL = FALSE, $extraULName = 'more') {
-    $menuLinks = array();
+    $menuLinks = [];
     if (!$surveyId) {
       return $menuLinks;
     }
 
-    static $voterLinks = array();
+    static $voterLinks = [];
     if (empty($voterLinks)) {
       $permissioned = FALSE;
       if (CRM_Core_Permission::check('manage campaign') ||
@@ -811,44 +811,44 @@ public static function buildPermissionLinks($surveyId, $enclosedInUL = FALSE, $e
       }
 
       if ($permissioned || CRM_Core_Permission::check("reserve campaign contacts")) {
-        $voterLinks['reserve'] = array(
+        $voterLinks['reserve'] = [
           'name' => 'reserve',
           'url' => 'civicrm/survey/search',
           'qs' => 'sid=%%id%%&reset=1&op=reserve',
           'title' => ts('Reserve Respondents'),
-        );
+        ];
       }
       if ($permissioned || CRM_Core_Permission::check("interview campaign contacts")) {
-        $voterLinks['release'] = array(
+        $voterLinks['release'] = [
           'name' => 'interview',
           'url' => 'civicrm/survey/search',
           'qs' => 'sid=%%id%%&reset=1&op=interview&force=1',
           'title' => ts('Interview Respondents'),
-        );
+        ];
       }
       if ($permissioned || CRM_Core_Permission::check("release campaign contacts")) {
-        $voterLinks['interview'] = array(
+        $voterLinks['interview'] = [
           'name' => 'release',
           'url' => 'civicrm/survey/search',
           'qs' => 'sid=%%id%%&reset=1&op=release&force=1',
           'title' => ts('Release Respondents'),
-        );
+        ];
       }
     }
 
     if (CRM_Core_Permission::check('access CiviReport')) {
       $reportID = self::getReportID($surveyId);
       if ($reportID) {
-        $voterLinks['report'] = array(
+        $voterLinks['report'] = [
           'name' => 'report',
           'url' => "civicrm/report/instance/{$reportID}",
           'qs' => 'reset=1',
           'title' => ts('View Survey Report'),
-        );
+        ];
       }
     }
 
-    $ids = array('id' => $surveyId);
+    $ids = ['id' => $surveyId];
     foreach ($voterLinks as $link) {
       if (!empty($link['qs']) &&
         !CRM_Utils_System::isNull($link['qs'])
@@ -886,19 +886,19 @@ public static function getSurveyProfileId($surveyId) {
       return NULL;
     }
 
-    static $ufIds = array();
+    static $ufIds = [];
     if (!array_key_exists($surveyId, $ufIds)) {
       //get the profile id.
-      $ufJoinParams = array(
+      $ufJoinParams = [
         'entity_id' => $surveyId,
         'entity_table' => 'civicrm_survey',
         'module' => 'CiviCampaign',
-      );
+      ];
 
       list($first, $second) = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
 
       if ($first) {
-        $ufIds[$surveyId] = array($first);
+        $ufIds[$surveyId] = [$first];
       }
       if ($second) {
         $ufIds[$surveyId][] = array_shift($second);
@@ -914,11 +914,11 @@ public static function getSurveyProfileId($surveyId) {
    * @return mixed
    */
   public Static function getReportID($surveyId) {
-    static $reportIds = array();
+    static $reportIds = [];
 
     if (!array_key_exists($surveyId, $reportIds)) {
       $query = "SELECT MAX(id) as id FROM civicrm_report_instance WHERE name = %1";
-      $reportID = CRM_Core_DAO::singleValueQuery($query, array(1 => array("survey_{$surveyId}", 'String')));
+      $reportID = CRM_Core_DAO::singleValueQuery($query, [1 => ["survey_{$surveyId}", 'String']]);
       $reportIds[$surveyId] = $reportID;
     }
     return $reportIds[$surveyId];
@@ -953,8 +953,8 @@ public static function surveyProfileTypes() {
     static $profileTypes;
 
     if (!isset($profileTypes)) {
-      $profileTypes = array_merge(array('Activity', 'Contact'), CRM_Contact_BAO_ContactType::basicTypes());
-      $profileTypes = array_diff($profileTypes, array('Organization', 'Household'));
+      $profileTypes = array_merge(['Activity', 'Contact'], CRM_Contact_BAO_ContactType::basicTypes());
+      $profileTypes = array_diff($profileTypes, ['Organization', 'Household']);
     }
 
     return $profileTypes;
@@ -974,7 +974,7 @@ public static function surveyProfileTypes() {
    */
   public static function getSurveyResponseFields($surveyId, $surveyTypeId = NULL) {
     if (empty($surveyId)) {
-      return array();
+      return [];
     }
 
     static $responseFields;
@@ -984,7 +984,7 @@ public static function getSurveyResponseFields($surveyId, $surveyTypeId = NULL)
       return $responseFields[$cacheKey];
     }
 
-    $responseFields[$cacheKey] = array();
+    $responseFields[$cacheKey] = [];
 
     $profileId = self::getSurveyProfileId($surveyId);
 
@@ -1001,7 +1001,7 @@ public static function getSurveyResponseFields($surveyId, $surveyTypeId = NULL)
     );
 
     //don't load these fields in grid.
-    $removeFields = array('File', 'RichTextEditor');
+    $removeFields = ['File', 'RichTextEditor'];
 
     $supportableFieldTypes = self::surveyProfileTypes();
 
@@ -1053,7 +1053,7 @@ public static function getInterviewers() {
       $whereClause = ' WHERE survey.activity_type_id IN ( ' . implode(' , ', array_keys($activityTypes)) . ' )';
     }
 
-    $interviewers = array();
+    $interviewers = [];
     $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate');
     $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
 
@@ -1103,8 +1103,8 @@ public static function releaseRespondent($params) {
      WHERE  activity.is_deleted = 0
        AND  activity.status_id = %1
        AND  activity.activity_type_id IN ( ' . implode(', ', $surveyActivityTypesIds) . ' )';
-      $activity = CRM_Core_DAO::executeQuery($query, array(1 => array($reserveStatusId, 'Positive')));
-      $releasedIds = array();
+      $activity = CRM_Core_DAO::executeQuery($query, [1 => [$reserveStatusId, 'Positive']]);
+      $releasedIds = [];
       while ($activity->fetch()) {
         if (!$activity->release_frequency) {
           continue;
@@ -1128,10 +1128,10 @@ public static function releaseRespondent($params) {
       }
     }
 
-    $rtnMsg = array(
+    $rtnMsg = [
       'is_error' => 0,
       'messages' => "Number of respondents released = {$releasedCount}",
-    );
+    ];
 
     return $rtnMsg;
   }
@@ -1146,14 +1146,14 @@ public static function releaseRespondent($params) {
    *
    * @return array|bool
    */
-  public static function buildOptions($fieldName, $context = NULL, $props = array()) {
-    $params = array();
+  public static function buildOptions($fieldName, $context = NULL, $props = []) {
+    $params = [];
     // Special logic for fields whose options depend on context or properties
     switch ($fieldName) {
       case 'activity_type_id':
         $campaignCompId = CRM_Core_Component::getComponentID('CiviCampaign');
         if ($campaignCompId) {
-          $params['condition'] = array("component_id={$campaignCompId}");
+          $params['condition'] = ["component_id={$campaignCompId}"];
         }
         break;
     }
diff --git a/CRM/Campaign/Form/Campaign.php b/CRM/Campaign/Form/Campaign.php
index 865ad02b0fd4..91536ec81d73 100644
--- a/CRM/Campaign/Form/Campaign.php
+++ b/CRM/Campaign/Form/Campaign.php
@@ -101,11 +101,11 @@ public function preProcess() {
     //load the values;
     $this->_values = $this->get('values');
     if (!is_array($this->_values)) {
-      $this->_values = array();
+      $this->_values = [];
 
       // if we are editing
       if (isset($this->_campaignId) && $this->_campaignId) {
-        $params = array('id' => $this->_campaignId);
+        $params = ['id' => $this->_campaignId];
         CRM_Campaign_BAO_Campaign::retrieve($params, $this->_values);
       }
 
@@ -150,7 +150,7 @@ public function setDefaultValues() {
 
     $dao = new CRM_Campaign_DAO_CampaignGroup();
 
-    $campaignGroups = array();
+    $campaignGroups = [];
     $dao->campaign_id = $this->_campaignId;
     $dao->find();
 
@@ -167,17 +167,17 @@ public function setDefaultValues() {
   public function buildQuickForm() {
     if ($this->_action & CRM_Core_Action::DELETE) {
 
-      $this->addButtons(array(
-          array(
+      $this->addButtons([
+          [
             'type' => 'next',
             'name' => ts('Delete'),
             'isDefault' => TRUE,
-          ),
-          array(
+          ],
+          [
             'type' => 'cancel',
             'name' => ts('Cancel'),
-          ),
-        )
+          ],
+        ]
       );
       return;
     }
@@ -204,7 +204,7 @@ public function buildQuickForm() {
     $this->add('datepicker', 'end_date', ts('End Date'));
 
     // add campaign type
-    $this->addSelect('campaign_type_id', array('onChange' => "CRM.buildCustomData( 'Campaign', this.value );"), TRUE);
+    $this->addSelect('campaign_type_id', ['onChange' => "CRM.buildCustomData( 'Campaign', this.value );"], TRUE);
 
     // add campaign status
     $this->addSelect('status_id');
@@ -218,8 +218,8 @@ public function buildQuickForm() {
     $campaigns = CRM_Campaign_BAO_Campaign::getCampaigns(CRM_Utils_Array::value('parent_id', $this->_values), $this->_campaignId);
     if (!empty($campaigns)) {
       $this->addElement('select', 'parent_id', ts('Parent ID'),
-        array('' => ts('- select Parent -')) + $campaigns,
-        array('class' => 'crm-select2')
+        ['' => ts('- select Parent -')] + $campaigns,
+        ['class' => 'crm-select2']
       );
     }
     $groups = CRM_Core_PseudoConstant::nestedGroup();
@@ -228,17 +228,17 @@ public function buildQuickForm() {
       ts('Include Group(s)'),
       $groups,
       FALSE,
-      array(
+      [
         'multiple' => TRUE,
         'class' => 'crm-select2 huge',
         'placeholder' => ts('- none -'),
-      )
+      ]
     );
 
-    $this->add('wysiwyg', 'goal_general', ts('Campaign Goals'), array('rows' => 2, 'cols' => 40));
-    $this->add('text', 'goal_revenue', ts('Revenue Goal'), array('size' => 8, 'maxlength' => 12));
+    $this->add('wysiwyg', 'goal_general', ts('Campaign Goals'), ['rows' => 2, 'cols' => 40]);
+    $this->add('text', 'goal_revenue', ts('Revenue Goal'), ['size' => 8, 'maxlength' => 12]);
     $this->addRule('goal_revenue', ts('Please enter a valid money value (e.g. %1).',
-      array(1 => CRM_Utils_Money::format('99.99', ' '))
+      [1 => CRM_Utils_Money::format('99.99', ' ')]
     ), 'money');
 
     // is this Campaign active
@@ -279,7 +279,7 @@ public function buildQuickForm() {
    * @see valid_date
    */
   public static function formRule($fields, $files, $errors) {
-    $errors = array();
+    $errors = [];
 
     return empty($errors) ? TRUE : $errors;
   }
@@ -292,7 +292,7 @@ public function postProcess() {
     $params = $this->controller->exportValues($this->_name);
     $session = CRM_Core_Session::singleton();
 
-    $groups = array();
+    $groups = [];
     if (isset($this->_campaignId)) {
       if ($this->_action & CRM_Core_Action::DELETE) {
         CRM_Campaign_BAO_Campaign::del($this->_campaignId);
@@ -342,7 +342,7 @@ public function postProcess() {
     $result = CRM_Campaign_BAO_Campaign::create($params);
 
     if ($result) {
-      CRM_Core_Session::setStatus(ts('Campaign %1 has been saved.', array(1 => $result->title)), ts('Saved'), 'success');
+      CRM_Core_Session::setStatus(ts('Campaign %1 has been saved.', [1 => $result->title]), ts('Saved'), 'success');
       $session->pushUserContext(CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=campaign'));
       $this->ajaxResponse['id'] = $result->id;
       $this->ajaxResponse['label'] = $result->title;
diff --git a/CRM/Campaign/Form/Gotv.php b/CRM/Campaign/Form/Gotv.php
index 7f017da8f38a..d260b93262ef 100644
--- a/CRM/Campaign/Form/Gotv.php
+++ b/CRM/Campaign/Form/Gotv.php
@@ -84,7 +84,7 @@ public function preProcess() {
     //append breadcrumb to survey dashboard.
     if (CRM_Campaign_BAO_Campaign::accessCampaign()) {
       $url = CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=survey');
-      CRM_Utils_System::appendBreadCrumb(array(array('title' => ts('Survey(s)'), 'url' => $url)));
+      CRM_Utils_System::appendBreadCrumb([['title' => ts('Survey(s)'), 'url' => $url]]);
     }
 
     //set the form title.
@@ -103,7 +103,7 @@ public function buildQuickForm() {
     CRM_Campaign_BAO_Query::buildSearchForm($this);
 
     //build the array of all search params.
-    $this->_searchParams = array();
+    $this->_searchParams = [];
     foreach ($this->_elements as $element) {
       $name = $element->_attributes['name'];
       if ($name == 'qfKey') {
@@ -114,7 +114,7 @@ public function buildQuickForm() {
     $this->set('searchParams', $this->_searchParams);
     $this->assign('searchParams', json_encode($this->_searchParams));
 
-    $defaults = array();
+    $defaults = [];
 
     if (!$this->_surveyId) {
       $this->_surveyId = key(CRM_Campaign_BAO_Survey::getSurveys(TRUE, TRUE));
@@ -142,7 +142,7 @@ public function buildQuickForm() {
   }
 
   public function validateIds() {
-    $errorMessages = array();
+    $errorMessages = [];
     //check for required permissions.
     if (!CRM_Core_Permission::check('manage campaign') &&
       !CRM_Core_Permission::check('administer CiviCampaign') &&
@@ -153,7 +153,7 @@ public function validateIds() {
 
     $surveys = CRM_Campaign_BAO_Survey::getSurveys();
     if (empty($surveys)) {
-      $errorMessages[] = ts("Oops. It looks like no surveys have been created. Click here to create a new survey.", array(1 => CRM_Utils_System::url('civicrm/survey/add', 'reset=1&action=add')));
+      $errorMessages[] = ts("Oops. It looks like no surveys have been created. Click here to create a new survey.", [1 => CRM_Utils_System::url('civicrm/survey/add', 'reset=1&action=add')]);
     }
 
     if ($this->_force && !$this->_surveyId) {
diff --git a/CRM/Campaign/Form/Petition.php b/CRM/Campaign/Form/Petition.php
index e1e005eda01f..30e9349ff42a 100644
--- a/CRM/Campaign/Form/Petition.php
+++ b/CRM/Campaign/Form/Petition.php
@@ -90,9 +90,9 @@ public function preProcess() {
     $this->_values = $this->get('values');
 
     if (!is_array($this->_values)) {
-      $this->_values = array();
+      $this->_values = [];
       if ($this->_surveyId) {
-        $params = array('id' => $this->_surveyId);
+        $params = ['id' => $this->_surveyId];
         CRM_Campaign_BAO_Survey::retrieve($params, $this->_values);
       }
       $this->set('values', $this->_values);
@@ -116,7 +116,7 @@ public function preProcess() {
     $url = CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=petition');
     $session->pushUserContext($url);
 
-    CRM_Utils_System::appendBreadCrumb(array(array('title' => ts('Petition Dashboard'), 'url' => $url)));
+    CRM_Utils_System::appendBreadCrumb([['title' => ts('Petition Dashboard'), 'url' => $url]]);
   }
 
   /**
@@ -129,20 +129,20 @@ public function preProcess() {
   public function setDefaultValues() {
     $defaults = $this->_values;
 
-    $ufContactJoinParams = array(
+    $ufContactJoinParams = [
       'entity_table' => 'civicrm_survey',
       'entity_id' => $this->_surveyId,
       'weight' => 2,
-    );
+    ];
 
     if ($ufContactGroupId = CRM_Core_BAO_UFJoin::findUFGroupId($ufContactJoinParams)) {
       $defaults['contact_profile_id'] = $ufContactGroupId;
     }
-    $ufActivityJoinParams = array(
+    $ufActivityJoinParams = [
       'entity_table' => 'civicrm_survey',
       'entity_id' => $this->_surveyId,
       'weight' => 1,
-    );
+    ];
 
     if ($ufActivityGroupId = CRM_Core_BAO_UFJoin::findUFGroupId($ufActivityJoinParams)) {
       $defaults['profile_id'] = $ufActivityGroupId;
@@ -165,17 +165,17 @@ public function buildQuickForm() {
 
     if ($this->_action & CRM_Core_Action::DELETE) {
       $this->addButtons(
-        array(
-          array(
+        [
+          [
             'type' => 'next',
             'name' => ts('Delete'),
             'isDefault' => TRUE,
-          ),
-          array(
+          ],
+          [
             'type' => 'cancel',
             'name' => ts('Cancel'),
-          ),
-        )
+          ],
+        ]
       );
       return;
     }
@@ -196,20 +196,20 @@ public function buildQuickForm() {
       'select' => ['minimumInputLength' => 0],
     ]);
 
-    $customContactProfiles = CRM_Core_BAO_UFGroup::getProfiles(array('Individual'));
+    $customContactProfiles = CRM_Core_BAO_UFGroup::getProfiles(['Individual']);
     // custom group id
     $this->add('select', 'contact_profile_id', ts('Contact Profile'),
-      array(
+      [
         '' => ts('- select -'),
-      ) + $customContactProfiles, TRUE
+      ] + $customContactProfiles, TRUE
     );
 
-    $customProfiles = CRM_Core_BAO_UFGroup::getProfiles(array('Activity'));
+    $customProfiles = CRM_Core_BAO_UFGroup::getProfiles(['Activity']);
     // custom group id
     $this->add('select', 'profile_id', ts('Activity Profile'),
-      array(
+      [
         '' => ts('- select -'),
-      ) + $customProfiles
+      ] + $customProfiles
     );
 
     // thank you title and text (html allowed in text)
@@ -230,26 +230,26 @@ public function buildQuickForm() {
 
     // add buttons
     $this->addButtons(
-      array(
-        array(
+      [
+        [
           'type' => 'next',
           'name' => ts('Save'),
           'isDefault' => TRUE,
-        ),
-        array(
+        ],
+        [
           'type' => 'next',
           'name' => ts('Save and New'),
           'subName' => 'new',
-        ),
-        array(
+        ],
+        [
           'type' => 'cancel',
           'name' => ts('Cancel'),
-        ),
-      )
+        ],
+      ]
     );
 
     // add a form rule to check default value
-    $this->addFormRule(array('CRM_Campaign_Form_Petition', 'formRule'), $this);
+    $this->addFormRule(['CRM_Campaign_Form_Petition', 'formRule'], $this);
   }
 
   /**
@@ -260,14 +260,14 @@ public function buildQuickForm() {
    * @return array|bool
    */
   public static function formRule($fields, $files, $form) {
-    $errors = array();
+    $errors = [];
     // Petitions should be unique by: title, campaign ID (if assigned) and activity type ID
     // NOTE: This class is called for both Petition create / update AND for Survey Results tab, but this rule is only for Petition.
-    $where = array('activity_type_id = %1', 'title = %2');
-    $params = array(
-      1 => array($fields['activity_type_id'], 'Integer'),
-      2 => array($fields['title'], 'String'),
-    );
+    $where = ['activity_type_id = %1', 'title = %2'];
+    $params = [
+      1 => [$fields['activity_type_id'], 'Integer'],
+      2 => [$fields['title'], 'String'],
+    ];
     $uniqueRuleErrorMessage = ts('This title is already associated with the selected activity type. Please specify a unique title.');
 
     if (empty($fields['campaign_id'])) {
@@ -275,14 +275,14 @@ public static function formRule($fields, $files, $form) {
     }
     else {
       $where[] = 'campaign_id = %3';
-      $params[3] = array($fields['campaign_id'], 'Integer');
+      $params[3] = [$fields['campaign_id'], 'Integer'];
       $uniqueRuleErrorMessage = ts('This title is already associated with the selected campaign and activity type. Please specify a unique title.');
     }
 
     // Exclude current Petition row if UPDATE.
     if ($form->_surveyId) {
       $where[] = 'id != %4';
-      $params[4] = array($form->_surveyId, 'Integer');
+      $params[4] = [$form->_surveyId, 'Integer'];
     }
 
     $whereClause = implode(' AND ', $where);
@@ -336,12 +336,12 @@ public function postProcess() {
     $surveyId = CRM_Campaign_BAO_Survey::create($params);
 
     // also update the ProfileModule tables
-    $ufJoinParams = array(
+    $ufJoinParams = [
       'is_active' => 1,
       'module' => 'CiviCampaign',
       'entity_table' => 'civicrm_survey',
       'entity_id' => $surveyId->id,
-    );
+    ];
 
     // first delete all past entries
     if ($this->_surveyId) {
diff --git a/CRM/Campaign/Form/Petition/Signature.php b/CRM/Campaign/Form/Petition/Signature.php
index 74fa32114f54..c973bfdc559d 100644
--- a/CRM/Campaign/Form/Petition/Signature.php
+++ b/CRM/Campaign/Form/Petition/Signature.php
@@ -181,7 +181,7 @@ public function preProcess() {
     }
     //check petition is valid and active
     $params['id'] = $this->_surveyId;
-    $this->petition = array();
+    $this->petition = [];
     CRM_Campaign_BAO_Survey::retrieve($params, $this->petition);
     if (empty($this->petition)) {
       CRM_Core_Error::fatal('Petition doesn\'t exist.');
@@ -201,12 +201,12 @@ public function preProcess() {
 
     // add the custom contact and activity profile fields to the signature form
 
-    $ufJoinParams = array(
+    $ufJoinParams = [
       'entity_id' => $this->_surveyId,
       'entity_table' => 'civicrm_survey',
       'module' => 'CiviCampaign',
       'weight' => 2,
-    );
+    ];
 
     $this->_contactProfileId = CRM_Core_BAO_UFJoin::findUFGroupId($ufJoinParams);
     if ($this->_contactProfileId) {
@@ -231,7 +231,7 @@ public function preProcess() {
    * Set default values for the form.
    */
   public function setDefaultValues() {
-    $this->_defaults = array();
+    $this->_defaults = [];
     if ($this->_contactId) {
       CRM_Core_BAO_UFGroup::setProfileDefaults($this->_contactId, $this->_contactProfileFields, $this->_defaults, TRUE);
       if ($this->_activityProfileId) {
@@ -296,13 +296,13 @@ public function buildQuickForm() {
       $this->buildCustom($this->_activityProfileId, 'petitionActivityProfile');
     }
     // add buttons
-    $this->addButtons(array(
-        array(
+    $this->addButtons([
+        [
           'type' => 'upload',
           'name' => ts('Sign the Petition'),
           'isDefault' => TRUE,
-        ),
-      )
+        ],
+      ]
     );
   }
 
@@ -318,7 +318,7 @@ public function buildQuickForm() {
    * @return array|bool
    */
   public static function formRule($fields, $files, $errors) {
-    $errors = array();
+    $errors = [];
 
     return empty($errors) ? TRUE : $errors;
   }
@@ -371,11 +371,11 @@ public function postProcess() {
       $ids[0] = $this->_contactId;
     }
     else {
-      $ids = CRM_Contact_BAO_Contact::getDuplicateContacts($params, $this->_ctype, 'Unsupervised', array(), FALSE);
+      $ids = CRM_Contact_BAO_Contact::getDuplicateContacts($params, $this->_ctype, 'Unsupervised', [], FALSE);
     }
 
     $petition_params['id'] = $this->_surveyId;
-    $petition = array();
+    $petition = [];
     CRM_Campaign_BAO_Survey::retrieve($petition_params, $petition);
 
     switch (count($ids)) {
diff --git a/CRM/Campaign/Form/Search/Campaign.php b/CRM/Campaign/Form/Search/Campaign.php
index f28c272a9a9c..331cadd60520 100644
--- a/CRM/Campaign/Form/Search/Campaign.php
+++ b/CRM/Campaign/Form/Search/Campaign.php
@@ -79,17 +79,17 @@ public function buildQuickForm() {
     $this->add('text', 'description', ts('Description'), $attributes['description']);
 
     //campaign start date.
-    $this->addDate('start_date', ts('From'), FALSE, array('formatType' => 'searchDate'));
+    $this->addDate('start_date', ts('From'), FALSE, ['formatType' => 'searchDate']);
 
     //campaign end date.
-    $this->addDate('end_date', ts('To'), FALSE, array('formatType' => 'searchDate'));
+    $this->addDate('end_date', ts('To'), FALSE, ['formatType' => 'searchDate']);
 
     //campaign type.
     $campaignTypes = CRM_Campaign_PseudoConstant::campaignType();
     $this->add('select', 'campaign_type_id', ts('Campaign Type'),
-      array(
+      [
         '' => ts('- select -'),
-      ) + $campaignTypes
+      ] + $campaignTypes
     );
 
     $this->set('campaignTypes', $campaignTypes);
@@ -98,23 +98,23 @@ public function buildQuickForm() {
     //campaign status
     $campaignStatus = CRM_Campaign_PseudoConstant::campaignStatus();
     $this->addElement('select', 'status_id', ts('Campaign Status'),
-      array(
+      [
         '' => ts('- select -'),
-      ) + $campaignStatus
+      ] + $campaignStatus
     );
     $this->set('campaignStatus', $campaignStatus);
     $this->assign('campaignStatus', json_encode($campaignStatus));
 
     //active campaigns
-    $this->addElement('select', 'is_active', ts('Is Active?'), array(
+    $this->addElement('select', 'is_active', ts('Is Active?'), [
       '' => ts('- select -'),
       '0' => ts('Yes'),
       '1' => ts('No'),
-        )
+        ]
     );
 
     //build the array of all search params.
-    $this->_searchParams = array();
+    $this->_searchParams = [];
     foreach ($this->_elements as $element) {
       $name = $element->_attributes['name'];
       $label = $element->_label;
diff --git a/CRM/Campaign/Form/Search/Petition.php b/CRM/Campaign/Form/Search/Petition.php
index a43174ab1518..d23e9e88295c 100644
--- a/CRM/Campaign/Form/Search/Petition.php
+++ b/CRM/Campaign/Form/Search/Petition.php
@@ -76,12 +76,12 @@ public function buildQuickForm() {
 
     //campaigns
     $campaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE);
-    $this->add('select', 'petition_campaign_id', ts('Campaign'), array('' => ts('- select -')) + $campaigns);
+    $this->add('select', 'petition_campaign_id', ts('Campaign'), ['' => ts('- select -')] + $campaigns);
     $this->set('petitionCampaigns', $campaigns);
     $this->assign('petitionCampaigns', json_encode($campaigns));
 
     //build the array of all search params.
-    $this->_searchParams = array();
+    $this->_searchParams = [];
     foreach ($this->_elements as $element) {
       $name = $element->_attributes['name'];
       $label = $element->_label;
diff --git a/CRM/Campaign/Form/Search/Survey.php b/CRM/Campaign/Form/Search/Survey.php
index ee5682caa406..3cf35bf2ee5f 100644
--- a/CRM/Campaign/Form/Search/Survey.php
+++ b/CRM/Campaign/Form/Search/Survey.php
@@ -78,21 +78,21 @@ public function buildQuickForm() {
     //activity Type id
     $surveyTypes = CRM_Campaign_BAO_Survey::getSurveyActivityType();
     $this->add('select', 'activity_type_id',
-      ts('Activity Type'), array(
+      ts('Activity Type'), [
         '' => ts('- select -'),
-      ) + $surveyTypes
+      ] + $surveyTypes
     );
     $this->set('surveyTypes', $surveyTypes);
     $this->assign('surveyTypes', json_encode($surveyTypes));
 
     //campaigns
     $campaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE);
-    $this->add('select', 'survey_campaign_id', ts('Campaign'), array('' => ts('- select -')) + $campaigns);
+    $this->add('select', 'survey_campaign_id', ts('Campaign'), ['' => ts('- select -')] + $campaigns);
     $this->set('surveyCampaigns', $campaigns);
     $this->assign('surveyCampaigns', json_encode($campaigns));
 
     //build the array of all search params.
-    $this->_searchParams = array();
+    $this->_searchParams = [];
     foreach ($this->_elements as $element) {
       $name = $element->_attributes['name'];
       $label = $element->_label;
diff --git a/CRM/Campaign/Form/Survey.php b/CRM/Campaign/Form/Survey.php
index 981514751aba..05eec10ceee6 100644
--- a/CRM/Campaign/Form/Survey.php
+++ b/CRM/Campaign/Form/Survey.php
@@ -84,11 +84,11 @@ public function preProcess() {
     if ($this->_surveyId) {
       $this->_single = TRUE;
 
-      $params = array('id' => $this->_surveyId);
+      $params = ['id' => $this->_surveyId];
       CRM_Campaign_BAO_Survey::retrieve($params, $surveyInfo);
       $this->_surveyTitle = $surveyInfo['title'];
       $this->assign('surveyTitle', $this->_surveyTitle);
-      CRM_Utils_System::setTitle(ts('Configure Survey - %1', array(1 => $this->_surveyTitle)));
+      CRM_Utils_System::setTitle(ts('Configure Survey - %1', [1 => $this->_surveyTitle]));
     }
 
     $this->assign('action', $this->_action);
@@ -100,7 +100,7 @@ public function preProcess() {
     // CRM-11480, CRM-11682
     // Preload libraries required by the "Questions" tab
     CRM_UF_Page_ProfileEditor::registerProfileScripts();
-    CRM_UF_Page_ProfileEditor::registerSchemas(array('IndividualModel', 'ActivityModel'));
+    CRM_UF_Page_ProfileEditor::registerSchemas(['IndividualModel', 'ActivityModel']);
 
     CRM_Campaign_Form_Survey_TabHeader::build($this);
   }
@@ -111,39 +111,39 @@ public function preProcess() {
   public function buildQuickForm() {
     $session = CRM_Core_Session::singleton();
     if ($this->_surveyId) {
-      $buttons = array(
-        array(
+      $buttons = [
+        [
           'type' => 'upload',
           'name' => ts('Save'),
           'isDefault' => TRUE,
-        ),
-        array(
+        ],
+        [
           'type' => 'upload',
           'name' => ts('Save and Done'),
           'subName' => 'done',
-        ),
-        array(
+        ],
+        [
           'type' => 'upload',
           'name' => ts('Save and Next'),
           'spacing' => '                 ',
           'subName' => 'next',
-        ),
-      );
+        ],
+      ];
     }
     else {
-      $buttons = array(
-        array(
+      $buttons = [
+        [
           'type' => 'upload',
           'name' => ts('Continue'),
           'spacing' => '                 ',
           'isDefault' => TRUE,
-        ),
-      );
+        ],
+      ];
     }
-    $buttons[] = array(
+    $buttons[] = [
       'type' => 'cancel',
       'name' => ts('Cancel'),
-    );
+    ];
     $this->addButtons($buttons);
 
     $url = CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=survey');
@@ -158,7 +158,7 @@ public function endPostProcess() {
         $tabTitle = 'Main settings';
       }
       $subPage = strtolower($className);
-      CRM_Core_Session::setStatus(ts("'%1' have been saved.", array(1 => $tabTitle)), ts('Saved'), 'success');
+      CRM_Core_Session::setStatus(ts("'%1' have been saved.", [1 => $tabTitle]), ts('Saved'), 'success');
 
       $this->postProcessHook();
 
diff --git a/CRM/Campaign/Form/Survey/Delete.php b/CRM/Campaign/Form/Survey/Delete.php
index e7df3edb4121..8d32335eb8cb 100644
--- a/CRM/Campaign/Form/Survey/Delete.php
+++ b/CRM/Campaign/Form/Survey/Delete.php
@@ -60,7 +60,7 @@ public function preProcess() {
     }
 
     $this->_surveyId = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE);
-    $params = array('id' => $this->_surveyId);
+    $params = ['id' => $this->_surveyId];
     CRM_Campaign_BAO_Survey::retrieve($params, $surveyInfo);
     $this->_surveyTitle = $surveyInfo['title'];
     $this->assign('surveyTitle', $this->_surveyTitle);
@@ -71,17 +71,17 @@ public function preProcess() {
    * Build the form object.
    */
   public function buildQuickForm() {
-    $this->addButtons(array(
-        array(
+    $this->addButtons([
+        [
           'type' => 'next',
           'name' => ts('Delete'),
           'isDefault' => TRUE,
-        ),
-        array(
+        ],
+        [
           'type' => 'cancel',
           'name' => ts('Cancel'),
-        ),
-      )
+        ],
+      ]
     );
   }
 
@@ -91,7 +91,7 @@ public function buildQuickForm() {
   public function postProcess() {
     if ($this->_surveyId) {
       CRM_Campaign_BAO_Survey::del($this->_surveyId);
-      CRM_Core_Session::setStatus('', ts("'%1' survey has been deleted.", array(1 => $this->_surveyTitle)), 'success');
+      CRM_Core_Session::setStatus('', ts("'%1' survey has been deleted.", [1 => $this->_surveyTitle]), 'success');
       CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=survey'));
     }
     else {
diff --git a/CRM/Campaign/Form/Survey/Main.php b/CRM/Campaign/Form/Survey/Main.php
index 901981ab07da..24aae308b45b 100644
--- a/CRM/Campaign/Form/Survey/Main.php
+++ b/CRM/Campaign/Form/Survey/Main.php
@@ -68,14 +68,14 @@ public function preProcess() {
 
     if ($this->_name != 'Petition') {
       $url = CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=survey');
-      CRM_Utils_System::appendBreadCrumb(array(array('title' => ts('Survey Dashboard'), 'url' => $url)));
+      CRM_Utils_System::appendBreadCrumb([['title' => ts('Survey Dashboard'), 'url' => $url]]);
     }
 
     $this->_values = $this->get('values');
     if (!is_array($this->_values)) {
-      $this->_values = array();
+      $this->_values = [];
       if ($this->_surveyId) {
-        $params = array('id' => $this->_surveyId);
+        $params = ['id' => $this->_surveyId];
         CRM_Campaign_BAO_Survey::retrieve($params, $this->_values);
       }
       $this->set('values', $this->_values);
@@ -127,7 +127,7 @@ public function buildQuickForm() {
     $this->add('text', 'title', ts('Title'), CRM_Core_DAO::getAttribute('CRM_Campaign_DAO_Survey', 'title'), TRUE);
 
     // Activity Type id
-    $this->addSelect('activity_type_id', array('option_url' => 'civicrm/admin/campaign/surveyType'), TRUE);
+    $this->addSelect('activity_type_id', ['option_url' => 'civicrm/admin/campaign/surveyType'], TRUE);
 
     $this->addEntityRef('campaign_id', ts('Campaign'), [
       'entity' => 'Campaign',
@@ -136,7 +136,7 @@ public function buildQuickForm() {
     ]);
 
     // script / instructions
-    $this->add('wysiwyg', 'instructions', ts('Instructions for interviewers'), array('rows' => 5, 'cols' => 40));
+    $this->add('wysiwyg', 'instructions', ts('Instructions for interviewers'), ['rows' => 5, 'cols' => 40]);
 
     // release frequency
     $this->add('number', 'release_frequency', ts('Release Frequency'), CRM_Core_DAO::getAttribute('CRM_Campaign_DAO_Survey', 'release_frequency'));
@@ -191,12 +191,12 @@ public function postProcess() {
     if (!empty($this->_values['result_id'])) {
       $query = "SELECT COUNT(*) FROM civicrm_survey WHERE result_id = %1";
       $countSurvey = (int) CRM_Core_DAO::singleValueQuery($query,
-        array(
-          1 => array(
+        [
+          1 => [
             $this->_values['result_id'],
             'Positive',
-          ),
-        )
+          ],
+        ]
       );
       // delete option group if no any survey is using it.
       if (!$countSurvey) {
diff --git a/CRM/Campaign/Form/Survey/Questions.php b/CRM/Campaign/Form/Survey/Questions.php
index 1b83d1489704..b0cfd2ddba73 100644
--- a/CRM/Campaign/Form/Survey/Questions.php
+++ b/CRM/Campaign/Form/Survey/Questions.php
@@ -45,13 +45,13 @@ class CRM_Campaign_Form_Survey_Questions extends CRM_Campaign_Form_Survey {
    *   array of default values
    */
   public function setDefaultValues() {
-    $defaults = array();
+    $defaults = [];
 
-    $ufJoinParams = array(
+    $ufJoinParams = [
       'entity_table' => 'civicrm_survey',
       'module' => 'CiviCampaign',
       'entity_id' => $this->_surveyId,
-    );
+    ];
 
     list($defaults['contact_profile_id'], $second)
       = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
@@ -71,23 +71,23 @@ public function buildQuickForm() {
       CRM_Core_Session::setStatus(
         ts(
           'There are no custom data sets for activity type "%1". To create one, click here.',
-          array(
+          [
             1 => $activityTypes[$subTypeId],
             2 => CRM_Utils_System::url('civicrm/admin/custom/group', 'action=add&reset=1'),
             3 => '_blank',
-          )
+          ]
         )
       );
     }
 
     $allowCoreTypes = CRM_Campaign_BAO_Survey::surveyProfileTypes();
-    $allowSubTypes = array(
-      'ActivityType' => array($subTypeId),
-    );
-    $entities = array(
-      array('entity_name' => 'contact_1', 'entity_type' => 'IndividualModel'),
-      array('entity_name' => 'activity_1', 'entity_type' => 'ActivityModel', 'entity_sub_type' => $subTypeId),
-    );
+    $allowSubTypes = [
+      'ActivityType' => [$subTypeId],
+    ];
+    $entities = [
+      ['entity_name' => 'contact_1', 'entity_type' => 'IndividualModel'],
+      ['entity_name' => 'activity_1', 'entity_type' => 'ActivityModel', 'entity_sub_type' => $subTypeId],
+    ];
     $this->addProfileSelector('contact_profile_id', ts('Contact Info'), $allowCoreTypes, $allowSubTypes, $entities);
     $this->addProfileSelector('activity_profile_id', ts('Questions'), $allowCoreTypes, $allowSubTypes, $entities);
     // Note: Because this is in a tab, we also preload the schema via CRM_Campaign_Form_Survey::preProcess
@@ -104,17 +104,17 @@ public function postProcess() {
     $params = $this->controller->exportValues($this->_name);
 
     // also update the ProfileModule tables
-    $ufJoinParams = array(
+    $ufJoinParams = [
       'is_active' => 1,
       'module' => 'CiviCampaign',
       'entity_table' => 'civicrm_survey',
       'entity_id' => $this->_surveyId,
-    );
+    ];
 
     // first delete all past entries
     CRM_Core_BAO_UFJoin::deleteAll($ufJoinParams);
 
-    $uf = array();
+    $uf = [];
     $wt = 2;
     if (!empty($params['contact_profile_id'])) {
       $uf[1] = $params['contact_profile_id'];
diff --git a/CRM/Campaign/Form/Survey/Results.php b/CRM/Campaign/Form/Survey/Results.php
index 4dd86299f718..5c2946ac8e97 100644
--- a/CRM/Campaign/Form/Survey/Results.php
+++ b/CRM/Campaign/Form/Survey/Results.php
@@ -53,16 +53,16 @@ public function preProcess() {
 
     $this->_values = $this->get('values');
     if (!is_array($this->_values)) {
-      $this->_values = array();
+      $this->_values = [];
       if ($this->_surveyId) {
-        $params = array('id' => $this->_surveyId);
+        $params = ['id' => $this->_surveyId];
         CRM_Campaign_BAO_Survey::retrieve($params, $this->_values);
       }
       $this->set('values', $this->_values);
     }
 
     $query = "SELECT MAX(id) as id, title FROM civicrm_report_instance WHERE name = %1 GROUP BY id";
-    $params = array(1 => array("survey_{$this->_surveyId}", 'String'));
+    $params = [1 => ["survey_{$this->_surveyId}", 'String']];
     $result = CRM_Core_DAO::executeQuery($query, $params);
     if ($result->fetch()) {
       $this->_reportId = $result->id;
@@ -100,43 +100,43 @@ public function buildQuickForm() {
     $optionGroups = CRM_Campaign_BAO_Survey::getResultSets();
 
     if (empty($optionGroups)) {
-      $optionTypes = array('1' => ts('Create new result set'));
+      $optionTypes = ['1' => ts('Create new result set')];
     }
     else {
-      $optionTypes = array(
+      $optionTypes = [
         '1' => ts('Create new result set'),
         '2' => ts('Use existing result set'),
-      );
+      ];
       $this->add('select',
         'option_group_id',
         ts('Select Result Set'),
-        array(
+        [
           '' => ts('- select -'),
-        ) + $optionGroups, FALSE,
-        array('onChange' => 'loadOptionGroup( )')
+        ] + $optionGroups, FALSE,
+        ['onChange' => 'loadOptionGroup( )']
       );
     }
 
     $element = &$this->addRadio('option_type',
       ts('Survey Responses'),
       $optionTypes,
-      array(
+      [
         'onclick' => "showOptionSelect();",
-      ), '
', TRUE + ], '
', TRUE ); if (empty($optionGroups) || empty($this->_values['result_id'])) { - $this->setdefaults(array('option_type' => 1)); + $this->setdefaults(['option_type' => 1]); } elseif (!empty($this->_values['result_id'])) { - $this->setdefaults(array( + $this->setdefaults([ 'option_type' => 2, 'option_group_id' => $this->_values['result_id'], - )); + ]); } // form fields of Custom Option rows - $defaultOption = array(); + $defaultOption = []; $_showHide = new CRM_Core_ShowHideBlocks('', ''); $optionAttributes = CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue'); @@ -190,10 +190,10 @@ public function buildQuickForm() { $this->freeze('report_title'); } - $this->addFormRule(array( + $this->addFormRule([ 'CRM_Campaign_Form_Survey_Results', 'formRule', - ), $this); + ], $this); parent::buildQuickForm(); } @@ -208,7 +208,7 @@ public function buildQuickForm() { * @return array|bool */ public static function formRule($fields, $files, $form) { - $errors = array(); + $errors = []; if (!empty($fields['option_label']) && !empty($fields['option_value']) && (count(array_filter($fields['option_label'])) == 0) && (count(array_filter($fields['option_value'])) == 0) @@ -357,7 +357,7 @@ public function postProcess() { $resultSetOptGrpId = $params['option_group_id']; } - $recontactInterval = array(); + $recontactInterval = []; if ($updateResultSet) { $optionValue = new CRM_Core_DAO_OptionValue(); $optionValue->option_group_id = $resultSetOptGrpId; @@ -409,23 +409,23 @@ public function postProcess() { if (!$this->_reportId && $survey->id && !empty($params['create_report'])) { $activityStatus = CRM_Core_PseudoConstant::activityStatus('name'); $activityStatus = array_flip($activityStatus); - $this->_params = array( + $this->_params = [ 'name' => "survey_{$survey->id}", 'title' => $params['report_title'] ? $params['report_title'] : $this->_values['title'], 'status_id_op' => 'eq', 'status_id_value' => $activityStatus['Scheduled'], // reserved status - 'survey_id_value' => array($survey->id), + 'survey_id_value' => [$survey->id], 'description' => ts('Detailed report for canvassing, phone-banking, walk lists or other surveys.'), - ); + ]; //Default value of order by - $this->_params['order_bys'] = array( - 1 => array( + $this->_params['order_bys'] = [ + 1 => [ 'column' => 'sort_name', 'order' => 'ASC', - ), - ); + ], + ]; // for WalkList or default - $displayFields = array( + $displayFields = [ 'id', 'sort_name', 'result', @@ -433,28 +433,28 @@ public function postProcess() { 'street_name', 'street_unit', 'survey_response', - ); + ]; if (CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'WalkList') == $this->_values['activity_type_id'] ) { - $this->_params['order_bys'] = array( - 1 => array( + $this->_params['order_bys'] = [ + 1 => [ 'column' => 'street_name', 'order' => 'ASC', - ), - 2 => array( + ], + 2 => [ 'column' => 'street_number_odd_even', 'order' => 'ASC', - ), - 3 => array( + ], + 3 => [ 'column' => 'street_number', 'order' => 'ASC', - ), - 4 => array( + ], + 4 => [ 'column' => 'sort_name', 'order' => 'ASC', - ), - ); + ], + ]; } elseif (CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'PhoneBank') == $this->_values['activity_type_id'] @@ -476,16 +476,16 @@ public function postProcess() { CRM_Report_Form_Instance::postProcess($this, FALSE); $query = "SELECT MAX(id) FROM civicrm_report_instance WHERE name = %1"; - $reportID = CRM_Core_DAO::singleValueQuery($query, array( - 1 => array( + $reportID = CRM_Core_DAO::singleValueQuery($query, [ + 1 => [ "survey_{$survey->id}", 'String', - ), - )); + ], + ]); if ($reportID) { $url = CRM_Utils_System::url("civicrm/report/instance/{$reportID}", 'reset=1'); $status = ts("A Survey Detail Report %2 has been created.", - array(1 => $url, 2 => $this->_params['title'])); + [1 => $url, 2 => $this->_params['title']]); } } diff --git a/CRM/Campaign/Form/Survey/TabHeader.php b/CRM/Campaign/Form/Survey/TabHeader.php index c55ccbd91689..3aecece43a03 100644 --- a/CRM/Campaign/Form/Survey/TabHeader.php +++ b/CRM/Campaign/Form/Survey/TabHeader.php @@ -52,11 +52,11 @@ public static function build(&$form) { $form->assign_by_ref('tabHeader', $tabs); CRM_Core_Resources::singleton() ->addScriptFile('civicrm', 'templates/CRM/common/TabHeader.js', 1, 'html-header') - ->addSetting(array( - 'tabSettings' => array( + ->addSetting([ + 'tabSettings' => [ 'active' => self::getCurrentTab($tabs), - ), - )); + ], + ]); return $tabs; } @@ -70,29 +70,29 @@ public static function process(&$form) { return NULL; } - $tabs = array( - 'main' => array( + $tabs = [ + 'main' => [ 'title' => ts('Main Information'), 'link' => NULL, 'valid' => FALSE, 'active' => FALSE, 'current' => FALSE, - ), - 'questions' => array( + ], + 'questions' => [ 'title' => ts('Questions'), 'link' => NULL, 'valid' => FALSE, 'active' => FALSE, 'current' => FALSE, - ), - 'results' => array( + ], + 'results' => [ 'title' => ts('Results'), 'link' => NULL, 'valid' => FALSE, 'active' => FALSE, 'current' => FALSE, - ), - ); + ], + ]; $surveyID = $form->getVar('_surveyId'); $class = $form->getVar('_name'); diff --git a/CRM/Campaign/Form/SurveyType.php b/CRM/Campaign/Form/SurveyType.php index 4e5b91fe1641..f7a38ad6c01e 100644 --- a/CRM/Campaign/Form/SurveyType.php +++ b/CRM/Campaign/Form/SurveyType.php @@ -98,7 +98,7 @@ public function setDefaultValues() { $defaults = parent::setDefaultValues(); if (!isset($defaults['weight']) || !$defaults['weight']) { - $fieldValues = array('option_group_id' => $this->_gid); + $fieldValues = ['option_group_id' => $this->_gid]; $defaults['weight'] = CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_OptionValue', $fieldValues); } @@ -127,7 +127,7 @@ public function buildQuickForm() { if ($this->_action == CRM_Core_Action::UPDATE && CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', $this->_id, 'is_reserved') ) { - $this->freeze(array('label', 'is_active')); + $this->freeze(['label', 'is_active']); } $this->add('number', 'weight', ts('Order'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'weight'), TRUE); @@ -140,7 +140,7 @@ public function buildQuickForm() { public function postProcess() { if ($this->_action & CRM_Core_Action::DELETE) { - $fieldValues = array('option_group_id' => $this->_gid); + $fieldValues = ['option_group_id' => $this->_gid]; $wt = CRM_Utils_Weight::delWeight('CRM_Core_DAO_OptionValue', $this->_id, $fieldValues); if (CRM_Core_BAO_OptionValue::del($this->_id)) { @@ -148,7 +148,7 @@ public function postProcess() { } } else { - $params = $ids = array(); + $params = $ids = []; $params = $this->exportValues(); // set db value of filter in params if filter is non editable @@ -159,7 +159,7 @@ public function postProcess() { $params['component_id'] = CRM_Core_Component::getComponentID('CiviCampaign'); $optionValue = CRM_Core_OptionValue::addOptionValue($params, $this->_gName, $this->_action, $this->_id); - CRM_Core_Session::setStatus(ts('The Survey type \'%1\' has been saved.', array(1 => $optionValue->label)), ts('Saved'), 'success'); + CRM_Core_Session::setStatus(ts('The Survey type \'%1\' has been saved.', [1 => $optionValue->label]), ts('Saved'), 'success'); } } diff --git a/CRM/Campaign/Form/Task.php b/CRM/Campaign/Form/Task.php index fb721b5e09b9..86b7a269b930 100644 --- a/CRM/Campaign/Form/Task.php +++ b/CRM/Campaign/Form/Task.php @@ -54,7 +54,7 @@ public function preProcess() { $taskName = CRM_Utils_Array::value($this->_task, $campaignTasks); $this->assign('taskName', $taskName); - $ids = array(); + $ids = []; if ($values['radio_ts'] == 'ts_sel') { foreach ($values as $name => $value) { if (substr($name, 0, CRM_Core_Form::CB_PREFIX_LEN) == CRM_Core_Form::CB_PREFIX) { @@ -108,17 +108,17 @@ public function setContactIDs() { * @param bool $submitOnce */ public function addDefaultButtons($title, $nextType = 'next', $backType = 'back', $submitOnce = FALSE) { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => $nextType, 'name' => $title, 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => $backType, 'name' => ts('Cancel'), - ), - ) + ], + ] ); } diff --git a/CRM/Campaign/Form/Task/Interview.php b/CRM/Campaign/Form/Task/Interview.php index 82fdf3b6d324..30bc84499d95 100644 --- a/CRM/Campaign/Form/Task/Interview.php +++ b/CRM/Campaign/Form/Task/Interview.php @@ -74,11 +74,11 @@ public function preProcess() { $this->_reserveToInterview = $this->get('reserveToInterview'); if ($this->_reserveToInterview || $this->_votingTab) { //user came from voting tab / reserve form. - foreach (array( + foreach ([ 'surveyId', 'contactIds', 'interviewerId', - ) as $fld) { + ] as $fld) { $this->{"_$fld"} = $this->get($fld); } //get the target voter ids. @@ -94,7 +94,7 @@ public function preProcess() { } if ($this->_surveyId) { - $params = array('id' => $this->_surveyId); + $params = ['id' => $this->_surveyId]; CRM_Campaign_BAO_Survey::retrieve($params, $this->_surveyDetails); } @@ -106,27 +106,27 @@ public function preProcess() { } elseif ($walkListActivityId == $this->_surveyDetails['activity_type_id']) { $orderByParams - = array( - 1 => array( + = [ + 1 => [ 'column' => 'civicrm_address.street_name', 'order' => 'ASC', - ), - 2 => array( + ], + 2 => [ 'column' => 'civicrm_address.street_number%2', 'order' => 'ASC', - ), - 3 => array( + ], + 3 => [ 'column' => 'civicrm_address.street_number', 'order' => 'ASC', - ), - 4 => array( + ], + 4 => [ 'column' => 'contact_a.sort_name', 'order' => 'ASC', - ), - ); + ], + ]; } - $orderBy = array(); + $orderBy = []; if (!empty($orderByParams)) { foreach ($orderByParams as $key => $val) { if (!empty($val['column'])) { @@ -148,7 +148,7 @@ public function preProcess() { WHERE {$clause} {$orderClause}"; - $this->_contactIds = array(); + $this->_contactIds = []; $dao = CRM_Core_DAO::executeQuery($sql); while ($dao->fetch()) { $this->_contactIds[] = $dao->id; @@ -156,10 +156,10 @@ public function preProcess() { } //get the contact read only fields to display. - $readOnlyFields = array_merge(array( + $readOnlyFields = array_merge([ 'contact_type' => '', 'sort_name' => ts('Name'), - )); + ]); //get the read only field data. $returnProperties = array_fill_keys(array_keys($readOnlyFields), 1); @@ -173,7 +173,7 @@ public function preProcess() { ); $scheduledStatusId = CRM_Core_PseudoConstant::getKey('CRM_Activity_DAO_Activity', 'activity_status_id', 'Scheduled'); - $activityIds = array(); + $activityIds = []; foreach ($this->_contactIds as $key => $voterId) { $actVals = CRM_Utils_Array::value($voterId, $this->_surveyActivityIds); $statusId = CRM_Utils_Array::value('status_id', $actVals); @@ -216,9 +216,9 @@ public function preProcess() { //get the survey values. $this->_surveyValues = $this->get('surveyValues'); if (!is_array($this->_surveyValues)) { - $this->_surveyValues = array(); + $this->_surveyValues = []; if ($this->_surveyId) { - $surveyParams = array('id' => $this->_surveyId); + $surveyParams = ['id' => $this->_surveyId]; CRM_Campaign_BAO_Survey::retrieve($surveyParams, $this->_surveyValues); } $this->set('surveyValues', $this->_surveyValues); @@ -231,7 +231,7 @@ public function preProcess() { //get the survey result options. $this->_resultOptions = $this->get('resultOptions'); if (!is_array($this->_resultOptions)) { - $this->_resultOptions = array(); + $this->_resultOptions = []; if ($resultOptionId = CRM_Utils_Array::value('result_id', $this->_surveyValues)) { $this->_resultOptions = CRM_Core_OptionGroup::valuesByID($resultOptionId); } @@ -244,24 +244,24 @@ public function preProcess() { //append breadcrumb to survey dashboard. if (CRM_Campaign_BAO_Campaign::accessCampaign()) { $url = CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=survey'); - CRM_Utils_System::appendBreadCrumb(array(array('title' => ts('Survey(s)'), 'url' => $url))); + CRM_Utils_System::appendBreadCrumb([['title' => ts('Survey(s)'), 'url' => $url]]); } //set the title. $this->_surveyTypeId = CRM_Utils_Array::value('activity_type_id', $this->_surveyValues); $surveyTypeLabel = CRM_Core_PseudoConstant::getLabel('CRM_Activity_BAO_Activity', 'activity_type_id', $this->_surveyTypeId); - CRM_Utils_System::setTitle(ts('Record %1 Responses', array(1 => $surveyTypeLabel))); + CRM_Utils_System::setTitle(ts('Record %1 Responses', [1 => $surveyTypeLabel])); } public function validateIds() { - $required = array( + $required = [ 'surveyId' => ts('Could not find Survey.'), 'interviewerId' => ts('Could not find Interviewer.'), 'contactIds' => ts('No respondents are currently reserved for you to interview.'), 'resultOptions' => ts('Oops. It looks like there is no response option configured.'), - ); + ]; - $errorMessages = array(); + $errorMessages = []; foreach ($required as $fld => $msg) { if (empty($this->{"_$fld"})) { if (!$this->_votingTab) { @@ -282,19 +282,19 @@ public function buildQuickForm() { $this->assign('surveyTypeId', $this->_surveyTypeId); $options - = array( + = [ '' => ' - none - ', 'civicrm_address.street_name' => 'Street Name', 'civicrm_address.street_number%2' => 'Odd / Even Street Number', 'civicrm_address.street_number' => 'Street Number', 'contact_a.sort_name' => 'Respondent Name', - ); + ]; for ($i = 1; $i < count($options); $i++) { $this->addElement('select', "order_bys[{$i}][column]", ts('Order by Column'), $options); - $this->addElement('select', "order_bys[{$i}][order]", ts('Order by Order'), array( + $this->addElement('select', "order_bys[{$i}][order]", ts('Order by Order'), [ 'ASC' => ts('Ascending'), 'DESC' => ts('Descending'), - )); + ]); } //pickup the uf fields. @@ -313,9 +313,9 @@ public function buildQuickForm() { //build the result field. if (!empty($this->_resultOptions)) { $this->add('select', "field[$contactId][result]", ts('Result'), - array( + [ '' => ts('- select -'), - ) + + ] + array_combine($this->_resultOptions, $this->_resultOptions) ); } @@ -326,7 +326,7 @@ public function buildQuickForm() { if ($this->_allowAjaxReleaseButton) { $this->addElement('hidden', "field[{$contactId}][is_release_or_reserve]", 0, - array('id' => "field_{$contactId}_is_release_or_reserve") + ['id' => "field_{$contactId}_is_release_or_reserve"] ); } } @@ -337,20 +337,20 @@ public function buildQuickForm() { return; } - $buttons = array( - array( + $buttons = [ + [ 'type' => 'cancel', 'name' => ts('Done'), 'subName' => 'interview', 'isDefault' => TRUE, - ), - ); + ], + ]; - $buttons[] = array( + $buttons[] = [ 'type' => 'submit', 'name' => ts('Order By >>'), 'subName' => 'orderBy', - ); + ]; $manageCampaign = CRM_Core_Permission::check('manage campaign'); $adminCampaign = CRM_Core_Permission::check('administer CiviCampaign'); @@ -358,21 +358,21 @@ public function buildQuickForm() { $adminCampaign || CRM_Core_Permission::check('release campaign contacts') ) { - $buttons[] = array( + $buttons[] = [ 'type' => 'next', 'name' => ts('Release Respondents >>'), 'subName' => 'interviewToRelease', - ); + ]; } if ($manageCampaign || $adminCampaign || CRM_Core_Permission::check('reserve campaign contacts') ) { - $buttons[] = array( + $buttons[] = [ 'type' => 'done', 'name' => ts('Reserve More Respondents >>'), 'subName' => 'interviewToReserve', - ); + ]; } $this->addButtons($buttons); @@ -383,7 +383,7 @@ public function buildQuickForm() { */ public function setDefaultValues() { //load default data for only contact fields. - $contactFields = $defaults = array(); + $contactFields = $defaults = []; foreach ($this->_surveyFields as $name => $field) { $acceptable_types = CRM_Contact_BAO_ContactType::basicTypes(); $acceptable_types[] = 'Contact'; @@ -400,33 +400,33 @@ public function setDefaultValues() { $walkListActivityId = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'WalkList'); if ($walkListActivityId == $this->_surveyDetails['activity_type_id']) { $defaults['order_bys'] - = array( - 1 => array( + = [ + 1 => [ 'column' => 'civicrm_address.street_name', 'order' => 'ASC', - ), - 2 => array( + ], + 2 => [ 'column' => 'civicrm_address.street_number%2', 'order' => 'ASC', - ), - 3 => array( + ], + 3 => [ 'column' => 'civicrm_address.street_number', 'order' => 'ASC', - ), - 4 => array( + ], + 4 => [ 'column' => 'contact_a.sort_name', 'order' => 'ASC', - ), - ); + ], + ]; } else { $defaults['order_bys'] - = array( - 1 => array( + = [ + 1 => [ 'column' => 'contact_a.sort_name', 'order' => 'ASC', - ), - ); + ], + ]; } return $defaults; } @@ -442,11 +442,11 @@ public function postProcess() { } elseif ($buttonName == '_qf_Interview_next_interviewToRelease') { //get ready to jump to release form. - foreach (array( + foreach ([ 'surveyId', 'contactIds', 'interviewerId', - ) as $fld) { + ] as $fld) { $this->controller->set($fld, $this->{"_$fld"}); } $this->controller->set('interviewToRelease', TRUE); @@ -493,9 +493,9 @@ public static function registerInterview($params) { CRM_Core_BAO_CustomValueTable::store($customParams, 'civicrm_activity', $activityId); //process contact data. - $contactParams = $fields = array(); + $contactParams = $fields = []; - $contactFieldTypes = array_merge(array('Contact'), CRM_Contact_BAO_ContactType::basicTypes()); + $contactFieldTypes = array_merge(['Contact'], CRM_Contact_BAO_ContactType::basicTypes()); $responseFields = CRM_Campaign_BAO_Survey::getSurveyResponseFields($params['survey_id']); if (!empty($responseFields)) { foreach ($params as $key => $value) { @@ -538,7 +538,7 @@ public static function registerInterview($params) { $subject .= ts('Respondent Interview'); $activity->subject = $subject; - $activityParams = array( + $activityParams = [ 'details' => 'details', 'result' => 'result', 'engagement_level' => 'activity_engagement_level', @@ -548,7 +548,7 @@ public static function registerInterview($params) { 'location' => 'activity_location', 'campaign_id' => 'activity_campaign_id', 'duration' => 'activity_duration', - ); + ]; foreach ($activityParams as $key => $field) { if (!empty($params[$field])) { $activity->$key = $params[$field]; @@ -585,7 +585,7 @@ public function getVoterIds() { $this->_interviewerId, $statusIds ); - $this->_contactIds = array(); + $this->_contactIds = []; foreach ($surveyActivities as $val) { $this->_contactIds[$val['voter_id']] = $val['voter_id']; } @@ -635,7 +635,7 @@ public function filterVoterIds() { INNER JOIN {$tempTableName} ON ( {$tempTableName}.survey_contact_id = contact.id ) WHERE contact.contact_type != %1"; $removeContact = CRM_Core_DAO::executeQuery($query, - array(1 => array($profileType, 'String')) + [1 => [$profileType, 'String']] ); while ($removeContact->fetch()) { unset($this->_contactIds[$removeContact->id]); diff --git a/CRM/Campaign/Form/Task/Print.php b/CRM/Campaign/Form/Task/Print.php index 6ac3b52f0198..e6fea042b596 100644 --- a/CRM/Campaign/Form/Task/Print.php +++ b/CRM/Campaign/Form/Task/Print.php @@ -81,18 +81,18 @@ public function buildQuickForm() { // // just need to add a javacript to popup the window for printing // - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => ts('Print Respondents'), - 'js' => array('onclick' => 'window.print()'), + 'js' => ['onclick' => 'window.print()'], 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'back', 'name' => ts('Done'), - ), - ) + ], + ] ); } diff --git a/CRM/Campaign/Form/Task/Release.php b/CRM/Campaign/Form/Task/Release.php index d8b34a1a5560..c45a8d536951 100644 --- a/CRM/Campaign/Form/Task/Release.php +++ b/CRM/Campaign/Form/Task/Release.php @@ -66,11 +66,11 @@ public function preProcess() { $this->_interviewToRelease = $this->get('interviewToRelease'); if ($this->_interviewToRelease) { //user came from interview form. - foreach (array( + foreach ([ 'surveyId', 'contactIds', 'interviewerId', - ) as $fld) { + ] as $fld) { $this->{"_$fld"} = $this->get($fld); } @@ -95,15 +95,15 @@ public function preProcess() { CRM_Core_Error::statusBounce(ts('Could not find respondents to release.')); } - $surveyDetails = array(); - $params = array('id' => $this->_surveyId); + $surveyDetails = []; + $params = ['id' => $this->_surveyId]; $this->_surveyDetails = CRM_Campaign_BAO_Survey::retrieve($params, $surveyDetails); $activityStatus = CRM_Core_PseudoConstant::activityStatus('name'); - $statusIds = array(); - foreach (array( + $statusIds = []; + foreach ([ 'Scheduled', - ) as $name) { + ] as $name) { if ($statusId = array_search($name, $activityStatus)) { $statusIds[] = $statusId; } @@ -123,7 +123,7 @@ public function preProcess() { //append breadcrumb to survey dashboard. if (CRM_Campaign_BAO_Campaign::accessCampaign()) { $url = CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=survey'); - CRM_Utils_System::appendBreadCrumb(array(array('title' => ts('Survey(s)'), 'url' => $url))); + CRM_Utils_System::appendBreadCrumb([['title' => ts('Survey(s)'), 'url' => $url]]); } //set the title. @@ -139,7 +139,7 @@ public function buildQuickForm() { } public function postProcess() { - $deleteActivityIds = array(); + $deleteActivityIds = []; foreach ($this->_contactIds as $cid) { if (array_key_exists($cid, $this->_surveyActivities)) { $deleteActivityIds[] = $this->_surveyActivities[$cid]['activity_id']; @@ -152,19 +152,19 @@ public function postProcess() { CRM_Core_DAO::executeQuery($query); if ($deleteActivityIds) { - $status = ts("Respondent has been released.", array( + $status = ts("Respondent has been released.", [ 'count' => count($deleteActivityIds), 'plural' => '%count respondents have been released.', - )); + ]); CRM_Core_Session::setStatus($status, ts('Released'), 'success'); } if (count($this->_contactIds) > count($deleteActivityIds)) { $status = ts('1 respondent did not release.', - array( + [ 'count' => (count($this->_contactIds) - count($deleteActivityIds)), 'plural' => '%count respondents did not release.', - ) + ] ); CRM_Core_Session::setStatus($status, ts('Notice'), 'alert'); } diff --git a/CRM/Campaign/Form/Task/Reserve.php b/CRM/Campaign/Form/Task/Reserve.php index 0d95e2b21a60..639156c16451 100644 --- a/CRM/Campaign/Form/Task/Reserve.php +++ b/CRM/Campaign/Form/Task/Reserve.php @@ -82,13 +82,13 @@ public function preProcess() { CRM_Core_Error::statusBounce(ts("Could not find contacts for reservation.")); } - $params = array('id' => $this->_surveyId); + $params = ['id' => $this->_surveyId]; CRM_Campaign_BAO_Survey::retrieve($params, $this->_surveyDetails); //get the survey activities. $activityStatus = CRM_Core_PseudoConstant::activityStatus('name'); - $statusIds = array(); - foreach (array('Scheduled') as $name) { + $statusIds = []; + foreach (['Scheduled'] as $name) { if ($statusId = array_search($name, $activityStatus)) { $statusIds[] = $statusId; } @@ -111,7 +111,7 @@ public function preProcess() { //append breadcrumb to survey dashboard. if (CRM_Campaign_BAO_Campaign::accessCampaign()) { $url = CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=survey'); - CRM_Utils_System::appendBreadCrumb(array(array('title' => ts('Survey(s)'), 'url' => $url))); + CRM_Utils_System::appendBreadCrumb([['title' => ts('Survey(s)'), 'url' => $url]]); } //set the title. @@ -127,10 +127,10 @@ public function validateSurvey() { } elseif (count($this->_contactIds) > ($maxVoters - $this->_numVoters)) { $errorMsg = ts('You can reserve a maximum of %count contact at a time for this survey.', - array( + [ 'plural' => 'You can reserve a maximum of %count contacts at a time for this survey.', 'count' => $maxVoters - $this->_numVoters, - ) + ] ); } } @@ -138,10 +138,10 @@ public function validateSurvey() { $defaultNum = CRM_Utils_Array::value('default_number_of_contacts', $this->_surveyDetails); if (!$errorMsg && $defaultNum && (count($this->_contactIds) > $defaultNum)) { $errorMsg = ts('You can reserve a maximum of %count contact at a time for this survey.', - array( + [ 'plural' => 'You can reserve a maximum of %count contacts at a time for this survey.', 'count' => $defaultNum, - ) + ] ); } @@ -163,37 +163,37 @@ public function buildQuickForm() { if (is_array($groups) && !empty($groups)) { $hasExistingGroups = TRUE; $this->addElement('select', 'groups', ts('Add respondent(s) to existing group(s)'), - $groups, array('multiple' => "multiple", 'class' => 'crm-select2') + $groups, ['multiple' => "multiple", 'class' => 'crm-select2'] ); } $this->assign('hasExistingGroups', $hasExistingGroups); - $buttons = array( - array( + $buttons = [ + [ 'type' => 'done', 'name' => ts('Reserve'), 'subName' => 'reserve', 'isDefault' => TRUE, - ), - ); + ], + ]; if (CRM_Core_Permission::check('manage campaign') || CRM_Core_Permission::check('administer CiviCampaign') || CRM_Core_Permission::check('interview campaign contacts') ) { - $buttons[] = array( + $buttons[] = [ 'type' => 'next', 'name' => ts('Reserve and Interview'), 'subName' => 'reserveToInterview', - ); + ]; } - $buttons[] = array( + $buttons[] = [ 'type' => 'back', 'name' => ts('Cancel'), - ); + ]; $this->addButtons($buttons); - $this->addFormRule(array('CRM_Campaign_Form_Task_Reserve', 'formRule'), $this); + $this->addFormRule(['CRM_Campaign_Form_Task_Reserve', 'formRule'], $this); } /** @@ -209,19 +209,19 @@ public function buildQuickForm() { * list of errors to be posted back to the form */ public static function formRule($fields, $files, $self) { - $errors = array(); + $errors = []; $invalidGroupName = FALSE; if (!empty($fields['newGroupName'])) { $title = trim($fields['newGroupName']); $name = CRM_Utils_String::titleToVar($title); $query = 'select count(*) from civicrm_group where name like %1 OR title like %2'; - $grpCnt = CRM_Core_DAO::singleValueQuery($query, array( - 1 => array($name, 'String'), - 2 => array($title, 'String'), - )); + $grpCnt = CRM_Core_DAO::singleValueQuery($query, [ + 1 => [$name, 'String'], + 2 => [$title, 'String'], + ]); if ($grpCnt) { $invalidGroupName = TRUE; - $errors['newGroupName'] = ts('Group \'%1\' already exists.', array(1 => $fields['newGroupName'])); + $errors['newGroupName'] = ts('Group \'%1\' already exists.', [1 => $fields['newGroupName']]); } } $self->assign('invalidGroupName', $invalidGroupName); @@ -239,14 +239,14 @@ public function postProcess() { $activityStatus = CRM_Core_PseudoConstant::activityStatus('name'); $statusHeld = array_search('Scheduled', $activityStatus); - $reservedVoterIds = array(); + $reservedVoterIds = []; foreach ($this->_contactIds as $cid) { $subject = $this->_surveyDetails['title'] . ' - ' . ts('Respondent Reservation'); $session = CRM_Core_Session::singleton(); - $activityParams = array( + $activityParams = [ 'source_contact_id' => $session->get('userID'), - 'assignee_contact_id' => array($this->_interviewerId), - 'target_contact_id' => array($cid), + 'assignee_contact_id' => [$this->_interviewerId], + 'target_contact_id' => [$cid], 'source_record_id' => $this->_surveyId, 'activity_type_id' => $this->_surveyDetails['activity_type_id'], 'subject' => $subject, @@ -254,7 +254,7 @@ public function postProcess() { 'status_id' => $statusHeld, 'skipRecentView' => 1, 'campaign_id' => CRM_Utils_Array::value('campaign_id', $this->_surveyDetails), - ); + ]; $activity = CRM_Activity_BAO_Activity::create($activityParams); if ($activity->id) { $countVoters++; @@ -270,10 +270,10 @@ public function postProcess() { // Success message if ($countVoters > 0) { - $status = '

' . ts("%count contact has been reserved.", array('plural' => '%count contacts have been reserved.', 'count' => $countVoters)) . '

'; + $status = '

' . ts("%count contact has been reserved.", ['plural' => '%count contacts have been reserved.', 'count' => $countVoters]) . '

'; if ($groupAdditions) { $status .= '

' . ts('They have been added to %1.', - array(1 => implode(' ' . ts('and') . ' ', $groupAdditions)) + [1 => implode(' ' . ts('and') . ' ', $groupAdditions)] ) . '

'; } CRM_Core_Session::setStatus($status, ts('Reservation Added'), 'success'); @@ -281,10 +281,10 @@ public function postProcess() { // Error message if (count($this->_contactIds) > $countVoters) { CRM_Core_Session::setStatus(ts('Reservation did not add for %count contact.', - array( + [ 'plural' => 'Reservation did not add for %count contacts.', 'count' => (count($this->_contactIds) - $countVoters), - ) + ] ), ts('Notice')); } @@ -306,24 +306,24 @@ public function postProcess() { * @return array */ private function _addRespondentToGroup($contactIds) { - $groupAdditions = array(); + $groupAdditions = []; if (empty($contactIds)) { return $groupAdditions; } $params = $this->controller->exportValues($this->_name); - $groups = CRM_Utils_Array::value('groups', $params, array()); + $groups = CRM_Utils_Array::value('groups', $params, []); $newGroupName = CRM_Utils_Array::value('newGroupName', $params); $newGroupDesc = CRM_Utils_Array::value('newGroupDesc', $params); $newGroupId = NULL; //create new group. if ($newGroupName) { - $grpParams = array( + $grpParams = [ 'title' => $newGroupName, 'description' => $newGroupDesc, 'is_active' => TRUE, - ); + ]; $group = CRM_Contact_BAO_Group::create($grpParams); $groups[] = $newGroupId = $group->id; } diff --git a/CRM/Campaign/Form/Task/Result.php b/CRM/Campaign/Form/Task/Result.php index 65543a1aec56..88185e585973 100644 --- a/CRM/Campaign/Form/Task/Result.php +++ b/CRM/Campaign/Form/Task/Result.php @@ -46,13 +46,13 @@ public function preProcess() { * Build the form object. */ public function buildQuickForm() { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'done', 'name' => ts('Done'), 'isDefault' => TRUE, - ), - ) + ], + ] ); } diff --git a/CRM/Campaign/Info.php b/CRM/Campaign/Info.php index 6cd4a7953e17..07b5373ff318 100644 --- a/CRM/Campaign/Info.php +++ b/CRM/Campaign/Info.php @@ -45,13 +45,13 @@ class CRM_Campaign_Info extends CRM_Core_Component_Info { * @return array */ public function getInfo() { - return array( + return [ 'name' => 'CiviCampaign', 'translatedName' => ts('CiviCampaign'), 'title' => ts('CiviCRM Campaign Engine'), 'search' => 1, 'showActivitiesInCore' => 1, - ); + ]; } @@ -64,35 +64,35 @@ public function getInfo() { * @return array */ public function getPermissions($getAllUnconditionally = FALSE, $descriptions = FALSE) { - $permissions = array( - 'administer CiviCampaign' => array( + $permissions = [ + 'administer CiviCampaign' => [ ts('administer CiviCampaign'), ts('Create new campaign, survey and petition types and their status'), - ), - 'manage campaign' => array( + ], + 'manage campaign' => [ ts('manage campaign'), ts('Create new campaigns, surveys and petitions, reserve respondents'), - ), - 'reserve campaign contacts' => array( + ], + 'reserve campaign contacts' => [ ts('reserve campaign contacts'), ts('Reserve campaign contacts for surveys and petitions'), - ), - 'release campaign contacts' => array( + ], + 'release campaign contacts' => [ ts('release campaign contacts'), ts('Release reserved campaign contacts for surveys and petitions'), - ), - 'interview campaign contacts' => array( + ], + 'interview campaign contacts' => [ ts('interview campaign contacts'), ts('Record survey and petition responses from their reserved contacts'), - ), - 'gotv campaign contacts' => array( + ], + 'gotv campaign contacts' => [ ts('GOTV campaign contacts'), ts('Record that contacts voted'), - ), - 'sign CiviCRM Petition' => array( + ], + 'sign CiviCRM Petition' => [ ts('sign CiviCRM Petition'), - ), - ); + ], + ]; if (!$descriptions) { foreach ($permissions as $name => $attr) { @@ -162,20 +162,20 @@ public function creatNewShortcut(&$shortCuts) { if (CRM_Core_Permission::check('manage campaign') || CRM_Core_Permission::check('administer CiviCampaign') ) { - $shortCuts = array_merge($shortCuts, array( - array( + $shortCuts = array_merge($shortCuts, [ + [ 'path' => 'civicrm/campaign/add', 'query' => "reset=1&action=add", 'ref' => 'new-campaign', 'title' => ts('Campaign'), - ), - array( + ], + [ 'path' => 'civicrm/survey/add', 'query' => "reset=1&action=add", 'ref' => 'new-survey', 'title' => ts('Survey'), - ), - )); + ], + ]); } } diff --git a/CRM/Campaign/Page/AJAX.php b/CRM/Campaign/Page/AJAX.php index ccb04eeed6cd..a784ef99af20 100644 --- a/CRM/Campaign/Page/AJAX.php +++ b/CRM/Campaign/Page/AJAX.php @@ -38,7 +38,7 @@ class CRM_Campaign_Page_AJAX { public static function registerInterview() { - $fields = array( + $fields = [ 'result', 'voter_id', 'survey_id', @@ -46,9 +46,9 @@ public static function registerInterview() { 'surveyTitle', 'interviewer_id', 'activity_type_id', - ); + ]; - $params = array(); + $params = []; foreach ($fields as $fld) { $params[$fld] = CRM_Utils_Array::value($fld, $_POST); } @@ -82,11 +82,11 @@ public static function registerInterview() { } } - $result = array( + $result = [ 'status' => 'fail', 'voter_id' => $voterId, 'activity_id' => $params['interviewer_id'], - ); + ]; //time to validate custom data. $errors = CRM_Core_BAO_CustomField::validateCustomData($params); @@ -108,7 +108,7 @@ public static function loadOptionGroupDetails() { $id = CRM_Utils_Request::retrieve('option_group_id', 'Integer', CRM_Core_DAO::$_nullObject, FALSE, NULL, 'POST'); $status = 'fail'; - $opValues = array(); + $opValues = []; if ($id) { $groupParams['id'] = $id; @@ -136,10 +136,10 @@ public static function loadOptionGroupDetails() { $status = 'success'; } - $result = array( + $result = [ 'status' => $status, 'result' => $opValues, - ); + ]; CRM_Utils_JSON::output($result); } @@ -149,7 +149,7 @@ public function voterList() { $searchCriteria = CRM_Utils_Request::retrieve('searchCriteria', 'String', CRM_Core_DAO::$_nullObject, FALSE, NULL, 'POST'); $searchParams = explode(',', $searchCriteria); - $params = $searchRows = array(); + $params = $searchRows = []; foreach ($searchParams as $param) { if (!empty($_POST[$param])) { $params[$param] = $_POST[$param]; @@ -157,10 +157,10 @@ public function voterList() { } //format multi-select group and contact types. - foreach (array( + foreach ([ 'group', 'contact_type', - ) as $param) { + ] as $param) { $paramValue = CRM_Utils_Array::value($param, $params); if ($paramValue) { unset($params[$param]); @@ -171,12 +171,12 @@ public function voterList() { } } - $voterClauseParams = array(); - foreach (array( + $voterClauseParams = []; + foreach ([ 'campaign_survey_id', 'survey_interviewer_id', 'campaign_search_voter_for', - ) as $fld) { + ] as $fld) { $voterClauseParams[$fld] = CRM_Utils_Array::value($fld, $params); } @@ -224,42 +224,42 @@ public function voterList() { } } - $selectorCols = array( + $selectorCols = [ 'sort_name', 'street_address', 'street_name', 'street_number', 'street_unit', - ); + ]; // get the data table params. - $dataTableParams = array( - 'sEcho' => array( + $dataTableParams = [ + 'sEcho' => [ 'name' => 'sEcho', 'type' => 'Integer', 'default' => 0, - ), - 'offset' => array( + ], + 'offset' => [ 'name' => 'iDisplayStart', 'type' => 'Integer', 'default' => 0, - ), - 'rowCount' => array( + ], + 'rowCount' => [ 'name' => 'iDisplayLength', 'type' => 'Integer', 'default' => 25, - ), - 'sort' => array( + ], + 'sort' => [ 'name' => 'iSortCol_0', 'type' => 'Integer', 'default' => 'sort_name', - ), - 'sortOrder' => array( + ], + 'sortOrder' => [ 'name' => 'sSortDir_0', 'type' => 'String', 'default' => 'asc', - ), - ); + ], + ]; foreach ($dataTableParams as $pName => $pValues) { $$pName = $pValues['default']; if (!empty($_POST[$pValues['name']])) { @@ -291,14 +291,14 @@ public function voterList() { $iTotal = $searchCount; - $selectorCols = array( + $selectorCols = [ 'contact_type', 'sort_name', 'street_address', 'street_name', 'street_number', 'street_unit', - ); + ]; $extraVoterColName = 'is_interview_conducted'; if ($params['campaign_search_voter_for'] == 'reserve') { @@ -328,7 +328,7 @@ public function voterList() { $result->contact_id ); - $searchRows[$contactID] = array('id' => $contactID); + $searchRows[$contactID] = ['id' => $contactID]; foreach ($selectorCols as $col) { $val = $result->$col; if ($col == 'contact_type') { @@ -357,7 +357,7 @@ public function voterList() { } } - $selectorElements = array_merge($selectorCols, array($extraVoterColName)); + $selectorElements = array_merge($selectorCols, [$extraVoterColName]); $iFilteredTotal = $iTotal; @@ -400,13 +400,13 @@ public function processVoterData() { } } if ($createActivity) { - $ids = array( + $ids = [ 'source_record_id', 'source_contact_id', 'target_contact_id', 'assignee_contact_id', - ); - $activityParams = array(); + ]; + $activityParams = []; foreach ($ids as $id) { $val = CRM_Utils_Array::value($id, $_POST); if (!$val) { @@ -421,12 +421,12 @@ public function processVoterData() { $activityStatus = CRM_Core_PseudoConstant::activityStatus('name'); $scheduledStatusId = array_search('Scheduled', $activityStatus); if ($isReserved) { - $surveyValues = array(); - $surveyParams = array('id' => $activityParams['source_record_id']); + $surveyValues = []; + $surveyParams = ['id' => $activityParams['source_record_id']]; CRM_Core_DAO::commonRetrieve('CRM_Campaign_DAO_Survey', $surveyParams, $surveyValues, - array('title', 'activity_type_id', 'campaign_id') + ['title', 'activity_type_id', 'campaign_id'] ); $activityTypeId = $surveyValues['activity_type_id']; @@ -451,11 +451,11 @@ public function processVoterData() { } else { //delete reserved activity for given voter. - $voterIds = array($activityParams['target_contact_id']); + $voterIds = [$activityParams['target_contact_id']]; $activities = CRM_Campaign_BAO_Survey::voterActivityDetails($activityParams['source_record_id'], $voterIds, $activityParams['source_contact_id'], - array($scheduledStatusId) + [$scheduledStatusId] ); foreach ($activities as $voterId => $values) { $activityId = CRM_Utils_Array::value('activity_id', $values); @@ -491,14 +491,14 @@ public function processVoterData() { } } - CRM_Utils_JSON::output(array('status' => $status)); + CRM_Utils_JSON::output(['status' => $status]); } public function campaignGroups() { $surveyId = CRM_Utils_Request::retrieve('survey_id', 'Positive', CRM_Core_DAO::$_nullObject, FALSE, NULL, 'POST' ); - $campGroups = array(); + $campGroups = []; if ($surveyId) { $campaignId = CRM_Core_DAO::getFieldValue('CRM_Campaign_DAO_Survey', $surveyId, 'campaign_id'); if ($campaignId) { @@ -511,22 +511,22 @@ public function campaignGroups() { if (empty($campGroups)) { $campGroups = CRM_Core_PseudoConstant::group(); } - $groups = array( - array( + $groups = [ + [ 'value' => '', 'title' => ts('- select -'), - ), - ); + ], + ]; foreach ($campGroups as $grpId => $title) { - $groups[] = array( + $groups[] = [ 'value' => $grpId, 'title' => $title, - ); + ]; } - $results = array( + $results = [ 'status' => 'success', 'groups' => $groups, - ); + ]; CRM_Utils_JSON::output($results); } @@ -540,7 +540,7 @@ public static function campaignList() { $searchCriteria = CRM_Utils_Request::retrieve('searchCriteria', 'String', CRM_Core_DAO::$_nullObject, FALSE, NULL, 'POST'); $searchParams = explode(',', $searchCriteria); - $params = $searchRows = array(); + $params = $searchRows = []; foreach ($searchParams as $param) { if (isset($_POST[$param])) { $params[$param] = $_POST[$param]; @@ -548,7 +548,7 @@ public static function campaignList() { } //this is sequence columns on datatable. - $selectorCols = array( + $selectorCols = [ 'id', 'name', 'title', @@ -562,36 +562,36 @@ public static function campaignList() { 'is_active', 'isActive', 'action', - ); + ]; // get the data table params. - $dataTableParams = array( - 'sEcho' => array( + $dataTableParams = [ + 'sEcho' => [ 'name' => 'sEcho', 'type' => 'Integer', 'default' => 0, - ), - 'offset' => array( + ], + 'offset' => [ 'name' => 'iDisplayStart', 'type' => 'Integer', 'default' => 0, - ), - 'rowCount' => array( + ], + 'rowCount' => [ 'name' => 'iDisplayLength', 'type' => 'Integer', 'default' => 25, - ), - 'sort' => array( + ], + 'sort' => [ 'name' => 'iSortCol_0', 'type' => 'Integer', 'default' => 'start_date', - ), - 'sortOrder' => array( + ], + 'sortOrder' => [ 'name' => 'sSortDir_0', 'type' => 'String', 'default' => 'desc', - ), - ); + ], + ]; foreach ($dataTableParams as $pName => $pValues) { $$pName = $pValues['default']; if (!empty($_POST[$pValues['name']])) { @@ -601,12 +601,12 @@ public static function campaignList() { } } } - foreach (array( + foreach ([ 'sort', 'offset', 'rowCount', 'sortOrder', - ) as $sortParam) { + ] as $sortParam) { $params[$sortParam] = $$sortParam; } @@ -643,7 +643,7 @@ public function surveyList() { $searchCriteria = CRM_Utils_Request::retrieve('searchCriteria', 'String', CRM_Core_DAO::$_nullObject, FALSE, NULL, 'POST'); $searchParams = explode(',', $searchCriteria); - $params = $searchRows = array(); + $params = $searchRows = []; foreach ($searchParams as $param) { if (!empty($_POST[$param])) { $params[$param] = $_POST[$param]; @@ -651,7 +651,7 @@ public function surveyList() { } //this is sequence columns on datatable. - $selectorCols = array( + $selectorCols = [ 'id', 'title', 'campaign_id', @@ -667,36 +667,36 @@ public function surveyList() { 'result_id', 'action', 'voterLinks', - ); + ]; // get the data table params. - $dataTableParams = array( - 'sEcho' => array( + $dataTableParams = [ + 'sEcho' => [ 'name' => 'sEcho', 'type' => 'Integer', 'default' => 0, - ), - 'offset' => array( + ], + 'offset' => [ 'name' => 'iDisplayStart', 'type' => 'Integer', 'default' => 0, - ), - 'rowCount' => array( + ], + 'rowCount' => [ 'name' => 'iDisplayLength', 'type' => 'Integer', 'default' => 25, - ), - 'sort' => array( + ], + 'sort' => [ 'name' => 'iSortCol_0', 'type' => 'Integer', 'default' => 'created_date', - ), - 'sortOrder' => array( + ], + 'sortOrder' => [ 'name' => 'sSortDir_0', 'type' => 'String', 'default' => 'desc', - ), - ); + ], + ]; foreach ($dataTableParams as $pName => $pValues) { $$pName = $pValues['default']; if (!empty($_POST[$pValues['name']])) { @@ -706,12 +706,12 @@ public function surveyList() { } } } - foreach (array( + foreach ([ 'sort', 'offset', 'rowCount', 'sortOrder', - ) as $sortParam) { + ] as $sortParam) { $params[$sortParam] = $$sortParam; } @@ -748,7 +748,7 @@ public function petitionList() { $searchCriteria = CRM_Utils_Request::retrieve('searchCriteria', 'String', CRM_Core_DAO::$_nullObject, FALSE, NULL, 'POST'); $searchParams = explode(',', $searchCriteria); - $params = $searchRows = array(); + $params = $searchRows = []; foreach ($searchParams as $param) { if (!empty($_POST[$param])) { $params[$param] = $_POST[$param]; @@ -756,7 +756,7 @@ public function petitionList() { } //this is sequence columns on datatable. - $selectorCols = array( + $selectorCols = [ 'id', 'title', 'campaign_id', @@ -767,36 +767,36 @@ public function petitionList() { 'is_active', 'isActive', 'action', - ); + ]; // get the data table params. - $dataTableParams = array( - 'sEcho' => array( + $dataTableParams = [ + 'sEcho' => [ 'name' => 'sEcho', 'type' => 'Integer', 'default' => 0, - ), - 'offset' => array( + ], + 'offset' => [ 'name' => 'iDisplayStart', 'type' => 'Integer', 'default' => 0, - ), - 'rowCount' => array( + ], + 'rowCount' => [ 'name' => 'iDisplayLength', 'type' => 'Integer', 'default' => 25, - ), - 'sort' => array( + ], + 'sort' => [ 'name' => 'iSortCol_0', 'type' => 'Integer', 'default' => 'created_date', - ), - 'sortOrder' => array( + ], + 'sortOrder' => [ 'name' => 'sSortDir_0', 'type' => 'String', 'default' => 'desc', - ), - ); + ], + ]; foreach ($dataTableParams as $pName => $pValues) { $$pName = $pValues['default']; if (!empty($_POST[$pValues['name']])) { @@ -806,12 +806,12 @@ public function petitionList() { } } } - foreach (array( + foreach ([ 'sort', 'offset', 'rowCount', 'sortOrder', - ) as $sortParam) { + ] as $sortParam) { $params[$sortParam] = $$sortParam; } diff --git a/CRM/Campaign/Page/DashBoard.php b/CRM/Campaign/Page/DashBoard.php index bccf6cfcb55f..08ac5a08e228 100644 --- a/CRM/Campaign/Page/DashBoard.php +++ b/CRM/Campaign/Page/DashBoard.php @@ -53,30 +53,30 @@ class CRM_Campaign_Page_DashBoard extends CRM_Core_Page { public static function campaignActionLinks() { // check if variable _actionsLinks is populated if (!isset(self::$_campaignActionLinks)) { - self::$_campaignActionLinks = array( - CRM_Core_Action::UPDATE => array( + self::$_campaignActionLinks = [ + CRM_Core_Action::UPDATE => [ 'name' => ts('Edit'), 'url' => 'civicrm/campaign/add', 'qs' => 'reset=1&action=update&id=%%id%%', 'title' => ts('Update Campaign'), - ), - CRM_Core_Action::DISABLE => array( + ], + CRM_Core_Action::DISABLE => [ 'name' => ts('Disable'), 'title' => ts('Disable Campaign'), 'ref' => 'crm-enable-disable', - ), - CRM_Core_Action::ENABLE => array( + ], + CRM_Core_Action::ENABLE => [ 'name' => ts('Enable'), 'title' => ts('Enable Campaign'), 'ref' => 'crm-enable-disable', - ), - CRM_Core_Action::DELETE => array( + ], + CRM_Core_Action::DELETE => [ 'name' => ts('Delete'), 'url' => 'civicrm/campaign/add', 'qs' => 'action=delete&reset=1&id=%%id%%', 'title' => ts('Delete Campaign'), - ), - ); + ], + ]; } return self::$_campaignActionLinks; @@ -88,30 +88,30 @@ public static function campaignActionLinks() { public static function surveyActionLinks() { // check if variable _actionsLinks is populated if (!isset(self::$_surveyActionLinks)) { - self::$_surveyActionLinks = array( - CRM_Core_Action::UPDATE => array( + self::$_surveyActionLinks = [ + CRM_Core_Action::UPDATE => [ 'name' => ts('Edit'), 'url' => 'civicrm/survey/configure/main', 'qs' => 'action=update&id=%%id%%&reset=1', 'title' => ts('Update Survey'), - ), - CRM_Core_Action::DISABLE => array( + ], + CRM_Core_Action::DISABLE => [ 'name' => ts('Disable'), 'ref' => 'crm-enable-disable', 'title' => ts('Disable Survey'), - ), - CRM_Core_Action::ENABLE => array( + ], + CRM_Core_Action::ENABLE => [ 'name' => ts('Enable'), 'ref' => 'crm-enable-disable', 'title' => ts('Enable Survey'), - ), - CRM_Core_Action::DELETE => array( + ], + CRM_Core_Action::DELETE => [ 'name' => ts('Delete'), 'url' => 'civicrm/survey/delete', 'qs' => 'id=%%id%%&reset=1', 'title' => ts('Delete Survey'), - ), - ); + ], + ]; } return self::$_surveyActionLinks; @@ -123,43 +123,43 @@ public static function surveyActionLinks() { public static function petitionActionLinks() { if (!isset(self::$_petitionActionLinks)) { self::$_petitionActionLinks = self::surveyActionLinks(); - self::$_petitionActionLinks[CRM_Core_Action::UPDATE] = array( + self::$_petitionActionLinks[CRM_Core_Action::UPDATE] = [ 'name' => ts('Edit'), 'url' => 'civicrm/petition/add', 'qs' => 'action=update&id=%%id%%&reset=1', 'title' => ts('Update Petition'), - ); - self::$_petitionActionLinks[CRM_Core_Action::DISABLE] = array( + ]; + self::$_petitionActionLinks[CRM_Core_Action::DISABLE] = [ 'name' => ts('Disable'), 'ref' => 'crm-enable-disable', 'title' => ts('Disable Petition'), - ); - self::$_petitionActionLinks[CRM_Core_Action::ENABLE] = array( + ]; + self::$_petitionActionLinks[CRM_Core_Action::ENABLE] = [ 'name' => ts('Enable'), 'ref' => 'crm-enable-disable', 'title' => ts('Enable Petition'), - ); - self::$_petitionActionLinks[CRM_Core_Action::DELETE] = array( + ]; + self::$_petitionActionLinks[CRM_Core_Action::DELETE] = [ 'name' => ts('Delete'), 'url' => 'civicrm/petition/add', 'qs' => 'action=delete&id=%%id%%&reset=1', 'title' => ts('Delete Petition'), - ); - self::$_petitionActionLinks[CRM_Core_Action::PROFILE] = array( + ]; + self::$_petitionActionLinks[CRM_Core_Action::PROFILE] = [ 'name' => ts('Sign'), 'url' => 'civicrm/petition/sign', 'qs' => 'sid=%%id%%&reset=1', 'title' => ts('Sign Petition'), 'fe' => TRUE, //CRM_Core_Action::PROFILE is used because there isn't a specific action for sign - ); - self::$_petitionActionLinks[CRM_Core_Action::BROWSE] = array( + ]; + self::$_petitionActionLinks[CRM_Core_Action::BROWSE] = [ 'name' => ts('Signatures'), 'url' => 'civicrm/activity/search', 'qs' => 'survey=%%id%%&force=1', 'title' => ts('List the signatures'), //CRM_Core_Action::PROFILE is used because there isn't a specific action for sign - ); + ]; } return self::$_petitionActionLinks; @@ -196,8 +196,8 @@ public function browseCampaign() { * * @return array */ - public static function getCampaignSummary($params = array()) { - $campaignsData = array(); + public static function getCampaignSummary($params = []) { + $campaignsData = []; //get the campaigns. $campaigns = CRM_Campaign_BAO_Campaign::getCampaignSummary($params); @@ -205,7 +205,7 @@ public static function getCampaignSummary($params = array()) { $config = CRM_Core_Config::singleton(); $campaignType = CRM_Campaign_PseudoConstant::campaignType(); $campaignStatus = CRM_Campaign_PseudoConstant::campaignStatus(); - $properties = array( + $properties = [ 'id', 'name', 'title', @@ -215,7 +215,7 @@ public static function getCampaignSummary($params = array()) { 'is_active', 'start_date', 'end_date', - ); + ]; foreach ($campaigns as $cmpid => $campaign) { foreach ($properties as $prop) { $campaignsData[$cmpid][$prop] = CRM_Utils_Array::value($prop, $campaign); @@ -251,7 +251,7 @@ public static function getCampaignSummary($params = array()) { } $campaignsData[$cmpid]['action'] = CRM_Core_Action::formLink(self::campaignActionLinks(), $action, - array('id' => $campaign['id']), + ['id' => $campaign['id']], ts('more'), FALSE, 'campaign.dashboard.row', @@ -296,8 +296,8 @@ public function browseSurvey() { * * @return array */ - public static function getSurveySummary($params = array()) { - $surveysData = array(); + public static function getSurveySummary($params = []) { + $surveysData = []; //get the survey. $config = CRM_Core_Config::singleton(); @@ -311,7 +311,7 @@ public static function getSurveySummary($params = array()) { $surveysData[$sid]['campaign'] = CRM_Utils_Array::value($campaignId, $campaigns); $surveysData[$sid]['activity_type'] = $surveyType[$survey['activity_type_id']]; if (!empty($survey['release_frequency'])) { - $surveysData[$sid]['release_frequency'] = ts('1 Day', array('plural' => '%count Days', 'count' => $survey['release_frequency'])); + $surveysData[$sid]['release_frequency'] = ts('1 Day', ['plural' => '%count Days', 'count' => $survey['release_frequency']]); } $action = array_sum(array_keys(self::surveyActionLinks($surveysData[$sid]['activity_type']))); @@ -344,7 +344,7 @@ public static function getSurveySummary($params = array()) { } $surveysData[$sid]['action'] = CRM_Core_Action::formLink(self::surveyActionLinks($surveysData[$sid]['activity_type']), $action, - array('id' => $sid), + ['id' => $sid], ts('more'), FALSE, 'survey.dashboard.row', @@ -402,9 +402,9 @@ public function browsePetition() { * * @return array */ - public static function getPetitionSummary($params = array()) { + public static function getPetitionSummary($params = []) { $config = CRM_Core_Config::singleton(); - $petitionsData = array(); + $petitionsData = []; //get the petitions. $petitions = CRM_Campaign_BAO_Petition::getPetitionSummary($params); @@ -439,7 +439,7 @@ public static function getPetitionSummary($params = array()) { $petitionsData[$pid]['action'] = CRM_Core_Action::formLink(self::petitionActionLinks(), $action, - array('id' => $pid), + ['id' => $pid], ts('more'), FALSE, 'petition.dashboard.row', @@ -453,11 +453,11 @@ public static function getPetitionSummary($params = array()) { } public function browse() { - $this->_tabs = array( + $this->_tabs = [ 'campaign' => ts('Campaigns'), 'survey' => ts('Surveys'), 'petition' => ts('Petitions'), - ); + ]; $subPageType = CRM_Utils_Request::retrieve('type', 'String', $this); if ($subPageType) { @@ -474,11 +474,11 @@ public function browse() { } CRM_Core_Resources::singleton() ->addScriptFile('civicrm', 'templates/CRM/common/TabHeader.js', 1, 'html-header') - ->addSetting(array( - 'tabSettings' => array( + ->addSetting([ + 'tabSettings' => [ 'active' => strtolower(CRM_Utils_Array::value('subPage', $_GET, 'campaign')), - ), - )); + ], + ]); } /** @@ -495,14 +495,14 @@ public function run() { } public function buildTabs() { - $allTabs = array(); + $allTabs = []; foreach ($this->_tabs as $name => $title) { - $allTabs[$name] = array( + $allTabs[$name] = [ 'title' => $title, 'valid' => TRUE, 'active' => TRUE, 'link' => CRM_Utils_System::url('civicrm/campaign', "reset=1&type=$name"), - ); + ]; } $allTabs['campaign']['class'] = 'livePage'; $this->assign('tabHeader', $allTabs); diff --git a/CRM/Campaign/Page/Petition/Confirm.php b/CRM/Campaign/Page/Petition/Confirm.php index 74c76e66ed14..4d6548f6ab1a 100644 --- a/CRM/Campaign/Page/Petition/Confirm.php +++ b/CRM/Campaign/Page/Petition/Confirm.php @@ -71,7 +71,7 @@ public function run() { $this->assign('survey_id', $petition_id); $pparams['id'] = $petition_id; - $this->petition = array(); + $this->petition = []; CRM_Campaign_BAO_Survey::retrieve($pparams, $this->petition); $this->assign('is_share', CRM_Utils_Array::value('is_share', $this->petition)); $this->assign('thankyou_title', CRM_Utils_Array::value('thankyou_title', $this->petition)); @@ -119,7 +119,7 @@ public static function confirm($contact_id, $subscribe_id, $hash, $activity_id, $ce->save(); CRM_Contact_BAO_GroupContact::addContactsToGroup( - array($contact_id), + [$contact_id], $se->group_id, 'Email', 'Added', diff --git a/CRM/Campaign/Page/Petition/ThankYou.php b/CRM/Campaign/Page/Petition/ThankYou.php index d0b8d1a67ad9..88eae02f3f14 100644 --- a/CRM/Campaign/Page/Petition/ThankYou.php +++ b/CRM/Campaign/Page/Petition/ThankYou.php @@ -40,7 +40,7 @@ public function run() { $id = CRM_Utils_Request::retrieve('id', 'Positive', $this); $petition_id = CRM_Utils_Request::retrieve('pid', 'Positive', $this); $params['id'] = $petition_id; - $this->petition = array(); + $this->petition = []; CRM_Campaign_BAO_Survey::retrieve($params, $this->petition); $this->assign('petitionTitle', $this->petition['title']); $this->assign('thankyou_title', CRM_Utils_Array::value('thankyou_title', $this->petition)); diff --git a/CRM/Campaign/Page/SurveyType.php b/CRM/Campaign/Page/SurveyType.php index bf495f2cb452..7303571c3fc1 100644 --- a/CRM/Campaign/Page/SurveyType.php +++ b/CRM/Campaign/Page/SurveyType.php @@ -79,9 +79,9 @@ public function preProcess() { $this->assign('gName', $this->_gName); $this->assign('GName', $this->_GName); - CRM_Utils_System::setTitle(ts('%1 Options', array(1 => $this->_GName))); + CRM_Utils_System::setTitle(ts('%1 Options', [1 => $this->_GName])); - $this->assign('addSurveyType', array("civicrm/admin/campaign/surveyType", "reset=1&action=add")); + $this->assign('addSurveyType', ["civicrm/admin/campaign/surveyType", "reset=1&action=add"]); } /** @@ -102,30 +102,30 @@ public function getBAOName() { */ public function &links() { if (!(self::$_links)) { - self::$_links = array( - CRM_Core_Action::UPDATE => array( + self::$_links = [ + CRM_Core_Action::UPDATE => [ 'name' => ts('Edit'), 'url' => 'civicrm/admin/campaign/surveyType', 'qs' => 'action=update&id=%%id%%&reset=1', - 'title' => ts('Edit %1', array(1 => $this->_gName)), - ), - CRM_Core_Action::DISABLE => array( + 'title' => ts('Edit %1', [1 => $this->_gName]), + ], + CRM_Core_Action::DISABLE => [ 'name' => ts('Disable'), 'ref' => 'crm-enable-disable', - 'title' => ts('Disable %1', array(1 => $this->_gName)), - ), - CRM_Core_Action::ENABLE => array( + 'title' => ts('Disable %1', [1 => $this->_gName]), + ], + CRM_Core_Action::ENABLE => [ 'name' => ts('Enable'), 'ref' => 'crm-enable-disable', - 'title' => ts('Enable %1', array(1 => $this->_gName)), - ), - CRM_Core_Action::DELETE => array( + 'title' => ts('Enable %1', [1 => $this->_gName]), + ], + CRM_Core_Action::DELETE => [ 'name' => ts('Delete'), 'url' => 'civicrm/admin/campaign/surveyType', 'qs' => 'action=delete&id=%%id%%', - 'title' => ts('Delete %1 Type', array(1 => $this->_gName)), - ), - ); + 'title' => ts('Delete %1 Type', [1 => $this->_gName]), + ], + ]; } return self::$_links; } @@ -143,7 +143,7 @@ public function run() { */ public function browse() { $campaingCompId = CRM_Core_Component::getComponentID('CiviCampaign'); - $groupParams = array('name' => $this->_gName); + $groupParams = ['name' => $this->_gName]; $optionValues = CRM_Core_OptionValue::getRows($groupParams, $this->links(), 'component_id,weight'); foreach ($optionValues as $key => $optionValue) { diff --git a/CRM/Campaign/Page/Vote.php b/CRM/Campaign/Page/Vote.php index 6d86c4ee58e5..4bb67d1cc477 100644 --- a/CRM/Campaign/Page/Vote.php +++ b/CRM/Campaign/Page/Vote.php @@ -70,10 +70,10 @@ public function interview() { } public function browse() { - $this->_tabs = array( + $this->_tabs = [ 'reserve' => ts('Reserve Respondents'), 'interview' => ts('Interview Respondents'), - ); + ]; $this->_surveyId = CRM_Utils_Request::retrieve('sid', 'Positive', $this); $this->_interviewerId = CRM_Utils_Request::retrieve('cid', 'Positive', $this); @@ -93,11 +93,11 @@ public function browse() { CRM_Core_Resources::singleton() ->addScriptFile('civicrm', 'templates/CRM/common/TabHeader.js', 1, 'html-header') - ->addSetting(array( - 'tabSettings' => array( + ->addSetting([ + 'tabSettings' => [ 'active' => strtolower(CRM_Utils_Array::value('subPage', $_GET, 'reserve')), - ), - )); + ], + ]); } /** @@ -110,16 +110,16 @@ public function run() { } public function buildTabs() { - $allTabs = array(); + $allTabs = []; foreach ($this->_tabs as $name => $title) { // check for required permissions. - if (!CRM_Core_Permission::check(array( - array( + if (!CRM_Core_Permission::check([ + [ 'manage campaign', 'administer CiviCampaign', "{$name} campaign contacts", - ), - )) + ], + ]) ) { continue; } @@ -131,12 +131,12 @@ public function buildTabs() { if ($this->_interviewerId) { $urlParams .= "&cid={$this->_interviewerId}"; } - $allTabs[$name] = array( + $allTabs[$name] = [ 'title' => $title, 'valid' => TRUE, 'active' => TRUE, 'link' => CRM_Utils_System::url('civicrm/campaign/vote', $urlParams), - ); + ]; } $this->assign('tabHeader', empty($allTabs) ? FALSE : $allTabs); diff --git a/CRM/Campaign/PseudoConstant.php b/CRM/Campaign/PseudoConstant.php index a5fb362a1e3a..c9838d310bb7 100644 --- a/CRM/Campaign/PseudoConstant.php +++ b/CRM/Campaign/PseudoConstant.php @@ -47,13 +47,13 @@ class CRM_Campaign_PseudoConstant extends CRM_Core_PseudoConstant { * Campaign Type * @var array */ - private static $campaignType = array(); + private static $campaignType = []; /** * Campaign Status * @var array */ - private static $campaignStatus = array(); + private static $campaignStatus = []; /** * Engagement Level diff --git a/CRM/Campaign/Selector/Search.php b/CRM/Campaign/Selector/Search.php index f3315a0b0045..584033391750 100644 --- a/CRM/Campaign/Selector/Search.php +++ b/CRM/Campaign/Selector/Search.php @@ -54,7 +54,7 @@ class CRM_Campaign_Selector_Search extends CRM_Core_Selector_Base implements CRM * Properties of contact we're interested in displaying * @var array */ - static $_properties = array( + static $_properties = [ 'contact_id', 'sort_name', 'street_unit', @@ -71,7 +71,7 @@ class CRM_Campaign_Selector_Search extends CRM_Core_Selector_Base implements CRM 'survey_activity_id', 'survey_activity_target_id', 'survey_activity_target_contact_id', - ); + ]; /** * Are we restricting ourselves to a single contact @@ -179,7 +179,7 @@ public function __construct( * @return array */ static public function &links() { - return self::$_links = array(); + return self::$_links = []; } /** @@ -241,11 +241,11 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { ); // process the result of the query - $rows = array(); + $rows = []; while ($result->fetch()) { $this->_query->convertToPseudoNames($result); - $row = array(); + $row = []; // the columns we are interested in foreach (self::$_properties as $property) { if (property_exists($result, $property)) { @@ -322,40 +322,40 @@ public function getQILL() { * the column headers that need to be displayed */ public function &getColumnHeaders($action = NULL, $output = NULL) { - self::$_columnHeaders = array(); + self::$_columnHeaders = []; if (!$this->_single) { - $contactDetails = array( - array( + $contactDetails = [ + [ 'name' => ts('Contact Name'), 'sort' => 'sort_name', 'direction' => CRM_Utils_Sort::ASCENDING, - ), - array( + ], + [ 'name' => ts('Street Number'), 'sort' => 'street_number', - ), - array( + ], + [ 'name' => ts('Street Name'), 'sort' => 'street_name', - ), - array('name' => ts('Street Address')), - array( + ], + ['name' => ts('Street Address')], + [ 'name' => ts('City'), 'sort' => 'city', - ), - array( + ], + [ 'name' => ts('Postal Code'), 'sort' => 'postal_code', - ), - array( + ], + [ 'name' => ts('State'), 'sort' => 'state_province_name', - ), - array('name' => ts('Country')), - array('name' => ts('Email')), - array('name' => ts('Phone')), - ); + ], + ['name' => ts('Country')], + ['name' => ts('Email')], + ['name' => ts('Phone')], + ]; self::$_columnHeaders = array_merge($contactDetails, self::$_columnHeaders); } diff --git a/CRM/Campaign/StateMachine/Search.php b/CRM/Campaign/StateMachine/Search.php index 37006e0dd177..6d38b3aa5f61 100644 --- a/CRM/Campaign/StateMachine/Search.php +++ b/CRM/Campaign/StateMachine/Search.php @@ -48,7 +48,7 @@ class CRM_Campaign_StateMachine_Search extends CRM_Core_StateMachine { public function __construct($controller, $action = CRM_Core_Action::NONE) { parent::__construct($controller, $action); - $this->_pages = array(); + $this->_pages = []; $this->_pages['CRM_Campaign_Form_Search'] = NULL; list($task, $result) = $this->taskName($controller, 'Search'); diff --git a/CRM/Campaign/Task.php b/CRM/Campaign/Task.php index 0cacffdc1b90..13682c1a44b0 100644 --- a/CRM/Campaign/Task.php +++ b/CRM/Campaign/Task.php @@ -55,35 +55,35 @@ class CRM_Campaign_Task extends CRM_Core_Task { */ public static function tasks() { if (!(self::$_tasks)) { - self::$_tasks = array( - self::INTERVIEW => array( + self::$_tasks = [ + self::INTERVIEW => [ 'title' => ts('Record Respondents Interview'), - 'class' => array( + 'class' => [ 'CRM_Campaign_Form_Task_Interview', 'CRM_Campaign_Form_Task_Release', - ), + ], 'result' => FALSE, - ), - self::RESERVE => array( + ], + self::RESERVE => [ 'title' => ts('Reserve Respondents'), - 'class' => array( + 'class' => [ 'CRM_Campaign_Form_Task_Reserve', 'CRM_Campaign_Form_Task_Interview', 'CRM_Campaign_Form_Task_Release', - ), + ], 'result' => FALSE, - ), - self::RELEASE => array( + ], + self::RELEASE => [ 'title' => ts('Release Respondents'), 'class' => 'CRM_Campaign_Form_Task_Release', 'result' => FALSE, - ), - self::TASK_PRINT => array( + ], + self::TASK_PRINT => [ 'title' => ts('Print Respondents'), 'class' => 'CRM_Campaign_Form_Task_Print', 'result' => FALSE, - ), - ); + ], + ]; parent::tasks(); } @@ -101,7 +101,7 @@ public static function tasks() { * @return array * set of tasks that are valid for the user */ - public static function permissionedTaskTitles($permission, $params = array()) { + public static function permissionedTaskTitles($permission, $params = []) { $tasks = self::taskTitles(); $tasks = parent::corePermissionedTaskTitles($tasks, $permission, $params); @@ -124,10 +124,10 @@ public static function getTask($value) { $value = self::INTERVIEW; } - return array( + return [ self::$_tasks[$value]['class'], self::$_tasks[$value]['result'], - ); + ]; } } diff --git a/CRM/Case/Audit/Audit.php b/CRM/Case/Audit/Audit.php index 1928fa4e4383..f58660fef31b 100644 --- a/CRM/Case/Audit/Audit.php +++ b/CRM/Case/Audit/Audit.php @@ -22,7 +22,7 @@ public function __construct($xmlString, $confFilename) { * @return array */ public function getActivities($printReport = FALSE) { - $retval = array(); + $retval = []; /* * Loop through the activities in the file and add them to the appropriate region array. @@ -41,16 +41,16 @@ public function getActivities($printReport = FALSE) { $activityindex = 0; $activityList = $doc->getElementsByTagName("Activity"); - $caseActivities = array(); - $activityStatusType = array(); + $caseActivities = []; + $activityStatusType = []; foreach ($activityList as $activity) { - $retval[$activityindex] = array(); + $retval[$activityindex] = []; - $ifBlankReplacements = array(); + $ifBlankReplacements = []; $completed = FALSE; - $sortValues = array('1970-01-01'); + $sortValues = ['1970-01-01']; $category = ''; $fieldindex = 1; $fields = $activity->getElementsByTagName("Field"); @@ -88,7 +88,7 @@ public function getActivities($printReport = FALSE) { } if ($this->auditConfig->includeInRegion($label, $region)) { - $retval[$activityindex][$region][$fieldindex] = array(); + $retval[$activityindex][$region][$fieldindex] = []; $retval[$activityindex][$region][$fieldindex]['label'] = $label; $retval[$activityindex][$region][$fieldindex]['datatype'] = $datatype; $retval[$activityindex][$region][$fieldindex]['value'] = $value; @@ -98,18 +98,18 @@ public function getActivities($printReport = FALSE) { //CRM-4570 if ($printReport) { - if (!in_array($label, array( + if (!in_array($label, [ 'Activity Type', 'Status', - )) + ]) ) { - $caseActivities[$activityindex][$fieldindex] = array(); + $caseActivities[$activityindex][$fieldindex] = []; $caseActivities[$activityindex][$fieldindex]['label'] = $label; $caseActivities[$activityindex][$fieldindex]['datatype'] = $datatype; $caseActivities[$activityindex][$fieldindex]['value'] = $value; } else { - $activityStatusType[$activityindex][$fieldindex] = array(); + $activityStatusType[$activityindex][$fieldindex] = []; $activityStatusType[$activityindex][$fieldindex]['label'] = $label; $activityStatusType[$activityindex][$fieldindex]['datatype'] = $datatype; $activityStatusType[$activityindex][$fieldindex]['value'] = $value; @@ -166,10 +166,10 @@ public function getActivities($printReport = FALSE) { } if ($printReport) { - @uasort($caseActivities, array($this, "compareActivities")); + @uasort($caseActivities, [$this, "compareActivities"]); } else { - @uasort($retval, array($this, "compareActivities")); + @uasort($retval, [$this, "compareActivities"]); } } diff --git a/CRM/Case/Audit/AuditConfig.php b/CRM/Case/Audit/AuditConfig.php index 5065cca44b79..be1ee8a08d47 100644 --- a/CRM/Case/Audit/AuditConfig.php +++ b/CRM/Case/Audit/AuditConfig.php @@ -22,8 +22,8 @@ public function __construct($filename) { // set some defaults $this->completionLabel = "Status"; $this->completionValue = "Completed"; - $this->sortByLabels = array("Actual Date", "Due Date"); - $this->ifBlanks = array(); + $this->sortByLabels = ["Actual Date", "Due Date"]; + $this->ifBlanks = []; $this->loadConfig(); } @@ -57,8 +57,8 @@ public function getIfBlanks() { } public function loadConfig() { - $this->regionFieldList = array(); - $this->includeRules = array(); + $this->regionFieldList = []; + $this->includeRules = []; $doc = new DOMDocument(); $xmlString = file_get_contents(dirname(__FILE__) . '/' . $this->filename); @@ -67,14 +67,14 @@ public function loadConfig() { $regions = $doc->getElementsByTagName("region"); foreach ($regions as $region) { $regionName = $region->getAttribute("name"); - $this->regionFieldList[$regionName] = array(); + $this->regionFieldList[$regionName] = []; // Inclusion/exclusion settings $includeRule = $region->getAttribute("includeRule"); if (empty($includeRule)) { $includeRule = 'include'; } - $this->includeRules[$regionName] = array('rule' => $includeRule); + $this->includeRules[$regionName] = ['rule' => $includeRule]; if ($includeRule == 'exclude') { $altRegion = $region->getAttribute("exclusionCorrespondingRegion"); $this->includeRules[$regionName]['altRegion'] = $altRegion; @@ -124,7 +124,7 @@ public function loadConfig() { $sortElement = $doc->getElementsByTagName("sortByLabels"); if (!empty($sortElement)) { - $this->sortByLabels = array(); + $this->sortByLabels = []; $label_elements = $sortElement->item(0)->getElementsByTagName("label"); foreach ($label_elements as $ele) { $this->sortByLabels[] = $ele->nodeValue; diff --git a/CRM/Case/BAO/CaseContact.php b/CRM/Case/BAO/CaseContact.php index cec9de15fea5..a8cfcdbb0280 100644 --- a/CRM/Case/BAO/CaseContact.php +++ b/CRM/Case/BAO/CaseContact.php @@ -57,7 +57,7 @@ public static function create($params) { $title = CRM_Contact_BAO_Contact::displayName($caseContact->contact_id) . ' - ' . $caseType; - $recentOther = array(); + $recentOther = []; if (CRM_Core_Permission::checkActionPermission('CiviCase', CRM_Core_Action::DELETE)) { $recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/contact/view/case', "action=delete&reset=1&id={$caseContact->case_id}&cid={$caseContact->contact_id}&context=home" @@ -81,12 +81,12 @@ public static function create($params) { * @inheritDoc */ public function addSelectWhereClause() { - return array( + return [ // Reuse case acls 'case_id' => CRM_Utils_SQL::mergeSubquery('Case'), // Case acls already check for contact access so we can just mark contact_id as handled - 'contact_id' => array(), - ); + 'contact_id' => [], + ]; // Don't call hook selectWhereClause, the case query already did } diff --git a/CRM/Case/BAO/CaseType.php b/CRM/Case/BAO/CaseType.php index aa65688f8766..b89f35abf30e 100644 --- a/CRM/Case/BAO/CaseType.php +++ b/CRM/Case/BAO/CaseType.php @@ -233,7 +233,7 @@ protected static function encodeXmlString($str) { */ public static function convertXmlToDefinition($xml) { // build PHP array based on definition - $definition = array(); + $definition = []; if (isset($xml->forkable)) { $definition['forkable'] = (int) $xml->forkable; @@ -249,7 +249,7 @@ public static function convertXmlToDefinition($xml) { // set activity types if (isset($xml->ActivityTypes)) { - $definition['activityTypes'] = array(); + $definition['activityTypes'] = []; foreach ($xml->ActivityTypes->ActivityType as $activityTypeXML) { $definition['activityTypes'][] = json_decode(json_encode($activityTypeXML), TRUE); } @@ -262,12 +262,12 @@ public static function convertXmlToDefinition($xml) { // set activity sets if (isset($xml->ActivitySets)) { - $definition['activitySets'] = array(); - $definition['timelineActivityTypes'] = array(); + $definition['activitySets'] = []; + $definition['timelineActivityTypes'] = []; foreach ($xml->ActivitySets->ActivitySet as $activitySetXML) { // parse basic properties - $activitySet = array(); + $activitySet = []; $activitySet['name'] = (string) $activitySetXML->name; $activitySet['label'] = (string) $activitySetXML->label; if ('true' == (string) $activitySetXML->timeline) { @@ -278,7 +278,7 @@ public static function convertXmlToDefinition($xml) { } if (isset($activitySetXML->ActivityTypes)) { - $activitySet['activityTypes'] = array(); + $activitySet['activityTypes'] = []; foreach ($activitySetXML->ActivityTypes->ActivityType as $activityTypeXML) { $activityType = json_decode(json_encode($activityTypeXML), TRUE); $activitySet['activityTypes'][] = $activityType; @@ -293,7 +293,7 @@ public static function convertXmlToDefinition($xml) { // set case roles if (isset($xml->CaseRoles)) { - $definition['caseRoles'] = array(); + $definition['caseRoles'] = []; foreach ($xml->CaseRoles->RelationshipType as $caseRoleXml) { $definition['caseRoles'][] = json_decode(json_encode($caseRoleXml), TRUE); } @@ -393,7 +393,7 @@ public static function del($caseTypeId) { $refCounts = $caseType->getReferenceCounts(); $total = array_sum(CRM_Utils_Array::collect('count', $refCounts)); if ($total) { - throw new CRM_Core_Exception(ts("You can not delete this case type -- it is assigned to %1 existing case record(s). If you do not want this case type to be used going forward, consider disabling it instead.", array(1 => $total))); + throw new CRM_Core_Exception(ts("You can not delete this case type -- it is assigned to %1 existing case record(s). If you do not want this case type to be used going forward, consider disabling it instead.", [1 => $total])); } $result = $caseType->delete(); CRM_Case_XMLRepository::singleton(TRUE); diff --git a/CRM/Case/BAO/Query.php b/CRM/Case/BAO/Query.php index 4fafe47ed742..e5bf54125eb7 100644 --- a/CRM/Case/BAO/Query.php +++ b/CRM/Case/BAO/Query.php @@ -261,7 +261,7 @@ public static function where(&$query) { */ public static function whereClauseSingle(&$values, &$query) { list($name, $op, $value, $grouping, $wildcard) = $values; - $val = $names = array(); + $val = $names = []; switch ($name) { case 'case_type_id': @@ -286,7 +286,7 @@ public static function whereClauseSingle(&$values, &$query) { $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_case.{$name}", $op, $value, "Integer"); list($op, $value) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Case_DAO_Case', $name, $value, $op); - $query->_qill[$grouping][] = ts('%1 %2 %3', array(1 => $label, 2 => $op, 3 => $value)); + $query->_qill[$grouping][] = ts('%1 %2 %3', [1 => $label, 2 => $op, 3 => $value]); $query->_tables['civicrm_case'] = $query->_whereTables['civicrm_case'] = 1; return; @@ -297,11 +297,11 @@ public static function whereClauseSingle(&$values, &$query) { $session = CRM_Core_Session::singleton(); $userID = $session->get('userID'); $query->_where[$grouping][] = ' ( ' . CRM_Contact_BAO_Query::buildClause("case_relationship.contact_id_b", $op, $userID, 'Int') . ' AND ' . CRM_Contact_BAO_Query::buildClause("case_relationship.is_active", '<>', 0, 'Int') . ' ) '; - $query->_qill[$grouping][] = ts('Case %1 My Cases', array(1 => $op)); + $query->_qill[$grouping][] = ts('Case %1 My Cases', [1 => $op]); $query->_tables['case_relationship'] = $query->_whereTables['case_relationship'] = 1; } elseif ($value == 1) { - $query->_qill[$grouping][] = ts('Case %1 All Cases', array(1 => $op)); + $query->_qill[$grouping][] = ts('Case %1 All Cases', [1 => $op]); $query->_where[$grouping][] = "civicrm_case_contact.contact_id = contact_a.id"; } $query->_tables['civicrm_case'] = $query->_whereTables['civicrm_case'] = 1; @@ -319,7 +319,7 @@ public static function whereClauseSingle(&$values, &$query) { case 'case_activity_subject': $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("case_activity.subject", $op, $value, 'String'); - $query->_qill[$grouping][] = ts("Activity Subject %1 '%2'", array(1 => $op, 2 => $value)); + $query->_qill[$grouping][] = ts("Activity Subject %1 '%2'", [1 => $op, 2 => $value]); $query->_tables['case_activity'] = $query->_whereTables['case_activity'] = 1; $query->_tables['civicrm_case'] = $query->_whereTables['civicrm_case'] = 1; $query->_tables['civicrm_case_contact'] = $query->_whereTables['civicrm_case_contact'] = 1; @@ -327,14 +327,14 @@ public static function whereClauseSingle(&$values, &$query) { case 'case_subject': $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_case.subject", $op, $value, 'String'); - $query->_qill[$grouping][] = ts("Case Subject %1 '%2'", array(1 => $op, 2 => $value)); + $query->_qill[$grouping][] = ts("Case Subject %1 '%2'", [1 => $op, 2 => $value]); $query->_tables['civicrm_case'] = $query->_whereTables['civicrm_case'] = 1; $query->_tables['civicrm_case_contact'] = $query->_whereTables['civicrm_case_contact'] = 1; return; case 'case_source_contact_id': $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_case_reporter.sort_name", $op, $value, 'String'); - $query->_qill[$grouping][] = ts("Activity Reporter %1 '%2'", array(1 => $op, 2 => $value)); + $query->_qill[$grouping][] = ts("Activity Reporter %1 '%2'", [1 => $op, 2 => $value]); $query->_tables['case_activity'] = $query->_whereTables['case_activity'] = 1; $query->_tables['civicrm_case_reporter'] = $query->_whereTables['civicrm_case_reporter'] = 1; $query->_tables['civicrm_case'] = $query->_whereTables['civicrm_case'] = 1; @@ -346,7 +346,7 @@ public static function whereClauseSingle(&$values, &$query) { $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("case_activity.activity_date_time", $op, $date, 'Date'); if ($date) { $date = CRM_Utils_Date::customFormat($date); - $query->_qill[$grouping][] = ts("Activity Actual Date %1 %2", array(1 => $op, 2 => $date)); + $query->_qill[$grouping][] = ts("Activity Actual Date %1 %2", [1 => $op, 2 => $date]); } $query->_tables['case_activity'] = $query->_whereTables['case_activity'] = 1; $query->_tables['civicrm_case'] = $query->_whereTables['civicrm_case'] = 1; @@ -358,7 +358,7 @@ public static function whereClauseSingle(&$values, &$query) { $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("case_activity.activity_date_time", $op, $date, 'Date'); if ($date) { $date = CRM_Utils_Date::customFormat($date); - $query->_qill[$grouping][] = ts("Activity Schedule Date %1 %2", array(1 => $op, 2 => $date)); + $query->_qill[$grouping][] = ts("Activity Schedule Date %1 %2", [1 => $op, 2 => $date]); } $query->_tables['case_activity'] = $query->_whereTables['case_activity'] = 1; $query->_tables['civicrm_case'] = $query->_whereTables['civicrm_case'] = 1; @@ -372,7 +372,7 @@ public static function whereClauseSingle(&$values, &$query) { } $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("case_activity.activity_type_id", $op, $value, 'Int'); - $query->_qill[$grouping][] = ts("Activity Type %1 %2", array(1 => $op, 2 => $names)); + $query->_qill[$grouping][] = ts("Activity Type %1 %2", [1 => $op, 2 => $names]); $query->_tables['case_activity'] = $query->_whereTables['case_activity'] = 1; $query->_tables['civicrm_case'] = $query->_whereTables['civicrm_case'] = 1; $query->_tables['case_activity_type'] = 1; @@ -386,7 +386,7 @@ public static function whereClauseSingle(&$values, &$query) { } $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("case_activity.status_id", $op, $value, 'Int'); - $query->_qill[$grouping][] = ts("Activity Type %1 %2", array(1 => $op, 2 => $names)); + $query->_qill[$grouping][] = ts("Activity Type %1 %2", [1 => $op, 2 => $names]); $query->_tables['case_activity'] = $query->_whereTables['case_activity'] = 1; $query->_tables['civicrm_case'] = $query->_whereTables['civicrm_case'] = 1; $query->_tables['case_activity_status'] = 1; @@ -395,7 +395,7 @@ public static function whereClauseSingle(&$values, &$query) { case 'case_activity_duration': $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("case_activity.duration", $op, $value, 'Int'); - $query->_qill[$grouping][] = ts("Activity Duration %1 %2", array(1 => $op, 2 => $value)); + $query->_qill[$grouping][] = ts("Activity Duration %1 %2", [1 => $op, 2 => $value]); $query->_tables['case_activity'] = $query->_whereTables['case_activity'] = 1; $query->_tables['civicrm_case'] = $query->_whereTables['civicrm_case'] = 1; $query->_tables['civicrm_case_contact'] = $query->_whereTables['civicrm_case_contact'] = 1; @@ -408,7 +408,7 @@ public static function whereClauseSingle(&$values, &$query) { } $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("case_activity.medium_id", $op, $value, 'Int'); - $query->_qill[$grouping][] = ts("Activity Medium %1 %2", array(1 => $op, 2 => $names)); + $query->_qill[$grouping][] = ts("Activity Medium %1 %2", [1 => $op, 2 => $names]); $query->_tables['case_activity'] = $query->_whereTables['case_activity'] = 1; $query->_tables['civicrm_case'] = $query->_whereTables['civicrm_case'] = 1; $query->_tables['case_activity_medium'] = 1; @@ -417,7 +417,7 @@ public static function whereClauseSingle(&$values, &$query) { case 'case_activity_details': $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("case_activity.details", $op, $value, 'String'); - $query->_qill[$grouping][] = ts("Activity Details %1 '%2'", array(1 => $op, 2 => $value)); + $query->_qill[$grouping][] = ts("Activity Details %1 '%2'", [1 => $op, 2 => $value]); $query->_tables['case_activity'] = $query->_whereTables['case_activity'] = 1; $query->_tables['civicrm_case'] = $query->_whereTables['civicrm_case'] = 1; $query->_tables['civicrm_case_contact'] = $query->_whereTables['civicrm_case_contact'] = 1; @@ -425,7 +425,7 @@ public static function whereClauseSingle(&$values, &$query) { case 'case_activity_is_auto': $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("case_activity.is_auto", $op, $value, 'Boolean'); - $query->_qill[$grouping][] = ts("Activity Auto Genrated %1 '%2'", array(1 => $op, 2 => $value)); + $query->_qill[$grouping][] = ts("Activity Auto Genrated %1 '%2'", [1 => $op, 2 => $value]); $query->_tables['case_activity'] = $query->_whereTables['case_activity'] = 1; $query->_tables['civicrm_case'] = $query->_whereTables['civicrm_case'] = 1; $query->_tables['civicrm_case_contact'] = $query->_whereTables['civicrm_case_contact'] = 1; @@ -435,7 +435,7 @@ public static function whereClauseSingle(&$values, &$query) { case 'case_role': $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("case_relation_type.name_b_a", $op, $value, 'String'); - $query->_qill[$grouping][] = ts("Role in Case %1 '%2'", array(1 => $op, 2 => $value)); + $query->_qill[$grouping][] = ts("Role in Case %1 '%2'", [1 => $op, 2 => $value]); $query->_tables['case_relation_type'] = $query->_whereTables['case_relationship_type'] = 1; $query->_tables['civicrm_case'] = $query->_whereTables['civicrm_case'] = 1; $query->_tables['civicrm_case_contact'] = $query->_whereTables['civicrm_case_contact'] = 1; @@ -467,7 +467,7 @@ public static function whereClauseSingle(&$values, &$query) { case 'case_taglist': $taglist = $value; - $value = array(); + $value = []; foreach ($taglist as $val) { if ($val) { $val = explode(',', $val); @@ -479,7 +479,7 @@ public static function whereClauseSingle(&$values, &$query) { } } case 'case_tags': - $tags = CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE)); + $tags = CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', ['onlyActive' => FALSE]); if (!empty($value)) { $val = explode(',', $value); @@ -491,7 +491,7 @@ public static function whereClauseSingle(&$values, &$query) { } $query->_where[$grouping][] = " civicrm_case_tag.tag_id IN (" . implode(',', $val) . " )"; - $query->_qill[$grouping][] = ts('Case Tags %1', array(1 => $op)) . ' ' . implode(' ' . ts('or') . ' ', $names); + $query->_qill[$grouping][] = ts('Case Tags %1', [1 => $op]) . ' ' . implode(' ' . ts('or') . ' ', $names); $query->_tables['civicrm_case'] = $query->_whereTables['civicrm_case'] = 1; $query->_tables['civicrm_case_contact'] = $query->_whereTables['civicrm_case_contact'] = 1; $query->_tables['civicrm_case_tag'] = $query->_whereTables['civicrm_case_tag'] = 1; @@ -598,7 +598,7 @@ public static function defaultReturnProperties( $properties = NULL; if ($mode & CRM_Contact_BAO_Query::MODE_CASE) { - $properties = array( + $properties = [ 'contact_type' => 1, 'contact_sub_type' => 1, 'contact_id' => 1, @@ -616,7 +616,7 @@ public static function defaultReturnProperties( 'case_scheduled_activity_date' => 1, 'phone' => 1, // 'case_scheduled_activity_type'=> 1 - ); + ]; if ($includeCustomFields) { // also get all the custom case properties @@ -643,7 +643,7 @@ public static function extraReturnProperties($mode) { $properties = NULL; if ($mode & CRM_Contact_BAO_Query::MODE_CASE) { - $properties = array( + $properties = [ 'case_start_date' => 1, 'case_end_date' => 1, 'case_subject' => 1, @@ -653,7 +653,7 @@ public static function extraReturnProperties($mode) { 'case_activity_medium_id' => 1, 'case_activity_details' => 1, 'case_activity_is_auto' => 1, - ); + ]; } return $properties; } @@ -663,11 +663,11 @@ public static function extraReturnProperties($mode) { */ public static function tableNames(&$tables) { if (!empty($tables['civicrm_case'])) { - $tables = array_merge(array('civicrm_case_contact' => 1), $tables); + $tables = array_merge(['civicrm_case_contact' => 1], $tables); } if (!empty($tables['case_relation_type'])) { - $tables = array_merge(array('case_relationship' => 1), $tables); + $tables = array_merge(['case_relationship' => 1], $tables); } } @@ -681,14 +681,14 @@ public static function buildSearchForm(&$form) { $configured = CRM_Case_BAO_Case::isCaseConfigured(); $form->assign('notConfigured', !$configured['configured']); - $form->addField('case_type_id', array('context' => 'search', 'entity' => 'Case')); - $form->addField('case_status_id', array('context' => 'search', 'entity' => 'Case')); + $form->addField('case_type_id', ['context' => 'search', 'entity' => 'Case']); + $form->addField('case_status_id', ['context' => 'search', 'entity' => 'Case']); CRM_Core_Form_Date::buildDateRange($form, 'case_from', 1, '_start_date_low', '_start_date_high', ts('From'), FALSE); CRM_Core_Form_Date::buildDateRange($form, 'case_to', 1, '_end_date_low', '_end_date_high', ts('From'), FALSE); $form->addElement('hidden', 'case_from_start_date_range_error'); $form->addElement('hidden', 'case_to_end_date_range_error'); - $form->addFormRule(array('CRM_Case_BAO_Query', 'formRule'), $form); + $form->addFormRule(['CRM_Case_BAO_Query', 'formRule'], $form); $form->assign('validCiviCase', TRUE); @@ -696,7 +696,7 @@ public static function buildSearchForm(&$form) { $accessAllCases = FALSE; if (CRM_Core_Permission::check('access all cases and activities')) { $accessAllCases = TRUE; - $caseOwner = array(1 => ts('Search All Cases'), 2 => ts('Only My Cases')); + $caseOwner = [1 => ts('Search All Cases'), 2 => ts('Only My Cases')]; $form->addRadio('case_owner', ts('Cases'), $caseOwner); if ($form->get('context') != 'dashboard') { $form->add('checkbox', 'upcoming', ts('Search Cases with Upcoming Activities')); @@ -707,7 +707,7 @@ public static function buildSearchForm(&$form) { $caseTags = CRM_Core_BAO_Tag::getColorTags('civicrm_case'); if ($caseTags) { - $form->add('select2', 'case_tags', ts('Case Tag(s)'), $caseTags, FALSE, array('class' => 'big', 'placeholder' => ts('- select -'), 'multiple' => TRUE)); + $form->add('select2', 'case_tags', ts('Case Tag(s)'), $caseTags, FALSE, ['class' => 'big', 'placeholder' => ts('- select -'), 'multiple' => TRUE]); } $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_case'); @@ -720,16 +720,16 @@ public static function buildSearchForm(&$form) { $form->addElement('text', 'case_subject', ts('Case Subject'), - array('class' => 'huge') + ['class' => 'huge'] ); $form->addElement('text', 'case_id', ts('Case ID') ); - self::addCustomFormFields($form, array('Case')); + self::addCustomFormFields($form, ['Case']); - $form->setDefaults(array('case_owner' => 1)); + $form->setDefaults(['case_owner' => 1]); } /** @@ -742,7 +742,7 @@ public static function buildSearchForm(&$form) { * @return bool|array */ public static function formRule($fields, $files, $form) { - $errors = array(); + $errors = []; if ((empty($fields['case_from_start_date_low']) || empty($fields['case_from_start_date_high'])) && (empty($fields['case_to_end_date_low']) || empty($fields['case_to_end_date_high']))) { return TRUE; diff --git a/CRM/Case/Form/Activity.php b/CRM/Case/Form/Activity.php index 9e2dda642d88..4b9cdbe1dde9 100644 --- a/CRM/Case/Form/Activity.php +++ b/CRM/Case/Form/Activity.php @@ -108,7 +108,7 @@ public function preProcess() { if ($this->_caseId && !CRM_Core_Permission::check('access all cases and activities') ) { - $params = array('type' => 'any'); + $params = ['type' => 'any']; $allCases = CRM_Case_BAO_Case::getCases(TRUE, $params); if (count(array_intersect($this->_caseId, array_keys($allCases))) == 0) { CRM_Core_Error::fatal(ts('You are not authorized to access this page.')); @@ -183,7 +183,7 @@ public function preProcess() { $activityCount = CRM_Case_BAO_Case::getCaseActivityCount($caseId, $this->_activityTypeId); if ($activityCount >= $activityInst[$this->_activityTypeName]) { if ($activityInst[$this->_activityTypeName] == 1) { - $atArray = array('activity_type_id' => $this->_activityTypeId); + $atArray = ['activity_type_id' => $this->_activityTypeId]; $activities = CRM_Case_BAO_Case::getCaseActivity($caseId, $atArray, $this->_currentUserId @@ -194,10 +194,10 @@ public function preProcess() { ); } CRM_Core_Error::statusBounce(ts("You can not add another '%1' activity to this case. %2", - array( + [ 1 => $this->_activityTypeName, - 2 => ts("Do you want to edit the existing activity?", array(1 => "href='$editUrl'")), - ) + 2 => ts("Do you want to edit the existing activity?", [1 => "href='$editUrl'"]), + ] ), $url ); @@ -220,7 +220,7 @@ public function preProcess() { */ public function setDefaultValues() { $this->_defaults = parent::setDefaultValues(); - $targetContactValues = array(); + $targetContactValues = []; foreach ($this->_caseId as $key => $val) { //get all clients. $clients = CRM_Case_BAO_Case::getContactNames($val); @@ -281,7 +281,7 @@ public function buildQuickForm() { if ($this->_caseType) { $xmlProcessor = new CRM_Case_XMLProcessor_Process(); - $aTypes = array(); + $aTypes = []; foreach (array_unique($this->_caseType) as $val) { $activityTypes = $xmlProcessor->get($val, 'ActivityTypes', TRUE); $aTypes = $aTypes + $activityTypes; @@ -291,7 +291,7 @@ public function buildQuickForm() { $openCaseID = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Open Case'); unset($aTypes[$openCaseID]); asort($aTypes); - $this->_fields['followup_activity_type_id']['attributes'] = array('' => '- select activity type -') + $aTypes; + $this->_fields['followup_activity_type_id']['attributes'] = ['' => '- select activity type -'] + $aTypes; } parent::buildQuickForm(); @@ -340,22 +340,22 @@ public function buildQuickForm() { } if (!empty($this->_relatedContacts)) { - $checkBoxes = array(); + $checkBoxes = []; foreach ($this->_relatedContacts as $id => $row) { foreach ($row as $key => $value) { - $checkBoxes[$key] = $this->addElement('checkbox', $key, NULL, NULL, array('class' => 'select-row')); + $checkBoxes[$key] = $this->addElement('checkbox', $key, NULL, NULL, ['class' => 'select-row']); } } $this->addGroup($checkBoxes, 'contact_check'); $this->addElement('checkbox', 'toggleSelect', NULL, NULL, - array('class' => 'select-rows') + ['class' => 'select-rows'] ); $this->assign('searchRows', $this->_relatedContacts); } $this->_relatedContacts = $rgc + $relCon; - $this->addFormRule(array('CRM_Case_Form_Activity', 'formRule'), $this); + $this->addFormRule(['CRM_Case_Form_Activity', 'formRule'], $this); } /** @@ -396,7 +396,7 @@ public function postProcess($params = NULL) { $caseAttributeActivities = CRM_Core_OptionGroup::values('activity_type', FALSE, FALSE, FALSE, $activityCondition); if (!array_key_exists($this->_activityTypeId, $caseAttributeActivities)) { - $params = array('id' => $this->_activityId); + $params = ['id' => $this->_activityId]; $activityDelete = CRM_Activity_BAO_Activity::deleteActivity($params, TRUE); if ($activityDelete) { $statusMsg = ts('The selected activity has been moved to the Trash. You can view and / or restore deleted activities by checking "Deleted Activities" from the Case Activities search filter (under Manage Case).
'); @@ -406,10 +406,10 @@ public function postProcess($params = NULL) { $statusMsg = ts("Selected Activity cannot be deleted."); } - $tagParams = array( + $tagParams = [ 'entity_table' => 'civicrm_activity', 'entity_id' => $this->_activityId, - ); + ]; CRM_Core_BAO_EntityTag::del($tagParams); CRM_Core_Session::setStatus('', $statusMsg, 'info'); @@ -418,7 +418,7 @@ public function postProcess($params = NULL) { if ($this->_action & CRM_Core_Action::RENEW) { $statusMsg = NULL; - $params = array('id' => $this->_activityId); + $params = ['id' => $this->_activityId]; $activityRestore = CRM_Activity_BAO_Activity::restoreActivity($params); if ($activityRestore) { $statusMsg = ts('The selected activity has been restored.
'); @@ -442,20 +442,20 @@ public function postProcess($params = NULL) { $params['target_contact_id'] = explode(',', $params['target_contact_id']); } else { - $params['target_contact_id'] = array(); + $params['target_contact_id'] = []; } // format activity custom data if (!empty($params['hidden_custom'])) { if ($this->_activityId) { // retrieve and include the custom data of old Activity - $oldActivity = civicrm_api3('Activity', 'getsingle', array('id' => $this->_activityId)); + $oldActivity = civicrm_api3('Activity', 'getsingle', ['id' => $this->_activityId]); $params = array_merge($oldActivity, $params); // unset custom fields-id from params since we want custom // fields to be saved for new activity. foreach ($params as $key => $value) { - $match = array(); + $match = []; if (preg_match('/^(custom_\d+_)(\d+)$/', $key, $match)) { $params[$match[1] . '-1'] = $params[$key]; @@ -487,7 +487,7 @@ public function postProcess($params = NULL) { $params['assignee_contact_id'] = explode(',', $params['assignee_contact_id']); } else { - $params['assignee_contact_id'] = array(); + $params['assignee_contact_id'] = []; } if (isset($this->_activityId)) { @@ -518,7 +518,7 @@ public function postProcess($params = NULL) { $params['case_id'] = $val; // activity create/update $activity = CRM_Activity_BAO_Activity::create($params); - $vvalue[] = array('case_id' => $val, 'actId' => $activity->id); + $vvalue[] = ['case_id' => $val, 'actId' => $activity->id]; // call end post process, after the activity has been created/updated. $this->endPostProcess($params, $activity); } @@ -526,7 +526,7 @@ public function postProcess($params = NULL) { else { // since the params we need to set are very few, and we don't want rest of the // work done by bao create method , lets use dao object to make the changes - $params = array('id' => $this->_activityId); + $params = ['id' => $this->_activityId]; $params['is_current_revision'] = 0; $activity = new CRM_Activity_DAO_Activity(); $activity->copyValues($params); @@ -556,7 +556,7 @@ public function postProcess($params = NULL) { foreach ($this->_caseId as $key => $val) { $newActParams['case_id'] = $val; $activity = CRM_Activity_BAO_Activity::create($newActParams); - $vvalue[] = array('case_id' => $val, 'actId' => $activity->id); + $vvalue[] = ['case_id' => $val, 'actId' => $activity->id]; // call end post process, after the activity has been created/updated. $this->endPostProcess($newActParams, $activity); } @@ -575,7 +575,7 @@ public function postProcess($params = NULL) { foreach ($vvalue as $vkey => $vval) { if ($vval['actId']) { // add tags if exists - $tagParams = array(); + $tagParams = []; if (!empty($params['tag'])) { if (!is_array($params['tag'])) { $params['tag'] = explode(',', $params['tag']); @@ -606,20 +606,20 @@ public function postProcess($params = NULL) { ); CRM_Case_BAO_Case::create($caseParams); // create case activity record - $caseParams = array( + $caseParams = [ 'activity_id' => $vval['actId'], 'case_id' => $vval['case_id'], - ); + ]; CRM_Case_BAO_Case::processCaseActivity($caseParams); } // send copy to selected contacts. $mailStatus = ''; - $mailToContacts = array(); + $mailToContacts = []; //CRM-5695 //check for notification settings for assignee contacts - $selectedContacts = array('contact_check'); + $selectedContacts = ['contact_check']; if (Civi::settings()->get('activity_assignee_notification')) { $selectedContacts[] = 'assignee_contact_id'; } @@ -631,7 +631,7 @@ public function postProcess($params = NULL) { $mailStatus = ts("A copy of the activity has also been sent to selected contacts(s)."); } else { - $this->_relatedContacts = CRM_Activity_BAO_ActivityAssignment::getAssigneeNames(array($vval['actId']), TRUE, FALSE); + $this->_relatedContacts = CRM_Activity_BAO_ActivityAssignment::getAssigneeNames([$vval['actId']], TRUE, FALSE); $mailStatus .= ' ' . ts("A copy of the activity has also been sent to assignee contacts(s)."); } //build an associative array with unique email addresses. @@ -657,7 +657,7 @@ public function postProcess($params = NULL) { } } - $extraParams = array('case_id' => $vval['case_id'], 'client_id' => $this->_currentlyViewedContactId); + $extraParams = ['case_id' => $vval['case_id'], 'client_id' => $this->_currentlyViewedContactId]; $result = CRM_Activity_BAO_Activity::sendToAssignee($activity, $mailToContacts, $extraParams); if (empty($result)) { $mailStatus = ''; @@ -669,15 +669,15 @@ public function postProcess($params = NULL) { $followupActivity = CRM_Activity_BAO_Activity::createFollowupActivity($vval['actId'], $params); if ($followupActivity) { - $caseParams = array( + $caseParams = [ 'activity_id' => $followupActivity->id, 'case_id' => $vval['case_id'], - ); + ]; CRM_Case_BAO_Case::processCaseActivity($caseParams); $followupStatus = ts("A followup activity has been scheduled.") . '

'; } } - $title = ts("%1 Saved", array(1 => $this->_activityTypeName)); + $title = ts("%1 Saved", [1 => $this->_activityTypeName]); CRM_Core_Session::setStatus($followupStatus . $mailStatus, $title, 'success'); } } diff --git a/CRM/Case/Form/Activity/ChangeCaseStartDate.php b/CRM/Case/Form/Activity/ChangeCaseStartDate.php index 7066aa10b578..aecb3caef7e8 100644 --- a/CRM/Case/Form/Activity/ChangeCaseStartDate.php +++ b/CRM/Case/Form/Activity/ChangeCaseStartDate.php @@ -60,11 +60,11 @@ public static function preProcess(&$form) { * @return array */ public static function setDefaultValues(&$form) { - $defaults = array(); + $defaults = []; $openCaseActivityType = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Open Case'); $caseId = CRM_Utils_Array::first($form->_caseId); - $openCaseParams = array('activity_type_id' => $openCaseActivityType); + $openCaseParams = ['activity_type_id' => $openCaseActivityType]; $openCaseInfo = CRM_Case_BAO_Case::getCaseActivityDates($caseId, $openCaseParams, TRUE); if (empty($openCaseInfo)) { $defaults['start_date'] = date('Y-m-d H:i:s'); @@ -164,7 +164,7 @@ public static function endPostProcess(&$form, &$params, $activity) { $activity->save(); // 2. initiate xml processor $xmlProcessor = new CRM_Case_XMLProcessor_Process(); - $xmlProcessorParams = array( + $xmlProcessorParams = [ 'clientID' => $form->_currentlyViewedContactId, 'creatorID' => $form->_currentUserId, 'standardTimeline' => 0, @@ -174,7 +174,7 @@ public static function endPostProcess(&$form, &$params, $activity) { 'activityTypeName' => 'Change Case Start Date', 'activitySetName' => 'standard_timeline', 'resetTimeline' => 1, - ); + ]; $xmlProcessor->run($caseType, $xmlProcessorParams); @@ -183,21 +183,21 @@ public static function endPostProcess(&$form, &$params, $activity) { if ($form->openCaseActivityId) { $abao = new CRM_Activity_BAO_Activity(); - $oldParams = array('id' => $form->openCaseActivityId); - $oldActivityDefaults = array(); + $oldParams = ['id' => $form->openCaseActivityId]; + $oldActivityDefaults = []; $oldActivity = $abao->retrieve($oldParams, $oldActivityDefaults); // save the old values require_once 'api/v3/utils.php'; - $openCaseParams = array(); + $openCaseParams = []; //@todo calling api functions directly is not supported _civicrm_api3_object_to_array($oldActivity, $openCaseParams); // update existing revision - $oldParams = array( + $oldParams = [ 'id' => $form->openCaseActivityId, 'is_current_revision' => 0, - ); + ]; $oldActivity = new CRM_Activity_DAO_Activity(); $oldActivity->copyValues($oldParams); $oldActivity->save(); @@ -219,17 +219,17 @@ public static function endPostProcess(&$form, &$params, $activity) { } else { // Create linkage to case - $caseActivityParams = array( + $caseActivityParams = [ 'activity_id' => $newActivity->id, 'case_id' => $caseId, - ); + ]; CRM_Case_BAO_Case::processCaseActivity($caseActivityParams); - $caseActivityParams = array( + $caseActivityParams = [ 'activityID' => $form->openCaseActivityId, 'mainActivityId' => $newActivity->id, - ); + ]; CRM_Activity_BAO_Activity::copyExtendedActivityData($caseActivityParams); } } diff --git a/CRM/Case/Form/Activity/ChangeCaseStatus.php b/CRM/Case/Form/Activity/ChangeCaseStatus.php index 62d1e3c0874e..a5503aac1e6b 100644 --- a/CRM/Case/Form/Activity/ChangeCaseStatus.php +++ b/CRM/Case/Form/Activity/ChangeCaseStatus.php @@ -46,7 +46,7 @@ public static function preProcess(&$form) { CRM_Core_Error::fatal(ts('Case Id not found.')); } - $form->addElement('checkbox', 'updateLinkedCases', NULL, NULL, array('class' => 'select-row')); + $form->addElement('checkbox', 'updateLinkedCases', NULL, NULL, ['class' => 'select-row']); $caseID = CRM_Utils_Array::first($form->_caseId); $cases = CRM_Case_BAO_Case::getRelatedCases($caseID); @@ -64,7 +64,7 @@ public static function preProcess(&$form) { * @return array */ public static function setDefaultValues(&$form) { - $defaults = array(); + $defaults = []; // Retrieve current case status $defaults['case_status_id'] = $form->_defaultCaseStatus; @@ -78,17 +78,17 @@ public static function buildQuickForm(&$form) { $form->removeElement('status_id'); $form->removeElement('priority_id'); - $caseTypes = array(); + $caseTypes = []; $form->_caseStatus = CRM_Case_PseudoConstant::caseStatus(); $statusNames = CRM_Case_PseudoConstant::caseStatus('name'); // Limit case statuses to allowed types for these case(s) - $allCases = civicrm_api3('Case', 'get', array('return' => 'case_type_id', 'id' => array('IN' => (array) $form->_caseId))); + $allCases = civicrm_api3('Case', 'get', ['return' => 'case_type_id', 'id' => ['IN' => (array) $form->_caseId]]); foreach ($allCases['values'] as $case) { $caseTypes[$case['case_type_id']] = $case['case_type_id']; } - $caseTypes = civicrm_api3('CaseType', 'get', array('id' => array('IN' => $caseTypes))); + $caseTypes = civicrm_api3('CaseType', 'get', ['id' => ['IN' => $caseTypes]]); foreach ($caseTypes['values'] as $ct) { if (!empty($ct['definition']['statuses'])) { foreach ($form->_caseStatus as $id => $label) { @@ -178,10 +178,10 @@ public static function endPostProcess(&$form, &$params, $activity) { // FIXME: Is there an existing function to close a relationship? $query = 'UPDATE civicrm_relationship SET end_date=%2 WHERE id=%1'; foreach ($rels as $relId => $relData) { - $relParams = array( - 1 => array($relId, 'Integer'), - 2 => array($params['end_date'], 'Timestamp'), - ); + $relParams = [ + 1 => [$relId, 'Integer'], + 2 => [$params['end_date'], 'Timestamp'], + ]; CRM_Core_DAO::executeQuery($query, $relParams); } } @@ -195,7 +195,7 @@ public static function endPostProcess(&$form, &$params, $activity) { // FIXME: Is there an existing function? $query = 'UPDATE civicrm_relationship SET end_date=NULL WHERE id=%1'; foreach ($rels as $relId => $relData) { - $relParams = array(1 => array($relId, 'Integer')); + $relParams = [1 => [$relId, 'Integer']]; CRM_Core_DAO::executeQuery($query, $relParams); } } @@ -207,10 +207,10 @@ public static function endPostProcess(&$form, &$params, $activity) { foreach ($form->_oldCaseStatus as $statuskey => $statusval) { if ($activity->subject == 'null') { - $activity->subject = ts('Case status changed from %1 to %2', array( + $activity->subject = ts('Case status changed from %1 to %2', [ 1 => CRM_Utils_Array::value($statusval, $form->_caseStatus), 2 => CRM_Utils_Array::value($params['case_status_id'], $form->_caseStatus), - ) + ] ); $activity->save(); } diff --git a/CRM/Case/Form/Activity/ChangeCaseType.php b/CRM/Case/Form/Activity/ChangeCaseType.php index 53fa4a051bbe..2a8ac64e850c 100644 --- a/CRM/Case/Form/Activity/ChangeCaseType.php +++ b/CRM/Case/Form/Activity/ChangeCaseType.php @@ -57,7 +57,7 @@ public static function preProcess(&$form) { * @return array */ public static function setDefaultValues(&$form) { - $defaults = array(); + $defaults = []; $defaults['is_reset_timeline'] = 1; @@ -84,7 +84,7 @@ public static function buildQuickForm(&$form) { $form->_caseType[$form->_caseTypeId] = CRM_Core_DAO::getFieldValue('CRM_Case_DAO_CaseType', $form->_caseTypeId, 'title'); } - $form->addField('case_type_id', array('context' => 'create', 'entity' => 'Case')); + $form->addField('case_type_id', ['context' => 'create', 'entity' => 'Case']); // timeline $form->addYesNo('is_reset_timeline', ts('Reset Case Timeline?'), NULL, TRUE); @@ -160,10 +160,10 @@ public static function endPostProcess(&$form, &$params, $activity) { if ($activity->subject == 'null') { $activity->subject = ts('Case type changed from %1 to %2', - array( + [ 1 => CRM_Utils_Array::value($form->_defaults['case_type_id'], $allCaseTypes), 2 => CRM_Utils_Array::value($params['case_type_id'], $allCaseTypes), - ) + ] ); $activity->save(); } @@ -171,7 +171,7 @@ public static function endPostProcess(&$form, &$params, $activity) { // 1. initiate xml processor $xmlProcessor = new CRM_Case_XMLProcessor_Process(); $caseId = CRM_Utils_Array::first($form->_caseId); - $xmlProcessorParams = array( + $xmlProcessorParams = [ 'clientID' => $form->_currentlyViewedContactId, 'creatorID' => $form->_currentUserId, 'standardTimeline' => 1, @@ -179,7 +179,7 @@ public static function endPostProcess(&$form, &$params, $activity) { 'activity_date_time' => CRM_Utils_Array::value('reset_date_time', $params), 'caseID' => $caseId, 'resetTimeline' => CRM_Utils_Array::value('is_reset_timeline', $params), - ); + ]; $xmlProcessor->run($caseType, $xmlProcessorParams); // status msg diff --git a/CRM/Case/Form/Activity/LinkCases.php b/CRM/Case/Form/Activity/LinkCases.php index f416d0d8f260..516647c3f41f 100644 --- a/CRM/Case/Form/Activity/LinkCases.php +++ b/CRM/Case/Form/Activity/LinkCases.php @@ -70,7 +70,7 @@ public static function preProcess(&$form) { * @return array */ public static function setDefaultValues(&$form) { - $defaults = array(); + $defaults = []; if (!empty($_GET['link_to_case_id']) && CRM_Utils_Rule::positiveInteger($_GET['link_to_case_id'])) { $defaults['link_to_case_id'] = $_GET['link_to_case_id']; } @@ -86,16 +86,16 @@ public static function buildQuickForm(&$form) { if (is_array($relatedCases) && !empty($relatedCases)) { $excludeCaseIds = array_merge($excludeCaseIds, array_keys($relatedCases)); } - $form->addEntityRef('link_to_case_id', ts('Link To Case'), array( + $form->addEntityRef('link_to_case_id', ts('Link To Case'), [ 'entity' => 'Case', - 'api' => array( - 'extra' => array('case_id.case_type_id.title', 'contact_id.sort_name'), - 'params' => array( - 'case_id' => array('NOT IN' => $excludeCaseIds), + 'api' => [ + 'extra' => ['case_id.case_type_id.title', 'contact_id.sort_name'], + 'params' => [ + 'case_id' => ['NOT IN' => $excludeCaseIds], 'case_id.is_deleted' => 0, - ), - ), - ), TRUE); + ], + ], + ], TRUE); } /** @@ -111,7 +111,7 @@ public static function buildQuickForm(&$form) { * list of errors to be posted back to the form */ public static function formRule($values, $files, $form) { - $errors = array(); + $errors = []; $linkCaseId = CRM_Utils_Array::value('link_to_case_id', $values); assert('is_numeric($linkCaseId)'); @@ -152,10 +152,10 @@ public static function endPostProcess(&$form, &$params, &$activity) { //create a link between two cases. if ($activityId && $linkCaseID) { - $caseParams = array( + $caseParams = [ 'case_id' => $linkCaseID, 'activity_id' => $activityId, - ); + ]; CRM_Case_BAO_Case::processCaseActivity($caseParams); } } diff --git a/CRM/Case/Form/Activity/OpenCase.php b/CRM/Case/Form/Activity/OpenCase.php index b2f2c5eaaa1e..1903cc87d410 100644 --- a/CRM/Case/Form/Activity/OpenCase.php +++ b/CRM/Case/Form/Activity/OpenCase.php @@ -93,7 +93,7 @@ public static function preProcess(&$form) { * @return array $defaults */ public static function setDefaultValues(&$form) { - $defaults = array(); + $defaults = []; if ($form->_context == 'caseActivity') { return $defaults; } @@ -152,25 +152,25 @@ public static function buildQuickForm(&$form) { return; } if ($form->_context == 'standalone') { - $form->addEntityRef('client_id', ts('Client'), array( + $form->addEntityRef('client_id', ts('Client'), [ 'create' => TRUE, 'multiple' => $form->_allowMultiClient, - ), TRUE); + ], TRUE); } - $element = $form->addField('case_type_id', array( + $element = $form->addField('case_type_id', [ 'context' => 'create', 'entity' => 'Case', 'onchange' => "CRM.buildCustomData('Case', this.value);", - ), TRUE); + ], TRUE); if ($form->_caseTypeId) { $element->freeze(); } - $csElement = $form->addField('status_id', array( + $csElement = $form->addField('status_id', [ 'context' => 'create', 'entity' => 'Case', - ), TRUE); + ], TRUE); if ($form->_caseStatusId) { $csElement->freeze(); } @@ -185,31 +185,31 @@ public static function buildQuickForm(&$form) { $form->add('datepicker', 'start_date', ts('Case Start Date'), [], TRUE); - $form->addField('medium_id', array('entity' => 'activity', 'context' => 'create'), TRUE); + $form->addField('medium_id', ['entity' => 'activity', 'context' => 'create'], TRUE); // calling this field activity_location to prevent conflict with contact location fields $form->add('text', 'activity_location', ts('Location'), CRM_Core_DAO::getAttribute('CRM_Activity_DAO_Activity', 'location')); - $form->add('wysiwyg', 'activity_details', ts('Details'), array('rows' => 4, 'cols' => 60), FALSE); + $form->add('wysiwyg', 'activity_details', ts('Details'), ['rows' => 4, 'cols' => 60], FALSE); - $form->addButtons(array( - array( + $form->addButtons([ + [ 'type' => 'upload', 'name' => ts('Save'), 'isDefault' => TRUE, 'submitOnce' => TRUE, - ), - array( + ], + [ 'type' => 'upload', 'name' => ts('Save and New'), 'subName' => 'new', 'submitOnce' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); } @@ -257,7 +257,7 @@ public static function formRule($fields, $files, $form) { return TRUE; } - $errors = array(); + $errors = []; return $errors; } @@ -294,25 +294,25 @@ public static function endPostProcess(&$form, &$params) { if (empty($cliId)) { CRM_Core_Error::fatal('client_id cannot be empty'); } - $contactParams = array( + $contactParams = [ 'case_id' => $params['case_id'], 'contact_id' => $cliId, - ); + ]; CRM_Case_BAO_CaseContact::create($contactParams); } } else { - $contactParams = array( + $contactParams = [ 'case_id' => $params['case_id'], 'contact_id' => $form->_currentlyViewedContactId, - ); + ]; CRM_Case_BAO_CaseContact::create($contactParams); } // 2. initiate xml processor $xmlProcessor = new CRM_Case_XMLProcessor_Process(); - $xmlProcessorParams = array( + $xmlProcessorParams = [ 'clientID' => $form->_currentlyViewedContactId, 'creatorID' => $form->_currentUserId, 'standardTimeline' => 1, @@ -325,7 +325,7 @@ public static function endPostProcess(&$form, &$params) { 'medium_id' => $params['medium_id'], 'details' => $params['activity_details'], 'relationship_end_date' => CRM_Utils_Array::value('end_date', $params), - ); + ]; if (array_key_exists('custom', $params) && is_array($params['custom'])) { $xmlProcessorParams['custom'] = $params['custom']; diff --git a/CRM/Case/Form/ActivityToCase.php b/CRM/Case/Form/ActivityToCase.php index 4d69175ffed5..d165d4c07984 100644 --- a/CRM/Case/Form/ActivityToCase.php +++ b/CRM/Case/Form/ActivityToCase.php @@ -58,8 +58,8 @@ public function preProcess() { * @return array */ public function setDefaultValues() { - $defaults = array(); - $params = array('id' => $this->_activityId); + $defaults = []; + $params = ['id' => $this->_activityId]; CRM_Activity_BAO_Activity::retrieve($params, $defaults); $defaults['file_on_case_activity_subject'] = $defaults['subject']; @@ -68,21 +68,21 @@ public function setDefaultValues() { // If this contact has an open case, supply it as a default $cid = CRM_Utils_Request::retrieve('cid', 'Integer'); if (!$cid) { - $act = civicrm_api3('Activity', 'getsingle', array('id' => $this->_activityId, 'return' => 'target_contact_id')); + $act = civicrm_api3('Activity', 'getsingle', ['id' => $this->_activityId, 'return' => 'target_contact_id']); if (!empty($act['target_contact_id'])) { $cid = $act['target_contact_id'][0]; } } if ($cid) { - $cases = civicrm_api3('CaseContact', 'get', array( + $cases = civicrm_api3('CaseContact', 'get', [ 'contact_id' => $cid, - 'case_id' => array('!=' => $this->_currentCaseId), - 'case_id.status_id' => array('!=' => "Closed"), + 'case_id' => ['!=' => $this->_currentCaseId], + 'case_id.status_id' => ['!=' => "Closed"], 'case_id.is_deleted' => 0, - 'case_id.end_date' => array('IS NULL' => 1), - 'options' => array('limit' => 1), + 'case_id.end_date' => ['IS NULL' => 1], + 'options' => ['limit' => 1], 'return' => 'case_id', - )); + ]); foreach ($cases['values'] as $record) { $defaults['file_on_case_unclosed_case_id'] = $record['case_id']; break; @@ -95,20 +95,20 @@ public function setDefaultValues() { * Build the form object. */ public function buildQuickForm() { - $this->addEntityRef('file_on_case_unclosed_case_id', ts('Select Case'), array( + $this->addEntityRef('file_on_case_unclosed_case_id', ts('Select Case'), [ 'entity' => 'Case', - 'api' => array( - 'extra' => array('contact_id'), - 'params' => array( - 'case_id' => array('!=' => $this->_currentCaseId), + 'api' => [ + 'extra' => ['contact_id'], + 'params' => [ + 'case_id' => ['!=' => $this->_currentCaseId], 'case_id.is_deleted' => 0, - 'case_id.status_id' => array('!=' => "Closed"), - 'case_id.end_date' => array('IS NULL' => 1), - ), - ), - ), TRUE); - $this->addEntityRef('file_on_case_target_contact_id', ts('With Contact(s)'), array('multiple' => TRUE)); - $this->add('text', 'file_on_case_activity_subject', ts('Subject'), array('size' => 50)); + 'case_id.status_id' => ['!=' => "Closed"], + 'case_id.end_date' => ['IS NULL' => 1], + ], + ], + ], TRUE); + $this->addEntityRef('file_on_case_target_contact_id', ts('With Contact(s)'), ['multiple' => TRUE]); + $this->add('text', 'file_on_case_activity_subject', ts('Subject'), ['size' => 50]); } } diff --git a/CRM/Case/Form/ActivityView.php b/CRM/Case/Form/ActivityView.php index e690d59b9da9..b18be74fdc36 100644 --- a/CRM/Case/Form/ActivityView.php +++ b/CRM/Case/Form/ActivityView.php @@ -66,31 +66,31 @@ public function preProcess() { $attachmentUrl = CRM_Core_BAO_File::attachmentInfo('civicrm_activity', $activityID); if ($attachmentUrl) { - $report['fields'][] = array( + $report['fields'][] = [ 'label' => 'Attachment(s)', 'value' => $attachmentUrl, 'type' => 'Link', - ); + ]; } $tags = CRM_Core_BAO_EntityTag::getTag($activityID, 'civicrm_activity'); if (!empty($tags)) { - $allTag = CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE)); + $allTag = CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', ['onlyActive' => FALSE]); foreach ($tags as $tid) { $tags[$tid] = $allTag[$tid]; } - $report['fields'][] = array( + $report['fields'][] = [ 'label' => 'Tags', 'value' => implode('
', $tags), 'type' => 'String', - ); + ]; } $this->assign('report', $report); $latestRevisionID = CRM_Activity_BAO_Activity::getLatestActivityId($activityID); - $viewPriorActivities = array(); + $viewPriorActivities = []; $priorActivities = CRM_Activity_BAO_Activity::getPriorAcitivities($activityID); foreach ($priorActivities as $activityId => $activityValues) { if (CRM_Case_BAO_Case::checkPermission($activityId, 'view', NULL, $contactID)) { @@ -152,7 +152,7 @@ public function preProcess() { $title = $title . $recentContactDisplay . ' (' . $activityTypes[$activityTypeID] . ')'; - $recentOther = array(); + $recentOther = []; if (CRM_Case_BAO_Case::checkPermission($activityID, 'edit')) { $recentOther['editUrl'] = CRM_Utils_System::url('civicrm/case/activity', "reset=1&action=update&id={$activityID}&cid={$recentContactId}&caseid={$caseID}&context=home" diff --git a/CRM/Case/Form/AddToCaseAsRole.php b/CRM/Case/Form/AddToCaseAsRole.php index af02512fdd40..20be94a95ad2 100644 --- a/CRM/Case/Form/AddToCaseAsRole.php +++ b/CRM/Case/Form/AddToCaseAsRole.php @@ -15,29 +15,29 @@ public function buildQuickForm() { 'select', 'role_type', ts('Relationship Type'), - array('' => ts('- select type -')) + $roleTypes, + ['' => ts('- select type -')] + $roleTypes, TRUE, - array('class' => 'crm-select2 twenty') + ['class' => 'crm-select2 twenty'] ); $this->addEntityRef( 'assign_to', ts('Assign to'), - array('entity' => 'Case'), + ['entity' => 'Case'], TRUE ); - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'submit', 'name' => ts('Submit'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - )); + ], + ]); } /** @@ -48,7 +48,7 @@ public function buildQuickForm() { */ private function getRoleTypes() { $relType = CRM_Contact_BAO_Relationship::getRelationType('Individual'); - $roleTypes = array(); + $roleTypes = []; foreach ($relType as $k => $v) { $roleTypes[substr($k, 0, strpos($k, '_'))] = $v; @@ -69,23 +69,23 @@ public function postProcess() { $clients = CRM_Case_BAO_Case::getCaseClients($caseId); - $params = array( + $params = [ 'contact_id_a' => $clients[0], 'contact_id_b' => $contacts, 'case_id' => $caseId, 'relationship_type_id' => $roleTypeId, - ); + ]; CRM_Contact_BAO_Relationship::createMultiple($params, 'a'); $url = CRM_Utils_System::url( 'civicrm/contact/view/case', - array( + [ 'cid' => $clients[0], 'id' => $caseId, 'reset' => 1, 'action' => 'view', - ) + ] ); CRM_Utils_System::redirect($url); } diff --git a/CRM/Case/Form/Case.php b/CRM/Case/Form/Case.php index de0ba89cb4f3..87885469db23 100644 --- a/CRM/Case/Form/Case.php +++ b/CRM/Case/Form/Case.php @@ -143,15 +143,15 @@ public function preProcess() { } if (!$this->_caseId) { - $caseAttributes = array( + $caseAttributes = [ 'case_type_id' => ts('Case Type'), 'status_id' => ts('Case Status'), 'medium_id' => ts('Activity Medium'), - ); + ]; foreach ($caseAttributes as $key => $label) { if (!CRM_Case_BAO_Case::buildOptions($key, 'create')) { - CRM_Core_Error::fatal(ts('You do not have any active %1', array(1 => $label))); + CRM_Core_Error::fatal(ts('You do not have any active %1', [1 => $label])); } } } @@ -192,7 +192,7 @@ public function preProcess() { $contact = new CRM_Contact_DAO_Contact(); $contact->id = $this->_currentlyViewedContactId; if (!$contact->find(TRUE)) { - CRM_Core_Error::statusBounce(ts('Client contact does not exist: %1', array(1 => $this->_currentlyViewedContactId))); + CRM_Core_Error::statusBounce(ts('Client contact does not exist: %1', [1 => $this->_currentlyViewedContactId])); } $this->assign('clientName', $contact->display_name); } @@ -238,18 +238,18 @@ public function buildQuickForm() { if ($this->_action & CRM_Core_Action::RENEW) { $title = ts('Restore'); } - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => $title, 'spacing' => '         ', 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); return; } @@ -262,19 +262,19 @@ public function buildQuickForm() { $s = CRM_Core_DAO::getAttribute('CRM_Activity_DAO_Activity', 'subject'); if (!is_array($s)) { - $s = array(); + $s = []; } $this->add('text', 'activity_subject', ts('Subject'), - array_merge($s, array( + array_merge($s, [ 'maxlength' => '128', - )), TRUE + ]), TRUE ); $tags = CRM_Core_BAO_Tag::getColorTags('civicrm_case'); if (!empty($tags)) { $this->add('select2', 'tag', ts('Tags'), $tags, FALSE, - array('class' => 'huge', 'multiple' => 'multiple') + ['class' => 'huge', 'multiple' => 'multiple'] ); } @@ -282,18 +282,18 @@ public function buildQuickForm() { $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_case'); CRM_Core_Form_Tag::buildQuickForm($this, $parentNames, 'civicrm_case', NULL, FALSE, TRUE); - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => ts('Save'), 'spacing' => '         ', 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); $className = "CRM_Case_Form_Activity_{$this->_activityTypeFile}"; @@ -310,8 +310,8 @@ public function addRules() { return TRUE; } $className = "CRM_Case_Form_Activity_{$this->_activityTypeFile}"; - $this->addFormRule(array($className, 'formRule'), $this); - $this->addFormRule(array('CRM_Case_Form_Case', 'formRule'), $this); + $this->addFormRule([$className, 'formRule'], $this); + $this->addFormRule(['CRM_Case_Form_Case', 'formRule'], $this); } /** @@ -384,9 +384,9 @@ public function submit(&$params) { unset($params['id'], $params['custom']); // add tags if exists - $tagParams = array(); + $tagParams = []; if (!empty($params['tag'])) { - $tagParams = array(); + $tagParams = []; if (!is_array($params['tag'])) { $params['tag'] = explode(',', $params['tag']); } diff --git a/CRM/Case/Form/CaseView.php b/CRM/Case/Form/CaseView.php index cd386d276bac..dd479144b48b 100644 --- a/CRM/Case/Form/CaseView.php +++ b/CRM/Case/Form/CaseView.php @@ -86,21 +86,21 @@ public function preProcess() { $this->assign('userID', CRM_Core_Session::getLoggedInContactID()); //retrieve details about case - $params = array('id' => $this->_caseID); + $params = ['id' => $this->_caseID]; - $returnProperties = array('case_type_id', 'subject', 'status_id', 'start_date'); + $returnProperties = ['case_type_id', 'subject', 'status_id', 'start_date']; CRM_Core_DAO::commonRetrieve('CRM_Case_BAO_Case', $params, $values, $returnProperties); $statuses = CRM_Case_PseudoConstant::caseStatus('label', FALSE); $caseTypeName = CRM_Case_BAO_Case::getCaseType($this->_caseID, 'name'); $caseType = CRM_Case_BAO_Case::getCaseType($this->_caseID); - $this->_caseDetails = array( + $this->_caseDetails = [ 'case_type' => $caseType, 'case_status' => CRM_Utils_Array::value($values['case_status_id'], $statuses), 'case_subject' => CRM_Utils_Array::value('subject', $values), 'case_start_date' => $values['case_start_date'], - ); + ]; $this->_caseType = $caseTypeName; $this->assign('caseDetails', $this->_caseDetails); @@ -121,7 +121,7 @@ public function preProcess() { CRM_Utils_System::setTitle($displayName . ' - ' . $caseType); - $recentOther = array(); + $recentOther = []; if (CRM_Core_Permission::checkActionPermission('CiviCase', CRM_Core_Action::DELETE)) { $recentOther['deleteUrl'] = CRM_Utils_System::url('civicrm/contact/view/case', "action=delete&reset=1&id={$this->_caseID}&cid={$this->_contactID}&context=home" @@ -147,16 +147,16 @@ public function preProcess() { } $this->assign('hasRelatedCases', (bool) $relatedCases); if ($relatedCases) { - $this->assign('relatedCaseLabel', ts('%1 Related Case', array( + $this->assign('relatedCaseLabel', ts('%1 Related Case', [ 'count' => count($relatedCases), 'plural' => '%1 Related Cases', - ))); - $this->assign('relatedCaseUrl', CRM_Utils_System::url('civicrm/contact/view/case', array( + ])); + $this->assign('relatedCaseUrl', CRM_Utils_System::url('civicrm/contact/view/case', [ 'id' => $this->_caseID, 'cid' => $this->_contactID, 'relatedCases' => 1, 'action' => 'view', - ))); + ])); } $entitySubType = !empty($values['case_type_id']) ? $values['case_type_id'] : NULL; @@ -176,7 +176,7 @@ public function preProcess() { * @return array; */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; return $defaults; } @@ -225,11 +225,11 @@ public function buildQuickForm() { // Only show "link cases" activity if other cases exist. $linkActTypeId = array_search('Link Cases', $allActTypes); if ($linkActTypeId) { - $count = civicrm_api3('Case', 'getcount', array( + $count = civicrm_api3('Case', 'getcount', [ 'check_permissions' => TRUE, - 'id' => array('!=' => $this->_caseID), + 'id' => ['!=' => $this->_caseID], 'is_deleted' => 0, - )); + ]); if (!$count) { unset($aTypes[$linkActTypeId]); } @@ -239,7 +239,7 @@ public function buildQuickForm() { asort($aTypes); } - $activityLinks = array('' => ts('Add Activity')); + $activityLinks = ['' => ts('Add Activity')]; foreach ($aTypes as $type => $label) { if ($type == $emailActivityType) { $url = CRM_Utils_System::url('civicrm/activity/email/add', @@ -261,20 +261,20 @@ public function buildQuickForm() { $activityLinks[$url] = $label; } - $this->add('select', 'add_activity_type_id', '', $activityLinks, FALSE, array('class' => 'crm-select2 crm-action-menu fa-calendar-check-o twenty')); + $this->add('select', 'add_activity_type_id', '', $activityLinks, FALSE, ['class' => 'crm-select2 crm-action-menu fa-calendar-check-o twenty']); if ($this->_hasAccessToAllCases) { $this->add('select', 'report_id', '', - array('' => ts('Activity Audit')) + $reports, + ['' => ts('Activity Audit')] + $reports, FALSE, - array('class' => 'crm-select2 crm-action-menu fa-list-alt') + ['class' => 'crm-select2 crm-action-menu fa-list-alt'] ); $this->add('select', 'timeline_id', '', - array('' => ts('Add Timeline')) + $reports, + ['' => ts('Add Timeline')] + $reports, FALSE, - array('class' => 'crm-select2 crm-action-menu fa-list-ol') + ['class' => 'crm-select2 crm-action-menu fa-list-ol'] ); } - $this->addElement('submit', $this->getButtonName('next'), ' ', array('class' => 'hiddenElement')); + $this->addElement('submit', $this->getButtonName('next'), ' ', ['class' => 'hiddenElement']); $this->buildMergeCaseForm(); @@ -315,7 +315,7 @@ public function buildQuickForm() { // Now build 'Other Relationships' array by removing relationships that are already listed under Case Roles // so they don't show up twice. - $clientRelationships = array(); + $clientRelationships = []; foreach ($relClient as $r) { if (!array_key_exists($r['id'], $caseRelationships)) { $clientRelationships[] = $r; @@ -324,7 +324,7 @@ public function buildQuickForm() { $this->assign('clientRelationships', $clientRelationships); // Now global contact list that appears on all cases. - $globalGroupInfo = array(); + $globalGroupInfo = []; CRM_Case_BAO_Case::getGlobalContacts($globalGroupInfo); $this->assign('globalGroupInfo', $globalGroupInfo); @@ -332,9 +332,9 @@ public function buildQuickForm() { $this->add('select', 'role_type', ts('Relationship Type'), - array('' => ts('- select type -')) + $allowedRelationshipTypes, + ['' => ts('- select type -')] + $allowedRelationshipTypes, FALSE, - array('class' => 'crm-select2 twenty', 'data-select-params' => '{"allowClear": false}') + ['class' => 'crm-select2 twenty', 'data-select-params' => '{"allowClear": false}'] ); $hookCaseSummary = CRM_Utils_Hook::caseSummary($this->_caseID); @@ -346,7 +346,7 @@ public function buildQuickForm() { if (!empty($allTags)) { $this->add('select2', 'case_tag', ts('Tags'), $allTags, FALSE, - array('id' => 'tags', 'multiple' => 'multiple') + ['id' => 'tags', 'multiple' => 'multiple'] ); $tags = CRM_Core_BAO_EntityTag::getTag($this->_caseID, 'civicrm_case'); @@ -361,7 +361,7 @@ public function buildQuickForm() { } } - $this->setDefaults(array('case_tag' => implode(',', array_keys($tags)))); + $this->setDefaults(['case_tag' => implode(',', array_keys($tags))]); $this->assign('tags', $tags); $this->assign('showTags', TRUE); @@ -374,37 +374,37 @@ public function buildQuickForm() { // see if we have any tagsets which can be assigned to cases $parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_case'); - $tagSetTags = array(); + $tagSetTags = []; if ($parentNames) { $this->assign('showTags', TRUE); - $tagSetItems = civicrm_api3('entityTag', 'get', array( + $tagSetItems = civicrm_api3('entityTag', 'get', [ 'entity_id' => $this->_caseID, 'entity_table' => 'civicrm_case', 'tag_id.parent_id.is_tagset' => 1, - 'options' => array('limit' => 0), - 'return' => array("tag_id.parent_id", "tag_id.parent_id.name", "tag_id.name"), - )); + 'options' => ['limit' => 0], + 'return' => ["tag_id.parent_id", "tag_id.parent_id.name", "tag_id.name"], + ]); foreach ($tagSetItems['values'] as $tag) { - $tagSetTags += array( - $tag['tag_id.parent_id'] => array( + $tagSetTags += [ + $tag['tag_id.parent_id'] => [ 'name' => $tag['tag_id.parent_id.name'], - 'items' => array(), - ), - ); + 'items' => [], + ], + ]; $tagSetTags[$tag['tag_id.parent_id']]['items'][] = $tag['tag_id.name']; } } $this->assign('tagSetTags', $tagSetTags); CRM_Core_Form_Tag::buildQuickForm($this, $parentNames, 'civicrm_case', $this->_caseID, FALSE, TRUE); - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'cancel', 'name' => ts('Done'), 'spacing' => '         ', 'isDefault' => TRUE, - ), - ) + ], + ] ); } @@ -423,15 +423,15 @@ public function postProcess() { $session->pushUserContext($url); if (!empty($params['timeline_id']) && !empty($_POST['_qf_CaseView_next'])) { - civicrm_api3('Case', 'addtimeline', array( + civicrm_api3('Case', 'addtimeline', [ 'case_id' => $this->_caseID, 'timeline' => $params['timeline_id'], - )); + ]); $xmlProcessor = new CRM_Case_XMLProcessor_Process(); $reports = $xmlProcessor->get($this->_caseType, 'ActivitySets'); CRM_Core_Session::setStatus(ts('Activities from the %1 activity set have been added to this case.', - array(1 => $reports[$params['timeline_id']]) + [1 => $reports[$params['timeline_id']]] ), ts('Done'), 'success'); } elseif ($this->_mergeCases && @@ -459,36 +459,36 @@ public function postProcess() { * @param array $aTypes * To include acivities related to current case id $form->_caseID. */ - public static function activityForm($form, $aTypes = array()) { + public static function activityForm($form, $aTypes = []) { $caseRelationships = CRM_Case_BAO_Case::getCaseRoles($form->_contactID, $form->_caseID); //build reporter select - $reporters = array("" => ts(' - any reporter - ')); + $reporters = ["" => ts(' - any reporter - ')]; foreach ($caseRelationships as $key => & $value) { $reporters[$value['cid']] = $value['name'] . " ( {$value['relation']} )"; } - $form->add('select', 'reporter_id', ts('Reporter/Role'), $reporters, FALSE, array('id' => 'reporter_id_' . $form->_caseID)); + $form->add('select', 'reporter_id', ts('Reporter/Role'), $reporters, FALSE, ['id' => 'reporter_id_' . $form->_caseID]); // take all case activity types for search filter, CRM-7187 - $aTypesFilter = array(); + $aTypesFilter = []; $allCaseActTypes = CRM_Case_PseudoConstant::caseActivityType(); foreach ($allCaseActTypes as $typeDetails) { - if (!in_array($typeDetails['name'], array('Open Case'))) { + if (!in_array($typeDetails['name'], ['Open Case'])) { $aTypesFilter[$typeDetails['id']] = CRM_Utils_Array::value('label', $typeDetails); } } $aTypesFilter = $aTypesFilter + $aTypes; asort($aTypesFilter); - $form->add('select', 'activity_type_filter_id', ts('Activity Type'), array('' => ts('- select activity type -')) + $aTypesFilter, FALSE, array('id' => 'activity_type_filter_id_' . $form->_caseID)); + $form->add('select', 'activity_type_filter_id', ts('Activity Type'), ['' => ts('- select activity type -')] + $aTypesFilter, FALSE, ['id' => 'activity_type_filter_id_' . $form->_caseID]); $activityStatus = CRM_Core_PseudoConstant::activityStatus(); - $form->add('select', 'status_id', ts('Status'), array("" => ts(' - any status - ')) + $activityStatus, FALSE, array('id' => 'status_id_' . $form->_caseID)); + $form->add('select', 'status_id', ts('Status'), ["" => ts(' - any status - ')] + $activityStatus, FALSE, ['id' => 'status_id_' . $form->_caseID]); // activity date search filters $form->add('datepicker', 'activity_date_low_' . $form->_caseID, ts('Activity Dates - From'), [], FALSE, ['time' => FALSE]); $form->add('datepicker', 'activity_date_high_' . $form->_caseID, ts('To'), [], FALSE, ['time' => FALSE]); if (CRM_Core_Permission::check('administer CiviCRM')) { - $form->add('checkbox', 'activity_deleted', ts('Deleted Activities'), '', FALSE, array('id' => 'activity_deleted_' . $form->_caseID)); + $form->add('checkbox', 'activity_deleted', ts('Deleted Activities'), '', FALSE, ['id' => 'activity_deleted_' . $form->_caseID]); } } @@ -496,16 +496,16 @@ public static function activityForm($form, $aTypes = array()) { * Form elements for merging cases */ public function buildMergeCaseForm() { - $otherCases = array(); - $result = civicrm_api3('Case', 'get', array( + $otherCases = []; + $result = civicrm_api3('Case', 'get', [ 'check_permissions' => TRUE, 'contact_id' => $this->_contactID, 'is_deleted' => 0, - 'id' => array('!=' => $this->_caseID), - 'return' => array('id', 'start_date', 'case_type_id.title'), - )); + 'id' => ['!=' => $this->_caseID], + 'return' => ['id', 'start_date', 'case_type_id.title'], + ]); foreach ($result['values'] as $id => $case) { - $otherCases[$id] = "#$id: {$case['case_type_id.title']} " . ts('(opened %1)', array(1 => $case['start_date'])); + $otherCases[$id] = "#$id: {$case['case_type_id.title']} " . ts('(opened %1)', [1 => $case['start_date']]); } $this->assign('mergeCases', $this->_mergeCases = (bool) $otherCases); @@ -513,18 +513,18 @@ public function buildMergeCaseForm() { if ($otherCases) { $this->add('select', 'merge_case_id', ts('Select Case for Merge'), - array( + [ '' => ts('- select case -'), - ) + $otherCases, + ] + $otherCases, FALSE, - array('class' => 'crm-select2 huge') + ['class' => 'crm-select2 huge'] ); $this->addElement('submit', $this->getButtonName('next', 'merge_case'), ts('Merge'), - array( + [ 'class' => 'hiddenElement', - ) + ] ); } } diff --git a/CRM/Case/Form/CustomData.php b/CRM/Case/Form/CustomData.php index d5e2285b8f94..0ff5a3dde932 100644 --- a/CRM/Case/Form/CustomData.php +++ b/CRM/Case/Form/CustomData.php @@ -76,10 +76,10 @@ public function preProcess() { // Array contains only one item foreach ($groupTree as $groupValues) { $this->_customTitle = $groupValues['title']; - CRM_Utils_System::setTitle(ts('Edit %1', array(1 => $groupValues['title']))); + CRM_Utils_System::setTitle(ts('Edit %1', [1 => $groupValues['title']])); } - $this->_defaults = array(); + $this->_defaults = []; CRM_Core_BAO_CustomGroup::setDefaults($groupTree, $this->_defaults); $this->setDefaults($this->_defaults); @@ -98,17 +98,17 @@ public function preProcess() { public function buildQuickForm() { // make this form an upload since we dont know if the custom data injected dynamically // is of type file etc - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'upload', 'name' => ts('Save'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); } @@ -130,7 +130,7 @@ public function postProcess() { $session->pushUserContext(CRM_Utils_System::url('civicrm/contact/view/case', "reset=1&id={$this->_entityID}&cid={$this->_contactID}&action=view")); $activityTypeID = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Change Custom Data'); - $activityParams = array( + $activityParams = [ 'activity_type_id' => $activityTypeID, 'source_contact_id' => $session->get('userID'), 'is_auto' => TRUE, @@ -139,13 +139,13 @@ public function postProcess() { 'target_contact_id' => $this->_contactID, 'details' => json_encode($this->_defaults), 'activity_date_time' => date('YmdHis'), - ); + ]; $activity = CRM_Activity_BAO_Activity::create($activityParams); - $caseParams = array( + $caseParams = [ 'activity_id' => $activity->id, 'case_id' => $this->_entityID, - ); + ]; CRM_Case_BAO_Case::processCaseActivity($caseParams); $transaction->commit(); diff --git a/CRM/Case/Form/EditClient.php b/CRM/Case/Form/EditClient.php index e48aec08fdf3..30c354a668f6 100644 --- a/CRM/Case/Form/EditClient.php +++ b/CRM/Case/Form/EditClient.php @@ -61,10 +61,10 @@ public function preProcess() { elseif ($context == 'dashboard') { $url = CRM_Utils_System::url('civicrm/case', 'reset=1'); } - elseif (in_array($context, array( + elseif (in_array($context, [ 'dashlet', 'dashletFullscreen', - ))) { + ])) { $url = CRM_Utils_System::url('civicrm/dashboard', 'reset=1'); } $session = CRM_Core_Session::singleton(); @@ -75,17 +75,17 @@ public function preProcess() { * Build the form object. */ public function buildQuickForm() { - $this->addEntityRef('reassign_contact_id', ts('Select Contact'), array('create' => TRUE), TRUE); - $this->addButtons(array( - array( + $this->addEntityRef('reassign_contact_id', ts('Select Contact'), ['create' => TRUE], TRUE); + $this->addButtons([ + [ 'type' => 'done', 'name' => ts('Reassign Case'), - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - )); + ], + ]); // This form may change the url structure so should not submit via ajax $this->preventAjaxSubmit(); @@ -93,7 +93,7 @@ public function buildQuickForm() { public function addRules() { - $this->addFormRule(array(get_class($this), 'formRule'), $this); + $this->addFormRule([get_class($this), 'formRule'], $this); } /** @@ -104,7 +104,7 @@ public function addRules() { * @return array */ public static function formRule($vals, $rule, $form) { - $errors = array(); + $errors = []; if (empty($vals['reassign_contact_id']) || $vals['reassign_contact_id'] == $form->get('cid')) { $errors['reassign_contact_id'] = ts("Please select a different contact."); } diff --git a/CRM/Case/Form/Report.php b/CRM/Case/Form/Report.php index 384f98a4f64d..5cb501fe1934 100644 --- a/CRM/Case/Form/Report.php +++ b/CRM/Case/Form/Report.php @@ -79,10 +79,10 @@ public function buildQuickForm() { return; } - $includeActivites = array( + $includeActivites = [ 1 => ts('All Activities'), 2 => ts('Exclude Completed Activities'), - ); + ]; $includeActivitesGroup = $this->addRadio('include_activities', NULL, $includeActivites, @@ -97,17 +97,17 @@ public function buildQuickForm() { ts('Redact (hide) Client and Service Provider Data') ); - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'refresh', 'name' => ts('Generate Report'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); // We want this form to redirect to a full page $this->preventAjaxSubmit(); diff --git a/CRM/Case/Form/Search.php b/CRM/Case/Form/Search.php index 14ca731cc0ff..313b74aa8ead 100644 --- a/CRM/Case/Form/Search.php +++ b/CRM/Case/Form/Search.php @@ -290,7 +290,7 @@ public function postProcess() { * @see valid_date */ public function addRules() { - $this->addFormRule(array('CRM_Case_Form_Search', 'formRule')); + $this->addFormRule(['CRM_Case_Form_Search', 'formRule']); } /** @@ -302,7 +302,7 @@ public function addRules() { * @return array|bool */ public static function formRule($fields) { - $errors = array(); + $errors = []; if (!empty($errors)) { return $errors; @@ -319,7 +319,7 @@ public static function formRule($fields) { * the default array reference */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; $defaults = $this->_formValues; return $defaults; } diff --git a/CRM/Case/Form/Task/Batch.php b/CRM/Case/Form/Task/Batch.php index 3c65b3103cc6..5d28b9761713 100644 --- a/CRM/Case/Form/Task/Batch.php +++ b/CRM/Case/Form/Task/Batch.php @@ -53,13 +53,13 @@ public function postProcess() { return; } - $customFields = array(); - $dateFields = array( + $customFields = []; + $dateFields = [ 'case_created_date', 'case_start_date', 'case_end_date', 'case_modified_date', - ); + ]; foreach ($params['field'] as $key => $value) { $value['id'] = $key; diff --git a/CRM/Case/Form/Task/Delete.php b/CRM/Case/Form/Task/Delete.php index cb878db818da..d32a9300ea13 100644 --- a/CRM/Case/Form/Task/Delete.php +++ b/CRM/Case/Form/Task/Delete.php @@ -84,16 +84,16 @@ public function postProcess() { if ($deleted) { if ($this->_moveToTrash) { - $msg = ts('%count case moved to trash.', array('plural' => '%count cases moved to trash.', 'count' => $deleted)); + $msg = ts('%count case moved to trash.', ['plural' => '%count cases moved to trash.', 'count' => $deleted]); } else { - $msg = ts('%count case permanently deleted.', array('plural' => '%count cases permanently deleted.', 'count' => $deleted)); + $msg = ts('%count case permanently deleted.', ['plural' => '%count cases permanently deleted.', 'count' => $deleted]); } CRM_Core_Session::setStatus($msg, ts('Removed'), 'success'); } if ($failed) { - CRM_Core_Session::setStatus(ts('1 could not be deleted.', array('plural' => '%count could not be deleted.', 'count' => $failed)), ts('Error'), 'error'); + CRM_Core_Session::setStatus(ts('1 could not be deleted.', ['plural' => '%count could not be deleted.', 'count' => $failed]), ts('Error'), 'error'); } } diff --git a/CRM/Case/Form/Task/Print.php b/CRM/Case/Form/Task/Print.php index 9138810a6317..09e0085768cd 100644 --- a/CRM/Case/Form/Task/Print.php +++ b/CRM/Case/Form/Task/Print.php @@ -73,18 +73,18 @@ public function buildQuickForm() { // // just need to add a javacript to popup the window for printing // - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => ts('Print Case List'), - 'js' => array('onclick' => 'window.print()'), + 'js' => ['onclick' => 'window.print()'], 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'back', 'name' => ts('Done'), - ), - ) + ], + ] ); } diff --git a/CRM/Case/Form/Task/Restore.php b/CRM/Case/Form/Task/Restore.php index 5bfdde5111d8..db78e81b73cc 100644 --- a/CRM/Case/Form/Task/Restore.php +++ b/CRM/Case/Form/Task/Restore.php @@ -73,15 +73,15 @@ public function postProcess() { } if ($restoredCases) { - $msg = ts('%count case restored from trash.', array( + $msg = ts('%count case restored from trash.', [ 'plural' => '%count cases restored from trash.', 'count' => $restoredCases, - )); + ]); CRM_Core_Session::setStatus($msg, ts('Restored'), 'success'); } if ($failed) { - CRM_Core_Session::setStatus(ts('1 could not be restored.', array('plural' => '%count could not be restored.', 'count' => $failed)), ts('Error'), 'error'); + CRM_Core_Session::setStatus(ts('1 could not be restored.', ['plural' => '%count could not be restored.', 'count' => $failed]), ts('Error'), 'error'); } } diff --git a/CRM/Case/Form/Task/Result.php b/CRM/Case/Form/Task/Result.php index 196dc972310a..49de632eba76 100644 --- a/CRM/Case/Form/Task/Result.php +++ b/CRM/Case/Form/Task/Result.php @@ -46,13 +46,13 @@ public function preProcess() { * Build the form object. */ public function buildQuickForm() { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'done', 'name' => ts('Done'), 'isDefault' => TRUE, - ), - ) + ], + ] ); } diff --git a/CRM/Case/Form/Task/SearchTaskHookSample.php b/CRM/Case/Form/Task/SearchTaskHookSample.php index f12ea6960ddb..f9f9744234d3 100644 --- a/CRM/Case/Form/Task/SearchTaskHookSample.php +++ b/CRM/Case/Form/Task/SearchTaskHookSample.php @@ -42,7 +42,7 @@ class CRM_Case_Form_Task_SearchTaskHookSample extends CRM_Case_Form_Task { */ public function preProcess() { parent::preProcess(); - $rows = array(); + $rows = []; // display name and email of all contact ids $caseIDs = implode(',', $this->_entityIds); $statusId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'case_status', 'id', 'name'); @@ -59,11 +59,11 @@ public function preProcess() { $dao = CRM_Core_DAO::executeQuery($query); while ($dao->fetch()) { - $rows[] = array( + $rows[] = [ 'display_name' => $dao->display_name, 'start_date' => CRM_Utils_Date::customFormat($dao->start_date), 'status' => $dao->status, - ); + ]; } $this->assign('rows', $rows); } @@ -72,13 +72,13 @@ public function preProcess() { * Build the form object. */ public function buildQuickForm() { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'done', 'name' => ts('Done'), 'isDefault' => TRUE, - ), - ) + ], + ] ); } diff --git a/CRM/Case/Info.php b/CRM/Case/Info.php index ab8130c66cfd..cb5e7b8cbb07 100644 --- a/CRM/Case/Info.php +++ b/CRM/Case/Info.php @@ -46,13 +46,13 @@ class CRM_Case_Info extends CRM_Core_Component_Info { * @return array */ public function getInfo() { - return array( + return [ 'name' => 'CiviCase', 'translatedName' => ts('CiviCase'), 'title' => ts('CiviCase Engine'), 'search' => 1, 'showActivitiesInCore' => 0, - ); + ]; } /** @@ -61,7 +61,7 @@ public function getInfo() { public function getAngularModules() { global $civicrm_root; - $result = array(); + $result = []; $result['crmCaseType'] = include "$civicrm_root/ang/crmCaseType.ang.php"; return $result; } @@ -89,28 +89,28 @@ public function getManagedEntities() { * @return array */ public function getPermissions($getAllUnconditionally = FALSE, $descriptions = FALSE) { - $permissions = array( - 'delete in CiviCase' => array( + $permissions = [ + 'delete in CiviCase' => [ ts('delete in CiviCase'), ts('Delete cases'), - ), - 'administer CiviCase' => array( + ], + 'administer CiviCase' => [ ts('administer CiviCase'), ts('Define case types, access deleted cases'), - ), - 'access my cases and activities' => array( + ], + 'access my cases and activities' => [ ts('access my cases and activities'), ts('View and edit only those cases managed by this user'), - ), - 'access all cases and activities' => array( + ], + 'access all cases and activities' => [ ts('access all cases and activities'), ts('View and edit all cases (for visible contacts)'), - ), - 'add cases' => array( + ], + 'add cases' => [ ts('add cases'), ts('Open a new case'), - ), - ); + ], + ]; if (!$descriptions) { foreach ($permissions as $name => $attr) { @@ -125,7 +125,7 @@ public function getPermissions($getAllUnconditionally = FALSE, $descriptions = F * @inheritDoc */ public function getReferenceCounts($dao) { - $result = array(); + $result = []; if ($dao instanceof CRM_Core_DAO_OptionValue) { /** @var $dao CRM_Core_DAO_OptionValue */ $activity_type_gid = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'activity_type', 'id', 'name'); @@ -133,11 +133,11 @@ public function getReferenceCounts($dao) { $count = CRM_Case_XMLRepository::singleton() ->getActivityReferenceCount($dao->name); if ($count > 0) { - $result[] = array( + $result[] = [ 'name' => 'casetypexml:activities', 'type' => 'casetypexml', 'count' => $count, - ); + ]; } } } @@ -146,11 +146,11 @@ public function getReferenceCounts($dao) { $count = CRM_Case_XMLRepository::singleton() ->getRelationshipReferenceCount($dao->{CRM_Case_XMLProcessor::REL_TYPE_CNAME}); if ($count > 0) { - $result[] = array( + $result[] = [ 'name' => 'casetypexml:relationships', 'type' => 'casetypexml', 'count' => $count, - ); + ]; } } return $result; @@ -161,7 +161,7 @@ public function getReferenceCounts($dao) { * @return array */ public function getUserDashboardElement() { - return array(); + return []; } /** @@ -169,11 +169,11 @@ public function getUserDashboardElement() { * @return array */ public function registerTab() { - return array( + return [ 'title' => ts('Cases'), 'url' => 'case', 'weight' => 50, - ); + ]; } /** @@ -189,10 +189,10 @@ public function getIcon() { * @return array */ public function registerAdvancedSearchPane() { - return array( + return [ 'title' => ts('Cases'), 'weight' => 50, - ); + ]; } /** @@ -213,14 +213,14 @@ public function creatNewShortcut(&$shortCuts) { ) { $activityType = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Open Case'); if ($activityType) { - $shortCuts = array_merge($shortCuts, array( - array( + $shortCuts = array_merge($shortCuts, [ + [ 'path' => 'civicrm/case/add', 'query' => "reset=1&action=add&atype={$activityType}&context=standalone", 'ref' => 'new-case', 'title' => ts('Case'), - ), - )); + ], + ]); } } } @@ -258,11 +258,11 @@ public static function onToggleComponents($oldValue, $newValue, $metadata) { * Array(string $value => string $label). */ public static function getRedactOptions() { - return array( + return [ 'default' => ts('Default'), '0' => ts('Do not redact emails'), '1' => ts('Redact emails'), - ); + ]; } /** @@ -270,11 +270,11 @@ public static function getRedactOptions() { * Array(string $value => string $label). */ public static function getMultiClientOptions() { - return array( + return [ 'default' => ts('Default'), '0' => ts('Single client per case'), '1' => ts('Multiple client per case'), - ); + ]; } /** @@ -282,11 +282,11 @@ public static function getMultiClientOptions() { * Array(string $value => string $label). */ public static function getSortOptions() { - return array( + return [ 'default' => ts('Default'), '0' => ts('Definition order'), '1' => ts('Alphabetical order'), - ); + ]; } } diff --git a/CRM/Case/ManagedEntities.php b/CRM/Case/ManagedEntities.php index 382f9a05a7b3..461b51f5dafc 100644 --- a/CRM/Case/ManagedEntities.php +++ b/CRM/Case/ManagedEntities.php @@ -14,14 +14,14 @@ class CRM_Case_ManagedEntities { * @throws CRM_Core_Exception */ public static function createManagedCaseTypes() { - $entities = array(); + $entities = []; // Use hook_civicrm_caseTypes to build a list of OptionValues // In the long run, we may want more specialized logic for this, but // this design is fairly convenient and will allow us to replace it // without changing the hook_civicrm_caseTypes interface. - $caseTypes = array(); + $caseTypes = []; CRM_Utils_Hook::caseTypes($caseTypes); $proc = new CRM_Case_XMLProcessor(); @@ -32,11 +32,11 @@ public static function createManagedCaseTypes() { } if (isset($caseType['module'], $caseType['name'], $caseType['file'])) { - $entities[] = array( + $entities[] = [ 'module' => $caseType['module'], 'name' => $caseType['name'], 'entity' => 'CaseType', - 'params' => array( + 'params' => [ 'version' => 3, 'name' => $caseType['name'], 'title' => (string) $xml->name, @@ -44,8 +44,8 @@ public static function createManagedCaseTypes() { 'is_reserved' => 1, 'is_active' => 1, 'weight' => $xml->weight ? $xml->weight : 1, - ), - ); + ], + ]; } else { throw new CRM_Core_Exception("Invalid case type"); @@ -64,26 +64,26 @@ public static function createManagedCaseTypes() { * @see CRM_Utils_Hook::managed */ public static function createManagedActivityTypes(CRM_Case_XMLRepository $xmlRepo, CRM_Core_ManagedEntities $me) { - $result = array(); + $result = []; $validActTypes = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, TRUE, 'name'); $actTypes = $xmlRepo->getAllDeclaredActivityTypes(); foreach ($actTypes as $actType) { - $managed = array( + $managed = [ 'module' => 'civicrm', 'name' => "civicase:act:$actType", 'entity' => 'OptionValue', 'update' => 'never', 'cleanup' => 'unused', - 'params' => array( + 'params' => [ 'version' => 3, 'option_group_id' => 'activity_type', 'label' => $actType, 'name' => $actType, 'description' => $actType, 'component_id' => 'CiviCase', - ), - ); + ], + ]; // We'll create managed-entity if this record doesn't exist yet // or if we previously decided to manage this record. @@ -108,7 +108,7 @@ public static function createManagedActivityTypes(CRM_Case_XMLRepository $xmlRep * @see CRM_Utils_Hook::managed */ public static function createManagedRelationshipTypes(CRM_Case_XMLRepository $xmlRepo, CRM_Core_ManagedEntities $me) { - $result = array(); + $result = []; if (!isset(Civi::$statics[__CLASS__]['reltypes'])) { $relationshipInfo = CRM_Core_PseudoConstant::relationshipType('label', TRUE, NULL); @@ -118,13 +118,13 @@ public static function createManagedRelationshipTypes(CRM_Case_XMLRepository $xm $relTypes = $xmlRepo->getAllDeclaredRelationshipTypes(); foreach ($relTypes as $relType) { - $managed = array( + $managed = [ 'module' => 'civicrm', 'name' => "civicase:rel:$relType", 'entity' => 'RelationshipType', 'update' => 'never', 'cleanup' => 'unused', - 'params' => array( + 'params' => [ 'version' => 3, 'name_a_b' => "$relType is", 'name_b_a' => $relType, @@ -135,8 +135,8 @@ public static function createManagedRelationshipTypes(CRM_Case_XMLRepository $xm 'contact_type_b' => 'Individual', 'contact_sub_type_a' => NULL, 'contact_sub_type_b' => NULL, - ), - ); + ], + ]; // We'll create managed-entity if this record doesn't exist yet // or if we previously decided to manage this record. diff --git a/CRM/Case/Page/AJAX.php b/CRM/Case/Page/AJAX.php index 78e93a3d392f..764f1f7d1307 100644 --- a/CRM/Case/Page/AJAX.php +++ b/CRM/Case/Page/AJAX.php @@ -50,15 +50,15 @@ public function processCaseTags() { CRM_Utils_System::permissionDenied(); } - $tagIds = array(); + $tagIds = []; if ($tags) { $tagIds = explode(',', $tags); } - $params = array( + $params = [ 'entity_id' => $caseId, 'entity_table' => 'civicrm_case', - ); + ]; CRM_Core_BAO_EntityTag::del($params); @@ -75,7 +75,7 @@ public function processCaseTags() { $session = CRM_Core_Session::singleton(); - $activityParams = array(); + $activityParams = []; $activityParams['source_contact_id'] = $session->get('userID'); $activityParams['activity_type_id'] = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Change Case Tags'); $activityParams['activity_date_time'] = date('YmdHis'); @@ -86,10 +86,10 @@ public function processCaseTags() { $activity = CRM_Activity_BAO_Activity::create($activityParams); - $caseParams = array( + $caseParams = [ 'activity_id' => $activity->id, 'case_id' => $caseId, - ); + ]; CRM_Case_BAO_Case::processCaseActivity($caseParams); @@ -103,10 +103,10 @@ public function processCaseTags() { public function caseDetails() { $caseId = CRM_Utils_Type::escape($_GET['caseId'], 'Positive'); - $case = civicrm_api3('Case', 'getsingle', array( + $case = civicrm_api3('Case', 'getsingle', [ 'id' => $caseId, 'check_permissions' => TRUE, - 'return' => array('subject', 'case_type_id', 'status_id', 'start_date', 'end_date')) + 'return' => ['subject', 'case_type_id', 'status_id', 'start_date', 'end_date']] ); $caseStatuses = CRM_Case_PseudoConstant::caseStatus(); @@ -136,10 +136,10 @@ public function addClient() { CRM_Utils_System::permissionDenied(); } - $params = array( + $params = [ 'case_id' => $caseId, 'contact_id' => $contactId, - ); + ]; CRM_Case_BAO_CaseContact::create($params); @@ -148,7 +148,7 @@ public function addClient() { $session = CRM_Core_Session::singleton(); - $activityParams = array(); + $activityParams = []; $activityParams['source_contact_id'] = $session->get('userID'); $activityParams['activity_type_id'] = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Add Client To Case'); $activityParams['activity_date_time'] = date('YmdHis'); @@ -159,10 +159,10 @@ public function addClient() { $activity = CRM_Activity_BAO_Activity::create($activityParams); - $caseParams = array( + $caseParams = [ 'activity_id' => $activity->id, 'case_id' => $caseId, - ); + ]; CRM_Case_BAO_Case::processCaseActivity($caseParams); CRM_Utils_JSON::output(TRUE); @@ -187,14 +187,14 @@ public static function deleteCaseRoles() { } public static function getCases() { - $requiredParameters = array( + $requiredParameters = [ 'type' => 'String', - ); - $optionalParameters = array( + ]; + $optionalParameters = [ 'case_type_id' => 'CommaSeparatedIntegers', 'status_id' => 'CommaSeparatedIntegers', 'all' => 'Positive', - ); + ]; $params = CRM_Core_Page_AJAX::defaultSortAndPagerParams(); $params += CRM_Core_Page_AJAX::validateParams($requiredParameters, $optionalParameters); @@ -202,10 +202,10 @@ public static function getCases() { $cases = CRM_Case_BAO_Case::getCases($allCases, $params); - $casesDT = array( + $casesDT = [ 'recordsFiltered' => $cases['total'], 'recordsTotal' => $cases['total'], - ); + ]; unset($cases['total']); $casesDT['data'] = array_values($cases); diff --git a/CRM/Case/Page/DashBoard.php b/CRM/Case/Page/DashBoard.php index f2dccd4af45c..fd0002c3cffe 100644 --- a/CRM/Case/Page/DashBoard.php +++ b/CRM/Case/Page/DashBoard.php @@ -84,8 +84,8 @@ public function preProcess() { $this->assign('newClient', TRUE); } $summary = CRM_Case_BAO_Case::getCasesSummary($allCases); - $upcoming = CRM_Case_BAO_Case::getCases($allCases, array(), 'dashboard', TRUE); - $recent = CRM_Case_BAO_Case::getCases($allCases, array('type' => 'recent'), 'dashboard', TRUE); + $upcoming = CRM_Case_BAO_Case::getCases($allCases, [], 'dashboard', TRUE); + $recent = CRM_Case_BAO_Case::getCases($allCases, ['type' => 'recent'], 'dashboard', TRUE); $this->assign('casesSummary', $summary); if (!empty($upcoming)) { diff --git a/CRM/Case/Page/Tab.php b/CRM/Case/Page/Tab.php index 8e1c9a91de57..36116498f418 100644 --- a/CRM/Case/Page/Tab.php +++ b/CRM/Case/Page/Tab.php @@ -67,7 +67,7 @@ public function preProcess() { if ($this->_id && ($this->_action & CRM_Core_Action::VIEW)) { //user might have special permissions to view this case, CRM-5666 if (!CRM_Core_Permission::check('access all cases and activities')) { - $userCases = CRM_Case_BAO_Case::getCases(FALSE, array('type' => 'any')); + $userCases = CRM_Case_BAO_Case::getCases(FALSE, ['type' => 'any']); if (!array_key_exists($this->_id, $userCases)) { CRM_Core_Error::fatal(ts('You are not authorized to access this page.')); } @@ -221,21 +221,21 @@ static public function &links() { if (!(self::$_links)) { $deleteExtra = ts('Are you sure you want to delete this case?'); - self::$_links = array( - CRM_Core_Action::VIEW => array( + self::$_links = [ + CRM_Core_Action::VIEW => [ 'name' => ts('Manage'), 'url' => 'civicrm/contact/view/case', 'qs' => 'action=view&reset=1&cid=%%cid%%&id=%%id%%', 'class' => 'no-popup', 'title' => ts('Manage Case'), - ), - CRM_Core_Action::DELETE => array( + ], + CRM_Core_Action::DELETE => [ 'name' => ts('Delete'), 'url' => 'civicrm/contact/view/case', 'qs' => 'action=delete&reset=1&cid=%%cid%%&id=%%id%%', 'title' => ts('Delete Case'), - ), - ); + ], + ]; } return self::$_links; } diff --git a/CRM/Case/PseudoConstant.php b/CRM/Case/PseudoConstant.php index bff8dc916002..3ee223686215 100644 --- a/CRM/Case/PseudoConstant.php +++ b/CRM/Case/PseudoConstant.php @@ -40,7 +40,7 @@ class CRM_Case_PseudoConstant extends CRM_Core_PseudoConstant { * Activity type * @var array */ - static $activityTypeList = array(); + static $activityTypeList = []; /** * Get all the case statues. @@ -156,7 +156,7 @@ public static function &caseActivityType($indexName = TRUE, $all = FALSE) { $cache = (int) $indexName . '_' . (int) $all; if (!array_key_exists($cache, self::$activityTypeList)) { - self::$activityTypeList[$cache] = array(); + self::$activityTypeList[$cache] = []; $query = " SELECT v.label as label ,v.value as value, v.name as name, v.description as description, v.icon @@ -179,7 +179,7 @@ public static function &caseActivityType($indexName = TRUE, $all = FALSE) { $dao = CRM_Core_DAO::executeQuery($query); - $activityTypes = array(); + $activityTypes = []; while ($dao->fetch()) { if ($indexName) { $index = $dao->name; @@ -187,7 +187,7 @@ public static function &caseActivityType($indexName = TRUE, $all = FALSE) { else { $index = $dao->value; } - $activityTypes[$index] = array(); + $activityTypes[$index] = []; $activityTypes[$index]['id'] = $dao->value; $activityTypes[$index]['label'] = $dao->label; $activityTypes[$index]['name'] = $dao->name; diff --git a/CRM/Case/Selector/Search.php b/CRM/Case/Selector/Search.php index d068a128af98..5869a50fd22e 100644 --- a/CRM/Case/Selector/Search.php +++ b/CRM/Case/Selector/Search.php @@ -54,7 +54,7 @@ class CRM_Case_Selector_Search extends CRM_Core_Selector_Base { * Properties of contact we're interested in displaying * @var array */ - static $_properties = array( + static $_properties = [ 'contact_id', 'contact_type', 'sort_name', @@ -67,7 +67,7 @@ class CRM_Case_Selector_Search extends CRM_Core_Selector_Base { 'case_type', 'case_role', 'phone', - ); + ]; /** * Are we restricting ourselves to a single contact @@ -184,45 +184,45 @@ static public function &links($isDeleted = FALSE, $key = NULL) { $extraParams = ($key) ? "&key={$key}" : NULL; if ($isDeleted) { - self::$_links = array( - CRM_Core_Action::RENEW => array( + self::$_links = [ + CRM_Core_Action::RENEW => [ 'name' => ts('Restore'), 'url' => 'civicrm/contact/view/case', 'qs' => 'reset=1&action=renew&id=%%id%%&cid=%%cid%%&context=%%cxt%%' . $extraParams, 'ref' => 'restore-case', 'title' => ts('Restore Case'), - ), - ); + ], + ]; } else { - self::$_links = array( - CRM_Core_Action::VIEW => array( + self::$_links = [ + CRM_Core_Action::VIEW => [ 'name' => ts('Manage'), 'url' => 'civicrm/contact/view/case', 'qs' => 'reset=1&id=%%id%%&cid=%%cid%%&action=view&context=%%cxt%%&selectedChild=case' . $extraParams, 'ref' => 'manage-case', 'class' => 'no-popup', 'title' => ts('Manage Case'), - ), - CRM_Core_Action::DELETE => array( + ], + CRM_Core_Action::DELETE => [ 'name' => ts('Delete'), 'url' => 'civicrm/contact/view/case', 'qs' => 'reset=1&action=delete&id=%%id%%&cid=%%cid%%&context=%%cxt%%' . $extraParams, 'ref' => 'delete-case', 'title' => ts('Delete Case'), - ), - CRM_Core_Action::UPDATE => array( + ], + CRM_Core_Action::UPDATE => [ 'name' => ts('Assign to Another Client'), 'url' => 'civicrm/contact/view/case/editClient', 'qs' => 'reset=1&action=update&id=%%id%%&cid=%%cid%%&context=%%cxt%%' . $extraParams, 'ref' => 'reassign', 'class' => 'medium-popup', 'title' => ts('Assign to Another Client'), - ), - ); + ], + ]; } - $actionLinks = array(); + $actionLinks = []; foreach (self::$_links as $key => $value) { $actionLinks['primaryActions'][$key] = $value; } @@ -292,10 +292,10 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { $this->_additionalClause ); // process the result of the query - $rows = array(); + $rows = []; //CRM-4418 check for view, edit, delete - $permissions = array(CRM_Core_Permission::VIEW); + $permissions = [CRM_Core_Permission::VIEW]; if (CRM_Core_Permission::check('access all cases and activities') || CRM_Core_Permission::check('access my cases and activities') ) { @@ -308,10 +308,10 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { $caseStatus = CRM_Core_OptionGroup::values('case_status', FALSE, FALSE, FALSE, " AND v.name = 'Urgent' "); - $scheduledInfo = array(); + $scheduledInfo = []; while ($result->fetch()) { - $row = array(); + $row = []; // the columns we are interested in foreach (self::$_properties as $property) { if (isset($result->$property)) { @@ -332,11 +332,11 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { $links = self::links($isDeleted, $this->_key); $row['action'] = CRM_Core_Action::formLink($links['primaryActions'], - $mask, array( + $mask, [ 'id' => $result->case_id, 'cid' => $result->contact_id, 'cxt' => $this->_context, - ), + ], ts('more'), FALSE, 'case.selector.actions', @@ -400,51 +400,51 @@ public function getQILL() { */ public function &getColumnHeaders($action = NULL, $output = NULL) { if (!isset(self::$_columnHeaders)) { - self::$_columnHeaders = array( - array( + self::$_columnHeaders = [ + [ 'name' => ts('Subject'), 'direction' => CRM_Utils_Sort::DONTCARE, - ), - array( + ], + [ 'name' => ts('Status'), 'sort' => 'case_status', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - array( + ], + [ 'name' => ts('Case Type'), 'sort' => 'case_type', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - array( + ], + [ 'name' => ts('My Role'), 'sort' => 'case_role', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - array( + ], + [ 'name' => ts('Case Manager'), 'direction' => CRM_Utils_Sort::DONTCARE, - ), - array( + ], + [ 'name' => ts('Most Recent'), 'sort' => 'case_recent_activity_date', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - array( + ], + [ 'name' => ts('Next Sched.'), 'sort' => 'case_scheduled_activity_date', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - array('name' => ts('Actions')), - ); + ], + ['name' => ts('Actions')], + ]; if (!$this->_single) { - $pre = array( - array( + $pre = [ + [ 'name' => ts('Client'), 'sort' => 'sort_name', 'direction' => CRM_Utils_Sort::ASCENDING, - ), - ); + ], + ]; self::$_columnHeaders = array_merge($pre, self::$_columnHeaders); } diff --git a/CRM/Case/StateMachine/Search.php b/CRM/Case/StateMachine/Search.php index 5bbea3e53288..8f29c530ad4a 100644 --- a/CRM/Case/StateMachine/Search.php +++ b/CRM/Case/StateMachine/Search.php @@ -48,7 +48,7 @@ class CRM_Case_StateMachine_Search extends CRM_Core_StateMachine { public function __construct($controller, $action = CRM_Core_Action::NONE) { parent::__construct($controller, $action); - $this->_pages = array(); + $this->_pages = []; $this->_pages['CRM_Case_Form_Search'] = NULL; list($task, $result) = $this->taskName($controller, 'Search'); diff --git a/CRM/Case/Task.php b/CRM/Case/Task.php index 06502469f46c..6196aa6cf433 100644 --- a/CRM/Case/Task.php +++ b/CRM/Case/Task.php @@ -53,44 +53,44 @@ class CRM_Case_Task extends CRM_Core_Task { */ public static function tasks() { if (!self::$_tasks) { - self::$_tasks = array( - self::TASK_DELETE => array( + self::$_tasks = [ + self::TASK_DELETE => [ 'title' => ts('Delete cases'), 'class' => 'CRM_Case_Form_Task_Delete', 'result' => FALSE, - ), - self::TASK_PRINT => array( + ], + self::TASK_PRINT => [ 'title' => ts('Print selected rows'), 'class' => 'CRM_Case_Form_Task_Print', 'result' => FALSE, - ), - self::TASK_EXPORT => array( + ], + self::TASK_EXPORT => [ 'title' => ts('Export cases'), - 'class' => array( + 'class' => [ 'CRM_Export_Form_Select_Case', 'CRM_Export_Form_Map', - ), + ], 'result' => FALSE, - ), - self::RESTORE_CASES => array( + ], + self::RESTORE_CASES => [ 'title' => ts('Restore cases'), 'class' => 'CRM_Case_Form_Task_Restore', 'result' => FALSE, - ), - self::PDF_LETTER => array( + ], + self::PDF_LETTER => [ 'title' => ts('Print/merge document'), 'class' => 'CRM_Case_Form_Task_PDF', 'result' => FALSE, - ), - self::BATCH_UPDATE => array( + ], + self::BATCH_UPDATE => [ 'title' => ts('Update multiple cases'), - 'class' => array( + 'class' => [ 'CRM_Case_Form_Task_PickProfile', 'CRM_Case_Form_Task_Batch', - ), + ], 'result' => FALSE, - ), - ); + ], + ]; //CRM-4418, check for delete if (!CRM_Core_Permission::check('delete in CiviCase')) { @@ -113,7 +113,7 @@ public static function tasks() { * @return array * set of tasks that are valid for the user */ - public static function permissionedTaskTitles($permission, $params = array()) { + public static function permissionedTaskTitles($permission, $params = []) { if (($permission == CRM_Core_Permission::EDIT) || CRM_Core_Permission::check('access all cases and activities') || CRM_Core_Permission::check('access my cases and activities') @@ -121,9 +121,9 @@ public static function permissionedTaskTitles($permission, $params = array()) { $tasks = self::taskTitles(); } else { - $tasks = array( + $tasks = [ self::TASK_EXPORT => self::$_tasks[self::TASK_EXPORT]['title'], - ); + ]; //CRM-4418, if (CRM_Core_Permission::check('delete in CiviCase')) { $tasks[self::TASK_DELETE] = self::$_tasks[self::TASK_DELETE]['title']; @@ -149,10 +149,10 @@ public static function getTask($value) { $value = self::TASK_PRINT; } - return array( + return [ self::$_tasks[$value]['class'], self::$_tasks[$value]['result'], - ); + ]; } } diff --git a/CRM/Case/XMLProcessor.php b/CRM/Case/XMLProcessor.php index 801279f44fff..d30b3cd06a86 100644 --- a/CRM/Case/XMLProcessor.php +++ b/CRM/Case/XMLProcessor.php @@ -113,7 +113,7 @@ public function &allRelationshipTypes() { if (self::$relationshipTypes === NULL) { $relationshipInfo = CRM_Core_PseudoConstant::relationshipType('label', TRUE); - self::$relationshipTypes = array(); + self::$relationshipTypes = []; foreach ($relationshipInfo as $id => $info) { self::$relationshipTypes[$id] = $info[CRM_Case_XMLProcessor::REL_TYPE_CNAME]; } diff --git a/CRM/Case/XMLProcessor/Process.php b/CRM/Case/XMLProcessor/Process.php index 255c7cc02985..338ae20fadd0 100644 --- a/CRM/Case/XMLProcessor/Process.php +++ b/CRM/Case/XMLProcessor/Process.php @@ -48,7 +48,7 @@ public function run($caseType, &$params) { if ($xml === FALSE) { $docLink = CRM_Utils_System::docURL2("user/case-management/set-up"); CRM_Core_Error::fatal(ts("Configuration file could not be retrieved for case type = '%1' %2.", - array(1 => $caseType, 2 => $docLink) + [1 => $caseType, 2 => $docLink] )); return FALSE; } @@ -73,7 +73,7 @@ public function get($caseType, $fieldSet, $isLabel = FALSE, $maskAction = FALSE) if ($xml === FALSE) { $docLink = CRM_Utils_System::docURL2("user/case-management/set-up"); CRM_Core_Error::fatal(ts("Unable to load configuration file for the referenced case type: '%1' %2.", - array(1 => $caseType, 2 => $docLink) + [1 => $caseType, 2 => $docLink] )); return FALSE; } @@ -183,7 +183,7 @@ public function processActivitySet($activitySetXML, &$params) { public function &caseRoles($caseRolesXML, $isCaseManager = FALSE) { $relationshipTypes = &$this->allRelationshipTypes(); - $result = array(); + $result = []; foreach ($caseRolesXML as $caseRoleXML) { foreach ($caseRoleXML->RelationshipType as $relationshipTypeXML) { $relationshipTypeName = (string ) $relationshipTypeXML->name; @@ -220,18 +220,18 @@ public function createRelationships($relationshipTypeName, &$params) { if ($relationshipTypeID === FALSE) { $docLink = CRM_Utils_System::docURL2("user/case-management/set-up"); CRM_Core_Error::fatal(ts('Relationship type %1, found in case configuration file, is not present in the database %2', - array(1 => $relationshipTypeName, 2 => $docLink) + [1 => $relationshipTypeName, 2 => $docLink] )); return FALSE; } $client = $params['clientID']; if (!is_array($client)) { - $client = array($client); + $client = [$client]; } foreach ($client as $key => $clientId) { - $relationshipParams = array( + $relationshipParams = [ 'relationship_type_id' => $relationshipTypeID, 'contact_id_a' => $clientId, 'contact_id_b' => $params['creatorID'], @@ -239,7 +239,7 @@ public function createRelationships($relationshipTypeName, &$params) { 'case_id' => $params['caseID'], 'start_date' => date("Ymd"), 'end_date' => CRM_Utils_Array::value('relationship_end_date', $params), - ); + ]; if (!$this->createRelationship($relationshipParams)) { CRM_Core_Error::fatal(); @@ -274,7 +274,7 @@ public function createRelationship(&$params) { */ public function activityTypes($activityTypesXML, $maxInst = FALSE, $isLabel = FALSE, $maskAction = FALSE) { $activityTypes = &$this->allActivityTypes(TRUE, TRUE); - $result = array(); + $result = []; foreach ($activityTypesXML as $activityTypeXML) { foreach ($activityTypeXML as $recordXML) { $activityTypeName = (string ) $recordXML->name; @@ -319,7 +319,7 @@ public function activityTypes($activityTypesXML, $maxInst = FALSE, $isLabel = FA * @return array symbolic activity-type names */ public function getDeclaredActivityTypes($caseTypeXML) { - $result = array(); + $result = []; if (!empty($caseTypeXML->ActivityTypes) && $caseTypeXML->ActivityTypes->ActivityType) { foreach ($caseTypeXML->ActivityTypes->ActivityType as $activityTypeXML) { @@ -348,7 +348,7 @@ public function getDeclaredActivityTypes($caseTypeXML) { * @return array symbolic relationship-type names */ public function getDeclaredRelationshipTypes($caseTypeXML) { - $result = array(); + $result = []; if (!empty($caseTypeXML->CaseRoles) && $caseTypeXML->CaseRoles->RelationshipType) { foreach ($caseTypeXML->CaseRoles->RelationshipType as $relTypeXML) { @@ -379,7 +379,7 @@ public function deleteEmptyActivity(&$params) { AND a.is_current_revision = 1 AND ca.case_id = %2 "; - $sqlParams = array(1 => array($params['clientID'], 'Integer'), 2 => array($params['caseID'], 'Integer')); + $sqlParams = [1 => [$params['clientID'], 'Integer'], 2 => [$params['caseID'], 'Integer']]; CRM_Core_DAO::executeQuery($query, $sqlParams); } @@ -398,10 +398,10 @@ public function isActivityPresent(&$params) { AND a.is_deleted = 0 "; - $sqlParams = array( - 1 => array($params['activityTypeID'], 'Integer'), - 2 => array($params['caseID'], 'Integer'), - ); + $sqlParams = [ + 1 => [$params['activityTypeID'], 'Integer'], + 2 => [$params['caseID'], 'Integer'], + ]; $count = CRM_Core_DAO::singleValueQuery($query, $sqlParams); // check for max instance @@ -427,7 +427,7 @@ public function createActivity($activityTypeXML, &$params) { if (!$activityTypeInfo) { $docLink = CRM_Utils_System::docURL2("user/case-management/set-up"); CRM_Core_Error::fatal(ts('Activity type %1, found in case configuration file, is not present in the database %2', - array(1 => $activityTypeName, 2 => $docLink) + [1 => $activityTypeName, 2 => $docLink] )); return FALSE; } @@ -450,7 +450,7 @@ public function createActivity($activityTypeXML, &$params) { } if ($activityTypeName == 'Open Case') { - $activityParams = array( + $activityParams = [ 'activity_type_id' => $activityTypeID, 'source_contact_id' => $params['creatorID'], 'is_auto' => FALSE, @@ -463,10 +463,10 @@ public function createActivity($activityTypeXML, &$params) { 'details' => CRM_Utils_Array::value('details', $params), 'duration' => CRM_Utils_Array::value('duration', $params), 'weight' => $orderVal, - ); + ]; } else { - $activityParams = array( + $activityParams = [ 'activity_type_id' => $activityTypeID, 'source_contact_id' => $params['creatorID'], 'is_auto' => TRUE, @@ -474,7 +474,7 @@ public function createActivity($activityTypeXML, &$params) { 'status_id' => CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_status_id', $statusName), 'target_contact_id' => $client, 'weight' => $orderVal, - ); + ]; } $activityParams['assignee_contact_id'] = $this->getDefaultAssigneeForActivity($activityParams, $activityTypeXML); @@ -512,7 +512,7 @@ public function createActivity($activityTypeXML, &$params) { else { $referenceActivityInfo = CRM_Utils_Array::value($referenceActivityName, $activityTypes); if ($referenceActivityInfo['id']) { - $caseActivityParams = array('activity_type_id' => $referenceActivityInfo['id']); + $caseActivityParams = ['activity_type_id' => $referenceActivityInfo['id']]; //if reference_select is set take according activity. if ($referenceSelect = (string) $activityTypeXML->reference_select) { @@ -565,10 +565,10 @@ public function createActivity($activityTypeXML, &$params) { } // create case activity record - $caseParams = array( + $caseParams = [ 'activity_id' => $activity->id, 'case_id' => $params['caseID'], - ); + ]; CRM_Case_BAO_Case::processCaseActivity($caseParams); return TRUE; } @@ -728,7 +728,7 @@ protected function getDefaultAssigneeBySpecificContact($activityTypeXML) { * @return array */ public static function activitySets($activitySetsXML) { - $result = array(); + $result = []; foreach ($activitySetsXML as $activitySetXML) { foreach ($activitySetXML as $recordXML) { $activitySetName = (string ) $recordXML->name; @@ -776,7 +776,7 @@ public function getCaseManagerRoleId($caseType) { */ public function getListeners($caseType) { $xml = $this->retrieve($caseType); - $listeners = array(); + $listeners = []; if ($xml->Listeners && $xml->Listeners->Listener) { foreach ($xml->Listeners->Listener as $listenerXML) { $class = (string) $listenerXML; diff --git a/CRM/Case/XMLProcessor/Settings.php b/CRM/Case/XMLProcessor/Settings.php index cef502b5af73..dbe1dedb432d 100644 --- a/CRM/Case/XMLProcessor/Settings.php +++ b/CRM/Case/XMLProcessor/Settings.php @@ -32,7 +32,7 @@ */ class CRM_Case_XMLProcessor_Settings extends CRM_Case_XMLProcessor { - private $_settings = array(); + private $_settings = []; /** * Run. diff --git a/CRM/Case/XMLRepository.php b/CRM/Case/XMLRepository.php index 7973e439a6c6..252babe18a96 100644 --- a/CRM/Case/XMLRepository.php +++ b/CRM/Case/XMLRepository.php @@ -40,7 +40,7 @@ class CRM_Case_XMLRepository { /** * @var array */ - protected $xml = array(); + protected $xml = []; /** * @var array|NULL @@ -64,10 +64,10 @@ public static function singleton($fresh = FALSE) { } public function flush() { - $this->xml = array(); + $this->xml = []; $this->hookCache = NULL; $this->allCaseTypes = NULL; - CRM_Core_DAO::$_dbColumnValueCache = array(); + CRM_Core_DAO::$_dbColumnValueCache = []; } /** @@ -76,7 +76,7 @@ public function flush() { * @param array $allCaseTypes * @param array $xml */ - public function __construct($allCaseTypes = NULL, $xml = array()) { + public function __construct($allCaseTypes = NULL, $xml = []) { $this->allCaseTypes = $allCaseTypes; $this->xml = $xml; } @@ -176,14 +176,14 @@ public function findXmlFile($caseType) { if (isset($config->customTemplateDir) && $config->customTemplateDir) { // check if the file exists in the custom templates directory $fileName = implode(DIRECTORY_SEPARATOR, - array( + [ $config->customTemplateDir, 'CRM', 'Case', 'xml', 'configuration', "$caseType.xml", - ) + ] ); } } @@ -192,24 +192,24 @@ public function findXmlFile($caseType) { if (!file_exists($fileName)) { // check if file exists locally $fileName = implode(DIRECTORY_SEPARATOR, - array( + [ dirname(__FILE__), 'xml', 'configuration', "$caseType.xml", - ) + ] ); } if (!file_exists($fileName)) { // check if file exists locally $fileName = implode(DIRECTORY_SEPARATOR, - array( + [ dirname(__FILE__), 'xml', 'configuration.sample', "$caseType.xml", - ) + ] ); } } @@ -222,7 +222,7 @@ public function findXmlFile($caseType) { */ public function getCaseTypesViaHook() { if ($this->hookCache === NULL) { - $this->hookCache = array(); + $this->hookCache = []; CRM_Utils_Hook::caseTypes($this->hookCache); } return $this->hookCache; @@ -242,7 +242,7 @@ public function getAllCaseTypes() { * @return array symbolic-names of activity-types */ public function getAllDeclaredActivityTypes() { - $result = array(); + $result = []; $p = new CRM_Case_XMLProcessor_Process(); foreach ($this->getAllCaseTypes() as $caseTypeName) { @@ -259,7 +259,7 @@ public function getAllDeclaredActivityTypes() { * @return array symbolic-names of relationship-types */ public function getAllDeclaredRelationshipTypes() { - $result = array(); + $result = []; $p = new CRM_Case_XMLProcessor_Process(); foreach ($this->getAllCaseTypes() as $caseTypeName) { diff --git a/CRM/Contact/ActionMapping.php b/CRM/Contact/ActionMapping.php index 4dee05a6ed91..90cae0a3a8dd 100644 --- a/CRM/Contact/ActionMapping.php +++ b/CRM/Contact/ActionMapping.php @@ -51,7 +51,7 @@ class CRM_Contact_ActionMapping extends \Civi\ActionSchedule\Mapping { * @param \Civi\ActionSchedule\Event\MappingRegisterEvent $registrations */ public static function onRegisterActionMappings(\Civi\ActionSchedule\Event\MappingRegisterEvent $registrations) { - $registrations->register(CRM_Contact_ActionMapping::create(array( + $registrations->register(CRM_Contact_ActionMapping::create([ 'id' => CRM_Contact_ActionMapping::CONTACT_MAPPING_ID, 'entity' => 'civicrm_contact', 'entity_label' => ts('Contact'), @@ -60,14 +60,14 @@ public static function onRegisterActionMappings(\Civi\ActionSchedule\Event\Mappi 'entity_status' => 'contact_date_reminder_options', 'entity_status_label' => ts('Annual Options'), 'entity_date_start' => 'date_field', - ))); + ])); } - private $contactDateFields = array( + private $contactDateFields = [ 'birth_date', 'created_date', 'modified_date', - ); + ]; /** * Determine whether a schedule based on this mapping is sufficiently @@ -79,7 +79,7 @@ public static function onRegisterActionMappings(\Civi\ActionSchedule\Event\Mappi * List of error messages. */ public function validateSchedule($schedule) { - $errors = array(); + $errors = []; if (CRM_Utils_System::isNull($schedule->entity_value) || $schedule->entity_value === '0') { $errors['entity'] = ts('Please select a specific date field.'); } @@ -119,29 +119,29 @@ public function createQuery($schedule, $phase, $defaultParams) { elseif (in_array($selectedValues[0], $this->contactDateFields)) { $dateDBField = $selectedValues[0]; $query = \CRM_Utils_SQL_Select::from("{$this->entity} e")->param($defaultParams); - $query->param(array( + $query->param([ 'casAddlCheckFrom' => 'civicrm_contact e', 'casContactIdField' => 'e.id', 'casEntityIdField' => 'e.id', 'casContactTableAlias' => 'e', - )); + ]); $query->where('e.is_deleted = 0 AND e.is_deceased = 0'); } else { //custom field - $customFieldParams = array('id' => substr($selectedValues[0], 7)); - $customGroup = $customField = array(); + $customFieldParams = ['id' => substr($selectedValues[0], 7)]; + $customGroup = $customField = []; \CRM_Core_BAO_CustomField::retrieve($customFieldParams, $customField); $dateDBField = $customField['column_name']; - $customGroupParams = array('id' => $customField['custom_group_id'], $customGroup); + $customGroupParams = ['id' => $customField['custom_group_id'], $customGroup]; \CRM_Core_BAO_CustomGroup::retrieve($customGroupParams, $customGroup); $query = \CRM_Utils_SQL_Select::from("{$customGroup['table_name']} e")->param($defaultParams); - $query->param(array( + $query->param([ 'casAddlCheckFrom' => "{$customGroup['table_name']} e", 'casContactIdField' => 'e.entity_id', 'casEntityIdField' => 'e.id', 'casContactTableAlias' => NULL, - )); + ]); $query->where('1'); // possible to have no "where" in this case } diff --git a/CRM/Contact/BAO/Contact/Location.php b/CRM/Contact/BAO/Contact/Location.php index a6c54fbfce74..8e7a12f373c6 100644 --- a/CRM/Contact/BAO/Contact/Location.php +++ b/CRM/Contact/BAO/Contact/Location.php @@ -45,11 +45,11 @@ class CRM_Contact_BAO_Contact_Location { * Array of display_name, email, location type and location id if found, or (null,null,null, null) */ public static function getEmailDetails($id, $isPrimary = TRUE, $locationTypeID = NULL) { - $params = array( + $params = [ 'location_type_id' => $locationTypeID, 'contact_id' => $id, - 'return' => array('contact_id.display_name', 'email', 'location_type_id', 'id'), - ); + 'return' => ['contact_id.display_name', 'email', 'location_type_id', 'id'], + ]; if ($isPrimary) { $params['is_primary'] = 1; } @@ -57,9 +57,9 @@ public static function getEmailDetails($id, $isPrimary = TRUE, $locationTypeID = if ($emails['count'] > 0) { $email = reset($emails['values']); - return array($email['contact_id.display_name'], $email['email'], $email['location_type_id'], $email['id']); + return [$email['contact_id.display_name'], $email['email'], $email['location_type_id'], $email['id']]; } - return array(NULL, NULL, NULL, NULL); + return [NULL, NULL, NULL, NULL]; } /** @@ -77,7 +77,7 @@ public static function getEmailDetails($id, $isPrimary = TRUE, $locationTypeID = public static function getPhoneDetails($id, $type = NULL) { CRM_Core_Error::deprecatedFunctionWarning('Phone.get API instead'); if (!$id) { - return array(NULL, NULL); + return [NULL, NULL]; } $cond = NULL; @@ -93,12 +93,12 @@ public static function getPhoneDetails($id, $type = NULL) { $cond AND civicrm_contact.id = %1"; - $params = array(1 => array($id, 'Integer')); + $params = [1 => [$id, 'Integer']]; $dao = CRM_Core_DAO::executeQuery($sql, $params); if ($dao->fetch()) { - return array($dao->display_name, $dao->phone, $dao->do_not_sms); + return [$dao->display_name, $dao->phone, $dao->do_not_sms]; } - return array(NULL, NULL, NULL); + return [NULL, NULL, NULL]; } /** @@ -142,22 +142,22 @@ public static function &getMapInfo($ids, $locationTypeID = NULL, $imageUrlOnly = AND civicrm_address.geo_code_2 IS NOT NULL AND civicrm_contact.id IN $idString "; - $params = array(); + $params = []; if (!$locationTypeID) { $sql .= " AND civicrm_address.is_primary = 1"; } else { $sql .= " AND civicrm_address.location_type_id = %1"; - $params[1] = array($locationTypeID, 'Integer'); + $params[1] = [$locationTypeID, 'Integer']; } $dao = CRM_Core_DAO::executeQuery($sql, $params); - $locations = array(); + $locations = []; $config = CRM_Core_Config::singleton(); while ($dao->fetch()) { - $location = array(); + $location = []; $location['contactID'] = $dao->contact_id; $location['displayName'] = addslashes($dao->display_name); $location['city'] = $dao->city; @@ -169,19 +169,19 @@ public static function &getMapInfo($ids, $locationTypeID = NULL, $imageUrlOnly = $address = ''; CRM_Utils_String::append($address, '
', - array( + [ $dao->street_address, $dao->supplemental_address_1, $dao->supplemental_address_2, $dao->supplemental_address_3, $dao->city, - ) + ] ); CRM_Utils_String::append($address, ', ', - array($dao->state, $dao->postal_code) + [$dao->state, $dao->postal_code] ); CRM_Utils_String::append($address, '
', - array($dao->country) + [$dao->country] ); $location['address'] = addslashes($address); $location['displayAddress'] = str_replace('
', ', ', addslashes($address)); diff --git a/CRM/Contact/BAO/Contact/Permission.php b/CRM/Contact/BAO/Contact/Permission.php index 4469a37c39f4..3ab63c829043 100644 --- a/CRM/Contact/BAO/Contact/Permission.php +++ b/CRM/Contact/BAO/Contact/Permission.php @@ -50,7 +50,7 @@ class CRM_Contact_BAO_Contact_Permission { * list of contact IDs the logged in user has the given permission for */ public static function allowList($contact_ids, $type = CRM_Core_Permission::VIEW) { - $result_set = array(); + $result_set = []; if (empty($contact_ids)) { // empty contact lists would cause trouble in the SQL. And be pointless. return $result_set; @@ -81,7 +81,7 @@ public static function allowList($contact_ids, $type = CRM_Core_Permission::VIEW // get logged in user $contactID = CRM_Core_Session::getLoggedInContactID(); if (empty($contactID)) { - return array(); + return []; } // make sure the cache is filled @@ -161,14 +161,14 @@ public static function allow($id, $type = CRM_Core_Permission::VIEW) { } // check permission based on relationship, CRM-2963 - if (self::relationshipList(array($id), $type)) { + if (self::relationshipList([$id], $type)) { return TRUE; } // We should probably do a cheap check whether it's in the cache first. // check permission based on ACL - $tables = array(); - $whereTables = array(); + $tables = []; + $whereTables = []; $permission = CRM_ACL_API::whereClause($type, $tables, $whereTables, NULL, FALSE, FALSE, TRUE); $from = CRM_Contact_BAO_Query::fromClause($whereTables); @@ -180,7 +180,7 @@ public static function allow($id, $type = CRM_Core_Permission::VIEW) { LIMIT 1 "; - if (CRM_Core_DAO::singleValueQuery($query, array(1 => array($id, 'Integer')))) { + if (CRM_Core_DAO::singleValueQuery($query, [1 => [$id, 'Integer']])) { return TRUE; } return FALSE; @@ -214,7 +214,7 @@ public static function cache($userID, $type = CRM_Core_Permission::VIEW, $force $operationClause = " operation = 'Edit' "; $operation = 'Edit'; } - $queryParams = array(1 => array($userID, 'Integer')); + $queryParams = [1 => [$userID, 'Integer']]; if (!$force) { // skip if already calculated @@ -236,8 +236,8 @@ public static function cache($userID, $type = CRM_Core_Permission::VIEW, $force } } - $tables = array(); - $whereTables = array(); + $tables = []; + $whereTables = []; $permission = CRM_ACL_API::whereClause($type, $tables, $whereTables, $userID, FALSE, FALSE, TRUE); @@ -273,16 +273,16 @@ public static function cacheClause($contactAlias = 'contact_a') { CRM_Core_Permission::check('edit all contacts') ) { if (is_array($contactAlias)) { - $wheres = array(); + $wheres = []; foreach ($contactAlias as $alias) { // CRM-6181 $wheres[] = "$alias.is_deleted = 0"; } - return array(NULL, '(' . implode(' AND ', $wheres) . ')'); + return [NULL, '(' . implode(' AND ', $wheres) . ')']; } else { // CRM-6181 - return array(NULL, "$contactAlias.is_deleted = 0"); + return [NULL, "$contactAlias.is_deleted = 0"]; } } @@ -291,7 +291,7 @@ public static function cacheClause($contactAlias = 'contact_a') { if (is_array($contactAlias) && !empty($contactAlias)) { //More than one contact alias - $clauses = array(); + $clauses = []; foreach ($contactAlias as $k => $alias) { $clauses[] = " INNER JOIN civicrm_acl_contact_cache aclContactCache_{$k} ON {$alias}.id = aclContactCache_{$k}.contact_id AND aclContactCache_{$k}.user_id = $contactID "; } @@ -304,7 +304,7 @@ public static function cacheClause($contactAlias = 'contact_a') { $whereClase = " aclContactCache.user_id = $contactID AND $contactAlias.is_deleted = 0"; } - return array($fromClause, $whereClase); + return [$fromClause, $whereClase]; } /** @@ -315,7 +315,7 @@ public static function cacheClause($contactAlias = 'contact_a') { * @return string|null */ public static function cacheSubquery() { - if (!CRM_Core_Permission::check(array(array('view all contacts', 'edit all contacts')))) { + if (!CRM_Core_Permission::check([['view all contacts', 'edit all contacts']])) { $contactID = (int) CRM_Core_Session::getLoggedInContactID(); self::cache($contactID); return "IN (SELECT contact_id FROM civicrm_acl_contact_cache WHERE user_id = $contactID)"; @@ -337,25 +337,25 @@ public static function cacheSubquery() { * List of contact IDs that the user has permissions for */ public static function relationshipList($contact_ids, $type) { - $result_set = array(); + $result_set = []; // no processing empty lists (avoid SQL errors as well) if (empty($contact_ids)) { - return array(); + return []; } // get the currently logged in user $contactID = CRM_Core_Session::getLoggedInContactID(); if (empty($contactID)) { - return array(); + return []; } // compile a list of queries (later to UNION) - $queries = array(); + $queries = []; $contact_id_list = implode(',', $contact_ids); // add a select statement for each direction - $directions = array(array('from' => 'a', 'to' => 'b'), array('from' => 'b', 'to' => 'a')); + $directions = [['from' => 'a', 'to' => 'b'], ['from' => 'b', 'to' => 'a']]; // CRM_Core_Permission::VIEW is satisfied by either CRM_Contact_BAO_Relationship::VIEW or CRM_Contact_BAO_Relationship::EDIT if ($type == CRM_Core_Permission::VIEW) { @@ -461,7 +461,7 @@ public static function validateOnlyChecksum($contactID, &$form, $redirect = TRUE // so here the contact is posing as $contactID, lets set the logging contact ID variable // CRM-8965 CRM_Core_DAO::executeQuery('SET @civicrm_user_id = %1', - array(1 => array($contactID, 'Integer')) + [1 => [$contactID, 'Integer']] ); return TRUE; diff --git a/CRM/Contact/BAO/Contact/Utils.php b/CRM/Contact/BAO/Contact/Utils.php index a4aff68fa82c..2b3f0879133a 100644 --- a/CRM/Contact/BAO/Contact/Utils.php +++ b/CRM/Contact/BAO/Contact/Utils.php @@ -47,16 +47,16 @@ class CRM_Contact_BAO_Contact_Utils { * @return string */ public static function getImage($contactType, $urlOnly = FALSE, $contactId = NULL, $addProfileOverlay = TRUE) { - static $imageInfo = array(); + static $imageInfo = []; $contactType = CRM_Utils_Array::explodePadded($contactType); $contactType = $contactType[0]; if (!array_key_exists($contactType, $imageInfo)) { - $imageInfo[$contactType] = array(); + $imageInfo[$contactType] = []; - $typeInfo = array(); - $params = array('name' => $contactType); + $typeInfo = []; + $params = ['name' => $contactType]; CRM_Contact_BAO_ContactType::retrieve($params, $typeInfo); if (!empty($typeInfo['image_URL'])) { @@ -253,7 +253,7 @@ public static function validChecksum($contactID, $inputCheck) { * max locations for the contact */ public static function maxLocations($contactId) { - $contactLocations = array(); + $contactLocations = []; // find number of location blocks for this contact and adjust value accordinly // get location type from email @@ -284,7 +284,7 @@ public static function maxLocations($contactId) { public static function createCurrentEmployerRelationship($contactID, $organization, $previousEmployerID = NULL, $newContact = FALSE) { //if organization name is passed. CRM-15368,CRM-15547 if ($organization && !is_numeric($organization)) { - $dupeIDs = CRM_Contact_BAO_Contact::getDuplicateContacts(array('organization_name' => $organization), 'Organization', 'Unsupervised', array(), FALSE); + $dupeIDs = CRM_Contact_BAO_Contact::getDuplicateContacts(['organization_name' => $organization], 'Organization', 'Unsupervised', [], FALSE); if (is_array($dupeIDs) && !empty($dupeIDs)) { // we should create relationship only w/ first org CRM-4193 @@ -295,17 +295,17 @@ public static function createCurrentEmployerRelationship($contactID, $organizati } else { //create new organization - $newOrg = array( + $newOrg = [ 'contact_type' => 'Organization', 'organization_name' => $organization, - ); + ]; $org = CRM_Contact_BAO_Contact::create($newOrg); $organization = $org->id; } } if ($organization && is_numeric($organization)) { - $cid = array('contact' => $contactID); + $cid = ['contact' => $contactID]; // get the relationship type id of "Employee of" $relTypeId = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_RelationshipType', 'Employee of', 'id', 'name_a_b'); @@ -314,11 +314,11 @@ public static function createCurrentEmployerRelationship($contactID, $organizati } // create employee of relationship - $relationshipParams = array( + $relationshipParams = [ 'is_active' => TRUE, 'relationship_type_id' => $relTypeId . '_a_b', - 'contact_check' => array($organization => TRUE), - ); + 'contact_check' => [$organization => TRUE], + ]; list($valid, $invalid, $duplicate, $saved, $relationshipIds) = CRM_Contact_BAO_Relationship::legacyCreateMultiple($relationshipParams, $cid); @@ -333,7 +333,7 @@ public static function createCurrentEmployerRelationship($contactID, $organizati } // set current employer - self::setCurrentEmployer(array($contactID => $organization)); + self::setCurrentEmployer([$contactID => $organization]); $relationshipParams['relationship_ids'] = $relationshipIds; // Handle related memberships. CRM-3792 @@ -358,7 +358,7 @@ public static function createCurrentEmployerRelationship($contactID, $organizati * @throws CiviCRM_API3_Exception */ public static function currentEmployerRelatedMembership($contactID, $employerID, $relationshipParams, $duplicate = FALSE, $previousEmpID = NULL) { - $ids = array(); + $ids = []; $action = CRM_Core_Action::ADD; //we do not know that triggered relationship record is active. @@ -453,7 +453,7 @@ public static function clearCurrentEmployer($contactId, $employerId = NULL) { if ($relationship->find(TRUE)) { CRM_Contact_BAO_Relationship::setIsActive($relationship->id, FALSE); CRM_Contact_BAO_Relationship::relatedMemberships($contactId, $relMembershipParams, - $ids = array(), + $ids = [], CRM_Core_Action::DELETE ); } @@ -499,7 +499,7 @@ public static function buildOnBehalfForm(&$form, $contactType, $countryID, $stat default: // individual $form->addElement('select', 'prefix_id', ts('Prefix'), - array('' => ts('- prefix -')) + CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id') + ['' => ts('- prefix -')] + CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'prefix_id') ); $form->addElement('text', 'first_name', ts('First Name'), $attributes['first_name'] @@ -511,7 +511,7 @@ public static function buildOnBehalfForm(&$form, $contactType, $countryID, $stat $attributes['last_name'] ); $form->addElement('select', 'suffix_id', ts('Suffix'), - array('' => ts('- suffix -')) + CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'suffix_id') + ['' => ts('- suffix -')] + CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'suffix_id') ); } @@ -569,19 +569,19 @@ public static function clearAllEmployee($employerId) { * returns array with links to contact view */ public static function formatContactIDSToLinks($contactIDs, $addViewLink = TRUE, $addEditLink = TRUE, $originalId = NULL) { - $contactLinks = array(); + $contactLinks = []; if (!is_array($contactIDs) || empty($contactIDs)) { return $contactLinks; } // does contact has sufficient permissions. - $permissions = array( + $permissions = [ 'view' => 'view all contacts', 'edit' => 'edit all contacts', 'merge' => 'merge duplicate contacts', - ); + ]; - $permissionedContactIds = array(); + $permissionedContactIds = []; foreach ($permissions as $task => $permission) { // give permission. if (CRM_Core_Permission::check($permission)) { @@ -592,10 +592,10 @@ public static function formatContactIDSToLinks($contactIDs, $addViewLink = TRUE, } // check permission on acl basis. - if (in_array($task, array( + if (in_array($task, [ 'view', 'edit', - ))) { + ])) { $aclPermission = CRM_Core_Permission::VIEW; if ($task == 'edit') { $aclPermission = CRM_Core_Permission::EDIT; @@ -676,10 +676,10 @@ public static function formatContactIDSToLinks($contactIDs, $addViewLink = TRUE, * @return array * array of contact info. */ - public static function contactDetails($componentIds, $componentName, $returnProperties = array()) { - $contactDetails = array(); + public static function contactDetails($componentIds, $componentName, $returnProperties = []) { + $contactDetails = []; if (empty($componentIds) || - !in_array($componentName, array('CiviContribute', 'CiviMember', 'CiviEvent', 'Activity', 'CiviCase')) + !in_array($componentName, ['CiviContribute', 'CiviMember', 'CiviEvent', 'Activity', 'CiviCase']) ) { return $contactDetails; } @@ -688,7 +688,7 @@ public static function contactDetails($componentIds, $componentName, $returnProp $autocompleteContactSearch = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_autocomplete_options' ); - $returnProperties = array_fill_keys(array_merge(array('sort_name'), + $returnProperties = array_fill_keys(array_merge(['sort_name'], array_keys($autocompleteContactSearch) ), 1); } @@ -711,13 +711,13 @@ public static function contactDetails($componentIds, $componentName, $returnProp $compTable = 'civicrm_participant'; } - $select = $from = array(); + $select = $from = []; foreach ($returnProperties as $property => $ignore) { - $value = (in_array($property, array( + $value = (in_array($property, [ 'city', 'street_address', 'postal_code', - ))) ? 'address' : $property; + ])) ? 'address' : $property; switch ($property) { case 'sort_name': if ($componentName == 'Activity') { @@ -784,7 +784,7 @@ public static function contactDetails($componentIds, $componentName, $returnProp $fromClause = implode(' ', $from); $selectClause = implode(', ', $select); $whereClause = "{$compTable}.id IN (" . implode(',', $componentIds) . ')'; - $groupBy = CRM_Contact_BAO_Query::getGroupByFromSelectColumns($select, array("{$compTable}.id", 'contact.id')); + $groupBy = CRM_Contact_BAO_Query::getGroupByFromSelectColumns($select, ["{$compTable}.id", 'contact.id']); $query = " SELECT contact.id as contactId, $compTable.id as componentId, $selectClause @@ -825,7 +825,7 @@ public static function processSharedAddress(&$address) { // Normal update process will automatically create new address with submitted values // 1. loop through entire submitted address array - $skipFields = array('is_primary', 'location_type_id', 'is_billing', 'master_id', 'update_current_employer'); + $skipFields = ['is_primary', 'location_type_id', 'is_billing', 'master_id', 'update_current_employer']; foreach ($address as & $values) { // 2. check if "Use another contact's address" is checked, if not continue // Additionally, if master_id is set (address was shared), set master_id to empty value. @@ -876,9 +876,9 @@ public static function processSharedAddress(&$address) { * associated array of contact names */ public static function getAddressShareContactNames(&$addresses) { - $contactNames = array(); + $contactNames = []; // get the list of master id's for address - $masterAddressIds = array(); + $masterAddressIds = []; foreach ($addresses as $key => $addressValue) { if (!empty($addressValue['master_id'])) { $masterAddressIds[] = $addressValue['master_id']; @@ -894,11 +894,11 @@ public static function getAddressShareContactNames(&$addresses) { while ($dao->fetch()) { $contactViewUrl = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$dao->cid}"); - $contactNames[$dao->id] = array( + $contactNames[$dao->id] = [ 'name' => "{$dao->display_name}", 'is_deleted' => $dao->is_deleted, 'contact_id' => $dao->cid, - ); + ]; } } return $contactNames; @@ -947,21 +947,21 @@ public static function updateGreeting($params) { $valueID = $id = self::defaultGreeting($contactType, $greeting); } - $filter = array( + $filter = [ 'contact_type' => $contactType, 'greeting_type' => $greeting, - ); + ]; $allGreetings = CRM_Core_PseudoConstant::greeting($filter); $originalGreetingString = $greetingString = CRM_Utils_Array::value($valueID, $allGreetings); if (!$greetingString) { - CRM_Core_Error::fatal(ts('Incorrect greeting value id %1, or no default greeting for this contact type and greeting type.', array(1 => $valueID))); + CRM_Core_Error::fatal(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); - $greetingsReturnProperties = array(); + $greetingsReturnProperties = []; if (is_array($tokens)) { $greetingsReturnProperties = array_fill_keys(array_values($tokens), 1); } @@ -976,7 +976,7 @@ public static function updateGreeting($params) { } //FIXME : apiQuery should handle these clause. - $filterContactFldIds = $filterIds = array(); + $filterContactFldIds = $filterIds = []; $idFldName = $displayFldName = NULL; if (in_array($greeting, CRM_Contact_BAO_Contact::$_greetingTypes)) { $idFldName = $greeting . '_id'; @@ -984,7 +984,7 @@ public static function updateGreeting($params) { } if ($idFldName) { - $queryParams = array(1 => array($contactType, 'String')); + $queryParams = [1 => [$contactType, 'String']]; // if $force == 1 then update all contacts else only // those with NULL greeting or addressee value CRM-9476 @@ -1002,7 +1002,7 @@ public static function updateGreeting($params) { if ($limit) { $sql .= " LIMIT 0, %2"; - $queryParams += array(2 => array($limit, 'Integer')); + $queryParams += [2 => [$limit, 'Integer']]; } $dao = CRM_Core_DAO::executeQuery($sql, $queryParams); @@ -1020,14 +1020,14 @@ public static function updateGreeting($params) { } // retrieve only required contact information - $extraParams[] = array('contact_type', '=', $contactType, 0, 0); + $extraParams[] = ['contact_type', '=', $contactType, 0, 0]; // we do token replacement in the replaceGreetingTokens hook list($greetingDetails) = CRM_Utils_Token::getTokenDetails(array_keys($filterContactFldIds), $greetingsReturnProperties, FALSE, FALSE, $extraParams ); // perform token replacement and build update SQL - $contactIds = array(); + $contactIds = []; $cacheFieldQuery = "UPDATE civicrm_contact SET {$greeting}_display = CASE id "; foreach ($greetingDetails as $contactID => $contactDetails) { if (!$processAll && @@ -1092,11 +1092,11 @@ public static function updateGreeting($params) { * @return int|NULL */ public static function defaultGreeting($contactType, $greetingType) { - $contactTypeFilters = array( + $contactTypeFilters = [ 'Individual' => 1, 'Household' => 2, 'Organization' => 3, - ); + ]; if (!isset($contactTypeFilters[$contactType])) { return NULL; } @@ -1120,15 +1120,15 @@ public static function defaultGreeting($contactType, $greetingType) { * Array of tokens. The ALL ke */ public static function getTokensRequiredForContactGreetings($contactParams) { - $tokens = array(); - foreach (array('addressee', 'email_greeting', 'postal_greeting') as $greeting) { + $tokens = []; + foreach (['addressee', 'email_greeting', 'postal_greeting'] as $greeting) { $string = ''; if (!empty($contactParams[$greeting . '_id'])) { $string = CRM_Core_PseudoConstant::getLabel('CRM_Contact_BAO_Contact', $greeting . '_id', $contactParams[$greeting . '_id']); } $string = isset($contactParams[$greeting . '_custom']) ? $contactParams[$greeting . '_custom'] : $string; if (empty($string)) { - $tokens[$greeting] = array(); + $tokens[$greeting] = []; } else { $tokens[$greeting] = CRM_Utils_Token::getTokens($string); diff --git a/CRM/Contact/BAO/ContactType.php b/CRM/Contact/BAO/ContactType.php index 87b1def2ad33..2b264dd8be8a 100644 --- a/CRM/Contact/BAO/ContactType.php +++ b/CRM/Contact/BAO/ContactType.php @@ -78,7 +78,7 @@ public static function basicTypeInfo($all = FALSE) { static $_cache = NULL; if ($_cache === NULL) { - $_cache = array(); + $_cache = []; } $argString = $all ? 'CRM_CT_BTI_1' : 'CRM_CT_BTI_0'; @@ -95,14 +95,14 @@ public static function basicTypeInfo($all = FALSE) { $sql .= " AND is_active = 1"; } - $params = array(); + $params = []; $dao = CRM_Core_DAO::executeQuery($sql, $params, FALSE, 'CRM_Contact_DAO_ContactType' ); while ($dao->fetch()) { - $value = array(); + $value = []; CRM_Core_DAO::storeValues($dao, $value); $_cache[$argString][$dao->name] = $value; } @@ -134,7 +134,7 @@ public static function basicTypes($all = FALSE) { public static function basicTypePairs($all = FALSE, $key = 'name') { $subtypes = self::basicTypeInfo($all); - $pairs = array(); + $pairs = []; foreach ($subtypes as $name => $info) { $index = ($key == 'name') ? $name : $info[$key]; $pairs[$index] = $info['label']; @@ -162,10 +162,10 @@ public static function subTypeInfo($contactType = NULL, $all = FALSE, $ignoreCac } if ($_cache === NULL) { - $_cache = array(); + $_cache = []; } if ($contactType && !is_array($contactType)) { - $contactType = array($contactType); + $contactType = [$contactType]; } $argString = $all ? 'CRM_CT_STI_1_' : 'CRM_CT_STI_0_'; @@ -177,7 +177,7 @@ public static function subTypeInfo($contactType = NULL, $all = FALSE, $ignoreCac $cache = CRM_Utils_Cache::singleton(); $_cache[$argString] = $cache->get($argString); if (!$_cache[$argString] || $ignoreCache) { - $_cache[$argString] = array(); + $_cache[$argString] = []; $ctWHERE = ''; if (!empty($contactType)) { @@ -193,11 +193,11 @@ public static function subTypeInfo($contactType = NULL, $all = FALSE, $ignoreCac if ($all === FALSE) { $sql .= " AND subtype.is_active = 1 AND parent.is_active = 1 ORDER BY parent.id"; } - $dao = CRM_Core_DAO::executeQuery($sql, array(), + $dao = CRM_Core_DAO::executeQuery($sql, [], FALSE, 'CRM_Contact_DAO_ContactType' ); while ($dao->fetch()) { - $value = array(); + $value = []; CRM_Core_DAO::storeValues($dao, $value); $value['parent'] = $dao->parent; $value['parent_label'] = $dao->parent_label; @@ -248,7 +248,7 @@ public static function subTypes($contactType = NULL, $all = FALSE, $columnName = public static function subTypePairs($contactType = NULL, $all = FALSE, $labelPrefix = '- ', $ignoreCache = FALSE) { $subtypes = self::subTypeInfo($contactType, $all, $ignoreCache); - $pairs = array(); + $pairs = []; foreach ($subtypes as $name => $info) { $pairs[$name] = $labelPrefix . $info['label']; } @@ -285,7 +285,7 @@ public static function contactTypeInfo($all = FALSE, $reset = FALSE) { } if ($_cache === NULL) { - $_cache = array(); + $_cache = []; } $argString = $all ? 'CRM_CT_CTI_1' : 'CRM_CT_CTI_0'; @@ -293,7 +293,7 @@ public static function contactTypeInfo($all = FALSE, $reset = FALSE) { $cache = CRM_Utils_Cache::singleton(); $_cache[$argString] = $cache->get($argString); if (!$_cache[$argString]) { - $_cache[$argString] = array(); + $_cache[$argString] = []; $sql = " SELECT type.*, parent.name as parent, parent.label as parent_label @@ -306,12 +306,12 @@ public static function contactTypeInfo($all = FALSE, $reset = FALSE) { } $dao = CRM_Core_DAO::executeQuery($sql, - array(), + [], FALSE, 'CRM_Contact_DAO_ContactType' ); while ($dao->fetch()) { - $value = array(); + $value = []; CRM_Core_DAO::storeValues($dao, $value); if (array_key_exists('parent_id', $value)) { $value['parent'] = $dao->parent; @@ -344,7 +344,7 @@ public static function contactTypePairs($all = FALSE, $typeName = NULL, $delimit $typeName = explode(CRM_Core_DAO::VALUE_SEPARATOR, trim($typeName, CRM_Core_DAO::VALUE_SEPARATOR)); } - $pairs = array(); + $pairs = []; if ($typeName) { foreach ($typeName as $type) { if (array_key_exists($type, $types)) { @@ -381,7 +381,7 @@ public static function getSelectElements( static $_cache = NULL; if ($_cache === NULL) { - $_cache = array(); + $_cache = []; } $argString = $all ? 'CRM_CT_GSE_1' : 'CRM_CT_GSE_0'; @@ -393,7 +393,7 @@ public static function getSelectElements( $_cache[$argString] = $cache->get($argString); if (!$_cache[$argString]) { - $_cache[$argString] = array(); + $_cache[$argString] = []; $sql = " SELECT c.name as child_name , c.label as child_label , c.id as child_id, @@ -411,7 +411,7 @@ public static function getSelectElements( } $sql .= " ORDER BY c.id"; - $values = array(); + $values = []; $dao = CRM_Core_DAO::executeQuery($sql); while ($dao->fetch()) { if (!empty($dao->parent_id)) { @@ -426,12 +426,12 @@ public static function getSelectElements( } if (!isset($values[$pName])) { - $values[$pName] = array(); + $values[$pName] = []; } - $values[$pName][] = array('key' => $key, 'label' => $label); + $values[$pName][] = ['key' => $key, 'label' => $label]; } - $selectElements = array(); + $selectElements = []; foreach ($values as $pName => $elements) { foreach ($elements as $element) { $selectElements[$element['key']] = $element['label']; @@ -468,18 +468,18 @@ public static function isaSubType($subType, $ignoreCache = FALSE) { public static function getBasicType($subType) { static $_cache = NULL; if ($_cache === NULL) { - $_cache = array(); + $_cache = []; } $isArray = TRUE; if ($subType && !is_array($subType)) { - $subType = array($subType); + $subType = [$subType]; $isArray = FALSE; } $argString = implode('_', $subType); if (!array_key_exists($argString, $_cache)) { - $_cache[$argString] = array(); + $_cache[$argString] = []; $sql = " SELECT subtype.name as contact_subtype, type.name as contact_type @@ -540,7 +540,7 @@ public static function isExtendsContactType($subType, $contactType, $ignoreCache * of contactTypes */ public static function getCreateNewList() { - $shortCuts = array(); + $shortCuts = []; //@todo FIXME - using the CRM_Core_DAO::VALUE_SEPARATOR creates invalid html - if you can find the form // this is loaded onto then replace with something like '__' & test $separator = CRM_Core_DAO::VALUE_SEPARATOR; @@ -553,12 +553,12 @@ public static function getCreateNewList() { if ($csType = CRM_Utils_Array::value('1', $typeValue)) { $typeUrl .= "&cst=$csType"; } - $shortCut = array( + $shortCut = [ 'path' => 'civicrm/contact/add', 'query' => "$typeUrl&reset=1", 'ref' => "new-$value", 'title' => $value, - ); + ]; if ($csType = CRM_Utils_Array::value('1', $typeValue)) { $shortCuts[$cType]['shortCuts'][] = $shortCut; } @@ -584,7 +584,7 @@ public static function del($contactTypeId) { return FALSE; } - $params = array('id' => $contactTypeId); + $params = ['id' => $contactTypeId]; self::retrieve($params, $typeInfo); $name = $typeInfo['name']; // check if any custom group @@ -615,7 +615,7 @@ public static function del($contactTypeId) { DELETE FROM civicrm_navigation WHERE name = %1"; - $params = array(1 => array("New $name", 'String')); + $params = [1 => ["New $name", 'String']]; $dao = CRM_Core_DAO::executeQuery($sql, $params); CRM_Core_BAO_Navigation::resetNavigation(); } @@ -655,10 +655,10 @@ public static function add(&$params) { } if (!empty($params['id'])) { - $newParams = array( + $newParams = [ 'label' => "New $contact", 'is_active' => $active, - ); + ]; CRM_Core_BAO_Navigation::processUpdate(['name' => "New $contactName"], $newParams); } else { @@ -666,16 +666,16 @@ public static function add(&$params) { if (!$name) { return; } - $value = array('name' => "New $name"); + $value = ['name' => "New $name"]; CRM_Core_BAO_Navigation::retrieve($value, $navinfo); - $navigation = array( + $navigation = [ 'label' => "New $contact", 'name' => "New $contactName", 'url' => "civicrm/contact/add?ct=$name&cst=$contactName&reset=1", 'permission' => 'add contacts', 'parent_id' => $navinfo['id'], 'is_active' => $active, - ); + ]; CRM_Core_BAO_Navigation::add($navigation); } CRM_Core_BAO_Navigation::resetNavigation(); @@ -698,10 +698,10 @@ public static function add(&$params) { * true if we found and updated the object, else false */ public static function setIsActive($id, $is_active) { - $params = array('id' => $id); + $params = ['id' => $id]; self::retrieve($params, $contactinfo); - $params = array('name' => "New $contactinfo[name]"); - $newParams = array('is_active' => $is_active); + $params = ['name' => "New $contactinfo[name]"]; + $newParams = ['is_active' => $is_active]; CRM_Core_BAO_Navigation::processUpdate($params, $newParams); CRM_Core_BAO_Navigation::resetNavigation(); return CRM_Core_DAO::setFieldValue('CRM_Contact_DAO_ContactType', $id, @@ -834,12 +834,12 @@ public static function hasRelationships($contactId, $contactType) { * * @return array */ - public static function getSubtypeCustomPair($contactType, $subtypeSet = array()) { + public static function getSubtypeCustomPair($contactType, $subtypeSet = []) { if (empty($subtypeSet)) { return $subtypeSet; } - $customSet = $subTypeClause = array(); + $customSet = $subTypeClause = []; foreach ($subtypeSet as $subtype) { $subtype = CRM_Utils_Type::escape($subtype, 'String'); $subtype = CRM_Core_DAO::VALUE_SEPARATOR . $subtype . CRM_Core_DAO::VALUE_SEPARATOR; @@ -848,7 +848,7 @@ public static function getSubtypeCustomPair($contactType, $subtypeSet = array()) $query = "SELECT table_name FROM civicrm_custom_group WHERE extends = %1 AND " . implode(" OR ", $subTypeClause); - $dao = CRM_Core_DAO::executeQuery($query, array(1 => array($contactType, 'String'))); + $dao = CRM_Core_DAO::executeQuery($query, [1 => [$contactType, 'String']]); while ($dao->fetch()) { $customSet[] = $dao->table_name; } @@ -869,8 +869,8 @@ public static function getSubtypeCustomPair($contactType, $subtypeSet = array()) public static function deleteCustomSetForSubtypeMigration( $contactID, $contactType, - $oldSubtypeSet = array(), - $newSubtypeSet = array() + $oldSubtypeSet = [], + $newSubtypeSet = [] ) { $oldCustomSet = self::getSubtypeCustomPair($contactType, $oldSubtypeSet); $newCustomSet = self::getSubtypeCustomPair($contactType, $newSubtypeSet); @@ -894,7 +894,7 @@ public static function deleteCustomSetForSubtypeMigration( * * @return bool */ - public static function deleteCustomRowsOfSubtype($gID, $subtypes = array(), $subtypesToPreserve = array()) { + public static function deleteCustomRowsOfSubtype($gID, $subtypes = [], $subtypesToPreserve = []) { if (!$gID or empty($subtypes)) { return FALSE; } @@ -910,7 +910,7 @@ public static function deleteCustomRowsOfSubtype($gID, $subtypes = array(), $sub } $subtypesToPreserveClause = implode(' AND ', $subtypesToPreserveClause); - $subtypeClause = array(); + $subtypeClause = []; foreach ($subtypes as $subtype) { $subtype = CRM_Utils_Type::escape($subtype, 'String'); $subtypeClause[] = "( civicrm_contact.contact_sub_type LIKE '%" . CRM_Core_DAO::VALUE_SEPARATOR . $subtype . CRM_Core_DAO::VALUE_SEPARATOR . "%'" @@ -942,7 +942,7 @@ public static function deleteCustomRowsOfSubtype($gID, $subtypes = array(), $sub public static function deleteCustomRowsForEntityID($customTable, $entityID) { $customTable = CRM_Utils_Type::escape($customTable, 'String'); $query = "DELETE FROM {$customTable} WHERE entity_id = %1"; - return CRM_Core_DAO::singleValueQuery($query, array(1 => array($entityID, 'Integer'))); + return CRM_Core_DAO::singleValueQuery($query, [1 => [$entityID, 'Integer']]); } } diff --git a/CRM/Contact/BAO/Group.php b/CRM/Contact/BAO/Group.php index 2b94fe37a493..3ac9d2747020 100644 --- a/CRM/Contact/BAO/Group.php +++ b/CRM/Contact/BAO/Group.php @@ -89,7 +89,7 @@ public static function discard($id) { $groupContact->delete(); // make all the 'add_to_group_id' field of 'civicrm_uf_group table', pointing to this group, as null - $params = array(1 => array($id, 'Integer')); + $params = [1 => [$id, 'Integer']]; $query = "UPDATE civicrm_uf_group SET `add_to_group_id`= NULL WHERE `add_to_group_id` = %1"; CRM_Core_DAO::executeQuery($query, $params); @@ -117,10 +117,10 @@ public static function discard($id) { CRM_Utils_Hook::post('delete', 'Group', $id, $group); // delete the recently created Group - $groupRecent = array( + $groupRecent = [ 'id' => $id, 'type' => 'Group', - ); + ]; CRM_Utils_Recent::del($groupRecent); } @@ -130,8 +130,8 @@ public static function discard($id) { * @param int $id */ public static function getGroupContacts($id) { - $params = array(array('group', 'IN', array(1 => $id), 0, 0)); - list($contacts, $_) = CRM_Contact_BAO_Query::apiQuery($params, array('contact_id')); + $params = [['group', 'IN', [1 => $id], 0, 0]]; + list($contacts, $_) = CRM_Contact_BAO_Query::apiQuery($params, ['contact_id']); return $contacts; } @@ -149,7 +149,7 @@ public static function getGroupContacts($id) { */ public static function memberCount($id, $status = 'Added', $countChildGroups = FALSE) { $groupContact = new CRM_Contact_DAO_GroupContact(); - $groupIds = array($id); + $groupIds = [$id]; if ($countChildGroups) { $groupIds = CRM_Contact_BAO_GroupNesting::getDescendentGroupIds($groupIds); } @@ -195,11 +195,11 @@ public static function memberCount($id, $status = 'Added', $countChildGroups = F * this array contains the list of members for this group id */ public static function getMember($groupID, $useCache = TRUE, $limit = 0) { - $params = array(array('group', '=', $groupID, 0, 0)); - $returnProperties = array('contact_id'); + $params = [['group', '=', $groupID, 0, 0]]; + $returnProperties = ['contact_id']; list($contacts) = CRM_Contact_BAO_Query::apiQuery($params, $returnProperties, NULL, NULL, 0, $limit, $useCache); - $aMembers = array(); + $aMembers = []; foreach ($contacts as $contact) { $aMembers[$contact['contact_id']] = 1; } @@ -278,7 +278,7 @@ public static function getGroups( $flag = $returnProperties && in_array('member_count', $returnProperties) ? 1 : 0; - $groups = array(); + $groups = []; while ($dao->fetch()) { $group = new CRM_Contact_DAO_Group(); if ($flag) { @@ -439,7 +439,7 @@ public static function create(&$params) { ) { // if no parent present and the group doesn't already have any parents, // make sure site group goes as parent - $params['parents'] = array($domainGroupID); + $params['parents'] = [$domainGroupID]; } if (!empty($params['parents'])) { @@ -480,7 +480,7 @@ public static function create(&$params) { CRM_Utils_Hook::post('create', 'Group', $group->id, $group); } - $recentOther = array(); + $recentOther = []; if (CRM_Core_Permission::check('edit groups')) { $recentOther['editUrl'] = CRM_Utils_System::url('civicrm/group', 'reset=1&action=update&id=' . $group->id); // currently same permission we are using for delete a group @@ -506,10 +506,10 @@ public static function create(&$params) { * and store it for future use */ public function buildClause() { - $params = array(array('group', 'IN', array($this->id), 0, 0)); + $params = [['group', 'IN', [$this->id], 0, 0]]; if (!empty($params)) { - $tables = $whereTables = array(); + $tables = $whereTables = []; $this->where_clause = CRM_Contact_BAO_Query::getWhereClause($params, NULL, $tables, $whereTables); if (!empty($tables)) { $this->select_tables = serialize($tables); @@ -635,12 +635,12 @@ public static function getPermissionClause() { */ protected static function flushCaches() { CRM_Utils_System::flushCache(); - $staticCaches = array( + $staticCaches = [ 'CRM_Core_PseudoConstant' => 'groups', 'CRM_ACL_API' => 'group_permission', 'CRM_ACL_BAO_ACL' => 'permissioned_groups', 'CRM_Contact_BAO_Group' => 'permission_clause', - ); + ]; foreach ($staticCaches as $class => $key) { if (isset(Civi::$statics[$class][$key])) { unset(Civi::$statics[$class][$key]); @@ -674,9 +674,9 @@ public static function createHiddenSmartGroup($params) { //save the mapping for search builder if (!$ssId) { //save record in mapping table - $mappingParams = array( + $mappingParams = [ 'mapping_type_id' => CRM_Core_PseudoConstant::getKey('CRM_Core_BAO_Mapping', 'mapping_type_id', 'Search Builder'), - ); + ]; $mapping = CRM_Core_BAO_Mapping::add($mappingParams); $mappingId = $mapping->id; } @@ -711,14 +711,14 @@ public static function createHiddenSmartGroup($params) { } else { //create group only when new saved search. - $groupParams = array( + $groupParams = [ 'title' => "Hidden Smart Group {$ssId}", 'is_active' => CRM_Utils_Array::value('is_active', $params, 1), 'is_hidden' => CRM_Utils_Array::value('is_hidden', $params, 1), 'group_type' => CRM_Utils_Array::value('group_type', $params), 'visibility' => CRM_Utils_Array::value('visibility', $params), 'saved_search_id' => $ssId, - ); + ]; $smartGroup = self::create($groupParams); $smartGroupId = $smartGroup->id; @@ -726,16 +726,16 @@ public static function createHiddenSmartGroup($params) { // Update mapping with the name and description of the hidden smart group. if ($mappingId) { - $mappingParams = array( + $mappingParams = [ 'id' => $mappingId, 'name' => CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $smartGroupId, 'name', 'id'), 'description' => CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $smartGroupId, 'description', 'id'), 'mapping_type_id' => CRM_Core_PseudoConstant::getKey('CRM_Core_BAO_Mapping', 'mapping_type_id', 'Search Builder'), - ); + ]; CRM_Core_BAO_Mapping::add($mappingParams); } - return array($smartGroupId, $ssId); + return [$smartGroupId, $ssId]; } /** @@ -770,9 +770,9 @@ static public function getGroupListSelector(&$params) { } // format params and add links - $groupList = array(); + $groupList = []; foreach ($groups as $id => $value) { - $group = array(); + $group = []; $group['group_id'] = $value['id']; $group['count'] = $value['count']; $group['title'] = $value['title']; @@ -781,12 +781,12 @@ static public function getGroupListSelector(&$params) { if (empty($params['parent_id']) && !empty($value['parents'])) { $group['parent_id'] = $value['parents']; $groupIds = explode(',', $value['parents']); - $title = array(); + $title = []; foreach ($groupIds as $gId) { $title[] = $allGroups[$gId]; } $group['title'] .= '
' . ts('Child of') . ': ' . implode(', ', $title) . '
'; - $value['class'] = array_diff($value['class'], array('crm-row-parent')); + $value['class'] = array_diff($value['class'], ['crm-row-parent']); } $group['DT_RowId'] = 'row_' . $value['id']; if (empty($params['parentsOnly'])) { @@ -797,7 +797,7 @@ static public function getGroupListSelector(&$params) { } } $group['DT_RowClass'] = 'crm-entity ' . implode(' ', $value['class']); - $group['DT_RowAttr'] = array(); + $group['DT_RowAttr'] = []; $group['DT_RowAttr']['data-id'] = $value['id']; $group['DT_RowAttr']['data-entity'] = 'group'; @@ -820,7 +820,7 @@ static public function getGroupListSelector(&$params) { array_push($groupList, $group); } - $groupsDT = array(); + $groupsDT = []; $groupsDT['data'] = $groupList; $groupsDT['recordsTotal'] = !empty($params['total']) ? $params['total'] : NULL; $groupsDT['recordsFiltered'] = !empty($params['total']) ? $params['total'] : NULL; @@ -890,7 +890,7 @@ public static function getGroupList(&$params) { //FIXME CRM-4418, now we are handling delete separately //if we introduce 'delete for group' make sure to handle here. - $groupPermissions = array(CRM_Core_Permission::VIEW); + $groupPermissions = [CRM_Core_Permission::VIEW]; if (CRM_Core_Permission::check('edit groups')) { $groupPermissions[] = CRM_Core_Permission::EDIT; $groupPermissions[] = CRM_Core_Permission::DELETE; @@ -902,16 +902,16 @@ public static function getGroupList(&$params) { $links = self::actionLinks($params); $allTypes = CRM_Core_OptionGroup::values('group_type'); - $values = array(); + $values = []; $visibility = CRM_Core_SelectValues::ufVisibility(); while ($object->fetch()) { $newLinks = $links; - $values[$object->id] = array( - 'class' => array(), + $values[$object->id] = [ + 'class' => [], 'count' => '0', - ); + ]; CRM_Core_DAO::storeValues($object, $values[$object->id]); if ($object->saved_search_id) { @@ -960,7 +960,7 @@ public static function getGroupList(&$params) { $groupTypes = explode(CRM_Core_DAO::VALUE_SEPARATOR, substr($values[$object->id]['group_type'], 1, -1) ); - $types = array(); + $types = []; foreach ($groupTypes as $type) { $types[] = CRM_Utils_Array::value($type, $allTypes); } @@ -969,10 +969,10 @@ public static function getGroupList(&$params) { if ($action) { $values[$object->id]['action'] = CRM_Core_Action::formLink($newLinks, $action, - array( + [ 'id' => $object->id, 'ssid' => $object->saved_search_id, - ), + ], ts('more'), FALSE, 'group.selector.row', @@ -1018,7 +1018,7 @@ public static function getGroupList(&$params) { $values[$object->id]['count'] = ts('unknown'); } else { - $values[$object->id]['count'] = civicrm_api3('Contact', 'getcount', array('group' => $object->id)); + $values[$object->id]['count'] = civicrm_api3('Contact', 'getcount', ['group' => $object->id]); } } @@ -1055,7 +1055,7 @@ public static function getGroupsHierarchy( $titleOnly = FALSE ) { if (empty($groupIDs)) { - return array(); + return []; } $groupIdString = '(' . implode(',', array_keys($groupIDs)) . ')'; @@ -1067,8 +1067,8 @@ public static function getGroupsHierarchy( // separators in front of the name to give it a visual offset. // Instead of recursively making mysql queries, we'll make one big // query and build the hierarchy with the algorithm below. - $groups = array(); - $args = array(1 => array($groupIdString, 'String')); + $groups = []; + $args = [1 => [$groupIdString, 'String']]; $query = " SELECT id, title, description, visibility, parents FROM civicrm_group @@ -1078,7 +1078,7 @@ public static function getGroupsHierarchy( // group can have > 1 parent so parents may be comma separated list (eg. '1,2,5'). $parentArray = explode(',', $parents); $parent = self::filterActiveGroups($parentArray); - $args[2] = array($parent, 'Integer'); + $args[2] = [$parent, 'Integer']; $query .= " AND SUBSTRING_INDEX(parents, ',', 1) = %2"; } $query .= " ORDER BY title"; @@ -1088,31 +1088,31 @@ public static function getGroupsHierarchy( // $roots represent the current leaf nodes that need to be checked for // children. $rows represent the unplaced nodes // $tree contains the child nodes based on their parent_id. - $roots = array(); - $tree = array(); + $roots = []; + $tree = []; while ($dao->fetch()) { if ($dao->parents) { $parentArray = explode(',', $dao->parents); $parent = self::filterActiveGroups($parentArray); - $tree[$parent][] = array( + $tree[$parent][] = [ 'id' => $dao->id, 'title' => $dao->title, 'visibility' => $dao->visibility, 'description' => $dao->description, - ); + ]; } else { - $roots[] = array( + $roots[] = [ 'id' => $dao->id, 'title' => $dao->title, 'visibility' => $dao->visibility, 'description' => $dao->description, - ); + ]; } } $dao->free(); - $hierarchy = array(); + $hierarchy = []; for ($i = 0; $i < count($roots); $i++) { self::buildGroupHierarchy($hierarchy, $roots[$i], $tree, $titleOnly, $spacer, 0); } @@ -1138,11 +1138,11 @@ private static function buildGroupHierarchy(&$hierarchy, $group, $tree, $titleOn $hierarchy[$group['id']] = $spaces . $group['title']; } else { - $hierarchy[$group['id']] = array( + $hierarchy[$group['id']] = [ 'title' => $spaces . $group['title'], 'description' => $group['description'], 'visibility' => $group['visibility'], - ); + ]; } // For performance reasons we use a for loop rather than a foreach. @@ -1185,15 +1185,15 @@ public static function getGroupCount(&$params) { * @return string */ public static function whereClause(&$params, $sortBy = TRUE, $excludeHidden = TRUE) { - $values = array(); + $values = []; $title = CRM_Utils_Array::value('title', $params); if ($title) { $clauses[] = "groups.title LIKE %1"; if (strpos($title, '%') !== FALSE) { - $params[1] = array($title, 'String', FALSE); + $params[1] = [$title, 'String', FALSE]; } else { - $params[1] = array($title, 'String', TRUE); + $params[1] = [$title, 'String', TRUE]; } } @@ -1203,14 +1203,14 @@ public static function whereClause(&$params, $sortBy = TRUE, $excludeHidden = TR if (!empty($types)) { $clauses[] = 'groups.group_type LIKE %2'; $typeString = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, $types) . CRM_Core_DAO::VALUE_SEPARATOR; - $params[2] = array($typeString, 'String', TRUE); + $params[2] = [$typeString, 'String', TRUE]; } } $visibility = CRM_Utils_Array::value('visibility', $params); if ($visibility) { $clauses[] = 'groups.visibility = %3'; - $params[3] = array($visibility, 'String'); + $params[3] = [$visibility, 'String']; } $groupStatus = CRM_Utils_Array::value('status', $params); @@ -1218,12 +1218,12 @@ public static function whereClause(&$params, $sortBy = TRUE, $excludeHidden = TR switch ($groupStatus) { case 1: $clauses[] = 'groups.is_active = 1'; - $params[4] = array($groupStatus, 'Integer'); + $params[4] = [$groupStatus, 'Integer']; break; case 2: $clauses[] = 'groups.is_active = 0'; - $params[4] = array($groupStatus, 'Integer'); + $params[4] = [$groupStatus, 'Integer']; break; case 3: @@ -1241,16 +1241,16 @@ public static function whereClause(&$params, $sortBy = TRUE, $excludeHidden = TR $parent_id = CRM_Utils_Array::value('parent_id', $params); if ($parent_id) { $clauses[] = 'groups.id IN (SELECT child_group_id FROM civicrm_group_nesting WHERE parent_group_id = %5)'; - $params[5] = array($parent_id, 'Integer'); + $params[5] = [$parent_id, 'Integer']; } if ($createdBy = CRM_Utils_Array::value('created_by', $params)) { $clauses[] = "createdBy.sort_name LIKE %6"; if (strpos($createdBy, '%') !== FALSE) { - $params[6] = array($createdBy, 'String', FALSE); + $params[6] = [$createdBy, 'String', FALSE]; } else { - $params[6] = array($createdBy, 'String', TRUE); + $params[6] = [$createdBy, 'String', TRUE]; } } @@ -1279,36 +1279,36 @@ public static function actionLinks($params) { $params['component_mode'] = CRM_Contact_BAO_Query::MODE_CONTACTS; } $modeValue = CRM_Contact_Form_Search::getModeValue($params['component_mode']); - $links = array( - CRM_Core_Action::VIEW => array( + $links = [ + CRM_Core_Action::VIEW => [ 'name' => $modeValue['selectorLabel'], 'url' => 'civicrm/group/search', 'qs' => 'reset=1&force=1&context=smog&gid=%%id%%&component_mode=' . $params['component_mode'], 'title' => ts('Group Contacts'), - ), - CRM_Core_Action::UPDATE => array( + ], + CRM_Core_Action::UPDATE => [ 'name' => ts('Settings'), 'url' => 'civicrm/group', 'qs' => 'reset=1&action=update&id=%%id%%', 'title' => ts('Edit Group'), - ), - CRM_Core_Action::DISABLE => array( + ], + CRM_Core_Action::DISABLE => [ 'name' => ts('Disable'), 'ref' => 'crm-enable-disable', 'title' => ts('Disable Group'), - ), - CRM_Core_Action::ENABLE => array( + ], + CRM_Core_Action::ENABLE => [ 'name' => ts('Enable'), 'ref' => 'crm-enable-disable', 'title' => ts('Enable Group'), - ), - CRM_Core_Action::DELETE => array( + ], + CRM_Core_Action::DELETE => [ 'name' => ts('Delete'), 'url' => 'civicrm/group', 'qs' => 'reset=1&action=delete&id=%%id%%', 'title' => ts('Delete Group'), - ), - ); + ], + ]; return $links; } @@ -1356,12 +1356,12 @@ protected function assignTestValue($fieldName, &$fieldDef, $counter) { * @return array */ public static function getChildGroupIds($regularGroupIDs) { - $childGroupIDs = array(); + $childGroupIDs = []; foreach ((array) $regularGroupIDs as $regularGroupID) { // temporary store the child group ID(s) of regular group identified by $id, // later merge with main child group array - $tempChildGroupIDs = array(); + $tempChildGroupIDs = []; // check that the regular group has any child group, if not then continue if ($childrenFound = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $regularGroupID, 'children')) { $tempChildGroupIDs[] = $childrenFound; @@ -1395,11 +1395,11 @@ public static function getChildGroupIds($regularGroupIDs) { */ public static function filterActiveGroups($parentArray) { if (count($parentArray) > 1) { - $result = civicrm_api3('Group', 'get', array( - 'id' => array('IN' => $parentArray), + $result = civicrm_api3('Group', 'get', [ + 'id' => ['IN' => $parentArray], 'is_active' => TRUE, 'return' => 'id', - )); + ]); $activeParentGroupIDs = CRM_Utils_Array::collect('id', $result['values']); foreach ($parentArray as $key => $groupID) { if (!array_key_exists($groupID, $activeParentGroupIDs)) { diff --git a/CRM/Contact/BAO/GroupContact.php b/CRM/Contact/BAO/GroupContact.php index 9bb1dc439a5f..688fb63f022e 100644 --- a/CRM/Contact/BAO/GroupContact.php +++ b/CRM/Contact/BAO/GroupContact.php @@ -140,7 +140,7 @@ public static function addContactsToGroup( $tracking = NULL ) { if (empty($contactIds) || empty($groupId)) { - return array(); + return []; } CRM_Utils_Hook::pre('create', 'GroupContact', $groupId, $contactIds); @@ -152,7 +152,7 @@ public static function addContactsToGroup( CRM_Utils_Hook::post('create', 'GroupContact', $groupId, $contactIds); - return array(count($contactIds), $numContactsAdded, $numContactsNotAdded); + return [count($contactIds), $numContactsAdded, $numContactsNotAdded]; } /** @@ -178,7 +178,7 @@ public static function removeContactsFromGroup( $tracking = NULL ) { if (!is_array($contactIds)) { - return array(0, 0, 0); + return [0, 0, 0]; } if ($status == 'Removed' || $status == 'Deleted') { @@ -202,14 +202,14 @@ public static function removeContactsFromGroup( if ($status == 'Deleted') { $query = "DELETE FROM civicrm_group_contact WHERE contact_id=$contactId AND group_id=$groupId"; $dao = CRM_Core_DAO::executeQuery($query); - $historyParams = array( + $historyParams = [ 'group_id' => $groupId, 'contact_id' => $contactId, 'status' => $status, 'method' => $method, 'date' => $date, 'tracking' => $tracking, - ); + ]; CRM_Contact_BAO_SubscriptionHistory::create($historyParams); } else { @@ -228,14 +228,14 @@ public static function removeContactsFromGroup( } //now we grant the negative membership to contact if not member. CRM-3711 - $historyParams = array( + $historyParams = [ 'group_id' => $groupId, 'contact_id' => $contactId, 'status' => $status, 'method' => $method, 'date' => $date, 'tracking' => $tracking, - ); + ]; CRM_Contact_BAO_SubscriptionHistory::create($historyParams); $groupContact->status = $status; $groupContact->save(); @@ -246,7 +246,7 @@ public static function removeContactsFromGroup( CRM_Utils_Hook::post($op, 'GroupContact', $groupId, $contactIds); - return array(count($contactIds), $numContactsRemoved, $numContactsNotRemoved); + return [count($contactIds), $numContactsRemoved, $numContactsNotRemoved]; } /** @@ -285,7 +285,7 @@ public static function getGroupList($contactId = 0, $visibility = FALSE) { $group->query($sql); - $values = array(); + $values = []; while ($group->fetch()) { $values[$group->id] = $group->title; } @@ -354,21 +354,21 @@ public static function getContactGroup( if ($excludeHidden) { $where .= " AND civicrm_group.is_hidden = 0 "; } - $params = array(1 => array($contactId, 'Integer')); + $params = [1 => [$contactId, 'Integer']]; if (!empty($status)) { $where .= ' AND civicrm_group_contact.status = %2'; - $params[2] = array($status, 'String'); + $params[2] = [$status, 'String']; } if (!empty($groupId)) { $where .= " AND civicrm_group.id = %3 "; - $params[3] = array($groupId, 'Integer'); + $params[3] = [$groupId, 'Integer']; } - $tables = array( + $tables = [ 'civicrm_group_contact' => 1, 'civicrm_group' => 1, 'civicrm_subscription_history' => 1, - ); - $whereTables = array(); + ]; + $whereTables = []; if ($ignorePermission) { $permission = ' ( 1 ) '; } @@ -401,7 +401,7 @@ public static function getContactGroup( } else { $dao = CRM_Core_DAO::executeQuery($sql, $params); - $values = array(); + $values = []; while ($dao->fetch()) { $id = $dao->civicrm_group_contact_id; $values[$id]['id'] = $id; @@ -470,10 +470,10 @@ public static function getMembershipDetail($contactId, $groupID, $method = 'Emai $orderBy "; - $params = array( - 1 => array($contactId, 'Integer'), - 2 => array($groupID, 'Integer'), - ); + $params = [ + 1 => [$contactId, 'Integer'], + 2 => [$groupID, 'Integer'], + ]; $dao = CRM_Core_DAO::executeQuery($query, $params); $dao->fetch(); return $dao; @@ -509,7 +509,7 @@ public static function getGroupId($groupContactID) { * @param string $method */ public static function create(&$params, $contactId, $visibility = FALSE, $method = 'Admin') { - $contactIds = array(); + $contactIds = []; $contactIds[] = $contactId; //if $visibility is true we are coming in via profile mean $method = 'Web' @@ -535,12 +535,12 @@ public static function create(&$params, $contactId, $visibility = FALSE, $method // this fix is done to prevent warning generated by array_key_exits incase of empty array is given as input if (!is_array($params)) { - $params = array(); + $params = []; } // this fix is done to prevent warning generated by array_key_exits incase of empty array is given as input if (!isset($contactGroup) || !is_array($contactGroup)) { - $contactGroup = array(); + $contactGroup = []; } // check which values has to be add/remove contact from group @@ -569,11 +569,11 @@ public static function isContactInGroup($contactID, $groupID) { return FALSE; } - $params = array( - array('group', 'IN', array($groupID), 0, 0), - array('contact_id', '=', $contactID, 0, 0), - ); - list($contacts, $_) = CRM_Contact_BAO_Query::apiQuery($params, array('contact_id')); + $params = [ + ['group', 'IN', [$groupID], 0, 0], + ['contact_id', '=', $contactID, 0, 0], + ]; + list($contacts, $_) = CRM_Contact_BAO_Query::apiQuery($params, ['contact_id']); if (!empty($contacts)) { return TRUE; @@ -595,10 +595,10 @@ public static function isContactInGroup($contactID, $groupID) { * TODO: use the 3rd $sqls param to append sql statements rather than executing them here */ public static function mergeGroupContact($mainContactId, $otherContactId) { - $params = array( - 1 => array($mainContactId, 'Integer'), - 2 => array($otherContactId, 'Integer'), - ); + $params = [ + 1 => [$mainContactId, 'Integer'], + 2 => [$otherContactId, 'Integer'], + ]; // find all groups that are in otherContactID but not in mainContactID, copy them over $sql = " @@ -610,7 +610,7 @@ public static function mergeGroupContact($mainContactId, $otherContactId) { "; $dao = CRM_Core_DAO::executeQuery($sql, $params); - $otherGroupIDs = array(); + $otherGroupIDs = []; while ($dao->fetch()) { $otherGroupIDs[] = $dao->group_id; } @@ -645,7 +645,7 @@ public static function mergeGroupContact($mainContactId, $otherContactId) { "; $dao = CRM_Core_DAO::executeQuery($sql, $params); - $groupIDs = array(); + $groupIDs = []; while ($dao->fetch()) { // only copy it over if it has added status and migrate the history if ($dao->group_status == 'Added') { @@ -738,19 +738,19 @@ public static function bulkAddContactsToGroup( AND status = %2 AND contact_id IN ( $contactStr ) "; - $params = array( - 1 => array($groupID, 'Integer'), - 2 => array($status, 'String'), - ); + $params = [ + 1 => [$groupID, 'Integer'], + 2 => [$status, 'String'], + ]; - $presentIDs = array(); + $presentIDs = []; $dao = CRM_Core_DAO::executeQuery($sql, $params); if ($dao->fetch()) { $presentIDs = explode(',', $dao->contactStr); $presentIDs = array_flip($presentIDs); } - $gcValues = $shValues = array(); + $gcValues = $shValues = []; foreach ($input as $cid) { if (isset($presentIDs[$cid])) { $numContactsNotAdded++; @@ -771,7 +771,7 @@ public static function bulkAddContactsToGroup( } } - return array($numContactsAdded, $numContactsNotAdded); + return [$numContactsAdded, $numContactsNotAdded]; } /** @@ -786,7 +786,7 @@ public static function bulkAddContactsToGroup( * * @return array|bool */ - public static function buildOptions($fieldName, $context = NULL, $props = array()) { + public static function buildOptions($fieldName, $context = NULL, $props = []) { $options = CRM_Core_PseudoConstant::get(__CLASS__, $fieldName, $props, $context); diff --git a/CRM/Contact/BAO/GroupContactCache.php b/CRM/Contact/BAO/GroupContactCache.php index 5bad91bed006..e05bd90938ae 100644 --- a/CRM/Contact/BAO/GroupContactCache.php +++ b/CRM/Contact/BAO/GroupContactCache.php @@ -32,7 +32,7 @@ */ class CRM_Contact_BAO_GroupContactCache extends CRM_Contact_DAO_GroupContactCache { - static $_alreadyLoaded = array(); + static $_alreadyLoaded = []; /** * Get a list of caching modes. @@ -40,13 +40,13 @@ class CRM_Contact_BAO_GroupContactCache extends CRM_Contact_DAO_GroupContactCach * @return array */ public static function getModes() { - return array( + return [ // Flush expired caches in response to user actions. 'opportunistic' => ts('Opportunistic Flush'), // Flush expired caches via background cron jobs. 'deterministic' => ts('Cron Flush'), - ); + ]; } /** @@ -122,7 +122,7 @@ public static function groupRefreshedClause($groupIDClause = NULL, $includeHidde */ public static function shouldGroupBeRefreshed($groupID, $includeHiddenGroups = FALSE) { $query = self::groupRefreshedClause("g.id = %1", $includeHiddenGroups); - $params = array(1 => array($groupID, 'Integer')); + $params = [1 => [$groupID, 'Integer']]; // if the query returns the group ID, it means the group is a valid candidate for refreshing return CRM_Core_DAO::singleValueQuery($query, $params); @@ -146,11 +146,11 @@ public static function loadAll($groupIDs = NULL, $limit = 0) { // this function is expensive and should be sparingly used if groupIDs is empty if (empty($groupIDs)) { $groupIDClause = NULL; - $groupIDs = array(); + $groupIDs = []; } else { if (!is_array($groupIDs)) { - $groupIDs = array($groupIDs); + $groupIDs = [$groupIDs]; } // note escapeString is a must here and we can't send the imploded value as second argument to @@ -175,7 +175,7 @@ public static function loadAll($groupIDs = NULL, $limit = 0) { "; $dao = CRM_Core_DAO::executeQuery($query); - $processGroupIDs = array(); + $processGroupIDs = []; $refreshGroupIDs = $groupIDs; while ($dao->fetch()) { $processGroupIDs[] = $dao->id; @@ -221,9 +221,9 @@ public static function add($groupIDs) { foreach ($groupIDs as $groupID) { // first delete the current cache self::clearGroupContactCache($groupID); - $params = array(array('group', 'IN', array($groupID), 0, 0)); + $params = [['group', 'IN', [$groupID], 0, 0]]; // the below call updates the cache table as a byproduct of the query - CRM_Contact_BAO_Query::apiQuery($params, array('contact_id'), NULL, NULL, 0, 0, FALSE); + CRM_Contact_BAO_Query::apiQuery($params, ['contact_id'], NULL, NULL, 0, 0, FALSE); } } @@ -295,7 +295,7 @@ public static function updateCacheTime($groupID, $processed) { */ public static function remove() { Civi::log() - ->warning('Deprecated code. This function should not be called without groupIDs. Extensions can use the api job.group_cache_flush for a hard flush or add an api option for soft flush', array('civi.tag' => 'deprecated')); + ->warning('Deprecated code. This function should not be called without groupIDs. Extensions can use the api job.group_cache_flush for a hard flush or add an api option for soft flush', ['civi.tag' => 'deprecated']); CRM_Contact_BAO_GroupContactCache::opportunisticCacheFlush(); } @@ -318,9 +318,9 @@ public static function clearGroupContactCache($groupID) { SET cache_date = null, refresh_date = null WHERE id = %1 "; - $params = array( - 1 => array($groupID, 'Integer'), - ); + $params = [ + 1 => [$groupID, 'Integer'], + ]; CRM_Core_DAO::executeQuery($query, $params); // also update the cache_date for these groups @@ -346,7 +346,7 @@ protected static function flushCaches() { // Someone else is kindly doing the refresh for us right now. return; } - $params = array(1 => array(self::getCacheInvalidDateTime(), 'String')); + $params = [1 => [self::getCacheInvalidDateTime(), 'String']]; // @todo this is consistent with previous behaviour but as the first query could take several seconds the second // could become inaccurate. It seems to make more sense to fetch them first & delete from an array (which would // also reduce joins). If we do this we should also consider how best to iterate the groups. If we do them one at @@ -394,7 +394,7 @@ protected static function flushCaches() { */ protected static function getLockForRefresh() { if (!isset(Civi::$statics[__CLASS__]['is_refresh_init'])) { - Civi::$statics[__CLASS__] = array('is_refresh_init' => FALSE); + Civi::$statics[__CLASS__] = ['is_refresh_init' => FALSE]; } if (Civi::$statics[__CLASS__]['is_refresh_init']) { @@ -448,7 +448,7 @@ public static function deterministicCacheFlush() { * TRUE if successful. */ public static function removeContact($cid, $groupId = NULL) { - $cids = array(); + $cids = []; // sanitize input foreach ((array) $cid as $c) { $cids[] = CRM_Utils_Type::escape($c, 'Integer'); @@ -514,7 +514,7 @@ public static function load(&$group, $force = FALSE) { CRM_Contact_BAO_ProximityQuery::fixInputParams($ssParams); } - $returnProperties = array(); + $returnProperties = []; if (CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_SavedSearch', $savedSearchID, 'mapping_id')) { $fv = CRM_Contact_BAO_SavedSearch::getFormValues($savedSearchID); $returnProperties = CRM_Core_BAO_Mapping::returnProperties($fv); @@ -585,7 +585,7 @@ public static function load(&$group, $force = FALSE) { $processed = FALSE; $tempTable = 'civicrm_temp_group_contact_cache' . rand(0, 2000); - foreach (array($sql, $sqlB) as $selectSql) { + foreach ([$sql, $sqlB] as $selectSql) { if (!$selectSql) { continue; } @@ -599,7 +599,7 @@ public static function load(&$group, $force = FALSE) { CRM_Core_DAO::executeQuery(" DROP TEMPORARY TABLE $tempTable"); } - self::updateCacheTime(array($groupID), $processed); + self::updateCacheTime([$groupID], $processed); if ($group->children) { @@ -610,7 +610,7 @@ public static function load(&$group, $force = FALSE) { WHERE civicrm_group_contact.status = 'Removed' AND civicrm_group_contact.group_id = $groupID "; $dao = CRM_Core_DAO::executeQuery($sql); - $removed_contacts = array(); + $removed_contacts = []; while ($dao->fetch()) { $removed_contacts[] = $dao->contact_id; } @@ -622,12 +622,12 @@ public static function load(&$group, $force = FALSE) { foreach ($removed_contacts as $removed_contact) { unset($contactIDs[$removed_contact]); } - $values = array(); + $values = []; foreach ($contactIDs as $contactID => $dontCare) { $values[] = "({$groupID},{$contactID})"; } - self::store(array($groupID), $values); + self::store([$groupID], $values); } } @@ -679,7 +679,7 @@ public static function contactGroup($contactID, $showHidden = FALSE) { $contactIDs = $contactID; } else { - $contactIDs = array($contactID); + $contactIDs = [$contactID]; } self::loadAll(); @@ -700,7 +700,7 @@ public static function contactGroup($contactID, $showHidden = FALSE) { "; $dao = CRM_Core_DAO::executeQuery($sql); - $contactGroup = array(); + $contactGroup = []; $prevContactID = NULL; while ($dao->fetch()) { if ( @@ -712,16 +712,16 @@ public static function contactGroup($contactID, $showHidden = FALSE) { $prevContactID = $dao->contact_id; if (!array_key_exists($dao->contact_id, $contactGroup)) { $contactGroup[$dao->contact_id] - = array('group' => array(), 'groupTitle' => array()); + = ['group' => [], 'groupTitle' => []]; } $contactGroup[$dao->contact_id]['group'][] - = array( + = [ 'id' => $dao->group_id, 'title' => $dao->title, 'description' => $dao->description, 'children' => $dao->children, - ); + ]; $contactGroup[$dao->contact_id]['groupTitle'][] = $dao->title; } diff --git a/CRM/Contact/BAO/GroupNesting.php b/CRM/Contact/BAO/GroupNesting.php index 615b9a0e97db..dae7b4a3fd2e 100644 --- a/CRM/Contact/BAO/GroupNesting.php +++ b/CRM/Contact/BAO/GroupNesting.php @@ -146,12 +146,12 @@ public static function hasParentGroups($groupId) { */ public static function getChildGroupIds($groupIds) { if (!is_array($groupIds)) { - $groupIds = array($groupIds); + $groupIds = [$groupIds]; } $dao = new CRM_Contact_DAO_GroupNesting(); $query = "SELECT child_group_id FROM civicrm_group_nesting WHERE parent_group_id IN (" . implode(',', $groupIds) . ")"; $dao->query($query); - $childGroupIds = array(); + $childGroupIds = []; while ($dao->fetch()) { $childGroupIds[] = $dao->child_group_id; } @@ -169,12 +169,12 @@ public static function getChildGroupIds($groupIds) { */ public static function getParentGroupIds($groupIds) { if (!is_array($groupIds)) { - $groupIds = array($groupIds); + $groupIds = [$groupIds]; } $dao = new CRM_Contact_DAO_GroupNesting(); $query = "SELECT parent_group_id FROM civicrm_group_nesting WHERE child_group_id IN (" . implode(',', $groupIds) . ")"; $dao->query($query); - $parentGroupIds = array(); + $parentGroupIds = []; while ($dao->fetch()) { $parentGroupIds[] = $dao->parent_group_id; } @@ -194,13 +194,13 @@ public static function getParentGroupIds($groupIds) { */ public static function getDescendentGroupIds($groupIds, $includeSelf = TRUE) { if (!is_array($groupIds)) { - $groupIds = array($groupIds); + $groupIds = [$groupIds]; } $dao = new CRM_Contact_DAO_GroupNesting(); $query = "SELECT child_group_id, parent_group_id FROM civicrm_group_nesting WHERE parent_group_id IN (" . implode(',', $groupIds) . ")"; $dao->query($query); - $tmpGroupIds = array(); - $childGroupIds = array(); + $tmpGroupIds = []; + $childGroupIds = []; if ($includeSelf) { $childGroupIds = $groupIds; } diff --git a/CRM/Contact/BAO/GroupNestingCache.php b/CRM/Contact/BAO/GroupNestingCache.php index af7ee5d5901a..74d7d6f1fe75 100644 --- a/CRM/Contact/BAO/GroupNestingCache.php +++ b/CRM/Contact/BAO/GroupNestingCache.php @@ -52,20 +52,20 @@ static public function update() { $dao = CRM_Core_DAO::executeQuery($sql); - $tree = array(); + $tree = []; while ($dao->fetch()) { if (!array_key_exists($dao->child, $tree)) { - $tree[$dao->child] = array( - 'children' => array(), - 'parents' => array(), - ); + $tree[$dao->child] = [ + 'children' => [], + 'parents' => [], + ]; } if (!array_key_exists($dao->parent, $tree)) { - $tree[$dao->parent] = array( - 'children' => array(), - 'parents' => array(), - ); + $tree[$dao->parent] = [ + 'children' => [], + 'parents' => [], + ]; } $tree[$dao->child]['parents'][] = $dao->parent; @@ -84,7 +84,7 @@ static public function update() { "; CRM_Core_DAO::executeQuery($sql); - $values = array(); + $values = []; foreach (array_keys($tree) as $id) { $parents = implode(',', $tree[$id]['parents']); $children = implode(',', $tree[$id]['children']); @@ -129,7 +129,7 @@ public static function checkCyclicGraph(&$tree) { * @return bool */ public static function isCyclic(&$tree, $id) { - $parents = $children = array(); + $parents = $children = []; self::getAll($parent, $tree, $id, 'parents'); self::getAll($child, $tree, $id, 'children'); @@ -232,7 +232,7 @@ public static function json() { foreach ($groups as $id => $name) { $string = "id:'$id', name:'$name'"; if (isset($tree[$id])) { - $children = array(); + $children = []; if (!empty($tree[$id]['children'])) { foreach ($tree[$id]['children'] as $child) { $children[] = "{_reference:'$child'}"; diff --git a/CRM/Contact/BAO/Household.php b/CRM/Contact/BAO/Household.php index 9b383d6b4c5a..523849e72327 100644 --- a/CRM/Contact/BAO/Household.php +++ b/CRM/Contact/BAO/Household.php @@ -54,17 +54,17 @@ public static function updatePrimaryContact($primaryContactId, $contactId) { $queryString = "UPDATE civicrm_contact SET primary_contact_id = "; - $params = array(); + $params = []; if ($primaryContactId) { $queryString .= '%1'; - $params[1] = array($primaryContactId, 'Integer'); + $params[1] = [$primaryContactId, 'Integer']; } else { $queryString .= "null"; } $queryString .= " WHERE id = %2"; - $params[2] = array($contactId, 'Integer'); + $params[2] = [$contactId, 'Integer']; return CRM_Core_DAO::executeQuery($queryString, $params); } diff --git a/CRM/Contact/BAO/Individual.php b/CRM/Contact/BAO/Individual.php index 28cfcbb221c2..e0ada62e16da 100644 --- a/CRM/Contact/BAO/Individual.php +++ b/CRM/Contact/BAO/Individual.php @@ -59,7 +59,7 @@ public static function format(&$params, &$contact) { // "null" value for example is passed by dedupe merge in order to empty. // Display name computation shouldn't consider such values. - foreach (array('first_name', 'middle_name', 'last_name', 'nick_name', 'formal_title', 'birth_date', 'deceased_date') as $displayField) { + foreach (['first_name', 'middle_name', 'last_name', 'nick_name', 'formal_title', 'birth_date', 'deceased_date'] as $displayField) { if (CRM_Utils_Array::value($displayField, $params) == "null") { $params[$displayField] = ''; } @@ -93,9 +93,9 @@ public static function format(&$params, &$contact) { //lets allow to update single name field though preserveDBName //but if db having null value and params contain value, CRM-4330. - $useDBNames = array(); + $useDBNames = []; - foreach (array('last', 'middle', 'first', 'nick') as $name) { + foreach (['last', 'middle', 'first', 'nick'] as $name) { $dbName = "{$name}_name"; $value = $individual->$dbName; @@ -105,7 +105,7 @@ public static function format(&$params, &$contact) { } } - foreach (array('prefix', 'suffix') as $name) { + foreach (['prefix', 'suffix'] as $name) { $dbName = "{$name}_id"; $value = $individual->$dbName; if ($value && !empty($params['preserveDBName'])) { @@ -122,7 +122,7 @@ public static function format(&$params, &$contact) { //2. lets get value from param if exists. //3. if not in params, lets get from db. - foreach (array('last', 'middle', 'first', 'nick') as $name) { + foreach (['last', 'middle', 'first', 'nick'] as $name) { $phpName = "{$name}Name"; $dbName = "{$name}_name"; $value = $individual->$dbName; @@ -139,7 +139,7 @@ public static function format(&$params, &$contact) { } } - foreach (array('prefix', 'suffix') as $name) { + foreach (['prefix', 'suffix'] as $name) { $dbName = "{$name}_id"; $value = $individual->$dbName; @@ -179,14 +179,14 @@ public static function format(&$params, &$contact) { } //first trim before further processing. - foreach (array('lastName', 'firstName', 'middleName') as $fld) { + foreach (['lastName', 'firstName', 'middleName'] as $fld) { $$fld = trim($$fld); } if ($lastName || $firstName || $middleName) { // make sure we have values for all the name fields. $formatted = $params; - $nameParams = array( + $nameParams = [ 'first_name' => $firstName, 'middle_name' => $middleName, 'last_name' => $lastName, @@ -196,7 +196,7 @@ public static function format(&$params, &$contact) { 'prefix_id' => $prefix_id, 'suffix_id' => $suffix_id, 'formal_title' => $formalTitle, - ); + ]; // make sure we have all the name fields. foreach ($nameParams as $name => $value) { if (empty($formatted[$name]) && $value) { @@ -204,9 +204,9 @@ public static function format(&$params, &$contact) { } } - $tokens = array(); + $tokens = []; CRM_Utils_Hook::tokens($tokens); - $tokenFields = array(); + $tokenFields = []; foreach ($tokens as $catTokens) { foreach ($catTokens as $token => $label) { $tokenFields[] = $token; @@ -248,7 +248,7 @@ public static function format(&$params, &$contact) { } //now set the names. - $names = array('displayName' => 'display_name', 'sortName' => 'sort_name'); + $names = ['displayName' => 'display_name', 'sortName' => 'sort_name']; foreach ($names as $value => $name) { if (empty($$value)) { if ($email) { @@ -273,29 +273,29 @@ public static function format(&$params, &$contact) { $format = CRM_Utils_Date::getDateFormat('birth'); if ($date = CRM_Utils_Array::value('birth_date', $params)) { - if (in_array($format, array( + if (in_array($format, [ 'dd-mm', 'mm/dd', - ))) { + ])) { $separator = '/'; if ($format == 'dd-mm') { $separator = '-'; } $date = $date . $separator . '1902'; } - elseif (in_array($format, array( + elseif (in_array($format, [ 'yy-mm', - ))) { + ])) { $date = $date . '-01'; } - elseif (in_array($format, array( + elseif (in_array($format, [ 'M yy', - ))) { + ])) { $date = $date . '-01'; } - elseif (in_array($format, array( + elseif (in_array($format, [ 'yy', - ))) { + ])) { $date = $date . '-01-01'; } $contact->birth_date = CRM_Utils_Date::processDate($date); @@ -305,29 +305,29 @@ public static function format(&$params, &$contact) { } if ($date = CRM_Utils_Array::value('deceased_date', $params)) { - if (in_array($format, array( + if (in_array($format, [ 'dd-mm', 'mm/dd', - ))) { + ])) { $separator = '/'; if ($format == 'dd-mm') { $separator = '-'; } $date = $date . $separator . '1902'; } - elseif (in_array($format, array( + elseif (in_array($format, [ 'yy-mm', - ))) { + ])) { $date = $date . '-01'; } - elseif (in_array($format, array( + elseif (in_array($format, [ 'M yy', - ))) { + ])) { $date = $date . '-01'; } - elseif (in_array($format, array( + elseif (in_array($format, [ 'yy', - ))) { + ])) { $date = $date . '-01-01'; } diff --git a/CRM/Contact/BAO/ProximityQuery.php b/CRM/Contact/BAO/ProximityQuery.php index 7ee0be7ad988..2815979a17ab 100644 --- a/CRM/Contact/BAO/ProximityQuery.php +++ b/CRM/Contact/BAO/ProximityQuery.php @@ -114,7 +114,7 @@ public static function earthXYZ($longitude, $latitude, $height = 0) { $y = ($radius + $height) * $cosLat * $sinLong; $z = ($radius * (1 - self::$_earthEccentricitySQ) + $height) * $sinLat; - return array($x, $y, $z); + return [$x, $y, $z]; } /** @@ -154,10 +154,10 @@ public static function earthLongitudeRange($longitude, $latitude, $distance) { $maxLong = $maxLong - pi() * 2; } - return array( + return [ rad2deg($minLong), rad2deg($maxLong), - ); + ]; } /** @@ -198,10 +198,10 @@ public static function earthLatitudeRange($longitude, $latitude, $distance) { $maxLat = $rightangle; } - return array( + return [ rad2deg($minLat), rad2deg($maxLat), - ); + ]; } /** @@ -215,15 +215,15 @@ public static function earthLatitudeRange($longitude, $latitude, $distance) { public static function where($latitude, $longitude, $distance, $tablePrefix = 'civicrm_address') { self::initialize(); - $params = array(); - $clause = array(); + $params = []; + $clause = []; list($minLongitude, $maxLongitude) = self::earthLongitudeRange($longitude, $latitude, $distance); list($minLatitude, $maxLatitude) = self::earthLatitudeRange($longitude, $latitude, $distance); // DONT consider NAN values (which is returned by rad2deg php function) // for checking BETWEEN geo_code's criteria as it throws obvious 'NAN' field not found DB: Error - $geoCodeWhere = array(); + $geoCodeWhere = []; if (!is_nan($minLatitude)) { $geoCodeWhere[] = "{$tablePrefix}.geo_code_1 >= $minLatitude "; } @@ -264,7 +264,7 @@ public static function process(&$query, &$values) { list($name, $op, $distance, $grouping, $wildcard) = $values; // also get values array for all address related info - $proximityVars = array( + $proximityVars = [ 'street_address' => 1, 'city' => 1, 'postal_code' => 1, @@ -275,10 +275,10 @@ public static function process(&$query, &$values) { 'distance_unit' => 0, 'geo_code_1' => 0, 'geo_code_2' => 0, - ); + ]; - $proximityAddress = array(); - $qill = array(); + $proximityAddress = []; + $qill = []; foreach ($proximityVars as $var => $recordQill) { $proximityValues = $query->getWhereValues("prox_{$var}", $grouping); if (!empty($proximityValues) && @@ -329,10 +329,10 @@ public static function process(&$query, &$values) { } $qill = ts('Proximity search to a distance of %1 from %2', - array( + [ 1 => $qillUnits, 2 => implode(', ', $qill), - ) + ] ); $query->_tables['civicrm_address'] = $query->_whereTables['civicrm_address'] = 1; @@ -374,7 +374,7 @@ public static function fixInputParams(&$input) { foreach ($input as $param) { if (CRM_Utils_Array::value('0', $param) == 'prox_distance') { // add prox_ prefix to these - $param_alter = array('street_address', 'city', 'postal_code', 'state_province', 'country'); + $param_alter = ['street_address', 'city', 'postal_code', 'state_province', 'country']; foreach ($input as $key => $_param) { if (in_array($_param[0], $param_alter)) { diff --git a/CRM/Contact/BAO/Query.php b/CRM/Contact/BAO/Query.php index 0e66244547c9..bc0450975b85 100644 --- a/CRM/Contact/BAO/Query.php +++ b/CRM/Contact/BAO/Query.php @@ -346,31 +346,31 @@ class CRM_Contact_BAO_Query { * * @var array */ - public static $_openedPanes = array(); + public static $_openedPanes = []; /** * For search builder - which custom fields are location-dependent * @var array */ - public $_locationSpecificCustomFields = array(); + public $_locationSpecificCustomFields = []; /** * The tables which have a dependency on location and/or address * * @var array */ - static $_dependencies = array( + static $_dependencies = [ 'civicrm_state_province' => 1, 'civicrm_country' => 1, 'civicrm_county' => 1, 'civicrm_address' => 1, 'civicrm_location_type' => 1, - ); + ]; /** * List of location specific fields. */ - static $_locationSpecificFields = array( + static $_locationSpecificFields = [ 'street_address', 'street_number', 'street_name', @@ -391,13 +391,13 @@ class CRM_Contact_BAO_Query { 'im', 'address_name', 'master_id', - ); + ]; /** * Remember if we handle either end of a number or date range * so we can skip the other */ - protected $_rangeCache = array(); + protected $_rangeCache = []; /** * Set to true when $this->relationship is run to avoid adding twice * @var Boolean @@ -410,7 +410,7 @@ class CRM_Contact_BAO_Query { */ static $_relationshipTempTable = NULL; - public $_pseudoConstantsSelect = array(); + public $_pseudoConstantsSelect = []; public $_groupUniqueKey = NULL; public $_groupKeys = []; @@ -448,11 +448,11 @@ public function __construct( $this->_primaryLocation = $primaryLocationOnly; $this->_params = &$params; if ($this->_params == NULL) { - $this->_params = array(); + $this->_params = []; } if ($returnProperties === self::NO_RETURN_PROPERTIES) { - $this->_returnProperties = array(); + $this->_returnProperties = []; } elseif (empty($returnProperties)) { $this->_returnProperties = self::defaultReturnProperties($mode); @@ -502,16 +502,16 @@ public function __construct( * This sort-of duplicates $mode in a confusing way. Probably not by design. */ public function initialize($apiEntity = NULL) { - $this->_select = array(); - $this->_element = array(); - $this->_tables = array(); - $this->_whereTables = array(); - $this->_where = array(); - $this->_qill = array(); - $this->_options = array(); - $this->_cfIDs = array(); - $this->_paramLookup = array(); - $this->_having = array(); + $this->_select = []; + $this->_element = []; + $this->_tables = []; + $this->_whereTables = []; + $this->_where = []; + $this->_qill = []; + $this->_options = []; + $this->_cfIDs = []; + $this->_paramLookup = []; + $this->_having = []; $this->_customQuery = NULL; @@ -568,7 +568,7 @@ public function initialize($apiEntity = NULL) { */ public function buildParamsLookup() { $trashParamExists = FALSE; - $paramByGroup = array(); + $paramByGroup = []; foreach ($this->_params as $k => $param) { if (!empty($param[0]) && $param[0] == 'contact_is_deleted') { $trashParamExists = TRUE; @@ -584,16 +584,16 @@ public function buildParamsLookup() { //cycle through group sets and explicitly add trash param if not set foreach ($paramByGroup as $setID => $set) { if ( - !in_array(array('contact_is_deleted', '=', '1', $setID, '0'), $this->_params) && - !in_array(array('contact_is_deleted', '=', '0', $setID, '0'), $this->_params) + !in_array(['contact_is_deleted', '=', '1', $setID, '0'], $this->_params) && + !in_array(['contact_is_deleted', '=', '0', $setID, '0'], $this->_params) ) { - $this->_params[] = array( + $this->_params[] = [ 'contact_is_deleted', '=', '0', $setID, '0', - ); + ]; } } } @@ -605,7 +605,7 @@ public function buildParamsLookup() { $cfID = CRM_Core_BAO_CustomField::getKeyID($value[0]); if ($cfID) { if (!array_key_exists($cfID, $this->_cfIDs)) { - $this->_cfIDs[$cfID] = array(); + $this->_cfIDs[$cfID] = []; } // Set wildcard value based on "and/or" selection foreach ($this->_params as $key => $param) { @@ -618,7 +618,7 @@ public function buildParamsLookup() { } if (!array_key_exists($value[0], $this->_paramLookup)) { - $this->_paramLookup[$value[0]] = array(); + $this->_paramLookup[$value[0]] = []; } if ($value[0] !== 'group') { // Just trying to unravel how group interacts here! This whole function is weird. @@ -635,7 +635,7 @@ public function buildParamsLookup() { * This sort-of duplicates $mode in a confusing way. Probably not by design. */ public function addSpecialFields($apiEntity) { - static $special = array('contact_type', 'contact_sub_type', 'sort_name', 'display_name'); + static $special = ['contact_type', 'contact_sub_type', 'sort_name', 'display_name']; // if get called via Contact.get API having address_id as return parameter if ($apiEntity == 'Contact') { $special[] = 'address_id'; @@ -705,7 +705,7 @@ public function selectClause($apiEntity = NULL) { $makeException = FALSE; //special handling for groups/tags - if (in_array($name, array('groups', 'tags', 'notes')) + if (in_array($name, ['groups', 'tags', 'notes']) && isset($this->_returnProperties[substr($name, 0, -1)]) ) { // @todo instead of setting make exception to get us into @@ -717,7 +717,7 @@ public function selectClause($apiEntity = NULL) { // since note has 3 different options we need special handling // note / note_subject / note_body if ($name == 'notes') { - foreach (array('note', 'note_subject', 'note_body') as $noteField) { + foreach (['note', 'note_subject', 'note_body'] as $noteField) { if (isset($this->_returnProperties[$noteField])) { $makeException = TRUE; break; @@ -735,7 +735,7 @@ public function selectClause($apiEntity = NULL) { if ($cfID) { // add to cfIDs array if not present if (!array_key_exists($cfID, $this->_cfIDs)) { - $this->_cfIDs[$cfID] = array(); + $this->_cfIDs[$cfID] = []; } } elseif (isset($field['where'])) { @@ -755,10 +755,10 @@ public function selectClause($apiEntity = NULL) { } if (in_array($tableName, - array('email_greeting', 'postal_greeting', 'addressee'))) { + ['email_greeting', 'postal_greeting', 'addressee'])) { $this->_element["{$name}_id"] = 1; $this->_select["{$name}_id"] = "contact_a.{$name}_id as {$name}_id"; - $this->_pseudoConstantsSelect[$name] = array('pseudoField' => $tableName, 'idCol' => "{$name}_id"); + $this->_pseudoConstantsSelect[$name] = ['pseudoField' => $tableName, 'idCol' => "{$name}_id"]; $this->_pseudoConstantsSelect[$name]['select'] = "{$name}.{$fieldName} as $name"; $this->_pseudoConstantsSelect[$name]['element'] = $name; @@ -796,37 +796,37 @@ public function selectClause($apiEntity = NULL) { } } else { - if (!in_array($tableName, array('civicrm_state_province', 'civicrm_country', 'civicrm_county'))) { + if (!in_array($tableName, ['civicrm_state_province', 'civicrm_country', 'civicrm_county'])) { $this->_tables[$tableName] = 1; } // also get the id of the tableName $tName = substr($tableName, 8); - if (in_array($tName, array('country', 'state_province', 'county'))) { + if (in_array($tName, ['country', 'state_province', 'county'])) { if ($tName == 'state_province') { - $this->_pseudoConstantsSelect['state_province_name'] = array( + $this->_pseudoConstantsSelect['state_province_name'] = [ 'pseudoField' => "{$tName}", 'idCol' => "{$tName}_id", 'bao' => 'CRM_Core_BAO_Address', 'table' => "civicrm_{$tName}", 'join' => " LEFT JOIN civicrm_{$tName} ON civicrm_address.{$tName}_id = civicrm_{$tName}.id ", - ); + ]; - $this->_pseudoConstantsSelect[$tName] = array( + $this->_pseudoConstantsSelect[$tName] = [ 'pseudoField' => 'state_province_abbreviation', 'idCol' => "{$tName}_id", 'table' => "civicrm_{$tName}", 'join' => " LEFT JOIN civicrm_{$tName} ON civicrm_address.{$tName}_id = civicrm_{$tName}.id ", - ); + ]; } else { - $this->_pseudoConstantsSelect[$name] = array( + $this->_pseudoConstantsSelect[$name] = [ 'pseudoField' => "{$tName}_id", 'idCol' => "{$tName}_id", 'bao' => 'CRM_Core_BAO_Address', 'table' => "civicrm_{$tName}", 'join' => " LEFT JOIN civicrm_{$tName} ON civicrm_address.{$tName}_id = civicrm_{$tName}.id ", - ); + ]; } $this->_select["{$tName}_id"] = "civicrm_address.{$tName}_id as {$tName}_id"; @@ -857,7 +857,7 @@ public function selectClause($apiEntity = NULL) { elseif ($tName == 'contact' && $fieldName === 'id') { // Handled elsewhere, explicitly ignore. Possibly for all tables... } - elseif (in_array($tName, array('country', 'county'))) { + elseif (in_array($tName, ['country', 'county'])) { $this->_pseudoConstantsSelect[$name]['select'] = "{$field['where']} as `$name`"; $this->_pseudoConstantsSelect[$name]['element'] = $name; } @@ -876,7 +876,7 @@ public function selectClause($apiEntity = NULL) { else { $this->_select[$name] = str_replace('civicrm_contact.', 'contact_a.', "{$field['where']} as `$name`"); } - if (!in_array($tName, array('state_province', 'country', 'county'))) { + if (!in_array($tName, ['state_province', 'country', 'county'])) { $this->_element[$name] = 1; } } @@ -903,10 +903,10 @@ public function selectClause($apiEntity = NULL) { $this->_element[$name] = 1; $this->_tables['civicrm_group_contact'] = 1; $this->_tables['civicrm_group_contact_cache'] = 1; - $this->_pseudoConstantsSelect["{$name}"] = array( + $this->_pseudoConstantsSelect["{$name}"] = [ 'pseudoField' => "groups", 'idCol' => "groups", - ); + ]; } elseif ($name === 'notes') { //@todo move this handling outside the big IF & ditch $makeException @@ -931,7 +931,7 @@ public function selectClause($apiEntity = NULL) { // this is a custom field with range search enabled, so we better check for two/from values if (!empty($this->_paramLookup[$name . '_from'])) { if (!array_key_exists($cfID, $this->_cfIDs)) { - $this->_cfIDs[$cfID] = array(); + $this->_cfIDs[$cfID] = []; } foreach ($this->_paramLookup[$name . '_from'] as $pID => $p) { // search in the cdID array for the same grouping @@ -943,14 +943,14 @@ public function selectClause($apiEntity = NULL) { } } if (!$fnd) { - $p[2] = array('from' => $p[2]); + $p[2] = ['from' => $p[2]]; $this->_cfIDs[$cfID][] = $p; } } } if (!empty($this->_paramLookup[$name . '_to'])) { if (!array_key_exists($cfID, $this->_cfIDs)) { - $this->_cfIDs[$cfID] = array(); + $this->_cfIDs[$cfID] = []; } foreach ($this->_paramLookup[$name . '_to'] as $pID => $p) { // search in the cdID array for the same grouping @@ -962,7 +962,7 @@ public function selectClause($apiEntity = NULL) { } } if (!$fnd) { - $p[2] = array('to' => $p[2]); + $p[2] = ['to' => $p[2]]; $this->_cfIDs[$cfID][] = $p; } } @@ -1006,11 +1006,11 @@ public function addHierarchicalElements() { } $locationTypes = CRM_Core_DAO_Address::buildOptions('location_type_id', 'validate'); - $processed = array(); + $processed = []; $index = 0; $addressCustomFields = CRM_Core_BAO_CustomField::getFieldsForImport('Address'); - $addressCustomFieldIds = array(); + $addressCustomFieldIds = []; foreach ($this->_returnProperties['location'] as $name => $elements) { $lCond = self::getPrimaryCondition($name); @@ -1036,7 +1036,7 @@ public function addHierarchicalElements() { $this->_element["{$tName}"] = 1; $locationTypeName = $tName; - $locationTypeJoin = array(); + $locationTypeJoin = []; $addWhereCount = 0; foreach ($elements as $elementFullName => $dontCare) { @@ -1055,7 +1055,7 @@ public function addHierarchicalElements() { // add address table - doesn't matter if we do it mutliple times - it's the same data // @todo ditch the double processing of addressJoin if ((in_array($elementCmpName, self::$_locationSpecificFields) || !empty($addressCustomFieldIds)) - && !in_array($elementCmpName, array('email', 'phone', 'im', 'openid')) + && !in_array($elementCmpName, ['email', 'phone', 'im', 'openid']) ) { list($aName, $addressJoin) = $this->addAddressTable($name, $lCond); $locationTypeJoin[$tName] = " ( $aName.location_type_id = $ltName.id ) "; @@ -1100,7 +1100,7 @@ public function addHierarchicalElements() { } elseif (is_numeric($name)) { //this for phone type to work - if (in_array($elementName, array('phone', 'phone_ext'))) { + if (in_array($elementName, ['phone', 'phone_ext'])) { $field = CRM_Utils_Array::value($elementName . "-Primary" . $elementType, $this->_fields); } else { @@ -1109,7 +1109,7 @@ public function addHierarchicalElements() { } else { //this is for phone type to work for profile edit - if (in_array($elementName, array('phone', 'phone_ext'))) { + if (in_array($elementName, ['phone', 'phone_ext'])) { $field = CRM_Utils_Array::value($elementName . "-$locationTypeId$elementType", $this->_fields); } else { @@ -1131,7 +1131,7 @@ public function addHierarchicalElements() { foreach ($this->_params as $id => $values) { if ((is_array($values) && $values[0] == $nm) || - (in_array($elementName, array('phone', 'im')) + (in_array($elementName, ['phone', 'im']) && (strpos($values[0], $nm) !== FALSE) ) ) { @@ -1160,18 +1160,18 @@ public function addHierarchicalElements() { $a = Civi::settings()->get('address_format'); if (substr_count($a, 'state_province_name') > 0) { - $this->_pseudoConstantsSelect["{$name}-{$elementFullName}"] = array( + $this->_pseudoConstantsSelect["{$name}-{$elementFullName}"] = [ 'pseudoField' => "{$pf}_id", 'idCol' => "{$tName}_id", 'bao' => 'CRM_Core_BAO_Address', - ); + ]; $this->_pseudoConstantsSelect["{$name}-{$elementFullName}"]['select'] = "`$tName`.name as `{$name}-{$elementFullName}`"; } else { - $this->_pseudoConstantsSelect["{$name}-{$elementFullName}"] = array( + $this->_pseudoConstantsSelect["{$name}-{$elementFullName}"] = [ 'pseudoField' => 'state_province_abbreviation', 'idCol' => "{$tName}_id", - ); + ]; $this->_pseudoConstantsSelect["{$name}-{$elementFullName}"]['select'] = "`$tName`.abbreviation as `{$name}-{$elementFullName}`"; } } @@ -1182,11 +1182,11 @@ public function addHierarchicalElements() { $this->_element[$provider] = 1; } if ($pf == 'country' || $pf == 'county') { - $this->_pseudoConstantsSelect["{$name}-{$elementFullName}"] = array( + $this->_pseudoConstantsSelect["{$name}-{$elementFullName}"] = [ 'pseudoField' => "{$pf}_id", 'idCol' => "{$tName}_id", 'bao' => 'CRM_Core_BAO_Address', - ); + ]; $this->_pseudoConstantsSelect["{$name}-{$elementFullName}"]['select'] = "`$tName`.$fieldName as `{$name}-{$elementFullName}`"; } else { @@ -1194,7 +1194,7 @@ public function addHierarchicalElements() { } } - if (in_array($pf, array('state_province', 'country', 'county'))) { + if (in_array($pf, ['state_province', 'country', 'county'])) { $this->_pseudoConstantsSelect["{$name}-{$elementFullName}"]['element'] = "{$name}-{$elementFullName}"; } else { @@ -1284,7 +1284,7 @@ public function addHierarchicalElements() { // table should be present in $this->_whereTables, // to add its condition in location type join, CRM-3939. if ($addWhereCount) { - $locClause = array(); + $locClause = []; foreach ($this->_whereTables as $tableName => $clause) { if (!empty($locationTypeJoin[$tableName])) { $locClause[] = $locationTypeJoin[$tableName]; @@ -1301,7 +1301,7 @@ public function addHierarchicalElements() { $customQuery = new CRM_Core_BAO_CustomQuery($addressCustomFieldIds); foreach ($addressCustomFieldIds as $cfID => $locTypeName) { foreach ($locTypeName as $name => $dnc) { - $this->_locationSpecificCustomFields[$cfID] = array($name, array_search($name, $locationTypes)); + $this->_locationSpecificCustomFields[$cfID] = [$name, array_search($name, $locationTypes)]; $fieldName = "$name-custom_{$cfID}"; $tName = "$name-address-custom-{$cfID}"; $aName = "`$name-address-custom-{$cfID}`"; @@ -1419,7 +1419,7 @@ public function query($count = FALSE, $sortByChar = FALSE, $groupContacts = FALS // ideally this code would be removed as it appears to be to support CRM-1203 // and passing in the required returnProperties from the url would // make more sense that globally applying the requirements of one form. - if (($this->_returnProperties != array('contact_id'))) { + if (($this->_returnProperties != ['contact_id'])) { $this->_select['group_contact_id'] = "$tbName.id as group_contact_id"; $this->_element['group_contact_id'] = 1; $this->_select['status'] = "$tbName.status as status"; @@ -1472,7 +1472,7 @@ public function query($count = FALSE, $sortByChar = FALSE, $groupContacts = FALS $this->filterRelatedContacts($from, $where, $having); } - return array($select, $from, $where, $having); + return [$select, $from, $where, $having]; } /** @@ -1541,8 +1541,8 @@ public static function fixDateValues($relative, &$from, &$to) { * @return array */ public static function convertFormValues(&$formValues, $wildcard = 0, $useEquals = FALSE, $apiEntity = NULL, - $entityReferenceFields = array()) { - $params = array(); + $entityReferenceFields = []) { + $params = []; if (empty($formValues)) { return $params; } @@ -1595,8 +1595,8 @@ public static function convertFormValues(&$formValues, $wildcard = 0, $useEquals // The form uses 1 field to represent two db fields if ($id == 'contact_type' && $values && (!is_array($values) || !array_intersect(array_keys($values), CRM_Core_DAO::acceptedSQLOperators()))) { - $contactType = array(); - $subType = array(); + $contactType = []; + $subType = []; foreach ((array) $values as $key => $type) { $types = explode('__', is_numeric($type) ? $key : $type, 2); $contactType[$types[0]] = $types[0]; @@ -1605,9 +1605,9 @@ public static function convertFormValues(&$formValues, $wildcard = 0, $useEquals $subType[$types[1]] = $types[1]; } } - $params[] = array('contact_type', 'IN', $contactType, 0, 0); + $params[] = ['contact_type', 'IN', $contactType, 0, 0]; if ($subType) { - $params[] = array('contact_sub_type', 'IN', $subType, 0, 0); + $params[] = ['contact_sub_type', 'IN', $subType, 0, 0]; } } elseif ($id == 'privacy') { @@ -1615,7 +1615,7 @@ public static function convertFormValues(&$formValues, $wildcard = 0, $useEquals $op = !empty($formValues['privacy']['do_not_toggle']) ? '=' : '!='; foreach ($formValues['privacy'] as $key => $value) { if ($value) { - $params[] = array($key, $op, $value, 0, 0); + $params[] = [$key, $op, $value, 0, 0]; } } } @@ -1653,7 +1653,7 @@ public static function convertFormValues(&$formValues, $wildcard = 0, $useEquals } elseif (in_array($id, $entityReferenceFields) && !empty($values) && is_string($values) && (strpos($values, ',') != FALSE)) { - $params[] = array($id, 'IN', explode(',', $values), 0, 0); + $params[] = [$id, 'IN', explode(',', $values), 0, 0]; } else { $values = CRM_Contact_BAO_Query::fixWhereValues($id, $values, $wildcard, $useEquals, $apiEntity); @@ -1675,14 +1675,14 @@ public static function convertFormValues(&$formValues, $wildcard = 0, $useEquals * */ public static function legacyConvertFormValues($id, &$values) { - $legacyElements = array( + $legacyElements = [ 'group', 'tag', 'contact_tags', 'contact_type', 'membership_type_id', 'membership_status_id', - ); + ]; if (in_array($id, $legacyElements) && is_array($values)) { // prior to 4.7, formValues for some attributes (e.g. group, tag) are stored in array(id1 => 1, id2 => 1), // as per the recent Search fixes $values need to be in standard array(id1, id2) format @@ -1717,7 +1717,7 @@ public static function fixWhereValues($id, &$values, $wildcard = 0, $useEquals = } if (!$skipWhere) { - $skipWhere = array( + $skipWhere = [ 'task', 'radio_ts', 'uf_group_id', @@ -1725,7 +1725,7 @@ public static function fixWhereValues($id, &$values, $wildcard = 0, $useEquals = 'qfKey', 'operator', 'display_relationship_type', - ); + ]; } if (in_array($id, $skipWhere) || @@ -1744,7 +1744,7 @@ public static function fixWhereValues($id, &$values, $wildcard = 0, $useEquals = } if (!$likeNames) { - $likeNames = array('sort_name', 'email', 'note', 'display_name'); + $likeNames = ['sort_name', 'email', 'note', 'display_name']; } // email comes in via advanced search @@ -1754,18 +1754,18 @@ public static function fixWhereValues($id, &$values, $wildcard = 0, $useEquals = } if (!$useEquals && in_array($id, $likeNames)) { - $result = array($id, 'LIKE', $values, 0, 1); + $result = [$id, 'LIKE', $values, 0, 1]; } elseif (is_string($values) && strpos($values, '%') !== FALSE) { - $result = array($id, 'LIKE', $values, 0, 0); + $result = [$id, 'LIKE', $values, 0, 0]; } elseif ($id == 'contact_type' || (!empty($values) && is_array($values) && !in_array(key($values), CRM_Core_DAO::acceptedSQLOperators(), TRUE)) ) { - $result = array($id, 'IN', $values, 0, $wildcard); + $result = [$id, 'IN', $values, 0, $wildcard]; } else { - $result = array($id, '=', $values, 0, $wildcard); + $result = [$id, '=', $values, 0, $wildcard]; } return $result; @@ -2027,8 +2027,8 @@ public function whereClauseSingle(&$values, $apiEntity = NULL) { * @return string */ public function whereClause($apiEntity = NULL) { - $this->_where[0] = array(); - $this->_qill[0] = array(); + $this->_where[0] = []; + $this->_qill[0] = []; $this->includeContactIds(); if (!empty($this->_params)) { @@ -2072,8 +2072,8 @@ public function whereClause($apiEntity = NULL) { $this->_qill = CRM_Utils_Array::crmArrayMerge($this->_qill, $this->_customQuery->_qill); } - $clauses = array(); - $andClauses = array(); + $clauses = []; + $andClauses = []; $validClauses = 0; if (!empty($this->_where)) { @@ -2114,10 +2114,10 @@ public function restWhere(&$values) { $wildcard = CRM_Utils_Array::value(4, $values); if (isset($grouping) && empty($this->_where[$grouping])) { - $this->_where[$grouping] = array(); + $this->_where[$grouping] = []; } - $multipleFields = array('url'); + $multipleFields = ['url']; //check if the location type exists for fields $lType = ''; @@ -2163,7 +2163,7 @@ public function restWhere(&$values) { $this->_where[$grouping][] = self::buildClause($where, $op, $value); $this->_tables[$aName] = $this->_whereTables[$aName] = 1; list($qillop, $qillVal) = self::buildQillForFieldValue('CRM_Core_DAO_Address', "state_province_id", $value, $op); - $this->_qill[$grouping][] = ts("%1 %2 %3", array(1 => $field['title'], 2 => $qillop, 3 => $qillVal)); + $this->_qill[$grouping][] = ts("%1 %2 %3", [1 => $field['title'], 2 => $qillop, 3 => $qillVal]); } elseif (!empty($field['pseudoconstant'])) { $this->optionValueQuery( @@ -2193,7 +2193,7 @@ public function restWhere(&$values) { $this->_tables[$aName] = $this->_whereTables[$aName] = 1; list($qillop, $qillVal) = CRM_Contact_BAO_Query::buildQillForFieldValue(NULL, $name, $value, $op); - $this->_qill[$grouping][] = ts("%1 %2 %3", array(1 => $field['title'], 2 => $qillop, 3 => $qillVal)); + $this->_qill[$grouping][] = ts("%1 %2 %3", [1 => $field['title'], 2 => $qillop, 3 => $qillVal]); } elseif ($name === 'world_region') { $this->optionValueQuery( @@ -2249,7 +2249,7 @@ public function restWhere(&$values) { } elseif ($name === 'email_greeting') { CRM_Core_Error::deprecatedFunctionWarning('pass in email_greeting_id or email_greeting_display'); - $filterCondition = array('greeting_type' => 'email_greeting'); + $filterCondition = ['greeting_type' => 'email_greeting']; $this->optionValueQuery( $name, $op, $value, $grouping, CRM_Core_PseudoConstant::greeting($filterCondition), @@ -2259,7 +2259,7 @@ public function restWhere(&$values) { } elseif ($name === 'postal_greeting') { CRM_Core_Error::deprecatedFunctionWarning('pass in postal_greeting_id or postal_greeting_display'); - $filterCondition = array('greeting_type' => 'postal_greeting'); + $filterCondition = ['greeting_type' => 'postal_greeting']; $this->optionValueQuery( $name, $op, $value, $grouping, CRM_Core_PseudoConstant::greeting($filterCondition), @@ -2269,7 +2269,7 @@ public function restWhere(&$values) { } elseif ($name === 'addressee') { CRM_Core_Error::deprecatedFunctionWarning('pass in addressee_id or addressee_display'); - $filterCondition = array('greeting_type' => 'addressee'); + $filterCondition = ['greeting_type' => 'addressee']; $this->optionValueQuery( $name, $op, $value, $grouping, CRM_Core_PseudoConstant::greeting($filterCondition), @@ -2323,10 +2323,10 @@ public function restWhere(&$values) { } list($qillop, $qillVal) = self::buildQillForFieldValue(NULL, $field['title'], $value, $op); - $this->_qill[$grouping][] = ts("%1 %2 %3", array( + $this->_qill[$grouping][] = ts("%1 %2 %3", [ 1 => $field['title'], 2 => $qillop, - 3 => (strpos($op, 'NULL') !== FALSE || strpos($op, 'EMPTY') !== FALSE) ? $qillVal : "'$qillVal'")); + 3 => (strpos($op, 'NULL') !== FALSE || strpos($op, 'EMPTY') !== FALSE) ? $qillVal : "'$qillVal'"]); if (is_array($value)) { // traditionally an array being passed has been a fatal error. We can take advantage of this to add support @@ -2339,11 +2339,11 @@ public function restWhere(&$values) { //Via Contact get api value is not in array(operator => array(values)) format ONLY for IN/NOT IN operators //so this condition will satisfy the search for now if (strpos($op, 'IN') !== FALSE) { - $value = array($op => $value); + $value = [$op => $value]; } // we don't know when this might happen else { - CRM_Core_Error::fatal(ts("%1 is not a valid operator", array(1 => $operator))); + CRM_Core_Error::fatal(ts("%1 is not a valid operator", [1 => $operator])); } } } @@ -2381,7 +2381,7 @@ public static function getLocationTableName(&$where, &$locType) { //get the location name $locationType = CRM_Core_DAO_Address::buildOptions('location_type_id', 'validate'); - $specialFields = array('email', 'im', 'phone', 'openid', 'phone_ext'); + $specialFields = ['email', 'im', 'phone', 'openid', 'phone_ext']; if (in_array($locType[0], $specialFields)) { //hack to fix / special handing for phone_ext if ($locType[0] == 'phone_ext') { @@ -2395,7 +2395,7 @@ public static function getLocationTableName(&$where, &$locType) { } } elseif (in_array($locType[0], - array( + [ 'address_name', 'street_address', 'street_name', @@ -2410,18 +2410,18 @@ public static function getLocationTableName(&$where, &$locType) { 'geo_code_1', 'geo_code_2', 'master_id', - ) + ] )) { //fix for search by profile with address fields. $tName = "{$locationType[$locType[1]]}-address"; } elseif (in_array($locType[0], - array( + [ 'on_hold', 'signature_html', 'signature_text', 'is_bulkmail', - ) + ] )) { $tName = "{$locationType[$locType[1]]}-email"; } @@ -2435,7 +2435,7 @@ public static function getLocationTableName(&$where, &$locType) { $tName = "{$locationType[$locType[1]]}-{$locType[0]}"; } $tName = str_replace(' ', '_', $tName); - return array($tName, $fldName); + return [$tName, $fldName]; } CRM_Core_Error::fatal(); } @@ -2449,7 +2449,7 @@ public static function getLocationTableName(&$where, &$locType) { * values for this query */ public function store($dao) { - $value = array(); + $value = []; foreach ($this->_element as $key => $dontCare) { if (property_exists($dao, $key)) { @@ -2461,7 +2461,7 @@ public function store($dao) { $count = 1; foreach ($values as $v) { if (!array_key_exists($v, $current)) { - $current[$v] = array(); + $current[$v] = []; } //bad hack for im_provider if ($lastElement == 'provider_id') { @@ -2569,24 +2569,24 @@ public static function fromClause(&$tables, $inner = NULL, $right = NULL, $prima } if (!empty($tables['civicrm_worldregion'])) { - $tables = array_merge(array('civicrm_country' => 1), $tables); + $tables = array_merge(['civicrm_country' => 1], $tables); } if ((!empty($tables['civicrm_state_province']) || !empty($tables['civicrm_country']) || CRM_Utils_Array::value('civicrm_county', $tables) ) && empty($tables['civicrm_address']) ) { - $tables = array_merge(array('civicrm_address' => 1), + $tables = array_merge(['civicrm_address' => 1], $tables ); } // add group_contact and group table is subscription history is present if (!empty($tables['civicrm_subscription_history']) && empty($tables['civicrm_group'])) { - $tables = array_merge(array( + $tables = array_merge([ 'civicrm_group' => 1, 'civicrm_group_contact' => 1, - ), + ], $tables ); } @@ -2620,7 +2620,7 @@ public static function fromClause(&$tables, $inner = NULL, $right = NULL, $prima $tempTable[$k . ".$key"] = $key; } ksort($tempTable); - $newTables = array(); + $newTables = []; foreach ($tempTable as $key) { $newTables[$key] = $tables[$key]; } @@ -2850,8 +2850,8 @@ public function deletedContacts($values) { public function contactType(&$values) { list($name, $op, $value, $grouping, $wildcard) = $values; - $subTypes = array(); - $clause = array(); + $subTypes = []; + $clause = []; // account for search builder mapping multiple values if (!is_array($value)) { @@ -2929,7 +2929,7 @@ public function includeContactSubTypes($value, $grouping, $op = 'LIKE') { $value = $value[$op]; } - $clause = array(); + $clause = []; $alias = "contact_a.contact_sub_type"; $qillOperators = CRM_Core_SelectValues::getSearchBuilderOperators(); @@ -2952,7 +2952,7 @@ public function includeContactSubTypes($value, $grouping, $op = 'LIKE') { if (!empty($clause)) { $this->_where[$grouping][] = "( " . implode(' OR ', $clause) . " )"; } - $this->_qill[$grouping][] = ts('Contact Subtype %1 ', array(1 => $qillOperators[$op])) . implode(' ' . ts('or') . ' ', array_keys($clause)); + $this->_qill[$grouping][] = ts('Contact Subtype %1 ', [1 => $qillOperators[$op]]) . implode(' ' . ts('or') . ' ', array_keys($clause)); } /** @@ -2978,7 +2978,7 @@ public function group($values) { if (is_array($value) && count($value) > 1) { if (strpos($op, 'IN') === FALSE && strpos($op, 'NULL') === FALSE) { - CRM_Core_Error::fatal(ts("%1 is not a valid operator", array(1 => $op))); + CRM_Core_Error::fatal(ts("%1 is not a valid operator", [1 => $op])); } $this->_useDistinct = TRUE; } @@ -2991,7 +2991,7 @@ public function group($values) { $value = array_keys($this->getGroupsFromTypeCriteria($value)); } - $regularGroupIDs = $smartGroupIDs = array(); + $regularGroupIDs = $smartGroupIDs = []; foreach ((array) $value as $id) { if (CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $id, 'saved_search_id')) { $smartGroupIDs[] = $id; @@ -3003,7 +3003,7 @@ public function group($values) { $isNotOp = ($op == 'NOT IN' || $op == '!='); - $statii = array(); + $statii = []; $gcsValues = $this->getWhereValues('group_contact_status', $grouping); if ($gcsValues && is_array($gcsValues[2]) @@ -3017,7 +3017,7 @@ public function group($values) { else { $statii[] = "'Added'"; } - $groupClause = array(); + $groupClause = []; if (count($regularGroupIDs) || empty($value)) { // include child groups IDs if any $childGroupIds = (array) CRM_Contact_BAO_Group::getChildGroupIds($regularGroupIDs); @@ -3048,7 +3048,7 @@ public function group($values) { ); } $gcTable = "`civicrm_group_contact-" . uniqid() . "`"; - $joinClause = array("contact_a.id = {$gcTable}.contact_id"); + $joinClause = ["contact_a.id = {$gcTable}.contact_id"]; if (strpos($op, 'IN') !== FALSE) { $clause = "{$gcTable}.group_id $op ( $groupIds ) "; @@ -3078,7 +3078,7 @@ public function group($values) { if ($isNotOp) { $groupIds = implode(',', (array) $smartGroupIDs); $gcTable = "civicrm_group_contact_{$this->_groupUniqueKey}"; - $joinClause = array("contact_a.id = {$gcTable}.contact_id"); + $joinClause = ["contact_a.id = {$gcTable}.contact_id"]; $this->_tables[$gcTable] = $this->_whereTables[$gcTable] = " LEFT JOIN civicrm_group_contact {$gcTable} ON (" . implode(' AND ', $joinClause) . ")"; if (strpos($op, 'IN') !== FALSE) { $groupClause[] = "{$gcTable}.group_id $op ( $groupIds ) AND {$gccTableAlias}.group_id IS NULL"; @@ -3097,9 +3097,9 @@ public function group($values) { } list($qillop, $qillVal) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Contact_DAO_Group', 'id', $value, $op); - $this->_qill[$grouping][] = ts("Group(s) %1 %2", array(1 => $qillop, 2 => $qillVal)); + $this->_qill[$grouping][] = ts("Group(s) %1 %2", [1 => $qillop, 2 => $qillVal]); if (strpos($op, 'NULL') === FALSE) { - $this->_qill[$grouping][] = ts("Group Status %1", array(1 => implode(' ' . ts('or') . ' ', $statii))); + $this->_qill[$grouping][] = ts("Group Status %1", [1 => implode(' ' . ts('or') . ' ', $statii)]); } } @@ -3114,7 +3114,7 @@ public function getGroupCacheTableKeys() { * @return array */ public function getGroupsFromTypeCriteria($value) { - $groupIds = array(); + $groupIds = []; foreach ((array) $value as $groupTypeValue) { $groupList = CRM_Core_PseudoConstant::group($groupTypeValue); $groupIds = ($groupIds + $groupList); @@ -3146,10 +3146,10 @@ public function addGroupContactCache($groups, $tableAlias, $joinTable = "contact return NULL; } elseif (strpos($op, 'IN') !== FALSE) { - $groups = array($op => $groups); + $groups = [$op => $groups]; } elseif (is_array($groups) && count($groups)) { - $groups = array('IN' => $groups); + $groups = ['IN' => $groups]; } // Find all the groups that are part of a saved search. @@ -3253,7 +3253,7 @@ public function tagSearch(&$values) { LEFT JOIN civicrm_tag {$tActTable} ON ( {$etActTable}.tag_id = {$tActTable}.id )"; $this->_where[$grouping][] = "({$tTable}.name $op '" . $escapedValue . "' OR {$tCaseTable}.name $op '" . $escapedValue . "' OR {$tActTable}.name $op '" . $escapedValue . "')"; - $this->_qill[$grouping][] = ts('Tag %1 %2', array(1 => $tagTypesText[2], 2 => $op)) . ' ' . $value; + $this->_qill[$grouping][] = ts('Tag %1 %2', [1 => $tagTypesText[2], 2 => $op]) . ' ' . $value; } else { $etTable = "`civicrm_entity_tag-" . uniqid() . "`"; @@ -3263,7 +3263,7 @@ public function tagSearch(&$values) { LEFT JOIN civicrm_tag {$tTable} ON ( {$etTable}.tag_id = {$tTable}.id ) "; $this->_where[$grouping][] = self::buildClause("{$tTable}.name", $op, $value, 'String'); - $this->_qill[$grouping][] = ts('Tagged %1', array(1 => $op)) . ' ' . $value; + $this->_qill[$grouping][] = ts('Tagged %1', [1 => $op]) . ' ' . $value; } } @@ -3275,7 +3275,7 @@ public function tagSearch(&$values) { public function tag(&$values) { list($name, $op, $value, $grouping, $wildcard) = $values; - list($qillop, $qillVal) = self::buildQillForFieldValue('CRM_Core_DAO_EntityTag', "tag_id", $value, $op, array('onlyActive' => FALSE)); + list($qillop, $qillVal) = self::buildQillForFieldValue('CRM_Core_DAO_EntityTag', "tag_id", $value, $op, ['onlyActive' => FALSE]); // API/Search Builder format array(operator => array(values)) if (is_array($value)) { if (in_array(key($value), CRM_Core_DAO::acceptedSQLOperators(), TRUE)) { @@ -3327,7 +3327,7 @@ public function tag(&$values) { LEFT JOIN civicrm_entity_tag as {$etActTable} ON ( {$etActTable}.entity_table = 'civicrm_activity' AND {$etActTable}.entity_id = civicrm_activity.id ) "; // CRM-10338 - if (in_array($op, array('IS NULL', 'IS NOT NULL', 'IS EMPTY', 'IS NOT EMPTY'))) { + if (in_array($op, ['IS NULL', 'IS NOT NULL', 'IS EMPTY', 'IS NOT EMPTY'])) { $this->_where[$grouping][] = "({$etTable}.tag_id $op OR {$etCaseTable}.tag_id $op OR {$etActTable}.tag_id $op)"; } else { @@ -3339,7 +3339,7 @@ public function tag(&$values) { = " LEFT JOIN civicrm_entity_tag {$etTable} ON ( {$etTable}.entity_id = contact_a.id AND {$etTable}.entity_table = 'civicrm_contact') "; // CRM-10338 - if (in_array($op, array('IS NULL', 'IS NOT NULL', 'IS EMPTY', 'IS NOT EMPTY'))) { + if (in_array($op, ['IS NULL', 'IS NOT NULL', 'IS EMPTY', 'IS NOT EMPTY'])) { // this converts IS (NOT)? EMPTY to IS (NOT)? NULL $op = str_replace('EMPTY', 'NULL', $op); $this->_where[$grouping][] = "{$etTable}.tag_id $op"; @@ -3353,7 +3353,7 @@ public function tag(&$values) { $this->_where[$grouping][] = "{$etTable}.tag_id $op ( $value )"; } } - $this->_qill[$grouping][] = ts('Tagged %1 %2', array(1 => $qillop, 2 => $qillVal)); + $this->_qill[$grouping][] = ts('Tagged %1 %2', [1 => $qillop, 2 => $qillVal]); } /** @@ -3386,7 +3386,7 @@ public function notes(&$values) { } $label = NULL; - $clauses = array(); + $clauses = []; if ($noteOption % 2 == 0) { $clauses[] = self::buildClause('civicrm_note.note', $op, $value, 'String'); $label = ts('Note: Body Only'); @@ -3397,7 +3397,7 @@ public function notes(&$values) { } $this->_where[$grouping][] = "( " . implode(' OR ', $clauses) . " )"; list($qillOp, $qillVal) = self::buildQillForFieldValue(NULL, $name, $n, $op); - $this->_qill[$grouping][] = ts("%1 %2 %3", array(1 => $label, 2 => $qillOp, 3 => $qillVal)); + $this->_qill[$grouping][] = ts("%1 %2 %3", [1 => $label, 2 => $qillOp, 3 => $qillVal]); } /** @@ -3451,14 +3451,14 @@ public function sortName(&$values) { $config = CRM_Core_Config::singleton(); - $sub = array(); + $sub = []; //By default, $sub elements should be joined together with OR statements (don't change this variable). $subGlue = ' OR '; $firstChar = substr($value, 0, 1); $lastChar = substr($value, -1, 1); - $quotes = array("'", '"'); + $quotes = ["'", '"']; // If string is quoted, strip quotes and otherwise don't alter it if ((strlen($value) > 2) && in_array($firstChar, $quotes) && in_array($lastChar, $quotes)) { $value = trim($value, implode('', $quotes)); @@ -3470,7 +3470,7 @@ public function sortName(&$values) { } $value = CRM_Core_DAO::escapeString(trim($value)); if (strlen($value)) { - $fieldsub = array(); + $fieldsub = []; $value = "'" . self::getWildCardedValue($wildcard, $op, $value) . "'"; if ($fieldName == 'sort_name') { $wc = "contact_a.sort_name"; @@ -3511,7 +3511,7 @@ public function greetings(&$values) { $name .= '_display'; list($qillop, $qillVal) = CRM_Contact_BAO_Query::buildQillForFieldValue(NULL, $name, $value, $op); - $this->_qill[$grouping][] = ts('Greeting %1 %2', array(1 => $qillop, 2 => $qillVal)); + $this->_qill[$grouping][] = ts('Greeting %1 %2', [1 => $qillop, 2 => $qillVal]); $this->_where[$grouping][] = self::buildClause("contact_a.{$name}", $op, $value, 'String'); } @@ -3668,7 +3668,7 @@ public function sortByCharacter(&$values) { $name = trim($value); $cond = " contact_a.sort_name LIKE '" . CRM_Core_DAO::escapeWildCardString($name) . "%'"; $this->_where[$grouping][] = $cond; - $this->_qill[$grouping][] = ts('Showing only Contacts starting with: \'%1\'', array(1 => $name)); + $this->_qill[$grouping][] = ts('Showing only Contacts starting with: \'%1\'', [1 => $name]); } /** @@ -3679,7 +3679,7 @@ public function includeContactIDs() { return; } - $contactIds = array(); + $contactIds = []; foreach ($this->_params as $id => $values) { if (substr($values[0], 0, CRM_Core_Form::CB_PREFIX_LEN) == CRM_Core_Form::CB_PREFIX) { $contactIds[] = substr($values[0], CRM_Core_Form::CB_PREFIX_LEN); @@ -3729,11 +3729,11 @@ public function postalCode(&$values) { } elseif ($name == 'postal_code_low') { $this->_where[$grouping][] = " ( $field >= '$val' ) "; - $this->_qill[$grouping][] = ts('Postal code greater than or equal to \'%1\'', array(1 => $value)); + $this->_qill[$grouping][] = ts('Postal code greater than or equal to \'%1\'', [1 => $value]); } elseif ($name == 'postal_code_high') { $this->_where[$grouping][] = " ( $field <= '$val' ) "; - $this->_qill[$grouping][] = ts('Postal code less than or equal to \'%1\'', array(1 => $value)); + $this->_qill[$grouping][] = ts('Postal code less than or equal to \'%1\'', [1 => $value]); } } @@ -3754,7 +3754,7 @@ public function locationType(&$values, $status = NULL) { $this->_whereTables['civicrm_address'] = 1; $locationType = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'); - $names = array(); + $names = []; foreach ($value as $id) { $names[] = $locationType[$id]; } @@ -3789,13 +3789,13 @@ public function country(&$values, $fromStateProvince = TRUE) { } $countryClause = $countryQill = NULL; - if (in_array($op, array('IS NULL', 'IS NOT NULL', 'IS EMPTY', 'IS NOT EMPTY')) || ($values && !empty($value))) { + if (in_array($op, ['IS NULL', 'IS NOT NULL', 'IS EMPTY', 'IS NOT EMPTY']) || ($values && !empty($value))) { $this->_tables['civicrm_address'] = 1; $this->_whereTables['civicrm_address'] = 1; $countryClause = self::buildClause('civicrm_address.country_id', $op, $value, 'Positive'); list($qillop, $qillVal) = CRM_Contact_BAO_Query::buildQillForFieldValue(NULL, 'country_id', $value, $op); - $countryQill = ts("%1 %2 %3", array(1 => 'Country', 2 => $qillop, 3 => $qillVal)); + $countryQill = ts("%1 %2 %3", [1 => 'Country', 2 => $qillop, 3 => $qillVal]); if (!$fromStateProvince) { $this->_where[$grouping][] = $countryClause; @@ -3805,13 +3805,13 @@ public function country(&$values, $fromStateProvince = TRUE) { if ($fromStateProvince) { if (!empty($countryClause)) { - return array( + return [ $countryClause, " ...AND... " . $countryQill, - ); + ]; } else { - return array(NULL, NULL); + return [NULL, NULL]; } } } @@ -3829,7 +3829,7 @@ public function county(&$values, $status = NULL) { if (!is_array($value)) { // force the county to be an array - $value = array($value); + $value = [$value]; } // check if the values are ids OR names of the counties @@ -3840,7 +3840,7 @@ public function county(&$values, $status = NULL) { break; } } - $names = array(); + $names = []; if ($op == '=') { $op = 'IN'; } @@ -3852,7 +3852,7 @@ public function county(&$values, $status = NULL) { $op = str_replace('EMPTY', 'NULL', $op); } - if (in_array($op, array('IS NULL', 'IS NOT NULL', 'IS EMPTY', 'IS NOT EMPTY'))) { + if (in_array($op, ['IS NULL', 'IS NOT NULL', 'IS EMPTY', 'IS NOT EMPTY'])) { $clause = "civicrm_address.county_id $op"; } elseif ($inputFormat == 'id') { @@ -3864,7 +3864,7 @@ public function county(&$values, $status = NULL) { } } else { - $inputClause = array(); + $inputClause = []; $county = CRM_Core_PseudoConstant::county(); foreach ($value as $name) { $name = trim($name); @@ -3912,7 +3912,7 @@ public function stateProvince(&$values, $status = NULL) { $this->_where[$grouping][] = $clause; list($qillop, $qillVal) = self::buildQillForFieldValue('CRM_Core_DAO_Address', "state_province_id", $value, $op); if (!$status) { - $this->_qill[$grouping][] = ts("State/Province %1 %2 %3", array(1 => $qillop, 2 => $qillVal, 3 => $countryQill)); + $this->_qill[$grouping][] = ts("State/Province %1 %2 %3", [1 => $qillop, 2 => $qillVal, 3 => $countryQill]); } else { return implode(' ' . ts('or') . ' ', $qillVal) . $countryQill; @@ -4052,8 +4052,8 @@ public function privacyOptions($values) { $compareOP = ''; } - $clauses = array(); - $qill = array(); + $clauses = []; + $qill = []; foreach ($value as $dontCare => $pOption) { $clauses[] = " ( contact_a.{$pOption} = 1 ) "; $field = CRM_Utils_Array::value($pOption, $this->_fields); @@ -4072,7 +4072,7 @@ public function preferredCommunication(&$values) { list($name, $op, $value, $grouping, $wildcard) = $values; if (!is_array($value)) { - $value = str_replace(array('(', ')'), '', explode(",", $value)); + $value = str_replace(['(', ')'], '', explode(",", $value)); } elseif (in_array(key($value), CRM_Core_DAO::acceptedSQLOperators(), TRUE)) { $op = key($value); @@ -4087,7 +4087,7 @@ public function preferredCommunication(&$values) { } $this->_where[$grouping][] = self::buildClause("contact_a.preferred_communication_method", $op, $value); - $this->_qill[$grouping][] = ts('Preferred Communication Method %1 %2', array(1 => $qillop, 2 => $qillVal)); + $this->_qill[$grouping][] = ts('Preferred Communication Method %1 %2', [1 => $qillop, 2 => $qillVal]); } /** @@ -4123,14 +4123,14 @@ public function relationship(&$values) { } } - $relTypes = $relTypesIds = array(); + $relTypes = $relTypesIds = []; if (!empty($relationType)) { $relationType[2] = (array) $relationType[2]; foreach ($relationType[2] as $relType) { $rel = explode('_', $relType); self::$_relType = $rel[1]; - $params = array('id' => $rel[0]); - $typeValues = array(); + $params = ['id' => $rel[0]]; + $typeValues = []; $rTypeValue = CRM_Contact_BAO_RelationshipType::retrieve($params, $typeValues); if (!empty($rTypeValue)) { if ($rTypeValue->name_a_b == $rTypeValue->name_b_a) { @@ -4146,7 +4146,7 @@ public function relationship(&$values) { // if we are creating a temp table we build our own where for the relationship table $relationshipTempTable = NULL; if (self::$_relType == 'reciprocal') { - $where = array(); + $where = []; self::$_relationshipTempTable = $relationshipTempTable = CRM_Core_DAO::createTempTableName('civicrm_rel'); if ($nameClause) { $where[$grouping][] = " sort_name $nameClause "; @@ -4198,7 +4198,7 @@ public function relationship(&$values) { //Get the names of the target groups for the qill $groupNames = CRM_Core_PseudoConstant::group(); - $qillNames = array(); + $qillNames = []; foreach ($targetGroup[2] as $groupId) { if (array_key_exists($groupId, $groupNames)) { $qillNames[] = $groupNames[$groupId]; @@ -4240,7 +4240,7 @@ public function relationship(&$values) { } $onlyDeleted = 0; - if (in_array(array('deleted_contacts', '=', '1', '0', '0'), $this->_params)) { + if (in_array(['deleted_contacts', '=', '1', '0', '0'], $this->_params)) { $onlyDeleted = 1; } $where[$grouping][] = "(contact_b.is_deleted = {$onlyDeleted})"; @@ -4296,7 +4296,7 @@ public function addRelationshipPermissionClauses($grouping, &$where) { if ($relPermission) { if (!is_array($relPermission[2])) { // this form value was scalar in previous versions of Civi - $relPermission[2] = array($relPermission[2]); + $relPermission[2] = [$relPermission[2]]; } $where[$grouping][] = "(civicrm_relationship.is_permission_a_b IN (" . implode(",", $relPermission[2]) . "))"; @@ -4315,11 +4315,11 @@ public function addRelationshipPermissionClauses($grouping, &$where) { * not the main query. */ public function addRelationshipDateClauses($grouping, &$where) { - $dateValues = array(); - $dateTypes = array( + $dateValues = []; + $dateTypes = [ 'start_date', 'end_date', - ); + ]; foreach ($dateTypes as $dateField) { $dateValueLow = $this->getWhereValues('relation_' . $dateField . '_low', $grouping); @@ -4345,7 +4345,7 @@ public function addRelationshipDateClauses($grouping, &$where) { * not the main query. */ public function addRelationshipActivePeriodClauses($grouping, &$where) { - $dateValues = array(); + $dateValues = []; $dateField = 'active_period_date'; $dateValueLow = $this->getWhereValues('relation_active_period_date_low', $grouping); @@ -4405,7 +4405,7 @@ public static function getRelationshipActivePeriodClauses($from, $to, $forceTabl */ public static function &defaultReturnProperties($mode = 1) { if (!isset(self::$_defaultReturnProperties)) { - self::$_defaultReturnProperties = array(); + self::$_defaultReturnProperties = []; } if (!isset(self::$_defaultReturnProperties[$mode])) { @@ -4418,7 +4418,7 @@ public static function &defaultReturnProperties($mode = 1) { } if (empty(self::$_defaultReturnProperties[$mode])) { - self::$_defaultReturnProperties[$mode] = array( + self::$_defaultReturnProperties[$mode] = [ 'home_URL' => 1, 'image_URL' => 1, 'legal_identifier' => 1, @@ -4472,7 +4472,7 @@ public static function &defaultReturnProperties($mode = 1) { 'contact_is_deleted' => 1, 'preferred_communication_method' => 1, 'preferred_language' => 1, - ); + ]; } } return self::$_defaultReturnProperties[$mode]; @@ -4608,11 +4608,11 @@ public static function apiQuery( // @todo derive this from the component class rather than hard-code two options. $entityIDField = ($mode == CRM_Contact_BAO_Query::MODE_CONTRIBUTE) ? 'contribution_id' : 'contact_id'; - $values = array(); + $values = []; while ($dao->fetch()) { if ($count) { $noRows = $dao->rowCount; - return array($noRows, NULL); + return [$noRows, NULL]; } $val = $query->store($dao); $convertedVals = $query->convertToPseudoNames($dao, TRUE, TRUE); @@ -4622,7 +4622,7 @@ public static function apiQuery( } $values[$dao->$entityIDField] = $val; } - return array($values, $options); + return [$values, $options]; } /** @@ -4693,22 +4693,22 @@ protected static function convertCustomRelativeFields(&$formValues, &$params, $v if ($from) { if ($to) { - $relativeFunction = array('BETWEEN' => array($from, $to)); + $relativeFunction = ['BETWEEN' => [$from, $to]]; } else { - $relativeFunction = array('>=' => $from); + $relativeFunction = ['>=' => $from]; } } else { - $relativeFunction = array('<=' => $to); + $relativeFunction = ['<=' => $to]; } - $params[] = array( + $params[] = [ $customFieldName, '=', $relativeFunction, 0, 0, - ); + ]; } /** @@ -4722,7 +4722,7 @@ public static function isCustomDateField($fieldName) { if (($customFieldID = CRM_Core_BAO_CustomField::getKeyID($fieldName)) == FALSE) { return FALSE; } - if ('Date' == civicrm_api3('CustomField', 'getvalue', array('id' => $customFieldID, 'return' => 'data_type'))) { + if ('Date' == civicrm_api3('CustomField', 'getvalue', ['id' => $customFieldID, 'return' => 'data_type'])) { return TRUE; } return FALSE; @@ -4816,7 +4816,7 @@ public static function appendAnyValueToSelect($selectClauses, $groupBy, $aggrega public static function getGroupByFromOrderBy(&$groupBy, $orderBys) { if (!CRM_Utils_SQL::disableFullGroupByMode()) { foreach ($orderBys as $orderBy) { - $orderBy = str_ireplace(array(' DESC', ' ASC', '`'), '', $orderBy); // remove sort syntax from ORDER BY clauses if present + $orderBy = str_ireplace([' DESC', ' ASC', '`'], '', $orderBy); // remove sort syntax from ORDER BY clauses if present // if ORDER BY column is not present in GROUP BY then append it to end if (preg_match('/(MAX|MIN)\(/i', trim($orderBy)) !== 1 && !strstr($groupBy, $orderBy)) { $groupBy .= ", {$orderBy}"; @@ -4931,7 +4931,7 @@ public function searchQuery( CRM_Core_DAO::reenableFullGroupByMode(); if ($groupContacts) { - $ids = array(); + $ids = []; while ($dao->fetch()) { $ids[] = $dao->id; } @@ -4969,7 +4969,7 @@ public function alphabetQuery() { public function getCachedContacts($cids, $includeContactIds) { CRM_Utils_Type::validateAll($cids, 'Positive'); $this->_includeContactIds = $includeContactIds; - $onlyDeleted = in_array(array('deleted_contacts', '=', '1', '0', '0'), $this->_params); + $onlyDeleted = in_array(['deleted_contacts', '=', '1', '0', '0'], $this->_params); list($select, $from, $where) = $this->query(FALSE, FALSE, FALSE, $onlyDeleted); $select .= sprintf(", (%s) AS _wgt", $this->createSqlCase('contact_a.id', $cids)); $where .= sprintf(' AND contact_a.id IN (%s)', implode(',', $cids)); @@ -5126,7 +5126,7 @@ public function qill() { */ public static function &defaultHierReturnProperties() { if (!isset(self::$_defaultHierReturnProperties)) { - self::$_defaultHierReturnProperties = array( + self::$_defaultHierReturnProperties = [ 'home_URL' => 1, 'image_URL' => 1, 'legal_identifier' => 1, @@ -5154,8 +5154,8 @@ public static function &defaultHierReturnProperties() { 'do_not_mail' => 1, 'do_not_sms' => 1, 'do_not_trade' => 1, - 'location' => array( - '1' => array( + 'location' => [ + '1' => [ 'location_type' => 1, 'street_address' => 1, 'city' => 1, @@ -5175,8 +5175,8 @@ public static function &defaultHierReturnProperties() { 'email-1' => 1, 'email-2' => 1, 'email-3' => 1, - ), - '2' => array( + ], + '2' => [ 'location_type' => 1, 'street_address' => 1, 'city' => 1, @@ -5195,9 +5195,9 @@ public static function &defaultHierReturnProperties() { 'email-1' => 1, 'email-2' => 1, 'email-3' => 1, - ), - ), - ); + ], + ], + ]; } return self::$_defaultHierReturnProperties; } @@ -5301,7 +5301,7 @@ public function dateQueryBuilder( $date = $format = NULL; if (strstr($op, 'IN')) { - $format = array(); + $format = []; foreach ($value as &$date) { $date = CRM_Utils_Date::processDate($date, NULL, FALSE, $dateFormat); if (!$appendTimeStamp) { @@ -5565,7 +5565,7 @@ public static function buildClause($field, $op, $value = NULL, $dataType = NULL) case 'NOT IN': // I feel like this would be escaped properly if passed through $queryString = CRM_Core_DAO::createSqlFilter. if (!empty($value) && (!is_array($value) || !array_key_exists($op, $value))) { - $value = array($op => (array) $value); + $value = [$op => (array) $value]; } default: @@ -5582,7 +5582,7 @@ public static function buildClause($field, $op, $value = NULL, $dataType = NULL) } if (!empty($value[0]) && $op === 'BETWEEN') { CRM_Core_Error::deprecatedFunctionWarning('Fix search input params'); - if (($queryString = CRM_Core_DAO::createSqlFilter($field, array($op => $value), $dataType)) != FALSE) { + if (($queryString = CRM_Core_DAO::createSqlFilter($field, [$op => $value], $dataType)) != FALSE) { return $queryString; } } @@ -5609,7 +5609,7 @@ public function openedSearchPanes($reset = FALSE) { } // pane name to table mapper - $panesMapper = array( + $panesMapper = [ ts('Contributions') => 'civicrm_contribution', ts('Memberships') => 'civicrm_membership', ts('Events') => 'civicrm_participant', @@ -5622,7 +5622,7 @@ public function openedSearchPanes($reset = FALSE) { ts('Notes') => 'civicrm_note', ts('Change Log') => 'civicrm_log', ts('Mailings') => 'civicrm_mailing', - ); + ]; CRM_Contact_BAO_Query_Hook::singleton()->getPanesMapper($panesMapper); foreach (array_keys($this->_whereTables) as $table) { @@ -5638,7 +5638,7 @@ public function openedSearchPanes($reset = FALSE) { * @param $operator */ public function setOperator($operator) { - $validOperators = array('AND', 'OR'); + $validOperators = ['AND', 'OR']; if (!in_array($operator, $validOperators)) { $operator = 'AND'; } @@ -5659,7 +5659,7 @@ public function getOperator() { */ public function filterRelatedContacts(&$from, &$where, &$having) { if (!isset(Civi::$statics[__CLASS__]['related_contacts_filter'])) { - Civi::$statics[__CLASS__]['related_contacts_filter'] = array(); + Civi::$statics[__CLASS__]['related_contacts_filter'] = []; } $_rTempCache =& Civi::$statics[__CLASS__]['related_contacts_filter']; // since there only can be one instance of this filter in every query @@ -5692,7 +5692,7 @@ public function filterRelatedContacts(&$from, &$where, &$having) { "; CRM_Core_DAO::executeQuery($sql); - $cache = array('tableName' => $tableName, 'queries' => array()); + $cache = ['tableName' => $tableName, 'queries' => []]; $_rTempCache[$arg_sig] = $cache; } // upsert the query depending on relationship type @@ -5701,10 +5701,10 @@ public function filterRelatedContacts(&$from, &$where, &$having) { } else { $tableName = $cache['tableName']; - $qcache = array( + $qcache = [ "from" => "", "where" => "", - ); + ]; $rTypes = CRM_Core_PseudoConstant::relationshipType(); if (is_numeric($this->_displayRelationshipType)) { $relationshipTypeLabel = $rTypes[$this->_displayRelationshipType]['label_a_b']; @@ -5769,7 +5769,7 @@ public function filterRelatedContacts(&$from, &$where, &$having) { */ public static function caseImportant($op) { return - in_array($op, array('LIKE', 'IS NULL', 'IS NOT NULL', 'IS EMPTY', 'IS NOT EMPTY')) ? FALSE : TRUE; + in_array($op, ['LIKE', 'IS NULL', 'IS NOT NULL', 'IS EMPTY', 'IS NOT EMPTY']) ? FALSE : TRUE; } /** @@ -5820,7 +5820,7 @@ public function optionValueQuery( $useIDsOnly = FALSE ) { - $pseudoFields = array( + $pseudoFields = [ 'email_greeting', 'postal_greeting', 'addressee', @@ -5828,7 +5828,7 @@ public function optionValueQuery( 'prefix_id', 'suffix_id', 'communication_style_id', - ); + ]; if ($useIDsOnly) { list($tableName, $fieldName) = explode('.', $field['where'], 2); @@ -5852,7 +5852,7 @@ public function optionValueQuery( $wc = "{$field['where']}"; } if (in_array($name, $pseudoFields)) { - if (!in_array($name, array('gender_id', 'prefix_id', 'suffix_id', 'communication_style_id'))) { + if (!in_array($name, ['gender_id', 'prefix_id', 'suffix_id', 'communication_style_id'])) { $wc = "contact_a.{$name}_id"; } $dataType = 'Positive'; @@ -5863,7 +5863,7 @@ public function optionValueQuery( } list($qillop, $qillVal) = CRM_Contact_BAO_Query::buildQillForFieldValue($daoName, $field['name'], $value, $op); - $this->_qill[$grouping][] = ts("%1 %2 %3", array(1 => $label, 2 => $qillop, 3 => $qillVal)); + $this->_qill[$grouping][] = ts("%1 %2 %3", [1 => $label, 2 => $qillop, 3 => $qillVal]); $this->_where[$grouping][] = self::buildClause($wc, $op, $value, $dataType); } @@ -5892,7 +5892,7 @@ public static function parseSearchBuilderString($string, $dataType = 'Integer') return FALSE; } - $returnValues = array(); + $returnValues = []; foreach ($values as $v) { if ($dataType == 'Integer' && !is_numeric($v)) { return FALSE; @@ -5923,7 +5923,7 @@ public function convertToPseudoNames(&$dao, $return = FALSE, $usedForAPI = FALSE if (empty($this->_pseudoConstantsSelect)) { return NULL; } - $values = array(); + $values = []; foreach ($this->_pseudoConstantsSelect as $key => $value) { if (!empty($this->_pseudoConstantsSelect[$key]['sorting'])) { continue; @@ -5983,7 +5983,7 @@ public function convertToPseudoNames(&$dao, $return = FALSE, $usedForAPI = FALSE $dao->$key = CRM_Core_PseudoConstant::stateProvinceAbbreviation($val); } // @todo handle this in the section above for pseudoconstants. - elseif (in_array($value['pseudoField'], array('participant_role_id', 'participant_role'))) { + elseif (in_array($value['pseudoField'], ['participant_role_id', 'participant_role'])) { // @todo define bao on this & merge into the above condition. $viewValues = explode(CRM_Core_DAO::VALUE_SEPARATOR, $val); @@ -6008,7 +6008,7 @@ public function convertToPseudoNames(&$dao, $return = FALSE, $usedForAPI = FALSE $lastElement = array_pop($keyVal); foreach ($keyVal as $v) { if (!array_key_exists($v, $current)) { - $current[$v] = array(); + $current[$v] = []; } $current = &$current[$v]; } @@ -6021,12 +6021,12 @@ public function convertToPseudoNames(&$dao, $return = FALSE, $usedForAPI = FALSE } } if (!$usedForAPI) { - foreach (array( + foreach ([ 'gender_id' => 'gender', 'prefix_id' => 'individual_prefix', 'suffix_id' => 'individual_suffix', 'communication_style_id' => 'communication_style', - ) as $realField => $labelField) { + ] as $realField => $labelField) { // This is a temporary routine for handling these fields while // we figure out how to handled them based on metadata in /// export and search builder. CRM-19815, CRM-19830. @@ -6049,7 +6049,7 @@ public function includePseudoFieldsJoin($sort) { return NULL; } $sort = is_string($sort) ? $sort : $sort->orderBy(); - $present = array(); + $present = []; foreach ($this->_pseudoConstantsSelect as $name => $value) { if (!empty($value['table'])) { @@ -6086,7 +6086,7 @@ public function includePseudoFieldsJoin($sort) { $this->_fromClause = $this->_fromClause . $presentClause; $this->_simpleFromClause = $this->_simpleFromClause . $presentSimpleFromClause; - return array($presentClause, $presentSimpleFromClause); + return [$presentClause, $presentSimpleFromClause]; } /** @@ -6109,7 +6109,7 @@ public static function buildQillForFieldValue( $fieldName, $fieldValue, $op, - $pseudoExtraParam = array(), + $pseudoExtraParam = [], $type = CRM_Utils_Type::T_STRING ) { $qillOperators = CRM_Core_SelectValues::getSearchBuilderOperators(); @@ -6123,7 +6123,7 @@ public static function buildQillForFieldValue( // if Operator chosen is NULL/EMPTY then if (strpos($op, 'NULL') !== FALSE || strpos($op, 'EMPTY') !== FALSE) { - return array(CRM_Utils_Array::value($op, $qillOperators, $op), ''); + return [CRM_Utils_Array::value($op, $qillOperators, $op), '']; } if ($fieldName == 'activity_type_id') { @@ -6156,7 +6156,7 @@ public static function buildQillForFieldValue( } if (is_array($fieldValue)) { - $qillString = array(); + $qillString = []; if (!empty($pseudoOptions)) { foreach ((array) $fieldValue as $val) { $qillString[] = CRM_Utils_Array::value($val, $pseudoOptions, $val); @@ -6186,7 +6186,7 @@ public static function buildQillForFieldValue( $fieldValue = CRM_Utils_Date::customFormat($fieldValue); } - return array(CRM_Utils_Array::value($op, $qillOperators, $op), $fieldValue); + return [CRM_Utils_Array::value($op, $qillOperators, $op), $fieldValue]; } /** @@ -6228,9 +6228,9 @@ public static function getWildCardedValue($wildcard, $op, $value) { * @param array $changeNames * Array of fields whose name should be changed */ - public static function processSpecialFormValue(&$formValues, $specialFields, $changeNames = array()) { + public static function processSpecialFormValue(&$formValues, $specialFields, $changeNames = []) { // Array of special fields whose value are considered only for NULL or EMPTY operators - $nullableFields = array('contribution_batch_id'); + $nullableFields = ['contribution_batch_id']; foreach ($specialFields as $element) { $value = CRM_Utils_Array::value($element, $formValues); @@ -6240,15 +6240,15 @@ public static function processSpecialFormValue(&$formValues, $specialFields, $ch unset($formValues[$element]); $element = $changeNames[$element]; } - $formValues[$element] = array('IN' => $value); + $formValues[$element] = ['IN' => $value]; } - elseif (in_array($value, array('IS NULL', 'IS NOT NULL', 'IS EMPTY', 'IS NOT EMPTY'))) { - $formValues[$element] = array($value => 1); + elseif (in_array($value, ['IS NULL', 'IS NOT NULL', 'IS EMPTY', 'IS NOT EMPTY'])) { + $formValues[$element] = [$value => 1]; } elseif (!in_array($element, $nullableFields)) { // if wildcard is already present return searchString as it is OR append and/or prepend with wildcard $isWilcard = strstr($value, '%') ? FALSE : CRM_Core_Config::singleton()->includeWildCardInName; - $formValues[$element] = array('LIKE' => self::getWildCardedValue($isWilcard, 'LIKE', $value)); + $formValues[$element] = ['LIKE' => self::getWildCardedValue($isWilcard, 'LIKE', $value)]; } } } @@ -6342,7 +6342,7 @@ protected function prepareOrderBy($sort, $sortOrder) { $cfID = CRM_Core_BAO_CustomField::getKeyID($field); // add to cfIDs array if not present if (!empty($cfID) && !array_key_exists($cfID, $this->_cfIDs)) { - $this->_cfIDs[$cfID] = array(); + $this->_cfIDs[$cfID] = []; $this->_customQuery = new CRM_Core_BAO_CustomQuery($this->_cfIDs, TRUE, $this->_locationSpecificCustomFields); $this->_customQuery->query(); $this->_select = array_merge($this->_select, $this->_customQuery->_select); @@ -6427,11 +6427,11 @@ public function convertGroupIDStringToLabelString(&$dao, $val) { public function setQillAndWhere($name, $op, $value, $grouping, $field) { $this->_where[$grouping][] = self::buildClause("contact_a.{$name}", $op, $value); list($qillop, $qillVal) = CRM_Contact_BAO_Query::buildQillForFieldValue(NULL, $name, $value, $op); - $this->_qill[$grouping][] = ts("%1 %2 %3", array( + $this->_qill[$grouping][] = ts("%1 %2 %3", [ 1 => $field['title'], 2 => $qillop, 3 => $qillVal, - )); + ]); } /** diff --git a/CRM/Contact/BAO/Query/Hook.php b/CRM/Contact/BAO/Query/Hook.php index 30b30451acea..4b020772be1e 100644 --- a/CRM/Contact/BAO/Query/Hook.php +++ b/CRM/Contact/BAO/Query/Hook.php @@ -62,7 +62,7 @@ public static function singleton() { */ public function getSearchQueryObjects() { if ($this->_queryObjects === NULL) { - $this->_queryObjects = array(); + $this->_queryObjects = []; CRM_Utils_Hook::queryObjects($this->_queryObjects, 'Contact'); } return $this->_queryObjects; @@ -72,7 +72,7 @@ public function getSearchQueryObjects() { * @return array */ public function &getFields() { - $extFields = array(); + $extFields = []; foreach (self::getSearchQueryObjects() as $obj) { $flds = $obj->getFields(); $extFields = array_merge($extFields, $flds); diff --git a/CRM/Contact/BAO/RelationshipType.php b/CRM/Contact/BAO/RelationshipType.php index f30a44fcfcb6..e229a03ea571 100644 --- a/CRM/Contact/BAO/RelationshipType.php +++ b/CRM/Contact/BAO/RelationshipType.php @@ -142,10 +142,10 @@ public static function del($relationshipTypeId) { $relationship->delete(); // remove this relationship type from membership types - $mems = civicrm_api3('MembershipType', 'get', array( - 'relationship_type_id' => array('LIKE' => "%{$relationshipTypeId}%"), - 'return' => array('id', 'relationship_type_id', 'relationship_direction'), - )); + $mems = civicrm_api3('MembershipType', 'get', [ + 'relationship_type_id' => ['LIKE' => "%{$relationshipTypeId}%"], + 'return' => ['id', 'relationship_type_id', 'relationship_direction'], + ]); foreach ($mems['values'] as $membershipTypeId => $membershipType) { $pos = array_search($relationshipTypeId, $membershipType['relationship_type_id']); // Api call may have returned false positives but currently the relationship_type_id uses diff --git a/CRM/Contact/BAO/SavedSearch.php b/CRM/Contact/BAO/SavedSearch.php index 67e95d095fb4..049dcaf5170b 100644 --- a/CRM/Contact/BAO/SavedSearch.php +++ b/CRM/Contact/BAO/SavedSearch.php @@ -92,7 +92,7 @@ public static function retrieve(&$params, &$defaults) { * the values of the posted saved search used as default values in various Search Form */ public static function getFormValues($id) { - $specialDateFields = array( + $specialDateFields = [ 'event_start_date_low' => 'event_date_low', 'event_end_date_high' => 'event_date_high', 'participant_register_date_low' => 'participant_date_low', @@ -101,7 +101,7 @@ public static function getFormValues($id) { 'case_from_start_date_high' => 'case_from_date_high', 'case_to_end_date_low' => 'case_to_date_low', 'case_to_end_date_high' => 'case_to_date_high', - ); + ]; $fv = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_SavedSearch', $id, 'form_values'); $result = NULL; @@ -110,7 +110,7 @@ public static function getFormValues($id) { $result = unserialize($fv); } - $specialFields = array('contact_type', 'group', 'contact_tags', 'member_membership_type_id', 'member_status_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); @@ -118,7 +118,7 @@ public static function getFormValues($id) { if (is_array($value) && in_array(key($value), CRM_Core_DAO::acceptedSQLOperators(), TRUE)) { $op = key($value); $value = CRM_Utils_Array::value($op, $value); - if (in_array($op, array('BETWEEN', '>=', '<='))) { + if (in_array($op, ['BETWEEN', '>=', '<='])) { self::decodeRelativeFields($result, $id, $op, $value); unset($result[$element]); continue; @@ -198,7 +198,7 @@ public static function getFormValues($id) { unset($result['privacy']['do_not_toggle']); } - $result['privacy_options'] = array(); + $result['privacy_options'] = []; foreach ($result['privacy'] as $name => $val) { if ($val) { $result['privacy_options'][] = $name; @@ -279,7 +279,7 @@ public static function contactIDsSQL($id) { return CRM_Contact_BAO_SearchCustom::contactIDSQL(NULL, $id); } else { - $tables = $whereTables = array('civicrm_contact' => 1); + $tables = $whereTables = ['civicrm_contact' => 1]; $where = CRM_Contact_BAO_SavedSearch::whereClause($id, $tables, $whereTables); if (!$where) { $where = '( 1 )'; @@ -307,10 +307,10 @@ public static function fromWhereEmail($id) { return CRM_Contact_BAO_SearchCustom::fromWhereEmail(NULL, $id); } else { - $tables = $whereTables = array('civicrm_contact' => 1, 'civicrm_email' => 1); + $tables = $whereTables = ['civicrm_contact' => 1, 'civicrm_email' => 1]; $where = CRM_Contact_BAO_SavedSearch::whereClause($id, $tables, $whereTables); $from = CRM_Contact_BAO_Query::fromClause($whereTables); - return array($from, $where); + return [$from, $where]; } } else { @@ -322,7 +322,7 @@ public static function fromWhereEmail($id) { $where = " ( 1 ) "; $tables['civicrm_contact'] = $whereTables['civicrm_contact'] = 1; $tables['civicrm_email'] = $whereTables['civicrm_email'] = 1; - return array($from, $where); + return [$from, $where]; } } @@ -340,7 +340,7 @@ public function buildClause() { } if (!empty($params)) { - $tables = $whereTables = array(); + $tables = $whereTables = []; $this->where_clause = CRM_Contact_BAO_Query::getWhereClause($params, NULL, $tables, $whereTables); if (!empty($tables)) { $this->select_tables = serialize($tables); @@ -422,7 +422,7 @@ protected function assignTestValue($fieldName, &$fieldDef, $counter) { if ($fieldName == 'form_values') { // A dummy value for form_values. $this->{$fieldName} = serialize( - array('sort_name' => "SortName{$counter}")); + ['sort_name' => "SortName{$counter}"]); } else { parent::assignTestValues($fieldName, $fieldDef, $counter); @@ -436,8 +436,8 @@ protected function assignTestValue($fieldName, &$fieldDef, $counter) { * @param array $formValues */ public static function saveRelativeDates(&$queryParams, $formValues) { - $relativeDates = array('relative_dates' => array()); - $specialDateFields = array('event_relative', 'case_from_relative', 'case_to_relative', 'participant_relative'); + $relativeDates = ['relative_dates' => []]; + $specialDateFields = ['event_relative', 'case_from_relative', 'case_to_relative', 'participant_relative']; foreach ($formValues as $id => $value) { if ((preg_match('/(_date|custom_[0-9]+)_relative$/', $id) || in_array($id, $specialDateFields)) && !empty($value)) { $entityName = strstr($id, '_date', TRUE); @@ -463,15 +463,15 @@ public static function saveRelativeDates(&$queryParams, $formValues) { */ public static function saveSkippedElement(&$queryParams, $formValues) { // these are elements which are skipped in a smart group criteria - $specialElements = array( + $specialElements = [ 'operator', 'component_mode', 'display_relationship_type', 'uf_group_id', - ); + ]; foreach ($specialElements as $element) { if (!empty($formValues[$element])) { - $queryParams[] = array($element, '=', $formValues[$element], 0, 0); + $queryParams[] = [$element, '=', $formValues[$element], 0, 0]; } } } diff --git a/CRM/Contact/BAO/SearchCustom.php b/CRM/Contact/BAO/SearchCustom.php index 625b6b82df58..cadd086e4c40 100644 --- a/CRM/Contact/BAO/SearchCustom.php +++ b/CRM/Contact/BAO/SearchCustom.php @@ -43,7 +43,7 @@ class CRM_Contact_BAO_SearchCustom { * @throws Exception */ public static function details($csID, $ssID = NULL, $gID = NULL) { - $error = array(NULL, NULL, NULL); + $error = [NULL, NULL, NULL]; if (!$csID && !$ssID && @@ -53,7 +53,7 @@ public static function details($csID, $ssID = NULL, $gID = NULL) { } $customSearchID = $csID; - $formValues = array(); + $formValues = []; if ($ssID || $gID) { if ($gID) { $ssID = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $gID, 'saved_search_id'); @@ -71,11 +71,11 @@ public static function details($csID, $ssID = NULL, $gID = NULL) { // check that the csid exists in the db along with the right file // and implements the right interface - $customSearchClass = civicrm_api3('OptionValue', 'getvalue', array( + $customSearchClass = civicrm_api3('OptionValue', 'getvalue', [ 'option_group_id' => 'custom_search', 'return' => 'name', 'value' => $customSearchID, - )); + ]); $ext = CRM_Extension_System::singleton()->getMapper(); @@ -95,7 +95,7 @@ public static function details($csID, $ssID = NULL, $gID = NULL) { CRM_Core_Error::fatal('Custom search file: ' . $customSearchFile . ' does not exist. Please verify your custom search settings in CiviCRM administrative panel.'); } - return array($customSearchID, $customSearchClass, $formValues); + return [$customSearchID, $customSearchClass, $formValues]; } /** @@ -138,7 +138,7 @@ public static function &buildFormValues($args) { $args = trim($args); $values = explode("\n", $args); - $formValues = array(); + $formValues = []; foreach ($values as $value) { list($n, $v) = CRM_Utils_System::explode('=', $value, 2); if (!empty($v)) { @@ -160,7 +160,7 @@ public static function fromWhereEmail($csID, $ssID) { $from = $customClass->from(); $where = $customClass->where(); - return array($from, $where); + return [$from, $where]; } } diff --git a/CRM/Contact/Form/Contact.php b/CRM/Contact/Form/Contact.php index 5c29e67b1bd2..5f3ce8babc46 100644 --- a/CRM/Contact/Form/Contact.php +++ b/CRM/Contact/Form/Contact.php @@ -90,13 +90,13 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form { */ protected $_duplicateButtonName; - protected $_editOptions = array(); + protected $_editOptions = []; - protected $_oldSubtypes = array(); + protected $_oldSubtypes = []; public $_blocks; - public $_values = array(); + public $_values = []; public $_action; @@ -162,7 +162,7 @@ public function preProcess() { $this, TRUE, NULL, 'REQUEST' ); if (!in_array($this->_contactType, - array('Individual', 'Household', 'Organization') + ['Individual', 'Household', 'Organization'] ) ) { CRM_Core_Error::statusBounce(ts('Could not get a contact id and/or contact type')); @@ -177,7 +177,7 @@ public function preProcess() { $this->_contactSubType && !(CRM_Contact_BAO_ContactType::isExtendsContactType($this->_contactSubType, $this->_contactType, TRUE)) ) { - CRM_Core_Error::statusBounce(ts("Could not get a valid contact subtype for contact type '%1'", array(1 => $this->_contactType))); + CRM_Core_Error::statusBounce(ts("Could not get a valid contact subtype for contact type '%1'", [1 => $this->_contactType])); } $this->_gid = CRM_Utils_Request::retrieve('gid', 'Integer', @@ -193,7 +193,7 @@ public function preProcess() { ); $typeLabel = implode(' / ', $typeLabel); - CRM_Utils_System::setTitle(ts('New %1', array(1 => $typeLabel))); + CRM_Utils_System::setTitle(ts('New %1', [1 => $typeLabel])); $session->pushUserContext(CRM_Utils_System::url('civicrm/dashboard', 'reset=1')); $this->_contactId = NULL; } @@ -204,13 +204,13 @@ public function preProcess() { } if ($this->_contactId) { - $defaults = array(); - $params = array('id' => $this->_contactId); - $returnProperities = array('id', 'contact_type', 'contact_sub_type', 'modified_date', 'is_deceased'); + $defaults = []; + $params = ['id' => $this->_contactId]; + $returnProperities = ['id', 'contact_type', 'contact_sub_type', 'modified_date', 'is_deceased']; CRM_Core_DAO::commonRetrieve('CRM_Contact_DAO_Contact', $params, $defaults, $returnProperities); if (empty($defaults['id'])) { - CRM_Core_Error::statusBounce(ts('A Contact with that ID does not exist: %1', array(1 => $this->_contactId))); + 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); @@ -226,7 +226,7 @@ public function preProcess() { if ($defaults['is_deceased']) { $displayName .= ' (deceased)'; } - $displayName = ts('Edit %1', array(1 => $displayName)); + $displayName = ts('Edit %1', [1 => $displayName]); // Check if this is default domain contact CRM-10482 if (CRM_Contact_BAO_Contact::checkDomainContact($this->_contactId)) { @@ -256,13 +256,13 @@ public function preProcess() { $this->_values = $values; } else { - $params = array( + $params = [ 'id' => $this->_contactId, 'contact_id' => $this->_contactId, 'noRelationships' => TRUE, 'noNotes' => TRUE, 'noGroups' => TRUE, - ); + ]; $contact = CRM_Contact_BAO_Contact::retrieve($params, $this->_values, TRUE); $this->set('values', $this->_values); @@ -430,7 +430,7 @@ public function setDefaultValues() { } // set defaults for blocks ( custom data, address, communication preference, notes, tags and groups ) foreach ($this->_editOptions as $name => $label) { - if (!in_array($name, array('Address', 'Notes'))) { + if (!in_array($name, ['Address', 'Notes'])) { $className = 'CRM_Contact_Form_Edit_' . $name; $className::setDefaultValues($this, $defaults); } @@ -561,19 +561,19 @@ public function addRules() { return; } - $this->addFormRule(array('CRM_Contact_Form_Edit_' . $this->_contactType, 'formRule'), $this->_contactId); + $this->addFormRule(['CRM_Contact_Form_Edit_' . $this->_contactType, 'formRule'], $this->_contactId); // Call Locking check if editing existing contact if ($this->_contactId) { - $this->addFormRule(array('CRM_Contact_Form_Edit_Lock', 'formRule'), $this->_contactId); + $this->addFormRule(['CRM_Contact_Form_Edit_Lock', 'formRule'], $this->_contactId); } if (array_key_exists('Address', $this->_editOptions)) { - $this->addFormRule(array('CRM_Contact_Form_Edit_Address', 'formRule'), $this); + $this->addFormRule(['CRM_Contact_Form_Edit_Address', 'formRule'], $this); } if (array_key_exists('CommunicationPreferences', $this->_editOptions)) { - $this->addFormRule(array('CRM_Contact_Form_Edit_CommunicationPreferences', 'formRule'), $this); + $this->addFormRule(['CRM_Contact_Form_Edit_CommunicationPreferences', 'formRule'], $this); } } @@ -615,11 +615,11 @@ public static function formRule($fields, &$errors, $contactId, $contactType) { $blocks['Address'] = $otherEditOptions['Address']; } - $website_types = array(); - $openIds = array(); + $website_types = []; + $openIds = []; $primaryID = FALSE; foreach ($blocks as $name => $label) { - $hasData = $hasPrimary = array(); + $hasData = $hasPrimary = []; $name = strtolower($name); if (!empty($fields[$name]) && is_array($fields[$name])) { foreach ($fields[$name] as $instance => $blockValues) { @@ -648,17 +648,17 @@ public static function formRule($fields, &$errors, $contactId, $contactType) { if (!empty($blockValues['is_primary'])) { $hasPrimary[] = $instance; if (!$primaryID && - in_array($name, array( + in_array($name, [ 'email', 'openid', - )) && !empty($blockValues[$name]) + ]) && !empty($blockValues[$name]) ) { $primaryID = $blockValues[$name]; } } if (empty($blockValues['location_type_id'])) { - $errors["{$name}[$instance][location_type_id]"] = ts('The Location Type should be set if there is %1 information.', array(1 => $label)); + $errors["{$name}[$instance][location_type_id]"] = ts('The Location Type should be set if there is %1 information.', [1 => $label]); } } @@ -667,18 +667,18 @@ public static function formRule($fields, &$errors, $contactId, $contactType) { $oid->openid = $openIds[$instance] = CRM_Utils_Array::value($name, $blockValues); $cid = isset($contactId) ? $contactId : 0; if ($oid->find(TRUE) && ($oid->contact_id != $cid)) { - $errors["{$name}[$instance][openid]"] = ts('%1 already exist.', array(1 => $blocks['OpenID'])); + $errors["{$name}[$instance][openid]"] = ts('%1 already exist.', [1 => $blocks['OpenID']]); } } } if (empty($hasPrimary) && !empty($hasData)) { - $errors["{$name}[1][is_primary]"] = ts('One %1 should be marked as primary.', array(1 => $label)); + $errors["{$name}[1][is_primary]"] = ts('One %1 should be marked as primary.', [1 => $label]); } if (count($hasPrimary) > 1) { $errors["{$name}[" . array_pop($hasPrimary) . "][is_primary]"] = ts('Only one %1 can be marked as primary.', - array(1 => $label) + [1 => $label] ); } } @@ -688,7 +688,7 @@ public static function formRule($fields, &$errors, $contactId, $contactType) { if (!empty($openIds) && (count(array_unique($openIds)) != count($openIds))) { foreach ($openIds as $instance => $value) { if (!array_key_exists($instance, array_unique($openIds))) { - $errors["openid[$instance][openid]"] = ts('%1 already used.', array(1 => $blocks['OpenID'])); + $errors["openid[$instance][openid]"] = ts('%1 already used.', [1 => $blocks['OpenID']]); } } } @@ -703,7 +703,7 @@ public static function formRule($fields, &$errors, $contactId, $contactType) { if (isset($fields['address']) && is_array($fields['address']) ) { - $invalidStreetNumbers = array(); + $invalidStreetNumbers = []; foreach ($fields['address'] as $cnt => $address) { if ($streetNumber = CRM_Utils_Array::value('street_number', $address)) { $parsedAddress = CRM_Core_BAO_Address::parseStreetAddress($address['street_number']); @@ -718,7 +718,7 @@ public static function formRule($fields, &$errors, $contactId, $contactType) { foreach ($invalidStreetNumbers as & $num) { $num = CRM_Contact_Form_Contact::ordinalNumber($num); } - $errors["address[$first][street_number]"] = ts('The street number you entered for the %1 address block(s) is not in an expected format. Street numbers may include numeric digit(s) followed by other characters. You can still enter the complete street address (unparsed) by clicking "Edit Complete Street Address".', array(1 => implode(', ', $invalidStreetNumbers))); + $errors["address[$first][street_number]"] = ts('The street number you entered for the %1 address block(s) is not in an expected format. Street numbers may include numeric digit(s) followed by other characters. You can still enter the complete street address (unparsed) by clicking "Edit Complete Street Address".', [1 => implode(', ', $invalidStreetNumbers)]); } } } @@ -743,19 +743,19 @@ public function buildQuickForm() { if ($this->_action == CRM_Core_Action::UPDATE) { $deleteExtra = json_encode(ts('Are you sure you want to delete contact image.')); - $deleteURL = array( - CRM_Core_Action::DELETE => array( + $deleteURL = [ + CRM_Core_Action::DELETE => [ 'name' => ts('Delete Contact Image'), 'url' => 'civicrm/contact/image', 'qs' => 'reset=1&cid=%%id%%&action=delete', 'extra' => 'onclick = "' . htmlspecialchars("if (confirm($deleteExtra)) this.href+='&confirmed=1'; else return false;") . '"', - ), - ); + ], + ]; $deleteURL = CRM_Core_Action::formLink($deleteURL, CRM_Core_Action::DELETE, - array( + [ 'id' => $this->_contactId, - ), + ], ts('more'), FALSE, 'contact.image.delete', @@ -773,7 +773,7 @@ public function buildQuickForm() { $checkSimilar = Civi::settings()->get('contact_ajax_check_similar'); $this->assign('checkSimilar', $checkSimilar); if ($checkSimilar == 1) { - $ruleParams = array('used' => 'Supervised', 'contact_type' => $this->_contactType); + $ruleParams = ['used' => 'Supervised', 'contact_type' => $this->_contactType]; $this->assign('ruleFields', CRM_Dedupe_BAO_Rule::dedupeRuleFields($ruleParams)); } @@ -784,15 +784,15 @@ public function buildQuickForm() { } // subtype is a common field. lets keep it here - $subtypes = CRM_Contact_BAO_Contact::buildOptions('contact_sub_type', 'create', array('contact_type' => $this->_contactType)); + $subtypes = CRM_Contact_BAO_Contact::buildOptions('contact_sub_type', 'create', ['contact_type' => $this->_contactType]); if (!empty($subtypes)) { - $this->addField('contact_sub_type', array( + $this->addField('contact_sub_type', [ 'label' => ts('Contact Type'), 'options' => $subtypes, 'class' => $buildCustomData, 'multiple' => 'multiple', 'option_url' => NULL, - )); + ]); } // build edit blocks ( custom data, demographics, communication preference, notes, tags and groups ) @@ -817,7 +817,7 @@ public function buildQuickForm() { CRM_Contact_Form_Location::buildQuickForm($this); // add attachment - $this->addField('image_URL', array('maxlength' => '255', 'label' => ts('Browse/Upload Image'))); + $this->addField('image_URL', ['maxlength' => '255', 'label' => ts('Browse/Upload Image')]); // add the dedupe button $this->addElement('submit', @@ -833,26 +833,26 @@ public function buildQuickForm() { ts('Save With Duplicate Household') ); - $buttons = array( - array( + $buttons = [ + [ 'type' => 'upload', 'name' => ts('Save'), 'subName' => 'view', 'isDefault' => TRUE, - ), - ); + ], + ]; if (CRM_Core_Permission::check('add contacts')) { - $buttons[] = array( + $buttons[] = [ 'type' => 'upload', 'name' => ts('Save and New'), 'spacing' => '                 ', 'subName' => 'new', - ); + ]; } - $buttons[] = array( + $buttons[] = [ 'type' => 'cancel', 'name' => ts('Cancel'), - ); + ]; if (!empty($this->_values['contact_sub_type'])) { $this->_oldSubtypes = explode(CRM_Core_DAO::VALUE_SEPARATOR, @@ -906,7 +906,7 @@ public function postProcess() { $params['contact_type'] = $this->_contactType; if (empty($params['contact_sub_type']) && $this->_isContactSubType) { - $params['contact_sub_type'] = array($this->_contactSubType); + $params['contact_sub_type'] = [$this->_contactSubType]; } if ($this->_contactId) { @@ -921,11 +921,11 @@ public function postProcess() { if (isset($params['contact_id'])) { // process membership status for deceased contact - $deceasedParams = array( + $deceasedParams = [ 'contact_id' => CRM_Utils_Array::value('contact_id', $params), 'is_deceased' => CRM_Utils_Array::value('is_deceased', $params, FALSE), 'deceased_date' => CRM_Utils_Array::value('deceased_date', $params, NULL), - ); + ]; $updateMembershipMsg = $this->updateMembershipStatus($deceasedParams); } @@ -984,7 +984,7 @@ public function postProcess() { $parseStatusMsg = self::parseAddressStatusMsg($parseResult); } - $blocks = array('email', 'phone', 'im', 'openid', 'address', 'website'); + $blocks = ['email', 'phone', 'im', 'openid', 'address', 'website']; foreach ($blocks as $block) { if (!empty($this->_preEditValues[$block]) && is_array($this->_preEditValues[$block])) { foreach ($this->_preEditValues[$block] as $count => $value) { @@ -1003,10 +1003,10 @@ public function postProcess() { // status message if ($this->_contactId) { - $message = ts('%1 has been updated.', array(1 => $contact->display_name)); + $message = ts('%1 has been updated.', [1 => $contact->display_name]); } else { - $message = ts('%1 has been created.', array(1 => $contact->display_name)); + $message = ts('%1 has been created.', [1 => $contact->display_name]); } // set the contact ID @@ -1035,7 +1035,7 @@ public function postProcess() { $session->setStatus($message, ts('Contact Saved'), 'success'); // add the recently viewed contact - $recentOther = array(); + $recentOther = []; if (($session->get('userID') == $contact->id) || CRM_Contact_BAO_Contact_Permission::allow($contact->id, CRM_Core_Permission::EDIT) ) { @@ -1101,7 +1101,7 @@ public static function blockDataExists(&$fields) { return FALSE; } - static $skipFields = array( + static $skipFields = [ 'location_type_id', 'is_primary', 'phone_type_id', @@ -1109,7 +1109,7 @@ public static function blockDataExists(&$fields) { 'country_id', 'website_type_id', 'master_id', - ); + ]; foreach ($fields as $name => $value) { $skipField = FALSE; foreach ($skipFields as $skip) { @@ -1154,27 +1154,27 @@ public static function checkDuplicateContacts(&$fields, &$errors, $contactID, $c // if this is a forced save, ignore find duplicate rule if (empty($fields['_qf_Contact_upload_duplicate'])) { - $ids = CRM_Contact_BAO_Contact::getDuplicateContacts($fields, $contactType, 'Supervised', array($contactID)); + $ids = CRM_Contact_BAO_Contact::getDuplicateContacts($fields, $contactType, 'Supervised', [$contactID]); if ($ids) { $contactLinks = CRM_Contact_BAO_Contact_Utils::formatContactIDSToLinks($ids, TRUE, TRUE, $contactID); $duplicateContactsLinks = '
'; - $duplicateContactsLinks .= ts('One matching contact was found. ', array( + $duplicateContactsLinks .= ts('One matching contact was found. ', [ 'count' => count($contactLinks['rows']), 'plural' => '%count matching contacts were found.
', - )); + ]); if ($contactLinks['msg'] == 'view') { - $duplicateContactsLinks .= ts('You can View the existing contact', array( + $duplicateContactsLinks .= ts('You can View the existing contact', [ 'count' => count($contactLinks['rows']), 'plural' => 'You can View the existing contacts', - )); + ]); } else { - $duplicateContactsLinks .= ts('You can View or Edit the existing contact', array( + $duplicateContactsLinks .= ts('You can View or Edit the existing contact', [ 'count' => count($contactLinks['rows']), 'plural' => 'You can View or Edit the existing contacts', - )); + ]); } if ($contactLinks['msg'] == 'merge') { // We should also get a merge link if this is for an existing contact @@ -1245,7 +1245,7 @@ public function getTemplateFileName() { * as array of success/fails for each address block */ public function parseAddress(&$params) { - $parseSuccess = $parsedFields = array(); + $parseSuccess = $parsedFields = []; if (!is_array($params['address']) || CRM_Utils_System::isNull($params['address']) ) { @@ -1255,11 +1255,11 @@ public function parseAddress(&$params) { foreach ($params['address'] as $instance => & $address) { $buildStreetAddress = FALSE; $parseFieldName = 'street_address'; - foreach (array( + foreach ([ 'street_number', 'street_name', 'street_unit', - ) as $fld) { + ] as $fld) { if (!empty($address[$fld])) { $parseFieldName = 'street_number'; $buildStreetAddress = TRUE; @@ -1287,16 +1287,16 @@ public function parseAddress(&$params) { $address['street_number'] = $parsedFields['street_number']; $streetAddress = NULL; - foreach (array( + foreach ([ 'street_number', 'street_number_suffix', 'street_name', 'street_unit', - ) as $fld) { - if (in_array($fld, array( + ] as $fld) { + if (in_array($fld, [ 'street_name', 'street_unit', - ))) { + ])) { $streetAddress .= ' '; } // CRM-17619 - if the street number suffix begins with a number, add a space @@ -1353,7 +1353,7 @@ public static function parseAddressStatusMsg($parseResult) { return $statusMsg; } - $parseFails = array(); + $parseFails = []; foreach ($parseResult as $instance => $success) { if (!$success) { $parseFails[] = self::ordinalNumber($instance); @@ -1362,7 +1362,7 @@ public static function parseAddressStatusMsg($parseResult) { if (!empty($parseFails)) { $statusMsg = ts("Complete street address(es) have been saved. However we were unable to split the address in the %1 address block(s) into address elements (street number, street name, street unit) due to an unrecognized address format. You can set the address elements manually by clicking 'Edit Address Elements' next to the Street Address field while in edit mode.", - array(1 => implode(', ', $parseFails)) + [1 => implode(', ', $parseFails)] ); } @@ -1459,7 +1459,7 @@ public function updateMembershipStatus($deceasedParams) { ); // add membership log - $membershipLog = array( + $membershipLog = [ 'membership_id' => $dao->id, 'status_id' => $deceasedStatusId, 'start_date' => CRM_Utils_Date::isoToMysql($dao->start_date), @@ -1468,12 +1468,12 @@ public function updateMembershipStatus($deceasedParams) { 'modified_date' => date('Ymd'), 'membership_type_id' => $dao->membership_type_id, 'max_related' => $dao->max_related, - ); + ]; CRM_Member_BAO_MembershipLog::add($membershipLog); //create activity when membership status is changed - $activityParam = array( + $activityParam = [ 'subject' => "Status changed from {$allStatus[$dao->status_id]} to {$allStatus[$deceasedStatusId]}", 'source_contact_id' => $userId, 'target_contact_id' => $dao->contact_id, @@ -1486,7 +1486,7 @@ public function updateMembershipStatus($deceasedParams) { 'is_auto' => 0, 'is_current_revision' => 1, 'is_deleted' => 0, - ); + ]; $activityResult = civicrm_api('activity', 'create', $activityParam); $memCount++; @@ -1495,7 +1495,7 @@ public function updateMembershipStatus($deceasedParams) { // set status msg if ($memCount) { $updateMembershipMsg = ts("%1 Current membership(s) for this contact have been set to 'Deceased' status.", - array(1 => $memCount) + [1 => $memCount] ); } } diff --git a/CRM/Contact/Form/CustomData.php b/CRM/Contact/Form/CustomData.php index 1b60d5f5b93b..dadbeb75e798 100644 --- a/CRM/Contact/Form/CustomData.php +++ b/CRM/Contact/Form/CustomData.php @@ -135,7 +135,7 @@ public function preProcess() { $groupTitle = CRM_Core_BAO_CustomGroup::getTitle($this->_groupID); $mode = CRM_Utils_Request::retrieve('mode', 'String', CRM_Core_DAO::$_nullObject, FALSE, NULL, 'GET'); $mode = ucfirst($mode); - CRM_Utils_System::setTitle(ts('%1 %2 Record', array(1 => $mode, 2 => $groupTitle))); + CRM_Utils_System::setTitle(ts('%1 %2 Record', [1 => $mode, 2 => $groupTitle])); if (!empty($_POST['hidden_custom'])) { $this->assign('postedInfo', TRUE); @@ -177,22 +177,22 @@ public function buildQuickForm() { if ($isMultiple) { $this->assign('multiRecordDisplay', $this->_multiRecordDisplay); $saveButtonName = $this->_copyValueId ? ts('Save a Copy') : ts('Save'); - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'upload', 'name' => $saveButtonName, 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'upload', 'name' => ts('Save and New'), 'subName' => 'new', - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); } } @@ -205,17 +205,17 @@ public function buildQuickForm() { // make this form an upload since we dont know if the custom data injected dynamically // is of type file etc - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'upload', 'name' => ts('Save'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); } @@ -234,7 +234,7 @@ public function setDefaultValues() { NULL, $this->_entityId, $this->_groupID, - array(), + [], NULL, TRUE, NULL, @@ -242,7 +242,7 @@ public function setDefaultValues() { TRUE, $this->_copyValueId ); - $valueIdDefaults = array(); + $valueIdDefaults = []; $groupTreeValueId = CRM_Core_BAO_CustomGroup::formatGroupTree($groupTree, $this->_copyValueId, $this); CRM_Core_BAO_CustomGroup::setDefaults($groupTreeValueId, $valueIdDefaults, FALSE, FALSE, $this->get('action')); $tableId = $groupTreeValueId[$this->_groupID]['table_id']; @@ -280,7 +280,7 @@ public function setDefaultValues() { $this->assign('customValueCount', $customValueCount); - $defaults = array(); + $defaults = []; return $defaults; } diff --git a/CRM/Contact/Form/DedupeFind.php b/CRM/Contact/Form/DedupeFind.php index 999390ec5ea8..69e62a70c62a 100644 --- a/CRM/Contact/Form/DedupeFind.php +++ b/CRM/Contact/Form/DedupeFind.php @@ -53,26 +53,26 @@ public function preProcess() { */ public function buildQuickForm() { - $groupList = array('' => ts('- All Contacts -')) + CRM_Core_PseudoConstant::nestedGroup(); + $groupList = ['' => ts('- All Contacts -')] + CRM_Core_PseudoConstant::nestedGroup(); - $this->add('select', 'group_id', ts('Select Group'), $groupList, FALSE, array('class' => 'crm-select2 huge')); + $this->add('select', 'group_id', ts('Select Group'), $groupList, FALSE, ['class' => 'crm-select2 huge']); if (Civi::settings()->get('dedupe_default_limit')) { $this->add('text', 'limit', ts('No of contacts to find matches for ')); } - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => ts('Continue'), 'isDefault' => TRUE, - ), + ], //hack to support cancel button functionality - array( + [ 'type' => 'submit', 'class' => 'cancel', 'icon' => 'fa-times', 'name' => ts('Cancel'), - ), - ) + ], + ] ); } diff --git a/CRM/Contact/Form/DedupeRules.php b/CRM/Contact/Form/DedupeRules.php index ee6483257ede..4a8294f44e0a 100644 --- a/CRM/Contact/Form/DedupeRules.php +++ b/CRM/Contact/Form/DedupeRules.php @@ -37,7 +37,7 @@ class CRM_Contact_Form_DedupeRules extends CRM_Admin_Form { const RULES_COUNT = 5; protected $_contactType; - protected $_fields = array(); + protected $_fields = []; protected $_rgid; /** @@ -60,7 +60,7 @@ public function preProcess() { $this->_rgid = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE, 0); // check if $contactType is valid - $contactTypes = civicrm_api3('Contact', 'getOptions', array('field' => "contact_type", 'context' => "validate")); + $contactTypes = civicrm_api3('Contact', 'getOptions', ['field' => "contact_type", 'context' => "validate"]); $contactType = CRM_Utils_Request::retrieve('contact_type', 'String', $this, FALSE, 0); if (CRM_Utils_Array::value($contactType, $contactTypes['values'])) { $this->_contactType = $contactType; @@ -107,38 +107,38 @@ public function preProcess() { * Build the form object. */ public function buildQuickForm() { - $this->addField('title', array('label' => ts('Rule Name')), TRUE); + $this->addField('title', ['label' => ts('Rule Name')], TRUE); $this->addRule('title', ts('A duplicate matching rule with this name already exists. Please select another name.'), - 'objectExists', array('CRM_Dedupe_DAO_RuleGroup', $this->_rgid, 'title') + 'objectExists', ['CRM_Dedupe_DAO_RuleGroup', $this->_rgid, 'title'] ); - $this->addField('used', array('label' => ts('Usage')), TRUE); - $disabled = array(); - $reserved = $this->addField('is_reserved', array('label' => ts('Reserved?'))); + $this->addField('used', ['label' => ts('Usage')], TRUE); + $disabled = []; + $reserved = $this->addField('is_reserved', ['label' => ts('Reserved?')]); if (!empty($this->_defaults['is_reserved'])) { $reserved->freeze(); } - $attributes = array('class' => 'two'); + $attributes = ['class' => 'two']; if (!empty($disabled)) { $attributes = array_merge($attributes, $disabled); } for ($count = 0; $count < self::RULES_COUNT; $count++) { $this->add('select', "where_$count", ts('Field'), - array( + [ NULL => ts('- none -'), - ) + $this->_fields, FALSE, $disabled + ] + $this->_fields, FALSE, $disabled ); - $this->addField("length_$count", array('entity' => 'Rule', 'name' => 'rule_length') + $attributes); - $this->addField("weight_$count", array('entity' => 'Rule', 'name' => 'rule_weight') + $attributes); + $this->addField("length_$count", ['entity' => 'Rule', 'name' => 'rule_length'] + $attributes); + $this->addField("weight_$count", ['entity' => 'Rule', 'name' => 'rule_weight'] + $attributes); } - $this->addField('threshold', array('label' => ts("Weight Threshold to Consider Contacts 'Matching':")) + $attributes); + $this->addField('threshold', ['label' => ts("Weight Threshold to Consider Contacts 'Matching':")] + $attributes); $this->assign('contact_type', $this->_contactType); - $this->addFormRule(array('CRM_Contact_Form_DedupeRules', 'formRule'), $this); + $this->addFormRule(['CRM_Contact_Form_DedupeRules', 'formRule'], $this); parent::buildQuickForm(); } @@ -156,7 +156,7 @@ public function buildQuickForm() { * list of errors to be posted back to the form */ public static function formRule($fields, $files, $self) { - $errors = array(); + $errors = []; $fieldSelected = FALSE; for ($count = 0; $count < self::RULES_COUNT; $count++) { if (!empty($fields["where_$count"]) || (isset($self->_defaults['is_reserved']) && !empty($self->_defaults["where_$count"]))) { @@ -208,10 +208,10 @@ public function postProcess() { SET used = 'General' WHERE contact_type = %1 AND used = %2"; - $queryParams = array( - 1 => array($this->_contactType, 'String'), - 2 => array($values['used'], 'String'), - ); + $queryParams = [ + 1 => [$this->_contactType, 'String'], + 2 => [$values['used'], 'String'], + ]; CRM_Core_DAO::executeQuery($query, $queryParams); } @@ -237,7 +237,7 @@ public function postProcess() { // lets skip updating of fields for reserved dedupe group if (CRM_Utils_Array::value('is_reserved', $this->_defaults)) { - CRM_Core_Session::setStatus(ts("The rule '%1' has been saved.", array(1 => $rgDao->title)), ts('Saved'), 'success'); + CRM_Core_Session::setStatus(ts("The rule '%1' has been saved.", [1 => $rgDao->title]), ts('Saved'), 'success'); return; } @@ -246,9 +246,9 @@ public function postProcess() { $ruleDao->delete(); $ruleDao->free(); - $substrLenghts = array(); + $substrLenghts = []; - $tables = array(); + $tables = []; $daoObj = new CRM_Core_DAO(); $database = $daoObj->database(); for ($count = 0; $count < self::RULES_COUNT; $count++) { @@ -269,7 +269,7 @@ public function postProcess() { $ruleDao->free(); if (!array_key_exists($table, $tables)) { - $tables[$table] = array(); + $tables[$table] = []; } $tables[$table][] = $field; } @@ -277,7 +277,7 @@ public function postProcess() { // CRM-6245: we must pass table/field/length triples to the createIndexes() call below if ($length) { if (!isset($substrLenghts[$table])) { - $substrLenghts[$table] = array(); + $substrLenghts[$table] = []; } //CRM-13417 to avoid fatal error "Incorrect prefix key; the used key part isn't a string, the used length is longer than the key part, or the storage engine doesn't support unique prefix keys, 1089" @@ -288,14 +288,14 @@ public function postProcess() { if ($dao->fetch()) { // set the length to null for all the fields where prefix length is not supported. eg. int,tinyint,date,enum etc dataTypes. - if ($dao->COLUMN_NAME == $field && !in_array($dao->DATA_TYPE, array( + if ($dao->COLUMN_NAME == $field && !in_array($dao->DATA_TYPE, [ 'char', 'varchar', 'binary', 'varbinary', 'text', 'blob', - )) + ]) ) { $length = NULL; } @@ -319,7 +319,7 @@ public function postProcess() { CRM_Core_BAO_PrevNextCache::deleteItem(NULL, $cacheKey); - CRM_Core_Session::setStatus(ts("The rule '%1' has been saved.", array(1 => $rgDao->title)), ts('Saved'), 'success'); + CRM_Core_Session::setStatus(ts("The rule '%1' has been saved.", [1 => $rgDao->title]), ts('Saved'), 'success'); } } diff --git a/CRM/Contact/Form/Domain.php b/CRM/Contact/Form/Domain.php index 472bb00b09aa..dcd9eb914677 100644 --- a/CRM/Contact/Form/Domain.php +++ b/CRM/Contact/Form/Domain.php @@ -62,7 +62,7 @@ class CRM_Contact_Form_Domain extends CRM_Core_Form { * * @var array */ - protected $_locationDefaults = array(); + protected $_locationDefaults = []; /** * How many locationBlocks should we display? @@ -111,8 +111,8 @@ public function preProcess() { * */ public function setDefaultValues() { - $defaults = array(); - $params = array(); + $defaults = []; + $params = []; if (isset($this->_id)) { $params['id'] = $this->_id; @@ -120,7 +120,7 @@ public function setDefaultValues() { $this->_contactId = $domainDefaults['contact_id']; unset($params['id']); - $locParams = array('contact_id' => $domainDefaults['contact_id']); + $locParams = ['contact_id' => $domainDefaults['contact_id']]; $this->_locationDefaults = $defaults = CRM_Core_BAO_Location::getValues($locParams); $config = CRM_Core_Config::singleton(); @@ -141,24 +141,24 @@ public function setDefaultValues() { * Build the form object. */ public function buildQuickForm() { - $this->addField('name', array('label' => ts('Organization Name')), TRUE); - $this->addField('description', array('label' => ts('Description'), 'size' => 30)); + $this->addField('name', ['label' => ts('Organization Name')], TRUE); + $this->addField('description', ['label' => ts('Description'), 'size' => 30]); //build location blocks. CRM_Contact_Form_Location::buildQuickForm($this); - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => ts('Save'), 'subName' => 'view', 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - )); + ], + ]); if ($this->_action & CRM_Core_Action::VIEW) { $this->freeze(); @@ -170,7 +170,7 @@ public function buildQuickForm() { * Add local and global form rules. */ public function addRules() { - $this->addFormRule(array('CRM_Contact_Form_Domain', 'formRule')); + $this->addFormRule(['CRM_Contact_Form_Domain', 'formRule']); } /** @@ -188,7 +188,7 @@ public static function formRule($fields) { // $errors === TRUE means no errors from above formRule excution, // so declaring $errors to array for further processing if ($errors === TRUE) { - $errors = array(); + $errors = []; } if ($fields['name'] == 'Default Domain Name') { @@ -230,15 +230,15 @@ public function postProcess() { $params['email'][1]['location_type_id'] = $defaultLocationType->id; } - $params += array('contact_id' => $this->_contactId); - $contactParams = array( + $params += ['contact_id' => $this->_contactId]; + $contactParams = [ 'sort_name' => $domain->name, 'display_name' => $domain->name, 'legal_name' => $domain->name, 'organization_name' => $domain->name, 'contact_id' => $this->_contactId, 'contact_type' => 'Organization', - ); + ]; if ($this->_contactId) { $contactParams['contact_sub_type'] = CRM_Contact_BAO_Contact::getContactSubType($this->_contactId); @@ -249,7 +249,7 @@ public function postProcess() { CRM_Core_BAO_Domain::edit($params, $this->_id); - CRM_Core_Session::setStatus(ts("Domain information for '%1' has been saved.", array(1 => $domain->name)), ts('Saved'), 'success'); + CRM_Core_Session::setStatus(ts("Domain information for '%1' has been saved.", [1 => $domain->name]), ts('Saved'), 'success'); $session = CRM_Core_Session::singleton(); $session->replaceUserContext(CRM_Utils_System::url('civicrm/admin', 'reset=1')); } diff --git a/CRM/Contact/Form/Edit/Address.php b/CRM/Contact/Form/Edit/Address.php index 2e9148007169..2420f8bdda10 100644 --- a/CRM/Contact/Form/Edit/Address.php +++ b/CRM/Contact/Form/Edit/Address.php @@ -58,40 +58,40 @@ public static function buildQuickForm(&$form, $addressBlockCount = NULL, $sharin $form->applyFilter('__ALL__', 'trim'); - $js = array(); + $js = []; if (!$inlineEdit) { - $js = array('onChange' => 'checkLocation( this.id );', 'placeholder' => NULL); + $js = ['onChange' => 'checkLocation( this.id );', 'placeholder' => NULL]; } //make location type required for inline edit - $form->addField("address[$blockId][location_type_id]", array('entity' => 'address', 'class' => 'eight', 'option_url' => NULL) + $js, $inlineEdit); + $form->addField("address[$blockId][location_type_id]", ['entity' => 'address', 'class' => 'eight', 'option_url' => NULL] + $js, $inlineEdit); if (!$inlineEdit) { - $js = array('id' => 'Address_' . $blockId . '_IsPrimary', 'onClick' => 'singleSelect( this.id );'); + $js = ['id' => 'Address_' . $blockId . '_IsPrimary', 'onClick' => 'singleSelect( this.id );']; } $form->addField( - "address[$blockId][is_primary]", array( + "address[$blockId][is_primary]", [ 'entity' => 'address', 'label' => ts('Primary location for this contact'), - 'text' => ts('Primary location for this contact')) + $js); + 'text' => ts('Primary location for this contact')] + $js); if (!$inlineEdit) { - $js = array('id' => 'Address_' . $blockId . '_IsBilling', 'onClick' => 'singleSelect( this.id );'); + $js = ['id' => 'Address_' . $blockId . '_IsBilling', 'onClick' => 'singleSelect( this.id );']; } $form->addField( - "address[$blockId][is_billing]", array( + "address[$blockId][is_billing]", [ 'entity' => 'address', 'label' => ts('Billing location for this contact'), - 'text' => ts('Billing location for this contact')) + $js); + 'text' => ts('Billing location for this contact')] + $js); // hidden element to store master address id - $form->addField("address[$blockId][master_id]", array('entity' => 'address', 'type' => 'hidden')); + $form->addField("address[$blockId][master_id]", ['entity' => 'address', 'type' => 'hidden']); $addressOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'address_options', TRUE, NULL, TRUE ); - $elements = array( + $elements = [ 'address_name', 'street_address', 'supplemental_address_1', @@ -108,7 +108,7 @@ public static function buildQuickForm(&$form, $addressBlockCount = NULL, $sharin 'street_number', 'street_name', 'street_unit', - ); + ]; foreach ($elements as $name) { //Remove id from name, to allow comparison against enabled addressOptions. @@ -117,11 +117,11 @@ public static function buildQuickForm(&$form, $addressBlockCount = NULL, $sharin if (empty($addressOptions[$nameWithoutID])) { $continue = TRUE; //Don't skip street parsed fields when parsing is enabled. - if (in_array($nameWithoutID, array( + if (in_array($nameWithoutID, [ 'street_number', 'street_name', 'street_unit', - )) && !empty($addressOptions['street_address_parsing']) + ]) && !empty($addressOptions['street_address_parsing']) ) { $continue = FALSE; } @@ -133,7 +133,7 @@ public static function buildQuickForm(&$form, $addressBlockCount = NULL, $sharin $name = 'name'; } - $params = array('entity' => 'address'); + $params = ['entity' => 'address']; if ($name == 'postal_code_suffix') { $params['label'] = ts('Suffix'); @@ -183,10 +183,10 @@ public static function buildQuickForm(&$form, $addressBlockCount = NULL, $sharin * @return array|bool * if no errors */ - public static function formRule($fields, $files = array(), $self = NULL) { - $errors = array(); + public static function formRule($fields, $files = [], $self = NULL) { + $errors = []; - $customDataRequiredFields = array(); + $customDataRequiredFields = []; if ($self && property_exists($self, '_addressRequireOmission')) { $customDataRequiredFields = explode(',', $self->_addressRequireOmission); } @@ -240,14 +240,14 @@ public static function formRule($fields, $files = array(), $self = NULL) { * Form object. */ public static function setDefaultValues(&$defaults, &$form) { - $addressValues = array(); + $addressValues = []; if (isset($defaults['address']) && is_array($defaults['address']) && !CRM_Utils_System::isNull($defaults['address']) ) { // start of contact shared adddress defaults - $sharedAddresses = array(); - $masterAddress = array(); + $sharedAddresses = []; + $masterAddress = []; // get contact name of shared contact names $shareAddressContactNames = CRM_Contact_BAO_Contact_Utils::getAddressShareContactNames($defaults['address']); @@ -255,15 +255,15 @@ public static function setDefaultValues(&$defaults, &$form) { foreach ($defaults['address'] as $key => $addressValue) { if (!empty($addressValue['master_id']) && !$shareAddressContactNames[$addressValue['master_id']]['is_deleted']) { $master_cid = $shareAddressContactNames[$addressValue['master_id']]['contact_id']; - $sharedAddresses[$key]['shared_address_display'] = array( + $sharedAddresses[$key]['shared_address_display'] = [ 'address' => $addressValue['display'], 'name' => $shareAddressContactNames[$addressValue['master_id']]['name'], - 'options' => CRM_Core_BAO_Address::getValues(array( + 'options' => CRM_Core_BAO_Address::getValues([ 'entity_id' => $master_cid, 'contact_id' => $master_cid, - )), + ]), 'master_id' => $addressValue['master_id'], - ); + ]; $defaults['address'][$key]['master_contact_id'] = $master_cid; } else { @@ -281,19 +281,19 @@ public static function setDefaultValues(&$defaults, &$form) { // start of parse address functionality // build street address, CRM-5450. if ($form->_parseStreetAddress) { - $parseFields = array('street_address', 'street_number', 'street_name', 'street_unit'); + $parseFields = ['street_address', 'street_number', 'street_name', 'street_unit']; foreach ($defaults['address'] as $cnt => & $address) { $streetAddress = NULL; - foreach (array( + foreach ([ 'street_number', 'street_number_suffix', 'street_name', 'street_unit', - ) as $fld) { - if (in_array($fld, array( + ] as $fld) { + if (in_array($fld, [ 'street_name', 'street_unit', - ))) { + ])) { $streetAddress .= ' '; } // CRM-17619 - if the street number suffix begins with a number, add a space @@ -324,7 +324,7 @@ public static function setDefaultValues(&$defaults, &$form) { $addressValues["{$field}_{$cnt}"] = CRM_Utils_Array::value($field, $address); } // don't load fields, use js to populate. - foreach (array('street_number', 'street_name', 'street_unit') as $f) { + foreach (['street_number', 'street_name', 'street_unit'] as $f) { if (isset($address[$f])) { unset($address[$f]); } @@ -333,12 +333,12 @@ public static function setDefaultValues(&$defaults, &$form) { $form->assign('allAddressFieldValues', json_encode($addressValues)); //hack to handle show/hide address fields. - $parsedAddress = array(); + $parsedAddress = []; if ($form->_contactId && !empty($_POST['address']) && is_array($_POST['address']) ) { foreach ($_POST['address'] as $cnt => $values) { $showField = 'streetAddress'; - foreach (array('street_number', 'street_name', 'street_unit') as $fld) { + foreach (['street_number', 'street_name', 'street_unit'] as $fld) { if (!empty($values[$fld])) { $showField = 'addressElements'; break; @@ -361,7 +361,7 @@ public static function setDefaultValues(&$defaults, &$form) { * @param array $groupTree */ public static function storeRequiredCustomDataInfo(&$form, $groupTree) { - if (in_array(CRM_Utils_System::getClassName($form), array('CRM_Contact_Form_Contact', 'CRM_Contact_Form_Inline_Address'))) { + if (in_array(CRM_Utils_System::getClassName($form), ['CRM_Contact_Form_Contact', 'CRM_Contact_Form_Inline_Address'])) { $requireOmission = NULL; foreach ($groupTree as $csId => $csVal) { // only process Address entity fields @@ -406,11 +406,11 @@ protected static function addCustomDataToForm(&$form, $entityId, $blockId) { } } - $defaults = array(); + $defaults = []; CRM_Core_BAO_CustomGroup::setDefaults($groupTree, $defaults); // since we change element name for address custom data, we need to format the setdefault values - $addressDefaults = array(); + $addressDefaults = []; foreach ($defaults as $key => $val) { if (!isset($val)) { continue; @@ -435,9 +435,9 @@ protected static function addCustomDataToForm(&$form, $entityId, $blockId) { $tplGroupTree = CRM_Core_Smarty::singleton() ->get_template_vars('address_groupTree'); - $tplGroupTree = empty($tplGroupTree) ? array() : $tplGroupTree; + $tplGroupTree = empty($tplGroupTree) ? [] : $tplGroupTree; - $form->assign('address_groupTree', $tplGroupTree + array($blockId => $groupTree)); + $form->assign('address_groupTree', $tplGroupTree + [$blockId => $groupTree]); // unset the temp smarty var that got created $form->assign('dnc_groupTree', NULL); } diff --git a/CRM/Contact/Form/Edit/CommunicationPreferences.php b/CRM/Contact/Form/Edit/CommunicationPreferences.php index 531a749d8444..dddb5d58d39f 100644 --- a/CRM/Contact/Form/Edit/CommunicationPreferences.php +++ b/CRM/Contact/Form/Edit/CommunicationPreferences.php @@ -41,7 +41,7 @@ class CRM_Contact_Form_Edit_CommunicationPreferences { * * @var array */ - static $greetings = array(); + static $greetings = []; /** * Build the form object elements for Communication Preferences object. @@ -55,7 +55,7 @@ public static function buildQuickForm(&$form) { // checkboxes for DO NOT phone, email, mail // we take labels from SelectValues - $privacy = $commPreff = $commPreference = array(); + $privacy = $commPreff = $commPreference = []; $privacyOptions = CRM_Core_SelectValues::privacy(); // we add is_opt_out as a separate checkbox below for display and help purposes so remove it here @@ -67,12 +67,12 @@ public static function buildQuickForm(&$form) { $form->addGroup($privacy, 'privacy', ts('Privacy'), ' 
'); // preferred communication method - $comm = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'preferred_communication_method', array('loclize' => TRUE)); + $comm = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'preferred_communication_method', ['loclize' => TRUE]); foreach ($comm as $value => $title) { $commPreff[] = $form->createElement('advcheckbox', $value, NULL, $title); } - $form->addField('preferred_communication_method', array('entity' => 'contact', 'type' => 'CheckBoxGroup')); - $form->addField('preferred_language', array('entity' => 'contact')); + $form->addField('preferred_communication_method', ['entity' => 'contact', 'type' => 'CheckBoxGroup']); + $form->addField('preferred_language', ['entity' => 'contact']); if (!empty($privacyOptions)) { $commPreference['privacy'] = $privacyOptions; @@ -84,27 +84,27 @@ public static function buildQuickForm(&$form) { //using for display purpose. $form->assign('commPreference', $commPreference); - $form->addField('preferred_mail_format', array('entity' => 'contact', 'label' => ts('Email Format'))); + $form->addField('preferred_mail_format', ['entity' => 'contact', 'label' => ts('Email Format')]); - $form->addField('is_opt_out', array('entity' => 'contact', 'label' => ts('NO BULK EMAILS (User Opt Out)'))); + $form->addField('is_opt_out', ['entity' => 'contact', 'label' => ts('NO BULK EMAILS (User Opt Out)')]); - $form->addField('communication_style_id', array('entity' => 'contact', 'type' => 'RadioGroup')); + $form->addField('communication_style_id', ['entity' => 'contact', 'type' => 'RadioGroup']); //check contact type and build filter clause accordingly for greeting types, CRM-4575 $greetings = self::getGreetingFields($form->_contactType); foreach ($greetings as $greeting => $fields) { - $filter = array( + $filter = [ 'contact_type' => $form->_contactType, 'greeting_type' => $greeting, - ); + ]; //add addressee in Contact form $greetingTokens = CRM_Core_PseudoConstant::greeting($filter); if (!empty($greetingTokens)) { $form->addElement('select', $fields['field'], $fields['label'], - array( + [ '' => ts('- select -'), - ) + $greetingTokens + ] + $greetingTokens ); //custom addressee $form->addElement('text', $fields['customField'], $fields['customLabel'], @@ -134,7 +134,7 @@ public static function formRule($fields, $files, $self) { $customizedValue = CRM_Core_PseudoConstant::getKey('CRM_Contact_BAO_Contact', $details['field'], 'Customized'); if (CRM_Utils_Array::value($details['field'], $fields) == $customizedValue && empty($fields[$details['customField']])) { $errors[$details['customField']] = ts('Custom %1 is a required field if %1 is of type Customized.', - array(1 => $details['label']) + [1 => $details['label']] ); } } @@ -202,36 +202,36 @@ public static function setDefaultValues(&$form, &$defaults) { */ public static function getGreetingFields($contactType) { if (empty(self::$greetings[$contactType])) { - self::$greetings[$contactType] = array(); + self::$greetings[$contactType] = []; - $js = array( + $js = [ 'onfocus' => "if (!this.value) { this.value='Dear ';} else return false", 'onblur' => "if ( this.value == 'Dear') { this.value='';} else return false", - ); + ]; - self::$greetings[$contactType] = array( - 'addressee' => array( + self::$greetings[$contactType] = [ + 'addressee' => [ 'field' => 'addressee_id', 'customField' => 'addressee_custom', 'label' => ts('Addressee'), 'customLabel' => ts('Custom Addressee'), 'js' => NULL, - ), - 'email_greeting' => array( + ], + 'email_greeting' => [ 'field' => 'email_greeting_id', 'customField' => 'email_greeting_custom', 'label' => ts('Email Greeting'), 'customLabel' => ts('Custom Email Greeting'), 'js' => $js, - ), - 'postal_greeting' => array( + ], + 'postal_greeting' => [ 'field' => 'postal_greeting_id', 'customField' => 'postal_greeting_custom', 'label' => ts('Postal Greeting'), 'customLabel' => ts('Custom Postal Greeting'), 'js' => $js, - ), - ); + ], + ]; } return self::$greetings[$contactType]; diff --git a/CRM/Contact/Form/Edit/Demographics.php b/CRM/Contact/Form/Edit/Demographics.php index 758233de48c0..0a2105a94adc 100644 --- a/CRM/Contact/Form/Edit/Demographics.php +++ b/CRM/Contact/Form/Edit/Demographics.php @@ -43,12 +43,12 @@ class CRM_Contact_Form_Edit_Demographics { * Reference to the form object. */ public static function buildQuickForm(&$form) { - $form->addField('gender_id', array('entity' => 'contact', 'type' => 'Radio', 'allowClear' => TRUE)); + $form->addField('gender_id', ['entity' => 'contact', 'type' => 'Radio', 'allowClear' => TRUE]); - $form->addField('birth_date', array('entity' => 'contact'), FALSE, FALSE); + $form->addField('birth_date', ['entity' => 'contact'], FALSE, FALSE); - $form->addField('is_deceased', array('entity' => 'contact', 'label' => ts('Contact is Deceased'), 'onclick' => "showDeceasedDate()")); - $form->addField('deceased_date', array('entity' => 'contact'), FALSE, FALSE); + $form->addField('is_deceased', ['entity' => 'contact', 'label' => ts('Contact is Deceased'), 'onclick' => "showDeceasedDate()"]); + $form->addField('deceased_date', ['entity' => 'contact'], FALSE, FALSE); } /** diff --git a/CRM/Contact/Form/Edit/Email.php b/CRM/Contact/Form/Edit/Email.php index 6a4d1bdc7d41..91ddeffea012 100644 --- a/CRM/Contact/Form/Edit/Email.php +++ b/CRM/Contact/Form/Edit/Email.php @@ -58,38 +58,38 @@ public static function buildQuickForm(&$form, $blockCount = NULL, $blockEdit = F $form->applyFilter('__ALL__', 'trim'); //Email box - $form->addField("email[$blockId][email]", array('entity' => 'email', 'aria-label' => ts('Email %1', [1 => $blockId]))); + $form->addField("email[$blockId][email]", ['entity' => 'email', 'aria-label' => ts('Email %1', [1 => $blockId])]); $form->addRule("email[$blockId][email]", ts('Email is not valid.'), 'email'); if (isset($form->_contactType) || $blockEdit) { //Block type - $form->addField("email[$blockId][location_type_id]", array('entity' => 'email', 'placeholder' => NULL, 'class' => 'eight', 'option_url' => NULL)); + $form->addField("email[$blockId][location_type_id]", ['entity' => 'email', 'placeholder' => NULL, 'class' => 'eight', 'option_url' => NULL]); //TODO: Refactor on_hold field to select. $multipleBulk = CRM_Core_BAO_Email::isMultipleBulkMail(); //On-hold select if ($multipleBulk) { - $holdOptions = array( + $holdOptions = [ 0 => ts('- select -'), 1 => ts('On Hold Bounce'), 2 => ts('On Hold Opt Out'), - ); + ]; $form->addElement('select', "email[$blockId][on_hold]", '', $holdOptions); } else { - $form->addField("email[$blockId][on_hold]", array('entity' => 'email', 'type' => 'advcheckbox', 'aria-label' => ts('On Hold for Email %1?', [1 => $blockId]))); + $form->addField("email[$blockId][on_hold]", ['entity' => 'email', 'type' => 'advcheckbox', 'aria-label' => ts('On Hold for Email %1?', [1 => $blockId])]); } //Bulkmail checkbox $form->assign('multipleBulk', $multipleBulk); - $js = array('id' => "Email_" . $blockId . "_IsBulkmail" , 'aria-label' => ts('Bulk Mailing for Email %1?', [1 => $blockId])); + $js = ['id' => "Email_" . $blockId . "_IsBulkmail" , 'aria-label' => ts('Bulk Mailing for Email %1?', [1 => $blockId])]; if (!$blockEdit) { $js['onClick'] = 'singleSelect( this.id );'; } $form->addElement('advcheckbox', "email[$blockId][is_bulkmail]", NULL, '', $js); //is_Primary radio - $js = array('id' => "Email_" . $blockId . "_IsPrimary", 'aria-label' => ts('Email %1 is primary?', [1 => $blockId])); + $js = ['id' => "Email_" . $blockId . "_IsPrimary", 'aria-label' => ts('Email %1 is primary?', [1 => $blockId])]; if (!$blockEdit) { $js['onClick'] = 'singleSelect( this.id );'; } @@ -99,11 +99,11 @@ public static function buildQuickForm(&$form, $blockCount = NULL, $blockEdit = F if (CRM_Utils_System::getClassName($form) == 'CRM_Contact_Form_Contact') { $form->add('textarea', "email[$blockId][signature_text]", ts('Signature (Text)'), - array('rows' => 2, 'cols' => 40) + ['rows' => 2, 'cols' => 40] ); $form->add('wysiwyg', "email[$blockId][signature_html]", ts('Signature (HTML)'), - array('rows' => 2, 'cols' => 40) + ['rows' => 2, 'cols' => 40] ); } } diff --git a/CRM/Contact/Form/Edit/Household.php b/CRM/Contact/Form/Edit/Household.php index c09c3d1a6059..1d9fc60fdf3e 100644 --- a/CRM/Contact/Form/Edit/Household.php +++ b/CRM/Contact/Form/Edit/Household.php @@ -58,15 +58,15 @@ public static function buildQuickForm(&$form, $inlineEditMode = NULL) { if (!$inlineEditMode || $inlineEditMode == 2) { // nick_name $form->addField('nick_name'); - $form->addField('contact_source', array('label' => ts('Source'))); + $form->addField('contact_source', ['label' => ts('Source')]); } if (!$inlineEditMode) { - $form->addField('external_identifier', array('label' => ts('External ID'))); + $form->addField('external_identifier', ['label' => ts('External ID')]); $form->addRule('external_identifier', ts('External ID already exists in Database.'), 'objectExists', - array('CRM_Contact_DAO_Contact', $form->_contactId, 'external_identifier') + ['CRM_Contact_DAO_Contact', $form->_contactId, 'external_identifier'] ); } } @@ -84,7 +84,7 @@ public static function buildQuickForm(&$form, $inlineEditMode = NULL) { * $error */ public static function formRule($fields, $files, $contactID = NULL) { - $errors = array(); + $errors = []; $primaryID = CRM_Contact_Form_Contact::formRule($fields, $errors, $contactID, 'Household'); // make sure that household name is set diff --git a/CRM/Contact/Form/Edit/IM.php b/CRM/Contact/Form/Edit/IM.php index 242426e4f9ee..78781d8c2242 100644 --- a/CRM/Contact/Form/Edit/IM.php +++ b/CRM/Contact/Form/Edit/IM.php @@ -56,14 +56,14 @@ public static function buildQuickForm(&$form, $blockCount = NULL, $blockEdit = F $form->applyFilter('__ALL__', 'trim'); //IM provider select - $form->addField("im[$blockId][provider_id]", array('entity' => 'im', 'class' => 'eight', 'placeholder' => NULL)); + $form->addField("im[$blockId][provider_id]", ['entity' => 'im', 'class' => 'eight', 'placeholder' => NULL]); //Block type select - $form->addField("im[$blockId][location_type_id]", array('entity' => 'im', 'class' => 'eight', 'placeholder' => NULL, 'option_url' => NULL)); + $form->addField("im[$blockId][location_type_id]", ['entity' => 'im', 'class' => 'eight', 'placeholder' => NULL, 'option_url' => NULL]); //IM box - $form->addField("im[$blockId][name]", array('entity' => 'im', 'aria-label' => ts('Instant Messenger %1', [1 => $blockId]))); + $form->addField("im[$blockId][name]", ['entity' => 'im', 'aria-label' => ts('Instant Messenger %1', [1 => $blockId])]); //is_Primary radio - $js = array('id' => 'IM_' . $blockId . '_IsPrimary', 'aria-label' => ts('Instant Messenger %1 is primary?', [1 => $blockId])); + $js = ['id' => 'IM_' . $blockId . '_IsPrimary', 'aria-label' => ts('Instant Messenger %1 is primary?', [1 => $blockId])]; if (!$blockEdit) { $js['onClick'] = 'singleSelect( this.id );'; } diff --git a/CRM/Contact/Form/Edit/Individual.php b/CRM/Contact/Form/Edit/Individual.php index 3534dca7c8f1..d39c7d95e8e1 100644 --- a/CRM/Contact/Form/Edit/Individual.php +++ b/CRM/Contact/Form/Edit/Individual.php @@ -69,10 +69,10 @@ public static function buildQuickForm(&$form, $inlineEditMode = NULL) { } foreach ($nameFields as $name) { - $props = array(); + $props = []; if ($name == 'prefix_id' || $name == 'suffix_id') { //override prefix/suffix label name as Prefix/Suffix respectively and adjust select size - $props = array('class' => 'eight', 'placeholder' => ' ', 'label' => $name == 'prefix_id' ? ts('Prefix') : ts('Suffix')); + $props = ['class' => 'eight', 'placeholder' => ' ', 'label' => $name == 'prefix_id' ? ts('Prefix') : ts('Suffix')]; } $form->addField($name, $props); } @@ -84,25 +84,25 @@ public static function buildQuickForm(&$form, $inlineEditMode = NULL) { // job title // override the size for UI to look better - $form->addField('job_title', array('size' => '30')); + $form->addField('job_title', ['size' => '30']); //Current Employer Element - $props = array( - 'api' => array('params' => array('contact_type' => 'Organization')), + $props = [ + 'api' => ['params' => ['contact_type' => 'Organization']], 'create' => TRUE, - ); + ]; $form->addField('employer_id', $props); - $form->addField('contact_source', array('class' => 'big')); + $form->addField('contact_source', ['class' => 'big']); } if (!$inlineEditMode) { //External Identifier Element - $form->addField('external_identifier', array('label' => 'External ID')); + $form->addField('external_identifier', ['label' => 'External ID']); $form->addRule('external_identifier', ts('External ID already exists in Database.'), 'objectExists', - array('CRM_Contact_DAO_Contact', $form->_contactId, 'external_identifier') + ['CRM_Contact_DAO_Contact', $form->_contactId, 'external_identifier'] ); CRM_Core_ShowHideBlocks::links($form, 'demographics', '', ''); } @@ -121,7 +121,7 @@ public static function buildQuickForm(&$form, $inlineEditMode = NULL) { * TRUE if no errors, else array of errors. */ public static function formRule($fields, $files, $contactID = NULL) { - $errors = array(); + $errors = []; $primaryID = CRM_Contact_Form_Contact::formRule($fields, $errors, $contactID, 'Individual'); // make sure that firstName and lastName or a primary OpenID is set diff --git a/CRM/Contact/Form/Edit/Lock.php b/CRM/Contact/Form/Edit/Lock.php index c2746fe95604..c844b8cea5e4 100644 --- a/CRM/Contact/Form/Edit/Lock.php +++ b/CRM/Contact/Form/Edit/Lock.php @@ -43,7 +43,7 @@ class CRM_Contact_Form_Edit_Lock { * Form object. */ public static function buildQuickForm(&$form) { - $form->addField('modified_date', array('type' => 'hidden', 'id' => 'modified_date', 'label' => '')); + $form->addField('modified_date', ['type' => 'hidden', 'id' => 'modified_date', 'label' => '']); } /** @@ -59,7 +59,7 @@ public static function buildQuickForm(&$form) { * true if no errors, else array of errors */ public static function formRule($fields, $files, $contactID = NULL) { - $errors = array(); + $errors = []; $timestamps = CRM_Contact_BAO_Contact::getTimestamps($contactID); if ($fields['modified_date'] != $timestamps['modified_date']) { diff --git a/CRM/Contact/Form/Edit/Notes.php b/CRM/Contact/Form/Edit/Notes.php index a23078fb1236..d926847685d7 100644 --- a/CRM/Contact/Form/Edit/Notes.php +++ b/CRM/Contact/Form/Edit/Notes.php @@ -39,8 +39,8 @@ class CRM_Contact_Form_Edit_Notes { */ public static function buildQuickForm(&$form) { $form->applyFilter('__ALL__', 'trim'); - $form->addField('subject', array('entity' => 'note', 'size' => '60')); - $form->addField('note', array('entity' => 'note', 'rows' => 3)); + $form->addField('subject', ['entity' => 'note', 'size' => '60']); + $form->addField('note', ['entity' => 'note', 'rows' => 3]); } } diff --git a/CRM/Contact/Form/Edit/OpenID.php b/CRM/Contact/Form/Edit/OpenID.php index 1f3f70d45786..2d4ab2ca0c6d 100644 --- a/CRM/Contact/Form/Edit/OpenID.php +++ b/CRM/Contact/Form/Edit/OpenID.php @@ -64,7 +64,7 @@ public static function buildQuickForm(&$form, $blockCount = NULL, $blockEdit = F $form->addElement('select', "openid[$blockId][location_type_id]", '', CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id')); //is_Primary radio - $js = array('id' => "OpenID_" . $blockId . "_IsPrimary"); + $js = ['id' => "OpenID_" . $blockId . "_IsPrimary"]; if (!$blockEdit) { $js['onClick'] = 'singleSelect( this.id );'; } diff --git a/CRM/Contact/Form/Edit/Organization.php b/CRM/Contact/Form/Edit/Organization.php index b2fbc22b2ccf..05ae544a4f9d 100644 --- a/CRM/Contact/Form/Edit/Organization.php +++ b/CRM/Contact/Form/Edit/Organization.php @@ -68,11 +68,11 @@ public static function buildQuickForm(&$form, $inlineEditMode = NULL) { } if (!$inlineEditMode) { - $form->addField('external_identifier', array('label' => ts('External ID'))); + $form->addField('external_identifier', ['label' => ts('External ID')]); $form->addRule('external_identifier', ts('External ID already exists in Database.'), 'objectExists', - array('CRM_Contact_DAO_Contact', $form->_contactId, 'external_identifier') + ['CRM_Contact_DAO_Contact', $form->_contactId, 'external_identifier'] ); } } @@ -85,7 +85,7 @@ public static function buildQuickForm(&$form, $inlineEditMode = NULL) { * @return array|bool */ public static function formRule($fields, $files, $contactID = NULL) { - $errors = array(); + $errors = []; $primaryID = CRM_Contact_Form_Contact::formRule($fields, $errors, $contactID, 'Organization'); // make sure that organization name is set diff --git a/CRM/Contact/Form/Edit/Phone.php b/CRM/Contact/Form/Edit/Phone.php index d7e2b72d9338..0a881f3f9502 100644 --- a/CRM/Contact/Form/Edit/Phone.php +++ b/CRM/Contact/Form/Edit/Phone.php @@ -58,25 +58,25 @@ public static function buildQuickForm(&$form, $addressBlockCount = NULL, $blockE $form->applyFilter('__ALL__', 'trim'); //phone type select - $form->addField("phone[$blockId][phone_type_id]", array( + $form->addField("phone[$blockId][phone_type_id]", [ 'entity' => 'phone', 'class' => 'eight', 'placeholder' => NULL, - )); + ]); //main phone number with crm_phone class - $form->addField("phone[$blockId][phone]", array('entity' => 'phone', 'class' => 'crm_phone twelve', 'aria-label' => ts('Phone %1', [1 => $blockId]))); - $form->addField("phone[$blockId][phone_ext]", array('entity' => 'phone', 'aria-label' => ts('Phone Extension %1', [1 => $blockId]))); + $form->addField("phone[$blockId][phone]", ['entity' => 'phone', 'class' => 'crm_phone twelve', 'aria-label' => ts('Phone %1', [1 => $blockId])]); + $form->addField("phone[$blockId][phone_ext]", ['entity' => 'phone', 'aria-label' => ts('Phone Extension %1', [1 => $blockId])]); if (isset($form->_contactType) || $blockEdit) { //Block type select - $form->addField("phone[$blockId][location_type_id]", array( + $form->addField("phone[$blockId][location_type_id]", [ 'entity' => 'phone', 'class' => 'eight', 'placeholder' => NULL, 'option_url' => NULL, - )); + ]); //is_Primary radio - $js = array('id' => 'Phone_' . $blockId . '_IsPrimary', 'onClick' => 'singleSelect( this.id );', 'aria-label' => ts('Phone %1 is primary?', [1 => $blockId])); + $js = ['id' => 'Phone_' . $blockId . '_IsPrimary', 'onClick' => 'singleSelect( this.id );', 'aria-label' => ts('Phone %1 is primary?', [1 => $blockId])]; $form->addElement('radio', "phone[$blockId][is_primary]", '', '', '1', $js); } // TODO: set this up as a group, we need a valid phone_type_id if we have a phone number diff --git a/CRM/Contact/Form/Edit/TagsAndGroups.php b/CRM/Contact/Form/Edit/TagsAndGroups.php index 2622b7895898..b89c3a023e9e 100644 --- a/CRM/Contact/Form/Edit/TagsAndGroups.php +++ b/CRM/Contact/Form/Edit/TagsAndGroups.php @@ -73,7 +73,7 @@ public static function buildQuickForm( $groupElementType = 'checkbox' ) { if (!isset($form->_tagGroup)) { - $form->_tagGroup = array(); + $form->_tagGroup = []; } // NYSS 5670 @@ -91,7 +91,7 @@ public static function buildQuickForm( $groupID = isset($form->_grid) ? $form->_grid : NULL; if ($groupID && $visibility) { - $ids = array($groupID => $groupID); + $ids = [$groupID => $groupID]; } else { if ($visibility) { @@ -107,8 +107,8 @@ public static function buildQuickForm( $groups = CRM_Contact_BAO_Group::getGroupsHierarchy($ids); $attributes['skiplabel'] = TRUE; - $elements = array(); - $groupsOptions = array(); + $elements = []; + $groupsOptions = []; foreach ($groups as $id => $group) { // make sure that this group has public visibility if ($visibility && @@ -128,7 +128,7 @@ public static function buildQuickForm( if ($groupElementType == 'select' && !empty($groupsOptions)) { $form->add('select', $fName, $groupName, $groupsOptions, FALSE, - array('id' => $fName, 'multiple' => 'multiple', 'class' => 'crm-select2 twenty') + ['id' => $fName, 'multiple' => 'multiple', 'class' => 'crm-select2 twenty'] ); $form->assign('groupCount', count($groupsOptions)); } @@ -137,7 +137,7 @@ public static function buildQuickForm( $form->addGroup($elements, $fName, $groupName, ' 
'); $form->assign('groupCount', count($elements)); if ($isRequired) { - $form->addRule($fName, ts('%1 is a required field.', array(1 => $groupName)), 'required'); + $form->addRule($fName, ts('%1 is a required field.', [1 => $groupName]), 'required'); } } $form->assign('groupElementType', $groupElementType); @@ -148,7 +148,7 @@ public static function buildQuickForm( $tags = CRM_Core_BAO_Tag::getColorTags('civicrm_contact'); if (!empty($tags)) { - $form->add('select2', 'tag', ts('Tag(s)'), $tags, FALSE, array('class' => 'huge', 'placeholder' => ts('- select -'), 'multiple' => TRUE)); + $form->add('select2', 'tag', ts('Tag(s)'), $tags, FALSE, ['class' => 'huge', 'placeholder' => ts('- select -'), 'multiple' => TRUE]); } // build tag widget diff --git a/CRM/Contact/Form/Edit/Website.php b/CRM/Contact/Form/Edit/Website.php index fb798a044a6f..8930e9956c2d 100644 --- a/CRM/Contact/Form/Edit/Website.php +++ b/CRM/Contact/Form/Edit/Website.php @@ -55,10 +55,10 @@ public static function buildQuickForm(&$form, $blockCount = NULL) { $form->applyFilter('__ALL__', 'trim'); //Website type select - $form->addField("website[$blockId][website_type_id]", array('entity' => 'website', 'class' => 'eight', 'placeholder' => NULL)); + $form->addField("website[$blockId][website_type_id]", ['entity' => 'website', 'class' => 'eight', 'placeholder' => NULL]); //Website box - $form->addField("website[$blockId][url]", array('entity' => 'website', 'aria-label' => ts('Website URL %1', [1 => $blockId]))); + $form->addField("website[$blockId][url]", ['entity' => 'website', 'aria-label' => ts('Website URL %1', [1 => $blockId])]); $form->addRule("website[$blockId][url]", ts('Enter a valid web address beginning with \'http://\' or \'https://\'.'), 'url'); } diff --git a/CRM/Contact/Form/GroupContact.php b/CRM/Contact/Form/GroupContact.php index 0a628244af89..522121091811 100644 --- a/CRM/Contact/Form/GroupContact.php +++ b/CRM/Contact/Form/GroupContact.php @@ -83,7 +83,7 @@ public function buildQuickForm() { $ids = CRM_Core_PseudoConstant::allGroup(); $heirGroups = CRM_Contact_BAO_Group::getGroupsHierarchy($ids); - $allGroups = array(); + $allGroups = []; foreach ($heirGroups as $id => $group) { // make sure that this group has public visibility if ($onlyPublicGroups && $group['visibility'] == 'User and User Admin Only') { @@ -111,7 +111,7 @@ public function buildQuickForm() { $groupSelect = $groupHierarchy; } - $groupSelect = array('' => ts('- select group -')) + $groupSelect; + $groupSelect = ['' => ts('- select group -')] + $groupSelect; if (count($groupSelect) > 1) { $session = CRM_Core_Session::singleton(); @@ -123,15 +123,15 @@ public function buildQuickForm() { $msg = ts('Add to a group'); } - $this->addField('group_id', array('class' => 'crm-action-menu fa-plus', 'placeholder' => $msg, 'options' => $groupSelect)); + $this->addField('group_id', ['class' => 'crm-action-menu fa-plus', 'placeholder' => $msg, 'options' => $groupSelect]); - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => ts('Add'), 'isDefault' => TRUE, - ), - ) + ], + ] ); } } @@ -140,7 +140,7 @@ public function buildQuickForm() { * Post process form. */ public function postProcess() { - $contactID = array($this->_contactId); + $contactID = [$this->_contactId]; $groupId = $this->controller->exportValue('GroupContact', 'group_id'); $method = ($this->_context == 'user') ? 'Web' : 'Admin'; @@ -154,7 +154,7 @@ public function postProcess() { if ($groupContact && $this->_context != 'user') { $groups = CRM_Core_PseudoConstant::group(); - CRM_Core_Session::setStatus(ts("Contact has been added to '%1'.", array(1 => $groups[$groupId])), ts('Added to Group'), 'success'); + CRM_Core_Session::setStatus(ts("Contact has been added to '%1'.", [1 => $groups[$groupId]]), ts('Added to Group'), 'success'); } } diff --git a/CRM/Contact/Form/Inline.php b/CRM/Contact/Form/Inline.php index dbf6413cfd57..541cf814c6bb 100644 --- a/CRM/Contact/Form/Inline.php +++ b/CRM/Contact/Form/Inline.php @@ -96,17 +96,17 @@ public function preProcess() { public function buildQuickForm() { CRM_Contact_Form_Inline_Lock::buildQuickForm($this, $this->_contactId); - $buttons = array( - array( + $buttons = [ + [ 'type' => 'upload', 'name' => ts('Save'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ); + ], + ]; $this->addButtons($buttons); } @@ -114,7 +114,7 @@ public function buildQuickForm() { * Override default cancel action. */ public function cancelAction() { - $response = array('status' => 'cancel'); + $response = ['status' => 'cancel']; CRM_Utils_JSON::output($response); } @@ -124,7 +124,7 @@ public function cancelAction() { * @return array */ public function setDefaultValues() { - $defaults = $params = array(); + $defaults = $params = []; $params['id'] = $this->_contactId; CRM_Contact_BAO_Contact::getValues($params, $defaults); @@ -175,11 +175,11 @@ public static function renderFooter($cid, $includeCount = TRUE) { 'contact_view_options', TRUE ); $smarty->assign('changeLog', $viewOptions['log']); - $ret = array('markup' => $smarty->fetch('CRM/common/contactFooter.tpl')); + $ret = ['markup' => $smarty->fetch('CRM/common/contactFooter.tpl')]; if ($includeCount) { $ret['count'] = CRM_Contact_BAO_Contact::getCountComponent('log', $cid); } - return array('changeLog' => $ret); + return ['changeLog' => $ret]; } } diff --git a/CRM/Contact/Form/Inline/Address.php b/CRM/Contact/Form/Inline/Address.php index ed07ea69837a..3bbd2d28a991 100644 --- a/CRM/Contact/Form/Inline/Address.php +++ b/CRM/Contact/Form/Inline/Address.php @@ -87,12 +87,12 @@ public function preProcess() { $addressSequence = CRM_Core_BAO_Address::addressSequence(); $this->assign('addressSequence', $addressSequence); - $this->_values = array(); + $this->_values = []; $this->_addressId = CRM_Utils_Request::retrieve('aid', 'Positive', $this, FALSE, NULL, $_REQUEST); $this->_action = CRM_Core_Action::ADD; if ($this->_addressId) { - $params = array('id' => $this->_addressId); + $params = ['id' => $this->_addressId]; $address = CRM_Core_BAO_Address::getValues($params, FALSE, 'id'); $this->_values['address'][$this->_locBlockNo] = array_pop($address); $this->_action = CRM_Core_Action::UPDATE; @@ -125,7 +125,7 @@ public function preProcess() { public function buildQuickForm() { parent::buildQuickForm(); CRM_Contact_Form_Edit_Address::buildQuickForm($this, $this->_locBlockNo, TRUE, TRUE); - $this->addFormRule(array('CRM_Contact_Form_Edit_Address', 'formRule'), $this); + $this->addFormRule(['CRM_Contact_Form_Edit_Address', 'formRule'], $this); } /** diff --git a/CRM/Contact/Form/Inline/CommunicationPreferences.php b/CRM/Contact/Form/Inline/CommunicationPreferences.php index 8f4b3358b66c..adbc82f07924 100644 --- a/CRM/Contact/Form/Inline/CommunicationPreferences.php +++ b/CRM/Contact/Form/Inline/CommunicationPreferences.php @@ -42,7 +42,7 @@ class CRM_Contact_Form_Inline_CommunicationPreferences extends CRM_Contact_Form_ public function buildQuickForm() { parent::buildQuickForm(); CRM_Contact_Form_Edit_CommunicationPreferences::buildQuickForm($this); - $this->addFormRule(array('CRM_Contact_Form_Edit_CommunicationPreferences', 'formRule'), $this); + $this->addFormRule(['CRM_Contact_Form_Edit_CommunicationPreferences', 'formRule'], $this); } /** diff --git a/CRM/Contact/Form/Inline/ContactInfo.php b/CRM/Contact/Form/Inline/ContactInfo.php index d33eae986361..55f1a1ddc822 100644 --- a/CRM/Contact/Form/Inline/ContactInfo.php +++ b/CRM/Contact/Form/Inline/ContactInfo.php @@ -73,9 +73,9 @@ public function postProcess() { CRM_Contact_BAO_Contact::create($params); // Saving current employer affects relationship tab, and possibly related memberships and contributions - $this->ajaxResponse['updateTabs'] = array( + $this->ajaxResponse['updateTabs'] = [ '#tab_rel' => CRM_Contact_BAO_Contact::getCountComponent('rel', $this->_contactId), - ); + ]; if (CRM_Core_Permission::access('CiviContribute')) { $this->ajaxResponse['updateTabs']['#tab_contribute'] = CRM_Contact_BAO_Contact::getCountComponent('contribution', $this->_contactId); } diff --git a/CRM/Contact/Form/Inline/ContactName.php b/CRM/Contact/Form/Inline/ContactName.php index 3a9a6db30e8b..2458683ff26f 100644 --- a/CRM/Contact/Form/Inline/ContactName.php +++ b/CRM/Contact/Form/Inline/ContactName.php @@ -45,7 +45,7 @@ public function buildQuickForm() { // Build contact type specific fields $class = 'CRM_Contact_Form_Edit_' . $this->_contactType; $class::buildQuickForm($this, 1); - $this->addFormRule(array('CRM_Contact_Form_Inline_ContactName', 'formRule'), $this); + $this->addFormRule(['CRM_Contact_Form_Inline_ContactName', 'formRule'], $this); } /** @@ -63,7 +63,7 @@ public static function formRule($fields, $errors, $form) { if (empty($fields['first_name']) && empty($fields['last_name']) && empty($fields['organization_name']) && empty($fields['household_name'])) { - $emails = civicrm_api3('Email', 'getcount', array('contact_id' => $form->_contactId)); + $emails = civicrm_api3('Email', 'getcount', ['contact_id' => $form->_contactId]); if (!$emails) { $errorField = $form->_contactType == 'Individual' ? 'last' : strtolower($form->_contactType); $errors[$errorField . '_name'] = ts('Contact with no email must have a name.'); diff --git a/CRM/Contact/Form/Inline/Email.php b/CRM/Contact/Form/Inline/Email.php index 2440f8bb3ccb..f7595e051c36 100644 --- a/CRM/Contact/Form/Inline/Email.php +++ b/CRM/Contact/Form/Inline/Email.php @@ -39,7 +39,7 @@ class CRM_Contact_Form_Inline_Email extends CRM_Contact_Form_Inline { /** * Email addresses of the contact that is been viewed. */ - private $_emails = array(); + private $_emails = []; /** * No of email blocks for inline edit. @@ -104,7 +104,7 @@ public function buildQuickForm() { CRM_Contact_Form_Edit_Email::buildQuickForm($this, $blockId, TRUE); } - $this->addFormRule(array('CRM_Contact_Form_Inline_Email', 'formRule'), $this); + $this->addFormRule(['CRM_Contact_Form_Inline_Email', 'formRule'], $this); } /** @@ -119,7 +119,7 @@ public function buildQuickForm() { * @return array */ public static function formRule($fields, $errors, $form) { - $hasData = $hasPrimary = $errors = array(); + $hasData = $hasPrimary = $errors = []; if (!empty($fields['email']) && is_array($fields['email'])) { foreach ($fields['email'] as $instance => $blockValues) { $dataExists = CRM_Contact_Form_Contact::blockDataExists($blockValues); @@ -152,7 +152,7 @@ public static function formRule($fields, $errors, $form) { * @return array */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; if (!empty($this->_emails)) { foreach ($this->_emails as $id => $value) { $defaults['email'][$id] = $value; @@ -191,7 +191,7 @@ public function postProcess() { if ($email['is_primary']) { CRM_Core_DAO::setFieldValue('CRM_Contact_DAO_Contact', $this->_contactId, 'display_name', $email['email']); CRM_Core_DAO::setFieldValue('CRM_Contact_DAO_Contact', $this->_contactId, 'sort_name', $email['email']); - $this->ajaxResponse['reloadBlocks'] = array('#crm-contactname-content'); + $this->ajaxResponse['reloadBlocks'] = ['#crm-contactname-content']; break; } } diff --git a/CRM/Contact/Form/Inline/IM.php b/CRM/Contact/Form/Inline/IM.php index 991443c59353..a44fbb3c4500 100644 --- a/CRM/Contact/Form/Inline/IM.php +++ b/CRM/Contact/Form/Inline/IM.php @@ -39,7 +39,7 @@ class CRM_Contact_Form_Inline_IM extends CRM_Contact_Form_Inline { /** * Ims of the contact that is been viewed. */ - private $_ims = array(); + private $_ims = []; /** * No of im blocks for inline edit. @@ -88,7 +88,7 @@ public function buildQuickForm() { CRM_Contact_Form_Edit_IM::buildQuickForm($this, $blockId, TRUE); } - $this->addFormRule(array('CRM_Contact_Form_Inline_IM', 'formRule')); + $this->addFormRule(['CRM_Contact_Form_Inline_IM', 'formRule']); } /** @@ -102,7 +102,7 @@ public function buildQuickForm() { * @return array */ public static function formRule($fields, $errors) { - $hasData = $hasPrimary = $errors = array(); + $hasData = $hasPrimary = $errors = []; if (!empty($fields['im']) && is_array($fields['im'])) { foreach ($fields['im'] as $instance => $blockValues) { $dataExists = CRM_Contact_Form_Contact::blockDataExists($blockValues); @@ -135,7 +135,7 @@ public static function formRule($fields, $errors) { * @return array */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; if (!empty($this->_ims)) { foreach ($this->_ims as $id => $value) { $defaults['im'][$id] = $value; diff --git a/CRM/Contact/Form/Inline/Lock.php b/CRM/Contact/Form/Inline/Lock.php index 3fa0a5ab47e2..62c94420f5b0 100644 --- a/CRM/Contact/Form/Inline/Lock.php +++ b/CRM/Contact/Form/Inline/Lock.php @@ -53,8 +53,8 @@ public static function buildQuickForm(&$form, $contactID) { // - V1:open E1:open E1:submit V1.email:open V1.email:submit // - V1:open V1.email:open E1:open E1:submit V1.email:submit V1:lock $timestamps = CRM_Contact_BAO_Contact::getTimestamps($contactID); - $form->addElement('hidden', 'oplock_ts', $timestamps['modified_date'], array('id' => 'oplock_ts')); - $form->addFormRule(array('CRM_Contact_Form_Inline_Lock', 'formRule'), $contactID); + $form->addElement('hidden', 'oplock_ts', $timestamps['modified_date'], ['id' => 'oplock_ts']); + $form->addFormRule(['CRM_Contact_Form_Inline_Lock', 'formRule'], $contactID); } /** @@ -70,7 +70,7 @@ public static function buildQuickForm(&$form, $contactID) { * true if no errors, else array of errors */ public static function formRule($fields, $files, $contactID = NULL) { - $errors = array(); + $errors = []; $timestamps = CRM_Contact_BAO_Contact::getTimestamps($contactID); if ($fields['oplock_ts'] != $timestamps['modified_date']) { @@ -93,7 +93,7 @@ public static function formRule($fields, $files, $contactID = NULL) { */ public static function getResponse($contactID) { $timestamps = CRM_Contact_BAO_Contact::getTimestamps($contactID); - return array('oplock_ts' => $timestamps['modified_date']); + return ['oplock_ts' => $timestamps['modified_date']]; } } diff --git a/CRM/Contact/Form/Inline/OpenID.php b/CRM/Contact/Form/Inline/OpenID.php index a225e3a81e3d..55b9f1b22726 100644 --- a/CRM/Contact/Form/Inline/OpenID.php +++ b/CRM/Contact/Form/Inline/OpenID.php @@ -39,7 +39,7 @@ class CRM_Contact_Form_Inline_OpenID extends CRM_Contact_Form_Inline { /** * Ims of the contact that is been viewed. */ - private $_openids = array(); + private $_openids = []; /** * No of openid blocks for inline edit. @@ -88,7 +88,7 @@ public function buildQuickForm() { CRM_Contact_Form_Edit_OpenID::buildQuickForm($this, $blockId, TRUE); } - $this->addFormRule(array('CRM_Contact_Form_Inline_OpenID', 'formRule')); + $this->addFormRule(['CRM_Contact_Form_Inline_OpenID', 'formRule']); } /** @@ -102,7 +102,7 @@ public function buildQuickForm() { * @return array */ public static function formRule($fields, $errors) { - $hasData = $hasPrimary = $errors = array(); + $hasData = $hasPrimary = $errors = []; if (!empty($fields['openid']) && is_array($fields['openid'])) { foreach ($fields['openid'] as $instance => $blockValues) { $dataExists = CRM_Contact_Form_Contact::blockDataExists($blockValues); @@ -135,7 +135,7 @@ public static function formRule($fields, $errors) { * @return array */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; if (!empty($this->_openids)) { foreach ($this->_openids as $id => $value) { $defaults['openid'][$id] = $value; diff --git a/CRM/Contact/Form/Inline/Phone.php b/CRM/Contact/Form/Inline/Phone.php index 9d46c70eee2b..1ee20388abfb 100644 --- a/CRM/Contact/Form/Inline/Phone.php +++ b/CRM/Contact/Form/Inline/Phone.php @@ -39,7 +39,7 @@ class CRM_Contact_Form_Inline_Phone extends CRM_Contact_Form_Inline { /** * Phones of the contact that is been viewed */ - private $_phones = array(); + private $_phones = []; /** * No of phone blocks for inline edit @@ -88,7 +88,7 @@ public function buildQuickForm() { CRM_Contact_Form_Edit_Phone::buildQuickForm($this, $blockId, TRUE); } - $this->addFormRule(array('CRM_Contact_Form_Inline_Phone', 'formRule')); + $this->addFormRule(['CRM_Contact_Form_Inline_Phone', 'formRule']); } /** @@ -102,7 +102,7 @@ public function buildQuickForm() { * @return array */ public static function formRule($fields, $errors) { - $hasData = $hasPrimary = $errors = array(); + $hasData = $hasPrimary = $errors = []; if (!empty($fields['phone']) && is_array($fields['phone'])) { $primaryID = NULL; foreach ($fields['phone'] as $instance => $blockValues) { @@ -136,7 +136,7 @@ public static function formRule($fields, $errors) { * @return array */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; if (!empty($this->_phones)) { foreach ($this->_phones as $id => $value) { $defaults['phone'][$id] = $value; diff --git a/CRM/Contact/Form/Inline/Website.php b/CRM/Contact/Form/Inline/Website.php index afab6f5679a8..0491e745ce47 100644 --- a/CRM/Contact/Form/Inline/Website.php +++ b/CRM/Contact/Form/Inline/Website.php @@ -39,7 +39,7 @@ class CRM_Contact_Form_Inline_Website extends CRM_Contact_Form_Inline { /** * Websitess of the contact that is been viewed. */ - private $_websites = array(); + private $_websites = []; /** * No of website blocks for inline edit. @@ -53,8 +53,8 @@ public function preProcess() { parent::preProcess(); //get all the existing websites - $params = array('contact_id' => $this->_contactId); - $values = array(); + $params = ['contact_id' => $this->_contactId]; + $values = []; $this->_websites = CRM_Core_BAO_Website::getValues($params, $values); } @@ -87,7 +87,7 @@ public function buildQuickForm() { CRM_Contact_Form_Edit_Website::buildQuickForm($this, $blockId, TRUE); } - $this->addFormRule(array('CRM_Contact_Form_Inline_Website', 'formRule'), $this); + $this->addFormRule(['CRM_Contact_Form_Inline_Website', 'formRule'], $this); } @@ -97,7 +97,7 @@ public function buildQuickForm() { * @return array */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; if (!empty($this->_websites)) { foreach ($this->_websites as $id => $value) { $defaults['website'][$id] = $value; @@ -142,9 +142,9 @@ public function postProcess() { * @return array */ public static function formRule($fields, $errors, $form) { - $hasData = $errors = array(); + $hasData = $errors = []; if (!empty($fields['website']) && is_array($fields['website'])) { - $types = array(); + $types = []; foreach ($fields['website'] as $instance => $blockValues) { $dataExists = CRM_Contact_Form_Contact::blockDataExists($blockValues); diff --git a/CRM/Contact/Form/Location.php b/CRM/Contact/Form/Location.php index 8218001d635d..0f3bd5c63b77 100644 --- a/CRM/Contact/Form/Location.php +++ b/CRM/Contact/Form/Location.php @@ -51,11 +51,11 @@ public static function preProcess(&$form) { if (is_a($form, 'CRM_Event_Form_ManageEvent_Location') || is_a($form, 'CRM_Contact_Form_Domain')) { - $form->_blocks = array( + $form->_blocks = [ 'Address' => ts('Address'), 'Email' => ts('Email'), 'Phone' => ts('Phone'), - ); + ]; } $form->assign('blocks', $form->_blocks); @@ -76,14 +76,14 @@ public static function preProcess(&$form) { */ public static function buildQuickForm(&$form) { // required for subsequent AJAX requests. - $ajaxRequestBlocks = array(); + $ajaxRequestBlocks = []; $generateAjaxRequest = 0; //build 1 instance of all blocks, without using ajax ... foreach ($form->_blocks as $blockName => $label) { $name = strtolower($blockName); - $instances = array(1); + $instances = [1]; if (!empty($_POST[$name]) && is_array($_POST[$name])) { $instances = array_keys($_POST[$name]); } diff --git a/CRM/Contact/Form/Merge.php b/CRM/Contact/Form/Merge.php index cbb1c3a8e8f3..6dc3475ef0ce 100644 --- a/CRM/Contact/Form/Merge.php +++ b/CRM/Contact/Form/Merge.php @@ -47,7 +47,7 @@ class CRM_Contact_Form_Merge extends CRM_Core_Form { /** * @var array */ - public $criteria = array(); + public $criteria = []; /** * Query limit to be retained in the urls. @@ -97,11 +97,11 @@ public function preProcess() { if (!$this->_rgid) { // Unset browse URL as we have come from the search screen. $browseUrl = ''; - $this->_rgid = civicrm_api3('RuleGroup', 'getvalue', array( + $this->_rgid = civicrm_api3('RuleGroup', 'getvalue', [ 'contact_type' => $this->_contactType, 'used' => 'Supervised', 'return' => 'id', - )); + ]); } $this->assign('browseUrl', $browseUrl); if ($browseUrl) { @@ -136,10 +136,10 @@ public function preProcess() { $this->assign('flip', $flipUrl); $this->prev = $this->next = NULL; - foreach (array( + foreach ([ 'prev', 'next', - ) as $position) { + ] as $position) { if (!empty($pos[$position])) { if ($pos[$position]['id1'] && $pos[$position]['id2']) { $rowParams = array_merge($urlParams, [ @@ -179,7 +179,7 @@ public function preProcess() { $this->assign('rgid', $this->_rgid); $this->assignSummaryRowsToTemplate($contacts); - $this->addElement('checkbox', 'toggleSelect', NULL, NULL, array('class' => 'select-rows')); + $this->addElement('checkbox', 'toggleSelect', NULL, NULL, ['class' => 'select-rows']); $this->assign('mainLocBlock', json_encode($rowsElementsAndInfo['main_details']['location_blocks'])); $this->assign('locationBlockInfo', json_encode(CRM_Dedupe_Merger::getLocationBlockInfo())); @@ -208,16 +208,16 @@ public function preProcess() { // on the form. if (substr($element[1], 0, 13) === 'move_location') { $element[4] = array_merge( - (array) CRM_Utils_Array::value(4, $element, array()), - array( + (array) CRM_Utils_Array::value(4, $element, []), + [ 'data-location' => substr($element[1], 14), 'data-is_location' => TRUE, - )); + ]); } if (substr($element[1], 0, 15) === 'location_blocks') { // @todo We could add some data elements here to make jquery manipulation more straight-forward // @todo consider enabling if it is an add & defaulting to true. - $element[4] = array_merge((array) CRM_Utils_Array::value(4, $element, array()), array('disabled' => TRUE)); + $element[4] = array_merge((array) CRM_Utils_Array::value(4, $element, []), ['disabled' => TRUE]); } $this->addElement($element[0], $element[1], @@ -248,35 +248,35 @@ public function addRules() { public function buildQuickForm() { $this->unsavedChangesWarn = FALSE; - CRM_Utils_System::setTitle(ts('Merge %1 contacts', array(1 => $this->_contactType))); - $buttons = array(); + CRM_Utils_System::setTitle(ts('Merge %1 contacts', [1 => $this->_contactType])); + $buttons = []; - $buttons[] = array( + $buttons[] = [ 'type' => 'next', 'name' => $this->next ? ts('Merge and go to Next Pair') : ts('Merge'), 'isDefault' => TRUE, 'icon' => $this->next ? 'fa-play-circle' : 'check', - ); + ]; if ($this->next || $this->prev) { - $buttons[] = array( + $buttons[] = [ 'type' => 'submit', 'name' => ts('Merge and go to Listing'), - ); - $buttons[] = array( + ]; + $buttons[] = [ 'type' => 'done', 'name' => ts('Merge and View Result'), 'icon' => 'fa-check-circle', - ); + ]; } - $buttons[] = array( + $buttons[] = [ 'type' => 'cancel', 'name' => ts('Cancel'), - ); + ]; $this->addButtons($buttons); - $this->addFormRule(array('CRM_Contact_Form_Merge', 'formRule'), $this); + $this->addFormRule(['CRM_Contact_Form_Merge', 'formRule'], $this); } /** @@ -287,13 +287,13 @@ public function buildQuickForm() { * @return array */ public static function formRule($fields, $files, $self) { - $errors = array(); + $errors = []; $link = CRM_Utils_System::href(ts('Flip between the original and duplicate contacts.'), 'civicrm/contact/merge', 'reset=1&action=update&cid=' . $self->_oid . '&oid=' . $self->_cid . '&rgid=' . $self->_rgid . '&flip=1' ); if (CRM_Contact_BAO_Contact::checkDomainContact($self->_oid)) { - $errors['_qf_default'] = ts("The Default Organization contact cannot be merged into another contact record. It is associated with the CiviCRM installation for this domain and contains information used for system functions. If you want to merge these records, you can: %1", array(1 => $link)); + $errors['_qf_default'] = ts("The Default Organization contact cannot be merged into another contact record. It is associated with the CiviCRM installation for this domain and contains information used for system functions. If you want to merge these records, you can: %1", [1 => $link]); } return $errors; } @@ -303,12 +303,12 @@ public function postProcess() { $formValues['main_details'] = $this->_mainDetails; $formValues['other_details'] = $this->_otherDetails; - $migrationData = array('migration_info' => $formValues); + $migrationData = ['migration_info' => $formValues]; CRM_Utils_Hook::merge('form', $migrationData, $this->_cid, $this->_oid); CRM_Dedupe_Merger::moveAllBelongings($this->_cid, $this->_oid, $migrationData['migration_info']); $name = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_cid, 'display_name'); - $message = '
  • ' . ts('%1 has been updated.', array(1 => $name)) . '
  • ' . ts('Contact ID %1 has been deleted.', array(1 => $this->_oid)) . '
'; + $message = '
  • ' . ts('%1 has been updated.', [1 => $name]) . '
  • ' . ts('Contact ID %1 has been deleted.', [1 => $this->_oid]) . '
'; CRM_Core_Session::setStatus($message, ts('Contacts Merged'), 'success'); $urlParams = ['reset' => 1, 'cid' => $this->_cid, 'rgid' => $this->_rgid, 'gid' => $this->_gid, 'limit' => $this->limit, 'criteria' => $this->criteria]; @@ -366,7 +366,7 @@ public function bounceIfInvalid($cid, $oid) { } if (!CRM_Dedupe_BAO_Rule::validateContacts($cid, $oid)) { - CRM_Core_Error::statusBounce(ts('The selected pair of contacts are marked as non duplicates. If these records should be merged, you can remove this exception on the Dedupe Exceptions page.', array(1 => CRM_Utils_System::url('civicrm/dedupe/exception', 'reset=1')))); + CRM_Core_Error::statusBounce(ts('The selected pair of contacts are marked as non duplicates. If these records should be merged, you can remove this exception on the Dedupe Exceptions page.', [1 => CRM_Utils_System::url('civicrm/dedupe/exception', 'reset=1')])); } if (!(CRM_Contact_BAO_Contact_Permission::allow($cid, CRM_Core_Permission::EDIT) && @@ -378,7 +378,7 @@ public function bounceIfInvalid($cid, $oid) { // ensure that oid is not the current user, if so refuse to do the merge if (CRM_Core_Session::singleton()->getLoggedInContactID() == $oid) { $message = ts('The contact record which is linked to the currently logged in user account - \'%1\' - cannot be deleted.', - array(1 => CRM_Core_Session::singleton()->getLoggedInContactDisplayName()) + [1 => CRM_Core_Session::singleton()->getLoggedInContactDisplayName()] ); CRM_Core_Error::statusBounce($message); } diff --git a/CRM/Contact/Form/RelatedContact.php b/CRM/Contact/Form/RelatedContact.php index 086852d9f3cd..ad21672bee3f 100644 --- a/CRM/Contact/Form/RelatedContact.php +++ b/CRM/Contact/Form/RelatedContact.php @@ -80,7 +80,7 @@ public function preProcess() { $contact = new CRM_Contact_DAO_Contact(); $contact->id = $this->_contactId; if (!$contact->find(TRUE)) { - CRM_Core_Error::statusBounce(ts('contact does not exist: %1', array(1 => $this->_contactId))); + CRM_Core_Error::statusBounce(ts('contact does not exist: %1', [1 => $this->_contactId])); } $this->_contactType = $contact->contact_type; @@ -111,7 +111,7 @@ public function setDefaultValues() { * Build the form object. */ public function buildQuickForm() { - $params = array(); + $params = []; $params['id'] = $params['contact_id'] = $this->_contactId; $contact = CRM_Contact_BAO_Contact::retrieve($params, $this->_defaults); @@ -132,17 +132,17 @@ public function buildQuickForm() { ts('Contact Information') ); - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => ts('Save'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - )); + ], + ]); } /** @@ -153,11 +153,11 @@ public function postProcess() { $params = $this->controller->exportValues($this->_name); $locType = CRM_Core_BAO_LocationType::getDefault(); - foreach (array( + foreach ([ 'phone', 'email', 'address', - ) as $locFld) { + ] as $locFld) { if (!empty($this->_defaults[$locFld]) && $this->_defaults[$locFld][1]['location_type_id']) { $params[$locFld][1]['is_primary'] = $this->_defaults[$locFld][1]['is_primary']; $params[$locFld][1]['location_type_id'] = $this->_defaults[$locFld][1]['location_type_id']; @@ -179,10 +179,10 @@ public function postProcess() { // set status message. if ($this->_contactId) { - $message = ts('%1 has been updated.', array(1 => $contact->display_name)); + $message = ts('%1 has been updated.', [1 => $contact->display_name]); } else { - $message = ts('%1 has been created.', array(1 => $contact->display_name)); + $message = ts('%1 has been created.', [1 => $contact->display_name]); } CRM_Core_Session::setStatus($message, ts('Contact Saved'), 'success'); } diff --git a/CRM/Contact/Form/Relationship.php b/CRM/Contact/Form/Relationship.php index ee3a24d0f5b5..686a371c2bf3 100644 --- a/CRM/Contact/Form/Relationship.php +++ b/CRM/Contact/Form/Relationship.php @@ -132,14 +132,14 @@ public function preProcess() { $this->assign('display_name_a', $this->_display_name_a); //get the relationship values. - $this->_values = array(); + $this->_values = []; if ($this->_relationshipId) { - $params = array('id' => $this->_relationshipId); + $params = ['id' => $this->_relationshipId]; CRM_Core_DAO::commonRetrieve('CRM_Contact_DAO_Relationship', $params, $this->_values); } // Check for permissions - if (in_array($this->_action, array(CRM_Core_Action::ADD, CRM_Core_Action::UPDATE, CRM_Core_Action::DELETE))) { + if (in_array($this->_action, [CRM_Core_Action::ADD, CRM_Core_Action::UPDATE, CRM_Core_Action::DELETE])) { if (!CRM_Contact_BAO_Contact_Permission::allow($this->_contactId, CRM_Core_Permission::EDIT) && !CRM_Contact_BAO_Contact_Permission::allow($this->_values['contact_id_b'], CRM_Core_Permission::EDIT)) { CRM_Core_Error::statusBounce(ts('You do not have the necessary permission to edit this contact.')); @@ -149,19 +149,19 @@ public function preProcess() { // Set page title based on action switch ($this->_action) { case CRM_Core_Action::VIEW: - CRM_Utils_System::setTitle(ts('View Relationship for %1', array(1 => $this->_display_name_a))); + CRM_Utils_System::setTitle(ts('View Relationship for %1', [1 => $this->_display_name_a])); break; case CRM_Core_Action::ADD: - CRM_Utils_System::setTitle(ts('Add Relationship for %1', array(1 => $this->_display_name_a))); + CRM_Utils_System::setTitle(ts('Add Relationship for %1', [1 => $this->_display_name_a])); break; case CRM_Core_Action::UPDATE: - CRM_Utils_System::setTitle(ts('Edit Relationship for %1', array(1 => $this->_display_name_a))); + CRM_Utils_System::setTitle(ts('Edit Relationship for %1', [1 => $this->_display_name_a])); break; case CRM_Core_Action::DELETE: - CRM_Utils_System::setTitle(ts('Delete Relationship for %1', array(1 => $this->_display_name_a))); + CRM_Utils_System::setTitle(ts('Delete Relationship for %1', [1 => $this->_display_name_a])); break; } @@ -178,7 +178,7 @@ public function preProcess() { } //get the relationship type id - $this->_relationshipTypeId = str_replace(array('_a_b', '_b_a'), array('', ''), $this->_rtypeId); + $this->_relationshipTypeId = str_replace(['_a_b', '_b_a'], ['', ''], $this->_rtypeId); //get the relationship type if (!$this->_rtype) { @@ -212,7 +212,7 @@ public function preProcess() { * Set default values for the form. */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; if ($this->_action & CRM_Core_Action::UPDATE) { if (!empty($this->_values)) { @@ -242,12 +242,12 @@ public function setDefaultValues() { $this->assign('display_name_b', $this->_display_name_b); } - $noteParams = array( + $noteParams = [ 'entity_id' => $this->_relationshipId, 'entity_table' => 'civicrm_relationship', 'limit' => 1, 'version' => 3, - ); + ]; $note = civicrm_api('Note', 'getsingle', $noteParams); $defaults['note'] = CRM_Utils_Array::value('note', $note); } @@ -267,7 +267,7 @@ public function setDefaultValues() { */ public function addRules() { if (!($this->_action & CRM_Core_Action::DELETE)) { - $this->addFormRule(array('CRM_Contact_Form_Relationship', 'dateRule')); + $this->addFormRule(['CRM_Contact_Form_Relationship', 'dateRule']); } } @@ -276,17 +276,17 @@ public function addRules() { */ public function buildQuickForm() { if ($this->_action & CRM_Core_Action::DELETE) { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => ts('Delete'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); return; } @@ -305,23 +305,23 @@ public function buildQuickForm() { $this->addField( 'relationship_type_id', - array( - 'options' => array('' => ts('- select -')) + $relationshipList, + [ + 'options' => ['' => ts('- select -')] + $relationshipList, 'class' => 'huge', 'placeholder' => '- select -', 'option_url' => 'civicrm/admin/reltype', - 'option_context' => array( + 'option_context' => [ 'contact_id' => $this->_contactId, 'relationship_direction' => $this->_rtype, 'relationship_id' => $this->_relationshipId, 'is_form' => TRUE, - ), - ), + ], + ], TRUE ); $label = $this->_action & CRM_Core_Action::ADD ? ts('Contact(s)') : ts('Contact'); - $contactField = $this->addField('related_contact_id', array('label' => $label, 'name' => 'contact_id_b', 'multiple' => TRUE, 'create' => TRUE), TRUE); + $contactField = $this->addField('related_contact_id', ['label' => $label, 'name' => 'contact_id_b', 'multiple' => TRUE, 'create' => TRUE], TRUE); // This field cannot be updated if ($this->_action & CRM_Core_Action::UPDATE) { $contactField->freeze(); @@ -329,39 +329,39 @@ public function buildQuickForm() { $this->add('advcheckbox', 'is_current_employer', $this->_contactType == 'Organization' ? ts('Current Employee') : ts('Current Employer')); - $this->addField('start_date', array('label' => ts('Start Date')), FALSE, FALSE); - $this->addField('end_date', array('label' => ts('End Date')), FALSE, FALSE); + $this->addField('start_date', ['label' => ts('Start Date')], FALSE, FALSE); + $this->addField('end_date', ['label' => ts('End Date')], FALSE, FALSE); - $this->addField('is_active', array('label' => ts('Enabled?'), 'type' => 'advcheckbox')); + $this->addField('is_active', ['label' => ts('Enabled?'), 'type' => 'advcheckbox']); - $this->addField('is_permission_a_b', array(), TRUE); - $this->addField('is_permission_b_a', array(), TRUE); + $this->addField('is_permission_a_b', [], TRUE); + $this->addField('is_permission_b_a', [], TRUE); - $this->addField('description', array('label' => ts('Description'))); + $this->addField('description', ['label' => ts('Description')]); CRM_Contact_Form_Edit_Notes::buildQuickForm($this); if ($this->_action & CRM_Core_Action::VIEW) { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'cancel', 'name' => ts('Done'), - ), - )); + ], + ]); } else { // make this form an upload since we don't know if the custom data injected dynamically is of type file etc. - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'upload', 'name' => ts('Save Relationship'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - )); + ], + ]); } } @@ -377,7 +377,7 @@ public function submit($params) { switch ($this->getAction()) { case CRM_Core_Action::DELETE: $this->deleteAction($this->_relationshipId); - return array(); + return []; case CRM_Core_Action::UPDATE: return $this->updateAction($params); @@ -414,13 +414,13 @@ public function postProcess() { $this->setEmploymentRelationship($params, $relationshipIds); // Refresh contact tabs which might have been affected - $this->ajaxResponse = array( - 'reloadBlocks' => array('#crm-contactinfo-content'), - 'updateTabs' => array( + $this->ajaxResponse = [ + 'reloadBlocks' => ['#crm-contactinfo-content'], + 'updateTabs' => [ '#tab_member' => CRM_Contact_BAO_Contact::getCountComponent('membership', $this->_contactId), '#tab_contribute' => CRM_Contact_BAO_Contact::getCountComponent('contribution', $this->_contactId), - ), - ); + ], + ]; } /** @@ -433,7 +433,7 @@ public function postProcess() { * mixed true or array of errors */ public static function dateRule($params) { - $errors = array(); + $errors = []; // check start and end date if (!empty($params['start_date']) && !empty($params['end_date'])) { @@ -457,28 +457,28 @@ public static function dateRule($params) { */ protected function setMessage($outcome) { if (!empty($outcome['valid']) && empty($outcome['saved'])) { - CRM_Core_Session::setStatus(ts('Relationship created.', array( + CRM_Core_Session::setStatus(ts('Relationship created.', [ 'count' => $outcome['valid'], 'plural' => '%count relationships created.', - )), ts('Saved'), 'success'); + ]), ts('Saved'), 'success'); } if (!empty($outcome['invalid'])) { - CRM_Core_Session::setStatus(ts('%count relationship record was not created due to an invalid contact type.', array( + CRM_Core_Session::setStatus(ts('%count relationship record was not created due to an invalid contact type.', [ 'count' => $outcome['invalid'], 'plural' => '%count relationship records were not created due to invalid contact types.', - )), ts('%count invalid relationship record', array( + ]), ts('%count invalid relationship record', [ 'count' => $outcome['invalid'], 'plural' => '%count invalid relationship records', - ))); + ])); } if (!empty($outcome['duplicate'])) { - CRM_Core_Session::setStatus(ts('One relationship was not created because it already exists.', array( + CRM_Core_Session::setStatus(ts('One relationship was not created because it already exists.', [ 'count' => $outcome['duplicate'], 'plural' => '%count relationships were not created because they already exist.', - )), ts('%count duplicate relationship', array( + ]), ts('%count duplicate relationship', [ 'count' => $outcome['duplicate'], 'plural' => '%count duplicate relationships', - ))); + ])); } if (!empty($outcome['saved'])) { CRM_Core_Session::setStatus(ts('Relationship record has been updated.'), ts('Saved'), 'success'); @@ -493,21 +493,21 @@ protected function setMessage($outcome) { public static function getRelationshipTypeMetadata($relationshipList) { $contactTypes = CRM_Contact_BAO_ContactType::contactTypeInfo(TRUE); $allRelationshipNames = CRM_Core_PseudoConstant::relationshipType('name'); - $jsData = array(); + $jsData = []; // Get just what we need to keep the dom small - $whatWeWant = array_flip(array( + $whatWeWant = array_flip([ 'contact_type_a', 'contact_type_b', 'contact_sub_type_a', 'contact_sub_type_b', - )); + ]); foreach ($allRelationshipNames as $id => $vals) { if (isset($relationshipList["{$id}_a_b"]) || isset($relationshipList["{$id}_b_a"])) { $jsData[$id] = array_filter(array_intersect_key($allRelationshipNames[$id], $whatWeWant)); // Add user-friendly placeholder - foreach (array('a', 'b') as $x) { + 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]); - $jsData[$id]["placeholder_$x"] = $type ? ts('- select %1 -', array(strtolower($contactTypes[$type]['label']))) : ts('- select contact -'); + $jsData[$id]["placeholder_$x"] = $type ? ts('- select %1 -', [strtolower($contactTypes[$type]['label'])]) : ts('- select contact -'); } } } @@ -524,7 +524,7 @@ private function deleteAction($id) { CRM_Contact_BAO_Relationship::del($id); // reload all blocks to reflect this change on the user interface. - $this->ajaxResponse['reloadBlocks'] = array('#crm-contactinfo-content'); + $this->ajaxResponse['reloadBlocks'] = ['#crm-contactinfo-content']; } /** @@ -544,8 +544,8 @@ private function updateAction($params) { throw new CRM_Core_Exception('Relationship create error ' . $e->getMessage()); } - $this->setMessage(array('saved' => TRUE)); - return array($params, array($this->_relationshipId)); + $this->setMessage(['saved' => TRUE]); + return [$params, [$this->_relationshipId]]; } /** @@ -565,7 +565,7 @@ private function createAction($params) { $this->setMessage($outcome); - return array($params, $relationshipIds); + return [$params, $relationshipIds]; } @@ -595,7 +595,7 @@ private function preparePostProcessParameters($values) { $params['is_permission_a_b'] = CRM_Utils_Array::value("is_permission_{$a}_{$b}", $values, 0); $params['is_permission_b_a'] = CRM_Utils_Array::value("is_permission_{$b}_{$a}", $values, 0); - return array($params, $a); + return [$params, $a]; } /** @@ -608,10 +608,10 @@ private function preparePostProcessParameters($values) { */ private function saveRelationshipNotes($relationshipIds, $note) { foreach ($relationshipIds as $id) { - $noteParams = array( + $noteParams = [ 'entity_id' => $id, 'entity_table' => 'civicrm_relationship', - ); + ]; $existing = civicrm_api3('note', 'get', $noteParams); if (!empty($existing['id'])) { @@ -641,7 +641,7 @@ private function saveRelationshipNotes($relationshipIds, $note) { * @param array $relationshipIds */ private function setEmploymentRelationship($params, $relationshipIds) { - $employerParams = array(); + $employerParams = []; foreach ($relationshipIds as $id) { if (!CRM_Contact_BAO_Relationship::isCurrentEmployerNeedingToBeCleared($params, $id) //don't think this is required to check again. diff --git a/CRM/Contact/Form/Search.php b/CRM/Contact/Form/Search.php index fc389c608750..4671db0ec8d9 100644 --- a/CRM/Contact/Form/Search.php +++ b/CRM/Contact/Form/Search.php @@ -129,7 +129,7 @@ class CRM_Contact_Form_Search extends CRM_Core_Form_Search { * * @var array */ - static $csv = array('contact_type', 'group', 'tag'); + static $csv = ['contact_type', 'group', 'tag']; /** * @var string how to display the results. Should we display as @@ -149,7 +149,7 @@ class CRM_Contact_Form_Search extends CRM_Core_Form_Search { * * @var array */ - protected $entityReferenceFields = array('event_id', 'membership_type_id'); + protected $entityReferenceFields = ['event_id', 'membership_type_id']; /** * Name of the selector to use. @@ -158,7 +158,7 @@ class CRM_Contact_Form_Search extends CRM_Core_Form_Search { protected $_customSearchID = NULL; protected $_customSearchClass = NULL; - protected $_openedPanes = array(); + protected $_openedPanes = []; /** * Explicitly declare the entity api name. @@ -175,7 +175,7 @@ public function getDefaultEntity() { */ public static function &validContext() { if (!(self::$_validContext)) { - self::$_validContext = array( + self::$_validContext = [ 'smog' => 'Show members of group', 'amtg' => 'Add members to group', 'basic' => 'Basic Search', @@ -183,7 +183,7 @@ public static function &validContext() { 'builder' => 'Search Builder', 'advanced' => 'Advanced Search', 'custom' => 'Custom Search', - ); + ]; } return self::$_validContext; } @@ -199,8 +199,8 @@ public static function isSearchContext($context) { } public static function setModeValues() { - self::$_modeValues = array( - CRM_Contact_BAO_Query::MODE_CONTACTS => array( + self::$_modeValues = [ + CRM_Contact_BAO_Query::MODE_CONTACTS => [ 'selectorName' => self::$_selectorName, 'selectorLabel' => ts('Contacts'), 'taskFile' => 'CRM/Contact/Form/Search/ResultTasks.tpl', @@ -209,8 +209,8 @@ public static function setModeValues() { 'resultContext' => NULL, 'taskClassName' => 'CRM_Contact_Task', 'component' => '', - ), - CRM_Contact_BAO_Query::MODE_CONTRIBUTE => array( + ], + CRM_Contact_BAO_Query::MODE_CONTRIBUTE => [ 'selectorName' => 'CRM_Contribute_Selector_Search', 'selectorLabel' => ts('Contributions'), 'taskFile' => 'CRM/common/searchResultTasks.tpl', @@ -219,8 +219,8 @@ public static function setModeValues() { 'resultContext' => 'Search', 'taskClassName' => 'CRM_Contribute_Task', 'component' => 'CiviContribute', - ), - CRM_Contact_BAO_Query::MODE_EVENT => array( + ], + CRM_Contact_BAO_Query::MODE_EVENT => [ 'selectorName' => 'CRM_Event_Selector_Search', 'selectorLabel' => ts('Event Participants'), 'taskFile' => 'CRM/common/searchResultTasks.tpl', @@ -229,8 +229,8 @@ public static function setModeValues() { 'resultContext' => 'Search', 'taskClassName' => 'CRM_Event_Task', 'component' => 'CiviEvent', - ), - CRM_Contact_BAO_Query::MODE_ACTIVITY => array( + ], + CRM_Contact_BAO_Query::MODE_ACTIVITY => [ 'selectorName' => 'CRM_Activity_Selector_Search', 'selectorLabel' => ts('Activities'), 'taskFile' => 'CRM/common/searchResultTasks.tpl', @@ -239,8 +239,8 @@ public static function setModeValues() { 'resultContext' => 'Search', 'taskClassName' => 'CRM_Activity_Task', 'component' => 'activity', - ), - CRM_Contact_BAO_Query::MODE_MEMBER => array( + ], + CRM_Contact_BAO_Query::MODE_MEMBER => [ 'selectorName' => 'CRM_Member_Selector_Search', 'selectorLabel' => ts('Memberships'), 'taskFile' => "CRM/common/searchResultTasks.tpl", @@ -249,8 +249,8 @@ public static function setModeValues() { 'resultContext' => 'Search', 'taskClassName' => 'CRM_Member_Task', 'component' => 'CiviMember', - ), - CRM_Contact_BAO_Query::MODE_CASE => array( + ], + CRM_Contact_BAO_Query::MODE_CASE => [ 'selectorName' => 'CRM_Case_Selector_Search', 'selectorLabel' => ts('Cases'), 'taskFile' => "CRM/common/searchResultTasks.tpl", @@ -259,8 +259,8 @@ public static function setModeValues() { 'resultContext' => 'Search', 'taskClassName' => 'CRM_Case_Task', 'component' => 'CiviCase', - ), - CRM_Contact_BAO_Query::MODE_CONTACTSRELATED => array( + ], + CRM_Contact_BAO_Query::MODE_CONTACTSRELATED => [ 'selectorName' => self::$_selectorName, 'selectorLabel' => ts('Related Contacts'), 'taskFile' => 'CRM/Contact/Form/Search/ResultTasks.tpl', @@ -269,8 +269,8 @@ public static function setModeValues() { 'resultContext' => NULL, 'taskClassName' => 'CRM_Contact_Task', 'component' => 'related_contact', - ), - CRM_Contact_BAO_Query::MODE_MAILING => array( + ], + CRM_Contact_BAO_Query::MODE_MAILING => [ 'selectorName' => 'CRM_Mailing_Selector_Search', 'selectorLabel' => ts('Mailings'), 'taskFile' => "CRM/common/searchResultTasks.tpl", @@ -279,8 +279,8 @@ public static function setModeValues() { 'resultContext' => 'Search', 'taskClassName' => 'CRM_Mailing_Task', 'component' => 'CiviMail', - ), - ); + ], + ]; } /** @@ -330,7 +330,7 @@ public static function getModeSelect() { self::setModeValues(); $enabledComponents = CRM_Core_Component::getEnabledComponents(); - $componentModes = array(); + $componentModes = []; foreach (self::$_modeValues as $id => & $value) { if (strpos($value['component'], 'Civi') !== FALSE && !array_key_exists($value['component'], $enabledComponents) @@ -398,11 +398,11 @@ public function buildQuickForm() { $search_custom_id = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_SavedSearch', $this->_ssID, 'search_custom_id'); - $savedSearchValues = array( + $savedSearchValues = [ 'id' => $this->_ssID, 'name' => CRM_Contact_BAO_SavedSearch::getName($this->_ssID, 'title'), 'search_custom_id' => $search_custom_id, - ); + ]; $this->assign_by_ref('savedSearch', $savedSearchValues); $this->assign('ssID', $this->_ssID); } @@ -433,7 +433,7 @@ public function buildQuickForm() { } // set the group title - $groupValues = array('id' => $this->_groupID, 'title' => $this->_group[$this->_groupID]); + $groupValues = ['id' => $this->_groupID, 'title' => $this->_group[$this->_groupID]]; $this->assign_by_ref('group', $groupValues); // also set ssID if this is a saved search @@ -448,10 +448,10 @@ public function buildQuickForm() { } // Set dynamic page title for 'Show Members of Group' - CRM_Utils_System::setTitle(ts('Contacts in Group: %1', array(1 => $this->_group[$this->_groupID]))); + CRM_Utils_System::setTitle(ts('Contacts in Group: %1', [1 => $this->_group[$this->_groupID]])); } - $group_contact_status = array(); + $group_contact_status = []; foreach (CRM_Core_SelectValues::groupContactStatus() as $k => $v) { if (!empty($k)) { $group_contact_status[] = $this->createElement('checkbox', $k, NULL, $v); @@ -475,23 +475,23 @@ public function buildQuickForm() { } // Set dynamic page title for 'Add Members Group' - CRM_Utils_System::setTitle(ts('Add to Group: %1', array(1 => $this->_group[$this->_amtgID]))); + CRM_Utils_System::setTitle(ts('Add to Group: %1', [1 => $this->_group[$this->_amtgID]])); // also set the group title and freeze the action task with Add Members to Group - $groupValues = array('id' => $this->_amtgID, 'title' => $this->_group[$this->_amtgID]); + $groupValues = ['id' => $this->_amtgID, 'title' => $this->_group[$this->_amtgID]]; $this->assign_by_ref('group', $groupValues); - $this->add('submit', $this->_actionButtonName, ts('Add Contacts to %1', array(1 => $this->_group[$this->_amtgID])), - array( + $this->add('submit', $this->_actionButtonName, ts('Add Contacts to %1', [1 => $this->_group[$this->_amtgID]]), + [ 'class' => 'crm-form-submit', - ) + ] ); $this->add('hidden', 'task', CRM_Contact_Task::GROUP_ADD); - $selectedRowsRadio = $this->addElement('radio', 'radio_ts', NULL, '', 'ts_sel', array('checked' => 'checked')); + $selectedRowsRadio = $this->addElement('radio', 'radio_ts', NULL, '', 'ts_sel', ['checked' => 'checked']); $allRowsRadio = $this->addElement('radio', 'radio_ts', NULL, '', 'ts_all'); $this->assign('ts_sel_id', $selectedRowsRadio->_attributes['id']); $this->assign('ts_all_id', $allRowsRadio->_attributes['id']); } - $selectedContactIds = array(); + $selectedContactIds = []; $qfKeyParam = CRM_Utils_Array::value('qfKey', $this->_formValues); // 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)) { @@ -637,7 +637,7 @@ public function preProcess() { // FIXME: we should generalise in a way that components could inject url-filters // just like they build their own form elements - foreach (array( + foreach ([ 'mailing_id', 'mailing_delivery_status', 'mailing_open_status', @@ -648,12 +648,12 @@ public function preProcess() { 'mailing_unsubscribe', 'mailing_date_low', 'mailing_date_high', - ) as $mailingFilter) { + ] as $mailingFilter) { $type = 'String'; if ($mailingFilter == 'mailing_id' && $filterVal = CRM_Utils_Request::retrieve('mailing_id', 'Positive', $this) ) { - $this->_formValues[$mailingFilter] = array($filterVal); + $this->_formValues[$mailingFilter] = [$filterVal]; } elseif ($filterVal = CRM_Utils_Request::retrieve($mailingFilter, $type, $this)) { $this->_formValues[$mailingFilter] = $filterVal; @@ -680,8 +680,8 @@ public function preProcess() { // show the context menu only when we’re not searching for deleted contacts; CRM-5673 if (empty($this->_formValues['deleted_contacts'])) { $menuItems = CRM_Contact_BAO_Contact::contextMenu(); - $primaryActions = CRM_Utils_Array::value('primaryActions', $menuItems, array()); - $this->_contextMenu = CRM_Utils_Array::value('moreActions', $menuItems, array()); + $primaryActions = CRM_Utils_Array::value('primaryActions', $menuItems, []); + $this->_contextMenu = CRM_Utils_Array::value('moreActions', $menuItems, []); $this->assign('contextMenu', $primaryActions + $this->_contextMenu); } diff --git a/CRM/Contact/Form/Search/Basic.php b/CRM/Contact/Form/Search/Basic.php index c68343686fa5..cdfc0c71ba2f 100644 --- a/CRM/Contact/Form/Search/Basic.php +++ b/CRM/Contact/Form/Search/Basic.php @@ -41,7 +41,7 @@ class CRM_Contact_Form_Search_Basic extends CRM_Contact_Form_Search { * * @var array */ - static $csv = array('contact_type', 'group', 'tag'); + static $csv = ['contact_type', 'group', 'tag']; /** * Build the form object. @@ -54,12 +54,12 @@ public function buildQuickForm() { ); if (!empty($searchOptions['contactType'])) { - $contactTypes = array('' => ts('- any contact type -')) + CRM_Contact_BAO_ContactType::getSelectElements(); + $contactTypes = ['' => ts('- any contact type -')] + CRM_Contact_BAO_ContactType::getSelectElements(); $this->add('select', 'contact_type', ts('is...'), $contactTypes, FALSE, - array('class' => 'crm-select2') + ['class' => 'crm-select2'] ); } @@ -67,22 +67,22 @@ public function buildQuickForm() { // Get hierarchical listing of groups, respecting ACLs for CRM-16836. $groupHierarchy = CRM_Contact_BAO_Group::getGroupsHierarchy($this->_group, NULL, '  ', TRUE); if (!empty($searchOptions['groups'])) { - $this->addField('group', array( + $this->addField('group', [ 'entity' => 'group_contact', 'label' => ts('in'), 'placeholder' => ts('- any group -'), 'options' => $groupHierarchy, - )); + ]); } if (!empty($searchOptions['tags'])) { // tag criteria if (!empty($this->_tag)) { - $this->addField('tag', array( + $this->addField('tag', [ 'entity' => 'entity_tag', 'label' => ts('with'), 'placeholder' => ts('- any tag -'), - )); + ]); } } @@ -97,7 +97,7 @@ public function buildQuickForm() { * the default array reference */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; $defaults['sort_name'] = CRM_Utils_Array::value('sort_name', $this->_formValues); foreach (self::$csv as $v) { @@ -125,7 +125,7 @@ public function setDefaultValues() { * Add local and global form rules. */ public function addRules() { - $this->addFormRule(array('CRM_Contact_Form_Search_Basic', 'formRule')); + $this->addFormRule(['CRM_Contact_Form_Search_Basic', 'formRule']); } /** @@ -204,7 +204,7 @@ public static function formRule($fields, $files, $form) { // check actionName and if next, then do not repeat a search, since we are going to the next page if (array_key_exists('_qf_Search_next', $fields)) { if (empty($fields['task'])) { - return array('task' => 'Please select a valid action.'); + return ['task' => 'Please select a valid action.']; } if (CRM_Utils_Array::value('task', $fields) == CRM_Contact_Task::SAVE_SEARCH) { @@ -222,7 +222,7 @@ public static function formRule($fields, $files, $form) { return TRUE; } } - return array('task' => 'Please select one or more checkboxes to perform the action on.'); + return ['task' => 'Please select one or more checkboxes to perform the action on.']; } return TRUE; } diff --git a/CRM/Contact/Form/Search/Builder.php b/CRM/Contact/Form/Search/Builder.php index 10f06b104f4a..a1322ee1b85e 100644 --- a/CRM/Contact/Form/Search/Builder.php +++ b/CRM/Contact/Form/Search/Builder.php @@ -91,7 +91,7 @@ public function preProcess() { */ public function buildQuickForm() { $fields = self::fields(); - $searchByLabelFields = array(); + $searchByLabelFields = []; // This array contain list of available fields and their corresponding data type, // later assigned as json string, to be used to filter list of mysql operators $fieldNameTypes = []; @@ -106,16 +106,16 @@ public function buildQuickForm() { // Add javascript CRM_Core_Resources::singleton() ->addScriptFile('civicrm', 'templates/CRM/Contact/Form/Search/Builder.js', 1, 'html-header') - ->addSetting(array( - 'searchBuilder' => array( + ->addSetting([ + 'searchBuilder' => [ // Index of newly added/expanded block (1-based index) 'newBlock' => $this->get('newBlock'), 'fieldOptions' => self::fieldOptions(), 'searchByLabelFields' => $searchByLabelFields, 'fieldTypes' => $fieldNameTypes, - 'generalOperators' => array('' => ts('-operator-')) + CRM_Core_SelectValues::getSearchBuilderOperators(), - ), - )); + 'generalOperators' => ['' => ts('-operator-')] + CRM_Core_SelectValues::getSearchBuilderOperators(), + ], + ]); //get the saved search mapping id $mappingId = NULL; if ($this->_ssID) { @@ -131,7 +131,7 @@ public function buildQuickForm() { * Add local and global form rules. */ public function addRules() { - $this->addFormRule(array('CRM_Contact_Form_Search_Builder', 'formRule'), $this); + $this->addFormRule(['CRM_Contact_Form_Search_Builder', 'formRule'], $this); } /** @@ -151,7 +151,7 @@ public static function formRule($values, $files, $self) { $fields = self::fields(); $fld = CRM_Core_BAO_Mapping::formattedFields($values, TRUE); - $errorMsg = array(); + $errorMsg = []; foreach ($fld as $k => $v) { if (!$v[1]) { $errorMsg["operator[$v[3]][$v[4]]"] = ts("Please enter the operator."); @@ -160,19 +160,19 @@ public static function formRule($values, $files, $self) { // CRM-10338 $v[2] = self::checkArrayKeyEmpty($v[2]); - if (in_array($v[1], array( + if (in_array($v[1], [ 'IS NULL', 'IS NOT NULL', 'IS EMPTY', 'IS NOT EMPTY', - )) && + ]) && !empty($v[2]) ) { - $errorMsg["value[$v[3]][$v[4]]"] = ts('Please clear your value if you want to use %1 operator.', array(1 => $v[1])); + $errorMsg["value[$v[3]][$v[4]]"] = ts('Please clear your value if you want to use %1 operator.', [1 => $v[1]]); } elseif (substr($v[0], 0, 7) === 'do_not_' or substr($v[0], 0, 3) === 'is_') { if (isset($v[2])) { - $v2 = array($v[2]); + $v2 = [$v[2]]; if (!isset($v[2])) { $errorMsg["value[$v[3]][$v[4]]"] = ts("Please enter a value."); } @@ -193,10 +193,10 @@ public static function formRule($values, $files, $self) { $type = $fields[$fieldKey]['data_type']; // hack to handle custom data of type state and country - if (in_array($type, array( + if (in_array($type, [ 'Country', 'StateProvince', - ))) { + ])) { $type = "Integer"; } } @@ -219,7 +219,7 @@ public static function formRule($values, $files, $self) { } // Check Empty values for Integer Or Boolean Or Date type For operators other than IS NULL and IS NOT NULL. elseif (!in_array($v[1], - array('IS NULL', 'IS NOT NULL', 'IS EMPTY', 'IS NOT EMPTY')) + ['IS NULL', 'IS NOT NULL', 'IS EMPTY', 'IS NOT EMPTY']) ) { if ((($type == 'Int' || $type == 'Boolean') && !is_array($v[2]) && !trim($v[2])) && $v[2] != '0') { $errorMsg["value[$v[3]][$v[4]]"] = ts("Please enter a value."); @@ -250,7 +250,7 @@ public static function formRule($values, $files, $self) { // Validate each value in parenthesis to avoid db errors if (empty($errorMsg)) { - $parenValues = array(); + $parenValues = []; $parenValues = is_array($v[2]) ? (array_key_exists($v[1], $v[2])) ? $v[2][$v[1]] : $v[2] : explode(',', trim($inVal, "(..)")); foreach ($parenValues as $val) { if ($type == 'Date' || $type == 'Timestamp') { @@ -438,7 +438,7 @@ public static function fields() { public static function fieldOptions() { // Hack to add options not retrieved by getfields // This list could go on and on, but it would be better to fix getfields - $options = array( + $options = [ 'group' => 'group_contact', 'tag' => 'entity_tag', 'on_hold' => 'yesno', @@ -450,8 +450,8 @@ public static function fieldOptions() { 'member_is_test' => 'yesno', 'member_is_pay_later' => 'yesno', 'is_override' => 'yesno', - ); - $entities = array( + ]; + $entities = [ 'contact', 'address', 'activity', @@ -461,7 +461,7 @@ public static function fieldOptions() { 'contribution', 'case', 'grant', - ); + ]; CRM_Contact_BAO_Query_Hook::singleton()->alterSearchBuilderOptions($entities, $options); foreach ($entities as $entity) { $fields = civicrm_api3($entity, 'getfields'); @@ -474,14 +474,14 @@ public static function fieldOptions() { } } elseif (!empty($info['data_type'])) { - if (in_array($info['data_type'], array('StateProvince', 'Country'))) { + if (in_array($info['data_type'], ['StateProvince', 'Country'])) { $options[$field] = $entity; } } - elseif (in_array(substr($field, 0, 3), array( + elseif (in_array(substr($field, 0, 3), [ 'is_', 'do_', - )) || CRM_Utils_Array::value('data_type', $info) == 'Boolean' + ]) || CRM_Utils_Array::value('data_type', $info) == 'Boolean' ) { $options[$field] = 'yesno'; if ($entity != 'contact') { diff --git a/CRM/Contact/Form/Search/Criteria.php b/CRM/Contact/Form/Search/Criteria.php index 7862472f7f70..10e61cb3a84c 100644 --- a/CRM/Contact/Form/Search/Criteria.php +++ b/CRM/Contact/Form/Search/Criteria.php @@ -43,7 +43,7 @@ public static function basic(&$form) { if ($contactTypes) { $form->add('select', 'contact_type', ts('Contact Type(s)'), $contactTypes, FALSE, - array('id' => 'contact_type', 'multiple' => 'multiple', 'class' => 'crm-select2', 'style' => 'width: 100%;') + ['id' => 'contact_type', 'multiple' => 'multiple', 'class' => 'crm-select2', 'style' => 'width: 100%;'] ); } } @@ -55,11 +55,11 @@ public static function basic(&$form) { $groupHierarchy = CRM_Contact_BAO_Group::getGroupsHierarchy($form->_group, NULL, '  ', TRUE); $form->add('select', 'group', ts('Groups'), $groupHierarchy, FALSE, - array('id' => 'group', 'multiple' => 'multiple', 'class' => 'crm-select2') + ['id' => 'group', 'multiple' => 'multiple', 'class' => 'crm-select2'] ); $groupOptions = CRM_Core_BAO_OptionValue::getOptionValuesAssocArrayFromName('group_type'); $form->add('select', 'group_type', ts('Group Types'), $groupOptions, FALSE, - array('id' => 'group_type', 'multiple' => 'multiple', 'class' => 'crm-select2') + ['id' => 'group_type', 'multiple' => 'multiple', 'class' => 'crm-select2'] ); $form->add('hidden', 'group_search_selected', 'group'); } @@ -71,7 +71,7 @@ public static function basic(&$form) { if ($contactTags) { $form->add('select', 'contact_tags', ts('Select Tag(s)'), $contactTags, FALSE, - array('id' => 'contact_tags', 'multiple' => 'multiple', 'class' => 'crm-select2', 'style' => 'width: 100%;') + ['id' => 'contact_tags', 'multiple' => 'multiple', 'class' => 'crm-select2', 'style' => 'width: 100%;'] ); } @@ -79,7 +79,7 @@ public static function basic(&$form) { CRM_Core_Form_Tag::buildQuickForm($form, $parentNames, 'civicrm_contact', NULL, TRUE, FALSE); $used_for = CRM_Core_OptionGroup::values('tag_used_for'); - $tagsTypes = array(); + $tagsTypes = []; $showAllTagTypes = FALSE; foreach ($used_for as $key => $value) { //check tags for every type and find if there are any defined @@ -94,7 +94,7 @@ public static function basic(&$form) { } $tagTypesText = implode(" or ", $tagsTypes); if ($showAllTagTypes) { - $form->add('checkbox', 'all_tag_types', ts('Include tags used for %1', array(1 => $tagTypesText))); + $form->add('checkbox', 'all_tag_types', ts('Include tags used for %1', [1 => $tagTypesText])); $form->add('hidden', 'tag_types_text', $tagTypesText); } } @@ -112,7 +112,7 @@ public static function basic(&$form) { $form->addElement('text', 'job_title', ts('Job Title'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'job_title')); //added internal ID - $form->add('number', 'contact_id', ts('Contact ID'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'id') + array('min' => 1)); + $form->add('number', 'contact_id', ts('Contact ID'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'id') + ['min' => 1]); $form->addRule('contact_id', ts('Please enter valid Contact ID'), 'positiveInteger'); //added external ID @@ -132,16 +132,16 @@ public static function basic(&$form) { // FIXME: This is probably a part of profiles - need to be // FIXME: eradicated from here when profiles are reworked. - $types = array('Participant', 'Contribution', 'Membership'); + $types = ['Participant', 'Contribution', 'Membership']; // get component profiles - $componentProfiles = array(); + $componentProfiles = []; $componentProfiles = CRM_Core_BAO_UFGroup::getProfiles($types); $ufGroups = CRM_Core_BAO_UFGroup::getModuleUFGroup('Search Profile', 1); $accessibleUfGroups = CRM_Core_Permission::ufGroup(CRM_Core_Permission::VIEW); - $searchProfiles = array(); + $searchProfiles = []; foreach ($ufGroups as $key => $var) { if (!array_key_exists($key, $componentProfiles) && in_array($key, $accessibleUfGroups)) { $searchProfiles[$key] = $var['title']; @@ -151,11 +151,11 @@ public static function basic(&$form) { $form->add('select', 'uf_group_id', ts('Views For Display Contacts'), - array( + [ '0' => ts('- default view -'), - ) + $searchProfiles, + ] + $searchProfiles, FALSE, - array('class' => 'crm-select2') + ['class' => 'crm-select2'] ); $componentModes = CRM_Contact_Form_Search::getModeSelect(); @@ -166,23 +166,23 @@ public static function basic(&$form) { ts('Display Results As'), $componentModes, FALSE, - array('class' => 'crm-select2') + ['class' => 'crm-select2'] ); } $form->addRadio( 'operator', ts('Search Operator'), - array( + [ CRM_Contact_BAO_Query::SEARCH_OPERATOR_AND => ts('AND'), CRM_Contact_BAO_Query::SEARCH_OPERATOR_OR => ts('OR'), - ), - array('allowClear' => FALSE) + ], + ['allowClear' => FALSE] ); // add the option to display relationships $rTypes = CRM_Core_PseudoConstant::relationshipType(); - $rSelect = array('' => ts('- Select Relationship Type-')); + $rSelect = ['' => ts('- Select Relationship Type-')]; foreach ($rTypes as $rid => $rValue) { if ($rValue['label_a_b'] == $rValue['label_b_a']) { $rSelect[$rid] = $rValue['label_a_b']; @@ -197,7 +197,7 @@ public static function basic(&$form) { 'display_relationship_type', ts('Display Results as Relationship'), $rSelect, - array('class' => 'crm-select2') + ['class' => 'crm-select2'] ); // checkboxes for DO NOT phone, email, mail @@ -208,49 +208,49 @@ public static function basic(&$form) { ts('Privacy'), $t, FALSE, - array( + [ 'id' => 'privacy_options', 'multiple' => 'multiple', 'class' => 'crm-select2', - ) + ] ); $form->addElement('select', 'privacy_operator', ts('Operator'), - array( + [ 'OR' => ts('OR'), 'AND' => ts('AND'), - ) + ] ); - $options = array( + $options = [ 1 => ts('Exclude'), 2 => ts('Include by Privacy Option(s)'), - ); - $form->addRadio('privacy_toggle', ts('Privacy Options'), $options, array('allowClear' => FALSE)); + ]; + $form->addRadio('privacy_toggle', ts('Privacy Options'), $options, ['allowClear' => FALSE]); // preferred communication method if (Civi::settings()->get('civimail_multiple_bulk_emails')) { $form->addSelect('email_on_hold', - array('entity' => 'email', 'multiple' => 'multiple', 'label' => ts('Email On Hold'), 'options' => CRM_Core_PseudoConstant::emailOnHoldOptions())); + ['entity' => 'email', 'multiple' => 'multiple', 'label' => ts('Email On Hold'), 'options' => CRM_Core_PseudoConstant::emailOnHoldOptions()]); } else { $form->add('advcheckbox', 'email_on_hold', ts('Email On Hold')); } $form->addSelect('preferred_communication_method', - array('entity' => 'contact', 'multiple' => 'multiple', 'label' => ts('Preferred Communication Method'), 'option_url' => NULL, 'placeholder' => ts('- any -'))); + ['entity' => 'contact', 'multiple' => 'multiple', 'label' => ts('Preferred Communication Method'), 'option_url' => NULL, 'placeholder' => ts('- any -')]); //CRM-6138 Preferred Language - $form->addSelect('preferred_language', array('class' => 'twenty', 'context' => 'search')); + $form->addSelect('preferred_language', ['class' => 'twenty', 'context' => 'search']); // Phone search $form->addElement('text', 'phone_numeric', ts('Phone'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Phone', 'phone')); $locationType = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'); $phoneType = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id'); - $form->add('select', 'phone_location_type_id', ts('Phone Location'), array('' => ts('- any -')) + $locationType, FALSE, array('class' => 'crm-select2')); - $form->add('select', 'phone_phone_type_id', ts('Phone Type'), array('' => ts('- any -')) + $phoneType, FALSE, array('class' => 'crm-select2')); + $form->add('select', 'phone_location_type_id', ts('Phone Location'), ['' => ts('- any -')] + $locationType, FALSE, ['class' => 'crm-select2']); + $form->add('select', 'phone_phone_type_id', ts('Phone Type'), ['' => ts('- any -')] + $phoneType, FALSE, ['class' => 'crm-select2']); } /** @@ -343,21 +343,21 @@ public static function location(&$form) { $attributes = CRM_Core_DAO::getAttribute('CRM_Core_DAO_Address'); - $elements = array( - 'street_address' => array(ts('Street Address'), $attributes['street_address'], NULL, NULL), - 'supplemental_address_1' => array(ts('Supplemental Address 1'), $attributes['supplemental_address_1'], NULL, NULL), - 'supplemental_address_2' => array(ts('Supplemental Address 2'), $attributes['supplemental_address_2'], NULL, NULL), - 'supplemental_address_3' => array(ts('Supplemental Address 3'), $attributes['supplemental_address_3'], NULL, NULL), - 'city' => array(ts('City'), $attributes['city'], NULL, NULL), - 'postal_code' => array(ts('Postal Code'), $attributes['postal_code'], NULL, NULL), - 'country' => array(ts('Country'), $attributes['country_id'], 'country', FALSE), - 'state_province' => array(ts('State/Province'), $attributes['state_province_id'], 'stateProvince', TRUE), - 'county' => array(ts('County'), $attributes['county_id'], 'county', TRUE), - 'address_name' => array(ts('Address Name'), $attributes['address_name'], NULL, NULL), - 'street_number' => array(ts('Street Number'), $attributes['street_number'], NULL, NULL), - 'street_name' => array(ts('Street Name'), $attributes['street_name'], NULL, NULL), - 'street_unit' => array(ts('Apt/Unit/Suite'), $attributes['street_unit'], NULL, NULL), - ); + $elements = [ + 'street_address' => [ts('Street Address'), $attributes['street_address'], NULL, NULL], + 'supplemental_address_1' => [ts('Supplemental Address 1'), $attributes['supplemental_address_1'], NULL, NULL], + 'supplemental_address_2' => [ts('Supplemental Address 2'), $attributes['supplemental_address_2'], NULL, NULL], + 'supplemental_address_3' => [ts('Supplemental Address 3'), $attributes['supplemental_address_3'], NULL, NULL], + 'city' => [ts('City'), $attributes['city'], NULL, NULL], + 'postal_code' => [ts('Postal Code'), $attributes['postal_code'], NULL, NULL], + 'country' => [ts('Country'), $attributes['country_id'], 'country', FALSE], + 'state_province' => [ts('State/Province'), $attributes['state_province_id'], 'stateProvince', TRUE], + 'county' => [ts('County'), $attributes['county_id'], 'county', TRUE], + 'address_name' => [ts('Address Name'), $attributes['address_name'], NULL, NULL], + 'street_number' => [ts('Street Number'), $attributes['street_number'], NULL, NULL], + 'street_name' => [ts('Street Name'), $attributes['street_name'], NULL, NULL], + 'street_unit' => [ts('Apt/Unit/Suite'), $attributes['street_unit'], NULL, NULL], + ]; $parseStreetAddress = CRM_Utils_Array::value('street_address_parsing', $addressOptions, 0); $form->assign('parseStreetAddress', $parseStreetAddress); @@ -365,7 +365,7 @@ public static function location(&$form) { list($title, $attributes, $select, $multiSelect) = $v; if (in_array($name, - array('street_number', 'street_name', 'street_unit') + ['street_number', 'street_name', 'street_unit'] )) { if (!$parseStreetAddress) { continue; @@ -384,8 +384,8 @@ public static function location(&$form) { $element = $form->addChainSelect($name); } else { - $selectElements = array('' => ts('- any -')) + CRM_Core_PseudoConstant::$select(); - $element = $form->add('select', $name, $title, $selectElements, FALSE, array('class' => 'crm-select2')); + $selectElements = ['' => ts('- any -')] + CRM_Core_PseudoConstant::$select(); + $element = $form->add('select', $name, $title, $selectElements, FALSE, ['class' => 'crm-select2']); } if ($multiSelect) { $element->setMultiple(TRUE); @@ -396,34 +396,34 @@ public static function location(&$form) { } if ($addressOptions['postal_code']) { - $attr = array('class' => 'six') + (array) CRM_Utils_Array::value('postal_code', $attributes); - $form->addElement('text', 'postal_code_low', NULL, $attr + array('placeholder' => ts('From'))); - $form->addElement('text', 'postal_code_high', NULL, $attr + array('placeholder' => ts('To'))); + $attr = ['class' => 'six'] + (array) CRM_Utils_Array::value('postal_code', $attributes); + $form->addElement('text', 'postal_code_low', NULL, $attr + ['placeholder' => ts('From')]); + $form->addElement('text', 'postal_code_high', NULL, $attr + ['placeholder' => ts('To')]); } } // extend addresses with proximity search if (CRM_Utils_GeocodeProvider::getUsableClassName()) { - $form->addElement('text', 'prox_distance', ts('Find contacts within'), array('class' => 'six')); - $form->addElement('select', 'prox_distance_unit', NULL, array( + $form->addElement('text', 'prox_distance', ts('Find contacts within'), ['class' => 'six']); + $form->addElement('select', 'prox_distance_unit', NULL, [ 'miles' => ts('Miles'), 'kilos' => ts('Kilometers'), - )); + ]); $form->addRule('prox_distance', ts('Please enter positive number as a distance'), 'numeric'); } - $form->addSelect('world_region', array('entity' => 'address', 'context' => 'search')); + $form->addSelect('world_region', ['entity' => 'address', 'context' => 'search']); // select for location type $locationType = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'); - $form->add('select', 'location_type', ts('Address Location'), $locationType, FALSE, array( + $form->add('select', 'location_type', ts('Address Location'), $locationType, FALSE, [ 'multiple' => TRUE, 'class' => 'crm-select2', 'placeholder' => ts('Primary'), - )); + ]); // custom data extending addresses - CRM_Core_BAO_Query::addCustomFormFields($form, array('Address')); + CRM_Core_BAO_Query::addCustomFormFields($form, ['Address']); } /** @@ -443,8 +443,8 @@ public static function changeLog(&$form) { // block for change log $form->addElement('text', 'changed_by', ts('Modified By'), NULL); - $dates = array(1 => ts('Added'), 2 => ts('Modified')); - $form->addRadio('log_date', NULL, $dates, array('allowClear' => TRUE)); + $dates = [1 => ts('Added'), 2 => ts('Modified')]; + $form->addRadio('log_date', NULL, $dates, ['allowClear' => TRUE]); CRM_Core_Form_Date::buildDateRange($form, 'log_date', 1, '_low', '_high', ts('From:'), FALSE, FALSE); } @@ -462,23 +462,23 @@ public static function task(&$form) { public static function relationship(&$form) { $form->add('hidden', 'hidden_relationship', 1); - $allRelationshipType = array(); + $allRelationshipType = []; $allRelationshipType = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, NULL, NULL, NULL, TRUE); - $form->add('select', 'relation_type_id', ts('Relationship Type'), array('' => ts('- select -')) + $allRelationshipType, FALSE, array('multiple' => TRUE, 'class' => 'crm-select2')); + $form->add('select', 'relation_type_id', ts('Relationship Type'), ['' => ts('- select -')] + $allRelationshipType, FALSE, ['multiple' => TRUE, 'class' => 'crm-select2']); $form->addElement('text', 'relation_target_name', ts('Target Contact'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name')); // relation status - $relStatusOption = array(ts('Active'), ts('Inactive'), ts('All')); + $relStatusOption = [ts('Active'), ts('Inactive'), ts('All')]; $form->addRadio('relation_status', ts('Relationship Status'), $relStatusOption); - $form->setDefaults(array('relation_status' => 0)); + $form->setDefaults(['relation_status' => 0]); // relation permission $allRelationshipPermissions = CRM_Contact_BAO_Relationship::buildOptions('is_permission_a_b'); $form->add('select', 'relation_permission', ts('Permissioned Relationship'), - array('' => ts('- select -')) + $allRelationshipPermissions, FALSE, array('multiple' => TRUE, 'class' => 'crm-select2')); + ['' => ts('- select -')] + $allRelationshipPermissions, FALSE, ['multiple' => TRUE, 'class' => 'crm-select2']); //add the target group if ($form->_group) { $form->add('select', 'relation_target_group', ts('Target Contact(s) in Group'), $form->_group, FALSE, - array('id' => 'relation_target_group', 'multiple' => 'multiple', 'class' => 'crm-select2') + ['id' => 'relation_target_group', 'multiple' => 'multiple', 'class' => 'crm-select2'] ); } CRM_Core_Form_Date::buildDateRange($form, 'relation_start_date', 1, '_low', '_high', ts('From:'), FALSE, FALSE); @@ -490,7 +490,7 @@ public static function relationship(&$form) { CRM_Core_Form_Date::buildDateRange($form, 'relation_date', 1, '_low', '_high', ts('From:'), FALSE, FALSE); // add all the custom searchable fields - CRM_Core_BAO_Query::addCustomFormFields($form, array('Relationship')); + CRM_Core_BAO_Query::addCustomFormFields($form, ['Relationship']); } /** @@ -499,12 +499,12 @@ public static function relationship(&$form) { public static function demographics(&$form) { $form->add('hidden', 'hidden_demographics', 1); // radio button for gender - $genderOptions = array(); + $genderOptions = []; $gender = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id'); foreach ($gender as $key => $var) { $genderOptions[$key] = $form->createElement('radio', NULL, ts('Gender'), $var, $key, - array('id' => "civicrm_gender_{$var}_{$key}") + ['id' => "civicrm_gender_{$var}_{$key}"] ); } $form->addGroup($genderOptions, 'gender_id', ts('Gender'))->setAttribute('allowClear', TRUE); @@ -529,16 +529,16 @@ public static function demographics(&$form) { public static function notes(&$form) { $form->add('hidden', 'hidden_notes', 1); - $options = array( + $options = [ 2 => ts('Body Only'), 3 => ts('Subject Only'), 6 => ts('Both'), - ); + ]; $form->addRadio('note_option', '', $options); $form->addElement('text', 'note', ts('Note Text'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name')); - $form->setDefaults(array('note_option' => 6)); + $form->setDefaults(['note_option' => 6]); } /** @@ -548,7 +548,7 @@ public static function notes(&$form) { */ public static function custom(&$form) { $form->add('hidden', 'hidden_custom', 1); - $extends = array_merge(array('Contact', 'Individual', 'Household', 'Organization'), + $extends = array_merge(['Contact', 'Individual', 'Household', 'Organization'], CRM_Contact_BAO_ContactType::subTypes() ); $groupDetails = CRM_Core_BAO_CustomGroup::getGroupDetail(NULL, TRUE, diff --git a/CRM/Contact/Form/Search/Custom/ActivitySearch.php b/CRM/Contact/Form/Search/Custom/ActivitySearch.php index 1c7e4d4f8c06..afda78618c2c 100644 --- a/CRM/Contact/Form/Search/Custom/ActivitySearch.php +++ b/CRM/Contact/Form/Search/Custom/ActivitySearch.php @@ -47,7 +47,7 @@ public function __construct(&$formValues) { /** * Define the columns for search result rows */ - $this->_columns = array( + $this->_columns = [ ts('Name') => 'sort_name', ts('Status') => 'activity_status', ts('Activity Type') => 'activity_type', @@ -61,7 +61,7 @@ public function __construct(&$formValues) { ts('Duration') => 'duration', ts('Details') => 'details', ts('Assignee') => 'assignee', - ); + ]; $this->_groupId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'activity_status', @@ -107,7 +107,7 @@ public function buildForm(&$form) { ); // Select box for Activity Type - $activityType = array('' => ' - select activity - ') + CRM_Core_PseudoConstant::activityType(); + $activityType = ['' => ' - select activity - '] + CRM_Core_PseudoConstant::activityType(); $form->add('select', 'activity_type_id', ts('Activity Type'), $activityType, @@ -115,7 +115,7 @@ public function buildForm(&$form) { ); // textbox for Activity Status - $activityStatus = array('' => ' - select status - ') + CRM_Core_PseudoConstant::activityStatus(); + $activityStatus = ['' => ' - select status - '] + CRM_Core_PseudoConstant::activityStatus(); $form->add('select', 'activity_status_id', ts('Activity Status'), $activityStatus, @@ -123,8 +123,8 @@ public function buildForm(&$form) { ); // Activity Date range - $form->add('datepicker', 'start_date', ts('Activity Date From'), [], FALSE, array('time' => FALSE)); - $form->add('datepicker', 'end_date', ts('...through'), [], FALSE, array('time' => FALSE)); + $form->add('datepicker', 'start_date', ts('Activity Date From'), [], FALSE, ['time' => FALSE]); + $form->add('datepicker', 'end_date', ts('...through'), [], FALSE, ['time' => FALSE]); // Contact Name field $form->add('text', 'sort_name', ts('Contact Name')); @@ -133,7 +133,7 @@ public function buildForm(&$form) { * If you are using the sample template, this array tells the template fields to render * for the search form. */ - $form->assign('elements', array( + $form->assign('elements', [ 'contact_type', 'activity_subject', 'activity_type_id', @@ -141,7 +141,7 @@ public function buildForm(&$form) { 'start_date', 'end_date', 'sort_name', - )); + ]); } /** @@ -296,7 +296,7 @@ public function from() { * @return string */ public function where($includeContactIDs = FALSE) { - $clauses = array(); + $clauses = []; // add contact name search; search on primary name, source contact, assignee $contactname = $this->_formValues['sort_name']; @@ -337,7 +337,7 @@ public function where($includeContactIDs = FALSE) { } if ($includeContactIDs) { - $contactIDs = array(); + $contactIDs = []; foreach ($this->_formValues as $id => $value) { if ($value && substr($id, 0, CRM_Core_Form::CB_PREFIX_LEN) == CRM_Core_Form::CB_PREFIX @@ -430,10 +430,10 @@ public function buildACLClause($tableAlias = 'contact') { * @return array */ public static function formatSavedSearchFields($formValues) { - $dateFields = array( + $dateFields = [ 'start_date', 'end_date', - ); + ]; foreach ($formValues as $element => $value) { if (in_array($element, $dateFields) && !empty($value)) { $formValues[$element] = date('Y-m-d', strtotime($value)); diff --git a/CRM/Contact/Form/Search/Custom/Base.php b/CRM/Contact/Form/Search/Custom/Base.php index 5ecf0738abbd..b4edd5986d43 100644 --- a/CRM/Contact/Form/Search/Custom/Base.php +++ b/CRM/Contact/Form/Search/Custom/Base.php @@ -153,7 +153,7 @@ public function &columns() { * @param $formValues */ public static function includeContactIDs(&$sql, &$formValues) { - $contactIDs = array(); + $contactIDs = []; foreach ($formValues as $id => $value) { if ($value && substr($id, 0, CRM_Core_Form::CB_PREFIX_LEN) == CRM_Core_Form::CB_PREFIX @@ -200,17 +200,17 @@ public function addSortOffset(&$sql, $offset, $rowcount, $sort) { * @throws Exception */ public function validateUserSQL(&$sql, $onlyWhere = FALSE) { - $includeStrings = array('contact_a'); - $excludeStrings = array('insert', 'delete', 'update'); + $includeStrings = ['contact_a']; + $excludeStrings = ['insert', 'delete', 'update']; if (!$onlyWhere) { - $includeStrings += array('select', 'from', 'where', 'civicrm_contact'); + $includeStrings += ['select', 'from', 'where', 'civicrm_contact']; } foreach ($includeStrings as $string) { if (stripos($sql, $string) === FALSE) { CRM_Core_Error::fatal(ts('Could not find \'%1\' string in SQL clause.', - array(1 => $string) + [1 => $string] )); } } @@ -218,7 +218,7 @@ public function validateUserSQL(&$sql, $onlyWhere = FALSE) { foreach ($excludeStrings as $string) { if (preg_match('/(\s' . $string . ')|(' . $string . '\s)/i', $sql)) { CRM_Core_Error::fatal(ts('Found illegal \'%1\' string in SQL clause.', - array(1 => $string) + [1 => $string] )); } } diff --git a/CRM/Contact/Form/Search/Custom/Basic.php b/CRM/Contact/Form/Search/Custom/Basic.php index e497591e379c..9968ce95c867 100644 --- a/CRM/Contact/Form/Search/Custom/Basic.php +++ b/CRM/Contact/Form/Search/Custom/Basic.php @@ -44,7 +44,7 @@ class CRM_Contact_Form_Search_Custom_Basic extends CRM_Contact_Form_Search_Custo public function __construct(&$formValues) { parent::__construct($formValues); - $this->_columns = array( + $this->_columns = [ '' => 'contact_type', ts('Name') => 'sort_name', ts('Address') => 'street_address', @@ -54,10 +54,10 @@ public function __construct(&$formValues) { ts('Country') => 'country', ts('Email') => 'email', ts('Phone') => 'phone', - ); + ]; $params = CRM_Contact_BAO_Query::convertFormValues($this->_formValues); - $returnProperties = array(); + $returnProperties = []; $returnProperties['contact_sub_type'] = 1; $addressOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, @@ -65,13 +65,13 @@ public function __construct(&$formValues) { ); foreach ($this->_columns as $name => $field) { - if (in_array($field, array( + if (in_array($field, [ 'street_address', 'city', 'state_province', 'postal_code', 'country', - )) && empty($addressOptions[$field]) + ]) && empty($addressOptions[$field]) ) { unset($this->_columns[$name]); continue; @@ -88,21 +88,21 @@ public function __construct(&$formValues) { * @param CRM_Core_Form $form */ public function buildForm(&$form) { - $contactTypes = array('' => ts('- any contact type -')) + CRM_Contact_BAO_ContactType::getSelectElements(); - $form->add('select', 'contact_type', ts('Find...'), $contactTypes, FALSE, array('class' => 'crm-select2 huge')); + $contactTypes = ['' => ts('- any contact type -')] + CRM_Contact_BAO_ContactType::getSelectElements(); + $form->add('select', 'contact_type', ts('Find...'), $contactTypes, FALSE, ['class' => 'crm-select2 huge']); // add select for groups - $group = array('' => ts('- any group -')) + CRM_Core_PseudoConstant::nestedGroup(); - $form->addElement('select', 'group', ts('in'), $group, array('class' => 'crm-select2 huge')); + $group = ['' => ts('- any group -')] + CRM_Core_PseudoConstant::nestedGroup(); + $form->addElement('select', 'group', ts('in'), $group, ['class' => 'crm-select2 huge']); // add select for categories - $tag = array('' => ts('- any tag -')) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE)); - $form->addElement('select', 'tag', ts('Tagged'), $tag, array('class' => 'crm-select2 huge')); + $tag = ['' => ts('- any tag -')] + CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', ['onlyActive' => FALSE]); + $form->addElement('select', 'tag', ts('Tagged'), $tag, ['class' => 'crm-select2 huge']); // text for sort_name $form->add('text', 'sort_name', ts('Name')); - $form->assign('elements', array('sort_name', 'contact_type', 'group', 'tag')); + $form->assign('elements', ['sort_name', 'contact_type', 'group', 'tag']); } /** diff --git a/CRM/Contact/Form/Search/Custom/ContribSYBNT.php b/CRM/Contact/Form/Search/Custom/ContribSYBNT.php index db0809ab079a..326388909005 100644 --- a/CRM/Contact/Form/Search/Custom/ContribSYBNT.php +++ b/CRM/Contact/Form/Search/Custom/ContribSYBNT.php @@ -46,32 +46,32 @@ public function __construct(&$formValues) { $this->_formValues = self::formatSavedSearchFields($formValues); $this->_permissionedComponent = 'CiviContribute'; - $this->_columns = array( + $this->_columns = [ ts('Contact ID') => 'contact_id', ts('Name') => 'display_name', ts('Contribution Count') => 'donation_count', ts('Contribution Amount') => 'donation_amount', - ); + ]; - $this->_amounts = array( + $this->_amounts = [ 'min_amount_1' => ts('Min Amount One'), 'max_amount_1' => ts('Max Amount One'), 'min_amount_2' => ts('Min Amount Two'), 'max_amount_2' => ts('Max Amount Two'), 'exclude_min_amount' => ts('Exclusion Min Amount'), 'exclude_max_amount' => ts('Exclusion Max Amount'), - ); + ]; - $this->_dates = array( + $this->_dates = [ 'start_date_1' => ts('Start Date One'), 'end_date_1' => ts('End Date One'), 'start_date_2' => ts('Start Date Two'), 'end_date_2' => ts('End Date Two'), 'exclude_start_date' => ts('Exclusion Start Date'), 'exclude_end_date' => ts('Exclusion End Date'), - ); + ]; - $this->_checkboxes = array('is_first_amount' => ts('First Donation?')); + $this->_checkboxes = ['is_first_amount' => ts('First Donation?')]; foreach ($this->_amounts as $name => $title) { $this->{$name} = CRM_Utils_Array::value($name, $this->_formValues); @@ -101,7 +101,7 @@ public function buildForm(&$form) { } foreach ($this->_dates as $name => $title) { - $form->add('datepicker', $name, $title, array(), FALSE, array('time' => FALSE)); + $form->add('datepicker', $name, $title, [], FALSE, ['time' => FALSE]); } foreach ($this->_checkboxes as $name => $title) { @@ -241,25 +241,25 @@ public function from() { * @return string */ public function where($includeContactIDs = FALSE) { - $clauses = array(); + $clauses = []; if (!empty($this->start_date_1)) { - $clauses[] = CRM_Core_DAO::composeQuery('contrib_1.receive_date >= %1', array(1 => array($this->start_date_1, 'String'))); + $clauses[] = CRM_Core_DAO::composeQuery('contrib_1.receive_date >= %1', [1 => [$this->start_date_1, 'String']]); } if (!empty($this->end_date_1)) { - $clauses[] = CRM_Core_DAO::composeQuery('contrib_1.receive_date <= %1', array(1 => array($this->end_date_1, 'String'))); + $clauses[] = CRM_Core_DAO::composeQuery('contrib_1.receive_date <= %1', [1 => [$this->end_date_1, 'String']]); } if (!empty($this->start_date_2) || !empty($this->end_date_2)) { $clauses[] = "contrib_2.is_test = 0"; if (!empty($this->start_date_2)) { - $clauses[] = CRM_Core_DAO::composeQuery('contrib_2.receive_date >= %1', array(1 => array($this->start_date_2, 'String'))); + $clauses[] = CRM_Core_DAO::composeQuery('contrib_2.receive_date >= %1', [1 => [$this->start_date_2, 'String']]); } if (!empty($this->end_date_2)) { - $clauses[] = CRM_Core_DAO::composeQuery('contrib_2.receive_date <= %1', array(1 => array($this->end_date_2, 'String'))); + $clauses[] = CRM_Core_DAO::composeQuery('contrib_2.receive_date <= %1', [1 => [$this->end_date_2, 'String']]); } } @@ -275,13 +275,13 @@ public function where($includeContactIDs = FALSE) { $sql = "CREATE TEMPORARY TABLE XG_CustomSearch_SYBNT ( contact_id int primary key) ENGINE=HEAP"; CRM_Core_DAO::executeQuery($sql); - $excludeClauses = array(); + $excludeClauses = []; if ($this->exclude_start_date) { - $excludeClauses[] = CRM_Core_DAO::composeQuery('c.receive_date >= %1', array(1 => array($this->exclude_start_date, 'String'))); + $excludeClauses[] = CRM_Core_DAO::composeQuery('c.receive_date >= %1', [1 => [$this->exclude_start_date, 'String']]); } if ($this->exclude_end_date) { - $excludeClauses[] = CRM_Core_DAO::composeQuery('c.receive_date <= %1', array(1 => array($this->exclude_end_date, 'String'))); + $excludeClauses[] = CRM_Core_DAO::composeQuery('c.receive_date <= %1', [1 => [$this->exclude_end_date, 'String']]); } $excludeClause = NULL; @@ -289,7 +289,7 @@ public function where($includeContactIDs = FALSE) { $excludeClause = ' AND ' . implode(' AND ', $excludeClauses); } - $having = array(); + $having = []; if ($this->exclude_min_amount) { $having[] = "sum(c.total_amount) >= {$this->exclude_min_amount}"; } @@ -344,7 +344,7 @@ public function where($includeContactIDs = FALSE) { * @return string */ public function having($includeContactIDs = FALSE) { - $clauses = array(); + $clauses = []; $min = CRM_Utils_Array::value('min_amount', $this->_formValues); if ($min) { $clauses[] = "sum(contrib_1.total_amount) >= $min"; @@ -409,14 +409,14 @@ public function buildACLClause($tableAlias = 'contact') { * @return array */ public static function formatSavedSearchFields($formValues) { - $dateFields = array( + $dateFields = [ 'start_date_1', 'end_date_1', 'start_date_2', 'end_date_2', 'exclude_start_date', 'exclude_end_date', - ); + ]; foreach ($formValues as $element => $value) { if (in_array($element, $dateFields) && !empty($value)) { $formValues[$element] = date('Y-m-d', strtotime($value)); diff --git a/CRM/Contact/Form/Search/Custom/ContributionAggregate.php b/CRM/Contact/Form/Search/Custom/ContributionAggregate.php index 65b1c859dca4..f776f8448e2d 100644 --- a/CRM/Contact/Form/Search/Custom/ContributionAggregate.php +++ b/CRM/Contact/Form/Search/Custom/ContributionAggregate.php @@ -46,12 +46,12 @@ public function __construct(&$formValues) { $this->_formValues = $formValues; // Define the columns for search result rows - $this->_columns = array( + $this->_columns = [ ts('Contact ID') => 'contact_id', ts('Name') => 'sort_name', ts('Contribution Count') => 'donation_count', ts('Contribution Amount') => 'donation_amount', - ); + ]; // define component access permission needed $this->_permissionedComponent = 'CiviContribute'; @@ -86,14 +86,14 @@ public function buildForm(&$form) { CRM_Core_Form_Date::buildDateRange($form, 'contribution_date', 1, '_low', '_high', ts('From:'), FALSE, FALSE); $form->addSelect('financial_type_id', - array('entity' => 'contribution', 'multiple' => 'multiple', 'context' => 'search') + ['entity' => 'contribution', 'multiple' => 'multiple', 'context' => 'search'] ); /** * If you are using the sample template, this array tells the template fields to render * for the search form. */ - $form->assign('elements', array('min_amount', 'max_amount')); + $form->assign('elements', ['min_amount', 'max_amount']); } /** @@ -195,10 +195,10 @@ public function from() { * @return string */ public function where($includeContactIDs = FALSE) { - $clauses = array( + $clauses = [ "contrib.contact_id = contact_a.id", "contrib.is_test = 0", - ); + ]; foreach ([ 'contribution_date_relative', @@ -222,7 +222,7 @@ public function where($includeContactIDs = FALSE) { } if ($includeContactIDs) { - $contactIDs = array(); + $contactIDs = []; foreach ($this->_formValues as $id => $value) { if ($value && substr($id, 0, CRM_Core_Form::CB_PREFIX_LEN) == CRM_Core_Form::CB_PREFIX @@ -254,7 +254,7 @@ public function where($includeContactIDs = FALSE) { * @return string */ public function having($includeContactIDs = FALSE) { - $clauses = array(); + $clauses = []; $min = CRM_Utils_Array::value('min_amount', $this->_formValues); if ($min) { $min = CRM_Utils_Rule::cleanMoney($min); diff --git a/CRM/Contact/Form/Search/Custom/DateAdded.php b/CRM/Contact/Form/Search/Custom/DateAdded.php index fb6f378bf308..14916ac87770 100644 --- a/CRM/Contact/Form/Search/Custom/DateAdded.php +++ b/CRM/Contact/Form/Search/Custom/DateAdded.php @@ -45,32 +45,32 @@ class CRM_Contact_Form_Search_Custom_DateAdded extends CRM_Contact_Form_Search_C public function __construct(&$formValues) { $this->_formValues = self::formatSavedSearchFields($formValues); - $this->_includeGroups = CRM_Utils_Array::value('includeGroups', $formValues, array()); - $this->_excludeGroups = CRM_Utils_Array::value('excludeGroups', $formValues, array()); + $this->_includeGroups = CRM_Utils_Array::value('includeGroups', $formValues, []); + $this->_excludeGroups = CRM_Utils_Array::value('excludeGroups', $formValues, []); - $this->_columns = array( + $this->_columns = [ ts('Contact ID') => 'contact_id', ts('Contact Type') => 'contact_type', ts('Name') => 'sort_name', ts('Date Added') => 'date_added', - ); + ]; } /** * @param CRM_Core_Form $form */ public function buildForm(&$form) { - $form->add('datepicker', 'start_date', ts('Start Date'), [], FALSE, array('time' => FALSE)); - $form->add('datepicker', 'end_date', ts('End Date'), [], FALSE, array('time' => FALSE)); + $form->add('datepicker', 'start_date', ts('Start Date'), [], FALSE, ['time' => FALSE]); + $form->add('datepicker', 'end_date', ts('End Date'), [], FALSE, ['time' => FALSE]); $groups = CRM_Core_PseudoConstant::nestedGroup(); - $select2style = array( + $select2style = [ 'multiple' => TRUE, 'style' => 'width: 100%; max-width: 60em;', 'class' => 'crm-select2', 'placeholder' => ts('- select -'), - ); + ]; $form->add('select', 'includeGroups', ts('Include Group(s)'), @@ -101,7 +101,7 @@ public function buildForm(&$form) { * if you are using the standard template, this array tells the template what elements * are part of the search criteria */ - $form->assign('elements', array('start_date', 'end_date', 'includeGroups', 'excludeGroups')); + $form->assign('elements', ['start_date', 'end_date', 'includeGroups', 'excludeGroups']); } /** @@ -137,9 +137,9 @@ public function all( $includeContactIDs = FALSE, $justIDs = FALSE ) { - $this->_includeGroups = CRM_Utils_Array::value('includeGroups', $this->_formValues, array()); + $this->_includeGroups = CRM_Utils_Array::value('includeGroups', $this->_formValues, []); - $this->_excludeGroups = CRM_Utils_Array::value('excludeGroups', $this->_formValues, array()); + $this->_excludeGroups = CRM_Utils_Array::value('excludeGroups', $this->_formValues, []); $this->_allSearch = FALSE; $this->_groups = FALSE; @@ -215,7 +215,7 @@ public function from() { // CRM-6356 if ($this->_groups) { //block for Group search - $smartGroup = array(); + $smartGroup = []; $group = new CRM_Contact_DAO_Group(); $group->is_active = 1; $group->find(); @@ -430,10 +430,10 @@ public function buildACLClause($tableAlias = 'contact') { * @return array */ public static function formatSavedSearchFields($formValues) { - $dateFields = array( + $dateFields = [ 'start_date', 'end_date', - ); + ]; foreach ($formValues as $element => $value) { if (in_array($element, $dateFields) && !empty($value)) { $formValues[$element] = date('Y-m-d', strtotime($value)); diff --git a/CRM/Contact/Form/Search/Custom/EventAggregate.php b/CRM/Contact/Form/Search/Custom/EventAggregate.php index 9b3973145e31..004e080c28d7 100644 --- a/CRM/Contact/Form/Search/Custom/EventAggregate.php +++ b/CRM/Contact/Form/Search/Custom/EventAggregate.php @@ -44,12 +44,12 @@ class CRM_Contact_Form_Search_Custom_EventAggregate extends CRM_Contact_Form_Sea */ public function __construct(&$formValues) { $this->_formValues = self::formatSavedSearchFields($formValues); - $this->_permissionedComponent = array('CiviContribute', 'CiviEvent'); + $this->_permissionedComponent = ['CiviContribute', 'CiviEvent']; /** * Define the columns for search result rows */ - $this->_columns = array( + $this->_columns = [ ts('Event') => 'event_name', ts('Type') => 'event_type', ts('Number of
Participant') => 'participant_count', @@ -57,7 +57,7 @@ public function __construct(&$formValues) { ts('Fee') => 'fee', ts('Net Payment') => 'net_payment', ts('Participant') => 'participant', - ); + ]; } /** @@ -83,7 +83,7 @@ public function buildForm(&$form) { $form->addElement('checkbox', "event_type_id[$eventId]", 'Event Type', $eventName); } $events = CRM_Event_BAO_Event::getEvents(1); - $form->add('select', 'event_id', ts('Event Name'), array('' => ts('- select -')) + $events); + $form->add('select', 'event_id', ts('Event Name'), ['' => ts('- select -')] + $events); $form->add('datepicker', 'start_date', ts('Payments Date From'), [], FALSE, ['time' => FALSE]); $form->add('datepicker', 'end_date', ts('...through'), [], FALSE, ['time' => FALSE]); @@ -92,14 +92,14 @@ public function buildForm(&$form) { * If you are using the sample template, this array tells the template fields to render * for the search form. */ - $form->assign('elements', array( + $form->assign('elements', [ 'paid_online', 'start_date', 'end_date', 'show_payees', 'event_type_id', 'event_id', - )); + ]); } /** @@ -226,7 +226,7 @@ public function from() { * @return string */ public function where($includeContactIDs = FALSE) { - $clauses = array(); + $clauses = []; $clauses[] = "civicrm_participant.status_id in ( 1 )"; $clauses[] = "civicrm_contribution.is_test = 0"; @@ -251,7 +251,7 @@ public function where($includeContactIDs = FALSE) { } if ($includeContactIDs) { - $contactIDs = array(); + $contactIDs = []; foreach ($this->_formValues as $id => $value) { if ($value && substr($id, 0, CRM_Core_Form::CB_PREFIX_LEN) == CRM_Core_Form::CB_PREFIX @@ -309,7 +309,7 @@ public function summary() { $dao = CRM_Core_DAO::executeQuery($sql, CRM_Core_DAO::$_nullArray ); - $totals = array(); + $totals = []; while ($dao->fetch()) { $totals['payment_amount'] = $dao->payment_amount; $totals['fee'] = $dao->fee; @@ -384,10 +384,10 @@ public function buildACLClause($tableAlias = 'contact') { * @return array */ public static function formatSavedSearchFields($formValues) { - $dateFields = array( + $dateFields = [ 'start_date', 'end_date', - ); + ]; foreach ($formValues as $element => $value) { if (in_array($element, $dateFields) && !empty($value)) { $formValues[$element] = date('Y-m-d', strtotime($value)); diff --git a/CRM/Contact/Form/Search/Custom/FullText.php b/CRM/Contact/Form/Search/Custom/FullText.php index 44c0f399bef7..43dad2e26eb9 100644 --- a/CRM/Contact/Form/Search/Custom/FullText.php +++ b/CRM/Contact/Form/Search/Custom/FullText.php @@ -71,7 +71,7 @@ class CRM_Contact_Form_Search_Custom_FullText extends CRM_Contact_Form_Search_Cu protected $_limitNumber = 10; protected $_limitNumberPlus1 = 11; // this should be one more than self::LIMIT - protected $_foundRows = array(); + protected $_foundRows = []; /** * Class constructor. @@ -79,14 +79,14 @@ class CRM_Contact_Form_Search_Custom_FullText extends CRM_Contact_Form_Search_Cu * @param array $formValues */ public function __construct(&$formValues) { - $this->_partialQueries = array( + $this->_partialQueries = [ new CRM_Contact_Form_Search_Custom_FullText_Contact(), new CRM_Contact_Form_Search_Custom_FullText_Activity(), new CRM_Contact_Form_Search_Custom_FullText_Case(), new CRM_Contact_Form_Search_Custom_FullText_Contribution(), new CRM_Contact_Form_Search_Custom_FullText_Participant(), new CRM_Contact_Form_Search_Custom_FullText_Membership(), - ); + ]; $formValues['table'] = $this->getFieldValue($formValues, 'table', 'String'); $this->_table = $formValues['table']; @@ -95,8 +95,8 @@ public function __construct(&$formValues) { $this->_text = $formValues['text']; if (!$this->_table) { - $this->_limitClause = array($this->_limitNumberPlus1, NULL); - $this->_limitRowClause = $this->_limitDetailClause = array($this->_limitNumber, NULL); + $this->_limitClause = [$this->_limitNumberPlus1, NULL]; + $this->_limitRowClause = $this->_limitDetailClause = [$this->_limitNumber, NULL]; } else { // when there is table specified, we would like to use the pager. But since @@ -107,8 +107,8 @@ public function __construct(&$formValues) { $pageId = CRM_Utils_Array::value('crmPID', $_REQUEST, 1); $offset = ($pageId - 1) * $rowCount; $this->_limitClause = NULL; - $this->_limitRowClause = array($rowCount, NULL); - $this->_limitDetailClause = array($rowCount, $offset); + $this->_limitRowClause = [$rowCount, NULL]; + $this->_limitDetailClause = [$rowCount, $offset]; } $this->_formValues = $formValues; @@ -150,7 +150,7 @@ public function buildTempTable() { $table = CRM_Utils_SQL_TempTable::build()->setCategory('custom')->setMemory()->setUtf8(); $this->_tableName = $table->getName(); - $this->_tableFields = array( + $this->_tableFields = [ 'id' => 'int unsigned NOT NULL AUTO_INCREMENT', 'table_name' => 'varchar(16)', 'contact_id' => 'int unsigned', @@ -197,7 +197,7 @@ public function buildTempTable() { // We may have multiple files to list on one record. // The temporary-table approach can't store full details for all of them 'file_ids' => 'varchar(255)', // comma-separate id listing - ); + ]; $sql = " "; @@ -255,7 +255,7 @@ public function filterACLContacts() { CRM_Contact_BAO_Contact_Permission::cache($contactID); - $params = array(1 => array($contactID, 'Integer')); + $params = [1 => [$contactID, 'Integer']]; $sql = " DELETE t.* @@ -301,7 +301,7 @@ public function buildForm(&$form) { ); // also add a select box to allow the search to be constrained - $tables = array('' => ts('All tables')); + $tables = ['' => ts('All tables')]; foreach ($this->_partialQueries as $partialQuery) { /** @var $partialQuery CRM_Contact_Form_Search_Custom_FullText_AbstractPartialQuery */ if ($partialQuery->isActive()) { @@ -318,7 +318,7 @@ public function buildForm(&$form) { // set form defaults if (!empty($form->_formValues)) { - $defaults = array(); + $defaults = []; if (isset($form->_formValues['text'])) { $defaults['text'] = $form->_formValues['text']; @@ -345,10 +345,10 @@ public function buildForm(&$form) { * @return array */ public function &columns() { - $this->_columns = array( + $this->_columns = [ ts('Contact ID') => 'contact_id', ts('Name') => 'sort_name', - ); + ]; return $this->_columns; } @@ -359,10 +359,10 @@ public function &columns() { public function summary() { $this->initialize(); - $summary = array(); + $summary = []; foreach ($this->_partialQueries as $partialQuery) { /** @var $partialQuery CRM_Contact_Form_Search_Custom_FullText_AbstractPartialQuery */ - $summary[$partialQuery->getName()] = array(); + $summary[$partialQuery->getName()] = []; } // now iterate through the table and add entries to the relevant section @@ -375,7 +375,7 @@ public function summary() { $activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, TRUE); $roleIds = CRM_Event_PseudoConstant::participantRole(); while ($dao->fetch()) { - $row = array(); + $row = []; foreach ($this->_tableFields as $name => $dontCare) { if ($name != 'activity_type_id') { $row[$name] = $dao->$name; @@ -386,7 +386,7 @@ public function summary() { } if (isset($row['participant_role'])) { $participantRole = explode(CRM_Core_DAO::VALUE_SEPARATOR, $row['participant_role']); - $viewRoles = array(); + $viewRoles = []; foreach ($participantRole as $v) { $viewRoles[] = $roleIds[$v]; } @@ -406,7 +406,7 @@ public function summary() { $summary[$dao->table_name][] = $row; } - $summary['Count'] = array(); + $summary['Count'] = []; foreach (array_keys($summary) as $table) { $summary['Count'][$table] = CRM_Utils_Array::value($table, $this->_foundRows); if ($summary['Count'][$table] >= self::LIMIT) { @@ -510,7 +510,7 @@ public function templateFile() { * @return array */ public function setDefaultValues() { - return array(); + return []; } /** diff --git a/CRM/Contact/Form/Search/Custom/FullText/AbstractPartialQuery.php b/CRM/Contact/Form/Search/Custom/FullText/AbstractPartialQuery.php index 9cd6252184f1..2e3c9ade0c98 100644 --- a/CRM/Contact/Form/Search/Custom/FullText/AbstractPartialQuery.php +++ b/CRM/Contact/Form/Search/Custom/FullText/AbstractPartialQuery.php @@ -121,10 +121,10 @@ public function fillCustomInfo(&$tables, $extends) { $dao = CRM_Core_DAO::executeQuery($sql); while ($dao->fetch()) { if (!array_key_exists($dao->table_name, $tables)) { - $tables[$dao->table_name] = array( + $tables[$dao->table_name] = [ 'id' => 'entity_id', - 'fields' => array(), - ); + 'fields' => [], + ]; } $tables[$dao->table_name]['fields'][$dao->column_name] = NULL; } @@ -175,15 +175,15 @@ public function runQueries($queryText, &$tables, $entityIDTableName, $limit) { continue; } - $query = $tableValues + array( + $query = $tableValues + [ 'text' => CRM_Utils_QueryFormatter::singleton() ->format($queryText, CRM_Utils_QueryFormatter::LANG_SOLR), - ); + ]; list($intLimit, $intOffset) = $this->parseLimitOffset($limit); $files = $searcher->search($query, $intLimit, $intOffset); - $matches = array(); + $matches = []; foreach ($files as $file) { - $matches[] = array('entity_id' => $file['xparent_id']); + $matches[] = ['entity_id' => $file['xparent_id']]; } if ($matches) { $insertSql = CRM_Utils_SQL_Insert::into($entityIDTableName)->usingReplace()->rows($matches)->toSQL(); @@ -191,8 +191,8 @@ public function runQueries($queryText, &$tables, $entityIDTableName, $limit) { } } else { - $fullTextFields = array(); // array (string $sqlColumnName) - $clauses = array(); // array (string $sqlExpression) + $fullTextFields = []; // array (string $sqlColumnName) + $clauses = []; // array (string $sqlExpression) foreach ($tableValues['fields'] as $fieldName => $fieldType) { if ($fieldType == 'Int') { @@ -242,10 +242,10 @@ public function runQueries($queryText, &$tables, $entityIDTableName, $limit) { } } - return array( + return [ 'count' => CRM_Core_DAO::singleValueQuery("SELECT count(*) FROM {$entityIDTableName}"), 'files' => $files, - ); + ]; } /** @@ -277,16 +277,16 @@ public function moveFileIDs($toTable, $parentIdColumn, $files) { return; } - $filesIndex = CRM_Utils_Array::index(array('xparent_id', 'file_id'), $files); + $filesIndex = CRM_Utils_Array::index(['xparent_id', 'file_id'], $files); // ex: $filesIndex[$xparent_id][$file_id] = array(...the file record...); $dao = CRM_Core_DAO::executeQuery(" SELECT distinct {$parentIdColumn} FROM {$toTable} WHERE table_name = %1 - ", array( - 1 => array($this->getName(), 'String'), - )); + ", [ + 1 => [$this->getName(), 'String'], + ]); while ($dao->fetch()) { if (empty($filesIndex[$dao->{$parentIdColumn}])) { continue; @@ -295,11 +295,11 @@ public function moveFileIDs($toTable, $parentIdColumn, $files) { CRM_Core_DAO::executeQuery("UPDATE {$toTable} SET file_ids = %1 WHERE table_name = %2 AND {$parentIdColumn} = %3 - ", array( - 1 => array(implode(',', array_keys($filesIndex[$dao->{$parentIdColumn}])), 'String'), - 2 => array($this->getName(), 'String'), - 3 => array($dao->{$parentIdColumn}, 'Int'), - )); + ", [ + 1 => [implode(',', array_keys($filesIndex[$dao->{$parentIdColumn}])), 'String'], + 2 => [$this->getName(), 'String'], + 3 => [$dao->{$parentIdColumn}, 'Int'], + ]); } } @@ -338,7 +338,7 @@ public function parseLimitOffset($limit) { if (!$intOffset) { $intOffset = 0; } - return array($intLimit, $intOffset); + return [$intLimit, $intOffset]; } } diff --git a/CRM/Contact/Form/Search/Custom/FullText/Activity.php b/CRM/Contact/Form/Search/Custom/FullText/Activity.php index 350edb67a58c..9af565f7bb42 100644 --- a/CRM/Contact/Form/Search/Custom/FullText/Activity.php +++ b/CRM/Contact/Form/Search/Custom/FullText/Activity.php @@ -71,7 +71,7 @@ public function fillTempTable($queryText, $entityIDTableName, $toTable, $queryLi public function prepareQueries($queryText, $entityIDTableName) { // Note: For available full-text indices, see CRM_Core_InnoDBIndexer - $contactSQL = array(); + $contactSQL = []; $contactSQL[] = " SELECT distinct ca.id @@ -82,7 +82,7 @@ public function prepareQueries($queryText, $entityIDTableName) { LEFT JOIN civicrm_option_group og ON og.name = 'activity_type' LEFT JOIN civicrm_option_value ov ON ( ov.option_group_id = og.id ) WHERE ( - ({$this->matchText('civicrm_contact c', array('sort_name', 'display_name', 'nick_name'), $queryText)}) + ({$this->matchText('civicrm_contact c', ['sort_name', 'display_name', 'nick_name'], $queryText)}) OR ({$this->matchText('civicrm_email e', 'email', $queryText)} AND ca.activity_type_id = ov.value AND ov.name IN ('Inbound Email', 'Email') ) ) @@ -105,20 +105,20 @@ public function prepareQueries($queryText, $entityIDTableName) { $contactSQL[] = " SELECT distinct ca.id FROM civicrm_activity ca -WHERE ({$this->matchText('civicrm_activity ca', array('subject', 'details'), $queryText)}) +WHERE ({$this->matchText('civicrm_activity ca', ['subject', 'details'], $queryText)}) AND (ca.is_deleted = 0 OR ca.is_deleted IS NULL) "; - $final = array(); + $final = []; - $tables = array( - 'civicrm_activity' => array('fields' => array()), - 'file' => array( + $tables = [ + 'civicrm_activity' => ['fields' => []], + 'file' => [ 'xparent_table' => 'civicrm_activity', - ), + ], 'sql' => $contactSQL, 'final' => $final, - ); + ]; $this->fillCustomInfo($tables, "( 'Activity' )"); return $tables;; diff --git a/CRM/Contact/Form/Search/Custom/FullText/Case.php b/CRM/Contact/Form/Search/Custom/FullText/Case.php index b77497407915..bf3f7eede706 100644 --- a/CRM/Contact/Form/Search/Custom/FullText/Case.php +++ b/CRM/Contact/Form/Search/Custom/FullText/Case.php @@ -74,14 +74,14 @@ public function fillTempTable($queryText, $entityIDTableName, $toTable, $queryLi public function prepareQueries($queryText, $entityIDTableName) { // Note: For available full-text indices, see CRM_Core_InnoDBIndexer - $contactSQL = array(); + $contactSQL = []; $contactSQL[] = " SELECT distinct cc.id FROM civicrm_case cc LEFT JOIN civicrm_case_contact ccc ON cc.id = ccc.case_id LEFT JOIN civicrm_contact c ON ccc.contact_id = c.id -WHERE ({$this->matchText('civicrm_contact c', array('sort_name', 'display_name', 'nick_name'), $queryText)}) +WHERE ({$this->matchText('civicrm_contact c', ['sort_name', 'display_name', 'nick_name'], $queryText)}) AND (cc.is_deleted = 0 OR cc.is_deleted IS NULL) "; @@ -106,13 +106,13 @@ public function prepareQueries($queryText, $entityIDTableName) { GROUP BY et.entity_id "; - $tables = array( - 'civicrm_case' => array('fields' => array()), - 'file' => array( + $tables = [ + 'civicrm_case' => ['fields' => []], + 'file' => [ 'xparent_table' => 'civicrm_case', - ), + ], 'sql' => $contactSQL, - ); + ]; return $tables; } diff --git a/CRM/Contact/Form/Search/Custom/FullText/Contact.php b/CRM/Contact/Form/Search/Custom/FullText/Contact.php index 375509e12d59..4930e99cd160 100644 --- a/CRM/Contact/Form/Search/Custom/FullText/Contact.php +++ b/CRM/Contact/Form/Search/Custom/FullText/Contact.php @@ -70,7 +70,7 @@ public function fillTempTable($queryText, $entityIDTableName, $toTable, $queryLi public function prepareQueries($queryText, $entityIDTableName) { // Note: For available full-text indices, see CRM_Core_InnoDBIndexer - $contactSQL = array(); + $contactSQL = []; $contactSQL[] = " SELECT et.entity_id FROM civicrm_entity_tag et @@ -84,48 +84,48 @@ public function prepareQueries($queryText, $entityIDTableName) { // lets delete all the deceased contacts from the entityID box // this allows us to keep numbers in sync // when we have acl contacts, the situation gets even more murky - $final = array(); + $final = []; $final[] = "DELETE FROM {$entityIDTableName} WHERE entity_id IN (SELECT id FROM civicrm_contact WHERE is_deleted = 1)"; - $tables = array( - 'civicrm_contact' => array( + $tables = [ + 'civicrm_contact' => [ 'id' => 'id', - 'fields' => array( + 'fields' => [ 'sort_name' => NULL, 'nick_name' => NULL, 'display_name' => NULL, - ), - ), - 'civicrm_address' => array( + ], + ], + 'civicrm_address' => [ 'id' => 'contact_id', - 'fields' => array( + 'fields' => [ 'street_address' => NULL, 'city' => NULL, 'postal_code' => NULL, - ), - ), - 'civicrm_email' => array( + ], + ], + 'civicrm_email' => [ 'id' => 'contact_id', - 'fields' => array('email' => NULL), - ), - 'civicrm_phone' => array( + 'fields' => ['email' => NULL], + ], + 'civicrm_phone' => [ 'id' => 'contact_id', - 'fields' => array('phone' => NULL), - ), - 'civicrm_note' => array( + 'fields' => ['phone' => NULL], + ], + 'civicrm_note' => [ 'id' => 'entity_id', 'entity_table' => 'civicrm_contact', - 'fields' => array( + 'fields' => [ 'subject' => NULL, 'note' => NULL, - ), - ), - 'file' => array( + ], + ], + 'file' => [ 'xparent_table' => 'civicrm_contact', - ), + ], 'sql' => $contactSQL, 'final' => $final, - ); + ]; // get the custom data info $this->fillCustomInfo($tables, diff --git a/CRM/Contact/Form/Search/Custom/FullText/Contribution.php b/CRM/Contact/Form/Search/Custom/FullText/Contribution.php index b6e0345ba1ae..758dcedfc3be 100644 --- a/CRM/Contact/Form/Search/Custom/FullText/Contribution.php +++ b/CRM/Contact/Form/Search/Custom/FullText/Contribution.php @@ -74,38 +74,38 @@ public function fillTempTable($queryText, $entityIDTableName, $toTable, $queryLi public function prepareQueries($queryText, $entityIDTableName) { // Note: For available full-text indices, see CRM_Core_InnoDBIndexer - $contactSQL = array(); + $contactSQL = []; $contactSQL[] = " SELECT distinct cc.id FROM civicrm_contribution cc INNER JOIN civicrm_contact c ON cc.contact_id = c.id -WHERE ({$this->matchText('civicrm_contact c', array('sort_name', 'display_name', 'nick_name'), $queryText)}) +WHERE ({$this->matchText('civicrm_contact c', ['sort_name', 'display_name', 'nick_name'], $queryText)}) "; - $tables = array( - 'civicrm_contribution' => array( + $tables = [ + 'civicrm_contribution' => [ 'id' => 'id', - 'fields' => array( + 'fields' => [ 'source' => NULL, 'amount_level' => NULL, 'trxn_Id' => NULL, 'invoice_id' => NULL, 'check_number' => 'Int', // Odd: This is really a VARCHAR, so why are we searching like an INT? 'total_amount' => 'Int', - ), - ), - 'file' => array( + ], + ], + 'file' => [ 'xparent_table' => 'civicrm_contribution', - ), + ], 'sql' => $contactSQL, - 'civicrm_note' => array( + 'civicrm_note' => [ 'id' => 'entity_id', 'entity_table' => 'civicrm_contribution', - 'fields' => array( + 'fields' => [ 'subject' => NULL, 'note' => NULL, - ), - ), - ); + ], + ], + ]; // get the custom data info $this->fillCustomInfo($tables, "( 'Contribution' )"); diff --git a/CRM/Contact/Form/Search/Custom/FullText/Membership.php b/CRM/Contact/Form/Search/Custom/FullText/Membership.php index 926b5bb8739c..f81694b6cf50 100644 --- a/CRM/Contact/Form/Search/Custom/FullText/Membership.php +++ b/CRM/Contact/Form/Search/Custom/FullText/Membership.php @@ -75,23 +75,23 @@ public function fillTempTable($queryText, $entityIDTableName, $toTable, $queryLi public function prepareQueries($queryText, $entityIDTableName) { // Note: For available full-text indices, see CRM_Core_InnoDBIndexer - $contactSQL = array(); + $contactSQL = []; $contactSQL[] = " SELECT distinct cm.id FROM civicrm_membership cm INNER JOIN civicrm_contact c ON cm.contact_id = c.id -WHERE ({$this->matchText('civicrm_contact c', array('sort_name', 'display_name', 'nick_name'), $queryText)}) +WHERE ({$this->matchText('civicrm_contact c', ['sort_name', 'display_name', 'nick_name'], $queryText)}) "; - $tables = array( - 'civicrm_membership' => array( + $tables = [ + 'civicrm_membership' => [ 'id' => 'id', - 'fields' => array('source' => NULL), - ), - 'file' => array( + 'fields' => ['source' => NULL], + ], + 'file' => [ 'xparent_table' => 'civicrm_membership', - ), + ], 'sql' => $contactSQL, - ); + ]; // get the custom data info $this->fillCustomInfo($tables, "( 'Membership' )"); diff --git a/CRM/Contact/Form/Search/Custom/FullText/Participant.php b/CRM/Contact/Form/Search/Custom/FullText/Participant.php index ad1da5af19ea..20bbbd3e4deb 100644 --- a/CRM/Contact/Form/Search/Custom/FullText/Participant.php +++ b/CRM/Contact/Form/Search/Custom/FullText/Participant.php @@ -75,35 +75,35 @@ public function fillTempTable($queryText, $entityIDTableName, $toTable, $queryLi public function prepareQueries($queryText, $entityIDTableName) { // Note: For available full-text indices, see CRM_Core_InnoDBIndexer - $contactSQL = array(); + $contactSQL = []; $contactSQL[] = " SELECT distinct cp.id FROM civicrm_participant cp INNER JOIN civicrm_contact c ON cp.contact_id = c.id -WHERE ({$this->matchText('civicrm_contact c', array('sort_name', 'display_name', 'nick_name'), $queryText)}) +WHERE ({$this->matchText('civicrm_contact c', ['sort_name', 'display_name', 'nick_name'], $queryText)}) "; - $tables = array( - 'civicrm_participant' => array( + $tables = [ + 'civicrm_participant' => [ 'id' => 'id', - 'fields' => array( + 'fields' => [ 'source' => NULL, 'fee_level' => NULL, 'fee_amount' => 'Int', - ), - ), - 'file' => array( + ], + ], + 'file' => [ 'xparent_table' => 'civicrm_participant', - ), + ], 'sql' => $contactSQL, - 'civicrm_note' => array( + 'civicrm_note' => [ 'id' => 'entity_id', 'entity_table' => 'civicrm_participant', - 'fields' => array( + 'fields' => [ 'subject' => NULL, 'note' => NULL, - ), - ), - ); + ], + ], + ]; // get the custom data info $this->fillCustomInfo($tables, "( 'Participant' )"); diff --git a/CRM/Contact/Form/Search/Custom/Group.php b/CRM/Contact/Form/Search/Custom/Group.php index b4fb09717a92..76c7efbc369a 100644 --- a/CRM/Contact/Form/Search/Custom/Group.php +++ b/CRM/Contact/Form/Search/Custom/Group.php @@ -48,18 +48,18 @@ class CRM_Contact_Form_Search_Custom_Group extends CRM_Contact_Form_Search_Custo */ public function __construct(&$formValues) { $this->_formValues = $formValues; - $this->_columns = array( + $this->_columns = [ ts('Contact ID') => 'contact_id', ts('Contact Type') => 'contact_type', ts('Name') => 'sort_name', ts('Group Name') => 'gname', ts('Tag Name') => 'tname', - ); + ]; - $this->_includeGroups = CRM_Utils_Array::value('includeGroups', $this->_formValues, array()); - $this->_excludeGroups = CRM_Utils_Array::value('excludeGroups', $this->_formValues, array()); - $this->_includeTags = CRM_Utils_Array::value('includeTags', $this->_formValues, array()); - $this->_excludeTags = CRM_Utils_Array::value('excludeTags', $this->_formValues, array()); + $this->_includeGroups = CRM_Utils_Array::value('includeGroups', $this->_formValues, []); + $this->_excludeGroups = CRM_Utils_Array::value('excludeGroups', $this->_formValues, []); + $this->_includeTags = CRM_Utils_Array::value('includeTags', $this->_formValues, []); + $this->_excludeTags = CRM_Utils_Array::value('excludeTags', $this->_formValues, []); //define variables $this->_allSearch = FALSE; @@ -95,19 +95,19 @@ public function buildForm(&$form) { $groups = CRM_Core_PseudoConstant::nestedGroup(); - $tags = CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE)); + $tags = CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', ['onlyActive' => FALSE]); if (count($groups) == 0 || count($tags) == 0) { CRM_Core_Session::setStatus(ts("At least one Group and Tag must be present for Custom Group / Tag search."), ts('Missing Group/Tag')); $url = CRM_Utils_System::url('civicrm/contact/search/custom/list', 'reset=1'); CRM_Utils_System::redirect($url); } - $select2style = array( + $select2style = [ 'multiple' => TRUE, 'style' => 'width: 100%; max-width: 60em;', 'class' => 'crm-select2', 'placeholder' => ts('- select -'), - ); + ]; $form->add('select', 'includeGroups', ts('Include Group(s)'), @@ -123,10 +123,10 @@ public function buildForm(&$form) { $select2style ); - $andOr = array( + $andOr = [ '1' => ts('Show contacts that meet the Groups criteria AND the Tags criteria'), '0' => ts('Show contacts that meet the Groups criteria OR the Tags criteria'), - ); + ]; $form->addRadio('andOr', ts('AND/OR'), $andOr, NULL, '
', TRUE); $form->add('select', 'includeTags', @@ -147,7 +147,7 @@ public function buildForm(&$form) { * if you are using the standard template, this array tells the template what elements * are part of the search criteria */ - $form->assign('elements', array('includeGroups', 'excludeGroups', 'andOr', 'includeTags', 'excludeTags')); + $form->assign('elements', ['includeGroups', 'excludeGroups', 'andOr', 'includeTags', 'excludeTags']); } /** @@ -247,7 +247,7 @@ public function from() { $this->_tableName = "civicrm_temp_custom_{$randomNum}"; //block for Group search - $smartGroup = array(); + $smartGroup = []; if ($this->_groups || $this->_allSearch) { $group = new CRM_Contact_DAO_Group(); $group->is_active = 1; @@ -503,8 +503,8 @@ public function from() { /* * Set from statement depending on array sel */ - $whereitems = array(); - foreach (array('Ig', 'It') as $inc) { + $whereitems = []; + foreach (['Ig', 'It'] as $inc) { if ($this->_andOr == 1) { if ($$inc) { $from .= " INNER JOIN {$inc}_{$this->_tableName} temptable$inc ON (contact_a.id = temptable$inc.contact_id)"; @@ -520,7 +520,7 @@ public function from() { } } $this->_where = $whereitems ? "(" . implode(' OR ', $whereitems) . ')' : '(1)'; - foreach (array('Xg', 'Xt') as $exc) { + foreach (['Xg', 'Xt'] as $exc) { if ($$exc) { $from .= " LEFT JOIN {$exc}_{$this->_tableName} temptable$exc ON (contact_a.id = temptable$exc.contact_id)"; $this->_where .= " AND temptable$exc.contact_id IS NULL"; @@ -547,7 +547,7 @@ public function from() { */ public function where($includeContactIDs = FALSE) { if ($includeContactIDs) { - $contactIDs = array(); + $contactIDs = []; foreach ($this->_formValues as $id => $value) { if ($value && diff --git a/CRM/Contact/Form/Search/Custom/MultipleValues.php b/CRM/Contact/Form/Search/Custom/MultipleValues.php index e6ace98635ed..2737366bdb1e 100644 --- a/CRM/Contact/Form/Search/Custom/MultipleValues.php +++ b/CRM/Contact/Form/Search/Custom/MultipleValues.php @@ -37,7 +37,7 @@ class CRM_Contact_Form_Search_Custom_MultipleValues extends CRM_Contact_Form_Sea protected $_options; protected $_aclFrom = NULL; protected $_aclWhere = NULL; - protected $fieldInfo = array(); + protected $fieldInfo = []; /** * Class constructor. @@ -53,11 +53,11 @@ public function __construct(&$formValues) { $this->_tag = CRM_Utils_Array::value('tag', $this->_formValues); - $this->_columns = array( + $this->_columns = [ ts('Contact ID') => 'contact_id', ts('Contact Type') => 'contact_type', ts('Name') => 'sort_name', - ); + ]; $this->_customGroupIDs = CRM_Utils_Array::value('custom_group', $formValues); @@ -70,7 +70,7 @@ public function __construct(&$formValues) { * Add all the fields for chosen groups */ public function addColumns() { - $this->_tables = array(); + $this->_tables = []; foreach ($this->_groupTree as $groupID => $group) { if (empty($this->_customGroupIDs[$groupID])) { continue; @@ -82,7 +82,7 @@ public function addColumns() { foreach ($group['fields'] as $fieldID => $field) { $this->_columns[$field['label']] = "custom_{$field['id']}"; if (!array_key_exists($group['table_name'], $this->_tables)) { - $this->_tables[$group['table_name']] = array(); + $this->_tables[$group['table_name']] = []; } $this->_tables[$group['table_name']][$field['id']] = $field['column_name']; } @@ -98,16 +98,16 @@ public function buildForm(&$form) { $form->add('text', 'sort_name', ts('Contact Name'), TRUE); - $contactTypes = array('' => ts('- any contact type -')) + CRM_Contact_BAO_ContactType::getSelectElements(); - $form->add('select', 'contact_type', ts('Find...'), $contactTypes, array('class' => 'crm-select2 huge')); + $contactTypes = ['' => ts('- any contact type -')] + CRM_Contact_BAO_ContactType::getSelectElements(); + $form->add('select', 'contact_type', ts('Find...'), $contactTypes, ['class' => 'crm-select2 huge']); // add select for groups - $group = array('' => ts('- any group -')) + CRM_Core_PseudoConstant::group(); - $form->addElement('select', 'group', ts('in'), $group, array('class' => 'crm-select2 huge')); + $group = ['' => ts('- any group -')] + CRM_Core_PseudoConstant::group(); + $form->addElement('select', 'group', ts('in'), $group, ['class' => 'crm-select2 huge']); // add select for tags - $tag = array('' => ts('- any tag -')) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE)); - $form->addElement('select', 'tag', ts('Tagged'), $tag, array('class' => 'crm-select2 huge')); + $tag = ['' => ts('- any tag -')] + CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', ['onlyActive' => FALSE]); + $form->addElement('select', 'tag', ts('Tagged'), $tag, ['class' => 'crm-select2 huge']); if (empty($this->_groupTree)) { CRM_Core_Error::statusBounce(ts("Atleast one Custom Group must be present, for Custom Group search."), @@ -178,7 +178,7 @@ public function all($offset = 0, $rowcount = 0, $sort = NULL, $includeContactIDs "; } - $customClauses = array(); + $customClauses = []; foreach ($this->_tables as $tableName => $fields) { foreach ($fields as $fieldID => $fieldName) { $customClauses[] = "{$tableName}.{$fieldName} as custom_{$fieldID}"; @@ -198,7 +198,7 @@ public function all($offset = 0, $rowcount = 0, $sort = NULL, $includeContactIDs public function from() { $this->buildACLClause('contact_a'); $from = "FROM civicrm_contact contact_a {$this->_aclFrom}"; - $customFrom = array(); + $customFrom = []; // lets do an INNER JOIN so we get only relevant values rather than all values if (!empty($this->_tables)) { foreach ($this->_tables as $tableName => $fields) { @@ -228,8 +228,8 @@ public function from() { */ public function where($includeContactIDs = FALSE) { $count = 1; - $clause = array(); - $params = array(); + $clause = []; + $params = []; $name = CRM_Utils_Array::value('sort_name', $this->_formValues ); @@ -237,7 +237,7 @@ public function where($includeContactIDs = FALSE) { if (strpos($name, '%') === FALSE) { $name = "%{$name}%"; } - $params[$count] = array($name, 'String'); + $params[$count] = [$name, 'String']; $clause[] = "contact_a.sort_name LIKE %{$count}"; $count++; } diff --git a/CRM/Contact/Form/Search/Custom/PostalMailing.php b/CRM/Contact/Form/Search/Custom/PostalMailing.php index 17c9a8c2f1ef..865740f7deed 100644 --- a/CRM/Contact/Form/Search/Custom/PostalMailing.php +++ b/CRM/Contact/Form/Search/Custom/PostalMailing.php @@ -41,7 +41,7 @@ class CRM_Contact_Form_Search_Custom_PostalMailing extends CRM_Contact_Form_Sear public function __construct(&$formValues) { parent::__construct($formValues); - $this->_columns = array( + $this->_columns = [ // If possible, don't use aliases for the columns you select. // You can prefix columns with table aliases, if needed. // @@ -59,21 +59,21 @@ public function __construct(&$formValues) { // If you don't do this, the patch of CRM-16587 might cause database // errors. ts('State') => 'state_province.name', - ); + ]; } /** * @param CRM_Core_Form $form */ public function buildForm(&$form) { - $groups = array('' => ts('- select group -')) + CRM_Core_PseudoConstant::nestedGroup(FALSE); - $form->addElement('select', 'group_id', ts('Group'), $groups, array('class' => 'crm-select2 huge')); + $groups = ['' => ts('- select group -')] + CRM_Core_PseudoConstant::nestedGroup(FALSE); + $form->addElement('select', 'group_id', ts('Group'), $groups, ['class' => 'crm-select2 huge']); /** * if you are using the standard template, this array tells the template what elements * are part of the search criteria */ - $form->assign('elements', array('group_id')); + $form->assign('elements', ['group_id']); } /** @@ -148,15 +148,15 @@ public function from() { * @return string */ public function where($includeContactIDs = FALSE) { - $params = array(); + $params = []; $count = 1; - $clause = array(); + $clause = []; $groupID = CRM_Utils_Array::value('group_id', $this->_formValues ); if ($groupID) { - $params[$count] = array($groupID, 'Integer'); + $params[$count] = [$groupID, 'Integer']; $clause[] = "cgc.group_id = %{$count}"; } diff --git a/CRM/Contact/Form/Search/Custom/PriceSet.php b/CRM/Contact/Form/Search/Custom/PriceSet.php index f62b8e010d50..3253fffb8131 100644 --- a/CRM/Contact/Form/Search/Custom/PriceSet.php +++ b/CRM/Contact/Form/Search/Custom/PriceSet.php @@ -81,11 +81,11 @@ public function buildTempTable() { "; foreach ($this->_columns as $dontCare => $fieldName) { - if (in_array($fieldName, array( + if (in_array($fieldName, [ 'contact_id', 'participant_id', 'display_name', - ))) { + ])) { continue; } $sql .= "{$fieldName} int default 0,\n"; @@ -133,12 +133,12 @@ public function fillTable() { $dao = CRM_Core_DAO::executeQuery($sql); // first store all the information by option value id - $rows = array(); + $rows = []; while ($dao->fetch()) { $contactID = $dao->contact_id; $participantID = $dao->participant_id; if (!isset($rows[$participantID])) { - $rows[$participantID] = array(); + $rows[$participantID] = []; } $rows[$participantID][] = "price_field_{$dao->price_field_value_id} = {$dao->qty}"; @@ -176,9 +176,9 @@ public function priceSetDAO($eventID = NULL) { AND p.entity_id = e.id "; - $params = array(); + $params = []; if ($eventID) { - $params[1] = array($eventID, 'Integer'); + $params[1] = [$eventID, 'Integer']; $sql .= " AND e.id = $eventID"; } @@ -196,7 +196,7 @@ public function priceSetDAO($eventID = NULL) { public function buildForm(&$form) { $dao = $this->priceSetDAO(); - $event = array(); + $event = []; while ($dao->fetch()) { $event[$dao->id] = $dao->title; } @@ -221,15 +221,15 @@ public function buildForm(&$form) { * if you are using the standard template, this array tells the template what elements * are part of the search criteria */ - $form->assign('elements', array('event_id')); + $form->assign('elements', ['event_id']); } public function setColumns() { - $this->_columns = array( + $this->_columns = [ ts('Contact ID') => 'contact_id', ts('Participant ID') => 'participant_id', ts('Name') => 'display_name', - ); + ]; if (!$this->_eventID) { return; @@ -292,10 +292,10 @@ public function all( contact_a.display_name as display_name"; foreach ($this->_columns as $dontCare => $fieldName) { - if (in_array($fieldName, array( + if (in_array($fieldName, [ 'contact_id', 'display_name', - ))) { + ])) { continue; } $selectClause .= ",\ntempTable.{$fieldName} as {$fieldName}"; diff --git a/CRM/Contact/Form/Search/Custom/Proximity.php b/CRM/Contact/Form/Search/Custom/Proximity.php index f1742af37ba8..4d382d46fa7b 100644 --- a/CRM/Contact/Form/Search/Custom/Proximity.php +++ b/CRM/Contact/Form/Search/Custom/Proximity.php @@ -74,14 +74,14 @@ public function __construct(&$formValues) { $this->_tag = CRM_Utils_Array::value('tag', $this->_formValues); - $this->_columns = array( + $this->_columns = [ ts('Name') => 'sort_name', ts('Street Address') => 'street_address', ts('City') => 'city', ts('Postal Code') => 'postal_code', ts('State') => 'state_province', ts('Country') => 'country', - ); + ]; } /** @@ -103,7 +103,7 @@ public function buildForm(&$form) { $form->add('text', 'distance', ts('Distance'), NULL, TRUE); - $proxUnits = array('km' => ts('km'), 'miles' => ts('miles')); + $proxUnits = ['km' => ts('km'), 'miles' => ts('miles')]; $form->add('select', 'prox_distance_unit', ts('Units'), $proxUnits, TRUE); $form->add('text', @@ -121,23 +121,23 @@ public function buildForm(&$form) { ts('Postal Code') ); - $defaults = array(); + $defaults = []; if ($countryDefault) { $defaults['country_id'] = $countryDefault; } $form->addChainSelect('state_province_id'); - $country = array('' => ts('- select -')) + CRM_Core_PseudoConstant::country(); - $form->add('select', 'country_id', ts('Country'), $country, TRUE, array('class' => 'crm-select2')); + $country = ['' => ts('- select -')] + CRM_Core_PseudoConstant::country(); + $form->add('select', 'country_id', ts('Country'), $country, TRUE, ['class' => 'crm-select2']); $form->add('text', 'geo_code_1', ts('Latitude')); $form->add('text', 'geo_code_2', ts('Longitude')); - $group = array('' => ts('- any group -')) + CRM_Core_PseudoConstant::nestedGroup(); - $form->addElement('select', 'group', ts('Group'), $group, array('class' => 'crm-select2 huge')); + $group = ['' => ts('- any group -')] + CRM_Core_PseudoConstant::nestedGroup(); + $form->addElement('select', 'group', ts('Group'), $group, ['class' => 'crm-select2 huge']); - $tag = array('' => ts('- any tag -')) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE)); - $form->addElement('select', 'tag', ts('Tag'), $tag, array('class' => 'crm-select2 huge')); + $tag = ['' => ts('- any tag -')] + CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', ['onlyActive' => FALSE]); + $form->addElement('select', 'tag', ts('Tag'), $tag, ['class' => 'crm-select2 huge']); /** * You can define a custom title for the search form @@ -148,7 +148,7 @@ public function buildForm(&$form) { * if you are using the standard template, this array tells the template what elements * are part of the search criteria */ - $form->assign('elements', array( + $form->assign('elements', [ 'distance', 'prox_distance_unit', 'street_address', @@ -158,7 +158,7 @@ public function buildForm(&$form) { 'state_province_id', 'group', 'tag', - )); + ]); } /** @@ -275,7 +275,7 @@ public function setDefaultValues() { $config = CRM_Core_Config::singleton(); $countryDefault = $config->defaultContactCountry; $stateprovinceDefault = $config->defaultContactStateProvince; - $defaults = array(); + $defaults = []; if ($countryDefault) { if ($countryDefault == '1228' || $countryDefault == '1226') { diff --git a/CRM/Contact/Form/Search/Custom/RandomSegment.php b/CRM/Contact/Form/Search/Custom/RandomSegment.php index 391ed0ec5089..57e45eb016b4 100644 --- a/CRM/Contact/Form/Search/Custom/RandomSegment.php +++ b/CRM/Contact/Form/Search/Custom/RandomSegment.php @@ -44,12 +44,12 @@ class CRM_Contact_Form_Search_Custom_RandomSegment extends CRM_Contact_Form_Sear public function __construct(&$formValues) { parent::__construct($formValues); - $this->_columns = array( + $this->_columns = [ ts('Contact ID') => 'contact_id', ts('Contact Type') => 'contact_type', ts('Name') => 'sort_name', ts('Email') => 'email', - ); + ]; $this->initialize(); } @@ -87,12 +87,12 @@ public function buildForm(&$form) { $groups = CRM_Core_PseudoConstant::nestedGroup(); - $select2style = array( + $select2style = [ 'multiple' => TRUE, 'style' => 'width: 100%; max-width: 60em;', 'class' => 'crm-select2', 'placeholder' => ts('- select -'), - ); + ]; $form->add('select', 'includeGroups', ts('Include Group(s)'), @@ -114,7 +114,7 @@ public function buildForm(&$form) { * if you are using the standard template, this array tells the template what elements * are part of the search criteria */ - $form->assign('elements', array('segmentSize', 'includeGroups', 'excludeGroups')); + $form->assign('elements', ['segmentSize', 'includeGroups', 'excludeGroups']); } /** @@ -162,7 +162,7 @@ public function from() { $this->_tableName = "civicrm_temp_custom_{$randomNum}"; //block for Group search - $smartGroup = array(); + $smartGroup = []; $group = new CRM_Contact_DAO_Group(); $group->is_active = 1; $group->find(); diff --git a/CRM/Contact/Form/Search/Custom/Sample.php b/CRM/Contact/Form/Search/Custom/Sample.php index 5e12d8a8cfb2..197985fd94c4 100644 --- a/CRM/Contact/Form/Search/Custom/Sample.php +++ b/CRM/Contact/Form/Search/Custom/Sample.php @@ -48,12 +48,12 @@ public function __construct(&$formValues) { } } - $this->_columns = array( + $this->_columns = [ ts('Contact ID') => 'contact_id', ts('Contact Type') => 'contact_type', ts('Name') => 'sort_name', ts('State') => 'state_province', - ); + ]; } /** @@ -69,7 +69,7 @@ public function buildForm(&$form) { TRUE ); - $stateProvince = array('' => ts('- any state/province -')) + CRM_Core_PseudoConstant::stateProvince(); + $stateProvince = ['' => ts('- any state/province -')] + CRM_Core_PseudoConstant::stateProvince(); $form->addElement('select', 'state_province_id', ts('State/Province'), $stateProvince); /** @@ -81,17 +81,17 @@ public function buildForm(&$form) { * if you are using the standard template, this array tells the template what elements * are part of the search criteria */ - $form->assign('elements', array('household_name', 'state_province_id')); + $form->assign('elements', ['household_name', 'state_province_id']); } /** * @return array */ public function summary() { - $summary = array( + $summary = [ 'summary' => 'This is a summary', 'total' => 50.0, - ); + ]; return $summary; } @@ -158,11 +158,11 @@ public function from() { * @return string */ public function where($includeContactIDs = FALSE) { - $params = array(); + $params = []; $where = "contact_a.contact_type = 'Household'"; $count = 1; - $clause = array(); + $clause = []; $name = CRM_Utils_Array::value('household_name', $this->_formValues ); @@ -170,7 +170,7 @@ public function where($includeContactIDs = FALSE) { if (strpos($name, '%') === FALSE) { $name = "%{$name}%"; } - $params[$count] = array($name, 'String'); + $params[$count] = [$name, 'String']; $clause[] = "contact_a.household_name LIKE %{$count}"; $count++; } @@ -185,7 +185,7 @@ public function where($includeContactIDs = FALSE) { } if ($state) { - $params[$count] = array($state, 'Integer'); + $params[$count] = [$state, 'Integer']; $clause[] = "state_province.id = %{$count}"; } @@ -211,7 +211,7 @@ public function templateFile() { * @return array */ public function setDefaultValues() { - return array_merge(array('household_name' => ''), $this->_formValues); + return array_merge(['household_name' => ''], $this->_formValues); } /** diff --git a/CRM/Contact/Form/Search/Custom/TagContributions.php b/CRM/Contact/Form/Search/Custom/TagContributions.php index 579032c71616..123de6f387fa 100644 --- a/CRM/Contact/Form/Search/Custom/TagContributions.php +++ b/CRM/Contact/Form/Search/Custom/TagContributions.php @@ -49,14 +49,14 @@ public function __construct(&$formValues) { /** * Define the columns for search result rows */ - $this->_columns = array( + $this->_columns = [ ts('Contact ID') => 'contact_id', ts('Full Name') => 'sort_name', ts('First Name') => 'first_name', ts('Last Name') => 'last_name', ts('Tag') => 'tag_name', ts('Totals') => 'amount', - ); + ]; } /** @@ -73,16 +73,16 @@ public function buildForm(&$form) { * Define the search form fields here */ - $form->add('datepicker', 'start_date', ts('Contribution Date From'), [], FALSE, array('time' => FALSE)); - $form->add('datepicker', 'end_date', ts('...through'), [], FALSE, array('time' => FALSE)); - $tag = array('' => ts('- any tag -')) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE)); + $form->add('datepicker', 'start_date', ts('Contribution Date From'), [], FALSE, ['time' => FALSE]); + $form->add('datepicker', 'end_date', ts('...through'), [], FALSE, ['time' => FALSE]); + $tag = ['' => ts('- any tag -')] + CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', ['onlyActive' => FALSE]); $form->addElement('select', 'tag', ts('Tagged'), $tag); /** * If you are using the sample template, this array tells the template fields to render * for the search form. */ - $form->assign('elements', array('start_date', 'end_date', 'tag')); + $form->assign('elements', ['start_date', 'end_date', 'tag']); } /** @@ -175,7 +175,7 @@ public function from() { * @return string */ public function where($includeContactIDs = FALSE) { - $clauses = array(); + $clauses = []; $clauses[] = "contact_a.contact_type = 'Individual'"; $clauses[] = "civicrm_contribution.contact_id = contact_a.id"; @@ -198,7 +198,7 @@ public function where($includeContactIDs = FALSE) { } if ($includeContactIDs) { - $contactIDs = array(); + $contactIDs = []; foreach ($this->_formValues as $id => $value) { if ($value && substr($id, 0, CRM_Core_Form::CB_PREFIX_LEN) == CRM_Core_Form::CB_PREFIX @@ -291,10 +291,10 @@ public function buildACLClause($tableAlias = 'contact') { * @return array */ public static function formatSavedSearchFields($formValues) { - $dateFields = array( + $dateFields = [ 'start_date', 'end_date', - ); + ]; foreach ($formValues as $element => $value) { if (in_array($element, $dateFields) && !empty($value)) { $formValues[$element] = date('Y-m-d', strtotime($value)); diff --git a/CRM/Contact/Form/Search/Custom/ZipCodeRange.php b/CRM/Contact/Form/Search/Custom/ZipCodeRange.php index 386080b48024..0ffa0ee4f054 100644 --- a/CRM/Contact/Form/Search/Custom/ZipCodeRange.php +++ b/CRM/Contact/Form/Search/Custom/ZipCodeRange.php @@ -41,7 +41,7 @@ class CRM_Contact_Form_Search_Custom_ZipCodeRange extends CRM_Contact_Form_Searc public function __construct(&$formValues) { parent::__construct($formValues); - $this->_columns = array( + $this->_columns = [ // If possible, don't use aliases for the columns you select. // You can prefix columns with table aliases, if needed. // @@ -53,7 +53,7 @@ public function __construct(&$formValues) { ts('Name') => 'sort_name', ts('Email') => 'email', ts('Zip') => 'postal_code', - ); + ]; } /** @@ -81,14 +81,14 @@ public function buildForm(&$form) { * if you are using the standard template, this array tells the template what elements * are part of the search criteria */ - $form->assign('elements', array('postal_code_low', 'postal_code_high')); + $form->assign('elements', ['postal_code_low', 'postal_code_high']); } /** * @return array */ public function summary() { - $summary = array(); + $summary = []; return $summary; } @@ -161,7 +161,7 @@ public function from() { * @return string */ public function where($includeContactIDs = FALSE) { - $params = array(); + $params = []; $low = CRM_Utils_Array::value('postal_code_low', $this->_formValues @@ -179,10 +179,10 @@ public function where($includeContactIDs = FALSE) { } $where = "ROUND(address.postal_code) >= %1 AND ROUND(address.postal_code) <= %2"; - $params = array( - 1 => array(trim($low), 'Integer'), - 2 => array(trim($high), 'Integer'), - ); + $params = [ + 1 => [trim($low), 'Integer'], + 2 => [trim($high), 'Integer'], + ]; if ($this->_aclWhere) { $where .= " AND {$this->_aclWhere} "; diff --git a/CRM/Contact/Form/Task.php b/CRM/Contact/Form/Task.php index 857d1b22b00a..76a875ee3880 100644 --- a/CRM/Contact/Form/Task.php +++ b/CRM/Contact/Form/Task.php @@ -98,8 +98,8 @@ public function preProcess() { * @throws \CRM_Core_Exception */ public static function preProcessCommon(&$form) { - $form->_contactIds = array(); - $form->_contactTypes = array(); + $form->_contactIds = []; + $form->_contactTypes = []; $useTable = (CRM_Utils_System::getClassName($form->controller->getStateMachine()) == 'CRM_Export_StateMachine_Standalone'); @@ -173,10 +173,10 @@ public static function preProcessCommon(&$form) { $allCids[$cacheKey] = self::getContactIds($form); } - $form->_contactIds = array(); + $form->_contactIds = []; if ($useTable) { $count = 0; - $insertString = array(); + $insertString = []; foreach ($allCids[$cacheKey] as $cid => $ignore) { $count++; $insertString[] = " ( {$cid} ) "; @@ -184,7 +184,7 @@ public static function preProcessCommon(&$form) { $string = implode(',', $insertString); $sql = "REPLACE INTO {$form->_componentTable} ( contact_id ) VALUES $string"; CRM_Core_DAO::executeQuery($sql); - $insertString = array(); + $insertString = []; } } if (!empty($insertString)) { @@ -208,7 +208,7 @@ public static function preProcessCommon(&$form) { elseif (CRM_Utils_Array::value('radio_ts', self::$_searchFormValues) == 'ts_sel') { // selected contacts only // need to perform action on only selected contacts - $insertString = array(); + $insertString = []; // refire sql in case of custom search if ($form->_action == CRM_Core_Action::COPY) { @@ -313,7 +313,7 @@ public static function getContactIds($form) { // fix for CRM-5165 $sortByCharacter = $form->get('sortByCharacter'); if ($sortByCharacter && $sortByCharacter != 1) { - $params[] = array('sortByCharacter', '=', $sortByCharacter, 0, 0); + $params[] = ['sortByCharacter', '=', $sortByCharacter, 0, 0]; } $queryOperator = $form->get('queryOperator'); if (!$queryOperator) { @@ -324,7 +324,7 @@ public static function getContactIds($form) { $queryOperator ); - $contactIds = array(); + $contactIds = []; while ($dao->fetch()) { $contactIds[$dao->contact_id] = $dao->contact_id; } @@ -341,7 +341,7 @@ public static function getContactIds($form) { * @return array */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; return $defaults; } @@ -377,18 +377,18 @@ public function postProcess() { * @param bool $submitOnce */ public function addDefaultButtons($title, $nextType = 'next', $backType = 'back', $submitOnce = FALSE) { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => $nextType, 'name' => $title, 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => $backType, 'name' => ts('Cancel'), 'icon' => 'fa-times', - ), - ) + ], + ] ); } @@ -415,10 +415,10 @@ public function mergeContactIdsByHousehold() { // Get Head of Household & Household Member relationships $relationKeyMOH = CRM_Utils_Array::key('Household Member of', $contactRelationshipTypes); $relationKeyHOH = CRM_Utils_Array::key('Head of Household for', $contactRelationshipTypes); - $householdRelationshipTypes = array( + $householdRelationshipTypes = [ $relationKeyMOH => $contactRelationshipTypes[$relationKeyMOH], $relationKeyHOH => $contactRelationshipTypes[$relationKeyHOH], - ); + ]; $relID = implode(',', $this->_contactIds); @@ -460,14 +460,14 @@ public function mergeContactIdsByHousehold() { // If contact list has changed, households will probably be at the end of // the list. Sort it again by sort_name. if (implode(',', $this->_contactIds) != $relID) { - $result = civicrm_api3('Contact', 'get', array( - 'return' => array('id'), - 'id' => array('IN' => $this->_contactIds), - 'options' => array( + $result = civicrm_api3('Contact', 'get', [ + 'return' => ['id'], + 'id' => ['IN' => $this->_contactIds], + 'options' => [ 'limit' => 0, 'sort' => "sort_name", - ), - )); + ], + ]); $this->_contactIds = array_keys($result['values']); } } @@ -482,7 +482,7 @@ private static function getSelectedContactNames() { $qfKey = CRM_Utils_Request::retrieve('qfKey', 'String'); $cacheKey = "civicrm search {$qfKey}"; - $cids = array(); + $cids = []; // Gymanstic time! foreach (Civi::service('prevnext')->getSelection($cacheKey) as $cacheKey => $values) { $cids = array_unique(array_merge($cids, array_keys($values))); @@ -512,12 +512,12 @@ public function createHiddenGroup() { $grpID = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $grpTitle, 'id', 'title'); if (!$grpID) { - $groupParams = array( + $groupParams = [ 'title' => $grpTitle, 'is_active' => 1, 'is_hidden' => 1, - 'group_type' => array('2' => 1), - ); + 'group_type' => ['2' => 1], + ]; $group = CRM_Contact_BAO_Group::create($groupParams); $grpID = $group->id; @@ -525,33 +525,33 @@ public function createHiddenGroup() { CRM_Contact_BAO_GroupContact::addContactsToGroup($this->_contactIds, $group->id); $newGroupTitle = "Hidden Group {$grpID}"; - $groupParams = array( + $groupParams = [ 'id' => $grpID, 'name' => CRM_Utils_String::titleToVar($newGroupTitle), 'title' => $newGroupTitle, - 'group_type' => array('2' => 1), - ); + 'group_type' => ['2' => 1], + ]; CRM_Contact_BAO_Group::create($groupParams); } // note at this point its a static group - return array($grpID, NULL); + return [$grpID, NULL]; } else { // Create a smart group. $ssId = $this->get('ssID'); - $hiddenSmartParams = array( - 'group_type' => array('2' => 1), + $hiddenSmartParams = [ + 'group_type' => ['2' => 1], // queryParams have been preprocessed esp WRT any entity reference fields - see + // https://github.com/civicrm/civicrm-core/pull/13250 'form_values' => $this->get('queryParams'), 'saved_search_id' => $ssId, 'search_custom_id' => $this->get('customSearchID'), 'search_context' => $this->get('context'), - ); + ]; list($smartGroupId, $savedSearchId) = CRM_Contact_BAO_Group::createHiddenSmartGroup($hiddenSmartParams); - return array($smartGroupId, $savedSearchId); + return [$smartGroupId, $savedSearchId]; } } diff --git a/CRM/Contact/Form/Task/AddToGroup.php b/CRM/Contact/Form/Task/AddToGroup.php index f8f665105d0f..c14badd6520b 100644 --- a/CRM/Contact/Form/Task/AddToGroup.php +++ b/CRM/Contact/Form/Task/AddToGroup.php @@ -77,16 +77,16 @@ public function preProcess() { public function buildQuickForm() { //create radio buttons to select existing group or add a new group - $options = array(ts('Add Contact To Existing Group'), ts('Create New Group')); + $options = [ts('Add Contact To Existing Group'), ts('Create New Group')]; if (!$this->_id) { - $this->addRadio('group_option', ts('Group Options'), $options, array('onclick' => "return showElements();")); + $this->addRadio('group_option', ts('Group Options'), $options, ['onclick' => "return showElements();"]); $this->add('text', 'title', ts('Group Name:') . ' ', CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Group', 'title') ); $this->addRule('title', ts('Name already exists in Database.'), - 'objectExists', array('CRM_Contact_DAO_Group', $this->_id, 'title') + 'objectExists', ['CRM_Contact_DAO_Group', $this->_id, 'title'] ); $this->add('textarea', 'description', ts('Description:') . ' ', @@ -115,9 +115,9 @@ public function buildQuickForm() { } // add select for groups - $group = array('' => ts('- select group -')) + CRM_Core_PseudoConstant::nestedGroup(); + $group = ['' => ts('- select group -')] + CRM_Core_PseudoConstant::nestedGroup(); - $groupElement = $this->add('select', 'group_id', ts('Select Group'), $group, FALSE, array('class' => 'crm-select2 huge')); + $groupElement = $this->add('select', 'group_id', ts('Select Group'), $group, FALSE, ['class' => 'crm-select2 huge']); $this->_title = $group[$this->_id]; @@ -125,13 +125,13 @@ public function buildQuickForm() { $groupElement->freeze(); // also set the group title - $groupValues = array('id' => $this->_id, 'title' => $this->_title); + $groupValues = ['id' => $this->_id, 'title' => $this->_title]; $this->assign_by_ref('group', $groupValues); } // Set dynamic page title for 'Add Members Group (confirm)' if ($this->_id) { - CRM_Utils_System::setTitle(ts('Add Contacts: %1', array(1 => $this->_title))); + CRM_Utils_System::setTitle(ts('Add Contacts: %1', [1 => $this->_title])); } else { CRM_Utils_System::setTitle(ts('Add Contacts to A Group')); @@ -148,7 +148,7 @@ public function buildQuickForm() { * the default array reference */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; if ($this->_context === 'amtg') { $defaults['group_id'] = $this->_id; @@ -162,7 +162,7 @@ public function setDefaultValues() { * Add local and global form rules. */ public function addRules() { - $this->addFormRule(array('CRM_Contact_Form_task_AddToGroup', 'formRule')); + $this->addFormRule(['CRM_Contact_Form_task_AddToGroup', 'formRule']); } /** @@ -174,7 +174,7 @@ public function addRules() { * list of errors to be posted back to the form */ public static function formRule($params) { - $errors = array(); + $errors = []; if (!empty($params['group_option']) && empty($params['title'])) { $errors['title'] = "Group Name is a required field"; @@ -193,7 +193,7 @@ public function postProcess() { $params = $this->controller->exportValues(); $groupOption = CRM_Utils_Array::value('group_option', $params, NULL); if ($groupOption) { - $groupParams = array(); + $groupParams = []; $groupParams['title'] = $params['title']; $groupParams['description'] = $params['description']; $groupParams['visibility'] = "User and User Admin Only"; @@ -219,24 +219,24 @@ public function postProcess() { list($total, $added, $notAdded) = CRM_Contact_BAO_GroupContact::addContactsToGroup($this->_contactIds, $groupID); - $status = array( - ts('%count contact added to group', array( + $status = [ + ts('%count contact added to group', [ 'count' => $added, 'plural' => '%count contacts added to group', - )), - ); + ]), + ]; if ($notAdded) { - $status[] = ts('%count contact was already in group', array( + $status[] = ts('%count contact was already in group', [ 'count' => $notAdded, 'plural' => '%count contacts were already in group', - )); + ]); } $status = '
  • ' . implode('
  • ', $status) . '
'; - CRM_Core_Session::setStatus($status, ts('Added Contact to %1', array( + CRM_Core_Session::setStatus($status, ts('Added Contact to %1', [ 1 => $groupName, 'count' => $added, 'plural' => 'Added Contacts to %1', - )), 'success', array('expires' => 0)); + ]), 'success', ['expires' => 0]); if ($this->_context === 'amtg') { CRM_Core_Session::singleton() diff --git a/CRM/Contact/Form/Task/AddToParentClass.php b/CRM/Contact/Form/Task/AddToParentClass.php index bfa6c6330976..729b86838f56 100644 --- a/CRM/Contact/Form/Task/AddToParentClass.php +++ b/CRM/Contact/Form/Task/AddToParentClass.php @@ -46,22 +46,22 @@ public function preProcess() { public function buildQuickForm() { $contactType = $this->get('contactType'); - CRM_Utils_System::setTitle(ts('Add Contacts to %1', array(1 => $contactType))); - $this->addElement('text', 'name', ts('Find Target %1', array(1 => $contactType))); + CRM_Utils_System::setTitle(ts('Add Contacts to %1', [1 => $contactType])); + $this->addElement('text', 'name', ts('Find Target %1', [1 => $contactType])); $this->add('select', 'relationship_type_id', ts('Relationship Type'), - array( + [ '' => ts('- select -'), - ) + + ] + CRM_Contact_BAO_Relationship::getRelationType($contactType), TRUE ); $searchRows = $this->get('searchRows'); $searchCount = $this->get('searchCount'); if ($searchRows) { - $checkBoxes = array(); + $checkBoxes = []; $chekFlag = 0; foreach ($searchRows as $id => $row) { if (!$chekFlag) { @@ -81,19 +81,19 @@ public function buildQuickForm() { $this->assign('searchCount', $searchCount); $this->assign('searchDone', $this->get('searchDone')); $this->assign('contact_type_display', ts($contactType)); - $this->addElement('submit', $this->getButtonName('refresh'), ts('Search'), array('class' => 'crm-form-submit')); - $this->addElement('submit', $this->getButtonName('cancel'), ts('Cancel'), array('class' => 'crm-form-submit')); - $this->addButtons(array( - array( + $this->addElement('submit', $this->getButtonName('refresh'), ts('Search'), ['class' => 'crm-form-submit']); + $this->addElement('submit', $this->getButtonName('cancel'), ts('Cancel'), ['class' => 'crm-form-submit']); + $this->addButtons([ + [ 'type' => 'next', - 'name' => ts('Add to %1', array(1 => $contactType)), + 'name' => ts('Add to %1', [1 => $contactType]), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); } /** @@ -106,10 +106,10 @@ public function addRelationships() { return; } $relationshipTypeParts = explode('_', $this->params['relationship_type_id']); - $params = array( + $params = [ 'relationship_type_id' => $relationshipTypeParts[0], 'is_active' => 1, - ); + ]; $secondaryRelationshipSide = $relationshipTypeParts[1]; $primaryRelationshipSide = $relationshipTypeParts[2]; $primaryFieldName = 'contact_id_' . $primaryRelationshipSide; @@ -125,33 +125,33 @@ public function addRelationships() { $relatedContactName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $params[$primaryFieldName], 'display_name'); - $status = array( - ts('%count %2 %3 relationship created', array( + $status = [ + ts('%count %2 %3 relationship created', [ 'count' => $outcome['valid'], 'plural' => '%count %2 %3 relationships created', 2 => $relationshipLabel, 3 => $relatedContactName, - )), - ); + ]), + ]; if ($outcome['duplicate']) { - $status[] = ts('%count was skipped because the contact is already %2 %3', array( + $status[] = ts('%count was skipped because the contact is already %2 %3', [ 'count' => $outcome['duplicate'], 'plural' => '%count were skipped because the contacts are already %2 %3', 2 => $relationshipLabel, 3 => $relatedContactName, - )); + ]); } if ($outcome['invalid']) { - $status[] = ts('%count relationship was not created because the contact is not of the right type for this relationship', array( + $status[] = ts('%count relationship was not created because the contact is not of the right type for this relationship', [ 'count' => $outcome['invalid'], 'plural' => '%count relationships were not created because the contact is not of the right type for this relationship', - )); + ]); } $status = '
  • ' . implode('
  • ', $status) . '
'; - CRM_Core_Session::setStatus($status, ts('Relationship created.', array( + CRM_Core_Session::setStatus($status, ts('Relationship created.', [ 'count' => $outcome['valid'], 'plural' => 'Relationships created.', - )), 'success', array('expires' => 0)); + ]), 'success', ['expires' => 0]); } @@ -164,20 +164,20 @@ public function addRelationships() { */ public function search(&$form, &$params) { //max records that will be listed - $searchValues = array(); + $searchValues = []; if (!empty($params['rel_contact'])) { if (isset($params['rel_contact_id']) && is_numeric($params['rel_contact_id']) ) { - $searchValues[] = array('contact_id', '=', $params['rel_contact_id'], 0, 1); + $searchValues[] = ['contact_id', '=', $params['rel_contact_id'], 0, 1]; } else { - $searchValues[] = array('sort_name', 'LIKE', $params['rel_contact'], 0, 1); + $searchValues[] = ['sort_name', 'LIKE', $params['rel_contact'], 0, 1]; } } $contactTypeAdded = FALSE; - $excludedContactIds = array(); + $excludedContactIds = []; if (isset($form->_contactId)) { $excludedContactIds[] = $form->_contactId; } @@ -200,18 +200,18 @@ public function search(&$form, &$params) { $form->set('contact_type', $type); $form->set('contact_sub_type', $subType); if ($type == 'Individual' || $type == 'Organization' || $type == 'Household') { - $searchValues[] = array('contact_type', '=', $type, 0, 0); + $searchValues[] = ['contact_type', '=', $type, 0, 0]; $contactTypeAdded = TRUE; } if ($subType) { - $searchValues[] = array('contact_sub_type', '=', $subType, 0, 0); + $searchValues[] = ['contact_sub_type', '=', $subType, 0, 0]; } } } if (!$contactTypeAdded && !empty($params['contact_type'])) { - $searchValues[] = array('contact_type', '=', $params['contact_type'], 0, 0); + $searchValues[] = ['contact_type', '=', $params['contact_type'], 0, 0]; } // get the count of contact @@ -224,7 +224,7 @@ public function search(&$form, &$params) { $result = $query->searchQuery(0, 50, NULL); $config = CRM_Core_Config::singleton(); - $searchRows = array(); + $searchRows = []; //variable is set if only one record is foun and that record already has relationship with the contact $duplicateRelationship = 0; diff --git a/CRM/Contact/Form/Task/AddToTag.php b/CRM/Contact/Form/Task/AddToTag.php index b7e2e4c0689d..c296641ac62f 100644 --- a/CRM/Contact/Form/Task/AddToTag.php +++ b/CRM/Contact/Form/Task/AddToTag.php @@ -72,7 +72,7 @@ public function buildQuickForm() { } public function addRules() { - $this->addFormRule(array('CRM_Contact_Form_Task_AddToTag', 'formRule')); + $this->addFormRule(['CRM_Contact_Form_Task_AddToTag', 'formRule']); } /** @@ -82,7 +82,7 @@ public function addRules() { * @return array */ public static function formRule($form, $rule) { - $errors = array(); + $errors = []; if (empty($form['tag']) && empty($form['contact_taglist'])) { $errors['_qf_default'] = ts("Please select at least one tag."); } @@ -95,7 +95,7 @@ public static function formRule($form, $rule) { public function postProcess() { //get the submitted values in an array $params = $this->controller->exportValues($this->_name); - $contactTags = $tagList = array(); + $contactTags = $tagList = []; // check if contact tags exists if (!empty($params['tag'])) { @@ -132,22 +132,22 @@ public function postProcess() { // merge contact and taglist tags $allTags = CRM_Utils_Array::crmArrayMerge($contactTags, $tagList); - $this->_name = array(); + $this->_name = []; foreach ($allTags as $key => $dnc) { $this->_name[] = $this->_tags[$key]; list($total, $added, $notAdded) = CRM_Core_BAO_EntityTag::addEntitiesToTag($this->_contactIds, $key, 'civicrm_contact', FALSE); - $status = array(ts('%count contact tagged', array('count' => $added, 'plural' => '%count contacts tagged'))); + $status = [ts('%count contact tagged', ['count' => $added, 'plural' => '%count contacts tagged'])]; if ($notAdded) { - $status[] = ts('%count contact already had this tag', array( + $status[] = ts('%count contact already had this tag', [ 'count' => $notAdded, 'plural' => '%count contacts already had this tag', - )); + ]); } $status = '
  • ' . implode('
  • ', $status) . '
'; - CRM_Core_Session::setStatus($status, ts("Added Tag %1", array(1 => $this->_tags[$key])), 'success', array('expires' => 0)); + CRM_Core_Session::setStatus($status, ts("Added Tag %1", [1 => $this->_tags[$key]]), 'success', ['expires' => 0]); } } diff --git a/CRM/Contact/Form/Task/AlterPreferences.php b/CRM/Contact/Form/Task/AlterPreferences.php index aed844fa766f..cd596f0c9822 100644 --- a/CRM/Contact/Form/Task/AlterPreferences.php +++ b/CRM/Contact/Form/Task/AlterPreferences.php @@ -43,7 +43,7 @@ class CRM_Contact_Form_Task_AlterPreferences extends CRM_Contact_Form_Task { public function buildQuickForm() { // add select for preferences - $options = array(ts('Add Selected Options'), ts('Remove selected options')); + $options = [ts('Add Selected Options'), ts('Remove selected options')]; $this->addRadio('actionTypeOption', ts('actionTypeOption'), $options); @@ -57,7 +57,7 @@ public function buildQuickForm() { } public function addRules() { - $this->addFormRule(array('CRM_Contact_Form_Task_AlterPreferences', 'formRule')); + $this->addFormRule(['CRM_Contact_Form_Task_AlterPreferences', 'formRule']); } /** @@ -68,7 +68,7 @@ public function addRules() { * the default array reference */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; $defaults['actionTypeOption'] = 0; return $defaults; @@ -81,7 +81,7 @@ public function setDefaultValues() { * @return array */ public static function formRule($form, $rule) { - $errors = array(); + $errors = []; if (empty($form['pref']) && empty($form['contact_taglist'])) { $errors['_qf_default'] = ts("Please select at least one privacy option."); } @@ -115,19 +115,19 @@ public function postProcess() { } // Status message $privacyOptions = CRM_Core_SelectValues::privacy(); - $status = array(); + $status = []; foreach ($privacyValues as $privacy_key => $privacy_value) { $label = $privacyOptions[$privacy_key]; - $status[] = $privacyValueNew ? ts("Added '%1'", array(1 => $label)) : ts("Removed '%1'", array(1 => $label)); + $status[] = $privacyValueNew ? ts("Added '%1'", [1 => $label]) : ts("Removed '%1'", [1 => $label]); } $status = '
  • ' . implode('
  • ', $status) . '
'; if ($count > 1) { - $title = ts('%1 Contacts Updated', array(1 => $count)); + $title = ts('%1 Contacts Updated', [1 => $count]); } else { $name = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $contact_id, 'display_name'); - $title = ts('%1 Updated', array(1 => $name)); + $title = ts('%1 Updated', [1 => $name]); } CRM_Core_Session::setStatus($status, $title, 'success'); diff --git a/CRM/Contact/Form/Task/Batch.php b/CRM/Contact/Form/Task/Batch.php index 3e2b50ccbe8f..cea1787a0654 100644 --- a/CRM/Contact/Form/Task/Batch.php +++ b/CRM/Contact/Form/Task/Batch.php @@ -88,7 +88,7 @@ public function buildQuickForm() { // remove file type field and then limit fields $suppressFields = FALSE; - $removehtmlTypes = array('File'); + $removehtmlTypes = ['File']; foreach ($this->_fields as $name => $field) { if ($cfID = CRM_Core_BAO_CustomField::getKeyID($name) && in_array($this->_fields[$name]['html_type'], $removehtmlTypes) @@ -101,17 +101,17 @@ public function buildQuickForm() { //FIX ME: phone ext field is added at the end and it gets removed because of below code //$this->_fields = array_slice($this->_fields, 0, $this->_maxFields); - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'submit', 'name' => ts('Update Contact(s)'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); $this->assign('profileTitle', $this->_title); @@ -119,7 +119,7 @@ public function buildQuickForm() { // if below fields are missing we should not reset sort name / display name // CRM-6794 - $preserveDefaultsArray = array( + $preserveDefaultsArray = [ 'first_name', 'last_name', 'middle_name', @@ -127,7 +127,7 @@ public function buildQuickForm() { 'prefix_id', 'suffix_id', 'household_name', - ); + ]; foreach ($this->_contactIds as $contactId) { $profileFields = $this->_fields; @@ -151,7 +151,7 @@ public function buildQuickForm() { } $this->addDefaultButtons(ts('Update Contacts')); - $this->addFormRule(array('CRM_Contact_Form_Task_Batch', 'formRule')); + $this->addFormRule(['CRM_Contact_Form_Task_Batch', 'formRule']); } /** @@ -165,9 +165,9 @@ public function setDefaultValues() { return NULL; } - $defaults = $sortName = array(); + $defaults = $sortName = []; foreach ($this->_contactIds as $contactId) { - $details[$contactId] = array(); + $details[$contactId] = []; //build sortname $sortName[$contactId] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', @@ -193,8 +193,8 @@ public function setDefaultValues() { * true if no errors, else array of errors */ public static function formRule($fields) { - $errors = array(); - $externalIdentifiers = array(); + $errors = []; + $externalIdentifiers = []; foreach ($fields['field'] as $componentId => $field) { foreach ($field as $fieldName => $fieldValue) { if ($fieldName == 'external_identifier') { @@ -248,10 +248,10 @@ public function postProcess() { CRM_Core_Session::setStatus('', ts("Updates Saved"), 'success'); if ($inValidSubtypeCnt) { - CRM_Core_Session::setStatus(ts('Contact Subtype field of 1 contact has not been updated.', array( + CRM_Core_Session::setStatus(ts('Contact Subtype field of 1 contact has not been updated.', [ 'plural' => 'Contact Subtype field of %count contacts has not been updated.', 'count' => $inValidSubtypeCnt, - )), ts('Invalid Subtype')); + ]), ts('Invalid Subtype')); } } @@ -289,7 +289,7 @@ public static function parseStreetAddress(&$contactValues, &$form) { return; } - $allParseValues = array(); + $allParseValues = []; foreach ($contactValues as $key => $value) { if (strpos($key, $addressFldKey) !== FALSE) { $locTypeId = substr($key, strlen($addressFldKey) + 1); diff --git a/CRM/Contact/Form/Task/Delete.php b/CRM/Contact/Form/Task/Delete.php index b9401dc36747..1c0b5c71e5ba 100644 --- a/CRM/Contact/Form/Task/Delete.php +++ b/CRM/Contact/Form/Task/Delete.php @@ -89,7 +89,7 @@ public function preProcess() { CRM_Core_Error::fatal(ts('This contact is a special one for the contact information associated with the CiviCRM installation for this domain. No one is allowed to delete it because the information is used for special system purposes.')); } - $this->_contactIds = array($cid); + $this->_contactIds = [$cid]; $this->_single = TRUE; $this->assign('totalSelectedContacts', 1); } @@ -100,7 +100,7 @@ public function preProcess() { $this->_sharedAddressMessage = $this->get('sharedAddressMessage'); if (!$this->_restore && !$this->_sharedAddressMessage) { // we check for each contact for shared contact address - $sharedContactList = array(); + $sharedContactList = []; $sharedAddressCount = 0; foreach ($this->_contactIds as $contactId) { // check if a contact that is being deleted has any shared addresses @@ -114,25 +114,25 @@ public function preProcess() { } } - $this->_sharedAddressMessage = array( + $this->_sharedAddressMessage = [ 'count' => $sharedAddressCount, 'contactList' => $sharedContactList, - ); + ]; if ($sharedAddressCount > 0) { if (count($this->_contactIds) > 1) { // more than one contact deleted - $message = ts('One of the selected contacts has an address record that is shared with 1 other contact.', array( + $message = ts('One of the selected contacts has an address record that is shared with 1 other contact.', [ 'plural' => 'One or more selected contacts have address records which are shared with %count other contacts.', 'count' => $sharedAddressCount, - )); + ]); } else { // only one contact deleted - $message = ts('This contact has an address record which is shared with 1 other contact.', array( + $message = ts('This contact has an address record which is shared with 1 other contact.', [ 'plural' => 'This contact has an address record which is shared with %count other contacts.', 'count' => $sharedAddressCount, - )); + ]); } CRM_Core_Session::setStatus($message . ' ' . ts('Shared addresses will not be removed or altered but will no longer be shared.'), ts('Shared Addesses Owner')); } @@ -168,7 +168,7 @@ public function buildQuickForm() { $this->addDefaultButtons($label, 'done'); } - $this->addFormRule(array('CRM_Contact_Form_Task_Delete', 'formRule'), $this); + $this->addFormRule(['CRM_Contact_Form_Task_Delete', 'formRule'], $this); } /** @@ -186,7 +186,7 @@ public function buildQuickForm() { */ public static function formRule($fields, $files, $self) { // CRM-12929 - $error = array(); + $error = []; if ($self->_skipUndelete) { CRM_Financial_BAO_FinancialItem::checkContactPresent($self->_contactIds, $error); } @@ -222,15 +222,15 @@ public function postProcess() { // Delete/Restore Contacts. Report errors. $deleted = 0; - $not_deleted = array(); + $not_deleted = []; foreach ($this->_contactIds as $cid) { $name = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $cid, 'display_name'); if (CRM_Contact_BAO_Contact::checkDomainContact($cid)) { - $session->setStatus(ts("'%1' cannot be deleted because the information is used for special system purposes.", array(1 => $name)), 'Cannot Delete Domain Contact', 'error'); + $session->setStatus(ts("'%1' cannot be deleted because the information is used for special system purposes.", [1 => $name]), 'Cannot Delete Domain Contact', 'error'); continue; } if ($currentUserId == $cid && !$this->_restore) { - $session->setStatus(ts("You are currently logged in as '%1'. You cannot delete yourself.", array(1 => $name)), 'Unable To Delete', 'error'); + $session->setStatus(ts("You are currently logged in as '%1'. You cannot delete yourself.", [1 => $name]), 'Unable To Delete', 'error'); continue; } if (CRM_Contact_BAO_Contact::deleteContact($cid, $this->_restore, $this->_skipUndelete)) { @@ -245,25 +245,25 @@ public function postProcess() { $title = ts('Deleted'); if ($this->_restore) { $title = ts('Restored'); - $status = ts('%1 has been restored from the trash.', array( + $status = ts('%1 has been restored from the trash.', [ 1 => $name, 'plural' => '%count contacts restored from trash.', 'count' => $deleted, - )); + ]); } elseif ($this->_skipUndelete) { - $status = ts('%1 has been permanently deleted.', array( + $status = ts('%1 has been permanently deleted.', [ 1 => $name, 'plural' => '%count contacts permanently deleted.', 'count' => $deleted, - )); + ]); } else { - $status = ts('%1 has been moved to the trash.', array( + $status = ts('%1 has been moved to the trash.', [ 1 => $name, 'plural' => '%count contacts moved to trash.', 'count' => $deleted, - )); + ]); } $session->setStatus($status, $title, 'success'); } @@ -283,7 +283,7 @@ public function postProcess() { } $message .= '
  • ' . implode('
  • ', $this->_sharedAddressMessage['contactList']) . '
'; - $session->setStatus($message, ts('Shared Addesses Owner Deleted'), 'info', array('expires' => 0)); + $session->setStatus($message, ts('Shared Addesses Owner Deleted'), 'info', ['expires' => 0]); $this->set('sharedAddressMessage', NULL); } diff --git a/CRM/Contact/Form/Task/Email.php b/CRM/Contact/Form/Task/Email.php index 034f294c7e9d..d8dd851e3349 100644 --- a/CRM/Contact/Form/Task/Email.php +++ b/CRM/Contact/Form/Task/Email.php @@ -64,31 +64,31 @@ class CRM_Contact_Form_Task_Email extends CRM_Contact_Form_Task { * Store "to" contact details. * @var array */ - public $_toContactDetails = array(); + public $_toContactDetails = []; /** * Store all selected contact id's, that includes to, cc and bcc contacts * @var array */ - public $_allContactIds = array(); + public $_allContactIds = []; /** * Store only "to" contact ids. * @var array */ - public $_toContactIds = array(); + public $_toContactIds = []; /** * Store only "cc" contact ids. * @var array */ - public $_ccContactIds = array(); + public $_ccContactIds = []; /** * Store only "bcc" contact ids. * @var array */ - public $_bccContactIds = array(); + public $_bccContactIds = []; /** * Build all the data structures needed to build the form. @@ -103,7 +103,7 @@ public function preProcess() { // Allow request to specify email id rather than contact id $toEmailId = CRM_Utils_Request::retrieve('email_id', 'String', $this); if ($toEmailId) { - $toEmail = civicrm_api('email', 'getsingle', array('version' => 3, 'id' => $toEmailId)); + $toEmail = civicrm_api('email', 'getsingle', ['version' => 3, 'id' => $toEmailId]); if (!empty($toEmail['email']) && !empty($toEmail['contact_id'])) { $this->_toEmail = $toEmail; } @@ -115,7 +115,7 @@ public function preProcess() { if ($cid) { $cid = explode(',', $cid); - $displayName = array(); + $displayName = []; foreach ($cid as $val) { $displayName[] = CRM_Contact_BAO_Contact::displayName($val); diff --git a/CRM/Contact/Form/Task/HookSample.php b/CRM/Contact/Form/Task/HookSample.php index 2ed6b570e43b..a93a92a7ed2d 100644 --- a/CRM/Contact/Form/Task/HookSample.php +++ b/CRM/Contact/Form/Task/HookSample.php @@ -54,15 +54,15 @@ public function preProcess() { AND e.is_primary = 1 AND c.id IN ( $contactIDs )"; - $rows = array(); + $rows = []; $dao = CRM_Core_DAO::executeQuery($query); while ($dao->fetch()) { - $rows[] = array( + $rows[] = [ 'id' => $dao->contact_id, 'name' => $dao->name, 'contact_type' => $dao->contact_type, 'email' => $dao->email, - ); + ]; } $this->assign('rows', $rows); diff --git a/CRM/Contact/Form/Task/Label.php b/CRM/Contact/Form/Task/Label.php index bbd4cc7c446f..674d1d1ad310 100644 --- a/CRM/Contact/Form/Task/Label.php +++ b/CRM/Contact/Form/Task/Label.php @@ -62,13 +62,13 @@ public static function buildLabelForm($form) { //add select for label $label = CRM_Core_BAO_LabelFormat::getList(TRUE); - $form->add('select', 'label_name', ts('Select Label'), array('' => ts('- select label -')) + $label, TRUE); + $form->add('select', 'label_name', ts('Select Label'), ['' => ts('- select label -')] + $label, TRUE); // add select for Location Type $form->addElement('select', 'location_type_id', ts('Select Location'), - array( + [ '' => ts('Primary'), - ) + CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'), TRUE + ] + CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'), TRUE ); // checkbox for SKIP contacts with Do Not Mail privacy option @@ -77,17 +77,17 @@ public static function buildLabelForm($form) { $form->add('checkbox', 'merge_same_address', ts('Merge labels for contacts with the same address'), NULL); $form->add('checkbox', 'merge_same_household', ts('Merge labels for contacts belonging to the same household'), NULL); - $form->addButtons(array( - array( + $form->addButtons([ + [ 'type' => 'submit', 'name' => ts('Make Mailing Labels'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Done'), - ), - )); + ], + ]); } /** @@ -97,7 +97,7 @@ public static function buildLabelForm($form) { * array of default values */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; $format = CRM_Core_BAO_LabelFormat::getDefaultValues(); $defaults['label_name'] = CRM_Utils_Array::value('name', $format); $defaults['do_not_mail'] = 1; @@ -126,10 +126,10 @@ public function postProcess() { } //build the returnproperties - $returnProperties = array('display_name' => 1, 'contact_type' => 1, 'prefix_id' => 1); + $returnProperties = ['display_name' => 1, 'contact_type' => 1, 'prefix_id' => 1]; $mailingFormat = Civi::settings()->get('mailing_format'); - $mailingFormatProperties = array(); + $mailingFormatProperties = []; if ($mailingFormat) { $mailingFormatProperties = CRM_Utils_Token::getReturnProperties($mailingFormat); $returnProperties = array_merge($returnProperties, $mailingFormatProperties); @@ -139,7 +139,7 @@ public function postProcess() { unset($mailingFormatProperties['addressee']); } - $customFormatProperties = array(); + $customFormatProperties = []; if (stristr($mailingFormat, 'custom_')) { foreach ($mailingFormatProperties as $token => $true) { if (substr($token, 0, 7) == 'custom_') { @@ -172,38 +172,38 @@ public function postProcess() { } //get the contacts information - $params = array(); + $params = []; if (!empty($fv['location_type_id'])) { $locType = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'); $locName = $locType[$fv['location_type_id']]; - $location = array('location' => array("{$locName}" => $address)); + $location = ['location' => ["{$locName}" => $address]]; $returnProperties = array_merge($returnProperties, $location); - $params[] = array('location_type', '=', array(1 => $fv['location_type_id']), 0, 0); + $params[] = ['location_type', '=', [1 => $fv['location_type_id']], 0, 0]; } else { $returnProperties = array_merge($returnProperties, $address); } - $rows = array(); + $rows = []; foreach ($this->_contactIds as $key => $contactID) { - $params[] = array( + $params[] = [ CRM_Core_Form::CB_PREFIX . $contactID, '=', 1, 0, 0, - ); + ]; } // fix for CRM-2651 if (!empty($fv['do_not_mail'])) { - $params[] = array('do_not_mail', '=', 0, 0, 0); + $params[] = ['do_not_mail', '=', 0, 0, 0]; } // fix for CRM-2613 - $params[] = array('is_deceased', '=', 0, 0, 0); + $params[] = ['is_deceased', '=', 0, 0, 0]; - $custom = array(); + $custom = []; foreach ($returnProperties as $name => $dontCare) { $cfID = CRM_Core_BAO_CustomField::getKeyID($name); if ($cfID) { @@ -226,9 +226,9 @@ public function postProcess() { 'CRM_Contact_Form_Task_Label' ); - $tokens = array(); + $tokens = []; CRM_Utils_Hook::tokens($tokens); - $tokenFields = array(); + $tokenFields = []; foreach ($tokens as $category => $catTokens) { foreach ($catTokens as $token => $tokenName) { $tokenFields[] = $token; @@ -269,8 +269,8 @@ public function postProcess() { $rows[$value][$field] = $fieldValue; } - $valuesothers = array(); - $paramsothers = array('contact_id' => $value); + $valuesothers = []; + $paramsothers = ['contact_id' => $value]; $valuesothers = CRM_Core_BAO_Location::getValues($paramsothers, $valuesothers); if (!empty($fv['location_type_id'])) { foreach ($valuesothers as $vals) { @@ -278,12 +278,12 @@ public function postProcess() { CRM_Utils_Array::value('location_type_id', $fv) ) { foreach ($vals as $k => $v) { - if (in_array($k, array( + if (in_array($k, [ 'email', 'phone', 'im', 'openid', - ))) { + ])) { if ($k == 'im') { $rows[$value][$k] = $v['1']['name']; } @@ -326,7 +326,7 @@ public function postProcess() { if ($commMethods = CRM_Utils_Array::value('preferred_communication_method', $row)) { $val = array_filter(explode(CRM_Core_DAO::VALUE_SEPARATOR, $commMethods)); $comm = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'preferred_communication_method'); - $temp = array(); + $temp = []; foreach ($val as $vals) { $temp[] = $comm[$vals]; } @@ -346,7 +346,7 @@ public function postProcess() { } $formatted = implode("\n", $lines); } - $rows[$id] = array($formatted); + $rows[$id] = [$formatted]; } //call function to create labels diff --git a/CRM/Contact/Form/Task/LabelCommon.php b/CRM/Contact/Form/Task/LabelCommon.php index 62a0013f246f..d9cb7052832a 100644 --- a/CRM/Contact/Form/Task/LabelCommon.php +++ b/CRM/Contact/Form/Task/LabelCommon.php @@ -80,21 +80,21 @@ public static function createLabel(&$contactRows, &$format, $fileName = 'Mailing */ public static function getRows($contactIDs, $locationTypeID, $respectDoNotMail, $mergeSameAddress, $mergeSameHousehold) { $locName = NULL; - $rows = array(); + $rows = []; //get the address format sequence from the config file $addressReturnProperties = CRM_Contact_Form_Task_LabelCommon::getAddressReturnProperties(); //build the return properties - $returnProperties = array('display_name' => 1, 'contact_type' => 1, 'prefix_id' => 1); + $returnProperties = ['display_name' => 1, 'contact_type' => 1, 'prefix_id' => 1]; $mailingFormat = Civi::settings()->get('mailing_format'); - $mailingFormatProperties = array(); + $mailingFormatProperties = []; if ($mailingFormat) { $mailingFormatProperties = CRM_Utils_Token::getReturnProperties($mailingFormat); $returnProperties = array_merge($returnProperties, $mailingFormatProperties); } - $customFormatProperties = array(); + $customFormatProperties = []; if (stristr($mailingFormat, 'custom_')) { foreach ($mailingFormatProperties as $token => $true) { if (substr($token, 0, 7) == 'custom_') { @@ -113,30 +113,30 @@ public static function getRows($contactIDs, $locationTypeID, $respectDoNotMail, } //get the contacts information - $params = $custom = array(); + $params = $custom = []; foreach ($contactIDs as $key => $contactID) { - $params[] = array( + $params[] = [ CRM_Core_Form::CB_PREFIX . $contactID, '=', 1, 0, 0, - ); + ]; } // fix for CRM-2651 if (!empty($respectDoNotMail['do_not_mail'])) { - $params[] = array('do_not_mail', '=', 0, 0, 0); + $params[] = ['do_not_mail', '=', 0, 0, 0]; } // fix for CRM-2613 - $params[] = array('is_deceased', '=', 0, 0, 0); + $params[] = ['is_deceased', '=', 0, 0, 0]; if ($locationTypeID) { $locType = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'); $locName = $locType[$locationTypeID]; - $location = array('location' => array("{$locName}" => $addressReturnProperties)); + $location = ['location' => ["{$locName}" => $addressReturnProperties]]; $returnProperties = array_merge($returnProperties, $location); - $params[] = array('location_type', '=', array($locationTypeID => 1), 0, 0); + $params[] = ['location_type', '=', [$locationTypeID => 1], 0, 0]; } else { $returnProperties = array_merge($returnProperties, $addressReturnProperties); @@ -193,8 +193,8 @@ public static function getRows($contactIDs, $locationTypeID, $respectDoNotMail, $rows[$value][$field] = $fieldValue; } - $valuesothers = array(); - $paramsothers = array('contact_id' => $value); + $valuesothers = []; + $paramsothers = ['contact_id' => $value]; $valuesothers = CRM_Core_BAO_Location::getValues($paramsothers, $valuesothers); if ($locationTypeID) { foreach ($valuesothers as $vals) { @@ -202,12 +202,12 @@ public static function getRows($contactIDs, $locationTypeID, $respectDoNotMail, $locationTypeID ) { foreach ($vals as $k => $v) { - if (in_array($k, array( + if (in_array($k, [ 'email', 'phone', 'im', 'openid', - ))) { + ])) { if ($k == 'im') { $rows[$value][$k] = $v['1']['name']; } @@ -240,7 +240,7 @@ public static function getRows($contactIDs, $locationTypeID, $respectDoNotMail, } } // sigh couldn't extract out tokenfields yet - return array($rows, $tokenFields); + return [$rows, $tokenFields]; } /** @@ -269,7 +269,7 @@ public static function getAddressReturnProperties() { */ public static function getTokenData(&$contacts) { $mailingFormat = Civi::settings()->get('mailing_format'); - $tokens = $tokenFields = array(); + $tokens = $tokenFields = []; $messageToken = CRM_Utils_Token::getTokens($mailingFormat); // also get all token values @@ -298,8 +298,8 @@ public static function getTokenData(&$contacts) { */ public function mergeSameHousehold(&$rows) { // group selected contacts by type - $individuals = array(); - $households = array(); + $individuals = []; + $households = []; foreach ($rows as $contact_id => $row) { if ($row['contact_type'] == 'Household') { $households[$contact_id] = $row; diff --git a/CRM/Contact/Form/Task/Map.php b/CRM/Contact/Form/Task/Map.php index 5d8d2947f397..f22d59d122e2 100644 --- a/CRM/Contact/Form/Task/Map.php +++ b/CRM/Contact/Form/Task/Map.php @@ -67,7 +67,7 @@ public function preProcess() { $type = 'Contact'; if ($cid) { - $ids = array($cid); + $ids = [$cid]; $this->_single = TRUE; if ($profileGID) { // this does a check and ensures that the user has permission on this profile @@ -113,13 +113,13 @@ public function preProcess() { * Build the form object. */ public function buildQuickForm() { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'done', 'name' => ts('Done'), 'isDefault' => TRUE, - ), - ) + ], + ] ); } @@ -221,14 +221,14 @@ public static function createMapXML($ids, $locationId, &$page, $addBreadCrumb, $ } } - $center = array( + $center = [ 'lat' => (float ) $sumLat / count($locations), 'lng' => (float ) $sumLng / count($locations), - ); - $span = array( + ]; + $span = [ 'lat' => (float ) ($maxLat - $minLat), 'lng' => (float ) ($maxLng - $minLng), - ); + ]; $page->assign_by_ref('center', $center); $page->assign_by_ref('span', $span); } diff --git a/CRM/Contact/Form/Task/Merge.php b/CRM/Contact/Form/Task/Merge.php index 2b914eee5e17..80359da7af4a 100644 --- a/CRM/Contact/Form/Task/Merge.php +++ b/CRM/Contact/Form/Task/Merge.php @@ -42,7 +42,7 @@ class CRM_Contact_Form_Task_Merge extends CRM_Contact_Form_Task { public function preProcess() { parent::preProcess(); $statusMsg = NULL; - $contactIds = array(); + $contactIds = []; if (is_array($this->_contactIds)) { $contactIds = array_unique($this->_contactIds); } @@ -51,7 +51,7 @@ public function preProcess() { } // do check for same contact type. - $contactTypes = array(); + $contactTypes = []; if (!$statusMsg) { $sql = "SELECT contact_type FROM civicrm_contact WHERE id IN (" . implode(',', $contactIds) . ")"; $contact = CRM_Core_DAO::executeQuery($sql); diff --git a/CRM/Contact/Form/Task/PDF.php b/CRM/Contact/Form/Task/PDF.php index b84f420604b3..67f42d2c30f3 100644 --- a/CRM/Contact/Form/Task/PDF.php +++ b/CRM/Contact/Form/Task/PDF.php @@ -88,9 +88,9 @@ public function preProcess() { * Set default values for the form. */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; if (isset($this->_activityId)) { - $params = array('id' => $this->_activityId); + $params = ['id' => $this->_activityId]; CRM_Activity_BAO_Activity::retrieve($params, $defaults); $defaults['html_message'] = CRM_Utils_Array::value('details', $defaults); } diff --git a/CRM/Contact/Form/Task/PDFLetterCommon.php b/CRM/Contact/Form/Task/PDFLetterCommon.php index 04ca1101a9ab..b52b24d76745 100644 --- a/CRM/Contact/Form/Task/PDFLetterCommon.php +++ b/CRM/Contact/Form/Task/PDFLetterCommon.php @@ -43,13 +43,13 @@ class CRM_Contact_Form_Task_PDFLetterCommon extends CRM_Core_Form_Task_PDFLetter * Array(string $machineName => string $label). */ public static function getLoggingOptions() { - return array( + return [ 'none' => ts('Do not record'), 'multiple' => ts('Multiple activities (one per contact)'), 'combined' => ts('One combined activity'), 'combined-attached' => ts('One combined activity plus one file attachment'), // 'multiple-attached' <== not worth the work - ); + ]; } /** @@ -59,8 +59,8 @@ public static function getLoggingOptions() { */ public static function preProcess(&$form) { CRM_Contact_Form_Task_EmailCommon::preProcessFromAddress($form); - $messageText = array(); - $messageSubject = array(); + $messageText = []; + $messageSubject = []; $dao = new CRM_Core_BAO_MessageTemplate(); $dao->is_active = 1; $dao->find(); @@ -82,7 +82,7 @@ public static function preProcessSingle(&$form, $cid) { $form->_contactIds = explode(',', $cid); // put contact display name in title for single contact mode if (count($form->_contactIds) === 1) { - CRM_Utils_System::setTitle(ts('Print/Merge Document for %1', array(1 => CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $cid, 'display_name')))); + CRM_Utils_System::setTitle(ts('Print/Merge Document for %1', [1 => CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $cid, 'display_name')])); } } @@ -106,14 +106,14 @@ public static function processMessageTemplate($formValues) { $messageToken = CRM_Utils_Token::getTokens($html_message); - $returnProperties = array(); + $returnProperties = []; if (isset($messageToken['contact'])) { foreach ($messageToken['contact'] as $key => $value) { $returnProperties[$value] = 1; } } - return array($formValues, $categories, $html_message, $messageToken, $returnProperties); + return [$formValues, $categories, $html_message, $messageToken, $returnProperties]; } /** @@ -129,7 +129,7 @@ public static function postProcess(&$form) { $buttonName = $form->controller->getButtonName(); $skipOnHold = isset($form->skipOnHold) ? $form->skipOnHold : FALSE; $skipDeceased = isset($form->skipDeceased) ? $form->skipDeceased : TRUE; - $html = $activityIds = array(); + $html = $activityIds = []; // CRM-21255 - Hrm, CiviCase 4+5 seem to report buttons differently... $c = $form->controller->container(); @@ -146,7 +146,7 @@ public static function postProcess(&$form) { foreach ($form->_contactIds as $item => $contactId) { $caseId = NULL; - $params = array('contact_id' => $contactId); + $params = ['contact_id' => $contactId]; list($contact) = CRM_Utils_Token::getTokenDetails($params, $returnProperties, @@ -216,15 +216,15 @@ public static function postProcess(&$form) { throw new \CRM_Core_Exception("Failed to capture document content (type=$type)!"); } foreach ($activityIds as $activityId) { - civicrm_api3('Attachment', 'create', array( + civicrm_api3('Attachment', 'create', [ 'entity_table' => 'civicrm_activity', 'entity_id' => $activityId, 'name' => $fileName, 'mime_type' => $mimeType, - 'options' => array( + 'options' => [ 'move-file' => $tee->getFileName(), - ), - )); + ], + ]); } } @@ -248,31 +248,31 @@ public static function postProcess(&$form) { * * @throws CRM_Core_Exception */ - public static function createActivities($form, $html_message, $contactIds, $subject, $campaign_id, $perContactHtml = array()) { + public static function createActivities($form, $html_message, $contactIds, $subject, $campaign_id, $perContactHtml = []) { - $activityParams = array( + $activityParams = [ 'subject' => $subject, 'campaign_id' => $campaign_id, 'source_contact_id' => CRM_Core_Session::singleton()->getLoggedInContactID(), 'activity_type_id' => CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Print PDF Letter'), 'activity_date_time' => date('YmdHis'), 'details' => $html_message, - ); + ]; if (!empty($form->_activityId)) { - $activityParams += array('id' => $form->_activityId); + $activityParams += ['id' => $form->_activityId]; } - $activityIds = array(); + $activityIds = []; switch (Civi::settings()->get('recordGeneratedLetters')) { case 'none': - return array(); + return []; case 'multiple': // One activity per contact. foreach ($contactIds as $i => $contactId) { - $fullParams = array( + $fullParams = [ 'target_contact_id' => $contactId, - ) + $activityParams; + ] + $activityParams; if (!empty($form->_caseId)) { $fullParams['case_id'] = $form->_caseId; } @@ -292,9 +292,9 @@ public static function createActivities($form, $html_message, $contactIds, $subj case 'combined': case 'combined-attached': // One activity with all contacts. - $fullParams = array( + $fullParams = [ 'target_contact_id' => $contactIds, - ) + $activityParams; + ] + $activityParams; if (!empty($form->_caseId)) { $fullParams['case_id'] = $form->_caseId; } @@ -320,12 +320,12 @@ public static function createActivities($form, $html_message, $contactIds, $subj * @throws \CRM_Core_Exception */ private static function getMimeType($type) { - $mimeTypes = array( + $mimeTypes = [ 'pdf' => 'application/pdf', 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'odt' => 'application/vnd.oasis.opendocument.text', 'html' => 'text/html', - ); + ]; if (isset($mimeTypes[$type])) { return $mimeTypes[$type]; } @@ -341,7 +341,7 @@ private static function getMimeType($type) { */ protected static function getTokenCategories() { if (!isset(Civi::$statics[__CLASS__]['token_categories'])) { - $tokens = array(); + $tokens = []; CRM_Utils_Hook::tokens($tokens); Civi::$statics[__CLASS__]['token_categories'] = array_keys($tokens); } diff --git a/CRM/Contact/Form/Task/PickProfile.php b/CRM/Contact/Form/Task/PickProfile.php index 2fdc1bdca21e..875d3ae1d49c 100644 --- a/CRM/Contact/Form/Task/PickProfile.php +++ b/CRM/Contact/Form/Task/PickProfile.php @@ -71,10 +71,10 @@ public function preProcess() { $validate = FALSE; //validations if (count($this->_contactIds) > $this->_maxContacts) { - CRM_Core_Session::setStatus(ts("The maximum number of contacts you can select for Update multiple contacts is %1. You have selected %2. Please select fewer contacts from your search results and try again.", array( + CRM_Core_Session::setStatus(ts("The maximum number of contacts you can select for Update multiple contacts is %1. You have selected %2. Please select fewer contacts from your search results and try again.", [ 1 => $this->_maxContacts, 2 => count($this->_contactIds), - )), ts('Maximum Exceeded'), 'error'); + ]), ts('Maximum Exceeded'), 'error'); $validate = TRUE; } @@ -106,10 +106,10 @@ public function buildQuickForm() { if (empty($profiles)) { $types = implode(' ' . ts('or') . ' ', $this->_contactTypes); - CRM_Core_Session::setStatus(ts("The contact type selected for Update multiple contacts does not have a corresponding profile. Please set up a profile for %1s and try again.", array(1 => $types)), ts('No Profile Available'), 'error'); + CRM_Core_Session::setStatus(ts("The contact type selected for Update multiple contacts does not have a corresponding profile. Please set up a profile for %1s and try again.", [1 => $types]), ts('No Profile Available'), 'error'); CRM_Utils_System::redirect($this->_userContext); } - $ufGroupElement = $this->add('select', 'uf_group_id', ts('Select Profile'), array('' => ts('- select profile -')) + $profiles, TRUE, array('class' => 'crm-select2 huge')); + $ufGroupElement = $this->add('select', 'uf_group_id', ts('Select Profile'), ['' => ts('- select profile -')] + $profiles, TRUE, ['class' => 'crm-select2 huge']); $this->addDefaultButtons(ts('Continue')); } @@ -118,7 +118,7 @@ public function buildQuickForm() { * Add local and global form rules. */ public function addRules() { - $this->addFormRule(array('CRM_Contact_Form_Task_PickProfile', 'formRule')); + $this->addFormRule(['CRM_Contact_Form_Task_PickProfile', 'formRule']); } /** diff --git a/CRM/Contact/Form/Task/Print.php b/CRM/Contact/Form/Task/Print.php index aeff179f3b03..8040df3e5d90 100644 --- a/CRM/Contact/Form/Task/Print.php +++ b/CRM/Contact/Form/Task/Print.php @@ -53,13 +53,13 @@ public function preProcess() { //using _contactIds field for creating params for query so that multiple selections on multiple pages //can be printed. foreach ($this->_contactIds as $contactId) { - $params[] = array( + $params[] = [ CRM_Core_Form::CB_PREFIX . $contactId, '=', 1, 0, 0, - ); + ]; } } @@ -112,18 +112,18 @@ public function buildQuickForm() { // // just need to add a javacript to popup the window for printing // - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => ts('Print Contact List'), - 'js' => array('onclick' => 'window.print()'), + 'js' => ['onclick' => 'window.print()'], 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'back', 'name' => ts('Done'), - ), - ) + ], + ] ); } diff --git a/CRM/Contact/Form/Task/ProximityCommon.php b/CRM/Contact/Form/Task/ProximityCommon.php index 79e21da02d7a..19d2bd37f04c 100644 --- a/CRM/Contact/Form/Task/ProximityCommon.php +++ b/CRM/Contact/Form/Task/ProximityCommon.php @@ -74,18 +74,18 @@ static public function buildQuickForm($form, $proxSearch) { $form->add('text', 'prox_postal_code', ts('Postal Code'), NULL, FALSE); - $form->addChainSelect('prox_state_province_id', array('required' => $proxRequired)); + $form->addChainSelect('prox_state_province_id', ['required' => $proxRequired]); - $country = array('' => ts('- select -')) + CRM_Core_PseudoConstant::country(); + $country = ['' => ts('- select -')] + CRM_Core_PseudoConstant::country(); $form->add('select', 'prox_country_id', ts('Country'), $country, $proxRequired); $form->add('text', 'prox_distance', ts('Distance'), NULL, $proxRequired); - $proxUnits = array('km' => ts('km'), 'miles' => ts('miles')); + $proxUnits = ['km' => ts('km'), 'miles' => ts('miles')]; $form->add('select', 'prox_distance_unit', ts('Units'), $proxUnits, $proxRequired); // prox_distance_unit - $form->addFormRule(array('CRM_Contact_Form_Task_ProximityCommon', 'formRule'), $form); + $form->addFormRule(['CRM_Contact_Form_Task_ProximityCommon', 'formRule'], $form); } /** @@ -101,7 +101,7 @@ static public function buildQuickForm($form, $proxSearch) { * true if no errors, else array of errors */ public static function formRule($fields, $files, $form) { - $errors = array(); + $errors = []; // If Distance is present, make sure state, country and city or postal code are populated. if (!empty($fields['prox_distance'])) { if (empty($fields['prox_state_province_id']) || empty($fields['prox_country_id'])) { @@ -126,7 +126,7 @@ public static function formRule($fields, $files, $form) { * the default array reference */ static public function setDefaultValues($form) { - $defaults = array(); + $defaults = []; $config = CRM_Core_Config::singleton(); $countryDefault = $config->defaultContactCountry; diff --git a/CRM/Contact/Form/Task/RemoveFromGroup.php b/CRM/Contact/Form/Task/RemoveFromGroup.php index ba8cc9f111fc..5df58cc48f03 100644 --- a/CRM/Contact/Form/Task/RemoveFromGroup.php +++ b/CRM/Contact/Form/Task/RemoveFromGroup.php @@ -43,8 +43,8 @@ class CRM_Contact_Form_Task_RemoveFromGroup extends CRM_Contact_Form_Task { */ public function buildQuickForm() { // add select for groups - $group = array('' => ts('- select group -')) + CRM_Core_PseudoConstant::nestedGroup(); - $groupElement = $this->add('select', 'group_id', ts('Select Group'), $group, TRUE, array('class' => 'crm-select2 huge')); + $group = ['' => ts('- select group -')] + CRM_Core_PseudoConstant::nestedGroup(); + $groupElement = $this->add('select', 'group_id', ts('Select Group'), $group, TRUE, ['class' => 'crm-select2 huge']); CRM_Utils_System::setTitle(ts('Remove Contacts from Group')); $this->addDefaultButtons(ts('Remove from Group')); @@ -58,7 +58,7 @@ public function buildQuickForm() { * the default array reference */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; if ($this->get('context') === 'smog') { $defaults['group_id'] = $this->get('gid'); @@ -75,24 +75,24 @@ public function postProcess() { list($total, $removed, $notRemoved) = CRM_Contact_BAO_GroupContact::removeContactsFromGroup($this->_contactIds, $groupId); - $status = array( - ts("%count contact removed from '%2'", array( + $status = [ + ts("%count contact removed from '%2'", [ 'count' => $removed, 'plural' => "%count contacts removed from '%2'", 2 => $group[$groupId], - )), - ); + ]), + ]; if ($notRemoved) { - $status[] = ts('1 contact was already not in this group', array( + $status[] = ts('1 contact was already not in this group', [ 'count' => $notRemoved, 'plural' => '%count contacts were already not in this group', - )); + ]); } $status = '
  • ' . implode('
  • ', $status) . '
'; - CRM_Core_Session::setStatus($status, ts("Removed Contact From Group", array( + CRM_Core_Session::setStatus($status, ts("Removed Contact From Group", [ 'plural' => "Removed Contacts From Group", 'count' => $removed, - )), 'success', array('expires' => 0)); + ]), 'success', ['expires' => 0]); } } diff --git a/CRM/Contact/Form/Task/RemoveFromTag.php b/CRM/Contact/Form/Task/RemoveFromTag.php index 3d5025ccdbb0..d88a15b59f7b 100644 --- a/CRM/Contact/Form/Task/RemoveFromTag.php +++ b/CRM/Contact/Form/Task/RemoveFromTag.php @@ -67,7 +67,7 @@ public function buildQuickForm() { } public function addRules() { - $this->addFormRule(array('CRM_Contact_Form_Task_RemoveFromTag', 'formRule')); + $this->addFormRule(['CRM_Contact_Form_Task_RemoveFromTag', 'formRule']); } /** @@ -77,7 +77,7 @@ public function addRules() { * @return array */ public static function formRule($form, $rule) { - $errors = array(); + $errors = []; if (empty($form['tag']) && empty($form['contact_taglist'])) { $errors['_qf_default'] = "Please select atleast one tag."; } @@ -91,7 +91,7 @@ public function postProcess() { //get the submitted values in an array $params = $this->controller->exportValues($this->_name); - $contactTags = $tagList = array(); + $contactTags = $tagList = []; // check if contact tags exists if (!empty($params['tag'])) { @@ -120,27 +120,27 @@ public function postProcess() { // merge contact and taglist tags $allTags = CRM_Utils_Array::crmArrayMerge($contactTags, $tagList); - $this->_name = array(); + $this->_name = []; foreach ($allTags as $key => $dnc) { $this->_name[] = $this->_tags[$key]; list($total, $removed, $notRemoved) = CRM_Core_BAO_EntityTag::removeEntitiesFromTag($this->_contactIds, $key, 'civicrm_contact', FALSE); - $status = array( - ts('%count contact un-tagged', array( + $status = [ + ts('%count contact un-tagged', [ 'count' => $removed, 'plural' => '%count contacts un-tagged', - )), - ); + ]), + ]; if ($notRemoved) { - $status[] = ts('1 contact already did not have this tag', array( + $status[] = ts('1 contact already did not have this tag', [ 'count' => $notRemoved, 'plural' => '%count contacts already did not have this tag', - )); + ]); } $status = '
  • ' . implode('
  • ', $status) . '
'; - CRM_Core_Session::setStatus($status, ts("Removed Tag %1", array(1 => $this->_tags[$key])), 'success', array('expires' => 0)); + CRM_Core_Session::setStatus($status, ts("Removed Tag %1", [1 => $this->_tags[$key]]), 'success', ['expires' => 0]); } } diff --git a/CRM/Contact/Form/Task/Result.php b/CRM/Contact/Form/Task/Result.php index 41a66dd5f04e..3222cf410a6f 100644 --- a/CRM/Contact/Form/Task/Result.php +++ b/CRM/Contact/Form/Task/Result.php @@ -46,10 +46,10 @@ public function preProcess() { $this->set('searchRows', ''); $context = $this->get('context'); - if (in_array($context, array( + if (in_array($context, [ 'smog', 'amtg', - ))) { + ])) { $urlParams = 'reset=1&force=1&context=smog&gid='; $urlParams .= ($context == 'smog') ? $this->get('gid') : $this->get('amtgID'); $session->replaceUserContext(CRM_Utils_System::url('civicrm/group/search', $urlParams)); @@ -94,13 +94,13 @@ public function preProcess() { * Build the form object. */ public function buildQuickForm() { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'done', 'name' => ts('Done'), 'isDefault' => TRUE, - ), - ) + ], + ] ); } diff --git a/CRM/Contact/Form/Task/SMSCommon.php b/CRM/Contact/Form/Task/SMSCommon.php index f4d304affd89..d6802158a196 100644 --- a/CRM/Contact/Form/Task/SMSCommon.php +++ b/CRM/Contact/Form/Task/SMSCommon.php @@ -37,11 +37,11 @@ class CRM_Contact_Form_Task_SMSCommon { const RECIEVED_SMS_ACTIVITY_SUBJECT = "SMS Received"; - public $_contactDetails = array(); + public $_contactDetails = []; - public $_allContactDetails = array(); + public $_allContactDetails = []; - public $_toContactPhone = array(); + public $_toContactPhone = []; /** @@ -75,7 +75,7 @@ public static function preProcessProvider(&$form) { } if ($activityCheck == count($form->_activityHolderIds)) { CRM_Core_Error::statusBounce(ts("The Reply SMS Could only be sent for activities with '%1' subject.", - array(1 => self::RECIEVED_SMS_ACTIVITY_SUBJECT) + [1 => self::RECIEVED_SMS_ACTIVITY_SUBJECT] )); } } @@ -88,11 +88,11 @@ public static function preProcessProvider(&$form) { */ public static function buildQuickForm(&$form) { - $toArray = array(); + $toArray = []; $providers = CRM_SMS_BAO_Provider::getProviders(NULL, NULL, TRUE, 'is_default desc'); - $providerSelect = array(); + $providerSelect = []; foreach ($providers as $provider) { $providerSelect[$provider['id']] = $provider['title']; } @@ -101,11 +101,11 @@ public static function buildQuickForm(&$form) { $cid = $form->get('cid'); if ($cid) { - $form->_contactIds = array($cid); + $form->_contactIds = [$cid]; } - $to = $form->add('text', 'to', ts('To'), array('class' => 'huge'), TRUE); - $form->add('text', 'activity_subject', ts('Name The SMS'), array('class' => 'huge'), TRUE); + $to = $form->add('text', 'to', ts('To'), ['class' => 'huge'], TRUE); + $form->add('text', 'activity_subject', ts('Name The SMS'), ['class' => 'huge'], TRUE); $toSetDefault = TRUE; if (property_exists($form, '_context') && $form->_context == 'standalone') { @@ -113,11 +113,11 @@ public static function buildQuickForm(&$form) { } // when form is submitted recompute contactIds - $allToSMS = array(); + $allToSMS = []; if ($to->getValue()) { $allToPhone = explode(',', $to->getValue()); - $form->_contactIds = array(); + $form->_contactIds = []; foreach ($allToPhone as $value) { list($contactId, $phone) = explode('::', $value); if ($contactId) { @@ -156,30 +156,30 @@ public static function buildQuickForm(&$form) { if (!$validActivities) { $errorMess = ""; if ($extendTargetContacts) { - $errorMess = ts('One selected activity consists of more than one target contact.', array( + $errorMess = ts('One selected activity consists of more than one target contact.', [ 'count' => $extendTargetContacts, 'plural' => '%count selected activities consist of more than one target contact.', - )); + ]); } if ($invalidActivity) { $errorMess = ($errorMess ? ' ' : ''); - $errorMess .= ts('The selected activity is invalid.', array( + $errorMess .= ts('The selected activity is invalid.', [ 'count' => $invalidActivity, 'plural' => '%count selected activities are invalid.', - )); + ]); } - CRM_Core_Error::statusBounce(ts("%1: SMS Reply will not be sent.", array(1 => $errorMess))); + CRM_Core_Error::statusBounce(ts("%1: SMS Reply will not be sent.", [1 => $errorMess])); } } if (is_array($form->_contactIds) && !empty($form->_contactIds) && $toSetDefault) { - $returnProperties = array( + $returnProperties = [ 'sort_name' => 1, 'phone' => 1, 'do_not_sms' => 1, 'is_deceased' => 1, 'display_name' => 1, - ); + ]; list($form->_contactDetails) = CRM_Utils_Token::getTokenDetails($form->_contactIds, $returnProperties, @@ -215,7 +215,7 @@ public static function buildQuickForm(&$form) { if (!empty($value['phone']) && $value['phone_type_id'] != CRM_Utils_Array::value('Mobile', $phoneTypes) && empty($value['is_deceased']) ) { - $filter = array('do_not_sms' => 0); + $filter = ['do_not_sms' => 0]; $contactPhones = CRM_Core_BAO_Phone::allPhones($contactId, FALSE, 'Mobile', $filter); if (count($contactPhones) > 0) { $mobilePhone = CRM_Utils_Array::retrieveValueRecursive($contactPhones, 'phone'); @@ -247,10 +247,10 @@ public static function buildQuickForm(&$form) { } if ($phone) { - $toArray[] = array( + $toArray[] = [ 'text' => '"' . $value['sort_name'] . '" (' . $phone . ')', 'id' => "$contactId::{$phone}", - ); + ]; } } @@ -294,7 +294,7 @@ public static function buildQuickForm(&$form) { $form->addDefaultButtons(ts('Send SMS'), 'upload'); } - $form->addFormRule(array('CRM_Contact_Form_Task_SMSCommon', 'formRule'), $form); + $form->addFormRule(['CRM_Contact_Form_Task_SMSCommon', 'formRule'], $form); } /** @@ -310,7 +310,7 @@ public static function buildQuickForm(&$form) { * true if no errors, else array of errors */ public static function formRule($fields, $dontCare, $self) { - $errors = array(); + $errors = []; $template = CRM_Core_Smarty::singleton(); @@ -322,7 +322,7 @@ public static function formRule($fields, $dontCare, $self) { $messageCheck = CRM_Utils_Array::value('sms_text_message', $fields); $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", array(1 => 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]); } } } @@ -349,11 +349,11 @@ public static function postProcess(&$form) { // process message template if (!empty($thisValues['SMSsaveTemplate']) || !empty($thisValues['SMSupdateTemplate'])) { - $messageTemplate = array( + $messageTemplate = [ 'msg_text' => $thisValues['sms_text_message'], 'is_active' => TRUE, 'is_sms' => TRUE, - ); + ]; if (!empty($thisValues['SMSsaveTemplate'])) { $messageTemplate['msg_title'] = $thisValues['SMSsaveTemplateName']; @@ -368,8 +368,8 @@ public static function postProcess(&$form) { } // format contact details array to handle multiple sms from same contact - $formattedContactDetails = array(); - $tempPhones = array(); + $formattedContactDetails = []; + $tempPhones = []; foreach ($form->_contactIds as $key => $contactId) { $phone = $form->_toContactPhone[$key]; @@ -400,10 +400,10 @@ public static function postProcess(&$form) { ); if ($countSuccess > 0) { - CRM_Core_Session::setStatus(ts('One message was sent successfully.', array( + CRM_Core_Session::setStatus(ts('One message was sent successfully.', [ 'plural' => '%count messages were sent successfully.', 'count' => $countSuccess, - )), ts('Message Sent', array('plural' => 'Messages Sent', 'count' => $countSuccess)), 'success'); + ]), ts('Message Sent', ['plural' => 'Messages Sent', 'count' => $countSuccess]), 'success'); } if (is_array($sent)) { @@ -414,17 +414,17 @@ public static function postProcess(&$form) { $status .= '
  • ' . $errMsg . '
  • '; } $status .= ''; - CRM_Core_Session::setStatus($status, ts('One Message Not Sent', array( + CRM_Core_Session::setStatus($status, ts('One Message Not Sent', [ 'count' => count($sent), 'plural' => '%count Messages Not Sent', - )), 'info'); + ]), 'info'); } else { //Display the name and number of contacts for those sms is not sent. $smsNotSent = array_diff_assoc($allContactIds, $contactIds); if (!empty($smsNotSent)) { - $not_sent = array(); + $not_sent = []; foreach ($smsNotSent as $index => $contactId) { $displayName = $form->_allContactDetails[$contactId]['display_name']; $phone = $form->_allContactDetails[$contactId]['phone']; @@ -433,13 +433,13 @@ public static function postProcess(&$form) { } $status = '(' . ts('because no phone number on file or communication preferences specify DO NOT SMS or Contact is deceased'); if (CRM_Utils_System::getClassName($form) == 'CRM_Activity_Form_Task_SMS') { - $status .= ' ' . ts("or the contact is not part of the activity '%1'", array(1 => self::RECIEVED_SMS_ACTIVITY_SUBJECT)); + $status .= ' ' . ts("or the contact is not part of the activity '%1'", [1 => self::RECIEVED_SMS_ACTIVITY_SUBJECT]); } $status .= ')
    • ' . implode('
    • ', $not_sent) . '
    '; - CRM_Core_Session::setStatus($status, ts('One Message Not Sent', array( + CRM_Core_Session::setStatus($status, ts('One Message Not Sent', [ 'count' => count($smsNotSent), 'plural' => '%count Messages Not Sent', - )), 'info'); + ]), 'info'); } } } diff --git a/CRM/Contact/Form/Task/SaveSearch.php b/CRM/Contact/Form/Task/SaveSearch.php index 87133586c636..f871162a3433 100644 --- a/CRM/Contact/Form/Task/SaveSearch.php +++ b/CRM/Contact/Form/Task/SaveSearch.php @@ -138,7 +138,7 @@ public function buildQuickForm() { $this->assign('partiallySelected', $formValues['radio_ts'] != 'ts_all'); } $this->addRule('title', ts('Name already exists in Database.'), - 'objectExists', array('CRM_Contact_DAO_Group', $groupID, 'title') + 'objectExists', ['CRM_Contact_DAO_Group', $groupID, 'title'] ); } @@ -160,9 +160,9 @@ public function postProcess() { if (!$this->_id) { //save record in mapping table - $mappingParams = array( + $mappingParams = [ 'mapping_type_id' => CRM_Core_PseudoConstant::getKey('CRM_Core_BAO_Mapping', 'mapping_type_id', 'Search Builder'), - ); + ]; $mapping = CRM_Core_BAO_Mapping::add($mappingParams); $mappingId = $mapping->id; } @@ -205,10 +205,10 @@ public function postProcess() { $savedSearch->search_custom_id = $this->get('customSearchID'); $savedSearch->save(); $this->set('ssID', $savedSearch->id); - CRM_Core_Session::setStatus(ts("Your smart group has been saved as '%1'.", array(1 => $formValues['title'])), ts('Group Saved'), 'success'); + CRM_Core_Session::setStatus(ts("Your smart group has been saved as '%1'.", [1 => $formValues['title']]), ts('Group Saved'), 'success'); // also create a group that is associated with this saved search only if new saved search - $params = array(); + $params = []; $params['title'] = $formValues['title']; $params['description'] = $formValues['description']; if (isset($formValues['group_type']) && is_array($formValues['group_type']) && count($formValues['group_type'])) { @@ -233,12 +233,12 @@ public function postProcess() { // Update mapping with the name and description of the group. if ($mappingId && $group) { - $mappingParams = array( + $mappingParams = [ 'id' => $mappingId, 'name' => CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $group->id, 'name', 'id'), 'description' => CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $group->id, 'description', 'id'), 'mapping_type_id' => CRM_Core_PseudoConstant::getKey('CRM_Core_BAO_Mapping', 'mapping_type_id', 'Search Builder'), - ); + ]; CRM_Core_BAO_Mapping::add($mappingParams); } @@ -257,7 +257,7 @@ public function postProcess() { * return array */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; if (empty($defaults['parents'])) { $defaults['parents'] = CRM_Core_BAO_Domain::getGroupId(); } diff --git a/CRM/Contact/Form/Task/SaveSearch/Update.php b/CRM/Contact/Form/Task/SaveSearch/Update.php index 703af1422b50..4d6e7446a719 100644 --- a/CRM/Contact/Form/Task/SaveSearch/Update.php +++ b/CRM/Contact/Form/Task/SaveSearch/Update.php @@ -57,10 +57,10 @@ public function preProcess() { */ public function setDefaultValues() { - $defaults = array(); - $params = array(); + $defaults = []; + $params = []; - $params = array('saved_search_id' => $this->_id); + $params = ['saved_search_id' => $this->_id]; CRM_Contact_BAO_Group::retrieve($params, $defaults); return $defaults; diff --git a/CRM/Contact/Form/Task/Unhold.php b/CRM/Contact/Form/Task/Unhold.php index 3da999ed314b..0f51395bc2b1 100644 --- a/CRM/Contact/Form/Task/Unhold.php +++ b/CRM/Contact/Form/Task/Unhold.php @@ -27,15 +27,15 @@ public function postProcess() { $rowCount = $result->affectedRows(); if ($rowCount) { - CRM_Core_Session::setStatus(ts('%count email was found on hold and updated.', array( + CRM_Core_Session::setStatus(ts('%count email was found on hold and updated.', [ 'count' => $rowCount, 'plural' => '%count emails were found on hold and updated.', - )), ts('Emails Restored'), 'success'); + ]), ts('Emails Restored'), 'success'); } else { - CRM_Core_Session::setStatus(ts('The selected contact does not have an email on hold.', array( + CRM_Core_Session::setStatus(ts('The selected contact does not have an email on hold.', [ 'plural' => 'None of the selected contacts have an email on hold.', - )), ts('No Emails to Restore'), 'info'); + ]), ts('No Emails to Restore'), 'info'); } } else { diff --git a/CRM/Contact/Form/Task/Useradd.php b/CRM/Contact/Form/Task/Useradd.php index 4fe0b7af121b..303fee2ad5b6 100644 --- a/CRM/Contact/Form/Task/Useradd.php +++ b/CRM/Contact/Form/Task/Useradd.php @@ -52,21 +52,21 @@ class CRM_Contact_Form_Task_Useradd extends CRM_Core_Form { public $_email; public function preProcess() { - $params = $defaults = $ids = array(); + $params = $defaults = $ids = []; $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE); $params['id'] = $params['contact_id'] = $this->_contactId; $contact = CRM_Contact_BAO_Contact::retrieve($params, $defaults, $ids); $this->_displayName = $contact->display_name; $this->_email = $contact->email; - CRM_Utils_System::setTitle(ts('Create User Record for %1', array(1 => $this->_displayName))); + CRM_Utils_System::setTitle(ts('Create User Record for %1', [1 => $this->_displayName])); } /** * Set default values for the form. */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; $defaults['contactID'] = $this->_contactId; $defaults['name'] = $this->_displayName; if (!empty($this->_email)) { @@ -80,32 +80,32 @@ public function setDefaultValues() { * Build the form object. */ public function buildQuickForm() { - $element = $this->add('text', 'name', ts('Full Name'), array('class' => 'huge')); + $element = $this->add('text', 'name', ts('Full Name'), ['class' => 'huge']); $element->freeze(); - $this->add('text', 'cms_name', ts('Username'), array('class' => 'huge')); + $this->add('text', 'cms_name', ts('Username'), ['class' => 'huge']); $this->addRule('cms_name', 'Username is required', 'required'); - $this->add('password', 'cms_pass', ts('Password'), array('class' => 'huge')); - $this->add('password', 'cms_confirm_pass', ts('Confirm Password'), array('class' => 'huge')); + $this->add('password', 'cms_pass', ts('Password'), ['class' => 'huge']); + $this->add('password', 'cms_confirm_pass', ts('Confirm Password'), ['class' => 'huge']); $this->addRule('cms_pass', 'Password is required', 'required'); - $this->addRule(array('cms_pass', 'cms_confirm_pass'), 'ERROR: Password mismatch', 'compare'); - $this->add('text', 'email', ts('Email:'), array('class' => 'huge'))->freeze(); + $this->addRule(['cms_pass', 'cms_confirm_pass'], 'ERROR: Password mismatch', 'compare'); + $this->add('text', 'email', ts('Email:'), ['class' => 'huge'])->freeze(); $this->add('hidden', 'contactID'); //add a rule to check username uniqueness - $this->addFormRule(array('CRM_Contact_Form_Task_Useradd', 'usernameRule')); + $this->addFormRule(['CRM_Contact_Form_Task_Useradd', 'usernameRule']); $this->addButtons( - array( - array( + [ + [ 'type' => 'next', 'name' => ts('Add'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); $this->setDefaults($this->setDefaultValues()); } @@ -130,11 +130,11 @@ public function postProcess() { */ public static function usernameRule($params) { $config = CRM_Core_Config::singleton(); - $errors = array(); - $check_params = array( + $errors = []; + $check_params = [ 'name' => $params['cms_name'], 'mail' => $params['email'], - ); + ]; $config->userSystem->checkUserNameEmailExists($check_params, $errors); return empty($errors) ? TRUE : $errors; diff --git a/CRM/Contact/Import/Controller.php b/CRM/Contact/Import/Controller.php index b73a8a43d13d..b483639ce785 100644 --- a/CRM/Contact/Import/Controller.php +++ b/CRM/Contact/Import/Controller.php @@ -54,7 +54,7 @@ public function __construct($title = NULL, $action = CRM_Core_Action::NONE, $mod // add all the actions $config = CRM_Core_Config::singleton(); - $this->addActions($config->uploadDir, array('uploadFile')); + $this->addActions($config->uploadDir, ['uploadFile']); } } diff --git a/CRM/Contact/Import/Form/DataSource.php b/CRM/Contact/Import/Form/DataSource.php index ddecff176efd..0c8f1061bcbb 100644 --- a/CRM/Contact/Import/Form/DataSource.php +++ b/CRM/Contact/Import/Form/DataSource.php @@ -61,10 +61,10 @@ public function preProcess() { CRM_Core_Error::fatal(ts('Database Configuration Error: Insufficient permissions. Import requires that the CiviCRM database user has permission to create temporary tables. Contact your site administrator for assistance.')); } - $results = array(); + $results = []; $config = CRM_Core_Config::singleton(); $handler = opendir($config->uploadDir); - $errorFiles = array('sqlImport.errors', 'sqlImport.conflicts', 'sqlImport.duplicates', 'sqlImport.mismatch'); + $errorFiles = ['sqlImport.errors', 'sqlImport.conflicts', 'sqlImport.duplicates', 'sqlImport.mismatch']; // check for post max size avoid when called twice $snippet = CRM_Utils_Array::value('snippet', $_GET, 0); @@ -81,10 +81,10 @@ public function preProcess() { } closedir($handler); if (!empty($results)) { - CRM_Core_Error::fatal(ts('%1 file(s) in %2 directory are not writable. Listed file(s) might be used during the import to log the errors occurred during Import process. Contact your site administrator for assistance.', array( + CRM_Core_Error::fatal(ts('%1 file(s) in %2 directory are not writable. Listed file(s) might be used during the import to log the errors occurred during Import process. Contact your site administrator for assistance.', [ 1 => implode(', ', $results), 2 => $config->uploadDir, - ))); + ])); } $this->_dataSourceIsValid = FALSE; @@ -146,11 +146,11 @@ public function buildQuickForm() { $this->assign('urlPathVar', 'snippet=4'); $this->add('select', 'dataSource', ts('Data Source'), $dataSources, TRUE, - array('onchange' => 'buildDataSourceFormBlock(this.value);') + ['onchange' => 'buildDataSourceFormBlock(this.value);'] ); // duplicate handling options - $duplicateOptions = array(); + $duplicateOptions = []; $duplicateOptions[] = $this->createElement('radio', NULL, NULL, ts('Skip'), CRM_Import_Parser::DUPLICATE_SKIP ); @@ -171,11 +171,11 @@ public function buildQuickForm() { $mappingArray = CRM_Core_BAO_Mapping::getMappings('Import Contact'); $this->assign('savedMapping', $mappingArray); - $this->addElement('select', 'savedMapping', ts('Mapping Option'), array('' => ts('- select -')) + $mappingArray); + $this->addElement('select', 'savedMapping', ts('Mapping Option'), ['' => ts('- select -')] + $mappingArray); - $js = array('onClick' => "buildSubTypes();buildDedupeRules();"); + $js = ['onClick' => "buildSubTypes();buildDedupeRules();"]; // contact types option - $contactOptions = array(); + $contactOptions = []; if (CRM_Contact_BAO_ContactType::isActive('Individual')) { $contactOptions[] = $this->createElement('radio', NULL, NULL, ts('Individual'), CRM_Import_Parser::CONTACT_INDIVIDUAL, $js @@ -209,24 +209,24 @@ public function buildQuickForm() { } $this->assign('geoCode', $geoCode); - $this->addElement('text', 'fieldSeparator', ts('Import Field Separator'), array('size' => 2)); + $this->addElement('text', 'fieldSeparator', ts('Import Field Separator'), ['size' => 2]); if (Civi::settings()->get('address_standardization_provider') == 'USPS') { $this->addElement('checkbox', 'disableUSPS', ts('Disable USPS address validation during import?')); } - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'upload', 'name' => ts('Continue'), 'spacing' => '          ', 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); } @@ -240,12 +240,12 @@ public function buildQuickForm() { */ public function setDefaultValues() { $config = CRM_Core_Config::singleton(); - $defaults = array( + $defaults = [ 'dataSource' => 'CRM_Import_DataSource_CSV', 'onDuplicate' => CRM_Import_Parser::DUPLICATE_SKIP, 'contactType' => CRM_Import_Parser::CONTACT_INDIVIDUAL, 'fieldSeparator' => $config->fieldSeparator, - ); + ]; if ($loadeMapping = $this->get('loadedMapping')) { $this->assign('loadedMapping', $loadeMapping); @@ -268,7 +268,7 @@ private function _getDataSources() { // Open the data source dir and scan it for class files global $civicrm_root; $dataSourceDir = $civicrm_root . DIRECTORY_SEPARATOR . 'CRM' . DIRECTORY_SEPARATOR . 'Import' . DIRECTORY_SEPARATOR . 'DataSource' . DIRECTORY_SEPARATOR; - $dataSources = array(); + $dataSources = []; if (!is_dir($dataSourceDir)) { CRM_Core_Error::fatal("Import DataSource directory $dataSourceDir does not exist"); } @@ -278,7 +278,7 @@ private function _getDataSources() { while (($dataSourceFile = readdir($dataSourceHandle)) !== FALSE) { $fileType = filetype($dataSourceDir . $dataSourceFile); - $matches = array(); + $matches = []; if (($fileType == 'file' || $fileType == 'link') && preg_match('/^(.+)\.php$/', $dataSourceFile, $matches) ) { @@ -307,14 +307,14 @@ public function postProcess() { // Setup the params array $this->_params = $this->controller->exportValues($this->_name); - $storeParams = array( + $storeParams = [ 'onDuplicate' => 'onDuplicate', 'dedupe' => 'dedupe', 'contactType' => 'contactType', 'contactSubType' => 'subType', 'dateFormats' => 'dateFormats', 'savedMapping' => 'savedMapping', - ); + ]; foreach ($storeParams as $storeName => $storeValueName) { $$storeName = $this->exportValue($storeValueName); @@ -343,7 +343,7 @@ public function postProcess() { // We should have the data in the DB now, parse it $importTableName = $this->get('importTableName'); $fieldNames = $this->_prepareImportTable($db, $importTableName); - $mapper = array(); + $mapper = []; $parser = new CRM_Contact_Import_Parser_Contact($mapper); $parser->setMaxLinesToProcess(100); @@ -404,7 +404,7 @@ private function _prepareImportTable($db, $importTableName) { AUTO_INCREMENT"; $db->query($alterQuery); - return array('status' => $statusFieldName, 'pk' => $primaryKeyName); + return ['status' => $statusFieldName, 'pk' => $primaryKeyName]; } /** diff --git a/CRM/Contact/Import/Form/Summary.php b/CRM/Contact/Import/Form/Summary.php index 2baf9b11f39d..811b3f62e22f 100644 --- a/CRM/Contact/Import/Form/Summary.php +++ b/CRM/Contact/Import/Form/Summary.php @@ -96,7 +96,7 @@ public function preProcess() { $this->assign('dupeActionString', $dupeActionString); - $properties = array( + $properties = [ 'totalRowCount', 'validRowCount', 'invalidRowCount', @@ -110,7 +110,7 @@ public function preProcess() { 'tagAdditions', 'unMatchCount', 'unparsedAddressCount', - ); + ]; foreach ($properties as $property) { $this->assign($property, $this->get($property)); } diff --git a/CRM/Contact/Import/Page/AJAX.php b/CRM/Contact/Import/Page/AJAX.php index 6c9e88034364..94a9e0afd3ce 100644 --- a/CRM/Contact/Import/Page/AJAX.php +++ b/CRM/Contact/Import/Page/AJAX.php @@ -53,7 +53,7 @@ public static function status() { } else { $status = "
      " . ts('No processing status reported yet.') . "
    "; - echo json_encode(array(0, $status)); + echo json_encode([0, $status]); } CRM_Utils_System::civiExit(); } diff --git a/CRM/Contact/Import/Parser.php b/CRM/Contact/Import/Parser.php index fd1f644da735..114986d8e78e 100644 --- a/CRM/Contact/Import/Parser.php +++ b/CRM/Contact/Import/Parser.php @@ -140,17 +140,17 @@ public function run( $this->_invalidRowCount = $this->_validCount = 0; $this->_totalCount = $this->_conflictCount = 0; - $this->_errors = array(); - $this->_warnings = array(); - $this->_conflicts = array(); - $this->_unparsedAddresses = array(); + $this->_errors = []; + $this->_warnings = []; + $this->_conflicts = []; + $this->_unparsedAddresses = []; $this->_tableName = $tableName; $this->_primaryKeyName = $primaryKeyName; $this->_statusFieldName = $statusFieldName; if ($mode == self::MODE_MAPFIELD) { - $this->_rows = array(); + $this->_rows = []; } else { $this->_activeFieldCount = count($this->_activeFields); @@ -293,30 +293,30 @@ public function run( if ($this->_invalidRowCount) { // removed view url for invlaid contacts - $headers = array_merge(array( + $headers = array_merge([ ts('Line Number'), ts('Reason'), - ), + ], $customHeaders ); $this->_errorFileName = self::errorFileName(self::ERROR); self::exportCSV($this->_errorFileName, $headers, $this->_errors); } if ($this->_conflictCount) { - $headers = array_merge(array( + $headers = array_merge([ ts('Line Number'), ts('Reason'), - ), + ], $customHeaders ); $this->_conflictFileName = self::errorFileName(self::CONFLICT); self::exportCSV($this->_conflictFileName, $headers, $this->_conflicts); } if ($this->_duplicateCount) { - $headers = array_merge(array( + $headers = array_merge([ ts('Line Number'), ts('View Contact URL'), - ), + ], $customHeaders ); @@ -324,10 +324,10 @@ public function run( self::exportCSV($this->_duplicateFileName, $headers, $this->_duplicates); } if ($this->_unMatchCount) { - $headers = array_merge(array( + $headers = array_merge([ ts('Line Number'), ts('Reason'), - ), + ], $customHeaders ); @@ -335,10 +335,10 @@ public function run( self::exportCSV($this->_misMatchFilemName, $headers, $this->_unMatch); } if ($this->_unparsedAddressCount) { - $headers = array_merge(array( + $headers = array_merge([ ts('Line Number'), ts('Contact Edit URL'), - ), + ], $customHeaders ); $this->_errorFileName = self::errorFileName(self::UNPARSED_ADDRESS_WARNING); @@ -485,7 +485,7 @@ public function setActiveFieldRelatedContactImProvider($elements) { * (reference ) associative array of name/value pairs */ public function &getActiveFieldParams() { - $params = array(); + $params = []; for ($i = 0; $i < $this->_activeFieldCount; $i++) { if ($this->_activeFields[$i]->_name == 'do_not_import') { @@ -495,13 +495,13 @@ public function &getActiveFieldParams() { if (isset($this->_activeFields[$i]->_value)) { if (isset($this->_activeFields[$i]->_hasLocationType)) { if (!isset($params[$this->_activeFields[$i]->_name])) { - $params[$this->_activeFields[$i]->_name] = array(); + $params[$this->_activeFields[$i]->_name] = []; } - $value = array( + $value = [ $this->_activeFields[$i]->_name => $this->_activeFields[$i]->_value, 'location_type_id' => $this->_activeFields[$i]->_hasLocationType, - ); + ]; if (isset($this->_activeFields[$i]->_phoneType)) { $value['phone_type_id'] = $this->_activeFields[$i]->_phoneType; @@ -515,10 +515,10 @@ public function &getActiveFieldParams() { $params[$this->_activeFields[$i]->_name][] = $value; } elseif (isset($this->_activeFields[$i]->_websiteType)) { - $value = array( + $value = [ $this->_activeFields[$i]->_name => $this->_activeFields[$i]->_value, 'website_type_id' => $this->_activeFields[$i]->_websiteType, - ); + ]; $params[$this->_activeFields[$i]->_name][] = $value; } @@ -532,7 +532,7 @@ public function &getActiveFieldParams() { //minor fix for CRM-4062 if (isset($this->_activeFields[$i]->_related)) { if (!isset($params[$this->_activeFields[$i]->_related])) { - $params[$this->_activeFields[$i]->_related] = array(); + $params[$this->_activeFields[$i]->_related] = []; } if (!isset($params[$this->_activeFields[$i]->_related]['contact_type']) && !empty($this->_activeFields[$i]->_relatedContactType)) { @@ -543,12 +543,12 @@ public function &getActiveFieldParams() { if (!empty($params[$this->_activeFields[$i]->_related][$this->_activeFields[$i]->_relatedContactDetails]) && !is_array($params[$this->_activeFields[$i]->_related][$this->_activeFields[$i]->_relatedContactDetails]) ) { - $params[$this->_activeFields[$i]->_related][$this->_activeFields[$i]->_relatedContactDetails] = array(); + $params[$this->_activeFields[$i]->_related][$this->_activeFields[$i]->_relatedContactDetails] = []; } - $value = array( + $value = [ $this->_activeFields[$i]->_relatedContactDetails => $this->_activeFields[$i]->_value, 'location_type_id' => $this->_activeFields[$i]->_relatedContactLocType, - ); + ]; if (isset($this->_activeFields[$i]->_relatedContactPhoneType)) { $value['phone_type_id'] = $this->_activeFields[$i]->_relatedContactPhoneType; @@ -562,10 +562,10 @@ public function &getActiveFieldParams() { $params[$this->_activeFields[$i]->_related][$this->_activeFields[$i]->_relatedContactDetails][] = $value; } elseif (isset($this->_activeFields[$i]->_relatedContactWebsiteType)) { - $params[$this->_activeFields[$i]->_related][$this->_activeFields[$i]->_relatedContactDetails][] = array( + $params[$this->_activeFields[$i]->_related][$this->_activeFields[$i]->_relatedContactDetails][] = [ 'url' => $this->_activeFields[$i]->_value, 'website_type_id' => $this->_activeFields[$i]->_relatedContactWebsiteType, - ); + ]; } else { $params[$this->_activeFields[$i]->_related][$this->_activeFields[$i]->_relatedContactDetails] = $this->_activeFields[$i]->_value; @@ -581,7 +581,7 @@ public function &getActiveFieldParams() { * @return array */ public function getColumnPatterns() { - $values = array(); + $values = []; foreach ($this->_fields as $name => $field) { $values[$name] = $field->_columnPattern; } @@ -682,8 +682,8 @@ public static function exportCSV($fileName, $header, $data) { CRM_Core_Error::movedSiteError($fileName); } //hack to remove '_status', '_statusMsg' and '_id' from error file - $errorValues = array(); - $dbRecordStatus = array('IMPORTED', 'ERROR', 'DUPLICATE', 'INVALID', 'NEW'); + $errorValues = []; + $dbRecordStatus = ['IMPORTED', 'ERROR', 'DUPLICATE', 'INVALID', 'NEW']; foreach ($data as $rowCount => $rowValues) { $count = 0; foreach ($rowValues as $key => $val) { @@ -696,7 +696,7 @@ public static function exportCSV($fileName, $header, $data) { } $data = $errorValues; - $output = array(); + $output = []; $fd = fopen($fileName, 'w'); foreach ($header as $key => $value) { @@ -733,11 +733,11 @@ public function updateImportRecord($id, &$params) { SET $statusFieldName = ?, ${statusFieldName}Msg = ? WHERE $primaryKeyName = ?"; - $args = array( + $args = [ $params[$statusFieldName], CRM_Utils_Array::value("${statusFieldName}Msg", $params), $id, - ); + ]; //print "Running query: $query
    With arguments: ".$params[$statusFieldName].", ".$params["${statusFieldName}Msg"].", $id
    "; @@ -756,9 +756,9 @@ public function updateImportRecord($id, &$params) { * Contact DAO fields. */ public function formatCommonData($params, &$formatted, &$contactFields) { - $csType = array( + $csType = [ CRM_Utils_Array::value('contact_type', $formatted), - ); + ]; //CRM-5125 //add custom fields for contact sub type @@ -776,11 +776,11 @@ public function formatCommonData($params, &$formatted, &$contactFields) { $customFields = $customFields + $addressCustomFields; //if a Custom Email Greeting, Custom Postal Greeting or Custom Addressee is mapped, and no "Greeting / Addressee Type ID" is provided, then automatically set the type = Customized, CRM-4575 - $elements = array( + $elements = [ 'email_greeting_custom' => 'email_greeting', 'postal_greeting_custom' => 'postal_greeting', 'addressee_custom' => 'addressee', - ); + ]; foreach ($elements as $k => $v) { if (array_key_exists($k, $params) && !(array_key_exists($v, $params))) { $label = key(CRM_Core_OptionGroup::values($v, TRUE, NULL, NULL, 'AND v.name = "Customized"')); @@ -860,9 +860,9 @@ public function formatCommonData($params, &$formatted, &$contactFields) { } } - $formatValues = array( + $formatValues = [ $key => $field, - ); + ]; if (($key !== 'preferred_communication_method') && (array_key_exists($key, $contactFields))) { // due to merging of individual table and @@ -909,8 +909,8 @@ public function formatCommonData($params, &$formatted, &$contactFields) { if (!empty($formatted[$key]) && !empty($params[$key])) { $mulValues = explode(',', $formatted[$key]); $customOption = CRM_Core_BAO_CustomOption::getCustomOption($customFieldID, TRUE); - $formatted[$key] = array(); - $params[$key] = array(); + $formatted[$key] = []; + $params[$key] = []; foreach ($mulValues as $v1) { foreach ($customOption as $v2) { if ((strtolower($v2['label']) == strtolower(trim($v1))) || @@ -1002,7 +1002,7 @@ protected function formatContactParameters(&$values, &$params) { // Custom // Cache the various object fields - static $fields = array(); + static $fields = []; // first add core contact values since for other Civi modules they are not added $contactFields = CRM_Contact_DAO_Contact::fields(); @@ -1042,10 +1042,10 @@ protected function formatContactParameters(&$values, &$params) { // CRM-4575 if (isset($values['email_greeting'])) { if (!empty($params['email_greeting_id'])) { - $emailGreetingFilter = array( + $emailGreetingFilter = [ 'contact_type' => CRM_Utils_Array::value('contact_type', $params), 'greeting_type' => 'email_greeting', - ); + ]; $emailGreetings = CRM_Core_PseudoConstant::greeting($emailGreetingFilter); $params['email_greeting'] = $emailGreetings[$params['email_greeting_id']]; } @@ -1058,10 +1058,10 @@ protected function formatContactParameters(&$values, &$params) { if (isset($values['postal_greeting'])) { if (!empty($params['postal_greeting_id'])) { - $postalGreetingFilter = array( + $postalGreetingFilter = [ 'contact_type' => CRM_Utils_Array::value('contact_type', $params), 'greeting_type' => 'postal_greeting', - ); + ]; $postalGreetings = CRM_Core_PseudoConstant::greeting($postalGreetingFilter); $params['postal_greeting'] = $postalGreetings[$params['postal_greeting_id']]; } @@ -1073,10 +1073,10 @@ protected function formatContactParameters(&$values, &$params) { if (isset($values['addressee'])) { if (!empty($params['addressee_id'])) { - $addresseeFilter = array( + $addresseeFilter = [ 'contact_type' => CRM_Utils_Array::value('contact_type', $params), 'greeting_type' => 'addressee', - ); + ]; $addressee = CRM_Core_PseudoConstant::addressee($addresseeFilter); $params['addressee'] = $addressee[$params['addressee_id']]; } @@ -1098,7 +1098,7 @@ protected function formatContactParameters(&$values, &$params) { } if (!empty($values['preferred_communication_method'])) { - $comm = array(); + $comm = []; $pcm = array_change_key_case(array_flip(CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'preferred_communication_method')), CASE_LOWER); $preffComm = explode(',', $values['preferred_communication_method']); @@ -1122,7 +1122,7 @@ protected function formatContactParameters(&$values, &$params) { if (!array_key_exists('website', $params) || !is_array($params['website']) ) { - $params['website'] = array(); + $params['website'] = []; } $websiteCount = count($params['website']); @@ -1135,13 +1135,13 @@ protected function formatContactParameters(&$values, &$params) { // get the formatted location blocks into params - w/ 3.0 format, CRM-4605 if (!empty($values['location_type_id'])) { - $blockTypes = array( + $blockTypes = [ 'phone' => 'Phone', 'email' => 'Email', 'im' => 'IM', 'openid' => 'OpenID', 'phone_ext' => 'Phone', - ); + ]; foreach ($blockTypes as $blockFieldName => $block) { if (!array_key_exists($blockFieldName, $values)) { continue; @@ -1149,7 +1149,7 @@ protected function formatContactParameters(&$values, &$params) { // block present in value array. if (!array_key_exists($blockFieldName, $params) || !is_array($params[$blockFieldName])) { - $params[$blockFieldName] = array(); + $params[$blockFieldName] = []; } if (!array_key_exists($block, $fields)) { @@ -1170,7 +1170,7 @@ protected function formatContactParameters(&$values, &$params) { if ($values['location_type_id'] === 'Primary') { if (!empty($params['id'])) { - $primary = civicrm_api3($block, 'get', array('return' => 'location_type_id', 'contact_id' => $params['id'], 'is_primary' => 1, 'sequential' => 1)); + $primary = civicrm_api3($block, 'get', ['return' => 'location_type_id', 'contact_id' => $params['id'], 'is_primary' => 1, 'sequential' => 1]); } $defaultLocationType = CRM_Core_BAO_LocationType::getDefault(); $values['location_type_id'] = (isset($primary) && $primary['count']) ? $primary['values'][0]['location_type_id'] : $defaultLocationType->id; @@ -1187,7 +1187,7 @@ protected function formatContactParameters(&$values, &$params) { // handle address fields. if (!array_key_exists('address', $params) || !is_array($params['address'])) { - $params['address'] = array(); + $params['address'] = []; } if (!array_key_exists('Address', $fields)) { @@ -1198,7 +1198,7 @@ protected function formatContactParameters(&$values, &$params) { // The actual formatting (like date, country ..etc) for address custom fields is taken care of while saving // the address in CRM_Core_BAO_Address::create method if (!empty($values['location_type_id'])) { - static $customFields = array(); + static $customFields = []; if (empty($customFields)) { $customFields = CRM_Core_BAO_CustomField::getFields('Address'); } @@ -1217,7 +1217,7 @@ protected function formatContactParameters(&$values, &$params) { if ($val) { $mulValues = explode(',', $val); $customOption = CRM_Core_BAO_CustomOption::getCustomOption($customFieldID, TRUE); - $newValues[$key] = array(); + $newValues[$key] = []; foreach ($mulValues as $v1) { foreach ($customOption as $v2) { if ((strtolower($v2['label']) == strtolower(trim($v1))) || @@ -1243,7 +1243,7 @@ protected function formatContactParameters(&$values, &$params) { _civicrm_api3_store_values($fields['Address'], $values, $params['address'][$values['location_type_id']]); - $addressFields = array( + $addressFields = [ 'county', 'country', 'state_province', @@ -1251,12 +1251,12 @@ protected function formatContactParameters(&$values, &$params) { 'supplemental_address_2', 'supplemental_address_3', 'StateProvince.name', - ); + ]; foreach ($addressFields as $field) { if (array_key_exists($field, $values)) { if (!array_key_exists('address', $params)) { - $params['address'] = array(); + $params['address'] = []; } $params['address'][$values['location_type_id']][$field] = $values[$field]; } @@ -1264,7 +1264,7 @@ protected function formatContactParameters(&$values, &$params) { if ($values['location_type_id'] === 'Primary') { if (!empty($params['id'])) { - $primary = civicrm_api3('Address', 'get', array('return' => 'location_type_id', 'contact_id' => $params['id'], 'is_primary' => 1, 'sequential' => 1)); + $primary = civicrm_api3('Address', 'get', ['return' => 'location_type_id', 'contact_id' => $params['id'], 'is_primary' => 1, 'sequential' => 1]); } $defaultLocationType = CRM_Core_BAO_LocationType::getDefault(); $params['address'][$values['location_type_id']]['location_type_id'] = (isset($primary) && $primary['count']) ? $primary['values'][0]['location_type_id'] : $defaultLocationType->id; @@ -1277,11 +1277,11 @@ protected function formatContactParameters(&$values, &$params) { if (isset($values['note'])) { // add a note field if (!isset($params['note'])) { - $params['note'] = array(); + $params['note'] = []; } $noteBlock = count($params['note']) + 1; - $params['note'][$noteBlock] = array(); + $params['note'][$noteBlock] = []; if (!isset($fields['Note'])) { $fields['Note'] = CRM_Core_DAO_Note::fields(); } diff --git a/CRM/Contact/Import/Parser/Contact.php b/CRM/Contact/Import/Parser/Contact.php index 1c5fd1069c8c..08bc64789f97 100644 --- a/CRM/Contact/Import/Parser/Contact.php +++ b/CRM/Contact/Import/Parser/Contact.php @@ -182,18 +182,18 @@ public function init() { } if (!empty($relationshipType)) { - $fields = array_merge($fields, array( - 'related' => array( + $fields = array_merge($fields, [ + 'related' => [ 'title' => ts('- related contact info -'), - ), - ), $relationshipType); + ], + ], $relationshipType); } foreach ($fields as $name => $field) { $this->addField($name, $field['title'], CRM_Utils_Array::value('type', $field), CRM_Utils_Array::value('headerPattern', $field), CRM_Utils_Array::value('dataPattern', $field), CRM_Utils_Array::value('hasLocationType', $field)); } - $this->_newContacts = array(); + $this->_newContacts = []; $this->setActiveFields($this->_mapperKeys); $this->setActiveFieldLocationTypes($this->_mapperLocType); @@ -224,7 +224,7 @@ public function init() { foreach ($this->_mapperKeys as $key) { if (substr($key, 0, 5) == 'email' && substr($key, 0, 14) != 'email_greeting') { $this->_emailIndex = $index; - $this->_allEmails = array(); + $this->_allEmails = []; } if (substr($key, 0, 5) == 'phone') { $this->_phoneIndex = $index; @@ -244,16 +244,16 @@ public function init() { if ($key == 'external_identifier') { $this->_externalIdentifierIndex = $index; - $this->_allExternalIdentifiers = array(); + $this->_allExternalIdentifiers = []; } $index++; } $this->_updateWithId = FALSE; - if (in_array('id', $this->_mapperKeys) || ($this->_externalIdentifierIndex >= 0 && in_array($this->_onDuplicate, array( + if (in_array('id', $this->_mapperKeys) || ($this->_externalIdentifierIndex >= 0 && in_array($this->_onDuplicate, [ CRM_Import_Parser::DUPLICATE_UPDATE, CRM_Import_Parser::DUPLICATE_FILL, - ))) + ])) ) { $this->_updateWithId = TRUE; } @@ -303,7 +303,7 @@ public function summary(&$values) { $errorRequired = FALSE; switch ($this->_contactType) { case 'Individual': - $missingNames = array(); + $missingNames = []; if ($this->_firstNameIndex < 0 || empty($values[$this->_firstNameIndex])) { $errorRequired = TRUE; $missingNames[] = ts('First Name'); @@ -347,10 +347,10 @@ public function summary(&$values) { $errorMessage = ts('Missing required field:') . ' ' . ts('Email Address'); } array_unshift($values, $errorMessage); - $importRecordParams = array( + $importRecordParams = [ $statusFieldName => 'ERROR', "${statusFieldName}Msg" => $errorMessage, - ); + ]; $this->updateImportRecord($values[count($values) - 1], $importRecordParams); return CRM_Import_Parser::ERROR; @@ -364,10 +364,10 @@ public function summary(&$values) { if (!CRM_Utils_Rule::email($email)) { $errorMessage = ts('Invalid Email address'); array_unshift($values, $errorMessage); - $importRecordParams = array( + $importRecordParams = [ $statusFieldName => 'ERROR', "${statusFieldName}Msg" => $errorMessage, - ); + ]; $this->updateImportRecord($values[count($values) - 1], $importRecordParams); return CRM_Import_Parser::ERROR; @@ -385,10 +385,10 @@ public function summary(&$values) { $errorMessage = ts('Missing required field:') . ' ' . ts('Email Address'); } array_unshift($values, $errorMessage); - $importRecordParams = array( + $importRecordParams = [ $statusFieldName => 'ERROR', "${statusFieldName}Msg" => $errorMessage, - ); + ]; $this->updateImportRecord($values[count($values) - 1], $importRecordParams); return CRM_Import_Parser::ERROR; @@ -400,12 +400,12 @@ public function summary(&$values) { /* If it's a dupe,external Identifier */ if ($externalDupe = CRM_Utils_Array::value($externalID, $this->_allExternalIdentifiers)) { - $errorMessage = ts('External ID conflicts with record %1', array(1 => $externalDupe)); + $errorMessage = ts('External ID conflicts with record %1', [1 => $externalDupe]); array_unshift($values, $errorMessage); - $importRecordParams = array( + $importRecordParams = [ $statusFieldName => 'ERROR', "${statusFieldName}Msg" => $errorMessage, - ); + ]; $this->updateImportRecord($values[count($values) - 1], $importRecordParams); return CRM_Import_Parser::ERROR; } @@ -435,10 +435,10 @@ public function summary(&$values) { if ($errorMessage) { $tempMsg = "Invalid value for field(s) : $errorMessage"; // put the error message in the import record in the DB - $importRecordParams = array( + $importRecordParams = [ $statusFieldName => 'ERROR', "${statusFieldName}Msg" => $tempMsg, - ); + ]; $this->updateImportRecord($values[count($values) - 1], $importRecordParams); array_unshift($values, $tempMsg); $errorMessage = NULL; @@ -448,9 +448,9 @@ public function summary(&$values) { //if user correcting errors by walking back //need to reset status ERROR msg to null //now currently we are having valid data. - $importRecordParams = array( + $importRecordParams = [ $statusFieldName => 'NEW', - ); + ]; $this->updateImportRecord($values[count($values) - 1], $importRecordParams); return CRM_Import_Parser::VALID; @@ -481,7 +481,7 @@ public function getAllFields() { */ public function import($onDuplicate, &$values, $doGeocodeAddress = FALSE) { $config = CRM_Core_Config::singleton(); - $this->_unparsedStreetAddressContacts = array(); + $this->_unparsedStreetAddressContacts = []; if (!$doGeocodeAddress) { // CRM-5854, reset the geocode method to null to prevent geocoding CRM_Utils_GeocodeProvider::disableForSession(); @@ -493,18 +493,18 @@ public function import($onDuplicate, &$values, $doGeocodeAddress = FALSE) { $statusFieldName = $this->_statusFieldName; if ($response != CRM_Import_Parser::VALID) { - $importRecordParams = array( + $importRecordParams = [ $statusFieldName => 'INVALID', "${statusFieldName}Msg" => "Invalid (Error Code: $response)", - ); + ]; $this->updateImportRecord($values[count($values) - 1], $importRecordParams); return $response; } $params = &$this->getActiveFieldParams(); - $formatted = array( + $formatted = [ 'contact_type' => $this->_contactType, - ); + ]; static $contactFields = NULL; if ($contactFields == NULL) { @@ -512,17 +512,17 @@ public function import($onDuplicate, &$values, $doGeocodeAddress = FALSE) { } //check if external identifier exists in database - if (!empty($params['external_identifier']) && (!empty($params['id']) || in_array($onDuplicate, array( + if (!empty($params['external_identifier']) && (!empty($params['id']) || in_array($onDuplicate, [ CRM_Import_Parser::DUPLICATE_SKIP, CRM_Import_Parser::DUPLICATE_NOCHECK, - ))) + ])) ) { - $extIDResult = civicrm_api3('Contact', 'get', array( + $extIDResult = civicrm_api3('Contact', 'get', [ 'external_identifier' => $params['external_identifier'], 'showAll' => 'all', - 'return' => array('id', 'contact_is_deleted'), - )); + 'return' => ['id', 'contact_is_deleted'], + ]); if (isset($extIDResult['id'])) { // record with matching external identifier does exist. $internalCid = $extIDResult['id']; @@ -535,16 +535,16 @@ public function import($onDuplicate, &$values, $doGeocodeAddress = FALSE) { // with an external_identifier that is non-unique. So... // we will update this contact to remove the external_identifier // and let a new record be created. - $update_params = array('id' => $internalCid, 'external_identifier' => ''); + $update_params = ['id' => $internalCid, 'external_identifier' => '']; civicrm_api3('Contact', 'create', $update_params); } else { $errorMessage = ts('External ID already exists in Database.'); array_unshift($values, $errorMessage); - $importRecordParams = array( + $importRecordParams = [ $statusFieldName => 'ERROR', "${statusFieldName}Msg" => $errorMessage, - ); + ]; $this->updateImportRecord($values[count($values) - 1], $importRecordParams); return CRM_Import_Parser::DUPLICATE; } @@ -578,10 +578,10 @@ public function import($onDuplicate, &$values, $doGeocodeAddress = FALSE) { $errorMessage = $e->getMessage(); array_unshift($values, $errorMessage); - $importRecordParams = array( + $importRecordParams = [ $statusFieldName => 'ERROR', "${statusFieldName}Msg" => $errorMessage, - ); + ]; $this->updateImportRecord($values[count($values) - 1], $importRecordParams); return CRM_Import_Parser::ERROR; } @@ -711,7 +711,7 @@ public function import($onDuplicate, &$values, $doGeocodeAddress = FALSE) { if ($createNewContact || ($this->_retCode != CRM_Import_Parser::NO_MATCH && $this->_updateWithId)) { //CRM-4430, don't carry if not submitted. - foreach (array('prefix_id', 'suffix_id', 'gender_id') as $name) { + foreach (['prefix_id', 'suffix_id', 'gender_id'] as $name) { if (!empty($formatted[$name])) { $options = CRM_Contact_BAO_Contact::buildOptions($name, 'get'); if (!isset($options[$formatted[$name]])) { @@ -741,10 +741,10 @@ public function import($onDuplicate, &$values, $doGeocodeAddress = FALSE) { if ($onDuplicate == CRM_Import_Parser::DUPLICATE_SKIP) { $errorMessage = "Skipping duplicate record"; array_unshift($values, $errorMessage); - $importRecordParams = array( + $importRecordParams = [ $statusFieldName => 'DUPLICATE', "${statusFieldName}Msg" => $errorMessage, - ); + ]; $this->updateImportRecord($values[count($values) - 1], $importRecordParams); return CRM_Import_Parser::DUPLICATE; } @@ -770,13 +770,13 @@ public function import($onDuplicate, &$values, $doGeocodeAddress = FALSE) { // call import hook $currentImportID = end($values); - $hookParams = array( + $hookParams = [ 'contactID' => $contactID, 'importID' => $currentImportID, 'importTempTable' => $this->_tableName, 'fieldHeaders' => $this->_mapperKeys, 'fields' => $this->_activeFields, - ); + ]; CRM_Utils_Hook::import('Contact', 'process', $this, $hookParams); } @@ -806,9 +806,9 @@ public function import($onDuplicate, &$values, $doGeocodeAddress = FALSE) { $relationType->find(TRUE); $direction = "contact_sub_type_$second"; - $formatting = array( + $formatting = [ 'contact_type' => $params[$key]['contact_type'], - ); + ]; //set subtype for related contact CRM-5125 if (isset($relationType->$direction)) { @@ -832,14 +832,14 @@ public function import($onDuplicate, &$values, $doGeocodeAddress = FALSE) { $params[$key]['id'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $params[$key]['external_identifier'], 'id', 'external_identifier'); } // check for valid related contact id in update/fill mode, CRM-4424 - if (in_array($onDuplicate, array( + if (in_array($onDuplicate, [ CRM_Import_Parser::DUPLICATE_UPDATE, CRM_Import_Parser::DUPLICATE_FILL, - )) && !empty($params[$key]['id']) + ]) && !empty($params[$key]['id']) ) { $relatedContactType = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $params[$key]['id'], 'contact_type'); if (!$relatedContactType) { - $errorMessage = ts("No contact found for this related contact ID: %1", array(1 => $params[$key]['id'])); + $errorMessage = ts("No contact found for this related contact ID: %1", [1 => $params[$key]['id']]); array_unshift($values, $errorMessage); return CRM_Import_Parser::NO_MATCH; } @@ -854,7 +854,7 @@ public function import($onDuplicate, &$values, $doGeocodeAddress = FALSE) { if (!empty($relatedCsType) && (!CRM_Contact_BAO_ContactType::isAllowEdit($params[$key]['id'], $relatedCsType) && $relatedCsType != CRM_Utils_Array::value('contact_sub_type', $formatting)) ) { - $errorMessage = ts("Mismatched or Invalid contact subtype found for this related contact.") . ' ' . ts("ID: %1", array(1 => $params[$key]['id'])); + $errorMessage = ts("Mismatched or Invalid contact subtype found for this related contact.") . ' ' . ts("ID: %1", [1 => $params[$key]['id']]); array_unshift($values, $errorMessage); return CRM_Import_Parser::NO_MATCH; } @@ -880,10 +880,10 @@ public function import($onDuplicate, &$values, $doGeocodeAddress = FALSE) { //fixed for CRM-4148 if (!empty($params[$key]['id'])) { - $contact = array( + $contact = [ 'contact_id' => $params[$key]['id'], - ); - $defaults = array(); + ]; + $defaults = []; $relatedNewContact = CRM_Contact_BAO_Contact::retrieve($contact, $defaults); } else { @@ -894,7 +894,7 @@ public function import($onDuplicate, &$values, $doGeocodeAddress = FALSE) { $relatedNewContact = clone($relatedNewContact); } - $matchedIDs = array(); + $matchedIDs = []; // To update/fill contact, get the matching contact Ids if duplicate contact found // otherwise get contact Id from object of related contact if (is_array($relatedNewContact) && civicrm_error($relatedNewContact)) { @@ -907,10 +907,10 @@ public function import($onDuplicate, &$values, $doGeocodeAddress = FALSE) { else { $errorMessage = $relatedNewContact['error_message']; array_unshift($values, $errorMessage); - $importRecordParams = array( + $importRecordParams = [ $statusFieldName => 'ERROR', "${statusFieldName}Msg" => $errorMessage, - ); + ]; $this->updateImportRecord($values[count($values) - 1], $importRecordParams); return CRM_Import_Parser::ERROR; } @@ -919,10 +919,10 @@ public function import($onDuplicate, &$values, $doGeocodeAddress = FALSE) { $matchedIDs[] = $relatedNewContact->id; } // update/fill related contact after getting matching Contact Ids, CRM-4424 - if (in_array($onDuplicate, array( + if (in_array($onDuplicate, [ CRM_Import_Parser::DUPLICATE_UPDATE, CRM_Import_Parser::DUPLICATE_FILL, - ))) { + ])) { //validation of related contact subtype for update mode //CRM-5125 $relatedCsType = NULL; @@ -939,7 +939,7 @@ public function import($onDuplicate, &$values, $doGeocodeAddress = FALSE) { $updatedContact = $this->createContact($formatting, $contactFields, $onDuplicate, $matchedIDs[0]); } } - static $relativeContact = array(); + static $relativeContact = []; if (CRM_Core_Error::isAPIError($relatedNewContact, CRM_Core_ERROR::DUPLICATE_CONTACT)) { if (count($matchedIDs) >= 1) { $relContactId = $matchedIDs[0]; @@ -968,21 +968,21 @@ public function import($onDuplicate, &$values, $doGeocodeAddress = FALSE) { //if more than one duplicate contact //found, create relationship with first contact // now create the relationship record - $relationParams = array(); - $relationParams = array( + $relationParams = []; + $relationParams = [ 'relationship_type_id' => $key, - 'contact_check' => array( + 'contact_check' => [ $relContactId => 1, - ), + ], 'is_active' => 1, 'skipRecentView' => TRUE, - ); + ]; // we only handle related contact success, we ignore failures for now // at some point wold be nice to have related counts as separate - $relationIds = array( + $relationIds = [ 'contact' => $primaryContactId, - ); + ]; list($valid, $invalid, $duplicate, $saved, $relationshipIds) = CRM_Contact_BAO_Relationship::legacyCreateMultiple($relationParams, $relationIds); @@ -995,13 +995,13 @@ public function import($onDuplicate, &$values, $doGeocodeAddress = FALSE) { //handle current employer, CRM-3532 if ($valid) { $allRelationships = CRM_Core_PseudoConstant::relationshipType('name'); - $relationshipTypeId = str_replace(array( + $relationshipTypeId = str_replace([ '_a_b', '_b_a', - ), array( + ], [ '', '', - ), $key); + ], $key); $relationshipType = str_replace($relationshipTypeId . '_', '', $key); $orgId = $individualId = NULL; if ($allRelationships[$relationshipTypeId]["name_{$relationshipType}"] == 'Employee of') { @@ -1031,7 +1031,7 @@ public function import($onDuplicate, &$values, $doGeocodeAddress = FALSE) { $code = NULL; if (($code = CRM_Utils_Array::value('code', $newContact['error_message'])) && ($code == CRM_Core_Error::DUPLICATE_CONTACT)) { - $urls = array(); + $urls = []; // need to fix at some stage and decide if the error will return an // array or string, crude hack for now if (is_array($newContact['error_message']['params'][0])) { @@ -1050,10 +1050,10 @@ public function import($onDuplicate, &$values, $doGeocodeAddress = FALSE) { // If we duplicate more than one record, skip no matter what if (count($cids) > 1) { $errorMessage = ts('Record duplicates multiple contacts'); - $importRecordParams = array( + $importRecordParams = [ $statusFieldName => 'ERROR', "${statusFieldName}Msg" => $errorMessage, - ); + ]; //combine error msg to avoid mismatch between error file columns. $errorMessage .= "\n" . $url_string; @@ -1066,7 +1066,7 @@ public function import($onDuplicate, &$values, $doGeocodeAddress = FALSE) { $contactId = array_shift($cids); $cid = NULL; - $vals = array('contact_id' => $contactId); + $vals = ['contact_id' => $contactId]; if ($onDuplicate == CRM_Import_Parser::DUPLICATE_REPLACE) { civicrm_api('contact', 'delete', $vals); @@ -1080,10 +1080,10 @@ public function import($onDuplicate, &$values, $doGeocodeAddress = FALSE) { } // else skip does nothing and just returns an error code. if ($cid) { - $contact = array( + $contact = [ 'contact_id' => $cid, - ); - $defaults = array(); + ]; + $defaults = []; $newContact = CRM_Contact_BAO_Contact::retrieve($contact, $defaults); } @@ -1092,10 +1092,10 @@ public function import($onDuplicate, &$values, $doGeocodeAddress = FALSE) { // different kind of error other than DUPLICATE $errorMessage = $newContact['error_message']; array_unshift($values, $errorMessage); - $importRecordParams = array( + $importRecordParams = [ $statusFieldName => 'ERROR', "${statusFieldName}Msg" => $errorMessage, - ); + ]; $this->updateImportRecord($values[count($values) - 1], $importRecordParams); return CRM_Import_Parser::ERROR; } @@ -1111,17 +1111,17 @@ public function import($onDuplicate, &$values, $doGeocodeAddress = FALSE) { //CRM-262 No Duplicate Checking if ($onDuplicate == CRM_Import_Parser::DUPLICATE_SKIP) { array_unshift($values, $url_string); - $importRecordParams = array( + $importRecordParams = [ $statusFieldName => 'DUPLICATE', "${statusFieldName}Msg" => "Skipping duplicate record", - ); + ]; $this->updateImportRecord($values[count($values) - 1], $importRecordParams); return CRM_Import_Parser::DUPLICATE; } - $importRecordParams = array( + $importRecordParams = [ $statusFieldName => 'IMPORTED', - ); + ]; $this->updateImportRecord($values[count($values) - 1], $importRecordParams); //return warning if street address is not parsed, CRM-5886 return $this->processMessage($values, $statusFieldName, CRM_Import_Parser::VALID); @@ -1130,10 +1130,10 @@ public function import($onDuplicate, &$values, $doGeocodeAddress = FALSE) { // Not a dupe, so we had an error $errorMessage = $newContact['error_message']; array_unshift($values, $errorMessage); - $importRecordParams = array( + $importRecordParams = [ $statusFieldName => 'ERROR', "${statusFieldName}Msg" => $errorMessage, - ); + ]; $this->updateImportRecord($values[count($values) - 1], $importRecordParams); return CRM_Import_Parser::ERROR; } @@ -1188,14 +1188,14 @@ public static function isErrorInCustomData($params, &$errorMessage, $csType = NU } // get array of subtypes - CRM-18708 - if (in_array($csType, array('Individual', 'Organization', 'Household'))) { + if (in_array($csType, ['Individual', 'Organization', 'Household'])) { $csType = self::getSubtypes($params['contact_type']); } if (is_array($csType)) { // fetch custom fields for every subtype and add it to $customFields array // CRM-18708 - $customFields = array(); + $customFields = []; foreach ($csType as $cType) { $customFields += CRM_Core_BAO_CustomField::getFields($params['contact_type'], FALSE, FALSE, $cType); } @@ -1243,14 +1243,14 @@ public static function isErrorInCustomData($params, &$errorMessage, $csType = NU } } // need not check for label filed import - $htmlType = array( + $htmlType = [ 'CheckBox', 'Multi-Select', 'Select', 'Radio', 'Multi-Select State/Province', 'Multi-Select Country', - ); + ]; if (!in_array($customFields[$customFieldID]['html_type'], $htmlType) || $customFields[$customFieldID]['data_type'] == 'Boolean' || $customFields[$customFieldID]['data_type'] == 'ContactReference') { $valid = CRM_Core_BAO_CustomValue::typecheck($customFields[$customFieldID]['data_type'], $value); if (!$valid) { @@ -1315,11 +1315,11 @@ public static function isErrorInCustomData($params, &$errorMessage, $csType = NU $limitCodes = CRM_Core_BAO_Country::countryLimit(); $error = TRUE; - foreach (array( + foreach ([ $countryNames, $countryIsoCodes, $limitCodes, - ) as $values) { + ] as $values) { if (in_array(trim($countryValue), $values)) { $error = FALSE; break; @@ -1449,7 +1449,7 @@ public function isErrorInCoreData($params, &$errorMessage) { break; case 'preferred_communication_method': - $preffComm = array(); + $preffComm = []; $preffComm = explode(',', $value); foreach ($preffComm as $v) { if (!self::in_value(trim($v), CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'preferred_communication_method'))) { @@ -1571,30 +1571,30 @@ public function isErrorInCoreData($params, &$errorMessage) { //custom email/postal greeting, custom addressee, CRM-4575 case 'email_greeting': - $emailGreetingFilter = array( + $emailGreetingFilter = [ 'contact_type' => $this->_contactType, 'greeting_type' => 'email_greeting', - ); + ]; if (!self::in_value($value, CRM_Core_PseudoConstant::greeting($emailGreetingFilter))) { self::addToErrorMsg(ts('Email Greeting must be one of the configured format options. Check Administer >> System Settings >> Option Groups >> Email Greetings for valid values'), $errorMessage); } break; case 'postal_greeting': - $postalGreetingFilter = array( + $postalGreetingFilter = [ 'contact_type' => $this->_contactType, 'greeting_type' => 'postal_greeting', - ); + ]; if (!self::in_value($value, CRM_Core_PseudoConstant::greeting($postalGreetingFilter))) { self::addToErrorMsg(ts('Postal Greeting must be one of the configured format options. Check Administer >> System Settings >> Option Groups >> Postal Greetings for valid values'), $errorMessage); } break; case 'addressee': - $addresseeFilter = array( + $addresseeFilter = [ 'contact_type' => $this->_contactType, 'greeting_type' => 'addressee', - ); + ]; if (!self::in_value($value, CRM_Core_PseudoConstant::greeting($addresseeFilter))) { self::addToErrorMsg(ts('Addressee must be one of the configured format options. Check Administer >> System Settings >> Option Groups >> Addressee for valid values'), $errorMessage); } @@ -1754,11 +1754,11 @@ public function createContact(&$formatted, &$contactFields, $onDuplicate, $conta $cid = CRM_Contact_BAO_Contact::createProfileContact($formatted, $contactFields, $contactId, NULL, NULL, $formatted['contact_type']); CRM_Core_Config::setPermitCacheFlushMode(TRUE); - $contact = array( + $contact = [ 'contact_id' => $cid, - ); + ]; - $defaults = array(); + $defaults = []; $newContact = CRM_Contact_BAO_Contact::retrieve($contact, $defaults); } @@ -1766,10 +1766,10 @@ public function createContact(&$formatted, &$contactFields, $onDuplicate, $conta if ($this->_parseStreetAddress && is_object($newContact) && property_exists($newContact, 'address') && $newContact->address) { foreach ($newContact->address as $address) { if (!empty($address['street_address']) && (empty($address['street_number']) || empty($address['street_name']))) { - $this->_unparsedStreetAddressContacts[] = array( + $this->_unparsedStreetAddressContacts[] = [ 'id' => $newContact->id, 'streetAddress' => $address['street_address'], - ); + ]; } } } @@ -1791,11 +1791,11 @@ public function formatParams(&$params, $onDuplicate, $cid) { return; } - $contactParams = array( + $contactParams = [ 'contact_id' => $cid, - ); + ]; - $defaults = array(); + $defaults = []; $contactObj = CRM_Contact_BAO_Contact::retrieve($contactParams, $defaults); $modeUpdate = $modeFill = FALSE; @@ -1811,13 +1811,13 @@ public function formatParams(&$params, $onDuplicate, $cid) { $groupTree = CRM_Core_BAO_CustomGroup::getTree($params['contact_type'], NULL, $cid, 0, NULL); CRM_Core_BAO_CustomGroup::setDefaults($groupTree, $defaults, FALSE, FALSE); - $locationFields = array( + $locationFields = [ 'email' => 'email', 'phone' => 'phone', 'im' => 'name', 'website' => 'website', 'address' => 'address', - ); + ]; $contact = get_object_vars($contactObj); @@ -1829,11 +1829,11 @@ public function formatParams(&$params, $onDuplicate, $cid) { if (array_key_exists($key, $locationFields)) { continue; } - elseif (in_array($key, array( + elseif (in_array($key, [ 'email_greeting', 'postal_greeting', 'addressee', - ))) { + ])) { // CRM-4575, need to null custom if ($params["{$key}_id"] != 4) { $params["{$key}_custom"] = 'null'; @@ -1842,7 +1842,7 @@ public function formatParams(&$params, $onDuplicate, $cid) { } else { if ($customFieldId = CRM_Core_BAO_CustomField::getKeyID($key)) { - $custom_params = array('id' => $contact['id'], 'return' => $key); + $custom_params = ['id' => $contact['id'], 'return' => $key]; $getValue = civicrm_api3('Contact', 'getvalue', $custom_params); if (empty($getValue)) { unset($getValue); @@ -1927,9 +1927,9 @@ public static function formatCustomDate(&$params, &$formatted, $dateType, $dateP */ public function processMessage(&$values, $statusFieldName, $returnCode) { if (empty($this->_unparsedStreetAddressContacts)) { - $importRecordParams = array( + $importRecordParams = [ $statusFieldName => 'IMPORTED', - ); + ]; } else { $errorMessage = ts("Record imported successfully but unable to parse the street address: "); @@ -1938,10 +1938,10 @@ public function processMessage(&$values, $statusFieldName, $returnCode) { $errorMessage .= "\n Contact ID:" . $contactValue['id'] . " " . $contactValue['streetAddress'] . ""; } array_unshift($values, $errorMessage); - $importRecordParams = array( + $importRecordParams = [ $statusFieldName => 'ERROR', "${statusFieldName}Msg" => $errorMessage, - ); + ]; $returnCode = CRM_Import_Parser::UNPARSED_ADDRESS_WARNING; } $this->updateImportRecord($values[count($values) - 1], $importRecordParams); @@ -1959,7 +1959,7 @@ public function checkRelatedContactFields($relKey, $params) { $allowToCreate = FALSE; //build the mapper field array. - static $relatedContactFields = array(); + static $relatedContactFields = []; if (!isset($relatedContactFields[$relKey])) { foreach ($this->_mapperRelated as $key => $name) { if (!$name) { @@ -1967,7 +1967,7 @@ public function checkRelatedContactFields($relKey, $params) { } if (!empty($relatedContactFields[$name]) && !is_array($relatedContactFields[$name])) { - $relatedContactFields[$name] = array(); + $relatedContactFields[$name] = []; } $fldName = CRM_Utils_Array::value($key, $this->_mapperRelatedContactDetails); if ($fldName == 'url') { @@ -1999,7 +1999,7 @@ public function checkRelatedContactFields($relKey, $params) { * @return array $subTypes */ public static function getSubtypes($contactType) { - $subTypes = array(); + $subTypes = []; $types = CRM_Contact_BAO_ContactType::subTypeInfo($contactType); if (count($types) > 0) { @@ -2031,18 +2031,18 @@ protected function getPossibleContactMatches($params) { if (!empty($params['external_identifier'])) { // Check for any match on external id, deleted or otherwise. - $extIDContact = civicrm_api3('Contact', 'get', array( + $extIDContact = civicrm_api3('Contact', 'get', [ 'external_identifier' => $params['external_identifier'], 'showAll' => 'all', - 'return' => array('id', 'contact_is_deleted'), - )); + 'return' => ['id', 'contact_is_deleted'], + ]); if (isset($extIDContact['id'])) { $extIDMatch = $extIDContact['id']; if ($extIDContact['values'][$extIDMatch]['contact_is_deleted'] == 1) { // If the contact is deleted, update external identifier to be blank // to avoid key error from MySQL. - $params = array('id' => $extIDMatch, 'external_identifier' => ''); + $params = ['id' => $extIDMatch, 'external_identifier' => '']; civicrm_api3('Contact', 'create', $params); // And now it is no longer a match. @@ -2050,7 +2050,7 @@ protected function getPossibleContactMatches($params) { } } } - $checkParams = array('check_permissions' => FALSE, 'match' => $params); + $checkParams = ['check_permissions' => FALSE, 'match' => $params]; $checkParams['match']['contact_type'] = $this->_contactType; $possibleMatches = civicrm_api3('Contact', 'duplicatecheck', $checkParams); @@ -2059,14 +2059,14 @@ protected function getPossibleContactMatches($params) { } if ($possibleMatches['count']) { if (in_array($extIDMatch, array_keys($possibleMatches['values']))) { - return array($extIDMatch); + return [$extIDMatch]; } else { throw new CRM_Core_Exception(ts( 'Matching this contact based on the de-dupe rule would cause an external ID conflict')); } } - return array($extIDMatch); + return [$extIDMatch]; } /** @@ -2078,7 +2078,7 @@ protected function getPossibleContactMatches($params) { * @return array $parserParameters */ public static function getParameterForParser($count) { - $baseArray = array(); + $baseArray = []; for ($i = 0; $i < $count; $i++) { $baseArray[$i] = NULL; } diff --git a/CRM/Contact/Page/AJAX.php b/CRM/Contact/Page/AJAX.php index 16b493e3a01e..db7dca4ab7fd 100644 --- a/CRM/Contact/Page/AJAX.php +++ b/CRM/Contact/Page/AJAX.php @@ -56,20 +56,20 @@ public static function contactReference() { $cfID = CRM_Utils_Type::escape($_GET['id'], 'Positive'); // check that this is a valid, active custom field of Contact Reference type - $params = array('id' => $cfID); - $returnProperties = array('filter', 'data_type', 'is_active'); - $cf = array(); + $params = ['id' => $cfID]; + $returnProperties = ['filter', 'data_type', 'is_active']; + $cf = []; CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_CustomField', $params, $cf, $returnProperties); if (!$cf['id'] || !$cf['is_active'] || $cf['data_type'] != 'ContactReference') { CRM_Utils_System::civiExit(1); } if (!empty($cf['filter'])) { - $filterParams = array(); + $filterParams = []; parse_str($cf['filter'], $filterParams); $action = CRM_Utils_Array::value('action', $filterParams); - if (!empty($action) && !in_array($action, array('get', 'lookup'))) { + if (!empty($action) && !in_array($action, ['get', 'lookup'])) { CRM_Utils_System::civiExit(1); } @@ -82,17 +82,17 @@ public static function contactReference() { 'contact_reference_options' ), '1'); - $return = array_unique(array_merge(array('sort_name'), $list)); + $return = array_unique(array_merge(['sort_name'], $list)); $limit = Civi::settings()->get('search_autocomplete_count'); - $params = array('offset' => 0, 'rowCount' => $limit, 'version' => 3); + $params = ['offset' => 0, 'rowCount' => $limit, 'version' => 3]; foreach ($return as $fld) { $params["return.{$fld}"] = 1; } if (!empty($action)) { - $excludeGet = array( + $excludeGet = [ 'reset', 'key', 'className', @@ -106,7 +106,7 @@ public static function contactReference() { 's', 'q', 'action', - ); + ]; foreach ($_GET as $param => $val) { if (empty($val) || in_array($param, $excludeGet) || @@ -139,15 +139,15 @@ public static function contactReference() { CRM_Utils_System::civiExit(1); } - $contactList = array(); + $contactList = []; foreach ($contact['values'] as $value) { - $view = array(); + $view = []; foreach ($return as $fld) { if (!empty($value[$fld])) { $view[] = $value[$fld]; } } - $contactList[] = array('id' => $value['id'], 'text' => implode(' :: ', $view)); + $contactList[] = ['id' => $value['id'], 'text' => implode(' :: ', $view)]; } if (!empty($_GET['is_unit_test'])) { @@ -211,13 +211,13 @@ public static function getPCPList() { "; $dao = CRM_Core_DAO::executeQuery($query); - $output = array('results' => array(), 'more' => FALSE); + $output = ['results' => [], 'more' => FALSE]; while ($dao->fetch()) { if (++$count > $max) { $output['more'] = TRUE; } else { - $output['results'][] = array('id' => $dao->id, 'text' => $dao->data); + $output['results'][] = ['id' => $dao->id, 'text' => $dao->data]; } } CRM_Utils_JSON::output($output); @@ -234,7 +234,7 @@ public static function relationship() { CRM_Utils_System::permissionDenied(); } - $ret = array('is_error' => 0); + $ret = ['is_error' => 0]; list($relTypeId, $b, $a) = explode('_', $relType); @@ -285,9 +285,9 @@ public static function relationship() { */ public static function customField() { $fieldId = CRM_Utils_Type::escape($_REQUEST['id'], 'Integer'); - $params = array('id' => $fieldId); - $returnProperties = array('help_pre', 'help_post'); - $values = array(); + $params = ['id' => $fieldId]; + $returnProperties = ['help_pre', 'help_post']; + $values = []; CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_CustomField', $params, $values, $returnProperties); CRM_Utils_JSON::output($values); @@ -321,7 +321,7 @@ public static function deleteCustomValue() { * check the CMS username. */ static public function checkUserName() { - $signer = new CRM_Utils_Signer(CRM_Core_Key::privateKey(), array('for', 'ts')); + $signer = new CRM_Utils_Signer(CRM_Core_Key::privateKey(), ['for', 'ts']); $sig = CRM_Utils_Request::retrieve('sig', 'String'); $for = CRM_Utils_Request::retrieve('for', 'String'); if ( @@ -329,26 +329,26 @@ static public function checkUserName() { || $for != 'civicrm/ajax/cmsuser' || !$signer->validate($sig, $_REQUEST) ) { - $user = array('name' => 'error'); + $user = ['name' => 'error']; CRM_Utils_JSON::output($user); } $config = CRM_Core_Config::singleton(); $username = trim(CRM_Utils_Array::value('cms_name', $_REQUEST)); - $params = array('name' => $username); + $params = ['name' => $username]; - $errors = array(); + $errors = []; $config->userSystem->checkUserNameEmailExists($params, $errors); if (isset($errors['cms_name']) || isset($errors['name'])) { //user name is not available - $user = array('name' => 'no'); + $user = ['name' => 'no']; CRM_Utils_JSON::output($user); } else { //user name is available - $user = array('name' => 'yes'); + $user = ['name' => 'yes']; CRM_Utils_JSON::output($user); } @@ -400,7 +400,7 @@ public static function getContactEmail() { } if ($queryString) { - $result = array(); + $result = []; $offset = CRM_Utils_Array::value('offset', $_GET, 0); $rowCount = Civi::settings()->get('search_autocomplete_count'); @@ -430,10 +430,10 @@ public static function getContactEmail() { $dao = CRM_Core_DAO::executeQuery($query); while ($dao->fetch()) { - $result[] = array( + $result[] = [ 'id' => $dao->id, 'text' => $dao->name, - ); + ]; } } else { @@ -457,10 +457,10 @@ public static function getContactEmail() { while ($dao->fetch()) { //working here - $result[] = array( + $result[] = [ 'text' => '"' . $dao->name . '" <' . $dao->email . '>', 'id' => (CRM_Utils_Array::value('id', $_GET)) ? "{$dao->id}::{$dao->email}" : '"' . $dao->name . '" <' . $dao->email . '>', - ); + ]; } } CRM_Utils_JSON::output($result); @@ -491,7 +491,7 @@ public static function getContactPhone() { } if ($queryString) { - $result = array(); + $result = []; $offset = (int) CRM_Utils_Request::retrieveValue('offset', 'Integer', 0, FALSE, 'GET'); $rowCount = (int) CRM_Utils_Request::retrieveValue('rowcount', 'Integer', 20, FALSE, 'GET'); @@ -520,10 +520,10 @@ public static function getContactPhone() { $dao = CRM_Core_DAO::executeQuery($query, $sqlParams); while ($dao->fetch()) { - $result[] = array( + $result[] = [ 'text' => '"' . $dao->name . '" (' . $dao->phone . ')', 'id' => (CRM_Utils_Array::value('id', $_GET)) ? "{$dao->id}::{$dao->phone}" : '"' . $dao->name . '" <' . $dao->phone . '>', - ); + ]; } CRM_Utils_JSON::output($result); } @@ -600,12 +600,12 @@ public static function getSignature() { $query = "SELECT signature_text, signature_html FROM civicrm_email WHERE id = {$emailID}"; $dao = CRM_Core_DAO::executeQuery($query); - $signatures = array(); + $signatures = []; while ($dao->fetch()) { - $signatures = array( + $signatures = [ 'signature_text' => $dao->signature_text, 'signature_html' => $dao->signature_html, - ); + ]; } CRM_Utils_JSON::output($signatures); @@ -640,7 +640,7 @@ public static function processDupes() { $status = $exception->delete(); } - CRM_Utils_JSON::output(array('status' => ($status) ? $oper : $status)); + CRM_Utils_JSON::output(['status' => ($status) ? $oper : $status]); } /** @@ -662,18 +662,18 @@ public static function getDedupes() { $whereClause = $orderByClause = ''; $cacheKeyString = CRM_Dedupe_Merger::getMergeCacheKeyString($rgid, $gid, json_decode($criteria, TRUE)); - $searchRows = array(); + $searchRows = []; $searchParams = self::getSearchOptionsFromRequest(); - $queryParams = array(); + $queryParams = []; $join = ''; - $where = array(); + $where = []; $isOrQuery = self::isOrQuery(); $nextParamKey = 3; - $mappings = array( + $mappings = [ 'dst' => 'cc1.display_name', 'src' => 'cc2.display_name', 'dst_email' => 'ce1.email', @@ -682,13 +682,13 @@ public static function getDedupes() { 'src_postcode' => 'ca2.postal_code', 'dst_street' => 'ca1.street', 'src_street' => 'ca2.street', - ); + ]; foreach ($mappings as $key => $dbName) { if (!empty($searchParams[$key])) { // CRM-18694. $wildcard = strstr($key, 'postcode') ? '' : '%'; - $queryParams[$nextParamKey] = array($wildcard . $searchParams[$key] . '%', 'String'); + $queryParams[$nextParamKey] = [$wildcard . $searchParams[$key] . '%', 'String']; $where[] = $dbName . " LIKE %{$nextParamKey} "; $nextParamKey++; } @@ -709,7 +709,7 @@ public static function getDedupes() { } $join .= CRM_Dedupe_Merger::getJoinOnDedupeTable(); - $select = array( + $select = [ 'cc1.contact_type' => 'dst_contact_type', 'cc1.display_name' => 'dst_display_name', 'cc1.contact_sub_type' => 'dst_contact_sub_type', @@ -722,7 +722,7 @@ public static function getDedupes() { 'ca2.postal_code' => 'src_postcode', 'ca1.street_address' => 'dst_street', 'ca2.street_address' => 'src_street', - ); + ]; if ($select) { $join .= " INNER JOIN civicrm_contact cc1 ON cc1.id = pn.entity_id1"; @@ -840,11 +840,11 @@ public static function getDedupes() { $count++; } - $dupePairs = array( + $dupePairs = [ 'data' => $searchRows, 'recordsTotal' => $iTotal, 'recordsFiltered' => $iFilteredTotal, - ); + ]; if (!empty($_REQUEST['is_unit_test'])) { return $dupePairs; } @@ -857,10 +857,10 @@ public static function getDedupes() { * @return array */ public static function getSearchOptionsFromRequest() { - $searchParams = array(); + $searchParams = []; $searchData = CRM_Utils_Array::value('search', $_REQUEST); $searchData['value'] = CRM_Utils_Type::escape($searchData['value'], 'String'); - $selectorElements = array( + $selectorElements = [ 'is_selected', 'is_selected_input', 'src_image', @@ -876,7 +876,7 @@ public static function getSearchOptionsFromRequest() { 'conflicts', 'weight', 'actions', - ); + ]; $columns = $_REQUEST['columns']; foreach ($columns as $column) { @@ -984,7 +984,7 @@ public static function selectUnselectContacts() { $contactIds = Civi::service('prevnext')->getSelection($cacheKey); $countSelectionCids = count($contactIds[$cacheKey]); - $arrRet = array('getCount' => $countSelectionCids); + $arrRet = ['getCount' => $countSelectionCids]; CRM_Utils_JSON::output($arrRet); } @@ -1006,10 +1006,10 @@ public static function getAddressDisplay() { $addressVal["error_message"] = "no contact id found"; } else { - $entityBlock = array( + $entityBlock = [ 'contact_id' => $contactId, 'entity_id' => $contactId, - ); + ]; $addressVal = CRM_Core_BAO_Address::getValues($entityBlock); } @@ -1024,10 +1024,10 @@ public static function toggleDedupeSelect() { $isSelected = CRM_Utils_Type::escape($_REQUEST['is_selected'], 'Boolean'); $cacheKeyString = CRM_Utils_Request::retrieve('cacheKey', 'Alphanumeric', $null, FALSE); - $params = array( - 1 => array($isSelected, 'Boolean'), - 3 => array("$cacheKeyString%", 'String'), // using % to address rows with conflicts as well - ); + $params = [ + 1 => [$isSelected, 'Boolean'], + 3 => ["$cacheKeyString%", 'String'], // using % to address rows with conflicts as well + ]; //check pnid is_array or integer $whereClause = NULL; @@ -1039,7 +1039,7 @@ public static function toggleDedupeSelect() { else { $pnid = CRM_Utils_Type::escape($pnid, 'Integer'); $whereClause = " id = %2"; - $params[2] = array($pnid, 'Integer'); + $params[2] = [$pnid, 'Integer']; } $sql = "UPDATE civicrm_prevnext_cache SET is_selected = %1 WHERE {$whereClause} AND cacheKey LIKE %3"; diff --git a/CRM/Contact/Page/CustomSearch.php b/CRM/Contact/Page/CustomSearch.php index b4ccd6948a81..e1f4749c25a1 100644 --- a/CRM/Contact/Page/CustomSearch.php +++ b/CRM/Contact/Page/CustomSearch.php @@ -60,7 +60,7 @@ public static function &info() { CRM_Core_DAO::$_nullArray ); - $rows = array(); + $rows = []; while ($dao->fetch()) { if (trim($dao->description)) { $rows[$dao->value] = $dao->description; diff --git a/CRM/Contact/Page/Dashlet.php b/CRM/Contact/Page/Dashlet.php index bd4ad153472b..3444e1ae993a 100644 --- a/CRM/Contact/Page/Dashlet.php +++ b/CRM/Contact/Page/Dashlet.php @@ -49,23 +49,23 @@ public function run() { // get dashlets for logged in contact $currentDashlets = CRM_Core_BAO_Dashboard::getContactDashlets(); - $contactDashlets = $availableDashlets = array(); + $contactDashlets = $availableDashlets = []; foreach ($currentDashlets as $item) { $key = "{$item['dashboard_id']}-0"; - $contactDashlets[$item['column_no']][$key] = array( + $contactDashlets[$item['column_no']][$key] = [ 'label' => $item['label'], 'is_reserved' => $allDashlets[$item['dashboard_id']]['is_reserved'], - ); + ]; unset($allDashlets[$item['dashboard_id']]); } foreach ($allDashlets as $dashletID => $values) { $key = "{$dashletID}-0"; - $availableDashlets[$key] = array( + $availableDashlets[$key] = [ 'label' => $values['label'], 'is_reserved' => $values['is_reserved'], - ); + ]; } $this->assign('contactDashlets', $contactDashlets); diff --git a/CRM/Contact/Page/DedupeException.php b/CRM/Contact/Page/DedupeException.php index 8b47b516e450..ea612da89163 100644 --- a/CRM/Contact/Page/DedupeException.php +++ b/CRM/Contact/Page/DedupeException.php @@ -53,26 +53,26 @@ public function run() { * @access protected */ protected function initializePager() { - $params = array(); + $params = []; $contactOneQ = CRM_Utils_Request::retrieve('crmContact1Q', 'String'); if ($contactOneQ) { - $params['contact_id1.display_name'] = array('LIKE' => '%' . $contactOneQ . '%'); - $params['contact_id2.display_name'] = array('LIKE' => '%' . $contactOneQ . '%'); + $params['contact_id1.display_name'] = ['LIKE' => '%' . $contactOneQ . '%']; + $params['contact_id2.display_name'] = ['LIKE' => '%' . $contactOneQ . '%']; $params['options']['or'] = [["contact_id1.display_name", "contact_id2.display_name"]]; } $totalitems = civicrm_api3('Exception', "getcount", $params); - $params = array( + $params = [ 'total' => $totalitems, 'rowCount' => CRM_Utils_Pager::ROWCOUNT, 'status' => ts('Dedupe Exceptions %%StatusMessage%%'), 'buttonBottom' => 'PagerBottomButton', 'buttonTop' => 'PagerTopButton', 'pageID' => $this->get(CRM_Utils_Pager::PAGE_ID), - ); + ]; $this->_pager = new CRM_Utils_Pager($params); $this->assign_by_ref('pager', $this->_pager); } @@ -93,14 +93,14 @@ protected function getExceptions() { $this->assign('searchcontact1', $contactOneQ); - $params = array( - "options" => array('limit' => $limit, 'offset' => $offset), + $params = [ + "options" => ['limit' => $limit, 'offset' => $offset], 'return' => ["contact_id1.display_name", "contact_id2.display_name", "contact_id1", "contact_id2"], - ); + ]; if ($contactOneQ != '') { - $params['contact_id1.display_name'] = array('LIKE' => '%' . $contactOneQ . '%'); - $params['contact_id2.display_name'] = array('LIKE' => '%' . $contactOneQ . '%'); + $params['contact_id1.display_name'] = ['LIKE' => '%' . $contactOneQ . '%']; + $params['contact_id2.display_name'] = ['LIKE' => '%' . $contactOneQ . '%']; $params['options']['or'] = [["contact_id1.display_name", "contact_id2.display_name"]]; } diff --git a/CRM/Contact/Page/DedupeFind.php b/CRM/Contact/Page/DedupeFind.php index a8e70a37dc94..56eba2c9846b 100644 --- a/CRM/Contact/Page/DedupeFind.php +++ b/CRM/Contact/Page/DedupeFind.php @@ -101,13 +101,13 @@ public function run() { } $this->_rgid = $rgid; - $urlQry = array( + $urlQry = [ 'reset' => 1, 'rgid' => $rgid, 'gid' => $gid, 'limit' => $limit, 'criteria' => $criteria, - ); + ]; $this->assign('urlQuery', CRM_Utils_System::makeQueryString($urlQry)); $this->assign('isSelected', $this->isSelected()); $criteria = json_decode($criteria, TRUE); @@ -139,12 +139,12 @@ public function run() { if (empty($result['merged']) && empty($result['skipped'])) { $message = ''; if ($mergedCount >= 1) { - $message = ts("%1 pairs of duplicates were merged", array(1 => $mergedCount)); + $message = ts("%1 pairs of duplicates were merged", [1 => $mergedCount]); } if ($skippedCount >= 1) { $message = $message ? "{$message} and " : ''; $message .= ts("%1 pairs of duplicates were skipped due to conflict", - array(1 => $skippedCount) + [1 => $skippedCount] ); } $message .= ts(" during the batch merge process with safe mode."); @@ -177,7 +177,7 @@ public function run() { if ($stats) { $message = CRM_Dedupe_Merger::getMergeStatsMsg($stats); $status = empty($stats['skipped']) ? 'success' : 'alert'; - CRM_Core_Session::setStatus($message, ts('Batch Complete'), $status, array('expires' => 0)); + CRM_Core_Session::setStatus($message, ts('Batch Complete'), $status, ['expires' => 0]); // reset so we not displaying same message again CRM_Dedupe_Merger::resetMergeStats($cacheKeyString); } @@ -191,8 +191,8 @@ public function run() { unset($urlQry['snippet']); CRM_Utils_System::redirect(CRM_Utils_System::url(CRM_Utils_System::currentPath(), $urlQry)); } - $ruleGroupName = civicrm_api3('RuleGroup', 'getvalue', array('id' => $rgid, 'return' => 'name')); - CRM_Core_Session::singleton()->setStatus(ts('No possible duplicates were found using %1 rule.', array(1 => $ruleGroupName)), ts('None Found'), 'info'); + $ruleGroupName = civicrm_api3('RuleGroup', 'getvalue', ['id' => $rgid, 'return' => 'name']); + CRM_Core_Session::singleton()->setStatus(ts('No possible duplicates were found using %1 rule.', [1 => $ruleGroupName]), ts('None Found'), 'info'); $url = CRM_Utils_System::url('civicrm/contact/deduperules', 'reset=1'); if ($context == 'search') { $url = CRM_Core_Session::singleton()->readUserContext(); diff --git a/CRM/Contact/Page/DedupeMerge.php b/CRM/Contact/Page/DedupeMerge.php index 01b5d3a60e27..45064446bba5 100644 --- a/CRM/Contact/Page/DedupeMerge.php +++ b/CRM/Contact/Page/DedupeMerge.php @@ -60,14 +60,14 @@ public static function getRunner() { $mode = CRM_Utils_Request::retrieveValue('mode', 'String', 'safe'); $criteria = CRM_Utils_Request::retrieve('criteria', 'Json', $null, FALSE, '{}'); - $urlQry = array( + $urlQry = [ 'reset' => 1, 'action' => 'update', 'rgid' => $rgid, 'gid' => $gid, 'limit' => $limit, 'criteria' => $criteria, - ); + ]; $criteria = json_decode($criteria, TRUE); $cacheKeyString = CRM_Dedupe_Merger::getMergeCacheKeyString($rgid, $gid, $criteria); @@ -77,11 +77,11 @@ public static function getRunner() { CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/contact/dedupefind', $urlQry)); } // Setup the Queue - $queue = CRM_Queue_Service::singleton()->create(array( + $queue = CRM_Queue_Service::singleton()->create([ 'name' => $cacheKeyString, 'type' => 'Sql', 'reset' => TRUE, - )); + ]); $where = NULL; $onlyProcessSelected = ($action == CRM_Core_Action::MAP) ? 1 : 0; @@ -97,8 +97,8 @@ public static function getRunner() { for ($i = 1; $i <= ceil($total / self::BATCHLIMIT); $i++) { $task = new CRM_Queue_Task( - array('CRM_Contact_Page_DedupeMerge', 'callBatchMerge'), - array($rgid, $gid, $mode, self::BATCHLIMIT, $onlyProcessSelected, $criteria), + ['CRM_Contact_Page_DedupeMerge', 'callBatchMerge'], + [$rgid, $gid, $mode, self::BATCHLIMIT, $onlyProcessSelected, $criteria], "Processed " . $i * self::BATCHLIMIT . " pair of duplicates out of " . $total ); @@ -111,12 +111,12 @@ public static function getRunner() { if ($onlyProcessSelected) { $urlQry['selected'] = 1; } - $runner = new CRM_Queue_Runner(array( + $runner = new CRM_Queue_Runner([ 'title' => ts('Merging Duplicates..'), 'queue' => $queue, 'errorMode' => CRM_Queue_Runner::ERROR_ABORT, 'onEndUrl' => CRM_Utils_System::url('civicrm/contact/dedupefind', $urlQry, TRUE, NULL, FALSE), - )); + ]); return $runner; } diff --git a/CRM/Contact/Page/DedupeRules.php b/CRM/Contact/Page/DedupeRules.php index 8570988d3444..73573cd38431 100644 --- a/CRM/Contact/Page/DedupeRules.php +++ b/CRM/Contact/Page/DedupeRules.php @@ -60,30 +60,30 @@ public function &links() { $deleteExtra = ts('Are you sure you want to delete this Rule?'); // helper variable for nicer formatting - $links = array(); + $links = []; if (CRM_Core_Permission::check('merge duplicate contacts')) { - $links[CRM_Core_Action::VIEW] = array( + $links[CRM_Core_Action::VIEW] = [ 'name' => ts('Use Rule'), 'url' => 'civicrm/contact/dedupefind', 'qs' => 'reset=1&rgid=%%id%%&action=preview', 'title' => ts('Use DedupeRule'), - ); + ]; } if (CRM_Core_Permission::check('administer dedupe rules')) { - $links[CRM_Core_Action::UPDATE] = array( + $links[CRM_Core_Action::UPDATE] = [ 'name' => ts('Edit Rule'), 'url' => 'civicrm/contact/deduperules', 'qs' => 'action=update&id=%%id%%', 'title' => ts('Edit DedupeRule'), - ); - $links[CRM_Core_Action::DELETE] = array( + ]; + $links[CRM_Core_Action::DELETE] = [ 'name' => ts('Delete'), 'url' => 'civicrm/contact/deduperules', 'qs' => 'action=delete&id=%%id%%', 'extra' => 'onclick = "return confirm(\'' . $deleteExtra . '\');"', 'title' => ts('Delete DedupeRule'), - ); + ]; } self::$_links = $links; @@ -130,14 +130,14 @@ public function run() { */ public function browse() { // get all rule groups - $ruleGroups = array(); + $ruleGroups = []; $dao = new CRM_Dedupe_DAO_RuleGroup(); $dao->orderBy('contact_type ASC, used ASC, title ASC'); $dao->find(); $dedupeRuleTypes = CRM_Core_SelectValues::getDedupeRuleTypes(); while ($dao->fetch()) { - $ruleGroups[$dao->contact_type][$dao->id] = array(); + $ruleGroups[$dao->contact_type][$dao->id] = []; CRM_Core_DAO::storeValues($dao, $ruleGroups[$dao->contact_type][$dao->id]); // form all action links @@ -155,7 +155,7 @@ public function browse() { $ruleGroups[$dao->contact_type][$dao->id]['action'] = CRM_Core_Action::formLink( $links, $action, - array('id' => $dao->id), + ['id' => $dao->id], ts('more'), FALSE, 'dedupeRule.manage.action', @@ -212,7 +212,7 @@ public function delete($id) { $rgDao->id = $id; if ($rgDao->find(TRUE)) { $rgDao->delete(); - CRM_Core_Session::setStatus(ts("The rule '%1' has been deleted.", array(1 => $rgDao->title)), ts('Rule Deleted'), 'success'); + CRM_Core_Session::setStatus(ts("The rule '%1' has been deleted.", [1 => $rgDao->title]), ts('Rule Deleted'), 'success'); CRM_Utils_System::redirect(CRM_Utils_System::url($this->userContext(), 'reset=1')); } } diff --git a/CRM/Contact/Page/ImageFile.php b/CRM/Contact/Page/ImageFile.php index 50e740edf435..9ea30c409b34 100644 --- a/CRM/Contact/Page/ImageFile.php +++ b/CRM/Contact/Page/ImageFile.php @@ -50,9 +50,9 @@ public function run() { // FIXME Optimize performance of image_url query $sql = "SELECT id FROM civicrm_contact WHERE image_url like %1;"; - $params = array( - 1 => array("%" . $_GET['photo'], 'String'), - ); + $params = [ + 1 => ["%" . $_GET['photo'], 'String'], + ]; $dao = CRM_Core_DAO::executeQuery($sql, $params); $cid = NULL; while ($dao->fetch()) { diff --git a/CRM/Contact/Page/Inline/Address.php b/CRM/Contact/Page/Inline/Address.php index 9b650809673e..10257bd46426 100644 --- a/CRM/Contact/Page/Inline/Address.php +++ b/CRM/Contact/Page/Inline/Address.php @@ -47,11 +47,11 @@ public function run() { $locBlockNo = CRM_Utils_Request::retrieve('locno', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST); $addressId = CRM_Utils_Request::retrieve('aid', 'Positive', CRM_Core_DAO::$_nullObject, FALSE, NULL, $_REQUEST); - $address = array(); + $address = []; if ($addressId > 0) { - $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array('labelColumn' => 'display_name')); + $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', ['labelColumn' => 'display_name']); - $entityBlock = array('id' => $addressId); + $entityBlock = ['id' => $addressId]; $address = CRM_Core_BAO_Address::getValues($entityBlock, FALSE, 'id'); if (!empty($address)) { foreach ($address as $key => & $value) { @@ -65,16 +65,16 @@ public function run() { if (!empty($currentAddressBlock['address'][$locBlockNo])) { // get contact name of shared contact names - $sharedAddresses = array(); + $sharedAddresses = []; $shareAddressContactNames = CRM_Contact_BAO_Contact_Utils::getAddressShareContactNames($currentAddressBlock['address']); foreach ($currentAddressBlock['address'] as $key => $addressValue) { if (!empty($addressValue['master_id']) && !$shareAddressContactNames[$addressValue['master_id']]['is_deleted'] ) { - $sharedAddresses[$key]['shared_address_display'] = array( + $sharedAddresses[$key]['shared_address_display'] = [ 'address' => $addressValue['display'], 'name' => $shareAddressContactNames[$addressValue['master_id']]['name'], - ); + ]; } } $idValue = $currentAddressBlock['address'][$locBlockNo]['id']; @@ -95,7 +95,7 @@ public function run() { $contact = new CRM_Contact_BAO_Contact(); $contact->id = $contactId; $contact->find(TRUE); - $privacy = array(); + $privacy = []; foreach (CRM_Contact_BAO_Contact::$_commPrefs as $name) { if (isset($contact->$name)) { $privacy[$name] = $contact->$name; diff --git a/CRM/Contact/Page/Inline/CommunicationPreferences.php b/CRM/Contact/Page/Inline/CommunicationPreferences.php index 3f3757470b34..c6d480a90282 100644 --- a/CRM/Contact/Page/Inline/CommunicationPreferences.php +++ b/CRM/Contact/Page/Inline/CommunicationPreferences.php @@ -45,9 +45,9 @@ public function run() { // get the emails for this contact $contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST); - $params = array('id' => $contactId); + $params = ['id' => $contactId]; - $defaults = array(); + $defaults = []; CRM_Contact_BAO_Contact::getValues($params, $defaults); $defaults['privacy_values'] = CRM_Core_SelectValues::privacy(); diff --git a/CRM/Contact/Page/Inline/ContactInfo.php b/CRM/Contact/Page/Inline/ContactInfo.php index fb8b2969ea78..3435e1935660 100644 --- a/CRM/Contact/Page/Inline/ContactInfo.php +++ b/CRM/Contact/Page/Inline/ContactInfo.php @@ -45,9 +45,9 @@ public function run() { // get the emails for this contact $contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST); - $params = array('id' => $contactId); + $params = ['id' => $contactId]; - $defaults = array(); + $defaults = []; CRM_Contact_BAO_Contact::getValues($params, $defaults); //get the current employer name diff --git a/CRM/Contact/Page/Inline/Demographics.php b/CRM/Contact/Page/Inline/Demographics.php index 7d9afb7a0269..39b4d424f20f 100644 --- a/CRM/Contact/Page/Inline/Demographics.php +++ b/CRM/Contact/Page/Inline/Demographics.php @@ -45,9 +45,9 @@ public function run() { // get the emails for this contact $contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST); - $params = array('id' => $contactId); + $params = ['id' => $contactId]; - $defaults = array(); + $defaults = []; CRM_Contact_BAO_Contact::getValues($params, $defaults); if (!empty($defaults['gender_id'])) { diff --git a/CRM/Contact/Page/Inline/Email.php b/CRM/Contact/Page/Inline/Email.php index f70792e34ee3..9a257e1a3bd1 100644 --- a/CRM/Contact/Page/Inline/Email.php +++ b/CRM/Contact/Page/Inline/Email.php @@ -45,9 +45,9 @@ public function run() { // get the emails for this contact $contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST); - $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array('labelColumn' => 'display_name')); + $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', ['labelColumn' => 'display_name']); - $entityBlock = array('contact_id' => $contactId); + $entityBlock = ['contact_id' => $contactId]; $emails = CRM_Core_BAO_Email::getValues($entityBlock); if (!empty($emails)) { foreach ($emails as &$value) { @@ -58,7 +58,7 @@ public function run() { $contact = new CRM_Contact_BAO_Contact(); $contact->id = $contactId; $contact->find(TRUE); - $privacy = array(); + $privacy = []; foreach (CRM_Contact_BAO_Contact::$_commPrefs as $name) { if (isset($contact->$name)) { $privacy[$name] = $contact->$name; diff --git a/CRM/Contact/Page/Inline/IM.php b/CRM/Contact/Page/Inline/IM.php index 045922fe6dfa..8b0fd8d52ce7 100644 --- a/CRM/Contact/Page/Inline/IM.php +++ b/CRM/Contact/Page/Inline/IM.php @@ -45,10 +45,10 @@ public function run() { // get the emails for this contact $contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST); - $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array('labelColumn' => 'display_name')); + $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', ['labelColumn' => 'display_name']); $IMProviders = CRM_Core_PseudoConstant::get('CRM_Core_DAO_IM', 'provider_id'); - $entityBlock = array('contact_id' => $contactId); + $entityBlock = ['contact_id' => $contactId]; $ims = CRM_Core_BAO_IM::getValues($entityBlock); if (!empty($ims)) { foreach ($ims as $key => & $value) { diff --git a/CRM/Contact/Page/Inline/OpenID.php b/CRM/Contact/Page/Inline/OpenID.php index 22dbec1a4213..b20baf6e5db9 100644 --- a/CRM/Contact/Page/Inline/OpenID.php +++ b/CRM/Contact/Page/Inline/OpenID.php @@ -45,9 +45,9 @@ public function run() { // get the emails for this contact $contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST); - $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array('labelColumn' => 'display_name')); + $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', ['labelColumn' => 'display_name']); - $entityBlock = array('contact_id' => $contactId); + $entityBlock = ['contact_id' => $contactId]; $openids = CRM_Core_BAO_OpenID::getValues($entityBlock); if (!empty($openids)) { foreach ($openids as $key => & $value) { diff --git a/CRM/Contact/Page/Inline/Phone.php b/CRM/Contact/Page/Inline/Phone.php index dc22002ccf46..4e78071fe3b7 100644 --- a/CRM/Contact/Page/Inline/Phone.php +++ b/CRM/Contact/Page/Inline/Phone.php @@ -45,10 +45,10 @@ public function run() { // get the emails for this contact $contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, TRUE, NULL, $_REQUEST); - $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array('labelColumn' => 'display_name')); + $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', ['labelColumn' => 'display_name']); $phoneTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Phone', 'phone_type_id'); - $entityBlock = array('contact_id' => $contactId); + $entityBlock = ['contact_id' => $contactId]; $phones = CRM_Core_BAO_Phone::getValues($entityBlock); if (!empty($phones)) { foreach ($phones as $key => & $value) { @@ -60,7 +60,7 @@ public function run() { $contact = new CRM_Contact_BAO_Contact(); $contact->id = $contactId; $contact->find(TRUE); - $privacy = array(); + $privacy = []; foreach (CRM_Contact_BAO_Contact::$_commPrefs as $name) { if (isset($contact->$name)) { $privacy[$name] = $contact->$name; diff --git a/CRM/Contact/Page/Inline/Website.php b/CRM/Contact/Page/Inline/Website.php index 5cf4a59c747a..929ec1e5091c 100644 --- a/CRM/Contact/Page/Inline/Website.php +++ b/CRM/Contact/Page/Inline/Website.php @@ -47,7 +47,7 @@ public function run() { $websiteTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Website', 'website_type_id'); - $params = array('contact_id' => $contactId); + $params = ['contact_id' => $contactId]; $websites = CRM_Core_BAO_Website::getValues($params, CRM_Core_DAO::$_nullArray); if (!empty($websites)) { foreach ($websites as $key => & $value) { diff --git a/CRM/Contact/Page/SavedSearch.php b/CRM/Contact/Page/SavedSearch.php index 72d890c746de..128b22239ef8 100644 --- a/CRM/Contact/Page/SavedSearch.php +++ b/CRM/Contact/Page/SavedSearch.php @@ -70,14 +70,14 @@ public function delete($id) { * content of the parents run method */ public function browse() { - $rows = array(); + $rows = []; $savedSearch = new CRM_Contact_DAO_SavedSearch(); $savedSearch->is_active = 1; $savedSearch->selectAdd(); $savedSearch->selectAdd('id, form_values'); $savedSearch->find(); - $properties = array('id', 'name', 'description'); + $properties = ['id', 'name', 'description']; while ($savedSearch->fetch()) { // get name and description from group object $group = new CRM_Contact_DAO_Group(); @@ -85,7 +85,7 @@ public function browse() { if ($group->find(TRUE)) { $permissions = CRM_Contact_BAO_Group::checkPermission($group->id, TRUE); if (!CRM_Utils_System::isNull($permissions)) { - $row = array(); + $row = []; $row['name'] = $group->title; $row['description'] = $group->description; @@ -100,7 +100,7 @@ public function browse() { $row['action'] = CRM_Core_Action::formLink( self::links(), $action, - array('id' => $row['id']), + ['id' => $row['id']], ts('more'), FALSE, 'savedSearch.manage.action', @@ -148,20 +148,20 @@ public static function &links() { $deleteExtra = ts('Do you really want to remove this Smart Group?'); - self::$_links = array( - CRM_Core_Action::VIEW => array( + self::$_links = [ + CRM_Core_Action::VIEW => [ 'name' => ts('Search'), 'url' => 'civicrm/contact/search/advanced', 'qs' => 'reset=1&force=1&ssID=%%id%%', 'title' => ts('Search'), - ), - CRM_Core_Action::DELETE => array( + ], + CRM_Core_Action::DELETE => [ 'name' => ts('Delete'), 'url' => 'civicrm/contact/search/saved', 'qs' => 'action=delete&id=%%id%%', 'extra' => 'onclick="return confirm(\'' . $deleteExtra . '\');"', - ), - ); + ], + ]; } return self::$_links; } diff --git a/CRM/Contact/Page/View.php b/CRM/Contact/Page/View.php index b51c292b2c61..ca01608a908c 100644 --- a/CRM/Contact/Page/View.php +++ b/CRM/Contact/Page/View.php @@ -101,7 +101,7 @@ public function preProcess() { // ensure that the id does exist if (CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_contactId, 'id') != $this->_contactId) { CRM_Core_Error::statusBounce( - ts('A Contact with that ID does not exist: %1', array(1 => $this->_contactId)), + ts('A Contact with that ID does not exist: %1', [1 => $this->_contactId]), CRM_Utils_System::url('civicrm/dashboard', 'reset=1') ); } @@ -109,13 +109,13 @@ public function preProcess() { $this->assign('contactId', $this->_contactId); // see if we can get prev/next positions from qfKey - $navContacts = array( + $navContacts = [ 'prevContactID' => NULL, 'prevContactName' => NULL, 'nextContactID' => NULL, 'nextContactName' => NULL, 'nextPrevError' => 0, - ); + ]; if ($qfKey) { $pos = Civi::service('prevnext')->getPositions("civicrm search $qfKey", $this->_contactId, @@ -146,18 +146,18 @@ public function preProcess() { } elseif ($context) { $this->assign('context', $context); - CRM_Utils_System::appendBreadCrumb(array( - array( + CRM_Utils_System::appendBreadCrumb([ + [ 'title' => ts('Search Results'), - 'url' => CRM_Utils_System::url("civicrm/contact/search/$context", array('qfKey' => $qfKey)), - ), - )); + 'url' => CRM_Utils_System::url("civicrm/contact/search/$context", ['qfKey' => $qfKey]), + ], + ]); } } $this->assign($navContacts); $path = CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $this->_contactId); - CRM_Utils_System::appendBreadCrumb(array(array('title' => ts('View Contact'), 'url' => $path))); + CRM_Utils_System::appendBreadCrumb([['title' => ts('View Contact'), 'url' => $path]]); if ($image_URL = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_contactId, 'image_URL')) { $this->assign("imageURL", CRM_Utils_File::getImageURL($image_URL)); @@ -184,11 +184,11 @@ public function preProcess() { // add to recently viewed block $isDeleted = (bool) CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_contactId, 'is_deleted'); - $recentOther = array( + $recentOther = [ 'imageUrl' => $contactImageUrl, 'subtype' => $contactSubtype, 'isDeleted' => $isDeleted, - ); + ]; if (CRM_Contact_BAO_Contact_Permission::allow($this->_contactId, CRM_Core_Permission::EDIT)) { $recentOther['editUrl'] = CRM_Utils_System::url('civicrm/contact/add', "reset=1&action=update&cid={$this->_contactId}"); @@ -309,11 +309,11 @@ public static function setTitle($contactId, $isDeleted = FALSE) { $contactImage = NULL; if (!isset($contactDetails[$contactId])) { list($displayName, $contactImage) = self::getContactDetails($contactId); - $contactDetails[$contactId] = array( + $contactDetails[$contactId] = [ 'displayName' => $displayName, 'contactImage' => $contactImage, 'isDeceased' => (bool) CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $contactId, 'is_deceased'), - ); + ]; } else { $displayName = $contactDetails[$contactId]['displayName']; @@ -370,7 +370,7 @@ public static function addUrls(&$obj, $cid) { } // See if other modules want to add links to the activtity bar - $hookLinks = array(); + $hookLinks = []; CRM_Utils_Hook::links('view.contact.activity', 'Contact', $cid, diff --git a/CRM/Contact/Page/View/ContactSmartGroup.php b/CRM/Contact/Page/View/ContactSmartGroup.php index 3ccfcbe6c1f9..d018f62402dd 100644 --- a/CRM/Contact/Page/View/ContactSmartGroup.php +++ b/CRM/Contact/Page/View/ContactSmartGroup.php @@ -46,7 +46,7 @@ public function browse() { // keep track of all 'added' contact groups so we can remove them from the smart group // section - $staticGroups = array(); + $staticGroups = []; if (!empty($in)) { foreach ($in as $group) { $staticGroups[$group['group_id']] = 1; @@ -58,7 +58,7 @@ public function browse() { $this->assign('groupParent', NULL); if (!empty($allGroup)) { - $smart = $parent = array(); + $smart = $parent = []; foreach ($allGroup['group'] as $group) { // delete all smart groups which are also in static groups if (isset($staticGroups[$group['id']])) { diff --git a/CRM/Contact/Page/View/CustomData.php b/CRM/Contact/Page/View/CustomData.php index 6cd9220f8c48..37983dab9619 100644 --- a/CRM/Contact/Page/View/CustomData.php +++ b/CRM/Contact/Page/View/CustomData.php @@ -139,7 +139,7 @@ public function run() { $recId = NULL; if ($this->_multiRecordDisplay == 'single') { $groupTitle = CRM_Core_BAO_CustomGroup::getTitle($this->_groupId); - CRM_Utils_System::setTitle(ts('View %1 Record', array(1 => $groupTitle))); + CRM_Utils_System::setTitle(ts('View %1 Record', [1 => $groupTitle])); $groupTree = CRM_Core_BAO_CustomGroup::getTree($entityType, NULL, $this->_contactId, $this->_groupId, $entitySubType, NULL, TRUE, NULL, FALSE, TRUE, $this->_cgcount ); diff --git a/CRM/Contact/Page/View/GroupContact.php b/CRM/Contact/Page/View/GroupContact.php index 78ee608f6cf2..88178d4b4764 100644 --- a/CRM/Contact/Page/View/GroupContact.php +++ b/CRM/Contact/Page/View/GroupContact.php @@ -45,7 +45,7 @@ public function browse() { // keep track of all 'added' contact groups so we can remove them from the smart group // section - $staticGroups = array(); + $staticGroups = []; if (!empty($in)) { foreach ($in as $group) { $staticGroups[$group['group_id']] = 1; @@ -176,7 +176,7 @@ public static function del($groupContactId, $status, $contactID) { return FALSE; } - $ids = array($contactID); + $ids = [$contactID]; $method = 'Admin'; $session = CRM_Core_Session::singleton(); diff --git a/CRM/Contact/Page/View/Log.php b/CRM/Contact/Page/View/Log.php index d59f20acaeaf..493148f4db6d 100644 --- a/CRM/Contact/Page/View/Log.php +++ b/CRM/Contact/Page/View/Log.php @@ -55,15 +55,15 @@ public function browse() { $log->orderBy('modified_date desc'); $log->find(); - $logEntries = array(); + $logEntries = []; while ($log->fetch()) { list($displayName, $contactImage) = CRM_Contact_BAO_Contact::getDisplayAndImage($log->modified_id); - $logEntries[] = array( + $logEntries[] = [ 'id' => $log->modified_id, 'name' => $displayName, 'image' => $contactImage, 'date' => $log->modified_date, - ); + ]; } $this->assign('logCount', count($logEntries)); diff --git a/CRM/Contact/Page/View/Note.php b/CRM/Contact/Page/View/Note.php index 39fe00be8cd1..e118762fd8ab 100644 --- a/CRM/Contact/Page/View/Note.php +++ b/CRM/Contact/Page/View/Note.php @@ -57,7 +57,7 @@ public function view() { $note = new CRM_Core_DAO_Note(); $note->id = $this->_id; if ($note->find(TRUE)) { - $values = array(); + $values = []; CRM_Core_DAO::storeValues($note, $values); $values['privacy'] = CRM_Core_PseudoConstant::getLabel('CRM_Core_BAO_Note', 'privacy', $values['privacy']); @@ -86,7 +86,7 @@ public function browse() { $note->orderBy('modified_date desc'); //CRM-4418, handling edit and delete separately. - $permissions = array($this->_permission); + $permissions = [$this->_permission]; if ($this->_permission == CRM_Core_Permission::EDIT) { //previously delete was subset of edit //so for consistency lets grant delete also. @@ -96,7 +96,7 @@ public function browse() { $this->assign('canAddNotes', CRM_Core_Permission::check('add contact notes')); - $values = array(); + $values = []; $links = self::links(); $action = array_sum(array_keys($links)) & $mask; @@ -107,10 +107,10 @@ public function browse() { $values[$note->id]['action'] = CRM_Core_Action::formLink($links, $action, - array( + [ 'id' => $note->id, 'cid' => $this->_contactId, - ), + ], ts('more'), FALSE, 'note.selector.row', @@ -140,11 +140,11 @@ public function browse() { $commentAction = CRM_Core_Action::formLink($commentLinks, $action, - array( + [ 'id' => $note->id, 'pid' => $note->entity_id, 'cid' => $note->entity_id, - ), + ], ts('more'), FALSE, 'note.comment.action', @@ -262,32 +262,32 @@ public static function &links() { if (!(self::$_links)) { $deleteExtra = ts('Are you sure you want to delete this note?'); - self::$_links = array( - CRM_Core_Action::VIEW => array( + self::$_links = [ + CRM_Core_Action::VIEW => [ 'name' => ts('View'), 'url' => 'civicrm/contact/view/note', 'qs' => 'action=view&reset=1&cid=%%cid%%&id=%%id%%&selectedChild=note', 'title' => ts('View Note'), - ), - CRM_Core_Action::UPDATE => array( + ], + CRM_Core_Action::UPDATE => [ 'name' => ts('Edit'), 'url' => 'civicrm/contact/view/note', 'qs' => 'action=update&reset=1&cid=%%cid%%&id=%%id%%&selectedChild=note', 'title' => ts('Edit Note'), - ), - CRM_Core_Action::ADD => array( + ], + CRM_Core_Action::ADD => [ 'name' => ts('Comment'), 'url' => 'civicrm/contact/view/note', 'qs' => 'action=add&reset=1&cid=%%cid%%&parentId=%%id%%&selectedChild=note', 'title' => ts('Add Comment'), - ), - CRM_Core_Action::DELETE => array( + ], + CRM_Core_Action::DELETE => [ 'name' => ts('Delete'), 'url' => 'civicrm/contact/view/note', 'qs' => 'action=delete&reset=1&cid=%%cid%%&id=%%id%%&selectedChild=note', 'title' => ts('Delete Note'), - ), - ); + ], + ]; } return self::$_links; } @@ -300,26 +300,26 @@ public static function &links() { */ public static function &commentLinks() { if (!(self::$_commentLinks)) { - self::$_commentLinks = array( - CRM_Core_Action::VIEW => array( + self::$_commentLinks = [ + CRM_Core_Action::VIEW => [ 'name' => ts('View'), 'url' => 'civicrm/contact/view/note', 'qs' => 'action=view&reset=1&cid=%%cid%%&id={id}&selectedChild=note', 'title' => ts('View Comment'), - ), - CRM_Core_Action::UPDATE => array( + ], + CRM_Core_Action::UPDATE => [ 'name' => ts('Edit'), 'url' => 'civicrm/contact/view/note', 'qs' => 'action=update&reset=1&cid=%%cid%%&id={id}&parentId=%%pid%%&selectedChild=note', 'title' => ts('Edit Comment'), - ), - CRM_Core_Action::DELETE => array( + ], + CRM_Core_Action::DELETE => [ 'name' => ts('Delete'), 'url' => 'civicrm/contact/view/note', 'qs' => 'action=delete&reset=1&cid=%%cid%%&id={id}&selectedChild=note', 'title' => ts('Delete Comment'), - ), - ); + ], + ]; } return self::$_commentLinks; } diff --git a/CRM/Contact/Page/View/Print.php b/CRM/Contact/Page/View/Print.php index d6fd3193d0f5..7ebbd4042704 100644 --- a/CRM/Contact/Page/View/Print.php +++ b/CRM/Contact/Page/View/Print.php @@ -55,9 +55,9 @@ public function run() { * View summary details of a contact. */ public function view() { - $params = array(); - $defaults = array(); - $ids = array(); + $params = []; + $defaults = []; + $ids = []; $params['id'] = $params['contact_id'] = $this->_contactId; $contact = CRM_Contact_BAO_Contact::retrieve($params, $defaults, $ids); diff --git a/CRM/Contact/Page/View/UserDashBoard.php b/CRM/Contact/Page/View/UserDashBoard.php index b9863de19861..af3e6e0d6bd5 100644 --- a/CRM/Contact/Page/View/UserDashBoard.php +++ b/CRM/Contact/Page/View/UserDashBoard.php @@ -101,7 +101,7 @@ public function preProcess() { $this->set('displayName', $displayName); $this->set('contactImage', $contactImage); - CRM_Utils_System::setTitle(ts('Dashboard - %1', array(1 => $displayName))); + CRM_Utils_System::setTitle(ts('Dashboard - %1', [1 => $displayName])); $this->assign('recentlyViewed', FALSE); } @@ -132,34 +132,34 @@ public function buildUserDashBoard() { ) { $userDashboard = $component->getUserDashboardObject(); - $dashboardElements[] = array( + $dashboardElements[] = [ 'class' => 'crm-dashboard-' . strtolower($component->name), 'sectionTitle' => $elem['title'], 'templatePath' => $userDashboard->getTemplateFileName(), 'weight' => $elem['weight'], - ); + ]; $userDashboard->run(); } } // CRM-16512 - Hide related contact table if user lacks permission to view self if (!empty($dashboardOptions['Permissioned Orgs']) && CRM_Core_Permission::check('view my contact')) { - $dashboardElements[] = array( + $dashboardElements[] = [ 'class' => 'crm-dashboard-permissionedOrgs', 'templatePath' => 'CRM/Contact/Page/View/RelationshipSelector.tpl', 'sectionTitle' => ts('Your Contacts / Organizations'), 'weight' => 40, - ); + ]; } if (!empty($dashboardOptions['PCP'])) { - $dashboardElements[] = array( + $dashboardElements[] = [ 'class' => 'crm-dashboard-pcp', 'templatePath' => 'CRM/Contribute/Page/PcpUserDashboard.tpl', 'sectionTitle' => ts('Personal Campaign Pages'), 'weight' => 40, - ); + ]; list($pcpBlock, $pcpInfo) = CRM_PCP_BAO_PCP::getPcpDashboardInfo($this->_contactId); $this->assign('pcpBlock', $pcpBlock); $this->assign('pcpInfo', $pcpInfo); @@ -167,17 +167,17 @@ public function buildUserDashBoard() { if (!empty($dashboardOptions['Assigned Activities']) && empty($this->_isChecksumUser)) { // Assigned Activities section - $dashboardElements[] = array( + $dashboardElements[] = [ 'class' => 'crm-dashboard-assignedActivities', 'templatePath' => 'CRM/Activity/Page/UserDashboard.tpl', 'sectionTitle' => ts('Your Assigned Activities'), 'weight' => 5, - ); + ]; $userDashboard = new CRM_Activity_Page_UserDashboard(); $userDashboard->run(); } - usort($dashboardElements, array('CRM_Utils_Sort', 'cmpFunc')); + usort($dashboardElements, ['CRM_Utils_Sort', 'cmpFunc']); $this->assign('dashboardElements', $dashboardElements); // return true when 'Invoices / Credit Notes' checkbox is checked @@ -213,32 +213,32 @@ public static function &links() { if (!(self::$_links)) { $disableExtra = ts('Are you sure you want to disable this relationship?'); - self::$_links = array( - CRM_Core_Action::UPDATE => array( + self::$_links = [ + CRM_Core_Action::UPDATE => [ 'name' => ts('Edit Contact Information'), 'url' => 'civicrm/contact/relatedcontact', 'qs' => 'action=update&reset=1&cid=%%cbid%%&rcid=%%cid%%', 'title' => ts('Edit Contact Information'), - ), - CRM_Core_Action::VIEW => array( + ], + CRM_Core_Action::VIEW => [ 'name' => ts('Dashboard'), 'url' => 'civicrm/user', 'class' => 'no-popup', 'qs' => 'reset=1&id=%%cbid%%', 'title' => ts('View Contact Dashboard'), - ), - ); + ], + ]; if (CRM_Core_Permission::check('access CiviCRM')) { - self::$_links += array( - CRM_Core_Action::DISABLE => array( + self::$_links += [ + CRM_Core_Action::DISABLE => [ 'name' => ts('Disable'), 'url' => 'civicrm/contact/view/rel', 'qs' => 'action=disable&reset=1&cid=%%cid%%&id=%%id%%&rtype=%%rtype%%&selectedChild=rel&context=dashboard', 'extra' => 'onclick = "return confirm(\'' . $disableExtra . '\');"', 'title' => ts('Disable Relationship'), - ), - ); + ], + ]; } } diff --git a/CRM/Contact/Page/View/Vcard.php b/CRM/Contact/Page/View/Vcard.php index 9e288fdec443..bbf06ec5ccca 100644 --- a/CRM/Contact/Page/View/Vcard.php +++ b/CRM/Contact/Page/View/Vcard.php @@ -47,16 +47,16 @@ class CRM_Contact_Page_View_Vcard extends CRM_Contact_Page_View { public function run() { $this->preProcess(); - $params = array(); - $defaults = array(); - $ids = array(); + $params = []; + $defaults = []; + $ids = []; $params['id'] = $params['contact_id'] = $this->_contactId; $contact = CRM_Contact_BAO_Contact::retrieve($params, $defaults, $ids); // now that we have the contact's data - let's build the vCard // TODO: non-US-ASCII support (requires changes to the Contact_Vcard_Build class) - $vcardNames = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array('labelColumn' => 'vcard_name')); + $vcardNames = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', ['labelColumn' => 'vcard_name']); $vcard = new Contact_Vcard_Build('2.1'); if ($defaults['contact_type'] == 'Individual') { diff --git a/CRM/Contact/Selector.php b/CRM/Contact/Selector.php index 1736f0b20b8c..385958764e9e 100644 --- a/CRM/Contact/Selector.php +++ b/CRM/Contact/Selector.php @@ -58,7 +58,7 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se * Properties of contact we're interested in displaying * @var array */ - static $_properties = array( + static $_properties = [ 'contact_id', 'contact_type', 'contact_sub_type', @@ -78,7 +78,7 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se 'do_not_email', 'do_not_phone', 'do_not_mail', - ); + ]; /** * FormValues is the array returned by exportValues called on @@ -263,34 +263,34 @@ public static function &links() { $searchContext = ($context) ? "&context=$context" : NULL; if (!(self::$_links)) { - self::$_links = array( - CRM_Core_Action::VIEW => array( + self::$_links = [ + CRM_Core_Action::VIEW => [ 'name' => ts('View'), 'url' => 'civicrm/contact/view', 'class' => 'no-popup', 'qs' => "reset=1&cid=%%id%%{$searchContext}{$extraParams}", 'title' => ts('View Contact Details'), 'ref' => 'view-contact', - ), - CRM_Core_Action::UPDATE => array( + ], + CRM_Core_Action::UPDATE => [ 'name' => ts('Edit'), 'url' => 'civicrm/contact/add', 'class' => 'no-popup', 'qs' => "reset=1&action=update&cid=%%id%%{$searchContext}{$extraParams}", 'title' => ts('Edit Contact Details'), 'ref' => 'edit-contact', - ), - ); + ], + ]; $config = CRM_Core_Config::singleton(); //CRM-16552: mapAPIKey is not mandatory as google no longer requires an API Key if ($config->mapProvider && ($config->mapAPIKey || $config->mapProvider == 'Google')) { - self::$_links[CRM_Core_Action::MAP] = array( + self::$_links[CRM_Core_Action::MAP] = [ 'name' => ts('Map'), 'url' => 'civicrm/contact/map', 'qs' => "reset=1&cid=%%id%%{$searchContext}{$extraParams}", 'title' => ts('Map Contact'), - ); + ]; } // Adding Context Menu Links in more action @@ -311,14 +311,14 @@ public static function &links() { $qs = "atype=3&action=add&reset=1&cid=%%id%%{$extraParams}"; } - self::$_links[$counter++] = array( + self::$_links[$counter++] = [ 'name' => $value['title'], 'url' => $url, 'qs' => $qs, 'title' => $value['title'], 'ref' => $value['ref'], 'class' => CRM_Utils_Array::value('class', $value), - ); + ]; } } } @@ -348,7 +348,7 @@ public function getPagerParams($action, &$params) { */ public function &getColHeads($action = NULL, $output = NULL) { $colHeads = self::_getColumnHeaders(); - $colHeads[] = array('desc' => ts('Actions'), 'name' => ts('Action')); + $colHeads[] = ['desc' => ts('Actions'), 'name' => ts('Action')]; return $colHeads; } @@ -369,18 +369,18 @@ public function &getColumnHeaders($action = NULL, $output = NULL) { // unset return property elements that we don't care if (!empty($this->_returnProperties)) { - $doNotCareElements = array( + $doNotCareElements = [ 'contact_type', 'contact_sub_type', 'sort_name', - ); + ]; foreach ($doNotCareElements as $value) { unset($this->_returnProperties[$value]); } } if ($output == CRM_Core_Selector_Controller::EXPORT) { - $csvHeaders = array(ts('Contact ID'), ts('Contact Type')); + $csvHeaders = [ts('Contact ID'), ts('Contact Type')]; foreach ($this->getColHeads($action, $output) as $column) { if (array_key_exists('name', $column)) { $csvHeaders[] = $column['name']; @@ -389,7 +389,7 @@ public function &getColumnHeaders($action = NULL, $output = NULL) { $headers = $csvHeaders; } elseif ($output == CRM_Core_Selector_Controller::SCREEN) { - $csvHeaders = array(ts('Name')); + $csvHeaders = [ts('Name')]; foreach ($this->getColHeads($action, $output) as $key => $column) { if (array_key_exists('name', $column) && $column['name'] && @@ -403,18 +403,18 @@ public function &getColumnHeaders($action = NULL, $output = NULL) { elseif ($this->_ufGroupID) { // we dont use the cached value of column headers // since it potentially changed because of the profile selected - static $skipFields = array('group', 'tag'); + static $skipFields = ['group', 'tag']; $direction = CRM_Utils_Sort::ASCENDING; $empty = TRUE; if (!self::$_columnHeaders) { - self::$_columnHeaders = array( - array('name' => ''), - array( + self::$_columnHeaders = [ + ['name' => ''], + [ 'name' => ts('Name'), 'sort' => 'sort_name', 'direction' => CRM_Utils_Sort::ASCENDING, - ), - ); + ], + ]; $locationTypes = CRM_Core_DAO_Address::buildOptions('location_type_id', 'validate'); @@ -432,11 +432,11 @@ public function &getColumnHeaders($action = NULL, $output = NULL) { $locationTypeName = $locationTypes[$lType]; } - if (in_array($fieldName, array( + if (in_array($fieldName, [ 'phone', 'im', 'email', - ))) { + ])) { if ($type) { $name = "`$locationTypeName-$fieldName-$type`"; } @@ -453,11 +453,11 @@ public function &getColumnHeaders($action = NULL, $output = NULL) { $name = 'contact_id'; } - self::$_columnHeaders[] = array( + self::$_columnHeaders[] = [ 'name' => $field['title'], 'sort' => $name, 'direction' => $direction, - ); + ]; $direction = CRM_Utils_Sort::DONTCARE; $empty = FALSE; } @@ -466,23 +466,23 @@ public function &getColumnHeaders($action = NULL, $output = NULL) { // if we dont have any valid columns, dont add the implicit ones // this allows the template to check on emptiness of column headers if ($empty) { - self::$_columnHeaders = array(); + self::$_columnHeaders = []; } else { - self::$_columnHeaders[] = array('desc' => ts('Actions'), 'name' => ts('Action')); + self::$_columnHeaders[] = ['desc' => ts('Actions'), 'name' => ts('Action')]; } } $headers = self::$_columnHeaders; } elseif (!empty($this->_returnProperties)) { - self::$_columnHeaders = array( - array('name' => ''), - array( + self::$_columnHeaders = [ + ['name' => ''], + [ 'name' => ts('Name'), 'sort' => 'sort_name', 'direction' => CRM_Utils_Sort::ASCENDING, - ), - ); + ], + ]; $properties = self::makeProperties($this->_returnProperties); foreach ($properties as $prop) { @@ -512,9 +512,9 @@ public function &getColumnHeaders($action = NULL, $output = NULL) { $title = ''; } - self::$_columnHeaders[] = array('name' => $title, 'sort' => $prop); + self::$_columnHeaders[] = ['name' => $title, 'sort' => $prop]; } - self::$_columnHeaders[] = array('name' => ts('Actions')); + self::$_columnHeaders[] = ['name' => ts('Actions')]; $headers = self::$_columnHeaders; } else { @@ -588,8 +588,8 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { } // process the result of the query - $rows = array(); - $permissions = array(CRM_Core_Permission::getPermission()); + $rows = []; + $permissions = [CRM_Core_Permission::getPermission()]; if (CRM_Core_Permission::check('delete contacts')) { $permissions[] = CRM_Core_Permission::DELETE; } @@ -605,8 +605,8 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { if ($this->_ufGroupID) { $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'); - $names = array(); - static $skipFields = array('group', 'tag'); + $names = []; + static $skipFields = ['group', 'tag']; foreach ($this->_fields as $key => $field) { if (!empty($field['in_selector']) && !in_array($key, $skipFields) @@ -628,11 +628,11 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { } $locationTypeName = str_replace(' ', '_', $locationTypeName); - if (in_array($fieldName, array( + if (in_array($fieldName, [ 'phone', 'im', 'email', - ))) { + ])) { if ($type) { $names[] = "{$locationTypeName}-{$fieldName}-{$type}"; } @@ -664,17 +664,17 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { //check explicitly added contact to a Smart Group. $groupID = CRM_Utils_Array::value('group', $this->_formValues); - $pseudoconstants = array(); + $pseudoconstants = []; // for CRM-3157 purposes if (in_array('world_region', $names)) { - $pseudoconstants['world_region'] = array( + $pseudoconstants['world_region'] = [ 'dbName' => 'worldregion_id', 'values' => CRM_Core_PseudoConstant::worldRegion(), - ); + ]; } foreach ($resultSet as $result) { - $row = array(); + $row = []; $this->_query->convertToPseudoNames($result); // the columns we are interested in foreach ($names as $property) { @@ -697,11 +697,11 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { $row[$property] = $result->$property . " ({$providerName})"; } } - elseif (in_array($property, array( + elseif (in_array($property, [ 'addressee', 'email_greeting', 'postal_greeting', - ))) { + ])) { $greeting = $property . '_display'; $row[$property] = $result->$greeting; } @@ -741,12 +741,12 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { ) { $contactID = $result->contact_id; if ($contactID) { - $gcParams = array( + $gcParams = [ 'contact_id' => $contactID, 'group_id' => $groupID, - ); + ]; - $gcDefaults = array(); + $gcDefaults = []; CRM_Core_DAO::commonRetrieve('CRM_Contact_DAO_GroupContact', $gcParams, $gcDefaults); if (empty($gcDefaults)) { @@ -770,33 +770,33 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { if (!empty($this->_formValues['deleted_contacts']) && CRM_Core_Permission::check('access deleted contacts') ) { - $links = array( - array( + $links = [ + [ 'name' => ts('View'), 'url' => 'civicrm/contact/view', 'qs' => 'reset=1&cid=%%id%%', 'class' => 'no-popup', 'title' => ts('View Contact Details'), - ), - array( + ], + [ 'name' => ts('Restore'), 'url' => 'civicrm/contact/view/delete', 'qs' => 'reset=1&cid=%%id%%&restore=1', 'title' => ts('Restore Contact'), - ), - ); + ], + ]; if (CRM_Core_Permission::check('delete contacts')) { - $links[] = array( + $links[] = [ 'name' => ts('Delete Permanently'), 'url' => 'civicrm/contact/view/delete', 'qs' => 'reset=1&cid=%%id%%&skip_undelete=1', 'title' => ts('Permanently Delete Contact'), - ); + ]; } $row['action'] = CRM_Core_Action::formLink( $links, NULL, - array('id' => $result->contact_id), + ['id' => $result->contact_id], ts('more'), FALSE, 'contact.selector.row', @@ -812,7 +812,7 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { $row['action'] = CRM_Core_Action::formLink( $links, $mask, - array('id' => $result->contact_id), + ['id' => $result->contact_id], ts('more'), FALSE, 'contact.selector.row', @@ -824,7 +824,7 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { $row['action'] = CRM_Core_Action::formLink( $links, $mapMask, - array('id' => $result->contact_id), + ['id' => $result->contact_id], ts('more'), FALSE, 'contact.selector.row', @@ -918,7 +918,7 @@ public function buildPrevNextCache($sort) { */ public function addActions(&$rows) { - $basicPermissions = CRM_Core_Permission::check('delete contacts') ? array(CRM_Core_Permission::DELETE) : array(); + $basicPermissions = CRM_Core_Permission::check('delete contacts') ? [CRM_Core_Permission::DELETE] : []; // get permissions on an individual level (CRM-12645) // @todo look at storing this to the session as this is called twice during search results render. @@ -929,10 +929,10 @@ public function addActions(&$rows) { foreach ($rows as $id => & $row) { $links = $links_template; if (in_array($id, $can_edit_list)) { - $mask = CRM_Core_Action::mask(array_merge(array(CRM_Core_Permission::EDIT), $basicPermissions)); + $mask = CRM_Core_Action::mask(array_merge([CRM_Core_Permission::EDIT], $basicPermissions)); } else { - $mask = CRM_Core_Action::mask(array_merge(array(CRM_Core_Permission::VIEW), $basicPermissions)); + $mask = CRM_Core_Action::mask(array_merge([CRM_Core_Permission::VIEW], $basicPermissions)); } if ((!is_numeric(CRM_Utils_Array::value('geo_code_1', $row))) && @@ -945,33 +945,33 @@ public function addActions(&$rows) { if (!empty($this->_formValues['deleted_contacts']) && CRM_Core_Permission::check('access deleted contacts') ) { - $links = array( - array( + $links = [ + [ 'name' => ts('View'), 'url' => 'civicrm/contact/view', 'qs' => 'reset=1&cid=%%id%%', 'class' => 'no-popup', 'title' => ts('View Contact Details'), - ), - array( + ], + [ 'name' => ts('Restore'), 'url' => 'civicrm/contact/view/delete', 'qs' => 'reset=1&cid=%%id%%&restore=1', 'title' => ts('Restore Contact'), - ), - ); + ], + ]; if (CRM_Core_Permission::check('delete contacts')) { - $links[] = array( + $links[] = [ 'name' => ts('Delete Permanently'), 'url' => 'civicrm/contact/view/delete', 'qs' => 'reset=1&cid=%%id%%&skip_undelete=1', 'title' => ts('Permanently Delete Contact'), - ); + ]; } $row['action'] = CRM_Core_Action::formLink( $links, NULL, - array('id' => $row['contact_id']), + ['id' => $row['contact_id']], ts('more'), FALSE, 'contact.selector.actions', @@ -983,7 +983,7 @@ public function addActions(&$rows) { $row['action'] = CRM_Core_Action::formLink( $links, $mask, - array('id' => $row['contact_id']), + ['id' => $row['contact_id']], ts('more'), FALSE, 'contact.selector.actions', @@ -1042,7 +1042,7 @@ public function fillupPrevNextCache($sort, $cacheKey, $start = 0, $end = self::C $selectSQL = "SELECT DISTINCT %1, contact_a.id, contact_a.sort_name"; - $sql = str_ireplace(array("SELECT contact_a.id as contact_id", "SELECT contact_a.id as id"), $selectSQL, $sql); + $sql = str_ireplace(["SELECT contact_a.id as contact_id", "SELECT contact_a.id as id"], $selectSQL, $sql); try { Civi::service('prevnext')->fillWithSql($cacheKey, $sql, [1 => [$cacheKey, 'String']]); } @@ -1130,38 +1130,38 @@ private static function &_getColumnHeaders() { 'address_options', TRUE, NULL, TRUE ); - self::$_columnHeaders = array( - 'contact_type' => array('desc' => ts('Contact Type')), - 'sort_name' => array( + self::$_columnHeaders = [ + 'contact_type' => ['desc' => ts('Contact Type')], + 'sort_name' => [ 'name' => ts('Name'), 'sort' => 'sort_name', 'direction' => CRM_Utils_Sort::ASCENDING, - ), - ); + ], + ]; - $defaultAddress = array( - 'street_address' => array('name' => ts('Address')), - 'city' => array( + $defaultAddress = [ + 'street_address' => ['name' => ts('Address')], + 'city' => [ 'name' => ts('City'), 'sort' => 'city', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - 'state_province' => array( + ], + 'state_province' => [ 'name' => ts('State'), 'sort' => 'state_province', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - 'postal_code' => array( + ], + 'postal_code' => [ 'name' => ts('Postal'), 'sort' => 'postal_code', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - 'country' => array( + ], + 'country' => [ 'name' => ts('Country'), 'sort' => 'country', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - ); + ], + ]; foreach ($defaultAddress as $columnName => $column) { if (!empty($addressOptions[$columnName])) { @@ -1169,13 +1169,13 @@ private static function &_getColumnHeaders() { } } - self::$_columnHeaders['email'] = array( + self::$_columnHeaders['email'] = [ 'name' => ts('Email'), 'sort' => 'email', 'direction' => CRM_Utils_Sort::DONTCARE, - ); + ]; - self::$_columnHeaders['phone'] = array('name' => ts('Phone')); + self::$_columnHeaders['phone'] = ['name' => ts('Phone')]; } return self::$_columnHeaders; } @@ -1237,16 +1237,16 @@ public function contactIDQuery($params, $sortID, $displayRelationshipType = NULL * @return array */ public function &makeProperties(&$returnProperties) { - $properties = array(); + $properties = []; foreach ($returnProperties as $name => $value) { if ($name != 'location') { // special handling for group and tag - if (in_array($name, array('group', 'tag'))) { + if (in_array($name, ['group', 'tag'])) { $name = "{$name}s"; } // special handling for notes - if (in_array($name, array('note', 'note_subject', 'note_body'))) { + if (in_array($name, ['note', 'note_subject', 'note_body'])) { $name = "notes"; } diff --git a/CRM/Contact/Selector/Custom.php b/CRM/Contact/Selector/Custom.php index c7498fd3356f..fa9d7ac463e5 100644 --- a/CRM/Contact/Selector/Custom.php +++ b/CRM/Contact/Selector/Custom.php @@ -57,7 +57,7 @@ class CRM_Contact_Selector_Custom extends CRM_Contact_Selector { * Properties of contact we're interested in displaying * @var array */ - static $_properties = array('contact_id', 'contact_type', 'display_name'); + static $_properties = ['contact_id', 'contact_type', 'display_name']; /** * FormValues is the array returned by exportValues called on @@ -165,33 +165,33 @@ public static function &links() { $extraParams = ($key) ? "&key={$key}" : NULL; if (!(self::$_links)) { - self::$_links = array( - CRM_Core_Action::VIEW => array( + self::$_links = [ + CRM_Core_Action::VIEW => [ 'name' => ts('View'), 'url' => 'civicrm/contact/view', 'qs' => "reset=1&cid=%%id%%{$extraParams}{$searchContext}", 'class' => 'no-popup', 'title' => ts('View Contact Details'), - ), - CRM_Core_Action::UPDATE => array( + ], + CRM_Core_Action::UPDATE => [ 'name' => ts('Edit'), 'url' => 'civicrm/contact/add', 'qs' => 'reset=1&action=update&cid=%%id%%', 'class' => 'no-popup', 'title' => ts('Edit Contact Details'), - ), - ); + ], + ]; $config = CRM_Core_Config::singleton(); //CRM-16552: mapAPIKey is not mandatory as google no longer requires an API Key if ($config->mapProvider && ($config->mapAPIKey || $config->mapProvider == 'Google')) { - self::$_links[CRM_Core_Action::MAP] = array( + self::$_links[CRM_Core_Action::MAP] = [ 'name' => ts('Map'), 'url' => 'civicrm/contact/map', 'qs' => 'reset=1&cid=%%id%%&searchType=custom', 'class' => 'no-popup', 'title' => ts('Map Contact'), - ); + ]; } } return self::$_links; @@ -227,7 +227,7 @@ public function getPagerParams($action, &$params) { */ public function &getColumnHeaders($action = NULL, $output = NULL) { $columns = $this->_search->columns(); - $headers = array(); + $headers = []; if ($output == CRM_Core_Selector_Controller::EXPORT || $output == CRM_Core_Selector_Controller::SCREEN) { foreach ($columns as $name => $key) { $headers[$key] = $name; @@ -237,14 +237,14 @@ public function &getColumnHeaders($action = NULL, $output = NULL) { else { foreach ($columns as $name => $key) { if (!empty($name)) { - $headers[] = array( + $headers[] = [ 'name' => $name, 'sort' => $key, 'direction' => CRM_Utils_Sort::ASCENDING, - ); + ]; } else { - $headers[] = array(); + $headers[] = []; } } return $headers; @@ -306,7 +306,7 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { $columnNames = array_values($columns); $links = self::links($this->_key); - $permissions = array(CRM_Core_Permission::getPermission()); + $permissions = [CRM_Core_Permission::getPermission()]; if (CRM_Core_Permission::check('delete contacts')) { $permissions[] = CRM_Core_Permission::DELETE; } @@ -323,9 +323,9 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { $image = TRUE; } // process the result of the query - $rows = array(); + $rows = []; while ($dao->fetch()) { - $row = array(); + $row = []; $empty = TRUE; // if contact query object present @@ -349,7 +349,7 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { $row['checkbox'] = CRM_Core_Form::CB_PREFIX . $contactID; $row['action'] = CRM_Core_Action::formLink($links, $mask, - array('id' => $contactID), + ['id' => $contactID], ts('more'), FALSE, 'contact.custom.actions', @@ -432,7 +432,7 @@ public function contactIDQuery($params, $sortID, $displayRelationshipType = NULL // no idea why they are there. // I wonder whether there is some helper function for this: - $matches = array(); + $matches = []; if (preg_match('/([0-9]*)(_(u|d))?/', $sortID, $matches)) { $columns = array_values($this->_search->columns()); $sort = $columns[$matches[1] - 1]; @@ -456,7 +456,7 @@ public function contactIDQuery($params, $sortID, $displayRelationshipType = NULL public function addActions(&$rows) { $links = self::links($this->_key); - $permissions = array(CRM_Core_Permission::getPermission()); + $permissions = [CRM_Core_Permission::getPermission()]; if (CRM_Core_Permission::check('delete contacts')) { $permissions[] = CRM_Core_Permission::DELETE; } @@ -465,7 +465,7 @@ public function addActions(&$rows) { foreach ($rows as $id => & $row) { $row['action'] = CRM_Core_Action::formLink($links, $mask, - array('id' => $row['contact_id']), + ['id' => $row['contact_id']], ts('more'), FALSE, 'contact.custom.actions', diff --git a/CRM/Contact/StateMachine/Search.php b/CRM/Contact/StateMachine/Search.php index 76d01e0826ea..97d8b375cd20 100644 --- a/CRM/Contact/StateMachine/Search.php +++ b/CRM/Contact/StateMachine/Search.php @@ -48,7 +48,7 @@ class CRM_Contact_StateMachine_Search extends CRM_Core_StateMachine { public function __construct($controller, $action = CRM_Core_Action::NONE) { parent::__construct($controller, $action); - $this->_pages = array(); + $this->_pages = []; if ($action == CRM_Core_Action::ADVANCED) { $this->_pages['CRM_Contact_Form_Search_Advanced'] = NULL; list($task, $result) = $this->taskName($controller, 'Advanced'); diff --git a/CRM/Contribute/ActionMapping/ByPage.php b/CRM/Contribute/ActionMapping/ByPage.php index b42e52b9c72d..285e7987a708 100644 --- a/CRM/Contribute/ActionMapping/ByPage.php +++ b/CRM/Contribute/ActionMapping/ByPage.php @@ -102,7 +102,7 @@ public function getStatusHeader() { * @throws CRM_Core_Exception */ public function getValueLabels() { - return CRM_Contribute_BAO_Contribution::buildOptions('contribution_page_id', 'get', array()); + return CRM_Contribute_BAO_Contribution::buildOptions('contribution_page_id', 'get', []); } /** @@ -117,7 +117,7 @@ public function getValueLabels() { * @throws CRM_Core_Exception */ public function getStatusLabels($value) { - return CRM_Contribute_BAO_Contribution::buildOptions('contribution_status_id', 'get', array()); + return CRM_Contribute_BAO_Contribution::buildOptions('contribution_status_id', 'get', []); } /** @@ -127,12 +127,12 @@ public function getStatusLabels($value) { * Array(string $fieldName => string $fieldLabel). */ public function getDateFields() { - return array( + return [ 'receive_date' => ts('Receive Date'), 'cancel_date' => ts('Cancel Date'), 'receipt_date' => ts('Receipt Date'), 'thankyou_date' => ts('Thank You Date'), - ); + ]; } /** @@ -146,7 +146,7 @@ public function getDateFields() { * Ex: array('assignee' => 'Activity Assignee'). */ public function getRecipientTypes() { - return array(); + return []; } /** @@ -163,7 +163,7 @@ public function getRecipientTypes() { * @see getRecipientTypes */ public function getRecipientListing($recipientType) { - return array(); + return []; } /** @@ -176,7 +176,7 @@ public function getRecipientListing($recipientType) { * List of error messages. */ public function validateSchedule($schedule) { - return array(); + return []; } /** diff --git a/CRM/Contribute/ActionMapping/ByType.php b/CRM/Contribute/ActionMapping/ByType.php index 288148af5034..8708ef396582 100644 --- a/CRM/Contribute/ActionMapping/ByType.php +++ b/CRM/Contribute/ActionMapping/ByType.php @@ -102,7 +102,7 @@ public function getStatusHeader() { * @throws CRM_Core_Exception */ public function getValueLabels() { - return CRM_Contribute_BAO_Contribution::buildOptions('financial_type_id', 'get', array()); + return CRM_Contribute_BAO_Contribution::buildOptions('financial_type_id', 'get', []); } /** @@ -117,7 +117,7 @@ public function getValueLabels() { * @throws CRM_Core_Exception */ public function getStatusLabels($value) { - return CRM_Contribute_BAO_Contribution::buildOptions('contribution_status_id', 'get', array()); + return CRM_Contribute_BAO_Contribution::buildOptions('contribution_status_id', 'get', []); } /** @@ -127,12 +127,12 @@ public function getStatusLabels($value) { * Array(string $fieldName => string $fieldLabel). */ public function getDateFields() { - return array( + return [ 'receive_date' => ts('Receive Date'), 'cancel_date' => ts('Cancel Date'), 'receipt_date' => ts('Receipt Date'), 'thankyou_date' => ts('Thank You Date'), - ); + ]; } /** @@ -146,9 +146,9 @@ public function getDateFields() { * Ex: array('assignee' => 'Activity Assignee'). */ public function getRecipientTypes() { - return array( + return [ 'soft_credit_type' => ts('Soft Credit Role'), - ); + ]; } /** @@ -170,7 +170,7 @@ public function getRecipientListing($recipientType) { return \CRM_Core_OptionGroup::values('soft_credit_type', FALSE, FALSE, FALSE, NULL, 'label', TRUE, FALSE, 'name'); default: - return array(); + return []; } } @@ -184,7 +184,7 @@ public function getRecipientListing($recipientType) { * List of error messages. */ public function validateSchedule($schedule) { - return array(); + return []; } /** diff --git a/CRM/Contribute/BAO/Contribution/Utils.php b/CRM/Contribute/BAO/Contribution/Utils.php index 03da0e1ba732..ebd162952e1f 100644 --- a/CRM/Contribute/BAO/Contribution/Utils.php +++ b/CRM/Contribute/BAO/Contribution/Utils.php @@ -100,12 +100,12 @@ public static function processConfirm( } if ($isPaymentTransaction) { - $contributionParams = array( + $contributionParams = [ 'id' => CRM_Utils_Array::value('contribution_id', $paymentParams), 'contact_id' => $contactID, 'is_test' => $isTest, 'source' => CRM_Utils_Array::value('source', $paymentParams, CRM_Utils_Array::value('description', $paymentParams)), - ); + ]; // CRM-21200: Don't overwrite contribution details during 'Pay now' payment if (empty($form->_params['contribution_id'])) { @@ -116,10 +116,10 @@ public static function processConfirm( else { // contribution.source only allows 255 characters so we are using ellipsify(...) to ensure it. $contributionParams['source'] = CRM_Utils_String::ellipsify( - ts('Paid later via page ID: %1. %2', array( + ts('Paid later via page ID: %1. %2', [ 1 => $form->_id, 2 => $contributionParams['source'], - )), + ]), 220 // eventually activity.description append price information to source text so keep it 220 to ensure string length doesn't exceed 255 characters. ); } @@ -152,7 +152,7 @@ public static function processConfirm( if ($paymentParams['skipLineItem']) { // We are not processing the line item here because we are processing a membership. // Do not continue with contribution processing in this function. - return array('contribution' => $contribution); + return ['contribution' => $contribution]; } $paymentParams['contributionID'] = $contribution->id; @@ -229,11 +229,11 @@ public static function processConfirm( // This is kind of a back-up for pay-later $0 transactions. // In other flows they pick up the manual processor & get dealt with above (I // think that might be better...). - return array( + return [ 'payment_status_id' => 1, 'contribution' => $contribution, 'payment_processor_id' => 0, - ); + ]; } CRM_Contribute_BAO_ContributionPage::sendMail($contactID, @@ -266,11 +266,11 @@ static protected function isPaymentTransaction($form) { */ public static function contributionChartMonthly($param) { if ($param) { - $param = array(1 => array($param, 'Integer')); + $param = [1 => [$param, 'Integer']]; } else { $param = date("Y"); - $param = array(1 => array($param, 'Integer')); + $param = [1 => [$param, 'Integer']]; } $query = " @@ -385,12 +385,12 @@ public static function _fillCommonParams(&$params, $type = 'paypal') { $params['address'][1]['location_type_id'] = $billingLocTypeId; } if (!CRM_Utils_System::isNull($params['email'])) { - $params['email'] = array( - 1 => array( + $params['email'] = [ + 1 => [ 'email' => $params['email'], 'location_type_id' => $billingLocTypeId, - ), - ); + ], + ]; } if (isset($transaction['trxn_id'])) { @@ -420,7 +420,7 @@ public static function _fillCommonParams(&$params, $type = 'paypal') { } $source = ts('ContributionProcessor: %1 API', - array(1 => ucfirst($type)) + [1 => ucfirst($type)] ); if (isset($transaction['source'])) { $transaction['source'] = $source . ':: ' . $transaction['source']; @@ -441,7 +441,7 @@ public static function getFirstLastDetails($contactID) { static $_cache; if (!$_cache) { - $_cache = array(); + $_cache = []; } if (!isset($_cache[$contactID])) { @@ -452,28 +452,28 @@ public static function getFirstLastDetails($contactID) { ORDER BY receive_date ASC LIMIT 1 "; - $params = array(1 => array($contactID, 'Integer')); + $params = [1 => [$contactID, 'Integer']]; $dao = CRM_Core_DAO::executeQuery($sql, $params); - $details = array( + $details = [ 'first' => NULL, 'last' => NULL, - ); + ]; if ($dao->fetch()) { - $details['first'] = array( + $details['first'] = [ 'total_amount' => $dao->total_amount, 'receive_date' => $dao->receive_date, - ); + ]; } // flip asc and desc to get the last query $sql = str_replace('ASC', 'DESC', $sql); $dao = CRM_Core_DAO::executeQuery($sql, $params); if ($dao->fetch()) { - $details['last'] = array( + $details['last'] = [ 'total_amount' => $dao->total_amount, 'receive_date' => $dao->receive_date, - ); + ]; } $_cache[$contactID] = $details; @@ -499,9 +499,9 @@ public static function getFirstLastDetails($contactID) { * */ public static function calculateTaxAmount($amount, $taxRate, $ugWeDoNotKnowIfItNeedsCleaning_Help = FALSE) { - $taxAmount = array(); + $taxAmount = []; if ($ugWeDoNotKnowIfItNeedsCleaning_Help) { - Civi::log()->warning('Deprecated function, make sure money is in usable format before calling this.', array('civi.tag' => 'deprecated')); + Civi::log()->warning('Deprecated function, make sure money is in usable format before calling this.', ['civi.tag' => 'deprecated']); $amount = CRM_Utils_Rule::cleanMoney($amount); } // There can not be any rounding at this stage - as this is prior to quantity multiplication @@ -544,35 +544,35 @@ public static function getContributionStatuses($usedFor = 'contribution', $id = $statusNames = CRM_Contribute_BAO_Contribution::buildOptions('contribution_status_id', 'validate'); } - $statusNamesToUnset = array(); + $statusNamesToUnset = []; // on create fetch statuses on basis of component if (!$id) { - $statusNamesToUnset = array( + $statusNamesToUnset = [ 'Refunded', 'Chargeback', 'Pending refund', - ); + ]; // Event registration and New Membership backoffice form support partially paid payment, // so exclude this status only for 'New Contribution' form if ($usedFor == 'contribution') { - $statusNamesToUnset = array_merge($statusNamesToUnset, array( + $statusNamesToUnset = array_merge($statusNamesToUnset, [ 'In Progress', 'Overdue', 'Partially paid', - )); + ]); } elseif ($usedFor == 'participant') { - $statusNamesToUnset = array_merge($statusNamesToUnset, array( + $statusNamesToUnset = array_merge($statusNamesToUnset, [ 'Cancelled', 'Failed', - )); + ]); } elseif ($usedFor == 'membership') { - $statusNamesToUnset = array_merge($statusNamesToUnset, array( + $statusNamesToUnset = array_merge($statusNamesToUnset, [ 'In Progress', 'Overdue', - )); + ]); } } else { @@ -581,40 +581,40 @@ public static function getContributionStatuses($usedFor = 'contribution', $id = switch ($name) { case 'Completed': // [CRM-17498] Removing unsupported status change options. - $statusNamesToUnset = array_merge($statusNamesToUnset, array( + $statusNamesToUnset = array_merge($statusNamesToUnset, [ 'Pending', 'Failed', 'Partially paid', 'Pending refund', - )); + ]); break; case 'Cancelled': case 'Chargeback': case 'Refunded': - $statusNamesToUnset = array_merge($statusNamesToUnset, array( + $statusNamesToUnset = array_merge($statusNamesToUnset, [ 'Pending', 'Failed', - )); + ]); break; case 'Pending': case 'In Progress': - $statusNamesToUnset = array_merge($statusNamesToUnset, array( + $statusNamesToUnset = array_merge($statusNamesToUnset, [ 'Refunded', 'Chargeback', - )); + ]); break; case 'Failed': - $statusNamesToUnset = array_merge($statusNamesToUnset, array( + $statusNamesToUnset = array_merge($statusNamesToUnset, [ 'Pending', 'Refunded', 'Chargeback', 'Completed', 'In Progress', 'Cancelled', - )); + ]); break; } } diff --git a/CRM/Contribute/BAO/ContributionPage.php b/CRM/Contribute/BAO/ContributionPage.php index 741c2e03f312..10e47c8a902d 100644 --- a/CRM/Contribute/BAO/ContributionPage.php +++ b/CRM/Contribute/BAO/ContributionPage.php @@ -88,17 +88,17 @@ public static function setIsActive($id, $is_active) { * @param array $values */ public static function setValues($id, &$values) { - $modules = array('CiviContribute', 'soft_credit', 'on_behalf'); + $modules = ['CiviContribute', 'soft_credit', 'on_behalf']; $values['custom_pre_id'] = $values['custom_post_id'] = NULL; - $params = array('id' => $id); + $params = ['id' => $id]; CRM_Core_DAO::commonRetrieve('CRM_Contribute_DAO_ContributionPage', $params, $values); // get the profile ids - $ufJoinParams = array( + $ufJoinParams = [ 'entity_table' => 'civicrm_contribution_page', 'entity_id' => $id, - ); + ]; // retrieve profile id as also unserialize module_data corresponding to each $module foreach ($modules as $module) { @@ -150,15 +150,15 @@ public static function setValues($id, &$values) { * @param array $fieldTypes */ public static function sendMail($contactID, $values, $isTest = FALSE, $returnMessageText = FALSE, $fieldTypes = NULL) { - $gIds = array(); - $params = array('custom_pre_id' => array(), 'custom_post_id' => array()); + $gIds = []; + $params = ['custom_pre_id' => [], 'custom_post_id' => []]; $email = NULL; // We are trying to fight the good fight against leaky variables (CRM-17519) so let's get really explicit // about ensuring the variables we want for the template are defined. // @todo add to this until all tpl params are explicit in this function and not waltzing around the codebase. // Next stage is to remove this & ensure there are no e-notices - ie. all are set before they hit this fn. - $valuesRequiredForTemplate = array( + $valuesRequiredForTemplate = [ 'customPre', 'customPost', 'customPre_grouptitle', @@ -168,7 +168,7 @@ public static function sendMail($contactID, $values, $isTest = FALSE, $returnMes 'amount', 'receipt_date', 'is_pay_later', - ); + ]; foreach ($valuesRequiredForTemplate as $valueRequiredForTemplate) { if (!isset($values[$valueRequiredForTemplate])) { @@ -179,26 +179,26 @@ public static function sendMail($contactID, $values, $isTest = FALSE, $returnMes if (isset($values['custom_pre_id'])) { $preProfileType = CRM_Core_BAO_UFField::getProfileType($values['custom_pre_id']); if ($preProfileType == 'Membership' && !empty($values['membership_id'])) { - $params['custom_pre_id'] = array( - array( + $params['custom_pre_id'] = [ + [ 'member_id', '=', $values['membership_id'], 0, 0, - ), - ); + ], + ]; } elseif ($preProfileType == 'Contribution' && !empty($values['contribution_id'])) { - $params['custom_pre_id'] = array( - array( + $params['custom_pre_id'] = [ + [ 'contribution_id', '=', $values['contribution_id'], 0, 0, - ), - ); + ], + ]; } $gIds['custom_pre_id'] = $values['custom_pre_id']; @@ -207,26 +207,26 @@ public static function sendMail($contactID, $values, $isTest = FALSE, $returnMes if (isset($values['custom_post_id'])) { $postProfileType = CRM_Core_BAO_UFField::getProfileType($values['custom_post_id']); if ($postProfileType == 'Membership' && !empty($values['membership_id'])) { - $params['custom_post_id'] = array( - array( + $params['custom_post_id'] = [ + [ 'member_id', '=', $values['membership_id'], 0, 0, - ), - ); + ], + ]; } elseif ($postProfileType == 'Contribution' && !empty($values['contribution_id'])) { - $params['custom_post_id'] = array( - array( + $params['custom_post_id'] = [ + [ 'contribution_id', '=', $values['contribution_id'], 0, 0, - ), - ); + ], + ]; } $gIds['custom_post_id'] = $values['custom_post_id']; @@ -234,48 +234,48 @@ public static function sendMail($contactID, $values, $isTest = FALSE, $returnMes if (!empty($values['is_for_organization'])) { if (!empty($values['membership_id'])) { - $params['onbehalf_profile'] = array( - array( + $params['onbehalf_profile'] = [ + [ 'member_id', '=', $values['membership_id'], 0, 0, - ), - ); + ], + ]; } elseif (!empty($values['contribution_id'])) { - $params['onbehalf_profile'] = array( - array( + $params['onbehalf_profile'] = [ + [ 'contribution_id', '=', $values['contribution_id'], 0, 0, - ), - ); + ], + ]; } } //check whether it is a test drive if ($isTest && !empty($params['custom_pre_id'])) { - $params['custom_pre_id'][] = array( + $params['custom_pre_id'][] = [ 'contribution_test', '=', 1, 0, 0, - ); + ]; } if ($isTest && !empty($params['custom_post_id'])) { - $params['custom_post_id'][] = array( + $params['custom_post_id'][] = [ 'contribution_test', '=', 1, 0, 0, - ); + ]; } if (!$returnMessageText && !empty($gIds)) { @@ -349,7 +349,7 @@ public static function sendMail($contactID, $values, $isTest = FALSE, $returnMes } if (isset($values['honor'])) { $honorValues = $values['honor']; - $template->_values = array('honoree_profile_id' => $values['honoree_profile_id']); + $template->_values = ['honoree_profile_id' => $values['honoree_profile_id']]; CRM_Contribute_BAO_ContributionSoft::formatHonoreeProfileFields( $template, $honorValues['honor_profile_values'], @@ -361,7 +361,7 @@ public static function sendMail($contactID, $values, $isTest = FALSE, $returnMes // Set email variables explicitly to avoid leaky smarty variables. // All of these will be assigned to the template, replacing any that might be assigned elsewhere. - $tplParams = array( + $tplParams = [ 'email' => $email, 'receiptFromEmail' => CRM_Utils_Array::value('receipt_from_email', $values), 'contactID' => $contactID, @@ -387,7 +387,7 @@ public static function sendMail($contactID, $values, $isTest = FALSE, $returnMes 'pay_later_receipt' => CRM_Utils_Array::value('pay_later_receipt', $values), 'honor_block_is_active' => CRM_Utils_Array::value('honor_block_is_active', $values), 'contributionStatus' => CRM_Utils_Array::value('contribution_status', $values), - ); + ]; if ($contributionTypeId = CRM_Utils_Array::value('financial_type_id', $values)) { $tplParams['financialTypeId'] = $contributionTypeId; @@ -432,23 +432,23 @@ public static function sendMail($contactID, $values, $isTest = FALSE, $returnMes } // use either the contribution or membership receipt, based on whether it’s a membership-related contrib or not - $sendTemplateParams = array( + $sendTemplateParams = [ 'groupName' => !empty($values['isMembership']) ? 'msg_tpl_workflow_membership' : 'msg_tpl_workflow_contribution', 'valueName' => !empty($values['isMembership']) ? 'membership_online_receipt' : 'contribution_online_receipt', 'contactId' => $contactID, 'tplParams' => $tplParams, 'isTest' => $isTest, 'PDFFilename' => 'receipt.pdf', - ); + ]; if ($returnMessageText) { list($sent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams); - return array( + return [ 'subject' => $subject, 'body' => $message, 'to' => $displayName, 'html' => $html, - ); + ]; } if (empty($values['receipt_from_name']) && empty($values['receipt_from_name'])) { @@ -501,9 +501,9 @@ public static function sendMail($contactID, $values, $isTest = FALSE, $returnMes * * @return array */ - protected static function getProfileNameAndFields($gid, $cid, &$params, $fieldTypes = array()) { + protected static function getProfileNameAndFields($gid, $cid, &$params, $fieldTypes = []) { $groupTitle = NULL; - $values = array(); + $values = []; if ($gid) { if (CRM_Core_BAO_UFGroup::filterUFGroups($gid, $cid)) { $fields = CRM_Core_BAO_UFGroup::getFields($gid, FALSE, CRM_Core_Action::VIEW, NULL, NULL, FALSE, NULL, FALSE, NULL, CRM_Core_Permission::CREATE, NULL); @@ -528,7 +528,7 @@ protected static function getProfileNameAndFields($gid, $cid, &$params, $fieldTy CRM_Core_BAO_UFGroup::getValues($cid, $fields, $values, FALSE, $params); } } - return array($groupTitle, $values); + return [$groupTitle, $values]; } /** @@ -545,17 +545,17 @@ protected static function getProfileNameAndFields($gid, $cid, &$params, $fieldTy * @param bool|object $autoRenewMembership is it a auto renew membership. */ public static function recurringNotify($type, $contactID, $pageID, $recur, $autoRenewMembership = FALSE) { - $value = array(); + $value = []; $isEmailReceipt = FALSE; if ($pageID) { - CRM_Core_DAO::commonRetrieveAll('CRM_Contribute_DAO_ContributionPage', 'id', $pageID, $value, array( + CRM_Core_DAO::commonRetrieveAll('CRM_Contribute_DAO_ContributionPage', 'id', $pageID, $value, [ 'title', 'is_email_receipt', 'receipt_from_name', 'receipt_from_email', 'cc_receipt', 'bcc_receipt', - )); + ]); $isEmailReceipt = CRM_Utils_Array::value('is_email_receipt', $value[$pageID]); } elseif ($recur->id) { @@ -579,11 +579,11 @@ public static function recurringNotify($type, $contactID, $pageID, $recur, $auto } list($displayName, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contactID, FALSE); - $templatesParams = array( + $templatesParams = [ 'groupName' => 'msg_tpl_workflow_contribution', 'valueName' => 'contribution_recurring_notify', 'contactId' => $contactID, - 'tplParams' => array( + 'tplParams' => [ 'recur_frequency_interval' => $recur->frequency_interval, 'recur_frequency_unit' => $recur->frequency_unit, 'recur_installments' => $recur->installments, @@ -595,11 +595,11 @@ public static function recurringNotify($type, $contactID, $pageID, $recur, $auto 'receipt_from_name' => $receiptFromName, 'receipt_from_email' => $receiptFromEmail, 'auto_renew_membership' => $autoRenewMembership, - ), + ], 'from' => $receiptFrom, 'toName' => $displayName, 'toEmail' => $email, - ); + ]; //CRM-13811 if ($pageID) { $templatesParams['cc'] = CRM_Utils_Array::value('cc_receipt', $value[$pageID]); @@ -667,67 +667,67 @@ public static function buildCustomDisplay($gid, $name, $cid, &$template, &$param * @return CRM_Contribute_DAO_ContributionPage */ public static function copy($id) { - $fieldsFix = array( - 'prefix' => array( + $fieldsFix = [ + 'prefix' => [ 'title' => ts('Copy of') . ' ', - ), - ); - $copy = &CRM_Core_DAO::copyGeneric('CRM_Contribute_DAO_ContributionPage', array( + ], + ]; + $copy = &CRM_Core_DAO::copyGeneric('CRM_Contribute_DAO_ContributionPage', [ 'id' => $id, - ), NULL, $fieldsFix); + ], NULL, $fieldsFix); //copying all the blocks pertaining to the contribution page - $copyPledgeBlock = &CRM_Core_DAO::copyGeneric('CRM_Pledge_DAO_PledgeBlock', array( + $copyPledgeBlock = &CRM_Core_DAO::copyGeneric('CRM_Pledge_DAO_PledgeBlock', [ 'entity_id' => $id, 'entity_table' => 'civicrm_contribution_page', - ), array( + ], [ 'entity_id' => $copy->id, - )); + ]); - $copyMembershipBlock = &CRM_Core_DAO::copyGeneric('CRM_Member_DAO_MembershipBlock', array( + $copyMembershipBlock = &CRM_Core_DAO::copyGeneric('CRM_Member_DAO_MembershipBlock', [ 'entity_id' => $id, 'entity_table' => 'civicrm_contribution_page', - ), array( + ], [ 'entity_id' => $copy->id, - )); + ]); - $copyUFJoin = &CRM_Core_DAO::copyGeneric('CRM_Core_DAO_UFJoin', array( + $copyUFJoin = &CRM_Core_DAO::copyGeneric('CRM_Core_DAO_UFJoin', [ 'entity_id' => $id, 'entity_table' => 'civicrm_contribution_page', - ), array( + ], [ 'entity_id' => $copy->id, - )); + ]); - $copyWidget = &CRM_Core_DAO::copyGeneric('CRM_Contribute_DAO_Widget', array( + $copyWidget = &CRM_Core_DAO::copyGeneric('CRM_Contribute_DAO_Widget', [ 'contribution_page_id' => $id, - ), array( + ], [ 'contribution_page_id' => $copy->id, - )); + ]); //copy price sets CRM_Price_BAO_PriceSet::copyPriceSet('civicrm_contribution_page', $id, $copy->id); - $copyTellFriend = &CRM_Core_DAO::copyGeneric('CRM_Friend_DAO_Friend', array( + $copyTellFriend = &CRM_Core_DAO::copyGeneric('CRM_Friend_DAO_Friend', [ 'entity_id' => $id, 'entity_table' => 'civicrm_contribution_page', - ), array( + ], [ 'entity_id' => $copy->id, - )); + ]); - $copyPersonalCampaignPages = &CRM_Core_DAO::copyGeneric('CRM_PCP_DAO_PCPBlock', array( + $copyPersonalCampaignPages = &CRM_Core_DAO::copyGeneric('CRM_PCP_DAO_PCPBlock', [ 'entity_id' => $id, 'entity_table' => 'civicrm_contribution_page', - ), array( + ], [ 'entity_id' => $copy->id, 'target_entity_id' => $copy->id, - )); + ]); - $copyPremium = &CRM_Core_DAO::copyGeneric('CRM_Contribute_DAO_Premium', array( + $copyPremium = &CRM_Core_DAO::copyGeneric('CRM_Contribute_DAO_Premium', [ 'entity_id' => $id, 'entity_table' => 'civicrm_contribution_page', - ), array( + ], [ 'entity_id' => $copy->id, - )); + ]); $premiumQuery = " SELECT id FROM civicrm_premiums @@ -737,11 +737,11 @@ public static function copy($id) { $premiumDao = CRM_Core_DAO::executeQuery($premiumQuery, CRM_Core_DAO::$_nullArray); while ($premiumDao->fetch()) { if ($premiumDao->id) { - CRM_Core_DAO::copyGeneric('CRM_Contribute_DAO_PremiumsProduct', array( + CRM_Core_DAO::copyGeneric('CRM_Contribute_DAO_PremiumsProduct', [ 'premiums_id' => $premiumDao->id, - ), array( + ], [ 'premiums_id' => $copyPremium->id, - )); + ]); } } @@ -759,14 +759,14 @@ public static function copy($id) { * @return array * info regarding all sections. */ - public static function getSectionInfo($contribPageIds = array()) { - $info = array(); + public static function getSectionInfo($contribPageIds = []) { + $info = []; $whereClause = NULL; if (is_array($contribPageIds) && !empty($contribPageIds)) { $whereClause = 'WHERE civicrm_contribution_page.id IN ( ' . implode(', ', $contribPageIds) . ' )'; } - $sections = array( + $sections = [ 'settings', 'amount', 'membership', @@ -776,7 +776,7 @@ public static function getSectionInfo($contribPageIds = array()) { 'pcp', 'widget', 'premium', - ); + ]; $query = " SELECT civicrm_contribution_page.id as id, civicrm_contribution_page.financial_type_id as settings, @@ -834,8 +834,8 @@ public static function getSectionInfo($contribPageIds = array()) { * * @return array|bool */ - public static function buildOptions($fieldName, $context = NULL, $props = array()) { - $params = array(); + public static function buildOptions($fieldName, $context = NULL, $props = []) { + $params = []; // Special logic for fields whose options depend on context or properties switch ($fieldName) { case 'financial_type_id': @@ -863,21 +863,21 @@ public static function formatModuleData($params, $setDefault = FALSE, $module) { $domain = new CRM_Core_DAO_Domain(); $domain->find(TRUE); - $moduleDataFormat = array( - 'soft_credit' => array( + $moduleDataFormat = [ + 'soft_credit' => [ 1 => 'soft_credit_types', - 'multilingual' => array( + 'multilingual' => [ 'honor_block_title', 'honor_block_text', - ), - ), - 'on_behalf' => array( + ], + ], + 'on_behalf' => [ 1 => 'is_for_organization', - 'multilingual' => array( + 'multilingual' => [ 'for_organization', - ), - ), - ); + ], + ], + ]; //When we are fetching the honor params respecting both multi and mono lingual state //and setting it to default param of Contribution Page's Main and Setting form @@ -902,10 +902,10 @@ public static function formatModuleData($params, $setDefault = FALSE, $module) { //check and handle multilingual honoree params if (!$domain->locales) { //if in singlelingual state simply return the array format - $json = array($module => NULL); + $json = [$module => NULL]; foreach ($moduleDataFormat[$module] as $key => $attribute) { if ($key === 'multilingual') { - $json[$module]['default'] = array(); + $json[$module]['default'] = []; foreach ($attribute as $attr) { $json[$module]['default'][$attr] = $params[$attr]; } @@ -919,10 +919,10 @@ public static function formatModuleData($params, $setDefault = FALSE, $module) { else { //if in multilingual state then retrieve the module_data against this contribution and //merge with earlier module_data json data to current so not to lose earlier multilingual module_data information - $json = array($module => NULL); + $json = [$module => NULL]; foreach ($moduleDataFormat[$module] as $key => $attribute) { if ($key === 'multilingual') { - $json[$module][$config->lcMessages] = array(); + $json[$module][$config->lcMessages] = []; foreach ($attribute as $attr) { $json[$module][$config->lcMessages][$attr] = $params[$attr]; } @@ -954,12 +954,12 @@ public static function formatModuleData($params, $setDefault = FALSE, $module) { * @return array */ public static function addInvoicePdfToEmail($contributionId, $userID) { - $contributionID = array($contributionId); - $contactId = array($userID); - $pdfParams = array( + $contributionID = [$contributionId]; + $contactId = [$userID]; + $pdfParams = [ 'output' => 'pdf_invoice', 'forPage' => 'confirmpage', - ); + ]; $pdfHtml = CRM_Contribute_Form_Task_Invoice::printPDF($contributionID, $pdfParams, $contactId); return $pdfHtml; } @@ -973,11 +973,11 @@ public static function addInvoicePdfToEmail($contributionId, $userID) { * isSeparateMembershipPayment */ public static function getIsMembershipPayment($id) { - $membershipBlocks = civicrm_api3('membership_block', 'get', array( + $membershipBlocks = civicrm_api3('membership_block', 'get', [ 'entity_table' => 'civicrm_contribution_page', 'entity_id' => $id, 'sequential' => TRUE, - )); + ]); if (!$membershipBlocks['count']) { return FALSE; } diff --git a/CRM/Contribute/BAO/ContributionRecur.php b/CRM/Contribute/BAO/ContributionRecur.php index 25e79ce86e0b..27f41cfcb2da 100644 --- a/CRM/Contribute/BAO/ContributionRecur.php +++ b/CRM/Contribute/BAO/ContributionRecur.php @@ -37,7 +37,7 @@ class CRM_Contribute_BAO_ContributionRecur extends CRM_Contribute_DAO_Contributi * * @var array */ - private static $inactiveStatuses = array('Cancelled', 'Chargeback', 'Refunded', 'Completed'); + private static $inactiveStatuses = ['Cancelled', 'Chargeback', 'Refunded', 'Completed']; /** * Create recurring contribution. @@ -75,13 +75,13 @@ public static function add(&$params) { // make sure we're not creating a new recurring contribution with the same transaction ID // or invoice ID as an existing recurring contribution - $duplicates = array(); + $duplicates = []; if (self::checkDuplicate($params, $duplicates)) { $error = CRM_Core_Error::singleton(); $d = implode(', ', $duplicates); $error->push(CRM_Core_Error::DUPLICATE_CONTRIBUTION, 'Fatal', - array($d), + [$d], "Found matching recurring contribution(s): $d" ); return $error; @@ -130,17 +130,17 @@ public static function checkDuplicate($params, &$duplicates) { $trxn_id = CRM_Utils_Array::value('trxn_id', $params); $invoice_id = CRM_Utils_Array::value('invoice_id', $params); - $clause = array(); - $params = array(); + $clause = []; + $params = []; if ($trxn_id) { $clause[] = "trxn_id = %1"; - $params[1] = array($trxn_id, 'String'); + $params[1] = [$trxn_id, 'String']; } if ($invoice_id) { $clause[] = "invoice_id = %2"; - $params[2] = array($invoice_id, 'String'); + $params[2] = [$invoice_id, 'String']; } if (empty($clause)) { @@ -150,7 +150,7 @@ public static function checkDuplicate($params, &$duplicates) { $clause = implode(' OR ', $clause); if ($id) { $clause = "( $clause ) AND id != %3"; - $params[3] = array($id, 'Integer'); + $params[3] = [$id, 'Integer']; } $query = "SELECT id FROM civicrm_contribution_recur WHERE $clause"; @@ -219,7 +219,7 @@ public static function getPaymentProcessorID($recurID) { */ public static function getCount(&$ids) { $recurID = implode(',', $ids); - $totalCount = array(); + $totalCount = []; $query = " SELECT contribution_recur_id, count( contribution_recur_id ) as commpleted @@ -265,7 +265,7 @@ public static function deleteRecurContribution($recurId) { * * @return bool */ - public static function cancelRecurContribution($recurId, $activityParams = array()) { + public static function cancelRecurContribution($recurId, $activityParams = []) { if (!$recurId) { return FALSE; } @@ -294,17 +294,17 @@ public static function cancelRecurContribution($recurId, $activityParams = array $membershipType = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $dao->membership_id, 'membership_type_id'); $membershipType = CRM_Utils_Array::value($membershipType, $membershipTypes); $details .= ' -
    ' . ts('Automatic renewal of %1 membership cancelled.', array(1 => $membershipType)); +
    ' . ts('Automatic renewal of %1 membership cancelled.', [1 => $membershipType]); } else { $details .= ' -
    ' . ts('The recurring contribution of %1, every %2 %3 has been cancelled.', array( +
    ' . ts('The recurring contribution of %1, every %2 %3 has been cancelled.', [ 1 => $dao->amount, 2 => $dao->frequency_interval, 3 => $dao->frequency_unit, - )); + ]); } - $activityParams = array( + $activityParams = [ 'source_contact_id' => $dao->contact_id, 'source_record_id' => $dao->recur_id, 'activity_type_id' => CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Cancel Recurring Contribution'), @@ -312,7 +312,7 @@ public static function cancelRecurContribution($recurId, $activityParams = array 'details' => $details, 'activity_date_time' => date('YmdHis'), 'status_id' => CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_status_id', 'Completed'), - ); + ]; $session = CRM_Core_Session::singleton(); $cid = $session->get('userID'); if ($cid) { @@ -350,7 +350,7 @@ public static function cancelRecurContribution($recurId, $activityParams = array */ public static function getRecurContributions($contactId) { CRM_Core_Error::deprecatedFunctionWarning('ContributionRecur.get API instead'); - $params = array(); + $params = []; $recurDAO = new CRM_Contribute_DAO_ContributionRecur(); $recurDAO->contact_id = $contactId; $recurDAO->find(); @@ -426,7 +426,7 @@ public static function getSubscriptionDetails($entityID, $entity = 'recur') { WHERE mp.membership_id = %1"; } - $dao = CRM_Core_DAO::executeQuery($sql, array(1 => array($entityID, 'Integer'))); + $dao = CRM_Core_DAO::executeQuery($sql, [1 => [$entityID, 'Integer']]); if ($dao->fetch()) { return $dao; } @@ -468,19 +468,19 @@ public static function supportsFinancialTypeChange($id) { * @return array * @throws \CiviCRM_API3_Exception */ - public static function getTemplateContribution($id, $overrides = array()) { - $templateContribution = civicrm_api3('Contribution', 'get', array( + public static function getTemplateContribution($id, $overrides = []) { + $templateContribution = civicrm_api3('Contribution', 'get', [ 'contribution_recur_id' => $id, - 'options' => array('limit' => 1, 'sort' => array('id DESC')), + 'options' => ['limit' => 1, 'sort' => ['id DESC']], 'sequential' => 1, 'contribution_test' => '', - )); + ]); if ($templateContribution['count']) { $result = array_merge($templateContribution['values'][0], $overrides); $result['line_item'] = CRM_Contribute_BAO_ContributionRecur::calculateRecurLineItems($id, $result['total_amount'], $result['financial_type_id']); return $result; } - return array(); + return []; } public static function setSubscriptionContext() { @@ -597,11 +597,11 @@ static public function copyCustomValues($recurId, $targetContributionId) { } // copy custom data - $extends = array('Contribution'); + $extends = ['Contribution']; $groupTree = CRM_Core_BAO_CustomGroup::getGroupDetail(NULL, NULL, $extends); if ($groupTree) { foreach ($groupTree as $groupID => $group) { - $table[$groupTree[$groupID]['table_name']] = array('entity_id'); + $table[$groupTree[$groupID]['table_name']] = ['entity_id']; foreach ($group['fields'] as $fieldID => $field) { $table[$groupTree[$groupID]['table_name']][] = $groupTree[$groupID]['fields'][$fieldID]['column_name']; } @@ -660,11 +660,11 @@ public static function addRecurLineItems($recurId, $contribution) { try { // @todo this should be done by virtue of editing the line item as this link // is deprecated. This may be the case but needs testing. - civicrm_api3('membership_payment', 'create', array( + civicrm_api3('membership_payment', 'create', [ 'membership_id' => $value['entity_id'], 'contribution_id' => $contribution->id, 'is_transactional' => FALSE, - )); + ]); } catch (CiviCRM_API3_Exception $e) { // we are catching & ignoring errors as an extra precaution since lost IPNs may be more serious that lost membership_payment data @@ -702,8 +702,8 @@ public static function addRecurLineItems($recurId, $contribution) { * @throws \CiviCRM_API3_Exception */ public static function updateRecurLinkedPledge($contributionID, $contributionRecurID, $contributionStatusID, $contributionAmount) { - $returnProperties = array('id', 'pledge_id'); - $paymentDetails = $paymentIDs = array(); + $returnProperties = ['id', 'pledge_id']; + $paymentDetails = $paymentIDs = []; if (CRM_Core_DAO::commonRetrieveAll('CRM_Pledge_DAO_PledgePayment', 'contribution_id', $contributionID, $paymentDetails, $returnProperties @@ -783,7 +783,7 @@ public static function recurringContribution(&$form) { } // If values have been supplied for recurring contribution fields, open the recurring contributions pane. - foreach (array('contribution_status_id', 'payment_processor_id', 'processor_id', 'trxn_id') as $fieldName) { + foreach (['contribution_status_id', 'payment_processor_id', 'processor_id', 'trxn_id'] as $fieldName) { if (!empty($form->_formValues['contribution_recur_' . $fieldName])) { $form->assign('contribution_recur_pane_open', TRUE); break; @@ -791,11 +791,11 @@ public static function recurringContribution(&$form) { } // Add field to check if payment is made for recurring contribution - $recurringPaymentOptions = array( + $recurringPaymentOptions = [ 1 => ts('All recurring contributions'), 2 => ts('Recurring contributions with at least one payment'), - ); - $form->addRadio('contribution_recur_payment_made', NULL, $recurringPaymentOptions, array('allowClear' => TRUE)); + ]; + $form->addRadio('contribution_recur_payment_made', NULL, $recurringPaymentOptions, ['allowClear' => TRUE]); CRM_Core_Form_Date::buildDateRange($form, 'contribution_recur_start_date', 1, '_low', '_high', ts('From'), FALSE, FALSE, 'birth'); CRM_Core_Form_Date::buildDateRange($form, 'contribution_recur_end_date', 1, '_low', '_high', ts('From'), FALSE, FALSE, 'birth'); CRM_Core_Form_Date::buildDateRange($form, 'contribution_recur_modified_date', 1, '_low', '_high', ts('From'), FALSE, FALSE, 'birth'); @@ -805,7 +805,7 @@ public static function recurringContribution(&$form) { // Add field for contribution status $form->addSelect('contribution_recur_contribution_status_id', - array('entity' => 'contribution', 'multiple' => 'multiple', 'context' => 'search', 'options' => CRM_Contribute_PseudoConstant::contributionStatus()) + ['entity' => 'contribution', 'multiple' => 'multiple', 'context' => 'search', 'options' => CRM_Contribute_PseudoConstant::contributionStatus()] ); $form->addElement('text', 'contribution_recur_processor_id', ts('Processor ID'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_ContributionRecur', 'processor_id')); @@ -814,7 +814,7 @@ public static function recurringContribution(&$form) { $paymentProcessorOpts = CRM_Contribute_BAO_ContributionRecur::buildOptions('payment_processor_id', 'get'); $form->add('select', 'contribution_recur_payment_processor_id', ts('Payment Processor ID'), $paymentProcessorOpts, FALSE, ['class' => 'crm-select2', 'multiple' => 'multiple']); - CRM_Core_BAO_Query::addCustomFormFields($form, array('ContributionRecur')); + CRM_Core_BAO_Query::addCustomFormFields($form, ['ContributionRecur']); } @@ -824,7 +824,7 @@ public static function recurringContribution(&$form) { * @return array */ public static function getRecurringFields() { - return array( + return [ 'contribution_recur_payment_made' => ts(''), 'contribution_recur_start_date' => ts('Recurring Contribution Start Date'), 'contribution_recur_next_sched_contribution_date' => ts('Next Scheduled Recurring Contribution'), @@ -833,7 +833,7 @@ public static function getRecurringFields() { 'contribution_recur_create_date' => ('Recurring Contribution Create Date'), 'contribution_recur_modified_date' => ('Recurring Contribution Modified Date'), 'contribution_recur_failure_retry_date' => ts('Failed Recurring Contribution Retry Date'), - ); + ]; } /** @@ -852,20 +852,20 @@ public static function getRecurringFields() { public static function updateOnNewPayment($recurringContributionID, $paymentStatus, $effectiveDate) { $effectiveDate = $effectiveDate ? date('Y-m-d', strtotime($effectiveDate)) : date('Y-m-d'); - if (!in_array($paymentStatus, array('Completed', 'Failed'))) { + if (!in_array($paymentStatus, ['Completed', 'Failed'])) { return; } - $params = array( + $params = [ 'id' => $recurringContributionID, - 'return' => array( + 'return' => [ 'contribution_status_id', 'next_sched_contribution_date', 'frequency_unit', 'frequency_interval', 'installments', 'failure_count', - ), - ); + ], + ]; $existing = civicrm_api3('ContributionRecur', 'getsingle', $params); @@ -907,7 +907,7 @@ protected static function isComplete($recurringContributionID, $installments) { 'SELECT count(*) FROM civicrm_contribution WHERE contribution_recur_id = %1 AND contribution_status_id = ' . CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed'), - array(1 => array($recurringContributionID, 'Integer')) + [1 => [$recurringContributionID, 'Integer']] ); if ($paidInstallments >= $installments) { return TRUE; @@ -925,14 +925,14 @@ protected static function isComplete($recurringContributionID, $installments) { * @return array */ public static function calculateRecurLineItems($recurId, $total_amount, $financial_type_id) { - $originalContribution = civicrm_api3('Contribution', 'getsingle', array( + $originalContribution = civicrm_api3('Contribution', 'getsingle', [ 'contribution_recur_id' => $recurId, 'contribution_test' => '', 'options' => ['limit' => 1], 'return' => ['id', 'financial_type_id'], - )); + ]); $lineItems = CRM_Price_BAO_LineItem::getLineItemsByContributionID($originalContribution['id']); - $lineSets = array(); + $lineSets = []; if (count($lineItems) == 1) { foreach ($lineItems as $index => $lineItem) { if ($lineItem['financial_type_id'] != $originalContribution['financial_type_id']) { @@ -989,7 +989,7 @@ public static function getInactiveStatuses() { * * @return array|bool */ - public static function buildOptions($fieldName, $context = NULL, $props = array()) { + public static function buildOptions($fieldName, $context = NULL, $props = []) { switch ($fieldName) { case 'payment_processor_id': diff --git a/CRM/Contribute/BAO/Premium.php b/CRM/Contribute/BAO/Premium.php index 16293827631e..f3fca06da77a 100644 --- a/CRM/Contribute/BAO/Premium.php +++ b/CRM/Contribute/BAO/Premium.php @@ -102,7 +102,7 @@ public static function del($premiumID) { * @param string $selectedOption */ public static function buildPremiumBlock(&$form, $pageID, $formItems = FALSE, $selectedProductID = NULL, $selectedOption = NULL) { - $form->add('hidden', "selectProduct", $selectedProductID, array('id' => 'selectProduct')); + $form->add('hidden', "selectProduct", $selectedProductID, ['id' => 'selectProduct']); $premiumDao = new CRM_Contribute_DAO_Premium(); $premiumDao->entity_table = 'civicrm_contribution_page'; @@ -111,7 +111,7 @@ public static function buildPremiumBlock(&$form, $pageID, $formItems = FALSE, $s if ($premiumDao->find(TRUE)) { $premiumID = $premiumDao->id; - $premiumBlock = array(); + $premiumBlock = []; CRM_Core_DAO::storeValues($premiumDao, $premiumBlock); CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($financialTypes, CRM_Core_Action::ADD); @@ -127,7 +127,7 @@ public static function buildPremiumBlock(&$form, $pageID, $formItems = FALSE, $s $premiumsProductDao->orderBy('weight'); $premiumsProductDao->find(); - $products = array(); + $products = []; while ($premiumsProductDao->fetch()) { $productDAO = new CRM_Contribute_DAO_Product(); $productDAO->id = $premiumsProductDao->product_id; @@ -148,7 +148,7 @@ public static function buildPremiumBlock(&$form, $pageID, $formItems = FALSE, $s CRM_Core_DAO::storeValues($productDAO, $products[$productDAO->id]); } } - $options = $temp = array(); + $options = $temp = []; $temp = explode(',', $productDAO->options); foreach ($temp as $value) { $options[trim($value)] = trim($value); @@ -188,7 +188,7 @@ public function buildPremiumPreviewBlock($form, $productID, $premiumProductID = } $radio[$productDAO->id] = $form->createElement('radio', NULL, NULL, NULL, $productDAO->id, NULL); - $options = $temp = array(); + $options = $temp = []; $temp = explode(',', $productDAO->options); foreach ($temp as $value) { $options[$value] = $value; @@ -218,10 +218,10 @@ public static function deletePremium($contributionPageID) { //need to delete entries from civicrm_premiums //as well as from civicrm_premiums_product, CRM-4586 - $params = array( + $params = [ 'entity_id' => $contributionPageID, 'entity_table' => 'civicrm_contribution_page', - ); + ]; $premium = new CRM_Contribute_DAO_Premium(); $premium->copyValues($params); @@ -245,7 +245,7 @@ public static function deletePremium($contributionPageID) { */ public static function getPremiumProductInfo() { if (!self::$productInfo) { - $products = $options = array(); + $products = $options = []; $dao = new CRM_Contribute_DAO_Product(); $dao->is_active = 1; @@ -262,7 +262,7 @@ public static function getPremiumProductInfo() { } } - self::$productInfo = array($products, $options); + self::$productInfo = [$products, $options]; } return self::$productInfo; } diff --git a/CRM/Contribute/BAO/Query.php b/CRM/Contribute/BAO/Query.php index 4be21cd7b788..d0af3c53fa11 100644 --- a/CRM/Contribute/BAO/Query.php +++ b/CRM/Contribute/BAO/Query.php @@ -157,21 +157,21 @@ public static function whereClauseSingle(&$values, &$query) { } // These are legacy names. // @todo enotices when these are hit so we can start to elimnate them. - $fieldAliases = array( + $fieldAliases = [ 'financial_type' => 'financial_type_id', 'contribution_page' => 'contribution_page_id', 'payment_instrument' => 'payment_instrument_id', // or payment_instrument_id? 'contribution_payment_instrument' => 'contribution_payment_instrument_id', 'contribution_status' => 'contribution_status_id', - ); + ]; $name = isset($fieldAliases[$name]) ? $fieldAliases[$name] : $name; $qillName = $name; if (in_array($name, $fieldAliases)) { $qillName = array_search($name, $fieldAliases); } - $pseudoExtraParam = array(); + $pseudoExtraParam = []; switch ($name) { case 'contribution_date': @@ -251,11 +251,11 @@ public static function whereClauseSingle(&$values, &$query) { case (strpos($name, '_date') !== FALSE && $name != 'contribution_fulfilled_date'): case 'contribution_campaign_id': - $fieldNamesNotToStripContributionFrom = array( + $fieldNamesNotToStripContributionFrom = [ 'contribution_currency_type', 'contribution_status_id', 'contribution_page_id', - ); + ]; // @todo these are mostly legacy params. Find a better way to deal with them. if (!in_array($name, $fieldNamesNotToStripContributionFrom) ) { @@ -264,9 +264,9 @@ public static function whereClauseSingle(&$values, &$query) { } $name = str_replace('contribution_', '', $name); } - if (in_array($name, array('contribution_currency', 'contribution_currency_type'))) { + if (in_array($name, ['contribution_currency', 'contribution_currency_type'])) { $qillName = $name = 'currency'; - $pseudoExtraParam = array('labelColumn' => 'name'); + $pseudoExtraParam = ['labelColumn' => 'name']; } $dataType = !empty($fields[$qillName]['type']) ? CRM_Utils_Type::typeToString($fields[$qillName]['type']) : 'String'; @@ -274,7 +274,7 @@ public static function whereClauseSingle(&$values, &$query) { $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_contribution.$name", $op, $value, $dataType); list($op, $value) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Contribute_DAO_Contribution', $name, $value, $op, $pseudoExtraParam); if (!($name == 'id' && $value == 0)) { - $query->_qill[$grouping][] = ts('%1 %2 %3', array(1 => $fields[$qillName]['title'], 2 => $op, 3 => $value)); + $query->_qill[$grouping][] = ts('%1 %2 %3', [1 => $fields[$qillName]['title'], 2 => $op, 3 => $value]); } $query->_tables['civicrm_contribution'] = $query->_whereTables['civicrm_contribution'] = 1; return; @@ -284,7 +284,7 @@ public static function whereClauseSingle(&$values, &$query) { $qillName = $name; if ($name == 'contribution_pcp_made_through_id') { $qillName = $name = 'pcp_id'; - $fields[$name] = array('title' => ts('Personal Campaign Page'), 'type' => 2); + $fields[$name] = ['title' => ts('Personal Campaign Page'), 'type' => 2]; } if ($name == 'contribution_soft_credit_type_id') { $qillName = str_replace('_id', '', $qillName); @@ -295,7 +295,7 @@ public static function whereClauseSingle(&$values, &$query) { $op, $value, CRM_Utils_Type::typeToString($fields[$qillName]['type']) ); list($op, $value) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Contribute_DAO_ContributionSoft', $name, $value, $op); - $query->_qill[$grouping][] = ts('%1 %2 %3', array(1 => $fields[$qillName]['title'], 2 => $op, 3 => $value)); + $query->_qill[$grouping][] = ts('%1 %2 %3', [1 => $fields[$qillName]['title'], 2 => $op, 3 => $value]); $query->_tables['civicrm_contribution_soft'] = $query->_whereTables['civicrm_contribution_soft'] = 1; return; @@ -371,12 +371,12 @@ public static function whereClauseSingle(&$values, &$query) { case 'contribution_recur_payment_processor_id': $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_contribution_recur.payment_processor_id", $op, $value, "String"); - $paymentProcessors = civicrm_api3('PaymentProcessor', 'get', array()); - $paymentProcessorNames = array(); + $paymentProcessors = civicrm_api3('PaymentProcessor', 'get', []); + $paymentProcessorNames = []; foreach ($value as $paymentProcessorId) { $paymentProcessorNames[] = $paymentProcessors['values'][$paymentProcessorId]['name']; } - $query->_qill[$grouping][] = ts("Recurring Contribution Payment Processor %1 %2", array(1 => $op, 2 => implode(', ', $paymentProcessorNames))); + $query->_qill[$grouping][] = ts("Recurring Contribution Payment Processor %1 %2", [1 => $op, 2 => implode(', ', $paymentProcessorNames)]); $query->_tables['civicrm_contribution_recur'] = $query->_whereTables['civicrm_contribution_recur'] = 1; return; @@ -387,7 +387,7 @@ public static function whereClauseSingle(&$values, &$query) { $op, $value, "String" ); $recurFields = CRM_Contribute_DAO_ContributionRecur::fields(); - $query->_qill[$grouping][] = ts("Recurring Contribution %1 %2 '%3'", array(1 => $recurFields[$fieldName]['title'], 2 => $op, 3 => $value)); + $query->_qill[$grouping][] = ts("Recurring Contribution %1 %2 '%3'", [1 => $recurFields[$fieldName]['title'], 2 => $op, 3 => $value]); $query->_tables['civicrm_contribution_recur'] = $query->_whereTables['civicrm_contribution_recur'] = 1; return; @@ -407,7 +407,7 @@ public static function whereClauseSingle(&$values, &$query) { case 'contribution_recur_contribution_status_id': $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_contribution_recur.contribution_status_id", $op, $value, 'String'); list($op, $value) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Contribute_DAO_ContributionRecur', 'contribution_status_id', $value, $op, $pseudoExtraParam); - $query->_qill[$grouping][] = ts("Recurring Contribution Status %1 '%2'", array(1 => $op, 2 => $value)); + $query->_qill[$grouping][] = ts("Recurring Contribution Status %1 '%2'", [1 => $op, 2 => $value]); $query->_tables['civicrm_contribution_recur'] = $query->_whereTables['civicrm_contribution_recur'] = 1; return; @@ -418,7 +418,7 @@ public static function whereClauseSingle(&$values, &$query) { $op = 'LIKE'; } $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause('civicrm_note.note', $op, $value, "String"); - $query->_qill[$grouping][] = ts('Contribution Note %1 %2', array(1 => $op, 2 => $quoteValue)); + $query->_qill[$grouping][] = ts('Contribution Note %1 %2', [1 => $op, 2 => $quoteValue]); $query->_tables['civicrm_contribution'] = $query->_whereTables['civicrm_contribution'] = $query->_whereTables['contribution_note'] = 1; return; @@ -446,7 +446,7 @@ public static function whereClauseSingle(&$values, &$query) { case 'contribution_batch_id': list($qillOp, $qillValue) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Batch_BAO_EntityBatch', 'batch_id', $value, $op); - $query->_qill[$grouping][] = ts('Batch Name %1 %2', array(1 => $qillOp, 2 => $qillValue)); + $query->_qill[$grouping][] = ts('Batch Name %1 %2', [1 => $qillOp, 2 => $qillValue]); $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause('civicrm_entity_batch.batch_id', $op, $value); $query->_tables['civicrm_contribution'] = $query->_whereTables['civicrm_contribution'] = 1; $query->_tables['civicrm_financial_trxn'] = $query->_whereTables['civicrm_financial_trxn'] = 1; @@ -457,7 +457,7 @@ public static function whereClauseSingle(&$values, &$query) { // CRM-16713 - contribution search by premiums on 'Find Contribution' form. $qillName = $name; list($operator, $productValue) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Contribute_DAO_Product', $name, $value, $op); - $query->_qill[$grouping][] = ts('%1 %2 %3', array(1 => $fields[$qillName]['title'], 2 => $operator, 3 => $productValue)); + $query->_qill[$grouping][] = ts('%1 %2 %3', [1 => $fields[$qillName]['title'], 2 => $operator, 3 => $productValue]); $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_product.id", $op, $value); $query->_tables['civicrm_product'] = $query->_whereTables['civicrm_product'] = 1; return; @@ -472,7 +472,7 @@ public static function whereClauseSingle(&$values, &$query) { $query->_tables['civicrm_financial_trxn'] = $query->_whereTables['civicrm_financial_trxn'] = 1; $query->_tables['civicrm_contribution'] = $query->_whereTables['civicrm_contribution'] = 1; list($op, $value) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Financial_DAO_FinancialTrxn', 'card_type_id', $value, $op); - $query->_qill[$grouping][] = ts('Card Type %1 %2', array(1 => $op, 2 => $value)); + $query->_qill[$grouping][] = ts('Card Type %1 %2', [1 => $op, 2 => $value]); return; case 'financial_trxn_pan_truncation': @@ -480,7 +480,7 @@ public static function whereClauseSingle(&$values, &$query) { $query->_tables['civicrm_financial_trxn'] = $query->_whereTables['civicrm_financial_trxn'] = 1; $query->_tables['civicrm_contribution'] = $query->_whereTables['civicrm_contribution'] = 1; list($op, $value) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Financial_DAO_FinancialTrxn', 'pan_truncation', $value, $op); - $query->_qill[$grouping][] = ts('Card Number %1 %2', array(1 => $op, 2 => $value)); + $query->_qill[$grouping][] = ts('Card Number %1 %2', [1 => $op, 2 => $value]); return; default: @@ -492,7 +492,7 @@ public static function whereClauseSingle(&$values, &$query) { // CRM-12597 CRM_Core_Session::setStatus(ts( 'We did not recognize the search field: %1. Please check and fix your contribution related smart groups.', - array(1 => $fldName) + [1 => $fldName] ) ); return; @@ -535,7 +535,7 @@ public static function from($name, $mode, $side) { switch ($name) { case 'civicrm_contribution': $from = " $side JOIN civicrm_contribution ON civicrm_contribution.contact_id = contact_a.id "; - if (in_array(self::$_contribOrSoftCredit, array("only_scredits", "both_related", "both"))) { + if (in_array(self::$_contribOrSoftCredit, ["only_scredits", "both_related", "both"])) { // switch the from table if its only soft credit search $from = " $side JOIN contribution_search_scredit_combined ON contribution_search_scredit_combined.contact_id = contact_a.id "; $from .= " $side JOIN civicrm_contribution ON civicrm_contribution.id = contribution_search_scredit_combined.id "; @@ -620,13 +620,13 @@ public static function from($name, $mode, $side) { break; case 'civicrm_contribution_soft': - if (!in_array(self::$_contribOrSoftCredit, array("only_scredits", "both_related", "both"))) { + if (!in_array(self::$_contribOrSoftCredit, ["only_scredits", "both_related", "both"])) { $from = " $side JOIN civicrm_contribution_soft ON civicrm_contribution_soft.contribution_id = civicrm_contribution.id"; } break; case 'civicrm_contribution_soft_contact': - if (in_array(self::$_contribOrSoftCredit, array("only_scredits", "both_related", "both"))) { + if (in_array(self::$_contribOrSoftCredit, ["only_scredits", "both_related", "both"])) { $from .= " $side JOIN civicrm_contact civicrm_contact_d ON (civicrm_contribution.contact_id = civicrm_contact_d.id ) AND contribution_search_scredit_combined.scredit_id IS NOT NULL"; } @@ -689,7 +689,7 @@ public static function initializeAnySoftCreditClause(&$query) { * * @return bool */ - public static function isSoftCreditOptionEnabled($queryParams = array()) { + public static function isSoftCreditOptionEnabled($queryParams = []) { static $tempTableFilled = FALSE; if (!empty($queryParams)) { foreach (array_keys($queryParams) as $id) { @@ -702,7 +702,7 @@ public static function isSoftCreditOptionEnabled($queryParams = array()) { } } if (in_array(self::$_contribOrSoftCredit, - array("only_scredits", "both_related", "both"))) { + ["only_scredits", "both_related", "both"])) { if (!$tempTableFilled) { // build a temp table which is union of contributions and soft credits // note: group-by in first part ensures uniqueness in counts @@ -731,11 +731,11 @@ public static function isSoftCreditOptionEnabled($queryParams = array()) { * @return array */ public static function softCreditReturnProperties($isExportMode = FALSE) { - $properties = array( + $properties = [ 'contribution_soft_credit_name' => 1, 'contribution_soft_credit_amount' => 1, 'contribution_soft_credit_type' => 1, - ); + ]; if ($isExportMode) { $properties['contribution_soft_credit_contact_id'] = 1; $properties['contribution_soft_credit_contribution_id'] = 1; @@ -753,7 +753,7 @@ public static function softCreditReturnProperties($isExportMode = FALSE) { * @return array */ public static function selectorReturnProperties($queryParams) { - $properties = array( + $properties = [ 'contact_type' => 1, 'contact_sub_type' => 1, 'sort_name' => 1, @@ -772,7 +772,7 @@ public static function selectorReturnProperties($queryParams) { 'currency' => 1, 'cancel_date' => 1, 'contribution_recur_id' => 1, - ); + ]; if (self::isSiteHasProducts()) { $properties['product_name'] = 1; $properties['contribution_product_id'] = 1; @@ -813,7 +813,7 @@ public static function isSiteHasProducts() { public static function defaultReturnProperties($mode, $includeCustomFields = TRUE) { $properties = NULL; if ($mode & CRM_Contact_BAO_Query::MODE_CONTRIBUTE) { - $properties = array( + $properties = [ // add 'contact_type' => 1, // fields @@ -887,7 +887,7 @@ public static function defaultReturnProperties($mode, $includeCustomFields = TRU 'contribution_campaign_id' => 1, // calling //function - ); + ]; if (self::isSiteHasProducts()) { $properties['fulfilled_date'] = 1; $properties['product_name'] = 1; @@ -927,56 +927,56 @@ public static function buildSearchForm(&$form) { // CRM-17602 // This hidden element added for displaying Date Range error correctly. Definitely a dirty hack, but... it works. $form->addElement('hidden', 'contribution_date_range_error'); - $form->addFormRule(array('CRM_Contribute_BAO_Query', 'formRule'), $form); + $form->addFormRule(['CRM_Contribute_BAO_Query', 'formRule'], $form); - $form->add('text', 'contribution_amount_low', ts('From'), array('size' => 8, 'maxlength' => 8)); - $form->addRule('contribution_amount_low', ts('Please enter a valid money value (e.g. %1).', array(1 => CRM_Utils_Money::format('9.99', ' '))), 'money'); + $form->add('text', 'contribution_amount_low', ts('From'), ['size' => 8, 'maxlength' => 8]); + $form->addRule('contribution_amount_low', ts('Please enter a valid money value (e.g. %1).', [1 => CRM_Utils_Money::format('9.99', ' ')]), 'money'); - $form->add('text', 'contribution_amount_high', ts('To'), array('size' => 8, 'maxlength' => 8)); - $form->addRule('contribution_amount_high', ts('Please enter a valid money value (e.g. %1).', array(1 => CRM_Utils_Money::format('99.99', ' '))), 'money'); + $form->add('text', 'contribution_amount_high', ts('To'), ['size' => 8, 'maxlength' => 8]); + $form->addRule('contribution_amount_high', ts('Please enter a valid money value (e.g. %1).', [1 => CRM_Utils_Money::format('99.99', ' ')]), 'money'); - $form->addField('cancel_reason', array('entity' => 'Contribution')); + $form->addField('cancel_reason', ['entity' => 'Contribution']); CRM_Core_Form_Date::buildDateRange($form, 'contribution_cancel_date', 1, '_low', '_high', ts('From:'), FALSE); $form->addElement('hidden', 'contribution_cancel_date_range_error'); // Adding select option for curreny type -- CRM-4711 $form->add('select', 'contribution_currency_type', ts('Currency Type'), - array( + [ '' => ts('- any -'), - ) + - CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'currency', array('labelColumn' => 'name')), - FALSE, array('class' => 'crm-select2') + ] + + CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'currency', ['labelColumn' => 'name']), + FALSE, ['class' => 'crm-select2'] ); // CRM-13848 CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($financialTypes, CRM_Core_Action::VIEW); $form->addSelect('financial_type_id', - array('entity' => 'contribution', 'multiple' => 'multiple', 'context' => 'search', 'options' => $financialTypes) + ['entity' => 'contribution', 'multiple' => 'multiple', 'context' => 'search', 'options' => $financialTypes] ); $form->add('select', 'contribution_page_id', ts('Contribution Page'), CRM_Contribute_PseudoConstant::contributionPage(), - FALSE, array('class' => 'crm-select2', 'multiple' => 'multiple', 'placeholder' => ts('- any -')) + FALSE, ['class' => 'crm-select2', 'multiple' => 'multiple', 'placeholder' => ts('- any -')] ); // use contribution_payment_instrument_id instead of payment_instrument_id // Contribution Edit form (pop-up on contribution/Contact(display Result as Contribution) open on search form), // then payment method change action not working properly because of same html ID present two time on one page $form->addSelect('contribution_payment_instrument_id', - array('entity' => 'contribution', 'field' => 'payment_instrument_id', 'multiple' => 'multiple', 'label' => ts('Payment Method'), 'option_url' => NULL, 'placeholder' => ts('- any -')) + ['entity' => 'contribution', 'field' => 'payment_instrument_id', 'multiple' => 'multiple', 'label' => ts('Payment Method'), 'option_url' => NULL, 'placeholder' => ts('- any -')] ); $form->add('select', 'contribution_pcp_made_through_id', ts('Personal Campaign Page'), - CRM_Contribute_PseudoConstant::pcPage(), FALSE, array('class' => 'crm-select2', 'multiple' => 'multiple', 'placeholder' => ts('- any -'))); + CRM_Contribute_PseudoConstant::pcPage(), FALSE, ['class' => 'crm-select2', 'multiple' => 'multiple', 'placeholder' => ts('- any -')]); $statusValues = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'contribution_status_id'); $form->add('select', 'contribution_status_id', ts('Contribution Status'), $statusValues, - FALSE, array('class' => 'crm-select2', 'multiple' => 'multiple') + FALSE, ['class' => 'crm-select2', 'multiple' => 'multiple'] ); // Add fields for thank you and receipt @@ -997,30 +997,30 @@ public static function buildSearchForm(&$form) { $form->addYesNo('contribution_pcp_display_in_roll', ts('Personal Campaign Page Honor Roll?'), TRUE); // Soft credit related fields - $options = array( + $options = [ 'only_contribs' => ts('Contributions Only'), 'only_scredits' => ts('Soft Credits Only'), 'both_related' => ts('Soft Credits with related Hard Credit'), 'both' => ts('Both'), - ); - $form->add('select', 'contribution_or_softcredits', ts('Contributions OR Soft Credits?'), $options, FALSE, array('class' => "crm-select2")); + ]; + $form->add('select', 'contribution_or_softcredits', ts('Contributions OR Soft Credits?'), $options, FALSE, ['class' => "crm-select2"]); $form->addSelect( 'contribution_soft_credit_type_id', - array( + [ 'entity' => 'contribution_soft', 'field' => 'soft_credit_type_id', 'multiple' => TRUE, 'context' => 'search', - ) + ] ); - $form->addField('financial_trxn_card_type_id', array('entity' => 'FinancialTrxn', 'name' => 'card_type_id', 'action' => 'get')); + $form->addField('financial_trxn_card_type_id', ['entity' => 'FinancialTrxn', 'name' => 'card_type_id', 'action' => 'get']); - $form->add('text', 'financial_trxn_pan_truncation', ts('Card Number'), array( + $form->add('text', 'financial_trxn_pan_truncation', ts('Card Number'), [ 'size' => 5, 'maxlength' => 4, 'autocomplete' => 'off', - )); + ]); if (CRM_Contribute_BAO_Query::isSiteHasProducts()) { // CRM-16713 - contribution search by premiums on 'Find Contribution' form. @@ -1035,7 +1035,7 @@ public static function buildSearchForm(&$form) { ); } - self::addCustomFormFields($form, array('Contribution')); + self::addCustomFormFields($form, ['Contribution']); CRM_Campaign_BAO_Campaign::addCampaignInComponentSearch($form, 'contribution_campaign_id'); @@ -1045,17 +1045,17 @@ public static function buildSearchForm(&$form) { if (!empty($batches)) { $form->add('select', 'contribution_batch_id', ts('Batch Name'), - array( + [ '' => ts('- any -'), // CRM-19325 'IS NULL' => ts('None'), - ) + $batches, - FALSE, array('class' => 'crm-select2') + ] + $batches, + FALSE, ['class' => 'crm-select2'] ); } $form->assign('validCiviContribute', TRUE); - $form->setDefaults(array('contribution_test' => 0)); + $form->setDefaults(['contribution_test' => 0]); CRM_Contribute_BAO_ContributionRecur::recurringContribution($form); } @@ -1070,7 +1070,7 @@ public static function buildSearchForm(&$form) { public static function tableNames(&$tables) { // Add contribution table if (!empty($tables['civicrm_product'])) { - $tables = array_merge(array('civicrm_contribution' => 1), $tables); + $tables = array_merge(['civicrm_contribution' => 1], $tables); } if (!empty($tables['civicrm_contribution_product']) && empty($tables['civicrm_product'])) { @@ -1118,7 +1118,7 @@ public static function buildDateWhere(&$values, $query, $name, $field, $title) { * @return bool|array */ public static function formRule($fields, $files, $form) { - $errors = array(); + $errors = []; if (!empty($fields['contribution_date_high']) && !empty($fields['contribution_date_low'])) { CRM_Utils_Rule::validDateRange($fields, 'contribution_date', $errors, ts('Date Received')); diff --git a/CRM/Contribute/BAO/Widget.php b/CRM/Contribute/BAO/Widget.php index 71d8361528c4..78535f2493f2 100644 --- a/CRM/Contribute/BAO/Widget.php +++ b/CRM/Contribute/BAO/Widget.php @@ -48,7 +48,7 @@ class CRM_Contribute_BAO_Widget extends CRM_Contribute_DAO_Widget { public static function getContributionPageData($contributionPageID, $widgetID, $includePending = FALSE) { $config = CRM_Core_Config::singleton(); - $data = array(); + $data = []; $data['currencySymbol'] = $config->defaultCurrencySymbol; if (empty($contributionPageID) || @@ -91,7 +91,7 @@ public static function getContributionPageData($contributionPageID, $widgetID, $ WHERE is_test = 0 AND contribution_status_id IN ({$status}) AND contribution_page_id = %1"; - $params = array(1 => array($contributionPageID, 'Integer')); + $params = [1 => [$contributionPageID, 'Integer']]; $dao = CRM_Core_DAO::executeQuery($query, $params); if ($dao->fetch()) { $data['num_donors'] = (int) $dao->count; @@ -107,7 +107,7 @@ public static function getContributionPageData($contributionPageID, $widgetID, $ SELECT goal_amount, start_date, end_date, is_active FROM civicrm_contribution_page WHERE id = %1"; - $params = array(1 => array($contributionPageID, 'Integer')); + $params = [1 => [$contributionPageID, 'Integer']]; $dao = CRM_Core_DAO::executeQuery($query, $params); $data['campaign_start'] = ''; @@ -131,9 +131,9 @@ public static function getContributionPageData($contributionPageID, $widgetID, $ $startDate >= $now ) { $data['is_active'] = FALSE; - $data['campaign_start'] = ts('Campaign starts on %1', array( + $data['campaign_start'] = ts('Campaign starts on %1', [ 1 => CRM_Utils_Date::customFormat($dao->start_date, $config->dateformatFull), - ) + ] ); } } @@ -145,23 +145,23 @@ public static function getContributionPageData($contributionPageID, $widgetID, $ ) { $data['is_active'] = FALSE; $data['campaign_start'] = ts('Campaign ended on %1', - array( + [ 1 => CRM_Utils_Date::customFormat($dao->end_date, $config->dateformatFull), - ) + ] ); } elseif ($startDate >= $now) { $data['campaign_start'] = ts('Campaign starts on %1', - array( + [ 1 => CRM_Utils_Date::customFormat($dao->start_date, $config->dateformatFull), - ) + ] ); } else { $data['campaign_start'] = ts('Campaign ends on %1', - array( + [ 1 => CRM_Utils_Date::customFormat($dao->end_date, $config->dateformatFull), - ) + ] ); } } @@ -179,13 +179,13 @@ public static function getContributionPageData($contributionPageID, $widgetID, $ $percent = $data['money_raised'] / $data['money_target']; $data['money_raised_percentage'] = (round($percent, 2)) * 100 . "%"; $data['money_target_display'] = CRM_Utils_Money::format($data['money_target']); - $data['money_raised'] = ts('Raised %1 of %2', array( + $data['money_raised'] = ts('Raised %1 of %2', [ 1 => CRM_Utils_Money::format($data['money_raised']), 2 => $data['money_target_display'], - )); + ]); } else { - $data['money_raised'] = ts('Raised %1', array(1 => CRM_Utils_Money::format($data['money_raised']))); + $data['money_raised'] = ts('Raised %1', [1 => CRM_Utils_Money::format($data['money_raised'])]); } $data['money_low'] = 0; @@ -195,7 +195,7 @@ public static function getContributionPageData($contributionPageID, $widgetID, $ // if is_active is false, show this link and hide the contribute button $data['homepage_link'] = $widget->url_homepage; - $data['colors'] = array(); + $data['colors'] = []; $data['colors']["title"] = $widget->color_title; $data['colors']["button"] = $widget->color_button; diff --git a/CRM/Contribute/Form.php b/CRM/Contribute/Form.php index 7beab54f86d7..745b0d7c66cb 100644 --- a/CRM/Contribute/Form.php +++ b/CRM/Contribute/Form.php @@ -42,10 +42,10 @@ class CRM_Contribute_Form extends CRM_Admin_Form { * @return array */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; if (isset($this->_id)) { - $params = array('id' => $this->_id); + $params = ['id' => $this->_id]; if (!empty($this->_BAOName)) { $baoName = $this->_BAOName; $baoName::retrieve($params, $defaults); diff --git a/CRM/Contribute/Form/AbstractEditPayment.php b/CRM/Contribute/Form/AbstractEditPayment.php index 3ee23fd7d983..70b4860aed48 100644 --- a/CRM/Contribute/Form/AbstractEditPayment.php +++ b/CRM/Contribute/Form/AbstractEditPayment.php @@ -55,7 +55,7 @@ class CRM_Contribute_Form_AbstractEditPayment extends CRM_Contact_Form_Task { public $_bltID; - public $_fields = array(); + public $_fields = []; /** * @var array current payment processor including a copy of the object in 'object' key @@ -67,7 +67,7 @@ class CRM_Contribute_Form_AbstractEditPayment extends CRM_Contact_Form_Task { * * @var array */ - public $_recurPaymentProcessors = array(); + public $_recurPaymentProcessors = []; /** * Array of processor options in the format id => array($id => $label) @@ -82,7 +82,7 @@ class CRM_Contribute_Form_AbstractEditPayment extends CRM_Contact_Form_Task { * Available payment processors with full details including the key 'object' indexed by their id * @var array */ - protected $_paymentProcessors = array(); + protected $_paymentProcessors = []; /** * Instance of the payment processor object. @@ -229,7 +229,7 @@ class CRM_Contribute_Form_AbstractEditPayment extends CRM_Contact_Form_Task { * such that both the fields and the order can be more easily altered by payment processors & other extensions * @var array */ - public $billingFieldSets = array(); + public $billingFieldSets = []; /** * Monetary fields that may be submitted. @@ -246,10 +246,10 @@ class CRM_Contribute_Form_AbstractEditPayment extends CRM_Contact_Form_Task { public function preProcess() { $this->_contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this); if (empty($this->_contactID) && !empty($this->_id) && $this->entity) { - $this->_contactID = civicrm_api3($this->entity, 'getvalue', array('id' => $this->_id, 'return' => 'contact_id')); + $this->_contactID = civicrm_api3($this->entity, 'getvalue', ['id' => $this->_id, 'return' => 'contact_id']); } $this->assign('contactID', $this->_contactID); - CRM_Core_Resources::singleton()->addVars('coreForm', array('contact_id' => (int) $this->_contactID)); + CRM_Core_Resources::singleton()->addVars('coreForm', ['contact_id' => (int) $this->_contactID]); $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, 'add'); $this->_mode = empty($this->_mode) ? CRM_Utils_Request::retrieve('mode', 'Alphanumeric', $this) : $this->_mode; $this->assign('isBackOffice', $this->isBackOffice); @@ -267,7 +267,7 @@ public function showRecordLinkMesssage($id) { $recordPaymentLink = CRM_Utils_System::url('civicrm/payment', "reset=1&id={$pid}&cid={$this->_contactID}&action=add&component=event" ); - CRM_Core_Session::setStatus(ts('Please use the Record Payment form if you have received an additional payment for this Partially paid contribution record.', array(1 => $recordPaymentLink)), ts('Notice'), 'alert'); + CRM_Core_Session::setStatus(ts('Please use the Record Payment form if you have received an additional payment for this Partially paid contribution record.', [1 => $recordPaymentLink]), ts('Notice'), 'alert'); } } } @@ -277,8 +277,8 @@ public function showRecordLinkMesssage($id) { * @param $values */ public function buildValuesAndAssignOnline_Note_Type($id, &$values) { - $ids = array(); - $params = array('id' => $id); + $ids = []; + $params = ['id' => $id]; CRM_Contribute_BAO_Contribution::getValues($params, $values, $ids); //Check if this is an online transaction (financial_trxn.payment_processor_id NOT NULL) @@ -348,7 +348,7 @@ public function assignPremiumProduct($id) { * @throws Exception */ public function getValidProcessors() { - $capabilities = array('BackOffice'); + $capabilities = ['BackOffice']; if ($this->_mode) { $capabilities[] = (ucfirst($this->_mode) . 'Mode'); } @@ -363,7 +363,7 @@ public function getValidProcessors() { public function assignProcessors() { //ensure that processor has a valid config //only valid processors get display to user - $this->assign('processorSupportsFutureStartDate', CRM_Financial_BAO_PaymentProcessor::hasPaymentProcessorSupporting(array('FutureRecurStartDate'))); + $this->assign('processorSupportsFutureStartDate', CRM_Financial_BAO_PaymentProcessor::hasPaymentProcessorSupporting(['FutureRecurStartDate'])); $this->_paymentProcessors = $this->getValidProcessors(); if (!isset($this->_paymentProcessor['id'])) { // if the payment processor isn't set yet (as indicated by the presence of an id,) we'll grab the first one which should be the default @@ -372,15 +372,15 @@ public function assignProcessors() { if (!$this->_mode) { $this->_paymentProcessor = $this->_paymentProcessors[0]; } - elseif (empty($this->_paymentProcessors) || array_keys($this->_paymentProcessors) === array(0)) { - throw new CRM_Core_Exception(ts('You will need to configure the %1 settings for your Payment Processor before you can submit a credit card transactions.', array(1 => $this->_mode))); + elseif (empty($this->_paymentProcessors) || array_keys($this->_paymentProcessors) === [0]) { + throw new CRM_Core_Exception(ts('You will need to configure the %1 settings for your Payment Processor before you can submit a credit card transactions.', [1 => $this->_mode])); } //Assign submitted processor value if it is different from the loaded one. if (!empty($this->_submitValues['payment_processor_id']) && $this->_paymentProcessor['id'] != $this->_submitValues['payment_processor_id']) { $this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($this->_submitValues['payment_processor_id']); } - $this->_processors = array(); + $this->_processors = []; foreach ($this->_paymentProcessors as $id => $processor) { // @todo review this. The inclusion of this IF was to address test processors being incorrectly loaded. // However the function $this->getValidProcessors() is expected to only return the processors relevant @@ -416,7 +416,7 @@ public function assignProcessors() { * * @return string */ - public function getCurrency($submittedValues = array()) { + public function getCurrency($submittedValues = []) { $config = CRM_Core_Config::singleton(); $currentCurrency = CRM_Utils_Array::value('currency', @@ -434,9 +434,9 @@ public function getCurrency($submittedValues = array()) { public function preProcessPledge() { //get the payment values associated with given pledge payment id OR check for payments due. - $this->_pledgeValues = array(); + $this->_pledgeValues = []; if ($this->_ppID) { - $payParams = array('id' => $this->_ppID); + $payParams = ['id' => $this->_ppID]; CRM_Pledge_BAO_PledgePayment::retrieve($payParams, $this->_pledgeValues['pledgePayment']); $this->_pledgeID = CRM_Utils_Array::value('pledge_id', $this->_pledgeValues['pledgePayment']); @@ -451,8 +451,8 @@ public function preProcessPledge() { //get the pledge values associated with given pledge payment. - $ids = array(); - $pledgeParams = array('id' => $this->_pledgeID); + $ids = []; + $pledgeParams = ['id' => $this->_pledgeID]; CRM_Pledge_BAO_Pledge::getValues($pledgeParams, $this->_pledgeValues, $ids); $this->assign('ppID', $this->_ppID); } @@ -481,7 +481,7 @@ public function preProcessPledge() { $pledgeTab = CRM_Utils_System::url('civicrm/contact/view', "reset=1&force=1&cid={$this->_contactID}&selectedChild=pledge" ); - CRM_Core_Session::setStatus(ts('This contact has pending or overdue pledge payments. Click here to view their Pledges tab and verify whether this contribution should be applied as a pledge payment.', array(1 => $pledgeTab)), ts('Notice'), 'alert'); + CRM_Core_Session::setStatus(ts('This contact has pending or overdue pledge payments. Click here to view their Pledges tab and verify whether this contribution should be applied as a pledge payment.', [1 => $pledgeTab]), ts('Notice'), 'alert'); } elseif ($paymentsDue) { // Show user link to oldest Pending or Overdue pledge payment @@ -497,11 +497,11 @@ public function preProcessPledge() { "reset=1&action=add&cid={$this->_contactID}&ppid={$payments['id']}&context=pledge" ); } - CRM_Core_Session::setStatus(ts('This contact has a pending or overdue pledge payment of %2 which is scheduled for %3. Click here to enter a pledge payment.', array( + CRM_Core_Session::setStatus(ts('This contact has a pending or overdue pledge payment of %2 which is scheduled for %3. Click here to enter a pledge payment.', [ 1 => $ppUrl, 2 => $ppAmountDue, 3 => $ppSchedDate, - )), ts('Notice'), 'alert'); + ]), ts('Notice'), 'alert'); } } } @@ -515,7 +515,7 @@ public function preProcessPledge() { */ public function unsetCreditCardFields($submittedValues) { //Offline Contribution. - $unsetParams = array( + $unsetParams = [ 'payment_processor_id', "email-{$this->_bltID}", 'hidden_buildCreditCard', @@ -532,7 +532,7 @@ public function unsetCreditCardFields($submittedValues) { 'cvv2', 'credit_card_exp_date', 'credit_card_type', - ); + ]; foreach ($unsetParams as $key) { if (isset($submittedValues[$key])) { unset($submittedValues[$key]); @@ -621,7 +621,7 @@ public static function formatCreditCardDetails(&$params) { * for pay later. */ protected function processBillingAddress() { - $fields = array(); + $fields = []; $fields['email-Primary'] = 1; $this->_params['email-5'] = $this->_params['email-Primary'] = $this->_contributorEmail; @@ -712,14 +712,14 @@ protected function addPaymentProcessorSelect($isRequired, $isBuildRecurBlock = F if (!$this->_mode) { return; } - $js = ($isBuildRecurBlock ? array('onChange' => "buildRecurBlock( this.value ); return false;") : NULL); + $js = ($isBuildRecurBlock ? ['onChange' => "buildRecurBlock( this.value ); return false;"] : NULL); if ($isBuildAutoRenewBlock) { - $js = array('onChange' => "buildAutoRenew( null, this.value, '{$this->_mode}');"); + $js = ['onChange' => "buildAutoRenew( null, this.value, '{$this->_mode}');"]; } $element = $this->add('select', 'payment_processor_id', ts('Payment Processor'), - array_diff_key($this->_processors, array(0 => 1)), + array_diff_key($this->_processors, [0 => 1]), $isRequired, $js ); diff --git a/CRM/Contribute/Form/AdditionalInfo.php b/CRM/Contribute/Form/AdditionalInfo.php index 8eedeaa8d998..eb68ed514c4c 100644 --- a/CRM/Contribute/Form/AdditionalInfo.php +++ b/CRM/Contribute/Form/AdditionalInfo.php @@ -46,12 +46,12 @@ class CRM_Contribute_Form_AdditionalInfo { public static function buildPremium(&$form) { //premium section $form->add('hidden', 'hidden_Premium', 1); - $sel1 = $sel2 = array(); + $sel1 = $sel2 = []; $dao = new CRM_Contribute_DAO_Product(); $dao->is_active = 1; $dao->find(); - $min_amount = array(); + $min_amount = []; $sel1[0] = ts('-select product-'); while ($dao->fetch()) { $sel1[$dao->id] = $dao->name . " ( " . $dao->sku . " )"; @@ -77,11 +77,11 @@ public static function buildPremium(&$form) { } } - $sel->setOptions(array($sel1, $sel2)); + $sel->setOptions([$sel1, $sel2]); $js .= "\n"; $form->assign('initHideBoxes', $js); - $form->add('datepicker', 'fulfilled_date', ts('Fulfilled'), [], FALSE, array('time' => FALSE)); + $form->add('datepicker', 'fulfilled_date', ts('Fulfilled'), [], FALSE, ['time' => FALSE]); $form->addElement('text', 'min_amount', ts('Minimum Contribution Amount')); } @@ -96,7 +96,7 @@ public static function buildAdditionalDetail(&$form) { $attributes = CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Contribution'); - $form->addField('thankyou_date', array('entity' => 'contribution'), FALSE, FALSE); + $form->addField('thankyou_date', ['entity' => 'contribution'], FALSE, FALSE); // add various amounts $nonDeductAmount = &$form->add('text', 'non_deductible_amount', ts('Non-deductible Amount'), @@ -125,7 +125,7 @@ public static function buildAdditionalDetail(&$form) { $form->addRule('invoice_id', ts('This Invoice ID already exists in the database.'), 'objectExists', - array('CRM_Contribute_DAO_Contribution', $form->_id, 'invoice_id') + ['CRM_Contribute_DAO_Contribution', $form->_id, 'invoice_id'] ); } $element = $form->add('text', 'creditnote_id', ts('Credit Note ID'), @@ -138,19 +138,19 @@ public static function buildAdditionalDetail(&$form) { $form->addRule('creditnote_id', ts('This Credit Note ID already exists in the database.'), 'objectExists', - array('CRM_Contribute_DAO_Contribution', $form->_id, 'creditnote_id') + ['CRM_Contribute_DAO_Contribution', $form->_id, 'creditnote_id'] ); } $form->add('select', 'contribution_page_id', ts('Online Contribution Page'), - array( + [ '' => ts('- select -'), - ) + + ] + CRM_Contribute_PseudoConstant::contributionPage() ); - $form->add('textarea', 'note', ts('Notes'), array("rows" => 4, "cols" => 60)); + $form->add('textarea', 'note', ts('Notes'), ["rows" => 4, "cols" => 60]); $statusName = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name'); if ($form->_id && $form->_values['contribution_status_id'] == array_search('Cancelled', $statusName)) { @@ -169,11 +169,11 @@ public static function buildAdditionalDetail(&$form) { public static function buildPaymentReminders(&$form) { //PaymentReminders section $form->add('hidden', 'hidden_PaymentReminders', 1); - $form->add('text', 'initial_reminder_day', ts('Send Initial Reminder'), array('size' => 3)); + $form->add('text', 'initial_reminder_day', ts('Send Initial Reminder'), ['size' => 3]); $form->addRule('initial_reminder_day', ts('Please enter a valid reminder day.'), 'positiveInteger'); - $form->add('text', 'max_reminders', ts('Send up to'), array('size' => 3)); + $form->add('text', 'max_reminders', ts('Send up to'), ['size' => 3]); $form->addRule('max_reminders', ts('Please enter a valid No. of reminders.'), 'positiveInteger'); - $form->add('text', 'additional_reminder_day', ts('Send additional reminders'), array('size' => 3)); + $form->add('text', 'additional_reminder_day', ts('Send additional reminders'), ['size' => 3]); $form->addRule('additional_reminder_day', ts('Please enter a valid additional reminder day.'), 'positiveInteger'); } @@ -185,7 +185,7 @@ public static function buildPaymentReminders(&$form) { * @param int $premiumID * @param array $options */ - public static function processPremium($params, $contributionID, $premiumID = NULL, $options = array()) { + public static function processPremium($params, $contributionID, $premiumID = NULL, $options = []) { $selectedProductID = $params['product_name'][0]; $selectedProductOptionID = CRM_Utils_Array::value(1, $params['product_name']); @@ -196,11 +196,11 @@ public static function processPremium($params, $contributionID, $premiumID = NUL $isDeleted = FALSE; //CRM-11106 - $premiumParams = array( + $premiumParams = [ 'id' => $selectedProductID, - ); + ]; - $productDetails = array(); + $productDetails = []; CRM_Contribute_BAO_Product::retrieve($premiumParams, $productDetails); $dao->financial_type_id = CRM_Utils_Array::value('financial_type_id', $productDetails); if (!empty($options[$selectedProductID])) { @@ -222,12 +222,12 @@ public static function processPremium($params, $contributionID, $premiumID = NUL $dao->save(); //CRM-11106 if ($premiumID == NULL || $isDeleted) { - $premiumParams = array( + $premiumParams = [ 'cost' => CRM_Utils_Array::value('cost', $productDetails), 'currency' => CRM_Utils_Array::value('currency', $productDetails), 'financial_type_id' => CRM_Utils_Array::value('financial_type_id', $productDetails), 'contributionId' => $contributionID, - ); + ]; if ($isDeleted) { $premiumParams['oldPremium']['product_id'] = $ContributionProduct->product_id; $premiumParams['oldPremium']['contribution_id'] = $ContributionProduct->contribution_id; @@ -251,15 +251,15 @@ public static function processNote($params, $contactID, $contributionID, $contri return; } //process note - $noteParams = array( + $noteParams = [ 'entity_table' => 'civicrm_contribution', 'note' => $params['note'], 'entity_id' => $contributionID, 'contact_id' => $contactID, - ); - $noteID = array(); + ]; + $noteID = []; if ($contributionNoteID) { - $noteID = array("id" => $contributionNoteID); + $noteID = ["id" => $contributionNoteID]; $noteParams['note'] = $noteParams['note'] ? $noteParams['note'] : "null"; } CRM_Core_BAO_Note::add($noteParams, $noteID); @@ -273,7 +273,7 @@ public static function processNote($params, $contactID, $contributionID, $contri * @param CRM_Core_Form $form */ public static function postProcessCommon(&$params, &$formatted, &$form) { - $fields = array( + $fields = [ 'non_deductible_amount', 'total_amount', 'fee_amount', @@ -282,7 +282,7 @@ public static function postProcessCommon(&$params, &$formatted, &$form) { 'creditnote_id', 'campaign_id', 'contribution_page_id', - ); + ]; foreach ($fields as $f) { $formatted[$f] = CRM_Utils_Array::value($f, $params); } @@ -339,12 +339,12 @@ public static function emailReceipt(&$form, &$params, $ccContribution = FALSE) { // retrieve individual prefix value for honoree if (isset($params['soft_credit'])) { - $softCreditTypes = $softCredits = array(); + $softCreditTypes = $softCredits = []; foreach ($params['soft_credit'] as $key => $softCredit) { - $softCredits[$key] = array( + $softCredits[$key] = [ 'Name' => $softCredit['contact_name'], 'Amount' => CRM_Utils_Money::format($softCredit['amount'], $softCredit['currency']), - ); + ]; $softCreditTypes[$key] = $softCredit['soft_credit_type_label']; } $form->assign('softCreditTypes', $softCreditTypes); @@ -408,16 +408,16 @@ public static function emailReceipt(&$form, &$params, $ccContribution = FALSE) { //handle custom data if (!empty($params['hidden_custom'])) { - $contribParams = array(array('contribution_id', '=', $params['contribution_id'], 0, 0)); + $contribParams = [['contribution_id', '=', $params['contribution_id'], 0, 0]]; if ($form->_mode == 'test') { - $contribParams[] = array('contribution_test', '=', 1, 0, 0); + $contribParams[] = ['contribution_test', '=', 1, 0, 0]; } //retrieve custom data - $customGroup = array(); + $customGroup = []; foreach ($form->_groupTree as $groupID => $group) { - $customFields = $customValues = array(); + $customFields = $customValues = []; if ($groupID == 'info') { continue; } @@ -462,7 +462,7 @@ public static function emailReceipt(&$form, &$params, $ccContribution = FALSE) { } list($sendReceipt, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate( - array( + [ 'groupName' => 'msg_tpl_workflow_contribution', 'valueName' => 'contribution_offline_receipt', 'contactId' => $params['contact_id'], @@ -473,7 +473,7 @@ public static function emailReceipt(&$form, &$params, $ccContribution = FALSE) { 'isTest' => $form->_mode == 'test', 'PDFFilename' => ts('receipt') . '.pdf', 'isEmailPdf' => $isEmailPdf, - ) + ] ); return $sendReceipt; diff --git a/CRM/Contribute/Form/AdditionalPayment.php b/CRM/Contribute/Form/AdditionalPayment.php index 93cb1e0ee9a7..84c7d7ba77eb 100644 --- a/CRM/Contribute/Form/AdditionalPayment.php +++ b/CRM/Contribute/Form/AdditionalPayment.php @@ -160,7 +160,7 @@ public function setDefaultValues() { if ($this->_view == 'transaction' && ($this->_action & CRM_Core_Action::BROWSE)) { return NULL; } - $defaults = array(); + $defaults = []; if ($this->_mode) { CRM_Core_Payment_Form::setDefaultValues($this, $this->_contactId); $defaults = array_merge($defaults, $this->_defaults); @@ -187,14 +187,14 @@ public function setDefaultValues() { */ public function buildQuickForm() { if ($this->_view == 'transaction' && ($this->_action & CRM_Core_Action::BROWSE)) { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'cancel', 'name' => ts('Done'), 'spacing' => '         ', 'isDefault' => TRUE, - ), - ) + ], + ] ); return; } @@ -220,7 +220,7 @@ public function buildQuickForm() { $this->add('textarea', 'receipt_text', ts('Confirmation Message')); $dateLabel = ($this->_refund) ? ts('Refund Date') : ts('Date Received'); - $this->addField('trxn_date', array('entity' => 'FinancialTrxn', 'label' => $dateLabel, 'context' => 'Contribution'), FALSE, FALSE); + $this->addField('trxn_date', ['entity' => 'FinancialTrxn', 'label' => $dateLabel, 'context' => 'Contribution'], FALSE, FALSE); if ($this->_contactId && $this->_id) { if ($this->_component == 'event') { @@ -237,17 +237,17 @@ public function buildQuickForm() { $js = NULL; // render backoffice payment fields only on offline mode if (!$this->_mode) { - $js = array('onclick' => "return verify( );"); + $js = ['onclick' => "return verify( );"]; $this->add('select', 'payment_instrument_id', ts('Payment Method'), - array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(), + ['' => ts('- select -')] + CRM_Contribute_PseudoConstant::paymentInstrument(), TRUE, - array('onChange' => "return showHideByValue('payment_instrument_id','4','checkNumber','table-row','select',false);") + ['onChange' => "return showHideByValue('payment_instrument_id','4','checkNumber','table-row','select',false);"] ); $this->add('text', 'check_number', ts('Check Number'), $attributes['financial_trxn_check_number']); - $this->add('text', 'trxn_id', ts('Transaction ID'), array('class' => 'twelve') + $attributes['trxn_id']); + $this->add('text', 'trxn_id', ts('Transaction ID'), ['class' => 'twelve'] + $attributes['trxn_id']); $this->add('text', 'fee_amount', ts('Fee Amount'), $attributes['fee_amount'] @@ -261,23 +261,23 @@ public function buildQuickForm() { } $buttonName = $this->_refund ? 'Record Refund' : 'Record Payment'; - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'upload', - 'name' => ts('%1', array(1 => $buttonName)), + 'name' => ts('%1', [1 => $buttonName]), 'js' => $js, 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); $mailingInfo = Civi::settings()->get('mailing_backend'); $this->assign('outBound_option', $mailingInfo['outBound_option']); - $this->addFormRule(array('CRM_Contribute_Form_AdditionalPayment', 'formRule'), $this); + $this->addFormRule(['CRM_Contribute_Form_AdditionalPayment', 'formRule'], $this); } /** @@ -288,7 +288,7 @@ public function buildQuickForm() { * @return array */ public static function formRule($fields, $files, $self) { - $errors = array(); + $errors = []; if ($self->_paymentType == 'owed' && $fields['total_amount'] > $self->_owed) { $errors['total_amount'] = ts('Payment amount cannot be greater than owed amount'); } @@ -338,16 +338,16 @@ public function submit($submittedValues) { } $contributionStatuses = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'contribution_status_id', - array('labelColumn' => 'name') + ['labelColumn' => 'name'] ); $contributionStatusID = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $this->_contributionId, 'contribution_status_id'); if ($contributionStatuses[$contributionStatusID] == 'Pending') { civicrm_api3('Contribution', 'create', - array( + [ 'id' => $this->_contributionId, 'contribution_status_id' => array_search('Partially paid', $contributionStatuses), 'is_pay_later' => 0, - ) + ] ); } @@ -357,25 +357,25 @@ public function submit($submittedValues) { $this->processCreditCard(); } - $defaults = array(); - $contribution = civicrm_api3('Contribution', 'getsingle', array( - 'return' => array("contribution_status_id"), + $defaults = []; + $contribution = civicrm_api3('Contribution', 'getsingle', [ + 'return' => ["contribution_status_id"], 'id' => $this->_contributionId, - )); + ]); $contributionStatusId = CRM_Utils_Array::value('contribution_status_id', $contribution); $result = CRM_Contribute_BAO_Contribution::recordAdditionalPayment($this->_contributionId, $this->_params, $this->_paymentType, $participantId); // Fetch the contribution & do proportional line item assignment - $params = array('id' => $this->_contributionId); + $params = ['id' => $this->_contributionId]; $contribution = CRM_Contribute_BAO_Contribution::retrieve($params, $defaults, $params); - CRM_Contribute_BAO_Contribution::addPayments(array($contribution), $contributionStatusId); + CRM_Contribute_BAO_Contribution::addPayments([$contribution], $contributionStatusId); if ($this->_contributionId && CRM_Core_Permission::access('CiviMember')) { - $membershipPaymentCount = civicrm_api3('MembershipPayment', 'getCount', array('contribution_id' => $this->_contributionId)); + $membershipPaymentCount = civicrm_api3('MembershipPayment', 'getCount', ['contribution_id' => $this->_contributionId]); if ($membershipPaymentCount) { $this->ajaxResponse['updateTabs']['#tab_member'] = CRM_Contact_BAO_Contact::getCountComponent('membership', $this->_contactID); } } if ($this->_contributionId && CRM_Core_Permission::access('CiviEvent')) { - $participantPaymentCount = civicrm_api3('ParticipantPayment', 'getCount', array('contribution_id' => $this->_contributionId)); + $participantPaymentCount = civicrm_api3('ParticipantPayment', 'getCount', ['contribution_id' => $this->_contributionId]); if ($participantPaymentCount) { $this->ajaxResponse['updateTabs']['#tab_participant'] = CRM_Contact_BAO_Contact::getCountComponent('participant', $this->_contactID); } @@ -398,7 +398,7 @@ public function processCreditCard() { $session = CRM_Core_Session::singleton(); $now = date('YmdHis'); - $fields = array(); + $fields = []; // we need to retrieve email address if ($this->_context == 'standalone' && !empty($this->_params['is_email_receipt'])) { @@ -491,7 +491,7 @@ public function processCreditCard() { $userSortName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $userID, 'sort_name' ); - $this->_params['source'] = ts('Submit Credit Card Payment by: %1', array(1 => $userSortName)); + $this->_params['source'] = ts('Submit Credit Card Payment by: %1', [1 => $userSortName]); } } @@ -539,7 +539,7 @@ public function testSubmit($params, $creditCardMode = NULL, $entityType = 'contr $this->_mode = $creditCardMode; } - $this->_fields = array(); + $this->_fields = []; $this->set('cid', $this->_contactId); parent::preProcess(); $this->submit($params); diff --git a/CRM/Contribute/Form/CancelSubscription.php b/CRM/Contribute/Form/CancelSubscription.php index 1ac38e03e3ea..ce98fbb513d7 100644 --- a/CRM/Contribute/Form/CancelSubscription.php +++ b/CRM/Contribute/Form/CancelSubscription.php @@ -123,7 +123,7 @@ public function buildQuickForm() { // Determine if we can cancel recurring contribution via API with this processor $cancelSupported = $this->_paymentProcessorObj->supports('CancelRecurring'); if ($cancelSupported) { - $searchRange = array(); + $searchRange = []; $searchRange[] = $this->createElement('radio', NULL, NULL, ts('Yes'), '1'); $searchRange[] = $this->createElement('radio', NULL, NULL, ts('No'), '0'); @@ -131,7 +131,7 @@ public function buildQuickForm() { $searchRange, 'send_cancel_request', ts('Send cancellation request to %1 ?', - array(1 => $this->_paymentProcessorObj->_processorName)) + [1 => $this->_paymentProcessorObj->_processorName]) ); } $this->assign('cancelSupported', $cancelSupported); @@ -151,18 +151,18 @@ public function buildQuickForm() { $type = 'submit'; } - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => $type, 'name' => $cancelButton, 'spacing' => '         ', 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Not Now'), - ), - ) + ], + ] ); } @@ -173,10 +173,10 @@ public function buildQuickForm() { * array of default values */ public function setDefaultValues() { - return array( + return [ 'is_notify' => 1, 'send_cancel_request' => 1, - ); + ]; } /** @@ -199,7 +199,7 @@ public function postProcess() { } if (CRM_Utils_Array::value('send_cancel_request', $params) == 1) { - $cancelParams = array('subscriptionId' => $this->_subscriptionDetails->subscription_id); + $cancelParams = ['subscriptionId' => $this->_subscriptionDetails->subscription_id]; $cancelSubscription = $this->_paymentProcessorObj->cancelSubscription($message, $cancelParams); } @@ -208,26 +208,26 @@ public function postProcess() { } elseif ($cancelSubscription) { $activityParams - = array( + = [ 'subject' => $this->_mid ? ts('Auto-renewal membership cancelled') : ts('Recurring contribution cancelled'), 'details' => $message, - ); + ]; $cancelStatus = CRM_Contribute_BAO_ContributionRecur::cancelRecurContribution( $this->_subscriptionDetails->recur_id, $activityParams ); if ($cancelStatus) { - $tplParams = array(); + $tplParams = []; if ($this->_mid) { - $inputParams = array('id' => $this->_mid); + $inputParams = ['id' => $this->_mid]; CRM_Member_BAO_Membership::getValues($inputParams, $tplParams); $tplParams = $tplParams[$this->_mid]; $tplParams['membership_status'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipStatus', $tplParams['status_id']); $tplParams['membershipType'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $tplParams['membership_type_id']); - $status = ts('The automatic renewal of your %1 membership has been cancelled as requested. This does not affect the status of your membership - you will receive a separate notification when your membership is up for renewal.', array(1 => $tplParams['membershipType'])); + $status = ts('The automatic renewal of your %1 membership has been cancelled as requested. This does not affect the status of your membership - you will receive a separate notification when your membership is up for renewal.', [1 => $tplParams['membershipType']]); $msgTitle = 'Membership Renewal Cancelled'; $msgType = 'info'; } @@ -235,13 +235,13 @@ public function postProcess() { $tplParams['recur_frequency_interval'] = $this->_subscriptionDetails->frequency_interval; $tplParams['recur_frequency_unit'] = $this->_subscriptionDetails->frequency_unit; $tplParams['amount'] = $this->_subscriptionDetails->amount; - $tplParams['contact'] = array('display_name' => $this->_donorDisplayName); + $tplParams['contact'] = ['display_name' => $this->_donorDisplayName]; $status = ts('The recurring contribution of %1, every %2 %3 has been cancelled.', - array( + [ 1 => $this->_subscriptionDetails->amount, 2 => $this->_subscriptionDetails->frequency_interval, 3 => $this->_subscriptionDetails->frequency_unit, - ) + ] ); $msgTitle = 'Contribution Cancelled'; $msgType = 'success'; @@ -254,7 +254,7 @@ public function postProcess() { 'id', $this->_subscriptionDetails->contribution_page_id, $value, - array('title', 'receipt_from_name', 'receipt_from_email') + ['title', 'receipt_from_name', 'receipt_from_email'] ); $receiptFrom = '"' . CRM_Utils_Array::value('receipt_from_name', $value[$this->_subscriptionDetails->contribution_page_id]) . @@ -269,7 +269,7 @@ public function postProcess() { // send notification $sendTemplateParams - = array( + = [ 'groupName' => $this->_mode == 'auto_renew' ? 'msg_tpl_workflow_membership' : 'msg_tpl_workflow_contribution', 'valueName' => $this->_mode == 'auto_renew' ? 'membership_autorenew_cancelled' : 'contribution_recurring_cancelled', 'contactId' => $this->_subscriptionDetails->contact_id, @@ -279,7 +279,7 @@ public function postProcess() { 'from' => $receiptFrom, 'toName' => $this->_donorDisplayName, 'toEmail' => $this->_donorEmail, - ); + ]; list($sent) = CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams); } } diff --git a/CRM/Contribute/Form/Contribution.php b/CRM/Contribute/Form/Contribution.php index 8326d73c03ce..f088ade2aa08 100644 --- a/CRM/Contribute/Form/Contribution.php +++ b/CRM/Contribute/Form/Contribution.php @@ -160,7 +160,7 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP * * @var array */ - public $_paymentFields = array(); + public $_paymentFields = []; /** * Logged in user's email. * @var string @@ -191,7 +191,7 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP * * @var array */ - protected $statusMessage = array(); + protected $statusMessage = []; /** * Status message title to be shown to the user. @@ -274,7 +274,7 @@ public function preProcess() { if ($this->_id) { $this->showRecordLinkMesssage($this->_id); } - $this->_values = array(); + $this->_values = []; // Current contribution id. if ($this->_id) { @@ -287,7 +287,7 @@ public function preProcess() { $this->applyCustomData('Contribution', CRM_Utils_Array::value('financial_type_id', $_POST), $this->_id); } - $this->_lineItems = array(); + $this->_lineItems = []; if ($this->_id) { if (!empty($this->_compId) && $this->_compContext == 'participant') { $this->assign('compId', $this->_compId); @@ -300,7 +300,7 @@ public function preProcess() { empty($lineItem) ? NULL : $this->_lineItems[] = $lineItem; } - $this->assign('lineItem', empty($lineItem) ? FALSE : array($lineItem)); + $this->assign('lineItem', empty($lineItem) ? FALSE : [$lineItem]); // Set title if ($this->_mode && $this->_id) { @@ -377,7 +377,7 @@ public function setDefaultValues() { } } - $amountFields = array('non_deductible_amount', 'fee_amount'); + $amountFields = ['non_deductible_amount', 'fee_amount']; foreach ($amountFields as $amt) { if (isset($defaults[$amt])) { $defaults[$amt] = CRM_Utils_Money::format($defaults[$amt], NULL, '%a'); @@ -406,10 +406,10 @@ public function setDefaultValues() { } $options_key = CRM_Utils_Array::key($this->_productDAO->product_option, $options); if ($options_key) { - $defaults['product_name'] = array($this->_productDAO->product_id, trim($options_key)); + $defaults['product_name'] = [$this->_productDAO->product_id, trim($options_key)]; } else { - $defaults['product_name'] = array($this->_productDAO->product_id); + $defaults['product_name'] = [$this->_productDAO->product_id]; } if ($this->_productDAO->fulfilled_date) { $defaults['fulfilled_date'] = $this->_productDAO->fulfilled_date; @@ -427,7 +427,7 @@ public function setDefaultValues() { if (!empty($defaults['contribution_status_id']) && in_array( CRM_Contribute_PseudoConstant::contributionStatus($defaults['contribution_status_id'], 'name'), // Historically not 'Cancelled' hence not using CRM_Contribute_BAO_Contribution::isContributionStatusNegative. - array('Refunded', 'Chargeback') + ['Refunded', 'Chargeback'] )) { $defaults['refund_trxn_id'] = CRM_Core_BAO_FinancialTrxn::getRefundTransactionTrxnID($this->_id); } @@ -460,18 +460,18 @@ public function setDefaultValues() { */ public function buildQuickForm() { if ($this->_action & CRM_Core_Action::DELETE) { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => ts('Delete'), 'spacing' => '         ', 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); return; } @@ -487,7 +487,7 @@ public function buildQuickForm() { CRM_Core_Error::fatal(ts('You do not have permission to access this page.')); } } - $allPanes = array(); + $allPanes = []; //tax rate from financialType $this->assign('taxRates', json_encode(CRM_Core_PseudoConstant::getTaxRates())); @@ -527,13 +527,13 @@ public function buildQuickForm() { $this->assign('buildPriceSet', $buildPriceSet); $defaults = $this->_values; - $additionalDetailFields = array( + $additionalDetailFields = [ 'note', 'thankyou_date', 'invoice_id', 'non_deductible_amount', 'fee_amount', - ); + ]; foreach ($additionalDetailFields as $key) { if (!empty($defaults[$key])) { $defaults['hidden_AdditionalDetail'] = 1; @@ -553,7 +553,7 @@ public function buildQuickForm() { $defaults['hidden_AdditionalDetail'] = 1; } - $paneNames = array(); + $paneNames = []; if (empty($this->_payNow)) { $paneNames[ts('Additional Details')] = 'AdditionalDetail'; } @@ -582,7 +582,7 @@ public function buildQuickForm() { } if ($buildRecurBlock) { CRM_Contribute_Form_Contribution_Main::buildRecur($this); - $this->setDefaults(array('is_recur' => 0)); + $this->setDefaults(['is_recur' => 0]); $this->assign('buildRecurBlock', TRUE); } } @@ -597,7 +597,7 @@ public function buildQuickForm() { $this->assign('qfKey', $qfKey); $this->assign('allPanes', $allPanes); - $this->addFormRule(array('CRM_Contribute_Form_Contribution', 'formRule'), $this); + $this->addFormRule(['CRM_Contribute_Form_Contribution', 'formRule'], $this); if ($this->_formType) { $this->assign('formType', $this->_formType); @@ -612,10 +612,10 @@ public function buildQuickForm() { $this->assign('entityID', $this->_id); if ($this->_context == 'standalone') { - $this->addEntityRef('contact_id', ts('Contact'), array( + $this->addEntityRef('contact_id', ts('Contact'), [ 'create' => TRUE, - 'api' => array('extra' => array('email')), - ), TRUE); + 'api' => ['extra' => ['email']], + ], TRUE); } $attributes = CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Contribution'); @@ -627,9 +627,9 @@ public function buildQuickForm() { } $financialType = $this->add('select', 'financial_type_id', ts('Financial Type'), - array('' => ts('- select -')) + $financialTypes, + ['' => ts('- select -')] + $financialTypes, TRUE, - array('onChange' => "CRM.buildCustomData( 'Contribution', this.value );") + ['onChange' => "CRM.buildCustomData( 'Contribution', this.value );"] ); $paymentInstrument = FALSE; @@ -639,12 +639,12 @@ public function buildQuickForm() { $checkPaymentID = array_search('Check', CRM_Contribute_PseudoConstant::paymentInstrument('name')); $paymentInstrument = $this->add('select', 'payment_instrument_id', ts('Payment Method'), - array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(), - $required, array('onChange' => "return showHideByValue('payment_instrument_id','{$checkPaymentID}','checkNumber','table-row','select',false);") + ['' => ts('- select -')] + CRM_Contribute_PseudoConstant::paymentInstrument(), + $required, ['onChange' => "return showHideByValue('payment_instrument_id','{$checkPaymentID}','checkNumber','table-row','select',false);"] ); } - $trxnId = $this->add('text', 'trxn_id', ts('Transaction ID'), array('class' => 'twelve') + $attributes['trxn_id']); + $trxnId = $this->add('text', 'trxn_id', ts('Transaction ID'), ['class' => 'twelve'] + $attributes['trxn_id']); //add receipt for offline contribution $this->addElement('checkbox', 'is_email_receipt', ts('Send Receipt?')); @@ -668,7 +668,7 @@ public function buildQuickForm() { $status = CRM_Contribute_BAO_Contribution_Utils::getContributionStatuses($component, $this->_id); // define the status IDs that show the cancellation info, see CRM-17589 - $cancelInfo_show_ids = array(); + $cancelInfo_show_ids = []; foreach (array_keys($status) as $status_id) { if (CRM_Contribute_BAO_Contribution::isContributionStatusNegative($status_id)) { $cancelInfo_show_ids[] = "'$status_id'"; @@ -698,9 +698,9 @@ public function buildQuickForm() { } // add various dates - $this->addField('receive_date', array('entity' => 'contribution'), !$this->_mode, FALSE); - $this->addField('receipt_date', array('entity' => 'contribution'), FALSE, FALSE); - $this->addField('cancel_date', array('entity' => 'contribution', 'label' => ts('Cancelled / Refunded Date')), FALSE, FALSE); + $this->addField('receive_date', ['entity' => 'contribution'], !$this->_mode, FALSE); + $this->addField('receipt_date', ['entity' => 'contribution'], FALSE, FALSE); + $this->addField('cancel_date', ['entity' => 'contribution', 'label' => ts('Cancelled / Refunded Date')], FALSE, FALSE); if ($this->_online) { $this->assign('hideCalender', TRUE); @@ -742,10 +742,10 @@ public function buildQuickForm() { // instead of selecting manually $financialTypeIds = CRM_Price_BAO_PriceSet::getAssoc(FALSE, 'CiviContribute', 'financial_type_id'); $element = $this->add('select', 'price_set_id', ts('Choose price set'), - array( + [ '' => ts('Choose price set'), - ) + $priceSets, - NULL, array('onchange' => "buildAmount( this.value, " . json_encode($financialTypeIds) . ");") + ] + $priceSets, + NULL, ['onchange' => "buildAmount( this.value, " . json_encode($financialTypeIds) . ");"] ); if ($this->_online && !($this->_action & CRM_Core_Action::UPDATE)) { $element->freeze(); @@ -754,18 +754,18 @@ public function buildQuickForm() { $this->assign('hasPriceSets', $hasPriceSets); if (!($this->_action & CRM_Core_Action::UPDATE)) { if ($this->_online || $this->_ppID) { - $attributes['total_amount'] = array_merge($attributes['total_amount'], array( + $attributes['total_amount'] = array_merge($attributes['total_amount'], [ 'READONLY' => TRUE, 'style' => "background-color:#EBECE4", - )); - $optionTypes = array( + ]); + $optionTypes = [ '1' => ts('Adjust Pledge Payment Schedule?'), '2' => ts('Adjust Total Pledge Amount?'), - ); + ]; $this->addRadio('option_type', NULL, $optionTypes, - array(), '
    ' + [], '
    ' ); $currencyFreeze = TRUE; @@ -791,30 +791,30 @@ public function buildQuickForm() { $js = NULL; if (!$this->_mode) { - $js = array('onclick' => "return verify( );"); + $js = ['onclick' => "return verify( );"]; } $mailingInfo = Civi::settings()->get('mailing_backend'); $this->assign('outBound_option', $mailingInfo['outBound_option']); - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'upload', 'name' => ts('Save'), 'js' => $js, 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'upload', 'name' => ts('Save and New'), 'js' => $js, 'subName' => 'new', - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); // if contribution is related to membership or participant freeze Financial Type, Amount @@ -859,7 +859,7 @@ public function buildQuickForm() { * true if no errors, else array of errors */ public static function formRule($fields, $files, $self) { - $errors = array(); + $errors = []; // Check for Credit Card Contribution. if ($self->_mode) { if (empty($fields['payment_processor_id'])) { @@ -904,15 +904,15 @@ public static function formRule($fields, $files, $self) { // $trxn_id must be unique CRM-13919 if (!empty($fields['trxn_id'])) { - $queryParams = array(1 => array($fields['trxn_id'], 'String')); + $queryParams = [1 => [$fields['trxn_id'], 'String']]; $query = 'select count(*) from civicrm_contribution where trxn_id = %1'; if ($self->_id) { - $queryParams[2] = array((int) $self->_id, 'Integer'); + $queryParams[2] = [(int) $self->_id, 'Integer']; $query .= ' and id !=%2'; } $tCnt = CRM_Core_DAO::singleValueQuery($query, $queryParams); if ($tCnt) { - $errors['trxn_id'] = ts('Transaction ID\'s must be unique. Transaction \'%1\' already exists in your database.', array(1 => $fields['trxn_id'])); + $errors['trxn_id'] = ts('Transaction ID\'s must be unique. Transaction \'%1\' already exists in your database.', [1 => $fields['trxn_id']]); } } if (!empty($fields['revenue_recognition_date']) @@ -991,13 +991,13 @@ public function postProcess() { $this->_id = $contribution->id; } if (!empty($this->_id) && CRM_Core_Permission::access('CiviMember')) { - $membershipPaymentCount = civicrm_api3('MembershipPayment', 'getCount', array('contribution_id' => $this->_id)); + $membershipPaymentCount = civicrm_api3('MembershipPayment', 'getCount', ['contribution_id' => $this->_id]); if ($membershipPaymentCount) { $this->ajaxResponse['updateTabs']['#tab_member'] = CRM_Contact_BAO_Contact::getCountComponent('membership', $this->_contactID); } } if (!empty($this->_id) && CRM_Core_Permission::access('CiviEvent')) { - $participantPaymentCount = civicrm_api3('ParticipantPayment', 'getCount', array('contribution_id' => $this->_id)); + $participantPaymentCount = civicrm_api3('ParticipantPayment', 'getCount', ['contribution_id' => $this->_id]); if ($participantPaymentCount) { $this->ajaxResponse['updateTabs']['#tab_participant'] = CRM_Contact_BAO_Contact::getCountComponent('participant', $this->_contactID); } @@ -1036,7 +1036,7 @@ protected function processCreditCard($submittedValues, $lineItem, $contactID) { $userSortName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $userID, 'sort_name' ); - $submittedValues['source'] = ts('Submit Credit Card Payment by: %1', array(1 => $userSortName)); + $submittedValues['source'] = ts('Submit Credit Card Payment by: %1', [1 => $userSortName]); } $params = $submittedValues; @@ -1122,7 +1122,7 @@ protected function processCreditCard($submittedValues, $lineItem, $contactID) { $this->assign('is_deductible', TRUE); $this->set('is_deductible', TRUE); } - $contributionParams = array( + $contributionParams = [ 'id' => CRM_Utils_Array::value('contribution_id', $this->_params), 'contact_id' => $contactID, 'line_item' => $lineItem, @@ -1131,7 +1131,7 @@ protected function processCreditCard($submittedValues, $lineItem, $contactID) { 'contribution_page_id' => CRM_Utils_Array::value('contribution_page_id', $this->_params), 'source' => CRM_Utils_Array::value('source', $paymentParams, CRM_Utils_Array::value('description', $paymentParams)), 'thankyou_date' => CRM_Utils_Array::value('thankyou_date', $this->_params), - ); + ]; $contributionParams['payment_instrument_id'] = $this->_paymentProcessor['payment_instrument_id']; $contribution = CRM_Contribute_Form_Contribution_Confirm::processFormContribution($this, @@ -1170,7 +1170,7 @@ protected function processCreditCard($submittedValues, $lineItem, $contactID) { */ if ($result['payment_status_id'] == $completeStatusId) { try { - civicrm_api3('contribution', 'completetransaction', array( + civicrm_api3('contribution', 'completetransaction', [ 'id' => $contribution->id, 'trxn_id' => $result['trxn_id'], 'payment_processor_id' => $this->_paymentProcessor['id'], @@ -1179,7 +1179,7 @@ protected function processCreditCard($submittedValues, $lineItem, $contactID) { 'card_type_id' => CRM_Utils_Array::value('card_type_id', $paymentParams), 'pan_truncation' => CRM_Utils_Array::value('pan_truncation', $paymentParams), 'is_email_receipt' => FALSE, - )); + ]); // This has now been set to 1 in the DB - declare it here also $contribution->contribution_status_id = 1; } @@ -1242,11 +1242,11 @@ protected function generatePane($type, $defaults) { $open = 'true'; } - $pane = array( + $pane = [ 'url' => CRM_Utils_System::url('civicrm/contact/view/contribution', $urlParams), 'open' => $open, 'id' => $type, - ); + ]; // See if we need to include this paneName in the current form. if ($this->_formType == $type || !empty($_POST["hidden_{$type}"]) || @@ -1281,29 +1281,29 @@ protected function generatePane($type, $defaults) { * @throws \CiviCRM_API3_Exception */ public function testSubmit($params, $action, $creditCardMode = NULL) { - $defaults = array( - 'soft_credit_contact_id' => array(), + $defaults = [ + 'soft_credit_contact_id' => [], 'receive_date' => date('Y-m-d H:i:s'), 'receipt_date' => '', 'cancel_date' => '', 'hidden_Premium' => 1, - ); + ]; $this->_bltID = 5; if (!empty($params['id'])) { - $existingContribution = civicrm_api3('contribution', 'getsingle', array( + $existingContribution = civicrm_api3('contribution', 'getsingle', [ 'id' => $params['id'], - )); + ]); $this->_id = $params['id']; $this->_values = $existingContribution; if (CRM_Contribute_BAO_Contribution::checkContributeSettings('invoicing')) { - $this->_values['tax_amount'] = civicrm_api3('contribution', 'getvalue', array( + $this->_values['tax_amount'] = civicrm_api3('contribution', 'getvalue', [ 'id' => $params['id'], 'return' => 'tax_amount', - )); + ]); } } else { - $existingContribution = array(); + $existingContribution = []; } $this->_defaults['contribution_status_id'] = CRM_Utils_Array::value('contribution_status_id', @@ -1324,7 +1324,7 @@ public function testSubmit($params, $action, $creditCardMode = NULL) { CRM_Contribute_Form_AdditionalInfo::buildPremium($this); - $this->_fields = array(); + $this->_fields = []; return $this->submit(array_merge($defaults, $params), $action, CRM_Utils_Array::value('pledge_payment_id', $params)); } @@ -1361,7 +1361,7 @@ protected function submit($submittedValues, $action, $pledgePaymentID) { } // Process price set and get total amount and line items. - $lineItem = array(); + $lineItem = []; $priceSetId = CRM_Utils_Array::value('price_set_id', $submittedValues); if (empty($priceSetId) && !$this->_id) { $this->_priceSetId = $priceSetId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', 'default_contribution_amount', 'id', 'name'); @@ -1424,10 +1424,10 @@ protected function submit($submittedValues, $action, $pledgePaymentID) { $entityTable = 'participant'; $entityID = $pId; $isRelatedId = FALSE; - $participantParams = array( + $participantParams = [ 'fee_amount' => $submittedValues['total_amount'], 'id' => $entityID, - ); + ]; CRM_Event_BAO_Participant::add($participantParams); if (empty($this->_lineItems)) { $this->_lineItems[] = CRM_Price_BAO_LineItem::getLineItems($entityID, 'participant', TRUE); @@ -1507,7 +1507,7 @@ protected function submit($submittedValues, $action, $pledgePaymentID) { $isEmpty = array_keys(array_flip($submittedValues['soft_credit_contact_id'])); if ($this->_id && count($isEmpty) == 1 && key($isEmpty) == NULL) { - civicrm_api3('ContributionSoft', 'get', array('contribution_id' => $this->_id, 'pcp_id' => NULL, 'api.ContributionSoft.delete' => 1)); + civicrm_api3('ContributionSoft', 'get', ['contribution_id' => $this->_id, 'pcp_id' => NULL, 'api.ContributionSoft.delete' => 1]); } // set the contact, when contact is selected @@ -1519,13 +1519,13 @@ protected function submit($submittedValues, $action, $pledgePaymentID) { // Credit Card Contribution. if ($this->_mode) { - $paramsSetByPaymentProcessingSubsystem = array( + $paramsSetByPaymentProcessingSubsystem = [ 'trxn_id', 'payment_instrument_id', 'contribution_status_id', 'cancel_date', 'cancel_reason', - ); + ]; foreach ($paramsSetByPaymentProcessingSubsystem as $key) { if (isset($formValues[$key])) { unset($formValues[$key]); @@ -1553,7 +1553,7 @@ protected function submit($submittedValues, $action, $pledgePaymentID) { CRM_Contribute_BAO_ContributionSoft::formatSoftCreditParams($submittedValues, $this); $params = array_merge($params, $submittedValues); - $fields = array( + $fields = [ 'financial_type_id', 'contribution_status_id', 'payment_instrument_id', @@ -1562,7 +1562,7 @@ protected function submit($submittedValues, $action, $pledgePaymentID) { 'check_number', 'card_type_id', 'pan_truncation', - ); + ]; foreach ($fields as $f) { $params[$f] = CRM_Utils_Array::value($f, $formValues); } @@ -1695,7 +1695,7 @@ protected function invoicingPostProcessHook($submittedValues, $action, $lineItem if (!CRM_Utils_Array::value('invoicing', $invoiceSettings)) { return; } - $taxRate = array(); + $taxRate = []; $getTaxDetails = FALSE; foreach ($lineItem as $key => $value) { diff --git a/CRM/Contribute/Form/Contribution/Confirm.php b/CRM/Contribute/Form/Contribution/Confirm.php index 24f3edc2e464..d597b15ece67 100644 --- a/CRM/Contribute/Form/Contribution/Confirm.php +++ b/CRM/Contribute/Form/Contribution/Confirm.php @@ -66,7 +66,7 @@ public static function handlePledge(&$form, $params, $contributionParams, $pledg //when user doing pledge payments. //update the schedule when payment(s) are made $amount = $params['amount']; - $pledgePaymentParams = array(); + $pledgePaymentParams = []; foreach ($params['pledge_amount'] as $paymentId => $dontCare) { $scheduledAmount = CRM_Core_DAO::getFieldValue( 'CRM_Pledge_DAO_PledgePayment', @@ -77,12 +77,12 @@ public static function handlePledge(&$form, $params, $contributionParams, $pledg $pledgePayment = ($amount >= $scheduledAmount) ? $scheduledAmount : $amount; if ($pledgePayment > 0) { - $pledgePaymentParams[] = array( + $pledgePaymentParams[] = [ 'id' => $paymentId, 'contribution_id' => $contribution->id, 'status_id' => $contribution->contribution_status_id, 'actual_amount' => $pledgePayment, - ); + ]; $amount -= $pledgePayment; } } @@ -99,7 +99,7 @@ public static function handlePledge(&$form, $params, $contributionParams, $pledg } else { //when user creating pledge record. - $pledgeParams = array(); + $pledgeParams = []; $pledgeParams['contact_id'] = $contribution->contact_id; $pledgeParams['installment_amount'] = $pledgeParams['actual_amount'] = $contribution->total_amount; $pledgeParams['contribution_id'] = $contribution->id; @@ -168,7 +168,7 @@ public static function handlePledge(&$form, $params, $contributionParams, $pledg public static function getContributionParams( $params, $financialTypeID, $paymentProcessorOutcome, $receiptDate, $recurringContributionID) { - $contributionParams = array( + $contributionParams = [ 'financial_type_id' => $financialTypeID, 'receive_date' => (CRM_Utils_Array::value('receive_date', $params)) ? CRM_Utils_Date::processDate($params['receive_date']) : date('YmdHis'), 'tax_amount' => CRM_Utils_Array::value('tax_amount', $params), @@ -183,15 +183,15 @@ public static function getContributionParams( 'thankyou_date' => isset($params['thankyou_date']) ? CRM_Utils_Date::format($params['thankyou_date']) : NULL, //setting to make available to hook - although seems wrong to set on form for BAO hook availability 'skipLineItem' => CRM_Utils_Array::value('skipLineItem', $params, 0), - ); + ]; if ($paymentProcessorOutcome) { $contributionParams['payment_processor'] = CRM_Utils_Array::value('payment_processor', $paymentProcessorOutcome); } if (!empty($params["is_email_receipt"])) { - $contributionParams += array( + $contributionParams += [ 'receipt_date' => $receiptDate, - ); + ]; } if ($recurringContributionID) { @@ -328,7 +328,7 @@ public function preProcess() { $this->_params['organization_id'] = CRM_Utils_Array::value('onbehalfof_id', $this->_params); } $this->_params['organization_name'] = $this->_params['onbehalf']['organization_name']; - $addressBlocks = array( + $addressBlocks = [ 'street_address', 'city', 'state_province', @@ -341,9 +341,9 @@ public function preProcess() { 'geo_code_1', 'geo_code_2', 'address_name', - ); + ]; - $blocks = array('email', 'phone', 'im', 'url', 'openid'); + $blocks = ['email', 'phone', 'im', 'url', 'openid']; foreach ($this->_params['onbehalf'] as $loc => $value) { $field = $typeId = NULL; if (strstr($loc, '-')) { @@ -388,7 +388,7 @@ public function preProcess() { $locationValue = $locType; } $locTypeId = ''; - $phoneExtField = array(); + $phoneExtField = []; if ($field == 'url') { $blockName = 'website'; @@ -407,7 +407,7 @@ public function preProcess() { //check if extension field exists $extField = str_replace('phone', 'phone_ext', $loc); if (isset($this->_params['onbehalf'][$extField])) { - $phoneExtField = array('phone_ext' => $this->_params['onbehalf'][$extField]); + $phoneExtField = ['phone_ext' => $this->_params['onbehalf'][$extField]]; } } @@ -418,14 +418,14 @@ public function preProcess() { $isPrimary = 0; } if ($locationValue) { - $blockValues = array( + $blockValues = [ $fieldName => $value, $locationType => $locationValue, 'is_primary' => $isPrimary, - ); + ]; if ($locTypeId) { - $blockValues = array_merge($blockValues, array($locTypeId => $typeId)); + $blockValues = array_merge($blockValues, [$locTypeId => $typeId]); } if (!empty($phoneExtField)) { $blockValues = array_merge($blockValues, $phoneExtField); @@ -454,11 +454,11 @@ public function preProcess() { elseif (!empty($this->_values['is_for_organization'])) { // no on behalf of an organization, CRM-5519 // so reset loc blocks from main params. - foreach (array( + foreach ([ 'phone', 'email', 'address', - ) as $blk) { + ] as $blk) { if (isset($this->_params[$blk])) { unset($this->_params[$blk]); } @@ -500,7 +500,7 @@ public function buildQuickForm() { $this->assign('soft_credit_type', $softCreditTypes[$params['soft_credit_type_id']]); CRM_Contribute_BAO_ContributionSoft::formatHonoreeProfileFields($this, $params['honor']); - $fieldTypes = array('Contact'); + $fieldTypes = ['Contact']; $fieldTypes[] = CRM_Core_BAO_UFGroup::getContactType($this->_values['honoree_profile_id']); $this->buildCustom($this->_values['honoree_profile_id'], 'honoreeProfileFields', TRUE, 'honor', $fieldTypes); } @@ -568,14 +568,14 @@ public function buildQuickForm() { !empty($params['is_for_organization']) ) && empty($this->_ccid) ) { - $fieldTypes = array('Contact', 'Organization'); + $fieldTypes = ['Contact', 'Organization']; $contactSubType = CRM_Contact_BAO_ContactType::subTypes('Organization'); $fieldTypes = array_merge($fieldTypes, $contactSubType); if (is_array($this->_membershipBlock) && !empty($this->_membershipBlock)) { - $fieldTypes = array_merge($fieldTypes, array('Membership')); + $fieldTypes = array_merge($fieldTypes, ['Membership']); } else { - $fieldTypes = array_merge($fieldTypes, array('Contribution')); + $fieldTypes = array_merge($fieldTypes, ['Contribution']); } $this->buildCustom($this->_values['onbehalf_profile_id'], 'onbehalfProfile', TRUE, 'onbehalf', $fieldTypes); @@ -610,22 +610,22 @@ public function buildQuickForm() { ) ); - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => $contribButton, 'spacing' => '         ', 'isDefault' => TRUE, - 'js' => array('onclick' => "return submitOnce(this,'" . $this->_name . "','" . ts('Processing') . "');"), - ), - array( + 'js' => ['onclick' => "return submitOnce(this,'" . $this->_name . "','" . ts('Processing') . "');"], + ], + [ 'type' => 'back', 'name' => ts('Go Back'), - ), - ) + ], + ] ); - $defaults = array(); + $defaults = []; $fields = array_fill_keys(array_keys($this->_fields), 1); $fields["billing_state_province-{$this->_bltID}"] = $fields["billing_country-{$this->_bltID}"] = $fields["email-{$this->_bltID}"] = 1; @@ -634,10 +634,10 @@ public function buildQuickForm() { // Recursively set defaults for nested fields if (isset($contact[$name]) && is_array($contact[$name]) && ($name == 'onbehalf' || $name == 'honor')) { foreach ($contact[$name] as $fieldName => $fieldValue) { - if (is_array($fieldValue) && !in_array($this->_fields[$name][$fieldName]['html_type'], array( + if (is_array($fieldValue) && !in_array($this->_fields[$name][$fieldName]['html_type'], [ 'Multi-Select', 'AdvMulti-Select', - )) + ]) ) { foreach ($fieldValue as $key => $value) { $defaults["{$name}[{$fieldName}][{$key}]"] = $value; @@ -659,11 +659,11 @@ public function buildQuickForm() { $defaults["{$name}_id"] = $contact["{$name}_id"]; } } - elseif (in_array($name, array( + elseif (in_array($name, [ 'addressee', 'email_greeting', 'postal_greeting', - )) && !empty($contact[$name . '_custom']) + ]) && !empty($contact[$name . '_custom']) ) { $defaults[$name . '_custom'] = $contact[$name . '_custom']; } @@ -822,14 +822,14 @@ protected function postProcessPremium($premiumParams, $contribution) { $this->assign('contact_email', $dao->premiums_contact_email); //create Premium record - $params = array( + $params = [ 'product_id' => $premiumParams['selectProduct'], 'contribution_id' => $contribution->id, 'product_option' => CRM_Utils_Array::value('options_' . $premiumParams['selectProduct'], $premiumParams), 'quantity' => 1, 'start_date' => CRM_Utils_Date::customFormat($startDate, '%Y%m%d'), 'end_date' => CRM_Utils_Date::customFormat($endDate, '%Y%m%d'), - ); + ]; if (!empty($premiumParams['selectProduct'])) { $daoPremiumsProduct = new CRM_Contribute_DAO_PremiumsProduct(); $daoPremiumsProduct->product_id = $premiumParams['selectProduct']; @@ -846,12 +846,12 @@ protected function postProcessPremium($premiumParams, $contribution) { CRM_Contribute_BAO_Contribution::addPremium($params); if ($productDAO->cost && !empty($params['financial_type_id'])) { - $trxnParams = array( + $trxnParams = [ 'cost' => $productDAO->cost, 'currency' => $productDAO->currency, 'financial_type_id' => $params['financial_type_id'], 'contributionId' => $contribution->id, - ); + ]; CRM_Core_BAO_FinancialTrxn::createPremiumTrxn($trxnParams); } } @@ -961,7 +961,7 @@ public static function processFormContribution( $invoiceSettings = Civi::settings()->get('contribution_invoice_settings'); $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings); if ($invoicing) { - $dataArray = array(); + $dataArray = []; // @todo - interrogate the line items passed in on the params array. // No reason to assume line items will be set on the form. foreach ($form->_lineItem as $lineItemKey => $lineItemValue) { @@ -1013,15 +1013,15 @@ public static function processFormContribution( } // Save note if ($contribution && !empty($params['contribution_note'])) { - $noteParams = array( + $noteParams = [ 'entity_table' => 'civicrm_contribution', 'note' => $params['contribution_note'], 'entity_id' => $contribution->id, 'contact_id' => $contribution->contact_id, 'modified_date' => date('Ymd'), - ); + ]; - CRM_Core_BAO_Note::add($noteParams, array()); + CRM_Core_BAO_Note::add($noteParams, []); } if (isset($params['related_contact'])) { @@ -1070,7 +1070,7 @@ public static function processRecurringContribution(&$form, &$params, $contactID return NULL; } - $recurParams = array('contact_id' => $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); @@ -1157,7 +1157,7 @@ public static function processRecurringContribution(&$form, &$params, $contactID */ public static function processOnBehalfOrganization(&$behalfOrganization, &$contactID, &$values, &$params, $fields = NULL) { $isNotCurrentEmployer = FALSE; - $dupeIDs = array(); + $dupeIDs = []; $orgID = NULL; if (!empty($behalfOrganization['organization_id'])) { $orgID = $behalfOrganization['organization_id']; @@ -1181,7 +1181,7 @@ public static function processOnBehalfOrganization(&$behalfOrganization, &$conta if (!$orgID) { // check if matching organization contact exists - $dupeIDs = CRM_Contact_BAO_Contact::getDuplicateContacts($behalfOrganization, 'Organization', 'Unsupervised', array(), FALSE); + $dupeIDs = CRM_Contact_BAO_Contact::getDuplicateContacts($behalfOrganization, 'Organization', 'Unsupervised', [], FALSE); // CRM-6243 says to pick the first org even if more than one match if (count($dupeIDs) >= 1) { @@ -1209,7 +1209,7 @@ public static function processOnBehalfOrganization(&$behalfOrganization, &$conta // create relationship if ($isNotCurrentEmployer) { $relParams['contact_check'][$orgID] = 1; - $cid = array('contact' => $contactID); + $cid = ['contact' => $contactID]; CRM_Contact_BAO_Relationship::legacyCreateMultiple($relParams, $cid); } @@ -1262,7 +1262,7 @@ public static function processOnBehalfOrganization(&$behalfOrganization, &$conta * Contribution object. */ public static function pcpNotifyOwner($contribution, $contributionSoft) { - $params = array('id' => $contributionSoft->pcp_id); + $params = ['id' => $contributionSoft->pcp_id]; CRM_Core_DAO::commonRetrieve('CRM_PCP_DAO_PCP', $params, $pcpInfo); $ownerNotifyID = CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCPBlock', $pcpInfo['pcp_block_id'], 'owner_notify_id'); $ownerNotifyOption = CRM_Core_PseudoConstant::getName('CRM_PCP_DAO_PCPBlock', 'owner_notify_id', $ownerNotifyID); @@ -1286,7 +1286,7 @@ public static function pcpNotifyOwner($contribution, $contributionSoft) { list($donorName, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contribution->contact_id); } list($ownerName, $ownerEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contributionSoft->contact_id); - $tplParams = array( + $tplParams = [ 'page_title' => $pcpInfo['title'], 'receive_date' => $contribution->receive_date, 'total_amount' => $contributionSoft->amount, @@ -1295,9 +1295,9 @@ public static function pcpNotifyOwner($contribution, $contributionSoft) { 'pcpInfoURL' => $pcpInfoURL, 'is_honor_roll_enabled' => $contributionSoft->pcp_display_in_roll, 'currency' => $contributionSoft->currency, - ); + ]; $domainValues = CRM_Core_BAO_Domain::getNameAndEmail(); - $sendTemplateParams = array( + $sendTemplateParams = [ 'groupName' => 'msg_tpl_workflow_contribution', 'valueName' => 'pcp_owner_notify', 'contactId' => $contributionSoft->contact_id, @@ -1306,7 +1306,7 @@ public static function pcpNotifyOwner($contribution, $contributionSoft) { 'from' => "$domainValues[0] <$domainValues[1]>", 'tplParams' => $tplParams, 'PDFFilename' => 'receipt.pdf', - ); + ]; CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams); } } @@ -1332,12 +1332,12 @@ public static function processPcp(&$page, $params) { else { $params['pcp_is_anonymous'] = 0; } - foreach (array( + foreach ([ 'pcp_display_in_roll', 'pcp_is_anonymous', 'pcp_roll_nickname', 'pcp_personal_note', - ) as $val) { + ] as $val) { if (!empty($params[$val])) { $page->assign($val, $params[$val]); } @@ -1362,7 +1362,7 @@ protected function processMembership($membershipParams, $contactID, $customField $membershipTypeIDs = (array) $membershipParams['selectMembership']; $membershipTypes = CRM_Member_BAO_Membership::buildMembershipTypeValues($this, $membershipTypeIDs); - $membershipType = empty($membershipTypes) ? array() : reset($membershipTypes); + $membershipType = empty($membershipTypes) ? [] : reset($membershipTypes); $isPending = $this->getIsPending(); $this->assign('membership_name', CRM_Utils_Array::value('name', $membershipType)); @@ -1434,7 +1434,7 @@ protected function postProcessMembership( $membershipContribution = NULL; $isTest = CRM_Utils_Array::value('is_test', $membershipParams, FALSE); - $errors = $paymentResults = array(); + $errors = $paymentResults = []; $form->_values['isMembership'] = TRUE; $isRecurForFirstTransaction = CRM_Utils_Array::value('is_recur', $form->_params, CRM_Utils_Array::value('is_recur', $membershipParams)); @@ -1469,7 +1469,7 @@ protected function postProcessMembership( $isRecurForFirstTransaction ); if (!empty($paymentResult['contribution'])) { - $paymentResults[] = array('contribution_id' => $paymentResult['contribution']->id, 'result' => $paymentResult); + $paymentResults[] = ['contribution_id' => $paymentResult['contribution']->id, 'result' => $paymentResult]; $this->postProcessPremium($premiumParams, $paymentResult['contribution']); //note that this will be over-written if we are using a separate membership transaction. Otherwise there is only one $membershipContribution = $paymentResult['contribution']; @@ -1485,9 +1485,9 @@ protected function postProcessMembership( if (empty($form->_params['auto_renew']) && !empty($membershipParams['is_recur'])) { unset($membershipParams['is_recur']); } - list($membershipContribution, $secondPaymentResult) = $this->processSecondaryFinancialTransaction($contactID, $form, array_merge($membershipParams, array('skipLineItem' => 1)), + list($membershipContribution, $secondPaymentResult) = $this->processSecondaryFinancialTransaction($contactID, $form, array_merge($membershipParams, ['skipLineItem' => 1]), $isTest, $unprocessedLineItems, CRM_Utils_Array::value('minimum_fee', $membershipDetails, 0), CRM_Utils_Array::value('financial_type_id', $membershipDetails)); - $paymentResults[] = array('contribution_id' => $membershipContribution->id, 'result' => $secondPaymentResult); + $paymentResults[] = ['contribution_id' => $membershipContribution->id, 'result' => $secondPaymentResult]; $totalAmount = $membershipContribution->total_amount; } catch (CRM_Core_Exception $e) { @@ -1507,9 +1507,9 @@ protected function postProcessMembership( } //@todo it should no longer be possible for it to get to this point & membership to not be an array if (is_array($membershipTypeIDs) && !empty($membershipContributionID)) { - $typesTerms = CRM_Utils_Array::value('types_terms', $membershipParams, array()); + $typesTerms = CRM_Utils_Array::value('types_terms', $membershipParams, []); - $membershipLines = $nonMembershipLines = array(); + $membershipLines = $nonMembershipLines = []; foreach ($unprocessedLineItems as $priceSetID => $lines) { foreach ($lines as $line) { if (!empty($line['membership_type_id'])) { @@ -1519,9 +1519,9 @@ protected function postProcessMembership( } $i = 1; - $form->_params['createdMembershipIDs'] = array(); + $form->_params['createdMembershipIDs'] = []; foreach ($membershipTypeIDs as $memType) { - $membershipLineItems = array(); + $membershipLineItems = []; if ($i < count($membershipTypeIDs)) { $membershipLineItems[$priceSetID][$membershipLines[$memType]] = $unprocessedLineItems[$priceSetID][$membershipLines[$memType]]; unset($unprocessedLineItems[$priceSetID][$membershipLines[$memType]]); @@ -1564,7 +1564,7 @@ protected function postProcessMembership( date('YmdHis'), CRM_Utils_Array::value('cms_contactID', $membershipParams), $customFieldsFormatted, $numTerms, $membershipID, $pending, - $contributionRecurID, $membershipSource, $isPayLater, $campaignId, array(), $membershipContribution, + $contributionRecurID, $membershipSource, $isPayLater, $campaignId, [], $membershipContribution, $membershipLineItems ); @@ -1627,7 +1627,7 @@ protected function postProcessMembership( // The contribution_other_id is effectively the ID for the only contribution or the non-membership contribution. // Since we have called the membership contribution (in a 2 contribution scenario) this is out // primary-contribution compared to that - but let's face it - it's all just too hard & confusing at the moment! - $paymentParams = array_merge($form->_params, array('contributionID' => $form->_values['contribution_other_id'])); + $paymentParams = array_merge($form->_params, ['contributionID' => $form->_values['contribution_other_id']]); // CRM-19792 : set necessary fields for payment processor CRM_Core_Payment_Form::mapParams($form->_bltID, $paymentParams, $paymentParams, TRUE); @@ -1636,7 +1636,7 @@ protected function postProcessMembership( // be performed yet, so do it now. if ($isPaidMembership && !$isProcessSeparateMembershipTransaction) { $paymentActionResult = $payment->doPayment($paymentParams, 'contribute'); - $paymentResults[] = array('contribution_id' => $paymentResult['contribution']->id, 'result' => $paymentActionResult); + $paymentResults[] = ['contribution_id' => $paymentResult['contribution']->id, 'result' => $paymentActionResult]; } // Do not send an email if Recurring transaction is done via Direct Mode // Email will we sent when the IPN is received. @@ -1668,7 +1668,7 @@ protected function postProcessMembership( $paymentProcessorIDs = explode(CRM_Core_DAO::VALUE_SEPARATOR, CRM_Utils_Array::value('payment_processor', $this->_values)); $this->_paymentProcessor['id'] = $paymentProcessorIDs[0]; } - $result = array('payment_status_id' => 1, 'contribution' => $membershipContribution); + $result = ['payment_status_id' => 1, 'contribution' => $membershipContribution]; $this->completeTransaction($result, $result['contribution']->id); } // return as completeTransaction() already sends the receipt mail. @@ -1744,7 +1744,7 @@ protected function processSecondaryFinancialTransaction($contactID, &$form, $tem //so for differentiating membership contribution from //main contribution. $form->_params['separate_membership_payment'] = 1; - $contributionParams = array( + $contributionParams = [ 'contact_id' => $contactID, 'line_item' => $lineItems, 'is_test' => $isTest, @@ -1752,7 +1752,7 @@ protected function processSecondaryFinancialTransaction($contactID, &$form, $tem $form->_values)), 'contribution_page_id' => $form->_id, 'source' => CRM_Utils_Array::value('source', $tempParams, CRM_Utils_Array::value('description', $tempParams)), - ); + ]; $isMonetary = !empty($form->_values['is_monetary']); if ($isMonetary) { if (empty($paymentParams['is_pay_later'])) { @@ -1773,7 +1773,7 @@ protected function processSecondaryFinancialTransaction($contactID, &$form, $tem $isRecur ); - $result = array(); + $result = []; // We're not processing the line item here because we are processing a membership. // To ensure processing of the correct parameters, replace relevant parameters @@ -1801,7 +1801,7 @@ protected function processSecondaryFinancialTransaction($contactID, &$form, $tem $form->assign('membership_trx_id', $result['trxn_id']); } - return array($membershipContribution, $result); + return [$membershipContribution, $result]; } /** @@ -1951,7 +1951,7 @@ public static function submit($params) { $form->_values['fee'] = $priceSetFields['fields']; $form->_priceSetId = $priceSetID; $form->setFormAmountFields($priceSetID); - $capabilities = array(); + $capabilities = []; if ($form->_mode) { $capabilities[] = (ucfirst($form->_mode) . 'Mode'); } @@ -1972,10 +1972,10 @@ public static function submit($params) { } $priceFields = $priceFields[$priceSetID]['fields']; - $lineItems = array(); + $lineItems = []; CRM_Price_BAO_PriceSet::processAmount($priceFields, $paramsProcessedForForm, $lineItems, 'civicrm_contribution', $priceSetID); - $form->_lineItem = array($priceSetID => $lineItems); - $membershipPriceFieldIDs = array(); + $form->_lineItem = [$priceSetID => $lineItems]; + $membershipPriceFieldIDs = []; foreach ((array) $lineItems as $lineItem) { if (!empty($lineItem['membership_type_id'])) { $form->set('useForMember', 1); @@ -2006,10 +2006,10 @@ public static function getFormParams($id, array $params) { $params['is_pay_later'] = 0; } elseif ($params['amount'] !== 0) { - $params['is_pay_later'] = civicrm_api3('contribution_page', 'getvalue', array( + $params['is_pay_later'] = civicrm_api3('contribution_page', 'getvalue', [ 'id' => $id, 'return' => 'is_pay_later', - )); + ]); } } if (empty($params['price_set_id'])) { @@ -2080,10 +2080,10 @@ protected function processFormSubmission($contactID) { CRM_Contact_BAO_Contact::processImageParams($params); } - $fields = array('email-Primary' => 1); + $fields = ['email-Primary' => 1]; // get the add to groups - $addToGroups = array(); + $addToGroups = []; // now set the values for the billing location. foreach ($this->_fields as $name => $value) { @@ -2105,8 +2105,8 @@ protected function processFormSubmission($contactID) { // normal behavior is continued. And use that variable to // process on-behalf-of functionality. if (!empty($this->_values['onbehalf_profile_id']) && empty($this->_ccid)) { - $behalfOrganization = array(); - $orgFields = array('organization_name', 'organization_id', 'org_option'); + $behalfOrganization = []; + $orgFields = ['organization_name', 'organization_id', 'org_option']; foreach ($orgFields as $fld) { if (array_key_exists($fld, $params)) { $behalfOrganization[$fld] = $params[$fld]; @@ -2120,10 +2120,10 @@ protected function processFormSubmission($contactID) { $behalfOrganization[$fld] = $values; } elseif (!(strstr($fld, '-'))) { - if (in_array($fld, array( + if (in_array($fld, [ 'contribution_campaign_id', 'member_campaign_id', - ))) { + ])) { $fld = 'campaign_id'; } else { @@ -2184,7 +2184,7 @@ protected function processFormSubmission($contactID) { unset($dupeParams['honor']); } - $contactID = CRM_Contact_BAO_Contact::getFirstDuplicateContact($dupeParams, 'Individual', 'Unsupervised', array(), FALSE); + $contactID = CRM_Contact_BAO_Contact::getFirstDuplicateContact($dupeParams, 'Individual', 'Unsupervised', [], FALSE); // Fetch default greeting id's if creating a contact if (!$contactID) { @@ -2216,7 +2216,7 @@ protected function processFormSubmission($contactID) { $this->_contactID = $contactID; //get email primary first if exist - $subscriptionEmail = array('email' => CRM_Utils_Array::value('email-Primary', $params)); + $subscriptionEmail = ['email' => CRM_Utils_Array::value('email-Primary', $params)]; if (!$subscriptionEmail['email']) { $subscriptionEmail['email'] = CRM_Utils_Array::value("email-{$this->_bltID}", $params); } @@ -2233,7 +2233,7 @@ protected function processFormSubmission($contactID) { !empty($this->_params['is_for_organization']) ) ) { - $ufFields = array(); + $ufFields = []; foreach ($this->_fields['onbehalf'] as $name => $value) { $ufFields[$name] = 1; } @@ -2361,7 +2361,7 @@ protected function doMembershipProcessing($contactID, $membershipParams, $premiu $this->_params['campaign_id'] = $membershipParams['onbehalf']['member_campaign_id']; } - $customFieldsFormatted = $fieldTypes = array(); + $customFieldsFormatted = $fieldTypes = []; if (!empty($membershipParams['onbehalf']) && is_array($membershipParams['onbehalf']) ) { @@ -2378,7 +2378,7 @@ protected function doMembershipProcessing($contactID, $membershipParams, $premiu ); } } - $fieldTypes = array('Contact', 'Organization', 'Membership'); + $fieldTypes = ['Contact', 'Organization', 'Membership']; } $priceFieldIds = $this->get('memberPriceFieldIDS'); @@ -2386,8 +2386,8 @@ protected function doMembershipProcessing($contactID, $membershipParams, $premiu if (!empty($priceFieldIds)) { $membershipParams['financial_type_id'] = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $priceFieldIds['id'], 'financial_type_id'); unset($priceFieldIds['id']); - $membershipTypeIds = array(); - $membershipTypeTerms = array(); + $membershipTypeIds = []; + $membershipTypeTerms = []; foreach ($priceFieldIds as $priceFieldId) { $membershipTypeId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceFieldValue', $priceFieldId, 'membership_type_id'); if ($membershipTypeId) { @@ -2403,7 +2403,7 @@ protected function doMembershipProcessing($contactID, $membershipParams, $premiu // CRM-12233 $membershipLineItems = $formLineItems; if ($this->_separateMembershipPayment && $this->_values['amount_block_is_active']) { - $membershipLineItems = array(); + $membershipLineItems = []; foreach ($this->_values['fee'] as $key => $feeValues) { if ($feeValues['name'] == 'membership_amount') { $fieldId = $this->_params['price_' . $key]; @@ -2455,7 +2455,7 @@ protected function doMembershipProcessing($contactID, $membershipParams, $premiu protected function completeTransaction($result, $contributionID) { if (CRM_Utils_Array::value('payment_status_id', $result) == 1) { try { - civicrm_api3('contribution', 'completetransaction', array( + civicrm_api3('contribution', 'completetransaction', [ 'id' => $contributionID, 'trxn_id' => CRM_Utils_Array::value('trxn_id', $result), 'payment_processor_id' => CRM_Utils_Array::value('payment_processor_id', $result, $this->_paymentProcessor['id']), @@ -2464,7 +2464,7 @@ protected function completeTransaction($result, $contributionID) { 'receive_date' => CRM_Utils_Array::value('receive_date', $result), 'card_type_id' => CRM_Utils_Array::value('card_type_id', $result), 'pan_truncation' => CRM_Utils_Array::value('pan_truncation', $result), - )); + ]); } catch (CiviCRM_API3_Exception $e) { if ($e->getErrorCode() != 'contribution_completed') { diff --git a/CRM/Contribute/Form/Contribution/Main.php b/CRM/Contribute/Form/Contribution/Main.php index 0115fab9a93a..4fd859f9bf01 100644 --- a/CRM/Contribute/Form/Contribution/Main.php +++ b/CRM/Contribute/Form/Contribution/Main.php @@ -51,7 +51,7 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu * Array of payment related fields to potentially display on this form (generally credit card or debit card fields). This is rendered via billingBlock.tpl * @var array */ - public $_paymentFields = array(); + public $_paymentFields = []; protected $_paymentProcessorID; protected $_snippet; @@ -103,8 +103,8 @@ public function setDefaultValues() { $contactID = $this->getContactID(); if (!empty($contactID)) { - $fields = array(); - $removeCustomFieldTypes = array('Contribution', 'Membership'); + $fields = []; + $removeCustomFieldTypes = ['Contribution', 'Membership']; $contribFields = CRM_Contribute_BAO_Contribution::getContributionFields(); // remove component related fields @@ -152,7 +152,7 @@ public function setDefaultValues() { //build set default for pledge overdue payment. if (!empty($this->_values['pledge_id'])) { //used to record completed pledge payment ids used later for honor default - $completedContributionIds = array(); + $completedContributionIds = []; $pledgePayments = CRM_Pledge_BAO_PledgePayment::getPledgePayments($this->_values['pledge_id']); $paymentAmount = 0; @@ -174,7 +174,7 @@ public function setDefaultValues() { $this->_defaults['price_' . $this->_priceSetId] = $paymentAmount; if (count($completedContributionIds)) { - $softCredit = array(); + $softCredit = []; foreach ($completedContributionIds as $id) { $softCredit = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($id); } @@ -217,7 +217,7 @@ public function setDefaultValues() { $entityId = $memtypeID = NULL; if ($this->_priceSetId) { if (($this->_useForMember && !empty($this->_currentMemberships)) || $this->_defaultMemTypeId) { - $selectedCurrentMemTypes = array(); + $selectedCurrentMemTypes = []; foreach ($this->_priceSet['fields'] as $key => $val) { foreach ($val['options'] as $keys => $values) { $opMemTypeId = CRM_Utils_Array::value('membership_type_id', $values); @@ -327,7 +327,7 @@ public function buildQuickForm() { if ($this->_emailExists == FALSE) { $this->add('text', "email-{$this->_bltID}", ts('Email Address'), - array('size' => 30, 'maxlength' => 60, 'class' => 'email'), + ['size' => 30, 'maxlength' => 60, 'class' => 'email'], TRUE ); $this->assign('showMainEmail', TRUE); @@ -336,9 +336,9 @@ public function buildQuickForm() { } else { $this->addElement('hidden', "email-{$this->_bltID}", 1); - $this->add('text', 'total_amount', ts('Total Amount'), array('readonly' => TRUE), FALSE); + $this->add('text', 'total_amount', ts('Total Amount'), ['readonly' => TRUE], FALSE); } - $pps = array(); + $pps = []; //@todo - this should be replaced by a check as to whether billing fields are set $onlinePaymentProcessorEnabled = FALSE; if (!empty($this->_paymentProcessors)) { @@ -451,7 +451,7 @@ public function buildQuickForm() { $this->_values['custom_post_id'] ) { if (!is_array($this->_values['custom_post_id'])) { - $profileIDs = array($this->_values['custom_post_id']); + $profileIDs = [$this->_values['custom_post_id']]; } else { $profileIDs = $this->_values['custom_post_id']; @@ -471,7 +471,7 @@ public function buildQuickForm() { } if ($this->_pcpId && empty($this->_ccid)) { if ($pcpSupporter = CRM_PCP_BAO_PCP::displayName($this->_pcpId)) { - $pcp_supporter_text = ts('This contribution is being made thanks to the effort of %1, who supports our campaign.', array(1 => $pcpSupporter)); + $pcp_supporter_text = ts('This contribution is being made thanks to the effort of %1, who supports our campaign.', [1 => $pcpSupporter]); // Only tell people that can also create a PCP if the contribution page has a non-empty value in the "Create Personal Campaign Page link" field. $text = CRM_PCP_BAO_PCP::getPcpBlockStatus($this->_id, 'contribute'); if (!empty($text)) { @@ -479,21 +479,21 @@ public function buildQuickForm() { } $this->assign('pcpSupporterText', $pcp_supporter_text); } - $prms = array('id' => $this->_pcpId); + $prms = ['id' => $this->_pcpId]; CRM_Core_DAO::commonRetrieve('CRM_PCP_DAO_PCP', $prms, $pcpInfo); if ($pcpInfo['is_honor_roll']) { $this->assign('isHonor', TRUE); $this->add('checkbox', 'pcp_display_in_roll', ts('Show my contribution in the public honor roll'), NULL, NULL, - array('onclick' => "showHideByValue('pcp_display_in_roll','','nameID|nickID|personalNoteID','block','radio',false); pcpAnonymous( );") + ['onclick' => "showHideByValue('pcp_display_in_roll','','nameID|nickID|personalNoteID','block','radio',false); pcpAnonymous( );"] ); - $extraOption = array('onclick' => "return pcpAnonymous( );"); - $elements = array(); + $extraOption = ['onclick' => "return pcpAnonymous( );"]; + $elements = []; $elements[] = &$this->createElement('radio', NULL, '', ts('Include my name and message'), 0, $extraOption); $elements[] = &$this->createElement('radio', NULL, '', ts('List my contribution anonymously'), 1, $extraOption); $this->addGroup($elements, 'pcp_is_anonymous', NULL, '   '); - $this->add('text', 'pcp_roll_nickname', ts('Name'), array('maxlength' => 30)); - $this->addField('pcp_personal_note', array('entity' => 'ContributionSoft', 'context' => 'create', 'style' => 'height: 3em; width: 40em;')); + $this->add('text', 'pcp_roll_nickname', ts('Name'), ['maxlength' => 30]); + $this->addField('pcp_personal_note', ['entity' => 'ContributionSoft', 'context' => 'create', 'style' => 'height: 3em; width: 40em;']); } } if (empty($this->_values['fee']) && empty($this->_ccid)) { @@ -520,24 +520,24 @@ public function buildQuickForm() { } if (!($allAreBillingModeProcessors && !$this->_values['is_pay_later'])) { - $submitButton = array( + $submitButton = [ 'type' => 'upload', 'name' => CRM_Utils_Array::value('is_confirm_enabled', $this->_values) ? ts('Confirm Contribution') : ts('Contribute'), 'spacing' => '         ', 'isDefault' => TRUE, - ); + ]; // Add submit-once behavior when confirm page disabled if (empty($this->_values['is_confirm_enabled'])) { - $submitButton['js'] = array('onclick' => "return submitOnce(this,'" . $this->_name . "','" . ts('Processing') . "');"); + $submitButton['js'] = ['onclick' => "return submitOnce(this,'" . $this->_name . "','" . ts('Processing') . "');"]; } //change button name for updating contribution if (!empty($this->_ccid)) { $submitButton['name'] = ts('Confirm Payment'); } - $this->addButtons(array($submitButton)); + $this->addButtons([$submitButton]); } - $this->addFormRule(array('CRM_Contribute_Form_Contribution_Main', 'formRule'), $this); + $this->addFormRule(['CRM_Contribute_Form_Contribution_Main', 'formRule'], $this); } /** @@ -554,10 +554,10 @@ public static function buildRecur(&$form) { $form->assign('is_recur_installments', CRM_Utils_Array::value('is_recur_installments', $form->_values)); $paymentObject = $form->getVar('_paymentObject'); if ($paymentObject) { - $form->assign('recurringHelpText', $paymentObject->getText('contributionPageRecurringHelp', array( + $form->assign('recurringHelpText', $paymentObject->getText('contributionPageRecurringHelp', [ 'is_recur_installments' => !empty($form->_values['is_recur_installments']), 'is_email_receipt' => !empty($form->_values['is_email_receipt']), - ))); + ])); } $form->add('checkbox', 'is_recur', ts('I want to contribute this amount'), NULL); @@ -594,7 +594,7 @@ public static function buildRecur(&$form) { } else { $form->assign('one_frequency_unit', FALSE); - $units = array(); + $units = []; $frequencyUnits = CRM_Core_OptionGroup::values('recur_frequency_units', FALSE, FALSE, TRUE); foreach ($unitVals as $key => $val) { if (array_key_exists($val, $frequencyUnits)) { @@ -632,7 +632,7 @@ public static function buildRecur(&$form) { * true if no errors, else array of errors */ public static function formRule($fields, $files, $self) { - $errors = array(); + $errors = []; $amount = self::computeAmount($fields, $self->_values); if (CRM_Utils_Array::value('auto_renew', $fields) && CRM_Utils_Array::value('payment_processor_id', $fields) == 0 @@ -652,7 +652,7 @@ public static function formRule($fields, $files, $self) { $membershipOrgDetails = CRM_Member_BAO_MembershipType::getMembershipTypeOrganization(); - $unallowedOrgs = array(); + $unallowedOrgs = []; foreach (array_keys($lifeMember) as $memTypeId) { $unallowedOrgs[] = $membershipOrgDetails[$memTypeId]; } @@ -665,7 +665,7 @@ public static function formRule($fields, $files, $self) { $priceField->orderBy('weight'); $priceField->find(); - $check = array(); + $check = []; $membershipIsActive = TRUE; $previousId = $otherAmount = FALSE; while ($priceField->fetch()) { @@ -688,12 +688,12 @@ public static function formRule($fields, $files, $self) { $max = CRM_Utils_Array::value('max_amount', $self->_values); if ($min && $otherAmountVal < $min) { $errors["price_{$priceField->id}"] = ts('Contribution amount must be at least %1', - array(1 => $min) + [1 => $min] ); } if ($max && $otherAmountVal > $max) { $errors["price_{$priceField->id}"] = ts('Contribution amount cannot be more than %1.', - array(1 => $max) + [1 => $max] ); } } @@ -713,7 +713,7 @@ public static function formRule($fields, $files, $self) { // For anonymous user check using dedupe rule // if user has Cancelled Membership if (!$memContactID) { - $memContactID = CRM_Contact_BAO_Contact::getFirstDuplicateContact($fields, 'Individual', 'Unsupervised', array(), FALSE); + $memContactID = CRM_Contact_BAO_Contact::getFirstDuplicateContact($fields, 'Individual', 'Unsupervised', [], FALSE); } $currentMemberships = CRM_Member_BAO_Membership::getContactsCancelledMembership($memContactID, $is_test @@ -726,7 +726,7 @@ public static function formRule($fields, $files, $self) { if (array_key_exists('membership_type_id', $fieldValue['options'][$fields['price_' . $fieldKey]]) && in_array($fieldValue['options'][$fields['price_' . $fieldKey]]['membership_type_id'], $currentMemberships) ) { - $errors['price_' . $fieldKey] = ts($errorText, array(1 => CRM_Member_PseudoConstant::membershipType($fieldValue['options'][$fields['price_' . $fieldKey]]['membership_type_id']))); + $errors['price_' . $fieldKey] = ts($errorText, [1 => CRM_Member_PseudoConstant::membershipType($fieldValue['options'][$fields['price_' . $fieldKey]]['membership_type_id'])]); } } else { @@ -735,7 +735,7 @@ public static function formRule($fields, $files, $self) { if (array_key_exists('membership_type_id', $fieldValue['options'][$key]) && in_array($fieldValue['options'][$key]['membership_type_id'], $currentMemberships) ) { - $errors['price_' . $fieldKey] = ts($errorText, array(1 => CRM_Member_PseudoConstant::membershipType($fieldValue['options'][$key]['membership_type_id']))); + $errors['price_' . $fieldKey] = ts($errorText, [1 => CRM_Member_PseudoConstant::membershipType($fieldValue['options'][$key]['membership_type_id'])]); } } } @@ -785,8 +785,8 @@ public static function formRule($fields, $files, $self) { } if ($self->_useForMember == 1 && !empty($check) && $membershipIsActive) { - $priceFieldIDS = array(); - $priceFieldMemTypes = array(); + $priceFieldIDS = []; + $priceFieldMemTypes = []; foreach ($self->_priceSet['fields'] as $priceId => $value) { if (!empty($fields['price_' . $priceId]) || ($self->_quickConfig && $value['name'] == 'membership_amount' && empty($self->_membershipBlock['is_required']))) { @@ -855,9 +855,9 @@ public static function formRule($fields, $files, $self) { $errors['_qf_default'] = ts('Contribution can not be less than zero. Please select the options accordingly'); } elseif (!empty($minAmt) && $fields['amount'] < $minAmt) { - $errors['_qf_default'] = ts('A minimum amount of %1 should be selected from Contribution(s).', array( + $errors['_qf_default'] = ts('A minimum amount of %1 should be selected from Contribution(s).', [ 1 => CRM_Utils_Money::format($minAmt), - )); + ]); } $amount = $fields['amount']; @@ -872,7 +872,7 @@ public static function formRule($fields, $files, $self) { $min_amount = $productDAO->min_contribution; if ($amount < $min_amount) { - $errors['selectProduct'] = ts('The premium you have selected requires a minimum contribution of %1', array(1 => CRM_Utils_Money::format($min_amount))); + $errors['selectProduct'] = ts('The premium you have selected requires a minimum contribution of %1', [1 => CRM_Utils_Money::format($min_amount)]); CRM_Core_Session::setStatus($errors['selectProduct']); } } @@ -968,7 +968,7 @@ public static function formRule($fields, $files, $self) { $customizedValue = CRM_Core_PseudoConstant::getKey('CRM_Contact_BAO_Contact', $greeting . '_id', 'Customized'); if ($customizedValue == $greetingType && empty($fielse[$greeting . '_custom'])) { $errors[$greeting . '_custom'] = ts('Custom %1 is a required field if %1 is of type Customized.', - array(1 => ucwords(str_replace('_', " ", $greeting))) + [1 => ucwords(str_replace('_', " ", $greeting))] ); } } @@ -1059,7 +1059,7 @@ public function submit($params) { $priceField->orderBy('weight'); $priceField->find(); - $priceOptions = array(); + $priceOptions = []; while ($priceField->fetch()) { CRM_Price_BAO_PriceFieldValue::getValues($priceField->id, $priceOptions); if (($selectedPriceOptionID = CRM_Utils_Array::value("price_{$priceField->id}", $params)) != FALSE && $selectedPriceOptionID > 0) { @@ -1151,7 +1151,7 @@ public function submit($params) { $this->set('lineItem', $this->_lineItem); } elseif ($priceSetId = CRM_Utils_Array::value('priceSetId', $params)) { - $lineItem = array(); + $lineItem = []; $is_quick_config = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $priceSetId, 'is_quick_config'); if ($is_quick_config) { foreach ($this->_values['fee'] as $key => & $val) { diff --git a/CRM/Contribute/Form/Contribution/ThankYou.php b/CRM/Contribute/Form/Contribution/ThankYou.php index f393a4c0a9a2..a82579729ab2 100644 --- a/CRM/Contribute/Form/Contribution/ThankYou.php +++ b/CRM/Contribute/Form/Contribution/ThankYou.php @@ -147,7 +147,7 @@ public function buildQuickForm() { $this->assign('soft_credit_type', $softCreditTypes[$params['soft_credit_type_id']]); CRM_Contribute_BAO_ContributionSoft::formatHonoreeProfileFields($this, $params['honor']); - $fieldTypes = array('Contact'); + $fieldTypes = ['Contact']; $fieldTypes[] = CRM_Core_BAO_UFGroup::getContactType($this->_values['honoree_profile_id']); $this->buildCustom($this->_values['honoree_profile_id'], 'honoreeProfileFields', TRUE, 'honor', $fieldTypes); } @@ -157,12 +157,12 @@ public function buildQuickForm() { if ($this->_pcpId) { $qParams .= "&pcpId={$this->_pcpId}"; $this->assign('pcpBlock', TRUE); - foreach (array( + foreach ([ 'pcp_display_in_roll', 'pcp_is_anonymous', 'pcp_roll_nickname', 'pcp_personal_note', - ) as $val) { + ] as $val) { if (!empty($this->_params[$val])) { $this->assign($val, $this->_params[$val]); } @@ -205,14 +205,14 @@ public function buildQuickForm() { !empty($params['is_for_organization']) ) && empty($this->_ccid) ) { - $fieldTypes = array('Contact', 'Organization'); + $fieldTypes = ['Contact', 'Organization']; $contactSubType = CRM_Contact_BAO_ContactType::subTypes('Organization'); $fieldTypes = array_merge($fieldTypes, $contactSubType); if (is_array($this->_membershipBlock) && !empty($this->_membershipBlock)) { - $fieldTypes = array_merge($fieldTypes, array('Membership')); + $fieldTypes = array_merge($fieldTypes, ['Membership']); } else { - $fieldTypes = array_merge($fieldTypes, array('Contribution')); + $fieldTypes = array_merge($fieldTypes, ['Contribution']); } $this->buildCustom($this->_values['onbehalf_profile_id'], 'onbehalfProfile', TRUE, 'onbehalf', $fieldTypes); @@ -226,8 +226,8 @@ public function buildQuickForm() { CRM_Utils_Date::mysqlToIso(CRM_Utils_Array::value('receive_date', $this->_params)) ); - $defaults = array(); - $fields = array(); + $defaults = []; + $fields = []; foreach ($this->_fields as $name => $dontCare) { if ($name != 'onbehalf' || $name != 'honor') { $fields[$name] = 1; @@ -245,11 +245,11 @@ public function buildQuickForm() { $defaults[$timeField] = $contact[$timeField]; } } - elseif (in_array($name, array( + elseif (in_array($name, [ 'addressee', 'email_greeting', 'postal_greeting', - )) && !empty($contact[$name . '_custom']) + ]) && !empty($contact[$name . '_custom']) ) { $defaults[$name . '_custom'] = $contact[$name . '_custom']; } @@ -296,12 +296,12 @@ public function buildQuickForm() { $isPendingOutcome = TRUE; try { // A payment notification update could have come in at any time. Check at the last minute. - $contributionStatusID = civicrm_api3('Contribution', 'getvalue', array( + $contributionStatusID = civicrm_api3('Contribution', 'getvalue', [ 'id' => CRM_Utils_Array::value('contributionID', $params), 'return' => 'contribution_status_id', 'is_test' => ($this->_mode == 'test') ? 1 : 0, 'invoice_id' => CRM_Utils_Array::value('invoiceID', $params), - )); + ]); if (CRM_Core_PseudoConstant::getName('CRM_Contribute_BAO_Contribution', 'contribution_status_id', $contributionStatusID) === 'Pending' && !empty($params['payment_processor_id']) ) { diff --git a/CRM/Contribute/Form/ContributionBase.php b/CRM/Contribute/Form/ContributionBase.php index 3e40cafd8faa..4b22fae1a430 100644 --- a/CRM/Contribute/Form/ContributionBase.php +++ b/CRM/Contribute/Form/ContributionBase.php @@ -92,14 +92,14 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form { * * @var array */ - public $_params = array(); + public $_params = []; /** * The fields involved in this contribution page * * @var array */ - public $_fields = array(); + public $_fields = []; /** * The billing location id for this contribution page. @@ -308,8 +308,8 @@ public function preProcess() { if (!$this->_values) { // get all the values from the dao object - $this->_values = array(); - $this->_fields = array(); + $this->_values = []; + $this->_fields = []; CRM_Contribute_BAO_ContributionPage::setValues($this->_id, $this->_values); if (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus() @@ -362,11 +362,11 @@ public function preProcess() { CRM_Price_BAO_PriceSet::initSet($this, $this->_id, 'civicrm_contribution_page'); // this avoids getting E_NOTICE errors in php - $setNullFields = array( + $setNullFields = [ 'amount_block_is_active', 'is_allow_other_amount', 'footer_text', - ); + ]; foreach ($setNullFields as $f) { if (!isset($this->_values[$f])) { $this->_values[$f] = NULL; @@ -473,7 +473,7 @@ public function preProcess() { ); $this->setTitle(($this->_pcpId ? $this->_pcpInfo['title'] : $this->_values['title'])); - $this->_defaults = array(); + $this->_defaults = []; $this->_amount = $this->get('amount'); // Assigning this to the template means it will be passed through to the payment form. @@ -521,23 +521,23 @@ public function assignToTemplate() { $this->set('name', $this->assignBillingName($this->_params)); $this->assign('paymentProcessor', $this->_paymentProcessor); - $vars = array( + $vars = [ 'amount', 'currencyID', 'credit_card_type', 'trxn_id', 'amount_level', - ); + ]; $config = CRM_Core_Config::singleton(); if (isset($this->_values['is_recur']) && !empty($this->_paymentProcessor['is_recur'])) { $this->assign('is_recur_enabled', 1); - $vars = array_merge($vars, array( + $vars = array_merge($vars, [ 'is_recur', 'frequency_interval', 'frequency_unit', 'installments', - )); + ]); } if (in_array('CiviPledge', $config->enableComponents) && @@ -545,12 +545,12 @@ public function assignToTemplate() { ) { $this->assign('pledge_enabled', 1); - $vars = array_merge($vars, array( + $vars = array_merge($vars, [ 'is_pledge', 'pledge_frequency_interval', 'pledge_frequency_unit', 'pledge_installments', - )); + ]); } // @todo - stop setting amount level in this function & call the CRM_Price_BAO_PriceSet::getAmountLevel @@ -607,7 +607,7 @@ public function buildCustom($id, $name, $viewOnly = FALSE, $profileContactType = // we don't allow conflicting fields to be // configured via profile - CRM 2100 - $fieldsToIgnore = array( + $fieldsToIgnore = [ 'receive_date' => 1, 'trxn_id' => 1, 'invoice_id' => 1, @@ -623,7 +623,7 @@ public function buildCustom($id, $name, $viewOnly = FALSE, $profileContactType = 'payment_instrument_id' => 1, 'contribution_check_number' => 1, 'financial_type' => 1, - ); + ]; $fields = CRM_Core_BAO_UFGroup::getFields($id, FALSE, CRM_Core_Action::ADD, NULL, NULL, FALSE, NULL, FALSE, NULL, CRM_Core_Permission::CREATE, NULL @@ -633,7 +633,7 @@ public function buildCustom($id, $name, $viewOnly = FALSE, $profileContactType = // determine if email exists in profile so we know if we need to manually insert CRM-2888, CRM-15067 foreach ($fields as $key => $field) { if (substr($key, 0, 6) == 'email-' && - !in_array($profileContactType, array('honor', 'onbehalf')) + !in_array($profileContactType, ['honor', 'onbehalf']) ) { $this->_emailExists = TRUE; $this->set('emailExists', TRUE); @@ -646,14 +646,14 @@ public function buildCustom($id, $name, $viewOnly = FALSE, $profileContactType = } //remove common fields only if profile is not configured for onbehalf/honor - if (!in_array($profileContactType, array('honor', 'onbehalf'))) { + if (!in_array($profileContactType, ['honor', 'onbehalf'])) { $fields = array_diff_key($fields, $this->_fields); } CRM_Core_BAO_Address::checkContactSharedAddressFields($fields, $contactID); $addCaptcha = FALSE; // fetch file preview when not submitted yet, like in online contribution Confirm and ThankYou page - $viewOnlyFileValues = empty($profileContactType) ? array() : array($profileContactType => array()); + $viewOnlyFileValues = empty($profileContactType) ? [] : [$profileContactType => []]; foreach ($fields as $key => $field) { if ($viewOnly && isset($field['data_type']) && @@ -686,14 +686,14 @@ public function buildCustom($id, $name, $viewOnly = FALSE, $profileContactType = if ($profileContactType) { //Since we are showing honoree name separately so we are removing it from honoree profile just for display if ($profileContactType == 'honor') { - $honoreeNamefields = array( + $honoreeNamefields = [ 'prefix_id', 'first_name', 'last_name', 'suffix_id', 'organization_name', 'household_name', - ); + ]; if (in_array($field['name'], $honoreeNamefields)) { unset($fields[$field['name']]); continue; @@ -842,7 +842,7 @@ public function buildComponentForm($id, $form) { $contactID = $this->getContactID(); - foreach (array('soft_credit', 'on_behalf') as $module) { + foreach (['soft_credit', 'on_behalf'] as $module) { if ($module == 'soft_credit') { if (empty($form->_values['honoree_profile_id'])) { continue; @@ -853,17 +853,17 @@ public function buildComponentForm($id, $form) { } $profileContactType = CRM_Core_BAO_UFGroup::getContactType($form->_values['honoree_profile_id']); - $requiredProfileFields = array( - 'Individual' => array('first_name', 'last_name'), - 'Organization' => array('organization_name', 'email'), - 'Household' => array('household_name', 'email'), - ); + $requiredProfileFields = [ + 'Individual' => ['first_name', 'last_name'], + 'Organization' => ['organization_name', 'email'], + 'Household' => ['household_name', 'email'], + ]; $validProfile = CRM_Core_BAO_UFGroup::checkValidProfile($form->_values['honoree_profile_id'], $requiredProfileFields[$profileContactType]); if (!$validProfile) { CRM_Core_Error::fatal(ts('This contribution page has been configured for contribution on behalf of honoree and the required fields of the selected honoree profile are disabled or doesn\'t exist.')); } - foreach (array('honor_block_title', 'honor_block_text') as $name) { + foreach (['honor_block_title', 'honor_block_text'] as $name) { $form->assign($name, $form->_values[$name]); } @@ -910,11 +910,11 @@ public function buildComponentForm($id, $form) { $msg = ts('Mixed profile not allowed for on behalf of registration/sign up.'); $onBehalfProfile = CRM_Core_BAO_UFGroup::profileGroups($form->_values['onbehalf_profile_id']); foreach ( - array( + [ 'Individual', 'Organization', 'Household', - ) as $contactType + ] as $contactType ) { if (in_array($contactType, $onBehalfProfile) && (in_array('Membership', $onBehalfProfile) || @@ -932,17 +932,17 @@ public function buildComponentForm($id, $form) { if (count($organizations)) { // Related org url - pass checksum if needed - $args = array( + $args = [ 'ufId' => $form->_values['onbehalf_profile_id'], 'cid' => '', - ); + ]; if (!empty($_GET['cs'])) { - $args = array( + $args = [ 'ufId' => $form->_values['onbehalf_profile_id'], 'uid' => $this->_contactID, 'cs' => $_GET['cs'], 'cid' => '', - ); + ]; } $locDataURL = CRM_Utils_System::url('civicrm/ajax/permlocation', $args, FALSE, NULL, FALSE); $form->assign('locDataURL', $locDataURL); @@ -950,12 +950,12 @@ public function buildComponentForm($id, $form) { if (count($organizations) > 0) { $form->add('select', 'onbehalfof_id', '', CRM_Utils_Array::collect('name', $organizations)); - $orgOptions = array( + $orgOptions = [ 0 => ts('Select an existing organization'), 1 => ts('Enter a new organization'), - ); + ]; $form->addRadio('org_option', ts('options'), $orgOptions); - $form->setDefaults(array('org_option' => 0)); + $form->setDefaults(['org_option' => 0]); } } @@ -988,9 +988,9 @@ public function buildComponentForm($id, $form) { $form->assign('submittedOnBehalfInfo', json_encode(str_replace('"', '\"', $form->_submitValues['onbehalf']), JSON_HEX_APOS)); } - $fieldTypes = array('Contact', 'Organization'); + $fieldTypes = ['Contact', 'Organization']; if (!empty($form->_membershipBlock)) { - $fieldTypes = array_merge($fieldTypes, array('Membership')); + $fieldTypes = array_merge($fieldTypes, ['Membership']); } $contactSubType = CRM_Contact_BAO_ContactType::subTypes('Organization'); $fieldTypes = array_merge($fieldTypes, $contactSubType); @@ -998,7 +998,7 @@ public function buildComponentForm($id, $form) { foreach ($profileFields as $name => $field) { if (in_array($field['field_type'], $fieldTypes)) { list($prefixName, $index) = CRM_Utils_System::explode('-', $name, 2); - if (in_array($prefixName, array('organization_name', 'email')) && empty($field['is_required'])) { + if (in_array($prefixName, ['organization_name', 'email']) && empty($field['is_required'])) { $field['is_required'] = 1; } if (count($form->_submitValues) && @@ -1066,18 +1066,18 @@ public function authenticatePledgeUser() { $contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this); //get pledge status and contact id - $pledgeValues = array(); - $pledgeParams = array('id' => $this->_values['pledge_id']); - $returnProperties = array('contact_id', 'status_id'); + $pledgeValues = []; + $pledgeParams = ['id' => $this->_values['pledge_id']]; + $returnProperties = ['contact_id', 'status_id']; CRM_Core_DAO::commonRetrieve('CRM_Pledge_DAO_Pledge', $pledgeParams, $pledgeValues, $returnProperties); //get all status $allStatus = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name'); - $validStatus = array( + $validStatus = [ array_search('Pending', $allStatus), array_search('In Progress', $allStatus), array_search('Overdue', $allStatus), - ); + ]; $validUser = FALSE; if ($this->_userID && @@ -1102,7 +1102,7 @@ public function authenticatePledgeUser() { //check for valid pledge status. if (!in_array($pledgeValues['status_id'], $validStatus)) { - CRM_Core_Error::fatal(ts('Oops. You cannot make a payment for this pledge - pledge status is %1.', array(1 => CRM_Utils_Array::value($pledgeValues['status_id'], $allStatus)))); + CRM_Core_Error::fatal(ts('Oops. You cannot make a payment for this pledge - pledge status is %1.', [1 => CRM_Utils_Array::value($pledgeValues['status_id'], $allStatus)])); } } @@ -1156,13 +1156,13 @@ protected function buildMembershipBlock( $separateMembershipPayment = FALSE; if ($this->_membershipBlock) { - $this->_currentMemberships = array(); + $this->_currentMemberships = []; - $membershipTypeIds = $membershipTypes = $radio = array(); + $membershipTypeIds = $membershipTypes = $radio = []; $membershipPriceset = (!empty($this->_priceSetId) && $this->_useForMember) ? TRUE : FALSE; $allowAutoRenewMembership = $autoRenewOption = FALSE; - $autoRenewMembershipTypeOptions = array(); + $autoRenewMembershipTypeOptions = []; $separateMembershipPayment = CRM_Utils_Array::value('is_separate_payment', $this->_membershipBlock); @@ -1234,7 +1234,7 @@ protected function buildMembershipBlock( elseif ($memType['is_active']) { if ($allowAutoRenewOpt) { - $javascriptMethod = array('onclick' => "return showHideAutoRenew( this.value );"); + $javascriptMethod = ['onclick' => "return showHideAutoRenew( this.value );"]; $autoRenewMembershipTypeOptions["autoRenewMembershipType_{$value}"] = (int) $memType['auto_renew'] * CRM_Utils_Array::value($value, CRM_Utils_Array::value('auto_renew', $this->_membershipBlock)); $allowAutoRenewMembership = TRUE; } @@ -1316,7 +1316,7 @@ protected function buildMembershipBlock( } elseif ($this->_membershipBlock['is_required'] && count($radio) == 1) { $temp = array_keys($radio); - $this->add('hidden', 'selectMembership', $temp[0], array('id' => 'selectMembership')); + $this->add('hidden', 'selectMembership', $temp[0], ['id' => 'selectMembership']); $this->assign('singleMembership', TRUE); $this->assign('showRadio', FALSE); } diff --git a/CRM/Contribute/Form/ContributionCharts.php b/CRM/Contribute/Form/ContributionCharts.php index 24283e37df6a..f8c10cd1ccd8 100644 --- a/CRM/Contribute/Form/ContributionCharts.php +++ b/CRM/Contribute/Form/ContributionCharts.php @@ -65,17 +65,17 @@ public function preProcess() { public function buildQuickForm() { //p3 = Three dimensional pie chart. //bvg = Vertical bar chart - $this->addElement('select', 'chart_type', ts('Chart Style'), array( + $this->addElement('select', 'chart_type', ts('Chart Style'), [ 'bvg' => ts('Bar'), 'p3' => ts('Pie'), - ) + ] ); $defaultValues['chart_type'] = $this->_chartType; $this->setDefaults($defaultValues); //take available years from database to show in drop down $currentYear = date('Y'); - $years = array(); + $years = []; if (!empty($this->_years)) { if (!array_key_exists($currentYear, $this->_years)) { $this->_years[$currentYear] = $currentYear; @@ -87,9 +87,9 @@ public function buildQuickForm() { } $this->addElement('select', 'select_year', ts('Select Year (for monthly breakdown)'), $years); - $this->setDefaults(array( + $this->setDefaults([ 'select_year' => ($this->_year) ? $this->_year : $currentYear, - )); + ]); } /** @@ -109,7 +109,7 @@ public function postProcess() { //take contribution information monthly $chartInfoMonthly = CRM_Contribute_BAO_Contribution_Utils::contributionChartMonthly($selectedYear); - $chartData = $abbrMonthNames = array(); + $chartData = $abbrMonthNames = []; if (is_array($chartInfoMonthly)) { for ($i = 1; $i <= 12; $i++) { $abbrMonthNames[$i] = strftime('%b', mktime(0, 0, 0, $i, 10, 1970)); @@ -186,7 +186,7 @@ public function postProcess() { $urlParams = NULL; if ($chartKey == 'by_month') { $monthPosition = array_search($index, $abbrMonthNames); - $startDate = CRM_Utils_Date::format(array('Y' => $selectedYear, 'M' => $monthPosition)); + $startDate = CRM_Utils_Date::format(['Y' => $selectedYear, 'M' => $monthPosition]); $endDate = date('Ymd', mktime(0, 0, 0, $monthPosition + 1, 0, $selectedYear)); $urlParams = "reset=1&force=1&status=1&start={$startDate}&end={$endDate}&test=0"; } @@ -196,7 +196,7 @@ public function postProcess() { $endDate = date('Ymd', mktime(0, 0, 0, $config->fiscalYearStart['M'], $config->fiscalYearStart['d'], (substr($index, 0, 4)) + 1)); } else { - $startDate = CRM_Utils_Date::format(array('Y' => substr($index, 0, 4))); + $startDate = CRM_Utils_Date::format(['Y' => substr($index, 0, 4)]); $endDate = date('Ymd', mktime(0, 0, 0, 13, 0, substr($index, 0, 4))); } $urlParams = "reset=1&force=1&status=1&start={$startDate}&end={$endDate}&test=0"; @@ -225,7 +225,7 @@ public function postProcess() { $xSize = 150; } } - $values['size'] = array('xSize' => $xSize, 'ySize' => $ySize); + $values['size'] = ['xSize' => $xSize, 'ySize' => $ySize]; } // finally assign this chart data to template. diff --git a/CRM/Contribute/Form/ContributionPage.php b/CRM/Contribute/Form/ContributionPage.php index 0ce526e05636..b426a3b92780 100644 --- a/CRM/Contribute/Form/ContributionPage.php +++ b/CRM/Contribute/Form/ContributionPage.php @@ -120,21 +120,21 @@ public function preProcess() { CRM_Contribute_Form_ContributionPage_TabHeader::build($this); if ($this->_action == CRM_Core_Action::UPDATE) { - CRM_Utils_System::setTitle(ts('Configure Page - %1', array(1 => $title))); + CRM_Utils_System::setTitle(ts('Configure Page - %1', [1 => $title])); } elseif ($this->_action == CRM_Core_Action::VIEW) { - CRM_Utils_System::setTitle(ts('Preview Page - %1', array(1 => $title))); + CRM_Utils_System::setTitle(ts('Preview Page - %1', [1 => $title])); } elseif ($this->_action == CRM_Core_Action::DELETE) { - CRM_Utils_System::setTitle(ts('Delete Page - %1', array(1 => $title))); + CRM_Utils_System::setTitle(ts('Delete Page - %1', [1 => $title])); } //cache values. $this->_values = $this->get('values'); if (!is_array($this->_values)) { - $this->_values = array(); + $this->_values = []; if (isset($this->_id) && $this->_id) { - $params = array('id' => $this->_id); + $params = ['id' => $this->_id]; CRM_Core_DAO::commonRetrieve('CRM_Contribute_DAO_ContributionPage', $params, $this->_values); CRM_Contribute_BAO_ContributionPage::setValues($this->_id, $this->_values); } @@ -150,7 +150,7 @@ public function preProcess() { } // Preload libraries required by the "Profiles" tab - $schemas = array('IndividualModel', 'OrganizationModel', 'ContributionModel'); + $schemas = ['IndividualModel', 'OrganizationModel', 'ContributionModel']; if (in_array('CiviMember', CRM_Core_Config::singleton()->enableComponents)) { $schemas[] = 'MembershipModel'; } @@ -176,53 +176,53 @@ public function buildQuickForm() { } if ($this->_single) { - $buttons = array( - array( + $buttons = [ + [ 'type' => 'next', 'name' => ts('Save'), 'spacing' => '         ', 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'upload', 'name' => ts('Save and Done'), 'spacing' => '         ', 'subName' => 'done', - ), - ); + ], + ]; if (!$this->_last) { - $buttons[] = array( + $buttons[] = [ 'type' => 'submit', 'name' => ts('Save and Next'), 'spacing' => '                 ', 'subName' => 'savenext', - ); + ]; } - $buttons[] = array( + $buttons[] = [ 'type' => 'cancel', 'name' => ts('Cancel'), - ); + ]; $this->addButtons($buttons); } else { - $buttons = array(); + $buttons = []; if (!$this->_first) { - $buttons[] = array( + $buttons[] = [ 'type' => 'back', 'name' => ts('Previous'), 'spacing' => '     ', - ); + ]; } - $buttons[] = array( + $buttons[] = [ 'type' => 'next', 'name' => ts('Continue'), 'spacing' => '         ', 'isDefault' => TRUE, - ); - $buttons[] = array( + ]; + $buttons[] = [ 'type' => 'cancel', 'name' => ts('Cancel'), - ); + ]; $this->addButtons($buttons); } @@ -231,7 +231,7 @@ public function buildQuickForm() { // views are implemented as frozen form if ($this->_action & CRM_Core_Action::VIEW) { $this->freeze(); - $this->addElement('button', 'done', ts('Done'), array('onclick' => "location.href='civicrm/admin/custom/group?reset=1&action=browse'")); + $this->addElement('button', 'done', ts('Done'), ['onclick' => "location.href='civicrm/admin/custom/group?reset=1&action=browse'"]); } // don't show option for contribution amounts section if membership price set @@ -251,7 +251,7 @@ public function buildQuickForm() { } } // set value in DOM that membership price set exists - CRM_Core_Resources::singleton()->addSetting(array('memberPriceset' => $hasMembershipBlk)); + CRM_Core_Resources::singleton()->addSetting(['memberPriceset' => $hasMembershipBlk]); } /** @@ -266,9 +266,9 @@ public function setDefaultValues() { //some child classes calling setdefaults directly w/o preprocess. $this->_values = $this->get('values'); if (!is_array($this->_values)) { - $this->_values = array(); + $this->_values = []; if (isset($this->_id) && $this->_id) { - $params = array('id' => $this->_id); + $params = ['id' => $this->_id]; CRM_Core_DAO::commonRetrieve('CRM_Contribute_DAO_ContributionPage', $params, $this->_values); } $this->set('values', $this->_values); @@ -279,16 +279,16 @@ public function setDefaultValues() { if (isset($this->_id)) { //set defaults for pledgeBlock values. - $pledgeBlockParams = array( + $pledgeBlockParams = [ 'entity_id' => $this->_id, 'entity_table' => ts('civicrm_contribution_page'), - ); - $pledgeBlockDefaults = array(); + ]; + $pledgeBlockDefaults = []; CRM_Pledge_BAO_PledgeBlock::retrieve($pledgeBlockParams, $pledgeBlockDefaults); if ($this->_pledgeBlockID = CRM_Utils_Array::value('id', $pledgeBlockDefaults)) { $defaults['is_pledge_active'] = TRUE; } - $pledgeBlock = array( + $pledgeBlock = [ 'is_pledge_interval', 'max_reminders', 'initial_reminder_day', @@ -296,15 +296,15 @@ public function setDefaultValues() { 'pledge_start_date', 'is_pledge_start_date_visible', 'is_pledge_start_date_editable', - ); + ]; foreach ($pledgeBlock as $key) { $defaults[$key] = CRM_Utils_Array::value($key, $pledgeBlockDefaults); if ($key == 'pledge_start_date' && CRM_Utils_Array::value($key, $pledgeBlockDefaults)) { $defaultPledgeDate = (array) json_decode($pledgeBlockDefaults['pledge_start_date']); - $pledgeDateFields = array( + $pledgeDateFields = [ 'pledge_calendar_date' => 'calendar_date', 'pledge_calendar_month' => 'calendar_month', - ); + ]; $defaults['pledge_default_toggle'] = key($defaultPledgeDate); foreach ($pledgeDateFields as $key => $value) { if (array_key_exists($value, $defaultPledgeDate)) { @@ -349,7 +349,7 @@ public function setDefaultValues() { } else { // CRM-10860 - $defaults['recur_frequency_unit'] = array('month' => 1); + $defaults['recur_frequency_unit'] = ['month' => 1]; } // confirm page starts out enabled @@ -419,7 +419,7 @@ public function endPostProcess() { } CRM_Core_Session::setStatus(ts("'%1' information has been saved.", - array(1 => CRM_Utils_Array::value('title', CRM_Utils_Array::value($subPage, $this->get('tabHeader')), $className)) + [1 => CRM_Utils_Array::value('title', CRM_Utils_Array::value($subPage, $this->get('tabHeader')), $className)] ), ts('Saved'), 'success'); $this->postProcessHook(); diff --git a/CRM/Contribute/Form/ContributionPage/AddProduct.php b/CRM/Contribute/Form/ContributionPage/AddProduct.php index cb55e4da75dc..70adad65a12c 100644 --- a/CRM/Contribute/Form/ContributionPage/AddProduct.php +++ b/CRM/Contribute/Form/ContributionPage/AddProduct.php @@ -68,7 +68,7 @@ public function preProcess() { * Note that in edit/view mode the default values are retrieved from the database. */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; if ($this->_pid) { $dao = new CRM_Contribute_DAO_PremiumsProduct(); @@ -95,7 +95,7 @@ public function setDefaultValues() { $premiumID = $dao->id; $sql = 'SELECT max( weight ) as max_weight FROM civicrm_premiums_product WHERE premiums_id = %1'; - $params = array(1 => array($premiumID, 'Integer')); + $params = [1 => [$premiumID, 'Integer']]; $dao = CRM_Core_DAO::executeQuery($sql, $params); $dao->fetch(); $defaults['weight'] = $dao->max_weight + 1; @@ -123,31 +123,31 @@ public function buildQuickForm() { CRM_Utils_System::redirect($url); } - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => ts('Delete'), 'spacing' => '    ', 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); return; } if ($this->_action & CRM_Core_Action::PREVIEW) { CRM_Contribute_BAO_Premium::buildPremiumPreviewBlock($this, NULL, $this->_pid); - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => ts('Done with Preview'), 'isDefault' => TRUE, - ), - ) + ], + ] ); return; } @@ -161,7 +161,7 @@ public function buildQuickForm() { $this->addElement('text', 'weight', ts('Order'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_PremiumsProduct', 'weight')); $financialType = CRM_Contribute_PseudoConstant::financialType(); - $premiumFinancialType = array(); + $premiumFinancialType = []; CRM_Core_PseudoConstant::populate( $premiumFinancialType, 'CRM_Financial_DAO_EntityFinancialAccount', @@ -171,7 +171,7 @@ public function buildQuickForm() { 'account_relationship = 8' ); - $costFinancialType = array(); + $costFinancialType = []; CRM_Core_PseudoConstant::populate( $costFinancialType, 'CRM_Financial_DAO_EntityFinancialAccount', @@ -195,24 +195,24 @@ public function buildQuickForm() { 'select', 'financial_type_id', ts('Financial Type'), - array('' => ts('- select -')) + $financialType + ['' => ts('- select -')] + $financialType ); $this->addRule('weight', ts('Please enter integer value for weight'), 'integer'); $session->pushUserContext(CRM_Utils_System::url($urlParams, 'action=update&reset=1&id=' . $this->_id)); if ($this->_single) { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => ts('Save'), 'spacing' => '    ', 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); } else { @@ -260,7 +260,7 @@ public function postProcess() { } // updateOtherWeights needs to filter on premiums_id - $filter = array('premiums_id' => $params['premiums_id']); + $filter = ['premiums_id' => $params['premiums_id']]; $params['weight'] = CRM_Utils_Weight::updateOtherWeights('CRM_Contribute_DAO_PremiumsProduct', $oldWeight, $params['weight'], $filter); $dao = new CRM_Contribute_DAO_PremiumsProduct(); diff --git a/CRM/Contribute/Form/ContributionPage/Amount.php b/CRM/Contribute/Form/ContributionPage/Amount.php index 3b24f835f60d..6de2f49ffaa4 100644 --- a/CRM/Contribute/Form/ContributionPage/Amount.php +++ b/CRM/Contribute/Form/ContributionPage/Amount.php @@ -41,7 +41,7 @@ class CRM_Contribute_Form_ContributionPage_Amount extends CRM_Contribute_Form_Co * * @var array */ - protected $_amountBlock = array(); + protected $_amountBlock = []; /** * Constants for number of options for data types of multiple option. @@ -54,28 +54,28 @@ class CRM_Contribute_Form_ContributionPage_Amount extends CRM_Contribute_Form_Co public function buildQuickForm() { // do u want to allow a free form text field for amount - $this->addElement('checkbox', 'is_allow_other_amount', ts('Allow other amounts'), NULL, array('onclick' => "minMax(this);showHideAmountBlock( this, 'is_allow_other_amount' );")); - $this->add('text', 'min_amount', ts('Minimum Amount'), array('size' => 8, 'maxlength' => 8)); - $this->addRule('min_amount', ts('Please enter a valid money value (e.g. %1).', array(1 => CRM_Utils_Money::format('9.99', ' '))), 'money'); + $this->addElement('checkbox', 'is_allow_other_amount', ts('Allow other amounts'), NULL, ['onclick' => "minMax(this);showHideAmountBlock( this, 'is_allow_other_amount' );"]); + $this->add('text', 'min_amount', ts('Minimum Amount'), ['size' => 8, 'maxlength' => 8]); + $this->addRule('min_amount', ts('Please enter a valid money value (e.g. %1).', [1 => CRM_Utils_Money::format('9.99', ' ')]), 'money'); - $this->add('text', 'max_amount', ts('Maximum Amount'), array('size' => 8, 'maxlength' => 8)); - $this->addRule('max_amount', ts('Please enter a valid money value (e.g. %1).', array(1 => CRM_Utils_Money::format('99.99', ' '))), 'money'); + $this->add('text', 'max_amount', ts('Maximum Amount'), ['size' => 8, 'maxlength' => 8]); + $this->addRule('max_amount', ts('Please enter a valid money value (e.g. %1).', [1 => CRM_Utils_Money::format('99.99', ' ')]), 'money'); //CRM-12055 $this->add('text', 'amount_label', ts('Contribution Amounts Label')); - $default = array($this->createElement('radio', NULL, NULL, NULL, 0)); - $this->add('hidden', "price_field_id", '', array('id' => "price_field_id")); - $this->add('hidden', "price_field_other", '', array('id' => "price_field_option")); + $default = [$this->createElement('radio', NULL, NULL, NULL, 0)]; + $this->add('hidden', "price_field_id", '', ['id' => "price_field_id"]); + $this->add('hidden', "price_field_other", '', ['id' => "price_field_option"]); for ($i = 1; $i <= self::NUM_OPTION; $i++) { // label $this->add('text', "label[$i]", ts('Label'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'label')); - $this->add('hidden', "price_field_value[$i]", '', array('id' => "price_field_value[$i]")); + $this->add('hidden', "price_field_value[$i]", '', ['id' => "price_field_value[$i]"]); // value $this->add('text', "value[$i]", ts('Value'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'value')); - $this->addRule("value[$i]", ts('Please enter a valid money value (e.g. %1).', array(1 => CRM_Utils_Money::format('99.99', ' '))), 'money'); + $this->addRule("value[$i]", ts('Please enter a valid money value (e.g. %1).', [1 => CRM_Utils_Money::format('99.99', ' ')]), 'money'); // default $default[] = $this->createElement('radio', NULL, NULL, NULL, $i); @@ -83,12 +83,12 @@ public function buildQuickForm() { $this->addGroup($default, 'default'); - $this->addElement('checkbox', 'amount_block_is_active', ts('Contribution Amounts section enabled'), NULL, array('onclick' => "showHideAmountBlock( this, 'amount_block_is_active' );")); + $this->addElement('checkbox', 'amount_block_is_active', ts('Contribution Amounts section enabled'), NULL, ['onclick' => "showHideAmountBlock( this, 'amount_block_is_active' );"]); $this->addElement('checkbox', 'is_monetary', ts('Execute real-time monetary transactions')); $paymentProcessors = CRM_Financial_BAO_PaymentProcessor::getAllPaymentProcessors('live'); - $recurringPaymentProcessor = $futurePaymentProcessor = $paymentProcessor = array(); + $recurringPaymentProcessor = $futurePaymentProcessor = $paymentProcessor = []; if (!empty($paymentProcessors)) { foreach ($paymentProcessors as $id => $processor) { @@ -116,18 +116,18 @@ public function buildQuickForm() { $this->addCheckBox('payment_processor', ts('Payment Processor'), array_flip($paymentProcessor), NULL, NULL, NULL, NULL, - array('  ', '  ', '  ', '
    ') + ['  ', '  ', '  ', '
    '] ); //check if selected payment processor supports recurring payment if (!empty($recurringPaymentProcessor)) { $this->addElement('checkbox', 'is_recur', ts('Recurring Contributions'), NULL, - array('onclick' => "showHideByValue('is_recur',true,'recurFields','table-row','radio',false);") + ['onclick' => "showHideByValue('is_recur',true,'recurFields','table-row','radio',false);"] ); $this->addCheckBox('recur_frequency_unit', ts('Supported recurring units'), CRM_Core_OptionGroup::values('recur_frequency_units', FALSE, FALSE, TRUE), NULL, NULL, NULL, NULL, - array('  ', '  ', '  ', '
    '), TRUE + ['  ', '  ', '  ', '
    '], TRUE ); $this->addElement('checkbox', 'is_recur_interval', ts('Support recurring intervals')); $this->addElement('checkbox', 'is_recur_installments', ts('Offer installments')); @@ -153,41 +153,41 @@ public function buildQuickForm() { $this->assign('price', TRUE); } $this->add('select', 'price_set_id', ts('Price Set'), - array( + [ '' => ts('- none -'), - ) + $price, - NULL, array('onchange' => "showHideAmountBlock( this.value, 'price_set_id' );") + ] + $price, + NULL, ['onchange' => "showHideAmountBlock( this.value, 'price_set_id' );"] ); //CiviPledge fields. $config = CRM_Core_Config::singleton(); if (in_array('CiviPledge', $config->enableComponents)) { $this->assign('civiPledge', TRUE); $this->addElement('checkbox', 'is_pledge_active', ts('Pledges'), - NULL, array('onclick' => "showHideAmountBlock( this, 'is_pledge_active' ); return showHideByValue('is_pledge_active',true,'pledgeFields','table-row','radio',false);") + NULL, ['onclick' => "showHideAmountBlock( this, 'is_pledge_active' ); return showHideByValue('is_pledge_active',true,'pledgeFields','table-row','radio',false);"] ); $this->addCheckBox('pledge_frequency_unit', ts('Supported pledge frequencies'), CRM_Core_OptionGroup::values('recur_frequency_units', FALSE, FALSE, TRUE), NULL, NULL, NULL, NULL, - array('  ', '  ', '  ', '
    '), TRUE + ['  ', '  ', '  ', '
    '], TRUE ); $this->addElement('checkbox', 'is_pledge_interval', ts('Allow frequency intervals')); - $this->addElement('text', 'initial_reminder_day', ts('Send payment reminder'), array('size' => 3)); - $this->addElement('text', 'max_reminders', ts('Send up to'), array('size' => 3)); - $this->addElement('text', 'additional_reminder_day', ts('Send additional reminders'), array('size' => 3)); + $this->addElement('text', 'initial_reminder_day', ts('Send payment reminder'), ['size' => 3]); + $this->addElement('text', 'max_reminders', ts('Send up to'), ['size' => 3]); + $this->addElement('text', 'additional_reminder_day', ts('Send additional reminders'), ['size' => 3]); if (!empty($futurePaymentProcessor)) { // CRM-18854 $this->addElement('checkbox', 'adjust_recur_start_date', ts('Adjust Recurring Start Date'), NULL, - array('onclick' => "showHideByValue('adjust_recur_start_date',true,'recurDefaults','table-row','radio',false);") + ['onclick' => "showHideByValue('adjust_recur_start_date',true,'recurDefaults','table-row','radio',false);"] ); $this->addDate('pledge_calendar_date', ts('Specific Calendar Date')); $month = CRM_Utils_Date::getCalendarDayOfMonth(); $this->add('select', 'pledge_calendar_month', ts('Specific day of Month'), $month); - $pledgeDefaults = array( + $pledgeDefaults = [ 'contribution_date' => ts('Day of Contribution'), 'calendar_date' => ts('Specific Calendar Date'), 'calendar_month' => ts('Specific day of Month'), - ); - $this->addRadio('pledge_default_toggle', ts('Recurring Contribution Start Date Default'), $pledgeDefaults, array('allowClear' => FALSE), '

    '); + ]; + $this->addRadio('pledge_default_toggle', ts('Recurring Contribution Start Date Default'), $pledgeDefaults, ['allowClear' => FALSE], '

    '); $this->addElement('checkbox', 'is_pledge_start_date_visible', ts('Show Recurring Donation Start Date?'), NULL); $this->addElement('checkbox', 'is_pledge_start_date_editable', ts('Allow Edits to Recurring Donation Start date?'), NULL); } @@ -196,7 +196,7 @@ public function buildQuickForm() { //add currency element. $this->addCurrency('currency', ts('Currency')); - $this->addFormRule(array('CRM_Contribute_Form_ContributionPage_Amount', 'formRule'), $this); + $this->addFormRule(['CRM_Contribute_Form_ContributionPage_Amount', 'formRule'], $this); parent::buildQuickForm(); } @@ -221,14 +221,14 @@ public function setDefaultValues() { if ($isQuick = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $priceSetId, 'is_quick_config')) { $this->assign('isQuick', $isQuick); //$priceField = CRM_Core_DAO::getFieldValue( 'CRM_Price_DAO_PriceField', $priceSetId, 'id', 'price_set_id' ); - $options = $pFIDs = array(); - $priceFieldParams = array('price_set_id' => $priceSetId); - $priceFields = CRM_Core_DAO::commonRetrieveAll('CRM_Price_DAO_PriceField', 'price_set_id', $priceSetId, $pFIDs, $return = array( + $options = $pFIDs = []; + $priceFieldParams = ['price_set_id' => $priceSetId]; + $priceFields = CRM_Core_DAO::commonRetrieveAll('CRM_Price_DAO_PriceField', 'price_set_id', $priceSetId, $pFIDs, $return = [ 'html_type', 'name', 'is_active', 'label', - )); + ]); foreach ($priceFields as $priceField) { if ($priceField['id'] && $priceField['html_type'] == 'Radio' && $priceField['name'] == 'contribution_amount') { $defaults['price_field_id'] = $priceField['id']; @@ -304,7 +304,7 @@ public function setDefaultValues() { * true if no errors, else array of errors */ public static function formRule($fields, $files, $self) { - $errors = array(); + $errors = []; //as for separate membership payment we has to have //contribution amount section enabled, hence to disable it need to //check if separate membership payment enabled, @@ -457,7 +457,7 @@ public function postProcess() { $priceSetID = CRM_Utils_Array::value('price_set_id', $params); // get required fields. - $fields = array( + $fields = [ 'id' => $this->_id, 'is_recur' => FALSE, 'min_amount' => "null", @@ -471,14 +471,14 @@ public function postProcess() { 'default_amount_id' => "null", 'is_allow_other_amount' => FALSE, 'amount_block_is_active' => FALSE, - ); - $resetFields = array(); + ]; + $resetFields = []; if ($priceSetID) { - $resetFields = array('min_amount', 'max_amount', 'is_allow_other_amount'); + $resetFields = ['min_amount', 'max_amount', 'is_allow_other_amount']; } if (empty($params['is_recur'])) { - $resetFields = array_merge($resetFields, array('is_recur_interval', 'recur_frequency_unit')); + $resetFields = array_merge($resetFields, ['is_recur_interval', 'recur_frequency_unit']); } foreach ($fields as $field => $defaultVal) { @@ -487,10 +487,10 @@ public function postProcess() { $val = $defaultVal; } - if (in_array($field, array( + if (in_array($field, [ 'min_amount', 'max_amount', - ))) { + ])) { $val = CRM_Utils_Rule::cleanMoney($val); } @@ -507,17 +507,17 @@ public function postProcess() { if (CRM_Utils_Array::value('adjust_recur_start_date', $params)) { $fieldValue = ''; - $pledgeDateFields = array( + $pledgeDateFields = [ 'calendar_date' => 'pledge_calendar_date', 'calendar_month' => 'pledge_calendar_month', - ); + ]; if ($params['pledge_default_toggle'] == 'contribution_date') { - $fieldValue = json_encode(array('contribution_date' => date('m/d/Y'))); + $fieldValue = json_encode(['contribution_date' => date('m/d/Y')]); } else { foreach ($pledgeDateFields as $key => $pledgeDateField) { if (CRM_Utils_Array::value($pledgeDateField, $params) && $params['pledge_default_toggle'] == $key) { - $fieldValue = json_encode(array($key => $params[$pledgeDateField])); + $fieldValue = json_encode([$key => $params[$pledgeDateField]]); break; } } @@ -584,19 +584,19 @@ public function postProcess() { $values = CRM_Utils_Array::value('value', $params); $default = CRM_Utils_Array::value('default', $params); - $options = array(); + $options = []; for ($i = 1; $i < self::NUM_OPTION; $i++) { if (isset($values[$i]) && (strlen(trim($values[$i])) > 0) ) { $values[$i] = $params['value'][$i] = CRM_Utils_Rule::cleanMoney(trim($values[$i])); - $options[] = array( + $options[] = [ 'label' => trim($labels[$i]), 'value' => $values[$i], 'weight' => $i, 'is_active' => 1, 'is_default' => $default == $i, - ); + ]; } } /* || !empty($params['price_field_value']) || CRM_Utils_Array::value( 'price_field_other', $params )*/ @@ -650,11 +650,11 @@ public function postProcess() { } CRM_Price_BAO_PriceSet::addTo('civicrm_contribution_page', $this->_id, $priceSetId); if (!empty($options)) { - $editedFieldParams = array( + $editedFieldParams = [ 'price_set_id' => $priceSetId, 'name' => 'contribution_amount', - ); - $editedResults = array(); + ]; + $editedResults = []; $noContriAmount = 1; CRM_Price_BAO_PriceField::retrieve($editedFieldParams, $editedResults); if (empty($editedResults['id'])) { @@ -686,16 +686,16 @@ public function postProcess() { $priceField = CRM_Price_BAO_PriceField::create($fieldParams); } if (!empty($params['is_allow_other_amount']) && empty($params['price_field_other'])) { - $editedFieldParams = array( + $editedFieldParams = [ 'price_set_id' => $priceSetId, 'name' => 'other_amount', - ); - $editedResults = array(); + ]; + $editedResults = []; CRM_Price_BAO_PriceField::retrieve($editedFieldParams, $editedResults); if (!$priceFieldID = CRM_Utils_Array::value('id', $editedResults)) { - $fieldParams = array( + $fieldParams = [ 'name' => 'other_amount', 'label' => ts('Other Amount'), 'price_set_id' => $priceSetId, @@ -703,7 +703,7 @@ public function postProcess() { 'financial_type_id' => CRM_Utils_Array::value('financial_type_id', $this->_values), 'is_display_amounts' => 0, 'weight' => 3, - ); + ]; $fieldParams['option_weight'][1] = 1; $fieldParams['option_amount'][1] = 1; if (!$noContriAmount) { @@ -723,11 +723,11 @@ public function postProcess() { if (!$noContriAmount) { $priceFieldValueID = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceFieldValue', $priceFieldID, 'id', 'price_field_id'); CRM_Core_DAO::setFieldValue('CRM_Price_DAO_PriceFieldValue', $priceFieldValueID, 'label', $params['amount_label']); - $fieldParams = array( + $fieldParams = [ 'is_required' => 1, 'label' => $params['amount_label'], 'id' => $priceFieldID, - ); + ]; } $fieldParams['is_active'] = 1; $priceField = CRM_Price_BAO_PriceField::add($fieldParams); @@ -740,11 +740,11 @@ public function postProcess() { elseif ($priceFieldID = CRM_Utils_Array::value('price_field_other', $params)) { $priceFieldValueID = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceFieldValue', $priceFieldID, 'id', 'price_field_id'); if (!$noContriAmount) { - $fieldParams = array( + $fieldParams = [ 'is_required' => 1, 'label' => $params['amount_label'], 'id' => $priceFieldID, - ); + ]; CRM_Price_BAO_PriceField::add($fieldParams); CRM_Core_DAO::setFieldValue('CRM_Price_DAO_PriceFieldValue', $priceFieldValueID, 'label', $params['amount_label']); } @@ -757,14 +757,14 @@ public function postProcess() { if (!empty($params['is_pledge_active'])) { $deletePledgeBlk = FALSE; - $pledgeBlockParams = array( + $pledgeBlockParams = [ 'entity_id' => $contributionPageID, 'entity_table' => ts('civicrm_contribution_page'), - ); + ]; if ($this->_pledgeBlockID) { $pledgeBlockParams['id'] = $this->_pledgeBlockID; } - $pledgeBlock = array( + $pledgeBlock = [ 'pledge_frequency_unit', 'max_reminders', 'initial_reminder_day', @@ -772,7 +772,7 @@ public function postProcess() { 'pledge_start_date', 'is_pledge_start_date_visible', 'is_pledge_start_date_editable', - ); + ]; foreach ($pledgeBlock as $key) { $pledgeBlockParams[$key] = CRM_Utils_Array::value($key, $params); } diff --git a/CRM/Contribute/Form/ContributionPage/Custom.php b/CRM/Contribute/Form/ContributionPage/Custom.php index 8831bc0fe4fa..94f02e99c194 100644 --- a/CRM/Contribute/Form/ContributionPage/Custom.php +++ b/CRM/Contribute/Form/ContributionPage/Custom.php @@ -41,31 +41,31 @@ class CRM_Contribute_Form_ContributionPage_Custom extends CRM_Contribute_Form_Co public function buildQuickForm() { // Register 'contact_1' model - $entities = array(); - $entities[] = array('entity_name' => 'contact_1', 'entity_type' => 'IndividualModel'); - $allowCoreTypes = array_merge(array('Contact', 'Individual'), CRM_Contact_BAO_ContactType::subTypes('Individual')); - $allowSubTypes = array(); + $entities = []; + $entities[] = ['entity_name' => 'contact_1', 'entity_type' => 'IndividualModel']; + $allowCoreTypes = array_merge(['Contact', 'Individual'], CRM_Contact_BAO_ContactType::subTypes('Individual')); + $allowSubTypes = []; // Register 'contribution_1' $financialTypeId = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $this->_id, 'financial_type_id'); $allowCoreTypes[] = 'Contribution'; //CRM-15427 - $allowSubTypes['ContributionType'] = array($financialTypeId); - $entities[] = array( + $allowSubTypes['ContributionType'] = [$financialTypeId]; + $entities[] = [ 'entity_name' => 'contribution_1', 'entity_type' => 'ContributionModel', 'entity_sub_type' => '*', - ); + ]; // If applicable, register 'membership_1' $member = CRM_Member_BAO_Membership::getMembershipBlock($this->_id); if ($member && $member['is_active']) { //CRM-15427 - $entities[] = array( + $entities[] = [ 'entity_name' => 'membership_1', 'entity_type' => 'MembershipModel', 'entity_sub_type' => '*', - ); + ]; $allowCoreTypes[] = 'Membership'; $allowSubTypes['MembershipType'] = explode(',', $member['membership_types']); } @@ -73,7 +73,7 @@ public function buildQuickForm() { $this->addProfileSelector('custom_pre_id', ts('Include Profile') . '
    ' . ts('(top of page)'), $allowCoreTypes, $allowSubTypes, $entities, TRUE); $this->addProfileSelector('custom_post_id', ts('Include Profile') . '
    ' . ts('(bottom of page)'), $allowCoreTypes, $allowSubTypes, $entities, TRUE); - $this->addFormRule(array('CRM_Contribute_Form_ContributionPage_Custom', 'formRule'), $this); + $this->addFormRule(['CRM_Contribute_Form_ContributionPage_Custom', 'formRule'], $this); parent::buildQuickForm(); } @@ -106,12 +106,12 @@ public function postProcess() { $transaction = new CRM_Core_Transaction(); // also update uf join table - $ufJoinParams = array( + $ufJoinParams = [ 'is_active' => 1, 'module' => 'CiviContribute', 'entity_table' => 'civicrm_contribution_page', 'entity_id' => $this->_id, - ); + ]; // first delete all past entries CRM_Core_BAO_UFJoin::deleteAll($ufJoinParams); @@ -156,7 +156,7 @@ public function getTitle() { * true if no errors, else array of errors */ public static function formRule($fields, $files, $form) { - $errors = array(); + $errors = []; $preProfileType = $postProfileType = NULL; // for membership profile make sure Membership section is enabled // get membership section for this contribution page diff --git a/CRM/Contribute/Form/ContributionPage/Delete.php b/CRM/Contribute/Form/ContributionPage/Delete.php index ce80ff7e61b2..b89a1448be69 100644 --- a/CRM/Contribute/Form/ContributionPage/Delete.php +++ b/CRM/Contribute/Form/ContributionPage/Delete.php @@ -79,19 +79,19 @@ public function buildQuickForm() { //if there are contributions related to Contribution Page //then onle cancel button is displayed - $buttons = array(); + $buttons = []; if (!$this->_relatedContributions) { - $buttons[] = array( + $buttons[] = [ 'type' => 'next', 'name' => ts('Delete Contribution Page'), 'isDefault' => TRUE, - ); + ]; } - $buttons[] = array( + $buttons[] = [ 'type' => 'cancel', 'name' => ts('Cancel'), - ); + ]; $this->addButtons($buttons); } @@ -105,10 +105,10 @@ public function postProcess() { // first delete the join entries associated with this contribution page $dao = new CRM_Core_DAO_UFJoin(); - $params = array( + $params = [ 'entity_table' => 'civicrm_contribution_page', 'entity_id' => $this->_id, - ); + ]; $dao->copyValues($params); $dao->delete(); @@ -137,7 +137,7 @@ public function postProcess() { $transaction->commit(); - CRM_Core_Session::setStatus(ts("The contribution page '%1' has been deleted.", array(1 => $this->_title)), ts('Deleted'), 'success'); + CRM_Core_Session::setStatus(ts("The contribution page '%1' has been deleted.", [1 => $this->_title]), ts('Deleted'), 'success'); } } diff --git a/CRM/Contribute/Form/ContributionPage/Premium.php b/CRM/Contribute/Form/ContributionPage/Premium.php index e041747ed921..109dbc39edda 100644 --- a/CRM/Contribute/Form/ContributionPage/Premium.php +++ b/CRM/Contribute/Form/ContributionPage/Premium.php @@ -40,7 +40,7 @@ class CRM_Contribute_Form_ContributionPage_Premium extends CRM_Contribute_Form_C * Set default values for the form. */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; if (isset($this->_id)) { $dao = new CRM_Contribute_DAO_Premium(); $dao->entity_table = 'civicrm_contribution_page'; @@ -74,7 +74,7 @@ public function buildQuickForm() { // CRM-10999 Control label and position for No Thank-you radio button $this->add('text', 'premiums_nothankyou_label', ts('No Thank-you Label'), $attributes['premiums_nothankyou_label']); - $positions = array(1 => ts('Before Premiums'), 2 => ts('After Premiums')); + $positions = [1 => ts('Before Premiums'), 2 => ts('After Premiums')]; $this->add('select', 'premiums_nothankyou_position', ts('No Thank-you Option'), $positions); $showForm = TRUE; @@ -92,7 +92,7 @@ public function buildQuickForm() { $this->assign('showForm', $showForm); parent::buildQuickForm(); - $this->addFormRule(array('CRM_Contribute_Form_ContributionPage_Premium', 'formRule'), $this); + $this->addFormRule(['CRM_Contribute_Form_ContributionPage_Premium', 'formRule'], $this); $premiumPage = new CRM_Contribute_Page_Premium(); $premiumPage->browse(); @@ -108,7 +108,7 @@ public function buildQuickForm() { * mixed true or array of errors */ public static function formRule($params) { - $errors = array(); + $errors = []; if (!empty($params['premiums_active'])) { if (empty($params['premiums_nothankyou_label'])) { $errors['premiums_nothankyou_label'] = ts('No Thank-you Label is a required field.'); diff --git a/CRM/Contribute/Form/ContributionPage/Settings.php b/CRM/Contribute/Form/ContributionPage/Settings.php index 13a3e4911561..c2f7aa06a7e3 100644 --- a/CRM/Contribute/Form/ContributionPage/Settings.php +++ b/CRM/Contribute/Form/ContributionPage/Settings.php @@ -58,7 +58,7 @@ public function setDefaultValues() { ); CRM_Utils_System::setTitle(ts('Title and Settings') . " ($title)"); - foreach (array('on_behalf', 'soft_credit') as $module) { + foreach (['on_behalf', 'soft_credit'] as $module) { $ufJoinDAO = new CRM_Core_DAO_UFJoin(); $ufJoinDAO->module = $module; $ufJoinDAO->entity_id = $this->_id; @@ -83,10 +83,10 @@ public function setDefaultValues() { if ($ufGroupDAO->find(TRUE)) { $defaults['honoree_profile'] = $ufGroupDAO->id; } - $defaults['soft_credit_types'] = array( + $defaults['soft_credit_types'] = [ CRM_Utils_Array::value('in_honor_of', $soft_credit_types), CRM_Utils_Array::value('in_memory_of', $soft_credit_types), - ); + ]; } else { $ufGroupDAO = new CRM_Core_DAO_UFGroup(); @@ -106,10 +106,10 @@ public function setDefaultValues() { if ($ufGroupDAO->find(TRUE)) { $defaults['honoree_profile'] = $ufGroupDAO->id; } - $defaults['soft_credit_types'] = array( + $defaults['soft_credit_types'] = [ CRM_Utils_Array::value('in_honor_of', $soft_credit_types), CRM_Utils_Array::value('in_memory_of', $soft_credit_types), - ); + ]; } return $defaults; @@ -125,9 +125,9 @@ public function buildQuickForm() { // financial Type CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($financialTypes, CRM_Core_Action::ADD); - $financialOptions = array( + $financialOptions = [ 'options' => $financialTypes, - ); + ]; if (!CRM_Core_Permission::check('administer CiviCRM Financial Types')) { $financialOptions['context'] = 'search'; } @@ -144,42 +144,42 @@ public function buildQuickForm() { $this->add('wysiwyg', 'footer_text', ts('Footer Message'), $attributes['footer_text']); //Register schema which will be used for OnBehalOf and HonorOf profile Selector - CRM_UF_Page_ProfileEditor::registerSchemas(array('OrganizationModel', 'HouseholdModel')); + CRM_UF_Page_ProfileEditor::registerSchemas(['OrganizationModel', 'HouseholdModel']); // is on behalf of an organization ? - $this->addElement('checkbox', 'is_organization', ts('Allow individuals to contribute and / or signup for membership on behalf of an organization?'), NULL, array('onclick' => "showHideByValue('is_organization',true,'for_org_text','table-row','radio',false);showHideByValue('is_organization',true,'for_org_option','table-row','radio',false);")); + $this->addElement('checkbox', 'is_organization', ts('Allow individuals to contribute and / or signup for membership on behalf of an organization?'), NULL, ['onclick' => "showHideByValue('is_organization',true,'for_org_text','table-row','radio',false);showHideByValue('is_organization',true,'for_org_option','table-row','radio',false);"]); //CRM-15787 - If applicable, register 'membership_1' $member = CRM_Member_BAO_Membership::getMembershipBlock($this->_id); - $coreTypes = array('Contact', 'Organization'); + $coreTypes = ['Contact', 'Organization']; - $entities[] = array( - 'entity_name' => array('contact_1'), + $entities[] = [ + 'entity_name' => ['contact_1'], 'entity_type' => 'OrganizationModel', - ); + ]; if ($member && $member['is_active']) { $coreTypes[] = 'Membership'; - $entities[] = array( - 'entity_name' => array('membership_1'), + $entities[] = [ + 'entity_name' => ['membership_1'], 'entity_type' => 'MembershipModel', - ); + ]; } $allowCoreTypes = array_merge($coreTypes, CRM_Contact_BAO_ContactType::subTypes('Organization')); - $allowSubTypes = array(); + $allowSubTypes = []; $this->addProfileSelector('onbehalf_profile_id', ts('Organization Profile'), $allowCoreTypes, $allowSubTypes, $entities); - $options = array(); + $options = []; $options[] = $this->createElement('radio', NULL, NULL, ts('Optional'), 1); $options[] = $this->createElement('radio', NULL, NULL, ts('Required'), 2); $this->addGroup($options, 'is_for_organization', ''); - $this->add('textarea', 'for_organization', ts('On behalf of Label'), array('rows' => 2, 'cols' => 50)); + $this->add('textarea', 'for_organization', ts('On behalf of Label'), ['rows' => 2, 'cols' => 50]); // collect goal amount - $this->add('text', 'goal_amount', ts('Goal Amount'), array('size' => 8, 'maxlength' => 12)); - $this->addRule('goal_amount', ts('Please enter a valid money value (e.g. %1).', array(1 => CRM_Utils_Money::format('99.99', ' '))), 'money'); + $this->add('text', 'goal_amount', ts('Goal Amount'), ['size' => 8, 'maxlength' => 12]); + $this->addRule('goal_amount', ts('Please enter a valid money value (e.g. %1).', [1 => CRM_Utils_Money::format('99.99', ' ')]), 'money'); // is confirmation page enabled? $this->addElement('checkbox', 'is_confirm_enabled', ts('Use a confirmation page?')); @@ -191,34 +191,34 @@ public function buildQuickForm() { $this->addElement('checkbox', 'is_active', ts('Is this Online Contribution Page Active?')); // should the honor be enabled - $this->addElement('checkbox', 'honor_block_is_active', ts('Honoree Section Enabled'), NULL, array('onclick' => "showHonor()")); + $this->addElement('checkbox', 'honor_block_is_active', ts('Honoree Section Enabled'), NULL, ['onclick' => "showHonor()"]); - $this->add('text', 'honor_block_title', ts('Honoree Section Title'), array('maxlength' => 255, 'size' => 45)); + $this->add('text', 'honor_block_title', ts('Honoree Section Title'), ['maxlength' => 255, 'size' => 45]); - $this->add('textarea', 'honor_block_text', ts('Honoree Introductory Message'), array('rows' => 2, 'cols' => 50)); + $this->add('textarea', 'honor_block_text', ts('Honoree Introductory Message'), ['rows' => 2, 'cols' => 50]); - $this->addSelect('soft_credit_types', array( + $this->addSelect('soft_credit_types', [ 'label' => ts('Honor Types'), 'entity' => 'ContributionSoft', 'field' => 'soft_credit_type_id', 'multiple' => TRUE, 'class' => 'huge', - )); + ]); - $entities = array( - array( + $entities = [ + [ 'entity_name' => 'contact_1', 'entity_type' => 'IndividualModel', - ), - ); + ], + ]; - $allowCoreTypes = array_merge(array( + $allowCoreTypes = array_merge([ 'Contact', 'Individual', 'Organization', 'Household', - ), CRM_Contact_BAO_ContactType::subTypes('Individual')); - $allowSubTypes = array(); + ], CRM_Contact_BAO_ContactType::subTypes('Individual')); + $allowSubTypes = []; $this->addProfileSelector('honoree_profile', ts('Honoree Profile'), $allowCoreTypes, $allowSubTypes, $entities); @@ -231,7 +231,7 @@ public function buildQuickForm() { $this->add('datepicker', 'start_date', ts('Start Date')); $this->add('datepicker', 'end_date', ts('End Date')); - $this->addFormRule(array('CRM_Contribute_Form_ContributionPage_Settings', 'formRule'), $this); + $this->addFormRule(['CRM_Contribute_Form_ContributionPage_Settings', 'formRule'], $this); parent::buildQuickForm(); } @@ -249,7 +249,7 @@ public function buildQuickForm() { * list of errors to be posted back to the form */ public static function formRule($values, $files, $self) { - $errors = array(); + $errors = []; $contributionPageId = $self->_id; //CRM-4286 if (strstr($values['title'], '/')) { @@ -262,7 +262,7 @@ public static function formRule($values, $files, $self) { $errors['onbehalf_profile_id'] = ts('Please select a profile to collect organization information on this contribution page.'); } else { - $requiredProfileFields = array('organization_name', 'email'); + $requiredProfileFields = ['organization_name', 'email']; if (!CRM_Core_BAO_UFGroup::checkValidProfile($values['onbehalf_profile_id'], $requiredProfileFields)) { $errors['onbehalf_profile_id'] = ts('Profile does not contain the minimum required fields for an On Behalf Of Organization'); } @@ -283,11 +283,11 @@ public static function formRule($values, $files, $self) { //dont allow on behalf of save when //pre or post profile consists of membership fields if ($contributionPageId && !empty($values['is_organization'])) { - $ufJoinParams = array( + $ufJoinParams = [ 'module' => 'CiviContribute', 'entity_table' => 'civicrm_contribution_page', 'entity_id' => $contributionPageId, - ); + ]; list($contributionProfiles['custom_pre_id'], $contributionProfiles['custom_post_id'] @@ -308,7 +308,7 @@ public static function formRule($values, $files, $self) { } } if (!empty($conProfileType)) { - $errors['is_organization'] = ts("You should move the membership related fields configured in %1 to the 'On Behalf' profile for this Contribution Page", array(1 => $conProfileType)); + $errors['is_organization'] = ts("You should move the membership related fields configured in %1 to the 'On Behalf' profile for this Contribution Page", [1 => $conProfileType]); } } return $errors; @@ -348,18 +348,18 @@ public function postProcess() { $dao = CRM_Contribute_BAO_ContributionPage::create($params); - $ufJoinParams = array( - 'is_organization' => array( + $ufJoinParams = [ + 'is_organization' => [ 'module' => 'on_behalf', 'entity_table' => 'civicrm_contribution_page', 'entity_id' => $dao->id, - ), - 'honor_block_is_active' => array( + ], + 'honor_block_is_active' => [ 'module' => 'soft_credit', 'entity_table' => 'civicrm_contribution_page', 'entity_id' => $dao->id, - ), - ); + ], + ]; foreach ($ufJoinParams as $index => $ufJoinParam) { if (!empty($params[$index])) { @@ -407,7 +407,7 @@ public function postProcess() { $url = 'civicrm/admin/contribute'; $urlParams = 'reset=1'; CRM_Core_Session::setStatus(ts("'%1' information has been saved.", - array(1 => $this->getTitle()) + [1 => $this->getTitle()] ), ts('Saved'), 'success'); } diff --git a/CRM/Contribute/Form/ContributionPage/TabHeader.php b/CRM/Contribute/Form/ContributionPage/TabHeader.php index 7deb3722f9cd..0becb7fb8af9 100644 --- a/CRM/Contribute/Form/ContributionPage/TabHeader.php +++ b/CRM/Contribute/Form/ContributionPage/TabHeader.php @@ -49,11 +49,11 @@ public static function build(&$form) { $form->assign_by_ref('tabHeader', $tabs); CRM_Core_Resources::singleton() ->addScriptFile('civicrm', 'templates/CRM/common/TabHeader.js', 1, 'html-header') - ->addSetting(array( - 'tabSettings' => array( + ->addSetting([ + 'tabSettings' => [ 'active' => self::getCurrentTab($tabs), - ), - )); + ], + ]); return $tabs; } @@ -67,74 +67,74 @@ public static function process(&$form) { return NULL; } - $tabs = array( - 'settings' => array( + $tabs = [ + 'settings' => [ 'title' => ts('Title'), 'link' => NULL, 'valid' => FALSE, 'active' => FALSE, 'current' => FALSE, - ), - 'amount' => array( + ], + 'amount' => [ 'title' => ts('Amounts'), 'link' => NULL, 'valid' => FALSE, 'active' => FALSE, 'current' => FALSE, - ), - 'membership' => array( + ], + 'membership' => [ 'title' => ts('Memberships'), 'link' => NULL, 'valid' => FALSE, 'active' => FALSE, 'current' => FALSE, - ), - 'thankyou' => array( + ], + 'thankyou' => [ 'title' => ts('Receipt'), 'link' => NULL, 'valid' => FALSE, 'active' => FALSE, 'current' => FALSE, - ), - 'friend' => array( + ], + 'friend' => [ 'title' => ts('Tell a Friend'), 'link' => NULL, 'valid' => FALSE, 'active' => FALSE, 'current' => FALSE, - ), - 'custom' => array( + ], + 'custom' => [ 'title' => ts('Profiles'), 'link' => NULL, 'valid' => FALSE, 'active' => FALSE, 'current' => FALSE, - ), - 'premium' => array( + ], + 'premium' => [ 'title' => ts('Premiums'), 'link' => NULL, 'valid' => FALSE, 'active' => FALSE, 'current' => FALSE, - ), - 'widget' => array( + ], + 'widget' => [ 'title' => ts('Widgets'), 'link' => NULL, 'valid' => FALSE, 'active' => FALSE, 'current' => FALSE, - ), - 'pcp' => array( + ], + 'pcp' => [ 'title' => ts('Personal Campaigns'), 'link' => NULL, 'valid' => FALSE, 'active' => FALSE, 'current' => FALSE, - ), - ); + ], + ]; $contribPageId = $form->getVar('_id'); - CRM_Utils_Hook::tabset('civicrm/admin/contribute', $tabs, array('contribution_page_id' => $contribPageId)); + CRM_Utils_Hook::tabset('civicrm/admin/contribute', $tabs, ['contribution_page_id' => $contribPageId]); $fullName = $form->getVar('_name'); $className = CRM_Utils_String::getClassName($fullName); @@ -177,7 +177,7 @@ public static function process(&$form) { $tabs[$key]['active'] = $tabs[$key]['valid'] = TRUE; } //get all section info. - $contriPageInfo = CRM_Contribute_BAO_ContributionPage::getSectionInfo(array($contribPageId)); + $contriPageInfo = CRM_Contribute_BAO_ContributionPage::getSectionInfo([$contribPageId]); foreach ($contriPageInfo[$contribPageId] as $section => $info) { if (!$info) { diff --git a/CRM/Contribute/Form/ContributionPage/ThankYou.php b/CRM/Contribute/Form/ContributionPage/ThankYou.php index 67e6e45e61e3..d8a53f151a12 100644 --- a/CRM/Contribute/Form/ContributionPage/ThankYou.php +++ b/CRM/Contribute/Form/ContributionPage/ThankYou.php @@ -54,11 +54,11 @@ public function buildQuickForm() { // thank you title and text (html allowed in text) $this->add('text', 'thankyou_title', ts('Thank-you Page Title'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_ContributionPage', 'thankyou_title'), TRUE); - $attributes = CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_ContributionPage', 'thankyou_text') + array('class' => 'collapsed'); + $attributes = CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_ContributionPage', 'thankyou_text') + ['class' => 'collapsed']; $this->add('wysiwyg', 'thankyou_text', ts('Thank-you Message'), $attributes); $this->add('wysiwyg', 'thankyou_footer', ts('Thank-you Footer'), $attributes); - $this->addElement('checkbox', 'is_email_receipt', ts('Email Receipt to Contributor?'), NULL, array('onclick' => "showReceipt()")); + $this->addElement('checkbox', 'is_email_receipt', ts('Email Receipt to Contributor?'), NULL, ['onclick' => "showReceipt()"]); $this->add('text', 'receipt_from_name', ts('Receipt From Name'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_ContributionPage', 'receipt_from_name')); $this->add('text', 'receipt_from_email', ts('Receipt From Email'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_ContributionPage', 'receipt_from_email')); $this->add('textarea', 'receipt_text', ts('Receipt Message'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_ContributionPage', 'receipt_text')); @@ -70,7 +70,7 @@ public function buildQuickForm() { $this->addRule('bcc_receipt', ts('Please enter a valid list of comma delimited email addresses'), 'emailList'); parent::buildQuickForm(); - $this->addFormRule(array('CRM_Contribute_Form_ContributionPage_ThankYou', 'formRule'), $this); + $this->addFormRule(['CRM_Contribute_Form_ContributionPage_ThankYou', 'formRule'], $this); } /** @@ -87,7 +87,7 @@ public function buildQuickForm() { * true if no errors, else array of errors */ public static function formRule($fields, $files, $options) { - $errors = array(); + $errors = []; // if is_email_receipt is set, the receipt message must be non-empty if (!empty($fields['is_email_receipt'])) { diff --git a/CRM/Contribute/Form/ContributionPage/Widget.php b/CRM/Contribute/Form/ContributionPage/Widget.php index 78f0434954af..2a88bc06b5df 100644 --- a/CRM/Contribute/Form/ContributionPage/Widget.php +++ b/CRM/Contribute/Form/ContributionPage/Widget.php @@ -61,90 +61,90 @@ public function preProcess() { 'title' ); - $this->_fields = array( - 'title' => array( + $this->_fields = [ + 'title' => [ ts('Title'), 'text', FALSE, $title, - ), - 'url_logo' => array( + ], + 'url_logo' => [ ts('URL to Logo Image'), 'text', FALSE, NULL, - ), - 'button_title' => array( + ], + 'button_title' => [ ts('Button Title'), 'text', FALSE, ts('Contribute!'), - ), - ); + ], + ]; - $this->_colorFields = array( - 'color_title' => array( + $this->_colorFields = [ + 'color_title' => [ ts('Title Text Color'), 'color', FALSE, '#2786C2', - ), - 'color_bar' => array( + ], + 'color_bar' => [ ts('Progress Bar Color'), 'color', FALSE, '#2786C2', - ), - 'color_main_text' => array( + ], + 'color_main_text' => [ ts('Additional Text Color'), 'color', FALSE, '#FFFFFF', - ), - 'color_main' => array( + ], + 'color_main' => [ ts('Background Color'), 'color', FALSE, '#96C0E7', - ), - 'color_main_bg' => array( + ], + 'color_main_bg' => [ ts('Background Color Top Area'), 'color', FALSE, '#B7E2FF', - ), - 'color_bg' => array( + ], + 'color_bg' => [ ts('Border Color'), 'color', FALSE, '#96C0E7', - ), - 'color_about_link' => array( + ], + 'color_about_link' => [ ts('Button Text Color'), 'color', FALSE, '#556C82', - ), - 'color_button' => array( + ], + 'color_button' => [ ts('Button Background Color'), 'color', FALSE, '#FFFFFF', - ), - 'color_homepage_link' => array( + ], + 'color_homepage_link' => [ ts('Homepage Link Color'), 'color', FALSE, '#FFFFFF', - ), - ); + ], + ]; } /** * Set default values for the form. */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; // check if there is a widget already created if ($this->_widget) { CRM_Core_DAO::storeValues($this->_widget, $defaults); @@ -175,7 +175,7 @@ public function buildQuickForm() { 'is_active', ts('Enable Widget?'), NULL, - array('onclick' => "widgetBlock(this)") + ['onclick' => "widgetBlock(this)"] ); $this->add('wysiwyg', 'about', ts('About'), $attributes['about']); @@ -206,7 +206,7 @@ public function buildQuickForm() { ts('Save and Preview') ); parent::buildQuickForm(); - $this->addFormRule(array('CRM_Contribute_Form_ContributionPage_Widget', 'formRule'), $this); + $this->addFormRule(['CRM_Contribute_Form_ContributionPage_Widget', 'formRule'], $this); } /** @@ -222,7 +222,7 @@ public function buildQuickForm() { * mixed true or array of errors */ public static function formRule($params, $files, $self) { - $errors = array(); + $errors = []; if (!empty($params['is_active'])) { if (empty($params['title'])) { $errors['title'] = ts('Title is a required field.'); @@ -233,7 +233,7 @@ public static function formRule($params, $files, $self) { foreach ($params as $key => $val) { if (substr($key, 0, 6) == 'color_' && empty($params[$key])) { - $errors[$key] = ts('%1 is a required field.', array(1 => $self->_colorFields[$key][0])); + $errors[$key] = ts('%1 is a required field.', [1 => $self->_colorFields[$key][0]]); } } } diff --git a/CRM/Contribute/Form/ContributionView.php b/CRM/Contribute/Form/ContributionView.php index aee9f0ec37e9..99b02342bdac 100644 --- a/CRM/Contribute/Form/ContributionView.php +++ b/CRM/Contribute/Form/ContributionView.php @@ -41,7 +41,7 @@ class CRM_Contribute_Form_ContributionView extends CRM_Core_Form { */ public function preProcess() { $id = $this->get('id'); - $params = array('id' => $id); + $params = ['id' => $id]; $context = CRM_Utils_Request::retrieve('context', 'Alphanumeric', $this); $this->assign('context', $context); @@ -94,7 +94,7 @@ public function preProcess() { if (!empty($values['contribution_recur_id'])) { $sql = "SELECT installments, frequency_interval, frequency_unit FROM civicrm_contribution_recur WHERE id = %1"; - $params = array(1 => array($values['contribution_recur_id'], 'Integer')); + $params = [1 => [$values['contribution_recur_id'], 'Integer']]; $dao = CRM_Core_DAO::executeQuery($sql, $params); if ($dao->fetch()) { $values['recur_installments'] = $dao->installments; @@ -132,7 +132,7 @@ public function preProcess() { // show billing address location details, if exists if (!empty($values['address_id'])) { - $addressParams = array('id' => CRM_Utils_Array::value('address_id', $values)); + $addressParams = ['id' => CRM_Utils_Array::value('address_id', $values)]; $addressDetails = CRM_Core_BAO_Address::getValues($addressParams, FALSE, 'id'); $addressDetails = array_values($addressDetails); $values['billing_address'] = $addressDetails[0]['display']; @@ -150,10 +150,10 @@ public function preProcess() { $this->assign($name, $value); } - $lineItems = array(); + $lineItems = []; $displayLineItems = FALSE; if ($id) { - $lineItems = array(CRM_Price_BAO_LineItem::getLineItemsByContributionID(($id))); + $lineItems = [CRM_Price_BAO_LineItem::getLineItemsByContributionID(($id))]; $firstLineItem = reset($lineItems[0]); if (empty($firstLineItem['price_set_id'])) { // CRM-20297 All we care is that it's not QuickConfig, so no price set @@ -162,10 +162,10 @@ public function preProcess() { } else { try { - $priceSet = civicrm_api3('PriceSet', 'getsingle', array( + $priceSet = civicrm_api3('PriceSet', 'getsingle', [ 'id' => $firstLineItem['price_set_id'], 'return' => 'is_quick_config, id', - )); + ]); $displayLineItems = !$priceSet['is_quick_config']; } catch (CiviCRM_API3_Exception $e) { @@ -215,7 +215,7 @@ public function preProcess() { $title = $displayName . ' - (' . CRM_Utils_Money::format($values['total_amount'], $values['currency']) . ' ' . ' - ' . $values['financial_type'] . ')'; - $recentOther = array(); + $recentOther = []; if (CRM_Core_Permission::checkActionPermission('CiviContribute', CRM_Core_Action::UPDATE)) { $recentOther['editUrl'] = CRM_Utils_System::url('civicrm/contact/view/contribution', "action=update&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home" @@ -235,7 +235,7 @@ public function preProcess() { $recentOther ); $contributionStatus = $status[$values['contribution_status_id']]; - if (in_array($contributionStatus, array('Partially paid', 'Pending refund')) + if (in_array($contributionStatus, ['Partially paid', 'Pending refund']) || ($contributionStatus == 'Pending' && $values['is_pay_later']) ) { if ($contributionStatus == 'Pending refund') { @@ -256,14 +256,14 @@ public function preProcess() { * Build the form object. */ public function buildQuickForm() { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'cancel', 'name' => ts('Done'), 'spacing' => '         ', 'isDefault' => TRUE, - ), - )); + ], + ]); } /** diff --git a/CRM/Contribute/Form/ManagePremiums.php b/CRM/Contribute/Form/ManagePremiums.php index 1176098f2c54..6cfbe11798cd 100644 --- a/CRM/Contribute/Form/ManagePremiums.php +++ b/CRM/Contribute/Form/ManagePremiums.php @@ -49,7 +49,7 @@ public function preProcess() { public function setDefaultValues() { $defaults = parent::setDefaultValues(); if ($this->_id) { - $params = array('id' => $this->_id); + $params = ['id' => $this->_id]; CRM_Contribute_BAO_Product::retrieve($params, $tempDefaults); if (isset($tempDefaults['image']) && isset($tempDefaults['thumbnail'])) { $defaults['imageUrl'] = $tempDefaults['image']; @@ -91,10 +91,10 @@ public function buildQuickForm() { $this->applyFilter('__ALL__', 'trim'); $this->add('text', 'name', ts('Name'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Product', 'name'), TRUE); - $this->addRule('name', ts('A product with this name already exists. Please select another name.'), 'objectExists', array( + $this->addRule('name', ts('A product with this name already exists. Please select another name.'), 'objectExists', [ 'CRM_Contribute_DAO_Product', $this->_id, - )); + ]); $this->add('text', 'sku', ts('SKU'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Product', 'sku')); $this->add('textarea', 'description', ts('Description'), 'rows=3, cols=60'); @@ -123,25 +123,25 @@ public function buildQuickForm() { $this->add('textarea', 'options', ts('Options'), 'rows=3, cols=60'); - $this->add('select', 'period_type', ts('Period Type'), array( + $this->add('select', 'period_type', ts('Period Type'), [ '' => '- select -', 'rolling' => 'Rolling', 'fixed' => 'Fixed', - )); + ]); $this->add('text', 'fixed_period_start_day', ts('Fixed Period Start Day'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Product', 'fixed_period_start_day')); - $this->add('Select', 'duration_unit', ts('Duration Unit'), array('' => '- select period -') + CRM_Core_SelectValues::getPremiumUnits()); + $this->add('Select', 'duration_unit', ts('Duration Unit'), ['' => '- select period -'] + CRM_Core_SelectValues::getPremiumUnits()); $this->add('text', 'duration_interval', ts('Duration'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Product', 'duration_interval')); - $this->add('Select', 'frequency_unit', ts('Frequency Unit'), array('' => '- select period -') + CRM_Core_SelectValues::getPremiumUnits()); + $this->add('Select', 'frequency_unit', ts('Frequency Unit'), ['' => '- select period -'] + CRM_Core_SelectValues::getPremiumUnits()); $this->add('text', 'frequency_interval', ts('Frequency'), CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Product', 'frequency_interval')); //Financial Type CRM-11106 $financialType = CRM_Contribute_PseudoConstant::financialType(); - $premiumFinancialType = array(); + $premiumFinancialType = []; CRM_Core_PseudoConstant::populate( $premiumFinancialType, 'CRM_Financial_DAO_EntityFinancialAccount', @@ -151,7 +151,7 @@ public function buildQuickForm() { 'account_relationship = 8' ); - $costFinancialType = array(); + $costFinancialType = []; CRM_Core_PseudoConstant::populate( $costFinancialType, 'CRM_Financial_DAO_EntityFinancialAccount', @@ -173,24 +173,24 @@ public function buildQuickForm() { 'select', 'financial_type_id', ts('Financial Type'), - array('' => ts('- select -')) + $financialType + ['' => ts('- select -')] + $financialType ); $this->add('checkbox', 'is_active', ts('Enabled?')); - $this->addFormRule(array('CRM_Contribute_Form_ManagePremiums', 'formRule')); + $this->addFormRule(['CRM_Contribute_Form_ManagePremiums', 'formRule']); - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'upload', 'name' => ts('Save'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); $this->assign('productId', $this->_id); } @@ -275,7 +275,7 @@ public function postProcess() { CRM_Contribute_BAO_Product::del($this->_id); } catch (CRM_Core_Exception $e) { - $message = ts("This Premium is linked to an Online Contribution page. Please remove it before deleting this Premium.", array(1 => CRM_Utils_System::url('civicrm/admin/contribute', 'reset=1'))); + $message = ts("This Premium is linked to an Online Contribution page. Please remove it before deleting this Premium.", [1 => CRM_Utils_System::url('civicrm/admin/contribute', 'reset=1')]); CRM_Core_Session::setStatus($message, ts('Cannot delete Premium'), 'error'); CRM_Core_Session::singleton()->pushUserContext(CRM_Utils_System::url('civicrm/admin/contribute/managePremiums', 'reset=1&action=browse')); return; @@ -289,7 +289,7 @@ public function postProcess() { $params = $this->controller->exportValues($this->_name); // Clean the the money fields - $moneyFields = array('cost', 'price', 'min_contribution'); + $moneyFields = ['cost', 'price', 'min_contribution']; foreach ($moneyFields as $field) { $params[$field] = CRM_Utils_Rule::cleanMoney($params[$field]); } @@ -305,7 +305,7 @@ public function postProcess() { $premium = CRM_Contribute_BAO_Product::create($params); CRM_Core_Session::setStatus( - ts("The Premium '%1' has been saved.", array(1 => $premium->name)), + ts("The Premium '%1' has been saved.", [1 => $premium->name]), ts('Saved'), 'success'); } @@ -316,14 +316,14 @@ public function postProcess() { * @param array $params */ protected function _processImages(&$params) { - $defaults = array( + $defaults = [ 'imageOption' => 'noImage', - 'uploadFile' => array('name' => ''), + 'uploadFile' => ['name' => ''], 'image' => '', 'thumbnail' => '', 'imageUrl' => '', 'thumbnailUrl' => '', - ); + ]; $params = array_merge($defaults, $params); // User is uploading an image diff --git a/CRM/Contribute/Form/Search.php b/CRM/Contribute/Form/Search.php index f00ec966214b..3aa1d912bfa8 100644 --- a/CRM/Contribute/Form/Search.php +++ b/CRM/Contribute/Form/Search.php @@ -269,10 +269,10 @@ public function postProcess() { $this->_formValues["contribution_test"] = 0; } - foreach (array( + foreach ([ 'contribution_amount_low', 'contribution_amount_high', - ) as $f) { + ] as $f) { if (isset($this->_formValues[$f])) { $this->_formValues[$f] = CRM_Utils_Rule::cleanMoney($this->_formValues[$f]); } @@ -280,7 +280,7 @@ public function postProcess() { $config = CRM_Core_Config::singleton(); if (!empty($_POST)) { - $specialParams = array( + $specialParams = [ 'financial_type_id', 'contribution_soft_credit_type_id', 'contribution_status_id', @@ -291,7 +291,7 @@ public function postProcess() { 'invoice_id', 'payment_instrument_id', 'contribution_batch_id', - ); + ]; CRM_Contact_BAO_Query::processSpecialFormValue($this->_formValues, $specialParams); $tags = CRM_Utils_Array::value('contact_tags', $this->_formValues); @@ -391,8 +391,8 @@ public function fixFormValues() { $status = CRM_Utils_Request::retrieve('status', 'String'); if ($status) { - $this->_formValues['contribution_status_id'] = array($status => 1); - $this->_defaults['contribution_status_id'] = array($status => 1); + $this->_formValues['contribution_status_id'] = [$status => 1]; + $this->_defaults['contribution_status_id'] = [$status => 1]; } $pcpid = (array) CRM_Utils_Request::retrieve('pcpid', 'String', $this); diff --git a/CRM/Contribute/Form/SearchContribution.php b/CRM/Contribute/Form/SearchContribution.php index 051613405ec9..1b3130469550 100644 --- a/CRM/Contribute/Form/SearchContribution.php +++ b/CRM/Contribute/Form/SearchContribution.php @@ -48,13 +48,13 @@ public function buildQuickForm() { CRM_Campaign_BAO_Campaign::addCampaignInComponentSearch($this); - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'refresh', 'name' => ts('Search'), 'isDefault' => TRUE, - ), - )); + ], + ]); } public function postProcess() { @@ -62,7 +62,7 @@ public function postProcess() { $parent = $this->controller->getParent(); $parent->set('searchResult', 1); if (!empty($params)) { - $fields = array('title', 'financial_type_id', 'campaign_id'); + $fields = ['title', 'financial_type_id', 'campaign_id']; foreach ($fields as $field) { if (isset($params[$field]) && !CRM_Utils_System::isNull($params[$field]) diff --git a/CRM/Contribute/Form/SoftCredit.php b/CRM/Contribute/Form/SoftCredit.php index 5a42f2f4f1da..b45472fda66f 100644 --- a/CRM/Contribute/Form/SoftCredit.php +++ b/CRM/Contribute/Form/SoftCredit.php @@ -51,7 +51,7 @@ public static function buildQuickForm(&$form) { if ($ufJoinDAO->find(TRUE)) { $jsonData = CRM_Contribute_BAO_ContributionPage::formatModuleData($ufJoinDAO->module_data, TRUE, 'soft_credit'); if ($jsonData) { - foreach (array('honor_block_title', 'honor_block_text') as $name) { + foreach (['honor_block_title', 'honor_block_text'] as $name) { $form->assign($name, $jsonData[$name]); } @@ -96,15 +96,15 @@ public static function buildQuickForm(&$form) { } for ($rowNumber = 1; $rowNumber <= $item_count; $rowNumber++) { - $form->addEntityRef("soft_credit_contact_id[{$rowNumber}]", ts('Contact'), array('create' => TRUE)); + $form->addEntityRef("soft_credit_contact_id[{$rowNumber}]", ts('Contact'), ['create' => TRUE]); $form->addMoney("soft_credit_amount[{$rowNumber}]", ts('Amount'), FALSE, NULL, FALSE); - $form->addSelect("soft_credit_type[{$rowNumber}]", array( + $form->addSelect("soft_credit_type[{$rowNumber}]", [ 'entity' => 'contribution_soft', 'field' => 'soft_credit_type_id', 'label' => ts('Type'), - )); + ]); if (!empty($form->_softCreditInfo['soft_credit'][$rowNumber]['soft_credit_id'])) { $form->add('hidden', "soft_credit_id[{$rowNumber}]", $form->_softCreditInfo['soft_credit'][$rowNumber]['soft_credit_id']); @@ -117,7 +117,7 @@ public static function buildQuickForm(&$form) { $form->assign('rowCount', $item_count); $form->addElement('hidden', 'sct_default_id', CRM_Core_OptionGroup::getDefaultValue("soft_credit_type"), - array('id' => 'sct_default_id') + ['id' => 'sct_default_id'] ); } @@ -135,7 +135,7 @@ public static function addPCPFields(&$form, $suffix = '') { if (!CRM_Utils_Array::crmIsEmptyArray($siteHasPCPs)) { $form->assign('siteHasPCPs', 1); // Fixme: Not a true entityRef field. Relies on PCP.js.tpl - $form->add('text', "pcp_made_through_id$suffix", ts('Credit to a Personal Campaign Page'), array('class' => 'twenty', 'placeholder' => ts('- select -'))); + $form->add('text', "pcp_made_through_id$suffix", ts('Credit to a Personal Campaign Page'), ['class' => 'twenty', 'placeholder' => ts('- select -')]); // stores the label $form->add('hidden', "pcp_made_through$suffix"); $form->addElement('checkbox', "pcp_display_in_roll$suffix", ts('Display in Honor Roll?'), NULL); @@ -191,7 +191,7 @@ public static function setDefaultValues(&$defaults, &$form) { * Array of errors */ public static function formRule($fields, $errors, $self) { - $errors = array(); + $errors = []; // if honor roll fields are populated but no PCP is selected if (empty($fields['pcp_made_through_id'])) { diff --git a/CRM/Contribute/Form/Task.php b/CRM/Contribute/Form/Task.php index 3ce717f915b4..0414b694d789 100644 --- a/CRM/Contribute/Form/Task.php +++ b/CRM/Contribute/Form/Task.php @@ -49,7 +49,7 @@ class CRM_Contribute_Form_Task extends CRM_Core_Form_Task { * * @var array */ - protected $_contributionContactIds = array(); + protected $_contributionContactIds = []; /** * The flag to tell if there are soft credits included. @@ -69,7 +69,7 @@ public function preProcess() { * @param CRM_Core_Form $form */ public static function preProcessCommon(&$form) { - $form->_contributionIds = array(); + $form->_contributionIds = []; $values = $form->controller->exportValues($form->get('searchFormName')); @@ -77,7 +77,7 @@ public static function preProcessCommon(&$form) { $contributeTasks = CRM_Contribute_Task::tasks(); $form->assign('taskName', CRM_Utils_Array::value($form->_task, $contributeTasks)); - $ids = array(); + $ids = []; if (isset($values['radio_ts']) && $values['radio_ts'] == 'ts_sel') { foreach ($values as $name => $value) { if (substr($name, 0, CRM_Core_Form::CB_PREFIX_LEN) == CRM_Core_Form::CB_PREFIX) { @@ -97,20 +97,20 @@ public static function preProcessCommon(&$form) { } } if (!$isTest) { - $queryParams[] = array( + $queryParams[] = [ 'contribution_test', '=', 0, 0, 0, - ); + ]; } - $returnProperties = array('contribution_id' => 1); + $returnProperties = ['contribution_id' => 1]; $sortOrder = $sortCol = NULL; if ($form->get(CRM_Utils_Sort::SORT_ORDER)) { $sortOrder = $form->get(CRM_Utils_Sort::SORT_ORDER); //Include sort column in select clause. - $sortCol = trim(str_replace(array('`', 'asc', 'desc'), '', $sortOrder)); + $sortCol = trim(str_replace(['`', 'asc', 'desc'], '', $sortOrder)); $returnProperties[$sortCol] = 1; } @@ -121,7 +121,7 @@ public static function preProcessCommon(&$form) { // @todo the function CRM_Contribute_BAO_Query::isSoftCreditOptionEnabled should handle this // can we remove? if not why not? if ($form->_includesSoftCredits) { - $contactIds = $contributionContactIds = array(); + $contactIds = $contributionContactIds = []; $query->_rowCountClause = " count(civicrm_contribution.id)"; $query->_groupByComponentClause = " GROUP BY contribution_search_scredit_combined.id, contribution_search_scredit_combined.contact_id, contribution_search_scredit_combined.scredit_id "; } @@ -208,17 +208,17 @@ public function setContactIDs() { * @param bool $submitOnce */ public function addDefaultButtons($title, $nextType = 'next', $backType = 'back', $submitOnce = FALSE) { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => $nextType, 'name' => $title, 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => $backType, 'name' => ts('Cancel'), - ), - ) + ], + ] ); } diff --git a/CRM/Contribute/Form/Task/Batch.php b/CRM/Contribute/Form/Task/Batch.php index 7ef312fff535..2e52dccdef95 100644 --- a/CRM/Contribute/Form/Task/Batch.php +++ b/CRM/Contribute/Form/Task/Batch.php @@ -61,7 +61,7 @@ public function preProcess() { parent::preProcess(); //get the contact read only fields to display. - $readOnlyFields = array_merge(array('sort_name' => ts('Name')), + $readOnlyFields = array_merge(['sort_name' => ts('Name')], CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_autocomplete_options', TRUE, NULL, FALSE, 'name', TRUE @@ -89,12 +89,12 @@ public function buildQuickForm() { CRM_Utils_System::setTitle($this->_title); $this->addDefaultButtons(ts('Save')); - $this->_fields = array(); + $this->_fields = []; $this->_fields = CRM_Core_BAO_UFGroup::getFields($ufGroupId, FALSE, CRM_Core_Action::VIEW); // remove file type field and then limit fields $suppressFields = FALSE; - $removehtmlTypes = array('File'); + $removehtmlTypes = ['File']; foreach ($this->_fields as $name => $field) { if ($cfID = CRM_Core_BAO_CustomField::getKeyID($name) && in_array($this->_fields[$name]['html_type'], $removehtmlTypes) @@ -112,17 +112,17 @@ public function buildQuickForm() { $this->_fields = array_slice($this->_fields, 0, $this->_maxFields); - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'submit', 'name' => ts('Update Contribution(s)'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); $this->assign('profileTitle', $this->_title); @@ -130,7 +130,7 @@ public function buildQuickForm() { //load all campaigns. if (array_key_exists('contribution_campaign_id', $this->_fields)) { - $this->_componentCampaigns = array(); + $this->_componentCampaigns = []; CRM_Core_PseudoConstant::populate($this->_componentCampaigns, 'CRM_Contribute_DAO_Contribution', TRUE, 'campaign_id', 'id', @@ -141,14 +141,14 @@ public function buildQuickForm() { // It is possible to have fields that are required in CiviCRM not be required in the // profile. Overriding that here. Perhaps a better approach would be to // make them required in the schema & read that up through getFields functionality. - $requiredFields = array('receive_date'); + $requiredFields = ['receive_date']; //fix for CRM-2752 $customFields = CRM_Core_BAO_CustomField::getFields('Contribution'); foreach ($this->_contributionIds as $contributionId) { $typeId = CRM_Core_DAO::getFieldValue("CRM_Contribute_DAO_Contribution", $contributionId, 'financial_type_id'); foreach ($this->_fields as $name => $field) { - $entityColumnValue = array(); + $entityColumnValue = []; if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($name)) { $customValue = CRM_Utils_Array::value($customFieldID, $customFields); if (!empty($customValue['extends_entity_column_value'])) { @@ -193,7 +193,7 @@ public function setDefaultValues() { return; } - $defaults = array(); + $defaults = []; foreach ($this->_contributionIds as $contributionId) { CRM_Core_BAO_UFGroup::setProfileDefaults(NULL, $this->_fields, $defaults, FALSE, $contributionId, 'Contribute'); } @@ -217,9 +217,9 @@ public function postProcess() { $value['financial_type_id'] = $value['financial_type']; } - $value['options'] = array( + $value['options'] = [ 'reload' => 1, - ); + ]; $contribution = civicrm_api3('Contribution', 'create', $value); $contribution = $contribution['values'][$contributionID]; diff --git a/CRM/Contribute/Form/Task/Delete.php b/CRM/Contribute/Form/Task/Delete.php index 26394d841165..82c69c935af6 100644 --- a/CRM/Contribute/Form/Task/Delete.php +++ b/CRM/Contribute/Form/Task/Delete.php @@ -82,17 +82,17 @@ public function buildQuickForm() { } } if ($count && empty($this->_contributionIds)) { - CRM_Core_Session::setStatus(ts('1 contribution could not be deleted.', array('plural' => '%count contributions could not be deleted.', 'count' => $count)), ts('Error'), 'error'); - $this->addButtons(array( - array( + CRM_Core_Session::setStatus(ts('1 contribution could not be deleted.', ['plural' => '%count contributions could not be deleted.', 'count' => $count]), ts('Error'), 'error'); + $this->addButtons([ + [ 'type' => 'back', 'name' => ts('Cancel'), - ), - ) + ], + ] ); } elseif ($count && !empty($this->_contributionIds)) { - CRM_Core_Session::setStatus(ts('1 contribution will not be deleted.', array('plural' => '%count contributions will not be deleted.', 'count' => $count)), ts('Warning'), 'warning'); + CRM_Core_Session::setStatus(ts('1 contribution will not be deleted.', ['plural' => '%count contributions will not be deleted.', 'count' => $count]), ts('Warning'), 'warning'); $this->addDefaultButtons(ts('Delete Contributions'), 'done'); } else { @@ -115,12 +115,12 @@ public function postProcess() { } if ($deleted) { - $msg = ts('%count contribution deleted.', array('plural' => '%count contributions deleted.', 'count' => $deleted)); + $msg = ts('%count contribution deleted.', ['plural' => '%count contributions deleted.', 'count' => $deleted]); CRM_Core_Session::setStatus($msg, ts('Removed'), 'success'); } if ($failed) { - CRM_Core_Session::setStatus(ts('1 could not be deleted.', array('plural' => '%count could not be deleted.', 'count' => $failed)), ts('Error'), 'error'); + CRM_Core_Session::setStatus(ts('1 could not be deleted.', ['plural' => '%count could not be deleted.', 'count' => $failed]), ts('Error'), 'error'); } } diff --git a/CRM/Contribute/Form/Task/Invoice.php b/CRM/Contribute/Form/Task/Invoice.php index 865f91b5a1ef..dffc33c9f4ed 100644 --- a/CRM/Contribute/Form/Task/Invoice.php +++ b/CRM/Contribute/Form/Task/Invoice.php @@ -73,7 +73,7 @@ class CRM_Contribute_Form_Task_Invoice extends CRM_Contribute_Form_Task { public function preProcess() { $id = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE); if ($id) { - $this->_contributionIds = array($id); + $this->_contributionIds = [$id]; $this->_componentClause = " civicrm_contribution.id IN ( $id ) "; $this->_single = TRUE; $this->assign('totalSelectedContributions', 1); @@ -92,8 +92,8 @@ public function preProcess() { // check that all the contribution ids have status Completed, Pending, Refunded. $this->_contributionStatusId = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name'); - $status = array('Completed', 'Pending', 'Refunded'); - $statusId = array(); + $status = ['Completed', 'Pending', 'Refunded']; + $statusId = []; foreach ($this->_contributionStatusId as $key => $value) { if (in_array($value, $status)) { $statusId[] = $key; @@ -117,12 +117,12 @@ public function preProcess() { } $url = CRM_Utils_System::url('civicrm/contribute/search', $urlParams); - $breadCrumb = array( - array( + $breadCrumb = [ + [ 'url' => $url, 'title' => ts('Search Results'), - ), - ); + ], + ]; CRM_Utils_System::appendBreadCrumb($breadCrumb); @@ -152,28 +152,28 @@ public function buildQuickForm() { $this->addElement('radio', 'output', NULL, ts('Email Invoice'), 'email_invoice'); $this->addElement('radio', 'output', NULL, ts('PDF Invoice'), 'pdf_invoice'); $this->addRule('output', ts('Selection required'), 'required'); - $this->addFormRule(array('CRM_Contribute_Form_Task_Invoice', 'formRule')); + $this->addFormRule(['CRM_Contribute_Form_Task_Invoice', 'formRule']); } else { $this->addRule('from_email_address', ts('From Email Address is required'), 'required'); } - $this->add('wysiwyg', 'email_comment', ts('If you would like to add personal message to email please add it here. (If sending to more then one receipient the same message will be sent to each contact.)'), array( + $this->add('wysiwyg', 'email_comment', ts('If you would like to add personal message to email please add it here. (If sending to more then one receipient the same message will be sent to each contact.)'), [ 'rows' => 2, 'cols' => 40, - )); + ]); - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'upload', 'name' => $this->_selectedOutput == 'email' ? ts('Send Email') : ts('Process Invoice(s)'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); } @@ -186,7 +186,7 @@ public function buildQuickForm() { * list of errors to be posted back to the form */ public static function formRule($values) { - $errors = array(); + $errors = []; if ($values['output'] == 'email_invoice' && empty($values['from_email_address'])) { $errors['from_email_address'] = ts("From Email Address is required"); @@ -215,7 +215,7 @@ public function postProcess() { */ public static function printPDF($contribIDs, &$params, $contactIds) { // get all the details needed to generate a invoice - $messageInvoice = array(); + $messageInvoice = []; $invoiceTemplate = CRM_Core_Smarty::singleton(); $invoiceElements = CRM_Contribute_Form_Task_PDF::getElements($contribIDs, $params, $contactIds); @@ -229,7 +229,7 @@ public static function printPDF($contribIDs, &$params, $contactIds) { $prefixValue = Civi::settings()->get('contribution_invoice_settings'); foreach ($invoiceElements['details'] as $contribID => $detail) { - $input = $ids = $objects = array(); + $input = $ids = $objects = []; if (in_array($detail['contact'], $invoiceElements['excludeContactIds'])) { continue; } @@ -258,11 +258,11 @@ public static function printPDF($contribIDs, &$params, $contactIds) { $objects['contribution']->receive_date = CRM_Utils_Date::isoToMysql($objects['contribution']->receive_date); - $addressParams = array('contact_id' => $contribution->contact_id); + $addressParams = ['contact_id' => $contribution->contact_id]; $addressDetails = CRM_Core_BAO_Address::getValues($addressParams); // to get billing address if present - $billingAddress = array(); + $billingAddress = []; foreach ($addressDetails as $address) { if (($address['is_billing'] == 1) && ($address['is_primary'] == 1) && ($address['contact_id'] == $contribution->contact_id)) { $billingAddress[$address['contact_id']] = $address; @@ -306,10 +306,10 @@ public static function printPDF($contribIDs, &$params, $contactIds) { $lineItem = CRM_Price_BAO_LineItem::getLineItems($eid, 'participant', NULL, TRUE, FALSE, TRUE); } - $resultPayments = civicrm_api3('Payment', 'get', array( + $resultPayments = civicrm_api3('Payment', 'get', [ 'sequential' => 1, 'contribution_id' => $contribID, - )); + ]); $amountPaid = 0; foreach ($resultPayments['values'] as $singlePayment) { // Only count payments that have been (status =) completed. @@ -320,7 +320,7 @@ public static function printPDF($contribIDs, &$params, $contactIds) { $amountDue = ($input['amount'] - $amountPaid); // retrieving the subtotal and sum of same tax_rate - $dataArray = array(); + $dataArray = []; $subTotal = 0; foreach ($lineItem as $taxRate) { if (isset($dataArray[(string) $taxRate['tax_rate']])) { @@ -333,18 +333,18 @@ public static function printPDF($contribIDs, &$params, $contactIds) { } // to email the invoice - $mailDetails = array(); - $values = array(); + $mailDetails = []; + $values = []; if ($contribution->_component == 'event') { $daoName = 'CRM_Event_DAO_Event'; $pageId = $contribution->_relatedObjects['event']->id; - $mailElements = array( + $mailElements = [ 'title', 'confirm_from_name', 'confirm_from_email', 'cc_confirm', 'bcc_confirm', - ); + ]; 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]); @@ -357,13 +357,13 @@ public static function printPDF($contribIDs, &$params, $contactIds) { elseif ($contribution->_component == 'contribute') { $daoName = 'CRM_Contribute_DAO_ContributionPage'; $pageId = $contribution->contribution_page_id; - $mailElements = array( + $mailElements = [ 'title', 'receipt_from_name', 'receipt_from_email', 'cc_receipt', 'bcc_receipt', - ); + ]; CRM_Core_DAO::commonRetrieveAll($daoName, 'id', $pageId, $mailDetails, $mailElements); $values['title'] = CRM_Utils_Array::value('title', CRM_Utils_Array::value($contribution->contribution_page_id, $mailDetails)); @@ -383,7 +383,7 @@ public static function printPDF($contribIDs, &$params, $contactIds) { // get organization address $domain = CRM_Core_BAO_Domain::getDomain(); - $locParams = array('contact_id' => $domain->contact_id); + $locParams = ['contact_id' => $domain->contact_id]; $locationDefaults = CRM_Core_BAO_Location::getValues($locParams); if (isset($locationDefaults['address'][1]['state_province_id'])) { $stateProvinceAbbreviationDomain = CRM_Core_PseudoConstant::stateProvinceAbbreviation($locationDefaults['address'][1]['state_province_id']); @@ -399,7 +399,7 @@ public static function printPDF($contribIDs, &$params, $contactIds) { } // parameters to be assign for template - $tplParams = array( + $tplParams = [ 'title' => $title, 'component' => $input['component'], 'id' => $contribution->id, @@ -443,20 +443,20 @@ public static function printPDF($contribIDs, &$params, $contactIds) { 'domain_country' => $countryDomain, 'domain_email' => CRM_Utils_Array::value('email', CRM_Utils_Array::value('1', $locationDefaults['email'])), 'domain_phone' => CRM_Utils_Array::value('phone', CRM_Utils_Array::value('1', $locationDefaults['phone'])), - ); + ]; if (isset($creditNoteId)) { $tplParams['creditnote_id'] = $creditNoteId; } $pdfFileName = $contribution->invoice_number . ".pdf"; - $sendTemplateParams = array( + $sendTemplateParams = [ 'groupName' => 'msg_tpl_workflow_contribution', 'valueName' => 'contribution_invoice_receipt', 'contactId' => $contribution->contact_id, 'tplParams' => $tplParams, 'PDFFilename' => $pdfFileName, - ); + ]; // from email address $fromEmailAddress = CRM_Utils_Array::value('from_email_address', $params); @@ -468,11 +468,11 @@ public static function printPDF($contribIDs, &$params, $contactIds) { return $html; } else { - $mail = array( + $mail = [ 'subject' => $subject, 'body' => $message, 'html' => $html, - ); + ]; if ($mail['html']) { $messageInvoice[] = $mail['html']; } @@ -484,7 +484,7 @@ public static function printPDF($contribIDs, &$params, $contactIds) { elseif ($contribution->_component == 'contribute') { $email = CRM_Contact_BAO_Contact::getPrimaryEmail($contribution->contact_id); - $sendTemplateParams['tplParams'] = array_merge($tplParams, array('email_comment' => $invoiceElements['params']['email_comment'])); + $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); @@ -498,7 +498,7 @@ public static function printPDF($contribIDs, &$params, $contactIds) { elseif ($contribution->_component == 'event') { $email = CRM_Contact_BAO_Contact::getPrimaryEmail($contribution->contact_id); - $sendTemplateParams['tplParams'] = array_merge($tplParams, array('email_comment' => $invoiceElements['params']['email_comment'])); + $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); @@ -517,11 +517,11 @@ public static function printPDF($contribIDs, &$params, $contactIds) { return $html; } else { - CRM_Utils_PDF_Utils::html2pdf($messageInvoice, $pdfFileName, FALSE, array( + CRM_Utils_PDF_Utils::html2pdf($messageInvoice, $pdfFileName, FALSE, [ 'margin_top' => 10, 'margin_left' => 65, 'metric' => 'px', - )); + ]); // functions call for adding activity with attachment $fileName = self::putFile($html, $pdfFileName); self::addActivities($subject, $contactIds, $fileName, $params); @@ -531,7 +531,7 @@ public static function printPDF($contribIDs, &$params, $contactIds) { } else { if ($invoiceElements['suppressedEmails']) { - $status = ts('Email was NOT sent to %1 contacts (no email address on file, or communication preferences specify DO NOT EMAIL, or contact is deceased).', array(1 => $invoiceElements['suppressedEmails'])); + $status = ts('Email was NOT sent to %1 contacts (no email address on file, or communication preferences specify DO NOT EMAIL, or contact is deceased).', [1 => $invoiceElements['suppressedEmails']]); $msgTitle = ts('Email Error'); $msgType = 'error'; } @@ -578,19 +578,19 @@ static public function addActivities($subject, $contactIds, $fileName, $params) ); } - $activityParams = array( + $activityParams = [ 'subject' => $subject, 'source_contact_id' => $userID, 'target_contact_id' => $contactIds, 'activity_type_id' => $activityTypeID, 'activity_date_time' => date('YmdHis'), - 'attachFile_1' => array( + 'attachFile_1' => [ 'uri' => $fileName, 'type' => 'application/pdf', 'location' => $fileName, 'upload_date' => date('YmdHis'), - ), - ); + ], + ]; CRM_Activity_BAO_Activity::create($activityParams); } @@ -624,9 +624,9 @@ static public function putFile($html, $name = 'Invoice.pdf') { */ public static function getPrintPDF() { $contributionId = CRM_Utils_Request::retrieve('id', 'Positive', CRM_Core_DAO::$_nullObject, FALSE); - $contributionIDs = array($contributionId); + $contributionIDs = [$contributionId]; $contactId = CRM_Utils_Request::retrieve('cid', 'Positive', CRM_Core_DAO::$_nullObject, FALSE); - $params = array('output' => 'pdf_invoice'); + $params = ['output' => 'pdf_invoice']; CRM_Contribute_Form_Task_Invoice::printPDF($contributionIDs, $params, $contactId); } diff --git a/CRM/Contribute/Form/Task/PDF.php b/CRM/Contribute/Form/Task/PDF.php index f29751970c0a..aff1abaf0d3f 100644 --- a/CRM/Contribute/Form/Task/PDF.php +++ b/CRM/Contribute/Form/Task/PDF.php @@ -56,7 +56,7 @@ public function preProcess() { ); if ($id) { - $this->_contributionIds = array($id); + $this->_contributionIds = [$id]; $this->_componentClause = " civicrm_contribution.id IN ( $id ) "; $this->_single = TRUE; $this->assign('totalSelectedContributions', 1); @@ -85,12 +85,12 @@ public function preProcess() { } $url = CRM_Utils_System::url('civicrm/contribute/search', $urlParams); - $breadCrumb = array( - array( + $breadCrumb = [ + [ 'url' => $url, 'title' => ts('Search Results'), - ), - ); + ], + ]; CRM_Contact_Form_Task_EmailCommon ::preProcessFromAddress($this, FALSE); // we have all the contribution ids, so now we get the contact ids parent::setContactIDs(); @@ -104,36 +104,36 @@ public function preProcess() { public function buildQuickForm() { $this->addElement('radio', 'output', NULL, ts('Email Receipts'), 'email_receipt', - array( + [ 'onClick' => "document.getElementById('selectPdfFormat').style.display = 'none'; - document.getElementById('selectEmailFrom').style.display = 'block';") + document.getElementById('selectEmailFrom').style.display = 'block';"] ); $this->addElement('radio', 'output', NULL, ts('PDF Receipts'), 'pdf_receipt', - array( + [ 'onClick' => "document.getElementById('selectPdfFormat').style.display = 'block'; - document.getElementById('selectEmailFrom').style.display = 'none';") + document.getElementById('selectEmailFrom').style.display = 'none';"] ); $this->addRule('output', ts('Selection required'), 'required'); $this->add('select', 'pdf_format_id', ts('Page Format'), - array(0 => ts('- default -')) + CRM_Core_BAO_PdfFormat::getList(TRUE) + [0 => ts('- default -')] + CRM_Core_BAO_PdfFormat::getList(TRUE) ); $this->add('checkbox', 'receipt_update', ts('Update receipt dates for these contributions'), FALSE); $this->add('checkbox', 'override_privacy', ts('Override privacy setting? (Do not email / Do not mail)'), FALSE); $this->add('select', 'from_email_address', ts('From Email'), $this->_fromEmails, FALSE); - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => ts('Process Receipt(s)'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'back', 'name' => ts('Cancel'), - ), - ) + ], + ] ); } @@ -142,7 +142,7 @@ public function buildQuickForm() { */ public function setDefaultValues() { $defaultFormat = CRM_Core_BAO_PdfFormat::getDefaultValues(); - return array('pdf_format_id' => $defaultFormat['id'], 'receipt_update' => 1, 'override_privacy' => 0); + return ['pdf_format_id' => $defaultFormat['id'], 'receipt_update' => 1, 'override_privacy' => 0]; } /** @@ -150,14 +150,14 @@ public function setDefaultValues() { */ public function postProcess() { // get all the details needed to generate a receipt - $message = array(); + $message = []; $template = CRM_Core_Smarty::singleton(); $params = $this->controller->exportValues($this->_name); $elements = self::getElements($this->_contributionIds, $params, $this->_contactIds); foreach ($elements['details'] as $contribID => $detail) { - $input = $ids = $objects = array(); + $input = $ids = $objects = []; if (in_array($detail['contact'], $elements['excludeContactIds'])) { continue; @@ -192,13 +192,13 @@ public function postProcess() { CRM_Core_DAO::singleValueQuery("SELECT payment_processor_id FROM civicrm_financial_trxn WHERE trxn_id = %1 - LIMIT 1", array( - 1 => array($contribution->trxn_id, 'String'))); + LIMIT 1", [ + 1 => [$contribution->trxn_id, 'String']]); // CRM_Contribute_BAO_Contribution::composeMessageArray expects mysql formatted date $objects['contribution']->receive_date = CRM_Utils_Date::isoToMysql($objects['contribution']->receive_date); - $values = array(); + $values = []; if (isset($params['from_email_address']) && !$elements['createPdf']) { // If a logged in user from email is used rather than a domain wide from email address // the from_email_address params key will be numerical and we need to convert it to be @@ -234,7 +234,7 @@ public function postProcess() { } else { if ($elements['suppressedEmails']) { - $status = ts('Email was NOT sent to %1 contacts (no email address on file, or communication preferences specify DO NOT EMAIL, or contact is deceased).', array(1 => $elements['suppressedEmails'])); + $status = ts('Email was NOT sent to %1 contacts (no email address on file, or communication preferences specify DO NOT EMAIL, or contact is deceased).', [1 => $elements['suppressedEmails']]); $msgTitle = ts('Email Error'); $msgType = 'error'; } @@ -263,7 +263,7 @@ public function postProcess() { * */ static public function getElements($contribIds, $params, $contactIds) { - $pdfElements = array(); + $pdfElements = []; $pdfElements['contribIDs'] = implode(',', $contribIds); @@ -280,14 +280,14 @@ static public function getElements($contribIds, $params, $contactIds) { $pdfElements['createPdf'] = TRUE; } - $excludeContactIds = array(); + $excludeContactIds = []; if (!$pdfElements['createPdf']) { - $returnProperties = array( + $returnProperties = [ 'email' => 1, 'do_not_email' => 1, 'is_deceased' => 1, 'on_hold' => 1, - ); + ]; list($contactDetails) = CRM_Utils_Token::getTokenDetails($contactIds, $returnProperties, FALSE, FALSE); $pdfElements['suppressedEmails'] = 0; diff --git a/CRM/Contribute/Form/Task/PDFLetter.php b/CRM/Contribute/Form/Task/PDFLetter.php index 397907b5099e..b481060195e3 100644 --- a/CRM/Contribute/Form/Task/PDFLetter.php +++ b/CRM/Contribute/Form/Task/PDFLetter.php @@ -88,9 +88,9 @@ public function preProcess() { * @return array */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; if (isset($this->_activityId)) { - $params = array('id' => $this->_activityId); + $params = ['id' => $this->_activityId]; CRM_Activity_BAO_Activity::retrieve($params, $defaults); $defaults['html_message'] = CRM_Utils_Array::value('details', $defaults); } @@ -117,41 +117,41 @@ public function buildQuickForm() { $this->add('checkbox', 'thankyou_update', ts('Update thank-you dates for these contributions'), FALSE); // Group options for tokens are not yet implemented. dgg - $options = array( + $options = [ '' => ts('- no grouping -'), 'contact_id' => ts('Contact'), 'contribution_recur_id' => ts('Contact and Recurring'), 'financial_type_id' => ts('Contact and Financial Type'), 'campaign_id' => ts('Contact and Campaign'), 'payment_instrument_id' => ts('Contact and Payment Method'), - ); - $this->addElement('select', 'group_by', ts('Group contributions by'), $options, array(), "
    ", FALSE); + ]; + $this->addElement('select', 'group_by', ts('Group contributions by'), $options, [], "
    ", FALSE); // this was going to be free-text but I opted for radio options in case there was a script injection risk - $separatorOptions = array('comma' => 'Comma', 'td' => 'Horizontal Table Cell', 'tr' => 'Vertical Table Cell', 'br' => 'Line Break'); + $separatorOptions = ['comma' => 'Comma', 'td' => 'Horizontal Table Cell', 'tr' => 'Vertical Table Cell', 'br' => 'Line Break']; $this->addElement('select', 'group_by_separator', ts('Separator (grouped contributions)'), $separatorOptions); - $emailOptions = array( + $emailOptions = [ '' => ts('Generate PDFs for printing (only)'), 'email' => ts('Send emails where possible. Generate printable PDFs for contacts who cannot receive email.'), 'both' => ts('Send emails where possible. Generate printable PDFs for all contacts.'), - ); + ]; if (CRM_Core_Config::singleton()->doNotAttachPDFReceipt) { $emailOptions['pdfemail'] = ts('Send emails with an attached PDF where possible. Generate printable PDFs for contacts who cannot receive email.'); $emailOptions['pdfemail_both'] = ts('Send emails with an attached PDF where possible. Generate printable PDFs for all contacts.'); } - $this->addElement('select', 'email_options', ts('Print and email options'), $emailOptions, array(), "
    ", FALSE); + $this->addElement('select', 'email_options', ts('Print and email options'), $emailOptions, [], "
    ", FALSE); - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'upload', 'name' => ts('Make Thank-you Letters'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Done'), - ), - ) + ], + ] ); } diff --git a/CRM/Contribute/Form/Task/PDFLetterCommon.php b/CRM/Contribute/Form/Task/PDFLetterCommon.php index 044d7df56f9a..c6af7bcd7c5d 100644 --- a/CRM/Contribute/Form/Task/PDFLetterCommon.php +++ b/CRM/Contribute/Form/Task/PDFLetterCommon.php @@ -32,13 +32,13 @@ public static function postProcess(&$form, $formValues = NULL) { } list($formValues, $categories, $html_message, $messageToken, $returnProperties) = self::processMessageTemplate($formValues); $isPDF = FALSE; - $emailParams = array(); + $emailParams = []; if (!empty($formValues['email_options'])) { $returnProperties['email'] = $returnProperties['on_hold'] = $returnProperties['is_deceased'] = $returnProperties['do_not_email'] = 1; - $emailParams = array( + $emailParams = [ 'subject' => CRM_Utils_Array::value('subject', $formValues), 'from' => CRM_Utils_Array::value('from_email_address', $formValues), - ); + ]; $emailParams['from'] = CRM_Utils_Mail::formatFromAddress($emailParams['from']); @@ -56,14 +56,14 @@ public static function postProcess(&$form, $formValues = NULL) { $updateStatus = ''; $task = 'CRM_Contribution_Form_Task_PDFLetterCommon'; $realSeparator = ', '; - $tableSeparators = array( + $tableSeparators = [ 'td' => '', 'tr' => '', - ); + ]; //the original thinking was mutliple options - but we are going with only 2 (comma & td) for now in case // there are security (& UI) issues we need to think through if (isset($formValues['group_by_separator'])) { - if (in_array($formValues['group_by_separator'], array('td', 'tr'))) { + if (in_array($formValues['group_by_separator'], ['td', 'tr'])) { $realSeparator = $tableSeparators[$formValues['group_by_separator']]; } elseif ($formValues['group_by_separator'] == 'br') { @@ -82,8 +82,8 @@ public static function postProcess(&$form, $formValues = NULL) { $contributionIDs = $form->getVar('_contributionContactIds'); } list($contributions, $contacts) = self::buildContributionArray($groupBy, $contributionIDs, $returnProperties, $skipOnHold, $skipDeceased, $messageToken, $task, $separator, $form->_includesSoftCredits); - $html = array(); - $contactHtml = $emailedHtml = array(); + $html = []; + $contactHtml = $emailedHtml = []; foreach ($contributions as $contributionId => $contribution) { $contact = &$contacts[$contribution['contact_id']]; $grouped = FALSE; @@ -108,7 +108,7 @@ public static function postProcess(&$form, $formValues = NULL) { $contact['is_sent'][$groupBy][$groupByID] = TRUE; } // Update receipt/thankyou dates - $contributionParams = array('id' => $contributionId); + $contributionParams = ['id' => $contributionId]; if ($receipt_update) { $contributionParams['receipt_date'] = $nowDate; } @@ -145,13 +145,13 @@ public static function postProcess(&$form, $formValues = NULL) { $form->postProcessHook(); if ($emailed) { - $updateStatus = ts('Receipts have been emailed to %1 contributions.', array(1 => $emailed)); + $updateStatus = ts('Receipts have been emailed to %1 contributions.', [1 => $emailed]); } if ($receipts) { - $updateStatus = ts('Receipt date has been updated for %1 contributions.', array(1 => $receipts)); + $updateStatus = ts('Receipt date has been updated for %1 contributions.', [1 => $receipts]); } if ($thanks) { - $updateStatus .= ' ' . ts('Thank-you date has been updated for %1 contributions.', array(1 => $thanks)); + $updateStatus .= ' ' . ts('Thank-you date has been updated for %1 contributions.', [1 => $thanks]); } if ($updateStatus) { @@ -174,7 +174,7 @@ public static function postProcess(&$form, $formValues = NULL) { * @return bool */ public static function isValidHTMLWithTableSeparator($tokens, $html) { - $relevantEntities = array('contribution'); + $relevantEntities = ['contribution']; foreach ($relevantEntities as $entity) { if (isset($tokens[$entity]) && is_array($tokens[$entity])) { foreach ($tokens[$entity] as $token) { @@ -254,18 +254,18 @@ private static function resolveTokens($html_message, $contact, $contribution, $m * @return array */ public static function buildContributionArray($groupBy, $contributionIDs, $returnProperties, $skipOnHold, $skipDeceased, $messageToken, $task, $separator, $isIncludeSoftCredits) { - $contributions = $contacts = array(); + $contributions = $contacts = []; foreach ($contributionIDs as $item => $contributionId) { // Basic return attributes available to the template. - $returnValues = array('contact_id', 'total_amount', 'financial_type', 'receive_date', 'contribution_campaign_title'); + $returnValues = ['contact_id', 'total_amount', 'financial_type', 'receive_date', 'contribution_campaign_title']; if (!empty($messageToken['contribution'])) { $returnValues = array_merge($messageToken['contribution'], $returnValues); } // retrieve contribution tokens listed in $returnProperties using Contribution.Get API - $contribution = civicrm_api3('Contribution', 'getsingle', array( + $contribution = civicrm_api3('Contribution', 'getsingle', [ 'id' => $contributionId, 'return' => $returnValues, - )); + ]); $contribution['campaign'] = CRM_Utils_Array::value('contribution_campaign_title', $contribution); $contributions[$contributionId] = $contribution; @@ -278,9 +278,9 @@ public static function buildContributionArray($groupBy, $contributionIDs, $retur $contactID = $contribution['contact_id']; } if (!isset($contacts[$contactID])) { - $contacts[$contactID] = array(); + $contacts[$contactID] = []; $contacts[$contactID]['contact_aggregate'] = 0; - $contacts[$contactID]['combined'] = $contacts[$contactID]['contribution_ids'] = array(); + $contacts[$contactID]['combined'] = $contacts[$contactID]['contribution_ids'] = []; } $contacts[$contactID]['contact_aggregate'] += $contribution['total_amount']; @@ -302,7 +302,7 @@ public static function buildContributionArray($groupBy, $contributionIDs, $retur // Hooks allow more nuanced smarty usage here. CRM_Core_Smarty::singleton()->assign('contributions', $contributions); foreach ($contacts as $contactID => $contact) { - $tokenResolvedContacts = CRM_Utils_Token::getTokenDetails(array('contact_id' => $contactID), + $tokenResolvedContacts = CRM_Utils_Token::getTokenDetails(['contact_id' => $contactID], $returnProperties, $skipOnHold, $skipDeceased, @@ -312,7 +312,7 @@ public static function buildContributionArray($groupBy, $contributionIDs, $retur ); $contacts[$contactID] = array_merge($tokenResolvedContacts[0][$contactID], $contact); } - return array($contributions, $contacts); + return [$contributions, $contacts]; } /** @@ -363,24 +363,24 @@ public static function assignCombinedContributionValues($contact, $contributions * * @return bool */ - public static function emailLetter($contact, $html, $is_pdf, $format = array(), $params = array()) { + public static function emailLetter($contact, $html, $is_pdf, $format = [], $params = []) { try { if (empty($contact['email'])) { return FALSE; } - $mustBeEmpty = array('do_not_email', 'is_deceased', 'on_hold'); + $mustBeEmpty = ['do_not_email', 'is_deceased', 'on_hold']; foreach ($mustBeEmpty as $emptyField) { if (!empty($contact[$emptyField])) { return FALSE; } } - $defaults = array( + $defaults = [ 'toName' => $contact['display_name'], 'toEmail' => $contact['email'], 'text' => '', 'html' => $html, - ); + ]; if (empty($params['from'])) { $emails = CRM_Core_BAO_Email::getFromEmail(); $emails = array_keys($emails); @@ -397,7 +397,7 @@ public static function emailLetter($contact, $html, $is_pdf, $format = array(), } if ($is_pdf) { $defaults['html'] = ts('Please see attached'); - $defaults['attachments'] = array(CRM_Utils_Mail::appendPDF('ThankYou.pdf', $html, $format)); + $defaults['attachments'] = [CRM_Utils_Mail::appendPDF('ThankYou.pdf', $html, $format)]; } $params = array_merge($defaults); return CRM_Utils_Mail::send($params); diff --git a/CRM/Contribute/Form/Task/PickProfile.php b/CRM/Contribute/Form/Task/PickProfile.php index c937de4ac42a..c4908eb0688a 100644 --- a/CRM/Contribute/Form/Task/PickProfile.php +++ b/CRM/Contribute/Form/Task/PickProfile.php @@ -67,10 +67,10 @@ public function preProcess() { $validate = FALSE; //validations if (count($this->_contributionIds) > $this->_maxContributions) { - CRM_Core_Session::setStatus(ts("The maximum number of contributions you can select for Update multiple contributions is %1. You have selected %2. Please select fewer contributions from your search results and try again.", array( + CRM_Core_Session::setStatus(ts("The maximum number of contributions you can select for Update multiple contributions is %1. You have selected %2. Please select fewer contributions from your search results and try again.", [ 1 => $this->_maxContributions, 2 => count($this->_contributionIds), - )), ts('Update multiple records error'), 'error'); + ]), ts('Update multiple records error'), 'error'); $validate = TRUE; } @@ -85,18 +85,18 @@ public function preProcess() { */ public function buildQuickForm() { - $types = array('Contribution'); + $types = ['Contribution']; $profiles = CRM_Core_BAO_UFGroup::getProfiles($types, TRUE); if (empty($profiles)) { - CRM_Core_Session::setStatus(ts("You will need to create a Profile containing the %1 fields you want to edit before you can use Update multiple contributions. Navigate to Administer CiviCRM > Customize Data and Screens > CiviCRM Profile to configure a Profile. Consult the online Administrator documentation for more information.", array(1 => $types[0])), ts('Profile Required'), 'error'); + CRM_Core_Session::setStatus(ts("You will need to create a Profile containing the %1 fields you want to edit before you can use Update multiple contributions. Navigate to Administer CiviCRM > Customize Data and Screens > CiviCRM Profile to configure a Profile. Consult the online Administrator documentation for more information.", [1 => $types[0]]), ts('Profile Required'), 'error'); CRM_Utils_System::redirect($this->_userContext); } $ufGroupElement = $this->add('select', 'uf_group_id', ts('Select Profile'), - array( + [ '' => ts('- select profile -'), - ) + $profiles, TRUE + ] + $profiles, TRUE ); $this->addDefaultButtons(ts('Continue')); } @@ -105,7 +105,7 @@ public function buildQuickForm() { * Add local and global form rules. */ public function addRules() { - $this->addFormRule(array('CRM_Contribute_Form_Task_PickProfile', 'formRule')); + $this->addFormRule(['CRM_Contribute_Form_Task_PickProfile', 'formRule']); } /** diff --git a/CRM/Contribute/Form/Task/Print.php b/CRM/Contribute/Form/Task/Print.php index 8b11f9088120..132e2cefe886 100644 --- a/CRM/Contribute/Form/Task/Print.php +++ b/CRM/Contribute/Form/Task/Print.php @@ -72,18 +72,18 @@ public function buildQuickForm() { // // just need to add a javascript to popup the window for printing // - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => ts('Print Contributions'), - 'js' => array('onclick' => 'window.print()'), + 'js' => ['onclick' => 'window.print()'], 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'back', 'name' => ts('Done'), - ), - ) + ], + ] ); } diff --git a/CRM/Contribute/Form/Task/Result.php b/CRM/Contribute/Form/Task/Result.php index 27f98f1647e2..6e9c0999ef20 100644 --- a/CRM/Contribute/Form/Task/Result.php +++ b/CRM/Contribute/Form/Task/Result.php @@ -46,13 +46,13 @@ public function preProcess() { * Build the form object. */ public function buildQuickForm() { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'done', 'name' => ts('Done'), 'isDefault' => TRUE, - ), - ) + ], + ] ); } diff --git a/CRM/Contribute/Form/Task/SearchTaskHookSample.php b/CRM/Contribute/Form/Task/SearchTaskHookSample.php index f7e46c5cad3f..ce9e319b8481 100644 --- a/CRM/Contribute/Form/Task/SearchTaskHookSample.php +++ b/CRM/Contribute/Form/Task/SearchTaskHookSample.php @@ -42,7 +42,7 @@ class CRM_Contribute_Form_Task_SearchTaskHookSample extends CRM_Contribute_Form_ */ public function preProcess() { parent::preProcess(); - $rows = array(); + $rows = []; // display name and contribution details of all selected contacts $contribIDs = implode(',', $this->_contributionIds); @@ -60,12 +60,12 @@ public function preProcess() { ); while ($dao->fetch()) { - $rows[] = array( + $rows[] = [ 'display_name' => $dao->display_name, 'amount' => $dao->amount, 'source' => $dao->source, 'receive_date' => $dao->receive_date, - ); + ]; } $this->assign('rows', $rows); } @@ -74,13 +74,13 @@ public function preProcess() { * Build the form object. */ public function buildQuickForm() { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'done', 'name' => ts('Done'), 'isDefault' => TRUE, - ), - ) + ], + ] ); } diff --git a/CRM/Contribute/Form/Task/Status.php b/CRM/Contribute/Form/Task/Status.php index c3f4e9d9e631..08262c92b3d5 100644 --- a/CRM/Contribute/Form/Task/Status.php +++ b/CRM/Contribute/Form/Task/Status.php @@ -55,7 +55,7 @@ public function preProcess() { ); if ($id) { - $this->_contributionIds = array($id); + $this->_contributionIds = [$id]; $this->_componentClause = " civicrm_contribution.id IN ( $id ) "; $this->_single = TRUE; $this->assign('totalSelectedContributions', 1); @@ -115,11 +115,11 @@ public function buildQuickForm() { ); // build a row for each contribution id - $this->_rows = array(); + $this->_rows = []; $attributes = CRM_Core_DAO::getAttribute('CRM_Contribute_DAO_Contribution'); - $defaults = array(); + $defaults = []; $now = date("Y-m-d"); - $paidByOptions = array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(); + $paidByOptions = ['' => ts('- select -')] + CRM_Contribute_PseudoConstant::paymentInstrument(); while ($dao->fetch()) { $row['contact_id'] = $dao->contact_id; @@ -131,7 +131,7 @@ public function buildQuickForm() { $this->addRule("trxn_id_{$row['contribution_id']}", ts('This Transaction ID already exists in the database. Include the account number for checks.'), 'objectExists', - array('CRM_Contribute_DAO_Contribution', $dao->contribution_id, 'trxn_id') + ['CRM_Contribute_DAO_Contribution', $dao->contribution_id, 'trxn_id'] ); $row['fee_amount'] = &$this->add('text', "fee_amount_{$row['contribution_id']}", ts('Fee Amount'), @@ -154,20 +154,20 @@ public function buildQuickForm() { $this->assign_by_ref('rows', $this->_rows); $this->setDefaults($defaults); - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => ts('Update Pending Status'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'back', 'name' => ts('Cancel'), - ), - ) + ], + ] ); - $this->addFormRule(array('CRM_Contribute_Form_Task_Status', 'formRule')); + $this->addFormRule(['CRM_Contribute_Form_Task_Status', 'formRule']); } /** @@ -180,7 +180,7 @@ public function buildQuickForm() { * list of errors to be posted back to the form */ public static function formRule($fields) { - $seen = $errors = array(); + $seen = $errors = []; foreach ($fields as $name => $value) { if (strpos($name, 'trxn_id_') !== FALSE) { if ($fields[$name]) { @@ -237,7 +237,7 @@ public static function processForm($form, $params) { // for each contribution id, we just call the baseIPN stuff foreach ($form->_rows as $row) { - $input = $ids = $objects = array(); + $input = $ids = $objects = []; $input['component'] = $details[$row['contribution_id']]['component']; $ids['contact'] = $row['contact_id']; @@ -323,7 +323,7 @@ public static function &getDetails($contributionIDs) { LEFT JOIN civicrm_participant p ON pp.participant_id = p.id WHERE c.id IN ( $contributionIDs )"; - $rows = array(); + $rows = []; $dao = CRM_Core_DAO::executeQuery($query, CRM_Core_DAO::$_nullArray ); @@ -333,7 +333,7 @@ public static function &getDetails($contributionIDs) { $rows[$dao->contribution_id]['contact'] = $dao->contact_id; if ($dao->membership_id) { if (!array_key_exists('membership', $rows[$dao->contribution_id])) { - $rows[$dao->contribution_id]['membership'] = array(); + $rows[$dao->contribution_id]['membership'] = []; } $rows[$dao->contribution_id]['membership'][] = $dao->membership_id; } diff --git a/CRM/Contribute/Form/UpdateSubscription.php b/CRM/Contribute/Form/UpdateSubscription.php index c1a092e53cbe..cbe2ee833391 100644 --- a/CRM/Contribute/Form/UpdateSubscription.php +++ b/CRM/Contribute/Form/UpdateSubscription.php @@ -52,7 +52,7 @@ class CRM_Contribute_Form_UpdateSubscription extends CRM_Contribute_Form_Contrib * * @var array */ - protected $editableScheduleFields = array(); + protected $editableScheduleFields = []; /** * The id of the contact associated with this recurring contribution. @@ -101,9 +101,9 @@ public function preProcess() { if ($this->_subscriptionDetails->membership_id && $this->_subscriptionDetails->auto_renew) { // Add Membership details to form - $membership = civicrm_api3('Membership', 'get', array( + $membership = civicrm_api3('Membership', 'get', [ 'contribution_recur_id' => $this->contributionRecurID, - )); + ]); if (!empty($membership['count'])) { $membershipDetails = reset($membership['values']); $values['membership_id'] = $membershipDetails['id']; @@ -131,10 +131,10 @@ public function preProcess() { else { $this->assign('changeHelpText', $changeHelpText); } - $alreadyHardCodedFields = array('amount', 'installments'); + $alreadyHardCodedFields = ['amount', 'installments']; foreach ($this->editableScheduleFields as $editableScheduleField) { if (!in_array($editableScheduleField, $alreadyHardCodedFields)) { - $this->addField($editableScheduleField, array('entity' => 'ContributionRecur'), FALSE, FALSE); + $this->addField($editableScheduleField, ['entity' => 'ContributionRecur'], FALSE, FALSE); } } @@ -163,7 +163,7 @@ public function preProcess() { * Note that in edit/view mode the default values are retrieved from the database. */ public function setDefaultValues() { - $this->_defaults = array(); + $this->_defaults = []; $this->_defaults['amount'] = $this->_subscriptionDetails->amount; $this->_defaults['installments'] = $this->_subscriptionDetails->installments; $this->_defaults['campaign_id'] = $this->_subscriptionDetails->campaign_id; @@ -181,16 +181,16 @@ public function setDefaultValues() { */ public function buildQuickForm() { // CRM-16398: If current recurring contribution got > 1 lineitems then make amount field readonly - $amtAttr = array('size' => 20); + $amtAttr = ['size' => 20]; $lineItems = CRM_Price_BAO_LineItem::getLineItemsByContributionID($this->_coid); if (count($lineItems) > 1) { - $amtAttr += array('readonly' => TRUE); + $amtAttr += ['readonly' => TRUE]; } $this->addMoney('amount', ts('Recurring Contribution Amount'), TRUE, $amtAttr, TRUE, 'currency', $this->_subscriptionDetails->currency, TRUE ); - $this->add('text', 'installments', ts('Number of Installments'), array('size' => 20), FALSE); + $this->add('text', 'installments', ts('Number of Installments'), ['size' => 20], FALSE); if ($this->_donorEmail) { $this->add('checkbox', 'is_notify', ts('Notify Contributor?')); @@ -201,7 +201,7 @@ public function buildQuickForm() { } if (CRM_Contribute_BAO_ContributionRecur::supportsFinancialTypeChange($this->contributionRecurID)) { - $this->addEntityRef('financial_type_id', ts('Financial Type'), array('entity' => 'FinancialType'), !$this->_selfService); + $this->addEntityRef('financial_type_id', ts('Financial Type'), ['entity' => 'FinancialType'], !$this->_selfService); } // Add custom data @@ -214,17 +214,17 @@ public function buildQuickForm() { } // define the buttons - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => $type, 'name' => ts('Save'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); } @@ -261,12 +261,12 @@ public function postProcess() { // save the changes CRM_Contribute_BAO_ContributionRecur::add($params); $status = ts('Recurring contribution has been updated to: %1, every %2 %3(s) for %4 installments.', - array( + [ 1 => CRM_Utils_Money::format($params['amount'], $this->_subscriptionDetails->currency), 2 => $this->_subscriptionDetails->frequency_interval, 3 => $this->_subscriptionDetails->frequency_unit, 4 => $params['installments'], - ) + ] ); $msgTitle = ts('Update Success'); @@ -276,10 +276,10 @@ public function postProcess() { if ($this->_subscriptionDetails->amount != $params['amount']) { $message .= "
    " . ts("Recurring contribution amount has been updated from %1 to %2 for this subscription.", - array( + [ 1 => CRM_Utils_Money::format($this->_subscriptionDetails->amount, $this->_subscriptionDetails->currency), 2 => CRM_Utils_Money::format($params['amount'], $this->_subscriptionDetails->currency), - )) . ' '; + ]) . ' '; if ($this->_subscriptionDetails->amount < $params['amount']) { $msg = ts('Recurring Contribution Updated - increased installment amount'); } @@ -289,20 +289,20 @@ public function postProcess() { } if ($this->_subscriptionDetails->installments != $params['installments']) { - $message .= "
    " . ts("Recurring contribution installments have been updated from %1 to %2 for this subscription.", array( + $message .= "
    " . ts("Recurring contribution installments have been updated from %1 to %2 for this subscription.", [ 1 => $this->_subscriptionDetails->installments, 2 => $params['installments'], - )) . ' '; + ]) . ' '; } - $activityParams = array( + $activityParams = [ 'source_contact_id' => $contactID, 'activity_type_id' => CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Update Recurring Contribution'), 'subject' => $msg, 'details' => $message, 'activity_date_time' => date('YmdHis'), 'status_id' => CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_status_id', 'Completed'), - ); + ]; $session = CRM_Core_Session::singleton(); $cid = $session->get('userID'); @@ -317,11 +317,11 @@ public function postProcess() { // send notification if ($this->_subscriptionDetails->contribution_page_id) { CRM_Core_DAO::commonRetrieveAll('CRM_Contribute_DAO_ContributionPage', 'id', - $this->_subscriptionDetails->contribution_page_id, $value, array( + $this->_subscriptionDetails->contribution_page_id, $value, [ 'title', 'receipt_from_name', 'receipt_from_email', - ) + ] ); $receiptFrom = '"' . CRM_Utils_Array::value('receipt_from_name', $value[$this->_subscriptionDetails->contribution_page_id]) . '" <' . $value[$this->_subscriptionDetails->contribution_page_id]['receipt_from_email'] . '>'; } @@ -332,17 +332,17 @@ public function postProcess() { list($donorDisplayName, $donorEmail) = CRM_Contact_BAO_Contact::getContactDetails($contactID); - $tplParams = array( + $tplParams = [ 'recur_frequency_interval' => $this->_subscriptionDetails->frequency_interval, 'recur_frequency_unit' => $this->_subscriptionDetails->frequency_unit, 'amount' => CRM_Utils_Money::format($params['amount']), 'installments' => $params['installments'], - ); + ]; - $tplParams['contact'] = array('display_name' => $donorDisplayName); + $tplParams['contact'] = ['display_name' => $donorDisplayName]; $tplParams['receipt_from_email'] = $receiptFrom; - $sendTemplateParams = array( + $sendTemplateParams = [ 'groupName' => 'msg_tpl_workflow_contribution', 'valueName' => 'contribution_recurring_edit', 'contactId' => $contactID, @@ -352,7 +352,7 @@ public function postProcess() { 'from' => $receiptFrom, 'toName' => $donorDisplayName, 'toEmail' => $donorEmail, - ); + ]; list($sent) = CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams); } } diff --git a/CRM/Contribute/Import/Controller.php b/CRM/Contribute/Import/Controller.php index 3368e3685ea9..7860644926cb 100644 --- a/CRM/Contribute/Import/Controller.php +++ b/CRM/Contribute/Import/Controller.php @@ -54,7 +54,7 @@ public function __construct($title = NULL, $action = CRM_Core_Action::NONE, $mod // add all the actions $config = CRM_Core_Config::singleton(); - $this->addActions($config->uploadDir, array('uploadFile')); + $this->addActions($config->uploadDir, ['uploadFile']); } } diff --git a/CRM/Contribute/Import/Field.php b/CRM/Contribute/Import/Field.php index db74800df67b..fdd1ce6177ee 100644 --- a/CRM/Contribute/Import/Field.php +++ b/CRM/Contribute/Import/Field.php @@ -152,7 +152,7 @@ public function validate() { return CRM_Utils_Rule::money($this->_value); case 'trxn_id': - static $seenTrxnIds = array(); + static $seenTrxnIds = []; if (in_array($this->_value, $seenTrxnIds)) { return FALSE; } diff --git a/CRM/Contribute/Import/Form/DataSource.php b/CRM/Contribute/Import/Form/DataSource.php index b4058d0a2a11..ff0ee51e5479 100644 --- a/CRM/Contribute/Import/Form/DataSource.php +++ b/CRM/Contribute/Import/Form/DataSource.php @@ -46,7 +46,7 @@ class CRM_Contribute_Import_Form_DataSource extends CRM_Import_Form_DataSource { public function buildQuickForm() { parent::buildQuickForm(); - $duplicateOptions = array(); + $duplicateOptions = []; $duplicateOptions[] = $this->createElement('radio', NULL, NULL, ts('Insert new contributions'), CRM_Import_Parser::DUPLICATE_SKIP ); @@ -57,9 +57,9 @@ public function buildQuickForm() { ts('Import mode') ); - $this->setDefaults(array('onDuplicate' => CRM_Import_Parser::DUPLICATE_SKIP)); + $this->setDefaults(['onDuplicate' => CRM_Import_Parser::DUPLICATE_SKIP]); - $this->addElement('submit', 'loadMapping', ts('Load Mapping'), NULL, array('onclick' => 'checkSelect()')); + $this->addElement('submit', 'loadMapping', ts('Load Mapping'), NULL, ['onclick' => 'checkSelect()']); $this->addContactTypeSelector(); } @@ -68,12 +68,12 @@ public function buildQuickForm() { * Process the uploaded file. */ public function postProcess() { - $this->storeFormValues(array( + $this->storeFormValues([ 'onDuplicate', 'contactType', 'dateFormats', 'savedMapping', - )); + ]); $this->submitFileForMapping('CRM_Contribute_Import_Parser_Contribution'); } diff --git a/CRM/Contribute/Import/Form/Preview.php b/CRM/Contribute/Import/Form/Preview.php index 0d60984e7121..074c06b6d5f6 100644 --- a/CRM/Contribute/Import/Form/Preview.php +++ b/CRM/Contribute/Import/Form/Preview.php @@ -84,7 +84,7 @@ public function preProcess() { $this->set('downloadMismatchRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams)); } - $properties = array( + $properties = [ 'mapper', 'softCreditFields', 'mapperSoftCreditType', @@ -97,7 +97,7 @@ public function preProcess() { 'downloadErrorRecordsUrl', 'downloadConflictRecordsUrl', 'downloadMismatchRecordsUrl', - ); + ]; $this->setStatusUrl(); foreach ($properties as $property) { @@ -118,9 +118,9 @@ public function postProcess() { $mapperSoftCreditType = $this->get('mapperSoftCreditType'); $mapper = $this->controller->exportValue('MapField', 'mapper'); - $mapperKeys = array(); - $mapperSoftCredit = array(); - $mapperPhoneType = array(); + $mapperKeys = []; + $mapperSoftCredit = []; + $mapperPhoneType = []; foreach ($mapper as $key => $value) { $mapperKeys[$key] = $mapper[$key][0]; @@ -138,7 +138,7 @@ public function postProcess() { $mapFields = $this->get('fields'); foreach ($mapper as $key => $value) { - $header = array(); + $header = []; if (isset($mapFields[$mapper[$key][0]])) { $header[] = $mapFields[$mapper[$key][0]]; } @@ -161,7 +161,7 @@ public function postProcess() { $errorStack = CRM_Core_Error::singleton(); $errors = $errorStack->getErrors(); - $errorMessage = array(); + $errorMessage = []; if (is_array($errors)) { foreach ($errors as $key => $value) { diff --git a/CRM/Contribute/Import/Form/Summary.php b/CRM/Contribute/Import/Form/Summary.php index 706d375e4b57..ddd0222305d4 100644 --- a/CRM/Contribute/Import/Form/Summary.php +++ b/CRM/Contribute/Import/Form/Summary.php @@ -101,7 +101,7 @@ public function preProcess() { } $this->assign('dupeActionString', $dupeActionString); - $properties = array( + $properties = [ 'totalRowCount', 'validRowCount', 'invalidRowCount', @@ -119,7 +119,7 @@ public function preProcess() { 'invalidPledgePaymentRowCount', 'downloadPledgePaymentErrorRecordsUrl', 'downloadSoftCreditErrorRecordsUrl', - ); + ]; foreach ($properties as $property) { $this->assign($property, $this->get($property)); } diff --git a/CRM/Contribute/Import/Parser.php b/CRM/Contribute/Import/Parser.php index d8669559b2a3..57a0156537c1 100644 --- a/CRM/Contribute/Import/Parser.php +++ b/CRM/Contribute/Import/Parser.php @@ -162,11 +162,11 @@ public function run( $this->_invalidRowCount = $this->_validCount = $this->_invalidSoftCreditRowCount = $this->_invalidPledgePaymentRowCount = 0; $this->_totalCount = $this->_conflictCount = 0; - $this->_errors = array(); - $this->_warnings = array(); - $this->_conflicts = array(); - $this->_pledgePaymentErrors = array(); - $this->_softCreditErrors = array(); + $this->_errors = []; + $this->_warnings = []; + $this->_conflicts = []; + $this->_pledgePaymentErrors = []; + $this->_softCreditErrors = []; if ($statusID) { $this->progressImport($statusID); $startTimestamp = $currTimestamp = $prevTimestamp = time(); @@ -175,7 +175,7 @@ public function run( $this->_fileSize = number_format(filesize($fileName) / 1024.0, 2); if ($mode == self::MODE_MAPFIELD) { - $this->_rows = array(); + $this->_rows = []; } else { $this->_activeFieldCount = count($this->_activeFields); @@ -345,10 +345,10 @@ public function run( } if ($this->_invalidRowCount) { // removed view url for invlaid contacts - $headers = array_merge(array( + $headers = array_merge([ ts('Line Number'), ts('Reason'), - ), + ], $customHeaders ); $this->_errorFileName = self::errorFileName(self::ERROR); @@ -357,10 +357,10 @@ public function run( if ($this->_invalidPledgePaymentRowCount) { // removed view url for invlaid contacts - $headers = array_merge(array( + $headers = array_merge([ ts('Line Number'), ts('Reason'), - ), + ], $customHeaders ); $this->_pledgePaymentErrorsFileName = self::errorFileName(self::PLEDGE_PAYMENT_ERROR); @@ -369,10 +369,10 @@ public function run( if ($this->_invalidSoftCreditRowCount) { // removed view url for invlaid contacts - $headers = array_merge(array( + $headers = array_merge([ ts('Line Number'), ts('Reason'), - ), + ], $customHeaders ); $this->_softCreditErrorsFileName = self::errorFileName(self::SOFT_CREDIT_ERROR); @@ -380,20 +380,20 @@ public function run( } if ($this->_conflictCount) { - $headers = array_merge(array( + $headers = array_merge([ ts('Line Number'), ts('Reason'), - ), + ], $customHeaders ); $this->_conflictFileName = self::errorFileName(self::CONFLICT); self::exportCSV($this->_conflictFileName, $headers, $this->_conflicts); } if ($this->_duplicateCount) { - $headers = array_merge(array( + $headers = array_merge([ ts('Line Number'), ts('View Contribution URL'), - ), + ], $customHeaders ); @@ -447,12 +447,12 @@ public function setActiveFieldSoftCreditType($elements) { * (reference ) associative array of name/value pairs */ public function &getActiveFieldParams() { - $params = array(); + $params = []; for ($i = 0; $i < $this->_activeFieldCount; $i++) { if (isset($this->_activeFields[$i]->_value)) { if (isset($this->_activeFields[$i]->_softCreditField)) { if (!isset($params[$this->_activeFields[$i]->_name])) { - $params[$this->_activeFields[$i]->_name] = array(); + $params[$this->_activeFields[$i]->_name] = []; } $params[$this->_activeFields[$i]->_name][$i][$this->_activeFields[$i]->_softCreditField] = $this->_activeFields[$i]->_value; if (isset($this->_activeFields[$i]->_softCreditType)) { @@ -568,7 +568,7 @@ public function set($store, $mode = self::MODE_SUMMARY) { * @param array $data */ public static function exportCSV($fileName, $header, $data) { - $output = array(); + $output = []; $fd = fopen($fileName, 'w'); foreach ($header as $key => $value) { diff --git a/CRM/Contribute/Import/Parser/Contribution.php b/CRM/Contribute/Import/Parser/Contribution.php index 8d0ac2297168..3d6dbd769199 100644 --- a/CRM/Contribute/Import/Parser/Contribution.php +++ b/CRM/Contribute/Import/Parser/Contribution.php @@ -74,27 +74,27 @@ public function init() { $fields = CRM_Contribute_BAO_Contribution::importableFields($this->_contactType, FALSE); $fields = array_merge($fields, - array( - 'soft_credit' => array( + [ + 'soft_credit' => [ 'title' => ts('Soft Credit'), 'softCredit' => TRUE, 'headerPattern' => '/Soft Credit/i', - ), - ) + ], + ] ); // add pledge fields only if its is enabled if (CRM_Core_Permission::access('CiviPledge')) { - $pledgeFields = array( - 'pledge_payment' => array( + $pledgeFields = [ + 'pledge_payment' => [ 'title' => ts('Pledge Payment'), 'headerPattern' => '/Pledge Payment/i', - ), - 'pledge_id' => array( + ], + 'pledge_id' => [ 'title' => ts('Pledge ID'), 'headerPattern' => '/Pledge ID/i', - ), - ); + ], + ]; $fields = array_merge($fields, $pledgeFields); } @@ -105,7 +105,7 @@ public function init() { $this->addField($name, $field['title'], $field['type'], $field['headerPattern'], $field['dataPattern']); } - $this->_newContributions = array(); + $this->_newContributions = []; $this->setActiveFields($this->_mapperKeys); $this->setActiveFieldSoftCredit($this->_mapperSoftCredit); @@ -228,7 +228,7 @@ public function import($onDuplicate, &$values) { $indieFields = $tempIndieFields; } - $paramValues = array(); + $paramValues = []; foreach ($params as $key => $field) { if ($field == NULL || $field === '') { continue; @@ -282,11 +282,11 @@ public function import($onDuplicate, &$values) { //fix for CRM-2219 - Update Contribution // onDuplicate == CRM_Import_Parser::DUPLICATE_UPDATE if (!empty($paramValues['invoice_id']) || !empty($paramValues['trxn_id']) || !empty($paramValues['contribution_id'])) { - $dupeIds = array( + $dupeIds = [ 'id' => CRM_Utils_Array::value('contribution_id', $paramValues), 'trxn_id' => CRM_Utils_Array::value('trxn_id', $paramValues), 'invoice_id' => CRM_Utils_Array::value('invoice_id', $paramValues), - ); + ]; $ids['contribution'] = CRM_Contribute_BAO_Contribution::checkDuplicateIds($dupeIds); @@ -298,7 +298,7 @@ public function import($onDuplicate, &$values) { ); //process note if (!empty($paramValues['note'])) { - $noteID = array(); + $noteID = []; $contactID = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $ids['contribution'], 'contact_id'); $daoNote = new CRM_Core_BAO_Note(); $daoNote->entity_table = 'civicrm_contribution'; @@ -307,32 +307,32 @@ public function import($onDuplicate, &$values) { $noteID['id'] = $daoNote->id; } - $noteParams = array( + $noteParams = [ 'entity_table' => 'civicrm_contribution', 'note' => $paramValues['note'], 'entity_id' => $ids['contribution'], 'contact_id' => $contactID, - ); + ]; CRM_Core_BAO_Note::add($noteParams, $noteID); unset($formatted['note']); } //need to check existing soft credit contribution, CRM-3968 if (!empty($formatted['soft_credit'])) { - $dupeSoftCredit = array( + $dupeSoftCredit = [ 'contact_id' => $formatted['soft_credit'], 'contribution_id' => $ids['contribution'], - ); + ]; //Delete all existing soft Contribution from contribution_soft table for pcp_id is_null $existingSoftCredit = CRM_Contribute_BAO_ContributionSoft::getSoftContribution($dupeSoftCredit['contribution_id']); if (isset($existingSoftCredit['soft_credit']) && !empty($existingSoftCredit['soft_credit'])) { foreach ($existingSoftCredit['soft_credit'] as $key => $existingSoftCreditValues) { if (!empty($existingSoftCreditValues['soft_credit_id'])) { - civicrm_api3('ContributionSoft', 'delete', array( + civicrm_api3('ContributionSoft', 'delete', [ 'id' => $existingSoftCreditValues['soft_credit_id'], 'pcp_id' => NULL, - )); + ]); } } } @@ -352,11 +352,11 @@ public function import($onDuplicate, &$values) { return CRM_Import_Parser::VALID; } else { - $labels = array( + $labels = [ 'id' => 'Contribution ID', 'trxn_id' => 'Transaction ID', 'invoice_id' => 'Invoice ID', - ); + ]; foreach ($dupeIds as $k => $v) { if ($v) { $errorMsg[] = "$labels[$k] $v"; @@ -417,10 +417,10 @@ public function import($onDuplicate, &$values) { } else { // Using new Dedupe rule. - $ruleParams = array( + $ruleParams = [ 'contact_type' => $this->_contactType, 'used' => 'Unsupervised', - ); + ]; $fieldsArray = CRM_Dedupe_BAO_Rule::dedupeRuleFields($ruleParams); $disp = NULL; foreach ($fieldsArray as $value) { @@ -505,7 +505,7 @@ public function processPledgePayments(&$formatted) { ); CRM_Pledge_BAO_PledgePayment::updatePledgePaymentStatus($formatted['pledge_id'], - array($formatted['pledge_payment_id']), + [$formatted['pledge_payment_id']], $completeStatusID, NULL, $formatted['total_amount'] diff --git a/CRM/Contribute/Info.php b/CRM/Contribute/Info.php index b72317b5fe14..b6934b6167e1 100644 --- a/CRM/Contribute/Info.php +++ b/CRM/Contribute/Info.php @@ -54,13 +54,13 @@ class CRM_Contribute_Info extends CRM_Core_Component_Info { * @return array */ public function getInfo() { - return array( + return [ 'name' => 'CiviContribute', 'translatedName' => ts('CiviContribute'), 'title' => ts('CiviCRM Contribution Engine'), 'search' => 1, 'showActivitiesInCore' => 1, - ); + ]; } /** @@ -80,23 +80,23 @@ public function getInfo() { * collection of permissions, null if none */ public function getPermissions($getAllUnconditionally = FALSE, $descriptions = FALSE) { - $permissions = array( - 'access CiviContribute' => array( + $permissions = [ + 'access CiviContribute' => [ ts('access CiviContribute'), ts('Record backend contributions (with edit contributions) and view all contributions (for visible contacts)'), - ), - 'edit contributions' => array( + ], + 'edit contributions' => [ ts('edit contributions'), ts('Record and update contributions'), - ), - 'make online contributions' => array( + ], + 'make online contributions' => [ ts('make online contributions'), - ), - 'delete in CiviContribute' => array( + ], + 'delete in CiviContribute' => [ ts('delete in CiviContribute'), ts('Delete contributions'), - ), - ); + ], + ]; if (!$descriptions) { foreach ($permissions as $name => $attr) { @@ -118,9 +118,9 @@ public function getPermissions($getAllUnconditionally = FALSE, $descriptions = F * @return array */ public function getAnonymousPermissionWarnings() { - return array( + return [ 'access CiviContribute', - ); + ]; } /** @@ -136,12 +136,12 @@ public function getAnonymousPermissionWarnings() { * @return array|null */ public function getUserDashboardElement() { - return array( + return [ 'name' => ts('Contributions'), 'title' => ts('Your Contribution(s)'), - 'perm' => array('make online contributions'), + 'perm' => ['make online contributions'], 'weight' => 10, - ); + ]; } /** @@ -157,11 +157,11 @@ public function getUserDashboardElement() { * @return array|null */ public function registerTab() { - return array( + return [ 'title' => ts('Contributions'), 'url' => 'contribution', 'weight' => 20, - ); + ]; } /** @@ -185,10 +185,10 @@ public function getIcon() { * @return array|null */ public function registerAdvancedSearchPane() { - return array( + return [ 'title' => ts('Contributions'), 'weight' => 20, - ); + ]; } /** @@ -217,20 +217,20 @@ public function creatNewShortcut(&$shortCuts, $newCredit) { if (CRM_Core_Permission::check('access CiviContribute') && CRM_Core_Permission::check('edit contributions') ) { - $shortCut[] = array( + $shortCut[] = [ 'path' => 'civicrm/contribute/add', 'query' => "reset=1&action=add&context=standalone", 'ref' => 'new-contribution', 'title' => ts('Contribution'), - ); + ]; if ($newCredit) { $title = ts('Contribution') . '
      (' . ts('credit card') . ')'; - $shortCut[0]['shortCuts'][] = array( + $shortCut[0]['shortCuts'][] = [ 'path' => 'civicrm/contribute/add', 'query' => "reset=1&action=add&context=standalone&mode=live", 'ref' => 'new-contribution-cc', 'title' => $title, - ); + ]; } $shortCuts = array_merge($shortCuts, $shortCut); } diff --git a/CRM/Contribute/Page/AJAX.php b/CRM/Contribute/Page/AJAX.php index efe9bd4b4b12..1f3c70c5fbd2 100644 --- a/CRM/Contribute/Page/AJAX.php +++ b/CRM/Contribute/Page/AJAX.php @@ -40,14 +40,14 @@ class CRM_Contribute_Page_AJAX { * Get Soft credit to list in DT */ public static function getSoftContributionRows() { - $requiredParameters = array( + $requiredParameters = [ 'cid' => 'Integer', 'context' => 'String', - ); - $optionalParameters = array( + ]; + $optionalParameters = [ 'entityID' => 'Integer', 'isTest' => 'Integer', - ); + ]; $params = CRM_Core_Page_AJAX::defaultSortAndPagerParams(); $params += CRM_Core_Page_AJAX::validateParams($requiredParameters, $optionalParameters); diff --git a/CRM/Contribute/Page/ContributionRecur.php b/CRM/Contribute/Page/ContributionRecur.php index 4365e1faa163..6a5029d0763a 100644 --- a/CRM/Contribute/Page/ContributionRecur.php +++ b/CRM/Contribute/Page/ContributionRecur.php @@ -51,9 +51,9 @@ public function view() { } try { - $contributionRecur = civicrm_api3('ContributionRecur', 'getsingle', array( + $contributionRecur = civicrm_api3('ContributionRecur', 'getsingle', [ 'id' => $this->_id, - )); + ]); } catch (Exception $e) { CRM_Core_Error::statusBounce('Recurring contribution not found (ID: ' . $this->_id); @@ -62,7 +62,7 @@ public function view() { $contributionRecur['payment_processor'] = CRM_Financial_BAO_PaymentProcessor::getPaymentProcessorName( CRM_Utils_Array::value('payment_processor_id', $contributionRecur) ); - $idFields = array('contribution_status_id', 'campaign_id', 'financial_type_id'); + $idFields = ['contribution_status_id', 'campaign_id', 'financial_type_id']; foreach ($idFields as $idField) { if (!empty($contributionRecur[$idField])) { $contributionRecur[substr($idField, 0, -3)] = CRM_Core_PseudoConstant::getLabel('CRM_Contribute_BAO_ContributionRecur', $idField, $contributionRecur[$idField]); @@ -70,9 +70,9 @@ public function view() { } // Add linked membership - $membership = civicrm_api3('Membership', 'get', array( + $membership = civicrm_api3('Membership', 'get', [ 'contribution_recur_id' => $contributionRecur['id'], - )); + ]); if (!empty($membership['count'])) { $membershipDetails = reset($membership['values']); $contributionRecur['membership_id'] = $membershipDetails['id']; diff --git a/CRM/Contribute/Page/ContributionRecurPayments.php b/CRM/Contribute/Page/ContributionRecurPayments.php index 70f62f8ca9e3..91419ff36428 100644 --- a/CRM/Contribute/Page/ContributionRecurPayments.php +++ b/CRM/Contribute/Page/ContributionRecurPayments.php @@ -38,15 +38,15 @@ public function run() { * viewed. */ private function loadRelatedContributions() { - $relatedContributions = array(); + $relatedContributions = []; - $relatedContributionsResult = civicrm_api3('Contribution', 'get', array( + $relatedContributionsResult = civicrm_api3('Contribution', 'get', [ 'sequential' => 1, 'contribution_recur_id' => $this->id, 'contact_id' => $this->contactId, - 'options' => array('limit' => 0), + 'options' => ['limit' => 0], 'contribution_test' => '', - )); + ]); foreach ($relatedContributionsResult['values'] as $contribution) { $this->insertAmountExpandingPaymentsControl($contribution); @@ -78,14 +78,14 @@ private function insertAmountExpandingPaymentsControl(&$contribution) { $amount = CRM_Utils_Money::format($contribution['total_amount'], $contribution['currency']); $expandPaymentsUrl = CRM_Utils_System::url('civicrm/payment', - array( + [ 'view' => 'transaction', 'component' => 'contribution', 'action' => 'browse', 'cid' => $this->contactId, 'id' => $contribution['contribution_id'], 'selector' => 1, - ), + ], FALSE, NULL, TRUE ); @@ -140,11 +140,11 @@ private function insertContributionActions(&$contribution) { $contribution['action'] = CRM_Core_Action::formLink( $this->buildContributionLinks($contribution), $this->getContributionPermissionsMask(), - array( + [ 'id' => $contribution['contribution_id'], 'cid' => $contribution['contact_id'], 'cxt' => 'contribution', - ), + ], ts('more'), FALSE, 'contribution.selector.row', @@ -172,34 +172,34 @@ private function buildContributionLinks($contribution) { if ($contribution['is_pay_later'] && CRM_Utils_Array::value('contribution_status', $contribution) == 'Pending') { $isPayLater = TRUE; - $links[CRM_Core_Action::ADD] = array( + $links[CRM_Core_Action::ADD] = [ 'name' => ts('Pay with Credit Card'), 'url' => 'civicrm/contact/view/contribution', 'qs' => 'reset=1&action=update&id=%%id%%&cid=%%cid%%&context=%%cxt%%&mode=live', 'title' => ts('Pay with Credit Card'), - ); + ]; } - if (in_array($contribution['contribution_status'], array('Partially paid', 'Pending refund')) || $isPayLater) { + if (in_array($contribution['contribution_status'], ['Partially paid', 'Pending refund']) || $isPayLater) { $buttonName = ts('Record Payment'); if ($contribution['contribution_status'] == 'Pending refund') { $buttonName = ts('Record Refund'); } elseif (CRM_Core_Config::isEnabledBackOfficeCreditCardPayments()) { - $links[CRM_Core_Action::BASIC] = array( + $links[CRM_Core_Action::BASIC] = [ 'name' => ts('Submit Credit Card payment'), 'url' => 'civicrm/payment/add', 'qs' => 'reset=1&id=%%id%%&cid=%%cid%%&action=add&component=contribution&mode=live', 'title' => ts('Submit Credit Card payment'), - ); + ]; } - $links[CRM_Core_Action::ADD] = array( + $links[CRM_Core_Action::ADD] = [ 'name' => $buttonName, 'url' => 'civicrm/payment', 'qs' => 'reset=1&id=%%id%%&cid=%%cid%%&action=add&component=contribution', 'title' => $buttonName, - ); + ]; } return $links; @@ -211,7 +211,7 @@ private function buildContributionLinks($contribution) { * @return int */ private function getContributionPermissionsMask() { - $permissions = array(CRM_Core_Permission::VIEW); + $permissions = [CRM_Core_Permission::VIEW]; if (CRM_Core_Permission::check('edit contributions')) { $permissions[] = CRM_Core_Permission::EDIT; } diff --git a/CRM/Contribute/Page/DashBoard.php b/CRM/Contribute/Page/DashBoard.php index 79835022dce5..29893f8812ba 100644 --- a/CRM/Contribute/Page/DashBoard.php +++ b/CRM/Contribute/Page/DashBoard.php @@ -44,18 +44,18 @@ class CRM_Contribute_Page_DashBoard extends CRM_Core_Page { public function preProcess() { CRM_Utils_System::setTitle(ts('CiviContribute')); - $status = array('Valid', 'Cancelled'); - $prefixes = array('start', 'month', 'year'); + $status = ['Valid', 'Cancelled']; + $prefixes = ['start', 'month', 'year']; $startDate = NULL; - $startToDate = $monthToDate = $yearToDate = array(); + $startToDate = $monthToDate = $yearToDate = []; //get contribution dates. $dates = CRM_Contribute_BAO_Contribution::getContributionDates(); - foreach (array( + foreach ([ 'now', 'yearDate', 'monthDate', - ) as $date) { + ] as $date) { $$date = $dates[$date]; } // fiscal years end date diff --git a/CRM/Contribute/Page/ManagePremiums.php b/CRM/Contribute/Page/ManagePremiums.php index 65fb5952587c..c4f0939a61af 100644 --- a/CRM/Contribute/Page/ManagePremiums.php +++ b/CRM/Contribute/Page/ManagePremiums.php @@ -63,36 +63,36 @@ public function getBAOName() { */ public function &links() { if (!(self::$_links)) { - self::$_links = array( - CRM_Core_Action::UPDATE => array( + self::$_links = [ + CRM_Core_Action::UPDATE => [ 'name' => ts('Edit'), 'url' => 'civicrm/admin/contribute/managePremiums', 'qs' => 'action=update&id=%%id%%&reset=1', 'title' => ts('Edit Premium'), - ), - CRM_Core_Action::PREVIEW => array( + ], + CRM_Core_Action::PREVIEW => [ 'name' => ts('Preview'), 'url' => 'civicrm/admin/contribute/managePremiums', 'qs' => 'action=preview&id=%%id%%', 'title' => ts('Preview Premium'), - ), - CRM_Core_Action::DISABLE => array( + ], + CRM_Core_Action::DISABLE => [ 'name' => ts('Disable'), 'ref' => 'crm-enable-disable', 'title' => ts('Disable Premium'), - ), - CRM_Core_Action::ENABLE => array( + ], + CRM_Core_Action::ENABLE => [ 'name' => ts('Enable'), 'ref' => 'crm-enable-disable', 'title' => ts('Enable Premium'), - ), - CRM_Core_Action::DELETE => array( + ], + CRM_Core_Action::DELETE => [ 'name' => ts('Delete'), 'url' => 'civicrm/admin/contribute/managePremiums', 'qs' => 'action=delete&id=%%id%%', 'title' => ts('Delete Premium'), - ), - ); + ], + ]; } return self::$_links; } @@ -123,13 +123,13 @@ public function run() { */ public function browse() { // get all custom groups sorted by weight - $premiums = array(); + $premiums = []; $dao = new CRM_Contribute_DAO_Product(); $dao->orderBy('name'); $dao->find(); while ($dao->fetch()) { - $premiums[$dao->id] = array(); + $premiums[$dao->id] = []; CRM_Core_DAO::storeValues($dao, $premiums[$dao->id]); // form all action links $action = array_sum(array_keys($this->links())); @@ -143,7 +143,7 @@ public function browse() { $premiums[$dao->id]['action'] = CRM_Core_Action::formLink(self::links(), $action, - array('id' => $dao->id), + ['id' => $dao->id], ts('more'), FALSE, 'premium.manage.row', diff --git a/CRM/Contribute/Page/Premium.php b/CRM/Contribute/Page/Premium.php index a24eb3960cc4..eb0c035fa521 100644 --- a/CRM/Contribute/Page/Premium.php +++ b/CRM/Contribute/Page/Premium.php @@ -64,27 +64,27 @@ public function &links() { // helper variable for nicer formatting $deleteExtra = ts('Are you sure you want to remove this product form this page?'); - self::$_links = array( - CRM_Core_Action::UPDATE => array( + self::$_links = [ + CRM_Core_Action::UPDATE => [ 'name' => ts('Edit'), 'url' => 'civicrm/admin/contribute/addProductToPage', 'qs' => 'action=update&id=%%id%%&pid=%%pid%%&reset=1', 'title' => ts('Edit Premium'), - ), - CRM_Core_Action::PREVIEW => array( + ], + CRM_Core_Action::PREVIEW => [ 'name' => ts('Preview'), 'url' => 'civicrm/admin/contribute/addProductToPage', 'qs' => 'action=preview&id=%%id%%&pid=%%pid%%', 'title' => ts('Preview Premium'), - ), - CRM_Core_Action::DELETE => array( + ], + CRM_Core_Action::DELETE => [ 'name' => ts('Remove'), 'url' => 'civicrm/admin/contribute/addProductToPage', 'qs' => 'action=delete&id=%%id%%&pid=%%pid%%', 'extra' => 'onclick = "if (confirm(\'' . $deleteExtra . '\') ) this.href+=\'&confirmed=1\'; else return false;"', 'title' => ts('Disable Premium'), - ), - ); + ], + ]; } return self::$_links; } @@ -126,7 +126,7 @@ public function run() { */ public function browse() { // get all custom groups sorted by weight - $premiums = array(); + $premiums = []; $pageID = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE, 0 ); @@ -152,14 +152,14 @@ public function browse() { $productDAO->is_active = 1; if ($productDAO->find(TRUE)) { - $premiums[$productDAO->id] = array(); + $premiums[$productDAO->id] = []; $premiums[$productDAO->id]['weight'] = $premiumsProductDao->weight; CRM_Core_DAO::storeValues($productDAO, $premiums[$productDAO->id]); $action = array_sum(array_keys($this->links())); $premiums[$premiumsProductDao->product_id]['action'] = CRM_Core_Action::formLink(self::links(), $action, - array('id' => $pageID, 'pid' => $premiumsProductDao->id), + ['id' => $pageID, 'pid' => $premiumsProductDao->id], ts('more'), FALSE, 'premium.contributionpage.row', diff --git a/CRM/Contribute/Page/Tab.php b/CRM/Contribute/Page/Tab.php index e055d79e7913..f87dff5bbc78 100644 --- a/CRM/Contribute/Page/Tab.php +++ b/CRM/Contribute/Page/Tab.php @@ -57,25 +57,25 @@ class CRM_Contribute_Page_Tab extends CRM_Core_Page { */ public static function &recurLinks($recurID = FALSE, $context = 'contribution') { if (!(self::$_links)) { - self::$_links = array( - CRM_Core_Action::VIEW => array( + self::$_links = [ + CRM_Core_Action::VIEW => [ 'name' => ts('View'), 'title' => ts('View Recurring Payment'), 'url' => 'civicrm/contact/view/contributionrecur', 'qs' => "reset=1&id=%%crid%%&cid=%%cid%%&context={$context}", - ), - CRM_Core_Action::UPDATE => array( + ], + CRM_Core_Action::UPDATE => [ 'name' => ts('Edit'), 'title' => ts('Edit Recurring Payment'), 'url' => 'civicrm/contribute/updaterecur', 'qs' => "reset=1&action=update&crid=%%crid%%&cid=%%cid%%&context={$context}", - ), - CRM_Core_Action::DISABLE => array( + ], + CRM_Core_Action::DISABLE => [ 'name' => ts('Cancel'), 'title' => ts('Cancel'), 'ref' => 'crm-enable-disable', - ), - ); + ], + ]; } if ($recurID) { @@ -93,12 +93,12 @@ public static function &recurLinks($recurID = FALSE, $context = 'contribution') } if ($paymentProcessorObj->supports('UpdateSubscriptionBillingInfo')) { - $links[CRM_Core_Action::RENEW] = array( + $links[CRM_Core_Action::RENEW] = [ 'name' => ts('Change Billing Details'), 'title' => ts('Change Billing Details'), 'url' => 'civicrm/contribute/updatebilling', 'qs' => "reset=1&crid=%%crid%%&cid=%%cid%%&context={$context}", - ); + ]; } if (!$paymentProcessorObj->supports('ChangeSubscriptionAmount') && !$paymentProcessorObj->supports('EditRecurringContribution')) { @@ -116,7 +116,7 @@ public static function &recurLinks($recurID = FALSE, $context = 'contribution') */ public function browse() { // add annual contribution - $annual = array(); + $annual = []; list($annual['count'], $annual['amount'], $annual['avg'] @@ -151,7 +151,7 @@ public function browse() { $softCreditList = CRM_Contribute_BAO_ContributionSoft::getSoftContributionList($this->_contactId, NULL, $isTest); if (!empty($softCreditList)) { - $softCreditTotals = array(); + $softCreditTotals = []; list($softCreditTotals['count'], $softCreditTotals['cancel']['count'], @@ -199,15 +199,15 @@ private function addRecurringContributionsBlock() { */ private function getActiveRecurringContributions() { try { - $contributionRecurResult = civicrm_api3('ContributionRecur', 'get', array( + $contributionRecurResult = civicrm_api3('ContributionRecur', 'get', [ 'contact_id' => $this->_contactId, - 'contribution_status_id' => array('NOT IN' => CRM_Contribute_BAO_ContributionRecur::getInactiveStatuses()), + '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); } catch (Exception $e) { - $recurContributions = array(); + $recurContributions = []; } return $this->buildRecurringContributionsArray($recurContributions); @@ -221,11 +221,11 @@ private function getActiveRecurringContributions() { */ private function getInactiveRecurringContributions() { try { - $contributionRecurResult = civicrm_api3('ContributionRecur', 'get', array( + $contributionRecurResult = civicrm_api3('ContributionRecur', 'get', [ 'contact_id' => $this->_contactId, - 'contribution_status_id' => array('IN' => CRM_Contribute_BAO_ContributionRecur::getInactiveStatuses()), + '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); } catch (Exception $e) { @@ -266,11 +266,11 @@ private function buildRecurringContributionsArray($recurContributions) { } $recurContributions[$recurId]['action'] = CRM_Core_Action::formLink(self::recurLinks($recurId), $actionMask, - array( + [ 'cid' => $this->_contactId, 'crid' => $recurId, 'cxt' => 'contribution', - ), + ], ts('more'), FALSE, 'contribution.selector.recurring', @@ -337,10 +337,10 @@ public function preProcess() { else { $this->_contactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this, empty($this->_id)); if (empty($this->_contactId)) { - $this->_contactId = civicrm_api3('contribution', 'getvalue', array( + $this->_contactId = civicrm_api3('contribution', 'getvalue', [ 'id' => $this->_id, 'return' => 'contact_id', - )); + ]); } $this->assign('contactId', $this->_contactId); diff --git a/CRM/Contribute/Page/UserDashboard.php b/CRM/Contribute/Page/UserDashboard.php index 1efad9f3862c..e02872e98467 100644 --- a/CRM/Contribute/Page/UserDashboard.php +++ b/CRM/Contribute/Page/UserDashboard.php @@ -86,8 +86,8 @@ public function listContribution() { $recurStatus = CRM_Contribute_PseudoConstant::contributionStatus(); - $recurRow = array(); - $recurIDs = array(); + $recurRow = []; + $recurIDs = []; while ($recur->fetch()) { if (empty($recur->payment_processor_id)) { // it's not clear why we continue here as any without a processor id would likely @@ -112,11 +112,11 @@ public function listContribution() { } $recurRow[$values['id']]['action'] = CRM_Core_Action::formLink(CRM_Contribute_Page_Tab::recurLinks($recur->id, 'dashboard'), - $action, array( + $action, [ 'cid' => $this->_contactId, 'crid' => $values['id'], 'cxt' => 'contribution', - ), + ], ts('more'), FALSE, 'contribution.dashboard.recurring', diff --git a/CRM/Contribute/PseudoConstant.php b/CRM/Contribute/PseudoConstant.php index 4c29ef368e84..37433be2e309 100644 --- a/CRM/Contribute/PseudoConstant.php +++ b/CRM/Contribute/PseudoConstant.php @@ -260,7 +260,7 @@ public static function &creditCard() { * array of all Premiums if any */ public static function products($pageID = NULL) { - $products = array(); + $products = []; $dao = new CRM_Contribute_DAO_Product(); $dao->is_active = 1; $dao->orderBy('id'); @@ -276,7 +276,7 @@ public static function products($pageID = NULL) { $dao->find(TRUE); $premiumID = $dao->id; - $productID = array(); + $productID = []; $dao = new CRM_Contribute_DAO_PremiumsProduct(); $dao->premiums_id = $premiumID; @@ -285,7 +285,7 @@ public static function products($pageID = NULL) { $productID[$dao->product_id] = $dao->product_id; } - $tempProduct = array(); + $tempProduct = []; foreach ($products as $key => $value) { if (!array_key_exists($key, $productID)) { $tempProduct[$key] = $value; @@ -365,10 +365,10 @@ public static function &pcPage($pageType = NULL, $id = NULL) { */ public static function &pcpStatus($column = 'label') { if (NULL === self::$pcpStatus) { - self::$pcpStatus = array(); + self::$pcpStatus = []; } if (!array_key_exists($column, self::$pcpStatus)) { - self::$pcpStatus[$column] = array(); + self::$pcpStatus[$column] = []; self::$pcpStatus[$column] = CRM_Core_OptionGroup::values('pcp_status', FALSE, FALSE, FALSE, NULL, $column @@ -390,11 +390,11 @@ public static function &pcpStatus($column = 'label') { * @return int */ public static function getRelationalFinancialAccount($entityId, $accountRelationType, $entityTable = 'civicrm_financial_type', $returnField = 'financial_account_id') { - $params = array( - 'return' => array($returnField), + $params = [ + 'return' => [$returnField], 'entity_table' => $entityTable, 'entity_id' => $entityId, - ); + ]; if ($accountRelationType) { $params['account_relationship.name'] = $accountRelationType; } diff --git a/CRM/Contribute/Selector/Search.php b/CRM/Contribute/Selector/Search.php index e17f043cb7cc..c8fa53a775d8 100644 --- a/CRM/Contribute/Selector/Search.php +++ b/CRM/Contribute/Selector/Search.php @@ -53,7 +53,7 @@ class CRM_Contribute_Selector_Search extends CRM_Core_Selector_Base implements C * Properties of contact we're interested in displaying * @var array */ - static $_properties = array( + static $_properties = [ 'contact_id', 'contribution_id', 'contact_type', @@ -78,7 +78,7 @@ class CRM_Contribute_Selector_Search extends CRM_Core_Selector_Base implements C 'contribution_soft_credit_contact_id', 'contribution_soft_credit_amount', 'contribution_soft_credit_type', - ); + ]; /** * Are we restricting ourselves to a single contact @@ -227,26 +227,26 @@ public static function &links($componentId = NULL, $componentAction = NULL, $key } if (!(self::$_links)) { - self::$_links = array( - CRM_Core_Action::VIEW => array( + self::$_links = [ + CRM_Core_Action::VIEW => [ 'name' => ts('View'), 'url' => 'civicrm/contact/view/contribution', 'qs' => "reset=1&id=%%id%%&cid=%%cid%%&action=view&context=%%cxt%%&selectedChild=contribute{$extraParams}", 'title' => ts('View Contribution'), - ), - CRM_Core_Action::UPDATE => array( + ], + CRM_Core_Action::UPDATE => [ 'name' => ts('Edit'), 'url' => 'civicrm/contact/view/contribution', 'qs' => "reset=1&action=update&id=%%id%%&cid=%%cid%%&context=%%cxt%%{$extraParams}", 'title' => ts('Edit Contribution'), - ), - CRM_Core_Action::DELETE => array( + ], + CRM_Core_Action::DELETE => [ 'name' => ts('Delete'), 'url' => 'civicrm/contact/view/contribution', 'qs' => "reset=1&action=delete&id=%%id%%&cid=%%cid%%&context=%%cxt%%{$extraParams}", 'title' => ts('Delete Contribution'), - ), - ); + ], + ]; } return self::$_links; } @@ -317,10 +317,10 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { $this->_contributionClause ); // process the result of the query - $rows = array(); + $rows = []; //CRM-4418 check for view/edit/delete - $permissions = array(CRM_Core_Permission::VIEW); + $permissions = [CRM_Core_Permission::VIEW]; if (CRM_Core_Permission::check('edit contributions')) { $permissions[] = CRM_Core_Permission::EDIT; } @@ -370,7 +370,7 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { $componentContext ); $checkLineItem = FALSE; - $row = array(); + $row = []; // Now check for lineItems if (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus()) { $lineItems = CRM_Price_BAO_LineItem::getLineItemsByContributionID($result->id); @@ -418,12 +418,12 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { if ($result->is_pay_later && CRM_Utils_Array::value('contribution_status_name', $row) == 'Pending') { $isPayLater = TRUE; $row['contribution_status'] .= ' (' . ts('Pay Later') . ')'; - $links[CRM_Core_Action::ADD] = array( + $links[CRM_Core_Action::ADD] = [ 'name' => ts('Pay with Credit Card'), 'url' => 'civicrm/contact/view/contribution', 'qs' => 'reset=1&action=update&id=%%id%%&cid=%%cid%%&context=%%cxt%%&mode=live', 'title' => ts('Pay with Credit Card'), - ); + ]; } elseif (CRM_Utils_Array::value('contribution_status_name', $row) == 'Pending') { $row['contribution_status'] .= ' (' . ts('Incomplete Transaction') . ')'; @@ -435,31 +435,31 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { $row['checkbox'] = CRM_Core_Form::CB_PREFIX . $result->contribution_id; - $actions = array( + $actions = [ 'id' => $result->contribution_id, 'cid' => $result->contact_id, 'cxt' => $this->_context, - ); + ]; - if (in_array($row['contribution_status_name'], array('Partially paid', 'Pending refund')) || $isPayLater) { + if (in_array($row['contribution_status_name'], ['Partially paid', 'Pending refund']) || $isPayLater) { $buttonName = ts('Record Payment'); if ($row['contribution_status_name'] == 'Pending refund') { $buttonName = ts('Record Refund'); } elseif (CRM_Core_Config::isEnabledBackOfficeCreditCardPayments()) { - $links[CRM_Core_Action::BASIC] = array( + $links[CRM_Core_Action::BASIC] = [ 'name' => ts('Submit Credit Card payment'), 'url' => 'civicrm/payment/add', 'qs' => 'reset=1&id=%%id%%&cid=%%cid%%&action=add&component=contribution&mode=live', 'title' => ts('Submit Credit Card payment'), - ); + ]; } - $links[CRM_Core_Action::ADD] = array( + $links[CRM_Core_Action::ADD] = [ 'name' => $buttonName, 'url' => 'civicrm/payment', 'qs' => 'reset=1&id=%%id%%&cid=%%cid%%&action=add&component=contribution', 'title' => $buttonName, - ); + ]; } $row['action'] = CRM_Core_Action::formLink( @@ -505,66 +505,66 @@ public function getQILL() { * the column headers that need to be displayed */ public function &getColumnHeaders($action = NULL, $output = NULL) { - $pre = array(); - self::$_columnHeaders = array( - array( + $pre = []; + self::$_columnHeaders = [ + [ 'name' => $this->_includeSoftCredits ? ts('Contribution Amount') : ts('Amount'), 'sort' => 'total_amount', 'direction' => CRM_Utils_Sort::DONTCARE, 'field_name' => 'total_amount', - ), - ); + ], + ]; if ($this->_includeSoftCredits) { self::$_columnHeaders = array_merge( self::$_columnHeaders, - array( - array( + [ + [ 'name' => ts('Soft Credit Amount'), 'sort' => 'contribution_soft_credit_amount', 'field_name' => 'contribution_soft_credit_amount', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - ) + ], + ] ); } self::$_columnHeaders = array_merge( self::$_columnHeaders, - array( - array( + [ + [ 'name' => ts('Type'), 'sort' => 'financial_type', 'field_name' => 'financial_type', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - array( + ], + [ 'name' => ts('Source'), 'sort' => 'contribution_source', 'field_name' => 'contribution_source', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - array( + ], + [ 'name' => ts('Received'), 'sort' => 'receive_date', 'field_name' => 'receive_date', 'type' => 'date', 'direction' => CRM_Utils_Sort::DESCENDING, - ), - array( + ], + [ 'name' => ts('Thank-you Sent'), 'sort' => 'thankyou_date', 'field_name' => 'thankyou_date', 'type' => 'date', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - array( + ], + [ 'name' => ts('Status'), 'sort' => 'contribution_status', 'field_name' => 'contribution_status', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - ) + ], + ] ); if (CRM_Contribute_BAO_Query::isSiteHasProducts()) { self::$_columnHeaders[] = [ @@ -575,37 +575,37 @@ public function &getColumnHeaders($action = NULL, $output = NULL) { ]; } if (!$this->_single) { - $pre = array( - array( + $pre = [ + [ 'name' => ts('Name'), 'sort' => 'sort_name', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - ); + ], + ]; } self::$_columnHeaders = array_merge($pre, self::$_columnHeaders); if ($this->_includeSoftCredits) { self::$_columnHeaders = array_merge( self::$_columnHeaders, - array( - array( + [ + [ 'name' => ts('Soft Credit For'), 'sort' => 'contribution_soft_credit_name', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - array( + ], + [ 'name' => ts('Soft Credit Type'), 'sort' => 'contribution_soft_credit_type', 'direction' => CRM_Utils_Sort::ASCENDING, - ), - ) + ], + ] ); } self::$_columnHeaders = array_merge( - self::$_columnHeaders, array( - array('desc' => ts('Actions'), 'type' => 'actions'), - ) + self::$_columnHeaders, [ + ['desc' => ts('Actions'), 'type' => 'actions'], + ] ); foreach (array_keys(self::$_columnHeaders) as $index) { // Add weight & space it out a bit to allow headers to be inserted. diff --git a/CRM/Contribute/StateMachine/Contribution.php b/CRM/Contribute/StateMachine/Contribution.php index 8d3a8eae645f..f7c598805c53 100644 --- a/CRM/Contribute/StateMachine/Contribution.php +++ b/CRM/Contribute/StateMachine/Contribution.php @@ -48,11 +48,11 @@ class CRM_Contribute_StateMachine_Contribution extends CRM_Core_StateMachine { public function __construct($controller, $action = CRM_Core_Action::NONE) { parent::__construct($controller, $action); - $this->_pages = array( + $this->_pages = [ 'CRM_Contribute_Form_Contribution_Main' => NULL, 'CRM_Contribute_Form_Contribution_Confirm' => NULL, 'CRM_Contribute_Form_Contribution_ThankYou' => NULL, - ); + ]; $this->addSequentialPages($this->_pages, $action); } diff --git a/CRM/Contribute/StateMachine/ContributionPage.php b/CRM/Contribute/StateMachine/ContributionPage.php index ce08f0f6e3ee..47ccc247b88b 100644 --- a/CRM/Contribute/StateMachine/ContributionPage.php +++ b/CRM/Contribute/StateMachine/ContributionPage.php @@ -52,7 +52,7 @@ public function __construct($controller, $action = CRM_Core_Action::NONE) { $config = CRM_Core_Config::singleton(); - $this->_pages = array( + $this->_pages = [ 'CRM_Contribute_Form_ContributionPage_Settings' => NULL, 'CRM_Contribute_Form_ContributionPage_Amount' => NULL, 'CRM_Member_Form_MembershipBlock' => NULL, @@ -62,7 +62,7 @@ public function __construct($controller, $action = CRM_Core_Action::NONE) { 'CRM_Contribute_Form_ContributionPage_Custom' => NULL, 'CRM_Contribute_Form_ContributionPage_Premium' => NULL, 'CRM_Contribute_Form_ContributionPage_Widget' => NULL, - ); + ]; if (!in_array("CiviMember", $config->enableComponents)) { unset($this->_pages['CRM_Member_Form_MembershipBlock']); diff --git a/CRM/Contribute/StateMachine/Search.php b/CRM/Contribute/StateMachine/Search.php index 43c344cb5e5f..43ac47fa1989 100644 --- a/CRM/Contribute/StateMachine/Search.php +++ b/CRM/Contribute/StateMachine/Search.php @@ -48,7 +48,7 @@ class CRM_Contribute_StateMachine_Search extends CRM_Core_StateMachine { public function __construct($controller, $action = CRM_Core_Action::NONE) { parent::__construct($controller, $action); - $this->_pages = array(); + $this->_pages = []; $this->_pages['CRM_Contribute_Form_Search'] = NULL; list($task, $result) = $this->taskName($controller, 'Search'); diff --git a/CRM/Contribute/Task.php b/CRM/Contribute/Task.php index 8b562c7c8d29..2c6065350ac1 100644 --- a/CRM/Contribute/Task.php +++ b/CRM/Contribute/Task.php @@ -56,62 +56,62 @@ class CRM_Contribute_Task extends CRM_Core_Task { */ public static function tasks() { if (!(self::$_tasks)) { - self::$_tasks = array( - self::TASK_DELETE => array( + self::$_tasks = [ + self::TASK_DELETE => [ 'title' => ts('Delete contributions'), 'class' => 'CRM_Contribute_Form_Task_Delete', 'result' => FALSE, - ), - self::TASK_PRINT => array( + ], + self::TASK_PRINT => [ 'title' => ts('Print selected rows'), 'class' => 'CRM_Contribute_Form_Task_Print', 'result' => FALSE, - ), - self::TASK_EXPORT => array( + ], + self::TASK_EXPORT => [ 'title' => ts('Export contributions'), - 'class' => array( + 'class' => [ 'CRM_Export_Form_Select', 'CRM_Export_Form_Map', - ), + ], 'result' => FALSE, - ), - self::BATCH_UPDATE => array( + ], + self::BATCH_UPDATE => [ 'title' => ts('Update multiple contributions'), - 'class' => array( + 'class' => [ 'CRM_Contribute_Form_Task_PickProfile', 'CRM_Contribute_Form_Task_Batch', - ), + ], 'result' => TRUE, - ), - self::TASK_EMAIL => array( - 'title' => ts('Email - send now (to %1 or less)', array( + ], + self::TASK_EMAIL => [ + 'title' => ts('Email - send now (to %1 or less)', [ 1 => Civi::settings() ->get('simple_mail_limit'), - )), + ]), 'class' => 'CRM_Contribute_Form_Task_Email', 'result' => TRUE, - ), - self::UPDATE_STATUS => array( + ], + self::UPDATE_STATUS => [ 'title' => ts('Update pending contribution status'), 'class' => 'CRM_Contribute_Form_Task_Status', 'result' => TRUE, - ), - self::PDF_RECEIPT => array( + ], + self::PDF_RECEIPT => [ 'title' => ts('Receipts - print or email'), 'class' => 'CRM_Contribute_Form_Task_PDF', 'result' => FALSE, - ), - self::PDF_THANKYOU => array( + ], + self::PDF_THANKYOU => [ 'title' => ts('Thank-you letters - print or email'), 'class' => 'CRM_Contribute_Form_Task_PDFLetter', 'result' => FALSE, - ), - self::PDF_INVOICE => array( + ], + self::PDF_INVOICE => [ 'title' => ts('Invoices - print or email'), 'class' => 'CRM_Contribute_Form_Task_Invoice', 'result' => FALSE, - ), - ); + ], + ]; //CRM-4418, check for delete if (!CRM_Core_Permission::check('delete in CiviContribute')) { @@ -147,7 +147,7 @@ public static function tasks() { * @return array * set of tasks that are valid for the user */ - public static function permissionedTaskTitles($permission, $params = array()) { + public static function permissionedTaskTitles($permission, $params = []) { if (!isset($params['softCreditFiltering'])) { $params['softCreditFiltering'] = FALSE; } @@ -157,11 +157,11 @@ public static function permissionedTaskTitles($permission, $params = array()) { $tasks = self::taskTitles(); } else { - $tasks = array( + $tasks = [ self::TASK_EXPORT => self::$_tasks[self::TASK_EXPORT]['title'], self::TASK_EMAIL => self::$_tasks[self::TASK_EMAIL]['title'], self::PDF_RECEIPT => self::$_tasks[self::PDF_RECEIPT]['title'], - ); + ]; //CRM-4418, if (CRM_Core_Permission::check('delete in CiviContribute')) { diff --git a/CRM/Contribute/Tokens.php b/CRM/Contribute/Tokens.php index d6aba8ff9e63..5906f5e969eb 100644 --- a/CRM/Contribute/Tokens.php +++ b/CRM/Contribute/Tokens.php @@ -41,7 +41,7 @@ class CRM_Contribute_Tokens extends \Civi\Token\AbstractTokenSubscriber { * @return array */ protected function getPassthruTokens() { - return array( + return [ 'contribution_page_id', 'receive_date', 'total_amount', @@ -54,7 +54,7 @@ protected function getPassthruTokens() { 'receipt_date', 'thankyou_date', 'tax_amount', - ); + ]; } /** @@ -63,13 +63,13 @@ protected function getPassthruTokens() { * @return array */ protected function getAliasTokens() { - return array( + return [ 'id' => 'contribution_id', 'payment_instrument' => 'payment_instrument_id', 'source' => 'contribution_source', 'status' => 'contribution_status_id', 'type' => 'financial_type_id', - ); + ]; } /** @@ -129,7 +129,7 @@ public function evaluateToken(\Civi\Token\TokenRow $row, $entity, $field, $prefe $fieldValue = isset($actionSearchResult->{"contrib_$field"}) ? $actionSearchResult->{"contrib_$field"} : NULL; $aliasTokens = $this->getAliasTokens(); - if (in_array($field, array('total_amount', 'fee_amount', 'net_amount'))) { + if (in_array($field, ['total_amount', 'fee_amount', 'net_amount'])) { return $row->format('text/plain')->tokens($entity, $field, \CRM_Utils_Money::format($fieldValue, $actionSearchResult->contrib_currency)); } diff --git a/CRM/Core/Action.php b/CRM/Core/Action.php index bd6ac2c2f703..4e5e811ea52b 100644 --- a/CRM/Core/Action.php +++ b/CRM/Core/Action.php @@ -77,7 +77,7 @@ class CRM_Core_Action { * @var array $_names type of variable name to action constant * */ - static $_names = array( + static $_names = [ 'add' => self::ADD, 'update' => self::UPDATE, 'view' => self::VIEW, @@ -95,7 +95,7 @@ class CRM_Core_Action { 'revert' => self::REVERT, 'close' => self::CLOSE, 'reopen' => self::REOPEN, - ); + ]; /** * The flipped version of the names array, initialized when used @@ -216,7 +216,7 @@ public static function formLink( // make links indexed sequentially instead of by bitmask // otherwise it's next to impossible to reliably add new ones - $seqLinks = array(); + $seqLinks = []; foreach ($links as $bit => $link) { $link['bit'] = $bit; $seqLinks[] = $link; @@ -226,7 +226,7 @@ public static function formLink( CRM_Utils_Hook::links($op, $objectName, $objectId, $seqLinks, $mask, $values); } - $url = array(); + $url = []; foreach ($seqLinks as $i => $link) { if (!$mask || !array_key_exists('bit', $link) || ($mask & $link['bit'])) { diff --git a/CRM/Core/BAO/ActionSchedule.php b/CRM/Core/BAO/ActionSchedule.php index fe30d41619a2..af9acb87a39d 100644 --- a/CRM/Core/BAO/ActionSchedule.php +++ b/CRM/Core/BAO/ActionSchedule.php @@ -58,9 +58,9 @@ public static function getMappings($filters = NULL) { return $_action_mapping; } elseif (isset($filters['id'])) { - return array( + return [ $filters['id'] => $_action_mapping[$filters['id']], - ); + ]; } else { throw new CRM_Core_Exception("getMappings() called with unsupported filter: " . implode(', ', array_keys($filters))); @@ -84,11 +84,11 @@ public static function getMapping($id) { * @throws CRM_Core_Exception */ public static function getAllEntityValueLabels() { - $entityValueLabels = array(); + $entityValueLabels = []; foreach (CRM_Core_BAO_ActionSchedule::getMappings() as $mapping) { /** @var \Civi\ActionSchedule\Mapping $mapping */ $entityValueLabels[$mapping->getId()] = $mapping->getValueLabels(); - $valueLabel = array('- ' . strtolower($mapping->getValueHeader()) . ' -'); + $valueLabel = ['- ' . strtolower($mapping->getValueHeader()) . ' -']; $entityValueLabels[$mapping->getId()] = $valueLabel + $entityValueLabels[$mapping->getId()]; } return $entityValueLabels; @@ -102,10 +102,10 @@ public static function getAllEntityValueLabels() { */ public static function getAllEntityStatusLabels() { $entityValueLabels = self::getAllEntityValueLabels(); - $entityStatusLabels = array(); + $entityStatusLabels = []; foreach (CRM_Core_BAO_ActionSchedule::getMappings() as $mapping) { /** @var \Civi\ActionSchedule\Mapping $mapping */ - $statusLabel = array('- ' . strtolower($mapping->getStatusHeader()) . ' -'); + $statusLabel = ['- ' . strtolower($mapping->getStatusHeader()) . ' -']; $entityStatusLabels[$mapping->getId()] = $entityValueLabels[$mapping->getId()]; foreach ($entityStatusLabels[$mapping->getId()] as $kkey => & $vval) { $vval = $statusLabel + $mapping->getStatusLabels($kkey); @@ -146,21 +146,21 @@ public static function &getList($namesOnly = FALSE, $filterMapping = NULL, $filt FROM civicrm_action_schedule cas "; - $queryParams = array(); + $queryParams = []; $where = " WHERE 1 "; if ($filterMapping and $filterValue) { $where .= " AND cas.entity_value = %1 AND cas.mapping_id = %2"; - $queryParams[1] = array($filterValue, 'Integer'); - $queryParams[2] = array($filterMapping->getId(), 'String'); + $queryParams[1] = [$filterValue, 'Integer']; + $queryParams[2] = [$filterMapping->getId(), 'String']; } $where .= " AND cas.used_for IS NULL"; $query .= $where; $dao = CRM_Core_DAO::executeQuery($query, $queryParams); while ($dao->fetch()) { /** @var Civi\ActionSchedule\Mapping $filterMapping */ - $filterMapping = CRM_Utils_Array::first(self::getMappings(array( + $filterMapping = CRM_Utils_Array::first(self::getMappings([ 'id' => $dao->mapping_id, - ))); + ])); $list[$dao->id]['id'] = $dao->id; $list[$dao->id]['title'] = $dao->title; $list[$dao->id]['start_action_offset'] = $dao->start_action_offset; @@ -194,7 +194,7 @@ public static function &getList($namesOnly = FALSE, $filterMapping = NULL, $filt * * @return CRM_Core_DAO_ActionSchedule */ - public static function add(&$params, $ids = array()) { + public static function add(&$params, $ids = []) { $actionSchedule = new CRM_Core_DAO_ActionSchedule(); $actionSchedule->copyValues($params); @@ -273,9 +273,9 @@ public static function setIsActive($id, $is_active) { * @throws CRM_Core_Exception */ public static function sendMailings($mappingID, $now) { - $mapping = CRM_Utils_Array::first(self::getMappings(array( + $mapping = CRM_Utils_Array::first(self::getMappings([ 'id' => $mappingID, - ))); + ])); $actionSchedule = new CRM_Core_DAO_ActionSchedule(); $actionSchedule->mapping_id = $mappingID; @@ -285,7 +285,7 @@ public static function sendMailings($mappingID, $now) { while ($actionSchedule->fetch()) { $query = CRM_Core_BAO_ActionSchedule::prepareMailingQuery($mapping, $actionSchedule); $dao = CRM_Core_DAO::executeQuery($query, - array(1 => array($actionSchedule->id, 'Integer')) + [1 => [$actionSchedule->id, 'Integer']] ); $multilingual = CRM_Core_I18n::isMultilingual(); @@ -296,7 +296,7 @@ public static function sendMailings($mappingID, $now) { CRM_Core_BAO_ActionSchedule::setCommunicationLanguage($actionSchedule->communication_language, $preferred_language); } - $errors = array(); + $errors = []; try { $tokenProcessor = self::createTokenProcessor($actionSchedule, $mapping); $tokenProcessor->addRow() @@ -322,12 +322,12 @@ public static function sendMailings($mappingID, $now) { } // update action log record - $logParams = array( + $logParams = [ 'id' => $dao->reminderID, 'is_error' => !empty($errors), 'message' => empty($errors) ? "null" : implode(' ', $errors), 'action_date_time' => $now, - ); + ]; CRM_Core_BAO_ActionLog::create($logParams); } @@ -342,7 +342,7 @@ public static function sendMailings($mappingID, $now) { * * @throws API_Exception */ - public static function buildRecipientContacts($mappingID, $now, $params = array()) { + public static function buildRecipientContacts($mappingID, $now, $params = []) { $actionSchedule = new CRM_Core_DAO_ActionSchedule(); $actionSchedule->mapping_id = $mappingID; $actionSchedule->is_active = 1; @@ -353,9 +353,9 @@ public static function buildRecipientContacts($mappingID, $now, $params = array( while ($actionSchedule->fetch()) { /** @var \Civi\ActionSchedule\Mapping $mapping */ - $mapping = CRM_Utils_Array::first(self::getMappings(array( + $mapping = CRM_Utils_Array::first(self::getMappings([ 'id' => $mappingID, - ))); + ])); $builder = new \Civi\ActionSchedule\RecipientBuilder($now, $actionSchedule, $mapping); $builder->build(); } @@ -367,7 +367,7 @@ public static function buildRecipientContacts($mappingID, $now, $params = array( * * @return array */ - public static function processQueue($now = NULL, $params = array()) { + public static function processQueue($now = NULL, $params = []) { $now = $now ? CRM_Utils_Time::setTime($now) : CRM_Utils_Time::getTime(); $mappings = CRM_Core_BAO_ActionSchedule::getMappings(); @@ -376,10 +376,10 @@ public static function processQueue($now = NULL, $params = array()) { CRM_Core_BAO_ActionSchedule::sendMailings($mappingID, $now); } - $result = array( + $result = [ 'is_error' => 0, 'messages' => ts('Sent all scheduled reminders successfully'), - ); + ]; return $result; } @@ -394,10 +394,10 @@ public static function isConfigured($id, $mappingID) { WHERE mapping_id = %1 AND entity_value = %2"; - $params = array( - 1 => array($mappingID, 'String'), - 2 => array($id, 'Integer'), - ); + $params = [ + 1 => [$mappingID, 'String'], + 2 => [$id, 'Integer'], + ]; return CRM_Core_DAO::singleValueQuery($queryString, $params); } @@ -409,13 +409,13 @@ public static function isConfigured($id, $mappingID) { */ public static function getRecipientListing($mappingID, $recipientType) { if (!$mappingID) { - return array(); + return []; } /** @var \Civi\ActionSchedule\Mapping $mapping */ - $mapping = CRM_Utils_Array::first(CRM_Core_BAO_ActionSchedule::getMappings(array( + $mapping = CRM_Utils_Array::first(CRM_Core_BAO_ActionSchedule::getMappings([ 'id' => $mappingID, - ))); + ])); return $mapping->getRecipientListing($recipientType); } @@ -475,7 +475,7 @@ protected static function createMailingActivity($tokenRow, $mapping, $contactID, = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Reminder Sent'); } - $activityParams = array( + $activityParams = [ 'subject' => $tokenRow->render('subject'), 'details' => $tokenRow->render('body_html'), 'source_contact_id' => $session->get('userID') ? $session->get('userID') : $contactID, @@ -486,13 +486,13 @@ protected static function createMailingActivity($tokenRow, $mapping, $contactID, 'status_id' => CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'status_id', 'Completed'), 'activity_type_id' => $activityTypeID, 'source_record_id' => $entityID, - ); + ]; // @todo use api, remove all the above wrangling $activity = CRM_Activity_BAO_Activity::create($activityParams); //file reminder on case if source activity is a case activity if (!empty($caseID)) { - $caseActivityParams = array(); + $caseActivityParams = []; $caseActivityParams['case_id'] = $caseID; $caseActivityParams['activity_id'] = $activity->id; CRM_Case_BAO_Case::processCaseActivity($caseActivityParams); @@ -511,13 +511,13 @@ protected static function prepareMailingQuery($mapping, $actionSchedule) { ->select("e.id as entityID, e.*") ->where("reminder.action_schedule_id = #casActionScheduleId") ->where("reminder.action_date_time IS NULL") - ->param(array( + ->param([ 'casActionScheduleId' => $actionSchedule->id, 'casMailingJoinType' => ($actionSchedule->limit_to == 0) ? 'LEFT JOIN' : 'INNER JOIN', 'casMappingId' => $mapping->getId(), 'casMappingEntity' => $mapping->getEntity(), 'casEntityJoinExpr' => 'e.id = reminder.entity_id', - )); + ]); if ($actionSchedule->limit_to == 0) { $select->where("e.id = reminder.entity_id OR reminder.entity_table = 'civicrm_contact'"); @@ -543,7 +543,7 @@ protected static function prepareMailingQuery($mapping, $actionSchedule) { protected static function sendReminderSms($tokenRow, $schedule, $toContactID) { $toPhoneNumber = self::pickSmsPhoneNumber($toContactID); if (!$toPhoneNumber) { - return array("sms_phone_missing" => "Couldn't find recipient's phone number."); + return ["sms_phone_missing" => "Couldn't find recipient's phone number."]; } $messageSubject = $tokenRow->render('subject'); @@ -551,20 +551,20 @@ protected static function sendReminderSms($tokenRow, $schedule, $toContactID) { $session = CRM_Core_Session::singleton(); $userID = $session->get('userID') ? $session->get('userID') : $tokenRow->context['contactId']; - $smsParams = array( + $smsParams = [ 'To' => $toPhoneNumber, 'provider_id' => $schedule->sms_provider_id, 'activity_subject' => $messageSubject, - ); + ]; $activityTypeID = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'SMS'); - $activityParams = array( + $activityParams = [ 'source_contact_id' => $userID, 'activity_type_id' => $activityTypeID, 'activity_date_time' => date('YmdHis'), 'subject' => $messageSubject, 'details' => $sms_body_text, 'status_id' => CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'status_id', 'Completed'), - ); + ]; $activity = CRM_Activity_BAO_Activity::create($activityParams); @@ -575,7 +575,7 @@ protected static function sendReminderSms($tokenRow, $schedule, $toContactID) { $userID ); - return array(); + return []; } /** @@ -603,7 +603,7 @@ protected static function pickFromEmail($actionSchedule) { protected static function sendReminderEmail($tokenRow, $schedule, $toContactID) { $toEmail = CRM_Contact_BAO_Contact::getPrimaryEmail($toContactID); if (!$toEmail) { - return array("email_missing" => "Couldn't find recipient's email address."); + return ["email_missing" => "Couldn't find recipient's email address."]; } $body_text = $tokenRow->render('body_text'); @@ -613,7 +613,7 @@ protected static function sendReminderEmail($tokenRow, $schedule, $toContactID) } // set up the parameters for CRM_Utils_Mail::send - $mailParams = array( + $mailParams = [ 'groupName' => 'Scheduled Reminder Sender', 'from' => self::pickFromEmail($schedule), 'toName' => $tokenRow->context['contact']['display_name'], @@ -621,7 +621,7 @@ protected static function sendReminderEmail($tokenRow, $schedule, $toContactID) 'subject' => $tokenRow->render('subject'), 'entity' => 'action_schedule', 'entity_id' => $schedule->id, - ); + ]; if (!$body_html || $tokenRow->context['contact']['preferred_mail_format'] == 'Text' || $tokenRow->context['contact']['preferred_mail_format'] == 'Both' @@ -637,10 +637,10 @@ protected static function sendReminderEmail($tokenRow, $schedule, $toContactID) } $result = CRM_Utils_Mail::send($mailParams); if (!$result || is_a($result, 'PEAR_Error')) { - return array('email_fail' => 'Failed to send message'); + return ['email_fail' => 'Failed to send message']; } - return array(); + return []; } /** @@ -649,12 +649,12 @@ protected static function sendReminderEmail($tokenRow, $schedule, $toContactID) * @return \Civi\Token\TokenProcessor */ protected static function createTokenProcessor($schedule, $mapping) { - $tp = new \Civi\Token\TokenProcessor(\Civi\Core\Container::singleton()->get('dispatcher'), array( + $tp = new \Civi\Token\TokenProcessor(\Civi\Core\Container::singleton()->get('dispatcher'), [ 'controller' => __CLASS__, 'actionSchedule' => $schedule, 'actionMapping' => $mapping, 'smarty' => TRUE, - )); + ]); $tp->addMessage('body_text', $schedule->body_text, 'text/plain'); $tp->addMessage('body_html', $schedule->body_html, 'text/html'); $tp->addMessage('sms_body_text', $schedule->sms_body_text, 'text/plain'); @@ -670,11 +670,11 @@ protected static function createTokenProcessor($schedule, $mapping) { * @return NULL|string */ protected static function pickSmsPhoneNumber($smsToContactId) { - $toPhoneNumbers = CRM_Core_BAO_Phone::allPhones($smsToContactId, FALSE, 'Mobile', array( + $toPhoneNumbers = CRM_Core_BAO_Phone::allPhones($smsToContactId, FALSE, 'Mobile', [ 'is_deceased' => 0, 'is_deleted' => 0, 'do_not_sms' => 0, - )); + ]); //to get primary mobile ph,if not get a first mobile phONE if (!empty($toPhoneNumbers)) { $toPhoneNumberDetails = reset($toPhoneNumbers); @@ -691,10 +691,10 @@ protected static function pickSmsPhoneNumber($smsToContactId) { * array(mixed $value => string $label). */ public static function getAdditionalRecipients() { - return array( + return [ 'manual' => ts('Choose Recipient(s)'), 'group' => ts('Select Group'), - ); + ]; } } diff --git a/CRM/Core/BAO/Address.php b/CRM/Core/BAO/Address.php index c7a9d68b9e99..8b5748501768 100644 --- a/CRM/Core/BAO/Address.php +++ b/CRM/Core/BAO/Address.php @@ -55,7 +55,7 @@ public static function create(&$params, $fixAddress = TRUE, $entity = NULL) { return NULL; } CRM_Core_BAO_Block::sortPrimaryFirst($params['address']); - $addresses = array(); + $addresses = []; $contactId = NULL; $updateBlankLocInfo = CRM_Utils_Array::value('updateBlankLocInfo', $params, FALSE); @@ -66,15 +66,15 @@ public static function create(&$params, $fixAddress = TRUE, $entity = NULL) { } else { // get all address from location block - $entityElements = array( + $entityElements = [ 'entity_table' => $params['entity_table'], 'entity_id' => $params['entity_id'], - ); + ]; $addresses = self::allEntityAddress($entityElements); } $isPrimary = $isBilling = TRUE; - $blocks = array(); + $blocks = []; foreach ($params['address'] as $key => $value) { if (!is_array($value)) { continue; @@ -92,7 +92,7 @@ public static function create(&$params, $fixAddress = TRUE, $entity = NULL) { // $updateBlankLocInfo will help take appropriate decision. CRM-5969 if (isset($value['id']) && !$addressExists && $updateBlankLocInfo) { //delete the existing record - CRM_Core_BAO_Block::blockDelete('Address', array('id' => $value['id'])); + CRM_Core_BAO_Block::blockDelete('Address', ['id' => $value['id']]); continue; } elseif (!$addressExists) { @@ -198,7 +198,7 @@ public static function fixAddress(&$params) { if (!empty($params['billing_street_address'])) { //Check address is coming from online contribution / registration page //Fixed :CRM-5076 - $billing = array( + $billing = [ 'street_address' => 'billing_street_address', 'city' => 'billing_city', 'postal_code' => 'billing_postal_code', @@ -206,7 +206,7 @@ public static function fixAddress(&$params) { 'state_province_id' => 'billing_state_province_id', 'country' => 'billing_country', 'country_id' => 'billing_country_id', - ); + ]; foreach ($billing as $key => $val) { if ($value = CRM_Utils_Array::value($val, $params)) { @@ -360,12 +360,12 @@ public static function fixAddress(&$params) { ); if ($parseStreetAddress && !empty($params['street_address'])) { - foreach (array( + foreach ([ 'street_number', 'street_name', 'street_unit', 'street_number_suffix', - ) as $fld) { + ] as $fld) { unset($params[$fld]); } // main parse string. @@ -400,7 +400,7 @@ public static function dataExists(&$params) { $config = CRM_Core_Config::singleton(); foreach ($params as $name => $value) { - if (in_array($name, array( + if (in_array($name, [ 'is_primary', 'location_type_id', 'id', @@ -408,7 +408,7 @@ public static function dataExists(&$params) { 'is_billing', 'display', 'master_id', - ))) { + ])) { continue; } elseif (!CRM_Utils_System::isNull($value)) { @@ -462,14 +462,14 @@ public static function &getValues($entityBlock, $microformat = FALSE, $fieldName if (empty($entityBlock)) { return NULL; } - $addresses = array(); + $addresses = []; $address = new CRM_Core_BAO_Address(); if (empty($entityBlock['entity_table'])) { $address->$fieldName = CRM_Utils_Array::value($fieldName, $entityBlock); } else { - $addressIds = array(); + $addressIds = []; $addressIds = self::allEntityAddress($entityBlock); if (!empty($addressIds[1])) { @@ -494,19 +494,19 @@ public static function &getValues($entityBlock, $microformat = FALSE, $fieldName while ($address->fetch()) { // deprecate reference. if ($count > 1) { - foreach (array( + foreach ([ 'state', 'state_name', 'country', 'world_region', - ) as $fld) { + ] as $fld) { if (isset($address->$fld)) { unset($address->$fld); } } } $stree = $address->street_address; - $values = array(); + $values = []; CRM_Core_DAO::storeValues($address, $values); // add state and country information: CRM-369 @@ -557,7 +557,7 @@ public static function &getValues($entityBlock, $microformat = FALSE, $fieldName * Unexplained parameter that I've always wondered about. */ public function addDisplay($microformat = FALSE) { - $fields = array( + $fields = [ // added this for CRM 1200 'address_id' => $this->id, // CRM-4003 @@ -573,7 +573,7 @@ public function addDisplay($microformat = FALSE) { 'postal_code_suffix' => isset($this->postal_code_suffix) ? $this->postal_code_suffix : "", 'country' => isset($this->country) ? $this->country : "", 'world_region' => isset($this->world_region) ? $this->world_region : "", - ); + ]; if (isset($this->county_id) && $this->county_id) { $fields['county'] = CRM_Core_PseudoConstant::county($this->county_id); @@ -607,9 +607,9 @@ public static function allAddress($id, $updateBlankLocInfo = FALSE) { FROM civicrm_contact, civicrm_address WHERE civicrm_address.contact_id = civicrm_contact.id AND civicrm_contact.id = %1 ORDER BY civicrm_address.is_primary DESC, address_id ASC"; - $params = array(1 => array($id, 'Integer')); + $params = [1 => [$id, 'Integer']]; - $addresses = array(); + $addresses = []; $dao = CRM_Core_DAO::executeQuery($query, $params); $count = 1; while ($dao->fetch()) { @@ -634,7 +634,7 @@ public static function allAddress($id, $updateBlankLocInfo = FALSE) { * the array of adrress data */ public static function allEntityAddress(&$entityElements) { - $addresses = array(); + $addresses = []; if (empty($entityElements)) { return $addresses; } @@ -651,7 +651,7 @@ public static function allEntityAddress(&$entityElements) { AND ltype.id = civicrm_address.location_type_id ORDER BY civicrm_address.is_primary DESC, civicrm_address.location_type_id DESC, address_id ASC "; - $params = array(1 => array($entityId, 'Integer')); + $params = [1 => [$entityId, 'Integer']]; $dao = CRM_Core_DAO::executeQuery($sql, $params); $locationCount = 1; while ($dao->fetch()) { @@ -674,21 +674,21 @@ public static function addressSequence() { $countryState = $cityPostal = FALSE; foreach ($addressSequence as $key => $field) { if ( - in_array($field, array('country', 'state_province')) && + in_array($field, ['country', 'state_province']) && !$countryState ) { $countryState = TRUE; $addressSequence[$key] = 'country_state_province'; } elseif ( - in_array($field, array('city', 'postal_code')) && + in_array($field, ['city', 'postal_code']) && !$cityPostal ) { $cityPostal = TRUE; $addressSequence[$key] = 'city_postal_code'; } elseif ( - in_array($field, array('country', 'state_province', 'city', 'postal_code')) + in_array($field, ['country', 'state_province', 'city', 'postal_code']) ) { unset($addressSequence[$key]); } @@ -719,12 +719,12 @@ public static function parseStreetAddress($streetAddress, $locale = NULL) { $locale = 'en_US'; } - $emptyParseFields = $parseFields = array( + $emptyParseFields = $parseFields = [ 'street_name' => '', 'street_unit' => '', 'street_number' => '', 'street_number_suffix' => '', - ); + ]; if (empty($streetAddress)) { return $parseFields; @@ -732,11 +732,11 @@ public static function parseStreetAddress($streetAddress, $locale = NULL) { $streetAddress = trim($streetAddress); - $matches = array(); - if (in_array($locale, array( + $matches = []; + if (in_array($locale, [ 'en_CA', 'fr_CA', - )) && preg_match('/^([A-Za-z0-9]+)[ ]*\-[ ]*/', $streetAddress, $matches) + ]) && preg_match('/^([A-Za-z0-9]+)[ ]*\-[ ]*/', $streetAddress, $matches) ) { $parseFields['street_unit'] = $matches[1]; // unset from rest of street address @@ -744,7 +744,7 @@ public static function parseStreetAddress($streetAddress, $locale = NULL) { } // get street number and suffix. - $matches = array(); + $matches = []; //alter street number/suffix handling so that we accept -digit if (preg_match('/^[A-Za-z0-9]+([\S]+)/', $streetAddress, $matches)) { // check that $matches[0] is numeric, else assume no street number @@ -752,7 +752,7 @@ public static function parseStreetAddress($streetAddress, $locale = NULL) { $streetNumAndSuffix = $matches[0]; // get street number. - $matches = array(); + $matches = []; if (preg_match('/^(\d+)/', $streetNumAndSuffix, $matches)) { $parseFields['street_number'] = $matches[0]; $suffix = preg_replace('/^(\d+)/', '', $streetNumAndSuffix); @@ -777,7 +777,7 @@ public static function parseStreetAddress($streetAddress, $locale = NULL) { } // suffix might be like 1/2 - $matches = array(); + $matches = []; if (preg_match('/^\d\/\d/', $streetAddress, $matches)) { $parseFields['street_number_suffix'] .= $matches[0]; @@ -788,7 +788,7 @@ public static function parseStreetAddress($streetAddress, $locale = NULL) { // now get the street unit. // supportable street unit formats. - $streetUnitFormats = array( + $streetUnitFormats = [ 'APT', 'APARTMENT', 'BSMT', @@ -829,19 +829,19 @@ public static function parseStreetAddress($streetAddress, $locale = NULL) { 'SUITE', 'UNIT', '#', - ); + ]; // overwriting $streetUnitFormats for 'en_CA' and 'fr_CA' locale - if (in_array($locale, array( + if (in_array($locale, [ 'en_CA', 'fr_CA', - ))) { - $streetUnitFormats = array('APT', 'APP', 'SUITE', 'BUREAU', 'UNIT'); + ])) { + $streetUnitFormats = ['APT', 'APP', 'SUITE', 'BUREAU', 'UNIT']; } //@todo per CRM-14459 this regex picks up words with the string in them - e.g APT picks up //Captain - presuming fixing regex (& adding test) to ensure a-z does not preced string will fix $streetUnitPreg = '/(' . implode('|\s', $streetUnitFormats) . ')(.+)?/i'; - $matches = array(); + $matches = []; if (preg_match($streetUnitPreg, $streetAddress, $matches)) { $parseFields['street_unit'] = trim($matches[0]); $streetAddress = str_replace($matches[0], '', $streetAddress); @@ -890,7 +890,7 @@ public static function isSupportedParsingLocale($locale = NULL) { $locale = $config->lcMessages; } - $parsingSupportedLocales = array('en_US', 'en_CA', 'fr_CA'); + $parsingSupportedLocales = ['en_US', 'en_CA', 'fr_CA']; if (in_array($locale, $parsingSupportedLocales)) { return TRUE; @@ -939,7 +939,7 @@ public static function validateAddressOptions($fields) { */ public static function checkContactSharedAddress($addressId) { $query = 'SELECT count(id) FROM civicrm_address WHERE master_id = %1'; - return CRM_Core_DAO::singleValueQuery($query, array(1 => array($addressId, 'Integer'))); + return CRM_Core_DAO::singleValueQuery($query, [1 => [$addressId, 'Integer']]); } /** @@ -956,7 +956,7 @@ public static function checkContactSharedAddressFields(&$fields, $contactId) { return; } - $sharedLocations = array(); + $sharedLocations = []; $query = " SELECT is_primary, @@ -965,7 +965,7 @@ public static function checkContactSharedAddressFields(&$fields, $contactId) { WHERE contact_id = %1 AND master_id IS NOT NULL"; - $dao = CRM_Core_DAO::executeQuery($query, array(1 => array($contactId, 'Positive'))); + $dao = CRM_Core_DAO::executeQuery($query, [1 => [$contactId, 'Positive']]); while ($dao->fetch()) { $sharedLocations[$dao->location_type_id] = $dao->location_type_id; if ($dao->is_primary) { @@ -978,7 +978,7 @@ public static function checkContactSharedAddressFields(&$fields, $contactId) { return; } - $addressFields = array( + $addressFields = [ 'city', 'county', 'country', @@ -992,7 +992,7 @@ public static function checkContactSharedAddressFields(&$fields, $contactId) { 'supplemental_address_1', 'supplemental_address_2', 'supplemental_address_3', - ); + ]; foreach ($fields as $name => & $values) { if (!is_array($values) || empty($values)) { @@ -1045,13 +1045,13 @@ public static function fixSharedAddress(&$params) { */ public static function processSharedAddress($addressId, $params) { $query = 'SELECT id, contact_id FROM civicrm_address WHERE master_id = %1'; - $dao = CRM_Core_DAO::executeQuery($query, array(1 => array($addressId, 'Integer'))); + $dao = CRM_Core_DAO::executeQuery($query, [1 => [$addressId, 'Integer']]); // Default to TRUE if not set to maintain api backward compatibility. $createRelationship = isset($params['update_current_employer']) ? $params['update_current_employer'] : TRUE; // unset contact id - $skipFields = array('is_primary', 'location_type_id', 'is_billing', 'contact_id'); + $skipFields = ['is_primary', 'location_type_id', 'is_billing', 'contact_id']; if (isset($params['master_id']) && !CRM_Utils_System::isNull($params['master_id'])) { if ($createRelationship) { // call the function to create a relationship for the new shared address @@ -1085,7 +1085,7 @@ public static function processSharedAddress($addressId, $params) { * Array[contact_id][contactDetails]. */ public static function mergeSameAddress(&$rows) { - $uniqueAddress = array(); + $uniqueAddress = []; foreach (array_keys($rows) as $rowID) { // load complete address as array key $address = trim($rows[$rowID]['street_address']) @@ -1101,10 +1101,10 @@ public static function mergeSameAddress(&$rows) { } // CRM-15120 - $formatted = array( + $formatted = [ 'first_name' => $rows[$rowID]['first_name'], 'individual_prefix' => $rows[$rowID]['individual_prefix'], - ); + ]; $format = Civi::settings()->get('display_name_format'); $firstNameWithPrefix = CRM_Utils_Address::format($formatted, $format, FALSE, FALSE); $firstNameWithPrefix = trim($firstNameWithPrefix); @@ -1178,7 +1178,7 @@ public static function processSharedAddressRelationship($masterAddressId, $curre FROM civicrm_contact cc INNER JOIN civicrm_address ca ON cc.id = ca.contact_id WHERE ca.id = %1'; - $dao = CRM_Core_DAO::executeQuery($query, array(1 => array($masterAddressId, 'Integer'))); + $dao = CRM_Core_DAO::executeQuery($query, [1 => [$masterAddressId, 'Integer']]); $dao->fetch(); // master address contact needs to be Household or Organization, otherwise return @@ -1200,12 +1200,12 @@ public static function processSharedAddressRelationship($masterAddressId, $curre CRM_Core_Error::fatal(ts("You seem to have deleted the relationship type 'Household Member of'")); } - $relParam = array( + $relParam = [ 'is_active' => TRUE, 'relationship_type_id' => $relTypeId, 'contact_id_a' => $currentContactId, 'contact_id_b' => $sharedContactId, - ); + ]; // If already there is a relationship record of $relParam criteria, avoid creating relationship again or else // it will casue CRM-16588 as the Duplicate Relationship Exception will revert other contact field values on update @@ -1252,10 +1252,10 @@ public static function setSharedAddressDeleteStatus($addressId = NULL, $contactI WHERE ca1.contact_id = %1'; } - $dao = CRM_Core_DAO::executeQuery($query, array(1 => array($entityId, 'Integer'))); + $dao = CRM_Core_DAO::executeQuery($query, [1 => [$entityId, 'Integer']]); - $deleteStatus = array(); - $sharedContactList = array(); + $deleteStatus = []; + $sharedContactList = []; $statusMessage = NULL; $addressCount = 0; while ($dao->fetch()) { @@ -1278,10 +1278,10 @@ public static function setSharedAddressDeleteStatus($addressId = NULL, $contactI CRM_Core_Session::setStatus($statusMessage, '', 'info'); } else { - return array( + return [ 'contactList' => $sharedContactList, 'count' => $addressCount, - ); + ]; } } @@ -1311,8 +1311,8 @@ public static function del($id) { * * @return array|bool */ - public static function buildOptions($fieldName, $context = NULL, $props = array()) { - $params = array(); + public static function buildOptions($fieldName, $context = NULL, $props = []) { + $params = []; // Special logic for fields whose options depend on context or properties switch ($fieldName) { // Filter state_province list based on chosen country or site defaults diff --git a/CRM/Core/BAO/Block.php b/CRM/Core/BAO/Block.php index f462b7ffca97..780d00acdade 100644 --- a/CRM/Core/BAO/Block.php +++ b/CRM/Core/BAO/Block.php @@ -37,12 +37,12 @@ class CRM_Core_BAO_Block { /** * Fields that are required for a valid block. */ - static $requiredBlockFields = array( - 'email' => array('email'), - 'phone' => array('phone'), - 'im' => array('name'), - 'openid' => array('openid'), - ); + static $requiredBlockFields = [ + 'email' => ['email'], + 'phone' => ['phone'], + 'im' => ['name'], + 'openid' => ['openid'], + ]; /** * Given the list of params in the params array, fetch the object @@ -63,7 +63,7 @@ public static function &getValues($blockName, $params) { $BAOString = 'CRM_Core_BAO_' . $blockName; $block = new $BAOString(); - $blocks = array(); + $blocks = []; if (!isset($params['entity_table'])) { $block->contact_id = $params['contact_id']; if (!$block->contact_id) { @@ -108,7 +108,7 @@ public static function retrieveBlock(&$block, $blockName) { $block->find(); $count = 1; - $blocks = array(); + $blocks = []; while ($block->fetch()) { CRM_Core_DAO::storeValues($block, $blocks[$count]); //unset is_primary after first block. Due to some bug in earlier version @@ -178,7 +178,7 @@ public static function blockExists($blockName, &$params) { * */ public static function getBlockIds($blockName, $contactId = NULL, $entityElements = NULL, $updateBlankLocInfo = FALSE) { - $allBlocks = array(); + $allBlocks = []; $name = ucfirst($blockName); if ($blockName == 'im') { @@ -226,15 +226,15 @@ public static function create($blockName, &$params, $entity = NULL, $contactId = $name = ucfirst($blockName); $isPrimary = $isBilling = TRUE; - $entityElements = $blocks = array(); + $entityElements = $blocks = []; $resetPrimaryId = NULL; $primaryId = FALSE; if ($entity) { - $entityElements = array( + $entityElements = [ 'entity_table' => $params['entity_table'], 'entity_id' => $params['entity_id'], - ); + ]; } else { $contactId = $params['contact_id']; @@ -320,16 +320,16 @@ public static function create($blockName, &$params, $entity = NULL, $contactId = // $updateBlankLocInfo will help take appropriate decision. CRM-5969 if (!empty($value['id']) && !$dataExists && $updateBlankLocInfo) { //delete the existing record - self::blockDelete($blockName, array('id' => $value['id'])); + self::blockDelete($blockName, ['id' => $value['id']]); continue; } elseif (!$dataExists) { continue; } - $contactFields = array( + $contactFields = [ 'contact_id' => $contactId, 'location_type_id' => CRM_Utils_Array::value('location_type_id', $value), - ); + ]; $contactFields['is_primary'] = 0; if ($isPrimary && !empty($value['is_primary'])) { @@ -422,11 +422,11 @@ public static function handlePrimary(&$params, $class) { // if is_primary = 1 if (!empty($params['is_primary'])) { $sql = "UPDATE $table SET is_primary = 0 WHERE contact_id = %1"; - $sqlParams = array(1 => array($contactId, 'Integer')); + $sqlParams = [1 => [$contactId, 'Integer']]; // we don't want to create unnecessary entries in the log_ tables so exclude the one we are working on if (!empty($params['id'])) { $sql .= " AND id <> %2"; - $sqlParams[2] = array($params['id'], 'Integer'); + $sqlParams[2] = [$params['id'], 'Integer']; } CRM_Core_DAO::executeQuery($sql, $sqlParams); return; diff --git a/CRM/Core/BAO/CMSUser.php b/CRM/Core/BAO/CMSUser.php index 3144e9ad9847..368bcd97dee9 100644 --- a/CRM/Core/BAO/CMSUser.php +++ b/CRM/Core/BAO/CMSUser.php @@ -113,9 +113,9 @@ public static function buildForm(&$form, $gid, $emailPresent, $action = CRM_Core if ($isCMSUser && $emailPresent) { if ($showUserRegistration) { if ($isCMSUser != 2) { - $extra = array( + $extra = [ 'onclick' => "return showHideByValue('cms_create_account','','details','block','radio',false );", - ); + ]; $form->addElement('checkbox', 'cms_create_account', ts('Create an account?'), NULL, $extra); $required = FALSE; } @@ -132,7 +132,7 @@ public static function buildForm(&$form, $gid, $emailPresent, $action = CRM_Core $form->add('password', 'cms_confirm_pass', ts('Confirm Password')); } - $form->addFormRule(array('CRM_Core_BAO_CMSUser', 'formRule'), $form); + $form->addFormRule(['CRM_Core_BAO_CMSUser', 'formRule'], $form); } $showCMS = TRUE; } @@ -167,7 +167,7 @@ public static function formRule($fields, $files, $form) { $isJoomla = ucfirst($config->userFramework) == 'Joomla' ? TRUE : FALSE; $isWordPress = $config->userFramework == 'WordPress' ? TRUE : FALSE; - $errors = array(); + $errors = []; if ($isDrupal || $isJoomla || $isWordPress) { $emailName = NULL; if (!empty($form->_bltID) && array_key_exists("email-{$form->_bltID}", $fields)) { @@ -214,10 +214,10 @@ public static function formRule($fields, $files, $form) { // now check that the cms db does not have the user name and/or email if ($isDrupal OR $isJoomla OR $isWordPress) { - $params = array( + $params = [ 'name' => $fields['cms_name'], 'mail' => $fields[$emailName], - ); + ]; } $config->userSystem->checkUserNameEmailExists($params, $errors, $emailName); diff --git a/CRM/Core/BAO/Cache.php b/CRM/Core/BAO/Cache.php index 793ee064c41d..ffdcfa7b31d2 100644 --- a/CRM/Core/BAO/Cache.php +++ b/CRM/Core/BAO/Cache.php @@ -73,7 +73,7 @@ public static function &getItem($group, $path, $componentID = NULL) { } if (self::$_cache === NULL) { - self::$_cache = array(); + self::$_cache = []; } $argString = "CRM_CT_{$group}_{$path}_{$componentID}"; @@ -115,7 +115,7 @@ public static function &getItems($group, $componentID = NULL) { } if (self::$_cache === NULL) { - self::$_cache = array(); + self::$_cache = []; } $argString = "CRM_CT_CI_{$group}_{$componentID}"; @@ -128,7 +128,7 @@ public static function &getItems($group, $componentID = NULL) { $where = self::whereCache($group, NULL, $componentID); $dao = CRM_Core_DAO::executeQuery("SELECT path, data FROM $table WHERE $where"); - $result = array(); + $result = []; while ($dao->fetch()) { $result[$dao->path] = self::decode($dao->data); } @@ -160,7 +160,7 @@ public static function setItem(&$data, $group, $path, $componentID = NULL) { } if (self::$_cache === NULL) { - self::$_cache = array(); + self::$_cache = []; } // get a lock so that multiple ajax requests on the same page @@ -181,22 +181,22 @@ public static function setItem(&$data, $group, $path, $componentID = NULL) { // "INSERT ... ON DUPE". Instead, use SELECT+(INSERT|UPDATE). if ($dataExists) { $sql = "UPDATE $table SET data = %1, created_date = %2 WHERE {$where}"; - $args = array( - 1 => array($dataSerialized, 'String'), - 2 => array($now, 'String'), - ); + $args = [ + 1 => [$dataSerialized, 'String'], + 2 => [$now, 'String'], + ]; $dao = CRM_Core_DAO::executeQuery($sql, $args, TRUE, NULL, FALSE, FALSE); } else { $insert = CRM_Utils_SQL_Insert::into($table) - ->row(array( + ->row([ 'group_name' => $group, 'path' => $path, 'component_id' => $componentID, 'data' => $dataSerialized, 'created_date' => $now, - )); - $dao = CRM_Core_DAO::executeQuery($insert->toSQL(), array(), TRUE, NULL, FALSE, FALSE); + ]); + $dao = CRM_Core_DAO::executeQuery($insert->toSQL(), [], TRUE, NULL, FALSE, FALSE); } $lock->release(); @@ -333,10 +333,10 @@ public static function restoreSessionFromCache($names) { protected static function pickSessionTtl($sessionKey) { $secureSessionTimeoutMinutes = (int) Civi::settings()->get('secure_cache_timeout_minutes'); if ($secureSessionTimeoutMinutes) { - $transactionPages = array( + $transactionPages = [ 'CRM_Contribute_Controller_Contribution', 'CRM_Event_Controller_Registration', - ); + ]; foreach ($transactionPages as $transactionPage) { if (strpos($sessionKey, $transactionPage) !== FALSE) { return $secureSessionTimeoutMinutes * 60; @@ -437,7 +437,7 @@ public static function decode($string) { * @return string */ protected static function whereCache($group, $path, $componentID) { - $clauses = array(); + $clauses = []; $clauses[] = ('group_name = "' . CRM_Core_DAO::escapeString($group) . '"'); if ($path) { $clauses[] = ('path = "' . CRM_Core_DAO::escapeString($path) . '"'); diff --git a/CRM/Core/BAO/Cache/Psr16.php b/CRM/Core/BAO/Cache/Psr16.php index 48ae52994d4e..986a4bcbf4b8 100644 --- a/CRM/Core/BAO/Cache/Psr16.php +++ b/CRM/Core/BAO/Cache/Psr16.php @@ -62,7 +62,7 @@ protected static function getGroup($group) { $cache = CRM_Utils_Cache::create([ 'name' => "bao_$group", - 'type' => array('*memory*', 'SqlGroup', 'ArrayCache'), + 'type' => ['*memory*', 'SqlGroup', 'ArrayCache'], // We're replacing CRM_Core_BAO_Cache, which traditionally used a front-cache // that was not aware of TTLs. So it seems more consistent/performant to // use 'fast' here. diff --git a/CRM/Core/BAO/ConfigSetting.php b/CRM/Core/BAO/ConfigSetting.php index 0338e56f0e47..946890452edb 100644 --- a/CRM/Core/BAO/ConfigSetting.php +++ b/CRM/Core/BAO/ConfigSetting.php @@ -108,7 +108,7 @@ public static function retrieve(&$defaults) { if ($domain->config_backend) { $defaults = unserialize($domain->config_backend); if ($defaults === FALSE || !is_array($defaults)) { - $defaults = array(); + $defaults = []; return FALSE; } @@ -231,7 +231,7 @@ public static function applyLocale($settings, $activatedLocales) { * @return string * @throws Exception */ - public static function doSiteMove($defaultValues = array()) { + public static function doSiteMove($defaultValues = []) { $moveStatus = ts('Beginning site move process...') . '
    '; $settings = Civi::settings(); @@ -240,15 +240,15 @@ public static function doSiteMove($defaultValues = array()) { if ($value && $value != $settings->getDefault($key)) { if ($settings->getMandatory($key) === NULL) { $settings->revert($key); - $moveStatus .= ts("WARNING: The setting (%1) has been reverted.", array( + $moveStatus .= ts("WARNING: The setting (%1) has been reverted.", [ 1 => $key, - )); + ]); $moveStatus .= '
    '; } else { - $moveStatus .= ts("WARNING: The setting (%1) is overridden and could not be reverted.", array( + $moveStatus .= ts("WARNING: The setting (%1) is overridden and could not be reverted.", [ 1 => $key, - )); + ]); $moveStatus .= '
    '; } } @@ -336,7 +336,7 @@ public static function disableComponent($componentName) { // get enabled-components from DB and add to the list $enabledComponents = Civi::settings()->get('enable_components'); - $enabledComponents = array_diff($enabledComponents, array($componentName)); + $enabledComponents = array_diff($enabledComponents, [$componentName]); self::setEnabledComponents($enabledComponents); @@ -360,7 +360,7 @@ public static function setEnabledComponents($enabledComponents) { * @return array */ public static function skipVars() { - return array( + return [ 'dsn', 'templateCompileDir', 'userFrameworkDSN', @@ -386,7 +386,7 @@ public static function skipVars() { 'autocompleteContactReference', 'checksumTimeout', 'checksum_timeout', - ); + ]; } /** @@ -410,26 +410,26 @@ public static function filterSkipVars($params) { * @return array */ private static function getUrlSettings() { - return array( + return [ 'userFrameworkResourceURL', 'imageUploadURL', 'customCSSURL', 'extensionsURL', - ); + ]; } /** * @return array */ private static function getPathSettings() { - return array( + return [ 'uploadDir', 'imageUploadDir', 'customFileUploadDir', 'customTemplateDir', 'customPHPPathDir', 'extensionsDir', - ); + ]; } } diff --git a/CRM/Core/BAO/Country.php b/CRM/Core/BAO/Country.php index 1a64a575c892..df195660c008 100644 --- a/CRM/Core/BAO/Country.php +++ b/CRM/Core/BAO/Country.php @@ -47,7 +47,7 @@ public static function provinceLimit() { if (!isset(Civi::$statics[__CLASS__]['provinceLimit'])) { $countryIsoCodes = CRM_Core_PseudoConstant::countryIsoCode(); $provinceLimit = Civi::settings()->get('provinceLimit'); - $country = array(); + $country = []; if (is_array($provinceLimit)) { foreach ($provinceLimit as $val) { // CRM-12007 @@ -74,7 +74,7 @@ public static function provinceLimit() { public static function countryLimit() { if (!isset(Civi::$statics[__CLASS__]['countryLimit'])) { $countryIsoCodes = CRM_Core_PseudoConstant::countryIsoCode(); - $country = array(); + $country = []; $countryLimit = Civi::settings()->get('countryLimit'); if (is_array($countryLimit)) { foreach ($countryLimit as $val) { @@ -139,10 +139,10 @@ public static function defaultCurrencySymbol($defaultCurrency = NULL) { if (!$cachedSymbol || $defaultCurrency) { $currency = $defaultCurrency ? $defaultCurrency : Civi::settings()->get('defaultCurrency'); if ($currency) { - $currencySymbols = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'currency', array( + $currencySymbols = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'currency', [ 'labelColumn' => 'symbol', 'orderColumn' => TRUE, - )); + ]); $cachedSymbol = CRM_Utils_Array::value($currency, $currencySymbols, ''); } else { diff --git a/CRM/Core/BAO/CustomGroup.php b/CRM/Core/BAO/CustomGroup.php index df5d09adaf05..8fa78cbf7ae4 100644 --- a/CRM/Core/BAO/CustomGroup.php +++ b/CRM/Core/BAO/CustomGroup.php @@ -64,11 +64,11 @@ public static function create(&$params) { $extends = CRM_Utils_Array::value('extends', $params, []); $extendsEntity = CRM_Utils_Array::value(0, $extends); - $participantEntities = array( + $participantEntities = [ 'ParticipantRole', 'ParticipantEventName', 'ParticipantEventType', - ); + ]; if (in_array($extendsEntity, $participantEntities)) { $group->extends = 'Participant'; @@ -92,10 +92,10 @@ public static function create(&$params) { if (!CRM_Utils_System::isNull($extendsChildType)) { $extendsChildType = implode(CRM_Core_DAO::VALUE_SEPARATOR, $extendsChildType); if (CRM_Utils_Array::value(0, $extends) == 'Relationship') { - $extendsChildType = str_replace(array('_a_b', '_b_a'), array( + $extendsChildType = str_replace(['_a_b', '_b_a'], [ '', '', - ), $extendsChildType); + ], $extendsChildType); } if (substr($extendsChildType, 0, 1) != CRM_Core_DAO::VALUE_SEPARATOR) { $extendsChildType = CRM_Core_DAO::VALUE_SEPARATOR . $extendsChildType . @@ -114,7 +114,7 @@ public static function create(&$params) { $oldWeight = 0; } $group->weight = CRM_Utils_Weight::updateOtherWeights('CRM_Core_DAO_CustomGroup', $oldWeight, CRM_Utils_Array::value('weight', $params, FALSE)); - $fields = array( + $fields = [ 'style', 'collapse_display', 'collapse_adv_display', @@ -122,7 +122,7 @@ public static function create(&$params) { 'help_post', 'is_active', 'is_multiple', - ); + ]; $current_db_version = CRM_Core_DAO::singleValueQuery("SELECT version FROM civicrm_domain WHERE id = " . CRM_Core_Config::domainID()); $is_public_version = $current_db_version >= '4.7.19' ? 1 : 0; if ($is_public_version) { @@ -176,7 +176,7 @@ public static function create(&$params) { if (CRM_Core_DAO_AllCoreTables::isCoreTable($tableName)) { // Bad idea. Prevent group creation because it might lead to a broken configuration. - CRM_Core_Error::fatal(ts("Cannot create custom table because %1 is already a core table.", array('1' => $tableName))); + CRM_Core_Error::fatal(ts("Cannot create custom table because %1 is already a core table.", ['1' => $tableName])); } } } @@ -304,15 +304,15 @@ public static function autoCreateByActivityType($activityTypeId) { return TRUE; } $activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE, FALSE); // everything - $params = array( + $params = [ 'version' => 3, 'extends' => 'Activity', 'extends_entity_column_id' => NULL, - 'extends_entity_column_value' => CRM_Utils_Array::implodePadded(array($activityTypeId)), - 'title' => ts('%1 Questions', array(1 => $activityTypes[$activityTypeId])), + 'extends_entity_column_value' => CRM_Utils_Array::implodePadded([$activityTypeId]), + 'title' => ts('%1 Questions', [1 => $activityTypes[$activityTypeId]]), 'style' => 'Inline', 'is_active' => 1, - ); + ]; $result = civicrm_api('CustomGroup', 'create', $params); return !$result['is_error']; } @@ -359,10 +359,10 @@ public static function autoCreateByActivityType($activityTypeId) { */ public static function getTree( $entityType, - $toReturn = array(), + $toReturn = [], $entityID = NULL, $groupID = NULL, - $subTypes = array(), + $subTypes = [], $subName = NULL, $fromCache = TRUE, $onlySubType = NULL, @@ -376,7 +376,7 @@ public static function getTree( } if (!is_array($subTypes)) { if (empty($subTypes)) { - $subTypes = array(); + $subTypes = []; } else { if (stristr($subTypes, ',')) { @@ -391,8 +391,8 @@ public static function getTree( // create a new tree // legacy hardcoded list of data to return - $tableData = array( - 'custom_field' => array( + $tableData = [ + 'custom_field' => [ 'id', 'name', 'label', @@ -412,8 +412,8 @@ public static function getTree( 'time_format', 'option_group_id', 'in_selector', - ), - 'custom_group' => array( + ], + 'custom_group' => [ 'id', 'name', 'table_name', @@ -427,8 +427,8 @@ public static function getTree( 'extends_entity_column_id', 'extends_entity_column_value', 'max_multiple', - ), - ); + ], + ]; $current_db_version = CRM_Core_DAO::singleValueQuery("SELECT version FROM civicrm_domain WHERE id = " . CRM_Core_Config::domainID()); $is_public_version = $current_db_version >= '4.7.19' ? 1 : 0; if ($is_public_version) { @@ -441,15 +441,15 @@ public static function getTree( // Supply defaults and remove unknown array keys $toReturn = array_intersect_key(array_filter($toReturn) + $tableData, $tableData); // Merge in required fields that we must have - $toReturn['custom_field'] = array_unique(array_merge($toReturn['custom_field'], array('id', 'column_name', 'data_type'))); - $toReturn['custom_group'] = array_unique(array_merge($toReturn['custom_group'], array('id', 'is_multiple', 'table_name', 'name'))); + $toReturn['custom_field'] = array_unique(array_merge($toReturn['custom_field'], ['id', 'column_name', 'data_type'])); + $toReturn['custom_group'] = array_unique(array_merge($toReturn['custom_group'], ['id', 'is_multiple', 'table_name', 'name'])); // Validate return fields $toReturn['custom_field'] = array_intersect($toReturn['custom_field'], array_keys(CRM_Core_DAO_CustomField::fieldKeys())); $toReturn['custom_group'] = array_intersect($toReturn['custom_group'], array_keys(CRM_Core_DAO_CustomGroup::fieldKeys())); } // create select - $select = array(); + $select = []; foreach ($toReturn as $tableName => $tableColumn) { foreach ($tableColumn as $columnName) { $select[] = "civicrm_{$tableName}.{$columnName} as civicrm_{$tableName}_{$columnName}"; @@ -478,7 +478,7 @@ public static function getTree( $in = "'$entityType'"; } - $params = array(); + $params = []; $sqlParamKey = 1; if (!empty($subTypes)) { foreach ($subTypes as $key => $subType) { @@ -497,7 +497,7 @@ public static function getTree( "; if ($subName) { $strWhere .= " AND civicrm_custom_group.extends_entity_column_id = %{$sqlParamKey}"; - $params[$sqlParamKey] = array($subName, 'String'); + $params[$sqlParamKey] = [$subName, 'String']; $sqlParamKey = $sqlParamKey + 1; } } @@ -515,7 +515,7 @@ public static function getTree( if ($groupID > 0) { // since we want a specific group id we add it to the where clause $strWhere .= " AND civicrm_custom_group.id = %{$sqlParamKey}"; - $params[$sqlParamKey] = array($groupID, 'Integer'); + $params[$sqlParamKey] = [$groupID, 'Integer']; } elseif (!$groupID) { // since groupID is false we need to show all Inline groups @@ -561,9 +561,9 @@ public static function getTree( } if (empty($groupTree)) { - $groupTree = $multipleFieldGroups = array(); + $groupTree = $multipleFieldGroups = []; $crmDAO = CRM_Core_DAO::executeQuery($queryString, $params); - $customValueTables = array(); + $customValueTables = []; // process records while ($crmDAO->fetch()) { @@ -575,7 +575,7 @@ public static function getTree( } // create an array for groups if it does not exist if (!array_key_exists($groupID, $groupTree)) { - $groupTree[$groupID] = array(); + $groupTree[$groupID] = []; $groupTree[$groupID]['id'] = $groupID; // populate the group information @@ -594,15 +594,15 @@ public static function getTree( } $groupTree[$groupID][$fieldName] = $crmDAO->$fullFieldName; } - $groupTree[$groupID]['fields'] = array(); + $groupTree[$groupID]['fields'] = []; - $customValueTables[$crmDAO->civicrm_custom_group_table_name] = array(); + $customValueTables[$crmDAO->civicrm_custom_group_table_name] = []; } // add the fields now (note - the query row will always contain a field) // we only reset this once, since multiple values come is as multiple rows if (!array_key_exists($fieldId, $groupTree[$groupID]['fields'])) { - $groupTree[$groupID]['fields'][$fieldId] = array(); + $groupTree[$groupID]['fields'][$fieldId] = []; } $customValueTables[$crmDAO->civicrm_custom_group_table_name][$crmDAO->civicrm_custom_field_column_name] = 1; @@ -620,7 +620,7 @@ public static function getTree( } if (!empty($customValueTables)) { - $groupTree['info'] = array('tables' => $customValueTables); + $groupTree['info'] = ['tables' => $customValueTables]; } $cache->set($cacheKey, $groupTree); @@ -628,8 +628,8 @@ public static function getTree( } // entitySelectClauses is an array of select clauses for custom value tables which are not multiple // and have data for the given entities. $entityMultipleSelectClauses is the same for ones with multiple - $entitySingleSelectClauses = $entityMultipleSelectClauses = $groupTree['info']['select'] = array(); - $singleFieldTables = array(); + $entitySingleSelectClauses = $entityMultipleSelectClauses = $groupTree['info']['select'] = []; + $singleFieldTables = []; // now that we have all the groups and fields, lets get the values // since we need to know the table and field names // add info to groupTree @@ -637,15 +637,15 @@ public static function getTree( if (isset($groupTree['info']) && !empty($groupTree['info']) && !empty($groupTree['info']['tables']) && $singleRecord != 'new' ) { - $select = $from = $where = array(); + $select = $from = $where = []; $groupTree['info']['where'] = NULL; foreach ($groupTree['info']['tables'] as $table => $fields) { $groupTree['info']['from'][] = $table; - $select = array( + $select = [ "{$table}.id as {$table}_id", "{$table}.entity_id as {$table}_entity_id", - ); + ]; foreach ($fields as $column => $dontCare) { $select[] = "{$table}.{$column} as {$table}_{$column}"; } @@ -692,7 +692,7 @@ protected static function validateSubTypeByEntity($entityType, $subType) { } $contactTypes = CRM_Contact_BAO_ContactType::basicTypeInfo(TRUE); - $contactTypes = array_merge($contactTypes, array('Event' => 1)); + $contactTypes = array_merge($contactTypes, ['Event' => 1]); if ($entityType != 'Contact' && !array_key_exists($entityType, $contactTypes)) { throw new CRM_Core_Exception('Invalid Entity Filter'); @@ -806,7 +806,7 @@ static public function buildEntityTreeMultipleFields(&$groupTree, $entityID, $en $offset = $singleRecord - 1; $query .= " LIMIT {$offset}, 1"; } - self::buildTreeEntityDataFromQuery($groupTree, $query, array($table), $singleRecord); + self::buildTreeEntityDataFromQuery($groupTree, $query, [$table], $singleRecord); } } @@ -882,23 +882,23 @@ static public function buildCustomFieldData($dao, &$groupTree, $table, $groupID, $customValue['fileURL'] = CRM_Utils_System::url('civicrm/file', "reset=1&id={$fileDAO->id}&eid={$dao->$entityIDName}&fcs=$fileHash"); $customValue['displayURL'] = NULL; $deleteExtra = ts('Are you sure you want to delete attached file.'); - $deleteURL = array( - CRM_Core_Action::DELETE => array( + $deleteURL = [ + CRM_Core_Action::DELETE => [ 'name' => ts('Delete Attached File'), 'url' => 'civicrm/file', 'qs' => 'reset=1&id=%%id%%&eid=%%eid%%&fid=%%fid%%&action=delete&fcs=%%fcs%%', 'extra' => 'onclick = "if (confirm( \'' . $deleteExtra . '\' ) ) this.href+=\'&confirmed=1\'; else return false;"', - ), - ); + ], + ]; $customValue['deleteURL'] = CRM_Core_Action::formLink($deleteURL, CRM_Core_Action::DELETE, - array( + [ 'id' => $fileDAO->id, 'eid' => $dao->$entityIDName, 'fid' => $fieldID, 'fcs' => $fileHash, - ), + ], ts('more'), FALSE, 'file.manage.delete', @@ -932,27 +932,27 @@ static public function buildCustomFieldData($dao, &$groupTree, $table, $groupID, } } else { - $customValue = array( + $customValue = [ 'id' => $dao->$idName, 'data' => '', - ); + ]; } } else { - $customValue = array( + $customValue = [ 'id' => $dao->$idName, 'data' => $dao->$fieldName, - ); + ]; } if (!array_key_exists('customValue', $groupTree[$groupID]['fields'][$fieldID])) { - $groupTree[$groupID]['fields'][$fieldID]['customValue'] = array(); + $groupTree[$groupID]['fields'][$fieldID]['customValue'] = []; } if (empty($groupTree[$groupID]['fields'][$fieldID]['customValue']) && !empty($singleRecord)) { - $groupTree[$groupID]['fields'][$fieldID]['customValue'] = array($singleRecord => $customValue); + $groupTree[$groupID]['fields'][$fieldID]['customValue'] = [$singleRecord => $customValue]; } elseif (empty($groupTree[$groupID]['fields'][$fieldID]['customValue'])) { - $groupTree[$groupID]['fields'][$fieldID]['customValue'] = array(1 => $customValue); + $groupTree[$groupID]['fields'][$fieldID]['customValue'] = [1 => $customValue]; } else { $groupTree[$groupID]['fields'][$fieldID]['customValue'][] = $customValue; @@ -991,11 +991,11 @@ public static function getTitle($id) { */ public static function &getGroupDetail($groupId = NULL, $searchable = NULL, &$extends = NULL, $inSelector = NULL) { // create a new tree - $groupTree = array(); + $groupTree = []; // using tableData to build the queryString - $tableData = array( - 'civicrm_custom_field' => array( + $tableData = [ + 'civicrm_custom_field' => [ 'id', 'label', 'data_type', @@ -1018,8 +1018,8 @@ public static function &getGroupDetail($groupId = NULL, $searchable = NULL, &$ex 'is_view', 'option_group_id', 'in_selector', - ), - 'civicrm_custom_group' => array( + ], + 'civicrm_custom_group' => [ 'id', 'name', 'title', @@ -1031,25 +1031,25 @@ public static function &getGroupDetail($groupId = NULL, $searchable = NULL, &$ex 'extends_entity_column_value', 'table_name', 'is_multiple', - ), - ); + ], + ]; // create select - $s = array(); + $s = []; foreach ($tableData as $tableName => $tableColumn) { foreach ($tableColumn as $columnName) { $s[] = "{$tableName}.{$columnName} as {$tableName}_{$columnName}"; } } $select = 'SELECT ' . implode(', ', $s); - $params = array(); + $params = []; // from, where, order by $from = " FROM civicrm_custom_field, civicrm_custom_group"; $where = " WHERE civicrm_custom_field.custom_group_id = civicrm_custom_group.id AND civicrm_custom_group.is_active = 1 AND civicrm_custom_field.is_active = 1 "; if ($groupId) { - $params[1] = array($groupId, 'Integer'); + $params[1] = [$groupId, 'Integer']; $where .= " AND civicrm_custom_group.id = %1"; } @@ -1062,7 +1062,7 @@ public static function &getGroupDetail($groupId = NULL, $searchable = NULL, &$ex } if ($extends) { - $clause = array(); + $clause = []; foreach ($extends as $e) { $clause[] = "civicrm_custom_group.extends = '$e'"; } @@ -1072,7 +1072,7 @@ public static function &getGroupDetail($groupId = NULL, $searchable = NULL, &$ex if (in_array('Activity', $extends)) { $extendValues = implode(',', array_keys(CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE))); $where .= " AND ( civicrm_custom_group.extends_entity_column_value IS NULL OR REPLACE( civicrm_custom_group.extends_entity_column_value, %2, ' ') IN ($extendValues) ) "; - $params[2] = array(CRM_Core_DAO::VALUE_SEPARATOR, 'String'); + $params[2] = [CRM_Core_DAO::VALUE_SEPARATOR, 'String']; } } @@ -1097,7 +1097,7 @@ public static function &getGroupDetail($groupId = NULL, $searchable = NULL, &$ex // create an array for groups if it does not exist if (!array_key_exists($groupId, $groupTree)) { - $groupTree[$groupId] = array(); + $groupTree[$groupId] = []; $groupTree[$groupId]['id'] = $groupId; foreach ($tableData['civicrm_custom_group'] as $v) { @@ -1110,11 +1110,11 @@ public static function &getGroupDetail($groupId = NULL, $searchable = NULL, &$ex $groupTree[$groupId][$v] = $crmDAO->$fullField; } - $groupTree[$groupId]['fields'] = array(); + $groupTree[$groupId]['fields'] = []; } // add the fields now (note - the query row will always contain a field) - $groupTree[$groupId]['fields'][$fieldId] = array(); + $groupTree[$groupId]['fields'][$fieldId] = []; $groupTree[$groupId]['fields'][$fieldId]['id'] = $fieldId; foreach ($tableData['civicrm_custom_field'] as $v) { @@ -1147,7 +1147,7 @@ public static function &getActiveGroups($entityType, $path, $cidToken = '%%cid%% // add whereAdd for entity type self::_addWhereAdd($customGroupDAO, $entityType, $cidToken); - $groups = array(); + $groups = []; $permissionClause = CRM_Core_Permission::customGroupClause(CRM_Core_Permission::VIEW, NULL, TRUE); $customGroupDAO->whereAdd($permissionClause); @@ -1158,12 +1158,12 @@ public static function &getActiveGroups($entityType, $path, $cidToken = '%%cid%% // process each group with menu tab while ($customGroupDAO->fetch()) { - $group = array(); + $group = []; $group['id'] = $customGroupDAO->id; $group['path'] = $path; $group['title'] = "$customGroupDAO->title"; $group['query'] = "reset=1&gid={$customGroupDAO->id}&cid={$cidToken}"; - $group['extra'] = array('gid' => $customGroupDAO->id); + $group['extra'] = ['gid' => $customGroupDAO->id]; $group['table_name'] = $customGroupDAO->table_name; $group['is_multiple'] = $customGroupDAO->is_multiple; $groups[] = $group; @@ -1298,7 +1298,7 @@ private static function _addWhereAdd(&$customGroupDAO, $entityType, $entityID = $csType = is_numeric($entityID) ? CRM_Contact_BAO_Contact::getContactSubType($entityID) : FALSE; if (!empty($csType)) { - $subtypeClause = array(); + $subtypeClause = []; foreach ($csType as $subtype) { $subtype = CRM_Core_DAO::VALUE_SEPARATOR . $subtype . CRM_Core_DAO::VALUE_SEPARATOR; @@ -1391,7 +1391,7 @@ public static function setDefaults(&$groupTree, &$defaults, $viewMode = FALSE, $ switch ($field['html_type']) { case 'Multi-Select': case 'CheckBox': - $defaults[$elementName] = array(); + $defaults[$elementName] = []; $customOption = CRM_Core_BAO_CustomOption::getCustomOption($field['id'], $inactiveNeeded); if ($viewMode) { $checkedData = explode(CRM_Core_DAO::VALUE_SEPARATOR, substr($value, 1, -1)); @@ -1525,7 +1525,7 @@ public static function postProcess(&$groupTree, &$params, $skipFile = FALSE) { if (!isset($groupTree[$groupID]['fields'][$fieldId]['customValue'])) { // field exists in db so populate value from "form". - $groupTree[$groupID]['fields'][$fieldId]['customValue'] = array(); + $groupTree[$groupID]['fields'][$fieldId]['customValue'] = []; } switch ($groupTree[$groupID]['fields'][$fieldId]['html_type']) { @@ -1566,7 +1566,7 @@ public static function postProcess(&$groupTree, &$params, $skipFile = FALSE) { // store the file in d/b $entityId = explode('=', $groupTree['info']['where'][0]); - $fileParams = array('upload_date' => date('YmdHis')); + $fileParams = ['upload_date' => date('YmdHis')]; if ($groupTree[$groupID]['fields'][$fieldId]['customValue']['fid']) { $fileParams['id'] = $groupTree[$groupID]['fields'][$fieldId]['customValue']['fid']; @@ -1585,11 +1585,11 @@ public static function postProcess(&$groupTree, &$params, $skipFile = FALSE) { $v['type'] ); } - $defaults = array(); - $paramsFile = array( + $defaults = []; + $paramsFile = [ 'entity_table' => $groupTree[$groupID]['table_name'], 'entity_id' => $entityId[1], - ); + ]; CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_EntityFile', $paramsFile, @@ -1659,17 +1659,17 @@ public static function buildQuickForm(&$form, &$groupTree, $inactiveNeeded = FAL */ public static function extractGetParams(&$form, $type) { if (empty($_GET)) { - return array(); + return []; } $groupTree = CRM_Core_BAO_CustomGroup::getTree($type); - $customValue = array(); - $htmlType = array( + $customValue = []; + $htmlType = [ 'CheckBox', 'Multi-Select', 'Select', 'Radio', - ); + ]; foreach ($groupTree as $group) { if (!isset($group['fields'])) { @@ -1692,7 +1692,7 @@ public static function extractGetParams(&$form, $type) { $value = str_replace("|", ",", $value); $mulValues = explode(',', $value); $customOption = CRM_Core_BAO_CustomOption::getCustomOption($key, TRUE); - $val = array(); + $val = []; foreach ($mulValues as $v1) { foreach ($customOption as $coID => $coValue) { if (strtolower(trim($coValue['label'])) == @@ -1822,7 +1822,7 @@ public static function mapTableName($table) { default: $query = " SELECT IF( EXISTS(SELECT name FROM civicrm_contact_type WHERE name like %1), 1, 0 )"; - $qParams = array(1 => array($table, 'String')); + $qParams = [1 => [$table, 'String']]; $result = CRM_Core_DAO::singleValueQuery($query, $qParams); if ($result) { @@ -1844,11 +1844,11 @@ public static function mapTableName($table) { * @throws \Exception */ public static function createTable($group) { - $params = array( + $params = [ 'name' => $group->table_name, 'is_multiple' => $group->is_multiple ? 1 : 0, 'extends_name' => self::mapTableName($group->extends), - ); + ]; $tableParams = CRM_Core_BAO_CustomField::defaultCustomTableSchema($params); @@ -1867,8 +1867,8 @@ public static function createTable($group) { * @throws \CRM_Core_Exception */ public static function formatGroupTree(&$groupTree, $groupCount = 1, &$form = NULL) { - $formattedGroupTree = array(); - $uploadNames = $formValues = array(); + $formattedGroupTree = []; + $uploadNames = $formValues = []; // retrieve qf key from url $qfKey = CRM_Utils_Request::retrieve('qf', 'String'); @@ -1966,7 +1966,7 @@ public static function formatGroupTree(&$groupTree, $groupCount = 1, &$form = NU * @throws \Exception */ public static function buildCustomDataView(&$form, &$groupTree, $returnCount = FALSE, $gID = NULL, $prefix = NULL, $customValueId = NULL, $entityId = NULL) { - $details = array(); + $details = []; foreach ($groupTree as $key => $group) { if ($key === 'info') { continue; @@ -1986,13 +1986,13 @@ public static function buildCustomDataView(&$form, &$groupTree, $returnCount = F $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']]['fields'][$k] = array( + $details[$groupID][$values['id']]['fields'][$k] = [ 'field_title' => CRM_Utils_Array::value('label', $properties), 'field_type' => CRM_Utils_Array::value('html_type', $properties), 'field_data_type' => CRM_Utils_Array::value('data_type', $properties), 'field_value' => CRM_Core_BAO_CustomField::displayValue($values['data'], $properties['id'], $entityId), 'options_per_line' => CRM_Utils_Array::value('options_per_line', $properties), - ); + ]; // editable = whether this set contains any non-read-only fields if (!isset($details[$groupID][$values['id']]['editable'])) { $details[$groupID][$values['id']]['editable'] = FALSE; @@ -2019,7 +2019,7 @@ public static function buildCustomDataView(&$form, &$groupTree, $returnCount = F $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]['fields'][$k] = array('field_title' => CRM_Utils_Array::value('label', $properties)); + $details[$groupID][0]['fields'][$k] = ['field_title' => CRM_Utils_Array::value('label', $properties)]; } } } @@ -2031,7 +2031,7 @@ public static function buildCustomDataView(&$form, &$groupTree, $returnCount = F return count($details[$gID]); } else { - $countValue = array(); + $countValue = []; foreach ($details as $key => $value) { $countValue[$key] = count($details[$key]); } @@ -2058,7 +2058,7 @@ public static function getGroupTitles($fieldIds) { return NULL; } - $groupLabels = array(); + $groupLabels = []; $fIds = "(" . implode(',', $fieldIds) . ")"; $query = " @@ -2070,12 +2070,12 @@ public static function getGroupTitles($fieldIds) { $dao = CRM_Core_DAO::executeQuery($query); while ($dao->fetch()) { - $groupLabels[$dao->fieldID] = array( + $groupLabels[$dao->fieldID] = [ 'fieldID' => $dao->fieldID, 'fieldLabel' => $dao->fieldLabel, 'groupID' => $dao->groupID, 'groupTitle' => $dao->groupTitle, - ); + ]; } return $groupLabels; @@ -2130,12 +2130,12 @@ public static function isGroupEmpty($gID) { * Array of types. * @throws \Exception */ - public static function getExtendedObjectTypes(&$types = array()) { - static $flag = FALSE, $objTypes = array(); + public static function getExtendedObjectTypes(&$types = []) { + static $flag = FALSE, $objTypes = []; if (!$flag) { - $extendObjs = array(); - CRM_Core_OptionValue::getValues(array('name' => 'cg_extend_objects'), $extendObjs); + $extendObjs = []; + CRM_Core_OptionValue::getValues(['name' => 'cg_extend_objects'], $extendObjs); foreach ($extendObjs as $ovId => $ovValues) { if ($ovValues['description']) { @@ -2143,7 +2143,7 @@ public static function getExtendedObjectTypes(&$types = array()) { list($callback, $args) = explode(';', trim($ovValues['description'])); if (empty($args)) { - $args = array(); + $args = []; } if (!is_array($args)) { @@ -2184,7 +2184,7 @@ public static function hasReachedMaxLimit($customGroupId, $entityId) { $tableName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $customGroupId, 'table_name'); // count the number of entries for a entity $sql = "SELECT COUNT(id) FROM {$tableName} WHERE entity_id = %1"; - $params = array(1 => array($entityId, 'Integer')); + $params = [1 => [$entityId, 'Integer']]; $count = CRM_Core_DAO::singleValueQuery($sql, $params); if ($count >= $maxMultiple) { @@ -2199,7 +2199,7 @@ public static function hasReachedMaxLimit($customGroupId, $entityId) { * @return array */ public static function getMultipleFieldGroup() { - $multipleGroup = array(); + $multipleGroup = []; $dao = new CRM_Core_DAO_CustomGroup(); $dao->is_multiple = 1; $dao->is_active = 1; diff --git a/CRM/Core/BAO/CustomOption.php b/CRM/Core/BAO/CustomOption.php index 99133b4a93f6..f667ba4d1f30 100644 --- a/CRM/Core/BAO/CustomOption.php +++ b/CRM/Core/BAO/CustomOption.php @@ -74,18 +74,18 @@ public static function getCustomOption( $fieldID, $inactiveNeeded = FALSE ) { - $options = array(); + $options = []; if (!$fieldID) { return $options; } - $optionValues = CRM_Core_PseudoConstant::get('CRM_Core_BAO_CustomField', 'custom_' . $fieldID, array(), $inactiveNeeded ? 'get' : 'create'); + $optionValues = CRM_Core_PseudoConstant::get('CRM_Core_BAO_CustomField', 'custom_' . $fieldID, [], $inactiveNeeded ? 'get' : 'create'); foreach ((array) $optionValues as $value => $label) { - $options[] = array( + $options[] = [ 'label' => $label, 'value' => $value, - ); + ]; } return $options; @@ -103,7 +103,7 @@ public static function getCustomOption( * -page= offset */ static public function getOptionListSelector(&$params) { - $options = array(); + $options = []; $field = CRM_Core_BAO_CustomField::getFieldObject($params['fid']); $defVal = CRM_Utils_Array::explodePadded($field->default_value); @@ -115,7 +115,7 @@ static public function getOptionListSelector(&$params) { if (!$field->option_group_id) { return $options; } - $queryParams = array(1 => array($field->option_group_id, 'Integer')); + $queryParams = [1 => [$field->option_group_id, 'Integer']]; $total = "SELECT COUNT(*) FROM civicrm_option_value WHERE option_group_id = %1"; $params['total'] = CRM_Core_DAO::singleValueQuery($total, $queryParams); @@ -126,10 +126,10 @@ static public function getOptionListSelector(&$params) { $dao = CRM_Core_DAO::executeQuery($query, $queryParams); $links = CRM_Custom_Page_Option::actionLinks(); - $fields = array('id', 'label', 'value'); + $fields = ['id', 'label', 'value']; $config = CRM_Core_Config::singleton(); while ($dao->fetch()) { - $options[$dao->id] = array(); + $options[$dao->id] = []; foreach ($fields as $k) { $options[$dao->id][$k] = $dao->$k; } @@ -176,11 +176,11 @@ static public function getOptionListSelector(&$params) { $options[$dao->id]['is_active'] = empty($dao->is_active) ? ts('No') : ts('Yes'); $options[$dao->id]['links'] = CRM_Core_Action::formLink($links, $action, - array( + [ 'id' => $dao->id, 'fid' => $params['fid'], 'gid' => $params['gid'], - ), + ], ts('more'), FALSE, 'customOption.row.actions', @@ -209,22 +209,22 @@ public static function del($optionId) { WHERE v.id = %1 AND g.id = f.option_group_id AND g.id = v.option_group_id"; - $params = array(1 => array($optionId, 'Integer')); + $params = [1 => [$optionId, 'Integer']]; $dao = CRM_Core_DAO::executeQuery($query, $params); if ($dao->fetch()) { if (in_array($dao->dataType, - array('Int', 'Float', 'Money', 'Boolean') + ['Int', 'Float', 'Money', 'Boolean'] )) { $value = 0; } else { $value = ''; } - $params = array( + $params = [ 'optionId' => $optionId, 'fieldId' => $dao->id, 'value' => $value, - ); + ]; // delete this value from the tables self::updateCustomValues($params); @@ -233,7 +233,7 @@ public static function del($optionId) { DELETE FROM civicrm_option_value WHERE id = %1"; - $params = array(1 => array($optionId, 'Integer')); + $params = [1 => [$optionId, 'Integer']]; CRM_Core_DAO::executeQuery($query, $params); } } @@ -259,7 +259,7 @@ public static function updateCustomValues($params) { civicrm_custom_field f WHERE f.custom_group_id = g.id AND f.id = %1"; - $queryParams = array(1 => array($params['fieldId'], 'Integer')); + $queryParams = [1 => [$params['fieldId'], 'Integer']]; $dao = CRM_Core_DAO::executeQuery($query, $queryParams); if ($dao->fetch()) { if ($dao->dataType == 'Money') { @@ -279,16 +279,16 @@ public static function updateCustomValues($params) { else { $dataType = $dao->dataType; } - $queryParams = array( - 1 => array( + $queryParams = [ + 1 => [ $params['value'], $dataType, - ), - 2 => array( + ], + 2 => [ $params['optionId'], 'Integer', - ), - ); + ], + ]; break; case 'Multi-Select': @@ -298,10 +298,10 @@ public static function updateCustomValues($params) { $query = " UPDATE {$dao->tableName} SET {$dao->columnName} = REPLACE( {$dao->columnName}, %1, %2 )"; - $queryParams = array( - 1 => array($oldString, 'String'), - 2 => array($newString, 'String'), - ); + $queryParams = [ + 1 => [$oldString, 'String'], + 2 => [$newString, 'String'], + ]; break; default: @@ -334,18 +334,18 @@ public static function updateValue($optionId, $newValue) { $customGroup->id = $customField->custom_group_id; $customGroup->find(TRUE); if (CRM_Core_BAO_CustomField::isSerialized($customField)) { - $params = array( - 1 => array(CRM_Utils_Array::implodePadded($oldValue), 'String'), - 2 => array(CRM_Utils_Array::implodePadded($newValue), 'String'), - 3 => array('%' . CRM_Utils_Array::implodePadded($oldValue) . '%', 'String'), - ); + $params = [ + 1 => [CRM_Utils_Array::implodePadded($oldValue), 'String'], + 2 => [CRM_Utils_Array::implodePadded($newValue), 'String'], + 3 => ['%' . CRM_Utils_Array::implodePadded($oldValue) . '%', 'String'], + ]; } else { - $params = array( - 1 => array($oldValue, 'String'), - 2 => array($newValue, 'String'), - 3 => array($oldValue, 'String'), - ); + $params = [ + 1 => [$oldValue, 'String'], + 2 => [$newValue, 'String'], + 3 => [$oldValue, 'String'], + ]; } $sql = "UPDATE `{$customGroup->table_name}` SET `{$customField->column_name}` = REPLACE(`{$customField->column_name}`, %1, %2) WHERE `{$customField->column_name}` LIKE %3"; $customGroup->free(); diff --git a/CRM/Core/BAO/CustomQuery.php b/CRM/Core/BAO/CustomQuery.php index 29335eaec8ad..f3efb735d350 100644 --- a/CRM/Core/BAO/CustomQuery.php +++ b/CRM/Core/BAO/CustomQuery.php @@ -107,7 +107,7 @@ class CRM_Core_BAO_CustomQuery { * * @var array */ - static $extendsMap = array( + static $extendsMap = [ 'Contact' => 'civicrm_contact', 'Individual' => 'civicrm_contact', 'Household' => 'civicrm_contact', @@ -126,7 +126,7 @@ class CRM_Core_BAO_CustomQuery { 'Address' => 'civicrm_address', 'Campaign' => 'civicrm_campaign', 'Survey' => 'civicrm_survey', - ); + ]; /** * Class constructor. @@ -140,19 +140,19 @@ class CRM_Core_BAO_CustomQuery { * @param bool $contactSearch * @param array $locationSpecificFields */ - public function __construct($ids, $contactSearch = FALSE, $locationSpecificFields = array()) { + public function __construct($ids, $contactSearch = FALSE, $locationSpecificFields = []) { $this->_ids = &$ids; $this->_locationSpecificCustomFields = $locationSpecificFields; - $this->_select = array(); - $this->_element = array(); - $this->_tables = array(); - $this->_whereTables = array(); - $this->_where = array(); - $this->_qill = array(); - $this->_options = array(); + $this->_select = []; + $this->_element = []; + $this->_tables = []; + $this->_whereTables = []; + $this->_where = []; + $this->_qill = []; + $this->_options = []; - $this->_fields = array(); + $this->_fields = []; $this->_contactSearch = $contactSearch; if (empty($this->_ids)) { @@ -187,7 +187,7 @@ public function __construct($ids, $contactSearch = FALSE, $locationSpecificField // if $extends is a subtype, refer contact table $extendsTable = self::$extendsMap['Contact']; } - $this->_fields[$dao->id] = array( + $this->_fields[$dao->id] = [ 'id' => $dao->id, 'label' => $dao->label, 'extends' => $extendsTable, @@ -197,18 +197,18 @@ public function __construct($ids, $contactSearch = FALSE, $locationSpecificField 'column_name' => $dao->column_name, 'table_name' => $dao->table_name, 'option_group_id' => $dao->option_group_id, - ); + ]; // Deprecated (and poorly named) cache of field attributes - $this->_options[$dao->id] = array( - 'attributes' => array( + $this->_options[$dao->id] = [ + 'attributes' => [ 'label' => $dao->label, 'data_type' => $dao->data_type, 'html_type' => $dao->html_type, - ), - ); + ], + ]; - $options = CRM_Core_PseudoConstant::get('CRM_Core_BAO_CustomField', 'custom_' . $dao->id, array(), 'search'); + $options = CRM_Core_PseudoConstant::get('CRM_Core_BAO_CustomField', 'custom_' . $dao->id, [], 'search'); if ($options) { $this->_options[$dao->id] += $options; } @@ -338,7 +338,7 @@ public function where() { elseif ($value) { $value = CRM_Utils_Type::escape($value, 'Integer'); } - $value = str_replace(array('[', ']', ','), array('\[', '\]', '[:comma:]'), $value); + $value = str_replace(['[', ']', ','], ['\[', '\]', '[:comma:]'], $value); $value = str_replace('|', '[:separator:]', $value); } elseif ($isSerialized) { @@ -349,7 +349,7 @@ public function where() { // CRM-19006: escape characters like comma, | before building regex pattern $value = (array) $value; foreach ($value as $key => $val) { - $value[$key] = str_replace(array('[', ']', ','), array('\[', '\]', '[:comma:]'), $val); + $value[$key] = str_replace(['[', ']', ','], ['\[', '\]', '[:comma:]'], $val); $value[$key] = str_replace('|', '[:separator:]', $value[$key]); } $value = implode(',', $value); @@ -359,7 +359,7 @@ public function where() { if ($isSerialized && !CRM_Utils_System::isNull($value) && !strstr($op, 'NULL') && !strstr($op, 'LIKE')) { $sp = CRM_Core_DAO::VALUE_SEPARATOR; $value = str_replace(",", "$sp|$sp", $value); - $value = str_replace(array('[:comma:]', '(', ')'), array(',', '[(]', '[)]'), $value); + $value = str_replace(['[:comma:]', '(', ')'], [',', '[(]', '[)]'], $value); $op = (strstr($op, '!') || strstr($op, 'NOT')) ? 'NOT RLIKE' : 'RLIKE'; $value = $sp . $value . $sp; @@ -390,7 +390,7 @@ public function where() { case 'Int': $this->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause($fieldName, $op, $value, 'Integer'); - $this->_qill[$grouping][] = ts("%1 %2 %3", array(1 => $field['label'], 2 => $qillOp, 3 => $qillValue));; + $this->_qill[$grouping][] = ts("%1 %2 %3", [1 => $field['label'], 2 => $qillOp, 3 => $qillValue]);; break; case 'Boolean': @@ -405,13 +405,13 @@ public function where() { $qillValue = $value ? 'Yes' : 'No'; } $this->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause($fieldName, $op, $value, 'Integer'); - $this->_qill[$grouping][] = ts("%1 %2 %3", array(1 => $field['label'], 2 => $qillOp, 3 => $qillValue)); + $this->_qill[$grouping][] = ts("%1 %2 %3", [1 => $field['label'], 2 => $qillOp, 3 => $qillValue]); break; case 'Link': case 'Memo': $this->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause($fieldName, $op, $value, 'String'); - $this->_qill[$grouping][] = ts("%1 %2 %3", array(1 => $field['label'], 2 => $qillOp, 3 => $qillValue)); + $this->_qill[$grouping][] = ts("%1 %2 %3", [1 => $field['label'], 2 => $qillOp, 3 => $qillValue]); break; case 'Money': @@ -433,12 +433,12 @@ public function where() { case 'Float': $this->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause($fieldName, $op, $value, 'Float'); - $this->_qill[$grouping][] = ts("%1 %2 %3", array(1 => $field['label'], 2 => $qillOp, 3 => $qillValue)); + $this->_qill[$grouping][] = ts("%1 %2 %3", [1 => $field['label'], 2 => $qillOp, 3 => $qillValue]); break; case 'Date': $this->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause($fieldName, $op, $value, 'Date'); - list($qillOp, $qillVal) = CRM_Contact_BAO_Query::buildQillForFieldValue(NULL, $field['label'], $value, $op, array(), CRM_Utils_Type::T_DATE); + list($qillOp, $qillVal) = CRM_Contact_BAO_Query::buildQillForFieldValue(NULL, $field['label'], $value, $op, [], CRM_Utils_Type::T_DATE); $this->_qill[$grouping][] = "{$field['label']} $qillOp '$qillVal'"; break; @@ -476,7 +476,7 @@ public function query() { $whereStr = NULL; if (!empty($this->_where)) { - $clauses = array(); + $clauses = []; foreach ($this->_where as $grouping => $values) { if (!empty($values)) { $clauses[] = ' ( ' . implode(' AND ', $values) . ' ) '; @@ -487,11 +487,11 @@ public function query() { } } - return array( + return [ implode(' , ', $this->_select), implode(' ', $this->_tables), $whereStr, - ); + ]; } } diff --git a/CRM/Core/BAO/CustomValue.php b/CRM/Core/BAO/CustomValue.php index 5e6a90fb662f..305567fcbe0e 100644 --- a/CRM/Core/BAO/CustomValue.php +++ b/CRM/Core/BAO/CustomValue.php @@ -183,14 +183,14 @@ public static function fixCustomFieldValue(&$formValues) { if (is_array($formValues[$key])) { if (!in_array(key($formValues[$key]), CRM_Core_DAO::acceptedSQLOperators(), TRUE)) { - $formValues[$key] = array('IN' => $formValues[$key]); + $formValues[$key] = ['IN' => $formValues[$key]]; } } elseif (($htmlType == 'TextArea' || ($htmlType == 'Text' && $dataType == 'String') ) && strstr($formValues[$key], '%') ) { - $formValues[$key] = array('LIKE' => $formValues[$key]); + $formValues[$key] = ['LIKE' => $formValues[$key]]; } } } @@ -208,9 +208,9 @@ public static function deleteCustomValue($customValueID, $customGroupID) { $tableName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $customGroupID, 'table_name'); // Retrieve the $entityId so we can pass that to the hook. - $entityID = CRM_Core_DAO::singleValueQuery("SELECT entity_id FROM {$tableName} WHERE id = %1", array( - 1 => array($customValueID, 'Integer'), - )); + $entityID = CRM_Core_DAO::singleValueQuery("SELECT entity_id FROM {$tableName} WHERE id = %1", [ + 1 => [$customValueID, 'Integer'], + ]); // delete custom value from corresponding custom value table $sql = "DELETE FROM {$tableName} WHERE id = {$customValueID}"; diff --git a/CRM/Core/BAO/CustomValueTable.php b/CRM/Core/BAO/CustomValueTable.php index bd4807cc1cfd..dac03b007509 100644 --- a/CRM/Core/BAO/CustomValueTable.php +++ b/CRM/Core/BAO/CustomValueTable.php @@ -46,7 +46,7 @@ public static function create(&$customParams) { return; } - $paramFieldsExtendContactForEntities = array(); + $paramFieldsExtendContactForEntities = []; foreach ($customParams as $tableName => $tables) { foreach ($tables as $index => $fields) { @@ -55,8 +55,8 @@ public static function create(&$customParams) { $hookOP = NULL; $entityID = NULL; $isMultiple = FALSE; - $set = array(); - $params = array(); + $set = []; + $params = []; $count = 1; foreach ($fields as $field) { if (!$sqlOP) { @@ -66,7 +66,7 @@ public static function create(&$customParams) { if (array_key_exists('id', $field)) { $sqlOP = "UPDATE $tableName "; $where = " WHERE id = %{$count}"; - $params[$count] = array($field['id'], 'Integer'); + $params[$count] = [$field['id'], 'Integer']; $count++; $hookOP = 'edit'; } @@ -90,9 +90,9 @@ public static function create(&$customParams) { elseif (!is_numeric($value) && !strstr($value, CRM_Core_DAO::VALUE_SEPARATOR)) { //fix for multi select state, CRM-3437 $mulValues = explode(',', $value); - $validStates = array(); + $validStates = []; foreach ($mulValues as $key => $stateVal) { - $states = array(); + $states = []; $states['state_province'] = trim($stateVal); CRM_Utils_Array::lookupValue($states, 'state_province', @@ -131,9 +131,9 @@ public static function create(&$customParams) { elseif (!is_numeric($value) && !strstr($value, CRM_Core_DAO::VALUE_SEPARATOR)) { //fix for multi select country, CRM-3437 $mulValues = explode(',', $value); - $validCountries = array(); + $validCountries = []; foreach ($mulValues as $key => $countryVal) { - $countries = array(); + $countries = []; $countries['country'] = trim($countryVal); CRM_Utils_Array::lookupValue($countries, 'country', CRM_Core_PseudoConstant::country(), TRUE @@ -225,7 +225,7 @@ public static function create(&$customParams) { } else { $set[$field['column_name']] = "%{$count}"; - $params[$count] = array($value, $type); + $params[$count] = [$value, $type]; $count++; } @@ -242,7 +242,7 @@ public static function create(&$customParams) { } if (!empty($set)) { - $setClause = array(); + $setClause = []; foreach ($set as $n => $v) { $setClause[] = "$n = $v"; } @@ -250,7 +250,7 @@ public static function create(&$customParams) { if (!$where) { // do this only for insert $set['entity_id'] = "%{$count}"; - $params[$count] = array($entityID, 'Integer'); + $params[$count] = [$entityID, 'Integer']; $count++; $fieldNames = implode(',', CRM_Utils_Type::escapeAll(array_keys($set), 'MysqlColumnNameOrAlias')); @@ -276,7 +276,7 @@ public static function create(&$customParams) { } if (!empty($paramFieldsExtendContactForEntities)) { - CRM_Contact_BAO_Contact::updateGreetingsOnTokenFieldChange($paramFieldsExtendContactForEntities, array('contact_id' => $entityID)); + CRM_Contact_BAO_Contact::updateGreetingsOnTokenFieldChange($paramFieldsExtendContactForEntities, ['contact_id' => $entityID]); } } @@ -340,10 +340,10 @@ public static function fieldToSQLType($type, $maxLength = 255) { * @param int $entityID */ public static function store(&$params, $entityTable, $entityID) { - $cvParams = array(); + $cvParams = []; foreach ($params as $fieldID => $param) { foreach ($param as $index => $customValue) { - $cvParam = array( + $cvParam = [ 'entity_table' => $entityTable, 'entity_id' => $entityID, 'value' => $customValue['value'], @@ -354,7 +354,7 @@ public static function store(&$params, $entityTable, $entityID) { 'column_name' => $customValue['column_name'], 'is_multiple' => CRM_Utils_Array::value('is_multiple', $customValue), 'file_id' => $customValue['file_id'], - ); + ]; // Fix Date type to be timestamp, since that is how we store in db. if ($cvParam['type'] == 'Date') { @@ -365,11 +365,11 @@ public static function store(&$params, $entityTable, $entityID) { $cvParam['id'] = $customValue['id']; } if (!array_key_exists($customValue['table_name'], $cvParams)) { - $cvParams[$customValue['table_name']] = array(); + $cvParams[$customValue['table_name']] = []; } if (!array_key_exists($index, $cvParams[$customValue['table_name']])) { - $cvParams[$customValue['table_name']][$index] = array(); + $cvParams[$customValue['table_name']][$index] = []; } $cvParams[$customValue['table_name']][$index][] = $cvParam; @@ -431,7 +431,7 @@ public static function &getEntityValues($entityID, $entityType = NULL, $fieldIDs return NULL; } - $cond = array(); + $cond = []; if ($entityType) { $cond[] = "cg.extends IN ( '$entityType' )"; } @@ -471,12 +471,12 @@ public static function &getEntityValues($entityID, $entityType = NULL, $fieldIDs "; $dao = CRM_Core_DAO::executeQuery($query); - $select = $fields = $isMultiple = array(); + $select = $fields = $isMultiple = []; while ($dao->fetch()) { if (!array_key_exists($dao->table_name, $select)) { - $fields[$dao->table_name] = array(); - $select[$dao->table_name] = array(); + $fields[$dao->table_name] = []; + $select[$dao->table_name] = []; } $fields[$dao->table_name][] = $dao->fieldID; $select[$dao->table_name][] = "{$dao->column_name} AS custom_{$dao->fieldID}"; @@ -484,7 +484,7 @@ public static function &getEntityValues($entityID, $entityType = NULL, $fieldIDs $file[$dao->table_name][$dao->fieldID] = $dao->fieldDataType; } - $result = $sortedResult = array(); + $result = $sortedResult = []; foreach ($select as $tableName => $clauses) { if (!empty($DTparams['sort'])) { $query = CRM_Core_DAO::executeQuery("SELECT id FROM {$tableName} WHERE entity_id = {$entityID}"); @@ -545,27 +545,27 @@ public static function setValues(&$params) { // first collect all the id/value pairs. The format is: // custom_X => value or custom_X_VALUEID => value (for multiple values), VALUEID == -1, -2 etc for new insertions - $values = array(); - $fieldValues = array(); + $values = []; + $fieldValues = []; foreach ($params as $n => $v) { if ($customFieldInfo = CRM_Core_BAO_CustomField::getKeyID($n, TRUE)) { $fieldID = (int ) $customFieldInfo[0]; if (CRM_Utils_Type::escape($fieldID, 'Integer', FALSE) === NULL) { return CRM_Core_Error::createAPIError(ts('field ID needs to be of type Integer for index %1', - array(1 => $fieldID) + [1 => $fieldID] )); } if (!array_key_exists($fieldID, $fieldValues)) { - $fieldValues[$fieldID] = array(); + $fieldValues[$fieldID] = []; } $id = -1; if ($customFieldInfo[1]) { $id = (int ) $customFieldInfo[1]; } - $fieldValues[$fieldID][] = array( + $fieldValues[$fieldID][] = [ 'value' => $v, 'id' => $id, - ); + ]; } } @@ -587,7 +587,7 @@ public static function setValues(&$params) { "; $dao = CRM_Core_DAO::executeQuery($sql); - $cvParams = array(); + $cvParams = []; while ($dao->fetch()) { $dataType = $dao->data_type == 'Date' ? 'Timestamp' : $dao->data_type; @@ -617,14 +617,14 @@ public static function setValues(&$params) { // Ensure that value is of the right data type elseif (CRM_Utils_Type::escape($fieldValue['value'], $dataType, FALSE) === NULL) { return CRM_Core_Error::createAPIError(ts('value: %1 is not of the right field data type: %2', - array( + [ 1 => $fieldValue['value'], 2 => $dao->data_type, - ) + ] )); } - $cvParam = array( + $cvParam = [ 'entity_id' => $params['entityID'], 'value' => $fieldValue['value'], 'type' => $dataType, @@ -634,7 +634,7 @@ public static function setValues(&$params) { 'column_name' => $dao->column_name, 'is_multiple' => $dao->is_multiple, 'extends' => $dao->extends, - ); + ]; if (!empty($params['id'])) { $cvParam['id'] = $params['id']; @@ -645,11 +645,11 @@ public static function setValues(&$params) { } if (!array_key_exists($dao->table_name, $cvParams)) { - $cvParams[$dao->table_name] = array(); + $cvParams[$dao->table_name] = []; } if (!array_key_exists($fieldValue['id'], $cvParams[$dao->table_name])) { - $cvParams[$dao->table_name][$fieldValue['id']] = array(); + $cvParams[$dao->table_name][$fieldValue['id']] = []; } if ($fieldValue['id'] > 0) { @@ -661,7 +661,7 @@ public static function setValues(&$params) { if (!empty($cvParams)) { self::create($cvParams); - return array('is_error' => 0, 'result' => 1); + return ['is_error' => 0, 'result' => 1]; } return CRM_Core_Error::createAPIError(ts('Unknown error')); @@ -699,21 +699,21 @@ public static function &getValues(&$params) { // first collect all the ids. The format is: // custom_ID - $fieldIDs = array(); + $fieldIDs = []; foreach ($params as $n => $v) { $key = $idx = NULL; if (substr($n, 0, 7) == 'custom_') { $idx = substr($n, 7); if (CRM_Utils_Type::escape($idx, 'Integer', FALSE) === NULL) { return CRM_Core_Error::createAPIError(ts('field ID needs to be of type Integer for index %1', - array(1 => $idx) + [1 => $idx] )); } $fieldIDs[] = (int ) $idx; } } - $default = array('Contact', 'Individual', 'Household', 'Organization'); + $default = ['Contact', 'Individual', 'Household', 'Organization']; if (!($type = CRM_Utils_Array::value('entityType', $params)) || in_array($params['entityType'], $default) ) { @@ -742,17 +742,17 @@ public static function &getValues(&$params) { // note that this behaviour is undesirable from an API point of view - it should return an empty array // since this is also called by the merger code & not sure the consequences of changing // are just handling undoing this in the api layer. ie. converting the error back into a success - $result = array( + $result = [ 'is_error' => 1, 'error_message' => 'No values found for the specified entity ID and custom field(s).', - ); + ]; return $result; } else { - $result = array( + $result = [ 'is_error' => 0, 'entityID' => $params['entityID'], - ); + ]; foreach ($values as $id => $value) { $result["custom_{$id}"] = $value; } diff --git a/CRM/Core/BAO/Dashboard.php b/CRM/Core/BAO/Dashboard.php index 8550e6cafc43..1bfd6812d212 100644 --- a/CRM/Core/BAO/Dashboard.php +++ b/CRM/Core/BAO/Dashboard.php @@ -64,7 +64,7 @@ public static function create($params) { * array of dashlets */ public static function getDashlets($all = TRUE, $checkPermission = TRUE) { - $dashlets = array(); + $dashlets = []; $dao = new CRM_Core_DAO_Dashboard(); if (!$all) { @@ -79,7 +79,7 @@ public static function getDashlets($all = TRUE, $checkPermission = TRUE) { continue; } - $values = array(); + $values = []; CRM_Core_DAO::storeValues($dao, $values); $dashlets[$dao->id] = $values; } @@ -101,15 +101,15 @@ public static function getDashlets($all = TRUE, $checkPermission = TRUE) { */ public static function getContactDashlets($contactID = NULL) { $contactID = $contactID ? $contactID : CRM_Core_Session::getLoggedInContactID(); - $dashlets = array(); + $dashlets = []; // Get contact dashboard dashlets. - $results = civicrm_api3('DashboardContact', 'get', array( + $results = civicrm_api3('DashboardContact', 'get', [ 'contact_id' => $contactID, 'is_active' => 1, 'dashboard_id.is_active' => 1, - 'options' => array('sort' => 'weight', 'limit' => 0), - 'return' => array( + 'options' => ['sort' => 'weight', 'limit' => 0], + 'return' => [ 'id', 'weight', 'column_no', @@ -121,12 +121,12 @@ public static function getContactDashlets($contactID = NULL) { 'dashboard_id.cache_minutes', 'dashboard_id.permission', 'dashboard_id.permission_operator', - ), - )); + ], + ]); foreach ($results['values'] as $item) { if (self::checkPermission(CRM_Utils_Array::value('dashboard_id.permission', $item), CRM_Utils_Array::value('dashboard_id.permission_operator', $item))) { - $dashlets[$item['id']] = array( + $dashlets[$item['id']] = [ 'dashboard_id' => $item['dashboard_id'], 'weight' => $item['weight'], 'column_no' => $item['column_no'], @@ -135,14 +135,14 @@ public static function getContactDashlets($contactID = NULL) { 'url' => $item['dashboard_id.url'], 'cache_minutes' => $item['dashboard_id.cache_minutes'], 'fullscreen_url' => CRM_Utils_Array::value('dashboard_id.fullscreen_url', $item), - ); + ]; } } // If empty, then initialize default dashlets for this user. if (!$results['count']) { // They may just have disabled all their dashlets. Check if any records exist for this contact. - if (!civicrm_api3('DashboardContact', 'getcount', array('contact_id' => $contactID))) { + if (!civicrm_api3('DashboardContact', 'getcount', ['contact_id' => $contactID])) { $dashlets = self::initializeDashlets(); } } @@ -154,16 +154,16 @@ public static function getContactDashlets($contactID = NULL) { * @return array */ public static function getContactDashletsForJS() { - $data = array(array(), array()); + $data = [[], []]; foreach (self::getContactDashlets() as $item) { - $data[$item['column_no']][] = array( + $data[$item['column_no']][] = [ 'id' => (int) $item['dashboard_id'], 'name' => $item['name'], 'title' => $item['label'], 'url' => self::parseUrl($item['url']), 'cacheMinutes' => $item['cache_minutes'], 'fullscreenUrl' => self::parseUrl($item['fullscreen_url']), - ); + ]; } return $data; } @@ -179,23 +179,23 @@ public static function getContactDashletsForJS() { * @throws \CiviCRM_API3_Exception */ public static function initializeDashlets() { - $dashlets = array(); - $getDashlets = civicrm_api3("Dashboard", "get", array( + $dashlets = []; + $getDashlets = civicrm_api3("Dashboard", "get", [ 'domain_id' => CRM_Core_Config::domainID(), 'option.limit' => 0, - )); + ]); $contactID = CRM_Core_Session::getLoggedInContactID(); - $allDashlets = CRM_Utils_Array::index(array('name'), $getDashlets['values']); - $defaultDashlets = array(); - $defaults = array('blog' => 1, 'getting-started' => '0'); + $allDashlets = CRM_Utils_Array::index(['name'], $getDashlets['values']); + $defaultDashlets = []; + $defaults = ['blog' => 1, 'getting-started' => '0']; foreach ($defaults as $name => $column) { if (!empty($allDashlets[$name]) && !empty($allDashlets[$name]['id'])) { - $defaultDashlets[$name] = array( + $defaultDashlets[$name] = [ 'dashboard_id' => $allDashlets[$name]['id'], 'is_active' => 1, 'column_no' => $column, 'contact_id' => $contactID, - ); + ]; } } CRM_Utils_Hook::dashboard_defaults($allDashlets, $defaultDashlets); @@ -209,7 +209,7 @@ public static function initializeDashlets() { else { $assignDashlets = civicrm_api3("dashboard_contact", "create", $defaultDashlet); $values = $assignDashlets['values'][$assignDashlets['id']]; - $dashlets[$assignDashlets['id']] = array( + $dashlets[$assignDashlets['id']] = [ 'dashboard_id' => $values['dashboard_id'], 'weight' => $values['weight'], 'column_no' => $values['column_no'], @@ -218,7 +218,7 @@ public static function initializeDashlets() { 'cache_minutes' => $dashlet['cache_minutes'], 'url' => $dashlet['url'], 'fullscreen_url' => CRM_Utils_Array::value('fullscreen_url', $dashlet), - ); + ]; } } } @@ -271,10 +271,10 @@ public static function checkPermission($permission, $operator) { } // hack to handle case permissions - if (!$componentName && in_array($key, array( + if (!$componentName && in_array($key, [ 'access my cases and activities', 'access all cases and activities', - )) + ]) ) { $componentName = 'CiviCase'; } @@ -335,7 +335,7 @@ public static function saveDashletChanges($columns, $contactID = NULL) { throw new RuntimeException("Failed to determine contact ID"); } - $dashletIDs = array(); + $dashletIDs = []; if (is_array($columns)) { foreach ($columns as $colNo => $dashlets) { if (!is_int($colNo)) { @@ -428,7 +428,7 @@ public static function addContactDashlet($dashlet) { // if dashlet is created by admin then you need to add it all contacts. // else just add to contact who is creating this dashlet - $contactIDs = array(); + $contactIDs = []; if ($admin) { $query = "SELECT distinct( contact_id ) FROM civicrm_dashboard_contact"; @@ -475,7 +475,7 @@ public static function addContactDashlet($dashlet) { */ public static function addContactDashletToDashboard(&$params) { $valuesString = NULL; - $columns = array(); + $columns = []; foreach ($params as $dashboardIDs) { $contactID = CRM_Utils_Array::value('contact_id', $dashboardIDs); $dashboardID = CRM_Utils_Array::value('dashboard_id', $dashboardIDs); diff --git a/CRM/Core/BAO/Discount.php b/CRM/Core/BAO/Discount.php index f2f4faff0589..dfef62e32882 100644 --- a/CRM/Core/BAO/Discount.php +++ b/CRM/Core/BAO/Discount.php @@ -92,7 +92,7 @@ public static function add(&$params) { * option group Ids associated with discount */ public static function getOptionGroup($entityId, $entityTable) { - $optionGroupIDs = array(); + $optionGroupIDs = []; $dao = new CRM_Core_DAO_Discount(); $dao->entity_id = $entityId; $dao->entity_table = $entityTable; diff --git a/CRM/Core/BAO/Domain.php b/CRM/Core/BAO/Domain.php index fd2632785c01..bfbb06fc64ec 100644 --- a/CRM/Core/BAO/Domain.php +++ b/CRM/Core/BAO/Domain.php @@ -103,9 +103,9 @@ public static function version($skipUsingCache = FALSE) { public function &getLocationValues() { if ($this->_location == NULL) { $domain = self::getDomain(NULL); - $params = array( + $params = [ 'contact_id' => $domain->contact_id, - ); + ]; $this->_location = CRM_Core_BAO_Location::getValues($params, TRUE); if (empty($this->_location)) { @@ -182,17 +182,17 @@ public static function getNameAndEmail($skipFatal = FALSE, $returnString = FALSE $fromName = CRM_Utils_Array::value(1, $fromArray); break; } - return array($fromName, $email); + return [$fromName, $email]; } if ($skipFatal) { - return array(NULL, NULL); + return [NULL, NULL]; } $url = CRM_Utils_System::url('civicrm/admin/options/from_email_address', 'reset=1' ); - $status = ts("There is no valid default from email address configured for the domain. You can configure here Configure From Email Address.", array(1 => $url)); + $status = ts("There is no valid default from email address configured for the domain. You can configure here Configure From Email Address.", [1 => $url]); CRM_Core_Error::fatal($status); } @@ -206,7 +206,7 @@ public static function addContactToDomainGroup($contactID) { $groupID = self::getGroupId(); if ($groupID) { - $contactIDs = array($contactID); + $contactIDs = [$contactID]; CRM_Contact_BAO_GroupContact::addContactsToGroup($contactIDs, $groupID); return $groupID; @@ -257,7 +257,7 @@ public static function isDomainGroup($groupId) { */ public static function getChildGroupIds() { $domainGroupID = self::getGroupId(); - $childGrps = array(); + $childGrps = []; if ($domainGroupID) { $childGrps = CRM_Contact_BAO_GroupNesting::getChildGroupIds($domainGroupID); @@ -273,7 +273,7 @@ public static function getChildGroupIds() { */ public static function getContactList() { $siteGroups = CRM_Core_BAO_Domain::getChildGroupIds(); - $siteContacts = array(); + $siteContacts = []; if (!empty($siteGroups)) { $query = " @@ -296,18 +296,18 @@ public static function getContactList() { * Try default from address then fall back to using logged in user details */ public static function getDefaultReceiptFrom() { - $domain = civicrm_api3('domain', 'getsingle', array('id' => CRM_Core_Config::domainID())); + $domain = civicrm_api3('domain', 'getsingle', ['id' => CRM_Core_Config::domainID()]); if (!empty($domain['from_email'])) { - return array($domain['from_name'], $domain['from_email']); + return [$domain['from_name'], $domain['from_email']]; } if (!empty($domain['domain_email'])) { - return array($domain['name'], $domain['domain_email']); + return [$domain['name'], $domain['domain_email']]; } $userName = ''; $userEmail = ''; if (!Civi::settings()->get('allow_mail_from_logged_in_contact')) { - return array($userName, $userEmail); + return [$userName, $userEmail]; } $userID = CRM_Core_Session::singleton()->getLoggedInContactID(); @@ -316,7 +316,7 @@ public static function getDefaultReceiptFrom() { } // If still empty fall back to the logged in user details. // return empty values no matter what. - return array($userName, $userEmail); + return [$userName, $userEmail]; } /** diff --git a/CRM/Core/BAO/Email.php b/CRM/Core/BAO/Email.php index 7fac7ccfb92a..20c6875d6a68 100644 --- a/CRM/Core/BAO/Email.php +++ b/CRM/Core/BAO/Email.php @@ -151,25 +151,25 @@ public static function allEmails($id, $updateBlankLocInfo = FALSE) { LEFT JOIN civicrm_location_type ON ( civicrm_email.location_type_id = civicrm_location_type.id ) WHERE civicrm_contact.id = %1 ORDER BY civicrm_email.is_primary DESC, email_id ASC "; - $params = array( - 1 => array( + $params = [ + 1 => [ $id, 'Integer', - ), - ); + ], + ]; - $emails = $values = array(); + $emails = $values = []; $dao = CRM_Core_DAO::executeQuery($query, $params); $count = 1; while ($dao->fetch()) { - $values = array( + $values = [ 'locationType' => $dao->locationType, 'is_primary' => $dao->is_primary, 'on_hold' => $dao->on_hold, 'id' => $dao->email_id, 'email' => $dao->email, 'locationTypeId' => $dao->locationTypeId, - ); + ]; if ($updateBlankLocInfo) { $emails[$count++] = $values; @@ -207,24 +207,24 @@ public static function allEntityEmails(&$entityElements) { AND ltype.id = e.location_type_id ORDER BY e.is_primary DESC, email_id ASC "; - $params = array( - 1 => array( + $params = [ + 1 => [ $entityId, 'Integer', - ), - ); + ], + ]; - $emails = array(); + $emails = []; $dao = CRM_Core_DAO::executeQuery($sql, $params); while ($dao->fetch()) { - $emails[$dao->email_id] = array( + $emails[$dao->email_id] = [ 'locationType' => $dao->locationType, 'is_primary' => $dao->is_primary, 'on_hold' => $dao->on_hold, 'id' => $dao->email_id, 'email' => $dao->email, 'locationTypeId' => $dao->locationTypeId, - ); + ]; } return $emails; @@ -249,7 +249,7 @@ public static function holdEmail(&$email) { //check for update mode if ($email->id) { - $params = array(1 => array($email->id, 'Integer')); + $params = [1 => [$email->id, 'Integer']]; if ($email->on_hold) { $sql = " SELECT id @@ -291,7 +291,7 @@ public static function holdEmail(&$email) { * @return array $domainEmails; */ public static function domainEmails() { - $domainEmails = array(); + $domainEmails = []; $domainFrom = (array) CRM_Core_OptionGroup::values('from_email_address'); foreach (array_keys($domainFrom) as $k) { $domainEmail = $domainFrom[$k]; diff --git a/CRM/Core/BAO/EntityTag.php b/CRM/Core/BAO/EntityTag.php index 5af715734f07..e7ec387c7971 100644 --- a/CRM/Core/BAO/EntityTag.php +++ b/CRM/Core/BAO/EntityTag.php @@ -45,7 +45,7 @@ class CRM_Core_BAO_EntityTag extends CRM_Core_DAO_EntityTag { * reference $tag array of category id's the contact belongs to. */ public static function getTag($entityID, $entityTable = 'civicrm_contact') { - $tags = array(); + $tags = []; $entityTag = new CRM_Core_BAO_EntityTag(); $entityTag->entity_id = $entityID; @@ -89,7 +89,7 @@ public static function add(&$params) { //invoke post hook on entityTag // we are using this format to keep things consistent between the single and bulk operations // so a bit different from other post hooks - $object = array(0 => array(0 => $params['entity_id']), 1 => $params['entity_table']); + $object = [0 => [0 => $params['entity_id']], 1 => $params['entity_table']]; CRM_Utils_Hook::post('create', 'EntityTag', $params['tag_id'], $object); } return $entityTag; @@ -125,7 +125,7 @@ public static function del(&$params) { //invoke post hook on entityTag if (!empty($params['tag_id'])) { - $object = array(0 => array(0 => $params['entity_id']), 1 => $params['entity_table']); + $object = [0 => [0 => $params['entity_id']], 1 => $params['entity_table']]; CRM_Utils_Hook::post('delete', 'EntityTag', $params['tag_id'], $object); } } @@ -148,10 +148,10 @@ public static function del(&$params) { public static function addEntitiesToTag(&$entityIds, $tagId, $entityTable, $applyPermissions) { $numEntitiesAdded = 0; $numEntitiesNotAdded = 0; - $entityIdsAdded = array(); + $entityIdsAdded = []; //invoke pre hook for entityTag - $preObject = array($entityIds, $entityTable); + $preObject = [$entityIds, $entityTable]; CRM_Utils_Hook::pre('create', 'EntityTag', $tagId, $preObject); foreach ($entityIds as $entityId) { @@ -177,12 +177,12 @@ public static function addEntitiesToTag(&$entityIds, $tagId, $entityTable, $appl } //invoke post hook on entityTag - $object = array($entityIdsAdded, $entityTable); + $object = [$entityIdsAdded, $entityTable]; CRM_Utils_Hook::post('create', 'EntityTag', $tagId, $object); CRM_Contact_BAO_GroupContactCache::opportunisticCacheFlush(); - return array(count($entityIds), $numEntitiesAdded, $numEntitiesNotAdded); + return [count($entityIds), $numEntitiesAdded, $numEntitiesNotAdded]; } /** @@ -226,10 +226,10 @@ public static function checkPermissionOnEntityTag($entityID, $entityTable) { public static function removeEntitiesFromTag(&$entityIds, $tagId, $entityTable, $applyPermissions) { $numEntitiesRemoved = 0; $numEntitiesNotRemoved = 0; - $entityIdsRemoved = array(); + $entityIdsRemoved = []; //invoke pre hook for entityTag - $preObject = array($entityIds, $entityTable); + $preObject = [$entityIds, $entityTable]; CRM_Utils_Hook::pre('delete', 'EntityTag', $tagId, $preObject); foreach ($entityIds as $entityId) { @@ -255,12 +255,12 @@ public static function removeEntitiesFromTag(&$entityIds, $tagId, $entityTable, } //invoke post hook on entityTag - $object = array($entityIdsRemoved, $entityTable); + $object = [$entityIdsRemoved, $entityTable]; CRM_Utils_Hook::post('delete', 'EntityTag', $tagId, $object); CRM_Contact_BAO_GroupContactCache::opportunisticCacheFlush(); - return array(count($entityIds), $numEntitiesRemoved, $numEntitiesNotRemoved); + return [count($entityIds), $numEntitiesRemoved, $numEntitiesNotRemoved]; } /** @@ -280,12 +280,12 @@ public static function create(&$params, $entityTable, $entityID) { // this fix is done to prevent warning generated by array_key_exits incase of empty array is given as input if (!is_array($params)) { - $params = array(); + $params = []; } // this fix is done to prevent warning generated by array_key_exits incase of empty array is given as input if (!is_array($entityTag)) { - $entityTag = array(); + $entityTag = []; } // check which values has to be inserted/deleted for contact @@ -315,7 +315,7 @@ public static function create(&$params, $entityTable, $entityID) { * array of entity ids */ public function getEntitiesByTag($tag) { - $entityIds = array(); + $entityIds = []; $entityTagDAO = new CRM_Core_DAO_EntityTag(); $entityTagDAO->tag_id = $tag->id; $entityTagDAO->find(); @@ -334,7 +334,7 @@ public function getEntitiesByTag($tag) { * @return array */ public static function getContactTags($contactID, $count = FALSE) { - $contactTags = array(); + $contactTags = []; if (!$count) { $select = "SELECT ct.id, ct.name "; } @@ -373,7 +373,7 @@ public static function getContactTags($contactID, $count = FALSE) { * @return array */ public static function getChildEntityTags($parentId, $entityId, $entityTable = 'civicrm_contact') { - $entityTags = array(); + $entityTags = []; $query = "SELECT ct.id as tag_id, name FROM civicrm_tag ct INNER JOIN civicrm_entity_tag et ON ( et.entity_id = {$entityId} AND et.entity_table = '{$entityTable}' AND et.tag_id = ct.id) @@ -382,10 +382,10 @@ public static function getChildEntityTags($parentId, $entityId, $entityTable = ' $dao = CRM_Core_DAO::executeQuery($query); while ($dao->fetch()) { - $entityTags[$dao->tag_id] = array( + $entityTags[$dao->tag_id] = [ 'id' => $dao->tag_id, 'name' => $dao->name, - ); + ]; } return $entityTags; @@ -403,26 +403,26 @@ public static function getChildEntityTags($parentId, $entityId, $entityTable = ' * @return array */ public function mergeTags($tagAId, $tagBId) { - $queryParams = array( - 1 => array($tagAId, 'Integer'), - 2 => array($tagBId, 'Integer'), - ); + $queryParams = [ + 1 => [$tagAId, 'Integer'], + 2 => [$tagBId, 'Integer'], + ]; // re-compute used_for field $query = "SELECT id, name, used_for FROM civicrm_tag WHERE id IN (%1, %2)"; $dao = CRM_Core_DAO::executeQuery($query, $queryParams); - $tags = array(); + $tags = []; while ($dao->fetch()) { $label = ($dao->id == $tagAId) ? 'tagA' : 'tagB'; $tags[$label] = $dao->name; - $tags["{$label}_used_for"] = $dao->used_for ? explode(",", $dao->used_for) : array(); + $tags["{$label}_used_for"] = $dao->used_for ? explode(",", $dao->used_for) : []; } $usedFor = array_merge($tags["tagA_used_for"], $tags["tagB_used_for"]); $usedFor = implode(',', array_unique($usedFor)); $tags["used_for"] = explode(",", $usedFor); // get all merge queries together - $sqls = array( + $sqls = [ // 1. update entity tag entries "UPDATE IGNORE civicrm_entity_tag SET tag_id = %1 WHERE tag_id = %2", // 2. move children @@ -435,8 +435,8 @@ public function mergeTags($tagAId, $tagBId) { "DELETE et2.* from civicrm_entity_tag et1 INNER JOIN civicrm_entity_tag et2 ON et1.entity_table = et2.entity_table AND et1.entity_id = et2.entity_id AND et1.tag_id = et2.tag_id WHERE et1.id < et2.id", // 6. remove orphaned entity_tags "DELETE FROM civicrm_entity_tag WHERE tag_id = %2", - ); - $tables = array('civicrm_entity_tag', 'civicrm_tag'); + ]; + $tables = ['civicrm_entity_tag', 'civicrm_tag']; // Allow hook_civicrm_merge() to add SQL statements for the merge operation AND / OR // perform any other actions like logging @@ -467,8 +467,8 @@ public function mergeTags($tagAId, $tagBId) { * * @return array|bool */ - public static function buildOptions($fieldName, $context = NULL, $props = array()) { - $params = array(); + public static function buildOptions($fieldName, $context = NULL, $props = []) { + $params = []; if ($fieldName == 'tag' || $fieldName == 'tag_id') { if (!empty($props['entity_table'])) { @@ -479,7 +479,7 @@ public static function buildOptions($fieldName, $context = NULL, $props = array( // Output tag list as nested hierarchy // TODO: This will only work when api.entity is "entity_tag". What about others? if ($context == 'search' || $context == 'create') { - $dummyArray = array(); + $dummyArray = []; return CRM_Core_BAO_Tag::getTags(CRM_Utils_Array::value('entity_table', $props, 'civicrm_contact'), $dummyArray, CRM_Utils_Array::value('parent_id', $params), '- '); } } @@ -487,8 +487,8 @@ public static function buildOptions($fieldName, $context = NULL, $props = array( $options = CRM_Core_PseudoConstant::get(__CLASS__, $fieldName, $params, $context); // Special formatting for validate/match context - if ($fieldName == 'entity_table' && in_array($context, array('validate', 'match'))) { - $options = array(); + if ($fieldName == 'entity_table' && in_array($context, ['validate', 'match'])) { + $options = []; foreach (self::buildOptions($fieldName) as $tableName => $label) { $bao = CRM_Core_DAO_AllCoreTables::getClassForTable($tableName); $apiName = CRM_Core_DAO_AllCoreTables::getBriefName($bao); diff --git a/CRM/Core/BAO/Extension.php b/CRM/Core/BAO/Extension.php index 8f461189b2e7..8bbe63fffacf 100644 --- a/CRM/Core/BAO/Extension.php +++ b/CRM/Core/BAO/Extension.php @@ -82,10 +82,10 @@ public static function del($id) { */ public static function setSchemaVersion($fullName, $schemaVersion) { $sql = 'UPDATE civicrm_extension SET schema_version = %1 WHERE full_name = %2'; - $params = array( - 1 => array($schemaVersion, 'String'), - 2 => array($fullName, 'String'), - ); + $params = [ + 1 => [$schemaVersion, 'String'], + 2 => [$fullName, 'String'], + ]; return CRM_Core_DAO::executeQuery($sql, $params); } @@ -98,9 +98,9 @@ public static function setSchemaVersion($fullName, $schemaVersion) { */ public static function getSchemaVersion($fullName) { $sql = 'SELECT schema_version FROM civicrm_extension WHERE full_name = %1'; - $params = array( - 1 => array($fullName, 'String'), - ); + $params = [ + 1 => [$fullName, 'String'], + ]; return CRM_Core_DAO::singleValueQuery($sql, $params); } diff --git a/CRM/Core/BAO/File.php b/CRM/Core/BAO/File.php index 5e1a32def07b..8845687292fb 100644 --- a/CRM/Core/BAO/File.php +++ b/CRM/Core/BAO/File.php @@ -38,7 +38,7 @@ */ class CRM_Core_BAO_File extends CRM_Core_DAO_File { - static $_signableFields = array('entityTable', 'entityID', 'fileID'); + static $_signableFields = ['entityTable', 'entityID', 'fileID']; /** * Takes an associative array and creates a File object. @@ -87,12 +87,12 @@ public static function path($fileID, $entityID) { $path = $config->customFileUploadDir . $fileDAO->uri; if (file_exists($path) && is_readable($path)) { - return array($path, $fileDAO->mime_type); + return [$path, $fileDAO->mime_type]; } } } - return array(NULL, NULL); + return [NULL, NULL]; } @@ -235,7 +235,7 @@ public static function deleteFileReferences($fileID, $entityID, $fieldID) { // also set the value to null of the table and column $query = "UPDATE $tableName SET $columnName = null WHERE $columnName = %1"; - $params = array(1 => array($fileID, 'Integer')); + $params = [1 => [$fileID, 'Integer']]; CRM_Core_DAO::executeQuery($query, $params); } @@ -270,8 +270,8 @@ public static function deleteEntityFile($entityTable, $entityID, $fileTypeID = N list($sql, $params) = self::sql($entityTable, $entityID, $fileTypeID, $fileID); $dao = CRM_Core_DAO::executeQuery($sql, $params); - $cfIDs = array(); - $cefIDs = array(); + $cfIDs = []; + $cefIDs = []; while ($dao->fetch()) { $cfIDs[$dao->cfID] = $dao->uri; $cefIDs[] = $dao->cefID; @@ -286,13 +286,13 @@ public static function deleteEntityFile($entityTable, $entityID, $fileTypeID = N if (!empty($cfIDs)) { // Delete file only if there no any entity using this file. - $deleteFiles = array(); + $deleteFiles = []; foreach ($cfIDs as $fId => $fUri) { //delete tags from entity tag table - $tagParams = array( + $tagParams = [ 'entity_table' => 'civicrm_file', 'entity_id' => $fId, - ); + ]; CRM_Core_BAO_EntityTag::del($tagParams); @@ -331,7 +331,7 @@ public static function getEntityFile($entityTable, $entityID, $addDeleteArgs = F list($sql, $params) = self::sql($entityTable, $entityID, NULL); $dao = CRM_Core_DAO::executeQuery($sql, $params); - $results = array(); + $results = []; while ($dao->fetch()) { $fileHash = self::generateFileHash($dao->entity_id, $dao->cfID); $result['fileID'] = $dao->cfID; @@ -352,11 +352,11 @@ public static function getEntityFile($entityTable, $entityID, $addDeleteArgs = F } //fix tag names - $tags = CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE)); + $tags = CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', ['onlyActive' => FALSE]); foreach ($results as &$values) { if (!empty($values['tag'])) { - $tagNames = array(); + $tagNames = []; foreach ($values['tag'] as $tid) { $tagNames[] = $tags[$tid]; } @@ -411,22 +411,22 @@ public static function sql($entityTable, $entityID, $fileTypeID = NULL, $fileID AND CEF.entity_id = %2"; } - $params = array( - 1 => array($entityTable, 'String'), - 2 => array($entityID, 'Integer'), - ); + $params = [ + 1 => [$entityTable, 'String'], + 2 => [$entityID, 'Integer'], + ]; if ($fileTypeID !== NULL) { $sql .= " AND CF.file_type_id = %3"; - $params[3] = array($fileTypeID, 'Integer'); + $params[3] = [$fileTypeID, 'Integer']; } if ($fileID !== NULL) { $sql .= " AND CF.id = %4"; - $params[4] = array($fileID, 'Integer'); + $params[4] = [$fileID, 'Integer']; } - return array($sql, $params); + return [$sql, $params]; } /** @@ -483,25 +483,25 @@ public static function buildAttachment(&$form, $entityTable, $entityID = NULL, $ $form->setMaxFileSize($maxFileSize * 1024 * 1024); $form->addRule("attachFile_$i", ts('File size should be less than %1 MByte(s)', - array(1 => $maxFileSize) + [1 => $maxFileSize] ), 'maxfilesize', $maxFileSize * 1024 * 1024 ); - $form->addElement('text', "attachDesc_$i", NULL, array( + $form->addElement('text', "attachDesc_$i", NULL, [ 'size' => 40, 'maxlength' => 255, 'placeholder' => ts('Description'), - )); + ]); if (!empty($tags)) { $form->add('select', "tag_$i", ts('Tags'), $tags, FALSE, - array( + [ 'id' => "tags_$i", 'multiple' => 'multiple', 'class' => 'huge crm-select2', 'placeholder' => ts('- none -'), - ) + ] ); } CRM_Core_Form_Tag::buildQuickForm($form, $parentNames, 'civicrm_file', NULL, FALSE, TRUE, "file_taglist_$i"); @@ -529,7 +529,7 @@ public static function attachmentInfo($entityTable, $entityID, $separator = '
    $attach) { $currentAttachmentURL[] = $attach['href']; } @@ -566,7 +566,7 @@ public static function formatAttachment( $attachFreeTags = "file_taglist_$i"; if (isset($formValues[$attachName]) && !empty($formValues[$attachName])) { // add static tags if selects - $tagParams = array(); + $tagParams = []; if (!empty($formValues[$attachTags])) { foreach ($formValues[$attachTags] as $tag) { $tagParams[$tag] = 1; @@ -575,11 +575,11 @@ public static function formatAttachment( // we dont care if the file is empty or not // CRM-7448 - $extraParams = array( + $extraParams = [ 'description' => $formValues[$attachDesc], 'tag' => $tagParams, - 'attachment_taglist' => CRM_Utils_Array::value($attachFreeTags, $formValues, array()), - ); + 'attachment_taglist' => CRM_Utils_Array::value($attachFreeTags, $formValues, []), + ]; CRM_Utils_File::formatFile($formValues, $attachName, $extraParams); @@ -626,7 +626,7 @@ public static function processAttachment(&$params, $entityTable, $entityID) { public static function uploadNames() { $numAttachments = Civi::settings()->get('max_attachments'); - $names = array(); + $names = []; for ($i = 1; $i <= $numAttachments; $i++) { $names[] = "attachFile_{$i}"; } @@ -680,7 +680,7 @@ public static function deleteURLArgs($entityTable, $entityID, $fileID) { * */ public static function deleteAttachment() { - $params = array(); + $params = []; $params['entityTable'] = CRM_Utils_Request::retrieve('entityTable', 'String', CRM_Core_DAO::$_nullObject, TRUE); $params['entityID'] = CRM_Utils_Request::retrieve('entityID', 'Positive', CRM_Core_DAO::$_nullObject, TRUE); $params['fileID'] = CRM_Utils_Request::retrieve('fileID', 'Positive', CRM_Core_DAO::$_nullObject, TRUE); @@ -756,7 +756,7 @@ public static function paperIconAttachment($entityTable, $entityID) { * @return CRM_Core_FileSearchInterface|NULL */ public static function getSearchService() { - $fileSearches = array(); + $fileSearches = []; CRM_Utils_Hook::fileSearches($fileSearches); // use the first available search diff --git a/CRM/Core/BAO/FinancialTrxn.php b/CRM/Core/BAO/FinancialTrxn.php index f6ec9f6c65e5..ee5c3267c7d4 100644 --- a/CRM/Core/BAO/FinancialTrxn.php +++ b/CRM/Core/BAO/FinancialTrxn.php @@ -66,12 +66,12 @@ public static function create($params) { } // Save to entity_financial_trxn table. - $entityFinancialTrxnParams = array( + $entityFinancialTrxnParams = [ 'entity_table' => CRM_Utils_Array::value('entity_table', $params, 'civicrm_contribution'), 'entity_id' => CRM_Utils_Array::value('entity_id', $params, CRM_Utils_Array::value('contribution_id', $params)), 'financial_trxn_id' => $trxn->id, 'amount' => $params['total_amount'], - ); + ]; $entityTrxn = new CRM_Financial_DAO_EntityFinancialTrxn(); $entityTrxn->copyValues($entityFinancialTrxnParams); @@ -92,11 +92,11 @@ public static function getBalanceTrxnAmt($contributionId, $contributionFinancial $toFinancialAccount = CRM_Contribute_PseudoConstant::getRelationalFinancialAccount($contributionFinancialTypeId, 'Accounts Receivable Account is'); $q = "SELECT ft.id, ft.total_amount FROM civicrm_financial_trxn ft INNER JOIN civicrm_entity_financial_trxn eft ON (eft.financial_trxn_id = ft.id AND eft.entity_table = 'civicrm_contribution') WHERE eft.entity_id = %1 AND ft.to_financial_account_id = %2"; - $p[1] = array($contributionId, 'Integer'); - $p[2] = array($toFinancialAccount, 'Integer'); + $p[1] = [$contributionId, 'Integer']; + $p[2] = [$toFinancialAccount, 'Integer']; $balanceAmtDAO = CRM_Core_DAO::executeQuery($q, $p); - $ret = array(); + $ret = []; if ($balanceAmtDAO->N) { $ret['total_amount'] = 0; } @@ -145,9 +145,9 @@ public static function retrieve(&$params, &$defaults) { * */ public static function getFinancialTrxnId($entity_id, $orderBy = 'ASC', $newTrxn = FALSE, $whereClause = '', $fromAccountID = NULL) { - $ids = array('entityFinancialTrxnId' => NULL, 'financialTrxnId' => NULL); + $ids = ['entityFinancialTrxnId' => NULL, 'financialTrxnId' => NULL]; - $params = array(1 => array($entity_id, 'Integer')); + $params = [1 => [$entity_id, 'Integer']]; $condition = ""; if (!$newTrxn) { $condition = " AND ((ceft1.entity_table IS NOT NULL) OR (cft.payment_instrument_id IS NOT NULL AND ceft1.entity_table IS NULL)) "; @@ -155,7 +155,7 @@ public static function getFinancialTrxnId($entity_id, $orderBy = 'ASC', $newTrxn if ($fromAccountID) { $condition .= " AND (cft.from_financial_account_id <> %2 OR cft.from_financial_account_id IS NULL)"; - $params[2] = array($fromAccountID, 'Integer'); + $params[2] = [$fromAccountID, 'Integer']; } if ($orderBy) { $orderBy = CRM_Utils_Type::escape($orderBy, 'String'); @@ -222,7 +222,7 @@ public static function getFinancialTrxnTotal($entity_id) { WHERE ft.entity_table = 'civicrm_contribution' AND ft.entity_id = %1 "; - $sqlParams = array(1 => array($entity_id, 'Integer')); + $sqlParams = [1 => [$entity_id, 'Integer']]; return CRM_Core_DAO::singleValueQuery($query, $sqlParams); } @@ -255,10 +255,10 @@ public static function getPayments($financial_trxn_id) { AND ef2.entity_table = 'civicrm_financial_trxn' AND ef1.entity_table = 'civicrm_financial_trxn'"; - $sqlParams = array(1 => array($financial_trxn_id, 'Integer')); + $sqlParams = [1 => [$financial_trxn_id, 'Integer']]; $dao = CRM_Core_DAO::executeQuery($query, $sqlParams); $i = 0; - $result = array(); + $result = []; while ($dao->fetch()) { $result[$i]['financial_trxn_id'] = $dao->financial_trxn_id; $result[$i]['amount'] = $dao->amount; @@ -267,7 +267,7 @@ public static function getPayments($financial_trxn_id) { if (empty($result)) { $query = "SELECT sum( amount ) amount FROM civicrm_entity_financial_trxn WHERE financial_trxn_id =%1 AND entity_table = 'civicrm_financial_item'"; - $sqlParams = array(1 => array($financial_trxn_id, 'Integer')); + $sqlParams = [1 => [$financial_trxn_id, 'Integer']]; $dao = CRM_Core_DAO::executeQuery($query, $sqlParams); if ($dao->fetch()) { @@ -297,7 +297,7 @@ public static function getFinancialTrxnLineTotal($entity_id, $entity_table = 'ci LEFT JOIN civicrm_line_item AS lt ON lt.id = fi.entity_id AND lt.entity_table = %2 WHERE lt.entity_id = %1 "; - $sqlParams = array(1 => array($entity_id, 'Integer'), 2 => array($entity_table, 'String')); + $sqlParams = [1 => [$entity_id, 'Integer'], 2 => [$entity_table, 'String']]; $dao = CRM_Core_DAO::executeQuery($query, $sqlParams); while ($dao->fetch()) { $result[$dao->financial_trxn_id][$dao->id] = $dao->amount; @@ -326,7 +326,7 @@ public static function deleteFinancialTrxn($entity_id) { LEFT JOIN civicrm_financial_item cfi ON ceft1.entity_table = 'civicrm_financial_item' and cfi.id = ceft1.entity_id WHERE ceft.entity_id = %1"; - CRM_Core_DAO::executeQuery($query, array(1 => array($entity_id, 'Integer'))); + CRM_Core_DAO::executeQuery($query, [1 => [$entity_id, 'Integer']]); return TRUE; } @@ -350,7 +350,7 @@ public static function createPremiumTrxn($params) { $contributionStatuses = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name'); $toFinancialAccountType = !empty($params['isDeleted']) ? 'Premiums Inventory Account is' : 'Cost of Sales Account is'; $fromFinancialAccountType = !empty($params['isDeleted']) ? 'Cost of Sales Account is' : 'Premiums Inventory Account is'; - $financialtrxn = array( + $financialtrxn = [ 'to_financial_account_id' => CRM_Contribute_PseudoConstant::getRelationalFinancialAccount($params['financial_type_id'], $toFinancialAccountType), 'from_financial_account_id' => CRM_Contribute_PseudoConstant::getRelationalFinancialAccount($params['financial_type_id'], $fromFinancialAccountType), 'trxn_date' => date('YmdHis'), @@ -359,23 +359,23 @@ public static function createPremiumTrxn($params) { 'status_id' => array_search('Completed', $contributionStatuses), 'entity_table' => 'civicrm_contribution', 'entity_id' => $params['contributionId'], - ); + ]; CRM_Core_BAO_FinancialTrxn::create($financialtrxn); } if (!empty($params['oldPremium'])) { - $premiumParams = array( + $premiumParams = [ 'id' => $params['oldPremium']['product_id'], - ); - $productDetails = array(); + ]; + $productDetails = []; CRM_Contribute_BAO_Product::retrieve($premiumParams, $productDetails); - $params = array( + $params = [ 'cost' => CRM_Utils_Array::value('cost', $productDetails), 'currency' => CRM_Utils_Array::value('currency', $productDetails), 'financial_type_id' => CRM_Utils_Array::value('financial_type_id', $productDetails), 'contributionId' => $params['oldPremium']['contribution_id'], 'isDeleted' => TRUE, - ); + ]; CRM_Core_BAO_FinancialTrxn::createPremiumTrxn($params); } } @@ -420,7 +420,7 @@ public static function recordFees($params) { $params['entity_id'] = $financialTrxnID['financialTrxnId']; } $fItemParams - = array( + = [ 'financial_account_id' => $financialAccount, 'contact_id' => CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Domain', $domainId, 'contact_id'), 'created_date' => date('YmdHis'), @@ -431,7 +431,7 @@ public static function recordFees($params) { 'entity_table' => 'civicrm_financial_trxn', 'entity_id' => $params['entity_id'], 'currency' => $params['trxnParams']['currency'], - ); + ]; $trxnIDS['id'] = $trxn->id; CRM_Financial_BAO_FinancialItem::create($fItemParams, NULL, $trxnIDS); } @@ -514,10 +514,10 @@ public static function getTotalPayments($contributionID, $includeRefund = FALSE) * @return array */ public static function getMembershipRevenueAmount($lineItem) { - $revenueAmount = array(); - $membershipDetail = civicrm_api3('Membership', 'getsingle', array( + $revenueAmount = []; + $membershipDetail = civicrm_api3('Membership', 'getsingle', [ 'id' => $lineItem['entity_id'], - )); + ]); if (empty($membershipDetail['end_date'])) { return $revenueAmount; } @@ -570,7 +570,7 @@ public static function createDeferredTrxn($lineItems, $contributionDetails, $upd ) { return; } - $trxnParams = array( + $trxnParams = [ 'contribution_id' => $contributionDetails->id, 'fee_amount' => '0.00', 'currency' => $contributionDetails->currency, @@ -578,9 +578,9 @@ public static function createDeferredTrxn($lineItems, $contributionDetails, $upd 'status_id' => $contributionDetails->contribution_status_id, 'payment_instrument_id' => $contributionDetails->payment_instrument_id, 'check_number' => $contributionDetails->check_number, - ); + ]; - $deferredRevenues = array(); + $deferredRevenues = []; foreach ($lineItems as $priceSetID => $lineItem) { if (!$priceSetID) { continue; @@ -595,12 +595,12 @@ public static function createDeferredTrxn($lineItems, $contributionDetails, $upd $deferredRevenues[$key]['financial_type_id'] = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_LineItem', $item['id'], 'financial_type_id'); } if (in_array($item['entity_table'], - array('civicrm_participant', 'civicrm_contribution')) + ['civicrm_participant', 'civicrm_contribution']) ) { - $deferredRevenues[$key]['revenue'][] = array( + $deferredRevenues[$key]['revenue'][] = [ 'amount' => $lineTotal, 'revenue_date' => $revenueRecognitionDate, - ); + ]; } else { // for membership @@ -614,11 +614,11 @@ public static function createDeferredTrxn($lineItems, $contributionDetails, $upd CRM_Utils_Hook::alterDeferredRevenueItems($deferredRevenues, $contributionDetails, $update, $context); foreach ($deferredRevenues as $key => $deferredRevenue) { - $results = civicrm_api3('EntityFinancialAccount', 'get', array( + $results = civicrm_api3('EntityFinancialAccount', 'get', [ 'entity_table' => 'civicrm_financial_type', 'entity_id' => $deferredRevenue['financial_type_id'], - 'account_relationship' => array('IN' => array('Income Account is', 'Deferred Revenue Account is')), - )); + 'account_relationship' => ['IN' => ['Income Account is', 'Deferred Revenue Account is']], + ]); if ($results['count'] != 2) { continue; } @@ -634,12 +634,12 @@ public static function createDeferredTrxn($lineItems, $contributionDetails, $upd $trxnParams['total_amount'] = $trxnParams['net_amount'] = $revenue['amount']; $trxnParams['trxn_date'] = CRM_Utils_Date::isoToMysql($revenue['revenue_date']); $financialTxn = CRM_Core_BAO_FinancialTrxn::create($trxnParams); - $entityParams = array( + $entityParams = [ 'entity_id' => $deferredRevenue['financial_item_id'], 'entity_table' => 'civicrm_financial_item', 'amount' => $revenue['amount'], 'financial_trxn_id' => $financialTxn->id, - ); + ]; civicrm_api3('EntityFinancialTrxn', 'create', $entityParams); } } @@ -655,13 +655,13 @@ public static function createDeferredTrxn($lineItems, $contributionDetails, $upd * */ public static function updateCreditCardDetails($contributionID, $panTruncation, $cardType) { - $financialTrxn = civicrm_api3('EntityFinancialTrxn', 'get', array( - 'return' => array('financial_trxn_id.payment_processor_id', 'financial_trxn_id'), + $financialTrxn = civicrm_api3('EntityFinancialTrxn', 'get', [ + 'return' => ['financial_trxn_id.payment_processor_id', 'financial_trxn_id'], 'entity_table' => 'civicrm_contribution', 'entity_id' => $contributionID, 'financial_trxn_id.is_payment' => TRUE, - 'options' => array('sort' => 'financial_trxn_id DESC', 'limit' => 1), - )); + 'options' => ['sort' => 'financial_trxn_id DESC', 'limit' => 1], + ]); // In case of Contribution status is Pending From Incomplete Transaction or Failed there is no Financial Entries created for Contribution. // Above api will return 0 count, in such case we won't update card type and pan truncation field. @@ -677,7 +677,7 @@ public static function updateCreditCardDetails($contributionID, $panTruncation, } $financialTrxnId = $financialTrxn['financial_trxn_id']; - $trxnparams = array('id' => $financialTrxnId); + $trxnparams = ['id' => $financialTrxnId]; if (isset($cardType)) { $trxnparams['card_type_id'] = $cardType; } @@ -714,19 +714,19 @@ public static function updateFinancialAccountsOnPaymentInstrumentChange($inputPa // If payment instrument is changed reverse the last payment // in terms of reversing financial item and trxn - $lastFinancialTrxn = civicrm_api3('FinancialTrxn', 'getsingle', array('id' => $lastFinancialTrxnId['financialTrxnId'])); + $lastFinancialTrxn = civicrm_api3('FinancialTrxn', 'getsingle', ['id' => $lastFinancialTrxnId['financialTrxnId']]); unset($lastFinancialTrxn['id']); $lastFinancialTrxn['trxn_date'] = $inputParams['trxnParams']['trxn_date']; $lastFinancialTrxn['total_amount'] = -$inputParams['trxnParams']['total_amount']; $lastFinancialTrxn['net_amount'] = -$inputParams['trxnParams']['net_amount']; $lastFinancialTrxn['fee_amount'] = -$inputParams['trxnParams']['fee_amount']; $lastFinancialTrxn['contribution_id'] = $prevContribution->id; - foreach (array($lastFinancialTrxn, $inputParams['trxnParams']) as $financialTrxnParams) { + foreach ([$lastFinancialTrxn, $inputParams['trxnParams']] as $financialTrxnParams) { $trxn = CRM_Core_BAO_FinancialTrxn::create($financialTrxnParams); - $trxnParams = array( + $trxnParams = [ 'total_amount' => $trxn->total_amount, 'contribution_id' => $currentContribution->id, - ); + ]; CRM_Contribute_BAO_Contribution::assignProportionalLineItems($trxnParams, $trxn->id, $prevContribution->total_amount); } diff --git a/CRM/Core/BAO/IM.php b/CRM/Core/BAO/IM.php index 1fdfe6cd66fb..a64d22341ede 100644 --- a/CRM/Core/BAO/IM.php +++ b/CRM/Core/BAO/IM.php @@ -98,20 +98,20 @@ public static function allIMs($id, $updateBlankLocInfo = FALSE) { civicrm_contact.id = %1 ORDER BY civicrm_im.is_primary DESC, im_id ASC "; - $params = array(1 => array($id, 'Integer')); + $params = [1 => [$id, 'Integer']]; - $ims = $values = array(); + $ims = $values = []; $dao = CRM_Core_DAO::executeQuery($query, $params); $count = 1; while ($dao->fetch()) { - $values = array( + $values = [ 'locationType' => $dao->locationType, 'is_primary' => $dao->is_primary, 'id' => $dao->im_id, 'name' => $dao->im, 'locationTypeId' => $dao->locationTypeId, 'providerId' => $dao->providerId, - ); + ]; if ($updateBlankLocInfo) { $ims[$count++] = $values; @@ -147,18 +147,18 @@ public static function allEntityIMs(&$entityElements) { AND ltype.id = cim.location_type_id ORDER BY cim.is_primary DESC, im_id ASC "; - $params = array(1 => array($entityId, 'Integer')); + $params = [1 => [$entityId, 'Integer']]; - $ims = array(); + $ims = []; $dao = CRM_Core_DAO::executeQuery($sql, $params); while ($dao->fetch()) { - $ims[$dao->im_id] = array( + $ims[$dao->im_id] = [ 'locationType' => $dao->locationType, 'is_primary' => $dao->is_primary, 'id' => $dao->im_id, 'name' => $dao->im, 'locationTypeId' => $dao->locationTypeId, - ); + ]; } return $ims; } diff --git a/CRM/Core/BAO/Job.php b/CRM/Core/BAO/Job.php index fddea464ae86..0b9a32272c7b 100644 --- a/CRM/Core/BAO/Job.php +++ b/CRM/Core/BAO/Job.php @@ -152,14 +152,14 @@ public static function cleanup($maxEntriesToKeep = 1000, $minDaysToKeep = 30) { * * @return CRM_Core_DAO */ - public static function copy($id, $params = array()) { - $fieldsFix = array( - 'suffix' => array( + public static function copy($id, $params = []) { + $fieldsFix = [ + 'suffix' => [ 'name' => ' - ' . ts('Copy'), - ), + ], 'replace' => $params, - ); - $copy = &CRM_Core_DAO::copyGeneric('CRM_Core_DAO_Job', array('id' => $id), NULL, $fieldsFix); + ]; + $copy = &CRM_Core_DAO::copyGeneric('CRM_Core_DAO_Job', ['id' => $id], NULL, $fieldsFix); $copy->save(); CRM_Utils_Hook::copy('Job', $copy); diff --git a/CRM/Core/BAO/LabelFormat.php b/CRM/Core/BAO/LabelFormat.php index 3690980e7745..96c4ffbf6202 100644 --- a/CRM/Core/BAO/LabelFormat.php +++ b/CRM/Core/BAO/LabelFormat.php @@ -45,112 +45,112 @@ class CRM_Core_BAO_LabelFormat extends CRM_Core_DAO_OptionValue { /** * Label Format fields stored in the 'value' field of the Option Value table. */ - private static $optionValueFields = array( - 'paper-size' => array( + private static $optionValueFields = [ + 'paper-size' => [ // Paper size: names defined in option_value table (option_group = 'paper_size') 'name' => 'paper-size', 'type' => CRM_Utils_Type::T_STRING, 'default' => 'letter', - ), - 'orientation' => array( + ], + 'orientation' => [ // Paper orientation: 'portrait' or 'landscape' 'name' => 'orientation', 'type' => CRM_Utils_Type::T_STRING, 'default' => 'portrait', - ), - 'font-name' => array( + ], + 'font-name' => [ // Font name: 'courier', 'helvetica', 'times' 'name' => 'font-name', 'type' => CRM_Utils_Type::T_STRING, 'default' => 'helvetica', - ), - 'font-size' => array( + ], + 'font-size' => [ // Font size: always in points 'name' => 'font-size', 'type' => CRM_Utils_Type::T_INT, 'default' => 8, - ), - 'font-style' => array( + ], + 'font-style' => [ // Font style: 'B' bold, 'I' italic, 'BI' bold+italic 'name' => 'font-style', 'type' => CRM_Utils_Type::T_STRING, 'default' => '', - ), - 'NX' => array( + ], + 'NX' => [ // Number of labels horizontally 'name' => 'NX', 'type' => CRM_Utils_Type::T_INT, 'default' => 3, - ), - 'NY' => array( + ], + 'NY' => [ // Number of labels vertically 'name' => 'NY', 'type' => CRM_Utils_Type::T_INT, 'default' => 10, - ), - 'metric' => array( + ], + 'metric' => [ // Unit of measurement for all of the following fields 'name' => 'metric', 'type' => CRM_Utils_Type::T_STRING, 'default' => 'mm', - ), - 'lMargin' => array( + ], + 'lMargin' => [ // Left margin 'name' => 'lMargin', 'type' => CRM_Utils_Type::T_FLOAT, 'metric' => TRUE, 'default' => 4.7625, - ), - 'tMargin' => array( + ], + 'tMargin' => [ // Right margin 'name' => 'tMargin', 'type' => CRM_Utils_Type::T_FLOAT, 'metric' => TRUE, 'default' => 12.7, - ), - 'SpaceX' => array( + ], + 'SpaceX' => [ // Horizontal space between two labels 'name' => 'SpaceX', 'type' => CRM_Utils_Type::T_FLOAT, 'metric' => TRUE, 'default' => 3.96875, - ), - 'SpaceY' => array( + ], + 'SpaceY' => [ // Vertical space between two labels 'name' => 'SpaceY', 'type' => CRM_Utils_Type::T_FLOAT, 'metric' => TRUE, 'default' => 0, - ), - 'width' => array( + ], + 'width' => [ // Width of label 'name' => 'width', 'type' => CRM_Utils_Type::T_FLOAT, 'metric' => TRUE, 'default' => 65.875, - ), - 'height' => array( + ], + 'height' => [ // Height of label 'name' => 'height', 'type' => CRM_Utils_Type::T_FLOAT, 'metric' => TRUE, 'default' => 25.4, - ), - 'lPadding' => array( + ], + 'lPadding' => [ // Space between text and left edge of label 'name' => 'lPadding', 'type' => CRM_Utils_Type::T_FLOAT, 'metric' => TRUE, 'default' => 5.08, - ), - 'tPadding' => array( + ], + 'tPadding' => [ // Space between text and top edge of label 'name' => 'tPadding', 'type' => CRM_Utils_Type::T_FLOAT, 'metric' => TRUE, 'default' => 5.08, - ), - ); + ], + ]; /** * Get page orientations recognized by the DOMPDF package used to create PDF letters. @@ -159,10 +159,10 @@ class CRM_Core_BAO_LabelFormat extends CRM_Core_DAO_OptionValue { * array of page orientations */ public static function getPageOrientations() { - return array( + return [ 'portrait' => ts('Portrait'), 'landscape' => ts('Landscape'), - ); + ]; } /** @@ -186,9 +186,9 @@ public static function getFontNames($name = 'label_format') { * array of font sizes */ public static function getFontSizes() { - $fontSizes = array(); + $fontSizes = []; for ($i = 6; $i <= 60; $i++) { - $fontSizes[$i] = ts('%1 pt', array(1 => $i)); + $fontSizes[$i] = ts('%1 pt', [1 => $i]); } return $fontSizes; @@ -201,12 +201,12 @@ public static function getFontSizes() { * array of measurement units */ public static function getUnits() { - return array( + return [ 'in' => ts('Inches'), 'cm' => ts('Centimeters'), 'mm' => ts('Millimeters'), 'pt' => ts('Points'), - ); + ]; } /** @@ -216,11 +216,11 @@ public static function getUnits() { * array of alignments */ public static function getTextAlignments() { - return array( + return [ 'R' => ts('Right'), 'L' => ts('Left'), 'C' => ts('Center'), - ); + ]; } /** @@ -230,11 +230,11 @@ public static function getTextAlignments() { * array of alignments */ public static function getFontStyles() { - return array( + return [ '' => ts('Normal'), 'B' => ts('Bold'), 'I' => ts('Italic'), - ); + ]; } /** @@ -283,7 +283,7 @@ public static function addOrder(&$list, $returnURL) { * (reference) label format list */ public static function &getList($namesOnly = FALSE, $groupName = 'label_format') { - static $list = array(); + static $list = []; if (self::_getGid($groupName)) { // get saved label formats from Option Value table $dao = new CRM_Core_DAO_OptionValue(); @@ -313,13 +313,13 @@ public static function &getList($namesOnly = FALSE, $groupName = 'label_format') * Name/value pairs containing the default Label Format values. */ public static function &getDefaultValues($groupName = 'label_format') { - $params = array('is_active' => 1, 'is_default' => 1); - $defaults = array(); + $params = ['is_active' => 1, 'is_default' => 1]; + $defaults = []; if (!self::retrieve($params, $defaults, $groupName)) { foreach (self::$optionValueFields as $name => $field) { $defaults[$name] = $field['default']; } - $filter = array('option_group_id' => self::_getGid($groupName)); + $filter = ['option_group_id' => self::_getGid($groupName)]; $defaults['weight'] = CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_OptionValue', $filter); } return $defaults; @@ -339,8 +339,8 @@ public static function &getDefaultValues($groupName = 'label_format') { * (reference) associative array of name/value pairs */ public static function &getLabelFormat($field, $val, $groupName = 'label_format') { - $params = array('is_active' => 1, $field => $val); - $labelFormat = array(); + $params = ['is_active' => 1, $field => $val]; + $labelFormat = []; if (self::retrieve($params, $labelFormat, $groupName)) { return $labelFormat; } @@ -519,7 +519,7 @@ public function saveLabelFormat(&$values, $id = NULL, $groupName = 'label_format $this->save(); // fix duplicate weights - $filter = array('option_group_id' => self::_getGid()); + $filter = ['option_group_id' => self::_getGid()]; CRM_Utils_Weight::correctDuplicateWeights('CRM_Core_DAO_OptionValue', $filter); } @@ -537,7 +537,7 @@ public static function del($id, $groupName) { $dao->id = $id; if ($dao->find(TRUE)) { if ($dao->option_group_id == self::_getGid($groupName)) { - $filter = array('option_group_id' => self::_getGid($groupName)); + $filter = ['option_group_id' => self::_getGid($groupName)]; CRM_Utils_Weight::delWeight('CRM_Core_DAO_OptionValue', $id, $filter); $dao->delete(); return; diff --git a/CRM/Core/BAO/Location.php b/CRM/Core/BAO/Location.php index 99b8758540fc..0cd00b5763c5 100644 --- a/CRM/Core/BAO/Location.php +++ b/CRM/Core/BAO/Location.php @@ -39,7 +39,7 @@ class CRM_Core_BAO_Location extends CRM_Core_DAO { /** * Location block element array. */ - static $blocks = array('phone', 'email', 'im', 'openid', 'address'); + static $blocks = ['phone', 'email', 'im', 'openid', 'address']; /** * Create various elements of location block. @@ -55,7 +55,7 @@ class CRM_Core_BAO_Location extends CRM_Core_DAO { * @return array */ public static function create(&$params, $fixAddress = TRUE, $entity = NULL) { - $location = array(); + $location = []; if (!self::dataExists($params)) { return $location; } @@ -72,10 +72,10 @@ public static function create(&$params, $fixAddress = TRUE, $entity = NULL) { if ($entity) { // this is a special case for adding values in location block table - $entityElements = array( + $entityElements = [ 'entity_table' => $params['entity_table'], 'entity_id' => $params['entity_id'], - ); + ]; $location['id'] = self::createLocBlock($location, $entityElements); } @@ -102,18 +102,18 @@ public static function create(&$params, $fixAddress = TRUE, $entity = NULL) { */ public static function createLocBlock(&$location, &$entityElements) { $locId = self::findExisting($entityElements); - $locBlock = array(); + $locBlock = []; if ($locId) { $locBlock['id'] = $locId; } - foreach (array( + foreach ([ 'phone', 'email', 'im', 'address', - ) as $loc) { + ] as $loc) { $locBlock["{$loc}_id"] = !empty($location["$loc"][0]) ? $location["$loc"][0]->id : NULL; $locBlock["{$loc}_2_id"] = !empty($location["$loc"][1]) ? $location["$loc"][1]->id : NULL; } @@ -150,7 +150,7 @@ public static function findExisting($entityElements) { FROM {$etable} e WHERE e.id = %1"; - $params = array(1 => array($eid, 'Integer')); + $params = [1 => [$eid, 'Integer']]; $dao = CRM_Core_DAO::executeQuery($query, $params); while ($dao->fetch()) { $locBlockId = $dao->locId; @@ -192,7 +192,7 @@ public static function deleteLocBlock($locBlockId) { $locBlock->find(TRUE); //resolve conflict of having same ids for multiple blocks - $store = array( + $store = [ 'IM_1' => $locBlock->im_id, 'IM_2' => $locBlock->im_2_id, 'Email_1' => $locBlock->email_id, @@ -201,7 +201,7 @@ public static function deleteLocBlock($locBlockId) { 'Phone_2' => $locBlock->phone_2_id, 'Address_1' => $locBlock->address_id, 'Address_2' => $locBlock->address_2_id, - ); + ]; $locBlock->delete(); foreach ($store as $daoName => $id) { if ($id) { @@ -249,12 +249,12 @@ public static function &getValues($entityBlock, $microformat = FALSE) { if (empty($entityBlock)) { return NULL; } - $blocks = array(); - $name_map = array( + $blocks = []; + $name_map = [ 'im' => 'IM', 'openid' => 'OpenID', - ); - $blocks = array(); + ]; + $blocks = []; //get all the blocks for this contact foreach (self::$blocks as $block) { if (array_key_exists($block, $name_map)) { @@ -293,9 +293,9 @@ public static function deleteLocationBlocks($contactId, $locationTypeId) { $locationTypeId = 'null'; } - static $blocks = array('Address', 'Phone', 'IM', 'OpenID', 'Email'); + static $blocks = ['Address', 'Phone', 'IM', 'OpenID', 'Email']; - $params = array('contact_id' => $contactId, 'location_type_id' => $locationTypeId); + $params = ['contact_id' => $contactId, 'location_type_id' => $locationTypeId]; foreach ($blocks as $name) { CRM_Core_BAO_Block::blockDelete($name, $params); } @@ -314,13 +314,13 @@ public static function deleteLocationBlocks($contactId, $locationTypeId) { */ public static function copyLocBlock($locBlockId, $updateLocBlockId = NULL) { //get the location info. - $defaults = $updateValues = array(); - $locBlock = array('id' => $locBlockId); + $defaults = $updateValues = []; + $locBlock = ['id' => $locBlockId]; CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_LocBlock', $locBlock, $defaults); if ($updateLocBlockId) { //get the location info for update. - $copyLocationParams = array('id' => $updateLocBlockId); + $copyLocationParams = ['id' => $updateLocBlockId]; CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_LocBlock', $copyLocationParams, $updateValues); foreach ($updateValues as $key => $value) { if ($key != 'id') { @@ -336,16 +336,16 @@ public static function copyLocBlock($locBlockId, $updateLocBlockId = NULL) { $name = ucfirst($tbl[0]); $updateParams = NULL; if ($updateId = CRM_Utils_Array::value($key, $updateValues)) { - $updateParams = array('id' => $updateId); + $updateParams = ['id' => $updateId]; } - $copy = CRM_Core_DAO::copyGeneric('CRM_Core_DAO_' . $name, array('id' => $value), $updateParams); + $copy = CRM_Core_DAO::copyGeneric('CRM_Core_DAO_' . $name, ['id' => $value], $updateParams); $copyLocationParams[$key] = $copy->id; } } $copyLocation = &CRM_Core_DAO::copyGeneric('CRM_Core_DAO_LocBlock', - array('id' => $locBlock['id']), + ['id' => $locBlock['id']], $copyLocationParams ); return $copyLocation->id; @@ -363,16 +363,16 @@ public static function checkPrimaryBlocks($contactId) { } // get the loc block ids. - $primaryLocBlockIds = CRM_Contact_BAO_Contact::getLocBlockIds($contactId, array('is_primary' => 1)); - $nonPrimaryBlockIds = CRM_Contact_BAO_Contact::getLocBlockIds($contactId, array('is_primary' => 0)); + $primaryLocBlockIds = CRM_Contact_BAO_Contact::getLocBlockIds($contactId, ['is_primary' => 1]); + $nonPrimaryBlockIds = CRM_Contact_BAO_Contact::getLocBlockIds($contactId, ['is_primary' => 0]); - foreach (array( + foreach ([ 'Email', 'IM', 'Phone', 'Address', 'OpenID', - ) as $block) { + ] as $block) { $name = strtolower($block); if (array_key_exists($name, $primaryLocBlockIds) && !CRM_Utils_System::isNull($primaryLocBlockIds[$name]) @@ -407,10 +407,10 @@ public static function checkPrimaryBlocks($contactId) { */ public static function getChainSelectValues($values, $valueType, $flatten = FALSE) { if (!$values) { - return array(); + return []; } $values = array_filter((array) $values); - $elements = array(); + $elements = []; $list = &$elements; $method = $valueType == 'country' ? 'stateProvinceForCountry' : 'countyForState'; foreach ($values as $val) { @@ -429,17 +429,17 @@ public static function getChainSelectValues($values, $valueType, $flatten = FALS else { // Option-groups for multiple categories if ($result && count($values) > 1) { - $elements[] = array( + $elements[] = [ 'value' => CRM_Core_PseudoConstant::$valueType($val, FALSE), - 'children' => array(), - ); + 'children' => [], + ]; $list = &$elements[count($elements) - 1]['children']; } foreach ($result as $id => $name) { - $list[] = array( + $list[] = [ 'value' => $name, 'key' => $id, - ); + ]; } } } diff --git a/CRM/Core/BAO/LocationType.php b/CRM/Core/BAO/LocationType.php index 00c92b4c6bab..269284ccca6e 100644 --- a/CRM/Core/BAO/LocationType.php +++ b/CRM/Core/BAO/LocationType.php @@ -92,8 +92,8 @@ public static function setIsActive($id, $is_active) { */ public static function &getDefault() { if (self::$_defaultLocationType == NULL) { - $params = array('is_default' => 1); - $defaults = array(); + $params = ['is_default' => 1]; + $defaults = []; self::$_defaultLocationType = self::retrieve($params, $defaults); } return self::$_defaultLocationType; @@ -106,7 +106,7 @@ public static function &getDefault() { */ public static function getBilling() { if (self::$_billingLocationType == NULL) { - $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', array(), 'validate'); + $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id', [], 'validate'); self::$_billingLocationType = array_search('Billing', $locationTypes); } return self::$_billingLocationType; @@ -147,7 +147,7 @@ public static function create(&$params) { * */ public static function del($locationTypeId) { - $entity = array('address', 'phone', 'email', 'im'); + $entity = ['address', 'phone', 'email', 'im']; //check dependencies foreach ($entity as $key) { if ($key == 'im') { diff --git a/CRM/Core/BAO/Log.php b/CRM/Core/BAO/Log.php index 10b3eb3b1bab..a22a4c1eef87 100644 --- a/CRM/Core/BAO/Log.php +++ b/CRM/Core/BAO/Log.php @@ -57,12 +57,12 @@ public static function &lastModified($id, $table = 'civicrm_contact') { if ($log->modified_id) { list($displayName, $contactImage) = CRM_Contact_BAO_Contact::getDisplayAndImage($log->modified_id); } - $result = array( + $result = [ 'id' => $log->modified_id, 'name' => $displayName, 'image' => $contactImage, 'date' => $log->modified_date, - ); + ]; } return $result; } @@ -94,7 +94,7 @@ public static function register( $userID = NULL ) { if (!self::$_processed) { - self::$_processed = array(); + self::$_processed = []; } if (!$userID) { @@ -128,7 +128,7 @@ public static function register( self::$_processed[$contactID][$userID] = 1; } else { - self::$_processed[$contactID] = array($userID => 1); + self::$_processed[$contactID] = [$userID => 1]; } $logData = "$tableName,$tableID"; @@ -183,8 +183,8 @@ public static function useLoggingReport() { $loggingSchema = new CRM_Logging_Schema(); if ($loggingSchema->isEnabled()) { - $params = array('report_id' => 'logging/contact/summary'); - $instance = array(); + $params = ['report_id' => 'logging/contact/summary']; + $instance = []; CRM_Report_BAO_ReportInstance::retrieve($params, $instance); if (!empty($instance) && diff --git a/CRM/Core/BAO/MailSettings.php b/CRM/Core/BAO/MailSettings.php index c5ec789a770a..05168c3e3ac0 100644 --- a/CRM/Core/BAO/MailSettings.php +++ b/CRM/Core/BAO/MailSettings.php @@ -51,7 +51,7 @@ public function __construct() { * DAO with the default mail settings set */ public static function defaultDAO($reset = FALSE) { - static $mailSettings = array(); + static $mailSettings = []; $domainID = CRM_Core_Config::domainID(); if (empty($mailSettings[$domainID]) || $reset) { $dao = new self(); @@ -151,7 +151,7 @@ public static function add(&$params) { //handle is_default. if (!empty($params['is_default'])) { $query = 'UPDATE civicrm_mail_settings SET is_default = 0 WHERE domain_id = %1'; - $queryParams = array(1 => array(CRM_Core_Config::domainID(), 'Integer')); + $queryParams = [1 => [CRM_Core_Config::domainID(), 'Integer']]; CRM_Core_DAO::executeQuery($query, $queryParams); } diff --git a/CRM/Core/BAO/Mapping.php b/CRM/Core/BAO/Mapping.php index faccc831cb68..ccf17e6b7904 100644 --- a/CRM/Core/BAO/Mapping.php +++ b/CRM/Core/BAO/Mapping.php @@ -115,14 +115,14 @@ public static function add($params) { * Array of mapping names, keyed by id. */ public static function getMappings($mappingType) { - $result = civicrm_api3('Mapping', 'get', array( + $result = civicrm_api3('Mapping', 'get', [ 'mapping_type_id' => $mappingType, - 'options' => array( + 'options' => [ 'sort' => 'name', 'limit' => 0, - ), - )); - $mapping = array(); + ], + ]); + $mapping = []; foreach ($result['values'] as $key => $value) { $mapping[$key] = $value['name']; @@ -151,13 +151,13 @@ public static function getCreateMappingValues($mappingType) { // it feels like there could be other instances so this is safer. $errorParams = $e->getExtraParams(); if ($errorParams['error_field'] === 'mapping_type_id') { - $mappingValues = civicrm_api3('Mapping', 'getoptions', array('field' => 'mapping_type_id')); - civicrm_api3('OptionValue', 'create', array( + $mappingValues = civicrm_api3('Mapping', 'getoptions', ['field' => 'mapping_type_id']); + civicrm_api3('OptionValue', 'create', [ 'option_group_id' => 'mapping_type', 'label' => $mappingType, 'value' => max(array_keys($mappingValues['values'])) + 1, 'is_reserved' => 1, - )); + ]); return CRM_Core_BAO_Mapping::getMappings($mappingType); } throw $e; @@ -184,8 +184,8 @@ public static function getMappingFields($mappingId, $addPrimary = FALSE) { $mapping->orderBy('column_number'); $mapping->find(); - $mappingName = $mappingLocation = $mappingContactType = $mappingPhoneType = array(); - $mappingImProvider = $mappingRelation = $mappingOperator = $mappingValue = $mappingWebsiteType = array(); + $mappingName = $mappingLocation = $mappingContactType = $mappingPhoneType = []; + $mappingImProvider = $mappingRelation = $mappingOperator = $mappingValue = $mappingWebsiteType = []; while ($mapping->fetch()) { $mappingName[$mapping->grouping][$mapping->column_number] = $mapping->name; $mappingContactType[$mapping->grouping][$mapping->column_number] = $mapping->contact_type; @@ -228,7 +228,7 @@ public static function getMappingFields($mappingId, $addPrimary = FALSE) { } } - return array( + return [ $mappingName, $mappingContactType, $mappingLocation, @@ -238,7 +238,7 @@ public static function getMappingFields($mappingId, $addPrimary = FALSE) { $mappingOperator, $mappingValue, $mappingWebsiteType, - ); + ]; } /** @@ -268,7 +268,7 @@ public static function checkMapping($nameField, $mapTypeId) { * associated array of elements */ public static function getFormattedFields($smartGroupId) { - $returnFields = array(); + $returnFields = []; //get the fields from mapping table $dao = new CRM_Core_DAO_MappingField(); @@ -303,14 +303,14 @@ public static function getFormattedFields($smartGroupId) { */ public static function buildMappingForm(&$form, $mappingType, $mappingId, $columnNo, $blockCount, $exportMode = NULL) { - $hasLocationTypes = array(); - $hasRelationTypes = array(); - $fields = array(); + $hasLocationTypes = []; + $hasRelationTypes = []; + $fields = []; //get the saved mapping details if ($mappingType == 'Export') { - $columnCount = array('1' => $columnNo); + $columnCount = ['1' => $columnNo]; $form->applyFilter('saveMappingName', 'trim'); //to save the current mappings @@ -322,8 +322,8 @@ public static function buildMappingForm(&$form, $mappingType, $mappingId, $colum else { $form->assign('loadedMapping', $mappingId); - $params = array('id' => $mappingId); - $temp = array(); + $params = ['id' => $mappingId]; + $temp = []; $mappingDetails = CRM_Core_BAO_Mapping::retrieve($params, $temp); $form->assign('savedName', $mappingDetails->name); @@ -336,17 +336,17 @@ public static function buildMappingForm(&$form, $mappingType, $mappingId, $colum $form->add('text', 'saveMappingDesc', ts('Description')); } - $form->addElement('checkbox', 'saveMapping', $saveDetailsName, NULL, array('onclick' => "showSaveDetails(this)")); - $form->addFormRule(array('CRM_Export_Form_Map', 'formRule'), $form->get('mappingTypeId')); + $form->addElement('checkbox', 'saveMapping', $saveDetailsName, NULL, ['onclick' => "showSaveDetails(this)"]); + $form->addFormRule(['CRM_Export_Form_Map', 'formRule'], $form->get('mappingTypeId')); } elseif ($mappingType == 'Search Builder') { $columnCount = $columnNo; $form->addElement('submit', 'addBlock', ts('Also include contacts where'), - array('class' => 'submit-link') + ['class' => 'submit-link'] ); } - $contactType = array('Individual', 'Household', 'Organization'); + $contactType = ['Individual', 'Household', 'Organization']; foreach ($contactType as $value) { if ($mappingType == 'Search Builder') { // get multiple custom group fields in this context @@ -361,7 +361,7 @@ public static function buildMappingForm(&$form, $mappingType, $mappingId, $colum $fields[$value] = CRM_Core_BAO_Address::validateAddressOptions($contactFields); ksort($fields[$value]); if ($mappingType == 'Export') { - $relationships = array(); + $relationships = []; $relationshipTypes = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, NULL, NULL, $value, TRUE); asort($relationshipTypes); @@ -378,7 +378,7 @@ public static function buildMappingForm(&$form, $mappingType, $mappingId, $colum if (!empty($relationships)) { $fields[$value] = array_merge($fields[$value], - array('related' => array('title' => ts('- related contact info -'))), + ['related' => ['title' => ts('- related contact info -')]], $relationships ); } @@ -391,15 +391,15 @@ public static function buildMappingForm(&$form, $mappingType, $mappingId, $colum } // add component fields - $compArray = array(); + $compArray = []; //we need to unset groups, tags, notes for component export if ($exportMode != CRM_Export_Form_Select::CONTACT_EXPORT) { - foreach (array( + foreach ([ 'groups', 'tags', 'notes', - ) as $value) { + ] as $value) { unset($fields['Individual'][$value]); unset($fields['Household'][$value]); unset($fields['Organization'][$value]); @@ -408,7 +408,7 @@ public static function buildMappingForm(&$form, $mappingType, $mappingId, $colum if ($mappingType == 'Search Builder') { //build the common contact fields array. - $fields['Contact'] = array(); + $fields['Contact'] = []; foreach ($fields['Individual'] as $key => $value) { if (!empty($fields['Household'][$key]) && !empty($fields['Organization'][$key])) { $fields['Contact'][$key] = $value; @@ -420,11 +420,11 @@ public static function buildMappingForm(&$form, $mappingType, $mappingId, $colum if (array_key_exists('note', $fields['Contact'])) { $noteTitle = $fields['Contact']['note']['title']; $fields['Contact']['note']['title'] = $noteTitle . ': ' . ts('Body and Subject'); - $fields['Contact']['note_body'] = array('title' => $noteTitle . ': ' . ts('Body Only'), 'name' => 'note_body'); - $fields['Contact']['note_subject'] = array( + $fields['Contact']['note_body'] = ['title' => $noteTitle . ': ' . ts('Body Only'), 'name' => 'note_body']; + $fields['Contact']['note_subject'] = [ 'title' => $noteTitle . ': ' . ts('Subject Only'), 'name' => 'note_subject', - ); + ]; } } @@ -442,9 +442,9 @@ public static function buildMappingForm(&$form, $mappingType, $mappingId, $colum //get the component payment fields // @todo - review this - inconsistent with other entities & hacky. if ($exportMode == CRM_Export_Form_Select::EVENT_EXPORT) { - $componentPaymentFields = array(); + $componentPaymentFields = []; foreach (CRM_Export_BAO_Export::componentPaymentFields() as $payField => $payTitle) { - $componentPaymentFields[$payField] = array('title' => $payTitle); + $componentPaymentFields[$payField] = ['title' => $payTitle]; } $fields['Participant'] = array_merge($fields['Participant'], $componentPaymentFields); } @@ -497,12 +497,12 @@ public static function buildMappingForm(&$form, $mappingType, $mappingId, $colum } //Contact Sub Type For export - $contactSubTypes = array(); + $contactSubTypes = []; $subTypes = CRM_Contact_BAO_ContactType::subTypeInfo(); foreach ($subTypes as $subType => $val) { //adding subtype specific relationships CRM-5256 - $csRelationships = array(); + $csRelationships = []; if ($mappingType == 'Export') { $subTypeRelationshipTypes @@ -571,19 +571,19 @@ public static function buildMappingForm(&$form, $mappingType, $mappingId, $colum if ($defaultLocationType) { $defaultLocation = $locationTypes[$defaultLocationType->id]; unset($locationTypes[$defaultLocationType->id]); - $locationTypes = array($defaultLocationType->id => $defaultLocation) + $locationTypes; + $locationTypes = [$defaultLocationType->id => $defaultLocation] + $locationTypes; } - $locationTypes = array(' ' => ts('Primary')) + $locationTypes; + $locationTypes = [' ' => ts('Primary')] + $locationTypes; // since we need a hierarchical list to display contact types & subtypes, // this is what we going to display in first selector $contactTypes = CRM_Contact_BAO_ContactType::getSelectElements(FALSE, FALSE); if ($mappingType == 'Search Builder') { - $contactTypes = array('Contact' => ts('Contacts')) + $contactTypes; + $contactTypes = ['Contact' => ts('Contacts')] + $contactTypes; } - $sel1 = array('' => ts('- select record type -')) + $contactTypes + $compArray; + $sel1 = ['' => ts('- select record type -')] + $contactTypes + $compArray; foreach ($sel1 as $key => $sel) { if ($key) { @@ -592,7 +592,7 @@ public static function buildMappingForm(&$form, $mappingType, $mappingId, $colum if (!in_array($key, $contactType)) { asort($mapperFields[$key]); } - $sel2[$key] = array('' => ts('- select field -')) + $mapperFields[$key]; + $sel2[$key] = ['' => ts('- select field -')] + $mapperFields[$key]; } } @@ -636,11 +636,11 @@ public static function buildMappingForm(&$form, $mappingType, $mappingId, $colum if (isset($hasRelationTypes[$k][$field])) { list($id, $first, $second) = explode('_', $field); // FIX ME: For now let's not expose custom data related to relationship - $relationshipCustomFields = array(); + $relationshipCustomFields = []; //$relationshipCustomFields = self::getRelationTypeCustomGroupData( $id ); //asort($relationshipCustomFields); - $relatedFields = array(); + $relatedFields = []; $relationshipType = new CRM_Contact_BAO_RelationshipType(); $relationshipType->id = $id; if ($relationshipType->find(TRUE)) { @@ -699,7 +699,7 @@ public static function buildMappingForm(&$form, $mappingType, $mappingId, $colum } //special fields that have location, hack for primary location - $specialFields = array( + $specialFields = [ 'street_address', 'supplemental_address_1', 'supplemental_address_2', @@ -714,7 +714,7 @@ public static function buildMappingForm(&$form, $mappingType, $mappingId, $colum 'phone', 'email', 'im', - ); + ]; if (isset($mappingId)) { list($mappingName, $mappingContactType, $mappingLocation, $mappingPhoneType, $mappingImProvider, @@ -741,13 +741,13 @@ public static function buildMappingForm(&$form, $mappingType, $mappingId, $colum $form->set('blockCount', $form->_blockCount); $form->set('columnCount', $form->_columnCount); - $defaults = $noneArray = $nullArray = array(); + $defaults = $noneArray = $nullArray = []; for ($x = 1; $x < $blockCount; $x++) { for ($i = 0; $i < $columnCount[$x]; $i++) { - $sel = &$form->addElement('hierselect', "mapper[$x][$i]", ts('Mapper for Field %1', array(1 => $i)), NULL); + $sel = &$form->addElement('hierselect', "mapper[$x][$i]", ts('Mapper for Field %1', [1 => $i]), NULL); $jsSet = FALSE; if (isset($mappingId)) { @@ -763,7 +763,7 @@ public static function buildMappingForm(&$form, $mappingType, $mappingId, $colum $relPhoneType = isset($mappingPhoneType[$x][$i]) ? $mappingPhoneType[$x][$i] : NULL; - $defaults["mapper[$x][$i]"] = array( + $defaults["mapper[$x][$i]"] = [ $mappingContactType[$x][$i], $mappingRelation[$x][$i], $locationId, @@ -771,24 +771,24 @@ public static function buildMappingForm(&$form, $mappingType, $mappingId, $colum $mappingName[$x][$i], $relLocationId, $relPhoneType, - ); + ]; if (!$locationId) { - $noneArray[] = array($x, $i, 2); + $noneArray[] = [$x, $i, 2]; } if (!$phoneType && !$imProvider) { - $noneArray[] = array($x, $i, 3); + $noneArray[] = [$x, $i, 3]; } if (!$mappingName[$x][$i]) { - $noneArray[] = array($x, $i, 4); + $noneArray[] = [$x, $i, 4]; } if (!$relLocationId) { - $noneArray[] = array($x, $i, 5); + $noneArray[] = [$x, $i, 5]; } if (!$relPhoneType) { - $noneArray[] = array($x, $i, 6); + $noneArray[] = [$x, $i, 6]; } - $noneArray[] = array($x, $i, 2); + $noneArray[] = [$x, $i, 2]; } else { $phoneType = isset($mappingPhoneType[$x][$i]) ? $mappingPhoneType[$x][$i] : NULL; @@ -797,25 +797,25 @@ public static function buildMappingForm(&$form, $mappingType, $mappingId, $colum $locationId = " "; } - $defaults["mapper[$x][$i]"] = array( + $defaults["mapper[$x][$i]"] = [ $mappingContactType[$x][$i], $mappingName[$x][$i], $locationId, $phoneType, - ); + ]; if (!$mappingName[$x][$i]) { - $noneArray[] = array($x, $i, 1); + $noneArray[] = [$x, $i, 1]; } if (!$locationId) { - $noneArray[] = array($x, $i, 2); + $noneArray[] = [$x, $i, 2]; } if (!$phoneType && !$imProvider) { - $noneArray[] = array($x, $i, 3); + $noneArray[] = [$x, $i, 3]; } - $noneArray[] = array($x, $i, 4); - $noneArray[] = array($x, $i, 5); - $noneArray[] = array($x, $i, 6); + $noneArray[] = [$x, $i, 4]; + $noneArray[] = [$x, $i, 5]; + $noneArray[] = [$x, $i, 6]; } $jsSet = TRUE; @@ -843,7 +843,7 @@ public static function buildMappingForm(&$form, $mappingType, $mappingId, $colum if (empty($formValues)) { // Incremented length for third select box(relationship type) for ($k = 1; $k < $j; $k++) { - $noneArray[] = array($x, $i, $k); + $noneArray[] = [$x, $i, $k]; } } else { @@ -853,17 +853,17 @@ public static function buildMappingForm(&$form, $mappingType, $mappingId, $colum if (!isset($formValues['mapper'][$x][$i][$k]) || (!$formValues['mapper'][$x][$i][$k]) ) { - $noneArray[] = array($x, $i, $k); + $noneArray[] = [$x, $i, $k]; } else { - $nullArray[] = array($x, $i, $k); + $nullArray[] = [$x, $i, $k]; } } } } else { for ($k = 1; $k < $j; $k++) { - $noneArray[] = array($x, $i, $k); + $noneArray[] = [$x, $i, $k]; } } } @@ -875,23 +875,23 @@ public static function buildMappingForm(&$form, $mappingType, $mappingId, $colum isset($formValues['mapper'][$x][$i][1]) && array_key_exists($formValues['mapper'][$x][$i][1], $relationshipTypes) ) { - $sel->setOptions(array($sel1, $sel2, $sel5, $sel6, $sel7, $sel3, $sel4)); + $sel->setOptions([$sel1, $sel2, $sel5, $sel6, $sel7, $sel3, $sel4]); } else { - $sel->setOptions(array($sel1, $sel2, $sel3, $sel4, $sel5, $sel6, $sel7)); + $sel->setOptions([$sel1, $sel2, $sel3, $sel4, $sel5, $sel6, $sel7]); } } else { - $sel->setOptions(array($sel1, $sel2, $sel3, $sel4, $sel5, $sel6, $sel7)); + $sel->setOptions([$sel1, $sel2, $sel3, $sel4, $sel5, $sel6, $sel7]); } } else { - $sel->setOptions(array($sel1, $sel2, $sel3, $sel4)); + $sel->setOptions([$sel1, $sel2, $sel3, $sel4]); } if ($mappingType == 'Search Builder') { //CRM -2292, restricted array set - $operatorArray = array('' => ts('-operator-')) + CRM_Core_SelectValues::getSearchBuilderOperators(); + $operatorArray = ['' => ts('-operator-')] + CRM_Core_SelectValues::getSearchBuilderOperators(); $form->add('select', "operator[$x][$i]", '', $operatorArray); $form->add('text', "value[$x][$i]", ''); @@ -905,7 +905,7 @@ public static function buildMappingForm(&$form, $mappingType, $mappingId, $colum $title = ts('Select more fields'); } - $form->addElement('submit', "addMore[$x]", $title, array('class' => 'submit-link')); + $form->addElement('submit', "addMore[$x]", $title, ['class' => 'submit-link']); } //end of block for @@ -913,8 +913,8 @@ public static function buildMappingForm(&$form, $mappingType, $mappingId, $colum $formName = "document." . (($mappingType == 'Export') ? 'Map' : 'Builder'); if (!empty($nullArray)) { $js .= "var nullArray = ["; - $elements = array(); - $seen = array(); + $elements = []; + $seen = []; foreach ($nullArray as $element) { $key = "{$element[0]}, {$element[1]}, {$element[2]}"; if (!isset($seen[$key])) { @@ -934,8 +934,8 @@ public static function buildMappingForm(&$form, $mappingType, $mappingId, $colum } if (!empty($noneArray)) { $js .= "var noneArray = ["; - $elements = array(); - $seen = array(); + $elements = []; + $seen = []; foreach ($noneArray as $element) { $key = "{$element[0]}, {$element[1]}, {$element[2]}"; if (!isset($seen[$key])) { @@ -976,7 +976,7 @@ public static function buildMappingForm(&$form, $mappingType, $mappingId, $colum public function getRelationTypeCustomGroupData($relationshipTypeId) { $customFields = CRM_Core_BAO_CustomField::getFields('Relationship', NULL, NULL, $relationshipTypeId, NULL, NULL); - $groupTitle = array(); + $groupTitle = []; foreach ($customFields as $krelation => $vrelation) { $groupTitle[$vrelation['label']] = $vrelation['groupTitle'] . '...' . $vrelation['label']; } @@ -1017,20 +1017,20 @@ public static function getCustomGroupName($customfieldId) { * formatted associated array of elements */ public static function formattedFields(&$params, $row = FALSE) { - $fields = array(); + $fields = []; if (empty($params) || !isset($params['mapper'])) { return $fields; } - $types = array('Individual', 'Organization', 'Household'); + $types = ['Individual', 'Organization', 'Household']; foreach ($params['mapper'] as $key => $value) { $contactType = NULL; foreach ($value as $k => $v) { if (in_array($v[0], $types)) { if ($contactType && $contactType != $v[0]) { CRM_Core_Error::fatal(ts("Cannot have two clauses with different types: %1, %2", - array(1 => $contactType, 2 => $v[0]) + [1 => $contactType, 2 => $v[0]] )); } $contactType = $v[0]; @@ -1060,7 +1060,7 @@ public static function formattedFields(&$params, $row = FALSE) { // CRM-14983: verify if values are comma separated convert to array if (!is_array($value) && strstr($params['operator'][$key][$k], 'IN')) { $value = explode(',', $value); - $value = array($params['operator'][$key][$k] => $value); + $value = [$params['operator'][$key][$k] => $value]; } // CRM-19081 Fix legacy StateProvince Field Values. // These derive from smart groups created using search builder under older @@ -1070,45 +1070,45 @@ public static function formattedFields(&$params, $row = FALSE) { } if ($row) { - $fields[] = array( + $fields[] = [ $fldName, $params['operator'][$key][$k], $value, $key, $k, - ); + ]; } else { - $fields[] = array( + $fields[] = [ $fldName, $params['operator'][$key][$k], $value, $key, 0, - ); + ]; } } } if ($contactType) { - $fields[] = array( + $fields[] = [ 'contact_type', '=', $contactType, $key, 0, - ); + ]; } } //add sortByCharacter values if (isset($params['sortByCharacter'])) { - $fields[] = array( + $fields[] = [ 'sortByCharacter', '=', $params['sortByCharacter'], 0, 0, - ); + ]; } return $fields; } @@ -1119,11 +1119,11 @@ public static function formattedFields(&$params, $row = FALSE) { * @return array */ public static function &returnProperties(&$params) { - $fields = array( + $fields = [ 'contact_type' => 1, 'contact_sub_type' => 1, 'sort_name' => 1, - ); + ]; if (empty($params) || empty($params['mapper'])) { return $fields; @@ -1139,13 +1139,13 @@ public static function &returnProperties(&$params) { if (isset($v[2]) && is_numeric($v[2])) { if (!array_key_exists('location', $fields)) { - $fields['location'] = array(); + $fields['location'] = []; } // make sure that we have a location fields and a location type for this $locationName = $locationTypes[$v[2]]; if (!array_key_exists($locationName, $fields['location'])) { - $fields['location'][$locationName] = array(); + $fields['location'][$locationName] = []; $fields['location'][$locationName]['location_type'] = $v[2]; } diff --git a/CRM/Core/BAO/MessageTemplate.php b/CRM/Core/BAO/MessageTemplate.php index d9fa8f2f7c7f..31a6f7369fd1 100644 --- a/CRM/Core/BAO/MessageTemplate.php +++ b/CRM/Core/BAO/MessageTemplate.php @@ -157,7 +157,7 @@ public static function del($messageTemplatesID) { SET msg_template_id = NULL WHERE msg_template_id = %1"; - $params = array(1 => array($messageTemplatesID, 'Integer')); + $params = [1 => [$messageTemplatesID, 'Integer']]; CRM_Core_DAO::executeQuery($query, $params); $messageTemplates = new CRM_Core_DAO_MessageTemplate(); @@ -177,7 +177,7 @@ public static function del($messageTemplatesID) { * @return object */ public static function getMessageTemplates($all = TRUE, $isSMS = FALSE) { - $msgTpls = array(); + $msgTpls = []; $messageTemplates = new CRM_Core_DAO_MessageTemplate(); $messageTemplates->is_active = 1; @@ -209,7 +209,7 @@ public static function sendReminder($contactId, $email, $messageTemplateID, $fro $domain = CRM_Core_BAO_Domain::getDomain(); $result = NULL; - $hookTokens = array(); + $hookTokens = []; if ($messageTemplates->find(TRUE)) { $body_text = $messageTemplates->msg_text; @@ -219,7 +219,7 @@ public static function sendReminder($contactId, $email, $messageTemplateID, $fro $body_text = CRM_Utils_String::htmlToText($body_html); } - $params = array(array('contact_id', '=', $contactId, 0, 0)); + $params = [['contact_id', '=', $contactId, 0, 0]]; list($contact, $_) = CRM_Contact_BAO_Query::apiQuery($params); //CRM-4524 @@ -237,13 +237,13 @@ public static function sendReminder($contactId, $email, $messageTemplateID, $fro CRM_Utils_Token::getTokens($body_subject)); // get replacement text for these tokens - $returnProperties = array("preferred_mail_format" => 1); + $returnProperties = ["preferred_mail_format" => 1]; if (isset($tokens['contact'])) { foreach ($tokens['contact'] as $key => $value) { $returnProperties[$value] = 1; } } - list($details) = CRM_Utils_Token::getTokenDetails(array($contactId), + list($details) = CRM_Utils_Token::getTokenDetails([$contactId], $returnProperties, NULL, NULL, FALSE, $tokens, @@ -251,12 +251,12 @@ public static function sendReminder($contactId, $email, $messageTemplateID, $fro $contact = reset($details); // call token hook - $hookTokens = array(); + $hookTokens = []; CRM_Utils_Hook::tokens($hookTokens); $categories = array_keys($hookTokens); // do replacements in text and html body - $type = array('html', 'text'); + $type = ['html', 'text']; foreach ($type as $key => $value) { $bodyType = "body_{$value}"; if ($$bodyType) { @@ -271,10 +271,10 @@ public static function sendReminder($contactId, $email, $messageTemplateID, $fro $text = $body_text; $smarty = CRM_Core_Smarty::singleton(); - foreach (array( + foreach ([ 'text', 'html', - ) as $elem) { + ] as $elem) { $$elem = $smarty->fetch("string:{$$elem}"); } @@ -287,13 +287,13 @@ public static function sendReminder($contactId, $email, $messageTemplateID, $fro $messageSubject = $smarty->fetch("string:{$messageSubject}"); // set up the parameters for CRM_Utils_Mail::send - $mailParams = array( + $mailParams = [ 'groupName' => 'Scheduled Reminder Sender', 'from' => $from, 'toName' => $contact['display_name'], 'toEmail' => $email, 'subject' => $messageSubject, - ); + ]; if (!$html || $contact['preferred_mail_format'] == 'Text' || $contact['preferred_mail_format'] == 'Both' ) { @@ -326,7 +326,7 @@ public static function revert($id) { $diverted->find(1); if ($diverted->N != 1) { - CRM_Core_Error::fatal(ts('Did not find a message template with id of %1.', array(1 => $id))); + CRM_Core_Error::fatal(ts('Did not find a message template with id of %1.', [1 => $id])); } $orig = new CRM_Core_BAO_MessageTemplate(); @@ -335,7 +335,7 @@ public static function revert($id) { $orig->find(1); if ($orig->N != 1) { - CRM_Core_Error::fatal(ts('Message template with id of %1 does not have a default to revert to.', array(1 => $id))); + CRM_Core_Error::fatal(ts('Message template with id of %1 does not have a default to revert to.', [1 => $id])); } $diverted->msg_subject = $orig->msg_subject; @@ -355,7 +355,7 @@ public static function revert($id) { * Array of four parameters: a boolean whether the email was sent, and the subject, text and HTML templates */ public static function sendTemplate($params) { - $defaults = array( + $defaults = [ // option group name of the template 'groupName' => NULL, // option value name of the template @@ -365,7 +365,7 @@ public static function sendTemplate($params) { // contact id if contact tokens are to be replaced 'contactId' => NULL, // additional template params (other than the ones already set in the template singleton) - 'tplParams' => array(), + 'tplParams' => [], // the From: header 'from' => NULL, // the recipient’s name @@ -384,7 +384,7 @@ public static function sendTemplate($params) { 'isTest' => FALSE, // filename of optional PDF version to add as attachment (do not include path) 'PDFFilename' => NULL, - ); + ]; $params = array_merge($defaults, $params); // Core#644 - handle contact ID passed as "From". @@ -407,7 +407,7 @@ public static function sendTemplate($params) { $query = 'SELECT msg_subject subject, msg_text text, msg_html html, pdf_format_id format FROM civicrm_msg_template mt WHERE mt.id = %1 AND mt.is_default = 1'; - $sqlParams = array(1 => array($params['messageTemplateID'], 'String')); + $sqlParams = [1 => [$params['messageTemplateID'], 'String']]; } else { // fetch the three elements from the db based on option_group and option_value names @@ -416,24 +416,24 @@ public static function sendTemplate($params) { JOIN civicrm_option_value ov ON workflow_id = ov.id JOIN civicrm_option_group og ON ov.option_group_id = og.id WHERE og.name = %1 AND ov.name = %2 AND mt.is_default = 1'; - $sqlParams = array(1 => array($params['groupName'], 'String'), 2 => array($params['valueName'], 'String')); + $sqlParams = [1 => [$params['groupName'], 'String'], 2 => [$params['valueName'], 'String']]; } $dao = CRM_Core_DAO::executeQuery($query, $sqlParams); $dao->fetch(); if (!$dao->N) { if ($params['messageTemplateID']) { - CRM_Core_Error::fatal(ts('No such message template: id=%1.', array(1 => $params['messageTemplateID']))); + CRM_Core_Error::fatal(ts('No such message template: id=%1.', [1 => $params['messageTemplateID']])); } else { - CRM_Core_Error::fatal(ts('No such message template: option group %1, option value %2.', array( + CRM_Core_Error::fatal(ts('No such message template: option group %1, option value %2.', [ 1 => $params['groupName'], 2 => $params['valueName'], - ))); + ])); } } - $mailContent = array( + $mailContent = [ 'subject' => $dao->subject, 'text' => $dao->text, 'html' => $dao->html, @@ -441,7 +441,7 @@ public static function sendTemplate($params) { 'groupName' => $params['groupName'], 'valueName' => $params['valueName'], 'messageTemplateID' => $params['messageTemplateID'], - ); + ]; $dao->free(); CRM_Utils_Hook::alterMailContent($mailContent); @@ -464,7 +464,7 @@ public static function sendTemplate($params) { // replace tokens in the three elements (in subject as if it was the text body) $domain = CRM_Core_BAO_Domain::getDomain(); - $hookTokens = array(); + $hookTokens = []; $mailing = new CRM_Mailing_BAO_Mailing(); $mailing->subject = $mailContent['subject']; $mailing->body_text = $mailContent['text']; @@ -476,8 +476,8 @@ public static function sendTemplate($params) { $contactID = CRM_Utils_Array::value('contactId', $params); if ($contactID) { - $contactParams = array('contact_id' => $contactID); - $returnProperties = array(); + $contactParams = ['contact_id' => $contactID]; + $returnProperties = []; if (isset($tokens['subject']['contact'])) { foreach ($tokens['subject']['contact'] as $name) { @@ -520,9 +520,9 @@ public static function sendTemplate($params) { $mailContent['text'] = CRM_Utils_Token::replaceContactTokens($mailContent['text'], $contact, FALSE, $tokens['text'], FALSE, TRUE); $mailContent['html'] = CRM_Utils_Token::replaceContactTokens($mailContent['html'], $contact, FALSE, $tokens['html'], FALSE, TRUE); - $contactArray = array($contactID => $contact); + $contactArray = [$contactID => $contact]; CRM_Utils_Hook::tokenValues($contactArray, - array($contactID), + [$contactID], NULL, CRM_Utils_Token::flattenTokens($tokens), // we should consider adding groupName and valueName here @@ -543,11 +543,11 @@ public static function sendTemplate($params) { foreach ($params['tplParams'] as $name => $value) { $smarty->assign($name, $value); } - foreach (array( + foreach ([ 'subject', 'text', 'html', - ) as $elem) { + ] as $elem) { $mailContent[$elem] = $smarty->fetch("string:{$mailContent[$elem]}"); } @@ -560,7 +560,7 @@ public static function sendTemplate($params) { $params['html'] = $mailContent['html']; if ($params['toEmail']) { - $contactParams = array(array('email', 'LIKE', $params['toEmail'], 0, 1)); + $contactParams = [['email', 'LIKE', $params['toEmail'], 0, 1]]; list($contact, $_) = CRM_Contact_BAO_Query::apiQuery($contactParams); $prefs = array_pop($contact); @@ -577,7 +577,7 @@ public static function sendTemplate($params) { if (isset($params['isEmailPdf']) && $params['isEmailPdf'] == 1) { $pdfHtml = CRM_Contribute_BAO_ContributionPage::addInvoicePdfToEmail($params['contributionId'], $params['contactId']); if (empty($params['attachments'])) { - $params['attachments'] = array(); + $params['attachments'] = []; } $params['attachments'][] = CRM_Utils_Mail::appendPDF('Invoice.pdf', $pdfHtml, $mailContent['format']); } @@ -587,7 +587,7 @@ public static function sendTemplate($params) { $params['html'] ) { if (empty($params['attachments'])) { - $params['attachments'] = array(); + $params['attachments'] = []; } $params['attachments'][] = CRM_Utils_Mail::appendPDF($params['PDFFilename'], $params['html'], $mailContent['format']); if (isset($params['tplParams']['email_comment'])) { @@ -603,7 +603,7 @@ public static function sendTemplate($params) { } } - return array($sent, $mailContent['subject'], $mailContent['text'], $mailContent['html']); + return [$sent, $mailContent['subject'], $mailContent['text'], $mailContent['html']]; } } diff --git a/CRM/Core/BAO/Navigation.php b/CRM/Core/BAO/Navigation.php index 7e025198b67b..56bd323332f0 100644 --- a/CRM/Core/BAO/Navigation.php +++ b/CRM/Core/BAO/Navigation.php @@ -174,7 +174,7 @@ public static function getNavigationList() { FROM civicrm_navigation WHERE domain_id = $domainID"; $result = CRM_Core_DAO::executeQuery($query); - $pidGroups = array(); + $pidGroups = []; while ($result->fetch()) { $pidGroups[$result->parent_id][$result->label] = $result->id; } @@ -183,7 +183,7 @@ public static function getNavigationList() { $pidGroups[''][$label] = self::_getNavigationValue($val, $pidGroups); } - $navigations = array(); + $navigations = []; self::_getNavigationLabel($pidGroups[''], $navigations); CRM_Core_BAO_Cache::setItem($navigations, 'navigation', $cacheKeyString); @@ -207,7 +207,7 @@ public static function _getNavigationLabel($list, &$navigations, $separator = '' if ($label == 'navigation_id') { continue; } - $translatedLabel = $i18n->crm_translate($label, array('context' => 'menu')); + $translatedLabel = $i18n->crm_translate($label, ['context' => 'menu']); $navigations[is_array($val) ? $val['navigation_id'] : $val] = "{$separator}{$translatedLabel}"; if (is_array($val)) { self::_getNavigationLabel($val, $navigations, $separator . '    '); @@ -227,7 +227,7 @@ public static function _getNavigationLabel($list, &$navigations, $separator = '' */ public static function _getNavigationValue($val, &$pidGroups) { if (array_key_exists($val, $pidGroups)) { - $list = array('navigation_id' => $val); + $list = ['navigation_id' => $val]; foreach ($pidGroups[$val] as $label => $id) { $list[$label] = self::_getNavigationValue($id, $pidGroups); } @@ -247,7 +247,7 @@ public static function _getNavigationValue($val, &$pidGroups) { */ public static function buildNavigationTree() { $domainID = CRM_Core_Config::domainID(); - $navigationTree = array(); + $navigationTree = []; $navigationMenu = new self(); $navigationMenu->domain_id = $domainID; @@ -255,8 +255,8 @@ public static function buildNavigationTree() { $navigationMenu->find(); while ($navigationMenu->fetch()) { - $navigationTree[$navigationMenu->id] = array( - 'attributes' => array( + $navigationTree[$navigationMenu->id] = [ + 'attributes' => [ 'label' => $navigationMenu->label, 'name' => $navigationMenu->name, 'url' => $navigationMenu->url, @@ -268,8 +268,8 @@ public static function buildNavigationTree() { 'parentID' => $navigationMenu->parent_id, 'navID' => $navigationMenu->id, 'active' => $navigationMenu->is_active, - ), - ); + ], + ]; } return self::buildTree($navigationTree); @@ -284,7 +284,7 @@ public static function buildNavigationTree() { * @return array */ private static function buildTree($elements, $parentId = NULL) { - $branch = array(); + $branch = []; foreach ($elements as $id => $element) { if ($element['attributes']['parentID'] == $parentId) { @@ -354,7 +354,7 @@ public static function recurseNavigation(&$value, &$navigationString, $skipMenuI if (isset($val['attributes']['separator']) && $val['attributes']['separator'] == 2) { $navigationString .= ''; } - $removeCharacters = array('/', '!', '&', '*', ' ', '(', ')', '.'); + $removeCharacters = ['/', '!', '&', '*', ' ', '(', ')', '.']; $navigationString .= '
  • ' . $name; self::recurseNavigation($val, $navigationString, $skipMenuItems); } @@ -430,7 +430,7 @@ public static function getMenuName(&$value, &$skipMenuItems) { // want to use ts() as it would throw the ts-extractor off $i18n = CRM_Core_I18n::singleton(); - $name = $i18n->crm_translate($value['attributes']['label'], array('context' => 'menu')); + $name = $i18n->crm_translate($value['attributes']['label'], ['context' => 'menu']); $url = CRM_Utils_Array::value('url', $value['attributes']); $parentID = CRM_Utils_Array::value('parentID', $value['attributes']); $navID = CRM_Utils_Array::value('navID', $value['attributes']); @@ -650,7 +650,7 @@ public static function processMove($nodeID, $referenceID, $position) { $incrementOtherNodes = TRUE; $sql = "SELECT weight from civicrm_navigation WHERE {$parentClause} ORDER BY weight LIMIT %1, 1"; - $params = array(1 => array($position, 'Positive')); + $params = [1 => [$position, 'Positive']]; $newWeight = CRM_Core_DAO::singleValueQuery($sql, $params); // this means node is moved to last position, so you need to get the weight of last element + 1 @@ -659,7 +659,7 @@ public static function processMove($nodeID, $referenceID, $position) { if ($position) { $lastPosition = $position - 1; $sql = "SELECT weight from civicrm_navigation WHERE {$parentClause} ORDER BY weight LIMIT %1, 1"; - $params = array(1 => array($lastPosition, 'Positive')); + $params = [1 => [$lastPosition, 'Positive']]; $newWeight = CRM_Core_DAO::singleValueQuery($sql, $params); // since last node increment + 1 @@ -734,7 +734,7 @@ public static function processUpdate($params, $newParams) { * @param int $domain_id */ public static function rebuildReportsNavigation($domain_id) { - $component_to_nav_name = array( + $component_to_nav_name = [ 'CiviContact' => 'Contact Reports', 'CiviContribute' => 'Contribution Reports', 'CiviMember' => 'Membership Reports', @@ -743,7 +743,7 @@ public static function rebuildReportsNavigation($domain_id) { 'CiviGrant' => 'Grant Reports', 'CiviMail' => 'Mailing Reports', 'CiviCampaign' => 'Campaign Reports', - ); + ]; // Create or update the top level Reports link. $reports_nav = self::createOrUpdateTopLevelReportsNavItem($domain_id); @@ -770,10 +770,10 @@ public static function rebuildReportsNavigation($domain_id) { $report_nav = self::createOrUpdateReportNavItem($report['title'], $report['url'], 'reset=1', $component_nav->id, $report['permission'], $domain_id, FALSE, TRUE); // Update the report instance to include the navigation id. $query = "UPDATE civicrm_report_instance SET navigation_id = %1 WHERE id = %2"; - $params = array( - 1 => array($report_nav->id, 'Integer'), - 2 => array($report_id, 'Integer'), - ); + $params = [ + 1 => [$report_nav->id, 'Integer'], + 2 => [$report_id, 'Integer'], + ]; CRM_Core_DAO::executeQuery($query, $params); } } @@ -859,19 +859,19 @@ public static function getAllActiveReportsByComponent($domain_id) { civicrm_report_instance.domain_id = %1 ORDER BY civicrm_option_value.weight"; - $dao = CRM_Core_DAO::executeQuery($sql, array( - 1 => array($domain_id, 'Integer'), - )); - $rows = array(); + $dao = CRM_Core_DAO::executeQuery($sql, [ + 1 => [$domain_id, 'Integer'], + ]); + $rows = []; while ($dao->fetch()) { $component_name = is_null($dao->name) ? 'CiviContact' : $dao->name; $component_id = is_null($dao->component_id) ? 99 : $dao->component_id; $rows[$component_id]['name'] = $component_name; - $rows[$component_id]['reports'][$dao->id] = array( + $rows[$component_id]['reports'][$dao->id] = [ 'title' => $dao->title, 'url' => "civicrm/report/instance/{$dao->id}", 'permission' => $dao->permission, - ); + ]; } return $rows; } @@ -926,17 +926,17 @@ public static function createReportNavItem($name, $url, $url_params, $parent_id, if ($url !== NULL) { $url = "{$url}?{$url_params}"; } - $params = array( + $params = [ 'name' => $name, 'label' => ts($name), 'url' => $url, 'parent_id' => $parent_id, 'is_active' => TRUE, - 'permission' => array( + 'permission' => [ $permission, - ), + ], 'domain_id' => $domain_id, - ); + ]; if ($id) { $params['id'] = $id; } diff --git a/CRM/Core/BAO/OpenID.php b/CRM/Core/BAO/OpenID.php index 7dad2b24dbfb..62561838feaf 100644 --- a/CRM/Core/BAO/OpenID.php +++ b/CRM/Core/BAO/OpenID.php @@ -116,20 +116,20 @@ public static function allOpenIDs($id, $updateBlankLocInfo = FALSE) { civicrm_contact.id = %1 ORDER BY civicrm_openid.is_primary DESC, openid_id ASC "; - $params = array(1 => array($id, 'Integer')); + $params = [1 => [$id, 'Integer']]; - $openids = $values = array(); + $openids = $values = []; $dao = CRM_Core_DAO::executeQuery($query, $params); $count = 1; while ($dao->fetch()) { - $values = array( + $values = [ 'locationType' => $dao->locationType, 'is_primary' => $dao->is_primary, 'id' => $dao->openid_id, 'openid' => $dao->openid, 'locationTypeId' => $dao->locationTypeId, 'allowed_to_login' => $dao->allowed_to_login, - ); + ]; if ($updateBlankLocInfo) { $openids[$count++] = $values; diff --git a/CRM/Core/BAO/OptionGroup.php b/CRM/Core/BAO/OptionGroup.php index d2b06edd53f1..ca491c19fc76 100644 --- a/CRM/Core/BAO/OptionGroup.php +++ b/CRM/Core/BAO/OptionGroup.php @@ -87,7 +87,7 @@ public static function setIsActive($id, $is_active) { * * @return object */ - public static function add(&$params, $ids = array()) { + public static function add(&$params, $ids = []) { if (empty($params['id']) && !empty($ids['optionGroup'])) { CRM_Core_Error::deprecatedFunctionWarning('no $ids array'); $params['id'] = $ids['optionGroup']; @@ -161,10 +161,10 @@ public static function getDataType($optionGroupId) { * ID of the option group. */ public static function ensureOptionGroupExists($params) { - $existingValues = civicrm_api3('OptionGroup', 'get', array( + $existingValues = civicrm_api3('OptionGroup', 'get', [ 'name' => $params['name'], 'return' => 'id', - )); + ]); if (!$existingValues['count']) { $result = civicrm_api3('OptionGroup', 'create', $params); return $result['id']; @@ -218,16 +218,16 @@ public static function getTitlesByNames() { * e.g. array("en_CA","fr_CA") */ public static function setActiveValues($optionGroupName, $activeValues) { - $params = array( - 1 => array($optionGroupName, 'String'), - ); + $params = [ + 1 => [$optionGroupName, 'String'], + ]; // convert activeValues into placeholders / params in the query - $placeholders = array(); + $placeholders = []; $i = count($params) + 1; foreach ($activeValues as $value) { $placeholders[] = "%{$i}"; - $params[$i] = array($value, 'String'); + $params[$i] = [$value, 'String']; $i++; } $placeholders = implode(', ', $placeholders); diff --git a/CRM/Core/BAO/OptionValue.php b/CRM/Core/BAO/OptionValue.php index 959b77d5e4d3..a681756418c0 100644 --- a/CRM/Core/BAO/OptionValue.php +++ b/CRM/Core/BAO/OptionValue.php @@ -53,9 +53,9 @@ public static function create($params) { if (empty($params['id'])) { self::setDefaults($params); } - $ids = array(); + $ids = []; if (!empty($params['id'])) { - $ids = array('optionValue' => $params['id']); + $ids = ['optionValue' => $params['id']]; } return CRM_Core_BAO_OptionValue::add($params, $ids); } @@ -100,7 +100,7 @@ public static function setDefaults(&$params) { */ public static function getDefaultWeight($params) { return (int) CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_OptionValue', - array('option_group_id' => $params['option_group_id'])); + ['option_group_id' => $params['option_group_id']]); } /** @@ -169,7 +169,7 @@ public static function setIsActive($id, $is_active) { * @return \CRM_Core_DAO_OptionValue * @throws \CRM_Core_Exception */ - public static function add(&$params, $ids = array()) { + public static function add(&$params, $ids = []) { $id = CRM_Utils_Array::value('id', $params, CRM_Utils_Array::value('optionValue', $ids)); // CRM-10921: do not reset attributes to default if this is an update //@todo consider if defaults are being set in the right place. 'dumb' defaults like @@ -213,7 +213,7 @@ public static function add(&$params, $ids = array()) { } } - $p = array(1 => array($params['option_group_id'], 'Integer')); + $p = [1 => [$params['option_group_id'], 'Integer']]; CRM_Core_DAO::executeQuery($query, $p); } @@ -311,7 +311,7 @@ public static function getActivityTypeDetails($activityTypeId) { $dao->fetch(); - return array($dao->label, $dao->description); + return [$dao->label, $dao->description]; } /** @@ -355,18 +355,18 @@ public static function updateRecords(&$optionValueId, $action) { // get the proper group name & affected field name // todo: this may no longer be needed for individuals - check inputs - $individuals = array( + $individuals = [ 'gender' => 'gender_id', 'individual_prefix' => 'prefix_id', 'individual_suffix' => 'suffix_id', 'communication_style' => 'communication_style_id', // Not only Individuals -- but the code seems to be generic for all contact types, despite the naming... - ); - $contributions = array('payment_instrument' => 'payment_instrument_id'); - $activities = array('activity_type' => 'activity_type_id'); - $participant = array('participant_role' => 'role_id'); - $eventType = array('event_type' => 'event_type_id'); - $aclRole = array('acl_role' => 'acl_role_id'); + ]; + $contributions = ['payment_instrument' => 'payment_instrument_id']; + $activities = ['activity_type' => 'activity_type_id']; + $participant = ['participant_role' => 'role_id']; + $eventType = ['event_type' => 'event_type_id']; + $aclRole = ['acl_role' => 'acl_role_id']; $all = array_merge($individuals, $contributions, $activities, $participant, $eventType, $aclRole); $fieldName = ''; @@ -506,9 +506,9 @@ public static function getOptionValuesArray($optionGroupID) { $dao->orderBy('weight ASC, label ASC'); $dao->find(); - $optionValues = array(); + $optionValues = []; while ($dao->fetch()) { - $optionValues[$dao->id] = array(); + $optionValues[$dao->id] = []; CRM_Core_DAO::storeValues($dao, $optionValues[$dao->id]); } @@ -531,7 +531,7 @@ public static function getOptionValuesArray($optionGroupID) { public static function getOptionValuesAssocArray($optionGroupID) { $optionValues = self::getOptionValuesArray($optionGroupID); - $options = array(); + $options = []; foreach ($optionValues as $id => $value) { $options[$value['value']] = $value['label']; } @@ -556,7 +556,7 @@ public static function getOptionValuesAssocArrayFromName($optionGroupName) { $dao->find(TRUE); $optionValues = self::getOptionValuesArray($dao->id); - $options = array(); + $options = []; foreach ($optionValues as $id => $value) { $options[$value['value']] = $value['label']; } @@ -575,12 +575,12 @@ public static function getOptionValuesAssocArrayFromName($optionGroupName) { * @return array the option value attributes. */ public static function ensureOptionValueExists($params) { - $result = civicrm_api3('OptionValue', 'get', array( + $result = civicrm_api3('OptionValue', 'get', [ 'option_group_id' => $params['option_group_id'], 'name' => $params['name'], 'return' => ['id', 'value'], 'sequential' => 1, - )); + ]); if (!$result['count']) { $result = civicrm_api3('OptionValue', 'create', $params); diff --git a/CRM/Core/BAO/PaperSize.php b/CRM/Core/BAO/PaperSize.php index fbe2895208c1..59664fff03ec 100644 --- a/CRM/Core/BAO/PaperSize.php +++ b/CRM/Core/BAO/PaperSize.php @@ -45,25 +45,25 @@ class CRM_Core_BAO_PaperSize extends CRM_Core_DAO_OptionValue { /** * Paper Size fields stored in the 'value' field of the Option Value table. */ - private static $optionValueFields = array( - 'metric' => array( + private static $optionValueFields = [ + 'metric' => [ 'name' => 'metric', 'type' => CRM_Utils_Type::T_STRING, 'default' => 'mm', - ), - 'width' => array( + ], + 'width' => [ 'name' => 'width', 'type' => CRM_Utils_Type::T_FLOAT, 'metric' => TRUE, 'default' => 612, - ), - 'height' => array( + ], + 'height' => [ 'name' => 'height', 'type' => CRM_Utils_Type::T_FLOAT, 'metric' => TRUE, 'default' => 792, - ), - ); + ], + ]; /** * Get Option Group ID for Paper Sizes. @@ -104,7 +104,7 @@ public static function &addOrder(&$list, $returnURL) { * (reference) Paper Size list */ public static function &getList($namesOnly = FALSE) { - static $list = array(); + static $list = []; if (self::_getGid()) { // get saved Paper Sizes from Option Value table $dao = new CRM_Core_DAO_OptionValue(); @@ -131,13 +131,13 @@ public static function &getList($namesOnly = FALSE) { * Name/value pairs containing the default Paper Size values. */ public static function &getDefaultValues() { - $params = array('is_active' => 1, 'is_default' => 1); - $defaults = array(); + $params = ['is_active' => 1, 'is_default' => 1]; + $defaults = []; if (!self::retrieve($params, $defaults)) { foreach (self::$optionValueFields as $name => $field) { $defaults[$name] = $field['default']; } - $filter = array('option_group_id' => self::_getGid()); + $filter = ['option_group_id' => self::_getGid()]; $defaults['weight'] = CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_OptionValue', $filter); } return $defaults; @@ -155,8 +155,8 @@ public static function &getDefaultValues() { * (reference) associative array of name/value pairs */ public static function &getPaperFormat($field, $val) { - $params = array('is_active' => 1, $field => $val); - $paperFormat = array(); + $params = ['is_active' => 1, $field => $val]; + $paperFormat = []; if (self::retrieve($params, $paperFormat)) { return $paperFormat; } @@ -314,7 +314,7 @@ public function savePaperSize(&$values, $id) { $this->save(); // fix duplicate weights - $filter = array('option_group_id' => self::_getGid()); + $filter = ['option_group_id' => self::_getGid()]; CRM_Utils_Weight::correctDuplicateWeights('CRM_Core_DAO_OptionValue', $filter); } @@ -331,7 +331,7 @@ public static function del($id) { $dao->id = $id; if ($dao->find(TRUE)) { if ($dao->option_group_id == self::_getGid()) { - $filter = array('option_group_id' => self::_getGid()); + $filter = ['option_group_id' => self::_getGid()]; CRM_Utils_Weight::delWeight('CRM_Core_DAO_OptionValue', $id, $filter); $dao->delete(); return; diff --git a/CRM/Core/BAO/PdfFormat.php b/CRM/Core/BAO/PdfFormat.php index 0d1fef31d954..21bd66deeef1 100644 --- a/CRM/Core/BAO/PdfFormat.php +++ b/CRM/Core/BAO/PdfFormat.php @@ -45,52 +45,52 @@ class CRM_Core_BAO_PdfFormat extends CRM_Core_DAO_OptionValue { /** * PDF Page Format fields stored in the 'value' field of the Option Value table. */ - private static $optionValueFields = array( - 'paper_size' => array( + private static $optionValueFields = [ + 'paper_size' => [ 'name' => 'paper_size', 'type' => CRM_Utils_Type::T_STRING, 'default' => 'letter', - ), - 'stationery' => array( + ], + 'stationery' => [ 'name' => 'stationery', 'type' => CRM_Utils_Type::T_STRING, 'default' => '', - ), - 'orientation' => array( + ], + 'orientation' => [ 'name' => 'orientation', 'type' => CRM_Utils_Type::T_STRING, 'default' => 'portrait', - ), - 'metric' => array( + ], + 'metric' => [ 'name' => 'metric', 'type' => CRM_Utils_Type::T_STRING, 'default' => 'in', - ), - 'margin_top' => array( + ], + 'margin_top' => [ 'name' => 'margin_top', 'type' => CRM_Utils_Type::T_FLOAT, 'metric' => TRUE, 'default' => 0.75, - ), - 'margin_bottom' => array( + ], + 'margin_bottom' => [ 'name' => 'margin_bottom', 'type' => CRM_Utils_Type::T_FLOAT, 'metric' => TRUE, 'default' => 0.75, - ), - 'margin_left' => array( + ], + 'margin_left' => [ 'name' => 'margin_left', 'type' => CRM_Utils_Type::T_FLOAT, 'metric' => TRUE, 'default' => 0.75, - ), - 'margin_right' => array( + ], + 'margin_right' => [ 'name' => 'margin_right', 'type' => CRM_Utils_Type::T_FLOAT, 'metric' => TRUE, 'default' => 0.75, - ), - ); + ], + ]; /** * Get page orientations recognized by the DOMPDF package used to create PDF letters. @@ -99,10 +99,10 @@ class CRM_Core_BAO_PdfFormat extends CRM_Core_DAO_OptionValue { * array of page orientations */ public static function getPageOrientations() { - return array( + return [ 'portrait' => ts('Portrait'), 'landscape' => ts('Landscape'), - ); + ]; } /** @@ -112,12 +112,12 @@ public static function getPageOrientations() { * array of measurement units */ public static function getUnits() { - return array( + return [ 'in' => ts('Inches'), 'cm' => ts('Centimeters'), 'mm' => ts('Millimeters'), 'pt' => ts('Points'), - ); + ]; } /** @@ -158,7 +158,7 @@ public static function addOrder(&$list, $returnURL) { * (reference) PDF Page Format list */ public static function &getList($namesOnly = FALSE) { - static $list = array(); + static $list = []; if (self::_getGid()) { // get saved PDF Page Formats from Option Value table $dao = new CRM_Core_DAO_OptionValue(); @@ -185,13 +185,13 @@ public static function &getList($namesOnly = FALSE) { * Name/value pairs containing the default PDF Page Format values. */ public static function &getDefaultValues() { - $params = array('is_active' => 1, 'is_default' => 1); - $defaults = array(); + $params = ['is_active' => 1, 'is_default' => 1]; + $defaults = []; if (!self::retrieve($params, $defaults)) { foreach (self::$optionValueFields as $name => $field) { $defaults[$name] = $field['default']; } - $filter = array('option_group_id' => self::_getGid()); + $filter = ['option_group_id' => self::_getGid()]; $defaults['weight'] = CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_OptionValue', $filter); // also set the id to avoid NOTICES, CRM-8454 @@ -212,8 +212,8 @@ public static function &getDefaultValues() { * (reference) associative array of name/value pairs */ public static function &getPdfFormat($field, $val) { - $params = array('is_active' => 1, $field => $val); - $pdfFormat = array(); + $params = ['is_active' => 1, $field => $val]; + $pdfFormat = []; if (self::retrieve($params, $pdfFormat)) { return $pdfFormat; } @@ -367,7 +367,7 @@ public function savePdfFormat(&$values, $id = NULL) { $this->save(); // fix duplicate weights - $filter = array('option_group_id' => self::_getGid()); + $filter = ['option_group_id' => self::_getGid()]; CRM_Utils_Weight::correctDuplicateWeights('CRM_Core_DAO_OptionValue', $filter); } @@ -384,7 +384,7 @@ public static function del($id) { $dao->id = $id; if ($dao->find(TRUE)) { if ($dao->option_group_id == self::_getGid()) { - $filter = array('option_group_id' => self::_getGid()); + $filter = ['option_group_id' => self::_getGid()]; CRM_Utils_Weight::delWeight('CRM_Core_DAO_OptionValue', $id, $filter); $dao->delete(); return; diff --git a/CRM/Core/BAO/Persistent.php b/CRM/Core/BAO/Persistent.php index cae5858db977..2694f8bef0f5 100644 --- a/CRM/Core/BAO/Persistent.php +++ b/CRM/Core/BAO/Persistent.php @@ -88,10 +88,10 @@ public static function add(&$params, &$ids) { * @return mixed */ public static function getContext($context, $name = NULL) { - static $contextNameData = array(); + static $contextNameData = []; if (!array_key_exists($context, $contextNameData)) { - $contextNameData[$context] = array(); + $contextNameData[$context] = []; $persisntentDAO = new CRM_Core_DAO_Persistent(); $persisntentDAO->context = $context; $persisntentDAO->find(); diff --git a/CRM/Core/BAO/Phone.php b/CRM/Core/BAO/Phone.php index cece40787d32..610cd1afbb3d 100644 --- a/CRM/Core/BAO/Phone.php +++ b/CRM/Core/BAO/Phone.php @@ -111,7 +111,7 @@ public static function &getValues($entityBlock) { * @return array * the array of phone ids which are potential numbers */ - public static function allPhones($id, $updateBlankLocInfo = FALSE, $type = NULL, $filters = array()) { + public static function allPhones($id, $updateBlankLocInfo = FALSE, $type = NULL, $filters = []) { if (!$id) { return NULL; } @@ -140,25 +140,25 @@ public static function allPhones($id, $updateBlankLocInfo = FALSE, $type = NULL, WHERE civicrm_contact.id = %1 $cond ORDER BY civicrm_phone.is_primary DESC, phone_id ASC "; - $params = array( - 1 => array( + $params = [ + 1 => [ $id, 'Integer', - ), - ); + ], + ]; - $numbers = $values = array(); + $numbers = $values = []; $dao = CRM_Core_DAO::executeQuery($query, $params); $count = 1; while ($dao->fetch()) { - $values = array( + $values = [ 'locationType' => $dao->locationType, 'is_primary' => $dao->is_primary, 'id' => $dao->phone_id, 'phone' => $dao->phone, 'locationTypeId' => $dao->locationTypeId, 'phoneTypeId' => $dao->phoneTypeId, - ); + ]; if ($updateBlankLocInfo) { $numbers[$count++] = $values; @@ -209,22 +209,22 @@ public static function allEntityPhones($entityElements, $type = NULL) { AND ltype.id = ph.location_type_id ORDER BY ph.is_primary DESC, phone_id ASC "; - $params = array( - 1 => array( + $params = [ + 1 => [ $entityId, 'Integer', - ), - ); - $numbers = array(); + ], + ]; + $numbers = []; $dao = CRM_Core_DAO::executeQuery($sql, $params); while ($dao->fetch()) { - $numbers[$dao->phone_id] = array( + $numbers[$dao->phone_id] = [ 'locationType' => $dao->locationType, 'is_primary' => $dao->is_primary, 'id' => $dao->phone_id, 'phone' => $dao->phone, 'locationTypeId' => $dao->locationTypeId, - ); + ]; } return $numbers; } @@ -242,17 +242,17 @@ public static function setOptionToNull($optionId) { // Ensure mysql phone function exists CRM_Core_DAO::checkSqlFunctionsExist(); - $tables = array( + $tables = [ 'civicrm_phone', 'civicrm_mapping_field', 'civicrm_uf_field', - ); - $params = array( - 1 => array( + ]; + $params = [ + 1 => [ $optionId, 'Integer', - ), - ); + ], + ]; foreach ($tables as $tableName) { $query = "UPDATE `{$tableName}` SET `phone_type_id` = NULL WHERE `phone_type_id` = %1"; diff --git a/CRM/Core/BAO/PreferencesDate.php b/CRM/Core/BAO/PreferencesDate.php index ffe16a16fa37..fdf0fc467ac5 100644 --- a/CRM/Core/BAO/PreferencesDate.php +++ b/CRM/Core/BAO/PreferencesDate.php @@ -108,7 +108,7 @@ public static function onChangeSetting($oldValue, $newValue, $metadata) { WHERE time_format IS NOT NULL AND time_format <> '' "; - $sqlParams = array(1 => array($newValue, 'String')); + $sqlParams = [1 => [$newValue, 'String']]; CRM_Core_DAO::executeQuery($query, $sqlParams); } diff --git a/CRM/Core/BAO/PrevNextCache.php b/CRM/Core/BAO/PrevNextCache.php index 71bc9e74ec2a..8d5fd872f7ba 100644 --- a/CRM/Core/BAO/PrevNextCache.php +++ b/CRM/Core/BAO/PrevNextCache.php @@ -51,7 +51,7 @@ class CRM_Core_BAO_PrevNextCache extends CRM_Core_DAO_PrevNextCache { */ public static function getPositions($cacheKey, $id1, $id2, &$mergeId = NULL, $join = NULL, $where = NULL, $flip = FALSE) { if ($flip) { - list($id1, $id2) = array($id2, $id1); + list($id1, $id2) = [$id2, $id1]; } if ($mergeId == NULL) { @@ -64,16 +64,16 @@ public static function getPositions($cacheKey, $id1, $id2, &$mergeId = NULL, $jo entity_table = 'civicrm_contact' "; - $params = array( - 1 => array($id1, 'Integer'), - 2 => array($id2, 'Integer'), - 3 => array($cacheKey, 'String'), - ); + $params = [ + 1 => [$id1, 'Integer'], + 2 => [$id2, 'Integer'], + 3 => [$cacheKey, 'String'], + ]; $mergeId = CRM_Core_DAO::singleValueQuery($query, $params); } - $pos = array('foundEntry' => 0); + $pos = ['foundEntry' => 0]; if ($mergeId) { $pos['foundEntry'] = 1; @@ -82,10 +82,10 @@ public static function getPositions($cacheKey, $id1, $id2, &$mergeId = NULL, $jo $where = " AND {$where}"; } - $p = array( - 1 => array($mergeId, 'Integer'), - 2 => array($cacheKey, 'String'), - ); + $p = [ + 1 => [$mergeId, 'Integer'], + 2 => [$cacheKey, 'String'], + ]; $sql = "SELECT pn.id, pn.entity_id1, pn.entity_id2, pn.data FROM civicrm_prevnext_cache pn {$join} "; $wherePrev = " WHERE pn.id < %1 AND pn.cacheKey = %2 {$where} ORDER BY ID DESC LIMIT 1"; $sqlPrev = $sql . $wherePrev; @@ -123,16 +123,16 @@ public static function deleteItem($id = NULL, $cacheKey = NULL, $entityTable = ' //clear cache $sql = "DELETE FROM civicrm_prevnext_cache WHERE entity_table = %1"; - $params = array(1 => array($entityTable, 'String')); + $params = [1 => [$entityTable, 'String']]; if (is_numeric($id)) { $sql .= " AND ( entity_id1 = %2 OR entity_id2 = %2 )"; - $params[2] = array($id, 'Integer'); + $params[2] = [$id, 'Integer']; } if (isset($cacheKey)) { $sql .= " AND cacheKey LIKE %3"; - $params[3] = array("{$cacheKey}%", 'String'); + $params[3] = ["{$cacheKey}%", 'String']; } CRM_Core_DAO::executeQuery($sql, $params); } @@ -148,16 +148,16 @@ public static function deleteItem($id = NULL, $cacheKey = NULL, $entityTable = ' */ public static function deletePair($id1, $id2, $cacheKey = NULL, $isViceVersa = FALSE, $entityTable = 'civicrm_contact') { $sql = "DELETE FROM civicrm_prevnext_cache WHERE entity_table = %1"; - $params = array(1 => array($entityTable, 'String')); + $params = [1 => [$entityTable, 'String']]; $pair = !$isViceVersa ? "entity_id1 = %2 AND entity_id2 = %3" : "(entity_id1 = %2 AND entity_id2 = %3) OR (entity_id1 = %3 AND entity_id2 = %2)"; $sql .= " AND ( {$pair} )"; - $params[2] = array($id1, 'Integer'); - $params[3] = array($id2, 'Integer'); + $params[2] = [$id1, 'Integer']; + $params[3] = [$id2, 'Integer']; if (isset($cacheKey)) { $sql .= " AND cacheKey LIKE %4"; - $params[4] = array("{$cacheKey}%", 'String'); // used % to address any row with conflict-cacheKey e.g "merge Individual_8_0_conflicts" + $params[4] = ["{$cacheKey}%", 'String']; // used % to address any row with conflict-cacheKey e.g "merge Individual_8_0_conflicts" } CRM_Core_DAO::executeQuery($sql, $params); @@ -183,12 +183,12 @@ public static function markConflict($id1, $id2, $cacheKey, $conflicts) { WHERE ((pn.entity_id1 = %1 AND pn.entity_id2 = %2) OR (pn.entity_id1 = %2 AND pn.entity_id2 = %1)) AND (cacheKey = %3 OR cacheKey = %4)"; - $params = array( - 1 => array($id1, 'Integer'), - 2 => array($id2, 'Integer'), - 3 => array("{$cacheKey}", 'String'), - 4 => array("{$cacheKey}_conflicts", 'String'), - ); + $params = [ + 1 => [$id1, 'Integer'], + 2 => [$id2, 'Integer'], + 3 => ["{$cacheKey}", 'String'], + 4 => ["{$cacheKey}_conflicts", 'String'], + ]; $pncFind = CRM_Core_DAO::executeQuery($sql, $params); while ($pncFind->fetch()) { @@ -232,27 +232,27 @@ public static function markConflict($id1, $id2, $cacheKey, $conflicts) { * * @return array */ - public static function retrieve($cacheKey, $join = NULL, $whereClause = NULL, $offset = 0, $rowCount = 0, $select = array(), $orderByClause = '', $includeConflicts = TRUE, $params = array()) { + public static function retrieve($cacheKey, $join = NULL, $whereClause = NULL, $offset = 0, $rowCount = 0, $select = [], $orderByClause = '', $includeConflicts = TRUE, $params = []) { $selectString = 'pn.*'; if (!empty($select)) { - $aliasArray = array(); + $aliasArray = []; foreach ($select as $column => $alias) { $aliasArray[] = $column . ' as ' . $alias; } $selectString .= " , " . implode(' , ', $aliasArray); } - $params = array( - 1 => array($cacheKey, 'String'), - ) + $params; + $params = [ + 1 => [$cacheKey, 'String'], + ] + $params; if (!empty($whereClause)) { $whereClause = " AND " . $whereClause; } if ($includeConflicts) { $where = ' WHERE (pn.cacheKey = %1 OR pn.cacheKey = %2)' . $whereClause; - $params[2] = array("{$cacheKey}_conflicts", 'String'); + $params[2] = ["{$cacheKey}_conflicts", 'String']; } else { $where = ' WHERE (pn.cacheKey = %1)' . $whereClause; @@ -275,7 +275,7 @@ public static function retrieve($cacheKey, $join = NULL, $whereClause = NULL, $o $dao = CRM_Core_DAO::executeQuery($query, $params); - $main = array(); + $main = []; $count = 0; while ($dao->fetch()) { if (self::is_serialized($dao->data)) { @@ -286,17 +286,17 @@ public static function retrieve($cacheKey, $join = NULL, $whereClause = NULL, $o } if (!empty($select)) { - $extraData = array(); + $extraData = []; foreach ($select as $sfield) { $extraData[$sfield] = $dao->$sfield; } - $main[$count] = array( + $main[$count] = [ 'prevnext_id' => $dao->id, 'is_selected' => $dao->is_selected, 'entity_id1' => $dao->entity_id1, 'entity_id2' => $dao->entity_id2, 'data' => $main[$count], - ); + ]; $main[$count] = array_merge($main[$count], $extraData); } $count++; @@ -337,7 +337,7 @@ public static function setItem($values) { * * @return int */ - public static function getCount($cacheKey, $join = NULL, $where = NULL, $op = "=", $params = array()) { + public static function getCount($cacheKey, $join = NULL, $where = NULL, $op = "=", $params = []) { $query = " SELECT COUNT(*) FROM civicrm_prevnext_cache pn {$join} @@ -347,10 +347,10 @@ public static function getCount($cacheKey, $join = NULL, $where = NULL, $op = "= $query .= " AND {$where}"; } - $params = array( - 1 => array($cacheKey, 'String'), - 2 => array("{$cacheKey}_conflicts", 'String'), - ) + $params; + $params = [ + 1 => [$cacheKey, 'String'], + 2 => ["{$cacheKey}_conflicts", 'String'], + ] + $params; return (int) CRM_Core_DAO::singleValueQuery($query, $params, TRUE, FALSE); } @@ -386,18 +386,18 @@ public static function refillCache($rgid, $gid, $cacheKeyString, $criteria, $che // 1. Clear cache if any $sql = "DELETE FROM civicrm_prevnext_cache WHERE cacheKey LIKE %1"; - CRM_Core_DAO::executeQuery($sql, array(1 => array("{$cacheKeyString}%", 'String'))); + CRM_Core_DAO::executeQuery($sql, [1 => ["{$cacheKeyString}%", 'String']]); // FIXME: we need to start using temp tables / queries here instead of arrays. // And cleanup code in CRM/Contact/Page/DedupeFind.php // 2. FILL cache - $foundDupes = array(); + $foundDupes = []; if ($rgid && $gid) { $foundDupes = CRM_Dedupe_Finder::dupesInGroup($rgid, $gid, $searchLimit); } elseif ($rgid) { - $contactIDs = array(); + $contactIDs = []; // The thing we really need to filter out is any chaining that would 'DO SOMETHING' to the DB. // criteria could be passed in via url so we want to ensure nothing could be in that url that // would chain to a delete. Limiting to getfields for 'get' limits us to declared fields, @@ -431,10 +431,10 @@ public static function cleanupCache() { WHERE c.group_name = %1 AND c.created_date < date_sub( NOW( ), INTERVAL %2 day ) "; - $params = array( - 1 => array('CiviCRM Search PrevNextCache', 'String'), - 2 => array($cacheTimeIntervalDays, 'Integer'), - ); + $params = [ + 1 => ['CiviCRM Search PrevNextCache', 'String'], + 2 => [$cacheTimeIntervalDays, 'Integer'], + ]; CRM_Core_DAO::executeQuery($sql, $params); } @@ -468,8 +468,8 @@ public static function flipPair(array $prevNextId, $onlySelected) { $dao->id = $id; if ($dao->find(TRUE)) { $originalData = unserialize($dao->data); - $srcFields = array('ID', 'Name'); - $swapFields = array('srcID', 'srcName', 'dstID', 'dstName'); + $srcFields = ['ID', 'Name']; + $swapFields = ['srcID', 'srcName', 'dstID', 'dstName']; $data = array_diff_assoc($originalData, array_fill_keys($swapFields, 1)); foreach ($srcFields as $key) { $data['src' . $key] = $originalData['dst' . $key]; diff --git a/CRM/Core/BAO/RecurringEntity.php b/CRM/Core/BAO/RecurringEntity.php index 3dfec02e659f..fcc5b4a5e8a5 100644 --- a/CRM/Core/BAO/RecurringEntity.php +++ b/CRM/Core/BAO/RecurringEntity.php @@ -39,54 +39,54 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { const RUNNING = 1; - public $schedule = array(); + public $schedule = []; public $scheduleId = NULL; - public $scheduleFormValues = array(); + public $scheduleFormValues = []; - public $dateColumns = array(); - public $overwriteColumns = array(); - public $intervalDateColumns = array(); - public $excludeDates = array(); + public $dateColumns = []; + public $overwriteColumns = []; + public $intervalDateColumns = []; + public $excludeDates = []; - public $linkedEntities = array(); + public $linkedEntities = []; public $isRecurringEntityRecord = TRUE; protected $recursion = NULL; protected $recursion_start_date = NULL; - public static $_entitiesToBeDeleted = array(); + public static $_entitiesToBeDeleted = []; public static $status = NULL; static $_recurringEntityHelper - = array( - 'civicrm_event' => array( + = [ + 'civicrm_event' => [ 'helper_class' => 'CRM_Event_DAO_Event', 'delete_func' => 'delete', 'pre_delete_func' => 'CRM_Event_Form_ManageEvent_Repeat::checkRegistrationForEvents', - ), - 'civicrm_activity' => array( + ], + 'civicrm_activity' => [ 'helper_class' => 'CRM_Activity_DAO_Activity', 'delete_func' => 'delete', 'pre_delete_func' => '', - ), - ); + ], + ]; static $_dateColumns - = array( - 'civicrm_event' => array( - 'dateColumns' => array('start_date'), - 'excludeDateRangeColumns' => array('start_date', 'end_date'), - 'intervalDateColumns' => array('end_date'), - ), - 'civicrm_activity' => array( - 'dateColumns' => array('activity_date_time'), - ), - ); + = [ + 'civicrm_event' => [ + 'dateColumns' => ['start_date'], + 'excludeDateRangeColumns' => ['start_date', 'end_date'], + 'intervalDateColumns' => ['end_date'], + ], + 'civicrm_activity' => [ + 'dateColumns' => ['activity_date_time'], + ], + ]; static $_tableDAOMapper - = array( + = [ 'civicrm_event' => 'CRM_Event_DAO_Event', 'civicrm_price_set_entity' => 'CRM_Price_DAO_PriceSetEntity', 'civicrm_uf_join' => 'CRM_Core_DAO_UFJoin', @@ -94,37 +94,37 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { 'civicrm_pcp_block' => 'CRM_PCP_DAO_PCPBlock', 'civicrm_activity' => 'CRM_Activity_DAO_Activity', 'civicrm_activity_contact' => 'CRM_Activity_DAO_ActivityContact', - ); + ]; static $_updateSkipFields - = array( - 'civicrm_event' => array('start_date', 'end_date'), - 'civicrm_tell_friend' => array('entity_id'), - 'civicrm_pcp_block' => array('entity_id'), - 'civicrm_activity' => array('activity_date_time'), - ); + = [ + 'civicrm_event' => ['start_date', 'end_date'], + 'civicrm_tell_friend' => ['entity_id'], + 'civicrm_pcp_block' => ['entity_id'], + 'civicrm_activity' => ['activity_date_time'], + ]; static $_linkedEntitiesInfo - = array( - 'civicrm_tell_friend' => array( + = [ + 'civicrm_tell_friend' => [ 'entity_id_col' => 'entity_id', 'entity_table_col' => 'entity_table', - ), - 'civicrm_price_set_entity' => array( + ], + 'civicrm_price_set_entity' => [ 'entity_id_col' => 'entity_id', 'entity_table_col' => 'entity_table', 'is_multirecord' => TRUE, - ), - 'civicrm_uf_join' => array( + ], + 'civicrm_uf_join' => [ 'entity_id_col' => 'entity_id', 'entity_table_col' => 'entity_table', 'is_multirecord' => TRUE, - ), - 'civicrm_pcp_block' => array( + ], + 'civicrm_pcp_block' => [ 'entity_id_col' => 'entity_id', 'entity_table_col' => 'entity_table', - ), - ); + ], + ]; //Define global CLASS CONSTANTS for recurring entity mode types const MODE_THIS_ENTITY_ONLY = 1; @@ -194,11 +194,11 @@ public static function add(&$params) { */ public static function quickAdd($parentId, $entityId, $entityTable) { $params - = array( + = [ 'parent_id' => $parentId, 'entity_id' => $entityId, 'entity_table' => $entityTable, - ); + ]; return self::add($params); } @@ -266,11 +266,11 @@ public function generateRecursion() { public function generateEntities() { self::setStatus(self::RUNNING); - $newEntities = array(); - $findCriteria = array(); + $newEntities = []; + $findCriteria = []; if (!empty($this->recursionDates)) { if ($this->entity_id) { - $findCriteria = array('id' => $this->entity_id); + $findCriteria = ['id' => $this->entity_id]; // save an entry with initiating entity-id & entity-table if ($this->entity_table && !$this->find(TRUE)) { @@ -296,7 +296,7 @@ public function generateEntities() { ); if (is_a($obj, 'CRM_Core_DAO') && $obj->id) { - $newCriteria = array(); + $newCriteria = []; $newEntities[$this->entity_table][$count] = $obj->id; foreach ($this->linkedEntities as $linkedInfo) { @@ -333,7 +333,7 @@ public function generateEntities() { public function generateRecursiveDates() { $this->generateRecursion(); - $recursionDates = array(); + $recursionDates = []; if (is_a($this->recursion, 'When')) { $initialCount = CRM_Utils_Array::value('start_action_offset', $this->schedule); @@ -419,7 +419,7 @@ public function generateRecursiveDates() { * an array of child ids */ static public function getEntitiesForParent($parentId, $entityTable, $includeParent = TRUE, $mode = 3, $initiatorId = NULL) { - $entities = array(); + $entities = []; if (empty($parentId) || empty($entityTable)) { return $entities; } @@ -428,11 +428,11 @@ static public function getEntitiesForParent($parentId, $entityTable, $includePar $initiatorId = $parentId; } - $queryParams = array( - 1 => array($parentId, 'Integer'), - 2 => array($entityTable, 'String'), - 3 => array($initiatorId, 'Integer'), - ); + $queryParams = [ + 1 => [$parentId, 'Integer'], + 2 => [$entityTable, 'String'], + 3 => [$initiatorId, 'Integer'], + ]; if (!$mode) { $mode = CRM_Core_DAO::singleValueQuery("SELECT mode FROM civicrm_recurring_entity WHERE entity_id = %3 AND entity_table = %2", $queryParams); @@ -455,11 +455,11 @@ static public function getEntitiesForParent($parentId, $entityTable, $includePar if ($recurringEntityID) { $query .= $includeParent ? " AND id >= %4" : " AND id > %4"; $query .= " ORDER BY id ASC"; // FIXME: change to order by dates - $queryParams[4] = array($recurringEntityID, 'Integer'); + $queryParams[4] = [$recurringEntityID, 'Integer']; } else { // something wrong, return empty - return array(); + return []; } } @@ -493,7 +493,7 @@ static public function getEntitiesFor($entityId, $entityTable, $includeParent = if ($parentId) { return self::getEntitiesForParent($parentId, $entityTable, $includeParent, $mode, $entityId); } - return array(); + return []; } /** @@ -524,10 +524,10 @@ static public function getParentFor($entityId, $entityTable, $includeParent = TR } $parentId = CRM_Core_DAO::singleValueQuery($query, - array( - 1 => array($entityId, 'Integer'), - 2 => array($entityTable, 'String'), - ) + [ + 1 => [$entityId, 'Integer'], + 2 => [$entityTable, 'String'], + ] ); return $parentId; } @@ -548,10 +548,10 @@ static public function getPositionAndCount($entityId, $entityTable) { WHERE parent_id = (SELECT parent_id FROM civicrm_recurring_entity WHERE entity_id = %1 AND entity_table = %2) AND entity_table = %2"; $dao = CRM_Core_DAO::executeQuery($query, - array( - 1 => array($entityId, 'Integer'), - 2 => array($entityTable, 'String'), - ) + [ + 1 => [$entityId, 'Integer'], + 2 => [$entityTable, 'String'], + ] ); while ($dao->fetch()) { @@ -561,7 +561,7 @@ static public function getPositionAndCount($entityId, $entityTable) { } } if ($count) { - return array($position, $count); + return [$position, $count]; } return NULL; } @@ -618,7 +618,7 @@ static public function triggerUpdate($event) { return; } - static $processedEntities = array(); + static $processedEntities = []; $obj =& $event->object; if (empty($obj->id) || empty($obj->__table)) { return; @@ -651,7 +651,7 @@ static public function triggerUpdate($event) { if (array_key_exists($entityTable, self::$_tableDAOMapper)) { $daoName = self::$_tableDAOMapper[$entityTable]; - $skipData = array(); + $skipData = []; if (array_key_exists($entityTable, self::$_updateSkipFields)) { $skipFields = self::$_updateSkipFields[$entityTable]; foreach ($skipFields as $sfield) { @@ -691,7 +691,7 @@ static public function triggerInsert($event) { return; } - static $processedEntities = array(); + static $processedEntities = []; if (empty($obj->id) || empty($obj->__table)) { return; } @@ -754,12 +754,12 @@ static public function triggerInsert($event) { } else { // linked entity doesn't exist. lets create them - $newCriteria = array( + $newCriteria = [ $idCol => $val['id'], $tableCol => $val['table'], - ); + ]; $linkedObj = CRM_Core_BAO_RecurringEntity::copyCreateEntity($obj->__table, - array('id' => $obj->id), + ['id' => $obj->id], $newCriteria, TRUE ); @@ -795,7 +795,7 @@ static public function triggerDelete($event) { return; } - static $processedEntities = array(); + static $processedEntities = []; if (empty($obj->id) || empty($obj->__table) || !$event->result) { return; } @@ -868,8 +868,8 @@ static public function delEntity($entityId, $entityTable, $isDelLinkedEntities = * * @return array */ - public function mapFormValuesToDB($formParams = array()) { - $dbParams = array(); + public function mapFormValuesToDB($formParams = []) { + $dbParams = []; if (!empty($formParams['used_for'])) { $dbParams['used_for'] = $formParams['used_for']; } @@ -955,9 +955,9 @@ static public function getScheduleReminderDetailsById($scheduleReminderId) { AND id = %1"; } $dao = CRM_Core_DAO::executeQuery($query, - array( - 1 => array($scheduleReminderId, 'Integer'), - ) + [ + 1 => [$scheduleReminderId, 'Integer'], + ] ); $dao->fetch(); return $dao; @@ -972,7 +972,7 @@ static public function getScheduleReminderDetailsById($scheduleReminderId) { * @return array */ public function getScheduleParams($scheduleReminderId) { - $scheduleReminderDetails = array(); + $scheduleReminderDetails = []; if ($scheduleReminderId) { //Get all the details from schedule reminder table $scheduleReminderDetails = self::getScheduleReminderDetailsById($scheduleReminderId); @@ -991,7 +991,7 @@ public function getScheduleParams($scheduleReminderId) { * @return object * When object */ - public function getRecursionFromSchedule($scheduleReminderDetails = array()) { + public function getRecursionFromSchedule($scheduleReminderDetails = []) { $r = new When(); //If there is some data for this id if ($scheduleReminderDetails['repetition_frequency_unit']) { @@ -1024,7 +1024,7 @@ public function getRecursionFromSchedule($scheduleReminderDetails = array()) { if ($scheduleReminderDetails['start_action_condition']) { $startActionCondition = $scheduleReminderDetails['start_action_condition']; $explodeStartActionCondition = explode(',', $startActionCondition); - $buildRuleArray = array(); + $buildRuleArray = []; foreach ($explodeStartActionCondition as $key => $val) { $buildRuleArray[] = strtoupper(substr($val, 0, 2)); } @@ -1058,10 +1058,10 @@ public function getRecursionFromSchedule($scheduleReminderDetails = array()) { break; } $concatStartActionDateBits = $startActionDate1 . strtoupper(substr($startActionDate[1], 0, 2)); - $r->byday(array($concatStartActionDateBits)); + $r->byday([$concatStartActionDateBits]); } elseif ($scheduleReminderDetails['limit_to']) { - $r->bymonthday(array($scheduleReminderDetails['limit_to'])); + $r->bymonthday([$scheduleReminderDetails['limit_to']]); } } @@ -1132,10 +1132,10 @@ public static function getReminderDetailsByEntityId($entityId, $used_for) { if ($used_for) { $query .= " AND used_for = %2"; } - $params = array( - 1 => array($entityId, 'Integer'), - 2 => array($used_for, 'String'), - ); + $params = [ + 1 => [$entityId, 'Integer'], + 2 => [$used_for, 'String'], + ]; $dao = CRM_Core_DAO::executeQuery($query, $params); $dao->fetch(); } @@ -1154,7 +1154,7 @@ public static function getReminderDetailsByEntityId($entityId, $used_for) { * @return array */ public static function updateModeLinkedEntity($entityId, $linkedEntityTable, $mainEntityTable) { - $result = array(); + $result = []; if ($entityId && $linkedEntityTable && $mainEntityTable) { if (CRM_Utils_Array::value($linkedEntityTable, self::$_tableDAOMapper)) { $dao = self::$_tableDAOMapper[$linkedEntityTable]; @@ -1164,11 +1164,11 @@ public static function updateModeLinkedEntity($entityId, $linkedEntityTable, $ma return NULL; } $entityTable = $linkedEntityTable; - $params = array( + $params = [ 'entity_id' => $entityId, 'entity_table' => $mainEntityTable, - ); - $defaults = array(); + ]; + $defaults = []; CRM_Core_DAO::commonRetrieve($dao, $params, $defaults); if (!empty($defaults['id'])) { $result['entityId'] = $defaults['id']; @@ -1193,7 +1193,7 @@ public static function updateModeLinkedEntity($entityId, $linkedEntityTable, $ma * @return array */ public static function updateModeAndPriceSet($entityId, $entityTable, $mode, $linkedEntityTable, $priceSet) { - $finalResult = array(); + $finalResult = []; if (!empty($linkedEntityTable)) { $result = CRM_Core_BAO_RecurringEntity::updateModeLinkedEntity($entityId, $linkedEntityTable, $entityTable); diff --git a/CRM/Core/BAO/SchemaHandler.php b/CRM/Core/BAO/SchemaHandler.php index 33840c922ddf..5fe0666b15c8 100644 --- a/CRM/Core/BAO/SchemaHandler.php +++ b/CRM/Core/BAO/SchemaHandler.php @@ -67,7 +67,7 @@ class CRM_Core_BAO_SchemaHandler { public static function createTable(&$params) { $sql = self::buildTableSQL($params); // do not i18n-rewrite - CRM_Core_DAO::executeQuery($sql, array(), TRUE, NULL, FALSE, FALSE); + CRM_Core_DAO::executeQuery($sql, [], TRUE, NULL, FALSE, FALSE); $config = CRM_Core_Config::singleton(); if ($config->logging) { @@ -258,7 +258,7 @@ public static function changeFKConstraint($tableName, $fkTableName) { ALTER TABLE {$tableName} ADD CONSTRAINT `FK_{$fkName}` FOREIGN KEY (`entity_id`) REFERENCES {$fkTableName} (`id`) ON DELETE CASCADE;"; // CRM-7007: do not i18n-rewrite this query - CRM_Core_DAO::executeQuery($addFKSql, array(), TRUE, NULL, FALSE, FALSE); + CRM_Core_DAO::executeQuery($addFKSql, [], TRUE, NULL, FALSE, FALSE); return TRUE; } @@ -333,7 +333,7 @@ public static function alterFieldSQL(&$params, $indexExist = FALSE, $triggerRebu } // CRM-7007: do not i18n-rewrite this query - CRM_Core_DAO::executeQuery($sql, array(), TRUE, NULL, FALSE, FALSE); + CRM_Core_DAO::executeQuery($sql, [], TRUE, NULL, FALSE, FALSE); $config = CRM_Core_Config::singleton(); if ($config->logging) { @@ -342,7 +342,7 @@ public static function alterFieldSQL(&$params, $indexExist = FALSE, $triggerRebu // Are there any modifies we DON'T was to call this function for (& shouldn't it be clever enough to cope?) if ($params['operation'] == 'add' || $params['operation'] == 'modify') { $logging = new CRM_Logging_Schema(); - $logging->fixSchemaDifferencesFor($params['table_name'], array(trim($prefix) => array($params['name'])), FALSE); + $logging->fixSchemaDifferencesFor($params['table_name'], [trim($prefix) => [$params['name']]], FALSE); } } @@ -378,7 +378,7 @@ public static function dropColumn($tableName, $columnName, $l18n = FALSE, $isUpg CRM_Core_DAO::executeQuery($sql); } else { - CRM_Core_DAO::executeQuery($sql, array(), TRUE, NULL, FALSE, FALSE); + CRM_Core_DAO::executeQuery($sql, [], TRUE, NULL, FALSE, FALSE); } $domain = new CRM_Core_DAO_Domain(); $domain->find(TRUE); @@ -428,8 +428,8 @@ public static function changeUniqueToIndex($tableName, $dropUnique = TRUE) { * @param string $createIndexPrefix * @param array $substrLengths */ - public static function createIndexes($tables, $createIndexPrefix = 'index', $substrLengths = array()) { - $queries = array(); + public static function createIndexes($tables, $createIndexPrefix = 'index', $substrLengths = []) { + $queries = []; $domain = new CRM_Core_DAO_Domain(); $domain->find(TRUE); $locales = explode(CRM_Core_DAO::VALUE_SEPARATOR, $domain->locales); @@ -444,7 +444,7 @@ public static function createIndexes($tables, $createIndexPrefix = 'index', $sub $query = "SHOW INDEX FROM $table"; $dao = CRM_Core_DAO::executeQuery($query); - $currentIndexes = array(); + $currentIndexes = []; while ($dao->fetch()) { $currentIndexes[] = $dao->Key_name; } @@ -466,12 +466,12 @@ public static function createIndexes($tables, $createIndexPrefix = 'index', $sub $lengthSize = isset($substrLengths[$table][$fieldName]) ? "({$substrLengths[$table][$fieldName]})" : ''; } - $names = array( + $names = [ "index_{$fieldName}{$lengthName}", "FK_{$table}_{$fieldName}{$lengthName}", "UI_{$fieldName}{$lengthName}", "{$createIndexPrefix}_{$fieldName}{$lengthName}", - ); + ]; // skip to the next $field if one of the above $names exists; handle multilingual for CRM-4126 foreach ($names as $name) { @@ -512,12 +512,12 @@ public static function createIndexes($tables, $createIndexPrefix = 'index', $sub * @return array('tableName' => array('index1', 'index2')) */ public static function getIndexes($tables) { - $indexes = array(); + $indexes = []; foreach ($tables as $table) { $query = "SHOW INDEX FROM $table"; $dao = CRM_Core_DAO::executeQuery($query); - $tableIndexes = array(); + $tableIndexes = []; while ($dao->fetch()) { $tableIndexes[$dao->Key_name]['name'] = $dao->Key_name; $tableIndexes[$dao->Key_name]['field'][] = $dao->Column_name . @@ -556,10 +556,10 @@ public static function alterFieldLength($customFieldID, $tableName, $columnName, SET text_length = %1 WHERE id = %2 "; - $params = array( - 1 => array($length, 'Integer'), - 2 => array($customFieldID, 'Integer'), - ); + $params = [ + 1 => [$length, 'Integer'], + 2 => [$customFieldID, 'Integer'], + ]; CRM_Core_DAO::executeQuery($sql, $params); $sql = " @@ -589,11 +589,11 @@ public static function alterFieldLength($customFieldID, $tableName, $columnName, } else { CRM_Core_Error::fatal(ts('Could Not Find Custom Field Details for %1, %2, %3', - array( + [ 1 => $tableName, 2 => $columnName, 3 => $customFieldID, - ) + ] )); } } @@ -609,7 +609,7 @@ public static function alterFieldLength($customFieldID, $tableName, $columnName, public static function checkIfIndexExists($tableName, $indexName) { $result = CRM_Core_DAO::executeQuery( "SHOW INDEX FROM $tableName WHERE key_name = %1 AND seq_in_index = 1", - array(1 => array($indexName, 'String')) + [1 => [$indexName, 'String']] ); if ($result->fetch()) { return TRUE; @@ -650,11 +650,11 @@ public static function checkFKExists($table_name, $constraint_name) { AND CONSTRAINT_NAME = %3 AND CONSTRAINT_TYPE = 'FOREIGN KEY' "; - $params = array( - 1 => array($dbUf['database'], 'String'), - 2 => array($table_name, 'String'), - 3 => array($constraint_name, 'String'), - ); + $params = [ + 1 => [$dbUf['database'], 'String'], + 2 => [$table_name, 'String'], + 3 => [$constraint_name, 'String'], + ]; $dao = CRM_Core_DAO::executeQuery($query, $params); if ($dao->fetch()) { @@ -673,7 +673,7 @@ public static function checkFKExists($table_name, $constraint_name) { */ public static function safeRemoveFK($table_name, $constraint_name) { if (self::checkFKExists($table_name, $constraint_name)) { - CRM_Core_DAO::executeQuery("ALTER TABLE {$table_name} DROP FOREIGN KEY {$constraint_name}", array()); + CRM_Core_DAO::executeQuery("ALTER TABLE {$table_name} DROP FOREIGN KEY {$constraint_name}", []); return TRUE; } return FALSE; @@ -704,10 +704,10 @@ public static function addIndexSignature($table, &$indices) { * index specifications */ public static function getMissingIndices($dropFalseIndices = FALSE) { - $requiredSigs = $existingSigs = array(); + $requiredSigs = $existingSigs = []; // Get the indices defined (originally) in the xml files $requiredIndices = CRM_Core_DAO_AllCoreTables::indices(); - $reqSigs = array(); + $reqSigs = []; foreach ($requiredIndices as $table => $indices) { $reqSigs[] = CRM_Utils_Array::collect('sig', $indices); } @@ -715,7 +715,7 @@ public static function getMissingIndices($dropFalseIndices = FALSE) { // Get the indices in the database $existingIndices = CRM_Core_BAO_SchemaHandler::getIndexes(array_keys($requiredIndices)); - $extSigs = array(); + $extSigs = []; foreach ($existingIndices as $table => $indices) { CRM_Core_BAO_SchemaHandler::addIndexSignature($table, $indices); $extSigs[] = CRM_Utils_Array::collect('sig', $indices); @@ -740,7 +740,7 @@ public static function getMissingIndices($dropFalseIndices = FALSE) { } // Get missing indices - $missingIndices = array(); + $missingIndices = []; foreach ($missingSigs as $sig) { $sigParts = explode('::', $sig); if (array_key_exists($sigParts[0], $requiredIndices)) { @@ -761,7 +761,7 @@ public static function getMissingIndices($dropFalseIndices = FALSE) { * @param array $missingIndices as returned by getMissingIndices() */ public static function createMissingIndices($missingIndices) { - $queries = array(); + $queries = []; foreach ($missingIndices as $table => $indexList) { foreach ($indexList as $index) { $queries[] = "CREATE " . diff --git a/CRM/Core/BAO/Setting.php b/CRM/Core/BAO/Setting.php index d5b11242f8c4..2c4b837bda63 100644 --- a/CRM/Core/BAO/Setting.php +++ b/CRM/Core/BAO/Setting.php @@ -118,13 +118,13 @@ public static function getItems(&$params, $domains = NULL, $settingsToReturn) { $domains[] = $originalDomain; } if (!empty($settingsToReturn) && !is_array($settingsToReturn)) { - $settingsToReturn = array($settingsToReturn); + $settingsToReturn = [$settingsToReturn]; } - $fields = $result = array(); + $fields = $result = []; $fieldsToGet = self::validateSettingsInput(array_flip($settingsToReturn), $fields, FALSE); foreach ($domains as $domainID) { - $result[$domainID] = array(); + $result[$domainID] = []; foreach ($fieldsToGet as $name => $value) { $contactID = CRM_Utils_Array::value('contact_id', $params); $setting = CRM_Core_BAO_Setting::getItem(NULL, $name, NULL, NULL, $contactID, $domainID); @@ -190,18 +190,18 @@ public static function setItem( * @return array */ public static function setItems(&$params, $domains = NULL) { - $domains = empty($domains) ? array(CRM_Core_Config::domainID()) : $domains; + $domains = empty($domains) ? [CRM_Core_Config::domainID()] : $domains; // FIXME: redundant validation // FIXME: this whole thing should just be a loop to call $settings->add() on each domain. - $fields = array(); + $fields = []; $fieldsToSet = self::validateSettingsInput($params, $fields); foreach ($fieldsToSet as $settingField => &$settingValue) { if (empty($fields['values'][$settingField])) { - Civi::log()->warning('Deprecated Path: There is a setting (' . $settingField . ') not correctly defined. You may see unpredictability due to this. CRM_Core_Setting::setItems', array('civi.tag' => 'deprecated')); - $fields['values'][$settingField] = array(); + Civi::log()->warning('Deprecated Path: There is a setting (' . $settingField . ') not correctly defined. You may see unpredictability due to this. CRM_Core_Setting::setItems', ['civi.tag' => 'deprecated']); + $fields['values'][$settingField] = []; } self::validateSetting($settingValue, $fields['values'][$settingField]); } @@ -230,7 +230,7 @@ public static function setItems(&$params, $domains = NULL) { * name => value array of the fields to be set (with extraneous removed) */ public static function validateSettingsInput($params, &$fields, $createMode = TRUE) { - $ignoredParams = array( + $ignoredParams = [ 'version', 'id', 'domain_id', @@ -256,9 +256,9 @@ public static function validateSettingsInput($params, &$fields, $createMode = TR // CRM-19877: ignore params extraneously passed by Joomla 'option', 'task', - ); + ]; $settingParams = array_diff_key($params, array_fill_keys($ignoredParams, TRUE)); - $getFieldsParams = array('version' => 3); + $getFieldsParams = ['version' => 3]; if (count($settingParams) == 1) { // ie we are only setting one field - we'll pass it into getfields for efficiency list($name) = array_keys($settingParams); @@ -274,7 +274,7 @@ public static function validateSettingsInput($params, &$fields, $createMode = TR } else { // no filters so we are interested in all for get mode. In create mode this means nothing to set - $filteredFields = $createMode ? array() : $fields['values']; + $filteredFields = $createMode ? [] : $fields['values']; } return $filteredFields; } @@ -360,7 +360,7 @@ public static function validateBoolSetting(&$value, $fieldSpec) { */ public static function getSettingSpecification( $componentID = NULL, - $filters = array(), + $filters = [], $domainID = NULL, $profile = NULL ) { @@ -395,7 +395,7 @@ public static function valueOptions( //enabled name => label require for new contact edit form, CRM-4605 if ($returnNameANDLabels) { - $names = $labels = $nameAndLabels = array(); + $names = $labels = $nameAndLabels = []; if ($returnField == 'name') { $names = $groupValues; $labels = CRM_Core_OptionGroup::values($name, FALSE, FALSE, $localize, $condition, 'label'); @@ -406,7 +406,7 @@ public static function valueOptions( } } - $returnValues = array(); + $returnValues = []; foreach ($groupValues as $gn => $gv) { $returnValues[$gv] = 0; } @@ -452,7 +452,7 @@ public static function setValueOption( elseif (is_array($value)) { $groupValues = CRM_Core_OptionGroup::values($name, FALSE, FALSE, FALSE, NULL, $keyField); - $cbValues = array(); + $cbValues = []; foreach ($groupValues as $key => $val) { if (!empty($value[$val])) { $cbValues[$key] = 1; @@ -503,7 +503,7 @@ public static function isAPIJobAllowedToRun($params) { } } else { - throw new Exception(ts("Job has not been executed as it is a %1 (non-production) environment.", array(1 => $environment))); + throw new Exception(ts("Job has not been executed as it is a %1 (non-production) environment.", [1 => $environment])); } } } @@ -526,7 +526,7 @@ public static function onChangeEnvironmentSetting($oldValue, $newValue, $metadat if ($mailing['outBound_option'] != 2) { Civi::settings()->set('mailing_backend_store', $mailing); } - Civi::settings()->set('mailing_backend', array('outBound_option' => CRM_Mailing_Config::OUTBOUND_OPTION_DISABLED)); + Civi::settings()->set('mailing_backend', ['outBound_option' => CRM_Mailing_Config::OUTBOUND_OPTION_DISABLED]); CRM_Core_Session::setStatus(ts('Outbound emails have been disabled. Scheduled jobs will not run unless runInNonProductionEnvironment=TRUE is added as a parameter for a specific job'), ts("Non-production environment set"), "success"); } else { diff --git a/CRM/Core/BAO/Tag.php b/CRM/Core/BAO/Tag.php index 9528336a3b31..b54aec9df1b3 100644 --- a/CRM/Core/BAO/Tag.php +++ b/CRM/Core/BAO/Tag.php @@ -90,7 +90,7 @@ public function getTree($usedFor = NULL, $excludeHidden = FALSE) { public function buildTree($usedFor = NULL, $excludeHidden = FALSE) { $sql = "SELECT id, parent_id, name, description, is_selectable FROM civicrm_tag"; - $whereClause = array(); + $whereClause = []; if ($usedFor) { $whereClause[] = "used_for like '%{$usedFor}%'"; } @@ -104,10 +104,10 @@ public function buildTree($usedFor = NULL, $excludeHidden = FALSE) { $sql .= " ORDER BY parent_id,name"; - $dao = CRM_Core_DAO::executeQuery($sql, array(), TRUE, NULL, FALSE, FALSE); + $dao = CRM_Core_DAO::executeQuery($sql, [], TRUE, NULL, FALSE, FALSE); - $refs = array(); - $this->tree = array(); + $refs = []; + $this->tree = []; while ($dao->fetch()) { $thisref = &$refs[$dao->id]; @@ -136,18 +136,18 @@ public function buildTree($usedFor = NULL, $excludeHidden = FALSE) { * @return array */ public static function getTagsUsedFor( - $usedFor = array('civicrm_contact'), + $usedFor = ['civicrm_contact'], $buildSelect = TRUE, $all = FALSE, $parentId = NULL ) { - $tags = array(); + $tags = []; if (empty($usedFor)) { return $tags; } if (!is_array($usedFor)) { - $usedFor = array($usedFor); + $usedFor = [$usedFor]; } if ($parentId === NULL) { @@ -210,26 +210,26 @@ public static function getTagsUsedFor( */ public static function getTags( $usedFor = 'civicrm_contact', - &$tags = array(), + &$tags = [], $parentId = NULL, $separator = '  ', $formatSelectable = FALSE ) { if (!is_array($tags)) { - $tags = array(); + $tags = []; } // We need to build a list of tags ordered by hierarchy and sorted by // name. The hierarchy will be communicated by an accumulation of // separators in front of the name to give it a visual offset. // Instead of recursively making mysql queries, we'll make one big // query and build the hierarchy with the algorithm below. - $args = array(1 => array('%' . $usedFor . '%', 'String')); + $args = [1 => ['%' . $usedFor . '%', 'String']]; $query = "SELECT id, name, parent_id, is_tagset, is_selectable FROM civicrm_tag WHERE used_for LIKE %1"; if ($parentId) { $query .= " AND parent_id = %2"; - $args[2] = array($parentId, 'Integer'); + $args[2] = [$parentId, 'Integer']; } $query .= " ORDER BY name"; $dao = CRM_Core_DAO::executeQuery($query, $args, TRUE, NULL, FALSE, FALSE); @@ -239,7 +239,7 @@ public static function getTags( // $roots represents the current leaf nodes that need to be checked for // children. $rows represents the unplaced nodes, not all of much // are necessarily placed. - $roots = $rows = array(); + $roots = $rows = []; while ($dao->fetch()) { // note that we are prepending id with "crm_disabled_opt" which identifies // them as disabled so that they cannot be selected. We do some magic @@ -252,21 +252,21 @@ public static function getTags( $idPrefix = "crm_disabled_opt"; } if ($dao->parent_id == $parentId && $dao->is_tagset == 0) { - $roots[] = array( + $roots[] = [ 'id' => $dao->id, 'prefix' => '', 'name' => $dao->name, 'idPrefix' => $idPrefix, - ); + ]; } else { - $rows[] = array( + $rows[] = [ 'id' => $dao->id, 'prefix' => '', 'name' => $dao->name, 'parent_id' => $dao->parent_id, 'idPrefix' => $idPrefix, - ); + ]; } } @@ -277,14 +277,14 @@ public static function getTags( // iterate through because we must modify the unplaced nodes list // during the loop. while (count($roots)) { - $new_roots = array(); + $new_roots = []; $current_rows = $rows; $root = array_shift($roots); - $tags[$root['id']] = array( + $tags[$root['id']] = [ $root['prefix'], $root['name'], $root['idPrefix'], - ); + ]; // As you find the children, append them to the end of the new set // of roots (maintain alphabetical ordering). Also remove the node @@ -292,12 +292,12 @@ public static function getTags( if (is_array($current_rows)) { foreach ($current_rows as $key => $row) { if ($row['parent_id'] == $root['id']) { - $new_roots[] = array( + $new_roots[] = [ 'id' => $row['id'], 'prefix' => $tags[$root['id']][0] . $separator, 'name' => $row['name'], 'idPrefix' => $row['idPrefix'], - ); + ]; unset($rows[$key]); } } @@ -312,7 +312,7 @@ public static function getTags( // appearance of ordering when transformed into HTML in the form layer. // here is the actual code that to prepends and set disabled attribute for // non-selectable tags - $formattedTags = array(); + $formattedTags = []; foreach ($tags as $key => $tag) { if (!empty($tag[2])) { $key = $tag[2] . "-" . $key; @@ -332,30 +332,30 @@ public static function getTags( * @throws \CiviCRM_API3_Exception */ public static function getColorTags($usedFor = NULL, $allowSelectingNonSelectable = FALSE, $exclude = NULL) { - $params = array( - 'options' => array( + $params = [ + 'options' => [ 'limit' => 0, 'sort' => "name ASC", - ), + ], 'is_tagset' => 0, - 'return' => array('name', 'description', 'parent_id', 'color', 'is_selectable', 'used_for'), - ); + 'return' => ['name', 'description', 'parent_id', 'color', 'is_selectable', 'used_for'], + ]; if ($usedFor) { - $params['used_for'] = array('LIKE' => "%$usedFor%"); + $params['used_for'] = ['LIKE' => "%$usedFor%"]; } if ($exclude) { - $params['id'] = array('!=' => $exclude); + $params['id'] = ['!=' => $exclude]; } - $allTags = array(); + $allTags = []; foreach (CRM_Utils_Array::value('values', civicrm_api3('Tag', 'get', $params)) as $id => $tag) { - $allTags[$id] = array( + $allTags[$id] = [ 'text' => $tag['name'], 'id' => $id, 'description' => CRM_Utils_Array::value('description', $tag), 'parent_id' => CRM_Utils_Array::value('parent_id', $tag), 'used_for' => CRM_Utils_Array::value('used_for', $tag), 'color' => CRM_Utils_Array::value('color', $tag), - ); + ]; if (!$allowSelectingNonSelectable && empty($tag['is_selectable'])) { $allTags[$id]['disabled'] = TRUE; } @@ -410,7 +410,7 @@ public static function del($id) { * @return CRM_Core_DAO_Tag|null * object on success, otherwise null */ - public static function add(&$params, $ids = array()) { + public static function add(&$params, $ids = []) { $id = CRM_Utils_Array::value('id', $params, CRM_Utils_Array::value('tag', $ids)); if (!$id && !self::dataExists($params)) { return NULL; @@ -464,10 +464,10 @@ public static function add(&$params, $ids = array()) { $tag->find(TRUE); if (!$tag->parent_id && $tag->used_for) { CRM_Core_DAO::executeQuery("UPDATE civicrm_tag SET used_for=%1 WHERE parent_id = %2", - array( - 1 => array($tag->used_for, 'String'), - 2 => array($tag->id, 'Integer'), - ) + [ + 1 => [$tag->used_for, 'String'], + 2 => [$tag->id, 'Integer'], + ] ); } @@ -502,15 +502,15 @@ public static function dataExists(&$params) { * array of tag sets */ public static function getTagSet($entityTable) { - $tagSets = array(); + $tagSets = []; $query = "SELECT name, id FROM civicrm_tag WHERE is_tagset=1 AND parent_id IS NULL and used_for LIKE %1"; - $dao = CRM_Core_DAO::executeQuery($query, array( - 1 => array( + $dao = CRM_Core_DAO::executeQuery($query, [ + 1 => [ '%' . $entityTable . '%', 'String', - ), - ), TRUE, NULL, FALSE, FALSE); + ], + ], TRUE, NULL, FALSE, FALSE); while ($dao->fetch()) { $tagSets[$dao->id] = $dao->name; } @@ -525,7 +525,7 @@ public static function getTagSet($entityTable) { * associated array of tag name and id */ public static function getTagsNotInTagset() { - $tags = $tagSets = array(); + $tags = $tagSets = []; // first get all the tag sets $query = "SELECT id FROM civicrm_tag WHERE is_tagset=1 AND parent_id IS NULL"; $dao = CRM_Core_DAO::executeQuery($query); @@ -557,9 +557,9 @@ public static function getTagsNotInTagset() { * associated array of child tags in Array('Parent Tag ID' => Array('Child Tag 1', ...)) format */ public static function getChildTags($searchString = NULL) { - $childTagIDs = array(); + $childTagIDs = []; - $whereClauses = array('parent.is_tagset <> 1'); + $whereClauses = ['parent.is_tagset <> 1']; if ($searchString) { $whereClauses[] = " child.name LIKE '%$searchString%' "; } @@ -579,7 +579,7 @@ public static function getChildTags($searchString = NULL) { while ($parentID) { $newParentID = CRM_Core_DAO::singleValueQuery(" SELECT parent_id FROM civicrm_tag WHERE id = $parentID "); if ($newParentID) { - $childTagIDs[$newParentID] = array($parentID); + $childTagIDs[$newParentID] = [$parentID]; } $parentID = $newParentID; } diff --git a/CRM/Core/BAO/UFField.php b/CRM/Core/BAO/UFField.php index ecf53c38784b..37ee29e17aec 100644 --- a/CRM/Core/BAO/UFField.php +++ b/CRM/Core/BAO/UFField.php @@ -54,10 +54,10 @@ class CRM_Core_BAO_UFField extends CRM_Core_DAO_UFField { public static function create(&$params) { // CRM-14756: kind of a hack-ish fix. If the user gives the id, uf_group_id is retrieved and then set. if (isset($params['id'])) { - $groupId = civicrm_api3('UFField', 'getvalue', array( + $groupId = civicrm_api3('UFField', 'getvalue', [ 'return' => 'uf_group_id', 'id' => $params['id'], - )); + ]); } else { $groupId = CRM_Utils_Array::value('uf_group_id', $params); @@ -97,7 +97,7 @@ public static function create(&$params) { $field_type = CRM_Utils_Array::value('field_type', $params); $location_type_id = CRM_Utils_Array::value('location_type_id', $params, CRM_Utils_Array::value('website_type_id', $params)); $phone_type = CRM_Utils_Array::value('phone_type_id', $params, CRM_Utils_Array::value('phone_type', $params)); - $params['field_name'] = array($field_type, $field_name, $location_type_id, $phone_type); + $params['field_name'] = [$field_type, $field_name, $location_type_id, $phone_type]; //@todo why is this even optional? Surely weight should just be 'managed' ?? if (CRM_Utils_Array::value('option.autoweight', $params, TRUE)) { $params['weight'] = CRM_Core_BAO_UFField::autoWeight($params); @@ -131,7 +131,7 @@ public static function create(&$params) { $fieldsType = CRM_Core_BAO_UFGroup::calculateGroupType($groupId, TRUE); CRM_Core_BAO_UFGroup::updateGroupTypes($groupId, $fieldsType); - civicrm_api3('profile', 'getfields', array('cache_clear' => TRUE)); + civicrm_api3('profile', 'getfields', ['cache_clear' => TRUE]); return $ufField; } @@ -235,9 +235,9 @@ public static function checkMultiRecordFieldExists($gId) { FROM civicrm_uf_field f, civicrm_uf_group g WHERE f.uf_group_id = g.id AND g.id = %1 AND f.field_name LIKE 'custom%'"; - $p = array(1 => array($gId, 'Integer')); + $p = [1 => [$gId, 'Integer']]; $dao = CRM_Core_DAO::executeQuery($queryString, $p); - $customFieldIds = array(); + $customFieldIds = []; $isMultiRecordFieldPresent = FALSE; while ($dao->fetch()) { if ($customId = CRM_Core_BAO_CustomField::getKeyID($dao->field_name)) { @@ -283,7 +283,7 @@ public static function autoWeight($params) { if (!empty($params['field_id'])) { $oldWeight = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFField', $params['field_id'], 'weight', 'id'); } - $fieldValues = array('uf_group_id' => $params['group_id']); + $fieldValues = ['uf_group_id' => $params['group_id']]; return CRM_Utils_Weight::updateOtherWeights('CRM_Core_DAO_UFField', $oldWeight, CRM_Utils_Array::value('weight', $params, 0), $fieldValues); } @@ -360,7 +360,7 @@ public static function setUFFieldStatus($customGroupId, $is_active) { FROM civicrm_custom_field, civicrm_custom_group WHERE civicrm_custom_field.custom_group_id = civicrm_custom_group.id AND civicrm_custom_group.id = %1"; - $p = array(1 => array($customGroupId, 'Integer')); + $p = [1 => [$customGroupId, 'Integer']]; $dao = CRM_Core_DAO::executeQuery($queryString, $p); while ($dao->fetch()) { @@ -419,7 +419,7 @@ public static function checkContactActivityProfileType($ufGroupId) { * @return bool */ public static function checkContactActivityProfileTypeByGroupType($ufGroupType) { - $profileTypes = array(); + $profileTypes = []; if ($ufGroupType) { $typeParts = explode(CRM_Core_DAO::VALUE_SEPARATOR, $ufGroupType); $profileTypes = explode(',', $typeParts[0]); @@ -428,7 +428,7 @@ public static function checkContactActivityProfileTypeByGroupType($ufGroupType) if (empty($profileTypes)) { return FALSE; } - $components = array('Contribution', 'Participant', 'Membership'); + $components = ['Contribution', 'Participant', 'Membership']; if (!in_array('Activity', $profileTypes)) { return FALSE; } @@ -443,7 +443,7 @@ public static function checkContactActivityProfileTypeByGroupType($ufGroupType) } } - $contactTypes = array('Individual', 'Household', 'Organization'); + $contactTypes = ['Individual', 'Household', 'Organization']; $subTypes = CRM_Contact_BAO_ContactType::subTypes(); $profileTypeComponent = array_intersect($components, $profileTypes); @@ -479,7 +479,7 @@ public static function checkValidProfileType($ufGroupId, $required, $optional = $ufGroup->id = $ufGroupId; $ufGroup->find(TRUE); - $profileTypes = array(); + $profileTypes = []; if ($ufGroup->group_type) { $typeParts = explode(CRM_Core_DAO::VALUE_SEPARATOR, $ufGroup->group_type); $profileTypes = explode(',', $typeParts[0]); @@ -522,7 +522,7 @@ public static function checkProfileType($ufGroupId) { $ufGroup->id = $ufGroupId; $ufGroup->find(TRUE); - $profileTypes = array(); + $profileTypes = []; if ($ufGroup->group_type) { $typeParts = explode(CRM_Core_DAO::VALUE_SEPARATOR, $ufGroup->group_type); $profileTypes = explode(',', $typeParts[0]); @@ -544,9 +544,9 @@ public static function checkProfileType($ufGroupId) { // suppress any subtypes if present CRM_Contact_BAO_ContactType::suppressSubTypes($profileTypes); - $contactTypes = array('Contact', 'Individual', 'Household', 'Organization'); - $components = array('Contribution', 'Participant', 'Membership', 'Activity'); - $fields = array(); + $contactTypes = ['Contact', 'Individual', 'Household', 'Organization']; + $components = ['Contribution', 'Participant', 'Membership', 'Activity']; + $fields = []; // check for mix profile condition if (count($profileTypes) > 1) { @@ -612,11 +612,11 @@ public static function getProfileType($ufGroupId, $returnMixType = TRUE, $onlyPu */ public static function calculateProfileType($ufGroupType, $returnMixType = TRUE, $onlyPure = FALSE, $skipComponentType = FALSE) { // profile types - $contactTypes = array('Contact', 'Individual', 'Household', 'Organization'); + $contactTypes = ['Contact', 'Individual', 'Household', 'Organization']; $subTypes = CRM_Contact_BAO_ContactType::subTypes(); - $components = array('Contribution', 'Participant', 'Membership', 'Activity'); + $components = ['Contribution', 'Participant', 'Membership', 'Activity']; - $profileTypes = array(); + $profileTypes = []; if ($ufGroupType) { $typeParts = explode(CRM_Core_DAO::VALUE_SEPARATOR, $ufGroupType); $profileTypes = explode(',', $typeParts[0]); @@ -647,7 +647,7 @@ public static function calculateProfileType($ufGroupType, $returnMixType = TRUE, } else { //check the there are any components include in profile - $componentCount = array(); + $componentCount = []; foreach ($components as $value) { if (in_array($value, $profileTypes)) { $componentCount[] = $value; @@ -655,14 +655,14 @@ public static function calculateProfileType($ufGroupType, $returnMixType = TRUE, } //check contact type included in profile - $contactTypeCount = array(); + $contactTypeCount = []; foreach ($contactTypes as $value) { if (in_array($value, $profileTypes)) { $contactTypeCount[] = $value; } } // subtype counter - $subTypeCount = array(); + $subTypeCount = []; foreach ($subTypes as $value) { if (in_array($value, $profileTypes)) { $subTypeCount[] = $value; @@ -723,8 +723,8 @@ public static function checkProfileGroupType($ctype) { $ufGroup = CRM_Core_DAO::executeQuery($query); - $fields = array(); - $validProfiles = array('Individual', 'Organization', 'Household', 'Contribution'); + $fields = []; + $validProfiles = ['Individual', 'Organization', 'Household', 'Contribution']; while ($ufGroup->fetch()) { $profileType = self::getProfileType($ufGroup->id); if (in_array($profileType, $validProfiles)) { @@ -810,16 +810,16 @@ public static function assignAddressField($key, &$profileAddressFields, $profile list($prefixName, $index) = CRM_Utils_System::explode('-', $key, 2); $profileFields = civicrm_api3('uf_field', 'get', array_merge($profileFilter, - array( + [ 'is_active' => 1, 'return' => 'field_name, is_required', - 'options' => array( + 'options' => [ 'limit' => 0, - ), - ) + ], + ] )); //check for valid fields ( fields that are present in billing block ) - $validBillingFields = array( + $validBillingFields = [ 'first_name', 'middle_name', 'last_name', @@ -829,10 +829,10 @@ public static function assignAddressField($key, &$profileAddressFields, $profile 'state_province', 'postal_code', 'country', - ); - $requiredBillingFields = array_diff($validBillingFields, array('middle_name', 'supplemental_address_1')); - $validProfileFields = array(); - $requiredProfileFields = array(); + ]; + $requiredBillingFields = array_diff($validBillingFields, ['middle_name', 'supplemental_address_1']); + $validProfileFields = []; + $requiredProfileFields = []; foreach ($profileFields['values'] as $field) { if (in_array($field['field_name'], $validBillingFields)) { @@ -865,7 +865,7 @@ public static function assignAddressField($key, &$profileAddressFields, $profile $potentiallyMissingRequiredFields = array_diff($requiredBillingFields, $requiredProfileFields); CRM_Core_Resources::singleton() - ->addSetting(array('billing' => array('billingProfileIsHideable' => empty($potentiallyMissingRequiredFields)))); + ->addSetting(['billing' => ['billingProfileIsHideable' => empty($potentiallyMissingRequiredFields)]]); } /** @@ -875,22 +875,22 @@ public static function assignAddressField($key, &$profileAddressFields, $profile * @param array $defaults : Form defaults * @return array, multidimensional; e.g. $result['FieldGroup']['field_name']['label'] */ - public static function getAvailableFields($gid = NULL, $defaults = array()) { - $fields = array( - 'Contact' => array(), + public static function getAvailableFields($gid = NULL, $defaults = []) { + $fields = [ + 'Contact' => [], 'Individual' => CRM_Contact_BAO_Contact::importableFields('Individual', FALSE, FALSE, TRUE, TRUE, TRUE), 'Household' => CRM_Contact_BAO_Contact::importableFields('Household', FALSE, FALSE, TRUE, TRUE, TRUE), 'Organization' => CRM_Contact_BAO_Contact::importableFields('Organization', FALSE, FALSE, TRUE, TRUE, TRUE), - ); + ]; // include hook injected fields $fields['Contact'] = array_merge($fields['Contact'], CRM_Contact_BAO_Query_Hook::singleton()->getFields()); // add current employer for individuals - $fields['Individual']['current_employer'] = array( + $fields['Individual']['current_employer'] = [ 'name' => 'organization_name', 'title' => ts('Current Employer'), - ); + ]; $addressOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'address_options', TRUE, NULL, TRUE @@ -917,11 +917,11 @@ public static function getAvailableFields($gid = NULL, $defaults = array()) { //unset extension unset($fields['Contact']['phone_ext']); //add psedo field - $fields['Contact']['phone_and_ext'] = array( + $fields['Contact']['phone_and_ext'] = [ 'name' => 'phone_and_ext', 'title' => ts('Phone and Extension'), 'hasLocationType' => 1, - ); + ]; // include Subtypes For Profile $subTypes = CRM_Contact_BAO_ContactType::subTypeInfo(); @@ -942,10 +942,10 @@ public static function getAvailableFields($gid = NULL, $defaults = array()) { unset($contribFields['is_test']); unset($contribFields['is_pay_later']); unset($contribFields['contribution_id']); - $contribFields['contribution_note'] = array( + $contribFields['contribution_note'] = [ 'name' => 'contribution_note', 'title' => ts('Contribution Note'), - ); + ]; $fields['Contribution'] = array_merge($contribFields, self::getContribBatchEntryFields()); } } @@ -1017,12 +1017,12 @@ public static function getAvailableFields($gid = NULL, $defaults = array()) { $fields['Activity'] = $activityFields; } - $fields['Formatting']['format_free_html_' . rand(1000, 9999)] = array( + $fields['Formatting']['format_free_html_' . rand(1000, 9999)] = [ 'name' => 'free_html', 'import' => FALSE, 'export' => FALSE, 'title' => 'Free HTML', - ); + ]; // Sort by title foreach ($fields as &$values) { @@ -1030,14 +1030,14 @@ public static function getAvailableFields($gid = NULL, $defaults = array()) { } //group selected and unwanted fields list - $ufFields = $gid ? CRM_Core_BAO_UFGroup::getFields($gid, FALSE, NULL, NULL, NULL, TRUE, NULL, TRUE) : array(); - $groupFieldList = array_merge($ufFields, array( + $ufFields = $gid ? CRM_Core_BAO_UFGroup::getFields($gid, FALSE, NULL, NULL, NULL, TRUE, NULL, TRUE) : []; + $groupFieldList = array_merge($ufFields, [ 'note', 'email_greeting_custom', 'postal_greeting_custom', 'addressee_custom', 'id', - )); + ]); //unset selected fields foreach ($groupFieldList as $key => $value) { if (is_int($key)) { @@ -1068,7 +1068,7 @@ public static function getAvailableFieldsFlat($force = FALSE) { static $result = NULL; if ($result === NULL || $force) { $fieldTree = self::getAvailableFields(); - $result = array(); + $result = []; foreach ($fieldTree as $field_type => $fields) { foreach ($fields as $field_name => $field) { if (!isset($result[$field_name])) { @@ -1097,32 +1097,32 @@ public static function isValidFieldName($fieldName) { */ public static function getContribBatchEntryFields() { if (self::$_contriBatchEntryFields === NULL) { - self::$_contriBatchEntryFields = array( - 'send_receipt' => array( + self::$_contriBatchEntryFields = [ + 'send_receipt' => [ 'name' => 'send_receipt', 'title' => ts('Send Receipt'), - ), - 'soft_credit' => array( + ], + 'soft_credit' => [ 'name' => 'soft_credit', 'title' => ts('Soft Credit'), - ), - 'soft_credit_type' => array( + ], + 'soft_credit_type' => [ 'name' => 'soft_credit_type', 'title' => ts('Soft Credit Type'), - ), - 'product_name' => array( + ], + 'product_name' => [ 'name' => 'product_name', 'title' => ts('Premiums'), - ), - 'contribution_note' => array( + ], + 'contribution_note' => [ 'name' => 'contribution_note', 'title' => ts('Contribution Note'), - ), - 'contribution_soft_credit_pcp_id' => array( + ], + 'contribution_soft_credit_pcp_id' => [ 'name' => 'contribution_soft_credit_pcp_id', 'title' => ts('Personal Campaign Page'), - ), - ); + ], + ]; } return self::$_contriBatchEntryFields; } @@ -1132,44 +1132,44 @@ public static function getContribBatchEntryFields() { */ public static function getMemberBatchEntryFields() { if (self::$_memberBatchEntryFields === NULL) { - self::$_memberBatchEntryFields = array( - 'send_receipt' => array( + self::$_memberBatchEntryFields = [ + 'send_receipt' => [ 'name' => 'send_receipt', 'title' => ts('Send Receipt'), - ), - 'soft_credit' => array( + ], + 'soft_credit' => [ 'name' => 'soft_credit', 'title' => ts('Soft Credit'), - ), - 'product_name' => array( + ], + 'product_name' => [ 'name' => 'product_name', 'title' => ts('Premiums'), - ), - 'financial_type' => array( + ], + 'financial_type' => [ 'name' => 'financial_type', 'title' => ts('Financial Type'), - ), - 'total_amount' => array( + ], + 'total_amount' => [ 'name' => 'total_amount', 'title' => ts('Total Amount'), - ), - 'receive_date' => array( + ], + 'receive_date' => [ 'name' => 'receive_date', 'title' => ts('Date Received'), - ), - 'payment_instrument' => array( + ], + 'payment_instrument' => [ 'name' => 'payment_instrument', 'title' => ts('Payment Method'), - ), - 'contribution_status_id' => array( + ], + 'contribution_status_id' => [ 'name' => 'contribution_status_id', 'title' => ts('Contribution Status'), - ), - 'trxn_id' => array( + ], + 'trxn_id' => [ 'name' => 'contribution_trxn_id', 'title' => ts('Contribution Transaction ID'), - ), - ); + ], + ]; } return self::$_memberBatchEntryFields; } diff --git a/CRM/Core/BAO/UFJoin.php b/CRM/Core/BAO/UFJoin.php index 9fb799975eb1..a4fcababf732 100644 --- a/CRM/Core/BAO/UFJoin.php +++ b/CRM/Core/BAO/UFJoin.php @@ -166,7 +166,7 @@ public static function getUFGroupIds(&$params) { $dao->orderBy('weight asc'); $dao->find(); $first = $firstActive = NULL; - $second = $secondActive = array(); + $second = $secondActive = []; while ($dao->fetch()) { if ($dao->weight == 1) { @@ -178,7 +178,7 @@ public static function getUFGroupIds(&$params) { $secondActive[] = $dao->is_active; } } - return array($first, $second, $firstActive, $secondActive); + return [$first, $second, $firstActive, $secondActive]; } /** @@ -186,11 +186,11 @@ public static function getUFGroupIds(&$params) { * @return array */ public static function entityTables() { - return array( + return [ 'civicrm_event' => 'Event', 'civicrm_contribution_page' => 'ContributionPage', 'civicrm_survey' => 'Survey', - ); + ]; } } diff --git a/CRM/Core/BAO/UFMatch.php b/CRM/Core/BAO/UFMatch.php index 333b12369e30..dab5fa387930 100644 --- a/CRM/Core/BAO/UFMatch.php +++ b/CRM/Core/BAO/UFMatch.php @@ -147,11 +147,11 @@ public static function synchronize(&$user, $update, $uf, $ctype, $isLogin = FALS list($displayName, $contactImage, $contactType, $contactSubtype, $contactImageUrl) = CRM_Contact_BAO_Contact::getDisplayAndImage($ufmatch->contact_id, TRUE, TRUE); - $otherRecent = array( + $otherRecent = [ 'imageUrl' => $contactImageUrl, 'subtype' => $contactSubtype, 'editUrl' => CRM_Utils_System::url('civicrm/contact/add', "reset=1&action=update&cid={$ufmatch->contact_id}"), - ); + ]; CRM_Utils_Recent::add($displayName, CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$ufmatch->contact_id}"), @@ -207,7 +207,7 @@ public static function &synchronizeUFMatch(&$user, $userKey, $uniqId, $uf, $stat $params = $_POST; $params['email'] = $uniqId; - $ids = CRM_Contact_BAO_Contact::getDuplicateContacts($params, 'Individual', 'Unsupervised', array(), FALSE); + $ids = CRM_Contact_BAO_Contact::getDuplicateContacts($params, 'Individual', 'Unsupervised', [], FALSE); if (!empty($ids) && Civi::settings()->get('uniq_email_per_site')) { // restrict dupeIds to ones that belong to current domain/site. @@ -240,10 +240,10 @@ public static function &synchronizeUFMatch(&$user, $userKey, $uniqId, $uf, $stat WHERE contact_id = %1 AND domain_id = %2 "; - $params = array( - 1 => array($dao->contact_id, 'Integer'), - 2 => array(CRM_Core_Config::domainID(), 'Integer'), - ); + $params = [ + 1 => [$dao->contact_id, 'Integer'], + 2 => [CRM_Core_Config::domainID(), 'Integer'], + ]; $conflict = CRM_Core_DAO::singleValueQuery($sql, $params); if (!$conflict) { @@ -266,7 +266,7 @@ public static function &synchronizeUFMatch(&$user, $userKey, $uniqId, $uf, $stat else { $primary_email = $user->email; } - $params = array('email-Primary' => $primary_email); + $params = ['email-Primary' => $primary_email]; } if ($ctype == 'Organization') { @@ -313,12 +313,12 @@ public static function &synchronizeUFMatch(&$user, $userKey, $uniqId, $uf, $stat OR uf_id = %3 ) AND domain_id = %4 "; - $params = array( - 1 => array($ufmatch->contact_id, 'Integer'), - 2 => array($ufmatch->uf_name, 'String'), - 3 => array($ufmatch->uf_id, 'Integer'), - 4 => array($ufmatch->domain_id, 'Integer'), - ); + $params = [ + 1 => [$ufmatch->contact_id, 'Integer'], + 2 => [$ufmatch->uf_name, 'String'], + 3 => [$ufmatch->uf_id, 'Integer'], + 4 => [$ufmatch->domain_id, 'Integer'], + ]; $conflict = CRM_Core_DAO::singleValueQuery($sql, $params); @@ -330,12 +330,12 @@ public static function &synchronizeUFMatch(&$user, $userKey, $uniqId, $uf, $stat } else { $msg = ts("Contact ID %1 is a match for %2 user %3 but has already been matched to %4", - array( + [ 1 => $ufmatch->contact_id, 2 => $uf, 3 => $ufmatch->uf_id, 4 => $conflict, - ) + ] ); unset($conflict); } @@ -437,10 +437,10 @@ public static function updateContactEmail($contactId, $emailAddress) { $query = "UPDATE civicrm_email SET email = %1 WHERE id = %2"; - $p = array( - 1 => array($emailAddress, 'String'), - 2 => array($emailID, 'Integer'), - ); + $p = [ + 1 => [$emailAddress, 'String'], + 2 => [$emailID, 'Integer'], + ]; $dao = CRM_Core_DAO::executeQuery($query, $p); } else { @@ -554,7 +554,7 @@ public static function isEmptyTable() { * contact_id on success, null otherwise */ public static function getContactIDs() { - $id = array(); + $id = []; $dao = new CRM_Core_DAO_UFMatch(); $dao->find(); while ($dao->fetch()) { @@ -636,7 +636,7 @@ public static function getUFValues($ufID = NULL) { $ufID = CRM_Utils_System::getLoggedInUfID(); } if (!$ufID) { - return array(); + return []; } static $ufValues; @@ -645,12 +645,12 @@ public static function getUFValues($ufID = NULL) { $ufmatch->uf_id = $ufID; $ufmatch->domain_id = CRM_Core_Config::domainID(); if ($ufmatch->find(TRUE)) { - $ufValues[$ufID] = array( + $ufValues[$ufID] = [ 'uf_id' => $ufmatch->uf_id, 'uf_name' => $ufmatch->uf_name, 'contact_id' => $ufmatch->contact_id, 'domain_id' => $ufmatch->domain_id, - ); + ]; } } return $ufValues[$ufID]; @@ -661,7 +661,7 @@ public static function getUFValues($ufID = NULL) { */ public function addSelectWhereClause() { // Prevent default behavior of joining ACLs onto the contact_id field - $clauses = array(); + $clauses = []; CRM_Utils_Hook::selectWhereClause($this, $clauses); return $clauses; } diff --git a/CRM/Core/BAO/Website.php b/CRM/Core/BAO/Website.php index 29e118b95848..f947253594eb 100644 --- a/CRM/Core/BAO/Website.php +++ b/CRM/Core/BAO/Website.php @@ -155,14 +155,14 @@ public static function del($id) { * @return bool */ public static function &getValues(&$params, &$values) { - $websites = array(); + $websites = []; $website = new CRM_Core_DAO_Website(); $website->contact_id = $params['contact_id']; $website->find(); $count = 1; while ($website->fetch()) { - $values['website'][$count] = array(); + $values['website'][$count] = []; CRM_Core_DAO::storeValues($website, $values['website'][$count]); $websites[$count] = $values['website'][$count]; @@ -192,16 +192,16 @@ public static function allWebsites($id, $updateBlankLocInfo = FALSE) { SELECT id, website_type_id FROM civicrm_website WHERE civicrm_website.contact_id = %1'; - $params = array(1 => array($id, 'Integer')); + $params = [1 => [$id, 'Integer']]; - $websites = $values = array(); + $websites = $values = []; $dao = CRM_Core_DAO::executeQuery($query, $params); $count = 1; while ($dao->fetch()) { - $values = array( + $values = [ 'id' => $dao->id, 'website_type_id' => $dao->website_type_id, - ); + ]; if ($updateBlankLocInfo) { $websites[$count++] = $values; diff --git a/CRM/Core/BAO/WordReplacement.php b/CRM/Core/BAO/WordReplacement.php index 47182a93173c..c234f68ccdd4 100644 --- a/CRM/Core/BAO/WordReplacement.php +++ b/CRM/Core/BAO/WordReplacement.php @@ -153,11 +153,11 @@ public static function getAllAsConfigArray($id) { FROM civicrm_word_replacement WHERE domain_id = %1 "; - $params = array(1 => array($id, 'Integer')); + $params = [1 => [$id, 'Integer']]; $dao = CRM_Core_DAO::executeQuery($query, $params); - $overrides = array(); + $overrides = []; while ($dao->fetch()) { if ($dao->is_active == 1) { @@ -223,26 +223,26 @@ public static function rebuild($clearCaches = TRUE) { * @see CRM_Core_BAO_WordReplacement::convertConfigArraysToAPIParams */ public static function getConfigArraysAsAPIParams($rebuildEach) { - $settingsResult = civicrm_api3('Setting', 'get', array( + $settingsResult = civicrm_api3('Setting', 'get', [ 'return' => 'lcMessages', - )); + ]); $returnValues = CRM_Utils_Array::first($settingsResult['values']); $lang = $returnValues['lcMessages']; - $wordReplacementCreateParams = array(); + $wordReplacementCreateParams = []; // get all domains - $result = civicrm_api3('domain', 'get', array( - 'return' => array('locale_custom_strings'), - )); + $result = civicrm_api3('domain', 'get', [ + 'return' => ['locale_custom_strings'], + ]); if (!empty($result["values"])) { foreach ($result["values"] as $value) { - $params = array(); + $params = []; $params["domain_id"] = $value["id"]; - $params["options"] = array('wp-rebuild' => $rebuildEach); + $params["options"] = ['wp-rebuild' => $rebuildEach]; // Unserialize word match string. $localeCustomArray = unserialize($value["locale_custom_strings"]); if (!empty($localeCustomArray)) { - $wordMatchArray = array(); + $wordMatchArray = []; // Only return the replacement strings of the current language, // otherwise some replacements will be duplicated, which will // lead to undesired results, like CRM-19683. @@ -279,10 +279,10 @@ public static function getConfigArraysAsAPIParams($rebuildEach) { * bug-fix in both places. */ public static function rebuildWordReplacementTable() { - civicrm_api3('word_replacement', 'replace', array( - 'options' => array('match' => array('domain_id', 'find_word')), + civicrm_api3('word_replacement', 'replace', [ + 'options' => ['match' => ['domain_id', 'find_word']], 'values' => self::getConfigArraysAsAPIParams(FALSE), - )); + ]); CRM_Core_BAO_WordReplacement::rebuild(); } @@ -312,11 +312,11 @@ public static function getLocaleCustomStrings($locale, $domainId = NULL) { */ private static function _getLocaleCustomStrings($domainId) { // TODO: Would it be worthwhile using memcache here? - $domain = CRM_Core_DAO::executeQuery('SELECT locale_custom_strings FROM civicrm_domain WHERE id = %1', array( - 1 => array($domainId, 'Integer'), - )); + $domain = CRM_Core_DAO::executeQuery('SELECT locale_custom_strings FROM civicrm_domain WHERE id = %1', [ + 1 => [$domainId, 'Integer'], + ]); while ($domain->fetch()) { - return empty($domain->locale_custom_strings) ? array() : unserialize($domain->locale_custom_strings); + return empty($domain->locale_custom_strings) ? [] : unserialize($domain->locale_custom_strings); } } @@ -345,10 +345,10 @@ public static function setLocaleCustomStrings($locale, $values, $domainId = NULL * @param string $lcs */ private static function _setLocaleCustomStrings($domainId, $lcs) { - CRM_Core_DAO::executeQuery("UPDATE civicrm_domain SET locale_custom_strings = %1 WHERE id = %2", array( - 1 => array(serialize($lcs), 'String'), - 2 => array($domainId, 'Integer'), - )); + CRM_Core_DAO::executeQuery("UPDATE civicrm_domain SET locale_custom_strings = %1 WHERE id = %2", [ + 1 => [serialize($lcs), 'String'], + 2 => [$domainId, 'Integer'], + ]); } } diff --git a/CRM/Core/ClassLoader.php b/CRM/Core/ClassLoader.php index 17998d223501..2a9606d5275a 100644 --- a/CRM/Core/ClassLoader.php +++ b/CRM/Core/ClassLoader.php @@ -71,7 +71,7 @@ public static function &singleton($force = FALSE) { */ protected function __construct() { $this->_registered = FALSE; - $this->civiTestClasses = array( + $this->civiTestClasses = [ 'CiviCaseTestCase', 'CiviDBAssert', 'CiviMailUtils', @@ -87,7 +87,7 @@ protected function __construct() { 'Membership', 'Participant', 'PaypalPro', - ); + ]; } /** @@ -133,16 +133,16 @@ public function register($prepend = FALSE) { // CRM-11304 // TODO Remove this autoloader. For civicrm-core and civicrm-packages, the composer autoloader works fine. // Extensions rely on include_path-based autoloading - spl_autoload_register(array($this, 'loadClass'), TRUE, $prepend); + spl_autoload_register([$this, 'loadClass'], TRUE, $prepend); $this->initHtmlPurifier($prepend); $this->_registered = TRUE; - $packages_path = implode(DIRECTORY_SEPARATOR, array($civicrm_base_path, 'packages')); - $include_paths = array( + $packages_path = implode(DIRECTORY_SEPARATOR, [$civicrm_base_path, 'packages']); + $include_paths = [ '.', $civicrm_base_path, $packages_path, - ); + ]; $include_paths = implode(PATH_SEPARATOR, $include_paths); set_include_path($include_paths . PATH_SEPARATOR . get_include_path()); // @todo Why do we need to load this again? @@ -167,7 +167,7 @@ public function initHtmlPurifier($prepend) { return; } require_once $htmlPurifierPath; - spl_autoload_register(array('HTMLPurifier_Bootstrap', 'autoload'), TRUE, $prepend); + spl_autoload_register(['HTMLPurifier_Bootstrap', 'autoload'], TRUE, $prepend); } /** diff --git a/CRM/Core/CodeGen/Config.php b/CRM/Core/CodeGen/Config.php index 1d6b2431d196..9adc75a4434d 100644 --- a/CRM/Core/CodeGen/Config.php +++ b/CRM/Core/CodeGen/Config.php @@ -9,13 +9,13 @@ public function run() { } public function setupCms() { - if (!in_array($this->config->cms, array( + if (!in_array($this->config->cms, [ 'backdrop', 'drupal', 'drupal8', 'joomla', 'wordpress', - ))) { + ])) { echo "Config file for '{$this->config->cms}' not known."; exit(); } @@ -38,7 +38,7 @@ public function setupCms() { * path to config template */ public function findConfigTemplate($cms) { - $candidates = array(); + $candidates = []; switch ($cms) { case 'backdrop': // FIXME!!!! diff --git a/CRM/Core/CodeGen/DAO.php b/CRM/Core/CodeGen/DAO.php index 1a47be7cc5db..69cc8d0e479a 100644 --- a/CRM/Core/CodeGen/DAO.php +++ b/CRM/Core/CodeGen/DAO.php @@ -71,7 +71,7 @@ public function run() { $template = new CRM_Core_CodeGen_Util_Template('php'); $template->assign('table', $this->tables[$this->name]); if (empty($this->tables[$this->name]['index'])) { - $template->assign('indicesPhp', var_export(array(), 1)); + $template->assign('indicesPhp', var_export([], 1)); } else { $template->assign('indicesPhp', var_export($this->tables[$this->name]['index'], 1)); @@ -91,7 +91,7 @@ public function getRaw() { $template = new CRM_Core_CodeGen_Util_Template('php'); $template->assign('table', $this->tables[$this->name]); if (empty($this->tables[$this->name]['index'])) { - $template->assign('indicesPhp', var_export(array(), 1)); + $template->assign('indicesPhp', var_export([], 1)); } else { $template->assign('indicesPhp', var_export($this->tables[$this->name]['index'], 1)); @@ -131,7 +131,7 @@ public function getAbsFileName() { */ protected function getTableChecksum() { if (!$this->tableChecksum) { - $flat = array(); + $flat = []; CRM_Utils_Array::flatten($this->tables[$this->name], $flat); ksort($flat); $this->tableChecksum = md5(json_encode($flat)); diff --git a/CRM/Core/CodeGen/I18n.php b/CRM/Core/CodeGen/I18n.php index e48ea1e93737..d34f30a5d260 100644 --- a/CRM/Core/CodeGen/I18n.php +++ b/CRM/Core/CodeGen/I18n.php @@ -12,9 +12,9 @@ public function run() { public function generateInstallLangs() { // CRM-7161: generate install/langs.php from the languages template // grep it for enabled languages and create a 'xx_YY' => 'Language name' $langs mapping - $matches = array(); + $matches = []; preg_match_all('/, 1, \'([a-z][a-z]_[A-Z][A-Z])\', \'..\', \{localize\}\'\{ts escape="sql"\}(.+)\{\/ts\}\'\{\/localize\}, /', file_get_contents('templates/languages.tpl'), $matches); - $langs = array(); + $langs = []; for ($i = 0; $i < count($matches[0]); $i++) { $langs[$matches[1][$i]] = $matches[2][$i]; } @@ -23,13 +23,13 @@ public function generateInstallLangs() { public function generateSchemaStructure() { echo "Generating CRM_Core_I18n_SchemaStructure...\n"; - $columns = array(); - $indices = array(); - $widgets = array(); + $columns = []; + $indices = []; + $widgets = []; foreach ($this->tables as $table) { if ($table['localizable']) { - $columns[$table['name']] = array(); - $widgets[$table['name']] = array(); + $columns[$table['name']] = []; + $widgets[$table['name']] = []; } else { continue; diff --git a/CRM/Core/CodeGen/Main.php b/CRM/Core/CodeGen/Main.php index 9edd7b781817..978f3e9cae27 100644 --- a/CRM/Core/CodeGen/Main.php +++ b/CRM/Core/CodeGen/Main.php @@ -108,7 +108,7 @@ public function main() { public function getTasks() { $this->init(); - $tasks = array(); + $tasks = []; $tasks[] = new CRM_Core_CodeGen_Config($this); $tasks[] = new CRM_Core_CodeGen_Reflection($this); $tasks[] = new CRM_Core_CodeGen_Schema($this); @@ -127,11 +127,11 @@ public function getTasks() { public function getSourceDigest() { if ($this->sourceDigest === NULL) { $srcDir = CRM_Core_CodeGen_Util_File::findCoreSourceDir(); - $files = CRM_Core_CodeGen_Util_File::findManyFiles(array( - array("$srcDir/CRM/Core/CodeGen", '*.php'), - array("$srcDir/xml", "*.php"), - array("$srcDir/xml", "*.tpl"), - )); + $files = CRM_Core_CodeGen_Util_File::findManyFiles([ + ["$srcDir/CRM/Core/CodeGen", '*.php'], + ["$srcDir/xml", "*.php"], + ["$srcDir/xml", "*.tpl"], + ]); $this->sourceDigest = CRM_Core_CodeGen_Util_File::digestAll($files); } diff --git a/CRM/Core/CodeGen/Schema.php b/CRM/Core/CodeGen/Schema.php index 48247fd427e7..b96cb39ebee9 100644 --- a/CRM/Core/CodeGen/Schema.php +++ b/CRM/Core/CodeGen/Schema.php @@ -75,14 +75,14 @@ public function generateLocaleDataSql() { $template->assign('locale', $locale); $template->assign('db_version', $this->config->db_version); - $sections = array( + $sections = [ 'civicrm_country.tpl', 'civicrm_state_province.tpl', 'civicrm_currency.tpl', 'civicrm_data.tpl', 'civicrm_navigation.tpl', 'civicrm_version_sql.tpl', - ); + ]; $ext = ($locale != 'en_US' ? ".$locale" : ''); // write the initialize base-data sql script @@ -96,10 +96,10 @@ public function generateLocaleDataSql() { public function generateSample() { $template = new CRM_Core_CodeGen_Util_Template('sql'); - $sections = array( + $sections = [ 'civicrm_sample.tpl', 'civicrm_acl.tpl', - ); + ]; $template->runConcat($sections, $this->config->sqlCodePath . 'civicrm_sample.mysql'); $template->run('case_sample.tpl', $this->config->sqlCodePath . 'case_sample.mysql'); @@ -111,7 +111,7 @@ public function generateSample() { public function findLocales() { require_once 'CRM/Core/Config.php'; $config = CRM_Core_Config::singleton(FALSE); - $locales = array(); + $locales = []; $localeDir = CRM_Core_I18n::getResourceDir(); if (file_exists($localeDir)) { $locales = preg_grep('/^[a-z][a-z]_[A-Z][A-Z]$/', scandir($localeDir)); diff --git a/CRM/Core/CodeGen/Specification.php b/CRM/Core/CodeGen/Specification.php index c23b92508831..660d8d619220 100644 --- a/CRM/Core/CodeGen/Specification.php +++ b/CRM/Core/CodeGen/Specification.php @@ -29,7 +29,7 @@ public function parse($schemaPath, $buildVersion, $verbose = TRUE) { } $this->database = &$this->getDatabase($dbXML); - $this->classNames = array(); + $this->classNames = []; # TODO: peel DAO-specific stuff out of getTables, and spec reading into its own class if ($verbose) { @@ -66,7 +66,7 @@ public function parse($schemaPath, $buildVersion, $verbose = TRUE) { * @return array */ public function &getDatabase(&$dbXML) { - $database = array('name' => trim((string ) $dbXML->name)); + $database = ['name' => trim((string ) $dbXML->name)]; $attributes = ''; $this->checkAndAppend($attributes, $dbXML, 'character_set', 'DEFAULT CHARACTER SET ', ''); @@ -91,7 +91,7 @@ public function &getDatabase(&$dbXML) { * @return array */ public function getTables($dbXML, &$database) { - $tables = array(); + $tables = []; foreach ($dbXML->tables as $tablesXML) { foreach ($tablesXML->table as $tableXML) { if ($this->value('drop', $tableXML, 0) > 0 && version_compare($this->value('drop', $tableXML, 0), $this->buildVersion, '<=')) { @@ -145,7 +145,7 @@ public function resolveForeignKey(&$tables, &$classNames, $name) { * @return array */ public function orderTables(&$tables) { - $ordered = array(); + $ordered = []; while (!empty($tables)) { foreach (array_keys($tables) as $name) { @@ -202,7 +202,7 @@ public function getTable($tableXML, &$database, &$tables) { } } - $table = array( + $table = [ 'name' => $name, 'base' => $daoPath, 'sourceFile' => $sourceFile, @@ -218,9 +218,9 @@ public function getTable($tableXML, &$database, &$tables) { 'localizable' => $localizable, 'log' => $this->value('log', $tableXML, 'false'), 'archive' => $this->value('archive', $tableXML, 'false'), - ); + ]; - $fields = array(); + $fields = []; foreach ($tableXML->field as $fieldXML) { if ($this->value('drop', $fieldXML, 0) > 0 && version_compare($this->value('drop', $fieldXML, 0), $this->buildVersion, '<=')) { continue; @@ -238,7 +238,7 @@ public function getTable($tableXML, &$database, &$tables) { } if ($this->value('index', $tableXML)) { - $index = array(); + $index = []; foreach ($tableXML->index as $indexXML) { if ($this->value('drop', $indexXML, 0) > 0 && version_compare($this->value('drop', $indexXML, 0), $this->buildVersion, '<=')) { continue; @@ -251,7 +251,7 @@ public function getTable($tableXML, &$database, &$tables) { } if ($this->value('foreignKey', $tableXML)) { - $foreign = array(); + $foreign = []; foreach ($tableXML->foreignKey as $foreignXML) { if ($this->value('drop', $foreignXML, 0) > 0 && version_compare($this->value('drop', $foreignXML, 0), $this->buildVersion, '<=')) { @@ -265,7 +265,7 @@ public function getTable($tableXML, &$database, &$tables) { } if ($this->value('dynamicForeignKey', $tableXML)) { - $dynamicForeign = array(); + $dynamicForeign = []; foreach ($tableXML->dynamicForeignKey as $foreignXML) { if ($this->value('drop', $foreignXML, 0) > 0 && version_compare($this->value('drop', $foreignXML, 0), $this->buildVersion, '<=')) { continue; @@ -286,7 +286,7 @@ public function getTable($tableXML, &$database, &$tables) { */ public function getField(&$fieldXML, &$fields) { $name = trim((string ) $fieldXML->name); - $field = array('name' => $name, 'localizable' => ((bool) $fieldXML->localizable) ? 1 : 0); + $field = ['name' => $name, 'localizable' => ((bool) $fieldXML->localizable) ? 1 : 0]; $type = (string ) $fieldXML->type; switch ($type) { case 'varchar': @@ -369,7 +369,7 @@ public function getField(&$fieldXML, &$fields) { $field['serialize'] = $this->value('serialize', $fieldXML); $field['html'] = $this->value('html', $fieldXML); if (!empty($field['html'])) { - $validOptions = array( + $validOptions = [ 'type', 'formatType', 'label', @@ -381,8 +381,8 @@ public function getField(&$fieldXML, &$fields) { 'rows', 'cols', 'size', */ - ); - $field['html'] = array(); + ]; + $field['html'] = []; foreach ($validOptions as $htmlOption) { if (!empty($fieldXML->html->$htmlOption)) { $field['html'][$htmlOption] = $this->value($htmlOption, $fieldXML->html); @@ -397,7 +397,7 @@ public function getField(&$fieldXML, &$fields) { } else { // default - $field['widget'] = array('type' => 'Text'); + $field['widget'] = ['type' => 'Text']; } if (isset($fieldXML->required)) { $field['widget']['required'] = $this->value('required', $fieldXML); @@ -409,8 +409,8 @@ public function getField(&$fieldXML, &$fields) { $field['pseudoconstant'] = $this->value('pseudoconstant', $fieldXML); if (!empty($field['pseudoconstant'])) { //ok this is a bit long-winded but it gets there & is consistent with above approach - $field['pseudoconstant'] = array(); - $validOptions = array( + $field['pseudoconstant'] = []; + $validOptions = [ // Fields can specify EITHER optionGroupName OR table, not both // (since declaring optionGroupName means we are using the civicrm_option_value table) 'optionGroupName', @@ -426,7 +426,7 @@ public function getField(&$fieldXML, &$fields) { 'callback', // Path to options edit form 'optionEditPath', - ); + ]; foreach ($validOptions as $pseudoOption) { if (!empty($fieldXML->pseudoconstant->$pseudoOption)) { $field['pseudoconstant'][$pseudoOption] = $this->value($pseudoOption, $fieldXML->pseudoconstant); @@ -485,10 +485,10 @@ public function getPrimaryKey(&$primaryXML, &$fields, &$table) { $fields[$name]['autoincrement'] = $auto; } $fields[$name]['autoincrement'] = $auto; - $primaryKey = array( + $primaryKey = [ 'name' => $name, 'autoincrement' => $auto, - ); + ]; // populate fields foreach ($primaryXML->fieldName as $v) { @@ -534,11 +534,11 @@ public function getIndex(&$indexXML, &$fields, &$indices) { //echo "\n\n*******************************************************\n"; //echo "entering getIndex\n"; - $index = array(); + $index = []; // empty index name is fine $indexName = trim((string) $indexXML->name); $index['name'] = $indexName; - $index['field'] = array(); + $index['field'] = []; // populate fields foreach ($indexXML->fieldName as $v) { @@ -605,7 +605,7 @@ public function getForeignKey(&$foreignXML, &$fields, &$foreignKeys, &$currentTa /** need to check for existence of table and key **/ $table = trim($this->value('table', $foreignXML)); - $foreignKey = array( + $foreignKey = [ 'name' => $name, 'table' => $table, 'uniqName' => "FK_{$currentTableName}_{$name}", @@ -615,7 +615,7 @@ public function getForeignKey(&$foreignXML, &$fields, &$foreignKeys, &$currentTa // we do this matching in a separate phase (resolveForeignKeys) 'className' => NULL, 'onDelete' => $this->value('onDelete', $foreignXML, FALSE), - ); + ]; $foreignKeys[$name] = &$foreignKey; } @@ -624,11 +624,11 @@ public function getForeignKey(&$foreignXML, &$fields, &$foreignKeys, &$currentTa * @param $dynamicForeignKeys */ public function getDynamicForeignKey(&$foreignXML, &$dynamicForeignKeys) { - $foreignKey = array( + $foreignKey = [ 'idColumn' => trim($foreignXML->idColumn), 'typeColumn' => trim($foreignXML->typeColumn), 'key' => trim($this->value('key', $foreignXML)), - ); + ]; $dynamicForeignKeys[] = $foreignKey; } @@ -710,7 +710,7 @@ protected function getSize($fieldXML) { // Infer from tag if was not explicitly set or was invalid // This map is slightly different from CRM_Core_Form_Renderer::$_sizeMapper // Because we usually want fields to render as smaller than their maxlength - $sizes = array( + $sizes = [ 2 => 'TWO', 4 => 'FOUR', 6 => 'SIX', @@ -718,7 +718,7 @@ protected function getSize($fieldXML) { 16 => 'TWELVE', 32 => 'MEDIUM', 64 => 'BIG', - ); + ]; foreach ($sizes as $length => $name) { if ($fieldXML->length <= $length) { return "CRM_Utils_Type::$name"; diff --git a/CRM/Core/CodeGen/Util/ArraySyntaxConverter.php b/CRM/Core/CodeGen/Util/ArraySyntaxConverter.php index 5554c6b45140..acb274e41e3d 100644 --- a/CRM/Core/CodeGen/Util/ArraySyntaxConverter.php +++ b/CRM/Core/CodeGen/Util/ArraySyntaxConverter.php @@ -18,7 +18,7 @@ public static function convert($code) { $tokens = token_get_all($code); // - - - - - PARSE CODE - - - - - - $replacements = array(); + $replacements = []; $offset = 0; for ($i = 0; $i < count($tokens); ++$i) { // Keep track of the current byte offset in the source code @@ -43,11 +43,11 @@ public static function convert($code) { } if ($isArraySyntax) { // Replace "array" and the opening bracket (including preceeding whitespace) with "[" - $replacements[] = array( + $replacements[] = [ 'start' => $offset - strlen($tokens[$i][1]), 'end' => $subOffset, 'string' => '[', - ); + ]; // Look for matching closing bracket (")") $subOffset = $offset; $openBracketsCount = 0; @@ -60,11 +60,11 @@ public static function convert($code) { --$openBracketsCount; if ($openBracketsCount == 0) { // Replace ")" with "]" - $replacements[] = array( + $replacements[] = [ 'start' => $subOffset - 1, 'end' => $subOffset, 'string' => ']', - ); + ]; break; } } diff --git a/CRM/Core/CodeGen/Util/File.php b/CRM/Core/CodeGen/Util/File.php index a7d5e1e45609..c2cedac40c54 100644 --- a/CRM/Core/CodeGen/Util/File.php +++ b/CRM/Core/CodeGen/Util/File.php @@ -85,7 +85,7 @@ public static function findCoreSourceDir() { * Array of file paths */ public static function findManyFiles($pairs) { - $files = array(); + $files = []; foreach ($pairs as $pair) { list ($dir, $pattern) = $pair; $files = array_merge($files, CRM_Utils_File::findFiles($dir, $pattern)); diff --git a/CRM/Core/CodeGen/Util/Smarty.php b/CRM/Core/CodeGen/Util/Smarty.php index 7e22561d9ac3..68a7077ec7d5 100644 --- a/CRM/Core/CodeGen/Util/Smarty.php +++ b/CRM/Core/CodeGen/Util/Smarty.php @@ -50,7 +50,7 @@ public function createSmarty() { require_once 'Smarty/Smarty.class.php'; $smarty = new Smarty(); $smarty->template_dir = "$base/xml/templates"; - $smarty->plugins_dir = array("$base/packages/Smarty/plugins", "$base/CRM/Core/Smarty/plugins"); + $smarty->plugins_dir = ["$base/packages/Smarty/plugins", "$base/CRM/Core/Smarty/plugins"]; $smarty->compile_dir = $this->getCompileDir(); $smarty->clear_all_cache(); diff --git a/CRM/Core/CommunityMessages.php b/CRM/Core/CommunityMessages.php index 999978a2bad9..9e7ad56aa358 100644 --- a/CRM/Core/CommunityMessages.php +++ b/CRM/Core/CommunityMessages.php @@ -94,12 +94,12 @@ public function getDocument() { $document = $this->cache->get('communityMessages'); if (empty($document) || !is_array($document)) { - $document = array( - 'messages' => array(), + $document = [ + 'messages' => [], 'expires' => 0, // ASAP 'ttl' => self::DEFAULT_RETRY, 'retry' => self::DEFAULT_RETRY, - ); + ]; $isChanged = TRUE; } @@ -164,10 +164,10 @@ public function isEnabled() { */ public function pick() { $document = $this->getDocument(); - $messages = array(); + $messages = []; foreach ($document['messages'] as $message) { if (!isset($message['perms'])) { - $message['perms'] = array(self::DEFAULT_PERMISSION); + $message['perms'] = [self::DEFAULT_PERMISSION]; } if (!CRM_Core_Permission::checkAnyPerm($message['perms'])) { continue; @@ -196,7 +196,7 @@ public function pick() { */ public static function evalMarkup($markup) { $config = CRM_Core_Config::singleton(); - $vals = array( + $vals = [ 'resourceUrl' => rtrim($config->resourceBase, '/'), 'ver' => CRM_Utils_System::version(), 'uf' => $config->userFramework, @@ -205,8 +205,8 @@ public static function evalMarkup($markup) { 'baseUrl' => $config->userFrameworkBaseURL, 'lang' => $config->lcMessages, 'co' => $config->defaultContactCountry, - ); - $vars = array(); + ]; + $vars = []; foreach ($vals as $k => $v) { $vars['%%' . $k . '%%'] = $v; $vars['{{' . $k . '}}'] = urlencode($v); diff --git a/CRM/Core/Component.php b/CRM/Core/Component.php index 7d8b051f419a..f7161bc5006e 100644 --- a/CRM/Core/Component.php +++ b/CRM/Core/Component.php @@ -51,8 +51,8 @@ class CRM_Core_Component { */ private static function &_info($force = FALSE) { if (!isset(Civi::$statics[__CLASS__]['info'])|| $force) { - Civi::$statics[__CLASS__]['info'] = array(); - $c = array(); + Civi::$statics[__CLASS__]['info'] = []; + $c = []; $config = CRM_Core_Config::singleton(); $c = self::getComponents(); @@ -89,7 +89,7 @@ public static function get($name, $attribute = NULL) { */ public static function &getComponents($force = FALSE) { if (!isset(Civi::$statics[__CLASS__]['all']) || $force) { - Civi::$statics[__CLASS__]['all'] = array(); + Civi::$statics[__CLASS__]['all'] = []; $cr = new CRM_Core_DAO_Component(); $cr->find(FALSE); @@ -117,7 +117,7 @@ public static function &getComponents($force = FALSE) { * Array(string $name => int $id). */ public static function &getComponentIDs() { - $componentIDs = array(); + $componentIDs = []; $cr = new CRM_Core_DAO_Component(); $cr->find(FALSE); @@ -150,7 +150,7 @@ static public function flushEnabledComponents() { public static function &getNames($translated = FALSE) { $allComponents = self::getComponents(); - $names = array(); + $names = []; foreach ($allComponents as $name => $comp) { if ($translated) { $names[$comp->componentID] = $comp->info['translatedName']; @@ -208,7 +208,7 @@ public static function xmlMenu() { // lets build the menu for all components $info = self::getComponents(TRUE); - $files = array(); + $files = []; foreach ($info as $name => $comp) { $files = array_merge($files, $comp->menuFiles() @@ -223,7 +223,7 @@ public static function xmlMenu() { */ public static function &menu() { $info = self::_info(); - $items = array(); + $items = []; foreach ($info as $name => $comp) { $mnu = $comp->getMenuObject(); @@ -275,7 +275,7 @@ public static function getComponentName($componentID) { */ public static function &getQueryFields($checkPermission = TRUE) { $info = self::_info(); - $fields = array(); + $fields = []; foreach ($info as $name => $comp) { if ($comp->usesSearch()) { $bqr = $comp->getBAOQueryObject(); @@ -383,7 +383,7 @@ public static function searchAction(&$row, $id) { */ public static function &contactSubTypes() { if (self::$_contactSubTypes == NULL) { - self::$_contactSubTypes = array(); + self::$_contactSubTypes = []; } return self::$_contactSubTypes; } @@ -431,7 +431,7 @@ public static function tableNames(&$tables) { * @return array */ public static function getComponentsFromFile($crmFolderDir) { - $components = array(); + $components = []; //traverse CRM folder and check for Info file if (is_dir($crmFolderDir) && $dir = opendir($crmFolderDir)) { while ($subDir = readdir($dir)) { diff --git a/CRM/Core/Component/Info.php b/CRM/Core/Component/Info.php index d1563d9f8271..fd4b55c5be33 100644 --- a/CRM/Core/Component/Info.php +++ b/CRM/Core/Component/Info.php @@ -113,7 +113,7 @@ public function __construct($name, $namespace, $componentID) { * @see CRM_Utils_Hook::angularModules */ public function getAngularModules() { - return array(); + return []; } /** @@ -134,7 +134,7 @@ abstract public function getInfo(); * @see CRM_Utils_Hook::managedEntities */ public function getManagedEntities() { - return array(); + return []; } /** @@ -145,7 +145,7 @@ public function getManagedEntities() { * @see CRM_Component_Info::getPermissions */ public function getAnonymousPermissionWarnings() { - return array(); + return []; } /** @@ -175,7 +175,7 @@ abstract public function getPermissions($getAllUnconditionally = FALSE); * - count: int, eg "5" if there are 5 email addresses that refer to $dao */ public function getReferenceCounts($dao) { - return array(); + return []; } /** diff --git a/CRM/Core/Config.php b/CRM/Core/Config.php index 2e5c7307daab..cd382e17d6f5 100644 --- a/CRM/Core/Config.php +++ b/CRM/Core/Config.php @@ -102,8 +102,8 @@ public function __construct() { */ public static function &singleton($loadFromDB = TRUE, $force = FALSE) { if (self::$_singleton === NULL || $force) { - $GLOBALS['civicrm_default_error_scope'] = CRM_Core_TemporaryErrorScope::create(array('CRM_Core_Error', 'handle')); - $errorScope = CRM_Core_TemporaryErrorScope::create(array('CRM_Core_Error', 'simpleHandler')); + $GLOBALS['civicrm_default_error_scope'] = CRM_Core_TemporaryErrorScope::create(['CRM_Core_Error', 'handle']); + $errorScope = CRM_Core_TemporaryErrorScope::create(['CRM_Core_Error', 'simpleHandler']); if (defined('E_DEPRECATED')) { error_reporting(error_reporting() & ~E_DEPRECATED); @@ -180,12 +180,12 @@ public function cleanup($value, $rmdir = TRUE) { // Whether we delete/create or simply preserve directories, we should // certainly make sure the restrictions are enforced. - foreach (array( + foreach ([ $this->templateCompileDir, $this->uploadDir, $this->configAndLogDir, $this->customFileUploadDir, - ) as $dir) { + ] as $dir) { if ($dir && is_dir($dir)) { CRM_Utils_File::restrictAccess($dir); } @@ -229,7 +229,7 @@ public function authenticate() { $userID = $session->get('userID'); if ($userID) { CRM_Core_DAO::executeQuery('SET @civicrm_user_id = %1', - array(1 => array($userID, 'Integer')) + [1 => [$userID, 'Integer']] ); } @@ -316,7 +316,7 @@ public function cleanupPermissions() { } else { // Cannot store permissions -- warn if any modules require them - $modules_with_perms = array(); + $modules_with_perms = []; foreach ($module_files as $module_file) { $perms = $this->userPermissionClass->getModulePermissions($module_file['prefix']); if (!empty($perms)) { @@ -325,7 +325,7 @@ public function cleanupPermissions() { } if (!empty($modules_with_perms)) { CRM_Core_Session::setStatus( - ts('Some modules define permissions, but the CMS cannot store them: %1', array(1 => implode(', ', $modules_with_perms))), + ts('Some modules define permissions, but the CMS cannot store them: %1', [1 => implode(', ', $modules_with_perms)]), ts('Permission Error'), 'error' ); @@ -347,7 +347,7 @@ public function clearModuleList() { * Clear db cache. */ public static function clearDBCache() { - $queries = array( + $queries = [ 'TRUNCATE TABLE civicrm_acl_cache', 'TRUNCATE TABLE civicrm_acl_contact_cache', 'TRUNCATE TABLE civicrm_cache', @@ -356,7 +356,7 @@ public static function clearDBCache() { 'TRUNCATE TABLE civicrm_group_contact_cache', 'TRUNCATE TABLE civicrm_menu', 'UPDATE civicrm_setting SET value = NULL WHERE name="navigation" AND contact_id IS NOT NULL', - ); + ]; foreach ($queries as $query) { CRM_Core_DAO::executeQuery($query); @@ -402,8 +402,8 @@ public static function clearTempTables($timeInterval = FALSE) { $query .= " AND CREATE_TIME < DATE_SUB(NOW(), INTERVAL {$timeInterval})"; } - $tableDAO = CRM_Core_DAO::executeQuery($query, array(1 => array($dao->database(), 'String'))); - $tables = array(); + $tableDAO = CRM_Core_DAO::executeQuery($query, [1 => [$dao->database(), 'String']]); + $tables = []; while ($tableDAO->fetch()) { $tables[] = $tableDAO->tableName; } @@ -464,7 +464,7 @@ public static function isUpgradeMode($path = NULL) { * @return bool */ public static function isEnabledBackOfficeCreditCardPayments() { - return CRM_Financial_BAO_PaymentProcessor::hasPaymentProcessorSupporting(array('BackOffice')); + return CRM_Financial_BAO_PaymentProcessor::hasPaymentProcessorSupporting(['BackOffice']); } /** diff --git a/CRM/Core/Config/MagicMerge.php b/CRM/Core/Config/MagicMerge.php index 7223816f2db1..90aa741bf8b4 100644 --- a/CRM/Core/Config/MagicMerge.php +++ b/CRM/Core/Config/MagicMerge.php @@ -56,7 +56,7 @@ class CRM_Core_Config_MagicMerge { private $locals, $settings; - private $cache = array(); + private $cache = []; /** * CRM_Core_Config_MagicMerge constructor. @@ -87,130 +87,130 @@ public static function getPropertyMap() { // Each mapping: $propertyName => Array(0 => $type, 1 => $foreignName|NULL, ...). // If $foreignName is omitted/null, then it's assumed to match the $propertyName. // Other parameters may be specified, depending on the type. - return array( + return [ // "local" properties are unique to each instance of CRM_Core_Config (each request). - 'doNotResetCache' => array('local'), - 'inCiviCRM' => array('local'), - 'keyDisable' => array('local'), - 'userFrameworkFrontend' => array('local'), - 'userPermissionTemp' => array('local'), + 'doNotResetCache' => ['local'], + 'inCiviCRM' => ['local'], + 'keyDisable' => ['local'], + 'userFrameworkFrontend' => ['local'], + 'userPermissionTemp' => ['local'], // "runtime" properties are computed from define()s, $_ENV, etc. // See also: CRM_Core_Config_Runtime. - 'dsn' => array('runtime'), - 'initialized' => array('runtime'), - 'userFramework' => array('runtime'), - 'userFrameworkClass' => array('runtime'), - 'userFrameworkDSN' => array('runtime'), - 'userFrameworkURLVar' => array('runtime'), - 'userHookClass' => array('runtime'), - 'cleanURL' => array('runtime'), - 'configAndLogDir' => array('runtime'), - 'templateCompileDir' => array('runtime'), - 'templateDir' => array('runtime'), + 'dsn' => ['runtime'], + 'initialized' => ['runtime'], + 'userFramework' => ['runtime'], + 'userFrameworkClass' => ['runtime'], + 'userFrameworkDSN' => ['runtime'], + 'userFrameworkURLVar' => ['runtime'], + 'userHookClass' => ['runtime'], + 'cleanURL' => ['runtime'], + 'configAndLogDir' => ['runtime'], + 'templateCompileDir' => ['runtime'], + 'templateDir' => ['runtime'], // "boot-svc" properties are critical services needed during init. // See also: Civi\Core\Container::getBootService(). - 'userSystem' => array('boot-svc'), - 'userPermissionClass' => array('boot-svc'), + 'userSystem' => ['boot-svc'], + 'userPermissionClass' => ['boot-svc'], - 'userFrameworkBaseURL' => array('user-system', 'getAbsoluteBaseURL'), - 'userFrameworkVersion' => array('user-system', 'getVersion'), - 'useFrameworkRelativeBase' => array('user-system', 'getRelativeBaseURL'), // ugh typo. + 'userFrameworkBaseURL' => ['user-system', 'getAbsoluteBaseURL'], + 'userFrameworkVersion' => ['user-system', 'getVersion'], + 'useFrameworkRelativeBase' => ['user-system', 'getRelativeBaseURL'], // ugh typo. // "setting" properties are loaded through the setting layer, esp // table "civicrm_setting" and global $civicrm_setting. // See also: Civi::settings(). - 'backtrace' => array('setting'), - 'contact_default_language' => array('setting'), - 'countryLimit' => array('setting'), - 'customTranslateFunction' => array('setting'), - 'dateInputFormat' => array('setting'), - 'dateformatDatetime' => array('setting'), - 'dateformatFull' => array('setting'), - 'dateformatPartial' => array('setting'), - 'dateformatTime' => array('setting'), - 'dateformatYear' => array('setting'), - 'dateformatFinancialBatch' => array('setting'), - 'dateformatshortdate' => array('setting'), - 'debug' => array('setting', 'debug_enabled'), // renamed. - 'defaultContactCountry' => array('setting'), - 'defaultContactStateProvince' => array('setting'), - 'defaultCurrency' => array('setting'), - 'defaultSearchProfileID' => array('setting'), - 'doNotAttachPDFReceipt' => array('setting'), - 'empoweredBy' => array('setting'), - 'enableComponents' => array('setting', 'enable_components'), // renamed. - 'enableSSL' => array('setting'), - 'fatalErrorHandler' => array('setting'), - 'fieldSeparator' => array('setting'), - 'fiscalYearStart' => array('setting'), - 'geoAPIKey' => array('setting'), - 'geoProvider' => array('setting'), - 'includeAlphabeticalPager' => array('setting'), - 'includeEmailInName' => array('setting'), - 'includeNickNameInName' => array('setting'), - 'includeOrderByClause' => array('setting'), - 'includeWildCardInName' => array('setting'), - 'inheritLocale' => array('setting'), - 'languageLimit' => array('setting'), - 'lcMessages' => array('setting'), - 'legacyEncoding' => array('setting'), - 'logging' => array('setting'), - 'mailThrottleTime' => array('setting'), - 'mailerBatchLimit' => array('setting'), - 'mailerJobSize' => array('setting'), - 'mailerJobsMax' => array('setting'), - 'mapAPIKey' => array('setting'), - 'mapProvider' => array('setting'), - 'maxFileSize' => array('setting'), - 'maxAttachments' => array('setting', 'max_attachments'), // renamed. - 'monetaryDecimalPoint' => array('setting'), - 'monetaryThousandSeparator' => array('setting'), - 'moneyformat' => array('setting'), - 'moneyvalueformat' => array('setting'), - 'provinceLimit' => array('setting'), - 'recaptchaOptions' => array('setting'), - 'recaptchaPublicKey' => array('setting'), - 'recaptchaPrivateKey' => array('setting'), - 'forceRecaptcha' => array('setting'), - 'replyTo' => array('setting'), - 'secondDegRelPermissions' => array('setting'), - 'smartGroupCacheTimeout' => array('setting'), - 'timeInputFormat' => array('setting'), - 'userFrameworkLogging' => array('setting'), - 'userFrameworkUsersTableName' => array('setting'), - 'verpSeparator' => array('setting'), - 'wkhtmltopdfPath' => array('setting'), - 'wpBasePage' => array('setting'), - 'wpLoadPhp' => array('setting'), + 'backtrace' => ['setting'], + 'contact_default_language' => ['setting'], + 'countryLimit' => ['setting'], + 'customTranslateFunction' => ['setting'], + 'dateInputFormat' => ['setting'], + 'dateformatDatetime' => ['setting'], + 'dateformatFull' => ['setting'], + 'dateformatPartial' => ['setting'], + 'dateformatTime' => ['setting'], + 'dateformatYear' => ['setting'], + 'dateformatFinancialBatch' => ['setting'], + 'dateformatshortdate' => ['setting'], + 'debug' => ['setting', 'debug_enabled'], // renamed. + 'defaultContactCountry' => ['setting'], + 'defaultContactStateProvince' => ['setting'], + 'defaultCurrency' => ['setting'], + 'defaultSearchProfileID' => ['setting'], + 'doNotAttachPDFReceipt' => ['setting'], + 'empoweredBy' => ['setting'], + 'enableComponents' => ['setting', 'enable_components'], // renamed. + 'enableSSL' => ['setting'], + 'fatalErrorHandler' => ['setting'], + 'fieldSeparator' => ['setting'], + 'fiscalYearStart' => ['setting'], + 'geoAPIKey' => ['setting'], + 'geoProvider' => ['setting'], + 'includeAlphabeticalPager' => ['setting'], + 'includeEmailInName' => ['setting'], + 'includeNickNameInName' => ['setting'], + 'includeOrderByClause' => ['setting'], + 'includeWildCardInName' => ['setting'], + 'inheritLocale' => ['setting'], + 'languageLimit' => ['setting'], + 'lcMessages' => ['setting'], + 'legacyEncoding' => ['setting'], + 'logging' => ['setting'], + 'mailThrottleTime' => ['setting'], + 'mailerBatchLimit' => ['setting'], + 'mailerJobSize' => ['setting'], + 'mailerJobsMax' => ['setting'], + 'mapAPIKey' => ['setting'], + 'mapProvider' => ['setting'], + 'maxFileSize' => ['setting'], + 'maxAttachments' => ['setting', 'max_attachments'], // renamed. + 'monetaryDecimalPoint' => ['setting'], + 'monetaryThousandSeparator' => ['setting'], + 'moneyformat' => ['setting'], + 'moneyvalueformat' => ['setting'], + 'provinceLimit' => ['setting'], + 'recaptchaOptions' => ['setting'], + 'recaptchaPublicKey' => ['setting'], + 'recaptchaPrivateKey' => ['setting'], + 'forceRecaptcha' => ['setting'], + 'replyTo' => ['setting'], + 'secondDegRelPermissions' => ['setting'], + 'smartGroupCacheTimeout' => ['setting'], + 'timeInputFormat' => ['setting'], + 'userFrameworkLogging' => ['setting'], + 'userFrameworkUsersTableName' => ['setting'], + 'verpSeparator' => ['setting'], + 'wkhtmltopdfPath' => ['setting'], + 'wpBasePage' => ['setting'], + 'wpLoadPhp' => ['setting'], // "setting-path" properties are settings with special filtering // to return normalized file paths. // Option: `mkdir` - auto-create dir // Option: `restrict` - auto-restrict remote access - 'customFileUploadDir' => array('setting-path', NULL, array('mkdir', 'restrict')), - 'customPHPPathDir' => array('setting-path'), - 'customTemplateDir' => array('setting-path'), - 'extensionsDir' => array('setting-path', NULL, array('mkdir')), - 'imageUploadDir' => array('setting-path', NULL, array('mkdir')), - 'uploadDir' => array('setting-path', NULL, array('mkdir', 'restrict')), + 'customFileUploadDir' => ['setting-path', NULL, ['mkdir', 'restrict']], + 'customPHPPathDir' => ['setting-path'], + 'customTemplateDir' => ['setting-path'], + 'extensionsDir' => ['setting-path', NULL, ['mkdir']], + 'imageUploadDir' => ['setting-path', NULL, ['mkdir']], + 'uploadDir' => ['setting-path', NULL, ['mkdir', 'restrict']], // "setting-url" properties are settings with special filtering // to return normalized URLs. // Option: `noslash` - don't append trailing slash // Option: `rel` - convert to relative URL (if possible) - 'customCSSURL' => array('setting-url', NULL, array('noslash')), - 'extensionsURL' => array('setting-url'), - 'imageUploadURL' => array('setting-url'), - 'resourceBase' => array('setting-url', 'userFrameworkResourceURL', array('rel')), - 'userFrameworkResourceURL' => array('setting-url'), + 'customCSSURL' => ['setting-url', NULL, ['noslash']], + 'extensionsURL' => ['setting-url'], + 'imageUploadURL' => ['setting-url'], + 'resourceBase' => ['setting-url', 'userFrameworkResourceURL', ['rel']], + 'userFrameworkResourceURL' => ['setting-url'], // "callback" properties are generated on-demand by calling a function. // @todo remove geocodeMethod. As of Feb 2018, $config->geocodeMethod works but gives a deprecation warning. - 'geocodeMethod' => array('callback', 'CRM_Utils_Geocode', 'getProviderClass'), - 'defaultCurrencySymbol' => array('callback', 'CRM_Core_BAO_Country', 'getDefaultCurrencySymbol'), - ); + 'geocodeMethod' => ['callback', 'CRM_Utils_Geocode', 'getProviderClass'], + 'defaultCurrencySymbol' => ['callback', 'CRM_Core_BAO_Country', 'getDefaultCurrencySymbol'], + ]; } /** @@ -244,10 +244,10 @@ public function __get($k) { $value = CRM_Utils_File::addTrailingSlash($value); if (isset($this->map[$k][2]) && in_array('mkdir', $this->map[$k][2])) { if (!is_dir($value) && !CRM_Utils_File::createDir($value, FALSE)) { - CRM_Core_Session::setStatus(ts('Failed to make directory (%1) at "%2". Please update the settings or file permissions.', array( + CRM_Core_Session::setStatus(ts('Failed to make directory (%1) at "%2". Please update the settings or file permissions.', [ 1 => $k, 2 => $value, - ))); + ])); } } if (isset($this->map[$k][2]) && in_array('restrict', $this->map[$k][2])) { @@ -258,7 +258,7 @@ public function __get($k) { return $value; case 'setting-url': - $options = !empty($this->map[$k][2]) ? $this->map[$k][2] : array(); + $options = !empty($this->map[$k][2]) ? $this->map[$k][2] : []; $value = $this->getSettings()->get($name); if ($value && !(in_array('noslash', $options))) { $value = CRM_Utils_File::addTrailingSlash($value, '/'); @@ -280,7 +280,7 @@ public function __get($k) { case 'user-system': $userSystem = \Civi\Core\Container::getBootService('userSystem'); - $this->cache[$k] = call_user_func(array($userSystem, $name)); + $this->cache[$k] = call_user_func([$userSystem, $name]); return $this->cache[$k]; case 'service': @@ -291,7 +291,7 @@ public function __get($k) { if (!isset($this->map[$k][1], $this->map[$k][2])) { throw new \CRM_Core_Exception("Cannot find getter for property CRM_Core_Config::\${$k}"); } - return \Civi\Core\Resolver::singleton()->call(array($this->map[$k][1], $this->map[$k][2]), array($k)); + return \Civi\Core\Resolver::singleton()->call([$this->map[$k][1], $this->map[$k][2]], [$k]); default: throw new \CRM_Core_Exception("Cannot read property CRM_Core_Config::\${$k} ($type)"); @@ -382,7 +382,7 @@ public function __unset($k) { if (!isset($this->map[$k][1], $this->map[$k][4])) { throw new \CRM_Core_Exception("Cannot find unsetter for property CRM_Core_Config::\${$k}"); } - \Civi\Core\Resolver::singleton()->call(array($this->map[$k][1], $this->map[$k][4]), array($k)); + \Civi\Core\Resolver::singleton()->call([$this->map[$k][1], $this->map[$k][4]], [$k]); return; default: @@ -405,14 +405,14 @@ protected function getSettings() { */ private function initLocals() { if ($this->locals === NULL) { - $this->locals = array( + $this->locals = [ 'inCiviCRM' => FALSE, 'doNotResetCache' => 0, 'keyDisable' => FALSE, 'initialized' => FALSE, 'userFrameworkFrontend' => FALSE, 'userPermissionTemp' => NULL, - ); + ]; } } diff --git a/CRM/Core/Config/Runtime.php b/CRM/Core/Config/Runtime.php index a9c39f3e3390..51a4cc3d340e 100644 --- a/CRM/Core/Config/Runtime.php +++ b/CRM/Core/Config/Runtime.php @@ -133,7 +133,7 @@ public function initialize($loadFromDB = TRUE) { $this->cleanURL = 0; } - $this->templateDir = array(dirname(dirname(dirname(__DIR__))) . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR); + $this->templateDir = [dirname(dirname(dirname(__DIR__))) . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR]; $this->initialized = 1; } @@ -152,7 +152,7 @@ private function fatal($message) { * Include custom PHP and template paths */ public function includeCustomPath() { - $customProprtyName = array('customPHPPathDir', 'customTemplateDir'); + $customProprtyName = ['customPHPPathDir', 'customTemplateDir']; foreach ($customProprtyName as $property) { $value = $this->getSettings()->get($property); if (!empty($value)) { @@ -173,14 +173,14 @@ public function includeCustomPath() { */ public static function getId() { if (!isset(Civi::$statics[__CLASS__]['id'])) { - Civi::$statics[__CLASS__]['id'] = md5(implode(\CRM_Core_DAO::VALUE_SEPARATOR, array( + Civi::$statics[__CLASS__]['id'] = md5(implode(\CRM_Core_DAO::VALUE_SEPARATOR, [ defined('CIVICRM_DOMAIN_ID') ? CIVICRM_DOMAIN_ID : 1, // e.g. one database, multi URL parse_url(CIVICRM_DSN, PHP_URL_PATH), // e.g. one codebase, multi database \CRM_Utils_Array::value('SCRIPT_FILENAME', $_SERVER, ''), // e.g. CMS vs extern vs installer \CRM_Utils_Array::value('HTTP_HOST', $_SERVER, ''), // e.g. name-based vhosts \CRM_Utils_Array::value('SERVER_PORT', $_SERVER, ''), // e.g. port-based vhosts // Depending on deployment arch, these signals *could* be redundant, but who cares? - ))); + ])); } return Civi::$statics[__CLASS__]['id']; } diff --git a/CRM/Core/Controller.php b/CRM/Core/Controller.php index b8da3db13227..1bd454992d7c 100644 --- a/CRM/Core/Controller.php +++ b/CRM/Core/Controller.php @@ -214,10 +214,10 @@ public function __construct( // only use the civicrm cache if we have a valid key // else we clash with other users CRM-7059 if (!empty($this->_key)) { - CRM_Core_Session::registerAndRetrieveSessionObjects(array( + CRM_Core_Session::registerAndRetrieveSessionObjects([ "_{$name}_container", - array('CiviCRM', $this->_scope), - )); + ['CiviCRM', $this->_scope], + ]); } parent::__construct($name, $modal); @@ -239,7 +239,7 @@ public function __construct( $this->_print = CRM_Core_Smarty::PRINT_NOFORM; } // Respond with JSON if in AJAX context (also support legacy value '6') - elseif (in_array($snippet, array(CRM_Core_Smarty::PRINT_JSON, 6))) { + elseif (in_array($snippet, [CRM_Core_Smarty::PRINT_JSON, 6])) { $this->_print = CRM_Core_Smarty::PRINT_JSON; $this->_QFResponseType = 'json'; } @@ -275,10 +275,10 @@ public function __construct( } public function fini() { - CRM_Core_BAO_Cache::storeSessionToCache(array( + CRM_Core_BAO_Cache::storeSessionToCache([ "_{$this->_name}_container", - array('CiviCRM', $this->_scope), - ), + ['CiviCRM', $this->_scope], + ], TRUE ); } @@ -382,7 +382,7 @@ public function validate() { * @param array $uploadNames for the various upload buttons (note u can have more than 1 upload) */ public function addActions($uploadDirectory = NULL, $uploadNames = NULL) { - $names = array( + $names = [ 'display' => 'CRM_Core_QuickForm_Action_Display', 'next' => 'CRM_Core_QuickForm_Action_Next', 'back' => 'CRM_Core_QuickForm_Action_Back', @@ -393,7 +393,7 @@ public function addActions($uploadDirectory = NULL, $uploadNames = NULL) { 'done' => 'CRM_Core_QuickForm_Action_Done', 'jump' => 'CRM_Core_QuickForm_Action_Jump', 'submit' => 'CRM_Core_QuickForm_Action_Submit', - ); + ]; foreach ($names as $name => $classPath) { $action = new $classPath($this->_stateMachine); @@ -535,12 +535,12 @@ public function get($name) { * @return array */ public function wizardHeader($currentPageName) { - $wizard = array(); - $wizard['steps'] = array(); + $wizard = []; + $wizard['steps'] = []; $count = 0; foreach ($this->_pages as $name => $page) { $count++; - $wizard['steps'][] = array( + $wizard['steps'][] = [ 'name' => $name, 'title' => $page->getTitle(), //'link' => $page->getLink ( ), @@ -549,7 +549,7 @@ public function wizardHeader($currentPageName) { 'valid' => TRUE, 'stepNumber' => $count, 'collapsed' => FALSE, - ); + ]; if ($name == $currentPageName) { $wizard['currentStepNumber'] = $count; @@ -570,7 +570,7 @@ public function wizardHeader($currentPageName) { * @param array $wizard */ public function addWizardStyle(&$wizard) { - $wizard['style'] = array( + $wizard['style'] = [ 'barClass' => '', 'stepPrefixCurrent' => '»', 'stepPrefixPast' => '✔', @@ -579,7 +579,7 @@ public function addWizardStyle(&$wizard) { 'subStepPrefixPast' => '  ', 'subStepPrefixFuture' => '  ', 'showTitle' => 1, - ); + ]; } /** diff --git a/CRM/Core/Controller/Simple.php b/CRM/Core/Controller/Simple.php index d472b9e4118e..b0a6154ad3a9 100644 --- a/CRM/Core/Controller/Simple.php +++ b/CRM/Core/Controller/Simple.php @@ -67,7 +67,7 @@ public function __construct( $this->_stateMachine = new CRM_Core_StateMachine($this); - $params = array($path => NULL); + $params = [$path => NULL]; $savedAction = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE, NULL); if (!empty($savedAction) && @@ -98,7 +98,7 @@ public function __construct( ); } elseif ($imageUpload) { - $this->addActions($config->imageUploadDir, array('uploadFile')); + $this->addActions($config->imageUploadDir, ['uploadFile']); } else { $this->addActions(); diff --git a/CRM/Core/DAO.php b/CRM/Core/DAO.php index 02b3d3d1587f..ea7abcc08573 100644 --- a/CRM/Core/DAO.php +++ b/CRM/Core/DAO.php @@ -64,7 +64,7 @@ class CRM_Core_DAO extends DB_DataObject { * @var array * @deprecated */ - static $_nullArray = array(); + static $_nullArray = []; static $_dbColumnValueCache = NULL; const NOT_NULL = 1, IS_NULL = 2, @@ -101,7 +101,7 @@ class CRM_Core_DAO extends DB_DataObject { * test objects - this prevents world regions, countries etc from being added / deleted * @var array */ - static $_testEntitiesToSkip = array(); + static $_testEntitiesToSkip = []; /** * The factory class for this application. * @var object @@ -114,7 +114,7 @@ class CRM_Core_DAO extends DB_DataObject { * https://issues.civicrm.org/jira/browse/CRM-17748 * internal variable for DAO to hold per-query settings */ - protected $_options = array(); + protected $_options = []; /** * Class constructor. @@ -170,12 +170,12 @@ public static function init($dsn) { $currentModes[] = 'ONLY_FULL_GROUP_BY'; } if (!in_array('STRICT_TRANS_TABLES', $currentModes)) { - $currentModes = array_merge(array('STRICT_TRANS_TABLES'), $currentModes); + $currentModes = array_merge(['STRICT_TRANS_TABLES'], $currentModes); } - CRM_Core_DAO::executeQuery("SET SESSION sql_mode = %1", array(1 => array(implode(',', $currentModes), 'String'))); + CRM_Core_DAO::executeQuery("SET SESSION sql_mode = %1", [1 => [implode(',', $currentModes), 'String']]); } CRM_Core_DAO::executeQuery('SET NAMES utf8'); - CRM_Core_DAO::executeQuery('SET @uniqueID = %1', array(1 => array(CRM_Utils_Request::id(), 'String'))); + CRM_Core_DAO::executeQuery('SET @uniqueID = %1', [1 => [CRM_Utils_Request::id(), 'String']]); } /** @@ -195,7 +195,7 @@ public static function disableFullGroupByMode() { if (in_array('ONLY_FULL_GROUP_BY', $currentModes) && CRM_Utils_SQL::isGroupByModeInDefault()) { $key = array_search('ONLY_FULL_GROUP_BY', $currentModes); unset($currentModes[$key]); - CRM_Core_DAO::executeQuery("SET SESSION sql_mode = %1", array(1 => array(implode(',', $currentModes), 'String'))); + CRM_Core_DAO::executeQuery("SET SESSION sql_mode = %1", [1 => [implode(',', $currentModes), 'String']]); } } @@ -206,7 +206,7 @@ public static function reenableFullGroupByMode() { $currentModes = CRM_Utils_SQL::getSqlModes(); if (!in_array('ONLY_FULL_GROUP_BY', $currentModes) && CRM_Utils_SQL::isGroupByModeInDefault()) { $currentModes[] = 'ONLY_FULL_GROUP_BY'; - CRM_Core_DAO::executeQuery("SET SESSION sql_mode = %1", array(1 => array(implode(',', $currentModes), 'String'))); + CRM_Core_DAO::executeQuery("SET SESSION sql_mode = %1", [1 => [implode(',', $currentModes), 'String']]); } } @@ -244,7 +244,7 @@ protected function assignTestFK($fieldName, $fieldDef, $params) { } elseif ($daoName == 'CRM_Member_DAO_MembershipType' && $fieldName == 'member_of_contact_id') { // FIXME: the fields() metadata is not specific enough - $depObject = CRM_Core_DAO::createTestObject($FKClassName, array('contact_type' => 'Organization')); + $depObject = CRM_Core_DAO::createTestObject($FKClassName, ['contact_type' => 'Organization']); $this->$dbName = $depObject->id; $depObject->free(); } @@ -385,7 +385,7 @@ public function reset() { /** * reset the various DB_DAO structures manually */ - $this->_query = array(); + $this->_query = []; $this->whereAdd(); $this->selectAdd(); $this->joinAdd(); @@ -487,7 +487,7 @@ public function initialize() { public function keys() { static $keys; if (!isset($keys)) { - $keys = array('id'); + $keys = ['id']; } return $keys; } @@ -502,7 +502,7 @@ public function keys() { public function sequenceKey() { static $sequenceKeys; if (!isset($sequenceKeys)) { - $sequenceKeys = array('id', TRUE); + $sequenceKeys = ['id', TRUE]; } return $sequenceKeys; } @@ -515,7 +515,7 @@ public function sequenceKey() { * Array of CRM_Core_Reference_Interface */ public static function getReferenceColumns() { - return array(); + return []; } /** @@ -538,7 +538,7 @@ public static function &fields() { public function table() { $fields = $this->fields(); - $table = array(); + $table = []; if ($fields) { foreach ($fields as $name => $value) { $table[$value['name']] = $value['type']; @@ -750,7 +750,7 @@ public static function makeAttribute($field) { $maxLength = CRM_Utils_Array::value('maxlength', $field); $size = CRM_Utils_Array::value('size', $field); if ($maxLength || $size) { - $attributes = array(); + $attributes = []; if ($maxLength) { $attributes['maxlength'] = $maxLength; } @@ -770,7 +770,7 @@ public static function makeAttribute($field) { $cols = 80; } - $attributes = array(); + $attributes = []; $attributes['rows'] = $rows; $attributes['cols'] = $cols; return $attributes; @@ -805,7 +805,7 @@ public static function getAttribute($class, $fieldName = NULL) { return self::makeAttribute($field); } else { - $attributes = array(); + $attributes = []; foreach ($fields as $name => $field) { $attribute = self::makeAttribute($field); if ($attribute) { @@ -931,7 +931,7 @@ public static function getDatabaseName() { * true if constraint exists, false otherwise */ public static function checkConstraintExists($tableName, $constraint) { - static $show = array(); + static $show = []; if (!array_key_exists($tableName, $show)) { $query = "SHOW CREATE TABLE $tableName"; @@ -957,8 +957,8 @@ public static function checkConstraintExists($tableName, $constraint) { * @return bool * true if CONSTRAINT keyword exists, false otherwise */ - public static function schemaRequiresRebuilding($tables = array("civicrm_contact")) { - $show = array(); + public static function schemaRequiresRebuilding($tables = ["civicrm_contact"]) { + $show = []; foreach ($tables as $tableName) { if (!array_key_exists($tableName, $show)) { $query = "SHOW CREATE TABLE $tableName"; @@ -993,7 +993,7 @@ public static function schemaRequiresRebuilding($tables = array("civicrm_contact * true if in format, false otherwise */ public static function checkFKConstraintInFormat($tableName, $columnName) { - static $show = array(); + static $show = []; if (!array_key_exists($tableName, $show)) { $query = "SHOW CREATE TABLE $tableName"; @@ -1056,7 +1056,7 @@ public static function checkTableExists($tableName) { SHOW TABLES LIKE %1 "; - $params = array(1 => array($tableName, 'String')); + $params = [1 => [$tableName, 'String']]; $dao = CRM_Core_DAO::executeQuery($query, $params); $result = $dao->fetch() ? TRUE : FALSE; @@ -1103,7 +1103,7 @@ public static function findById($id) { * @return array */ public function fetchAll() { - $result = array(); + $result = []; while ($this->fetch()) { $result[] = $this->toArray(); } @@ -1160,7 +1160,7 @@ public function fetchValue() { * Ex: ["foo" => "The Foo Bar", "baz" => "The Baz Qux"] */ public function fetchMap($keyColumn, $valueColumn) { - $result = array(); + $result = []; while ($this->fetch()) { $result[$this->{$keyColumn}] = $this->{$valueColumn}; } @@ -1197,7 +1197,7 @@ public static function getFieldValue($daoName, $searchValue, $returnColumn = 'na $cacheKey = "{$daoName}:{$searchValue}:{$returnColumn}:{$searchColumn}"; if (self::$_dbColumnValueCache === NULL) { - self::$_dbColumnValueCache = array(); + self::$_dbColumnValueCache = []; } if (!array_key_exists($cacheKey, self::$_dbColumnValueCache) || $force) { @@ -1344,7 +1344,7 @@ public static function deleteEntityContact($daoName, $contactId) { */ static public function executeUnbufferedQuery( $query, - $params = array(), + $params = [], $abort = TRUE, $daoName = NULL, $freeDAO = FALSE, @@ -1360,7 +1360,7 @@ static public function executeUnbufferedQuery( $freeDAO, $i18nRewrite, $trapException, - array('result_buffering' => 0) + ['result_buffering' => 0] ); } @@ -1385,13 +1385,13 @@ static public function executeUnbufferedQuery( */ public static function &executeQuery( $query, - $params = array(), + $params = [], $abort = TRUE, $daoName = NULL, $freeDAO = FALSE, $i18nRewrite = TRUE, $trapException = FALSE, - $options = array() + $options = [] ) { $queryStr = self::composeQuery($query, $params, $abort); @@ -1440,12 +1440,12 @@ public static function &executeQuery( */ public function isValidOption($options) { $isValid = FALSE; - $validOptions = array( + $validOptions = [ 'result_buffering', 'persistent', 'ssl', 'portability', - ); + ]; if (empty($options)) { return $isValid; @@ -1475,7 +1475,7 @@ public function isValidOption($options) { */ public static function &singleValueQuery( $query, - $params = array(), + $params = [], $abort = TRUE, $i18nRewrite = TRUE ) { @@ -1512,7 +1512,7 @@ public static function &singleValueQuery( * @throws Exception */ public static function composeQuery($query, $params, $abort = TRUE) { - $tr = array(); + $tr = []; foreach ($params as $key => $item) { if (is_numeric($key)) { if (CRM_Utils_Type::validate($item[0], $item[1]) !== NULL) { @@ -1627,9 +1627,9 @@ public static function ©Generic($daoName, $criteria, $newData = NULL, $field $fields = $object->fields(); if (!is_array($fieldsFix)) { - $fieldsToPrefix = array(); - $fieldsToSuffix = array(); - $fieldsToReplace = array(); + $fieldsToPrefix = []; + $fieldsToSuffix = []; + $fieldsToReplace = []; } if (!empty($fieldsFix['prefix'])) { $fieldsToPrefix = $fieldsFix['prefix']; @@ -1688,7 +1688,7 @@ public static function ©Generic($daoName, $criteria, $newData = NULL, $field * * @return CRM_Core_DAO|null */ - public static function cascadeUpdate($daoName, $fromId, $toId, $newData = array()) { + public static function cascadeUpdate($daoName, $fromId, $toId, $newData = []) { $object = new $daoName(); $object->id = $fromId; @@ -1734,7 +1734,7 @@ public static function cascadeUpdate($daoName, $fromId, $toId, $newData = array( * @return array */ public static function getContactIDsFromComponent($componentIDs, $tableName, $idField = 'id') { - $contactIDs = array(); + $contactIDs = []; if (empty($componentIDs)) { return $contactIDs; @@ -1782,7 +1782,7 @@ public static function commonRetrieveAll($daoName, $fieldIdName = 'id', $fieldId $object->find(); while ($object->fetch()) { - $defaults = array(); + $defaults = []; self::storeValues($object, $defaults); $details[$object->id] = $defaults; } @@ -1828,8 +1828,8 @@ public static function escapeString($string) { if (!defined('CIVICRM_DSN')) { // See http://php.net/manual/en/mysqli.real-escape-string.php for the // list of characters mysqli_real_escape_string escapes. - $search = array("\\", "\x00", "\n", "\r", "'", '"', "\x1a"); - $replace = array("\\\\", "\\0", "\\n", "\\r", "\'", '\"', "\\Z"); + $search = ["\\", "\x00", "\n", "\r", "'", '"', "\x1a"]; + $replace = ["\\\\", "\\0", "\\n", "\\r", "\'", '\"', "\\Z"]; return str_replace($search, $replace, $string); } $_dao = new CRM_Core_DAO(); @@ -1856,7 +1856,7 @@ public static function escapeStrings($strings, $default = NULL) { return $default; } - $escapes = array_map(array($_dao, 'escape'), $strings); + $escapes = array_map([$_dao, 'escape'], $strings); return '"' . implode('","', $escapes) . '"'; } @@ -1871,7 +1871,7 @@ public static function escapeWildCardString($string) { // card characters and could come in via sortByCharacter // note that mysql does not escape these characters if ($string && in_array($string, - array('%', '_', '%%', '_%') + ['%', '_', '%%', '_%'] ) ) { return '\\' . $string; @@ -1895,7 +1895,7 @@ public static function escapeWildCardString($string) { */ public static function createTestObject( $daoName, - $params = array(), + $params = [], $numObjects = 1, $createOnly = FALSE ) { @@ -1905,14 +1905,14 @@ public static function createTestObject( $config->backtrace = TRUE; static $counter = 0; - CRM_Core_DAO::$_testEntitiesToSkip = array( + CRM_Core_DAO::$_testEntitiesToSkip = [ 'CRM_Core_DAO_Worldregion', 'CRM_Core_DAO_StateProvince', 'CRM_Core_DAO_Country', 'CRM_Core_DAO_Domain', 'CRM_Financial_DAO_FinancialType', //because valid ones exist & we use pick them due to pseudoconstant can't reliably create & delete these - ); + ]; // Prefer to instantiate BAO's instead of DAO's (when possible) // so that assignTestValue()/assignTestFK() can be overloaded. @@ -1976,7 +1976,7 @@ public static function createTestObject( * @param string $daoName * @param array $params */ - public static function deleteTestObjects($daoName, $params = array()) { + public static function deleteTestObjects($daoName, $params = []) { //this is a test function also backtrace is set for the test suite it sometimes unsets itself // so we re-set here in case $config = CRM_Core_Config::singleton(); @@ -1985,7 +1985,7 @@ public static function deleteTestObjects($daoName, $params = array()) { $object = new $daoName(); $object->id = CRM_Utils_Array::value('id', $params); - $deletions = array(); // array(array(0 => $daoName, 1 => $daoParams)) + $deletions = []; // array(array(0 => $daoName, 1 => $daoParams)) if ($object->find(TRUE)) { $fields = $object->fields(); @@ -2003,7 +2003,7 @@ public static function deleteTestObjects($daoName, $params = array()) { // to make this test process pass - line below makes pass for now && $dbName != 'member_of_contact_id' ) { - $deletions[] = array($FKClassName, array('id' => $object->$dbName)); // x + $deletions[] = [$FKClassName, ['id' => $object->$dbName]]; // x } } } @@ -2115,7 +2115,7 @@ public static function debugPrint($message = NULL, $printDAO = TRUE) { if ($printDAO) { global $_DB_DATAOBJECT; - $q = array(); + $q = []; foreach (array_keys($_DB_DATAOBJECT['RESULTS']) as $id) { $q[] = $_DB_DATAOBJECT['RESULTS'][$id]->query; } @@ -2185,7 +2185,7 @@ public static function createTriggers(&$info, $onlyTableName = NULL) { * @return array */ public static function createReferenceColumns($className) { - $result = array(); + $result = []; $fields = $className::fields(); foreach ($fields as $field) { if (isset($field['pseudoconstant'], $field['pseudoconstant']['optionGroupName'])) { @@ -2210,7 +2210,7 @@ public static function createReferenceColumns($className) { public function findReferences() { $links = self::getReferencesToTable(static::getTableName()); - $occurrences = array(); + $occurrences = []; foreach ($links as $refSpec) { /** @var $refSpec CRM_Core_Reference_Interface */ $daoName = CRM_Core_DAO_AllCoreTables::getClassForTable($refSpec->getReferenceTable()); @@ -2239,7 +2239,7 @@ public function findReferences() { public function getReferenceCounts() { $links = self::getReferencesToTable(static::getTableName()); - $counts = array(); + $counts = []; foreach ($links as $refSpec) { /** @var $refSpec CRM_Core_Reference_Interface */ $count = $refSpec->getReferenceCount($this); @@ -2274,7 +2274,7 @@ public function getReferenceCounts() { * foreign key reference to $tableName, and the column where the key appears. */ public static function getReferencesToTable($tableName) { - $refsFound = array(); + $refsFound = []; foreach (CRM_Core_DAO_AllCoreTables::getClasses() as $daoClassName) { $links = $daoClassName::getReferenceColumns(); $daoTableName = $daoClassName::getTableName(); @@ -2333,7 +2333,7 @@ public static function appendCustomTablesExtendingContacts(&$cidRefs) { $customValueTables = CRM_Core_BAO_CustomGroup::getAllCustomGroupsByBaseEntity('Contact'); $customValueTables->find(); while ($customValueTables->fetch()) { - $cidRefs[$customValueTables->table_name] = array('entity_id'); + $cidRefs[$customValueTables->table_name] = ['entity_id']; } } @@ -2424,7 +2424,7 @@ public static function appendPseudoConstantsToFields(&$fields) { * * @return array|bool */ - public static function buildOptions($fieldName, $context = NULL, $props = array()) { + public static function buildOptions($fieldName, $context = NULL, $props = []) { // If a given bao does not override this function $baoName = get_called_class(); return CRM_Core_PseudoConstant::get($baoName, $fieldName, $props, $context); @@ -2462,14 +2462,14 @@ public function getOptionLabels() { * @return array */ public static function buildOptionsContext($context = NULL) { - $contexts = array( + $contexts = [ 'get' => "get: all options are returned, even if they are disabled; labels are translated.", 'create' => "create: options are filtered appropriately for the object being created/updated; labels are translated.", 'search' => "search: searchable options are returned; labels are translated.", 'validate' => "validate: all options are returned, even if they are disabled; machine names are used in place of labels.", 'abbreviate' => "abbreviate: enabled options are returned; labels are replaced with abbreviations.", 'match' => "match: enabled options are returned using machine names as keys; labels are translated.", - ); + ]; // Validation: enforce uniformity of this param if ($context !== NULL && !isset($contexts[$context])) { throw new Exception("'$context' is not a valid context for buildOptions."); @@ -2559,10 +2559,10 @@ public static function createSQLFilter($fieldName, $filter, $type = NULL, $alias if (empty($criteria)) { throw new Exception("invalid criteria for $operator"); } - $escapedCriteria = array_map(array( + $escapedCriteria = array_map([ 'CRM_Core_DAO', 'escapeString', - ), $criteria); + ], $criteria); if (!$returnSanitisedArray) { return (sprintf('%s %s ("%s")', $fieldName, $operator, implode('", "', $escapedCriteria))); } @@ -2588,7 +2588,7 @@ public static function createSQLFilter($fieldName, $filter, $type = NULL, $alias * @return array */ public static function acceptedSQLOperators() { - return array( + return [ '=', '<=', '>=', @@ -2604,7 +2604,7 @@ public static function acceptedSQLOperators() { 'NOT BETWEEN', 'IS NOT NULL', 'IS NULL', - ); + ]; } /** @@ -2696,7 +2696,7 @@ public function setApiFilter(&$params) { * @return array */ public function addSelectWhereClause() { - $clauses = array(); + $clauses = []; $fields = $this->fields(); foreach ($fields as $fieldName => $field) { // Clause for contact-related entities like Email, Relationship, etc. @@ -2705,7 +2705,7 @@ public function addSelectWhereClause() { } // Clause for an entity_table/entity_id combo if ($fieldName == 'entity_id' && isset($fields['entity_table'])) { - $relatedClauses = array(); + $relatedClauses = []; $relatedEntities = $this->buildOptions('entity_table', 'get'); foreach ((array) $relatedEntities as $table => $ent) { if (!empty($ent)) { @@ -2741,7 +2741,7 @@ public static function getSelectWhereClause($tableAlias = NULL) { if ($tableAlias === NULL) { $tableAlias = $bao->tableName(); } - $clauses = array(); + $clauses = []; foreach ((array) $bao->addSelectWhereClause() as $field => $vals) { $clauses[$field] = NULL; if ($vals) { @@ -2760,7 +2760,7 @@ public static function getSelectWhereClause($tableAlias = NULL) { * @return bool */ public static function requireSafeDBName($database) { - $matches = array(); + $matches = []; preg_match( "/^[\w\-]*[a-z]+[\w\-]*$/i", $database, @@ -2786,7 +2786,7 @@ public static function serializeField($value, $serializationType) { } switch ($serializationType) { case self::SERIALIZE_SEPARATOR_BOOKEND: - return $value === array() ? '' : CRM_Utils_Array::implodePadded($value); + return $value === [] ? '' : CRM_Utils_Array::implodePadded($value); case self::SERIALIZE_SEPARATOR_TRIMMED: return is_array($value) ? implode(self::VALUE_SEPARATOR, $value) : $value; @@ -2818,7 +2818,7 @@ public static function unSerializeField($value, $serializationType) { return NULL; } if ($value === '') { - return array(); + return []; } switch ($serializationType) { case self::SERIALIZE_SEPARATOR_BOOKEND: @@ -2828,10 +2828,10 @@ public static function unSerializeField($value, $serializationType) { return explode(self::VALUE_SEPARATOR, trim($value)); case self::SERIALIZE_JSON: - return strlen($value) ? json_decode($value, TRUE) : array(); + return strlen($value) ? json_decode($value, TRUE) : []; case self::SERIALIZE_PHP: - return strlen($value) ? unserialize($value) : array(); + return strlen($value) ? unserialize($value) : []; case self::SERIALIZE_COMMA: return explode(',', trim(str_replace(', ', '', $value))); diff --git a/CRM/Core/DAO/AllCoreTables.php b/CRM/Core/DAO/AllCoreTables.php index 03060e11a6b5..df2531256964 100644 --- a/CRM/Core/DAO/AllCoreTables.php +++ b/CRM/Core/DAO/AllCoreTables.php @@ -47,15 +47,15 @@ public static function init($fresh = FALSE) { if ($init && !$fresh) { return; } - Civi::$statics[__CLASS__] = array(); + Civi::$statics[__CLASS__] = []; $file = preg_replace('/\.php$/', '.data.php', __FILE__); $entityTypes = require $file; CRM_Utils_Hook::entityTypes($entityTypes); - self::$entityTypes = array(); - self::$tables = array(); - self::$daoToClass = array(); + self::$entityTypes = []; + self::$tables = []; + self::$daoToClass = []; foreach ($entityTypes as $entityType) { self::registerEntityType( $entityType['name'], @@ -81,13 +81,13 @@ public static function init($fresh = FALSE) { public static function registerEntityType($daoName, $className, $tableName, $fields_callback = NULL, $links_callback = NULL) { self::$daoToClass[$daoName] = $className; self::$tables[$tableName] = $className; - self::$entityTypes[$className] = array( + self::$entityTypes[$className] = [ 'name' => $daoName, 'class' => $className, 'table' => $tableName, 'fields_callback' => $fields_callback, 'links_callback' => $links_callback, - ); + ]; } /** @@ -113,10 +113,10 @@ public static function tables() { * List of indices. */ public static function indices($localize = TRUE) { - $indices = array(); + $indices = []; self::init(); foreach (self::$daoToClass as $class) { - if (is_callable(array($class, 'indices'))) { + if (is_callable([$class, 'indices'])) { $indices[$class::getTableName()] = $class::indices($localize); } } @@ -141,13 +141,13 @@ public static function multilingualize($class, $originalIndices) { } $classFields = $class::fields(); - $finalIndices = array(); + $finalIndices = []; foreach ($originalIndices as $index) { if ($index['localizable']) { foreach ($locales as $locale) { $localIndex = $index; $localIndex['name'] .= "_" . $locale; - $fields = array(); + $fields = []; foreach ($localIndex['field'] as $field) { $baseField = explode('(', $field); if ($classFields[$baseField[0]]['localizable']) { @@ -296,7 +296,7 @@ public static function getExports($dao, $labelName, $prefix, $foreignDAOs) { // $cacheKey = $dao . ':' . ($prefix ? 'export-prefix' : 'export'); if (!isset(Civi::$statics[__CLASS__][$cacheKey])) { - $exports = array(); + $exports = []; $fields = $dao::fields(); foreach ($fields as $name => $field) { @@ -336,7 +336,7 @@ public static function getImports($dao, $labelName, $prefix, $foreignDAOs) { // $cacheKey = $dao . ':' . ($prefix ? 'import-prefix' : 'import'); if (!isset(Civi::$statics[__CLASS__][$cacheKey])) { - $imports = array(); + $imports = []; $fields = $dao::fields(); foreach ($fields as $name => $field) { @@ -372,7 +372,7 @@ public static function invoke($className, $event, &$values) { self::init(); if (isset(self::$entityTypes[$className][$event])) { foreach (self::$entityTypes[$className][$event] as $filter) { - $args = array($className, &$values); + $args = [$className, &$values]; \Civi\Core\Resolver::singleton()->call($filter, $args); } } diff --git a/CRM/Core/DAO/permissions.php b/CRM/Core/DAO/permissions.php index 5c0e84175999..6ba337cd1b4a 100644 --- a/CRM/Core/DAO/permissions.php +++ b/CRM/Core/DAO/permissions.php @@ -50,7 +50,7 @@ function _civicrm_api3_permissions($entity, $action, &$params) { CRM_Utils_Hook::alterAPIPermissions($entity, $action, $params, $permissions); // Merge permissions for this entity with the defaults - $perm = CRM_Utils_Array::value($entity, $permissions, array()) + $permissions['default']; + $perm = CRM_Utils_Array::value($entity, $permissions, []) + $permissions['default']; // Return exact match if permission for this action has been declared if (isset($perm[$action])) { diff --git a/CRM/Core/Error.php b/CRM/Core/Error.php index 163a1b44d3be..41895ed7c45b 100644 --- a/CRM/Core/Error.php +++ b/CRM/Core/Error.php @@ -125,11 +125,11 @@ public function __construct() { $this->setLogger($log); // PEAR<=1.9.0 does not declare "static" properly. - if (!is_callable(array('PEAR', '__callStatic'))) { - $this->setDefaultCallback(array($this, 'handlePES')); + if (!is_callable(['PEAR', '__callStatic'])) { + $this->setDefaultCallback([$this, 'handlePES']); } else { - PEAR_ErrorStack::setDefaultCallback(array($this, 'handlePES')); + PEAR_ErrorStack::setDefaultCallback([$this, 'handlePES']); } } @@ -142,7 +142,7 @@ public function __construct() { static public function getMessages(&$error, $separator = '
    ') { if (is_a($error, 'CRM_Core_Error')) { $errors = $error->getErrors(); - $message = array(); + $message = []; foreach ($errors as $e) { $message[] = $e['code'] . ': ' . $e['message']; } @@ -277,7 +277,7 @@ public static function simpleHandler($pearError) { */ public static function getErrorDetails($pearError) { // create the error array - $error = array(); + $error = []; $error['callback'] = $pearError->getCallback(); $error['code'] = $pearError->getCode(); $error['message'] = $pearError->getMessage(); @@ -328,10 +328,10 @@ public static function handlePES($pearError) { * @throws Exception */ public static function fatal($message = NULL, $code = NULL, $email = NULL) { - $vars = array( + $vars = [ 'message' => $message, 'code' => $code, - ); + ]; if (self::$modeException) { // CRM-11043 @@ -346,7 +346,7 @@ public static function fatal($message = NULL, $code = NULL, $email = NULL) { } if (!$message) { - $message = ts('We experienced an unexpected error. You may have found a bug. For more information on how to provide a bug report, please read: %1', array(1 => 'https://civicrm.org/bug-reporting')); + $message = ts('We experienced an unexpected error. You may have found a bug. For more information on how to provide a bug report, please read: %1', [1 => 'https://civicrm.org/bug-reporting']); } if (php_sapi_name() == "cli") { @@ -382,10 +382,10 @@ function_exists($config->fatalErrorHandler) // If we are in an ajax callback, format output appropriately if (CRM_Utils_Array::value('snippet', $_REQUEST) === CRM_Core_Smarty::PRINT_JSON) { - $out = array( + $out = [ 'status' => 'fatal', 'content' => '
    ' . ts('Sorry but we are not able to provide this at the moment.') . '
    ', - ); + ]; if ($config->backtrace && CRM_Core_Permission::check('view debug output')) { $out['backtrace'] = self::parseBacktrace(debug_backtrace()); $message .= '

    See console for backtrace

    '; @@ -420,13 +420,13 @@ public static function handleUnhandledException($exception) { CRM_Core_Error::debug_var('handleUnhandledException_nestedException', self::formatTextException($other)); } $config = CRM_Core_Config::singleton(); - $vars = array( + $vars = [ 'message' => $exception->getMessage(), 'code' => NULL, 'exception' => $exception, - ); + ]; if (!$vars['message']) { - $vars['message'] = ts('We experienced an unexpected error. You may have found a bug. For more information on how to provide a bug report, please read: %1', array(1 => 'https://civicrm.org/bug-reporting')); + $vars['message'] = ts('We experienced an unexpected error. You may have found a bug. For more information on how to provide a bug report, please read: %1', [1 => 'https://civicrm.org/bug-reporting']); } // Case A: CLI @@ -613,7 +613,7 @@ public static function debug_log_message($message, $out = FALSE, $prefix = '', $ if (!empty(\Civi::$statics[__CLASS__]['userFrameworkLogging'])) { // should call $config->userSystem->logger($message) here - but I got a situation where userSystem was not an object - not sure why if ($config->userSystem->is_drupal and function_exists('watchdog')) { - watchdog('civicrm', '%message', array('%message' => $message), WATCHDOG_DEBUG); + watchdog('civicrm', '%message', ['%message' => $message], WATCHDOG_DEBUG); } } @@ -643,7 +643,7 @@ public static function debug_query($string) { */ public static function debug_query_result($query) { $results = CRM_Core_DAO::executeQuery($query)->fetchAll(); - CRM_Core_Error::debug_var('dao result', array('query' => $query, 'results' => $results)); + CRM_Core_Error::debug_var('dao result', ['query' => $query, 'results' => $results]); } /** @@ -669,12 +669,12 @@ public static function createDebugLogger($prefix = '') { */ public static function generateLogFileHash($config) { // Use multiple (but stable) inputs for hash information. - $md5inputs = array( + $md5inputs = [ defined('CIVICRM_SITE_KEY') ? CIVICRM_SITE_KEY : 'NO_SITE_KEY', $config->userFrameworkBaseURL, md5($config->dsn), $config->dsn, - ); + ]; // Trim 8 chars off the string, make it slightly easier to find // but reveals less information from the hash. return substr(md5(var_export($md5inputs, 1)), 8); @@ -766,9 +766,9 @@ public static function formatBacktrace($backTrace, $showArgs = TRUE, $maxArgLen * @see Exception::getTrace() */ public static function parseBacktrace($backTrace, $showArgs = TRUE, $maxArgLen = 80) { - $ret = array(); + $ret = []; foreach ($backTrace as $trace) { - $args = array(); + $args = []; $fnName = CRM_Utils_Array::value('function', $trace); $className = isset($trace['class']) ? ($trace['class'] . $trace['type']) : ''; @@ -845,13 +845,13 @@ public static function formatHtmlException(Exception $e) { // Exception backtrace if ($e instanceof PEAR_Exception) { $ei = $e; - while (is_callable(array($ei, 'getCause'))) { + while (is_callable([$ei, 'getCause'])) { if ($ei->getCause() instanceof PEAR_Error) { $msg .= ''; $msg .= sprintf('', ts('Error Field'), ts('Error Value')); $msg .= ''; - foreach (array('Type', 'Code', 'Message', 'Mode', 'UserInfo', 'DebugInfo') as $f) { - $msg .= sprintf('', $f, call_user_func(array($ei->getCause(), "get$f"))); + foreach (['Type', 'Code', 'Message', 'Mode', 'UserInfo', 'DebugInfo'] as $f) { + $msg .= sprintf('', $f, call_user_func([$ei->getCause(), "get$f"])); } $msg .= '
    %s%s
    %s%s
    %s%s
    '; } @@ -877,10 +877,10 @@ public static function formatTextException(Exception $e) { $msg = get_class($e) . ": \"" . $e->getMessage() . "\"\n"; $ei = $e; - while (is_callable(array($ei, 'getCause'))) { + while (is_callable([$ei, 'getCause'])) { if ($ei->getCause() instanceof PEAR_Error) { - foreach (array('Type', 'Code', 'Message', 'Mode', 'UserInfo', 'DebugInfo') as $f) { - $msg .= sprintf(" * ERROR %s: %s\n", strtoupper($f), call_user_func(array($ei->getCause(), "get$f"))); + foreach (['Type', 'Code', 'Message', 'Mode', 'UserInfo', 'DebugInfo'] as $f) { + $msg .= sprintf(" * ERROR %s: %s\n", strtoupper($f), call_user_func([$ei->getCause(), "get$f"])); } } $ei = $ei->getCause(); @@ -899,7 +899,7 @@ public static function formatTextException(Exception $e) { */ public static function createError($message, $code = 8000, $level = 'Fatal', $params = NULL) { $error = CRM_Core_Error::singleton(); - $error->push($code, $level, array($params), $message); + $error->push($code, $level, [$params], $message); return $error; } @@ -920,9 +920,9 @@ public static function statusBounce($status, $redirect = NULL, $title = NULL) { if ($title === NULL) { $title = ts('Error'); } - $session->setStatus($status, $title, 'alert', array('expires' => 0)); + $session->setStatus($status, $title, 'alert', ['expires' => 0]); if (CRM_Utils_Array::value('snippet', $_REQUEST) === CRM_Core_Smarty::PRINT_JSON) { - CRM_Core_Page_AJAX::returnJsonResponse(array('status' => 'error')); + CRM_Core_Page_AJAX::returnJsonResponse(['status' => 'error']); } CRM_Utils_System::redirect($redirect); } @@ -933,8 +933,8 @@ public static function statusBounce($status, $redirect = NULL, $title = NULL) { */ public static function reset() { $error = self::singleton(); - $error->_errors = array(); - $error->_errorsByLevel = array(); + $error->_errors = []; + $error->_errorsByLevel = []; } /** @@ -979,7 +979,7 @@ public static function &createAPIError($msg, $data = NULL) { throw new Exception($msg, $data); } - $values = array(); + $values = []; $values['is_error'] = 1; $values['error_message'] = $msg; @@ -1040,7 +1040,7 @@ public static function deprecatedFunctionWarning($newMethod) { $dbt = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2); $callerFunction = isset($dbt[1]['function']) ? $dbt[1]['function'] : NULL; $callerClass = isset($dbt[1]['class']) ? $dbt[1]['class'] : NULL; - Civi::log()->warning("Deprecated function $callerClass::$callerFunction, use $newMethod.", array('civi.tag' => 'deprecated')); + Civi::log()->warning("Deprecated function $callerClass::$callerFunction, use $newMethod.", ['civi.tag' => 'deprecated']); } } diff --git a/CRM/Core/Error/Log.php b/CRM/Core/Error/Log.php index 571df81622d7..fc31c16223f8 100644 --- a/CRM/Core/Error/Log.php +++ b/CRM/Core/Error/Log.php @@ -37,7 +37,7 @@ class CRM_Core_Error_Log extends \Psr\Log\AbstractLogger { * CRM_Core_Error_Log constructor. */ public function __construct() { - $this->map = array( + $this->map = [ \Psr\Log\LogLevel::DEBUG => PEAR_LOG_DEBUG, \Psr\Log\LogLevel::INFO => PEAR_LOG_INFO, \Psr\Log\LogLevel::NOTICE => PEAR_LOG_NOTICE, @@ -46,7 +46,7 @@ public function __construct() { \Psr\Log\LogLevel::CRITICAL => PEAR_LOG_CRIT, \Psr\Log\LogLevel::ALERT => PEAR_LOG_ALERT, \Psr\Log\LogLevel::EMERGENCY => PEAR_LOG_EMERG, - ); + ]; } /** @@ -56,7 +56,7 @@ public function __construct() { * @param string $message * @param array $context */ - public function log($level, $message, array $context = array()) { + public function log($level, $message, array $context = []) { // FIXME: This flattens a $context a bit prematurely. When integrating // with external/CMS logs, we should pass through $context. if (!empty($context)) { diff --git a/CRM/Core/Exception.php b/CRM/Core/Exception.php index 8cecf32a5149..f87deadb83dd 100644 --- a/CRM/Core/Exception.php +++ b/CRM/Core/Exception.php @@ -38,7 +38,7 @@ * Extra params to return. eg an extra array of ids. It is not mandatory, but can help the computer using the api. Keep in mind the api consumer isn't to be trusted. eg. the database password is NOT a good extra data. */ class CRM_Core_Exception extends PEAR_Exception { - private $errorData = array(); + private $errorData = []; /** * Class constructor. @@ -48,9 +48,9 @@ class CRM_Core_Exception extends PEAR_Exception { * @param array $errorData * @param null $previous */ - public function __construct($message, $error_code = 0, $errorData = array(), $previous = NULL) { + public function __construct($message, $error_code = 0, $errorData = [], $previous = NULL) { parent::__construct(ts($message)); - $this->errorData = $errorData + array('error_code' => $error_code); + $this->errorData = $errorData + ['error_code' => $error_code]; } /** diff --git a/CRM/Core/Form.php b/CRM/Core/Form.php index 662580ee4f10..e6ecef99e47d 100644 --- a/CRM/Core/Form.php +++ b/CRM/Core/Form.php @@ -64,7 +64,7 @@ class CRM_Core_Form extends HTML_QuickForm_Page { * * @var array */ - public $_defaults = array(); + public $_defaults = []; /** * (QUASI-PROTECTED) The options passed into this form @@ -151,7 +151,7 @@ class CRM_Core_Form extends HTML_QuickForm_Page { * to have the time field re-incorporated into the field & 'now' set if * no value has been passed in */ - protected $_dateFields = array(); + protected $_dateFields = []; /** * Cache the smarty template for efficiency reasons @@ -170,14 +170,14 @@ class CRM_Core_Form extends HTML_QuickForm_Page { * * @var array */ - public $ajaxResponse = array(); + public $ajaxResponse = []; /** * Url path used to reach this page * * @var array */ - public $urlPath = array(); + public $urlPath = []; /** * Context of the form being loaded. @@ -230,18 +230,18 @@ public function setContext() { * @internal to keep track of chain-select fields * @var array */ - private $_chainSelectFields = array(); + private $_chainSelectFields = []; /** * Extra input types we support via the "add" method * @var array */ - public static $html5Types = array( + public static $html5Types = [ 'number', 'url', 'email', 'color', - ); + ]; /** * Constructor for the basic form page. @@ -318,7 +318,7 @@ public function addClass($className) { * Register all the standard rules that most forms potentially use. */ public function registerRules() { - static $rules = array( + static $rules = [ 'title', 'longTitle', 'variable', @@ -345,7 +345,7 @@ public function registerRules() { 'settingPath', 'autocomplete', 'validContact', - ); + ]; foreach ($rules as $rule) { $this->registerRule($rule, 'callback', $rule, 'CRM_Utils_Rule'); @@ -377,7 +377,7 @@ public function &add( // Fudge some extra types that quickform doesn't support $inputType = $type; if ($type == 'wysiwyg' || in_array($type, self::$html5Types)) { - $attributes = ($attributes ? $attributes : array()) + array('class' => ''); + $attributes = ($attributes ? $attributes : []) + ['class' => '']; $attributes['class'] = ltrim($attributes['class'] . " crm-form-$type"); if ($type == 'wysiwyg' && isset($attributes['preset'])) { $attributes['data-preset'] = $attributes['preset']; @@ -389,15 +389,15 @@ public function &add( if ($inputType == 'select2') { $type = 'text'; $options = $attributes; - $attributes = $attributes = ($extra ? $extra : array()) + array('class' => ''); + $attributes = $attributes = ($extra ? $extra : []) + ['class' => '']; $attributes['class'] = ltrim($attributes['class'] . " crm-select2 crm-form-select2"); - $attributes['data-select-params'] = json_encode(array('data' => $options, 'multiple' => !empty($attributes['multiple']))); + $attributes['data-select-params'] = json_encode(['data' => $options, 'multiple' => !empty($attributes['multiple'])]); unset($attributes['multiple']); $extra = NULL; } // @see http://wiki.civicrm.org/confluence/display/CRMDOC/crmDatepicker if ($type == 'datepicker') { - $attributes = ($attributes ? $attributes : array()); + $attributes = ($attributes ? $attributes : []); $attributes['data-crm-datepicker'] = json_encode((array) $extra); if (!empty($attributes['aria-label']) || $label) { $attributes['aria-label'] = CRM_Utils_Array::value('aria-label', $attributes, $label); @@ -419,7 +419,7 @@ public function &add( $extra['placeholder'] = $required ? ts('- select -') : ts('- none -'); } if (($extra['placeholder'] || $extra['placeholder'] === '') && empty($extra['multiple']) && is_array($attributes) && !isset($attributes[''])) { - $attributes = array('' => $extra['placeholder']) + $attributes; + $attributes = ['' => $extra['placeholder']] + $attributes; } } } @@ -429,15 +429,15 @@ public function &add( } if ($inputType == 'color') { - $this->addRule($name, ts('%1 must contain a color value e.g. #ffffff.', array(1 => $label)), 'regex', '/#[0-9a-fA-F]{6}/'); + $this->addRule($name, ts('%1 must contain a color value e.g. #ffffff.', [1 => $label]), 'regex', '/#[0-9a-fA-F]{6}/'); } if ($required) { if ($type == 'file') { - $error = $this->addRule($name, ts('%1 is a required field.', array(1 => $label)), 'uploadedfile'); + $error = $this->addRule($name, ts('%1 is a required field.', [1 => $label]), 'uploadedfile'); } else { - $error = $this->addRule($name, ts('%1 is a required field.', array(1 => $label)), 'required'); + $error = $this->addRule($name, ts('%1 is a required field.', [1 => $label]), 'required'); } if (HTML_QuickForm::isError($error)) { CRM_Core_Error::fatal(HTML_QuickForm::errorMessage($element)); @@ -490,10 +490,10 @@ public function mainProcess($allowAjax = TRUE) { $this->postProcessHook(); // Respond with JSON if in AJAX context (also support legacy value '6') - if ($allowAjax && !empty($_REQUEST['snippet']) && in_array($_REQUEST['snippet'], array( + if ($allowAjax && !empty($_REQUEST['snippet']) && in_array($_REQUEST['snippet'], [ CRM_Core_Smarty::PRINT_JSON, 6, - )) + ]) ) { $this->ajaxResponse['buttonName'] = str_replace('_qf_' . $this->getAttribute('id') . '_', '', $this->controller->getButtonName()); $this->ajaxResponse['action'] = $this->_action; @@ -556,7 +556,7 @@ public function validate() { $this->validateChainSelectFields(); - $hookErrors = array(); + $hookErrors = []; CRM_Utils_Hook::validateForm( get_class($this), @@ -639,13 +639,13 @@ public function buildForm() { * formats. */ public function addButtons($params) { - $prevnext = $spacing = array(); + $prevnext = $spacing = []; foreach ($params as $button) { if (!empty($button['submitOnce'])) { $button['js']['onclick'] = "return submitOnce(this,'{$this->_name}','" . ts('Processing') . "');"; } - $attrs = array('class' => 'crm-form-submit') + (array) CRM_Utils_Array::value('js', $button); + $attrs = ['class' => 'crm-form-submit'] + (array) CRM_Utils_Array::value('js', $button); if (!empty($button['class'])) { $attrs['class'] .= ' ' . $button['class']; @@ -655,7 +655,7 @@ public function addButtons($params) { $attrs['class'] .= ' default'; } - if (in_array($button['type'], array('upload', 'next', 'submit', 'done', 'process', 'refresh'))) { + if (in_array($button['type'], ['upload', 'next', 'submit', 'done', 'process', 'refresh'])) { $attrs['class'] .= ' validate'; $defaultIcon = 'fa-check'; } @@ -680,7 +680,7 @@ public function addButtons($params) { } } - if (in_array($button['type'], array('next', 'upload', 'done')) && $button['name'] === ts('Save')) { + if (in_array($button['type'], ['next', 'upload', 'done']) && $button['name'] === ts('Save')) { $attrs['accesskey'] = 'S'; } $icon = CRM_Utils_Array::value('icon', $button, $defaultIcon); @@ -696,7 +696,7 @@ public function addButtons($params) { // if button type is upload, set the enctype if ($button['type'] == 'upload') { - $this->updateAttributes(array('enctype' => 'multipart/form-data')); + $this->updateAttributes(['enctype' => 'multipart/form-data']); $this->setMaxFileSize(); } @@ -777,7 +777,7 @@ public function assignBillingType() { */ protected function assignPaymentProcessor($isPayLaterEnabled) { $this->_paymentProcessors = CRM_Financial_BAO_PaymentProcessor::getPaymentProcessors( - array(ucfirst($this->_mode) . 'Mode'), + [ucfirst($this->_mode) . 'Mode'], $this->_paymentProcessorIDs ); if ($isPayLaterEnabled) { @@ -830,7 +830,7 @@ protected function formatParamsForPaymentProcessor($fields) { $this->_params = array_merge($this->_params, $addressParams); } - $nameFields = array('first_name', 'middle_name', 'last_name'); + $nameFields = ['first_name', 'middle_name', 'last_name']; foreach ($nameFields as $name) { $fields[$name] = 1; if (array_key_exists("billing_$name", $this->_params)) { @@ -876,7 +876,7 @@ protected function preProcessPaymentOptions() { CRM_Core_Payment_ProcessorForm::preProcess($this); } else { - $this->_paymentProcessor = array(); + $this->_paymentProcessor = []; } CRM_Financial_Form_Payment::addCreditCardJs($this->_paymentProcessorID); } @@ -977,10 +977,10 @@ public function getTemplateFileName() { else { $tplname = strtr( CRM_Utils_System::getClassName($this), - array( + [ '_' => DIRECTORY_SEPARATOR, '\\' => DIRECTORY_SEPARATOR, - ) + ] ) . '.tpl'; } return $tplname; @@ -1128,9 +1128,9 @@ public function get_template_vars($name = NULL) { * * @return HTML_QuickForm_group */ - public function &addRadio($name, $title, $values, $attributes = array(), $separator = NULL, $required = FALSE) { - $options = array(); - $attributes = $attributes ? $attributes : array(); + public function &addRadio($name, $title, $values, $attributes = [], $separator = NULL, $required = FALSE) { + $options = []; + $attributes = $attributes ? $attributes : []; $allowClear = !empty($attributes['allowClear']); unset($attributes['allowClear']); $attributes['id_suffix'] = $name; @@ -1145,7 +1145,7 @@ public function &addRadio($name, $title, $values, $attributes = array(), $separa } if ($required) { - $this->addRule($name, ts('%1 is a required field.', array(1 => $title)), 'required'); + $this->addRule($name, ts('%1 is a required field.', [1 => $title]), 'required'); } if ($allowClear) { $group->setAttribute('allowClear', TRUE); @@ -1160,9 +1160,9 @@ public function &addRadio($name, $title, $values, $attributes = array(), $separa * @param null $required * @param array $attributes */ - public function addYesNo($id, $title, $allowClear = FALSE, $required = NULL, $attributes = array()) { - $attributes += array('id_suffix' => $id); - $choice = array(); + public function addYesNo($id, $title, $allowClear = FALSE, $required = NULL, $attributes = []) { + $attributes += ['id_suffix' => $id]; + $choice = []; $choice[] = $this->createElement('radio', NULL, '11', ts('Yes'), '1', $attributes); $choice[] = $this->createElement('radio', NULL, '11', ts('No'), '0', $attributes); @@ -1171,7 +1171,7 @@ public function addYesNo($id, $title, $allowClear = FALSE, $required = NULL, $at $group->setAttribute('allowClear', TRUE); } if ($required) { - $this->addRule($id, ts('%1 is a required field.', array(1 => $title)), 'required'); + $this->addRule($id, ts('%1 is a required field.', [1 => $title]), 'required'); } } @@ -1192,7 +1192,7 @@ public function addCheckBox( $javascriptMethod = NULL, $separator = '
    ', $flipValues = FALSE ) { - $options = array(); + $options = []; if ($javascriptMethod) { foreach ($values as $key => $var) { @@ -1227,7 +1227,7 @@ public function addCheckBox( if ($required) { $this->addRule($id, - ts('%1 is a required field.', array(1 => $title)), + ts('%1 is a required field.', [1 => $title]), 'required' ); } @@ -1235,7 +1235,7 @@ public function addCheckBox( public function resetValues() { $data = $this->controller->container(); - $data['values'][$this->_name] = array(); + $data['values'][$this->_name] = []; } /** @@ -1250,21 +1250,21 @@ public function resetValues() { * @param bool|string $submitOnce If true, add javascript to next button submit which prevents it from being clicked more than once */ public function addDefaultButtons($title, $nextType = 'next', $backType = 'back', $submitOnce = FALSE) { - $buttons = array(); + $buttons = []; if ($backType != NULL) { - $buttons[] = array( + $buttons[] = [ 'type' => $backType, 'name' => ts('Previous'), - ); + ]; } if ($nextType != NULL) { - $nextButton = array( + $nextButton = [ 'type' => $nextType, 'name' => $title, 'isDefault' => TRUE, - ); + ]; if ($submitOnce) { - $nextButton['js'] = array('onclick' => "return submitOnce(this,'{$this->_name}','" . ts('Processing') . "');"); + $nextButton['js'] = ['onclick' => "return submitOnce(this,'{$this->_name}','" . ts('Processing') . "');"]; } $buttons[] = $nextButton; } @@ -1282,12 +1282,12 @@ public function addDefaultButtons($title, $nextType = 'next', $backType = 'back' */ public function addDateRange($name, $from = '_from', $to = '_to', $label = 'From:', $dateFormat = 'searchDate', $required = FALSE, $displayTime = FALSE) { if ($displayTime) { - $this->addDateTime($name . $from, $label, $required, array('formatType' => $dateFormat)); - $this->addDateTime($name . $to, ts('To:'), $required, array('formatType' => $dateFormat)); + $this->addDateTime($name . $from, $label, $required, ['formatType' => $dateFormat]); + $this->addDateTime($name . $to, ts('To:'), $required, ['formatType' => $dateFormat]); } else { - $this->addDate($name . $from, $label, $required, array('formatType' => $dateFormat)); - $this->addDate($name . $to, ts('To:'), $required, array('formatType' => $dateFormat)); + $this->addDate($name . $from, $label, $required, ['formatType' => $dateFormat]); + $this->addDate($name . $to, ts('To:'), $required, ['formatType' => $dateFormat]); } } @@ -1304,10 +1304,10 @@ public function addDateRange($name, $from = '_from', $to = '_to', $label = 'From */ public function addDatePickerRange($fieldName, $label, $isDateTime = FALSE, $required = FALSE, $fromLabel = 'From', $toLabel = 'To') { - $options = array( + $options = [ '' => ts('- any -'), 0 => ts('Choose Date Range'), - ) + CRM_Core_OptionGroup::values('relative_date_filters'); + ] + CRM_Core_OptionGroup::values('relative_date_filters'); $this->add('select', "{$fieldName}_relative", @@ -1379,7 +1379,7 @@ public function getDefaultContext() { * @throws CRM_Core_Exception * @return HTML_QuickForm_Element */ - public function addSelect($name, $props = array(), $required = FALSE) { + public function addSelect($name, $props = [], $required = FALSE) { if (!isset($props['entity'])) { $props['entity'] = $this->getDefaultEntity(); } @@ -1420,7 +1420,7 @@ public function addSelect($name, $props = array(), $required = FALSE) { if ( $uniqueName === $props['field'] || CRM_Utils_Array::value('name', $fieldSpec) === $props['field'] || - in_array($props['field'], CRM_Utils_Array::value('api.aliases', $fieldSpec, array())) + in_array($props['field'], CRM_Utils_Array::value('api.aliases', $fieldSpec, [])) ) { break; } @@ -1460,7 +1460,7 @@ public function addSelect($name, $props = array(), $required = FALSE) { * @throws \Exception * @return HTML_QuickForm_Element */ - public function addField($name, $props = array(), $required = FALSE, $legacyDate = TRUE) { + public function addField($name, $props = [], $required = FALSE, $legacyDate = TRUE) { // Resolve context. if (empty($props['context'])) { $props['context'] = $this->getDefaultContext(); @@ -1496,12 +1496,12 @@ public function addField($name, $props = array(), $required = FALSE, $legacyDate $widget = 'Text'; } - $isSelect = (in_array($widget, array( + $isSelect = (in_array($widget, [ 'Select', 'CheckBoxGroup', 'RadioGroup', 'Radio', - ))); + ])); if ($isSelect) { // Fetch options from the api unless passed explicitly. @@ -1531,7 +1531,7 @@ public function addField($name, $props = array(), $required = FALSE, $legacyDate $props['data-api-field'] = $props['name']; } } - $props += CRM_Utils_Array::value('html', $fieldSpec, array()); + $props += CRM_Utils_Array::value('html', $fieldSpec, []); CRM_Utils_Array::remove($props, 'entity', 'name', 'context', 'label', 'action', 'type', 'option_url', 'options'); // TODO: refactor switch statement, to separate methods. @@ -1567,7 +1567,7 @@ public function addField($name, $props = array(), $required = FALSE, $legacyDate } else { $fieldSpec = CRM_Utils_Date::addDateMetadataToField($fieldSpec, $fieldSpec); - $attributes = array('format' => $fieldSpec['date_format']); + $attributes = ['format' => $fieldSpec['date_format']]; return $this->add('datepicker', $name, $label, $attributes, $required, $fieldSpec['datepicker']['extra']); } @@ -1580,11 +1580,11 @@ public function addField($name, $props = array(), $required = FALSE, $legacyDate return $this->addRadio($name, $label, $options, $props, $separator, $required); case 'ChainSelect': - $props += array( + $props += [ 'required' => $required, 'label' => $label, 'multiple' => $context == 'search', - ); + ]; return $this->addChainSelect($name, $props); case 'Select': @@ -1662,7 +1662,7 @@ public function addProfileSelector($name, $label, $allowCoreTypes, $allowSubType // FIXME: Instead of adhoc serialization, use a single json_encode() CRM_UF_Page_ProfileEditor::registerProfileScripts(); CRM_UF_Page_ProfileEditor::registerSchemas(CRM_Utils_Array::collect('entity_type', $entities)); - $this->add('text', $name, $label, array( + $this->add('text', $name, $label, [ 'class' => 'crm-profile-selector', // Note: client treats ';;' as equivalent to \0, and ';;' works better in HTML 'data-group-type' => CRM_Core_BAO_UFGroup::encodeGroupType($allowCoreTypes, $allowSubTypes, ';;'), @@ -1670,7 +1670,7 @@ public function addProfileSelector($name, $label, $allowCoreTypes, $allowSubType //CRM-15427 'data-default' => $default, 'data-usedfor' => json_encode($usedFor), - )); + ]); } /** @@ -1700,7 +1700,7 @@ public static function &getTemplate() { public function addUploadElement($elementName) { $uploadNames = $this->get('uploadNames'); if (!$uploadNames) { - $uploadNames = array(); + $uploadNames = []; } if (is_array($elementName)) { foreach ($elementName as $name) { @@ -1757,8 +1757,8 @@ public function setVar($name, $value) { public function addDate($name, $label, $required = FALSE, $attributes = NULL) { if (!empty($attributes['formatType'])) { // get actual format - $params = array('name' => $attributes['formatType']); - $values = array(); + $params = ['name' => $attributes['formatType']]; + $values = []; // cache date information static $dateFormat; @@ -1820,12 +1820,12 @@ public function addDate($name, $label, $required = FALSE, $attributes = NULL) { $elementName = substr($name, 0, strlen($name) - 1) . '_time]'; } - $this->add('text', $elementName, ts('Time'), array('timeFormat' => $show24Hours)); + $this->add('text', $elementName, ts('Time'), ['timeFormat' => $show24Hours]); } } if ($required) { - $this->addRule($name, ts('Please select %1', array(1 => $label)), 'required'); + $this->addRule($name, ts('Please select %1', [1 => $label]), 'required'); if (!empty($attributes['addTime']) && !empty($attributes['addTimeRequired'])) { $this->addRule($elementName, ts('Please enter a time.'), 'required'); } @@ -1844,7 +1844,7 @@ public function addDate($name, $label, $required = FALSE, $attributes = NULL) { * @param null $attributes */ public function addDateTime($name, $label, $required = FALSE, $attributes = NULL) { - $addTime = array('addTime' => TRUE); + $addTime = ['addTime' => TRUE]; if (is_array($attributes)) { $attributes = array_merge($attributes, $addTime); } @@ -1912,9 +1912,9 @@ public function addCurrency( Civi::log()->warning('addCurrency: Currency ' . $defaultCurrency . ' is disabled but still in use!'); $currencies[$defaultCurrency] = $defaultCurrency; } - $options = array('class' => 'crm-select2 eight'); + $options = ['class' => 'crm-select2 eight']; if (!$required) { - $currencies = array('' => '') + $currencies; + $currencies = ['' => ''] + $currencies; $options['placeholder'] = ts('- none -'); } $ele = $this->add('select', $name, $label, $currencies, $required, $options); @@ -1928,7 +1928,7 @@ public function addCurrency( // In some case, setting currency field by default might override the default value // as encountered in CRM-20527 for batch data entry if ($setDefaultCurrency) { - $this->setDefaults(array($name => $defaultCurrency)); + $this->setDefaults([$name => $defaultCurrency]); } } @@ -1953,9 +1953,9 @@ public function addCurrency( * * @return HTML_QuickForm_Element */ - public function addEntityRef($name, $label = '', $props = array(), $required = FALSE) { + public function addEntityRef($name, $label = '', $props = [], $required = FALSE) { // Default properties - $props['api'] = CRM_Utils_Array::value('api', $props, array()); + $props['api'] = CRM_Utils_Array::value('api', $props, []); $props['entity'] = CRM_Utils_String::convertStringToCamel(CRM_Utils_Array::value('entity', $props, 'Contact')); $props['class'] = ltrim(CRM_Utils_Array::value('class', $props, '') . ' crm-form-entityref'); @@ -1963,13 +1963,13 @@ public function addEntityRef($name, $label = '', $props = array(), $required = F unset($props['create']); } - $props['placeholder'] = CRM_Utils_Array::value('placeholder', $props, $required ? ts('- select %1 -', array(1 => ts(str_replace('_', ' ', $props['entity'])))) : ts('- none -')); + $props['placeholder'] = CRM_Utils_Array::value('placeholder', $props, $required ? ts('- select %1 -', [1 => ts(str_replace('_', ' ', $props['entity']))]) : ts('- none -')); - $defaults = array(); + $defaults = []; if (!empty($props['multiple'])) { $defaults['multiple'] = TRUE; } - $props['select'] = CRM_Utils_Array::value('select', $props, array()) + $defaults; + $props['select'] = CRM_Utils_Array::value('select', $props, []) + $defaults; $this->formatReferenceFieldAttributes($props, get_class($this)); return $this->add('text', $name, $label, $props, $required); @@ -2023,7 +2023,7 @@ public function convertDateFieldsToMySQL(&$params) { * @param $elementName */ public function removeFileRequiredRules($elementName) { - $this->_required = array_diff($this->_required, array($elementName)); + $this->_required = array_diff($this->_required, [$elementName]); if (isset($this->_rules[$elementName])) { foreach ($this->_rules[$elementName] as $index => $ruleInfo) { if ($ruleInfo['type'] == 'uploadedfile') { @@ -2055,7 +2055,7 @@ public function cancelAction() { public static function validateMandatoryFields($fields, $values, &$errors) { foreach ($fields as $name => $fld) { if (!empty($fld['is_required']) && CRM_Utils_System::isNull(CRM_Utils_Array::value($name, $values))) { - $errors[$name] = ts('%1 is a required field.', array(1 => $fld['title'])); + $errors[$name] = ts('%1 is a required field.', [1 => $fld['title']]); } } } @@ -2088,14 +2088,14 @@ protected function setContactID() { // from that page // we don't really need to set it when $tempID is set because the params have that stored $this->set('cid', 0); - CRM_Core_Resources::singleton()->addVars('coreForm', array('contact_id' => (int) $tempID)); + CRM_Core_Resources::singleton()->addVars('coreForm', ['contact_id' => (int) $tempID]); return (int) $tempID; } $userID = $this->getLoggedInUserContactID(); if (!is_null($tempID) && $tempID === $userID) { - CRM_Core_Resources::singleton()->addVars('coreForm', array('contact_id' => (int) $tempID)); + CRM_Core_Resources::singleton()->addVars('coreForm', ['contact_id' => (int) $tempID]); return (int) $userID; } @@ -2105,18 +2105,18 @@ protected function setContactID() { //check for anonymous user. $validUser = CRM_Contact_BAO_Contact_Utils::validChecksum($tempID, $userChecksum); if ($validUser) { - CRM_Core_Resources::singleton()->addVars('coreForm', array('contact_id' => (int) $tempID)); - CRM_Core_Resources::singleton()->addVars('coreForm', array('checksum' => $userChecksum)); + CRM_Core_Resources::singleton()->addVars('coreForm', ['contact_id' => (int) $tempID]); + CRM_Core_Resources::singleton()->addVars('coreForm', ['checksum' => $userChecksum]); return $tempID; } } // check if user has permission, CRM-12062 elseif ($tempID && CRM_Contact_BAO_Contact_Permission::allow($tempID)) { - CRM_Core_Resources::singleton()->addVars('coreForm', array('contact_id' => (int) $tempID)); + CRM_Core_Resources::singleton()->addVars('coreForm', ['contact_id' => (int) $tempID]); return $tempID; } if (is_numeric($userID)) { - CRM_Core_Resources::singleton()->addVars('coreForm', array('contact_id' => (int) $userID)); + CRM_Core_Resources::singleton()->addVars('coreForm', ['contact_id' => (int) $userID]); } return is_numeric($userID) ? $userID : NULL; } @@ -2162,34 +2162,34 @@ public function getLoggedInUserContactID() { * * @todo add data attributes so we can deal with multiple instances on a form */ - public function addAutoSelector($profiles = array(), $autoCompleteField = array()) { - $autoCompleteField = array_merge(array( + public function addAutoSelector($profiles = [], $autoCompleteField = []) { + $autoCompleteField = array_merge([ 'id_field' => 'select_contact_id', 'placeholder' => ts('Select someone else ...'), 'show_hide' => TRUE, - 'api' => array('params' => array('contact_type' => 'Individual')), - ), $autoCompleteField); + 'api' => ['params' => ['contact_type' => 'Individual']], + ], $autoCompleteField); if ($this->canUseAjaxContactLookups()) { $this->assign('selectable', $autoCompleteField['id_field']); - $this->addEntityRef($autoCompleteField['id_field'], NULL, array( + $this->addEntityRef($autoCompleteField['id_field'], NULL, [ 'placeholder' => $autoCompleteField['placeholder'], 'api' => $autoCompleteField['api'], - )); + ]); CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/AlternateContactSelector.js', 1, 'html-header') - ->addSetting(array( - 'form' => array('autocompletes' => $autoCompleteField), - 'ids' => array('profile' => $profiles), - )); + ->addSetting([ + 'form' => ['autocompletes' => $autoCompleteField], + 'ids' => ['profile' => $profiles], + ]); } } /** */ public function canUseAjaxContactLookups() { - if (0 < (civicrm_api3('contact', 'getcount', array('check_permissions' => 1))) && - CRM_Core_Permission::check(array(array('access AJAX API', 'access CiviCRM'))) + if (0 < (civicrm_api3('contact', 'getcount', ['check_permissions' => 1])) && + CRM_Core_Permission::check([['access AJAX API', 'access CiviCRM']]) ) { return TRUE; } @@ -2207,7 +2207,7 @@ public function canUseAjaxContactLookups() { */ public function addCIDZeroOptions($onlinePaymentProcessorEnabled) { $this->assign('nocid', TRUE); - $profiles = array(); + $profiles = []; if ($this->_values['custom_pre_id']) { $profiles[] = $this->_values['custom_pre_id']; } @@ -2233,16 +2233,16 @@ public function addCIDZeroOptions($onlinePaymentProcessorEnabled) { */ public function getProfileDefaults($profile_id = 'Billing', $contactID = NULL) { try { - $defaults = civicrm_api3('profile', 'getsingle', array( + $defaults = civicrm_api3('profile', 'getsingle', [ 'profile_id' => (array) $profile_id, 'contact_id' => $contactID, - )); + ]); return $defaults; } catch (Exception $e) { // the try catch block gives us silent failure -not 100% sure this is a good idea // as silent failures are often worse than noisy ones - return array(); + return []; } } @@ -2269,20 +2269,20 @@ public function allowAjaxSubmit() { public function setPageTitle($entityLabel) { switch ($this->_action) { case CRM_Core_Action::ADD: - CRM_Utils_System::setTitle(ts('New %1', array(1 => $entityLabel))); + CRM_Utils_System::setTitle(ts('New %1', [1 => $entityLabel])); break; case CRM_Core_Action::UPDATE: - CRM_Utils_System::setTitle(ts('Edit %1', array(1 => $entityLabel))); + CRM_Utils_System::setTitle(ts('Edit %1', [1 => $entityLabel])); break; case CRM_Core_Action::VIEW: case CRM_Core_Action::PREVIEW: - CRM_Utils_System::setTitle(ts('View %1', array(1 => $entityLabel))); + CRM_Utils_System::setTitle(ts('View %1', [1 => $entityLabel])); break; case CRM_Core_Action::DELETE: - CRM_Utils_System::setTitle(ts('Delete %1', array(1 => $entityLabel))); + CRM_Utils_System::setTitle(ts('Delete %1', [1 => $entityLabel])); break; } } @@ -2295,14 +2295,14 @@ public function setPageTitle($entityLabel) { * * @return HTML_QuickForm_Element */ - public function addChainSelect($elementName, $settings = array()) { - $props = $settings += array( - 'control_field' => str_replace(array('state_province', 'StateProvince', 'county', 'County'), array( + public function addChainSelect($elementName, $settings = []) { + $props = $settings += [ + 'control_field' => str_replace(['state_province', 'StateProvince', 'county', 'County'], [ 'country', 'Country', 'state_province', 'StateProvince', - ), $elementName), + ], $elementName), 'data-callback' => strpos($elementName, 'rovince') ? 'civicrm/ajax/jqState' : 'civicrm/ajax/jqCounty', 'label' => strpos($elementName, 'rovince') ? ts('State/Province') : ts('County'), 'data-empty-prompt' => strpos($elementName, 'rovince') ? ts('Choose country first') : ts('Choose state first'), @@ -2310,7 +2310,7 @@ public function addChainSelect($elementName, $settings = array()) { 'multiple' => FALSE, 'required' => FALSE, 'placeholder' => empty($settings['required']) ? ts('- none -') : ts('- select -'), - ); + ]; CRM_Utils_Array::remove($props, 'label', 'required', 'control_field', 'context'); $props['class'] = (empty($props['class']) ? '' : "{$props['class']} ") . 'crm-select2'; $props['data-select-prompt'] = $props['placeholder']; @@ -2334,13 +2334,13 @@ public function addTaskMenu($tasks) { if (is_array($tasks) && !empty($tasks)) { // Set constants means this will always load with an empty value, not reloading any submitted value. // This is appropriate as it is a pseudofield. - $this->setConstants(array('task' => '')); + $this->setConstants(['task' => '']); $this->assign('taskMetaData', $tasks); - $select = $this->add('select', 'task', NULL, array('' => ts('Actions')), FALSE, array( - 'class' => 'crm-select2 crm-action-menu fa-check-circle-o huge crm-search-result-actions') + $select = $this->add('select', 'task', NULL, ['' => ts('Actions')], FALSE, [ + 'class' => 'crm-select2 crm-action-menu fa-check-circle-o huge crm-search-result-actions'] ); foreach ($tasks as $key => $task) { - $attributes = array(); + $attributes = []; if (isset($task['data'])) { foreach ($task['data'] as $dataKey => $dataValue) { $attributes['data-' . $dataKey] = $dataValue; @@ -2352,10 +2352,10 @@ public function addTaskMenu($tasks) { $this->_actionButtonName = $this->getButtonName('next', 'action'); } $this->assign('actionButtonName', $this->_actionButtonName); - $this->add('submit', $this->_actionButtonName, ts('Go'), array('class' => 'hiddenElement crm-search-go-button')); + $this->add('submit', $this->_actionButtonName, ts('Go'), ['class' => 'hiddenElement crm-search-go-button']); // Radio to choose "All items" or "Selected items only" - $selectedRowsRadio = $this->addElement('radio', 'radio_ts', NULL, '', 'ts_sel', array('checked' => 'checked')); + $selectedRowsRadio = $this->addElement('radio', 'radio_ts', NULL, '', 'ts_sel', ['checked' => 'checked']); $allRowsRadio = $this->addElement('radio', 'radio_ts', NULL, '', 'ts_all'); $this->assign('ts_sel_id', $selectedRowsRadio->_attributes['id']); $this->assign('ts_all_id', $allRowsRadio->_attributes['id']); @@ -2373,7 +2373,7 @@ private function preProcessChainSelectFields() { if ($this->elementExists($target)) { $targetField = $this->getElement($target); $targetType = $targetField->getAttribute('data-callback') == 'civicrm/ajax/jqCounty' ? 'county' : 'stateProvince'; - $options = array(); + $options = []; // If the control field is on the form, setup chain-select and dynamically populate options if ($this->elementExists($control)) { $controlField = $this->getElement($control); @@ -2382,10 +2382,10 @@ private function preProcessChainSelectFields() { $targetField->setAttribute('class', $targetField->getAttribute('class') . ' crm-chain-select-target'); $css = (string) $controlField->getAttribute('class'); - $controlField->updateAttributes(array( + $controlField->updateAttributes([ 'class' => ($css ? "$css " : 'crm-select2 ') . 'crm-chain-select-control', 'data-target' => $target, - )); + ]); $controlValue = $controlField->getValue(); if ($controlValue) { $options = CRM_Core_BAO_Location::getChainSelectValues($controlValue, $controlType, TRUE); @@ -2403,10 +2403,10 @@ private function preProcessChainSelectFields() { $options = CRM_Core_PseudoConstant::$targetType(); } if (!$targetField->getAttribute('multiple')) { - $options = array('' => $targetField->getAttribute('placeholder')) + $options; + $options = ['' => $targetField->getAttribute('placeholder')] + $options; $targetField->removeAttribute('placeholder'); } - $targetField->_options = array(); + $targetField->_options = []; $targetField->loadArray($options); } } @@ -2445,7 +2445,7 @@ private function validateChainSelectFields() { * * @return string */ - public function assignBillingName($params = array()) { + public function assignBillingName($params = []) { $name = ''; if (empty($params)) { $params = $this->_params; @@ -2480,7 +2480,7 @@ public function assignBillingName($params = array()) { * * @return string */ - public function getCurrency($submittedValues = array()) { + public function getCurrency($submittedValues = []) { $currency = CRM_Utils_Array::value('currency', $this->_values); // For event forms, currency is in a different spot if (empty($currency)) { diff --git a/CRM/Core/Form/Date.php b/CRM/Core/Form/Date.php index 4d03e18b4d78..354762f65bb6 100644 --- a/CRM/Core/Form/Date.php +++ b/CRM/Core/Form/Date.php @@ -45,7 +45,7 @@ class CRM_Core_Form_Date { */ public static function buildAllowedDateFormats(&$form) { - $dateOptions = array(); + $dateOptions = []; if (CRM_Utils_System::getClassName($form) == 'CRM_Activity_Import_Form_DataSource') { $dateText = ts('yyyy-mm-dd OR yyyy-mm-dd HH:mm OR yyyymmdd OR yyyymmdd HH:mm (1998-12-25 OR 1998-12-25 15:33 OR 19981225 OR 19981225 10:30 OR ( 2008-9-1 OR 2008-9-1 15:33 OR 20080901 15:33)'); @@ -62,7 +62,7 @@ public static function buildAllowedDateFormats(&$form) { $dateOptions[] = $form->createElement('radio', NULL, NULL, ts('dd-mon-yy OR dd/mm/yy (25-Dec-98 OR 25/12/98)'), self::DATE_dd_mon_yy); $dateOptions[] = $form->createElement('radio', NULL, NULL, ts('dd/mm/yyyy (25/12/1998) OR (1/9/2008)'), self::DATE_dd_mm_yyyy); $form->addGroup($dateOptions, 'dateFormats', ts('Date Format'), '
    '); - $form->setDefaults(array('dateFormats' => self::DATE_yyyy_mm_dd)); + $form->setDefaults(['dateFormats' => self::DATE_yyyy_mm_dd]); } @@ -86,9 +86,9 @@ public static function buildAllowedDateFormats(&$form) { public static function buildDateRange( &$form, $fieldName, $count = 1, $from = '_from', $to = '_to', $fromLabel = 'From:', - $required = FALSE, $operators = array(), + $required = FALSE, $operators = [], $dateFormat = 'searchDate', $displayTime = FALSE, - $attributes = array('class' => 'crm-select2') + $attributes = ['class' => 'crm-select2'] ) { $selector = CRM_Core_Form_Date::returnDateRangeSelector( @@ -129,13 +129,13 @@ public static function buildDateRange( public static function returnDateRangeSelector( &$form, $fieldName, $count = 1, $from = '_from', $to = '_to', $fromLabel = 'From:', - $required = FALSE, $operators = array(), + $required = FALSE, $operators = [], $dateFormat = 'searchDate', $displayTime = FALSE ) { - $selector = array( + $selector = [ '' => ts('- any -'), 0 => ts('Choose Date Range'), - ); + ]; // CRM-16195 Pull relative date filters from an option group $selector = $selector + CRM_Core_OptionGroup::values('relative_date_filters'); diff --git a/CRM/Core/Form/EntityFormTrait.php b/CRM/Core/Form/EntityFormTrait.php index 63e5f781f992..96a15fdcd8c9 100644 --- a/CRM/Core/Form/EntityFormTrait.php +++ b/CRM/Core/Form/EntityFormTrait.php @@ -133,27 +133,27 @@ protected function buildDeleteForm() { */ protected function addFormButtons() { if ($this->isViewContext() || $this->_action & CRM_Core_Action::PREVIEW) { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'cancel', 'name' => ts('Done'), 'isDefault' => TRUE, - ), - ) + ], + ] ); } else { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => $this->isDeleteContext() ? ts('Delete') : ts('Save'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); } } diff --git a/CRM/Core/Form/RecurringEntity.php b/CRM/Core/Form/RecurringEntity.php index 72088fda328d..97f7bfaf1363 100644 --- a/CRM/Core/Form/RecurringEntity.php +++ b/CRM/Core/Form/RecurringEntity.php @@ -49,7 +49,7 @@ class CRM_Core_Form_RecurringEntity { /** * Schedule Reminder data */ - protected static $_scheduleReminderDetails = array(); + protected static $_scheduleReminderDetails = []; /** * Parent Entity ID @@ -59,7 +59,7 @@ class CRM_Core_Form_RecurringEntity { /** * Exclude date information */ - public static $_excludeDateInfo = array(); + public static $_excludeDateInfo = []; /** * Entity Table @@ -93,8 +93,8 @@ public static function preProcess($entityTable) { self::$_scheduleReminderID = self::$_scheduleReminderDetails->id; } } - CRM_Core_OptionValue::getValues(array('name' => $entityTable . '_repeat_exclude_dates_' . self::$_parentEntityId), $optionValue); - $excludeOptionValues = array(); + CRM_Core_OptionValue::getValues(['name' => $entityTable . '_repeat_exclude_dates_' . self::$_parentEntityId], $optionValue); + $excludeOptionValues = []; if (!empty($optionValue)) { foreach ($optionValue as $key => $val) { $excludeOptionValues[$val['value']] = substr(CRM_Utils_Date::mysqlToIso($val['value']), 0, 10); @@ -121,9 +121,9 @@ public static function preProcess($entityTable) { */ public static function setDefaultValues() { // Defaults for new entity - $defaults = array( + $defaults = [ 'repetition_frequency_unit' => 'week', - ); + ]; // Default for existing entity if (self::$_scheduleReminderID) { @@ -168,8 +168,8 @@ public static function setDefaultValues() { */ public static function buildQuickForm(&$form) { // FIXME: this is using the following as keys rather than the standard numeric keys returned by CRM_Utils_Date - $dayOfTheWeek = array(); - $dayKeys = array( + $dayOfTheWeek = []; + $dayKeys = [ 'sunday', 'monday', 'tuesday', @@ -177,64 +177,64 @@ public static function buildQuickForm(&$form) { 'thursday', 'friday', 'saturday', - ); + ]; foreach (CRM_Utils_Date::getAbbrWeekdayNames() as $k => $label) { $dayOfTheWeek[$dayKeys[$k]] = $label; } - $form->add('select', 'repetition_frequency_unit', ts('Repeats every'), CRM_Core_SelectValues::getRecurringFrequencyUnits(), FALSE, array('class' => 'required')); + $form->add('select', 'repetition_frequency_unit', ts('Repeats every'), CRM_Core_SelectValues::getRecurringFrequencyUnits(), FALSE, ['class' => 'required']); $numericOptions = CRM_Core_SelectValues::getNumericOptions(1, 30); - $form->add('select', 'repetition_frequency_interval', NULL, $numericOptions, FALSE, array('class' => 'required')); - $form->add('datepicker', 'repetition_start_date', ts('Start Date'), array(), FALSE, array('time' => TRUE)); + $form->add('select', 'repetition_frequency_interval', NULL, $numericOptions, FALSE, ['class' => 'required']); + $form->add('datepicker', 'repetition_start_date', ts('Start Date'), [], FALSE, ['time' => TRUE]); foreach ($dayOfTheWeek as $key => $val) { $startActionCondition[] = $form->createElement('checkbox', $key, NULL, $val); } $form->addGroup($startActionCondition, 'start_action_condition', ts('Repeats on')); - $roptionTypes = array( + $roptionTypes = [ '1' => ts('day of the month'), '2' => ts('day of the week'), - ); - $form->addRadio('repeats_by', ts("Repeats on"), $roptionTypes, array('required' => TRUE), NULL); + ]; + $form->addRadio('repeats_by', ts("Repeats on"), $roptionTypes, ['required' => TRUE], NULL); $form->add('select', 'limit_to', '', CRM_Core_SelectValues::getNumericOptions(1, 31)); - $dayOfTheWeekNo = array( + $dayOfTheWeekNo = [ 'first' => ts('First'), 'second' => ts('Second'), 'third' => ts('Third'), 'fourth' => ts('Fourth'), 'last' => ts('Last'), - ); + ]; $form->add('select', 'entity_status_1', '', $dayOfTheWeekNo); $form->add('select', 'entity_status_2', '', $dayOfTheWeek); - $eoptionTypes = array( + $eoptionTypes = [ '1' => ts('After'), '2' => ts('On'), - ); - $form->addRadio('ends', ts("Ends"), $eoptionTypes, array('class' => 'required'), NULL); + ]; + $form->addRadio('ends', ts("Ends"), $eoptionTypes, ['class' => 'required'], NULL); // Offset options gets key=>val pairs like 1=>2 because the BAO wants to know the number of // children while it makes more sense to the user to see the total number including the parent. $offsetOptions = range(1, 30); unset($offsetOptions[0]); $form->add('select', 'start_action_offset', NULL, $offsetOptions, FALSE); - $form->addFormRule(array('CRM_Core_Form_RecurringEntity', 'formRule')); - $form->add('datepicker', 'repeat_absolute_date', ts('On'), array(), FALSE, array('time' => FALSE)); - $form->add('text', 'exclude_date_list', ts('Exclude Dates'), array('class' => 'twenty')); - $form->addElement('hidden', 'allowRepeatConfigToSubmit', '', array('id' => 'allowRepeatConfigToSubmit')); - $form->addButtons(array( - array( + $form->addFormRule(['CRM_Core_Form_RecurringEntity', 'formRule']); + $form->add('datepicker', 'repeat_absolute_date', ts('On'), [], FALSE, ['time' => FALSE]); + $form->add('text', 'exclude_date_list', ts('Exclude Dates'), ['class' => 'twenty']); + $form->addElement('hidden', 'allowRepeatConfigToSubmit', '', ['id' => 'allowRepeatConfigToSubmit']); + $form->addButtons([ + [ 'type' => 'submit', 'name' => ts('Save'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); // For client-side pluralization - $form->assign('recurringFrequencyOptions', array( + $form->assign('recurringFrequencyOptions', [ 'single' => CRM_Utils_Array::makeNonAssociative(CRM_Core_SelectValues::getRecurringFrequencyUnits()), 'plural' => CRM_Utils_Array::makeNonAssociative(CRM_Core_SelectValues::getRecurringFrequencyUnits(2)), - )); + ]); } /** @@ -247,10 +247,10 @@ public static function buildQuickForm(&$form) { * list of errors to be posted back to the form */ public static function formRule($values) { - $errors = array(); + $errors = []; //Process this function only when you get this variable if ($values['allowRepeatConfigToSubmit'] == 1) { - $dayOfTheWeek = array('monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday'); + $dayOfTheWeek = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']; //Repeats if (empty($values['repetition_frequency_unit'])) { $errors['repetition_frequency_unit'] = ts('This is a required field'); @@ -300,7 +300,7 @@ public static function formRule($values) { } if ($values['repeats_by'] == 2) { if (!empty($values['entity_status_1'])) { - $dayOfTheWeekNo = array('first', 'second', 'third', 'fourth', 'last'); + $dayOfTheWeekNo = ['first', 'second', 'third', 'fourth', 'last']; if (!in_array($values['entity_status_1'], $dayOfTheWeekNo)) { $errors['entity_status_1'] = ts('Invalid option'); } @@ -331,7 +331,7 @@ public static function formRule($values) { * * @throws \CiviCRM_API3_Exception */ - public static function postProcess($params = array(), $type, $linkedEntities = array()) { + public static function postProcess($params = [], $type, $linkedEntities = []) { // Check entity_id not present in params take it from class variable if (empty($params['entity_id'])) { $params['entity_id'] = self::$_entityId; @@ -362,7 +362,7 @@ public static function postProcess($params = array(), $type, $linkedEntities = a $actionScheduleObj = CRM_Core_BAO_ActionSchedule::add($dbParams); //exclude dates - $excludeDateList = array(); + $excludeDateList = []; if (CRM_Utils_Array::value('exclude_date_list', $params) && CRM_Utils_Array::value('parent_entity_id', $params) && $actionScheduleObj->entity_value) { //Since we get comma separated values lets get them in array $excludeDates = explode(",", $params['exclude_date_list']); @@ -376,18 +376,18 @@ public static function postProcess($params = array(), $type, $linkedEntities = a if ($optionGroupIdExists) { CRM_Core_BAO_OptionGroup::del($optionGroupIdExists); } - $optionGroupParams = array( + $optionGroupParams = [ 'name' => $type . '_repeat_exclude_dates_' . $actionScheduleObj->entity_value, 'title' => $type . ' recursion', 'is_reserved' => 0, 'is_active' => 1, - ); + ]; $opGroup = CRM_Core_BAO_OptionGroup::add($optionGroupParams); if ($opGroup->id) { $oldWeight = 0; - $fieldValues = array('option_group_id' => $opGroup->id); + $fieldValues = ['option_group_id' => $opGroup->id]; foreach ($excludeDates as $val) { - $optionGroupValue = array( + $optionGroupValue = [ 'option_group_id' => $opGroup->id, 'label' => CRM_Utils_Date::processDate($val), 'value' => CRM_Utils_Date::processDate($val), @@ -395,7 +395,7 @@ public static function postProcess($params = array(), $type, $linkedEntities = a 'description' => 'Used for recurring ' . $type, 'weight' => CRM_Utils_Weight::updateOtherWeights('CRM_Core_DAO_OptionValue', $oldWeight, CRM_Utils_Array::value('weight', $params), $fieldValues), 'is_active' => 1, - ); + ]; $excludeDateList[] = $optionGroupValue['value']; CRM_Core_BAO_OptionValue::create($optionGroupValue); } @@ -413,9 +413,9 @@ public static function postProcess($params = array(), $type, $linkedEntities = a if (CRM_Utils_Array::value('pre_delete_func', CRM_Core_BAO_RecurringEntity::$_recurringEntityHelper[$params['entity_table']]) && CRM_Utils_Array::value('helper_class', CRM_Core_BAO_RecurringEntity::$_recurringEntityHelper[$params['entity_table']]) ) { - $preDeleteResult = call_user_func_array(CRM_Core_BAO_RecurringEntity::$_recurringEntityHelper[$params['entity_table']]['pre_delete_func'], array($params['entity_id'])); + $preDeleteResult = call_user_func_array(CRM_Core_BAO_RecurringEntity::$_recurringEntityHelper[$params['entity_table']]['pre_delete_func'], [$params['entity_id']]); if (!empty($preDeleteResult)) { - call_user_func(array(CRM_Core_BAO_RecurringEntity::$_recurringEntityHelper[$params['entity_table']]['helper_class'], $preDeleteResult)); + call_user_func([CRM_Core_BAO_RecurringEntity::$_recurringEntityHelper[$params['entity_table']]['helper_class'], $preDeleteResult]); } } //Ready to execute delete on entities if it has delete function set @@ -428,10 +428,10 @@ public static function postProcess($params = array(), $type, $linkedEntities = a $result = civicrm_api3( ucfirst(strtolower($apiType)), CRM_Core_BAO_RecurringEntity::$_recurringEntityHelper[$params['entity_table']]['delete_func'], - array( + [ 'sequential' => 1, 'id' => $eid, - ) + ] ); if ($result['error']) { CRM_Core_Error::statusBounce('Error creating recurring list'); @@ -444,10 +444,10 @@ public static function postProcess($params = array(), $type, $linkedEntities = a $result = civicrm_api3( ucfirst(strtolower($apiType)), CRM_Core_BAO_RecurringEntity::$_recurringEntityHelper[$params['entity_table']]['delete_func'], - array( + [ 'sequential' => 1, 'id' => $value['id'], - ) + ] ); if ($result['error']) { CRM_Core_Error::statusBounce('Error creating recurring list'); diff --git a/CRM/Core/Form/Renderer.php b/CRM/Core/Form/Renderer.php index 1eeb9f0b7d64..201c266f0753 100644 --- a/CRM/Core/Form/Renderer.php +++ b/CRM/Core/Form/Renderer.php @@ -53,7 +53,7 @@ class CRM_Core_Form_Renderer extends HTML_QuickForm_Renderer_ArraySmarty { * * @var array */ - static $_sizeMapper = array( + static $_sizeMapper = [ 2 => 'two', 4 => 'four', 6 => 'six', @@ -62,7 +62,7 @@ class CRM_Core_Form_Renderer extends HTML_QuickForm_Renderer_ArraySmarty { 20 => 'medium', 30 => 'big', 45 => 'huge', - ); + ]; /** * Constructor. @@ -141,7 +141,7 @@ public function _elementToArray(&$element, $required, $error) { } // Active form elements else { - $typesToShowEditLink = array('select', 'group'); + $typesToShowEditLink = ['select', 'group']; $hasEditPath = NULL !== $element->getAttribute('data-option-edit-path'); if (in_array($element->getType(), $typesToShowEditLink) && $hasEditPath) { @@ -171,12 +171,12 @@ public function _elementToArray(&$element, $required, $error) { public static function updateAttributes(&$element, $required, $error) { // lets create an id for all input elements, so we can generate nice label tags // to make it nice and clean, we'll just use the elementName if it is non null - $attributes = array(); + $attributes = []; if (!$element->getAttribute('id')) { $name = $element->getAttribute('name'); if ($name) { - $attributes['id'] = str_replace(array(']', '['), - array('', '_'), + $attributes['id'] = str_replace([']', '['], + ['', '_'], $name ); } @@ -246,8 +246,8 @@ public static function preProcessEntityRef($field) { $entity = $field->getAttribute('data-api-entity'); // Get api params, ensure it is an array $params = $field->getAttribute('data-api-params'); - $params = $params ? json_decode($params, TRUE) : array(); - $result = civicrm_api3($entity, 'getlist', array('id' => $val) + $params); + $params = $params ? json_decode($params, TRUE) : []; + $result = civicrm_api3($entity, 'getlist', ['id' => $val] + $params); // Purify label output of entityreference fields if (!empty($result['values'])) { foreach ($result['values'] as &$res) { @@ -303,7 +303,7 @@ public function renderFrozenSelect2(&$el, $field) { $params = json_decode($field->getAttribute('data-select-params'), TRUE); $val = $field->getValue(); if ($val && !empty($params['data'])) { - $display = array(); + $display = []; foreach (explode(',', $val) as $item) { $match = CRM_Utils_Array::findInTree($item, $params['data']); if (isset($match['text']) && strlen($match['text'])) { @@ -324,17 +324,17 @@ public function renderFrozenSelect2(&$el, $field) { public function renderFrozenEntityRef(&$el, $field) { $entity = $field->getAttribute('data-api-entity'); $vals = json_decode($field->getAttribute('data-entity-value'), TRUE); - $display = array(); + $display = []; // Custom fields of type contactRef store their data in a slightly different format if ($field->getAttribute('data-crm-custom') && $entity == 'Contact') { - $vals = array(array('id' => $vals['id'], 'label' => $vals['text'])); + $vals = [['id' => $vals['id'], 'label' => $vals['text']]]; } foreach ($vals as $val) { // Format contact as link if ($entity == 'Contact' && CRM_Contact_BAO_Contact_Permission::allow($val['id'], CRM_Core_Permission::VIEW)) { - $url = CRM_Utils_System::url("civicrm/contact/view", array('reset' => 1, 'cid' => $val['id'])); + $url = CRM_Utils_System::url("civicrm/contact/view", ['reset' => 1, 'cid' => $val['id']]); $val['label'] = '' . CRM_Utils_String::purifyHTML($val['label']) . ''; } $display[] = $val['label']; @@ -358,21 +358,21 @@ public static function preprocessContactReference($field) { 'contact_reference_options' ), '1'); - $return = array_unique(array_merge(array('sort_name'), $list)); + $return = array_unique(array_merge(['sort_name'], $list)); - $contact = civicrm_api('contact', 'getsingle', array('id' => $val, 'return' => $return, 'version' => 3)); + $contact = civicrm_api('contact', 'getsingle', ['id' => $val, 'return' => $return, 'version' => 3]); if (!empty($contact['id'])) { - $view = array(); + $view = []; foreach ($return as $fld) { if (!empty($contact[$fld])) { $view[] = $contact[$fld]; } } - $field->setAttribute('data-entity-value', json_encode(array( + $field->setAttribute('data-entity-value', json_encode([ 'id' => $contact['id'], 'text' => implode(' :: ', $view), - ))); + ])); } } } diff --git a/CRM/Core/Form/Search.php b/CRM/Core/Form/Search.php index c0defa2ac521..836ed37eecb3 100644 --- a/CRM/Core/Form/Search.php +++ b/CRM/Core/Form/Search.php @@ -77,7 +77,7 @@ class CRM_Core_Form_Search extends CRM_Core_Form { * * @var array */ - protected $_taskList = array(); + protected $_taskList = []; /** * Declare entity reference fields as they will need to be converted. @@ -87,7 +87,7 @@ class CRM_Core_Form_Search extends CRM_Core_Form { * * @var array */ - protected $entityReferenceFields = array(); + protected $entityReferenceFields = []; /** * Builds the list of tasks or actions that a searcher can perform on a result set. @@ -130,13 +130,13 @@ public function buildQuickform() { ->addScriptFile('civicrm', 'js/crm.searchForm.js', 1, 'html-header') ->addStyleFile('civicrm', 'css/searchForm.css', 1, 'html-header'); - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'refresh', 'name' => ts('Search'), 'isDefault' => TRUE, - ), - )); + ], + ]); $this->addClass('crm-search-form'); @@ -253,11 +253,11 @@ protected function getEntityDefaults($entity) { * @param array $rows */ public function addRowSelectors($rows) { - $this->addElement('checkbox', 'toggleSelect', NULL, NULL, array('class' => 'select-rows')); + $this->addElement('checkbox', 'toggleSelect', NULL, NULL, ['class' => 'select-rows']); if (!empty($rows)) { foreach ($rows as $row) { if (CRM_Utils_Array::value('checkbox', $row)) { - $this->addElement('checkbox', $row['checkbox'], NULL, NULL, array('class' => 'select-row')); + $this->addElement('checkbox', $row['checkbox'], NULL, NULL, ['class' => 'select-row']); } } } @@ -269,9 +269,9 @@ public function addRowSelectors($rows) { * @param array $tasks */ public function addTaskMenu($tasks) { - $taskMetaData = array(); + $taskMetaData = []; foreach ($tasks as $key => $task) { - $taskMetaData[$key] = array('title' => $task); + $taskMetaData[$key] = ['title' => $task]; } parent::addTaskMenu($taskMetaData); } @@ -289,7 +289,7 @@ protected function addSortNameField() { $this->addElement( 'text', 'sort_name', - civicrm_api3('setting', 'getvalue', array('name' => 'includeEmailInName', 'group' => 'Search Preferences')) ? $this->getSortNameLabelWithEmail() : $this->getSortNameLabelWithOutEmail(), + civicrm_api3('setting', 'getvalue', ['name' => 'includeEmailInName', 'group' => 'Search Preferences']) ? $this->getSortNameLabelWithEmail() : $this->getSortNameLabelWithOutEmail(), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name') ); } @@ -335,25 +335,25 @@ protected function addContactSearchFields() { $this->_group = CRM_Core_PseudoConstant::nestedGroup(); if ($this->_group) { $this->add('select', 'group', $this->getGroupLabel(), $this->_group, FALSE, - array( + [ 'id' => 'group', 'multiple' => 'multiple', 'class' => 'crm-select2', - ) + ] ); } $contactTags = CRM_Core_BAO_Tag::getTags(); if ($contactTags) { $this->add('select', 'contact_tags', $this->getTagLabel(), $contactTags, FALSE, - array( + [ 'id' => 'contact_tags', 'multiple' => 'multiple', 'class' => 'crm-select2', - ) + ] ); } - $this->addField('contact_type', array('entity' => 'Contact')); + $this->addField('contact_type', ['entity' => 'Contact']); if (CRM_Core_Permission::check('access deleted contacts') && Civi::settings()->get('contact_undelete')) { $this->addElement('checkbox', 'deleted_contacts', ts('Search in Trash') . '
    ' . ts('(deleted contacts)')); diff --git a/CRM/Core/Form/ShortCode.php b/CRM/Core/Form/ShortCode.php index 46f815539cc2..8d5d2b1ad1d6 100644 --- a/CRM/Core/Form/ShortCode.php +++ b/CRM/Core/Form/ShortCode.php @@ -52,7 +52,7 @@ class CRM_Core_Form_ShortCode extends CRM_Core_Form { * select => key + EntityRef params * ]] */ - public $components = array(); + public $components = []; /** * List of radio option groups to display on the form @@ -63,7 +63,7 @@ class CRM_Core_Form_ShortCode extends CRM_Core_Form { * @var array * [key, components, options] */ - public $options = array(); + public $options = []; /** @@ -72,99 +72,99 @@ class CRM_Core_Form_ShortCode extends CRM_Core_Form { public function preProcess() { $config = CRM_Core_Config::singleton(); - $this->components['user-dashboard'] = array( + $this->components['user-dashboard'] = [ 'label' => ts("User Dashboard"), 'select' => NULL, - ); - $this->components['profile'] = array( + ]; + $this->components['profile'] = [ 'label' => ts("Profile"), - 'select' => array( + 'select' => [ 'key' => 'gid', 'entity' => 'UFGroup', - 'select' => array('minimumInputLength' => 0), - 'api' => array( - 'params' => array( + 'select' => ['minimumInputLength' => 0], + 'api' => [ + 'params' => [ 'id' => $this->profileAccess(), - ), - ), - ), - ); + ], + ], + ], + ]; if (in_array('CiviContribute', $config->enableComponents)) { - $this->components['contribution'] = array( + $this->components['contribution'] = [ 'label' => ts("Contribution Page"), - 'select' => array( + 'select' => [ 'key' => 'id', 'entity' => 'ContributionPage', - 'select' => array('minimumInputLength' => 0), - ), - ); + 'select' => ['minimumInputLength' => 0], + ], + ]; } if (in_array('CiviEvent', $config->enableComponents)) { - $this->components['event'] = array( + $this->components['event'] = [ 'label' => ts("Event Page"), - 'select' => array( + 'select' => [ 'key' => 'id', 'entity' => 'Event', - 'select' => array('minimumInputLength' => 0), - ), - ); + 'select' => ['minimumInputLength' => 0], + ], + ]; } if (in_array('CiviCampaign', $config->enableComponents)) { - $this->components['petition'] = array( + $this->components['petition'] = [ 'label' => ts("Petition"), - 'select' => array( + 'select' => [ 'key' => 'id', 'entity' => 'Survey', - 'select' => array('minimumInputLength' => 0), - 'api' => array( - 'params' => array( + 'select' => ['minimumInputLength' => 0], + 'api' => [ + 'params' => [ 'activity_type_id' => "Petition", - ), - ), - ), - ); + ], + ], + ], + ]; } - $this->options = array( - array( + $this->options = [ + [ 'key' => 'action', - 'components' => array('event'), - 'options' => array( + 'components' => ['event'], + 'options' => [ 'info' => ts('Event Info Page'), 'register' => ts('Event Registration Page'), - ), - ), - array( + ], + ], + [ 'key' => 'mode', - 'components' => array('contribution', 'event'), - 'options' => array( + 'components' => ['contribution', 'event'], + 'options' => [ 'live' => ts('Live Mode'), 'test' => ts('Test Drive'), - ), - ), - array( + ], + ], + [ 'key' => 'mode', - 'components' => array('profile'), - 'options' => array( + 'components' => ['profile'], + 'options' => [ 'create' => ts('Create'), 'edit' => ts('Edit'), 'view' => ts('View'), 'search' => ts('Search/Public Directory'), - ), - ), - array( + ], + ], + [ 'key' => 'hijack', 'components' => TRUE, 'label' => ts('If you only insert one shortcode, you can choose to override all page content with the content of the shortcode.'), - 'options' => array( + 'options' => [ '0' => ts("Don't override"), '1' => ts('Override page content'), - ), - ), - ); + ], + ], + ]; } /** @@ -174,12 +174,12 @@ public function buildQuickForm() { $components = CRM_Utils_Array::collect('label', $this->components); $data = CRM_Utils_Array::collect('select', $this->components); - $this->add('select', 'component', NULL, $components, FALSE, array('class' => 'crm-select2', 'data-key' => 'component', 'data-entities' => json_encode($data))); - $this->add('text', 'entity', NULL, array('placeholder' => ts('- select -'))); + $this->add('select', 'component', NULL, $components, FALSE, ['class' => 'crm-select2', 'data-key' => 'component', 'data-entities' => json_encode($data)]); + $this->add('text', 'entity', NULL, ['placeholder' => ts('- select -')]); - $options = $defaults = array(); + $options = $defaults = []; foreach ($this->options as $num => $field) { - $this->addRadio("option_$num", CRM_Utils_Array::value('label', $field), $field['options'], array('allowClear' => FALSE, 'data-key' => $field['key'])); + $this->addRadio("option_$num", CRM_Utils_Array::value('label', $field), $field['options'], ['allowClear' => FALSE, 'data-key' => $field['key']]); if ($field['components'] === TRUE) { $field['components'] = array_keys($this->components); } @@ -214,11 +214,11 @@ private function profileAccess() { AND j.module = 'Profile' "; $dao = CRM_Core_DAO::executeQuery($sql); - $ids = array(); + $ids = []; while ($dao->fetch()) { $ids[] = $dao->id; } - return array('IN' => $ids); + return ['IN' => $ids]; } // No postProccess fn; this form never gets submitted diff --git a/CRM/Core/Form/Tag.php b/CRM/Core/Form/Tag.php index b47d0779ca4d..5f785ddffe4b 100644 --- a/CRM/Core/Form/Tag.php +++ b/CRM/Core/Form/Tag.php @@ -58,7 +58,7 @@ class CRM_Core_Form_Tag { public static function buildQuickForm( &$form, $parentNames, $entityTable, $entityId = NULL, $skipTagCreate = FALSE, $skipEntityAction = FALSE, $tagsetElementName = NULL) { - $tagset = $form->_entityTagValues = array(); + $tagset = $form->_entityTagValues = []; $form->assign("isTagset", FALSE); $mode = NULL; @@ -77,22 +77,22 @@ public static function buildQuickForm( } $tagset[$tagsetItem]['tagsetElementName'] = $tagsetElementName; - $form->addEntityRef("{$tagsetElementName}[{$parentId}]", $parentNameItem, array( + $form->addEntityRef("{$tagsetElementName}[{$parentId}]", $parentNameItem, [ 'entity' => 'Tag', 'multiple' => TRUE, 'create' => !$skipTagCreate, - 'api' => array('params' => array('parent_id' => $parentId)), + 'api' => ['params' => ['parent_id' => $parentId]], 'data-entity_table' => $entityTable, 'data-entity_id' => $entityId, 'class' => "crm-$mode-tagset", - 'select' => array('minimumInputLength' => 0), - )); + 'select' => ['minimumInputLength' => 0], + ]); if ($entityId) { $tagset[$tagsetItem]['entityId'] = $entityId; $entityTags = CRM_Core_BAO_EntityTag::getChildEntityTags($parentId, $entityId, $entityTable); if ($entityTags) { - $form->setDefaults(array("{$tagsetElementName}[{$parentId}]" => implode(',', array_keys($entityTags)))); + $form->setDefaults(["{$tagsetElementName}[{$parentId}]" => implode(',', array_keys($entityTags))]); } } else { @@ -109,7 +109,7 @@ public static function buildQuickForm( // Merge this tagset info with possibly existing info in the template $tagsetInfo = (array) $form->get_template_vars("tagsetInfo"); if (empty($tagsetInfo[$mode])) { - $tagsetInfo[$mode] = array(); + $tagsetInfo[$mode] = []; } $tagsetInfo[$mode] = array_merge($tagsetInfo[$mode], $tagset); $form->assign("tagsetInfo", $tagsetInfo); @@ -152,8 +152,8 @@ public static function postProcess(&$params, $entityId, $entityTable = 'civicrm_ // when form is submitted with tagset values below logic will work and in the case when all tags in a tagset // are deleted we will have to set $params[tagset id] = '' which is done by above logic foreach ($params as $parentId => $value) { - $newTagIds = array(); - $tagIds = array(); + $newTagIds = []; + $tagIds = []; if ($value) { $tagIds = explode(',', $value); @@ -178,7 +178,7 @@ public static function postProcess(&$params, $entityId, $entityTable = 'civicrm_ if (!empty($newTagIds)) { // New tag ids can be inserted directly into the db table. - $insertValues = array(); + $insertValues = []; foreach ($newTagIds as $tagId) { $insertValues[] = "( {$tagId}, {$entityId}, '{$entityTable}' ) "; } diff --git a/CRM/Core/Form/Task.php b/CRM/Core/Form/Task.php index 7ca43d4a2f94..c79fcf5321ac 100644 --- a/CRM/Core/Form/Task.php +++ b/CRM/Core/Form/Task.php @@ -106,7 +106,7 @@ public function preProcess() { * @throws \CRM_Core_Exception */ public static function preProcessCommon(&$form) { - $form->_entityIds = array(); + $form->_entityIds = []; $searchFormValues = $form->controller->exportValues($form->get('searchFormName')); @@ -115,7 +115,7 @@ public static function preProcessCommon(&$form) { $entityTasks = $className::tasks(); $form->assign('taskName', $entityTasks[$form->_task]); - $entityIds = array(); + $entityIds = []; if ($searchFormValues['radio_ts'] == 'ts_sel') { foreach ($searchFormValues as $name => $value) { if (substr($name, 0, CRM_Core_Form::CB_PREFIX_LEN) == CRM_Core_Form::CB_PREFIX) { @@ -194,17 +194,17 @@ public function setContactIDs() { * @param bool $submitOnce */ public function addDefaultButtons($title, $nextType = 'next', $backType = 'back', $submitOnce = FALSE) { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => $nextType, 'name' => $title, 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => $backType, 'name' => ts('Cancel'), - ), - ) + ], + ] ); } diff --git a/CRM/Core/Form/Task/Batch.php b/CRM/Core/Form/Task/Batch.php index 474dd6c83dbd..76d1b8575632 100644 --- a/CRM/Core/Form/Task/Batch.php +++ b/CRM/Core/Form/Task/Batch.php @@ -67,7 +67,7 @@ public function preProcess() { parent::preProcess(); // get the contact read only fields to display. - $readOnlyFields = array_merge(array('sort_name' => ts('Name')), + $readOnlyFields = array_merge(['sort_name' => ts('Name')], CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_autocomplete_options', TRUE, NULL, FALSE, 'name', TRUE @@ -95,7 +95,7 @@ public function buildQuickForm() { if (!$ufGroupId) { throw new InvalidArgumentException('ufGroupId is missing'); } - $this->_title = ts("Update multiple %1s", array(1 => $this::$entityShortname)) . ' - ' . CRM_Core_BAO_UFGroup::getTitle($ufGroupId); + $this->_title = ts("Update multiple %1s", [1 => $this::$entityShortname]) . ' - ' . CRM_Core_BAO_UFGroup::getTitle($ufGroupId); CRM_Utils_System::setTitle($this->_title); $this->addDefaultButtons(ts('Save')); @@ -103,7 +103,7 @@ public function buildQuickForm() { // remove file type field and then limit fields $suppressFields = FALSE; - $removeHtmlTypes = array('File'); + $removeHtmlTypes = ['File']; foreach ($this->_fields as $name => $field) { if ($cfID = CRM_Core_BAO_CustomField::getKeyID($name) && in_array($this->_fields[$name]['html_type'], $removeHtmlTypes) @@ -121,17 +121,17 @@ public function buildQuickForm() { $this->_fields = array_slice($this->_fields, 0, $this->_maxFields); - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'submit', 'name' => ts('Update ' . ucfirst($this::$entityShortname) . 's)'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - )); + ], + ]); $this->assign('profileTitle', $this->_title); $this->assign('componentIds', $this->_entityIds); @@ -142,7 +142,7 @@ public function buildQuickForm() { foreach ($this->_fields as $name => $field) { if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($name)) { $customValue = CRM_Utils_Array::value($customFieldID, $customFields); - $entityColumnValue = array(); + $entityColumnValue = []; if (!empty($customValue['extends_entity_column_value'])) { $entityColumnValue = explode(CRM_Core_DAO::VALUE_SEPARATOR, $customValue['extends_entity_column_value'] @@ -166,7 +166,7 @@ public function buildQuickForm() { // don't set the status message when form is submitted. $buttonName = $this->controller->getButtonName('submit'); if ($suppressFields && $buttonName != '_qf_Batch_next') { - CRM_Core_Session::setStatus(ts("File type field(s) in the selected profile are not supported for Update multiple %1s", array(1 => $this::$entityShortname)), ts('Unsupported Field Type'), 'error'); + CRM_Core_Session::setStatus(ts("File type field(s) in the selected profile are not supported for Update multiple %1s", [1 => $this::$entityShortname]), ts('Unsupported Field Type'), 'error'); } $this->addDefaultButtons(ts('Update ' . ucfirst($this::$entityShortname) . 's')); @@ -183,10 +183,10 @@ public function buildQuickForm() { */ public function setDefaultValues() { if (empty($this->_fields)) { - return array(); + return []; } - $defaults = array(); + $defaults = []; foreach ($this->_entityIds as $entityId) { CRM_Core_BAO_UFGroup::setProfileDefaults(NULL, $this->_fields, $defaults, FALSE, $entityId, ucfirst($this::$entityShortname)); } diff --git a/CRM/Core/Form/Task/PDFLetterCommon.php b/CRM/Core/Form/Task/PDFLetterCommon.php index fdbbeb7781f1..5fd95efa67ef 100644 --- a/CRM/Core/Form/Task/PDFLetterCommon.php +++ b/CRM/Core/Form/Task/PDFLetterCommon.php @@ -64,25 +64,25 @@ public static function buildQuickForm(&$form) { 'text', 'subject', ts('Activity Subject'), - array('size' => 45, 'maxlength' => 255), + ['size' => 45, 'maxlength' => 255], FALSE ); - $form->add('static', 'pdf_format_header', NULL, ts('Page Format: %1', array(1 => ''))); - $form->addSelect('format_id', array( + $form->add('static', 'pdf_format_header', NULL, ts('Page Format: %1', [1 => ''])); + $form->addSelect('format_id', [ 'label' => ts('Select Format'), 'placeholder' => ts('Default'), 'entity' => 'message_template', 'field' => 'pdf_format_id', 'option_url' => 'civicrm/admin/pdfFormats', - )); + ]); $form->add( 'select', 'paper_size', ts('Paper Size'), - array(0 => ts('- default -')) + CRM_Core_BAO_PaperSize::getList(TRUE), + [0 => ts('- default -')] + CRM_Core_BAO_PaperSize::getList(TRUE), FALSE, - array('onChange' => "selectPaper( this.value ); showUpdateFormatChkBox();") + ['onChange' => "selectPaper( this.value ); showUpdateFormatChkBox();"] ); $form->add('static', 'paper_dimensions', NULL, ts('Width x Height')); $form->add( @@ -91,7 +91,7 @@ public static function buildQuickForm(&$form) { ts('Orientation'), CRM_Core_BAO_PdfFormat::getPageOrientations(), FALSE, - array('onChange' => "updatePaperDimensions(); showUpdateFormatChkBox();") + ['onChange' => "updatePaperDimensions(); showUpdateFormatChkBox();"] ); $form->add( 'select', @@ -99,34 +99,34 @@ public static function buildQuickForm(&$form) { ts('Unit of Measure'), CRM_Core_BAO_PdfFormat::getUnits(), FALSE, - array('onChange' => "selectMetric( this.value );") + ['onChange' => "selectMetric( this.value );"] ); $form->add( 'text', 'margin_left', ts('Left Margin'), - array('size' => 8, 'maxlength' => 8, 'onkeyup' => "showUpdateFormatChkBox();"), + ['size' => 8, 'maxlength' => 8, 'onkeyup' => "showUpdateFormatChkBox();"], TRUE ); $form->add( 'text', 'margin_right', ts('Right Margin'), - array('size' => 8, 'maxlength' => 8, 'onkeyup' => "showUpdateFormatChkBox();"), + ['size' => 8, 'maxlength' => 8, 'onkeyup' => "showUpdateFormatChkBox();"], TRUE ); $form->add( 'text', 'margin_top', ts('Top Margin'), - array('size' => 8, 'maxlength' => 8, 'onkeyup' => "showUpdateFormatChkBox();"), + ['size' => 8, 'maxlength' => 8, 'onkeyup' => "showUpdateFormatChkBox();"], TRUE ); $form->add( 'text', 'margin_bottom', ts('Bottom Margin'), - array('size' => 8, 'maxlength' => 8, 'onkeyup' => "showUpdateFormatChkBox();"), + ['size' => 8, 'maxlength' => 8, 'onkeyup' => "showUpdateFormatChkBox();"], TRUE ); @@ -157,29 +157,29 @@ public static function buildQuickForm(&$form) { CRM_Mailing_BAO_Mailing::commonCompose($form); - $buttons = array(); + $buttons = []; if ($form->get('action') != CRM_Core_Action::VIEW) { - $buttons[] = array( + $buttons[] = [ 'type' => 'upload', 'name' => ts('Download Document'), 'isDefault' => TRUE, 'icon' => 'fa-download', - ); - $buttons[] = array( + ]; + $buttons[] = [ 'type' => 'submit', 'name' => ts('Preview'), 'subName' => 'preview', 'icon' => 'fa-search', 'isDefault' => FALSE, - ); + ]; } - $buttons[] = array( + $buttons[] = [ 'type' => 'cancel', 'name' => $form->get('action') == CRM_Core_Action::VIEW ? ts('Done') : ts('Cancel'), - ); + ]; $form->addButtons($buttons); - $form->addFormRule(array('CRM_Core_Form_Task_PDFLetterCommon', 'formRule'), $form); + $form->addFormRule(['CRM_Core_Form_Task_PDFLetterCommon', 'formRule'], $form); } /** @@ -204,7 +204,7 @@ public static function setDefaultValues() { * TRUE if no errors, else array of errors. */ public static function formRule($fields, $files, $self) { - $errors = array(); + $errors = []; $template = CRM_Core_Smarty::singleton(); // If user uploads non-document file other than odt/docx @@ -241,12 +241,12 @@ public static function processTemplate(&$formValues) { // process message template if (!empty($formValues['saveTemplate']) || !empty($formValues['updateTemplate'])) { - $messageTemplate = array( + $messageTemplate = [ 'msg_text' => NULL, 'msg_html' => $formValues['html_message'], 'msg_subject' => NULL, 'is_active' => TRUE, - ); + ]; $messageTemplate['pdf_format_id'] = 'null'; if (!empty($formValues['bind_format']) && $formValues['format_id']) { @@ -297,23 +297,23 @@ public static function processTemplate(&$formValues) { * @param $message */ public static function formatMessage(&$message) { - $newLineOperators = array( - 'p' => array( + $newLineOperators = [ + 'p' => [ 'oper' => '

    ', 'pattern' => '/<(\s+)?p(\s+)?>/m', - ), - 'br' => array( + ], + 'br' => [ 'oper' => '
    ', 'pattern' => '/<(\s+)?br(\s+)?\/>/m', - ), - ); + ], + ]; $htmlMsg = preg_split($newLineOperators['p']['pattern'], $message); foreach ($htmlMsg as $k => & $m) { $messages = preg_split($newLineOperators['br']['pattern'], $m); foreach ($messages as $key => & $msg) { $msg = trim($msg); - $matches = array(); + $matches = []; if (preg_match('/^( )+/', $msg, $matches)) { $spaceLen = strlen($matches[0]) / 6; $trimMsg = ltrim($msg, '  '); diff --git a/CRM/Core/Form/Task/PickProfile.php b/CRM/Core/Form/Task/PickProfile.php index c23af2f00010..4043833a5562 100644 --- a/CRM/Core/Form/Task/PickProfile.php +++ b/CRM/Core/Form/Task/PickProfile.php @@ -85,11 +85,11 @@ public function preProcess() { // validations if (count($this->_entityIds) > $this->_maxEntities) { - CRM_Core_Session::setStatus(ts("The maximum number of %3 you can select for Update multiple %3 is %1. You have selected %2. Please select fewer %3 from your search results and try again.", array( + CRM_Core_Session::setStatus(ts("The maximum number of %3 you can select for Update multiple %3 is %1. You have selected %2. Please select fewer %3 from your search results and try again.", [ 1 => $this->_maxEntities, 2 => count($this->_entityIds), 3 => $this::$entityShortname . 's', - )), ts('Update multiple records error'), 'error'); + ]), ts('Update multiple records error'), 'error'); CRM_Utils_System::redirect($this->_userContext); } } @@ -100,16 +100,16 @@ public function preProcess() { * @return void */ public function buildQuickForm() { - $types = array(ucfirst($this::$entityShortname)); + $types = [ucfirst($this::$entityShortname)]; $profiles = CRM_Core_BAO_UFGroup::getProfiles($types, TRUE); if (empty($profiles)) { CRM_Core_Session::setStatus( ts("You will need to create a Profile containing the %1 fields you want to edit before you can use Update multiple %2. Navigate to Administer > Customize Data and Screens > Profiles to configure a Profile. Consult the online Administrator documentation for more information.", - array( + [ 1 => $types[0], 2 => $this::$entityShortname . 's', - )), + ]), ts('Update multiple records error'), 'error' ); @@ -119,9 +119,9 @@ public function buildQuickForm() { $this->add('select', 'uf_group_id', ts('Select Profile'), - array( + [ '' => ts('- select profile -'), - ) + $profiles, + ] + $profiles, TRUE ); $this->addDefaultButtons(ts('Continue')); @@ -137,7 +137,7 @@ public function buildQuickForm() { * @return void */ public function addRules() { - $this->addFormRule(array('CRM_' . ucfirst($this::$entityShortname) . '_Form_Task_PickProfile', 'formRule')); + $this->addFormRule(['CRM_' . ucfirst($this::$entityShortname) . '_Form_Task_PickProfile', 'formRule']); } /** diff --git a/CRM/Core/I18n.php b/CRM/Core/I18n.php index 119ff57f9dae..425565de5bce 100644 --- a/CRM/Core/I18n.php +++ b/CRM/Core/I18n.php @@ -84,7 +84,7 @@ protected static function escapeSql($text) { * - native gettext: we cache the value for textdomain() * - phpgettext: we cache the file streamer. */ - private $_extensioncache = array(); + private $_extensioncache = []; /** * @var string @@ -192,15 +192,15 @@ public static function languages($justEnabled = FALSE) { $all = CRM_Contact_BAO_Contact::buildOptions('preferred_language'); // get labels - $rows = array(); - $labels = array(); - CRM_Core_OptionValue::getValues(array('name' => 'languages'), $rows); + $rows = []; + $labels = []; + CRM_Core_OptionValue::getValues(['name' => 'languages'], $rows); foreach ($rows as $id => $row) { $labels[$row['name']] = $row['label']; } // check which ones are available; add them to $all if not there already - $codes = array(); + $codes = []; if (is_dir(CRM_Core_I18n::getResourceDir()) && $dir = opendir(CRM_Core_I18n::getResourceDir())) { while ($filename = readdir($dir)) { if (preg_match('/^[a-z][a-z]_[A-Z][A-Z]$/', $filename)) { @@ -228,7 +228,7 @@ public static function languages($justEnabled = FALSE) { if ($enabled === NULL) { $config = CRM_Core_Config::singleton(); - $enabled = array(); + $enabled = []; if (isset($config->languageLimit) and $config->languageLimit) { foreach ($all as $code => $name) { if (in_array($code, array_keys($config->languageLimit))) { @@ -273,7 +273,7 @@ public static function uiLanguages($justCodes = FALSE) { * modified string */ public function strarg($str) { - $tr = array(); + $tr = []; $p = 0; for ($i = 1; $i < func_num_args(); $i++) { $arg = func_get_arg($i); @@ -327,7 +327,7 @@ public static function getResourceDir() { * @return string * the translated string */ - public function crm_translate($text, $params = array()) { + public function crm_translate($text, $params = []) { if (isset($params['escape'])) { $escape = $params['escape']; unset($params['escape']); @@ -441,7 +441,7 @@ protected function crm_translate_raw($text, $domain, $count, $plural, $context) Civi::$statics[__CLASS__][$replacementsLocale] = CRM_Core_BAO_WordReplacement::getLocaleCustomStrings($replacementsLocale); } else { - Civi::$statics[__CLASS__][$replacementsLocale] = array(); + Civi::$statics[__CLASS__][$replacementsLocale] = []; } } $stringTable = Civi::$statics[__CLASS__][$replacementsLocale]; @@ -483,7 +483,7 @@ protected function crm_translate_raw($text, $domain, $count, $plural, $context) } // expand %count in translated string to $count - $text = strtr($text, array('%count' => $count)); + $text = strtr($text, ['%count' => $count]); // if not plural, but the locale's set, translate } @@ -527,7 +527,7 @@ public function translate($string) { */ public function localizeArray( &$array, - $params = array() + $params = [] ) { $tsLocale = CRM_Core_I18n::getLocale(); @@ -555,7 +555,7 @@ public function localizeTitles(&$array) { $array[$key] = $value; } elseif ((string ) $key == 'title') { - $array[$key] = ts($value, array('context' => 'menu')); + $array[$key] = ts($value, ['context' => 'menu']); } } } @@ -686,7 +686,7 @@ public function setLocale($locale) { */ public static function &singleton() { if (!isset(Civi::$statics[__CLASS__]['singleton'])) { - Civi::$statics[__CLASS__]['singleton'] = array(); + Civi::$statics[__CLASS__]['singleton'] = []; } $tsLocale = CRM_Core_I18n::getLocale(); if (!isset(Civi::$statics[__CLASS__]['singleton'][$tsLocale])) { @@ -703,7 +703,7 @@ public static function &singleton() { * the final LC_TIME that got set */ public static function setLcTime() { - static $locales = array(); + static $locales = []; $tsLocale = CRM_Core_I18n::getLocale(); if (!isset($locales[$tsLocale])) { @@ -730,10 +730,10 @@ public static function getContactDefaultLanguage() { return NULL; } if (empty($language) || $language === '*default*') { - $language = civicrm_api3('setting', 'getvalue', array( + $language = civicrm_api3('setting', 'getvalue', [ 'name' => 'lcMessages', 'group' => CRM_Core_BAO_Setting::LOCALIZATION_PREFERENCES_NAME, - )); + ]); } elseif ($language == 'current_site_language') { return CRM_Core_I18n::getLocale(); @@ -765,7 +765,7 @@ public static function getLocale() { * @return string * the translated string */ -function ts($text, $params = array()) { +function ts($text, $params = []) { static $areSettingsAvailable = FALSE; static $lastLocale = NULL; static $i18n = NULL; diff --git a/CRM/Core/I18n/Form.php b/CRM/Core/I18n/Form.php index 7c191c75f868..8433616cdd74 100644 --- a/CRM/Core/I18n/Form.php +++ b/CRM/Core/I18n/Form.php @@ -51,7 +51,7 @@ public function buildQuickForm() { $this->addElement('hidden', 'field', $field); $this->addElement('hidden', 'id', $id); - $cols = array(); + $cols = []; foreach ($this->_locales as $locale) { $cols[] = "{$field}_{$locale} {$locale}"; } @@ -66,7 +66,7 @@ public function buildQuickForm() { $widget = $widgets[$table][$field]; // attributes - $attributes = array('class' => ''); + $attributes = ['class' => '']; if (isset($widget['rows'])) { $attributes['rows'] = $widget['rows']; } @@ -123,12 +123,12 @@ public function postProcess() { CRM_Core_Error::fatal("$table.$field is not internationalized."); } - $cols = array(); - $params = array(array($values['id'], 'Int')); + $cols = []; + $params = [[$values['id'], 'Int']]; $i = 1; foreach ($this->_locales as $locale) { $cols[] = "{$field}_{$locale} = %$i"; - $params[$i] = array($values["{$field}_{$locale}"], 'String'); + $params[$i] = [$values["{$field}_{$locale}"], 'String']; $i++; } $query = "UPDATE $table SET " . implode(', ', $cols) . " WHERE id = %0"; diff --git a/CRM/Core/I18n/PseudoConstant.php b/CRM/Core/I18n/PseudoConstant.php index 8d703ebf6b08..1866cf9eacd0 100644 --- a/CRM/Core/I18n/PseudoConstant.php +++ b/CRM/Core/I18n/PseudoConstant.php @@ -50,10 +50,10 @@ public static function longForShort($short) { public static function &longForShortMapping() { static $longForShortMapping = NULL; if ($longForShortMapping === NULL) { - $rows = array(); - CRM_Core_OptionValue::getValues(array('name' => 'languages'), $rows); + $rows = []; + CRM_Core_OptionValue::getValues(['name' => 'languages'], $rows); - $longForShortMapping = array(); + $longForShortMapping = []; foreach ($rows as $row) { $longForShortMapping[$row['value']] = $row['name']; } @@ -84,12 +84,12 @@ public static function shortForLong($long) { * @return array */ public static function getRTLlanguages() { - $rtl = array( + $rtl = [ 'ar', 'fa', 'he', 'ur', - ); + ]; return $rtl; } diff --git a/CRM/Core/I18n/Schema.php b/CRM/Core/I18n/Schema.php index 0920c4c13260..64cb94b08f9f 100644 --- a/CRM/Core/I18n/Schema.php +++ b/CRM/Core/I18n/Schema.php @@ -73,7 +73,7 @@ public static function makeMultilingual($locale) { // build the column-adding SQL queries $columns = CRM_Core_I18n_SchemaStructure::columns(); $indices = CRM_Core_I18n_SchemaStructure::indices(); - $queries = array(); + $queries = []; foreach ($columns as $table => $hash) { // drop old indices if (isset($indices[$table])) { @@ -167,7 +167,7 @@ public static function makeSinglelingualTable( $retain, $table, $class = 'CRM_Core_I18n_SchemaStructure', - $triggers = array() + $triggers = [] ) { $domain = new CRM_Core_DAO_Domain(); $domain->find(TRUE); @@ -180,8 +180,8 @@ public static function makeSinglelingualTable( $columns =& $class::columns(); $indices =& $class::indices(); - $queries = array(); - $dropQueries = array(); + $queries = []; + $dropQueries = []; // drop indices if (isset($indices[$table])) { foreach ($indices[$table] as $index) { @@ -260,7 +260,7 @@ public static function addLocale($locale, $source) { // build the required SQL queries $columns = CRM_Core_I18n_SchemaStructure::columns(); $indices = CRM_Core_I18n_SchemaStructure::indices(); - $queries = array(); + $queries = []; foreach ($columns as $table => $hash) { // add new columns foreach ($hash as $column => $type) { @@ -314,13 +314,13 @@ public static function rebuildMultilingualSchema($locales, $version = NULL, $isU } $indices =& $class::indices(); $tables =& $class::tables(); - $queries = array(); + $queries = []; $dao = new CRM_Core_DAO(); // get all of the already existing indices - $existing = array(); + $existing = []; foreach (array_keys($indices) as $table) { - $existing[$table] = array(); + $existing[$table] = []; $dao->query("SHOW INDEX FROM $table", FALSE); while ($dao->fetch()) { if (preg_match('/_[a-z][a-z]_[A-Z][A-Z]$/', $dao->Key_name)) { @@ -417,9 +417,9 @@ public static function getLatestSchema($version) { $version = str_ireplace(".upgrade", "", $version); // fetch all the SchemaStructure versions we ship and sort by version - $schemas = array(); + $schemas = []; foreach (scandir(dirname(__FILE__)) as $file) { - $matches = array(); + $matches = []; if (preg_match('/^SchemaStructure_([0-9a-z_]+)\.php$/', $file, $matches)) { $schemas[] = str_replace('_', '.', $matches[1]); } @@ -451,10 +451,10 @@ private static function createIndexQueries($locale, $table, $class = 'CRM_Core_I $indices =& $class::indices(); $columns =& $class::columns(); if (!isset($indices[$table])) { - return array(); + return []; } - $queries = array(); + $queries = []; foreach ($indices[$table] as $index) { $unique = isset($index['unique']) && $index['unique'] ? 'UNIQUE' : ''; foreach ($index['field'] as $i => $col) { @@ -495,8 +495,8 @@ private static function createIndexQueries($locale, $table, $class = 'CRM_Core_I */ private static function createViewQuery($locale, $table, &$dao, $class = 'CRM_Core_I18n_SchemaStructure', $isUpgradeMode = FALSE) { $columns =& $class::columns(); - $cols = array(); - $tableCols = array(); + $cols = []; + $tableCols = []; $dao->query("DESCRIBE {$table}", FALSE); while ($dao->fetch()) { // view non-internationalized columns directly @@ -560,7 +560,7 @@ public static function triggerInfo(&$info, $tableName = NULL) { continue; } - $trigger = array(); + $trigger = []; foreach ($hash as $column => $_) { $trigger[] = "IF NEW.{$column}_{$locale} IS NOT NULL THEN"; @@ -569,9 +569,9 @@ public static function triggerInfo(&$info, $tableName = NULL) { } foreach ($locales as $old) { $trigger[] = "ELSEIF NEW.{$column}_{$old} IS NOT NULL THEN"; - foreach (array_merge($locales, array( + foreach (array_merge($locales, [ $locale, - )) as $loc) { + ]) as $loc) { if ($loc == $old) { continue; } @@ -582,17 +582,17 @@ public static function triggerInfo(&$info, $tableName = NULL) { } $sql = implode(' ', $trigger); - $info[] = array( - 'table' => array($table), + $info[] = [ + 'table' => [$table], 'when' => 'BEFORE', - 'event' => array('UPDATE'), + 'event' => ['UPDATE'], 'sql' => $sql, - ); + ]; } // take care of the ON INSERT triggers foreach ($columns as $table => $hash) { - $trigger = array(); + $trigger = []; foreach ($hash as $column => $_) { $trigger[] = "IF NEW.{$column}_{$locale} IS NOT NULL THEN"; foreach ($locales as $old) { @@ -600,9 +600,9 @@ public static function triggerInfo(&$info, $tableName = NULL) { } foreach ($locales as $old) { $trigger[] = "ELSEIF NEW.{$column}_{$old} IS NOT NULL THEN"; - foreach (array_merge($locales, array( + foreach (array_merge($locales, [ $locale, - )) as $loc) { + ]) as $loc) { if ($loc == $old) { continue; } @@ -613,12 +613,12 @@ public static function triggerInfo(&$info, $tableName = NULL) { } $sql = implode(' ', $trigger); - $info[] = array( - 'table' => array($table), + $info[] = [ + 'table' => [$table], 'when' => 'BEFORE', - 'event' => array('INSERT'), + 'event' => ['INSERT'], 'sql' => $sql, - ); + ]; } } diff --git a/CRM/Core/I18n/SchemaStructure_4_2_alpha1.php b/CRM/Core/I18n/SchemaStructure_4_2_alpha1.php index 6b49ab712e50..2450e0f27784 100644 --- a/CRM/Core/I18n/SchemaStructure_4_2_alpha1.php +++ b/CRM/Core/I18n/SchemaStructure_4_2_alpha1.php @@ -39,74 +39,74 @@ class CRM_Core_I18n_SchemaStructure_4_2_alpha1 { public static function &columns() { static $result = NULL; if (!$result) { - $result = array( - 'civicrm_location_type' => array( + $result = [ + 'civicrm_location_type' => [ 'display_name' => "varchar(64)", - ), - 'civicrm_option_group' => array( + ], + 'civicrm_option_group' => [ 'title' => "varchar(255)", 'description' => "varchar(255)", - ), - 'civicrm_contact_type' => array( + ], + 'civicrm_contact_type' => [ 'label' => "varchar(64)", 'description' => "text", - ), - 'civicrm_premiums' => array( + ], + 'civicrm_premiums' => [ 'premiums_intro_title' => "varchar(255)", 'premiums_intro_text' => "text", - ), - 'civicrm_product' => array( + ], + 'civicrm_product' => [ 'name' => "varchar(255)", 'description' => "text", 'options' => "text", - ), - 'civicrm_membership_status' => array( + ], + 'civicrm_membership_status' => [ 'label' => "varchar(128)", - ), - 'civicrm_survey' => array( + ], + 'civicrm_survey' => [ 'thankyou_title' => "varchar(255)", 'thankyou_text' => "text", - ), - 'civicrm_participant_status_type' => array( + ], + 'civicrm_participant_status_type' => [ 'label' => "varchar(255)", - ), - 'civicrm_tell_friend' => array( + ], + 'civicrm_tell_friend' => [ 'title' => "varchar(255)", 'intro' => "text", 'suggested_message' => "text", 'thankyou_title' => "varchar(255)", 'thankyou_text' => "text", - ), - 'civicrm_price_set' => array( + ], + 'civicrm_price_set' => [ 'title' => "varchar(255)", 'help_pre' => "text", 'help_post' => "text", - ), - 'civicrm_batch' => array( + ], + 'civicrm_batch' => [ 'title' => "varchar(64)", 'description' => "text", - ), - 'civicrm_custom_group' => array( + ], + 'civicrm_custom_group' => [ 'title' => "varchar(64)", 'help_pre' => "text", 'help_post' => "text", - ), - 'civicrm_custom_field' => array( + ], + 'civicrm_custom_field' => [ 'label' => "varchar(255)", 'help_pre' => "text", 'help_post' => "text", - ), - 'civicrm_dashboard' => array( + ], + 'civicrm_dashboard' => [ 'label' => "varchar(255)", - ), - 'civicrm_option_value' => array( + ], + 'civicrm_option_value' => [ 'label' => "varchar(255)", 'description' => "text", - ), - 'civicrm_group' => array( + ], + 'civicrm_group' => [ 'title' => "varchar(64)", - ), - 'civicrm_contribution_page' => array( + ], + 'civicrm_contribution_page' => [ 'title' => "varchar(255)", 'intro_text' => "text", 'pay_later_text' => "text", @@ -120,40 +120,40 @@ public static function &columns() { 'footer_text' => "text", 'honor_block_title' => "varchar(255)", 'honor_block_text' => "text", - ), - 'civicrm_price_field' => array( + ], + 'civicrm_price_field' => [ 'label' => "varchar(255)", 'help_pre' => "text", 'help_post' => "text", - ), - 'civicrm_uf_group' => array( + ], + 'civicrm_uf_group' => [ 'title' => "varchar(64)", 'help_pre' => "text", 'help_post' => "text", - ), - 'civicrm_uf_field' => array( + ], + 'civicrm_uf_field' => [ 'help_post' => "text", 'help_pre' => "text", 'label' => "varchar(255)", - ), - 'civicrm_membership_type' => array( + ], + 'civicrm_membership_type' => [ 'name' => "varchar(128)", 'description' => "varchar(255)", - ), - 'civicrm_membership_block' => array( + ], + 'civicrm_membership_block' => [ 'new_title' => "varchar(255)", 'new_text' => "text", 'renewal_title' => "varchar(255)", 'renewal_text' => "text", - ), - 'civicrm_price_field_value' => array( + ], + 'civicrm_price_field_value' => [ 'label' => "varchar(255)", 'description' => "text", - ), - 'civicrm_pcp_block' => array( + ], + 'civicrm_pcp_block' => [ 'link_text' => "varchar(255)", - ), - 'civicrm_event' => array( + ], + 'civicrm_event' => [ 'title' => "varchar(255)", 'summary' => "text", 'description' => "text", @@ -175,8 +175,8 @@ public static function &columns() { 'waitlist_text' => "text", 'approval_req_text' => "text", 'template_title' => "varchar(255)", - ), - ); + ], + ]; } return $result; } @@ -187,37 +187,37 @@ public static function &columns() { public static function &indices() { static $result = NULL; if (!$result) { - $result = array( - 'civicrm_custom_group' => array( - 'UI_title_extends' => array( + $result = [ + 'civicrm_custom_group' => [ + 'UI_title_extends' => [ 'name' => 'UI_title_extends', - 'field' => array( + 'field' => [ 'title', 'extends', - ), + ], 'unique' => 1, - ), - ), - 'civicrm_custom_field' => array( - 'UI_label_custom_group_id' => array( + ], + ], + 'civicrm_custom_field' => [ + 'UI_label_custom_group_id' => [ 'name' => 'UI_label_custom_group_id', - 'field' => array( + 'field' => [ 'label', 'custom_group_id', - ), + ], 'unique' => 1, - ), - ), - 'civicrm_group' => array( - 'UI_title' => array( + ], + ], + 'civicrm_group' => [ + 'UI_title' => [ 'name' => 'UI_title', - 'field' => array( + 'field' => [ 'title', - ), + ], 'unique' => 1, - ), - ), - ); + ], + ], + ]; } return $result; } diff --git a/CRM/Core/I18n/SchemaStructure_4_3_1.php b/CRM/Core/I18n/SchemaStructure_4_3_1.php index 09bc0977c55f..6078d089ed8f 100644 --- a/CRM/Core/I18n/SchemaStructure_4_3_1.php +++ b/CRM/Core/I18n/SchemaStructure_4_3_1.php @@ -39,62 +39,62 @@ class CRM_Core_I18n_SchemaStructure_4_3_1 { public static function &columns() { static $result = NULL; if (!$result) { - $result = array( - 'civicrm_location_type' => array( + $result = [ + 'civicrm_location_type' => [ 'display_name' => "varchar(64)", - ), - 'civicrm_option_group' => array( + ], + 'civicrm_option_group' => [ 'title' => "varchar(255)", 'description' => "varchar(255)", - ), - 'civicrm_contact_type' => array( + ], + 'civicrm_contact_type' => [ 'label' => "varchar(64)", 'description' => "text", - ), - 'civicrm_batch' => array( + ], + 'civicrm_batch' => [ 'title' => "varchar(64)", 'description' => "text", - ), - 'civicrm_premiums' => array( + ], + 'civicrm_premiums' => [ 'premiums_intro_title' => "varchar(255)", 'premiums_intro_text' => "text", 'premiums_nothankyou_label' => "varchar(255)", - ), - 'civicrm_membership_status' => array( + ], + 'civicrm_membership_status' => [ 'label' => "varchar(128)", - ), - 'civicrm_survey' => array( + ], + 'civicrm_survey' => [ 'thankyou_title' => "varchar(255)", 'thankyou_text' => "text", - ), - 'civicrm_participant_status_type' => array( + ], + 'civicrm_participant_status_type' => [ 'label' => "varchar(255)", - ), - 'civicrm_tell_friend' => array( + ], + 'civicrm_tell_friend' => [ 'title' => "varchar(255)", 'intro' => "text", 'suggested_message' => "text", 'thankyou_title' => "varchar(255)", 'thankyou_text' => "text", - ), - 'civicrm_custom_group' => array( + ], + 'civicrm_custom_group' => [ 'title' => "varchar(64)", 'help_pre' => "text", 'help_post' => "text", - ), - 'civicrm_custom_field' => array( + ], + 'civicrm_custom_field' => [ 'label' => "varchar(255)", 'help_pre' => "text", 'help_post' => "text", - ), - 'civicrm_option_value' => array( + ], + 'civicrm_option_value' => [ 'label' => "varchar(255)", 'description' => "text", - ), - 'civicrm_group' => array( + ], + 'civicrm_group' => [ 'title' => "varchar(64)", - ), - 'civicrm_contribution_page' => array( + ], + 'civicrm_contribution_page' => [ 'title' => "varchar(255)", 'intro_text' => "text", 'pay_later_text' => "text", @@ -110,53 +110,53 @@ public static function &columns() { 'footer_text' => "text", 'honor_block_title' => "varchar(255)", 'honor_block_text' => "text", - ), - 'civicrm_product' => array( + ], + 'civicrm_product' => [ 'name' => "varchar(255)", 'description' => "text", 'options' => "text", - ), - 'civicrm_membership_type' => array( + ], + 'civicrm_membership_type' => [ 'name' => "varchar(128)", 'description' => "varchar(255)", - ), - 'civicrm_membership_block' => array( + ], + 'civicrm_membership_block' => [ 'new_title' => "varchar(255)", 'new_text' => "text", 'renewal_title' => "varchar(255)", 'renewal_text' => "text", - ), - 'civicrm_price_set' => array( + ], + 'civicrm_price_set' => [ 'title' => "varchar(255)", 'help_pre' => "text", 'help_post' => "text", - ), - 'civicrm_dashboard' => array( + ], + 'civicrm_dashboard' => [ 'label' => "varchar(255)", - ), - 'civicrm_uf_group' => array( + ], + 'civicrm_uf_group' => [ 'title' => "varchar(64)", 'help_pre' => "text", 'help_post' => "text", - ), - 'civicrm_uf_field' => array( + ], + 'civicrm_uf_field' => [ 'help_post' => "text", 'help_pre' => "text", 'label' => "varchar(255)", - ), - 'civicrm_price_field' => array( + ], + 'civicrm_price_field' => [ 'label' => "varchar(255)", 'help_pre' => "text", 'help_post' => "text", - ), - 'civicrm_price_field_value' => array( + ], + 'civicrm_price_field_value' => [ 'label' => "varchar(255)", 'description' => "text", - ), - 'civicrm_pcp_block' => array( + ], + 'civicrm_pcp_block' => [ 'link_text' => "varchar(255)", - ), - 'civicrm_event' => array( + ], + 'civicrm_event' => [ 'title' => "varchar(255)", 'summary' => "text", 'description' => "text", @@ -180,8 +180,8 @@ public static function &columns() { 'waitlist_text' => "text", 'approval_req_text' => "text", 'template_title' => "varchar(255)", - ), - ); + ], + ]; } return $result; } @@ -192,37 +192,37 @@ public static function &columns() { public static function &indices() { static $result = NULL; if (!$result) { - $result = array( - 'civicrm_custom_group' => array( - 'UI_title_extends' => array( + $result = [ + 'civicrm_custom_group' => [ + 'UI_title_extends' => [ 'name' => 'UI_title_extends', - 'field' => array( + 'field' => [ 'title', 'extends', - ), + ], 'unique' => 1, - ), - ), - 'civicrm_custom_field' => array( - 'UI_label_custom_group_id' => array( + ], + ], + 'civicrm_custom_field' => [ + 'UI_label_custom_group_id' => [ 'name' => 'UI_label_custom_group_id', - 'field' => array( + 'field' => [ 'label', 'custom_group_id', - ), + ], 'unique' => 1, - ), - ), - 'civicrm_group' => array( - 'UI_title' => array( + ], + ], + 'civicrm_group' => [ + 'UI_title' => [ 'name' => 'UI_title', - 'field' => array( + 'field' => [ 'title', - ), + ], 'unique' => 1, - ), - ), - ); + ], + ], + ]; } return $result; } diff --git a/CRM/Core/I18n/SchemaStructure_4_5_alpha1.php b/CRM/Core/I18n/SchemaStructure_4_5_alpha1.php index 6fcb08633477..0ecc107866e0 100644 --- a/CRM/Core/I18n/SchemaStructure_4_5_alpha1.php +++ b/CRM/Core/I18n/SchemaStructure_4_5_alpha1.php @@ -40,64 +40,64 @@ class CRM_Core_I18n_SchemaStructure_4_5_alpha1 { public static function &columns() { static $result = NULL; if (!$result) { - $result = array( - 'civicrm_location_type' => array( + $result = [ + 'civicrm_location_type' => [ 'display_name' => "varchar(64)", - ), - 'civicrm_option_group' => array( + ], + 'civicrm_option_group' => [ 'title' => "varchar(255)", 'description' => "varchar(255)", - ), - 'civicrm_contact_type' => array( + ], + 'civicrm_contact_type' => [ 'label' => "varchar(64)", 'description' => "text", - ), - 'civicrm_batch' => array( + ], + 'civicrm_batch' => [ 'title' => "varchar(64)", 'description' => "text", - ), - 'civicrm_premiums' => array( + ], + 'civicrm_premiums' => [ 'premiums_intro_title' => "varchar(255)", 'premiums_intro_text' => "text", 'premiums_nothankyou_label' => "varchar(255)", - ), - 'civicrm_membership_status' => array( + ], + 'civicrm_membership_status' => [ 'label' => "varchar(128)", - ), - 'civicrm_survey' => array( + ], + 'civicrm_survey' => [ 'title' => "varchar(255)", 'instructions' => "text", 'thankyou_title' => "varchar(255)", 'thankyou_text' => "text", - ), - 'civicrm_participant_status_type' => array( + ], + 'civicrm_participant_status_type' => [ 'label' => "varchar(255)", - ), - 'civicrm_tell_friend' => array( + ], + 'civicrm_tell_friend' => [ 'title' => "varchar(255)", 'intro' => "text", 'suggested_message' => "text", 'thankyou_title' => "varchar(255)", 'thankyou_text' => "text", - ), - 'civicrm_custom_group' => array( + ], + 'civicrm_custom_group' => [ 'title' => "varchar(64)", 'help_pre' => "text", 'help_post' => "text", - ), - 'civicrm_custom_field' => array( + ], + 'civicrm_custom_field' => [ 'label' => "varchar(255)", 'help_pre' => "text", 'help_post' => "text", - ), - 'civicrm_option_value' => array( + ], + 'civicrm_option_value' => [ 'label' => "varchar(255)", 'description' => "text", - ), - 'civicrm_group' => array( + ], + 'civicrm_group' => [ 'title' => "varchar(64)", - ), - 'civicrm_contribution_page' => array( + ], + 'civicrm_contribution_page' => [ 'title' => "varchar(255)", 'intro_text' => "text", 'pay_later_text' => "text", @@ -111,53 +111,53 @@ public static function &columns() { 'receipt_from_name' => "varchar(255)", 'receipt_text' => "text", 'footer_text' => "text", - ), - 'civicrm_product' => array( + ], + 'civicrm_product' => [ 'name' => "varchar(255)", 'description' => "text", 'options' => "text", - ), - 'civicrm_membership_type' => array( + ], + 'civicrm_membership_type' => [ 'name' => "varchar(128)", 'description' => "varchar(255)", - ), - 'civicrm_membership_block' => array( + ], + 'civicrm_membership_block' => [ 'new_title' => "varchar(255)", 'new_text' => "text", 'renewal_title' => "varchar(255)", 'renewal_text' => "text", - ), - 'civicrm_price_set' => array( + ], + 'civicrm_price_set' => [ 'title' => "varchar(255)", 'help_pre' => "text", 'help_post' => "text", - ), - 'civicrm_dashboard' => array( + ], + 'civicrm_dashboard' => [ 'label' => "varchar(255)", - ), - 'civicrm_uf_group' => array( + ], + 'civicrm_uf_group' => [ 'title' => "varchar(64)", 'help_pre' => "text", 'help_post' => "text", - ), - 'civicrm_uf_field' => array( + ], + 'civicrm_uf_field' => [ 'help_post' => "text", 'help_pre' => "text", 'label' => "varchar(255)", - ), - 'civicrm_price_field' => array( + ], + 'civicrm_price_field' => [ 'label' => "varchar(255)", 'help_pre' => "text", 'help_post' => "text", - ), - 'civicrm_price_field_value' => array( + ], + 'civicrm_price_field_value' => [ 'label' => "varchar(255)", 'description' => "text", - ), - 'civicrm_pcp_block' => array( + ], + 'civicrm_pcp_block' => [ 'link_text' => "varchar(255)", - ), - 'civicrm_event' => array( + ], + 'civicrm_event' => [ 'title' => "varchar(255)", 'summary' => "text", 'description' => "text", @@ -181,8 +181,8 @@ public static function &columns() { 'waitlist_text' => "text", 'approval_req_text' => "text", 'template_title' => "varchar(255)", - ), - ); + ], + ]; } return $result; } @@ -193,37 +193,37 @@ public static function &columns() { public static function &indices() { static $result = NULL; if (!$result) { - $result = array( - 'civicrm_custom_group' => array( - 'UI_title_extends' => array( + $result = [ + 'civicrm_custom_group' => [ + 'UI_title_extends' => [ 'name' => 'UI_title_extends', - 'field' => array( + 'field' => [ 'title', 'extends', - ), + ], 'unique' => 1, - ), - ), - 'civicrm_custom_field' => array( - 'UI_label_custom_group_id' => array( + ], + ], + 'civicrm_custom_field' => [ + 'UI_label_custom_group_id' => [ 'name' => 'UI_label_custom_group_id', - 'field' => array( + 'field' => [ 'label', 'custom_group_id', - ), + ], 'unique' => 1, - ), - ), - 'civicrm_group' => array( - 'UI_title' => array( + ], + ], + 'civicrm_group' => [ + 'UI_title' => [ 'name' => 'UI_title', - 'field' => array( + 'field' => [ 'title', - ), + ], 'unique' => 1, - ), - ), - ); + ], + ], + ]; } return $result; } diff --git a/CRM/Core/I18n/SchemaStructure_4_5_beta2.php b/CRM/Core/I18n/SchemaStructure_4_5_beta2.php index ebde87cd0ee1..125b6f8030b7 100644 --- a/CRM/Core/I18n/SchemaStructure_4_5_beta2.php +++ b/CRM/Core/I18n/SchemaStructure_4_5_beta2.php @@ -41,68 +41,68 @@ class CRM_Core_I18n_SchemaStructure_4_5_beta2 { public static function &columns() { static $result = NULL; if (!$result) { - $result = array( - 'civicrm_location_type' => array( + $result = [ + 'civicrm_location_type' => [ 'display_name' => "varchar(64)", - ), - 'civicrm_option_group' => array( + ], + 'civicrm_option_group' => [ 'title' => "varchar(255)", 'description' => "varchar(255)", - ), - 'civicrm_contact_type' => array( + ], + 'civicrm_contact_type' => [ 'label' => "varchar(64)", 'description' => "text", - ), - 'civicrm_batch' => array( + ], + 'civicrm_batch' => [ 'title' => "varchar(64)", 'description' => "text", - ), - 'civicrm_premiums' => array( + ], + 'civicrm_premiums' => [ 'premiums_intro_title' => "varchar(255)", 'premiums_intro_text' => "text", 'premiums_nothankyou_label' => "varchar(255)", - ), - 'civicrm_membership_status' => array( + ], + 'civicrm_membership_status' => [ 'label' => "varchar(128)", - ), - 'civicrm_survey' => array( + ], + 'civicrm_survey' => [ 'title' => "varchar(255)", 'instructions' => "text", 'thankyou_title' => "varchar(255)", 'thankyou_text' => "text", - ), - 'civicrm_participant_status_type' => array( + ], + 'civicrm_participant_status_type' => [ 'label' => "varchar(255)", - ), - 'civicrm_case_type' => array( + ], + 'civicrm_case_type' => [ 'title' => "varchar(64)", 'description' => "varchar(255)", - ), - 'civicrm_tell_friend' => array( + ], + 'civicrm_tell_friend' => [ 'title' => "varchar(255)", 'intro' => "text", 'suggested_message' => "text", 'thankyou_title' => "varchar(255)", 'thankyou_text' => "text", - ), - 'civicrm_custom_group' => array( + ], + 'civicrm_custom_group' => [ 'title' => "varchar(64)", 'help_pre' => "text", 'help_post' => "text", - ), - 'civicrm_custom_field' => array( + ], + 'civicrm_custom_field' => [ 'label' => "varchar(255)", 'help_pre' => "text", 'help_post' => "text", - ), - 'civicrm_option_value' => array( + ], + 'civicrm_option_value' => [ 'label' => "varchar(255)", 'description' => "text", - ), - 'civicrm_group' => array( + ], + 'civicrm_group' => [ 'title' => "varchar(64)", - ), - 'civicrm_contribution_page' => array( + ], + 'civicrm_contribution_page' => [ 'title' => "varchar(255)", 'intro_text' => "text", 'pay_later_text' => "text", @@ -116,53 +116,53 @@ public static function &columns() { 'receipt_from_name' => "varchar(255)", 'receipt_text' => "text", 'footer_text' => "text", - ), - 'civicrm_product' => array( + ], + 'civicrm_product' => [ 'name' => "varchar(255)", 'description' => "text", 'options' => "text", - ), - 'civicrm_membership_type' => array( + ], + 'civicrm_membership_type' => [ 'name' => "varchar(128)", 'description' => "varchar(255)", - ), - 'civicrm_membership_block' => array( + ], + 'civicrm_membership_block' => [ 'new_title' => "varchar(255)", 'new_text' => "text", 'renewal_title' => "varchar(255)", 'renewal_text' => "text", - ), - 'civicrm_price_set' => array( + ], + 'civicrm_price_set' => [ 'title' => "varchar(255)", 'help_pre' => "text", 'help_post' => "text", - ), - 'civicrm_dashboard' => array( + ], + 'civicrm_dashboard' => [ 'label' => "varchar(255)", - ), - 'civicrm_uf_group' => array( + ], + 'civicrm_uf_group' => [ 'title' => "varchar(64)", 'help_pre' => "text", 'help_post' => "text", - ), - 'civicrm_uf_field' => array( + ], + 'civicrm_uf_field' => [ 'help_post' => "text", 'help_pre' => "text", 'label' => "varchar(255)", - ), - 'civicrm_price_field' => array( + ], + 'civicrm_price_field' => [ 'label' => "varchar(255)", 'help_pre' => "text", 'help_post' => "text", - ), - 'civicrm_price_field_value' => array( + ], + 'civicrm_price_field_value' => [ 'label' => "varchar(255)", 'description' => "text", - ), - 'civicrm_pcp_block' => array( + ], + 'civicrm_pcp_block' => [ 'link_text' => "varchar(255)", - ), - 'civicrm_event' => array( + ], + 'civicrm_event' => [ 'title' => "varchar(255)", 'summary' => "text", 'description' => "text", @@ -186,8 +186,8 @@ public static function &columns() { 'waitlist_text' => "text", 'approval_req_text' => "text", 'template_title' => "varchar(255)", - ), - ); + ], + ]; } return $result; } @@ -200,37 +200,37 @@ public static function &columns() { public static function &indices() { static $result = NULL; if (!$result) { - $result = array( - 'civicrm_custom_group' => array( - 'UI_title_extends' => array( + $result = [ + 'civicrm_custom_group' => [ + 'UI_title_extends' => [ 'name' => 'UI_title_extends', - 'field' => array( + 'field' => [ 'title', 'extends', - ), + ], 'unique' => 1, - ), - ), - 'civicrm_custom_field' => array( - 'UI_label_custom_group_id' => array( + ], + ], + 'civicrm_custom_field' => [ + 'UI_label_custom_group_id' => [ 'name' => 'UI_label_custom_group_id', - 'field' => array( + 'field' => [ 'label', 'custom_group_id', - ), + ], 'unique' => 1, - ), - ), - 'civicrm_group' => array( - 'UI_title' => array( + ], + ], + 'civicrm_group' => [ + 'UI_title' => [ 'name' => 'UI_title', - 'field' => array( + 'field' => [ 'title', - ), + ], 'unique' => 1, - ), - ), - ); + ], + ], + ]; } return $result; } diff --git a/CRM/Core/I18n/SchemaStructure_4_7_alpha1.php b/CRM/Core/I18n/SchemaStructure_4_7_alpha1.php index 3bfcb287b4ae..3b14ff6a0a61 100644 --- a/CRM/Core/I18n/SchemaStructure_4_7_alpha1.php +++ b/CRM/Core/I18n/SchemaStructure_4_7_alpha1.php @@ -41,68 +41,68 @@ class CRM_Core_I18n_SchemaStructure_4_7_alpha1 { public static function &columns() { static $result = NULL; if (!$result) { - $result = array( - 'civicrm_location_type' => array( + $result = [ + 'civicrm_location_type' => [ 'display_name' => "varchar(64)", - ), - 'civicrm_option_group' => array( + ], + 'civicrm_option_group' => [ 'title' => "varchar(255)", 'description' => "varchar(255)", - ), - 'civicrm_contact_type' => array( + ], + 'civicrm_contact_type' => [ 'label' => "varchar(64)", 'description' => "text", - ), - 'civicrm_batch' => array( + ], + 'civicrm_batch' => [ 'title' => "varchar(64)", 'description' => "text", - ), - 'civicrm_premiums' => array( + ], + 'civicrm_premiums' => [ 'premiums_intro_title' => "varchar(255)", 'premiums_intro_text' => "text", 'premiums_nothankyou_label' => "varchar(255)", - ), - 'civicrm_membership_status' => array( + ], + 'civicrm_membership_status' => [ 'label' => "varchar(128)", - ), - 'civicrm_survey' => array( + ], + 'civicrm_survey' => [ 'title' => "varchar(255)", 'instructions' => "text", 'thankyou_title' => "varchar(255)", 'thankyou_text' => "text", - ), - 'civicrm_participant_status_type' => array( + ], + 'civicrm_participant_status_type' => [ 'label' => "varchar(255)", - ), - 'civicrm_case_type' => array( + ], + 'civicrm_case_type' => [ 'title' => "varchar(64)", 'description' => "varchar(255)", - ), - 'civicrm_tell_friend' => array( + ], + 'civicrm_tell_friend' => [ 'title' => "varchar(255)", 'intro' => "text", 'suggested_message' => "text", 'thankyou_title' => "varchar(255)", 'thankyou_text' => "text", - ), - 'civicrm_custom_group' => array( + ], + 'civicrm_custom_group' => [ 'title' => "varchar(64)", 'help_pre' => "text", 'help_post' => "text", - ), - 'civicrm_custom_field' => array( + ], + 'civicrm_custom_field' => [ 'label' => "varchar(255)", 'help_pre' => "text", 'help_post' => "text", - ), - 'civicrm_option_value' => array( + ], + 'civicrm_option_value' => [ 'label' => "varchar(255)", 'description' => "text", - ), - 'civicrm_group' => array( + ], + 'civicrm_group' => [ 'title' => "varchar(64)", - ), - 'civicrm_contribution_page' => array( + ], + 'civicrm_contribution_page' => [ 'title' => "varchar(255)", 'intro_text' => "text", 'pay_later_text' => "text", @@ -115,53 +115,53 @@ public static function &columns() { 'receipt_from_name' => "varchar(255)", 'receipt_text' => "text", 'footer_text' => "text", - ), - 'civicrm_product' => array( + ], + 'civicrm_product' => [ 'name' => "varchar(255)", 'description' => "text", 'options' => "text", - ), - 'civicrm_membership_type' => array( + ], + 'civicrm_membership_type' => [ 'name' => "varchar(128)", 'description' => "varchar(255)", - ), - 'civicrm_membership_block' => array( + ], + 'civicrm_membership_block' => [ 'new_title' => "varchar(255)", 'new_text' => "text", 'renewal_title' => "varchar(255)", 'renewal_text' => "text", - ), - 'civicrm_price_set' => array( + ], + 'civicrm_price_set' => [ 'title' => "varchar(255)", 'help_pre' => "text", 'help_post' => "text", - ), - 'civicrm_dashboard' => array( + ], + 'civicrm_dashboard' => [ 'label' => "varchar(255)", - ), - 'civicrm_uf_group' => array( + ], + 'civicrm_uf_group' => [ 'title' => "varchar(64)", 'help_pre' => "text", 'help_post' => "text", - ), - 'civicrm_uf_field' => array( + ], + 'civicrm_uf_field' => [ 'help_post' => "text", 'help_pre' => "text", 'label' => "varchar(255)", - ), - 'civicrm_price_field' => array( + ], + 'civicrm_price_field' => [ 'label' => "varchar(255)", 'help_pre' => "text", 'help_post' => "text", - ), - 'civicrm_price_field_value' => array( + ], + 'civicrm_price_field_value' => [ 'label' => "varchar(255)", 'description' => "text", - ), - 'civicrm_pcp_block' => array( + ], + 'civicrm_pcp_block' => [ 'link_text' => "varchar(255)", - ), - 'civicrm_event' => array( + ], + 'civicrm_event' => [ 'title' => "varchar(255)", 'summary' => "text", 'description' => "text", @@ -185,13 +185,13 @@ public static function &columns() { 'waitlist_text' => "text", 'approval_req_text' => "text", 'template_title' => "varchar(255)", - ), - 'civicrm_relationship_type' => array( + ], + 'civicrm_relationship_type' => [ 'label_a_b' => "varchar(64)", 'label_b_a' => "varchar(64)", 'description' => "varchar(255)", - ), - ); + ], + ]; } return $result; } @@ -204,37 +204,37 @@ public static function &columns() { public static function &indices() { static $result = NULL; if (!$result) { - $result = array( - 'civicrm_custom_group' => array( - 'UI_title_extends' => array( + $result = [ + 'civicrm_custom_group' => [ + 'UI_title_extends' => [ 'name' => 'UI_title_extends', - 'field' => array( + 'field' => [ 'title', 'extends', - ), + ], 'unique' => 1, - ), - ), - 'civicrm_custom_field' => array( - 'UI_label_custom_group_id' => array( + ], + ], + 'civicrm_custom_field' => [ + 'UI_label_custom_group_id' => [ 'name' => 'UI_label_custom_group_id', - 'field' => array( + 'field' => [ 'label', 'custom_group_id', - ), + ], 'unique' => 1, - ), - ), - 'civicrm_group' => array( - 'UI_title' => array( + ], + ], + 'civicrm_group' => [ + 'UI_title' => [ 'name' => 'UI_title', - 'field' => array( + 'field' => [ 'title', - ), + ], 'unique' => 1, - ), - ), - ); + ], + ], + ]; } return $result; } diff --git a/CRM/Core/IDS.php b/CRM/Core/IDS.php index 8d1fed7f041e..648b680d22ff 100644 --- a/CRM/Core/IDS.php +++ b/CRM/Core/IDS.php @@ -35,11 +35,11 @@ class CRM_Core_IDS { /** * Define the threshold for the ids reactions. */ - private $threshold = array( + private $threshold = [ 'log' => 25, 'warn' => 50, 'kick' => 75, - ); + ]; /** * @var string @@ -62,7 +62,7 @@ public function check($route) { } // lets bypass a few civicrm urls from this check - $skip = array('civicrm/admin/setting/updateConfigBackend', 'civicrm/admin/messageTemplates'); + $skip = ['civicrm/admin/setting/updateConfigBackend', 'civicrm/admin/messageTemplates']; CRM_Utils_Hook::idsException($skip); $this->path = $route['path']; if (in_array($this->path, $skip)) { @@ -120,17 +120,17 @@ public static function createBaseConfig() { $tmpDir = empty($config->uploadDir) ? CIVICRM_TEMPLATE_COMPILEDIR : $config->uploadDir; global $civicrm_root; - return array( - 'General' => array( + return [ + 'General' => [ 'filter_type' => 'xml', 'filter_path' => "{$civicrm_root}/packages/IDS/default_filter.xml", 'tmp_path' => $tmpDir, 'HTML_Purifier_Path' => $civicrm_root . '/vendor/ezyang/htmlpurifier/library/HTMLPurifier.auto.php', 'HTML_Purifier_Cache' => $tmpDir, 'scan_keys' => '', - 'exceptions' => array('__utmz', '__utmc'), - ), - ); + 'exceptions' => ['__utmz', '__utmc'], + ], + ]; } /** @@ -139,7 +139,7 @@ public static function createBaseConfig() { * @return array */ public static function createStandardConfig() { - $excs = array( + $excs = [ 'widget_code', 'html_message', 'text_message', @@ -173,7 +173,7 @@ public static function createStandardConfig() { 'suggested_message', 'page_text', 'details', - ); + ]; $result = self::createBaseConfig(); @@ -191,10 +191,10 @@ public static function createStandardConfig() { */ public static function createRouteConfig($route) { $config = \CRM_Core_IDS::createStandardConfig(); - foreach (array('json', 'html', 'exceptions') as $section) { + foreach (['json', 'html', 'exceptions'] as $section) { if (isset($route['ids_arguments'][$section])) { if (!isset($config['General'][$section])) { - $config['General'][$section] = array(); + $config['General'][$section] = []; } foreach ($route['ids_arguments'][$section] as $v) { $config['General'][$section][] = $v; @@ -251,10 +251,10 @@ private function log($result, $reaction = 0) { isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : '127.0.0.1' ); - $data = array(); + $data = []; $session = CRM_Core_Session::singleton(); foreach ($result as $event) { - $data[] = array( + $data[] = [ 'name' => $event->getName(), 'value' => stripslashes($event->getValue()), 'page' => $_SERVER['REQUEST_URI'], @@ -263,7 +263,7 @@ private function log($result, $reaction = 0) { 'ip' => $ip, 'reaction' => $reaction, 'impact' => $result->getImpact(), - ); + ]; } CRM_Core_Error::debug_var('IDS Detector Details', $data); @@ -294,18 +294,18 @@ private function kick() { if (in_array( $this->path, - array("civicrm/ajax/rest", "civicrm/api/json") + ["civicrm/ajax/rest", "civicrm/api/json"] )) { require_once "api/v3/utils.php"; $error = civicrm_api3_create_error( $msg, - array( + [ 'IP' => $_SERVER['REMOTE_ADDR'], 'error_code' => 'IDS_KICK', 'level' => 'security', 'referer' => $_SERVER['HTTP_REFERER'], 'reason' => 'XSS suspected', - ) + ] ); CRM_Utils_JSON::output($error); } diff --git a/CRM/Core/InnoDBIndexer.php b/CRM/Core/InnoDBIndexer.php index 8d4f2291caaa..123792a656b1 100644 --- a/CRM/Core/InnoDBIndexer.php +++ b/CRM/Core/InnoDBIndexer.php @@ -43,38 +43,38 @@ class CRM_Core_InnoDBIndexer { */ public static function singleton($fresh = FALSE) { if ($fresh || self::$singleton === NULL) { - $indices = array( - 'civicrm_address' => array( - array('street_address', 'city', 'postal_code'), - ), - 'civicrm_activity' => array( - array('subject', 'details'), - ), - 'civicrm_contact' => array( - array('sort_name', 'nick_name', 'display_name'), - ), - 'civicrm_contribution' => array( - array('source', 'amount_level', 'trxn_Id', 'invoice_id'), - ), - 'civicrm_email' => array( - array('email'), - ), - 'civicrm_membership' => array( - array('source'), - ), - 'civicrm_note' => array( - array('subject', 'note'), - ), - 'civicrm_participant' => array( - array('source', 'fee_level'), - ), - 'civicrm_phone' => array( - array('phone'), - ), - 'civicrm_tag' => array( - array('name'), - ), - ); + $indices = [ + 'civicrm_address' => [ + ['street_address', 'city', 'postal_code'], + ], + 'civicrm_activity' => [ + ['subject', 'details'], + ], + 'civicrm_contact' => [ + ['sort_name', 'nick_name', 'display_name'], + ], + 'civicrm_contribution' => [ + ['source', 'amount_level', 'trxn_Id', 'invoice_id'], + ], + 'civicrm_email' => [ + ['email'], + ], + 'civicrm_membership' => [ + ['source'], + ], + 'civicrm_note' => [ + ['subject', 'note'], + ], + 'civicrm_participant' => [ + ['source', 'fee_level'], + ], + 'civicrm_phone' => [ + ['phone'], + ], + 'civicrm_tag' => [ + ['name'], + ], + ]; $active = Civi::settings()->get('enable_innodb_fts'); self::$singleton = new self($active, $indices); } @@ -156,7 +156,7 @@ public function hasDeclaredIndex($table, $fields) { foreach ($this->indices[$table] as $idxFields) { // TODO determine if $idxFields must be exact match or merely a subset // if (sort($fields) == sort($idxFields)) { - if (array_diff($fields, $idxFields) == array()) { + if (array_diff($fields, $idxFields) == []) { return TRUE; } } @@ -177,7 +177,7 @@ public function findActualFtsIndexNames($table) { if (version_compare($mysqlVersion, '5.6', '<')) { // If we're not on 5.6+, then there cannot be any InnoDB FTS indices! // Also: information_schema.innodb_sys_indexes is only available on 5.6+. - return array(); + return []; } // Note: this only works in MySQL 5.6, but this whole system is intended to only work in MySQL 5.6 @@ -189,7 +189,7 @@ public function findActualFtsIndexNames($table) { AND i.name like '" . self::IDX_PREFIX . "%' "; $dao = CRM_Core_DAO::executeQuery($sql); - $indexNames = array(); + $indexNames = []; while ($dao->fetch()) { $indexNames[$dao->index_name] = $dao->index_name; } @@ -206,7 +206,7 @@ public function findActualFtsIndexNames($table) { * (string $indexName => string $sql) */ public function buildIndexSql($table) { - $sqls = array(); // array (string $idxName => string $sql) + $sqls = []; // array (string $idxName => string $sql) if ($this->isActive && isset($this->indices[$table])) { foreach ($this->indices[$table] as $fields) { $name = self::IDX_PREFIX . md5($table . '::' . implode(',', $fields)); @@ -225,7 +225,7 @@ public function buildIndexSql($table) { * (string $idxName => string $sql) */ public function dropIndexSql($table) { - $sqls = array(); + $sqls = []; $names = $this->findActualFtsIndexNames($table); foreach ($names as $name) { $sqls[$name] = sprintf("DROP INDEX %s ON %s", $name, $table); @@ -250,7 +250,7 @@ public function reconcileIndexSqls($table) { array_keys($buildIndexSqls) )); - $todoSqls = array(); + $todoSqls = []; foreach ($allIndexNames as $indexName) { if (isset($buildIndexSqls[$indexName]) && isset($dropIndexSqls[$indexName])) { // already exists @@ -272,7 +272,7 @@ public function reconcileIndexSqls($table) { * @return array */ public function normalizeIndices($indices) { - $result = array(); + $result = []; foreach ($indices as $table => $indicesByTable) { foreach ($indicesByTable as $k => $fields) { sort($fields); diff --git a/CRM/Core/Invoke.php b/CRM/Core/Invoke.php index e8c4a4a97c3c..15ff125b0b9d 100644 --- a/CRM/Core/Invoke.php +++ b/CRM/Core/Invoke.php @@ -109,7 +109,7 @@ public static function _invoke($args) { * @void */ static public function hackMenuRebuild($args) { - if (array('civicrm', 'menu', 'rebuild') == $args || array('civicrm', 'clearcache') == $args) { + if (['civicrm', 'menu', 'rebuild'] == $args || ['civicrm', 'clearcache'] == $args) { // ensure that the user has a good privilege level if (CRM_Core_Permission::check('administer CiviCRM')) { self::rebuildMenuAndCaches(); @@ -328,12 +328,12 @@ static public function runItem($item) { * */ public static function form($action, $contact_type, $contact_sub_type) { - CRM_Utils_System::setUserContext(array('civicrm/contact/search/basic', 'civicrm/contact/view')); + CRM_Utils_System::setUserContext(['civicrm/contact/search/basic', 'civicrm/contact/view']); $wrapper = new CRM_Utils_Wrapper(); $properties = CRM_Core_Component::contactSubTypeProperties($contact_sub_type, 'Edit'); if ($properties) { - $wrapper->run($properties['class'], ts('New %1', array(1 => $contact_sub_type)), $action, TRUE); + $wrapper->run($properties['class'], ts('New %1', [1 => $contact_sub_type]), $action, TRUE); } else { $wrapper->run('CRM_Contact_Form_Contact', ts('New Contact'), $action, TRUE); diff --git a/CRM/Core/JobManager.php b/CRM/Core/JobManager.php index 38f6db414ca8..5d269cf24ae2 100644 --- a/CRM/Core/JobManager.php +++ b/CRM/Core/JobManager.php @@ -44,7 +44,7 @@ class CRM_Core_JobManager { */ var $currentJob = NULL; - var $singleRunParams = array(); + var $singleRunParams = []; var $_source = NULL; @@ -83,10 +83,10 @@ public function execute($auth = TRUE) { $this->logEntry('Finishing scheduled jobs execution.'); // Set last cron date for the status check - $statusPref = array( + $statusPref = [ 'name' => 'checkLastCron', 'check_info' => gmdate('U'), - ); + ]; CRM_Core_BAO_StatusPreference::create($statusPref); } @@ -156,7 +156,7 @@ public function executeJob($job) { //Disable outBound option after executing the job. $environment = CRM_Core_Config::environment(NULL, TRUE); if ($environment != 'Production' && !empty($job->apiParams['runInNonProductionEnvironment'])) { - Civi::settings()->set('mailing_backend', array('outBound_option' => CRM_Mailing_Config::OUTBOUND_OPTION_DISABLED)); + Civi::settings()->set('mailing_backend', ['outBound_option' => CRM_Mailing_Config::OUTBOUND_OPTION_DISABLED]); } } @@ -168,13 +168,13 @@ public function executeJob($job) { * ($id => CRM_Core_ScheduledJob) */ private function _getJobs() { - $jobs = array(); + $jobs = []; $dao = new CRM_Core_DAO_Job(); $dao->orderBy('name'); $dao->domain_id = CRM_Core_Config::domainID(); $dao->find(); while ($dao->fetch()) { - $temp = array(); + $temp = []; CRM_Core_DAO::storeValues($dao, $temp); $jobs[$dao->id] = new CRM_Core_ScheduledJob($temp); } diff --git a/CRM/Core/Joomla.php b/CRM/Core/Joomla.php index 50766d9fc407..8305fa224166 100644 --- a/CRM/Core/Joomla.php +++ b/CRM/Core/Joomla.php @@ -52,7 +52,7 @@ public static function sidebarLeft() { return; } - $blockIds = array( + $blockIds = [ CRM_Core_Block::CREATE_NEW, CRM_Core_Block::RECENTLY_VIEWED, CRM_Core_Block::DASHBOARD, @@ -60,9 +60,9 @@ public static function sidebarLeft() { CRM_Core_Block::LANGSWITCH, //CRM_Core_Block::EVENT, //CRM_Core_Block::FULLTEXT_SEARCH - ); + ]; - $blocks = array(); + $blocks = []; foreach ($blockIds as $id) { $blocks[] = CRM_Core_Block::getContent($id); } diff --git a/CRM/Core/Lock.php b/CRM/Core/Lock.php index 460475e4183f..789639506cd2 100644 --- a/CRM/Core/Lock.php +++ b/CRM/Core/Lock.php @@ -182,10 +182,10 @@ public function acquire($timeout = NULL) { } $query = "SELECT GET_LOCK( %1, %2 )"; - $params = array( - 1 => array($this->_id, 'String'), - 2 => array($timeout ? $timeout : $this->_timeout, 'Integer'), - ); + $params = [ + 1 => [$this->_id, 'String'], + 2 => [$timeout ? $timeout : $this->_timeout, 'Integer'], + ]; $res = CRM_Core_DAO::singleValueQuery($query, $params); if ($res) { if (defined('CIVICRM_LOCK_DEBUG')) { @@ -220,7 +220,7 @@ public function release() { } $query = "SELECT RELEASE_LOCK( %1 )"; - $params = array(1 => array($this->_id, 'String')); + $params = [1 => [$this->_id, 'String']]; return CRM_Core_DAO::singleValueQuery($query, $params); } } @@ -230,7 +230,7 @@ public function release() { */ public function isFree() { $query = "SELECT IS_FREE_LOCK( %1 )"; - $params = array(1 => array($this->_id, 'String')); + $params = [1 => [$this->_id, 'String']]; return CRM_Core_DAO::singleValueQuery($query, $params); } diff --git a/CRM/Core/ManagedEntities.php b/CRM/Core/ManagedEntities.php index fe9631d0dbd0..f5ee0c38cabc 100644 --- a/CRM/Core/ManagedEntities.php +++ b/CRM/Core/ManagedEntities.php @@ -13,11 +13,11 @@ class CRM_Core_ManagedEntities { * @return array */ public static function getCleanupOptions() { - return array( + return [ 'always' => ts('Always'), 'never' => ts('Never'), 'unused' => ts('If Unused'), - ); + ]; } /** @@ -55,7 +55,7 @@ public static function scheduleReconciliation() { function () { CRM_Core_ManagedEntities::singleton(TRUE)->reconcile(); }, - array(), + [], 'ManagedEntities::reconcile' ); } @@ -92,9 +92,9 @@ public function get($moduleName, $name) { $dao->module = $moduleName; $dao->name = $name; if ($dao->find(TRUE)) { - $params = array( + $params = [ 'id' => $dao->entity_id, - ); + ]; $result = NULL; try { $result = civicrm_api3($dao->entity_type, 'getsingle', $params); @@ -204,7 +204,7 @@ public function reconcileDisabledModules() { * unknown modules. */ public function reconcileUnknownModules() { - $knownModules = array(); + $knownModules = []; if (array_key_exists(0, $this->moduleIndex) && is_array($this->moduleIndex[0])) { $knownModules = array_merge($knownModules, array_keys($this->moduleIndex[0])); } @@ -257,10 +257,10 @@ public function updateExistingEntity($dao, $todo) { $doUpdate = ($policy == 'always'); if ($doUpdate) { - $defaults = array( + $defaults = [ 'id' => $dao->entity_id, 'is_active' => 1, // FIXME: test whether is_active is valid - ); + ]; $params = array_merge($defaults, $todo['params']); $result = civicrm_api($dao->entity_type, 'create', $params); if ($result['is_error']) { @@ -284,11 +284,11 @@ public function disableEntity($dao) { // FIXME: if ($dao->entity_type supports is_active) { if (TRUE) { // FIXME cascading for payproc types? - $params = array( + $params = [ 'version' => 3, 'id' => $dao->entity_id, 'is_active' => 0, - ); + ]; $result = civicrm_api($dao->entity_type, 'create', $params); if ($result['is_error']) { $this->onApiError($dao->entity_type, 'create', $params, $result); @@ -314,10 +314,10 @@ public function removeStaleEntity($dao) { break; case 'unused': - $getRefCount = civicrm_api3($dao->entity_type, 'getrefcount', array( + $getRefCount = civicrm_api3($dao->entity_type, 'getrefcount', [ 'debug' => 1, 'id' => $dao->entity_id, - )); + ]); $total = 0; foreach ($getRefCount['values'] as $refCount) { @@ -332,10 +332,10 @@ public function removeStaleEntity($dao) { } if ($doDelete) { - $params = array( + $params = [ 'version' => 3, 'id' => $dao->entity_id, - ); + ]; $check = civicrm_api3($dao->entity_type, 'get', $params); if ((bool) $check['count']) { $result = civicrm_api($dao->entity_type, 'delete', $params); @@ -343,9 +343,9 @@ public function removeStaleEntity($dao) { $this->onApiError($dao->entity_type, 'delete', $params, $result); } } - CRM_Core_DAO::executeQuery('DELETE FROM civicrm_managed WHERE id = %1', array( - 1 => array($dao->id, 'Integer'), - )); + CRM_Core_DAO::executeQuery('DELETE FROM civicrm_managed WHERE id = %1', [ + 1 => [$dao->id, 'Integer'], + ]); } } @@ -356,7 +356,7 @@ public function removeStaleEntity($dao) { */ public function getDeclarations() { if ($this->declarations === NULL) { - $this->declarations = array(); + $this->declarations = []; foreach (CRM_Core_Component::getEnabledComponents() as $component) { /** @var CRM_Core_Component_Info $component */ $this->declarations = array_merge($this->declarations, $component->getManagedEntities()); @@ -375,7 +375,7 @@ public function getDeclarations() { * indexed by is_active,name */ protected static function createModuleIndex($modules) { - $result = array(); + $result = []; foreach ($modules as $module) { $result[$module->is_active][$module->name] = $module; } @@ -390,14 +390,14 @@ protected static function createModuleIndex($modules) { * indexed by module,name */ protected static function createDeclarationIndex($moduleIndex, $declarations) { - $result = array(); + $result = []; if (!isset($moduleIndex[TRUE])) { return $result; } foreach ($moduleIndex[TRUE] as $moduleName => $module) { if ($module->is_active) { // need an empty array() for all active modules, even if there are no current $declarations - $result[$moduleName] = array(); + $result[$moduleName] = []; } } foreach ($declarations as $declaration) { @@ -414,7 +414,7 @@ protected static function createDeclarationIndex($moduleIndex, $declarations) { */ protected static function validate($declarations) { foreach ($declarations as $declare) { - foreach (array('name', 'module', 'entity', 'params') as $key) { + foreach (['name', 'module', 'entity', 'params'] as $key) { if (empty($declare[$key])) { $str = print_r($declare, TRUE); return ("Managed Entity is missing field \"$key\": $str"); @@ -448,12 +448,12 @@ protected static function cleanDeclarations($declarations) { * @throws Exception */ protected function onApiError($entity, $action, $params, $result) { - CRM_Core_Error::debug_var('ManagedEntities_failed', array( + CRM_Core_Error::debug_var('ManagedEntities_failed', [ 'entity' => $entity, 'action' => $action, 'params' => $params, 'result' => $result, - )); + ]); throw new Exception('API error: ' . $result['error_message']); } diff --git a/CRM/Core/Module.php b/CRM/Core/Module.php index 0f812529787a..eca6f6e38dbf 100644 --- a/CRM/Core/Module.php +++ b/CRM/Core/Module.php @@ -87,7 +87,7 @@ public static function getAll($fresh = FALSE) { * @see CRM_Extension_Manager::STATUS_DISABLED */ public static function collectStatuses($modules) { - $statuses = array(); + $statuses = []; foreach ($modules as $module) { $statuses[$module->name] = $module->is_active ? CRM_Extension_Manager::STATUS_INSTALLED : CRM_Extension_Manager::STATUS_DISABLED; diff --git a/CRM/Core/OptionGroup.php b/CRM/Core/OptionGroup.php index 2b80acc673dd..94368ec6a30a 100644 --- a/CRM/Core/OptionGroup.php +++ b/CRM/Core/OptionGroup.php @@ -31,17 +31,17 @@ * @copyright CiviCRM LLC (c) 2004-2019 */ class CRM_Core_OptionGroup { - static $_values = array(); - static $_cache = array(); + static $_values = []; + static $_cache = []; /** * $_domainIDGroups array maintains the list of option groups for whom * domainID is to be considered. */ - static $_domainIDGroups = array( + static $_domainIDGroups = [ 'from_email_address', 'grant_type', - ); + ]; /** * @param CRM_Core_DAO $dao @@ -56,7 +56,7 @@ public static function &valuesCommon( $dao, $flip = FALSE, $grouping = FALSE, $localize = FALSE, $valueColumnName = 'label' ) { - self::$_values = array(); + self::$_values = []; while ($dao->fetch()) { if ($flip) { @@ -164,7 +164,7 @@ public static function &values( $query .= " ORDER BY v.{$orderBy}"; - $p = array(1 => array($name, 'String')); + $p = [1 => [$name, 'String']]; $dao = CRM_Core_DAO::executeQuery($query, $p); $var = self::valuesCommon($dao, $flip, $grouping, $localize, $labelColumnName); @@ -252,7 +252,7 @@ public static function &valuesByID($id, $flip = FALSE, $grouping = FALSE, $local } $query .= " ORDER BY v.weight, v.label"; - $p = array(1 => array($id, 'Integer')); + $p = [1 => [$id, 'Integer']]; $dao = CRM_Core_DAO::executeQuery($query, $p); $var = self::valuesCommon($dao, $flip, $grouping, $localize, $labelColumnName); @@ -284,7 +284,7 @@ public static function lookupValues(&$params, $names, $flip = FALSE) { foreach ($names as $postName => $value) { // See if $params field is in $names array (i.e. is a value that we need to lookup) if ($postalName = CRM_Utils_Array::value($postName, $params)) { - $postValues = array(); + $postValues = []; // params[$postName] may be a Ctrl+A separated value list if (is_string($postalName) && strpos($postalName, CRM_Core_DAO::VALUE_SEPARATOR) == FALSE @@ -298,24 +298,24 @@ public static function lookupValues(&$params, $names, $flip = FALSE) { elseif (is_array($postalName)) { $postValues = $postalName; } - $newValue = array(); + $newValue = []; foreach ($postValues as $postValue) { if (!$postValue) { continue; } if ($flip) { - $p = array(1 => array($postValue, 'String')); + $p = [1 => [$postValue, 'String']]; $lookupBy = 'v.label= %1'; $select = "v.value"; } else { - $p = array(1 => array($postValue, 'Integer')); + $p = [1 => [$postValue, 'Integer']]; $lookupBy = 'v.value = %1'; $select = "v.label"; } - $p[2] = array($value['groupName'], 'String'); + $p[2] = [$value['groupName'], 'String']; $query = " SELECT $select FROM civicrm_option_value v, @@ -361,10 +361,10 @@ public static function getLabel($groupName, $value, $onlyActiveValue = TRUE) { if ($onlyActiveValue) { $query .= " AND v.is_active = 1 "; } - $p = array( - 1 => array($groupName, 'String'), - 2 => array($value, 'Integer'), - ); + $p = [ + 1 => [$groupName, 'String'], + 2 => [$value, 'Integer'], + ]; $dao = CRM_Core_DAO::executeQuery($query, $p); if ($dao->fetch()) { return $dao->label; @@ -409,10 +409,10 @@ public static function getValue( AND v.$labelField = %2 "; - $p = array( - 1 => array($groupName, 'String'), - 2 => array($label, $labelType), - ); + $p = [ + 1 => [$groupName, 'String'], + 2 => [$label, $labelType], + ]; $dao = CRM_Core_DAO::executeQuery($query, $p); if ($dao->fetch()) { $dao->free(); @@ -450,7 +450,7 @@ public static function getDefaultValue($groupName) { $query .= " AND v.domain_id = " . CRM_Core_Config::domainID(); } - $p = array(1 => array($groupName, 'String')); + $p = [1 => [$groupName, 'String']]; return CRM_Core_DAO::singleValueQuery($query, $p); } @@ -529,23 +529,23 @@ public static function getAssoc($groupName, &$values, $flip = FALSE, $field = 'n AND g.$field = %1 ORDER BY v.weight "; - $params = array(1 => array($groupName, 'String')); + $params = [1 => [$groupName, 'String']]; $dao = CRM_Core_DAO::executeQuery($query, $params); - $fields = array('value', 'label', 'name', 'description', 'amount_id', 'weight'); + $fields = ['value', 'label', 'name', 'description', 'amount_id', 'weight']; if ($flip) { - $values = array(); + $values = []; } else { foreach ($fields as $field) { - $values[$field] = array(); + $values[$field] = []; } } $index = 1; while ($dao->fetch()) { if ($flip) { - $value = array(); + $value = []; foreach ($fields as $field) { $value[$field] = $dao->$field; } @@ -572,7 +572,7 @@ public static function deleteAssoc($groupName, $operator = "=") { WHERE g.id = v.option_group_id AND g.name {$operator} %1"; - $params = array(1 => array($groupName, 'String')); + $params = [1 => [$groupName, 'String']]; $dao = CRM_Core_DAO::executeQuery($query, $params); } @@ -606,24 +606,24 @@ public static function getRowValues( $query .= " AND v.is_active = 1"; } - $p = array( - 1 => array($groupName, 'String'), - 2 => array($fieldValue, $fieldType), - ); + $p = [ + 1 => [$groupName, 'String'], + 2 => [$fieldValue, $fieldType], + ]; $dao = CRM_Core_DAO::executeQuery($query, $p); - $row = array(); + $row = []; if ($dao->fetch()) { - foreach (array( + foreach ([ 'id', 'name', 'value', 'label', 'weight', 'description', - ) as $fld) { + ] as $fld) { $row[$fld] = $dao->$fld; - if ($localize && in_array($fld, array('label', 'description'))) { + if ($localize && in_array($fld, ['label', 'description'])) { $row[$fld] = ts($row[$fld]); } } @@ -644,14 +644,14 @@ public static function getRowValues( * @param string $name * @param array $params */ - public static function flush($name, $params = array()) { - $defaults = array( + public static function flush($name, $params = []) { + $defaults = [ 'flip' => FALSE, 'grouping' => FALSE, 'localize' => FALSE, 'condition' => NULL, 'labelColumnName' => 'label', - ); + ]; $params = array_merge($defaults, $params); self::flushValues( @@ -683,8 +683,8 @@ public static function flush($name, $params = array()) { * the intuitive urge to flush that class. */ public static function flushAll() { - self::$_values = array(); - self::$_cache = array(); + self::$_values = []; + self::$_cache = []; CRM_Utils_Cache::singleton()->flush(); } diff --git a/CRM/Core/OptionValue.php b/CRM/Core/OptionValue.php index 007a6ea0b795..7390deb4ce57 100644 --- a/CRM/Core/OptionValue.php +++ b/CRM/Core/OptionValue.php @@ -71,7 +71,7 @@ class CRM_Core_OptionValue { * */ public static function getRows($groupParams, $links, $orderBy = 'weight', $skipEmptyComponents = TRUE) { - $optionValue = array(); + $optionValue = []; $optionGroupID = NULL; $isGroupLocked = FALSE; @@ -116,7 +116,7 @@ public static function getRows($groupParams, $links, $orderBy = 'weight', $skipE $componentNames = CRM_Core_Component::getNames(); $visibilityLabels = CRM_Core_PseudoConstant::visibility(); while ($dao->fetch()) { - $optionValue[$dao->id] = array(); + $optionValue[$dao->id] = []; CRM_Core_DAO::storeValues($dao, $optionValue[$dao->id]); if (!empty($optionValue[$dao->id]['component_id']) && empty($componentNames[$optionValue[$dao->id]['component_id']]) && @@ -155,11 +155,11 @@ public static function getRows($groupParams, $links, $orderBy = 'weight', $skipE $optionValue[$dao->id]['order'] = $optionValue[$dao->id]['weight']; $optionValue[$dao->id]['icon'] = CRM_Utils_Array::value('icon', $optionValue[$dao->id], ''); $optionValue[$dao->id]['action'] = CRM_Core_Action::formLink($links, $action, - array( + [ 'id' => $dao->id, 'gid' => $optionGroupID, 'value' => $dao->value, - ), + ], ts('more'), FALSE, 'optionValue.row.actions', @@ -214,13 +214,13 @@ public static function addOptionValue(&$params, $optionGroupName, $action, $opti if ($optionValueID) { $oldWeight = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', $optionValueID, 'weight', 'id'); } - $fieldValues = array('option_group_id' => $optionGroupID); + $fieldValues = ['option_group_id' => $optionGroupID]; $params['weight'] = CRM_Utils_Weight::updateOtherWeights('CRM_Core_DAO_OptionValue', $oldWeight, CRM_Utils_Array::value('weight', $params), $fieldValues); } $params['option_group_id'] = $optionGroupID; if (($action & CRM_Core_Action::ADD) && !isset($params['value'])) { - $fieldValues = array('option_group_id' => $optionGroupID); + $fieldValues = ['option_group_id' => $optionGroupID]; // use the next available value /* CONVERT(value, DECIMAL) is used to convert varchar field 'value' to decimal->integer */ @@ -295,7 +295,7 @@ public static function optionExists($value, $daoName, $daoID, $optionGroupID, $f public static function getFields($mode = '', $contactType = 'Individual') { $key = "$mode $contactType"; if (empty(self::$_fields[$key]) || !self::$_fields[$key]) { - self::$_fields[$key] = array(); + self::$_fields[$key] = []; $option = CRM_Core_DAO_OptionValue::import(); @@ -303,48 +303,48 @@ public static function getFields($mode = '', $contactType = 'Individual') { $optionName = $option[$id]; } - $nameTitle = array(); + $nameTitle = []; if ($mode == 'contribute') { // This is part of a move towards standardising option values but we // should derive them from the fields array so am deprecating it again... // note that the reason this was needed was that payment_instrument_id was // not set to exportable. - $nameTitle = array( - 'payment_instrument' => array( + $nameTitle = [ + 'payment_instrument' => [ 'name' => 'payment_instrument', 'title' => ts('Payment Method'), 'headerPattern' => '/^payment|(p(ayment\s)?instrument)$/i', - ), - ); + ], + ]; } elseif ($mode == '') { //the fields email greeting and postal greeting are meant only for Individual and Household //the field addressee is meant for all contact types, CRM-4575 - if (in_array($contactType, array( + if (in_array($contactType, [ 'Individual', 'Household', 'Organization', 'All', - ))) { - $nameTitle = array( - 'addressee' => array( + ])) { + $nameTitle = [ + 'addressee' => [ 'name' => 'addressee', 'title' => ts('Addressee'), 'headerPattern' => '/^addressee$/i', - ), - ); - $title = array( - 'email_greeting' => array( + ], + ]; + $title = [ + 'email_greeting' => [ 'name' => 'email_greeting', 'title' => ts('Email Greeting'), 'headerPattern' => '/^email_greeting$/i', - ), - 'postal_greeting' => array( + ], + 'postal_greeting' => [ 'name' => 'postal_greeting', 'title' => ts('Postal Greeting'), 'headerPattern' => '/^postal_greeting$/i', - ), - ); + ], + ]; $nameTitle = array_merge($nameTitle, $title); } } @@ -439,7 +439,7 @@ public static function getValues($groupParams, &$values, $orderBy = 'weight', $i if ($groupId) { $where .= " AND option_group.id = %1"; - $params[1] = array($groupId, 'Integer'); + $params[1] = [$groupId, 'Integer']; if (!$groupName) { $groupName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', $groupId, 'name', 'id' @@ -449,7 +449,7 @@ public static function getValues($groupParams, &$values, $orderBy = 'weight', $i if ($groupName) { $where .= " AND option_group.name = %2"; - $params[2] = array($groupName, 'String'); + $params[2] = [$groupName, 'String']; } if (in_array($groupName, CRM_Core_OptionGroup::$_domainIDGroups)) { @@ -461,7 +461,7 @@ public static function getValues($groupParams, &$values, $orderBy = 'weight', $i $dao = CRM_Core_DAO::executeQuery($query, $params); while ($dao->fetch()) { - $values[$dao->id] = array( + $values[$dao->id] = [ 'id' => $dao->id, 'label' => $dao->label, 'value' => $dao->value, @@ -470,7 +470,7 @@ public static function getValues($groupParams, &$values, $orderBy = 'weight', $i 'weight' => $dao->weight, 'is_active' => $dao->is_active, 'is_default' => $dao->is_default, - ); + ]; } } diff --git a/CRM/Core/Page.php b/CRM/Core/Page.php index 7db96fb92cc5..e8908fea50f1 100644 --- a/CRM/Core/Page.php +++ b/CRM/Core/Page.php @@ -98,14 +98,14 @@ class CRM_Core_Page { * * @var array */ - public $ajaxResponse = array(); + public $ajaxResponse = []; /** * Url path used to reach this page * * @var array */ - public $urlPath = array(); + public $urlPath = []; /** * Should crm.livePage.js be added to the page? @@ -144,7 +144,7 @@ public function __construct($title = NULL, $mode = NULL) { $this->_print = CRM_Core_Smarty::PRINT_NOFORM; } // Support 'json' as well as legacy value '6' - elseif (in_array($_REQUEST['snippet'], array(CRM_Core_Smarty::PRINT_JSON, 6))) { + elseif (in_array($_REQUEST['snippet'], [CRM_Core_Smarty::PRINT_JSON, 6])) { $this->_print = CRM_Core_Smarty::PRINT_JSON; } else { @@ -177,12 +177,12 @@ public function run() { CRM_Utils_Hook::pageRun($this); if ($this->_print) { - if (in_array($this->_print, array( + if (in_array($this->_print, [ CRM_Core_Smarty::PRINT_SNIPPET, CRM_Core_Smarty::PRINT_PDF, CRM_Core_Smarty::PRINT_NOFORM, CRM_Core_Smarty::PRINT_JSON, - ))) { + ])) { $content = self::$_template->fetch('CRM/common/snippet.tpl'); } else { @@ -199,7 +199,7 @@ public function run() { if ($this->_print == CRM_Core_Smarty::PRINT_PDF) { CRM_Utils_PDF_Utils::html2pdf($content, "{$this->_name}.pdf", FALSE, - array('paper_size' => 'a3', 'orientation' => 'landscape') + ['paper_size' => 'a3', 'orientation' => 'landscape'] ); } elseif ($this->_print == CRM_Core_Smarty::PRINT_JSON) { @@ -317,10 +317,10 @@ public function reset() { public function getTemplateFileName() { return strtr( CRM_Utils_System::getClassName($this), - array( + [ '_' => DIRECTORY_SEPARATOR, '\\' => DIRECTORY_SEPARATOR, - ) + ] ) . '.tpl'; } @@ -420,8 +420,8 @@ public function setVar($name, $value) { * @throws \CiviCRM_API3_Exception */ protected function assignFieldMetadataToTemplate($entity) { - $fields = civicrm_api3($entity, 'getfields', array('action' => 'get')); - $dateFields = array(); + $fields = civicrm_api3($entity, 'getfields', ['action' => 'get']); + $dateFields = []; foreach ($fields['values'] as $fieldName => $fieldMetaData) { if (isset($fieldMetaData['html']) && CRM_Utils_Array::value('type', $fieldMetaData['html']) == 'Select Date') { $dateFields[$fieldName] = CRM_Utils_Date::addDateMetadataToField($fieldMetaData, $fieldMetaData); diff --git a/CRM/Core/Page/AJAX.php b/CRM/Core/Page/AJAX.php index a51f0ad3e4fb..2f11ee1c9d6f 100644 --- a/CRM/Core/Page/AJAX.php +++ b/CRM/Core/Page/AJAX.php @@ -50,7 +50,7 @@ public static function run() { } if (!$className) { - CRM_Core_Error::fatal(ts('Invalid className: %1', array(1 => $className))); + CRM_Core_Error::fatal(ts('Invalid className: %1', [1 => $className])); } $fnName = NULL; @@ -64,7 +64,7 @@ public static function run() { switch ($type) { case 'method': - call_user_func(array($className, $fnName)); + call_user_func([$className, $fnName]); break; case 'page': @@ -102,7 +102,7 @@ public static function setIsQuickConfig() { // return false if $id is null and // $context is not civicrm_event or civicrm_contribution_page - if (!$id || !in_array($context, array('civicrm_event', 'civicrm_contribution_page'))) { + if (!$id || !in_array($context, ['civicrm_event', 'civicrm_contribution_page'])) { return FALSE; } $priceSetId = CRM_Price_BAO_PriceSet::getFor($context, $id, NULL); @@ -113,7 +113,7 @@ public static function setIsQuickConfig() { INNER JOIN {$context} ce ON cpse.entity_id = ce.id AND ce.id = %1 SET cps.is_quick_config = 0, cps.financial_type_id = IF(cps.financial_type_id IS NULL, ce.financial_type_id, cps.financial_type_id) "; - CRM_Core_DAO::executeQuery($sql, array(1 => array($id, 'Integer'))); + CRM_Core_DAO::executeQuery($sql, [1 => [$id, 'Integer']]); if ($context == 'civicrm_event') { CRM_Core_BAO_Discount::del($id, $context); @@ -168,15 +168,15 @@ public static function checkAuthz($type, $className, $fnName = NULL) { public static function returnJsonResponse($response) { // Allow lazy callers to not wrap content in an array if (is_string($response)) { - $response = array('content' => $response); + $response = ['content' => $response]; } // Add session variables to response $session = CRM_Core_Session::singleton(); - $response += array( + $response += [ 'status' => 'success', 'userContext' => htmlspecialchars_decode($session->readUserContext()), 'title' => CRM_Utils_System::$title, - ); + ]; // crmMessages will be automatically handled by our ajax preprocessor // @see js/Common.js if ($session->getStatus(FALSE)) { @@ -222,11 +222,11 @@ public static function setJsHeaders($ttl = NULL) { * @return array */ public static function defaultSortAndPagerParams($defaultOffset = 0, $defaultRowCount = 25, $defaultSort = NULL, $defaultsortOrder = 'asc') { - $params = array( - '_raw_values' => array(), - ); + $params = [ + '_raw_values' => [], + ]; - $sortMapper = array(); + $sortMapper = []; if (isset($_GET['columns'])) { foreach ($_GET['columns'] as $key => $value) { $sortMapper[$key] = CRM_Utils_Type::validate($value['data'], 'MysqlColumnNameOrAlias'); @@ -261,8 +261,8 @@ public static function defaultSortAndPagerParams($defaultOffset = 0, $defaultRow * * @return array */ - public static function validateParams($requiredParams = array(), $optionalParams = array()) { - $params = array(); + public static function validateParams($requiredParams = [], $optionalParams = []) { + $params = []; foreach ($requiredParams as $param => $type) { $params[$param] = CRM_Utils_Type::validate(CRM_Utils_Array::value($param, $_GET), $type); diff --git a/CRM/Core/Page/AJAX/Attachment.php b/CRM/Core/Page/AJAX/Attachment.php index fe71fd8f8235..f06559285e42 100644 --- a/CRM/Core/Page/AJAX/Attachment.php +++ b/CRM/Core/Page/AJAX/Attachment.php @@ -62,18 +62,18 @@ public static function attachFile() { */ public static function _attachFile($post, $files, $server) { $config = CRM_Core_Config::singleton(); - $results = array(); + $results = []; foreach ($files as $key => $file) { if (!$config->debug && !self::checkToken($post['crm_attachment_token'])) { require_once 'api/v3/utils.php'; $results[$key] = civicrm_api3_create_error("SECURITY ALERT: Attaching files via AJAX requires a recent, valid token.", - array( + [ 'IP' => $server['REMOTE_ADDR'], 'level' => 'security', 'referer' => $server['HTTP_REFERER'], 'reason' => 'CSRF suspected', - ) + ] ); } elseif ($file['error']) { @@ -85,14 +85,14 @@ public static function _attachFile($post, $files, $server) { // We want check_permissions=1 while creating the DB record and check_permissions=0 while moving upload, // so split the work across two api calls. - $params = array(); + $params = []; if (isset($file['name'])) { $params['name'] = $file['name']; } if (isset($file['type'])) { $params['mime_type'] = $file['type']; } - foreach (array('entity_table', 'entity_id', 'description') as $field) { + foreach (['entity_table', 'entity_id', 'description'] as $field) { if (isset($post[$field])) { $params[$field] = $post[$field]; } @@ -103,12 +103,12 @@ public static function _attachFile($post, $files, $server) { $results[$key] = civicrm_api('Attachment', 'create', $params); if (!$results[$key]['is_error']) { - $moveParams = array( + $moveParams = [ 'id' => $results[$key]['id'], 'version' => 3, 'options.move-file' => $file['tmp_name'], // note: in this second call, check_permissions==false - ); + ]; $moveResult = civicrm_api('Attachment', 'create', $moveParams); if ($moveResult['is_error']) { $results[$key] = $moveResult; @@ -149,12 +149,12 @@ public static function sendResponse($result) { * @return string */ public static function createToken() { - $signer = new CRM_Utils_Signer(CRM_Core_Key::privateKey(), array('for', 'ts')); + $signer = new CRM_Utils_Signer(CRM_Core_Key::privateKey(), ['for', 'ts']); $ts = CRM_Utils_Time::getTimeRaw(); - return $signer->sign(array( + return $signer->sign([ 'for' => 'crmAttachment', 'ts' => $ts, - )) . ';;;' . $ts; + ]) . ';;;' . $ts; } /** @@ -166,14 +166,14 @@ public static function createToken() { */ public static function checkToken($token) { list ($signature, $ts) = explode(';;;', $token); - $signer = new CRM_Utils_Signer(CRM_Core_Key::privateKey(), array('for', 'ts')); + $signer = new CRM_Utils_Signer(CRM_Core_Key::privateKey(), ['for', 'ts']); if (!is_numeric($ts) || CRM_Utils_Time::getTimeRaw() > $ts + self::ATTACHMENT_TOKEN_TTL) { return FALSE; } - return $signer->validate($signature, array( + return $signer->validate($signature, [ 'for' => 'crmAttachment', 'ts' => $ts, - )); + ]); } } diff --git a/CRM/Core/Page/AJAX/Location.php b/CRM/Core/Page/AJAX/Location.php index ecaff14078c1..04066e4bd166 100644 --- a/CRM/Core/Page/AJAX/Location.php +++ b/CRM/Core/Page/AJAX/Location.php @@ -63,8 +63,8 @@ public static function getPermissionedLocation() { CRM_Utils_System::civiExit(); } - $values = array(); - $entityBlock = array('contact_id' => $cid); + $values = []; + $entityBlock = ['contact_id' => $cid]; $location = CRM_Core_BAO_Location::getValues($entityBlock); $config = CRM_Core_Config::singleton(); @@ -79,30 +79,30 @@ public static function getPermissionedLocation() { if (is_array($values) && !empty($values)) { $locType = $values[1]['location_type_id']; if ($fld == 'email') { - $elements["onbehalf_{$fld}-{$locType}"] = array( + $elements["onbehalf_{$fld}-{$locType}"] = [ 'type' => 'Text', 'value' => $location[$fld][1][$fld], - ); + ]; unset($profileFields["{$fld}-{$locType}"]); } elseif ($fld == 'phone') { $phoneTypeId = $values[1]['phone_type_id']; - $elements["onbehalf_{$fld}-{$locType}-{$phoneTypeId}"] = array( + $elements["onbehalf_{$fld}-{$locType}-{$phoneTypeId}"] = [ 'type' => 'Text', 'value' => $location[$fld][1][$fld], - ); + ]; unset($profileFields["{$fld}-{$locType}-{$phoneTypeId}"]); } elseif ($fld == 'im') { $providerId = $values[1]['provider_id']; - $elements["onbehalf_{$fld}-{$locType}"] = array( + $elements["onbehalf_{$fld}-{$locType}"] = [ 'type' => 'Text', 'value' => $location[$fld][1][$fld], - ); - $elements["onbehalf_{$fld}-{$locType}provider_id"] = array( + ]; + $elements["onbehalf_{$fld}-{$locType}provider_id"] = [ 'type' => 'Select', 'value' => $location[$fld][1]['provider_id'], - ); + ]; unset($profileFields["{$fld}-{$locType}-{$providerId}"]); } } @@ -111,20 +111,20 @@ public static function getPermissionedLocation() { if (!empty($website)) { foreach ($website as $key => $val) { $websiteTypeId = $values[1]['website_type_id']; - $elements["onbehalf_url-1"] = array( + $elements["onbehalf_url-1"] = [ 'type' => 'Text', 'value' => $website[1]['url'], - ); - $elements["onbehalf_url-1-website_type_id"] = array( + ]; + $elements["onbehalf_url-1-website_type_id"] = [ 'type' => 'Select', 'value' => $website[1]['website_type_id'], - ); + ]; unset($profileFields["url-1"]); } } $locTypeId = isset($location['address'][1]) ? $location['address'][1]['location_type_id'] : NULL; - $addressFields = array( + $addressFields = [ 'street_address', 'supplemental_address_1', 'supplemental_address_2', @@ -134,27 +134,27 @@ public static function getPermissionedLocation() { 'county', 'state_province', 'country', - ); + ]; foreach ($addressFields as $field) { if (array_key_exists($field, $addressSequence)) { $addField = $field; $type = 'Text'; - if (in_array($field, array('state_province', 'country', 'county'))) { + if (in_array($field, ['state_province', 'country', 'county'])) { $addField = "{$field}_id"; $type = 'Select'; } - $elements["onbehalf_{$field}-{$locTypeId}"] = array( + $elements["onbehalf_{$field}-{$locTypeId}"] = [ 'type' => $type, 'value' => isset($location['address'][1]) ? CRM_Utils_Array::value($addField, $location['address'][1]) : NULL, - ); + ]; unset($profileFields["{$field}-{$locTypeId}"]); } } //set custom field defaults - $defaults = array(); + $defaults = []; CRM_Core_BAO_UFGroup::setProfileDefaults($cid, $profileFields, $defaults, TRUE, NULL, NULL, TRUE); if (!empty($defaults)) { @@ -210,32 +210,32 @@ public static function getLocBlock() { // i wish i could retrieve loc block info based on loc_block_id, // Anyway, lets retrieve an event which has loc_block_id set to 'lbid'. if ($_REQUEST['lbid']) { - $params = array('1' => array($_REQUEST['lbid'], 'Integer')); + $params = ['1' => [$_REQUEST['lbid'], 'Integer']]; $eventId = CRM_Core_DAO::singleValueQuery('SELECT id FROM civicrm_event WHERE loc_block_id=%1 LIMIT 1', $params); } // now lets use the event-id obtained above, to retrieve loc block information. if ($eventId) { - $params = array('entity_id' => $eventId, 'entity_table' => 'civicrm_event'); + $params = ['entity_id' => $eventId, 'entity_table' => 'civicrm_event']; // second parameter is of no use, but since required, lets use the same variable. $location = CRM_Core_BAO_Location::getValues($params, $params); } - $result = array(); + $result = []; $addressOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'address_options', TRUE, NULL, TRUE ); // lets output only required fields. foreach ($addressOptions as $element => $isSet) { - if ($isSet && (!in_array($element, array( + if ($isSet && (!in_array($element, [ 'im', 'openid', - ))) + ])) ) { - if (in_array($element, array( + if (in_array($element, [ 'country', 'state_province', 'county', - ))) { + ])) { $element .= '_id'; } elseif ($element == 'address_name') { @@ -244,29 +244,29 @@ public static function getLocBlock() { $fld = "address[1][{$element}]"; $value = CRM_Utils_Array::value($element, $location['address'][1]); $value = $value ? $value : ""; - $result[str_replace(array( + $result[str_replace([ '][', '[', "]", - ), array('_', '_', ''), $fld)] = $value; + ], ['_', '_', ''], $fld)] = $value; } } - foreach (array( + foreach ([ 'email', 'phone_type_id', 'phone', - ) as $element) { + ] as $element) { $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 = $value ? $value : ""; - $result[str_replace(array( + $result[str_replace([ '][', '[', "]", - ), array('_', '_', ''), $fld)] = $value; + ], ['_', '_', ''], $fld)] = $value; } } diff --git a/CRM/Core/Page/AJAX/RecurringEntity.php b/CRM/Core/Page/AJAX/RecurringEntity.php index f091bf479508..198b22c33ed0 100644 --- a/CRM/Core/Page/AJAX/RecurringEntity.php +++ b/CRM/Core/Page/AJAX/RecurringEntity.php @@ -13,7 +13,7 @@ class CRM_Core_Page_AJAX_RecurringEntity { public static function updateMode() { - $finalResult = array(); + $finalResult = []; if (CRM_Utils_Array::value('mode', $_REQUEST) && CRM_Utils_Array::value('entityId', $_REQUEST) && CRM_Utils_Array::value('entityTable', $_REQUEST)) { $mode = CRM_Utils_Type::escape($_REQUEST['mode'], 'Integer'); $entityId = CRM_Utils_Type::escape($_REQUEST['entityId'], 'Integer'); diff --git a/CRM/Core/Page/Basic.php b/CRM/Core/Page/Basic.php index 27d4cbdf364a..aeeaa199f3e6 100644 --- a/CRM/Core/Page/Basic.php +++ b/CRM/Core/Page/Basic.php @@ -222,7 +222,7 @@ public function browse() { $baoString = $this->getBAOName(); $object = new $baoString(); - $values = array(); + $values = []; // lets make sure we get the stuff sorted by name if it exists $fields = &$object->fields(); @@ -257,7 +257,7 @@ public function browse() { $permission = $this->checkPermission($object->id, $object->$key); } if ($permission) { - $values[$object->id] = array(); + $values[$object->id] = []; CRM_Core_DAO::storeValues($object, $values[$object->id]); if (is_a($object, 'CRM_Contact_DAO_RelationshipType')) { @@ -305,11 +305,11 @@ public function action(&$object, $action, &$values, &$links, $permission, $force $newAction = $action; $hasDelete = $hasDisable = TRUE; - if (!empty($values['name']) && in_array($values['name'], array( + if (!empty($values['name']) && in_array($values['name'], [ 'encounter_medium', 'case_type', 'case_status', - ))) { + ])) { static $caseCount = NULL; if (!isset($caseCount)) { $caseCount = CRM_Case_BAO_Case::caseCount(NULL, FALSE); @@ -326,11 +326,11 @@ public function action(&$object, $action, &$values, &$links, $permission, $force $values['class'] = 'reserved'; // check if object is relationship type - $exceptions = array( + $exceptions = [ 'CRM_Contact_BAO_RelationshipType', 'CRM_Core_BAO_LocationType', 'CRM_Badge_BAO_Layout', - ); + ]; if (in_array($object_type, $exceptions)) { $newAction = CRM_Core_Action::VIEW + CRM_Core_Action::UPDATE; @@ -356,7 +356,7 @@ public function action(&$object, $action, &$values, &$links, $permission, $force } //CRM-4418, handling edit and delete separately. - $permissions = array($permission); + $permissions = [$permission]; if ($hasDelete && ($permission == CRM_Core_Permission::EDIT)) { //previously delete was subset of edit //so for consistency lets grant delete also. diff --git a/CRM/Core/Page/QUnit.php b/CRM/Core/Page/QUnit.php index 5920d7779c61..ae1c90c3441a 100644 --- a/CRM/Core/Page/QUnit.php +++ b/CRM/Core/Page/QUnit.php @@ -43,7 +43,7 @@ public function run() { CRM_Core_Resources::singleton()->addScriptFile($ext, "tests/qunit/$suite/test.js", 1000, 'html-header'); } - CRM_Utils_System::setTitle(ts('QUnit: %2 (%1)', array(1 => $ext, 2 => $suite))); + CRM_Utils_System::setTitle(ts('QUnit: %2 (%1)', [1 => $ext, 2 => $suite])); CRM_Core_Resources::singleton() ->addScriptFile('civicrm', 'bower_components/qunit/qunit/qunit.js', 1, 'html-header') ->addStyleFile('civicrm', 'bower_components/qunit/qunit/qunit.css', 1, 'html-header'); @@ -64,13 +64,13 @@ public function getRequestExtAndSuite() { && isset($arg[3]) && isset($arg[4]) ) { - return array( + return [ trim(CRM_Utils_Type::escape($arg[3], 'String'), '/'), trim(CRM_Utils_Type::escape($arg[4], 'String'), '/'), - ); + ]; } else { - return array(NULL, NULL); + return [NULL, NULL]; } } diff --git a/CRM/Core/Page/RecurringEntityPreview.php b/CRM/Core/Page/RecurringEntityPreview.php index e3cfb4392116..e2505f6a6f10 100644 --- a/CRM/Core/Page/RecurringEntityPreview.php +++ b/CRM/Core/Page/RecurringEntityPreview.php @@ -37,7 +37,7 @@ class CRM_Core_Page_RecurringEntityPreview extends CRM_Core_Page { */ public function run() { $parentEntityId = $startDate = $endDate = NULL; - $dates = $original = array(); + $dates = $original = []; $formValues = $_REQUEST; if (!empty($formValues['entity_table'])) { $startDateColumnName = CRM_Core_BAO_RecurringEntity::$_dateColumns[$formValues['entity_table']]['dateColumns'][0]; @@ -71,11 +71,11 @@ public function run() { if (CRM_Utils_Array::value('intervalDateColumns', CRM_Core_BAO_RecurringEntity::$_dateColumns[$formValues['entity_table']])) { if ($endDate) { $interval = $recursion->getInterval($startDate, $endDate); - $recursion->intervalDateColumns = array($endDateColumnName => $interval); + $recursion->intervalDateColumns = [$endDateColumnName => $interval]; } } - $dates = array_merge(array($original), $recursion->generateRecursiveDates()); + $dates = array_merge([$original], $recursion->generateRecursiveDates()); foreach ($dates as $key => &$value) { if ($startDateColumnName) { diff --git a/CRM/Core/Page/Redirect.php b/CRM/Core/Page/Redirect.php index 98b24af9f793..90be62a20bc2 100644 --- a/CRM/Core/Page/Redirect.php +++ b/CRM/Core/Page/Redirect.php @@ -19,7 +19,7 @@ class CRM_Core_Page_Redirect extends CRM_Core_Page { * @param string $path * @param array $pageArgs */ - public function run($path = NULL, $pageArgs = array()) { + public function run($path = NULL, $pageArgs = []) { $url = self::createUrl($path, $_REQUEST, $pageArgs, TRUE); CRM_Utils_System::redirect($url); } @@ -41,7 +41,7 @@ public static function createUrl($requestPath, $requestArgs, $pageArgs, $absolut CRM_Core_Error::fatal('This page is configured as a redirect, but it does not have a target.'); } - $vars = array(); + $vars = []; // note: %% isn't legal in a well-formed URL, so it's not a bad variable-delimiter foreach ($requestPath as $pathPos => $pathPart) { $vars["%%{$pathPos}%%"] = urlencode($pathPart); diff --git a/CRM/Core/Payment/AuthorizeNet.php b/CRM/Core/Payment/AuthorizeNet.php index 3a6479cf4495..0d39e192ac7b 100644 --- a/CRM/Core/Payment/AuthorizeNet.php +++ b/CRM/Core/Payment/AuthorizeNet.php @@ -28,7 +28,7 @@ class CRM_Core_Payment_AuthorizeNet extends CRM_Core_Payment { protected $_mode = NULL; - protected $_params = array(); + protected $_params = []; /** * We only need one instance of this object. So we use the singleton @@ -126,7 +126,7 @@ public function doDirectPayment(&$params) { return $params; } - $postFields = array(); + $postFields = []; $authorizeNetFields = $this->_getAuthorizeNetFields(); // Set up our call for hook_civicrm_paymentProcessor, @@ -198,7 +198,7 @@ public function doDirectPayment(&$params) { // fix for CRM-2566 if (($this->_mode == 'test') || $response_fields[6] == 0) { $query = "SELECT MAX(trxn_id) FROM civicrm_contribution WHERE trxn_id RLIKE 'test[0-9]+'"; - $p = array(); + $p = []; $trxn_id = strval(CRM_Core_DAO::singleValueQuery($query, $p)); $trxn_id = str_replace('test', '', $trxn_id); $trxn_id = intval($trxn_id) + 1; @@ -321,7 +321,7 @@ public function doRecurPayment() { return self::error(9002, 'Could not initiate connection to payment gateway'); } curl_setopt($submit, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($submit, CURLOPT_HTTPHEADER, array("Content-Type: text/xml")); + curl_setopt($submit, CURLOPT_HTTPHEADER, ["Content-Type: text/xml"]); curl_setopt($submit, CURLOPT_HEADER, 1); curl_setopt($submit, CURLOPT_POSTFIELDS, $arbXML); curl_setopt($submit, CURLOPT_POST, 1); @@ -359,7 +359,7 @@ public function _getAuthorizeNetFields() { if (empty($amount)) {//CRM-9894 would this ever be the case?? $amount = $this->_getParam('amount'); } - $fields = array(); + $fields = []; $fields['x_login'] = $this->_getParam('apiLogin'); $fields['x_tran_key'] = $this->_getParam('paymentKey'); $fields['x_email_customer'] = $this->_getParam('emailCustomer'); @@ -462,10 +462,10 @@ public function explode_csv($data) { $data = trim($data); //make it easier to parse fields with quotes in them $data = str_replace('""', "''", $data); - $fields = array(); + $fields = []; while ($data != '') { - $matches = array(); + $matches = []; if ($data[0] == '"') { // handle quoted fields preg_match('/^"(([^"]|\\")*?)",?(.*)$/', $data, $matches); @@ -501,13 +501,13 @@ public function _parseArbReturn($content) { $code = $this->_substring_between($content, '', ''); $text = $this->_substring_between($content, '', ''); $subscriptionId = $this->_substring_between($content, '', ''); - return array( + return [ 'refId' => $refId, 'resultCode' => $resultCode, 'code' => $code, 'text' => $text, 'subscriptionId' => $subscriptionId, - ); + ]; } /** @@ -547,7 +547,7 @@ public function _substring_between(&$haystack, $start, $end) { public function _getParam($field, $xmlSafe = FALSE) { $value = CRM_Utils_Array::value($field, $this->_params, ''); if ($xmlSafe) { - $value = str_replace(array('&', '"', "'", '<', '>'), '', $value); + $value = str_replace(['&', '"', "'", '<', '>'], '', $value); } return $value; } @@ -561,10 +561,10 @@ public function _getParam($field, $xmlSafe = FALSE) { public function &error($errorCode = NULL, $errorMessage = NULL) { $e = CRM_Core_Error::singleton(); if ($errorCode) { - $e->push($errorCode, 0, array(), $errorMessage); + $e->push($errorCode, 0, [], $errorMessage); } else { - $e->push(9001, 0, array(), 'Unknown System Error.'); + $e->push(9001, 0, [], 'Unknown System Error.'); } return $e; } @@ -595,7 +595,7 @@ public function _setParam($field, $value) { * the error message if any */ public function checkConfig() { - $error = array(); + $error = []; if (empty($this->_paymentProcessor['user_name'])) { $error[] = ts('APILogin is not set for this payment processor'); } @@ -625,7 +625,7 @@ public function accountLoginURL() { * * @return bool|object */ - public function cancelSubscription(&$message = '', $params = array()) { + public function cancelSubscription(&$message = '', $params = []) { $template = CRM_Core_Smarty::singleton(); $template->assign('subscriptionType', 'cancel'); @@ -643,7 +643,7 @@ public function cancelSubscription(&$message = '', $params = array()) { } curl_setopt($submit, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($submit, CURLOPT_HTTPHEADER, array("Content-Type: text/xml")); + curl_setopt($submit, CURLOPT_HTTPHEADER, ["Content-Type: text/xml"]); curl_setopt($submit, CURLOPT_HEADER, 1); curl_setopt($submit, CURLOPT_POSTFIELDS, $arbXML); curl_setopt($submit, CURLOPT_POST, 1); @@ -672,7 +672,7 @@ public function cancelSubscription(&$message = '', $params = array()) { * * @return bool|object */ - public function updateSubscriptionBillingInfo(&$message = '', $params = array()) { + public function updateSubscriptionBillingInfo(&$message = '', $params = []) { $template = CRM_Core_Smarty::singleton(); $template->assign('subscriptionType', 'updateBilling'); @@ -702,7 +702,7 @@ public function updateSubscriptionBillingInfo(&$message = '', $params = array()) } curl_setopt($submit, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($submit, CURLOPT_HTTPHEADER, array("Content-Type: text/xml")); + curl_setopt($submit, CURLOPT_HTTPHEADER, ["Content-Type: text/xml"]); curl_setopt($submit, CURLOPT_HEADER, 1); curl_setopt($submit, CURLOPT_POSTFIELDS, $arbXML); curl_setopt($submit, CURLOPT_POST, 1); @@ -739,7 +739,7 @@ static public function handlePaymentNotification() { * * @return bool|object */ - public function changeSubscriptionAmount(&$message = '', $params = array()) { + public function changeSubscriptionAmount(&$message = '', $params = []) { $template = CRM_Core_Smarty::singleton(); $template->assign('subscriptionType', 'update'); @@ -764,7 +764,7 @@ public function changeSubscriptionAmount(&$message = '', $params = array()) { } curl_setopt($submit, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($submit, CURLOPT_HTTPHEADER, array("Content-Type: text/xml")); + curl_setopt($submit, CURLOPT_HTTPHEADER, ["Content-Type: text/xml"]); curl_setopt($submit, CURLOPT_HEADER, 1); curl_setopt($submit, CURLOPT_POSTFIELDS, $arbXML); curl_setopt($submit, CURLOPT_POST, 1); diff --git a/CRM/Core/Payment/AuthorizeNetIPN.php b/CRM/Core/Payment/AuthorizeNetIPN.php index 8455449c8da0..b68bd8cf2ccb 100644 --- a/CRM/Core/Payment/AuthorizeNetIPN.php +++ b/CRM/Core/Payment/AuthorizeNetIPN.php @@ -55,7 +55,7 @@ public function main($component = 'contribute') { //we only get invoice num as a key player from payment gateway response. //for ARB we get x_subscription_id and x_subscription_paynum $x_subscription_id = $this->retrieve('x_subscription_id', 'String'); - $ids = $objects = $input = array(); + $ids = $objects = $input = []; if ($x_subscription_id) { // Presence of the id means it is approved. @@ -81,19 +81,19 @@ public function main($component = 'contribute') { $paymentProcessorTypeID = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_PaymentProcessorType', 'AuthNet', 'id', 'name' ); - $paymentProcessorID = (int) civicrm_api3('PaymentProcessor', 'getvalue', array( + $paymentProcessorID = (int) civicrm_api3('PaymentProcessor', 'getvalue', [ 'is_test' => 0, - 'options' => array('limit' => 1), + 'options' => ['limit' => 1], 'payment_processor_type_id' => $paymentProcessorTypeID, 'return' => 'id', - )); + ]); } if (!$this->validateData($input, $ids, $objects, TRUE, $paymentProcessorID)) { return FALSE; } if (!empty($ids['paymentProcessor']) && $objects['contributionRecur']->payment_processor_id != $ids['paymentProcessor']) { - Civi::log()->warning('Payment Processor does not match the recurring processor id.', array('civi.tag' => 'deprecated')); + Civi::log()->warning('Payment Processor does not match the recurring processor id.', ['civi.tag' => 'deprecated']); } if ($component == 'contribute' && $ids['contributionRecur']) { @@ -135,7 +135,7 @@ public function recur(&$input, &$ids, &$objects, $first) { $now = date('YmdHis'); // fix dates that already exist - $dates = array('create_date', 'start_date', 'end_date', 'cancel_date', 'modified_date'); + $dates = ['create_date', 'start_date', 'end_date', 'cancel_date', 'modified_date']; foreach ($dates as $name) { if ($recur->$name) { $recur->$name = CRM_Utils_Date::isoToMysql($recur->$name); @@ -192,7 +192,7 @@ public function recur(&$input, &$ids, &$objects, $first) { $recur->cancel_date = $now; $recur->save(); - $message = ts("Subscription payment failed - %1", array(1 => htmlspecialchars($input['response_reason_text']))); + $message = ts("Subscription payment failed - %1", [1 => htmlspecialchars($input['response_reason_text'])]); CRM_Core_Error::debug_log_message($message); // the recurring contribution has declined a payment or has failed @@ -257,7 +257,7 @@ public function getInput(&$input, &$ids) { return FALSE; } $billingID = $ids['billing']; - $params = array( + $params = [ 'first_name' => 'x_first_name', 'last_name' => 'x_last_name', "street_address-{$billingID}" => 'x_address', @@ -266,7 +266,7 @@ public function getInput(&$input, &$ids) { "postal_code-{$billingID}" => 'x_zip', "country-{$billingID}" => 'x_country', "email-{$billingID}" => 'x_email', - ); + ]; foreach ($params as $civiName => $resName) { $input[$civiName] = $this->retrieve($resName, 'String', FALSE); } @@ -296,14 +296,14 @@ public function getIDs(&$ids, &$input) { $contRecur->fetch(); $ids['contributionRecur'] = $contRecur->id; if ($ids['contact'] != $contRecur->contact_id) { - $message = ts("Recurring contribution appears to have been re-assigned from id %1 to %2, continuing with %2.", array(1 => $ids['contact'], 2 => $contRecur->contact_id)); + $message = ts("Recurring contribution appears to have been re-assigned from id %1 to %2, continuing with %2.", [1 => $ids['contact'], 2 => $contRecur->contact_id]); CRM_Core_Error::debug_log_message($message); $ids['contact'] = $contRecur->contact_id; } if (!$ids['contributionRecur']) { $message = ts("Could not find contributionRecur id"); $log = new CRM_Utils_SystemLogger(); - $log->error('payment_notification', array('message' => $message, 'ids' => $ids, 'input' => $input)); + $log->error('payment_notification', ['message' => $message, 'ids' => $ids, 'input' => $input]); throw new CRM_Core_Exception($message); } diff --git a/CRM/Core/Payment/BaseIPN.php b/CRM/Core/Payment/BaseIPN.php index 9dd044fc365d..e538c84ecd05 100644 --- a/CRM/Core/Payment/BaseIPN.php +++ b/CRM/Core/Payment/BaseIPN.php @@ -37,7 +37,7 @@ class CRM_Core_Payment_BaseIPN { * the code does not need to keep retrieving from the http request * @var array */ - protected $_inputParameters = array(); + protected $_inputParameters = []; /** * Only used by AuthorizeNetIPN. @@ -164,10 +164,10 @@ public function loadObjects(&$input, &$ids, &$objects, $required, $paymentProces // default options are that we log an error & echo it out // note that we should refactor this error handling into error code @ some point // but for now setting up enough separation so we can do unit tests - $error_handling = array( + $error_handling = [ 'log_error' => 1, 'echo_error' => 1, - ); + ]; } $ids['paymentProcessor'] = $paymentProcessorID; if (is_a($objects['contribution'], 'CRM_Contribute_BAO_Contribution')) { @@ -195,10 +195,10 @@ public function loadObjects(&$input, &$ids, &$objects, $required, $paymentProces echo $e->getMessage(); } if (!empty($error_handling['return_error'])) { - return array( + return [ 'is_error' => 1, 'error_message' => ($e->getMessage()), - ); + ]; } } $objects = array_merge($objects, $contribution->_relatedObjects); @@ -214,13 +214,13 @@ public function loadObjects(&$input, &$ids, &$objects, $required, $paymentProces * * @return bool */ - public function failed(&$objects, &$transaction, $input = array()) { + public function failed(&$objects, &$transaction, $input = []) { $contribution = &$objects['contribution']; - $memberships = array(); + $memberships = []; if (!empty($objects['membership'])) { $memberships = &$objects['membership']; if (is_numeric($memberships)) { - $memberships = array($objects['membership']); + $memberships = [$objects['membership']]; } } @@ -231,10 +231,10 @@ public function failed(&$objects, &$transaction, $input = array()) { $participant = &$objects['participant']; // CRM-15546 - $contributionStatuses = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'contribution_status_id', array( + $contributionStatuses = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'contribution_status_id', [ 'labelColumn' => 'name', 'flip' => 1, - )); + ]); $contribution->receive_date = CRM_Utils_Date::isoToMysql($contribution->receive_date); $contribution->receipt_date = CRM_Utils_Date::isoToMysql($contribution->receipt_date); $contribution->thankyou_date = CRM_Utils_Date::isoToMysql($contribution->thankyou_date); @@ -256,17 +256,17 @@ public function failed(&$objects, &$transaction, $input = array()) { if (empty($input['IAmAHorribleNastyBeyondExcusableHackInTheCRMEventFORMTaskClassThatNeedsToBERemoved'])) { if (!empty($memberships)) { // if transaction is failed then set "Cancelled" as membership status - $membershipStatuses = CRM_Core_PseudoConstant::get('CRM_Member_DAO_Membership', 'status_id', array( + $membershipStatuses = CRM_Core_PseudoConstant::get('CRM_Member_DAO_Membership', 'status_id', [ 'labelColumn' => 'name', 'flip' => 1, - )); + ]); foreach ($memberships as $membership) { if ($membership) { $membership->status_id = $membershipStatuses['Cancelled']; $membership->save(); //update related Memberships. - $params = array('status_id' => $membershipStatuses['Cancelled']); + $params = ['status_id' => $membershipStatuses['Cancelled']]; CRM_Member_BAO_Membership::updateRelatedMemberships($membership->id, $params); } } @@ -309,11 +309,11 @@ public function pending(&$objects, &$transaction) { * * @return bool */ - public function cancelled(&$objects, &$transaction, $input = array()) { + public function cancelled(&$objects, &$transaction, $input = []) { $contribution = &$objects['contribution']; $memberships = &$objects['membership']; if (is_numeric($memberships)) { - $memberships = array($objects['membership']); + $memberships = [$objects['membership']]; } $participant = &$objects['participant']; @@ -321,10 +321,10 @@ public function cancelled(&$objects, &$transaction, $input = array()) { if (empty($contribution->id)) { $addLineItems = TRUE; } - $contributionStatuses = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'contribution_status_id', array( + $contributionStatuses = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'contribution_status_id', [ 'labelColumn' => 'name', 'flip' => 1, - )); + ]); $contribution->contribution_status_id = $contributionStatuses['Cancelled']; $contribution->cancel_date = self::$_now; $contribution->cancel_reason = CRM_Utils_Array::value('reasonCode', $input); @@ -347,10 +347,10 @@ public function cancelled(&$objects, &$transaction, $input = array()) { if (empty($input['IAmAHorribleNastyBeyondExcusableHackInTheCRMEventFORMTaskClassThatNeedsToBERemoved'])) { if (!empty($memberships)) { - $membershipStatuses = CRM_Core_PseudoConstant::get('CRM_Member_DAO_Membership', 'status_id', array( + $membershipStatuses = CRM_Core_PseudoConstant::get('CRM_Member_DAO_Membership', 'status_id', [ 'labelColumn' => 'name', 'flip' => 1, - )); + ]); // Cancel only Pending memberships // CRM-18688 $pendingStatusId = $membershipStatuses['Pending']; @@ -360,7 +360,7 @@ public function cancelled(&$objects, &$transaction, $input = array()) { $membership->save(); //update related Memberships. - $params = array('status_id' => $membershipStatuses['Cancelled']); + $params = ['status_id' => $membershipStatuses['Cancelled']]; CRM_Member_BAO_Membership::updateRelatedMemberships($membership->id, $params); } } @@ -464,7 +464,7 @@ public function completeTransaction(&$input, &$ids, &$objects, &$transaction, $r public function getBillingID(&$ids) { $ids['billing'] = CRM_Core_BAO_LocationType::getBilling(); if (!$ids['billing']) { - CRM_Core_Error::debug_log_message(ts('Please set a location type of %1', array(1 => 'Billing'))); + CRM_Core_Error::debug_log_message(ts('Please set a location type of %1', [1 => 'Billing'])); echo "Failure: Could not find billing location type

    "; return FALSE; } diff --git a/CRM/Core/Payment/Dummy.php b/CRM/Core/Payment/Dummy.php index 92f932c273cc..1fdbd9cda340 100644 --- a/CRM/Core/Payment/Dummy.php +++ b/CRM/Core/Payment/Dummy.php @@ -22,8 +22,8 @@ class CRM_Core_Payment_Dummy extends CRM_Core_Payment { protected $_mode = NULL; - protected $_params = array(); - protected $_doDirectPaymentResult = array(); + protected $_params = []; + protected $_doDirectPaymentResult = []; /** * Set result from do Direct Payment for test purposes. @@ -34,7 +34,7 @@ class CRM_Core_Payment_Dummy extends CRM_Core_Payment { public function setDoDirectPaymentResult($doDirectPaymentResult) { $this->_doDirectPaymentResult = $doDirectPaymentResult; if (empty($this->_doDirectPaymentResult['trxn_id'])) { - $this->_doDirectPaymentResult['trxn_id'] = array(); + $this->_doDirectPaymentResult['trxn_id'] = []; } else { $this->_doDirectPaymentResult['trxn_id'] = (array) $doDirectPaymentResult['trxn_id']; @@ -104,7 +104,7 @@ public function doDirectPayment(&$params) { } if ($this->_mode == 'test') { $query = "SELECT MAX(trxn_id) FROM civicrm_contribution WHERE trxn_id LIKE 'test\\_%'"; - $p = array(); + $p = []; $trxn_id = strval(CRM_Core_Dao::singleValueQuery($query, $p)); $trxn_id = str_replace('test_', '', $trxn_id); $trxn_id = intval($trxn_id) + 1; @@ -112,7 +112,7 @@ public function doDirectPayment(&$params) { } else { $query = "SELECT MAX(trxn_id) FROM civicrm_contribution WHERE trxn_id LIKE 'live_%'"; - $p = array(); + $p = []; $trxn_id = strval(CRM_Core_Dao::singleValueQuery($query, $p)); $trxn_id = str_replace('live_', '', $trxn_id); $trxn_id = intval($trxn_id) + 1; @@ -214,7 +214,7 @@ public function checkConfig() { * @return array */ public function getEditableRecurringScheduleFields() { - return array('amount', 'next_sched_contribution_date'); + return ['amount', 'next_sched_contribution_date']; } /** @@ -223,7 +223,7 @@ public function getEditableRecurringScheduleFields() { * * @return bool|object */ - public function cancelSubscription(&$message = '', $params = array()) { + public function cancelSubscription(&$message = '', $params = []) { return TRUE; } diff --git a/CRM/Core/Payment/Elavon.php b/CRM/Core/Payment/Elavon.php index eef6b148295f..7b91ac425198 100644 --- a/CRM/Core/Payment/Elavon.php +++ b/CRM/Core/Payment/Elavon.php @@ -230,7 +230,7 @@ public function doDirectPayment(&$params) { if ($processorResponse['ssl_result_message'] == "APPROVED") { if ($this->_mode == 'test') { $query = "SELECT MAX(trxn_id) FROM civicrm_contribution WHERE trxn_id LIKE 'test%'"; - $p = array(); + $p = []; $trxn_id = strval(CRM_Core_Dao::singleValueQuery($query, $p)); $trxn_id = str_replace('test', '', $trxn_id); $trxn_id = intval($trxn_id) + 1; @@ -287,7 +287,7 @@ public function &errorExit($errorCode = NULL, $errorMessage = NULL) { * */ public function checkConfig() { - $errorMsg = array(); + $errorMsg = []; if (empty($this->_paymentProcessor['user_name'])) { $errorMsg[] = ' ' . ts('ssl_merchant_id is not set for this payment processor'); @@ -405,7 +405,7 @@ public function GetNodeValue($NodeName, &$strXML) { * @return mixed */ public function decodeXMLresponse($Xml) { - $processorResponse = array(); + $processorResponse = []; $processorResponse['ssl_result'] = self::GetNodeValue("ssl_result", $Xml); $processorResponse['ssl_result_message'] = self::GetNodeValue("ssl_result_message", $Xml); diff --git a/CRM/Core/Payment/FirstData.php b/CRM/Core/Payment/FirstData.php index 6af1f1cea298..38b0b2dc48b2 100644 --- a/CRM/Core/Payment/FirstData.php +++ b/CRM/Core/Payment/FirstData.php @@ -160,7 +160,7 @@ public function doDirectPayment(&$params) { } if (!defined('CURLOPT_SSLCERT')) { - CRM_Core_Error::fatal(ts('%1 - Gateway requires curl with SSL support', array(1 => $paymentProcessor))); + CRM_Core_Error::fatal(ts('%1 - Gateway requires curl with SSL support', [1 => $paymentProcessor])); } /********************************************************** @@ -346,7 +346,7 @@ public function &errorExit($errorCode = NULL, $errorMessage = NULL) { * CiviCRM V2.0 Declaration */ public function checkConfig() { - $errorMsg = array(); + $errorMsg = []; if (empty($this->_paymentProcessor['user_name'])) { $errorMsg[] = ts(' Store Name is not set for this payment processor'); diff --git a/CRM/Core/Payment/Form.php b/CRM/Core/Payment/Form.php index 112f441e8468..09b39a2362f0 100644 --- a/CRM/Core/Payment/Form.php +++ b/CRM/Core/Payment/Form.php @@ -56,7 +56,7 @@ class CRM_Core_Payment_Form { * ID of the payment processor. */ static public function setPaymentFieldsByProcessor(&$form, $processor, $billing_profile_id = NULL, $isBackOffice = FALSE, $paymentInstrumentID = NULL) { - $form->billingFieldSets = array(); + $form->billingFieldSets = []; // Load the pay-later processor // @todo load this right up where the other processors are loaded initially. if (empty($processor)) { @@ -75,7 +75,7 @@ static public function setPaymentFieldsByProcessor(&$form, $processor, $billing_ $form->assign('paymentFields', self::getPaymentFields($processor)); self::setBillingAddressFields($form, $processor); // @todo - this may be obsolete - although potentially it could be used to re-order things in the form. - $form->billingFieldSets['billing_name_address-group']['fields'] = array(); + $form->billingFieldSets['billing_name_address-group']['fields'] = []; } /** @@ -117,7 +117,7 @@ protected static function addCommonFields(&$form, $paymentFields) { foreach ($paymentFields as $name => $field) { $field['extra'] = isset($field['extra']) ? $field['extra'] : NULL; if ($field['htmlType'] == 'chainSelect') { - $form->addChainSelect($field['name'], array('required' => FALSE)); + $form->addChainSelect($field['name'], ['required' => FALSE]); } else { $form->add($field['htmlType'], @@ -345,7 +345,7 @@ public static function validateCreditCard($values, &$errors, $processorID = NULL * @param bool $reverse */ public static function mapParams($id, $src, &$dst, $reverse = FALSE) { - $map = array( + $map = [ 'first_name' => 'billing_first_name', 'middle_name' => 'billing_middle_name', 'last_name' => 'billing_last_name', @@ -357,7 +357,7 @@ public static function mapParams($id, $src, &$dst, $reverse = FALSE) { 'postal_code' => "billing_postal_code-$id", 'country' => "billing_country-$id", 'contactID' => 'contact_id', - ); + ]; foreach ($map as $n => $v) { if (!$reverse) { diff --git a/CRM/Core/Payment/Manual.php b/CRM/Core/Payment/Manual.php index 8798f5cce91b..5621d712800c 100644 --- a/CRM/Core/Payment/Manual.php +++ b/CRM/Core/Payment/Manual.php @@ -62,7 +62,7 @@ public function getBillingAddressFields($billingLocationID = NULL) { // @todo - use profile api to retrieve this - either as pseudo-profile or (better) set up billing // as a reserved profile in the DB and (even better) allow the profile to be selected // on the form instead of just 'billing for pay=later bool' - return array( + return [ 'first_name' => 'billing_first_name', 'middle_name' => 'billing_middle_name', 'last_name' => 'billing_last_name', @@ -71,10 +71,10 @@ public function getBillingAddressFields($billingLocationID = NULL) { 'country' => "billing_country_id-{$billingLocationID}", 'state_province' => "billing_state_province_id-{$billingLocationID}", 'postal_code' => "billing_postal_code-{$billingLocationID}", - ); + ]; } else { - return array(); + return []; } } @@ -85,17 +85,17 @@ public function getBillingAddressFields($billingLocationID = NULL) { */ public function getPaymentFormFields() { if (!$this->isBackOffice()) { - return array(); + return []; } $paymentInstrument = CRM_Core_PseudoConstant::getName('CRM_Contribute_BAO_Contribution', 'payment_instrument_id', $this->getPaymentInstrumentID()); if ($paymentInstrument === 'Credit Card') { - return array('credit_card_type', 'pan_truncation'); + return ['credit_card_type', 'pan_truncation']; } elseif ($paymentInstrument === 'Check') { - return array('check_number'); + return ['check_number']; } - return array(); + return []; } /** diff --git a/CRM/Core/Payment/PayJunction.php b/CRM/Core/Payment/PayJunction.php index 3b70daea0650..0dcbecf453ba 100644 --- a/CRM/Core/Payment/PayJunction.php +++ b/CRM/Core/Payment/PayJunction.php @@ -66,7 +66,7 @@ public function doDirectPayment(&$params) { $pjpgCustInfo->setEmail($params['email']); - $billing = array( + $billing = [ "logon" => $logon, "password" => $password, "url_site" => $url_site, @@ -77,7 +77,7 @@ public function doDirectPayment(&$params) { "province" => $params['state_province'], "postal_code" => $params['postal_code'], "country" => $params['country'], - ); + ]; $pjpgCustInfo->setBilling($billing); // create pjpgTransaction object @@ -85,7 +85,7 @@ public function doDirectPayment(&$params) { $expiry_string = sprintf('%04d%02d', $params['year'], $params['month']); - $txnArray = array( + $txnArray = [ 'type' => 'purchase', 'order_id' => $my_orderid, 'amount' => sprintf('%01.2f', $params['amount']), @@ -94,7 +94,7 @@ public function doDirectPayment(&$params) { 'crypt_type' => '7', 'cavv' => $params['cvv2'], 'cust_id' => $params['contact_id'], - ); + ]; // Allow further manipulation of params via custom hooks CRM_Utils_Hook::alterPaymentProcessorParams($this, $params, $txnArray); @@ -126,7 +126,7 @@ public function doDirectPayment(&$params) { $numRecurs = $params['installments']; - $recurArray = array( + $recurArray = [ 'dc_schedule_create' => $dc_schedule_create, // (day | week | month) 'recur_unit' => $recurUnit, @@ -137,7 +137,7 @@ public function doDirectPayment(&$params) { 'period' => $recurInterval, 'dc_schedule_start' => $dc_schedule_start, 'amount' => sprintf('%01.2f', $params['amount']), - ); + ]; $pjpgRecur = new pjpgRecur($recurArray); @@ -265,7 +265,7 @@ public function _setParam($field, $value) { * the error message if any */ public function checkConfig() { - $error = array(); + $error = []; if (empty($this->_paymentProcessor['user_name'])) { $error[] = ts('Username is not set for this payment processor'); } diff --git a/CRM/Core/Payment/PayPalIPN.php b/CRM/Core/Payment/PayPalIPN.php index 6af63aaeeec3..155fae1d5741 100644 --- a/CRM/Core/Payment/PayPalIPN.php +++ b/CRM/Core/Payment/PayPalIPN.php @@ -40,7 +40,7 @@ class CRM_Core_Payment_PayPalIPN extends CRM_Core_Payment_BaseIPN { * the code does not need to keep retrieving from the http request * @var array */ - protected $_inputParameters = array(); + protected $_inputParameters = []; /** * Constructor function. @@ -116,7 +116,7 @@ public function recur(&$input, &$ids, &$objects, $first) { $now = date('YmdHis'); // fix dates that already exist - $dates = array('create', 'start', 'end', 'cancel', 'modified'); + $dates = ['create', 'start', 'end', 'cancel', 'modified']; foreach ($dates as $date) { $name = "{$date}_date"; if ($recur->$name) { @@ -308,7 +308,7 @@ public function single(&$input, &$ids, &$objects, $recur = FALSE, $first = FALSE * @throws \CiviCRM_API3_Exception */ public function main() { - $objects = $ids = $input = array(); + $objects = $ids = $input = []; $component = $this->retrieve('module', 'String'); $input['component'] = $component; @@ -372,7 +372,7 @@ public function getInput(&$input, &$ids) { $input['reasonCode'] = $this->retrieve('ReasonCode', 'String', FALSE); $billingID = $ids['billing']; - $lookup = array( + $lookup = [ "first_name" => 'first_name', "last_name" => 'last_name', "street_address-{$billingID}" => 'address_street', @@ -380,7 +380,7 @@ public function getInput(&$input, &$ids) { "state-{$billingID}" => 'address_state', "postal_code-{$billingID}" => 'address_zip', "country-{$billingID}" => 'address_country_code', - ); + ]; foreach ($lookup as $name => $paypalName) { $value = $this->retrieve($paypalName, 'String', FALSE); $input[$name] = $value ? $value : NULL; @@ -424,10 +424,10 @@ public function getPayPalPaymentProcessorID($input, $ids) { // Then we try and get it from recurring contribution ID if (!empty($ids['contributionRecur'])) { - $contributionRecur = civicrm_api3('ContributionRecur', 'getsingle', array( + $contributionRecur = civicrm_api3('ContributionRecur', 'getsingle', [ 'id' => $ids['contributionRecur'], 'return' => ['payment_processor_id'], - )); + ]); if (!empty($contributionRecur['payment_processor_id'])) { return $contributionRecur['payment_processor_id']; } diff --git a/CRM/Core/Payment/PayPalImpl.php b/CRM/Core/Payment/PayPalImpl.php index a273bbcad77f..badb5e22eba6 100644 --- a/CRM/Core/Payment/PayPalImpl.php +++ b/CRM/Core/Payment/PayPalImpl.php @@ -148,15 +148,15 @@ public function buildForm(&$form) { if ($this->supportsPreApproval()) { $this->addPaypalExpressCode($form); if ($this->isPayPalType($this::PAYPAL_EXPRESS)) { - CRM_Core_Region::instance('billing-block-post')->add(array( + CRM_Core_Region::instance('billing-block-post')->add([ 'template' => 'CRM/Financial/Form/PaypalExpress.tpl', 'name' => 'paypal_express', - )); + ]); } if ($this->isPayPalType($this::PAYPAL_PRO)) { - CRM_Core_Region::instance('billing-block-pre')->add(array( + CRM_Core_Region::instance('billing-block-pre')->add([ 'template' => 'CRM/Financial/Form/PaypalPro.tpl', - )); + ]); } } return FALSE; @@ -193,7 +193,7 @@ protected function addPaypalExpressCode(&$form) { 'image', $form->_expressButtonName, $this->_paymentProcessor['url_button'], - array('class' => 'crm-form-submit') + ['class' => 'crm-form-submit'] ); } } @@ -245,7 +245,7 @@ public function validatePaymentInstrument($values, &$errors) { * @throws \Civi\Payment\Exception\PaymentProcessorException */ protected function setExpressCheckOut(&$params) { - $args = array(); + $args = []; $this->initialize($args, 'SetExpressCheckout'); @@ -292,7 +292,7 @@ protected function setExpressCheckOut(&$params) { * @throws \Civi\Payment\Exception\PaymentProcessorException */ public function getPreApprovalDetails($storedDetails) { - return empty($storedDetails['token']) ? array() : $this->getExpressCheckoutDetails($storedDetails['token']); + return empty($storedDetails['token']) ? [] : $this->getExpressCheckoutDetails($storedDetails['token']); } /** @@ -308,7 +308,7 @@ public function getPreApprovalDetails($storedDetails) { * @throws \Civi\Payment\Exception\PaymentProcessorException */ public function getExpressCheckoutDetails($token) { - $args = array(); + $args = []; $this->initialize($args, 'GetExpressCheckoutDetails'); $args['token'] = $token; @@ -322,7 +322,7 @@ public function getExpressCheckoutDetails($token) { } /* Success */ - $fieldMap = array( + $fieldMap = [ 'token' => 'token', 'payer_status' => 'payerstatus', 'payer_id' => 'payerid', @@ -335,7 +335,7 @@ public function getExpressCheckoutDetails($token) { 'postal_code' => 'shiptozip', 'state_province' => 'shiptostate', 'country' => 'shiptocountrycode', - ); + ]; return $this->mapPaypalParamsToCivicrmParams($fieldMap, $result); } @@ -356,7 +356,7 @@ public function doExpressCheckout(&$params) { if (!empty($params['is_recur'])) { return $this->createRecurringPayments($params); } - $args = array(); + $args = []; $this->initialize($args, 'DoExpressCheckoutPayment'); $args['token'] = $params['token']; @@ -411,7 +411,7 @@ public function doExpressCheckout(&$params) { * @throws \Exception */ public function createRecurringPayments(&$params) { - $args = array(); + $args = []; $this->initialize($args, 'CreateRecurringPaymentsProfile'); $start_time = strtotime(date('m/d/Y')); @@ -524,7 +524,7 @@ public function doPayment(&$params, $component = 'contribute') { * @throws \Civi\Payment\Exception\PaymentProcessorException */ public function doDirectPayment(&$params, $component = 'contribute') { - $args = array(); + $args = []; $this->initialize($args, 'DoDirectPayment'); @@ -619,20 +619,20 @@ public function doDirectPayment(&$params, $component = 'contribute') { public function doQuery($params) { //CRM-18140 - trxn_id not returned for recurring paypal transaction if (!empty($params['is_recur'])) { - return array(); + return []; } elseif (empty($params['trxn_id'])) { throw new \Civi\Payment\Exception\PaymentProcessorException('transaction id not set'); } - $args = array( + $args = [ 'TRANSACTIONID' => $params['trxn_id'], - ); + ]; $this->initialize($args, 'GetTransactionDetails'); $result = $this->invokeAPI($args); - return array( + return [ 'fee_amount' => $result['feeamt'], 'net_amount' => $params['gross_amount'] - $result['feeamt'], - ); + ]; } /** @@ -643,7 +643,7 @@ public function doQuery($params) { * @throws \Civi\Payment\Exception\PaymentProcessorException */ public function checkConfig() { - $error = array(); + $error = []; if (!$this->isPayPalType($this::PAYPAL_STANDARD)) { if (empty($this->_paymentProcessor['signature'])) { @@ -718,9 +718,9 @@ public function isSuppressSubmitButtons() { * @return array|bool|object * @throws \Civi\Payment\Exception\PaymentProcessorException */ - public function cancelSubscription(&$message = '', $params = array()) { + public function cancelSubscription(&$message = '', $params = []) { if ($this->isPayPalType($this::PAYPAL_PRO) || $this->isPayPalType($this::PAYPAL_EXPRESS)) { - $args = array(); + $args = []; $this->initialize($args, 'ManageRecurringPaymentsProfileStatus'); $args['PROFILEID'] = CRM_Utils_Array::value('subscriptionId', $params); @@ -750,11 +750,11 @@ static public function handlePaymentNotification() { if (is_numeric($lastParam)) { $params['processor_id'] = $lastParam; } - $result = civicrm_api3('PaymentProcessor', 'get', array( + $result = civicrm_api3('PaymentProcessor', 'get', [ 'sequential' => 1, 'id' => $params['processor_id'], - 'api.PaymentProcessorType.getvalue' => array('return' => "name"), - )); + 'api.PaymentProcessorType.getvalue' => ['return' => "name"], + ]); if (!$result['count']) { throw new CRM_Core_Exception("Could not find a processor with the given processor_id value '{$params['processor_id']}'."); } @@ -787,10 +787,10 @@ static public function handlePaymentNotification() { * @return array|bool|object * @throws \Civi\Payment\Exception\PaymentProcessorException */ - public function updateSubscriptionBillingInfo(&$message = '', $params = array()) { + public function updateSubscriptionBillingInfo(&$message = '', $params = []) { if ($this->isPayPalType($this::PAYPAL_PRO)) { $config = CRM_Core_Config::singleton(); - $args = array(); + $args = []; $this->initialize($args, 'UpdateRecurringPaymentsProfile'); $args['PROFILEID'] = $params['subscriptionId']; @@ -826,10 +826,10 @@ public function updateSubscriptionBillingInfo(&$message = '', $params = array()) * @return array|bool|object * @throws \Civi\Payment\Exception\PaymentProcessorException */ - public function changeSubscriptionAmount(&$message = '', $params = array()) { + public function changeSubscriptionAmount(&$message = '', $params = []) { if ($this->isPayPalType($this::PAYPAL_PRO)) { $config = CRM_Core_Config::singleton(); - $args = array(); + $args = []; $this->initialize($args, 'UpdateRecurringPaymentsProfile'); $args['PROFILEID'] = $params['subscriptionId']; @@ -861,14 +861,14 @@ public function changeSubscriptionAmount(&$message = '', $params = array()) { */ public function doPreApproval(&$params) { if (!$this->isPaypalExpress($params)) { - return array(); + return []; } $this->_component = $params['component']; $token = $this->setExpressCheckOut($params); - return array( - 'pre_approval_parameters' => array('token' => $token), + return [ + 'pre_approval_parameters' => ['token' => $token], 'redirect_url' => $this->_paymentProcessor['url_site'] . "/cgi-bin/webscr?cmd=_express-checkout&token=$token", - ); + ]; } /** @@ -879,8 +879,8 @@ public function doPreApproval(&$params) { */ public function doTransferCheckout(&$params, $component = 'contribute') { - $notifyParameters = array('module' => $component); - $notifyParameterMap = array( + $notifyParameters = ['module' => $component]; + $notifyParameterMap = [ 'contactID' => 'contactID', 'contributionID' => 'contributionID', 'eventID' => 'eventID', @@ -891,7 +891,7 @@ public function doTransferCheckout(&$params, $component = 'contribute') { 'accountingCode' => 'accountingCode', 'contributionRecurID' => 'contributionRecurID', 'contributionPageID' => 'contributionPageID', - ); + ]; foreach ($notifyParameterMap as $paramsName => $notifyName) { if (!empty($params[$paramsName])) { $notifyParameters[$notifyName] = $params[$paramsName]; @@ -914,7 +914,7 @@ public function doTransferCheckout(&$params, $component = 'contribute') { TRUE, NULL, FALSE ); - $paypalParams = array( + $paypalParams = [ 'business' => $this->_paymentProcessor['user_name'], 'notify_url' => $notifyURL, 'item_name' => $this->getPaymentDescription($params, 127), @@ -931,10 +931,10 @@ public function doTransferCheckout(&$params, $component = 'contribute') { 'charset' => function_exists('mb_internal_encoding') ? mb_internal_encoding() : 'UTF-8', 'custom' => json_encode($notifyParameters), 'bn' => 'CiviCRM_SP', - ); + ]; // add name and address if available, CRM-3130 - $otherVars = array( + $otherVars = [ 'first_name' => 'first_name', 'last_name' => 'last_name', 'street_address' => 'address1', @@ -944,7 +944,7 @@ public function doTransferCheckout(&$params, $component = 'contribute') { 'state_province' => 'state', 'postal_code' => 'zip', 'email' => 'email', - ); + ]; foreach (array_keys($params) as $p) { // get the base name without the location type suffixed to it @@ -976,7 +976,7 @@ public function doTransferCheckout(&$params, $component = 'contribute') { CRM_Core_Error::fatal(ts('Recurring contribution, but no database id')); } - $paypalParams += array( + $paypalParams += [ 'cmd' => '_xclick-subscriptions', 'a3' => $this->getAmount($params), 'p3' => $params['frequency_interval'], @@ -986,13 +986,13 @@ public function doTransferCheckout(&$params, $component = 'contribute') { 'srt' => CRM_Utils_Array::value('installments', $params), 'no_note' => 1, 'modify' => 0, - ); + ]; } else { - $paypalParams += array( + $paypalParams += [ 'cmd' => '_xclick', 'amount' => $params['amount'], - ); + ]; } // Allow further manipulation of the arguments via custom hooks .. @@ -1045,7 +1045,7 @@ public function invokeAPI($args, $url = NULL) { $url = $this->_paymentProcessor['url_api'] . 'nvp'; } - $p = array(); + $p = []; foreach ($args as $n => $v) { $p[] = "$n=" . urlencode($v); } @@ -1115,7 +1115,7 @@ public function invokeAPI($args, $url = NULL) { * @return array */ public static function deformat($str) { - $result = array(); + $result = []; while (strlen($str)) { // position of key @@ -1148,7 +1148,7 @@ public function getPaymentFormFields() { return $this->getCreditCardFormFields(); } else { - return array(); + return []; } } @@ -1161,7 +1161,7 @@ public function getPaymentFormFields() { * @return array */ protected function mapPaypalParamsToCivicrmParams($fieldMap, $paypalParams) { - $params = array(); + $params = []; foreach ($fieldMap as $civicrmField => $paypalField) { $params[$civicrmField] = isset($paypalParams[$paypalField]) ? $paypalParams[$paypalField] : NULL; } @@ -1193,10 +1193,10 @@ protected function isPaypalExpress($params) { // The contribution form passes a 'button' but the event form might still set one of these fields. // @todo more standardisation & get paypal fully out of the form layer. - $possibleExpressFields = array( + $possibleExpressFields = [ '_qf_Register_upload_express_x', '_qf_Payment_upload_express_x', - ); + ]; if (array_intersect_key($params, array_fill_keys($possibleExpressFields, 1))) { return TRUE; } diff --git a/CRM/Core/Payment/PayPalProIPN.php b/CRM/Core/Payment/PayPalProIPN.php index 9fd23b8d5e96..4e0bcb46b09f 100644 --- a/CRM/Core/Payment/PayPalProIPN.php +++ b/CRM/Core/Payment/PayPalProIPN.php @@ -39,13 +39,13 @@ class CRM_Core_Payment_PayPalProIPN extends CRM_Core_Payment_BaseIPN { * the code does not need to keep retrieving from the http request * @var array */ - protected $_inputParameters = array(); + protected $_inputParameters = []; /** * Store for the variables from the invoice string. * @var array */ - protected $_invoiceData = array(); + protected $_invoiceData = []; /** * Is this a payment express transaction. @@ -103,7 +103,7 @@ public function setInvoiceData() { $rpInvoiceArray = explode('&', $this->_inputParameters['rp_invoice_id']); // for clarify let's also store without the single letter unreadable //@todo after more refactoring we might ditch storing the one letter stuff - $mapping = array( + $mapping = [ 'i' => 'invoice_id', 'm' => 'component', 'c' => 'contact_id', @@ -111,7 +111,7 @@ public function setInvoiceData() { 'r' => 'contribution_recur_id', 'p' => 'participant_id', 'e' => 'event_id', - ); + ]; foreach ($rpInvoiceArray as $rpInvoiceValue) { $rpValueArray = explode('=', $rpInvoiceValue); $this->_invoiceData[$rpValueArray[0]] = $rpValueArray[1]; @@ -184,7 +184,7 @@ public function recur(&$input, &$ids, &$objects, $first) { $now = date('YmdHis'); // fix dates that already exist - $dates = array('create', 'start', 'end', 'cancel', 'modified'); + $dates = ['create', 'start', 'end', 'cancel', 'modified']; foreach ($dates as $date) { $name = "{$date}_date"; if ($recur->$name) { @@ -214,10 +214,10 @@ public function recur(&$input, &$ids, &$objects, $first) { $contributionStatuses = array_flip(CRM_Contribute_BAO_Contribution::buildOptions('contribution_status_id', 'validate')); switch ($txnType) { case 'recurring_payment_profile_created': - if (in_array($recur->contribution_status_id, array( + if (in_array($recur->contribution_status_id, [ $contributionStatuses['Pending'], $contributionStatuses['In Progress'], - )) + ]) && !empty($recur->processor_id) ) { echo "already handled"; @@ -405,12 +405,12 @@ public function getPayPalPaymentProcessorID() { $paymentProcessorTypeID = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_PaymentProcessorType', 'PayPal', 'id', 'name' ); - return (int) civicrm_api3('PaymentProcessor', 'getvalue', array( + return (int) civicrm_api3('PaymentProcessor', 'getvalue', [ 'is_test' => 0, - 'options' => array('limit' => 1), + 'options' => ['limit' => 1], 'payment_processor_type_id' => $paymentProcessorTypeID, 'return' => 'id', - )); + ]); } @@ -428,7 +428,7 @@ public function main() { $this->handlePaymentExpress(); return; } - $objects = $ids = $input = array(); + $objects = $ids = $input = []; $this->_component = $input['component'] = self::getValue('m'); $input['invoice'] = self::getValue('i', TRUE); // get the contribution and contact ids from the GET params @@ -460,10 +460,10 @@ public function main() { INNER JOIN civicrm_membership_payment mp ON m.id = mp.membership_id AND mp.contribution_id = %1 WHERE m.contribution_recur_id = %2 LIMIT 1"; - $sqlParams = array( - 1 => array($ids['contribution'], 'Integer'), - 2 => array($ids['contributionRecur'], 'Integer'), - ); + $sqlParams = [ + 1 => [$ids['contribution'], 'Integer'], + 2 => [$ids['contributionRecur'], 'Integer'], + ]; if ($membershipId = CRM_Core_DAO::singleValueQuery($sql, $sqlParams)) { $ids['membership'] = $membershipId; } @@ -513,7 +513,7 @@ public function getInput(&$input, &$ids) { $input['reasonCode'] = self::retrieve('ReasonCode', 'String', 'POST', FALSE); $billingID = $ids['billing']; - $lookup = array( + $lookup = [ "first_name" => 'first_name', "last_name" => 'last_name', "street_address-{$billingID}" => 'address_street', @@ -521,7 +521,7 @@ public function getInput(&$input, &$ids) { "state-{$billingID}" => 'address_state', "postal_code-{$billingID}" => 'address_zip', "country-{$billingID}" => 'address_country_code', - ); + ]; foreach ($lookup as $name => $paypalName) { $value = self::retrieve($paypalName, 'String', 'POST', FALSE); $input[$name] = $value ? $value : NULL; @@ -554,7 +554,7 @@ public function handlePaymentExpress() { // also note that a lot of the complexity above could be removed if we used // http://stackoverflow.com/questions/4848227/validate-that-ipn-call-is-from-paypal // as membership id etc can be derived by the load objects fn - $objects = $ids = $input = array(); + $objects = $ids = $input = []; $isFirst = FALSE; $input['invoice'] = self::getValue('i', FALSE); //Avoid return in case of unit test. @@ -562,10 +562,10 @@ public function handlePaymentExpress() { return; } $input['txnType'] = $this->retrieve('txn_type', 'String'); - $contributionRecur = civicrm_api3('contribution_recur', 'getsingle', array( + $contributionRecur = civicrm_api3('contribution_recur', 'getsingle', [ 'return' => 'contact_id, id, payment_processor_id', 'invoice_id' => $input['invoice'], - )); + ]); if ($input['txnType'] !== 'recurring_payment' && $input['txnType'] !== 'recurring_payment_profile_created') { throw new CRM_Core_Exception('Paypal IPNS not handled other than recurring_payments'); @@ -587,12 +587,12 @@ public function handlePaymentExpress() { $isFirst = TRUE; } // arg api won't get this - fix it - $ids['contributionPage'] = CRM_Core_DAO::singleValueQuery("SELECT contribution_page_id FROM civicrm_contribution WHERE invoice_id = %1", array( - 1 => array( + $ids['contributionPage'] = CRM_Core_DAO::singleValueQuery("SELECT contribution_page_id FROM civicrm_contribution WHERE invoice_id = %1", [ + 1 => [ $ids['contribution'], 'Integer', - ), - )); + ], + ]); // only handle component at this stage - not terribly sure how a recurring event payment would arise // & suspec main function may be a victom of copy & paste // membership would be an easy add - but not relevant to my customer... @@ -613,9 +613,9 @@ public function handlePaymentExpress() { */ public function transactionExists($trxn_id) { if (CRM_Core_DAO::singleValueQuery("SELECT count(*) FROM civicrm_contribution WHERE trxn_id = %1", - array( - 1 => array($trxn_id, 'String'), - )) + [ + 1 => [$trxn_id, 'String'], + ]) ) { return TRUE; } diff --git a/CRM/Core/Payment/PayflowPro.php b/CRM/Core/Payment/PayflowPro.php index 2020b2a8cd81..46541a4b165d 100644 --- a/CRM/Core/Payment/PayflowPro.php +++ b/CRM/Core/Payment/PayflowPro.php @@ -89,7 +89,7 @@ public function doDirectPayment(&$params) { * */ - $payflow_query_array = array( + $payflow_query_array = [ 'USER' => $user, 'VENDOR' => $this->_paymentProcessor['user_name'], 'PARTNER' => $this->_paymentProcessor['signature'], @@ -121,7 +121,7 @@ public function doDirectPayment(&$params) { 'ORDERDESC' => urlencode($params['description']), 'VERBOSITY' => 'MEDIUM', 'BILLTOCOUNTRY' => urlencode($params['country']), - ); + ]; if ($params['installments'] == 1) { $params['is_recur'] = FALSE; @@ -272,7 +272,7 @@ public function doDirectPayment(&$params) { return self::errorExit(9016, "No RESULT code from PayPal."); } - $nvpArray = array(); + $nvpArray = []; while (strlen($result)) { // name $keypos = strpos($result, '='); @@ -386,13 +386,13 @@ public function doTransferCheckout(&$params, $component) { * the error message if any, null if OK */ public function checkConfig() { - $errorMsg = array(); + $errorMsg = []; if (empty($this->_paymentProcessor['user_name'])) { $errorMsg[] = ' ' . ts('ssl_merchant_id is not set for this payment processor'); } if (empty($this->_paymentProcessor['url_site'])) { - $errorMsg[] = ' ' . ts('URL is not set for %1', array(1 => $this->_paymentProcessor['name'])); + $errorMsg[] = ' ' . ts('URL is not set for %1', [1 => $this->_paymentProcessor['name']]); } if (!empty($errorMsg)) { diff --git a/CRM/Core/Payment/PaymentExpress.php b/CRM/Core/Payment/PaymentExpress.php index 07322ed5ba53..28552293feed 100644 --- a/CRM/Core/Payment/PaymentExpress.php +++ b/CRM/Core/Payment/PaymentExpress.php @@ -77,7 +77,7 @@ public function __construct($mode, &$paymentProcessor) { public function checkConfig() { $config = CRM_Core_Config::singleton(); - $error = array(); + $error = []; if (empty($this->_paymentProcessor['user_name'])) { $error[] = ts('UserID is not set in the Administer » System Settings » Payment Processors'); @@ -159,7 +159,7 @@ public function doTransferCheckout(&$params, $component) { } - $dpsParams = array( + $dpsParams = [ 'AmountInput' => str_replace(",", "", number_format($params['amount'], 2)), 'CurrencyInput' => $params['currencyID'], 'MerchantReference' => $merchantRef, @@ -171,7 +171,7 @@ public function doTransferCheckout(&$params, $component) { 'TxnId' => '', 'UrlFail' => $url, 'UrlSuccess' => $url, - ); + ]; // Allow further manipulation of params via custom hooks CRM_Utils_Hook::alterPaymentProcessorParams($this, $params, $dpsParams); diff --git a/CRM/Core/Payment/PaymentExpressIPN.php b/CRM/Core/Payment/PaymentExpressIPN.php index 52bd5ce82ee7..8683a65f853a 100644 --- a/CRM/Core/Payment/PaymentExpressIPN.php +++ b/CRM/Core/Payment/PaymentExpressIPN.php @@ -111,7 +111,7 @@ public function __construct($mode, &$paymentProcessor) { * @return bool */ public function newOrderNotify($success, $privateData, $component, $amount, $transactionReference) { - $ids = $input = $params = array(); + $ids = $input = $params = []; $input['component'] = strtolower($component); @@ -255,7 +255,7 @@ public static function getContext($privateData, $orderNo) { } } - return array($isTest, $component, $duplicateTransaction); + return [$isTest, $component, $duplicateTransaction]; } /** @@ -286,11 +286,11 @@ public static function main($dps_method, $rawPostData, $dps_url, $dps_user, $dps } if ($dps_method == "pxpay") { - $processResponse = CRM_Core_Payment_PaymentExpressUtils::_valueXml(array( + $processResponse = CRM_Core_Payment_PaymentExpressUtils::_valueXml([ 'PxPayUserId' => $dps_user, 'PxPayKey' => $dps_key, 'Response' => $_GET['result'], - )); + ]); $processResponse = CRM_Core_Payment_PaymentExpressUtils::_valueXml('ProcessResponse', $processResponse); fwrite($message_log, sprintf("\n\r%s:- %s\n", date("D M j G:i:s T Y"), @@ -308,7 +308,7 @@ public static function main($dps_method, $rawPostData, $dps_url, $dps_user, $dps $info = curl_getinfo($curl); if ($info['http_code'] < 200 || $info['http_code'] > 299) { $log_message = "DPS error: HTTP %1 retrieving %2."; - CRM_Core_Error::fatal(ts($log_message, array(1 => $info['http_code'], 2 => $info['url']))); + CRM_Core_Error::fatal(ts($log_message, [1 => $info['http_code'], 2 => $info['url']])); } else { fwrite($message_log, sprintf("\n\r%s:- %s\n", date("D M j G:i:s T Y"), $response)); @@ -318,7 +318,7 @@ public static function main($dps_method, $rawPostData, $dps_url, $dps_user, $dps $valid = CRM_Core_Payment_PaymentExpressUtils::_xmlAttribute($response, 'valid'); // CRM_Core_Payment_PaymentExpressUtils::_xmlAttribute() returns NULL if preg fails. if (is_null($valid)) { - CRM_Core_Error::fatal(ts("DPS error: Unable to parse XML response from DPS.", array(1 => $valid))); + CRM_Core_Error::fatal(ts("DPS error: Unable to parse XML response from DPS.", [1 => $valid])); } $success = CRM_Core_Payment_PaymentExpressUtils::_xmlElement($response, 'Success'); $txnId = CRM_Core_Payment_PaymentExpressUtils::_xmlElement($response, 'TxnId'); @@ -439,7 +439,7 @@ public static function main($dps_method, $rawPostData, $dps_url, $dps_user, $dps * @return array */ public static function stringToArray($str) { - $vars = $labels = array(); + $vars = $labels = []; $labels = explode(',', $str); foreach ($labels as $label) { $terms = explode('=', $label); diff --git a/CRM/Core/Payment/ProcessorForm.php b/CRM/Core/Payment/ProcessorForm.php index ba07a854fc6f..55ec6ffff435 100644 --- a/CRM/Core/Payment/ProcessorForm.php +++ b/CRM/Core/Payment/ProcessorForm.php @@ -80,12 +80,12 @@ public static function preProcess(&$form, $type = NULL, $mode = NULL) { } if (!empty($form->_values['custom_pre_id'])) { - $profileAddressFields = array(); + $profileAddressFields = []; $fields = CRM_Core_BAO_UFGroup::getFields($form->_values['custom_pre_id'], FALSE, CRM_Core_Action::ADD, NULL, NULL, FALSE, NULL, FALSE, NULL, CRM_Core_Permission::CREATE, NULL); foreach ((array) $fields as $key => $value) { - CRM_Core_BAO_UFField::assignAddressField($key, $profileAddressFields, array('uf_group_id' => $form->_values['custom_pre_id'])); + CRM_Core_BAO_UFField::assignAddressField($key, $profileAddressFields, ['uf_group_id' => $form->_values['custom_pre_id']]); } if (count($profileAddressFields)) { $form->set('profileAddressFields', $profileAddressFields); @@ -128,7 +128,7 @@ public static function preProcess(&$form, $type = NULL, $mode = NULL) { ) { CRM_Core_Error::fatal(ts('This contribution page is configured to support separate contribution and membership payments. This %1 plugin does not currently support multiple simultaneous payments, or the option to "Execute real-time monetary transactions" is disabled. Please contact the site administrator and notify them of this error', - array(1 => $form->_paymentProcessor['payment_processor_type']) + [1 => $form->_paymentProcessor['payment_processor_type']] ) ); } diff --git a/CRM/Core/Payment/Realex.php b/CRM/Core/Payment/Realex.php index c757923468da..5a4931d214b4 100644 --- a/CRM/Core/Payment/Realex.php +++ b/CRM/Core/Payment/Realex.php @@ -42,7 +42,7 @@ class CRM_Core_Payment_Realex extends CRM_Core_Payment { protected $_mode = NULL; - protected $_params = array(); + protected $_params = []; /** * We only need one instance of this object. So we use the singleton @@ -147,7 +147,7 @@ public function doDirectPayment(&$params) { return self::error(9002, ts('Could not initiate connection to payment gateway')); } - curl_setopt($submit, CURLOPT_HTTPHEADER, array('SOAPAction: ""')); + curl_setopt($submit, CURLOPT_HTTPHEADER, ['SOAPAction: ""']); curl_setopt($submit, CURLOPT_RETURNTRANSFER, 1); curl_setopt($submit, CURLOPT_TIMEOUT, 60); curl_setopt($submit, CURLOPT_SSL_VERIFYPEER, Civi::settings()->get('verifySSL')); @@ -204,12 +204,12 @@ public function doDirectPayment(&$params) { // FIXME: We are using the trxn_result_code column to store all these extra details since there // seems to be nowhere else to put them. This is THE WRONG THING TO DO! - $extras = array( + $extras = [ 'authcode' => $response['AUTHCODE'], 'batch_id' => $response['BATCHID'], 'message' => $response['MESSAGE'], 'trxn_result_code' => $response['RESULT'], - ); + ]; $params['trxn_id'] = $response['PASREF']; $params['trxn_result_code'] = serialize($extras); @@ -230,8 +230,8 @@ public function doDirectPayment(&$params) { * An array of the result with following keys: */ public function xml_parse_into_assoc($xml) { - $input = array(); - $result = array(); + $input = []; + $result = []; $result['#error'] = FALSE; $result['#return'] = NULL; @@ -250,11 +250,11 @@ public function xml_parse_into_assoc($xml) { } else { $result['#error'] = ts('Error parsing XML result - error code = %1 at line %2 char %3', - array( + [ 1 => xml_get_error_code($xmlparser), 2 => xml_get_current_line_number($xmlparser), 3 => xml_get_current_column_number($xmlparser), - ) + ] ); } } @@ -269,8 +269,8 @@ public function xml_parse_into_assoc($xml) { * @return array */ public function _xml_parse($input, $depth = 1) { - $output = array(); - $children = array(); + $output = []; + $children = []; foreach ($input as $data) { if ($data['level'] == $depth) { @@ -280,7 +280,7 @@ public function _xml_parse($input, $depth = 1) { break; case 'open': - $children = array(); + $children = []; break; case 'close': @@ -475,7 +475,7 @@ public function &error($errorCode = NULL, $errorMessage = NULL) { * the error message if any */ public function checkConfig() { - $error = array(); + $error = []; if (empty($this->_paymentProcessor['user_name'])) { $error[] = ts('Merchant ID is not set for this payment processor'); } diff --git a/CRM/Core/Payment/eWAY.php b/CRM/Core/Payment/eWAY.php index 97359f040cd5..49759569803f 100644 --- a/CRM/Core/Payment/eWAY.php +++ b/CRM/Core/Payment/eWAY.php @@ -465,7 +465,7 @@ public function &errorExit($errorCode = NULL, $errorMessage = NULL) { * ***************************************************************************************** */ public function checkConfig() { - $errorMsg = array(); + $errorMsg = []; if (empty($this->_paymentProcessor['user_name'])) { $errorMsg[] = ts('eWAY CustomerID is not set for this payment processor'); diff --git a/CRM/Core/Permission.php b/CRM/Core/Permission.php index 10a9bd10bd5f..5a3f0eff7aa0 100644 --- a/CRM/Core/Permission.php +++ b/CRM/Core/Permission.php @@ -254,8 +254,8 @@ public static function customGroupAdmin() { */ public static function customGroup($type = CRM_Core_Permission::VIEW, $reset = FALSE) { $customGroups = CRM_Core_PseudoConstant::get('CRM_Core_DAO_CustomField', 'custom_group_id', - array('fresh' => $reset)); - $defaultGroups = array(); + ['fresh' => $reset]); + $defaultGroups = []; // check if user has all powerful permission // or administer civicrm permission (CRM-1905) @@ -380,7 +380,7 @@ public static function event($type = CRM_Core_Permission::VIEW, $eventID = NULL, } } $events = CRM_Event_PseudoConstant::event(NULL, TRUE); - $includeEvents = array(); + $includeEvents = []; // check if user has all powerful permission if (self::check('register for events')) { @@ -477,7 +477,7 @@ public static function checkActionPermission($module, $action) { $permissionName = "delete in $module"; } else { - $editPermissions = array( + $editPermissions = [ 'CiviEvent' => 'edit event participants', 'CiviMember' => 'edit memberships', 'CiviPledge' => 'edit pledges', @@ -485,7 +485,7 @@ public static function checkActionPermission($module, $action) { 'CiviGrant' => 'edit grants', 'CiviMail' => 'access CiviMail', 'CiviAuction' => 'add auction items', - ); + ]; $permissionName = CRM_Utils_Array::value($module, $editPermissions); } @@ -585,7 +585,7 @@ public static function checkMenuItem(&$item) { * @return array */ public static function basicPermissions($all = FALSE, $descriptions = FALSE) { - $cacheKey = implode('-', array($all, $descriptions)); + $cacheKey = implode('-', [$all, $descriptions]); if (empty(Civi::$statics[__CLASS__][__FUNCTION__][$cacheKey])) { Civi::$statics[__CLASS__][__FUNCTION__][$cacheKey] = self::assembleBasicPermissions($all, $descriptions); } @@ -605,7 +605,7 @@ public static function assembleBasicPermissions($all = FALSE, $descriptions = FA $permissions = self::getCorePermissions($descriptions); if (self::isMultisiteEnabled()) { - $permissions['administer Multiple Organizations'] = array($prefix . ts('administer Multiple Organizations')); + $permissions['administer Multiple Organizations'] = [$prefix . ts('administer Multiple Organizations')]; } if (!$descriptions) { @@ -627,7 +627,7 @@ public static function assembleBasicPermissions($all = FALSE, $descriptions = FA foreach ($perm as $p => $attr) { if (!is_array($attr)) { - $attr = array($attr); + $attr = [$attr]; } $attr[0] = $info['translatedName'] . ': ' . $attr[0]; @@ -653,11 +653,11 @@ public static function assembleBasicPermissions($all = FALSE, $descriptions = FA * @return array */ public static function getAnonymousPermissionsWarnings() { - static $permissions = array(); + static $permissions = []; if (empty($permissions)) { - $permissions = array( + $permissions = [ 'administer CiviCRM', - ); + ]; $components = CRM_Core_Component::getComponents(); foreach ($components as $comp) { if (!method_exists($comp, 'getAnonymousPermissionWarnings')) { @@ -685,236 +685,236 @@ public static function validateForPermissionWarnings($anonymous_perms) { */ public static function getCorePermissions() { $prefix = ts('CiviCRM') . ': '; - $permissions = array( - 'add contacts' => array( + $permissions = [ + 'add contacts' => [ $prefix . ts('add contacts'), ts('Create a new contact record in CiviCRM'), - ), - 'view all contacts' => array( + ], + 'view all contacts' => [ $prefix . ts('view all contacts'), ts('View ANY CONTACT in the CiviCRM database, export contact info and perform activities such as Send Email, Phone Call, etc.'), - ), - 'edit all contacts' => array( + ], + 'edit all contacts' => [ $prefix . ts('edit all contacts'), ts('View, Edit and Delete ANY CONTACT in the CiviCRM database; Create and edit relationships, tags and other info about the contacts'), - ), - 'view my contact' => array( + ], + 'view my contact' => [ $prefix . ts('view my contact'), - ), - 'edit my contact' => array( + ], + 'edit my contact' => [ $prefix . ts('edit my contact'), - ), - 'delete contacts' => array( + ], + 'delete contacts' => [ $prefix . ts('delete contacts'), - ), - 'access deleted contacts' => array( + ], + 'access deleted contacts' => [ $prefix . ts('access deleted contacts'), ts('Access contacts in the trash'), - ), - 'import contacts' => array( + ], + 'import contacts' => [ $prefix . ts('import contacts'), ts('Import contacts and activities'), - ), - 'import SQL datasource' => array( + ], + 'import SQL datasource' => [ $prefix . ts('import SQL datasource'), ts('When importing, consume data directly from a SQL datasource'), - ), - 'edit groups' => array( + ], + 'edit groups' => [ $prefix . ts('edit groups'), ts('Create new groups, edit group settings (e.g. group name, visibility...), delete groups'), - ), - 'administer CiviCRM' => array( + ], + 'administer CiviCRM' => [ $prefix . ts('administer CiviCRM'), ts('Perform all tasks in the Administer CiviCRM control panel and Import Contacts'), - ), - 'skip IDS check' => array( + ], + 'skip IDS check' => [ $prefix . ts('skip IDS check'), ts('Warning: Give to trusted roles only; this permission has security implications. IDS system is bypassed for users with this permission. Prevents false errors for admin users.'), - ), - 'access uploaded files' => array( + ], + 'access uploaded files' => [ $prefix . ts('access uploaded files'), ts('View / download files including images and photos'), - ), - 'profile listings and forms' => array( + ], + 'profile listings and forms' => [ $prefix . ts('profile listings and forms'), ts('Warning: Give to trusted roles only; this permission has privacy implications. Add/edit data in online forms and access public searchable directories.'), - ), - 'profile listings' => array( + ], + 'profile listings' => [ $prefix . ts('profile listings'), ts('Warning: Give to trusted roles only; this permission has privacy implications. Access public searchable directories.'), - ), - 'profile create' => array( + ], + 'profile create' => [ $prefix . ts('profile create'), ts('Add data in a profile form.'), - ), - 'profile edit' => array( + ], + 'profile edit' => [ $prefix . ts('profile edit'), ts('Edit data in a profile form.'), - ), - 'profile view' => array( + ], + 'profile view' => [ $prefix . ts('profile view'), ts('View data in a profile.'), - ), - 'access all custom data' => array( + ], + 'access all custom data' => [ $prefix . ts('access all custom data'), ts('View all custom fields regardless of ACL rules'), - ), - 'view all activities' => array( + ], + 'view all activities' => [ $prefix . ts('view all activities'), ts('View all activities (for visible contacts)'), - ), - 'delete activities' => array( + ], + 'delete activities' => [ $prefix . ts('Delete activities'), - ), - 'edit inbound email basic information' => array( + ], + 'edit inbound email basic information' => [ $prefix . ts('edit inbound email basic information'), ts('Edit all inbound email activities (for visible contacts) basic information. Content editing not allowed.'), - ), - 'edit inbound email basic information and content' => array( + ], + 'edit inbound email basic information and content' => [ $prefix . ts('edit inbound email basic information and content'), ts('Edit all inbound email activities (for visible contacts) basic information and content.'), - ), - 'access CiviCRM' => array( + ], + 'access CiviCRM' => [ $prefix . ts('access CiviCRM backend and API'), ts('Master control for access to the main CiviCRM backend and API. Give to trusted roles only.'), - ), - 'access Contact Dashboard' => array( + ], + 'access Contact Dashboard' => [ $prefix . ts('access Contact Dashboard'), ts('View Contact Dashboard (for themselves and visible contacts)'), - ), - 'translate CiviCRM' => array( + ], + 'translate CiviCRM' => [ $prefix . ts('translate CiviCRM'), ts('Allow User to enable multilingual'), - ), - 'manage tags' => array( + ], + 'manage tags' => [ $prefix . ts('manage tags'), ts('Create and rename tags'), - ), - 'administer reserved groups' => array( + ], + 'administer reserved groups' => [ $prefix . ts('administer reserved groups'), ts('Edit and disable Reserved Groups (Needs Edit Groups)'), - ), - 'administer Tagsets' => array( + ], + 'administer Tagsets' => [ $prefix . ts('administer Tagsets'), - ), - 'administer reserved tags' => array( + ], + 'administer reserved tags' => [ $prefix . ts('administer reserved tags'), - ), - 'administer dedupe rules' => array( + ], + 'administer dedupe rules' => [ $prefix . ts('administer dedupe rules'), ts('Create and edit rules, change the supervised and unsupervised rules'), - ), - 'merge duplicate contacts' => array( + ], + 'merge duplicate contacts' => [ $prefix . ts('merge duplicate contacts'), ts('Delete Contacts must also be granted in order for this to work.'), - ), - 'force merge duplicate contacts' => array( + ], + 'force merge duplicate contacts' => [ $prefix . ts('force merge duplicate contacts'), ts('Delete Contacts must also be granted in order for this to work.'), - ), - 'view debug output' => array( + ], + 'view debug output' => [ $prefix . ts('view debug output'), ts('View results of debug and backtrace'), - ), + ], - 'view all notes' => array( + 'view all notes' => [ $prefix . ts('view all notes'), ts("View notes (for visible contacts) even if they're marked admin only"), - ), - 'add contact notes' => array( + ], + 'add contact notes' => [ $prefix . ts('add contact notes'), ts("Create notes for contacts"), - ), - 'access AJAX API' => array( + ], + 'access AJAX API' => [ $prefix . ts('access AJAX API'), ts('Allow API access even if Access CiviCRM is not granted'), - ), - 'access contact reference fields' => array( + ], + 'access contact reference fields' => [ $prefix . ts('access contact reference fields'), ts('Allow entering data into contact reference fields'), - ), - 'create manual batch' => array( + ], + 'create manual batch' => [ $prefix . ts('create manual batch'), ts('Create an accounting batch (with Access to CiviContribute and View Own/All Manual Batches)'), - ), - 'edit own manual batches' => array( + ], + 'edit own manual batches' => [ $prefix . ts('edit own manual batches'), ts('Edit accounting batches created by user'), - ), - 'edit all manual batches' => array( + ], + 'edit all manual batches' => [ $prefix . ts('edit all manual batches'), ts('Edit all accounting batches'), - ), - 'close own manual batches' => array( + ], + 'close own manual batches' => [ $prefix . ts('close own manual batches'), ts('Close accounting batches created by user (with Access to CiviContribute)'), - ), - 'close all manual batches' => array( + ], + 'close all manual batches' => [ $prefix . ts('close all manual batches'), ts('Close all accounting batches (with Access to CiviContribute)'), - ), - 'reopen own manual batches' => array( + ], + 'reopen own manual batches' => [ $prefix . ts('reopen own manual batches'), ts('Reopen accounting batches created by user (with Access to CiviContribute)'), - ), - 'reopen all manual batches' => array( + ], + 'reopen all manual batches' => [ $prefix . ts('reopen all manual batches'), ts('Reopen all accounting batches (with Access to CiviContribute)'), - ), - 'view own manual batches' => array( + ], + 'view own manual batches' => [ $prefix . ts('view own manual batches'), ts('View accounting batches created by user (with Access to CiviContribute)'), - ), - 'view all manual batches' => array( + ], + 'view all manual batches' => [ $prefix . ts('view all manual batches'), ts('View all accounting batches (with Access to CiviContribute)'), - ), - 'delete own manual batches' => array( + ], + 'delete own manual batches' => [ $prefix . ts('delete own manual batches'), ts('Delete accounting batches created by user'), - ), - 'delete all manual batches' => array( + ], + 'delete all manual batches' => [ $prefix . ts('delete all manual batches'), ts('Delete all accounting batches'), - ), - 'export own manual batches' => array( + ], + 'export own manual batches' => [ $prefix . ts('export own manual batches'), ts('Export accounting batches created by user'), - ), - 'export all manual batches' => array( + ], + 'export all manual batches' => [ $prefix . ts('export all manual batches'), ts('Export all accounting batches'), - ), - 'administer payment processors' => array( + ], + 'administer payment processors' => [ $prefix . ts('administer payment processors'), ts('Add, Update, or Disable Payment Processors'), - ), - 'edit message templates' => array( + ], + 'edit message templates' => [ $prefix . ts('edit message templates'), - ), - 'edit system workflow message templates' => array( + ], + 'edit system workflow message templates' => [ $prefix . ts('edit system workflow message templates'), - ), - 'edit user-driven message templates' => array( + ], + 'edit user-driven message templates' => [ $prefix . ts('edit user-driven message templates'), - ), - 'view my invoices' => array( + ], + 'view my invoices' => [ $prefix . ts('view my invoices'), ts('Allow users to view/ download their own invoices'), - ), - 'edit api keys' => array( + ], + 'edit api keys' => [ $prefix . ts('edit api keys'), ts('Edit API keys'), - ), - 'edit own api keys' => array( + ], + 'edit own api keys' => [ $prefix . ts('edit own api keys'), ts('Edit user\'s own API keys'), - ), - 'send SMS' => array( + ], + 'send SMS' => [ $prefix . ts('send SMS'), ts('Send an SMS'), - ), - ); + ], + ]; return $permissions; } @@ -938,62 +938,62 @@ public static function getCorePermissions() { * @return array of permissions */ public static function getEntityActionPermissions() { - $permissions = array(); + $permissions = []; // These are the default permissions - if any entity does not declare permissions for a given action, // (or the entity does not declare permissions at all) - then the action will be used from here - $permissions['default'] = array( + $permissions['default'] = [ // applies to getfields, getoptions, etc. - 'meta' => array('access CiviCRM'), + 'meta' => ['access CiviCRM'], // catch-all, applies to create, get, delete, etc. // If an entity declares it's own 'default' action it will override this one - 'default' => array('administer CiviCRM'), - ); + 'default' => ['administer CiviCRM'], + ]; // Note: Additional permissions in DynamicFKAuthorization - $permissions['attachment'] = array( - 'default' => array( - array('access CiviCRM', 'access AJAX API'), - ), - ); + $permissions['attachment'] = [ + 'default' => [ + ['access CiviCRM', 'access AJAX API'], + ], + ]; // Contact permissions - $permissions['contact'] = array( - 'create' => array( + $permissions['contact'] = [ + 'create' => [ 'access CiviCRM', 'add contacts', - ), - 'delete' => array( + ], + 'delete' => [ 'access CiviCRM', 'delete contacts', - ), + ], // managed by query object - 'get' => array(), + 'get' => [], // managed by _civicrm_api3_check_edit_permissions - 'update' => array(), - 'getquick' => array( - array('access CiviCRM', 'access AJAX API'), - ), - 'duplicatecheck' => array( + 'update' => [], + 'getquick' => [ + ['access CiviCRM', 'access AJAX API'], + ], + 'duplicatecheck' => [ 'access CiviCRM', - ), - ); + ], + ]; // CRM-16963 - Permissions for country. - $permissions['country'] = array( - 'get' => array( + $permissions['country'] = [ + 'get' => [ 'access CiviCRM', - ), - 'default' => array( + ], + 'default' => [ 'administer CiviCRM', - ), - ); + ], + ]; // Contact-related data permissions. - $permissions['address'] = array( + $permissions['address'] = [ // get is managed by BAO::addSelectWhereClause // create/delete are managed by _civicrm_api3_check_edit_permissions - 'default' => array(), - ); + 'default' => [], + ]; $permissions['email'] = $permissions['address']; $permissions['phone'] = $permissions['address']; $permissions['website'] = $permissions['address']; @@ -1001,496 +1001,496 @@ public static function getEntityActionPermissions() { $permissions['open_i_d'] = $permissions['address']; // Also managed by ACLs - CRM-19448 - $permissions['entity_tag'] = array('default' => array()); + $permissions['entity_tag'] = ['default' => []]; $permissions['note'] = $permissions['entity_tag']; // Allow non-admins to get and create tags to support tagset widget // Delete is still reserved for admins - $permissions['tag'] = array( - 'get' => array('access CiviCRM'), - 'create' => array('access CiviCRM'), - 'update' => array('access CiviCRM'), - ); + $permissions['tag'] = [ + 'get' => ['access CiviCRM'], + 'create' => ['access CiviCRM'], + 'update' => ['access CiviCRM'], + ]; //relationship permissions - $permissions['relationship'] = array( + $permissions['relationship'] = [ // get is managed by BAO::addSelectWhereClause - 'get' => array(), - 'delete' => array( + 'get' => [], + 'delete' => [ 'access CiviCRM', 'edit all contacts', - ), - 'default' => array( + ], + 'default' => [ 'access CiviCRM', 'edit all contacts', - ), - ); + ], + ]; // CRM-17741 - Permissions for RelationshipType. - $permissions['relationship_type'] = array( - 'get' => array( + $permissions['relationship_type'] = [ + 'get' => [ 'access CiviCRM', - ), - 'default' => array( + ], + 'default' => [ 'administer CiviCRM', - ), - ); + ], + ]; // Activity permissions - $permissions['activity'] = array( - 'delete' => array( + $permissions['activity'] = [ + 'delete' => [ 'access CiviCRM', 'delete activities', - ), - 'get' => array( + ], + 'get' => [ 'access CiviCRM', // Note that view all activities is also required within the api // if the id is not passed in. Where the id is passed in the activity // specific check functions are used and tested. - ), - 'default' => array( + ], + 'default' => [ 'access CiviCRM', 'view all activities', - ), - ); + ], + ]; $permissions['activity_contact'] = $permissions['activity']; // Case permissions - $permissions['case'] = array( - 'create' => array( + $permissions['case'] = [ + 'create' => [ 'access CiviCRM', 'add cases', - ), - 'delete' => array( + ], + 'delete' => [ 'access CiviCRM', 'delete in CiviCase', - ), - 'restore' => array( + ], + 'restore' => [ 'administer CiviCase', - ), - 'merge' => array( + ], + 'merge' => [ 'administer CiviCase', - ), - 'default' => array( + ], + 'default' => [ // At minimum the user needs one of the following. Finer-grained access is controlled by CRM_Case_BAO_Case::addSelectWhereClause - array('access my cases and activities', 'access all cases and activities'), - ), - ); + ['access my cases and activities', 'access all cases and activities'], + ], + ]; $permissions['case_contact'] = $permissions['case']; - $permissions['case_type'] = array( - 'default' => array('administer CiviCase'), - 'get' => array( + $permissions['case_type'] = [ + 'default' => ['administer CiviCase'], + 'get' => [ // nested array = OR - array('access my cases and activities', 'access all cases and activities'), - ), - ); + ['access my cases and activities', 'access all cases and activities'], + ], + ]; // Campaign permissions - $permissions['campaign'] = array( - 'get' => array('access CiviCRM'), - 'default' => array( + $permissions['campaign'] = [ + 'get' => ['access CiviCRM'], + 'default' => [ // nested array = OR - array('administer CiviCampaign', 'manage campaign'), - ), - ); + ['administer CiviCampaign', 'manage campaign'], + ], + ]; $permissions['survey'] = $permissions['campaign']; // Financial permissions - $permissions['contribution'] = array( - 'get' => array( + $permissions['contribution'] = [ + 'get' => [ 'access CiviCRM', 'access CiviContribute', - ), - 'delete' => array( + ], + 'delete' => [ 'access CiviCRM', 'access CiviContribute', 'delete in CiviContribute', - ), - 'completetransaction' => array( + ], + 'completetransaction' => [ 'edit contributions', - ), - 'default' => array( + ], + 'default' => [ 'access CiviCRM', 'access CiviContribute', 'edit contributions', - ), - ); + ], + ]; $permissions['line_item'] = $permissions['contribution']; // Payment permissions - $permissions['payment'] = array( - 'get' => array( + $permissions['payment'] = [ + 'get' => [ 'access CiviCRM', 'access CiviContribute', - ), - 'delete' => array( + ], + 'delete' => [ 'access CiviCRM', 'access CiviContribute', 'delete in CiviContribute', - ), - 'cancel' => array( + ], + 'cancel' => [ 'access CiviCRM', 'access CiviContribute', 'edit contributions', - ), - 'create' => array( + ], + 'create' => [ 'access CiviCRM', 'access CiviContribute', 'edit contributions', - ), - 'default' => array( + ], + 'default' => [ 'access CiviCRM', 'access CiviContribute', 'edit contributions', - ), - ); + ], + ]; $permissions['contribution_recur'] = $permissions['payment']; // Custom field permissions - $permissions['custom_field'] = array( - 'default' => array( + $permissions['custom_field'] = [ + 'default' => [ 'administer CiviCRM', 'access all custom data', - ), - ); + ], + ]; $permissions['custom_group'] = $permissions['custom_field']; // Event permissions - $permissions['event'] = array( - 'create' => array( + $permissions['event'] = [ + 'create' => [ 'access CiviCRM', 'access CiviEvent', 'edit all events', - ), - 'delete' => array( + ], + 'delete' => [ 'access CiviCRM', 'access CiviEvent', 'delete in CiviEvent', - ), - 'get' => array( + ], + 'get' => [ 'access CiviCRM', 'access CiviEvent', 'view event info', - ), - 'update' => array( + ], + 'update' => [ 'access CiviCRM', 'access CiviEvent', 'edit all events', - ), - ); + ], + ]; // Loc block is only used for events $permissions['loc_block'] = $permissions['event']; - $permissions['state_province'] = array( - 'get' => array( + $permissions['state_province'] = [ + 'get' => [ 'access CiviCRM', - ), - ); + ], + ]; // Price sets are shared by several components, user needs access to at least one of them - $permissions['price_set'] = array( - 'default' => array( - array('access CiviEvent', 'access CiviContribute', 'access CiviMember'), - ), - 'get' => array( - array('access CiviCRM', 'view event info', 'make online contributions'), - ), - ); + $permissions['price_set'] = [ + 'default' => [ + ['access CiviEvent', 'access CiviContribute', 'access CiviMember'], + ], + 'get' => [ + ['access CiviCRM', 'view event info', 'make online contributions'], + ], + ]; // File permissions - $permissions['file'] = array( - 'default' => array( + $permissions['file'] = [ + 'default' => [ 'access CiviCRM', 'access uploaded files', - ), - ); + ], + ]; $permissions['files_by_entity'] = $permissions['file']; // Group permissions - $permissions['group'] = array( - 'get' => array( + $permissions['group'] = [ + 'get' => [ 'access CiviCRM', - ), - 'default' => array( + ], + 'default' => [ 'access CiviCRM', 'edit groups', - ), - ); + ], + ]; $permissions['group_nesting'] = $permissions['group']; $permissions['group_organization'] = $permissions['group']; //Group Contact permission - $permissions['group_contact'] = array( - 'get' => array( + $permissions['group_contact'] = [ + 'get' => [ 'access CiviCRM', - ), - 'default' => array( + ], + 'default' => [ 'access CiviCRM', 'edit all contacts', - ), - ); + ], + ]; // CiviMail Permissions - $civiMailBasePerms = array( + $civiMailBasePerms = [ // To get/preview/update, one must have least one of these perms: // Mailing API implementations enforce nuances of create/approve/schedule permissions. 'access CiviMail', 'create mailings', 'schedule mailings', 'approve mailings', - ); - $permissions['mailing'] = array( - 'get' => array( + ]; + $permissions['mailing'] = [ + 'get' => [ 'access CiviCRM', $civiMailBasePerms, - ), - 'delete' => array( + ], + 'delete' => [ 'access CiviCRM', $civiMailBasePerms, 'delete in CiviMail', - ), - 'submit' => array( + ], + 'submit' => [ 'access CiviCRM', - array('access CiviMail', 'schedule mailings'), - ), - 'default' => array( + ['access CiviMail', 'schedule mailings'], + ], + 'default' => [ 'access CiviCRM', $civiMailBasePerms, - ), - ); + ], + ]; $permissions['mailing_group'] = $permissions['mailing']; $permissions['mailing_job'] = $permissions['mailing']; $permissions['mailing_recipients'] = $permissions['mailing']; - $permissions['mailing_a_b'] = array( - 'get' => array( + $permissions['mailing_a_b'] = [ + 'get' => [ 'access CiviCRM', 'access CiviMail', - ), - 'delete' => array( + ], + 'delete' => [ 'access CiviCRM', 'access CiviMail', 'delete in CiviMail', - ), - 'submit' => array( + ], + 'submit' => [ 'access CiviCRM', - array('access CiviMail', 'schedule mailings'), - ), - 'default' => array( + ['access CiviMail', 'schedule mailings'], + ], + 'default' => [ 'access CiviCRM', 'access CiviMail', - ), - ); + ], + ]; // Membership permissions - $permissions['membership'] = array( - 'get' => array( + $permissions['membership'] = [ + 'get' => [ 'access CiviCRM', 'access CiviMember', - ), - 'delete' => array( + ], + 'delete' => [ 'access CiviCRM', 'access CiviMember', 'delete in CiviMember', - ), - 'default' => array( + ], + 'default' => [ 'access CiviCRM', 'access CiviMember', 'edit memberships', - ), - ); + ], + ]; $permissions['membership_status'] = $permissions['membership']; $permissions['membership_type'] = $permissions['membership']; - $permissions['membership_payment'] = array( - 'create' => array( + $permissions['membership_payment'] = [ + 'create' => [ 'access CiviCRM', 'access CiviMember', 'edit memberships', 'access CiviContribute', 'edit contributions', - ), - 'delete' => array( + ], + 'delete' => [ 'access CiviCRM', 'access CiviMember', 'delete in CiviMember', 'access CiviContribute', 'delete in CiviContribute', - ), - 'get' => array( + ], + 'get' => [ 'access CiviCRM', 'access CiviMember', 'access CiviContribute', - ), - 'update' => array( + ], + 'update' => [ 'access CiviCRM', 'access CiviMember', 'edit memberships', 'access CiviContribute', 'edit contributions', - ), - ); + ], + ]; // Participant permissions - $permissions['participant'] = array( - 'create' => array( + $permissions['participant'] = [ + 'create' => [ 'access CiviCRM', 'access CiviEvent', 'register for events', - ), - 'delete' => array( + ], + 'delete' => [ 'access CiviCRM', 'access CiviEvent', 'edit event participants', - ), - 'get' => array( + ], + 'get' => [ 'access CiviCRM', 'access CiviEvent', 'view event participants', - ), - 'update' => array( + ], + 'update' => [ 'access CiviCRM', 'access CiviEvent', 'edit event participants', - ), - ); - $permissions['participant_payment'] = array( - 'create' => array( + ], + ]; + $permissions['participant_payment'] = [ + 'create' => [ 'access CiviCRM', 'access CiviEvent', 'register for events', 'access CiviContribute', 'edit contributions', - ), - 'delete' => array( + ], + 'delete' => [ 'access CiviCRM', 'access CiviEvent', 'edit event participants', 'access CiviContribute', 'delete in CiviContribute', - ), - 'get' => array( + ], + 'get' => [ 'access CiviCRM', 'access CiviEvent', 'view event participants', 'access CiviContribute', - ), - 'update' => array( + ], + 'update' => [ 'access CiviCRM', 'access CiviEvent', 'edit event participants', 'access CiviContribute', 'edit contributions', - ), - ); + ], + ]; // Pledge permissions - $permissions['pledge'] = array( - 'create' => array( + $permissions['pledge'] = [ + 'create' => [ 'access CiviCRM', 'access CiviPledge', 'edit pledges', - ), - 'delete' => array( + ], + 'delete' => [ 'access CiviCRM', 'access CiviPledge', 'delete in CiviPledge', - ), - 'get' => array( + ], + 'get' => [ 'access CiviCRM', 'access CiviPledge', - ), - 'update' => array( + ], + 'update' => [ 'access CiviCRM', 'access CiviPledge', 'edit pledges', - ), - ); + ], + ]; //CRM-16777: Disable schedule reminder for user that have 'edit all events' and 'administer CiviCRM' permission. - $permissions['action_schedule'] = array( - 'update' => array( - array( + $permissions['action_schedule'] = [ + 'update' => [ + [ 'access CiviCRM', 'edit all events', - ), - ), - ); + ], + ], + ]; - $permissions['pledge_payment'] = array( - 'create' => array( + $permissions['pledge_payment'] = [ + 'create' => [ 'access CiviCRM', 'access CiviPledge', 'edit pledges', 'access CiviContribute', 'edit contributions', - ), - 'delete' => array( + ], + 'delete' => [ 'access CiviCRM', 'access CiviPledge', 'delete in CiviPledge', 'access CiviContribute', 'delete in CiviContribute', - ), - 'get' => array( + ], + 'get' => [ 'access CiviCRM', 'access CiviPledge', 'access CiviContribute', - ), - 'update' => array( + ], + 'update' => [ 'access CiviCRM', 'access CiviPledge', 'edit pledges', 'access CiviContribute', 'edit contributions', - ), - ); + ], + ]; // Profile permissions - $permissions['profile'] = array( - 'get' => array(), // the profile will take care of this - ); + $permissions['profile'] = [ + 'get' => [], // the profile will take care of this + ]; - $permissions['uf_group'] = array( - 'create' => array( + $permissions['uf_group'] = [ + 'create' => [ 'access CiviCRM', - array( + [ 'administer CiviCRM', 'manage event profiles', - ), - ), - 'get' => array( + ], + ], + 'get' => [ 'access CiviCRM', - ), - 'update' => array( + ], + 'update' => [ 'access CiviCRM', - array( + [ 'administer CiviCRM', 'manage event profiles', - ), - ), - ); + ], + ], + ]; $permissions['uf_field'] = $permissions['uf_join'] = $permissions['uf_group']; - $permissions['uf_field']['delete'] = array( + $permissions['uf_field']['delete'] = [ 'access CiviCRM', - array( + [ 'administer CiviCRM', 'manage event profiles', - ), - ); + ], + ]; $permissions['option_value'] = $permissions['uf_group']; $permissions['option_group'] = $permissions['option_value']; - $permissions['custom_value'] = array( - 'gettree' => array('access CiviCRM'), - ); + $permissions['custom_value'] = [ + 'gettree' => ['access CiviCRM'], + ]; - $permissions['message_template'] = array( - 'get' => array('access CiviCRM'), - 'create' => array(array('edit message templates', 'edit user-driven message templates', 'edit system workflow message templates')), - 'update' => array(array('edit message templates', 'edit user-driven message templates', 'edit system workflow message templates')), - ); + $permissions['message_template'] = [ + 'get' => ['access CiviCRM'], + 'create' => [['edit message templates', 'edit user-driven message templates', 'edit system workflow message templates']], + 'update' => [['edit message templates', 'edit user-driven message templates', 'edit system workflow message templates']], + ]; $permissions['report_template']['update'] = 'save Report Criteria'; $permissions['report_template']['create'] = 'save Report Criteria'; @@ -1544,17 +1544,17 @@ public static function giveMeAllACLs() { //check for acl. $aclPermission = self::getPermission(); - if (in_array($aclPermission, array( + if (in_array($aclPermission, [ CRM_Core_Permission::EDIT, CRM_Core_Permission::VIEW, - )) + ]) ) { return TRUE; } // run acl where hook and see if the user is supplying an ACL clause // that is not false - $tables = $whereTables = array(); + $tables = $whereTables = []; $where = NULL; CRM_Utils_Hook::aclWhereClause(CRM_Core_Permission::VIEW, @@ -1579,7 +1579,7 @@ public static function getComponentName($permission) { return $componentName; } - static $allCompPermissions = array(); + static $allCompPermissions = []; if (empty($allCompPermissions)) { $components = CRM_Core_Component::getComponents(); foreach ($components as $name => $comp) { diff --git a/CRM/Core/Permission/Backdrop.php b/CRM/Core/Permission/Backdrop.php index 7e9336f9460f..9d4507c5a363 100644 --- a/CRM/Core/Permission/Backdrop.php +++ b/CRM/Core/Permission/Backdrop.php @@ -74,10 +74,10 @@ class CRM_Core_Permission_Backdrop extends CRM_Core_Permission_DrupalBase { * true if yes, else false */ public function check($str, $userId = NULL) { - $str = $this->translatePermission($str, 'Drupal', array( + $str = $this->translatePermission($str, 'Drupal', [ 'view user account' => 'access user profiles', 'administer users' => 'administer users', - )); + ]); if ($str == CRM_Core_Permission::ALWAYS_DENY_PERMISSION) { return FALSE; } @@ -149,7 +149,7 @@ public function upgradePermissions($permissions) { * a comma separated list of email addresses */ public function permissionEmails($permissionName) { - static $_cache = array(); + static $_cache = []; if (isset($_cache[$permissionName])) { return $_cache[$permissionName]; @@ -177,7 +177,7 @@ public function permissionEmails($permissionName) { $_cache[$permissionName] = self::getContactEmails($uids); return $_cache[$permissionName]; */ - return array(); + return []; } } diff --git a/CRM/Core/Permission/Base.php b/CRM/Core/Permission/Base.php index 79893ad30e5f..c14e63e3ae79 100644 --- a/CRM/Core/Permission/Base.php +++ b/CRM/Core/Permission/Base.php @@ -240,10 +240,10 @@ public function upgradePermissions($permissions) { * @see CRM_Core_Permission::getCorePermissions */ public static function getModulePermissions($module) { - $return_permissions = array(); + $return_permissions = []; $fn_name = "{$module}_civicrm_permission"; if (function_exists($fn_name)) { - $module_permissions = array(); + $module_permissions = []; $fn_name($module_permissions); $return_permissions = $module_permissions; } @@ -260,12 +260,12 @@ public static function getModulePermissions($module) { * Array of permissions, in the same format as CRM_Core_Permission::getCorePermissions(). */ public function getAllModulePermissions($descriptions = FALSE) { - $permissions = array(); + $permissions = []; CRM_Utils_Hook::permission($permissions); if ($descriptions) { foreach ($permissions as $permission => $label) { - $permissions[$permission] = (is_array($label)) ? $label : array($label); + $permissions[$permission] = (is_array($label)) ? $label : [$label]; } } else { diff --git a/CRM/Core/Permission/Drupal.php b/CRM/Core/Permission/Drupal.php index 060c5f2df126..4f67b6ce3899 100644 --- a/CRM/Core/Permission/Drupal.php +++ b/CRM/Core/Permission/Drupal.php @@ -74,10 +74,10 @@ class CRM_Core_Permission_Drupal extends CRM_Core_Permission_DrupalBase { * true if yes, else false */ public function check($str, $userId = NULL) { - $str = $this->translatePermission($str, 'Drupal', array( + $str = $this->translatePermission($str, 'Drupal', [ 'view user account' => 'access user profiles', 'administer users' => 'administer users', - )); + ]); if ($str == CRM_Core_Permission::ALWAYS_DENY_PERMISSION) { return FALSE; } @@ -146,13 +146,13 @@ public function upgradePermissions($permissions) { * a comma separated list of email addresses */ public function permissionEmails($permissionName) { - static $_cache = array(); + static $_cache = []; if (isset($_cache[$permissionName])) { return $_cache[$permissionName]; } - $uids = array(); + $uids = []; $sql = " SELECT {users}.uid, {role_permission}.permission FROM {users} diff --git a/CRM/Core/Permission/Drupal6.php b/CRM/Core/Permission/Drupal6.php index 9d524ebca55a..d969ed42373f 100644 --- a/CRM/Core/Permission/Drupal6.php +++ b/CRM/Core/Permission/Drupal6.php @@ -73,10 +73,10 @@ class CRM_Core_Permission_Drupal6 extends CRM_Core_Permission_DrupalBase { * true if yes, else false */ public function check($str, $userId = NULL) { - $str = $this->translatePermission($str, 'Drupal6', array( + $str = $this->translatePermission($str, 'Drupal6', [ 'view user account' => 'access user profiles', 'administer users' => 'administer users', - )); + ]); if ($str == CRM_Core_Permission::ALWAYS_DENY_PERMISSION) { return FALSE; } @@ -104,7 +104,7 @@ public function check($str, $userId = NULL) { */ public function checkGroupRole($array) { if (function_exists('user_load') && isset($array)) { - $user = user_load(array('uid' => $GLOBALS['user']->uid)); + $user = user_load(['uid' => $GLOBALS['user']->uid]); //if giver roles found in user roles - return true foreach ($array as $key => $value) { if (in_array($value, $user->roles)) { @@ -125,13 +125,13 @@ public function checkGroupRole($array) { * a comma separated list of email addresses */ public function roleEmails($roleName) { - static $_cache = array(); + static $_cache = []; if (isset($_cache[$roleName])) { return $_cache[$roleName]; } - $uids = array(); + $uids = []; $sql = " SELECT {users}.uid FROM {users} @@ -160,13 +160,13 @@ public function roleEmails($roleName) { * a comma separated list of email addresses */ public function permissionEmails($permissionName) { - static $_cache = array(); + static $_cache = []; if (isset($_cache[$permissionName])) { return $_cache[$permissionName]; } - $uids = array(); + $uids = []; $sql = " SELECT {users}.uid, {permission}.perm FROM {users} @@ -211,7 +211,7 @@ public function upgradePermissions($permissions) { * Array of permissions, in the same format as CRM_Core_Permission::getCorePermissions(). */ public static function getModulePermissions($module) { - $return_permissions = array(); + $return_permissions = []; $fn_name = "{$module}_civicrm_permission"; if (function_exists($fn_name)) { $fn_name($return_permissions); diff --git a/CRM/Core/Permission/Drupal8.php b/CRM/Core/Permission/Drupal8.php index d4d6a81190f6..2b728bc47733 100644 --- a/CRM/Core/Permission/Drupal8.php +++ b/CRM/Core/Permission/Drupal8.php @@ -48,9 +48,9 @@ class CRM_Core_Permission_Drupal8 extends CRM_Core_Permission_DrupalBase { * @return bool */ public function check($str, $userId = NULL) { - $str = $this->translatePermission($str, 'Drupal', array( + $str = $this->translatePermission($str, 'Drupal', [ 'view user account' => 'access user profiles', - )); + ]); if ($str == CRM_Core_Permission::ALWAYS_DENY_PERMISSION) { return FALSE; @@ -72,7 +72,7 @@ public function check($str, $userId = NULL) { * a comma separated list of email addresses */ public function permissionEmails($permissionName) { - static $_cache = array(); + static $_cache = []; if (isset($_cache[$permissionName])) { return $_cache[$permissionName]; @@ -83,7 +83,7 @@ function (\Drupal\user\RoleInterface $role) { return $role->id(); }, user_roles(TRUE, $permissionName) ); - $users = \Drupal::entityTypeManager()->getStorage('user')->loadByProperties(array('roles' => $role_ids)); + $users = \Drupal::entityTypeManager()->getStorage('user')->loadByProperties(['roles' => $role_ids]); $uids = array_keys($users); $_cache[$permissionName] = self::getContactEmails($uids); diff --git a/CRM/Core/Permission/DrupalBase.php b/CRM/Core/Permission/DrupalBase.php index ac8a530cb901..b691211be25a 100644 --- a/CRM/Core/Permission/DrupalBase.php +++ b/CRM/Core/Permission/DrupalBase.php @@ -76,13 +76,13 @@ class CRM_Core_Permission_DrupalBase extends CRM_Core_Permission_Base { */ public function group($groupType = NULL, $excludeHidden = TRUE) { if (!isset($this->_viewPermissionedGroups)) { - $this->_viewPermissionedGroups = $this->_editPermissionedGroups = array(); + $this->_viewPermissionedGroups = $this->_editPermissionedGroups = []; } $groupKey = $groupType ? $groupType : 'all'; if (!isset($this->_viewPermissionedGroups[$groupKey])) { - $this->_viewPermissionedGroups[$groupKey] = $this->_editPermissionedGroups[$groupKey] = array(); + $this->_viewPermissionedGroups[$groupKey] = $this->_editPermissionedGroups[$groupKey] = []; $groups = CRM_Core_PseudoConstant::allGroup($groupType, $excludeHidden); @@ -162,7 +162,7 @@ public function groupClause($type, &$tables, &$whereTables) { $clause = ' ( 0 ) '; } else { - $clauses = array(); + $clauses = []; $groups = implode(', ', $this->_editPermissionedGroups[$groupKey]); $clauses[] = ' ( civicrm_group_contact.group_id IN ( ' . implode(', ', array_keys($this->_editPermissionedGroups[$groupKey])) . " ) AND civicrm_group_contact.status = 'Added' ) "; $tables['civicrm_group_contact'] = 1; @@ -193,7 +193,7 @@ public function groupClause($type, &$tables, &$whereTables) { $clause = ' ( 0 ) '; } else { - $clauses = array(); + $clauses = []; $groups = implode(', ', $this->_viewPermissionedGroups[$groupKey]); $clauses[] = ' civicrm_group.id IN (' . implode(', ', array_keys($this->_viewPermissionedGroups[$groupKey])) . " ) "; $tables['civicrm_group'] = 1; @@ -245,7 +245,7 @@ public function getContactEmails($uids) { $dao = CRM_Core_DAO::executeQuery($sql); - $emails = array(); + $emails = []; while ($dao->fetch()) { $emails[] = $dao->email; } @@ -292,13 +292,13 @@ public function isModulePermissionSupported() { * a comma separated list of email addresses */ public function permissionEmails($permissionName) { - static $_cache = array(); + static $_cache = []; if (isset($_cache[$permissionName])) { return $_cache[$permissionName]; } - $uids = array(); + $uids = []; $sql = " SELECT {users}.uid, {role_permission}.permission FROM {users} diff --git a/CRM/Core/Permission/Joomla.php b/CRM/Core/Permission/Joomla.php index afe3a5669a92..2eea7228a8e7 100644 --- a/CRM/Core/Permission/Joomla.php +++ b/CRM/Core/Permission/Joomla.php @@ -120,7 +120,7 @@ public function translateJoomlaPermission($perm) { return CRM_Core_Permission::ALWAYS_DENY_PERMISSION; case NULL: - return array('civicrm.' . CRM_Utils_String::munge(strtolower($name)), 'com_civicrm'); + return ['civicrm.' . CRM_Utils_String::munge(strtolower($name)), 'com_civicrm']; default: return CRM_Core_Permission::ALWAYS_DENY_PERMISSION; @@ -144,7 +144,7 @@ public function checkGroupRole($array) { * @inheritDoc */ public function upgradePermissions($permissions) { - $translatedPerms = array(); + $translatedPerms = []; // Flipping the $permissions array gives us just the raw names of the // permissions. The descriptions, etc., are irrelevant for the purposes of @@ -188,7 +188,7 @@ private function getUserGroupPermsAssociations() { // Joomla gotcha: loadObject returns NULL in the case of no matches. $result = $db->loadObject(); - return $result ? json_decode($result->rules) : (object) array(); + return $result ? json_decode($result->rules) : (object) []; } /** diff --git a/CRM/Core/Permission/Temp.php b/CRM/Core/Permission/Temp.php index ae52b512f2d8..18740068a917 100644 --- a/CRM/Core/Permission/Temp.php +++ b/CRM/Core/Permission/Temp.php @@ -103,7 +103,7 @@ public function check($perm) { * Array(string $permName => bool $granted). */ protected function index($grants) { - $idx = array(); + $idx = []; foreach ($grants as $grant) { foreach ($grant as $perm) { $idx[$perm] = 1; diff --git a/CRM/Core/Permission/WordPress.php b/CRM/Core/Permission/WordPress.php index 9fe039fd27e9..dc5224f7f963 100644 --- a/CRM/Core/Permission/WordPress.php +++ b/CRM/Core/Permission/WordPress.php @@ -49,9 +49,9 @@ class CRM_Core_Permission_WordPress extends CRM_Core_Permission_Base { */ public function check($str, $userId = NULL) { // Generic cms 'administer users' role tranlates to users with the 'edit_users' capability' in WordPress - $str = $this->translatePermission($str, 'WordPress', array( + $str = $this->translatePermission($str, 'WordPress', [ 'administer users' => 'edit_users', - )); + ]); if ($str == CRM_Core_Permission::ALWAYS_DENY_PERMISSION) { return FALSE; } diff --git a/CRM/Core/PrevNextCache/Redis.php b/CRM/Core/PrevNextCache/Redis.php index 8e4ef801ff0d..a08d9ba0c614 100644 --- a/CRM/Core/PrevNextCache/Redis.php +++ b/CRM/Core/PrevNextCache/Redis.php @@ -249,7 +249,7 @@ private function initCacheKey($cacheKey) { foreach ($this->redis->zRange($allKey, -1, -1, TRUE) as $lastElem => $lastScore) { $maxScore = $lastScore; } - return array($allKey, $dataKey, $selKey, $maxScore); + return [$allKey, $dataKey, $selKey, $maxScore]; } } diff --git a/CRM/Core/PrevNextCache/Sql.php b/CRM/Core/PrevNextCache/Sql.php index efa1756a0219..51f767bee078 100644 --- a/CRM/Core/PrevNextCache/Sql.php +++ b/CRM/Core/PrevNextCache/Sql.php @@ -91,7 +91,7 @@ public function markSelection($cacheKey, $action, $ids = NULL) { if (!$cacheKey) { return; } - $params = array(); + $params = []; if ($ids && $cacheKey && $action) { if (is_array($ids)) { @@ -106,17 +106,17 @@ public function markSelection($cacheKey, $action, $ids = NULL) { WHERE cacheKey = %1 AND (entity_id1 = %2 OR entity_id2 = %2) "; - $params[2] = array("{$ids}", 'Integer'); + $params[2] = ["{$ids}", 'Integer']; } if ($action == 'select') { $whereClause .= "AND is_selected = 0"; $sql = "UPDATE civicrm_prevnext_cache SET is_selected = 1 {$whereClause}"; - $params[1] = array($cacheKey, 'String'); + $params[1] = [$cacheKey, 'String']; } elseif ($action == 'unselect') { $whereClause .= "AND is_selected = 1"; $sql = "UPDATE civicrm_prevnext_cache SET is_selected = 0 {$whereClause}"; - $params[1] = array($cacheKey, 'String'); + $params[1] = [$cacheKey, 'String']; } // default action is reseting } @@ -126,7 +126,7 @@ public function markSelection($cacheKey, $action, $ids = NULL) { SET is_selected = 0 WHERE cacheKey = %1 AND is_selected = 1 "; - $params[1] = array($cacheKey, 'String'); + $params[1] = [$cacheKey, 'String']; } CRM_Core_DAO::executeQuery($sql, $params); } @@ -147,7 +147,7 @@ public function getSelection($cacheKey, $action = 'get') { if (!$cacheKey) { return NULL; } - $params = array(); + $params = []; if ($cacheKey && ($action == 'get' || $action == 'getall')) { $actionGet = ($action == "get") ? " AND is_selected = 1 " : ""; @@ -157,9 +157,9 @@ public function getSelection($cacheKey, $action = 'get') { $actionGet ORDER BY id "; - $params[1] = array($cacheKey, 'String'); + $params[1] = [$cacheKey, 'String']; - $contactIds = array($cacheKey => array()); + $contactIds = [$cacheKey => []]; $cIdDao = CRM_Core_DAO::executeQuery($sql, $params); while ($cIdDao->fetch()) { $contactIds[$cacheKey][$cIdDao->entity_id1] = 1; @@ -223,16 +223,16 @@ public function getPositions($cacheKey, $id1) { */ public function deleteItem($id = NULL, $cacheKey = NULL) { $sql = "DELETE FROM civicrm_prevnext_cache WHERE (1)"; - $params = array(); + $params = []; if (is_numeric($id)) { $sql .= " AND ( entity_id1 = %2 OR entity_id2 = %2 )"; - $params[2] = array($id, 'Integer'); + $params[2] = [$id, 'Integer']; } if (isset($cacheKey)) { $sql .= " AND cacheKey = %3"; - $params[3] = array($cacheKey, 'String'); + $params[3] = [$cacheKey, 'String']; } CRM_Core_DAO::executeQuery($sql, $params); } @@ -259,7 +259,7 @@ public function getCount($cacheKey) { * List of contact IDs. */ public function fetch($cacheKey, $offset, $rowCount) { - $cids = array(); + $cids = []; $dao = CRM_Utils_SQL_Select::from('civicrm_prevnext_cache pnc') ->where('pnc.cacheKey = @cacheKey', ['cacheKey' => $cacheKey]) ->select('pnc.entity_id1 as cid') diff --git a/CRM/Core/PseudoConstant.php b/CRM/Core/PseudoConstant.php index fb59a3c5f86a..96f9bba42314 100644 --- a/CRM/Core/PseudoConstant.php +++ b/CRM/Core/PseudoConstant.php @@ -77,7 +77,7 @@ class CRM_Core_PseudoConstant { * States/provinces abbreviations * @var array */ - private static $stateProvinceAbbreviation = array(); + private static $stateProvinceAbbreviation = []; /** * Country. @@ -198,7 +198,7 @@ class CRM_Core_PseudoConstant { * array on success, FALSE on error. * */ - public static function get($daoName, $fieldName, $params = array(), $context = NULL) { + public static function get($daoName, $fieldName, $params = [], $context = NULL) { CRM_Core_DAO::buildOptionsContext($context); $flip = !empty($params['flip']); // Historically this was 'false' but according to the notes in @@ -206,13 +206,13 @@ public static function get($daoName, $fieldName, $params = array(), $context = N // timidly changing for 'search' only to fix world_region in search options. $localizeDefault = in_array($context, ['search']) ? TRUE : FALSE; // Merge params with defaults - $params += array( + $params += [ 'grouping' => FALSE, 'localize' => $localizeDefault, 'onlyActive' => ($context == 'validate' || $context == 'get') ? FALSE : TRUE, 'fresh' => FALSE, 'context' => $context, - ); + ]; $entity = CRM_Core_DAO_AllCoreTables::getBriefName(CRM_Core_DAO_AllCoreTables::getCanonicalClassName($daoName)); // Custom fields are not in the schema @@ -252,11 +252,11 @@ public static function get($daoName, $fieldName, $params = array(), $context = N } // Merge params with schema defaults - $params += array( - 'condition' => CRM_Utils_Array::value('condition', $pseudoconstant, array()), + $params += [ + 'condition' => CRM_Utils_Array::value('condition', $pseudoconstant, []), 'keyColumn' => CRM_Utils_Array::value('keyColumn', $pseudoconstant), 'labelColumn' => CRM_Utils_Array::value('labelColumn', $pseudoconstant), - ); + ]; if ($context == 'abbreviate') { switch ($fieldName) { @@ -320,7 +320,7 @@ public static function get($daoName, $fieldName, $params = array(), $context = N $select = "SELECT %1 AS id, %2 AS label"; $from = "FROM %3"; - $wheres = array(); + $wheres = []; $order = "ORDER BY %2"; // Use machine name in certain contexts @@ -339,7 +339,7 @@ public static function get($daoName, $fieldName, $params = array(), $context = N } // onlyActive param will automatically filter on common flags if (!empty($params['onlyActive'])) { - foreach (array('is_active' => 1, 'is_deleted' => 0, 'is_test' => 0, 'is_hidden' => 0) as $flag => $val) { + foreach (['is_active' => 1, 'is_deleted' => 0, 'is_test' => 0, 'is_hidden' => 0] as $flag => $val) { if (in_array($flag, $availableFields)) { $wheres[] = "$flag = $val"; } @@ -349,14 +349,14 @@ public static function get($daoName, $fieldName, $params = array(), $context = N if (in_array('domain_id', $availableFields)) { $wheres[] = 'domain_id = ' . CRM_Core_Config::domainID(); } - $queryParams = array( - 1 => array($params['keyColumn'], 'String', CRM_Core_DAO::QUERY_FORMAT_NO_QUOTES), - 2 => array($params['labelColumn'], 'String', CRM_Core_DAO::QUERY_FORMAT_NO_QUOTES), - 3 => array($pseudoconstant['table'], 'String', CRM_Core_DAO::QUERY_FORMAT_NO_QUOTES), - ); + $queryParams = [ + 1 => [$params['keyColumn'], 'String', CRM_Core_DAO::QUERY_FORMAT_NO_QUOTES], + 2 => [$params['labelColumn'], 'String', CRM_Core_DAO::QUERY_FORMAT_NO_QUOTES], + 3 => [$pseudoconstant['table'], 'String', CRM_Core_DAO::QUERY_FORMAT_NO_QUOTES], + ]; // Add orderColumn param if (!empty($params['orderColumn'])) { - $queryParams[4] = array($params['orderColumn'], 'String', CRM_Core_DAO::QUERY_FORMAT_NO_QUOTES); + $queryParams[4] = [$params['orderColumn'], 'String', CRM_Core_DAO::QUERY_FORMAT_NO_QUOTES]; $order = "ORDER BY %4"; } // Support no sorting if $params[orderColumn] is FALSE @@ -368,7 +368,7 @@ public static function get($daoName, $fieldName, $params = array(), $context = N $order = "ORDER BY weight"; } - $output = array(); + $output = []; $query = "$select $from"; if ($wheres) { $query .= " WHERE " . implode($wheres, ' AND '); @@ -381,7 +381,7 @@ public static function get($daoName, $fieldName, $params = array(), $context = N $dao->free(); // Localize results if (!empty($params['localize']) || $pseudoconstant['table'] == 'civicrm_country' || $pseudoconstant['table'] == 'civicrm_state_province') { - $I18nParams = array(); + $I18nParams = []; if (isset($fieldSpec['localize_context'])) { $I18nParams['context'] = $fieldSpec['localize_context']; } @@ -401,7 +401,7 @@ public static function get($daoName, $fieldName, $params = array(), $context = N // Return "Yes" and "No" for boolean fields elseif (CRM_Utils_Array::value('type', $fieldSpec) === CRM_Utils_Type::T_BOOLEAN) { - $output = $context == 'validate' ? array(0, 1) : CRM_Core_SelectValues::boolean(); + $output = $context == 'validate' ? [0, 1] : CRM_Core_SelectValues::boolean(); CRM_Utils_Hook::fieldOptions($entity, $fieldName, $output, $params); return $flip ? array_flip($output) : $output; } @@ -569,7 +569,7 @@ public static function populate( } $object->find(); - $var = array(); + $var = []; while ($object->fetch()) { $var[$object->$key] = $object->$retrieve; } @@ -619,7 +619,7 @@ public static function &activityType() { $index .= '_' . (int) $onlyComponentActivities; if (NULL === self::$activityType) { - self::$activityType = array(); + self::$activityType = []; } if (!isset(self::$activityType[$index]) || $reset) { @@ -632,7 +632,7 @@ public static function &activityType() { $componentClause = " v.component_id IS NOT NULL"; } - $componentIds = array(); + $componentIds = []; $compInfo = CRM_Core_Component::getEnabledComponents(); // build filter for listing activity types only if their @@ -690,7 +690,7 @@ public static function &stateProvince($id = FALSE, $limit = TRUE) { if ($limit) { $countryIsoCodes = self::countryIsoCode(); $limitCodes = CRM_Core_BAO_Country::provinceLimit(); - $limitIds = array(); + $limitIds = []; foreach ($limitCodes as $code) { $limitIds = array_merge($limitIds, array_keys($countryIsoCodes, $code)); } @@ -707,9 +707,9 @@ public static function &stateProvince($id = FALSE, $limit = TRUE) { $tsLocale = CRM_Core_I18n::getLocale(); if ($tsLocale != '' and $tsLocale != 'en_US') { $i18n = CRM_Core_I18n::singleton(); - $i18n->localizeArray(self::$stateProvince, array( + $i18n->localizeArray(self::$stateProvince, [ 'context' => 'province', - )); + ]); self::$stateProvince = CRM_Utils_Array::asort(self::$stateProvince); } } @@ -744,12 +744,12 @@ public static function stateProvinceAbbreviation($id = FALSE, $limit = TRUE) { $query = "SELECT abbreviation FROM civicrm_state_province WHERE id = %1"; - $params = array( - 1 => array( + $params = [ + 1 => [ $id, 'Integer', - ), - ); + ], + ]; self::$stateProvinceAbbreviation[$id] = CRM_Core_DAO::singleValueQuery($query, $params); } return self::$stateProvinceAbbreviation[$id]; @@ -760,7 +760,7 @@ public static function stateProvinceAbbreviation($id = FALSE, $limit = TRUE) { if ($limit) { $countryIsoCodes = self::countryIsoCode(); $limitCodes = CRM_Core_BAO_Country::provinceLimit(); - $limitIds = array(); + $limitIds = []; foreach ($limitCodes as $code) { $tmpArray = array_keys($countryIsoCodes, $code); @@ -788,7 +788,7 @@ public static function stateProvinceAbbreviation($id = FALSE, $limit = TRUE) { */ public static function stateProvinceAbbreviationForCountry($countryID) { if (!isset(\Civi::$statics[__CLASS__]['stateProvinceAbbreviationForCountry'][$countryID])) { - \Civi::$statics[__CLASS__]['stateProvinceAbbreviationForCountry'][$countryID] = array(); + \Civi::$statics[__CLASS__]['stateProvinceAbbreviationForCountry'][$countryID] = []; } self::populate(\Civi::$statics[__CLASS__]['stateProvinceAbbreviationForCountry'][$countryID], 'CRM_Core_DAO_StateProvince', TRUE, 'abbreviation', 'is_active', "country_id = " . (int) $countryID, 'abbreviation'); return \Civi::$statics[__CLASS__]['stateProvinceAbbreviationForCountry'][$countryID]; @@ -825,7 +825,7 @@ public static function country($id = FALSE, $applyLimit = TRUE) { if (($id && !CRM_Utils_Array::value($id, self::$country)) || !self::$country || !$id) { $config = CRM_Core_Config::singleton(); - $limitCodes = array(); + $limitCodes = []; if ($applyLimit) { // limit the country list to the countries specified in CIVICRM_COUNTRY_LIMIT @@ -833,9 +833,9 @@ public static function country($id = FALSE, $applyLimit = TRUE) { // K/P: We need to fix this, i dont think it works with new setting files $limitCodes = CRM_Core_BAO_Country::countryLimit(); if (!is_array($limitCodes)) { - $limitCodes = array( + $limitCodes = [ $config->countryLimit => 1, - ); + ]; } $limitCodes = array_intersect(self::countryIsoCode(), $limitCodes); @@ -864,9 +864,9 @@ public static function country($id = FALSE, $applyLimit = TRUE) { $tsLocale = CRM_Core_I18n::getLocale(); if ($tsLocale != '' and $tsLocale != 'en_US') { $i18n = CRM_Core_I18n::singleton(); - $i18n->localizeArray(self::$country, array( + $i18n->localizeArray(self::$country, [ 'context' => 'country', - )); + ]); self::$country = CRM_Utils_Array::asort(self::$country); } } @@ -1040,7 +1040,7 @@ public static function &staticGroup($onlyPublic = FALSE, $groupType = NULL, $exc public static function &relationshipType($valueColumnName = 'label', $reset = FALSE, $isActive = 1) { $cacheKey = $valueColumnName . '::' . $isActive; if (!CRM_Utils_Array::value($cacheKey, self::$relationshipType) || $reset) { - self::$relationshipType[$cacheKey] = array(); + self::$relationshipType[$cacheKey] = []; //now we have name/label columns CRM-3336 $column_a_b = "{$valueColumnName}_a_b"; @@ -1055,7 +1055,7 @@ public static function &relationshipType($valueColumnName = 'label', $reset = FA $relationshipTypeDAO->find(); while ($relationshipTypeDAO->fetch()) { - self::$relationshipType[$cacheKey][$relationshipTypeDAO->id] = array( + self::$relationshipType[$cacheKey][$relationshipTypeDAO->id] = [ 'id' => $relationshipTypeDAO->id, $column_a_b => $relationshipTypeDAO->$column_a_b, $column_b_a => $relationshipTypeDAO->$column_b_a, @@ -1063,7 +1063,7 @@ public static function &relationshipType($valueColumnName = 'label', $reset = FA 'contact_type_b' => "$relationshipTypeDAO->contact_type_b", 'contact_sub_type_a' => "$relationshipTypeDAO->contact_sub_type_a", 'contact_sub_type_b' => "$relationshipTypeDAO->contact_sub_type_b", - ); + ]; } } @@ -1084,7 +1084,7 @@ public static function ¤cyCode() { $query = "SELECT name FROM civicrm_currency"; $dao = CRM_Core_DAO::executeQuery($query); - $currencyCode = array(); + $currencyCode = []; while ($dao->fetch()) { self::$currencyCode[] = $dao->name; } @@ -1229,10 +1229,10 @@ public static function &worldRegion($id = FALSE) { */ public static function &activityStatus($column = 'label') { if (NULL === self::$activityStatus) { - self::$activityStatus = array(); + self::$activityStatus = []; } if (!array_key_exists($column, self::$activityStatus)) { - self::$activityStatus[$column] = array(); + self::$activityStatus[$column] = []; self::$activityStatus[$column] = CRM_Core_OptionGroup::values('activity_status', FALSE, FALSE, FALSE, NULL, $column); } @@ -1255,7 +1255,7 @@ public static function &activityStatus($column = 'label') { */ public static function &visibility($column = 'label') { if (!isset(self::$visibility)) { - self::$visibility = array(); + self::$visibility = []; } if (!isset(self::$visibility[$column])) { @@ -1276,7 +1276,7 @@ public static function &stateProvinceForCountry($countryID, $field = 'name') { $cacheKey = "{$countryID}_{$field}"; if (!$_cache) { - $_cache = array(); + $_cache = []; } if (!empty($_cache[$cacheKey])) { @@ -1288,16 +1288,16 @@ public static function &stateProvinceForCountry($countryID, $field = 'name') { FROM civicrm_state_province WHERE country_id = %1 ORDER BY name"; - $params = array( - 1 => array( + $params = [ + 1 => [ $countryID, 'Integer', - ), - ); + ], + ]; $dao = CRM_Core_DAO::executeQuery($query, $params); - $result = array(); + $result = []; while ($dao->fetch()) { $result[$dao->id] = $dao->name; } @@ -1307,9 +1307,9 @@ public static function &stateProvinceForCountry($countryID, $field = 'name') { $tsLocale = CRM_Core_I18n::getLocale(); if ($tsLocale != '' and $tsLocale != 'en_US') { $i18n = CRM_Core_I18n::singleton(); - $i18n->localizeArray($result, array( + $i18n->localizeArray($result, [ 'context' => 'province', - )); + ]); $result = CRM_Utils_Array::asort($result); } @@ -1337,7 +1337,7 @@ public static function &countyForState($stateID) { $dao = CRM_Core_DAO::executeQuery($query); - $result = array(); + $result = []; while ($dao->fetch()) { $result[$dao->id] = $dao->abbreviation . ': ' . $dao->name; } @@ -1348,7 +1348,7 @@ public static function &countyForState($stateID) { $cacheKey = "{$stateID}_name"; if (!$_cache) { - $_cache = array(); + $_cache = []; } if (!empty($_cache[$cacheKey])) { @@ -1360,16 +1360,16 @@ public static function &countyForState($stateID) { FROM civicrm_county WHERE state_province_id = %1 ORDER BY name"; - $params = array( - 1 => array( + $params = [ + 1 => [ $stateID, 'Integer', - ), - ); + ], + ]; $dao = CRM_Core_DAO::executeQuery($query, $params); - $result = array(); + $result = []; while ($dao->fetch()) { $result[$dao->id] = $dao->name; } @@ -1397,7 +1397,7 @@ public static function countryIDForStateID($stateID) { FROM civicrm_state_province WHERE id = %1 "; - $params = array(1 => array($stateID, 'Integer')); + $params = [1 => [$stateID, 'Integer']]; return CRM_Core_DAO::singleValueQuery($query, $params); } @@ -1418,7 +1418,7 @@ public static function countryIDForStateID($stateID) { */ public static function greeting($filter, $columnName = 'label') { if (!isset(Civi::$statics[__CLASS__]['greeting'])) { - Civi::$statics[__CLASS__]['greeting'] = array(); + Civi::$statics[__CLASS__]['greeting'] = []; } $index = $filter['greeting_type'] . '_' . $columnName; @@ -1469,7 +1469,7 @@ public static function greeting($filter, $columnName = 'label') { */ public static function &getExtensions() { if (!self::$extensions) { - self::$extensions = array(); + self::$extensions = []; $sql = ' SELECT full_name, label FROM civicrm_extension @@ -1535,13 +1535,13 @@ public static function getModuleExtensions($fresh = FALSE) { */ public static function getTaxRates() { if (!isset(Civi::$statics[__CLASS__]['taxRates'])) { - Civi::$statics[__CLASS__]['taxRates'] = array(); - $option = civicrm_api3('option_value', 'get', array( + Civi::$statics[__CLASS__]['taxRates'] = []; + $option = civicrm_api3('option_value', 'get', [ 'sequential' => 1, 'option_group_id' => 'account_relationship', 'name' => 'Sales Tax Account is', - )); - $value = array(); + ]); + $value = []; if ($option['count'] !== 0) { if ($option['count'] > 1) { foreach ($option['values'] as $opt) { @@ -1578,11 +1578,11 @@ public static function getTaxRates() { * @return array */ public static function emailOnHoldOptions() { - return array( + return [ '0' => ts('No'), '1' => ts('On Hold Bounce'), '2' => ts('On Hold Opt Out'), - ); + ]; } } diff --git a/CRM/Core/QuickForm/Action/Display.php b/CRM/Core/QuickForm/Action/Display.php index 578b9c5fae78..9118e2f2f3d8 100644 --- a/CRM/Core/QuickForm/Action/Display.php +++ b/CRM/Core/QuickForm/Action/Display.php @@ -152,7 +152,7 @@ public function renderForm(&$page) { } if ($controller->_QFResponseType == 'json') { - $response = array('content' => $html); + $response = ['content' => $html]; if (!empty($page->ajaxResponse)) { $response += $page->ajaxResponse; } @@ -169,7 +169,7 @@ public function renderForm(&$page) { $content, "{$page->_name}.pdf", FALSE, - array('paper_size' => 'a3', 'orientation' => 'landscape') + ['paper_size' => 'a3', 'orientation' => 'landscape'] ); } else { diff --git a/CRM/Core/QuickForm/Action/Upload.php b/CRM/Core/QuickForm/Action/Upload.php index 9c60e1cb843c..b684036a1927 100644 --- a/CRM/Core/QuickForm/Action/Upload.php +++ b/CRM/Core/QuickForm/Action/Upload.php @@ -96,19 +96,19 @@ public function upload(&$page, &$data, $pageName, $uploadName) { $newName = CRM_Utils_File::makeFileName($value['name']); $status = $element->moveUploadedFile($this->_uploadDir, $newName); if (!$status) { - CRM_Core_Error::statusBounce(ts('We could not move the uploaded file %1 to the upload directory %2. Please verify that the \'Temporary Files\' setting points to a valid path which is writable by your web server.', array( + CRM_Core_Error::statusBounce(ts('We could not move the uploaded file %1 to the upload directory %2. Please verify that the \'Temporary Files\' setting points to a valid path which is writable by your web server.', [ 1 => $value['name'], 2 => $this->_uploadDir, - ))); + ])); } if (!empty($data['values'][$pageName][$uploadName]['name'])) { @unlink($this->_uploadDir . $data['values'][$pageName][$uploadName]); } - $value = array( + $value = [ 'name' => $this->_uploadDir . $newName, 'type' => $value['type'], - ); + ]; //CRM-19460 handle brackets if present in $uploadName, similar things we do it for all other inputs. $value = $element->_prepareValue($value, TRUE); $data['values'][$pageName] = HTML_QuickForm::arrayMerge($data['values'][$pageName], $value); diff --git a/CRM/Core/QuickForm/GroupMultiSelect.php b/CRM/Core/QuickForm/GroupMultiSelect.php index fe20778e805f..051ccda21753 100644 --- a/CRM/Core/QuickForm/GroupMultiSelect.php +++ b/CRM/Core/QuickForm/GroupMultiSelect.php @@ -65,8 +65,8 @@ public function toHtml() { foreach ($this->_options as $option) { - $_labelAttributes = array('style', 'class', 'onmouseover', 'onmouseout'); - $labelAttributes = array(); + $_labelAttributes = ['style', 'class', 'onmouseover', 'onmouseout']; + $labelAttributes = []; foreach ($_labelAttributes as $attr) { if (isset($option['attr'][$attr])) { $labelAttributes[$attr] = $option['attr'][$attr]; @@ -92,19 +92,19 @@ public function toHtml() { $strHtmlRemove = ''; // build the select all button with all its attributes - $attributes = array('onclick' => "{$this->_jsPrefix}{$this->_jsPostfix}('" . $this->getName() . "', 1);"); + $attributes = ['onclick' => "{$this->_jsPrefix}{$this->_jsPostfix}('" . $this->getName() . "', 1);"]; $this->_allButtonAttributes = array_merge($this->_allButtonAttributes, $attributes); $attrStrAll = $this->_getAttrString($this->_allButtonAttributes); $strHtmlAll = "" . PHP_EOL; // build the select none button with all its attributes - $attributes = array('onclick' => "{$this->_jsPrefix}{$this->_jsPostfix}('" . $this->getName() . "', 0);"); + $attributes = ['onclick' => "{$this->_jsPrefix}{$this->_jsPostfix}('" . $this->getName() . "', 0);"]; $this->_noneButtonAttributes = array_merge($this->_noneButtonAttributes, $attributes); $attrStrNone = $this->_getAttrString($this->_noneButtonAttributes); $strHtmlNone = "" . PHP_EOL; // build the toggle selection button with all its attributes - $attributes = array('onclick' => "{$this->_jsPrefix}{$this->_jsPostfix}('" . $this->getName() . "', 2);"); + $attributes = ['onclick' => "{$this->_jsPrefix}{$this->_jsPostfix}('" . $this->getName() . "', 2);"]; $this->_toggleButtonAttributes = array_merge($this->_toggleButtonAttributes, $attributes); $attrStrToggle = $this->_getAttrString($this->_toggleButtonAttributes); $strHtmlToggle = "" . PHP_EOL; @@ -116,26 +116,26 @@ public function toHtml() { // ... or a dual multi-select // set name of Select From Box - $this->_attributesUnselected = array( + $this->_attributesUnselected = [ 'name' => '__' . $selectName, 'ondblclick' => "{$this->_jsPrefix}{$this->_jsPostfix}(this.form.elements['__" . $selectName . "'], this.form.elements['_" . $selectName . "'], this.form.elements['" . $selectName . "'], 'add')", - ); + ]; $this->_attributesUnselected = array_merge($this->_attributes, $this->_attributesUnselected); $attrUnselected = $this->_getAttrString($this->_attributesUnselected); // set name of Select To Box - $this->_attributesSelected = array( + $this->_attributesSelected = [ 'name' => '_' . $selectName, 'ondblclick' => "{$this->_jsPrefix}{$this->_jsPostfix}(this.form.elements['__" . $selectName . "'], this.form.elements['_" . $selectName . "'], this.form.elements['" . $selectName . "'], 'remove')", - ); + ]; $this->_attributesSelected = array_merge($this->_attributes, $this->_attributesSelected); $attrSelected = $this->_getAttrString($this->_attributesSelected); // set name of Select hidden Box - $this->_attributesHidden = array( + $this->_attributesHidden = [ 'name' => $selectName, 'style' => 'overflow: hidden; visibility: hidden; width: 1px; height: 0;', - ); + ]; $this->_attributesHidden = array_merge($this->_attributes, $this->_attributesHidden); $attrHidden = $this->_getAttrString($this->_attributesHidden); @@ -145,11 +145,11 @@ public function toHtml() { $arrHtmlSelected = array_fill(0, $append, ' '); } else { - $arrHtmlSelected = array(); + $arrHtmlSelected = []; } $options = count($this->_options); - $arrHtmlUnselected = array(); + $arrHtmlUnselected = []; if ($options > 0) { $arrHtmlHidden = array_fill(0, $options, ' '); @@ -176,7 +176,7 @@ public function toHtml() { } } else { - $arrHtmlHidden = array(); + $arrHtmlHidden = []; } // The 'unselected' multi-select which appears on the left @@ -207,43 +207,43 @@ public function toHtml() { $strHtmlHidden .= ''; // build the remove button with all its attributes - $attributes = array('onclick' => "{$this->_jsPrefix}{$this->_jsPostfix}(this.form.elements['__" . $selectName . "'], this.form.elements['_" . $selectName . "'], this.form.elements['" . $selectName . "'], 'remove'); return false;"); + $attributes = ['onclick' => "{$this->_jsPrefix}{$this->_jsPostfix}(this.form.elements['__" . $selectName . "'], this.form.elements['_" . $selectName . "'], this.form.elements['" . $selectName . "'], 'remove'); return false;"]; $this->_removeButtonAttributes = array_merge($this->_removeButtonAttributes, $attributes); $attrStrRemove = $this->_getAttrString($this->_removeButtonAttributes); $strHtmlRemove = "" . PHP_EOL; // build the add button with all its attributes - $attributes = array('onclick' => "{$this->_jsPrefix}{$this->_jsPostfix}(this.form.elements['__" . $selectName . "'], this.form.elements['_" . $selectName . "'], this.form.elements['" . $selectName . "'], 'add'); return false;"); + $attributes = ['onclick' => "{$this->_jsPrefix}{$this->_jsPostfix}(this.form.elements['__" . $selectName . "'], this.form.elements['_" . $selectName . "'], this.form.elements['" . $selectName . "'], 'add'); return false;"]; $this->_addButtonAttributes = array_merge($this->_addButtonAttributes, $attributes); $attrStrAdd = $this->_getAttrString($this->_addButtonAttributes); $strHtmlAdd = "" . PHP_EOL; // build the select all button with all its attributes - $attributes = array('onclick' => "{$this->_jsPrefix}{$this->_jsPostfix}(this.form.elements['__" . $selectName . "'], this.form.elements['_" . $selectName . "'], this.form.elements['" . $selectName . "'], 'all'); return false;"); + $attributes = ['onclick' => "{$this->_jsPrefix}{$this->_jsPostfix}(this.form.elements['__" . $selectName . "'], this.form.elements['_" . $selectName . "'], this.form.elements['" . $selectName . "'], 'all'); return false;"]; $this->_allButtonAttributes = array_merge($this->_allButtonAttributes, $attributes); $attrStrAll = $this->_getAttrString($this->_allButtonAttributes); $strHtmlAll = "" . PHP_EOL; // build the select none button with all its attributes - $attributes = array('onclick' => "{$this->_jsPrefix}{$this->_jsPostfix}(this.form.elements['__" . $selectName . "'], this.form.elements['_" . $selectName . "'], this.form.elements['" . $selectName . "'], 'none'); return false;"); + $attributes = ['onclick' => "{$this->_jsPrefix}{$this->_jsPostfix}(this.form.elements['__" . $selectName . "'], this.form.elements['_" . $selectName . "'], this.form.elements['" . $selectName . "'], 'none'); return false;"]; $this->_noneButtonAttributes = array_merge($this->_noneButtonAttributes, $attributes); $attrStrNone = $this->_getAttrString($this->_noneButtonAttributes); $strHtmlNone = "" . PHP_EOL; // build the toggle button with all its attributes - $attributes = array('onclick' => "{$this->_jsPrefix}{$this->_jsPostfix}(this.form.elements['__" . $selectName . "'], this.form.elements['_" . $selectName . "'], this.form.elements['" . $selectName . "'], 'toggle'); return false;"); + $attributes = ['onclick' => "{$this->_jsPrefix}{$this->_jsPostfix}(this.form.elements['__" . $selectName . "'], this.form.elements['_" . $selectName . "'], this.form.elements['" . $selectName . "'], 'toggle'); return false;"]; $this->_toggleButtonAttributes = array_merge($this->_toggleButtonAttributes, $attributes); $attrStrToggle = $this->_getAttrString($this->_toggleButtonAttributes); $strHtmlToggle = "" . PHP_EOL; // build the move up button with all its attributes - $attributes = array('onclick' => "{$this->_jsPrefix}moveUp(this.form.elements['_" . $selectName . "'], this.form.elements['" . $selectName . "']); return false;"); + $attributes = ['onclick' => "{$this->_jsPrefix}moveUp(this.form.elements['_" . $selectName . "'], this.form.elements['" . $selectName . "']); return false;"]; $this->_upButtonAttributes = array_merge($this->_upButtonAttributes, $attributes); $attrStrUp = $this->_getAttrString($this->_upButtonAttributes); $strHtmlMoveUp = "" . PHP_EOL; // build the move down button with all its attributes - $attributes = array('onclick' => "{$this->_jsPrefix}moveDown(this.form.elements['_" . $selectName . "'], this.form.elements['" . $selectName . "']); return false;"); + $attributes = ['onclick' => "{$this->_jsPrefix}moveDown(this.form.elements['_" . $selectName . "'], this.form.elements['" . $selectName . "']); return false;"]; $this->_downButtonAttributes = array_merge($this->_downButtonAttributes, $attributes); $attrStrDown = $this->_getAttrString($this->_downButtonAttributes); $strHtmlMoveDown = "" . PHP_EOL; @@ -271,7 +271,7 @@ public function toHtml() { $strHtml = preg_replace('/\s*.*\s*/i', '', $strHtml); } - $placeHolders = array( + $placeHolders = [ '{stylesheet}', '{javascript}', '{class}', @@ -284,8 +284,8 @@ public function toHtml() { '{toggle}', '{moveup}', '{movedown}', - ); - $htmlElements = array( + ]; + $htmlElements = [ $this->getElementCss(FALSE), $this->getElementJs(FALSE), $this->_tableAttributes, @@ -298,7 +298,7 @@ public function toHtml() { $strHtmlToggle, $strHtmlMoveUp, $strHtmlMoveDown, - ); + ]; $strHtml = str_replace($placeHolders, $htmlElements, $strHtml); diff --git a/CRM/Core/QuickForm/NestedAdvMultiSelect.php b/CRM/Core/QuickForm/NestedAdvMultiSelect.php index a210b710b17f..84a787a1c643 100644 --- a/CRM/Core/QuickForm/NestedAdvMultiSelect.php +++ b/CRM/Core/QuickForm/NestedAdvMultiSelect.php @@ -67,7 +67,7 @@ public function load( ) { switch (TRUE) { case ($options instanceof Iterator): - $arr = array(); + $arr = []; foreach ($options as $key => $val) { $arr[$key] = $val; } diff --git a/CRM/Core/Reference/Basic.php b/CRM/Core/Reference/Basic.php index 797d5832ab9d..a3e1fe73f8a7 100644 --- a/CRM/Core/Reference/Basic.php +++ b/CRM/Core/Reference/Basic.php @@ -83,9 +83,9 @@ public function findReferences($targetDao) { if (!CRM_Core_BAO_SchemaHandler::checkIfFieldExists($this->getReferenceTable(), 'id')) { $select = '*'; } - $params = array( - 1 => array($targetDao->$targetColumn, 'String'), - ); + $params = [ + 1 => [$targetDao->$targetColumn, 'String'], + ]; $sql = <<getReferenceTable()} @@ -104,22 +104,22 @@ public function findReferences($targetDao) { */ public function getReferenceCount($targetDao) { $targetColumn = $this->getTargetKey(); - $params = array( - 1 => array($targetDao->$targetColumn, 'String'), - ); + $params = [ + 1 => [$targetDao->$targetColumn, 'String'], + ]; $sql = <<getReferenceTable()} WHERE {$this->getReferenceKey()} = %1 EOS; - return array( - 'name' => implode(':', array('sql', $this->getReferenceTable(), $this->getReferenceKey())), + return [ + 'name' => implode(':', ['sql', $this->getReferenceTable(), $this->getReferenceKey()]), 'type' => get_class($this), 'table' => $this->getReferenceTable(), 'key' => $this->getReferenceKey(), 'count' => CRM_Core_DAO::singleValueQuery($sql, $params), - ); + ]; } } diff --git a/CRM/Core/Reference/Dynamic.php b/CRM/Core/Reference/Dynamic.php index 64fc790ebc34..6c5ba398ca1e 100644 --- a/CRM/Core/Reference/Dynamic.php +++ b/CRM/Core/Reference/Dynamic.php @@ -28,12 +28,12 @@ public function findReferences($targetDao) { $refColumn = $this->getReferenceKey(); $targetColumn = $this->getTargetKey(); - $params = array( - 1 => array($targetDao->$targetColumn, 'String'), + $params = [ + 1 => [$targetDao->$targetColumn, 'String'], // If anyone complains about $targetDao::getTableName(), then could use // "{get_class($targetDao)}::getTableName();" - 2 => array($targetDao::getTableName(), 'String'), - ); + 2 => [$targetDao::getTableName(), 'String'], + ]; $sql = <<getTargetKey(); - $params = array( - 1 => array($targetDao->$targetColumn, 'String'), + $params = [ + 1 => [$targetDao->$targetColumn, 'String'], // If anyone complains about $targetDao::getTableName(), then could use // "{get_class($targetDao)}::getTableName();" - 2 => array($targetDao::getTableName(), 'String'), - ); + 2 => [$targetDao::getTableName(), 'String'], + ]; $sql = <<getTypeColumn()} = %2 EOS; - return array( - 'name' => implode(':', array('sql', $this->getReferenceTable(), $this->getReferenceKey())), + return [ + 'name' => implode(':', ['sql', $this->getReferenceTable(), $this->getReferenceKey()]), 'type' => get_class($this), 'table' => $this->getReferenceTable(), 'key' => $this->getReferenceKey(), 'count' => CRM_Core_DAO::singleValueQuery($sql, $params), - ); + ]; } } diff --git a/CRM/Core/Region.php b/CRM/Core/Region.php index 77b3e6065b2a..6ea85bc07a84 100644 --- a/CRM/Core/Region.php +++ b/CRM/Core/Region.php @@ -51,15 +51,15 @@ public function __construct($name) { civicrm_smarty_register_string_resource(); $this->_name = $name; - $this->_snippets = array(); + $this->_snippets = []; // Placeholder which represents any of the default content generated by the main Smarty template - $this->add(array( + $this->add([ 'name' => 'default', 'type' => 'markup', 'markup' => '', 'weight' => 0, - )); + ]); $this->_isSorted = TRUE; } @@ -103,12 +103,12 @@ public function __construct($name) { * @return array */ public function add($snippet) { - static $types = array('markup', 'template', 'callback', 'scriptUrl', 'script', 'jquery', 'style', 'styleUrl'); - $defaults = array( + static $types = ['markup', 'template', 'callback', 'scriptUrl', 'script', 'jquery', 'style', 'styleUrl']; + $defaults = [ 'region' => $this->_name, 'weight' => 1, 'disabled' => FALSE, - ); + ]; $snippet += $defaults; if (!isset($snippet['type'])) { foreach ($types as $type) { @@ -166,7 +166,7 @@ public function render($default, $allowCmsOverride = TRUE) { $cms = CRM_Core_Config::singleton()->userSystem; if (!$this->_isSorted) { - uasort($this->_snippets, array('CRM_Core_Region', '_cmpSnippet')); + uasort($this->_snippets, ['CRM_Core_Region', '_cmpSnippet']); $this->_isSorted = TRUE; } @@ -223,7 +223,7 @@ public function render($default, $allowCmsOverride = TRUE) { default: require_once 'CRM/Core/Error.php'; CRM_Core_Error::fatal(ts('Snippet type %1 is unrecognized', - array(1 => $snippet['type']))); + [1 => $snippet['type']])); } } return $html; diff --git a/CRM/Core/Resources.php b/CRM/Core/Resources.php index 0e4e7755ece0..49110577174c 100644 --- a/CRM/Core/Resources.php +++ b/CRM/Core/Resources.php @@ -65,23 +65,23 @@ class CRM_Core_Resources { /** * @var array free-form data tree */ - protected $settings = array(); + protected $settings = []; protected $addedSettings = FALSE; /** * @var array of callables */ - protected $settingsFactories = array(); + protected $settingsFactories = []; /** * @var array ($regionName => bool) */ - protected $addedCoreResources = array(); + protected $addedCoreResources = []; /** * @var array ($regionName => bool) */ - protected $addedCoreStyles = array(); + protected $addedCoreStyles = []; /** * @var string a value to append to JS/CSS URLs to coerce cache resets @@ -157,13 +157,13 @@ public function __construct($extMapper, $cache, $cacheCodeKey = NULL) { */ public function addPermissions($permNames) { $permNames = (array) $permNames; - $perms = array(); + $perms = []; foreach ($permNames as $permName) { $perms[$permName] = CRM_Core_Permission::check($permName); } - return $this->addSetting(array( + return $this->addSetting([ 'permissions' => $perms, - )); + ]); } /** @@ -205,13 +205,13 @@ public function addScriptFile($ext, $file, $weight = self::DEFAULT_WEIGHT, $regi * @return CRM_Core_Resources */ public function addScriptUrl($url, $weight = self::DEFAULT_WEIGHT, $region = self::DEFAULT_REGION) { - CRM_Core_Region::instance($region)->add(array( + CRM_Core_Region::instance($region)->add([ 'name' => $url, 'type' => 'scriptUrl', 'scriptUrl' => $url, 'weight' => $weight, 'region' => $region, - )); + ]); return $this; } @@ -227,13 +227,13 @@ public function addScriptUrl($url, $weight = self::DEFAULT_WEIGHT, $region = sel * @return CRM_Core_Resources */ public function addScript($code, $weight = self::DEFAULT_WEIGHT, $region = self::DEFAULT_REGION) { - CRM_Core_Region::instance($region)->add(array( + CRM_Core_Region::instance($region)->add([ // 'name' => automatic 'type' => 'script', 'script' => $code, 'weight' => $weight, 'region' => $region, - )); + ]); return $this; } @@ -254,9 +254,9 @@ public function addScript($code, $weight = self::DEFAULT_WEIGHT, $region = self: * @return CRM_Core_Resources */ public function addVars($nameSpace, $vars) { - $existing = CRM_Utils_Array::value($nameSpace, CRM_Utils_Array::value('vars', $this->settings), array()); + $existing = CRM_Utils_Array::value($nameSpace, CRM_Utils_Array::value('vars', $this->settings), []); $vars = $this->mergeSettings($existing, $vars); - $this->addSetting(array('vars' => array($nameSpace => $vars))); + $this->addSetting(['vars' => [$nameSpace => $vars]]); return $this; } @@ -273,12 +273,12 @@ public function addSetting($settings) { if (!$this->addedSettings) { $region = self::isAjaxMode() ? 'ajax-snippet' : 'html-header'; $resources = $this; - CRM_Core_Region::instance($region)->add(array( + CRM_Core_Region::instance($region)->add([ 'callback' => function (&$snippet, &$html) use ($resources) { $html .= "\n" . $resources->renderSetting(); }, 'weight' => -100000, - )); + ]); $this->addedSettings = TRUE; } return $this; @@ -292,7 +292,7 @@ public function addSetting($settings) { */ public function addSettingsFactory($callable) { // Make sure our callback has been registered - $this->addSetting(array()); + $this->addSetting([]); $this->settingsFactories[] = $callable; return $this; } @@ -375,18 +375,18 @@ public function renderSetting() { */ public function addString($text, $domain = 'civicrm') { foreach ((array) $text as $str) { - $translated = ts($str, array( - 'domain' => ($domain == 'civicrm') ? NULL : array($domain, NULL), + $translated = ts($str, [ + 'domain' => ($domain == 'civicrm') ? NULL : [$domain, NULL], 'raw' => TRUE, - )); + ]); // We only need to push this string to client if the translation // is actually different from the original if ($translated != $str) { $bucket = $domain == 'civicrm' ? 'strings' : 'strings::' . $domain; - $this->addSetting(array( - $bucket => array($str => $translated), - )); + $this->addSetting([ + $bucket => [$str => $translated], + ]); } } return $this; @@ -421,13 +421,13 @@ public function addStyleFile($ext, $file, $weight = self::DEFAULT_WEIGHT, $regio * @return CRM_Core_Resources */ public function addStyleUrl($url, $weight = self::DEFAULT_WEIGHT, $region = self::DEFAULT_REGION) { - CRM_Core_Region::instance($region)->add(array( + CRM_Core_Region::instance($region)->add([ 'name' => $url, 'type' => 'styleUrl', 'styleUrl' => $url, 'weight' => $weight, 'region' => $region, - )); + ]); return $this; } @@ -443,13 +443,13 @@ public function addStyleUrl($url, $weight = self::DEFAULT_WEIGHT, $region = self * @return CRM_Core_Resources */ public function addStyle($code, $weight = self::DEFAULT_WEIGHT, $region = self::DEFAULT_REGION) { - CRM_Core_Region::instance($region)->add(array( + CRM_Core_Region::instance($region)->add([ // 'name' => automatic 'type' => 'style', 'style' => $code, 'weight' => $weight, 'region' => $region, - )); + ]); return $this; } @@ -520,7 +520,7 @@ public function getUrl($ext, $file = NULL, $addCacheCode = FALSE) { public function glob($ext, $patterns, $flags = NULL) { $path = $this->getPath($ext); $patterns = (array) $patterns; - $files = array(); + $files = []; foreach ($patterns as $pattern) { if (preg_match(';^(assetBuilder|ext)://;', $pattern)) { $files[] = $pattern; @@ -604,11 +604,11 @@ public function addCoreResources($region = 'html-header') { } } // Add global settings - $settings = array( - 'config' => array( + $settings = [ + 'config' => [ 'isFrontend' => $config->userFrameworkFrontend, - ), - ); + ], + ]; // Disable profile creation if user lacks permission if (!CRM_Core_Permission::check('edit all contacts') && !CRM_Core_Permission::check('add contacts')) { $settings['config']['entityRef']['contactCreate'] = FALSE; @@ -673,7 +673,7 @@ public function getStrings() { public static function outputLocalizationJS() { CRM_Core_Page_AJAX::setJsHeaders(); $config = CRM_Core_Config::singleton(); - $vars = array( + $vars = [ 'moneyFormat' => json_encode(CRM_Utils_Money::format(1234.56)), 'contactSearch' => json_encode($config->includeEmailInName ? ts('Start typing a name or email...') : ts('Start typing a name...')), 'otherSearch' => json_encode(ts('Enter search term...')), @@ -683,7 +683,7 @@ public static function outputLocalizationJS() { 'resourceCacheCode' => self::singleton()->getCacheCode(), 'locale' => CRM_Core_I18n::getLocale(), 'cid' => (int) CRM_Core_Session::getLoggedInContactID(), - ); + ]; print CRM_Core_Smarty::singleton()->fetchWith('CRM/common/l10n.js.tpl', $vars); CRM_Utils_System::civiExit(); } @@ -701,7 +701,7 @@ public function coreResourceList($region) { // Scripts needed by everyone, everywhere // FIXME: This is too long; list needs finer-grained segmentation - $items = array( + $items = [ "bower_components/jquery/dist/jquery.min.js", "bower_components/jquery-ui/jquery-ui.min.js", "bower_components/jquery-ui/themes/smoothness/jquery-ui.min.css", @@ -721,7 +721,7 @@ public function coreResourceList($region) { "js/crm.datepicker.js", "js/crm.ajax.js", "js/wysiwyg/crm.wysiwyg.js", - ); + ]; // Dynamic localization script $items[] = $this->addCacheCode( @@ -733,12 +733,12 @@ public function coreResourceList($region) { $editor = Civi::settings()->get('editor_id'); if ($editor == "CKEditor") { CRM_Admin_Page_CKEditorConfig::setConfigDefault(); - $items[] = array( - 'config' => array( + $items[] = [ + 'config' => [ 'wysisygScriptLocation' => Civi::paths()->getUrl("[civicrm.root]/js/wysiwyg/crm.ckeditor.js"), 'CKEditorCustomConfig' => CRM_Admin_Page_CKEditorConfig::getConfigUrl(), - ), - ); + ], + ]; } // These scripts are only needed by back-office users @@ -793,7 +793,7 @@ public function coreResourceList($region) { // Search for i18n file in order of specificity (try fr-CA, then fr) list($lang) = explode('_', $tsLocale); $path = "bower_components/jquery-ui/ui/i18n"; - foreach (array(str_replace('_', '-', $tsLocale), $lang) as $language) { + foreach ([str_replace('_', '-', $tsLocale), $lang] as $language) { $localizationFile = "$path/datepicker-{$language}.js"; if ($this->getPath('civicrm', $localizationFile)) { $items[] = $localizationFile; @@ -813,11 +813,11 @@ public function coreResourceList($region) { * is this page request an ajax snippet? */ public static function isAjaxMode() { - if (in_array(CRM_Utils_Array::value('snippet', $_REQUEST), array( + if (in_array(CRM_Utils_Array::value('snippet', $_REQUEST), [ CRM_Core_Smarty::PRINT_SNIPPET, CRM_Core_Smarty::PRINT_NOFORM, CRM_Core_Smarty::PRINT_JSON, - )) + ]) ) { return TRUE; } diff --git a/CRM/Core/Resources/Strings.php b/CRM/Core/Resources/Strings.php index f8a9175315c5..4f1315c46835 100644 --- a/CRM/Core/Resources/Strings.php +++ b/CRM/Core/Resources/Strings.php @@ -69,14 +69,14 @@ public function flush() { public function get($bucket, $file, $format) { $stringsByFile = $this->cache->get($bucket); // array($file => array(...strings...)) if (!$stringsByFile) { - $stringsByFile = array(); + $stringsByFile = []; } if (!isset($stringsByFile[$file])) { if ($file && is_readable($file)) { $stringsByFile[$file] = $this->extract($file, $format); } else { - $stringsByFile[$file] = array(); + $stringsByFile[$file] = []; } $this->cache->set($bucket, $stringsByFile); } diff --git a/CRM/Core/ScheduledJob.php b/CRM/Core/ScheduledJob.php index 0802b0e6aa00..eb2be0bf13b9 100644 --- a/CRM/Core/ScheduledJob.php +++ b/CRM/Core/ScheduledJob.php @@ -40,9 +40,9 @@ class CRM_Core_ScheduledJob { var $name = NULL; - var $apiParams = array(); + var $apiParams = []; - var $remarks = array(); + var $remarks = []; /** * @param array $params @@ -60,7 +60,7 @@ public function __construct($params) { // testing in the cron job setup. To permanenty require // hardcoded api version, it's enough to move below line // under following if block. - $this->apiParams = array('version' => $this->version); + $this->apiParams = ['version' => $this->version]; if (!empty($this->parameters)) { $lines = explode("\n", $this->parameters); @@ -91,9 +91,9 @@ public function saveLastRun($date = NULL) { */ public function clearScheduledRunDate() { CRM_Core_DAO::executeQuery('UPDATE civicrm_job SET scheduled_run_date = NULL WHERE id = %1', - array( - '1' => array($this->id, 'Integer'), - )); + [ + '1' => [$this->id, 'Integer'], + ]); } /** diff --git a/CRM/Core/SelectValues.php b/CRM/Core/SelectValues.php index 87b08e890f23..87dd9c37ebee 100644 --- a/CRM/Core/SelectValues.php +++ b/CRM/Core/SelectValues.php @@ -43,10 +43,10 @@ class CRM_Core_SelectValues { * @return array */ public static function boolean() { - return array( + return [ 1 => ts('Yes'), 0 => ts('No'), - ); + ]; } /** @@ -55,11 +55,11 @@ public static function boolean() { * @return array */ public static function pmf() { - return array( + return [ 'Both' => ts('Both'), 'HTML' => ts('HTML'), 'Text' => ts('Text'), - ); + ]; } /** @@ -68,14 +68,14 @@ public static function pmf() { * @return array */ public static function privacy() { - return array( + return [ 'do_not_phone' => ts('Do not phone'), 'do_not_email' => ts('Do not email'), 'do_not_mail' => ts('Do not mail'), 'do_not_sms' => ts('Do not sms'), 'do_not_trade' => ts('Do not trade'), 'is_opt_out' => ts('No bulk emails (User Opt Out)'), - ); + ]; } /** @@ -98,11 +98,11 @@ public static function contactType() { * @return array */ public static function unitList($unitType = NULL) { - $unitList = array( + $unitList = [ 'day' => ts('day'), 'month' => ts('month'), 'year' => ts('year'), - ); + ]; if ($unitType == 'duration') { $unitList['lifetime'] = ts('lifetime'); } @@ -124,10 +124,10 @@ public static function membershipTypeUnitList() { * @return array */ public static function periodType() { - return array( + return [ 'rolling' => ts('Rolling'), 'fixed' => ts('Fixed'), - ); + ]; } /** @@ -136,12 +136,12 @@ public static function periodType() { * @return array */ public static function emailSelectMethods() { - return array( + return [ 'automatic' => ts("Automatic"), 'location-only' => ts("Only send to email addresses assigned to the specified location"), 'location-prefer' => ts("Prefer email addresses assigned to the specified location"), 'location-exclude' => ts("Exclude email addresses assigned to the specified location"), - ); + ]; } /** @@ -150,10 +150,10 @@ public static function emailSelectMethods() { * @return array */ public static function memberVisibility() { - return array( + return [ 'Public' => ts('Public'), 'Admin' => ts('Admin'), - ); + ]; } /** @@ -162,11 +162,11 @@ public static function memberVisibility() { * @return array */ public static function memberAutoRenew() { - return array( + return [ ts('No auto-renew option'), ts('Give option, but not required'), ts('Auto-renew required'), - ); + ]; } /** @@ -175,11 +175,11 @@ public static function memberAutoRenew() { * @return array */ public static function eventDate() { - return array( + return [ 'start_date' => ts('start date'), 'end_date' => ts('end date'), 'join_date' => ts('member since'), - ); + ]; } /** @@ -188,7 +188,7 @@ public static function eventDate() { * @return array */ public static function customHtmlType() { - return array( + return [ 'Text' => ts('Single-line input field (text or numeric)'), 'TextArea' => ts('Multi-line text box (textarea)'), 'Select' => ts('Drop-down (select list)'), @@ -205,7 +205,7 @@ public static function customHtmlType() { 'Multi-Select' => ts('Multi-Select'), 'Link' => ts('Link'), 'ContactReference' => ts('Autocomplete-Select'), - ); + ]; } /** @@ -215,7 +215,7 @@ public static function customHtmlType() { * */ public static function customGroupExtends() { - $customGroupExtends = array( + $customGroupExtends = [ 'Activity' => ts('Activities'), 'Relationship' => ts('Relationships'), 'Contribution' => ts('Contributions'), @@ -231,9 +231,9 @@ public static function customGroupExtends() { 'Grant' => ts('Grants'), 'Address' => ts('Addresses'), 'Campaign' => ts('Campaigns'), - ); + ]; $contactTypes = self::contactType(); - $contactTypes = !empty($contactTypes) ? array('Contact' => 'Contacts') + $contactTypes : array(); + $contactTypes = !empty($contactTypes) ? ['Contact' => 'Contacts'] + $contactTypes : []; $extendObjs = CRM_Core_OptionGroup::values('cg_extend_objects'); $customGroupExtends = array_merge($contactTypes, $customGroupExtends, $extendObjs); return $customGroupExtends; @@ -245,11 +245,11 @@ public static function customGroupExtends() { * @return array */ public static function customGroupStyle() { - return array( + return [ 'Tab' => ts('Tab'), 'Inline' => ts('Inline'), 'Tab with table' => ts('Tab with table'), - ); + ]; } /** @@ -258,16 +258,16 @@ public static function customGroupStyle() { * @return array */ public static function ufGroupTypes() { - $ufGroupType = array( + $ufGroupType = [ 'Profile' => ts('Standalone Form or Directory'), 'Search Profile' => ts('Search Views'), - ); + ]; if (CRM_Core_Config::singleton()->userSystem->supports_form_extensions) { - $ufGroupType += array( + $ufGroupType += [ 'User Registration' => ts('Drupal User Registration'), 'User Account' => ts('View/Edit Drupal User Account'), - ); + ]; } return $ufGroupType; } @@ -278,11 +278,11 @@ public static function ufGroupTypes() { * @return array */ public static function groupContactStatus() { - return array( + return [ 'Added' => ts('Added'), 'Removed' => ts('Removed'), 'Pending' => ts('Pending'), - ); + ]; } /** @@ -291,10 +291,10 @@ public static function groupContactStatus() { * @return array */ public static function groupType() { - return array( + return [ 'query' => ts('Dynamic'), 'static' => ts('Static'), - ); + ]; } /** @@ -312,11 +312,11 @@ public static function groupType() { */ public static function date($type = NULL, $format = NULL, $minOffset = NULL, $maxOffset = NULL, $context = 'display') { // These options are deprecated. Definitely not used in datepicker. Possibly not even in jcalendar+addDateTime. - $date = array( + $date = [ 'addEmptyOption' => TRUE, 'emptyOptionText' => ts('- select -'), 'emptyOptionValue' => '', - ); + ]; if ($format) { $date['format'] = $format; @@ -366,11 +366,11 @@ public static function date($type = NULL, $format = NULL, $minOffset = NULL, $ma * @return array */ public static function ufVisibility() { - return array( + return [ 'User and User Admin Only' => ts('User and User Admin Only'), 'Public Pages' => ts('Expose Publicly'), 'Public Pages and Listings' => ts('Expose Publicly and for Listings'), - ); + ]; } /** @@ -379,10 +379,10 @@ public static function ufVisibility() { * @return array */ public static function groupVisibility() { - return array( + return [ 'User and User Admin Only' => ts('User and User Admin Only'), 'Public Pages' => ts('Public Pages'), - ); + ]; } /** @@ -391,7 +391,7 @@ public static function groupVisibility() { * @return array */ public static function mailingComponents() { - return array( + return [ 'Header' => ts('Header'), 'Footer' => ts('Footer'), 'Reply' => ts('Reply Auto-responder'), @@ -400,7 +400,7 @@ public static function mailingComponents() { 'Welcome' => ts('Welcome Message'), 'Unsubscribe' => ts('Unsubscribe Message'), 'Resubscribe' => ts('Resubscribe Message'), - ); + ]; } /** @@ -409,7 +409,7 @@ public static function mailingComponents() { * @return array */ public function getHours() { - $hours = array(); + $hours = []; for ($i = 0; $i <= 6; $i++) { $hours[$i] = $i; } @@ -422,7 +422,7 @@ public function getHours() { * @return array */ public function getMinutes() { - $minutes = array(); + $minutes = []; for ($i = 0; $i < 60; $i = $i + 15) { $minutes[$i] = $i; } @@ -438,7 +438,7 @@ public function getMinutes() { public static function mapProvider() { static $map = NULL; if (!$map) { - $map = array('' => '- select -') + CRM_Utils_System::getPluginList('templates/CRM/Contact/Form/Task/Map', ".tpl"); + $map = ['' => '- select -'] + CRM_Utils_System::getPluginList('templates/CRM/Contact/Form/Task/Map', ".tpl"); } return $map; } @@ -452,7 +452,7 @@ public static function mapProvider() { public static function geoProvider() { static $geo = NULL; if (!$geo) { - $geo = array('' => '- select -') + CRM_Utils_System::getPluginList('CRM/Utils/Geocode'); + $geo = ['' => '- select -'] + CRM_Utils_System::getPluginList('CRM/Utils/Geocode'); } return $geo; } @@ -466,7 +466,7 @@ public static function geoProvider() { public static function addressProvider() { static $addr = NULL; if (!$addr) { - $addr = array_merge(['' => '- select -'], CRM_Utils_System::getPluginList('CRM/Utils/Address', '.php', array('BatchUpdate'))); + $addr = array_merge(['' => '- select -'], CRM_Utils_System::getPluginList('CRM/Utils/Address', '.php', ['BatchUpdate'])); } return $addr; } @@ -477,7 +477,7 @@ public static function addressProvider() { * @return array */ public static function mailingTokens() { - return array( + return [ '{action.unsubscribe}' => ts('Unsubscribe via email'), '{action.unsubscribeUrl}' => ts('Unsubscribe via web page'), '{action.resubscribe}' => ts('Resubscribe via email'), @@ -494,7 +494,7 @@ public static function mailingTokens() { '{mailing.name}' => ts('Mailing name'), '{mailing.group}' => ts('Mailing group'), '{mailing.viewUrl}' => ts('Mailing permalink'), - ); + ]; } /** @@ -503,12 +503,12 @@ public static function mailingTokens() { * @return array */ public static function activityTokens() { - return array( + return [ '{activity.activity_id}' => ts('Activity ID'), '{activity.subject}' => ts('Activity Subject'), '{activity.details}' => ts('Activity Details'), '{activity.activity_date_time}' => ts('Activity Date Time'), - ); + ]; } /** @@ -517,7 +517,7 @@ public static function activityTokens() { * @return array */ public static function membershipTokens() { - return array( + return [ '{membership.id}' => ts('Membership ID'), '{membership.status}' => ts('Membership Status'), '{membership.type}' => ts('Membership Type'), @@ -525,7 +525,7 @@ public static function membershipTokens() { '{membership.join_date}' => ts('Membership Join Date'), '{membership.end_date}' => ts('Membership End Date'), '{membership.fee}' => ts('Membership Fee'), - ); + ]; } /** @@ -534,7 +534,7 @@ public static function membershipTokens() { * @return array */ public static function eventTokens() { - return array( + return [ '{event.event_id}' => ts('Event ID'), '{event.title}' => ts('Event Title'), '{event.start_date}' => ts('Event Start Date'), @@ -549,7 +549,7 @@ public static function eventTokens() { '{event.info_url}' => ts('Event Info URL'), '{event.registration_url}' => ts('Event Registration URL'), '{event.balance}' => ts('Event Balance'), - ); + ]; } /** @@ -558,7 +558,7 @@ public static function eventTokens() { * @return array */ public static function contributionTokens() { - return array_merge(array( + return array_merge([ '{contribution.contribution_id}' => ts('Contribution ID'), '{contribution.total_amount}' => ts('Total Amount'), '{contribution.fee_amount}' => ts('Fee Amount'), @@ -582,7 +582,7 @@ public static function contributionTokens() { //'{contribution.address_id}' => ts('Address ID'), '{contribution.check_number}' => ts('Check Number'), '{contribution.campaign}' => ts('Contribution Campaign'), - ), CRM_Utils_Token::getCustomFieldTokens('contribution', TRUE)); + ], CRM_Utils_Token::getCustomFieldTokens('contribution', TRUE)); } /** @@ -593,17 +593,17 @@ public static function contributionTokens() { public static function contactTokens() { static $tokens = NULL; if (!$tokens) { - $additionalFields = array( - 'checksum' => array('title' => ts('Checksum')), - 'contact_id' => array('title' => ts('Internal Contact ID')), - ); + $additionalFields = [ + 'checksum' => ['title' => ts('Checksum')], + 'contact_id' => ['title' => ts('Internal Contact ID')], + ]; $exportFields = array_merge(CRM_Contact_BAO_Contact::exportableFields(), $additionalFields); $values = array_merge(array_keys($exportFields)); unset($values[0]); //FIXME:skipping some tokens for time being. - $skipTokens = array( + $skipTokens = [ 'is_bulkmail', 'group', 'tag', @@ -614,9 +614,9 @@ public static function contactTokens() { 'legal_identifier', 'contact_sub_type', 'user_unique_id', - ); + ]; - $customFields = CRM_Core_BAO_CustomField::getFields(array('Individual', 'Address')); + $customFields = CRM_Core_BAO_CustomField::getFields(['Individual', 'Address']); $legacyTokenNames = array_flip(CRM_Utils_Token::legacyContactTokens()); foreach ($values as $val) { @@ -639,7 +639,7 @@ public static function contactTokens() { } // Get all the hook tokens too - $hookTokens = array(); + $hookTokens = []; CRM_Utils_Hook::tokens($hookTokens); foreach ($hookTokens as $tokenValues) { foreach ($tokenValues as $key => $value) { @@ -674,7 +674,7 @@ public static function participantTokens() { unset($values[0]); // skipping some tokens for time being. - $skipTokens = array( + $skipTokens = [ 'event_id', 'participant_is_pay_later', 'participant_is_test', @@ -683,7 +683,7 @@ public static function participantTokens() { 'participant_campaign_id', 'participant_status', 'participant_discount_name', - ); + ]; $customFields = CRM_Core_BAO_CustomField::getFields('Participant'); @@ -728,7 +728,7 @@ public static function caseTokens($caseTypeId = NULL) { * @return array */ public static function getDatePluginInputFormats() { - $dateInputFormats = array( + $dateInputFormats = [ "mm/dd/yy" => ts('mm/dd/yyyy (12/31/2009)'), "dd/mm/yy" => ts('dd/mm/yyyy (31/12/2009)'), "yy-mm-dd" => ts('yyyy-mm-dd (2009-12-31)'), @@ -744,7 +744,7 @@ public static function getDatePluginInputFormats() { "yy-mm" => ts('yyyy-mm (2009-12)'), 'M yy' => ts('M yyyy (Dec 2009)'), "yy" => ts('yyyy (2009)'), - ); + ]; /* Year greater than 2000 get wrong result for following format @@ -768,10 +768,10 @@ public static function getDatePluginInputFormats() { * @return array */ public static function getTimeFormats() { - return array( + return [ '1' => ts('12 Hours'), '2' => ts('24 Hours'), - ); + ]; } /** @@ -783,7 +783,7 @@ public static function getTimeFormats() { * @return array */ public static function getNumericOptions($start = 0, $end = 10) { - $numericOptions = array(); + $numericOptions = []; for ($i = $start; $i <= $end; $i++) { $numericOptions[$i] = $i; } @@ -796,10 +796,10 @@ public static function getNumericOptions($start = 0, $end = 10) { * @return array */ public static function getBarcodeTypes() { - return array( + return [ 'barcode' => ts('Linear (1D)'), 'qrcode' => ts('QR code'), - ); + ]; } /** @@ -808,11 +808,11 @@ public static function getBarcodeTypes() { * @return array */ public static function getDedupeRuleTypes() { - return array( + return [ 'Unsupervised' => ts('Unsupervised'), 'Supervised' => ts('Supervised'), 'General' => ts('General'), - ); + ]; } /** @@ -821,10 +821,10 @@ public static function getDedupeRuleTypes() { * @return array */ public static function getCampaignGroupTypes() { - return array( + return [ 'Include' => ts('Include'), 'Exclude' => ts('Exclude'), - ); + ]; } /** @@ -833,12 +833,12 @@ public static function getCampaignGroupTypes() { * @return array */ public static function getSubscriptionHistoryMethods() { - return array( + return [ 'Admin' => ts('Admin'), 'Email' => ts('Email'), 'Web' => ts('Web'), 'API' => ts('API'), - ); + ]; } /** @@ -847,12 +847,12 @@ public static function getSubscriptionHistoryMethods() { * @return array */ public static function getPremiumUnits() { - return array( + return [ 'day' => ts('Day'), 'week' => ts('Week'), 'month' => ts('Month'), 'year' => ts('Year'), - ); + ]; } /** @@ -861,13 +861,13 @@ public static function getPremiumUnits() { * @return array */ public static function getExtensionTypes() { - return array( + return [ 'payment' => ts('Payment'), 'search' => ts('Search'), 'report' => ts('Report'), 'module' => ts('Module'), 'sms' => ts('SMS'), - ); + ]; } /** @@ -876,7 +876,7 @@ public static function getExtensionTypes() { * @return array */ public static function getJobFrequency() { - return array( + return [ // CRM-17669 'Yearly' => ts('Yearly'), 'Quarter' => ts('Quarterly'), @@ -886,7 +886,7 @@ public static function getJobFrequency() { 'Daily' => ts('Daily'), 'Hourly' => ts('Hourly'), 'Always' => ts('Every time cron job is run'), - ); + ]; } /** @@ -920,14 +920,14 @@ public static function getSearchBuilderOperators($fieldType = NULL) { * @return array */ public static function getProfileGroupType() { - $profileGroupType = array( + $profileGroupType = [ 'Activity' => ts('Activities'), 'Contribution' => ts('Contributions'), 'Membership' => ts('Memberships'), 'Participant' => ts('Participants'), - ); + ]; $contactTypes = self::contactType(); - $contactTypes = !empty($contactTypes) ? array('Contact' => 'Contacts') + $contactTypes : array(); + $contactTypes = !empty($contactTypes) ? ['Contact' => 'Contacts'] + $contactTypes : []; $profileGroupType = array_merge($contactTypes, $profileGroupType); return $profileGroupType; @@ -940,10 +940,10 @@ public static function getProfileGroupType() { * @return array */ public static function getWordReplacementMatchType() { - return array( + return [ 'exactMatch' => ts('Exact Match'), 'wildcardMatch' => ts('Wildcard Match'), - ); + ]; } /** @@ -952,11 +952,11 @@ public static function getWordReplacementMatchType() { * @return array */ public static function getMailingGroupTypes() { - return array( + return [ 'Include' => ts('Include'), 'Exclude' => ts('Exclude'), 'Base' => ts('Base'), - ); + ]; } /** @@ -965,35 +965,35 @@ public static function getMailingGroupTypes() { * @return array */ public static function getMailingJobStatus() { - return array( + return [ 'Scheduled' => ts('Scheduled'), 'Running' => ts('Running'), 'Complete' => ts('Complete'), 'Paused' => ts('Paused'), 'Canceled' => ts('Canceled'), - ); + ]; } /** * @return array */ public static function billingMode() { - return array( + return [ CRM_Core_Payment::BILLING_MODE_FORM => 'form', CRM_Core_Payment::BILLING_MODE_BUTTON => 'button', CRM_Core_Payment::BILLING_MODE_NOTIFY => 'notify', - ); + ]; } /** * @return array */ public static function contributeMode() { - return array( + return [ CRM_Core_Payment::BILLING_MODE_FORM => 'direct', CRM_Core_Payment::BILLING_MODE_BUTTON => 'directIPN', CRM_Core_Payment::BILLING_MODE_NOTIFY => 'notify', - ); + ]; } /** @@ -1007,13 +1007,13 @@ public static function getRecurringFrequencyUnits($count = 1) { // @todo this used to refer to the 'recur_frequency_unit' option_values which // is for recurring payments and probably not good to re-use for recurring entities. // If something other than a hard-coded list is desired, add a new option_group. - return array( - 'hour' => ts('hour', array('plural' => 'hours', 'count' => $count)), - 'day' => ts('day', array('plural' => 'days', 'count' => $count)), - 'week' => ts('week', array('plural' => 'weeks', 'count' => $count)), - 'month' => ts('month', array('plural' => 'months', 'count' => $count)), - 'year' => ts('year', array('plural' => 'years', 'count' => $count)), - ); + return [ + 'hour' => ts('hour', ['plural' => 'hours', 'count' => $count]), + 'day' => ts('day', ['plural' => 'days', 'count' => $count]), + 'week' => ts('week', ['plural' => 'weeks', 'count' => $count]), + 'month' => ts('month', ['plural' => 'months', 'count' => $count]), + 'year' => ts('year', ['plural' => 'years', 'count' => $count]), + ]; } /** @@ -1022,7 +1022,7 @@ public static function getRecurringFrequencyUnits($count = 1) { * @return array */ public static function getRelativeDateTerms() { - return array( + return [ 'previous' => ts('Previous'), 'previous_2' => ts('Previous 2'), 'previous_before' => ts('Prior to Previous'), @@ -1038,7 +1038,7 @@ public static function getRelativeDateTerms() { 'starting' => ts('Upcoming'), 'less' => ts('To End of'), 'next' => ts('Next'), - ); + ]; } /** @@ -1047,14 +1047,14 @@ public static function getRelativeDateTerms() { * @return array */ public static function getRelativeDateUnits() { - return array( + return [ 'year' => ts('Years'), 'fiscal_year' => ts('Fiscal Years'), 'quarter' => ts('Quarters'), 'month' => ts('Months'), 'week' => ts('Weeks'), 'day' => ts('Days'), - ); + ]; } /** @@ -1063,12 +1063,12 @@ public static function getRelativeDateUnits() { * @return array */ public static function documentFormat() { - return array( + return [ 'pdf' => ts('Portable Document Format (.pdf)'), 'docx' => ts('MS Word (.docx)'), 'odt' => ts('Open Office (.odt)'), 'html' => ts('Webpage (.html)'), - ); + ]; } /** @@ -1077,10 +1077,10 @@ public static function documentFormat() { * @return array */ public static function documentApplicationType() { - return array( + return [ 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'odt' => 'application/vnd.oasis.opendocument.text', - ); + ]; } /** @@ -1089,11 +1089,11 @@ public static function documentApplicationType() { * @return array */ public static function activityTextOptions() { - return array( + return [ 2 => ts('Details Only'), 3 => ts('Subject Only'), 6 => ts('Both'), - ); + ]; } /** @@ -1102,11 +1102,11 @@ public static function activityTextOptions() { * @return array */ public static function getPermissionedRelationshipOptions() { - return array( + return [ CRM_Contact_BAO_Relationship::NONE => ts('None'), CRM_Contact_BAO_Relationship::VIEW => ts('View only'), CRM_Contact_BAO_Relationship::EDIT => ts('View and update'), - ); + ]; } /** @@ -1130,7 +1130,7 @@ public static function getDashboardEntriesCount() { * @return array */ public static function quicksearchOptions() { - $includeEmail = civicrm_api3('setting', 'getvalue', array('name' => 'includeEmailInName', 'group' => 'Search Preferences')); + $includeEmail = civicrm_api3('setting', 'getvalue', ['name' => 'includeEmailInName', 'group' => 'Search Preferences']); $options = [ 'sort_name' => $includeEmail ? ts('Name/Email') : ts('Name'), 'contact_id' => ts('Contact ID'), diff --git a/CRM/Core/Selector/Base.php b/CRM/Core/Selector/Base.php index 202d5ba13638..cc4f35342e82 100644 --- a/CRM/Core/Selector/Base.php +++ b/CRM/Core/Selector/Base.php @@ -121,7 +121,7 @@ public function &getSortOrder($action) { $columnHeaders = &$this->getColumnHeaders(NULL); if (!isset($this->_order)) { - $this->_order = array(); + $this->_order = []; $start = 2; $firstElementNotFound = TRUE; if (!empty($columnHeaders)) { diff --git a/CRM/Core/Selector/Controller.php b/CRM/Core/Selector/Controller.php index a5082d2917fd..30a9225b9b59 100644 --- a/CRM/Core/Selector/Controller.php +++ b/CRM/Core/Selector/Controller.php @@ -164,7 +164,7 @@ class CRM_Core_Selector_Controller { * * @var array */ - public static $_properties = array('columnHeaders', 'rows', 'rowsEmpty'); + public static $_properties = ['columnHeaders', 'rows', 'rowsEmpty']; /** * Should we compute actions dynamically (since they are quite verbose) @@ -209,9 +209,9 @@ public function __construct($object, $pageID, $sortID, $action, $store = NULL, $ $this->_sortID .= '_u'; } - $params = array( + $params = [ 'pageID' => $this->_pageID, - ); + ]; // let the constructor initialize this, should happen only once if (!isset(self::$_template)) { @@ -339,8 +339,8 @@ public function run() { // output requires paging/sorting capability $rows = self::getRows($this); CRM_Utils_Hook::searchColumns($contextName, $columnHeaders, $rows, $this); - $reorderedHeaders = array(); - $noWeightHeaders = array(); + $reorderedHeaders = []; + $noWeightHeaders = []; foreach ($columnHeaders as $key => $columnHeader) { // So far only contribution selector sets weight, so just use key if not. // Extension writers will need to fix other getColumnHeaders (or add a wrapper) diff --git a/CRM/Core/Session.php b/CRM/Core/Session.php index 7e7957c61f80..c9d10d2b3a9f 100644 --- a/CRM/Core/Session.php +++ b/CRM/Core/Session.php @@ -120,7 +120,7 @@ public function initialize($isRead = FALSE) { if (!(isset($GLOBALS['lazy_session']) && $GLOBALS['lazy_session'] == TRUE)) { drupal_session_start(); } - $_SESSION = array(); + $_SESSION = []; } else { session_start(); @@ -136,7 +136,7 @@ public function initialize($isRead = FALSE) { if (!isset($this->_session[$this->_key]) || !is_array($this->_session[$this->_key]) ) { - $this->_session[$this->_key] = array(); + $this->_session[$this->_key] = []; } } @@ -150,11 +150,11 @@ public function reset($all = 1) { $this->initialize(); // to make certain we clear it, first initialize it to empty - $this->_session[$this->_key] = array(); + $this->_session[$this->_key] = []; unset($this->_session[$this->_key]); } else { - $this->_session = array(); + $this->_session = []; } } @@ -175,7 +175,7 @@ public function createScope($prefix, $isRead = FALSE) { } if (empty($this->_session[$this->_key][$prefix])) { - $this->_session[$this->_key][$prefix] = array(); + $this->_session[$this->_key][$prefix] = []; } } @@ -465,7 +465,7 @@ public function getStatus($reset = FALSE) { * defaults to 10 seconds for most messages, 5 if it has a title but no body, * or 0 for errors or messages containing links */ - public static function setStatus($text, $title = '', $type = 'alert', $options = array()) { + public static function setStatus($text, $title = '', $type = 'alert', $options = []) { // make sure session is initialized, CRM-8120 $session = self::singleton(); $session->initialize(); @@ -475,10 +475,10 @@ public static function setStatus($text, $title = '', $type = 'alert', $options = $title = CRM_Utils_String::purifyHTML($title); // default options - $options += array('unique' => TRUE); + $options += ['unique' => TRUE]; if (!isset(self::$_singleton->_session[self::$_singleton->_key]['status'])) { - self::$_singleton->_session[self::$_singleton->_key]['status'] = array(); + self::$_singleton->_session[self::$_singleton->_key]['status'] = []; } if ($text || $title) { if ($options['unique']) { @@ -489,12 +489,12 @@ public static function setStatus($text, $title = '', $type = 'alert', $options = } } unset($options['unique']); - self::$_singleton->_session[self::$_singleton->_key]['status'][] = array( + self::$_singleton->_session[self::$_singleton->_key]['status'][] = [ 'text' => $text, 'title' => $title, 'type' => $type, 'options' => $options ? $options : NULL, - ); + ]; } } @@ -505,7 +505,7 @@ public static function setStatus($text, $title = '', $type = 'alert', $options = */ public static function registerAndRetrieveSessionObjects($names) { if (!is_array($names)) { - $names = array($names); + $names = [$names]; } if (!self::$_managedNames) { @@ -561,7 +561,7 @@ public function getLoggedInContactDisplayName() { if (!$userContactID) { return ''; } - return civicrm_api3('Contact', 'getvalue', array('id' => $userContactID, 'return' => 'display_name')); + return civicrm_api3('Contact', 'getvalue', ['id' => $userContactID, 'return' => 'display_name']); } /** diff --git a/CRM/Core/ShowHideBlocks.php b/CRM/Core/ShowHideBlocks.php index 626074941f50..ba2edef2062e 100644 --- a/CRM/Core/ShowHideBlocks.php +++ b/CRM/Core/ShowHideBlocks.php @@ -68,14 +68,14 @@ public function __construct($show = NULL, $hide = NULL) { $this->_show = $show; } else { - $this->_show = array(); + $this->_show = []; } if (!empty($hide)) { $this->_hide = $hide; } else { - $this->_hide = array(); + $this->_hide = []; } } @@ -182,7 +182,7 @@ public static function links(&$form, $prefix, $showLinkText, $hideLinkText, $ass $hideCode = "if(event.preventDefault) event.preventDefault(); else event.returnValue = false; cj('#id_{$prefix}').hide(); cj('#id_{$prefix}_show').show();"; self::setIcons(); - $values = array(); + $values = []; $values['show'] = self::linkHtml("${prefix}_show", "#${prefix}_hide", self::$_showIcon . $showLinkText, "onclick=\"$showCode\""); $values['hide'] = self::linkHtml("${prefix}_hide", "#${prefix}", self::$_hideIcon . $hideLinkText, "onclick=\"$hideCode\""); @@ -215,7 +215,7 @@ public static function links(&$form, $prefix, $showLinkText, $hideLinkText, $ass * The hide block string. */ public function linksForArray(&$form, $index, $maxIndex, $prefix, $showLinkText, $hideLinkText, $elementType = NULL, $hideLink = NULL) { - $showHidePrefix = str_replace(array("]", "["), array("", "_"), $prefix); + $showHidePrefix = str_replace(["]", "["], ["", "_"], $prefix); $showHidePrefix = "id_" . $showHidePrefix; if ($index == $maxIndex) { $showCode = $hideCode = "return false;"; @@ -240,18 +240,18 @@ public function linksForArray(&$form, $index, $maxIndex, $prefix, $showLinkText, self::setIcons(); if ($elementType) { $form->addElement('link', "${prefix}[${index}][show]", NULL, "#${prefix}_${index}", self::$_showIcon . $showLinkText, - array('onclick' => "cj('#${prefix}_${index}_show').hide(); cj('#${prefix}_${index}').show();" . $showCode) + ['onclick' => "cj('#${prefix}_${index}_show').hide(); cj('#${prefix}_${index}').show();" . $showCode] ); $form->addElement('link', "${prefix}[${index}][hide]", NULL, "#${prefix}_${index}", self::$_hideIcon . $hideLinkText, - array('onclick' => "cj('#${prefix}_${index}').hide(); cj('#${prefix}_${index}_show').show();" . $hideCode) + ['onclick' => "cj('#${prefix}_${index}').hide(); cj('#${prefix}_${index}_show').show();" . $hideCode] ); } else { $form->addElement('link', "${prefix}[${index}][show]", NULL, "#${prefix}_${index}", self::$_showIcon . $showLinkText, - array('onclick' => "cj('#{$showHidePrefix}_{$index}_show').hide(); cj('#{$showHidePrefix}_{$index}').show();" . $showCode) + ['onclick' => "cj('#{$showHidePrefix}_{$index}_show').hide(); cj('#{$showHidePrefix}_{$index}').show();" . $showCode] ); $form->addElement('link', "${prefix}[${index}][hide]", NULL, "#${prefix}_${index}", self::$_hideIcon . $hideLinkText, - array('onclick' => "cj('#{$showHidePrefix}_{$index}').hide(); cj('#{$showHidePrefix}_{$index}_show').show();" . $hideCode) + ['onclick' => "cj('#{$showHidePrefix}_{$index}').hide(); cj('#{$showHidePrefix}_{$index}_show').show();" . $hideCode] ); } } diff --git a/CRM/Core/Smarty.php b/CRM/Core/Smarty.php index 25615fc8a937..06b05313e3c3 100644 --- a/CRM/Core/Smarty.php +++ b/CRM/Core/Smarty.php @@ -75,7 +75,7 @@ class CRM_Core_Smarty extends Smarty { /** * @var array (string $name => mixed $value) a list of variables ot save temporarily */ - private $backupFrames = array(); + private $backupFrames = []; /** * Class constructor. @@ -90,7 +90,7 @@ private function initialize() { $config = CRM_Core_Config::singleton(); if (isset($config->customTemplateDir) && $config->customTemplateDir) { - $this->template_dir = array_merge(array($config->customTemplateDir), + $this->template_dir = array_merge([$config->customTemplateDir], $config->templateDir ); } @@ -134,10 +134,10 @@ private function initialize() { $pluginsDir = __DIR__ . DIRECTORY_SEPARATOR . 'Smarty' . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR; if ($customPluginsDir) { - $this->plugins_dir = array($customPluginsDir, $smartyDir . 'plugins', $pluginsDir); + $this->plugins_dir = [$customPluginsDir, $smartyDir . 'plugins', $pluginsDir]; } else { - $this->plugins_dir = array($smartyDir . 'plugins', $pluginsDir); + $this->plugins_dir = [$smartyDir . 'plugins', $pluginsDir]; } // add the session and the config here @@ -154,7 +154,7 @@ private function initialize() { $this->assign('langSwitch', CRM_Core_I18n::uiLanguages()); } - $this->register_function('crmURL', array('CRM_Utils_System', 'crmURL')); + $this->register_function('crmURL', ['CRM_Utils_System', 'crmURL']); $this->load_filter('pre', 'resetExtScope'); $this->assign('crmPermissions', new CRM_Core_Smarty_Permissions()); @@ -259,7 +259,7 @@ public function addTemplateDir($path) { array_unshift($this->template_dir, $path); } else { - $this->template_dir = array($path, $this->template_dir); + $this->template_dir = [$path, $this->template_dir]; } } @@ -283,7 +283,7 @@ public function addTemplateDir($path) { */ public function pushScope($vars) { $oldVars = $this->get_template_vars(); - $backupFrame = array(); + $backupFrame = []; foreach ($vars as $key => $value) { $backupFrame[$key] = isset($oldVars[$key]) ? $oldVars[$key] : NULL; } diff --git a/CRM/Core/Smarty/plugins/block.crmButton.php b/CRM/Core/Smarty/plugins/block.crmButton.php index 462a056b4e72..30074e9b098e 100644 --- a/CRM/Core/Smarty/plugins/block.crmButton.php +++ b/CRM/Core/Smarty/plugins/block.crmButton.php @@ -49,7 +49,7 @@ function smarty_block_crmButton($params, $text, &$smarty) { // Generate url (pass 'html' param as false to avoid double-encode by htmlAttributes) if (empty($params['href'])) { - $params['href'] = CRM_Utils_System::crmURL($params + array('h' => FALSE)); + $params['href'] = CRM_Utils_System::crmURL($params + ['h' => FALSE]); } // Always add class 'button' - fixme probably should be crm-button $params['class'] = empty($params['class']) ? 'button' : 'button ' . $params['class']; diff --git a/CRM/Core/Smarty/plugins/block.localize.php b/CRM/Core/Smarty/plugins/block.localize.php index af203ef9d62c..151356f72c18 100644 --- a/CRM/Core/Smarty/plugins/block.localize.php +++ b/CRM/Core/Smarty/plugins/block.localize.php @@ -53,7 +53,7 @@ function smarty_block_localize($params, $text, &$smarty) { return $text; } - $lines = array(); + $lines = []; foreach ($smarty->_tpl_vars['locales'] as $locale) { $line = $text; if ($params['field']) { diff --git a/CRM/Core/Smarty/plugins/function.crmAPI.php b/CRM/Core/Smarty/plugins/function.crmAPI.php index 12263519cee5..7c4db3139304 100644 --- a/CRM/Core/Smarty/plugins/function.crmAPI.php +++ b/CRM/Core/Smarty/plugins/function.crmAPI.php @@ -43,7 +43,7 @@ function smarty_function_crmAPI($params, &$smarty) { $smarty->trigger_error("assign: missing 'entity' parameter"); return "crmAPI: missing 'entity' parameter"; } - $errorScope = CRM_Core_TemporaryErrorScope::create(array('CRM_Utils_REST', 'fatal')); + $errorScope = CRM_Core_TemporaryErrorScope::create(['CRM_Utils_REST', 'fatal']); $entity = $params['entity']; $action = CRM_Utils_Array::value('action', $params, 'get'); $params['sequential'] = CRM_Utils_Array::value('sequential', $params, 1); diff --git a/CRM/Core/Smarty/plugins/function.crmAttributes.php b/CRM/Core/Smarty/plugins/function.crmAttributes.php index 20d9832efd1e..91a40c24caa6 100644 --- a/CRM/Core/Smarty/plugins/function.crmAttributes.php +++ b/CRM/Core/Smarty/plugins/function.crmAttributes.php @@ -43,6 +43,6 @@ * @return string */ function smarty_function_crmAttributes($params, &$smarty) { - $attributes = isset($params['a']) ? $params['a'] : array(); + $attributes = isset($params['a']) ? $params['a'] : []; return CRM_Utils_String::htmlAttributes($attributes); } diff --git a/CRM/Core/Smarty/plugins/function.crmCrudLink.php b/CRM/Core/Smarty/plugins/function.crmCrudLink.php index 8c063d44a157..61a9d157c6d6 100644 --- a/CRM/Core/Smarty/plugins/function.crmCrudLink.php +++ b/CRM/Core/Smarty/plugins/function.crmCrudLink.php @@ -51,11 +51,11 @@ function smarty_function_crmCrudLink($params, &$smarty) { $params['action'] = 'VIEW'; } - $link = CRM_Utils_System::createDefaultCrudLink(array( + $link = CRM_Utils_System::createDefaultCrudLink([ 'action' => constant('CRM_Core_Action::' . $params['action']), 'entity_table' => $params['table'], 'entity_id' => $params['id'], - )); + ]); if ($link) { return sprintf('%s', diff --git a/CRM/Core/Smarty/plugins/function.crmScript.php b/CRM/Core/Smarty/plugins/function.crmScript.php index 71d43a2e9b60..6b9e823e40b2 100644 --- a/CRM/Core/Smarty/plugins/function.crmScript.php +++ b/CRM/Core/Smarty/plugins/function.crmScript.php @@ -48,11 +48,11 @@ * @throws Exception */ function smarty_function_crmScript($params, &$smarty) { - $params += array( + $params += [ 'weight' => CRM_Core_Resources::DEFAULT_WEIGHT, 'region' => CRM_Core_Resources::DEFAULT_REGION, 'ext' => 'civicrm', - ); + ]; if (array_key_exists('file', $params)) { Civi::resources()->addScriptFile($params['ext'], $params['file'], $params['weight'], $params['region']); diff --git a/CRM/Core/Smarty/plugins/function.crmSetting.php b/CRM/Core/Smarty/plugins/function.crmSetting.php index 72411c998b3d..ffe9cd023652 100644 --- a/CRM/Core/Smarty/plugins/function.crmSetting.php +++ b/CRM/Core/Smarty/plugins/function.crmSetting.php @@ -43,7 +43,7 @@ */ function smarty_function_crmSetting($params, &$smarty) { - $errorScope = CRM_Core_TemporaryErrorScope::create(array('CRM_Utils_REST', 'fatal')); + $errorScope = CRM_Core_TemporaryErrorScope::create(['CRM_Utils_REST', 'fatal']); unset($params['method']); unset($params['assign']); $params['version'] = 3; diff --git a/CRM/Core/Smarty/plugins/function.help.php b/CRM/Core/Smarty/plugins/function.help.php index 744df2cffba9..ad593e4dd2a9 100644 --- a/CRM/Core/Smarty/plugins/function.help.php +++ b/CRM/Core/Smarty/plugins/function.help.php @@ -56,7 +56,7 @@ function smarty_function_help($params, &$smarty) { return NULL; } - $params['file'] = str_replace(array('.tpl', '.hlp'), '', $params['file']); + $params['file'] = str_replace(['.tpl', '.hlp'], '', $params['file']); if (empty($params['title'])) { $vars = $smarty->get_template_vars(); @@ -83,7 +83,7 @@ function smarty_function_help($params, &$smarty) { } // Escape for html - $title = htmlspecialchars(ts('%1 Help', array(1 => $name))); + $title = htmlspecialchars(ts('%1 Help', [1 => $name])); // Escape for html and js $name = htmlspecialchars(json_encode($name), ENT_QUOTES); diff --git a/CRM/Core/Smarty/plugins/function.isValueChange.php b/CRM/Core/Smarty/plugins/function.isValueChange.php index 04d9d4487fa4..8c3116ea9b69 100644 --- a/CRM/Core/Smarty/plugins/function.isValueChange.php +++ b/CRM/Core/Smarty/plugins/function.isValueChange.php @@ -53,7 +53,7 @@ * @return NULL */ function smarty_function_isValueChange($params, &$smarty) { - static $values = array(); + static $values = []; if (empty($params['key'])) { $smarty->trigger_error("Missing required parameter, 'key', in isValueChange plugin."); diff --git a/CRM/Core/Smarty/plugins/function.sectionTotal.php b/CRM/Core/Smarty/plugins/function.sectionTotal.php index 6ded8123bd65..fee8b7d3811a 100644 --- a/CRM/Core/Smarty/plugins/function.sectionTotal.php +++ b/CRM/Core/Smarty/plugins/function.sectionTotal.php @@ -62,7 +62,7 @@ function smarty_function_sectionTotal($params, &$smarty) { * Note: This array is created and assigned to the template in CRM_Report_Form::sectionTotals() */ - static $sectionValues = array(); + static $sectionValues = []; // move back in the stack, if necessary if (count($sectionValues) > $params['depth']) { diff --git a/CRM/Core/Smarty/plugins/function.simpleActivityContacts.php b/CRM/Core/Smarty/plugins/function.simpleActivityContacts.php index 38e17dd41964..b45e5f85f782 100644 --- a/CRM/Core/Smarty/plugins/function.simpleActivityContacts.php +++ b/CRM/Core/Smarty/plugins/function.simpleActivityContacts.php @@ -38,28 +38,28 @@ function smarty_function_simpleActivityContacts($params, &$smarty) { require_once 'api/api.php'; require_once 'api/v3/utils.php'; - $activity = civicrm_api('activity', 'getsingle', array( + $activity = civicrm_api('activity', 'getsingle', [ 'version' => 3, 'id' => $params['activity_id'], 'return.target_contact_id' => 1, 'return.assignee_contact_id' => 1, - )); + ]); - $baseContactParams = array('version' => 3); + $baseContactParams = ['version' => 3]; foreach (explode(',', $params['return']) as $field) { $baseContactParams['return.' . $field] = 1; } - foreach (array( + foreach ([ 'target', 'assignee', - ) as $role) { - $contact = array(); + ] as $role) { + $contact = []; if (!empty($activity[$role . '_contact_id'])) { $contact_id = array_shift($activity[$role . '_contact_id']); - $contact = civicrm_api('contact', 'getsingle', $baseContactParams + array( + $contact = civicrm_api('contact', 'getsingle', $baseContactParams + [ 'contact_id' => $contact_id, - )); + ]); } $smarty->assign($params[$role . '_var'], $contact); } diff --git a/CRM/Core/Smarty/plugins/modifier.crmAddClass.php b/CRM/Core/Smarty/plugins/modifier.crmAddClass.php index bbf0eb31d3ca..4f1b0cd2b7c7 100644 --- a/CRM/Core/Smarty/plugins/modifier.crmAddClass.php +++ b/CRM/Core/Smarty/plugins/modifier.crmAddClass.php @@ -46,7 +46,7 @@ */ function smarty_modifier_crmAddClass($string, $class) { // Standardize white space - $string = str_replace(array('class ="', 'class= "', 'class = "'), 'class="', $string); + $string = str_replace(['class ="', 'class= "', 'class = "'], 'class="', $string); if (strpos($string, 'class="') !== FALSE) { $string = str_replace('class="', 'class="' . "$class ", $string); } diff --git a/CRM/Core/Smarty/resources/String.php b/CRM/Core/Smarty/resources/String.php index 6c9d80bdcb98..0ac2ad8dca99 100644 --- a/CRM/Core/Smarty/resources/String.php +++ b/CRM/Core/Smarty/resources/String.php @@ -74,11 +74,11 @@ function civicrm_smarty_resource_string_get_trusted($tpl_name, &$smarty_obj) { function civicrm_smarty_register_string_resource() { $template = CRM_Core_Smarty::singleton(); - $template->register_resource('string', array( + $template->register_resource('string', [ 'civicrm_smarty_resource_string_get_template', 'civicrm_smarty_resource_string_get_timestamp', 'civicrm_smarty_resource_string_get_secure', 'civicrm_smarty_resource_string_get_trusted', - ) + ] ); } diff --git a/CRM/Core/StateMachine.php b/CRM/Core/StateMachine.php index a78a3e545075..d4f7407f6fbd 100644 --- a/CRM/Core/StateMachine.php +++ b/CRM/Core/StateMachine.php @@ -94,7 +94,7 @@ public function __construct(&$controller, $action = CRM_Core_Action::NONE) { $this->_controller = &$controller; $this->_action = $action; - $this->_states = array(); + $this->_states = []; } /** @@ -262,7 +262,7 @@ public function addSequentialPages(&$pages) { $this->_pages = &$pages; $numPages = count($pages); - $this->_pageNames = array(); + $this->_pageNames = []; foreach ($pages as $tempName => $value) { if (!empty($value['className'])) { $this->_pageNames[] = $tempName; diff --git a/CRM/Core/TableHierarchy.php b/CRM/Core/TableHierarchy.php index f0d62fae1ca1..05037234e08d 100644 --- a/CRM/Core/TableHierarchy.php +++ b/CRM/Core/TableHierarchy.php @@ -39,7 +39,7 @@ class CRM_Core_TableHierarchy { * This array defines weights for table, which are used to sort array of table in from clause * @var array */ - static $info = array( + static $info = [ 'civicrm_contact' => '01', 'civicrm_address' => '09', 'civicrm_county' => '10', @@ -75,7 +75,7 @@ class CRM_Core_TableHierarchy { 'civicrm_mailing_event_opened' => '41', 'civicrm_mailing_event_reply' => '42', 'civicrm_mailing_event_trackable_url_open' => '43', - ); + ]; /** * @return array diff --git a/CRM/Core/Task.php b/CRM/Core/Task.php index 4f2a545b1fdf..1ecace68330e 100644 --- a/CRM/Core/Task.php +++ b/CRM/Core/Task.php @@ -98,7 +98,7 @@ public static function tasks() { public static function taskTitles() { static::tasks(); - $titles = array(); + $titles = []; foreach (self::$_tasks as $id => $value) { $titles[$id] = $value['title']; } @@ -175,10 +175,10 @@ public static function getTask($value) { // Children can specify a default task (eg. print), pick another if it is not valid. $value = key(self::$_tasks); } - return array( + return [ CRM_Utils_Array::value('class', self::$_tasks[$value]), CRM_Utils_Array::value('result', self::$_tasks[$value]), - ); + ]; } /** @@ -195,10 +195,10 @@ public static function getTaskAndTitleByClass($className) { if ((!empty($value['url']) || $task == self::TASK_EXPORT) && ((is_array($value['class']) && in_array($className, $value['class'])) || ($value['class'] == $className))) { - return array($task, CRM_Utils_Array::value('title', $value)); + return [$task, CRM_Utils_Array::value('title', $value)]; } } - return array(); + return []; } } diff --git a/CRM/Core/TemporaryErrorScope.php b/CRM/Core/TemporaryErrorScope.php index 7f7849608366..0aefdbf63dca 100644 --- a/CRM/Core/TemporaryErrorScope.php +++ b/CRM/Core/TemporaryErrorScope.php @@ -28,14 +28,14 @@ class CRM_Core_TemporaryErrorScope { * @return CRM_Core_TemporaryErrorScope */ public static function useException() { - return self::create(array('CRM_Core_Error', 'exceptionHandler'), 1); + return self::create(['CRM_Core_Error', 'exceptionHandler'], 1); } /** * @return CRM_Core_TemporaryErrorScope */ public static function ignoreException() { - return self::create(array('CRM_Core_Error', 'nullHandler')); + return self::create(['CRM_Core_Error', 'nullHandler']); } /** @@ -45,11 +45,11 @@ public static function ignoreException() { * @return CRM_Core_TemporaryErrorScope */ public static function create($callback, $modeException = NULL) { - $newFrame = array( + $newFrame = [ '_PEAR_default_error_mode' => PEAR_ERROR_CALLBACK, '_PEAR_default_error_options' => $callback, 'modeException' => $modeException, - ); + ]; return new CRM_Core_TemporaryErrorScope($newFrame); } @@ -70,11 +70,11 @@ public function __destruct() { * Read the active error-handler settings */ public static function getActive() { - return array( + return [ '_PEAR_default_error_mode' => $GLOBALS['_PEAR_default_error_mode'], '_PEAR_default_error_options' => $GLOBALS['_PEAR_default_error_options'], 'modeException' => CRM_Core_Error::$modeException, - ); + ]; } /** diff --git a/CRM/Custom/Form/ChangeFieldType.php b/CRM/Custom/Form/ChangeFieldType.php index 31f82d492894..89aa390a1891 100644 --- a/CRM/Custom/Form/ChangeFieldType.php +++ b/CRM/Custom/Form/ChangeFieldType.php @@ -66,8 +66,8 @@ public function preProcess() { $this, TRUE ); - $this->_values = array(); - $params = array('id' => $this->_id); + $this->_values = []; + $params = ['id' => $this->_id]; CRM_Core_BAO_CustomField::retrieve($params, $this->_values); $this->_htmlTypeTransitions = self::fieldTypeTransitions(CRM_Utils_Array::value('data_type', $this->_values), @@ -85,7 +85,7 @@ public function preProcess() { $session->pushUserContext($url); CRM_Utils_System::setTitle(ts('Change Field Type: %1', - array(1 => $this->_values['label']) + [1 => $this->_values['label']] )); } @@ -99,7 +99,7 @@ public function buildQuickForm() { $srcHtmlType = $this->add('select', 'src_html_type', ts('Current HTML Type'), - array($this->_values['html_type'] => $this->_values['html_type']), + [$this->_values['html_type'] => $this->_values['html_type']], TRUE ); @@ -111,24 +111,24 @@ public function buildQuickForm() { $dstHtmlType = $this->add('select', 'dst_html_type', ts('New HTML Type'), - array( + [ '' => ts('- select -'), - ) + $this->_htmlTypeTransitions, + ] + $this->_htmlTypeTransitions, TRUE ); - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => ts('Change Field Type'), 'isDefault' => TRUE, - 'js' => array('onclick' => 'return checkCustomDataField();'), - ), - array( + 'js' => ['onclick' => 'return checkCustomDataField();'], + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); } @@ -145,17 +145,17 @@ public function postProcess() { 'table_name' ); - $singleValueOps = array( + $singleValueOps = [ 'Text', 'Select', 'Radio', 'Autocomplete-Select', - ); + ]; - $mutliValueOps = array( + $mutliValueOps = [ 'CheckBox', 'Multi-Select', - ); + ]; $srcHtmlType = $this->_values['html_type']; $dstHtmlType = $params['dst_html_type']; @@ -164,11 +164,11 @@ public function postProcess() { $customField->id = $this->_id; $customField->find(TRUE); - if ($dstHtmlType == 'Text' && in_array($srcHtmlType, array( + if ($dstHtmlType == 'Text' && in_array($srcHtmlType, [ 'Select', 'Radio', 'Autocomplete-Select', - )) + ]) ) { $customField->option_group_id = "NULL"; CRM_Core_BAO_CustomField::checkOptionGroup($this->_values['option_group_id']); @@ -192,7 +192,7 @@ public function postProcess() { CRM_Core_BAO_Cache::deleteGroup('contact fields'); CRM_Core_Session::setStatus(ts('Input type of custom field \'%1\' has been successfully changed to \'%2\'.', - array(1 => $this->_values['label'], 2 => $dstHtmlType) + [1 => $this->_values['label'], 2 => $dstHtmlType] ), ts('Field Type Changed'), 'success'); } @@ -209,17 +209,17 @@ public static function fieldTypeTransitions($dataType, $htmlType) { return NULL; } - $singleValueOps = array( + $singleValueOps = [ 'Text' => 'Text', 'Select' => 'Select', 'Radio' => 'Radio', 'Autocomplete-Select' => 'Autocomplete-Select', - ); + ]; - $mutliValueOps = array( + $mutliValueOps = [ 'CheckBox' => 'CheckBox', 'Multi-Select' => 'Multi-Select', - ); + ]; switch ($dataType) { case 'String': @@ -248,10 +248,10 @@ public static function fieldTypeTransitions($dataType, $htmlType) { break; case 'Memo': - $ops = array( + $ops = [ 'TextArea' => 'TextArea', 'RichTextEditor' => 'RichTextEditor', - ); + ]; if (in_array($htmlType, array_keys($ops))) { unset($ops[$htmlType]); return $ops; @@ -278,10 +278,10 @@ public function firstValueToFlatten($table, $column) { continue; } $value = CRM_Core_DAO::VALUE_SEPARATOR . $dao->{$column} . CRM_Core_DAO::VALUE_SEPARATOR; - $params = array( - 1 => array((string) $value, 'String'), - 2 => array($dao->id, 'Integer'), - ); + $params = [ + 1 => [(string) $value, 'String'], + 2 => [$dao->id, 'Integer'], + ]; CRM_Core_DAO::executeQuery($updateSql, $params); } } @@ -299,10 +299,10 @@ public function flattenToFirstValue($table, $column) { $dao = CRM_Core_DAO::executeQuery($selectSql); while ($dao->fetch()) { $values = self::explode($dao->{$column}); - $params = array( - 1 => array((string) array_shift($values), 'String'), - 2 => array($dao->id, 'Integer'), - ); + $params = [ + 1 => [(string) array_shift($values), 'String'], + 2 => [$dao->id, 'Integer'], + ]; CRM_Core_DAO::executeQuery($updateSql, $params); } } @@ -314,7 +314,7 @@ public function flattenToFirstValue($table, $column) { */ public static function explode($str) { if (empty($str) || $str == CRM_Core_DAO::VALUE_SEPARATOR . CRM_Core_DAO::VALUE_SEPARATOR) { - return array(); + return []; } else { return explode(CRM_Core_DAO::VALUE_SEPARATOR, trim($str, CRM_Core_DAO::VALUE_SEPARATOR)); diff --git a/CRM/Custom/Form/CustomData.php b/CRM/Custom/Form/CustomData.php index d2a644f7ff18..3cc0d279c8f4 100644 --- a/CRM/Custom/Form/CustomData.php +++ b/CRM/Custom/Form/CustomData.php @@ -173,7 +173,7 @@ public static function preProcess( * @return array */ public static function setDefaultValues(&$form) { - $defaults = array(); + $defaults = []; CRM_Core_BAO_CustomGroup::setDefaults($form->_groupTree, $defaults, FALSE, FALSE, $form->get('action')); return $defaults; } @@ -232,11 +232,11 @@ public static function setGroupTree(&$form, $subType, $gid, $onlySubType = NULL, foreach ($keys as $key) { $form->_groupTree[$key] = $groupTree[$key]; } - return array($form, $groupTree); + return [$form, $groupTree]; } else { $form->_groupTree = $groupTree; - return array($form, $groupTree); + return [$form, $groupTree]; } } diff --git a/CRM/Custom/Form/CustomDataByType.php b/CRM/Custom/Form/CustomDataByType.php index ddc7bc6c7272..c88a29fb1622 100644 --- a/CRM/Custom/Form/CustomDataByType.php +++ b/CRM/Custom/Form/CustomDataByType.php @@ -71,7 +71,7 @@ public function preProcess() { * @return array */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; CRM_Core_BAO_CustomGroup::setDefaults($this->_groupTree, $defaults, FALSE, FALSE, $this->get('action')); return $defaults; } diff --git a/CRM/Custom/Form/DeleteField.php b/CRM/Custom/Form/DeleteField.php index 44564e3d0c64..f196a29b9f01 100644 --- a/CRM/Custom/Form/DeleteField.php +++ b/CRM/Custom/Form/DeleteField.php @@ -61,13 +61,13 @@ class CRM_Custom_Form_DeleteField extends CRM_Core_Form { public function preProcess() { $this->_id = $this->get('id'); - $defaults = array(); - $params = array('id' => $this->_id); + $defaults = []; + $params = ['id' => $this->_id]; CRM_Core_BAO_CustomField::retrieve($params, $defaults); $this->_title = CRM_Utils_Array::value('label', $defaults); $this->assign('title', $this->_title); - CRM_Utils_System::setTitle(ts('Delete %1', array(1 => $this->_title))); + CRM_Utils_System::setTitle(ts('Delete %1', [1 => $this->_title])); } /** @@ -77,17 +77,17 @@ public function preProcess() { */ public function buildQuickForm() { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => ts('Delete Custom Field'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); } @@ -104,7 +104,7 @@ public function postProcess() { CRM_Core_BAO_CustomField::deleteField($field); // also delete any profiles associted with this custom field - CRM_Core_Session::setStatus(ts('The custom field \'%1\' has been deleted.', array(1 => $field->label)), '', 'success'); + CRM_Core_Session::setStatus(ts('The custom field \'%1\' has been deleted.', [1 => $field->label]), '', 'success'); } diff --git a/CRM/Custom/Form/DeleteGroup.php b/CRM/Custom/Form/DeleteGroup.php index c0693c3705ed..4c6af1a9a4f0 100644 --- a/CRM/Custom/Form/DeleteGroup.php +++ b/CRM/Custom/Form/DeleteGroup.php @@ -61,8 +61,8 @@ class CRM_Custom_Form_DeleteGroup extends CRM_Core_Form { public function preProcess() { $this->_id = $this->get('id'); - $defaults = array(); - $params = array('id' => $this->_id); + $defaults = []; + $params = ['id' => $this->_id]; CRM_Core_BAO_CustomGroup::retrieve($params, $defaults); $this->_title = $defaults['title']; @@ -71,7 +71,7 @@ public function preProcess() { $customField->custom_group_id = $this->_id; if ($customField->find(TRUE)) { - CRM_Core_Session::setStatus(ts("The Group '%1' cannot be deleted! You must Delete all custom fields in this group prior to deleting the group.", array(1 => $this->_title)), ts('Deletion Error'), 'error'); + CRM_Core_Session::setStatus(ts("The Group '%1' cannot be deleted! You must Delete all custom fields in this group prior to deleting the group.", [1 => $this->_title]), ts('Deletion Error'), 'error'); $url = CRM_Utils_System::url('civicrm/admin/custom/group', "reset=1"); CRM_Utils_System::redirect($url); return TRUE; @@ -88,17 +88,17 @@ public function preProcess() { */ public function buildQuickForm() { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => ts('Delete Custom Group'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); } @@ -114,7 +114,7 @@ public function postProcess() { $wt = CRM_Utils_Weight::delWeight('CRM_Core_DAO_CustomGroup', $this->_id); CRM_Core_BAO_CustomGroup::deleteGroup($group); - CRM_Core_Session::setStatus(ts("The Group '%1' has been deleted.", array(1 => $group->title)), '', 'success'); + CRM_Core_Session::setStatus(ts("The Group '%1' has been deleted.", [1 => $group->title]), '', 'success'); } } diff --git a/CRM/Custom/Form/Field.php b/CRM/Custom/Form/Field.php index 1d64aadc8a0a..f9e25de480f3 100644 --- a/CRM/Custom/Form/Field.php +++ b/CRM/Custom/Form/Field.php @@ -99,10 +99,10 @@ public function preProcess() { //custom field id $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this); - $this->_values = array(); + $this->_values = []; //get the values form db if update. if ($this->_id) { - $params = array('id' => $this->_id); + $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); @@ -128,39 +128,39 @@ public function preProcess() { } if (self::$_dataToLabels == NULL) { - self::$_dataToLabels = array( - array( + self::$_dataToLabels = [ + [ 'Text' => ts('Text'), 'Select' => ts('Select'), 'Radio' => ts('Radio'), 'CheckBox' => ts('CheckBox'), 'Multi-Select' => ts('Multi-Select'), 'Autocomplete-Select' => ts('Autocomplete-Select'), - ), - array( + ], + [ 'Text' => ts('Text'), 'Select' => ts('Select'), 'Radio' => ts('Radio'), - ), - array( + ], + [ 'Text' => ts('Text'), 'Select' => ts('Select'), 'Radio' => ts('Radio'), - ), - array( + ], + [ 'Text' => ts('Text'), 'Select' => ts('Select'), 'Radio' => ts('Radio'), - ), - array('TextArea' => ts('TextArea'), 'RichTextEditor' => ts('Rich Text Editor')), - array('Date' => ts('Select Date')), - array('Radio' => ts('Radio')), - array('StateProvince' => ts('Select State/Province'), 'Multi-Select' => ts('Multi-Select State/Province')), - array('Country' => ts('Select Country'), 'Multi-Select' => ts('Multi-Select Country')), - array('File' => ts('Select File')), - array('Link' => ts('Link')), - array('ContactReference' => ts('Autocomplete-Select')), - ); + ], + ['TextArea' => ts('TextArea'), 'RichTextEditor' => ts('Rich Text Editor')], + ['Date' => ts('Select Date')], + ['Radio' => ts('Radio')], + ['StateProvince' => ts('Select State/Province'), 'Multi-Select' => ts('Multi-Select State/Province')], + ['Country' => ts('Select Country'), 'Multi-Select' => ts('Multi-Select Country')], + ['File' => ts('Select File')], + ['Link' => ts('Link')], + ['ContactReference' => ts('Autocomplete-Select')], + ]; } } @@ -222,10 +222,10 @@ public function setDefaultValues() { $defaultHTMLType = array_search($defaults['html_type'], self::$_dataToHTML[$defaultDataType] ); - $defaults['data_type'] = array( + $defaults['data_type'] = [ '0' => $defaultDataType, '1' => $defaultHTMLType, - ); + ]; $this->_defaultDataType = $defaults['data_type']; } @@ -247,7 +247,7 @@ public function setDefaultValues() { } if ($this->_action & CRM_Core_Action::ADD) { - $fieldValues = array('custom_group_id' => $this->_gid); + $fieldValues = ['custom_group_id' => $this->_gid]; $defaults['weight'] = CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_CustomField', $fieldValues); $defaults['text_length'] = 255; @@ -300,7 +300,7 @@ public function buildQuickForm() { ); $dt = &self::$_dataTypeValues; - $it = array(); + $it = []; foreach ($dt as $key => $value) { $it[$key] = self::$_dataToLabels[$key]; } @@ -309,7 +309,7 @@ public function buildQuickForm() { ts('Data and Input Field Type'), '   ' ); - $sel->setOptions(array($dt, $it)); + $sel->setOptions([$dt, $it]); if (CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $this->_gid, 'is_multiple')) { $this->add('checkbox', 'in_selector', ts('Display in Table?')); @@ -336,7 +336,7 @@ public function buildQuickForm() { $optionGroupMetadata = civicrm_api3('OptionGroup', 'get', $optionGroupParams); // OptionGroup selection - $optionTypes = array('1' => ts('Create a new set of options')); + $optionTypes = ['1' => ts('Create a new set of options')]; if (!empty($optionGroupMetadata['values'])) { $emptyOptGroup = FALSE; @@ -346,9 +346,9 @@ public function buildQuickForm() { $this->add('select', 'option_group_id', ts('Multiple Choice Option Sets'), - array( + [ '' => ts('- select -'), - ) + $optionGroups + ] + $optionGroups ); } else { @@ -359,9 +359,9 @@ public function buildQuickForm() { $element = &$this->addRadio('option_type', ts('Option Type'), $optionTypes, - array( + [ 'onclick' => "showOptionSelect();", - ), '
    ' + ], '
    ' ); // if empty option group freeze the option type. if ($emptyOptGroup) { @@ -376,7 +376,7 @@ public function buildQuickForm() { ts('Limit List to Group'), $contactGroups, FALSE, - array('multiple' => 'multiple', 'class' => 'crm-select2') + ['multiple' => 'multiple', 'class' => 'crm-select2'] ); $this->add('text', @@ -385,10 +385,10 @@ public function buildQuickForm() { $attributes['filter'] ); - $this->add('hidden', 'filter_selected', 'Group', array('id' => 'filter_selected')); + $this->add('hidden', 'filter_selected', 'Group', ['id' => 'filter_selected']); // form fields of Custom Option rows - $defaultOption = array(); + $defaultOption = []; $_showHide = new CRM_Core_ShowHideBlocks('', ''); for ($i = 1; $i <= self::NUM_OPTION; $i++) { @@ -438,7 +438,7 @@ public function buildQuickForm() { $this->add('number', 'text_length', ts('Database field length'), - $attributes['text_length'] + array('min' => 1), + $attributes['text_length'] + ['min' => 1], FALSE ); $this->addRule('text_length', ts('Value should be a positive number'), 'integer'); @@ -460,11 +460,11 @@ public function buildQuickForm() { $this->addRule('end_date_years', ts('Value should be a positive number'), 'integer'); $this->add('select', 'date_format', ts('Date Format'), - array('' => ts('- select -')) + CRM_Core_SelectValues::getDatePluginInputFormats() + ['' => ts('- select -')] + CRM_Core_SelectValues::getDatePluginInputFormats() ); $this->add('select', 'time_format', ts('Time'), - array('' => ts('- none -')) + CRM_Core_SelectValues::getTimeFormats() + ['' => ts('- none -')] + CRM_Core_SelectValues::getTimeFormats() ); // for Note field @@ -502,7 +502,7 @@ public function buildQuickForm() { $this->add('advcheckbox', 'is_required', ts('Required?')); // checkbox / radio options per line - $this->add('number', 'options_per_line', ts('Options Per Line'), array('min' => 0)); + $this->add('number', 'options_per_line', ts('Options Per Line'), ['min' => 0]); $this->addRule('options_per_line', ts('must be a numeric value'), 'numeric'); // default value, help pre, help post, mask, attributes, javascript ? @@ -532,33 +532,33 @@ public function buildQuickForm() { ); // is searchable by range? - $searchRange = array(); + $searchRange = []; $searchRange[] = $this->createElement('radio', NULL, NULL, ts('Yes'), '1'); $searchRange[] = $this->createElement('radio', NULL, NULL, ts('No'), '0'); $this->addGroup($searchRange, 'is_search_range', ts('Search by Range?')); // add buttons - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'done', 'name' => ts('Save'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'next', 'name' => ts('Save and New'), 'subName' => 'new', - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); // add a form rule to check default value - $this->addFormRule(array('CRM_Custom_Form_Field', 'formRule'), $this); + $this->addFormRule(['CRM_Custom_Form_Field', 'formRule'], $this); // if view mode pls freeze it with the done button. if ($this->_action & CRM_Core_Action::VIEW) { @@ -567,7 +567,7 @@ public function buildQuickForm() { $this->addElement('button', 'done', ts('Done'), - array('onclick' => "location.href='$url'") + ['onclick' => "location.href='$url'"] ); } } @@ -588,7 +588,7 @@ public function buildQuickForm() { public static function formRule($fields, $files, $self) { $default = CRM_Utils_Array::value('default_value', $fields); - $errors = array(); + $errors = []; self::clearEmptyOptions($fields); @@ -597,14 +597,14 @@ public static function formRule($fields, $files, $self) { $name = CRM_Utils_String::munge($title, '_', 64); $gId = $self->_gid; // CRM-7564 $query = 'select count(*) from civicrm_custom_field where ( name like %1 OR label like %2 ) and id != %3 and custom_group_id = %4'; - $fldCnt = CRM_Core_DAO::singleValueQuery($query, array( - 1 => array($name, 'String'), - 2 => array($title, 'String'), - 3 => array((int) $self->_id, 'Integer'), - 4 => array($gId, 'Integer'), - )); + $fldCnt = CRM_Core_DAO::singleValueQuery($query, [ + 1 => [$name, 'String'], + 2 => [$title, 'String'], + 3 => [(int) $self->_id, 'Integer'], + 4 => [$gId, 'Integer'], + ]); if ($fldCnt) { - $errors['label'] = ts('Custom field \'%1\' already exists in Database.', array(1 => $title)); + $errors['label'] = ts('Custom field \'%1\' already exists in Database.', [1 => $title]); } //checks the given custom field name doesnot start with digit @@ -668,7 +668,7 @@ public static function formRule($fields, $files, $self) { case 'Country': if (!empty($default)) { $query = "SELECT count(*) FROM civicrm_country WHERE name = %1 OR iso_code = %1"; - $params = array(1 => array($fields['default_value'], 'String')); + $params = [1 => [$fields['default_value'], 'String']]; if (CRM_Core_DAO::singleValueQuery($query, $params) <= 0) { $errors['default_value'] = ts('Invalid default value for country.'); } @@ -682,7 +682,7 @@ public static function formRule($fields, $files, $self) { FROM civicrm_state_province WHERE name = %1 OR abbreviation = %1"; - $params = array(1 => array($fields['default_value'], 'String')); + $params = [1 => [$fields['default_value'], 'String']]; if (CRM_Core_DAO::singleValueQuery($query, $params) <= 0) { $errors['default_value'] = ts('The invalid default value for State/Province data type'); } @@ -698,7 +698,7 @@ public static function formRule($fields, $files, $self) { $errors['filter'] = ts("Only 'get' action is supported."); } } - $self->setDefaults(array('filter_selected', $fields['filter_selected'])); + $self->setDefaults(['filter_selected', $fields['filter_selected']]); break; } } @@ -719,7 +719,7 @@ public static function formRule($fields, $files, $self) { if (isset($fields['data_type'][1])) { $dataField = $fields['data_type'][1]; } - $optionFields = array('Select', 'Multi-Select', 'CheckBox', 'Radio'); + $optionFields = ['Select', 'Multi-Select', 'CheckBox', 'Radio']; if (isset($fields['option_type']) && $fields['option_type'] == 1) { //capture duplicate Custom option values @@ -833,7 +833,7 @@ public static function formRule($fields, $files, $self) { } elseif (isset($dataField) && in_array($dataField, $optionFields) && - !in_array($dataType, array('Boolean', 'Country', 'StateProvince')) + !in_array($dataType, ['Boolean', 'Country', 'StateProvince']) ) { if (!$fields['option_group_id']) { $errors['option_group_id'] = ts('You must select a Multiple Choice Option set if you chose Reuse an existing set.'); @@ -844,13 +844,13 @@ public static function formRule($fields, $files, $self) { FROM civicrm_custom_field WHERE data_type != %1 AND option_group_id = %2"; - $params = array( - 1 => array( + $params = [ + 1 => [ self::$_dataTypeKeys[$fields['data_type'][0]], 'String', - ), - 2 => array($fields['option_group_id'], 'Integer'), - ); + ], + 2 => [$fields['option_group_id'], 'Integer'], + ]; $count = CRM_Core_DAO::singleValueQuery($query, $params); if ($count > 0) { $errors['option_group_id'] = ts('The data type of the multiple choice option set you\'ve selected does not match the data type assigned to this field.'); @@ -928,12 +928,12 @@ public function postProcess() { } //fix for 'is_search_range' field. - if (in_array($dataTypeKey, array( + if (in_array($dataTypeKey, [ 1, 2, 3, 5, - ))) { + ])) { if (empty($params['is_searchable'])) { $params['is_search_range'] = 0; } @@ -957,7 +957,7 @@ public function postProcess() { // fix for CRM-316 $oldWeight = NULL; if ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD)) { - $fieldValues = array('custom_group_id' => $this->_gid); + $fieldValues = ['custom_group_id' => $this->_gid]; if ($this->_id) { $oldWeight = $this->_values['weight']; } @@ -1019,7 +1019,7 @@ public function postProcess() { // reset the cache CRM_Core_BAO_Cache::deleteGroup('contact fields'); - $msg = '

    ' . ts("Custom field '%1' has been saved.", array(1 => $customField->label)) . '

    '; + $msg = '

    ' . ts("Custom field '%1' has been saved.", [1 => $customField->label]) . '

    '; $buttonName = $this->controller->getButtonName(); $session = CRM_Core_Session::singleton(); diff --git a/CRM/Custom/Form/Group.php b/CRM/Custom/Form/Group.php index 57135f0c5c4c..d57e422557da 100644 --- a/CRM/Custom/Form/Group.php +++ b/CRM/Custom/Form/Group.php @@ -57,7 +57,7 @@ class CRM_Custom_Form_Group extends CRM_Core_Form { * * @var array */ - protected $_subtypes = array(); + protected $_subtypes = []; /** * Set variables up before form is built. @@ -75,18 +75,18 @@ public function preProcess() { // setting title for html page if ($this->_action == CRM_Core_Action::UPDATE) { $title = CRM_Core_BAO_CustomGroup::getTitle($this->_id); - CRM_Utils_System::setTitle(ts('Edit %1', array(1 => $title))); + CRM_Utils_System::setTitle(ts('Edit %1', [1 => $title])); } elseif ($this->_action == CRM_Core_Action::VIEW) { $title = CRM_Core_BAO_CustomGroup::getTitle($this->_id); - CRM_Utils_System::setTitle(ts('Preview %1', array(1 => $title))); + CRM_Utils_System::setTitle(ts('Preview %1', [1 => $title])); } else { CRM_Utils_System::setTitle(ts('New Custom Field Set')); } if (isset($this->_id)) { - $params = array('id' => $this->_id); + $params = ['id' => $this->_id]; CRM_Core_BAO_CustomGroup::retrieve($params, $this->_defaults); $subExtends = CRM_Utils_Array::value('extends_entity_column_value', $this->_defaults); @@ -110,18 +110,18 @@ public function preProcess() { * true if no errors, else array of errors */ public static function formRule($fields, $files, $self) { - $errors = array(); + $errors = []; //validate group title as well as name. $title = $fields['title']; $name = CRM_Utils_String::munge($title, '_', 64); $query = 'select count(*) from civicrm_custom_group where ( name like %1) and id != %2'; - $grpCnt = CRM_Core_DAO::singleValueQuery($query, array( - 1 => array($name, 'String'), - 2 => array((int) $self->_id, 'Integer'), - )); + $grpCnt = CRM_Core_DAO::singleValueQuery($query, [ + 1 => [$name, 'String'], + 2 => [(int) $self->_id, 'Integer'], + ]); if ($grpCnt) { - $errors['title'] = ts('Custom group \'%1\' already exists in Database.', array(1 => $title)); + $errors['title'] = ts('Custom group \'%1\' already exists in Database.', [1 => $title]); } if (!empty($fields['extends'][1])) { @@ -134,7 +134,7 @@ public static function formRule($fields, $files, $self) { $errors['extends'] = ts("You need to select the type of record that this set of custom fields is applicable for."); } - $extends = array('Activity', 'Relationship', 'Group', 'Contribution', 'Membership', 'Event', 'Participant'); + $extends = ['Activity', 'Relationship', 'Group', 'Contribution', 'Membership', 'Event', 'Participant']; if (in_array($fields['extends'][0], $extends) && $fields['style'] == 'Tab') { $errors['style'] = ts("Display Style should be Inline for this Class"); $self->assign('showStyle', TRUE); @@ -170,7 +170,7 @@ public static function formRule($fields, $files, $self) { * @see valid_date */ public function addRules() { - $this->addFormRule(array('CRM_Custom_Form_Group', 'formRule'), $this); + $this->addFormRule(['CRM_Custom_Form_Group', 'formRule'], $this); } /** @@ -188,11 +188,11 @@ public function buildQuickForm() { $this->add('text', 'title', ts('Set Name'), $attributes['title'], TRUE); //Fix for code alignment, CRM-3058 - $contactTypes = array('Contact', 'Individual', 'Household', 'Organization'); + $contactTypes = ['Contact', 'Individual', 'Household', 'Organization']; $this->assign('contactTypes', json_encode($contactTypes)); - $sel1 = array("" => ts("- select -")) + CRM_Core_SelectValues::customGroupExtends(); - $sel2 = array(); + $sel1 = ["" => ts("- select -")] + CRM_Core_SelectValues::customGroupExtends(); + $sel2 = []; $activityType = CRM_Core_PseudoConstant::activityType(FALSE, TRUE, FALSE, 'label', TRUE); $eventType = CRM_Core_OptionGroup::values('event_type'); @@ -227,22 +227,22 @@ public function buildQuickForm() { foreach ($sel2 as $main => $sub) { if (!empty($sel2[$main])) { - $sel2[$main] = array( + $sel2[$main] = [ '' => ts("- Any -"), - ) + $sel2[$main]; + ] + $sel2[$main]; } } $cSubTypes = CRM_Core_Component::contactSubTypes(); if (!empty($cSubTypes)) { - $contactSubTypes = array(); + $contactSubTypes = []; foreach ($cSubTypes as $key => $value) { $contactSubTypes[$key] = $key; } - $sel2['Contact'] = array( + $sel2['Contact'] = [ "" => ("- Any -"), - ) + $contactSubTypes; + ] + $contactSubTypes; } else { if (!isset($this->_id)) { @@ -258,13 +258,13 @@ public function buildQuickForm() { $sel = &$this->add('hierselect', 'extends', ts('Used For'), - array( + [ 'name' => 'extends[0]', 'style' => 'vertical-align: top;', - ), + ], TRUE ); - $sel->setOptions(array($sel1, $sel2)); + $sel->setOptions([$sel1, $sel2]); if (is_a($sel->_elements[1], 'HTML_QuickForm_select')) { // make second selector a multi-select - $sel->_elements[1]->setMultiple(TRUE); @@ -345,18 +345,18 @@ public function buildQuickForm() { $this->assign('showStyle', FALSE); $this->assign('showMultiple', FALSE); - $buttons = array( - array( + $buttons = [ + [ 'type' => 'next', 'name' => ts('Save'), 'spacing' => '         ', 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ); + ], + ]; if (!$this->_isGroupEmpty && !empty($this->_subtypes)) { $buttons[0]['class'] = 'crm-warnDataLoss'; } @@ -365,7 +365,7 @@ public function buildQuickForm() { // TODO: Is this condition ever true? Can this code be removed? if ($this->_action & CRM_Core_Action::VIEW) { $this->freeze(); - $this->addElement('button', 'done', ts('Done'), array('onclick' => "location.href='civicrm/admin/custom/group?reset=1&action=browse'")); + $this->addElement('button', 'done', ts('Done'), ['onclick' => "location.href='civicrm/admin/custom/group?reset=1&action=browse'"]); } } @@ -405,11 +405,11 @@ public function setDefaultValues() { $defaults['extends'][1] = $this->_subtypes; } else { - $defaults['extends'][1] = array(0 => ''); + $defaults['extends'][1] = [0 => '']; } if ($extends == 'Relationship' && !empty($this->_subtypes)) { - $relationshipDefaults = array(); + $relationshipDefaults = []; foreach ($defaults['extends'][1] as $donCare => $rel_type_id) { $relationshipDefaults[] = $rel_type_id; } @@ -438,7 +438,7 @@ public function postProcess() { } if (!empty($this->_subtypes)) { - $subtypesToBeRemoved = array(); + $subtypesToBeRemoved = []; $subtypesToPreserve = $params['extends'][1]; // Don't remove any value if group is extended to -any- subtype if (!empty($subtypesToPreserve[0])) { @@ -460,14 +460,14 @@ public function postProcess() { CRM_Core_BAO_Cache::deleteGroup('contact fields'); if ($this->_action & CRM_Core_Action::UPDATE) { - CRM_Core_Session::setStatus(ts('Your custom field set \'%1 \' has been saved.', array(1 => $group->title)), ts('Saved'), 'success'); + CRM_Core_Session::setStatus(ts('Your custom field set \'%1 \' has been saved.', [1 => $group->title]), ts('Saved'), 'success'); } else { // Jump directly to adding a field if popups are disabled $action = CRM_Core_Resources::singleton()->ajaxPopupsEnabled ? '' : '/add'; $url = CRM_Utils_System::url("civicrm/admin/custom/group/field$action", 'reset=1&new=1&gid=' . $group->id . '&action=' . ($action ? 'add' : 'browse')); CRM_Core_Session::setStatus(ts("Your custom field set '%1' has been added. You can add custom fields now.", - array(1 => $group->title) + [1 => $group->title] ), ts('Saved'), 'success'); $session = CRM_Core_Session::singleton(); $session->replaceUserContext($url); @@ -478,7 +478,7 @@ public function postProcess() { $config = CRM_Core_Config::singleton(); if (is_array($db_prefix) && $config->userSystem->is_drupal && module_exists('views')) { // get table_name for each custom group - $tables = array(); + $tables = []; $sql = "SELECT table_name FROM civicrm_custom_group WHERE is_active = 1"; $result = CRM_Core_DAO::executeQuery($sql); while ($result->fetch()) { @@ -490,7 +490,7 @@ public function postProcess() { if (!empty($missingTableNames)) { CRM_Core_Session::setStatus(ts("To ensure that all of your custom data groups are available to Views, you may need to add the following key(s) to the db_prefix array in your settings.php file: '%1'.", - array(1 => implode(', ', $missingTableNames)) + [1 => implode(', ', $missingTableNames)] ), ts('Note'), 'info'); } } diff --git a/CRM/Custom/Form/MoveField.php b/CRM/Custom/Form/MoveField.php index a6be59df5bba..d05af627a346 100644 --- a/CRM/Custom/Form/MoveField.php +++ b/CRM/Custom/Form/MoveField.php @@ -95,7 +95,7 @@ public function preProcess() { ); CRM_Utils_System::setTitle(ts('Custom Field Move: %1', - array(1 => $this->_srcFieldLabel) + [1 => $this->_srcFieldLabel] )); $session = CRM_Core_Session::singleton(); @@ -115,9 +115,9 @@ public function buildQuickForm() { CRM_Core_Error::statusBounce(ts('You need more than one custom group to move fields')); } - $customGroup = array( + $customGroup = [ '' => ts('- select -'), - ) + $customGroup; + ] + $customGroup; $this->add('select', 'dst_group_id', ts('Destination'), @@ -125,20 +125,20 @@ public function buildQuickForm() { TRUE ); - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => ts('Move Custom Field'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); - $this->addFormRule(array('CRM_Custom_Form_MoveField', 'formRule'), $this); + $this->addFormRule(['CRM_Custom_Form_MoveField', 'formRule'], $this); } /** @@ -151,7 +151,7 @@ public function buildQuickForm() { public static function formRule($fields, $files, $self) { $self->_dstGID = $fields['dst_group_id']; $tmp = CRM_Core_BAO_CustomField::_moveFieldValidate($self->_srcFID, $self->_dstGID); - $errors = array(); + $errors = []; if ($tmp['newGroupID']) { $errors['dst_group_id'] = $tmp['newGroupID']; } @@ -172,11 +172,11 @@ public function postProcess() { ); $srcUrl = CRM_Utils_System::url('civicrm/admin/custom/group/field', "reset=1&action=browse&gid={$this->_dstGID}"); CRM_Core_Session::setStatus(ts("%1 has been moved to the custom set %2.", - array( + [ 1 => $this->_srcFieldLabel, 2 => $dstGroup, 3 => $srcUrl, - )), '', 'success'); + ]), '', 'success'); } } diff --git a/CRM/Custom/Form/Option.php b/CRM/Custom/Form/Option.php index dffed8944eb1..96d8a42058a0 100644 --- a/CRM/Custom/Form/Option.php +++ b/CRM/Custom/Form/Option.php @@ -105,12 +105,12 @@ public function preProcess() { * array of default values */ public function setDefaultValues() { - $defaults = $fieldDefaults = array(); + $defaults = $fieldDefaults = []; if (isset($this->_id)) { - $params = array('id' => $this->_id); + $params = ['id' => $this->_id]; CRM_Core_BAO_CustomOption::retrieve($params, $defaults); - $paramsField = array('id' => $this->_fid); + $paramsField = ['id' => $this->_fid]; CRM_Core_BAO_CustomField::retrieve($paramsField, $fieldDefaults); if ($fieldDefaults['html_type'] == 'CheckBox' @@ -136,7 +136,7 @@ public function setDefaultValues() { } if ($this->_action & CRM_Core_Action::ADD) { - $fieldValues = array('option_group_id' => $this->_optionGroupID); + $fieldValues = ['option_group_id' => $this->_optionGroupID]; $defaults['weight'] = CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_OptionValue', $fieldValues); } @@ -150,19 +150,19 @@ public function setDefaultValues() { */ public function buildQuickForm() { if ($this->_action == CRM_Core_Action::DELETE) { - $option = civicrm_api3('option_value', 'getsingle', array('id' => $this->_id)); + $option = civicrm_api3('option_value', 'getsingle', ['id' => $this->_id]); $this->assign('label', $option['label']); - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => ts('Delete'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); } else { @@ -192,25 +192,25 @@ public function buildQuickForm() { $this->add('checkbox', 'default_value', ts('Default')); // add a custom form rule - $this->addFormRule(array('CRM_Custom_Form_Option', 'formRule'), $this); + $this->addFormRule(['CRM_Custom_Form_Option', 'formRule'], $this); // add buttons - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => ts('Save'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'next', 'name' => ts('Save and New'), 'subName' => 'new', - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); // if view mode pls freeze it with the done button. @@ -223,7 +223,7 @@ public function buildQuickForm() { $this->addElement('button', 'done', ts('Done'), - array('onclick' => "location.href='$url'", 'class' => 'crm-form-submit cancel', 'crm-icon' => 'fa-times') + ['onclick' => "location.href='$url'", 'class' => 'crm-form-submit cancel', 'crm-icon' => 'fa-times'] ); } } @@ -248,17 +248,17 @@ public static function formRule($fields, $files, $form) { $fieldId = $form->_fid; $optionGroupId = $form->_optionGroupID; - $temp = array(); + $temp = []; if (empty($form->_id)) { $query = " SELECT count(*) FROM civicrm_option_value WHERE option_group_id = %1 AND label = %2"; - $params = array( - 1 => array($optionGroupId, 'Integer'), - 2 => array($optionLabel, 'String'), - ); + $params = [ + 1 => [$optionGroupId, 'Integer'], + 2 => [$optionLabel, 'String'], + ]; if (CRM_Core_DAO::singleValueQuery($query, $params) > 0) { $errors['label'] = ts('There is an entry with the same label.'); } @@ -268,10 +268,10 @@ public static function formRule($fields, $files, $form) { FROM civicrm_option_value WHERE option_group_id = %1 AND value = %2"; - $params = array( - 1 => array($optionGroupId, 'Integer'), - 2 => array($optionValue, 'String'), - ); + $params = [ + 1 => [$optionGroupId, 'Integer'], + 2 => [$optionValue, 'String'], + ]; if (CRM_Core_DAO::singleValueQuery($query, $params) > 0) { $errors['value'] = ts('There is an entry with the same value.'); } @@ -287,11 +287,11 @@ public static function formRule($fields, $files, $form) { WHERE option_group_id = %1 AND id != %2 AND label = %3"; - $params = array( - 1 => array($optionGroupId, 'Integer'), - 2 => array($optionId, 'Integer'), - 3 => array($optionLabel, 'String'), - ); + $params = [ + 1 => [$optionGroupId, 'Integer'], + 2 => [$optionId, 'Integer'], + 3 => [$optionLabel, 'String'], + ]; if (CRM_Core_DAO::singleValueQuery($query, $params) > 0) { $errors['label'] = ts('There is an entry with the same label.'); } @@ -303,11 +303,11 @@ public static function formRule($fields, $files, $form) { WHERE option_group_id = %1 AND id != %2 AND value = %3"; - $params = array( - 1 => array($optionGroupId, 'Integer'), - 2 => array($optionId, 'Integer'), - 3 => array($optionValue, 'String'), - ); + $params = [ + 1 => [$optionGroupId, 'Integer'], + 2 => [$optionId, 'Integer'], + 3 => [$optionValue, 'String'], + ]; if (CRM_Core_DAO::singleValueQuery($query, $params) > 0) { $errors['value'] = ts('There is an entry with the same value.'); } @@ -317,7 +317,7 @@ public static function formRule($fields, $files, $form) { SELECT data_type FROM civicrm_custom_field WHERE id = %1"; - $params = array(1 => array($fieldId, 'Integer')); + $params = [1 => [$fieldId, 'Integer']]; $dao = CRM_Core_DAO::executeQuery($query, $params); if ($dao->fetch()) { switch ($dao->data_type) { @@ -356,7 +356,7 @@ public static function formRule($fields, $files, $form) { case 'Country': if (!empty($fields["value"])) { - $params = array(1 => array($fields['value'], 'String')); + $params = [1 => [$fields['value'], 'String']]; $query = "SELECT count(*) FROM civicrm_country WHERE name = %1 OR iso_code = %1"; if (CRM_Core_DAO::singleValueQuery($query, $params) <= 0) { $errors['value'] = ts('Invalid default value for country.'); @@ -366,7 +366,7 @@ public static function formRule($fields, $files, $form) { case 'StateProvince': if (!empty($fields["value"])) { - $params = array(1 => array($fields['value'], 'String')); + $params = [1 => [$fields['value'], 'String']]; $query = " SELECT count(*) FROM civicrm_state_province @@ -393,11 +393,11 @@ public function postProcess() { $params = $this->controller->exportValues('Option'); if ($this->_action == CRM_Core_Action::DELETE) { - $option = civicrm_api3('option_value', 'getsingle', array('id' => $this->_id)); - $fieldValues = array('option_group_id' => $this->_optionGroupID); + $option = civicrm_api3('option_value', 'getsingle', ['id' => $this->_id]); + $fieldValues = ['option_group_id' => $this->_optionGroupID]; CRM_Utils_Weight::delWeight('CRM_Core_DAO_OptionValue', $this->_id, $fieldValues); CRM_Core_BAO_CustomOption::del($this->_id); - CRM_Core_Session::setStatus(ts('Option "%1" has been deleted.', array(1 => $option['label'])), ts('Deleted'), 'success'); + CRM_Core_Session::setStatus(ts('Option "%1" has been deleted.', [1 => $option['label']]), ts('Deleted'), 'success'); return; } @@ -417,7 +417,7 @@ public function postProcess() { $oldWeight = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', $this->_id, 'weight', 'id'); } - $fieldValues = array('option_group_id' => $this->_optionGroupID); + $fieldValues = ['option_group_id' => $this->_optionGroupID]; $customOption->weight = CRM_Utils_Weight::updateOtherWeights( 'CRM_Core_DAO_OptionValue', @@ -443,7 +443,7 @@ public function postProcess() { if (!empty($params['default_value'])) { if (!in_array($customOption->value, $defVal)) { if (empty($defVal[0])) { - $defVal = array($customOption->value); + $defVal = [$customOption->value]; } else { $defVal[] = $customOption->value; @@ -456,7 +456,7 @@ public function postProcess() { } } elseif (in_array($customOption->value, $defVal)) { - $tempVal = array(); + $tempVal = []; foreach ($defVal as $v) { if ($v != $customOption->value) { $tempVal[] = $v; @@ -498,7 +498,7 @@ public function postProcess() { $customOption->save(); - $msg = ts('Your multiple choice option \'%1\' has been saved', array(1 => $customOption->label)); + $msg = ts('Your multiple choice option \'%1\' has been saved', [1 => $customOption->label]); CRM_Core_Session::setStatus($msg, '', 'success'); $buttonName = $this->controller->getButtonName(); $session = CRM_Core_Session::singleton(); diff --git a/CRM/Custom/Form/Preview.php b/CRM/Custom/Form/Preview.php index 1e3296d0dd2e..4ad064eaf5be 100644 --- a/CRM/Custom/Form/Preview.php +++ b/CRM/Custom/Form/Preview.php @@ -63,8 +63,8 @@ public function preProcess() { $this->_fieldId = $this->get('fieldId'); if ($this->_fieldId) { // field preview - $defaults = array(); - $params = array('id' => $this->_fieldId); + $defaults = []; + $params = ['id' => $this->_fieldId]; $fieldDAO = new CRM_Core_DAO_CustomField(); CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_CustomField', $params, $defaults); @@ -75,9 +75,9 @@ public function preProcess() { CRM_Core_Error::statusBounce(ts('This field is inactive so it will not display on edit form.')); } - $groupTree = array(); + $groupTree = []; $groupTree[$this->_groupId]['id'] = 0; - $groupTree[$this->_groupId]['fields'] = array(); + $groupTree[$this->_groupId]['fields'] = []; $groupTree[$this->_groupId]['fields'][$this->_fieldId] = $defaults; $this->_groupTree = CRM_Core_BAO_CustomGroup::formatGroupTree($groupTree, 1, $this); $this->assign('preview_type', 'field'); @@ -96,7 +96,7 @@ public function preProcess() { * the default array reference */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; CRM_Core_BAO_CustomGroup::setDefaults($this->_groupTree, $defaults, FALSE, FALSE); @@ -117,13 +117,13 @@ public function buildQuickForm() { $this->assign('groupTree', $this->_groupTree); } - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'cancel', 'name' => ts('Done with Preview'), 'isDefault' => TRUE, - ), - ) + ], + ] ); } diff --git a/CRM/Custom/Import/Controller.php b/CRM/Custom/Import/Controller.php index a5053f34eff8..375991f3f796 100644 --- a/CRM/Custom/Import/Controller.php +++ b/CRM/Custom/Import/Controller.php @@ -26,7 +26,7 @@ public function __construct($title = NULL, $action = CRM_Core_Action::NONE, $mod // add all the actions $config = CRM_Core_Config::singleton(); - $this->addActions($config->uploadDir, array('uploadFile')); + $this->addActions($config->uploadDir, ['uploadFile']); } } diff --git a/CRM/Custom/Import/Form/DataSource.php b/CRM/Custom/Import/Form/DataSource.php index e592cda3be2d..91221240fb0f 100644 --- a/CRM/Custom/Import/Form/DataSource.php +++ b/CRM/Custom/Import/Form/DataSource.php @@ -47,11 +47,11 @@ class CRM_Custom_Import_Form_DataSource extends CRM_Import_Form_DataSource { */ public function setDefaultValues() { $config = CRM_Core_Config::singleton(); - $defaults = array( + $defaults = [ 'contactType' => CRM_Import_Parser::CONTACT_INDIVIDUAL, 'fieldSeparator' => $config->fieldSeparator, 'multipleCustomData' => $this->_id, - ); + ]; if ($loadeMapping = $this->get('loadedMapping')) { $this->assign('loadedMapping', $loadeMapping); @@ -70,7 +70,7 @@ public function buildQuickForm() { parent::buildQuickForm(); $multipleCustomData = CRM_Core_BAO_CustomGroup::getMultipleFieldGroup(); - $this->add('select', 'multipleCustomData', ts('Multi-value Custom Data'), array('' => ts('- select -')) + $multipleCustomData, TRUE); + $this->add('select', 'multipleCustomData', ts('Multi-value Custom Data'), ['' => ts('- select -')] + $multipleCustomData, TRUE); $this->addContactTypeSelector(); } @@ -81,12 +81,12 @@ public function buildQuickForm() { * @return void */ public function postProcess() { - $this->storeFormValues(array( + $this->storeFormValues([ 'contactType', 'dateFormats', 'savedMapping', 'multipleCustomData', - )); + ]); $this->submitFileForMapping('CRM_Custom_Import_Parser_Api', 'multipleCustomData'); } diff --git a/CRM/Custom/Import/Form/MapField.php b/CRM/Custom/Import/Form/MapField.php index abc0138c04e8..b7a42335c242 100644 --- a/CRM/Custom/Import/Form/MapField.php +++ b/CRM/Custom/Import/Form/MapField.php @@ -23,7 +23,7 @@ public function preProcess() { $this->_columnCount = $this->get('columnCount'); $this->assign('columnCount', $this->_columnCount); $this->_dataValues = $this->get('dataValues'); - $highlightedFields = array('contact_id', 'external_identifier'); + $highlightedFields = ['contact_id', 'external_identifier']; //Separate column names from actual values. $columnNames = $this->_dataValues[0]; @@ -52,7 +52,7 @@ public function preProcess() { */ public function buildQuickForm() { parent::buildQuickForm(); - $this->addFormRule(array('CRM_Custom_Import_Form_MapField', 'formRule')); + $this->addFormRule(['CRM_Custom_Import_Form_MapField', 'formRule']); } /** @@ -65,10 +65,10 @@ public function buildQuickForm() { * list of errors to be posted back to the form */ public static function formRule($fields) { - $errors = array(); + $errors = []; $fieldMessage = NULL; if (!array_key_exists('savedMapping', $fields)) { - $importKeys = array(); + $importKeys = []; foreach ($fields['mapper'] as $mapperPart) { $importKeys[] = $mapperPart[0]; } @@ -78,7 +78,7 @@ public static function formRule($fields) { if (!isset($errors['_qf_default'])) { $errors['_qf_default'] = ''; } - $errors['_qf_default'] .= ts('Missing required field: %1', array(1 => ts('Contact ID or External Identifier'))); + $errors['_qf_default'] .= ts('Missing required field: %1', [1 => ts('Contact ID or External Identifier')]); } } @@ -136,10 +136,10 @@ public function postProcess() { $skipColumnHeader = $this->controller->exportValue('DataSource', 'skipColumnHeader'); $this->_entity = $this->controller->exportValue('DataSource', 'entity'); - $mapperKeys = array(); - $mapper = array(); + $mapperKeys = []; + $mapper = []; $mapperKeys = $this->controller->exportValue($this->_name, 'mapper'); - $mapperKeysMain = array(); + $mapperKeysMain = []; for ($i = 0; $i < $this->_columnCount; $i++) { $mapper[$i] = $this->_mapperFields[$mapperKeys[$i][0]]; @@ -158,7 +158,7 @@ public function postProcess() { $mappingFields->mapping_id = $params['mappingId']; $mappingFields->find(); - $mappingFieldsId = array(); + $mappingFieldsId = []; while ($mappingFields->fetch()) { if ($mappingFields->id) { $mappingFieldsId[$mappingFields->column_number] = $mappingFields->id; @@ -183,11 +183,11 @@ public function postProcess() { //Saving Mapping Details and Records if (!empty($params['saveMapping'])) { - $mappingParams = array( + $mappingParams = [ 'name' => $params['saveMappingName'], 'description' => $params['saveMappingDesc'], 'mapping_type_id' => CRM_Core_PseudoConstant::getKey('CRM_Core_BAO_Mapping', 'mapping_type_id', $this->_mappingType), - ); + ]; $saveMapping = CRM_Core_BAO_Mapping::add($mappingParams); for ($i = 0; $i < $this->_columnCount; $i++) { diff --git a/CRM/Custom/Import/Form/Preview.php b/CRM/Custom/Import/Form/Preview.php index 3d772fcda1a0..76a5765705ce 100644 --- a/CRM/Custom/Import/Form/Preview.php +++ b/CRM/Custom/Import/Form/Preview.php @@ -56,7 +56,7 @@ public function preProcess() { $this->set('downloadMismatchRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams)); } - $properties = array( + $properties = [ 'mapper', 'dataValues', 'columnCount', @@ -67,7 +67,7 @@ public function preProcess() { 'downloadErrorRecordsUrl', 'downloadConflictRecordsUrl', 'downloadMismatchRecordsUrl', - ); + ]; foreach ($properties as $property) { $this->assign($property, $this->get($property)); @@ -90,7 +90,7 @@ public function postProcess() { $entity = $this->get('_entity'); $mapper = $this->controller->exportValue('MapField', 'mapper'); - $mapperKeys = array(); + $mapperKeys = []; foreach ($mapper as $key => $value) { $mapperKeys[$key] = $mapper[$key][0]; @@ -102,7 +102,7 @@ public function postProcess() { $mapFields = $this->get('fields'); foreach ($mapper as $key => $value) { - $header = array(); + $header = []; if (isset($mapFields[$mapper[$key][0]])) { $header[] = $mapFields[$mapper[$key][0]]; } @@ -123,7 +123,7 @@ public function postProcess() { $errorStack = CRM_Core_Error::singleton(); $errors = $errorStack->getErrors(); - $errorMessage = array(); + $errorMessage = []; if (is_array($errors)) { foreach ($errors as $key => $value) { diff --git a/CRM/Custom/Import/Parser.php b/CRM/Custom/Import/Parser.php index 29fd491e128f..7d8fb5e2ac96 100644 --- a/CRM/Custom/Import/Parser.php +++ b/CRM/Custom/Import/Parser.php @@ -115,14 +115,14 @@ public function run( $this->_invalidRowCount = $this->_validCount = 0; $this->_totalCount = $this->_conflictCount = 0; - $this->_errors = array(); - $this->_warnings = array(); - $this->_conflicts = array(); + $this->_errors = []; + $this->_warnings = []; + $this->_conflicts = []; $this->_fileSize = number_format(filesize($fileName) / 1024.0, 2); if ($mode == self::MODE_MAPFIELD) { - $this->_rows = array(); + $this->_rows = []; } else { $this->_activeFieldCount = count($this->_activeFields); @@ -251,30 +251,30 @@ public function run( } if ($this->_invalidRowCount) { // removed view url for invlaid contacts - $headers = array_merge(array( + $headers = array_merge([ ts('Line Number'), ts('Reason'), - ), + ], $customHeaders ); $this->_errorFileName = self::errorFileName(self::ERROR); self::exportCSV($this->_errorFileName, $headers, $this->_errors); } if ($this->_conflictCount) { - $headers = array_merge(array( + $headers = array_merge([ ts('Line Number'), ts('Reason'), - ), + ], $customHeaders ); $this->_conflictFileName = self::errorFileName(self::CONFLICT); self::exportCSV($this->_conflictFileName, $headers, $this->_conflicts); } if ($this->_duplicateCount) { - $headers = array_merge(array( + $headers = array_merge([ ts('Line Number'), ts('View Activity History URL'), - ), + ], $customHeaders ); @@ -312,7 +312,7 @@ public function setActiveFields($fieldKeys) { * (reference ) associative array of name/value pairs */ public function &getActiveFieldParams() { - $params = array(); + $params = []; for ($i = 0; $i < $this->_activeFieldCount; $i++) { if (isset($this->_activeFields[$i]->_value) && !isset($params[$this->_activeFields[$i]->_name]) diff --git a/CRM/Custom/Import/Parser/Api.php b/CRM/Custom/Import/Parser/Api.php index dad22e5fd5ac..13f0c2db89a0 100644 --- a/CRM/Custom/Import/Parser/Api.php +++ b/CRM/Custom/Import/Parser/Api.php @@ -6,16 +6,16 @@ class CRM_Custom_Import_Parser_Api extends CRM_Custom_Import_Parser { protected $_entity = ''; - protected $_fields = array(); - protected $_requiredFields = array(); - protected $_dateFields = array(); + protected $_fields = []; + protected $_requiredFields = []; + protected $_dateFields = []; protected $_multipleCustomData = ''; /** * Params for the current entity being prepared for the api. * @var array */ - protected $_params = array(); + protected $_params = []; /** * Class constructor. @@ -32,11 +32,11 @@ public function __construct(&$mapperKeys, $mapperLocType = NULL, $mapperPhoneTyp public function setFields() { $customGroupID = $this->_multipleCustomData; $importableFields = $this->getGroupFieldsForImport($customGroupID, $this); - $this->_fields = array_merge(array( - 'do_not_import' => array('title' => ts('- do not import -')), - 'contact_id' => array('title' => ts('Contact ID')), - 'external_identifier' => array('title' => ts('External Identifier')), - ), $importableFields); + $this->_fields = array_merge([ + 'do_not_import' => ['title' => ts('- do not import -')], + 'contact_id' => ['title' => ts('Contact ID')], + 'external_identifier' => ['title' => ts('External Identifier')], + ], $importableFields); } /** @@ -121,7 +121,7 @@ public function summary(&$values) { $errorMessage = NULL; $contactType = $this->_contactType ? $this->_contactType : 'Organization'; - CRM_Contact_Import_Parser_Contact::isErrorInCustomData($this->_params + array('contact_type' => $contactType), $errorMessage, $this->_contactSubType, NULL); + CRM_Contact_Import_Parser_Contact::isErrorInCustomData($this->_params + ['contact_type' => $contactType], $errorMessage, $this->_contactSubType, NULL); // pseudoconstants if ($errorMessage) { @@ -147,10 +147,10 @@ public function summary(&$values) { public function import($onDuplicate, &$values) { $response = $this->summary($values); if ($response != CRM_Import_Parser::VALID) { - $importRecordParams = array( + $importRecordParams = [ $statusFieldName => 'INVALID', "${statusFieldName}Msg" => "Invalid (Error Code: $response)", - ); + ]; return $response; } @@ -159,9 +159,9 @@ public function import($onDuplicate, &$values) { $params = $this->getActiveFieldParams(); $contactType = $this->_contactType ? $this->_contactType : 'Organization'; - $formatted = array( + $formatted = [ 'contact_type' => $contactType, - ); + ]; $session = CRM_Core_Session::singleton(); $dateType = $session->get('dateTypes'); @@ -237,8 +237,8 @@ public function fini() { * */ public function getGroupFieldsForImport($id) { - $importableFields = array(); - $params = array('custom_group_id' => $id); + $importableFields = []; + $params = ['custom_group_id' => $id]; $allFields = civicrm_api3('custom_field', 'get', $params); $fields = $allFields['values']; foreach ($fields as $id => $values) { @@ -249,7 +249,7 @@ public function getGroupFieldsForImport($id) { /* generate the key for the fields array */ $key = "custom_$id"; $regexp = preg_replace('/[.,;:!?]/', '', CRM_Utils_Array::value(0, $values)); - $importableFields[$key] = array( + $importableFields[$key] = [ 'name' => $key, 'title' => CRM_Utils_Array::value('label', $values), 'headerPattern' => '/' . preg_quote($regexp, '/') . '/', @@ -259,7 +259,7 @@ public function getGroupFieldsForImport($id) { 'data_type' => CRM_Utils_Array::value('data_type', $values), 'html_type' => CRM_Utils_Array::value('html_type', $values), 'is_search_range' => CRM_Utils_Array::value('is_search_range', $values), - ); + ]; 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); diff --git a/CRM/Custom/Page/AJAX.php b/CRM/Custom/Page/AJAX.php index 5f3e9530c7b8..6774b584e8ca 100644 --- a/CRM/Custom/Page/AJAX.php +++ b/CRM/Custom/Page/AJAX.php @@ -54,7 +54,7 @@ public static function getOptionList() { $options = CRM_Core_BAO_CustomOption::getOptionListSelector($params); $iFilteredTotal = $iTotal = $params['total']; - $selectorElements = array( + $selectorElements = [ 'label', 'value', 'description', @@ -62,7 +62,7 @@ public static function getOptionList() { 'is_active', 'links', 'class', - ); + ]; CRM_Utils_System::setHttpHeader('Content-Type', 'application/json'); echo CRM_Utils_JSON::encodeDataTableSelector($options, $sEcho, $iTotal, $iFilteredTotal, $selectorElements); @@ -76,11 +76,11 @@ public static function getOptionList() { public static function fixOrdering() { $params = $_REQUEST; - $queryParams = array( - 1 => array($params['start'], 'Integer'), - 2 => array($params['end'], 'Integer'), - 3 => array($params['gid'], 'Integer'), - ); + $queryParams = [ + 1 => [$params['start'], 'Integer'], + 2 => [$params['end'], 'Integer'], + 3 => [$params['gid'], 'Integer'], + ]; $dao = "SELECT id FROM civicrm_option_value WHERE weight = %1 AND option_group_id = %3"; $startid = CRM_Core_DAO::singleValueQuery($dao, $queryParams); @@ -133,12 +133,12 @@ public static function getMultiRecordFieldList() { list($fields, $attributes) = $obj->browse(); // format params and add class attributes - $fieldList = array(); + $fieldList = []; foreach ($fields as $id => $value) { - $field = array(); + $field = []; foreach ($value as $fieldId => &$fieldName) { if (!empty($attributes[$fieldId][$id]['class'])) { - $fieldName = array('data' => $fieldName, 'cellClass' => $attributes[$fieldId][$id]['class']); + $fieldName = ['data' => $fieldName, 'cellClass' => $attributes[$fieldId][$id]['class']]; } if (is_numeric($fieldId)) { $fName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', $fieldId, 'column_name'); @@ -150,7 +150,7 @@ public static function getMultiRecordFieldList() { } $totalRecords = !empty($obj->_total) ? $obj->_total : 0; - $multiRecordFields = array(); + $multiRecordFields = []; $multiRecordFields['data'] = $fieldList; $multiRecordFields['recordsTotal'] = $totalRecords; $multiRecordFields['recordsFiltered'] = $totalRecords; diff --git a/CRM/Custom/Page/Field.php b/CRM/Custom/Page/Field.php index 5fd2159975d9..328f5d89265b 100644 --- a/CRM/Custom/Page/Field.php +++ b/CRM/Custom/Page/Field.php @@ -67,49 +67,49 @@ class CRM_Custom_Page_Field extends CRM_Core_Page { */ public static function &actionLinks() { if (!isset(self::$_actionLinks)) { - self::$_actionLinks = array( - CRM_Core_Action::UPDATE => array( + self::$_actionLinks = [ + CRM_Core_Action::UPDATE => [ 'name' => ts('Edit Field'), 'url' => 'civicrm/admin/custom/group/field/update', 'qs' => 'action=update&reset=1&gid=%%gid%%&id=%%id%%', 'title' => ts('Edit Custom Field'), - ), - CRM_Core_Action::BROWSE => array( + ], + CRM_Core_Action::BROWSE => [ 'name' => ts('Edit Multiple Choice Options'), 'url' => 'civicrm/admin/custom/group/field/option', 'qs' => 'reset=1&action=browse&gid=%%gid%%&fid=%%id%%', 'title' => ts('List Custom Options'), - ), - CRM_Core_Action::PREVIEW => array( + ], + CRM_Core_Action::PREVIEW => [ 'name' => ts('Preview Field Display'), 'url' => 'civicrm/admin/custom/group/field', 'qs' => 'action=preview&reset=1&gid=%%gid%%&id=%%id%%', 'title' => ts('Preview Custom Field'), - ), - CRM_Core_Action::DISABLE => array( + ], + CRM_Core_Action::DISABLE => [ 'name' => ts('Disable'), 'ref' => 'crm-enable-disable', 'title' => ts('Disable Custom Field'), - ), - CRM_Core_Action::ENABLE => array( + ], + CRM_Core_Action::ENABLE => [ 'name' => ts('Enable'), 'ref' => 'crm-enable-disable', 'title' => ts('Enable Custom Field'), - ), - CRM_Core_Action::EXPORT => array( + ], + CRM_Core_Action::EXPORT => [ 'name' => ts('Move'), 'url' => 'civicrm/admin/custom/group/field/move', 'class' => 'small-popup', 'qs' => 'reset=1&fid=%%id%%', 'title' => ts('Move Custom Field'), - ), - CRM_Core_Action::DELETE => array( + ], + CRM_Core_Action::DELETE => [ 'name' => ts('Delete'), 'url' => 'civicrm/admin/custom/group/field', 'qs' => 'action=delete&reset=1&gid=%%gid%%&id=%%id%%', 'title' => ts('Delete Custom Field'), - ), - ); + ], + ]; } return self::$_actionLinks; } @@ -125,7 +125,7 @@ public function browse() { $resourceManager->addScriptFile('civicrm', 'js/crm.addNew.js', 999, 'html-header'); } - $customField = array(); + $customField = []; $customFieldBAO = new CRM_Core_BAO_CustomField(); // fkey is gid @@ -134,7 +134,7 @@ public function browse() { $customFieldBAO->find(); while ($customFieldBAO->fetch()) { - $customField[$customFieldBAO->id] = array(); + $customField[$customFieldBAO->id] = []; CRM_Core_DAO::storeValues($customFieldBAO, $customField[$customFieldBAO->id]); $action = array_sum(array_keys(self::actionLinks())); if ($customFieldBAO->is_active) { @@ -171,10 +171,10 @@ public function browse() { $customField[$customFieldBAO->id]['data_type'] = $customFieldDataType[$customField[$customFieldBAO->id]['data_type']]; $customField[$customFieldBAO->id]['order'] = $customField[$customFieldBAO->id]['weight']; $customField[$customFieldBAO->id]['action'] = CRM_Core_Action::formLink(self::actionLinks(), $action, - array( + [ 'id' => $customFieldBAO->id, 'gid' => $this->_gid, - ), + ], ts('more'), FALSE, 'customField.row.actions', @@ -231,7 +231,7 @@ public function run() { ); if ($id) { - $values = civicrm_api3('custom_field', 'getsingle', array('id' => $id)); + $values = civicrm_api3('custom_field', 'getsingle', ['id' => $id]); $this->_gid = $values['custom_group_id']; } // get the group id @@ -262,7 +262,7 @@ public function run() { $controller->setEmbedded(TRUE); $controller->process(); $controller->run(); - $fieldValues = array('custom_group_id' => $this->_gid); + $fieldValues = ['custom_group_id' => $this->_gid]; $wt = CRM_Utils_Weight::delWeight('CRM_Core_DAO_CustomField', $id, $fieldValues); } @@ -271,7 +271,7 @@ public function run() { $this->assign('gid', $this->_gid); $this->assign('groupTitle', $groupTitle); if ($action & CRM_Core_Action::BROWSE) { - CRM_Utils_System::setTitle(ts('%1 - Custom Fields', array(1 => $groupTitle))); + CRM_Utils_System::setTitle(ts('%1 - Custom Fields', [1 => $groupTitle])); } } diff --git a/CRM/Custom/Page/Group.php b/CRM/Custom/Page/Group.php index 1d84c711d537..48b9b36f1026 100644 --- a/CRM/Custom/Page/Group.php +++ b/CRM/Custom/Page/Group.php @@ -60,42 +60,42 @@ class CRM_Custom_Page_Group extends CRM_Core_Page { public static function &actionLinks() { // check if variable _actionsLinks is populated if (!isset(self::$_actionLinks)) { - self::$_actionLinks = array( - CRM_Core_Action::BROWSE => array( + self::$_actionLinks = [ + CRM_Core_Action::BROWSE => [ 'name' => ts('View and Edit Custom Fields'), 'url' => 'civicrm/admin/custom/group/field', 'qs' => 'reset=1&action=browse&gid=%%id%%', 'title' => ts('View and Edit Custom Fields'), - ), - CRM_Core_Action::PREVIEW => array( + ], + CRM_Core_Action::PREVIEW => [ 'name' => ts('Preview'), 'url' => 'civicrm/admin/custom/group', 'qs' => 'action=preview&reset=1&id=%%id%%', 'title' => ts('Preview Custom Data Set'), - ), - CRM_Core_Action::UPDATE => array( + ], + CRM_Core_Action::UPDATE => [ 'name' => ts('Settings'), 'url' => 'civicrm/admin/custom/group', 'qs' => 'action=update&reset=1&id=%%id%%', 'title' => ts('Edit Custom Set'), - ), - CRM_Core_Action::DISABLE => array( + ], + CRM_Core_Action::DISABLE => [ 'name' => ts('Disable'), 'ref' => 'crm-enable-disable', 'title' => ts('Disable Custom Set'), - ), - CRM_Core_Action::ENABLE => array( + ], + CRM_Core_Action::ENABLE => [ 'name' => ts('Enable'), 'ref' => 'crm-enable-disable', 'title' => ts('Enable Custom Set'), - ), - CRM_Core_Action::DELETE => array( + ], + CRM_Core_Action::DELETE => [ 'name' => ts('Delete'), 'url' => 'civicrm/admin/custom/group', 'qs' => 'action=delete&reset=1&id=%%id%%', 'title' => ts('Delete Custom Set'), - ), - ); + ], + ]; } return self::$_actionLinks; } @@ -200,7 +200,7 @@ public function preview($id) { */ public function browse($action = NULL) { // get all custom groups sorted by weight - $customGroup = array(); + $customGroup = []; $dao = new CRM_Core_DAO_CustomGroup(); $dao->is_reserved = FALSE; $dao->orderBy('weight, title'); @@ -210,7 +210,7 @@ public function browse($action = NULL) { $customGroupStyle = CRM_Core_SelectValues::customGroupStyle(); while ($dao->fetch()) { $id = $dao->id; - $customGroup[$id] = array(); + $customGroup[$id] = []; CRM_Core_DAO::storeValues($dao, $customGroup[$id]); // form all action links $action = array_sum(array_keys(self::actionLinks())); @@ -224,7 +224,7 @@ public function browse($action = NULL) { } $customGroup[$id]['order'] = $customGroup[$id]['weight']; $customGroup[$id]['action'] = CRM_Core_Action::formLink(self::actionLinks(), $action, - array('id' => $id), + ['id' => $id], ts('more'), FALSE, 'customGroup.row.actions', @@ -238,7 +238,7 @@ public function browse($action = NULL) { } //fix for Displaying subTypes - $subTypes = array(); + $subTypes = []; $subTypes['Activity'] = CRM_Core_PseudoConstant::activityType(FALSE, TRUE, FALSE, 'label', TRUE); $subTypes['Contribution'] = CRM_Contribute_PseudoConstant::financialType(); @@ -246,7 +246,7 @@ public function browse($action = NULL) { $subTypes['Event'] = CRM_Core_OptionGroup::values('event_type'); $subTypes['Grant'] = CRM_Core_OptionGroup::values('grant_type'); $subTypes['Campaign'] = CRM_Campaign_PseudoConstant::campaignType(); - $subTypes['Participant'] = array(); + $subTypes['Participant'] = []; $subTypes['ParticipantRole'] = CRM_Core_OptionGroup::values('participant_role');; $subTypes['ParticipantEventName'] = CRM_Event_PseudoConstant::event(); $subTypes['ParticipantEventType'] = CRM_Core_OptionGroup::values('event_type'); @@ -258,7 +258,7 @@ public function browse($action = NULL) { $relTypeOrg = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, 'null', NULL, 'Organization'); $relTypeHou = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, 'null', NULL, 'Household'); - $allRelationshipType = array(); + $allRelationshipType = []; $allRelationshipType = array_merge($relTypeInd, $relTypeOrg); $allRelationshipType = array_merge($allRelationshipType, $relTypeHou); @@ -274,7 +274,7 @@ public function browse($action = NULL) { $subTypes['Relationship'] = $allRelationshipType; $cSubTypes = CRM_Core_Component::contactSubTypes(); - $contactSubTypes = array(); + $contactSubTypes = []; foreach ($cSubTypes as $key => $value) { $contactSubTypes[$key] = $key; } diff --git a/CRM/Custom/Page/Option.php b/CRM/Custom/Page/Option.php index 24e2a6b1f6ba..bfdfc015bcb0 100644 --- a/CRM/Custom/Page/Option.php +++ b/CRM/Custom/Page/Option.php @@ -74,36 +74,36 @@ class CRM_Custom_Page_Option extends CRM_Core_Page { */ public static function &actionLinks() { if (!isset(self::$_actionLinks)) { - self::$_actionLinks = array( - CRM_Core_Action::UPDATE => array( + self::$_actionLinks = [ + CRM_Core_Action::UPDATE => [ 'name' => ts('Edit Option'), 'url' => 'civicrm/admin/custom/group/field/option', 'qs' => 'reset=1&action=update&id=%%id%%&fid=%%fid%%&gid=%%gid%%', 'title' => ts('Edit Multiple Choice Option'), - ), - CRM_Core_Action::VIEW => array( + ], + CRM_Core_Action::VIEW => [ 'name' => ts('View'), 'url' => 'civicrm/admin/custom/group/field/option', 'qs' => 'action=view&id=%%id%%&fid=%%fid%%', 'title' => ts('View Multiple Choice Option'), - ), - CRM_Core_Action::DISABLE => array( + ], + CRM_Core_Action::DISABLE => [ 'name' => ts('Disable'), 'ref' => 'crm-enable-disable', 'title' => ts('Disable Multiple Choice Option'), - ), - CRM_Core_Action::ENABLE => array( + ], + CRM_Core_Action::ENABLE => [ 'name' => ts('Enable'), 'ref' => 'crm-enable-disable', 'title' => ts('Enable Multiple Choice Option'), - ), - CRM_Core_Action::DELETE => array( + ], + CRM_Core_Action::DELETE => [ 'name' => ts('Delete'), 'url' => 'civicrm/admin/custom/group/field/option', 'qs' => 'action=delete&id=%%id%%&fid=%%fid%%', 'title' => ts('Delete Multiple Choice Option'), - ), - ); + ], + ]; } return self::$_actionLinks; } @@ -122,11 +122,11 @@ public function alphabetize() { SELECT id, label FROM civicrm_option_value WHERE option_group_id = %1"; - $params = array( - 1 => array($optionGroupID, 'Integer'), - ); + $params = [ + 1 => [$optionGroupID, 'Integer'], + ]; $dao = CRM_Core_DAO::executeQuery($query, $params); - $optionValue = array(); + $optionValue = []; while ($dao->fetch()) { $optionValue[$dao->id] = $dao->label; } @@ -166,19 +166,19 @@ public function browse() { SELECT id, label FROM civicrm_custom_field WHERE option_group_id = %1"; - $params = array( - 1 => array($optionGroupID, 'Integer'), - 2 => array($this->_fid, 'Integer'), - ); + $params = [ + 1 => [$optionGroupID, 'Integer'], + 2 => [$this->_fid, 'Integer'], + ]; $dao = CRM_Core_DAO::executeQuery($query, $params); - $reusedNames = array(); + $reusedNames = []; if ($dao->N > 1) { while ($dao->fetch()) { $reusedNames[] = $dao->label; } $reusedNames = implode(', ', $reusedNames); $newTitle = ts('%1 - Multiple Choice Options', - array(1 => $reusedNames) + [1 => $reusedNames] ); CRM_Utils_System::setTitle($newTitle); $this->assign('reusedNames', $reusedNames); @@ -238,12 +238,12 @@ public function run() { $this->assign('isOptionGroupLocked', $isOptionGroupLocked); //as url contain $gid so append breadcrumb dynamically. - $breadcrumb = array( - array( + $breadcrumb = [ + [ 'title' => ts('Custom Data Fields'), 'url' => CRM_Utils_System::url('civicrm/admin/custom/group/field', 'reset=1&gid=' . $this->_gid), - ), - ); + ], + ]; CRM_Utils_System::appendBreadCrumb($breadcrumb); if ($this->_fid) { @@ -251,7 +251,7 @@ public function run() { $this->assign('fid', $this->_fid); $this->assign('gid', $this->_gid); $this->assign('fieldTitle', $fieldTitle); - CRM_Utils_System::setTitle(ts('%1 - Multiple Choice Options', array(1 => $fieldTitle))); + CRM_Utils_System::setTitle(ts('%1 - Multiple Choice Options', [1 => $fieldTitle])); } // get the requested action diff --git a/CRM/Cxn/ApiRouter.php b/CRM/Cxn/ApiRouter.php index ff9d557c0c6b..4ea90fdac053 100644 --- a/CRM/Cxn/ApiRouter.php +++ b/CRM/Cxn/ApiRouter.php @@ -41,7 +41,7 @@ class CRM_Cxn_ApiRouter { * @return mixed */ public static function route($cxn, $entity, $action, $params) { - $SUPER_PERM = array('administer CiviCRM'); + $SUPER_PERM = ['administer CiviCRM']; require_once 'api/v3/utils.php'; diff --git a/CRM/Cxn/BAO/Cxn.php b/CRM/Cxn/BAO/Cxn.php index f28732c1e854..156ccfb8394e 100644 --- a/CRM/Cxn/BAO/Cxn.php +++ b/CRM/Cxn/BAO/Cxn.php @@ -71,10 +71,10 @@ public static function getSiteCallbackUrl() { */ public static function updateAppMeta($appMeta) { \Civi\Cxn\Rpc\AppMeta::validate($appMeta); - CRM_Core_DAO::executeQuery('UPDATE civicrm_cxn SET app_meta = %1 WHERE app_guid = %2', array( - 1 => array(json_encode($appMeta), 'String'), - 2 => array($appMeta['appId'], 'String'), - )); + CRM_Core_DAO::executeQuery('UPDATE civicrm_cxn SET app_meta = %1 WHERE app_guid = %2', [ + 1 => [json_encode($appMeta), 'String'], + 2 => [$appMeta['appId'], 'String'], + ]); } /** @@ -160,7 +160,7 @@ public static function createApiServer() { $apiServer->setLog(new CRM_Utils_SystemLogger()); $apiServer->setCertValidator(self::createCertificateValidator()); $apiServer->setHttp(CRM_Cxn_CiviCxnHttp::singleton()); - $apiServer->setRouter(array('CRM_Cxn_ApiRouter', 'route')); + $apiServer->setRouter(['CRM_Cxn_ApiRouter', 'route']); return $apiServer; } diff --git a/CRM/Cxn/CiviCxnHttp.php b/CRM/Cxn/CiviCxnHttp.php index 0d6024812cc0..f8acdb970432 100644 --- a/CRM/Cxn/CiviCxnHttp.php +++ b/CRM/Cxn/CiviCxnHttp.php @@ -22,11 +22,11 @@ class CRM_Cxn_CiviCxnHttp extends \Civi\Cxn\Rpc\Http\PhpHttp { */ public static function singleton($fresh = FALSE) { if (self::$singleton === NULL || $fresh) { - $cache = CRM_Utils_Cache::create(array( + $cache = CRM_Utils_Cache::create([ 'name' => 'CiviCxnHttp', - 'type' => Civi::settings()->get('debug_enabled') ? 'ArrayCache' : array('SqlGroup', 'ArrayCache'), + 'type' => Civi::settings()->get('debug_enabled') ? 'ArrayCache' : ['SqlGroup', 'ArrayCache'], 'prefetch' => FALSE, - )); + ]); self::$singleton = new CRM_Cxn_CiviCxnHttp($cache); } @@ -50,7 +50,7 @@ public function __construct($cache) { * @return array * array($headers, $blob, $code) */ - public function send($verb, $url, $blob, $headers = array()) { + public function send($verb, $url, $blob, $headers = []) { $lowVerb = strtolower($verb); if ($lowVerb === 'get' && $this->cache) { @@ -67,11 +67,11 @@ public function send($verb, $url, $blob, $headers = array()) { $expires = CRM_Utils_Http::parseExpiration($result[0]); if ($expires !== NULL) { $cachePath = 'get_' . md5($url); - $cacheLine = array( + $cacheLine = [ 'url' => $url, 'expires' => $expires, 'data' => $result, - ); + ]; $this->cache->set($cachePath, $cacheLine); } } @@ -93,9 +93,9 @@ public function send($verb, $url, $blob, $headers = array()) { protected function createStreamOpts($verb, $url, $blob, $headers) { $result = parent::createStreamOpts($verb, $url, $blob, $headers); - $caConfig = CA_Config_Stream::probe(array( + $caConfig = CA_Config_Stream::probe([ 'verify_peer' => (bool) Civi::settings()->get('verifySSL'), - )); + ]); if ($caConfig->isEnableSSL()) { $result['ssl'] = $caConfig->toStreamOptions(); } diff --git a/CRM/Cxn/CiviCxnStore.php b/CRM/Cxn/CiviCxnStore.php index dc25dc8c51ba..972fbfa1dbc0 100644 --- a/CRM/Cxn/CiviCxnStore.php +++ b/CRM/Cxn/CiviCxnStore.php @@ -5,14 +5,14 @@ */ class CRM_Cxn_CiviCxnStore implements Civi\Cxn\Rpc\CxnStore\CxnStoreInterface { - protected $cxns = array(); + protected $cxns = []; /** * @inheritDoc */ public function getAll() { if (!$this->cxns) { - $this->cxns = array(); + $this->cxns = []; $dao = new CRM_Cxn_DAO_Cxn(); $dao->find(); while ($dao->fetch()) { @@ -71,9 +71,9 @@ public function add($cxn) { WHERE created_date IS NULL AND cxn_guid = %1 '; - CRM_Core_DAO::executeQuery($sql, array( - 1 => array($cxn['cxnId'], 'String'), - )); + CRM_Core_DAO::executeQuery($sql, [ + 1 => [$cxn['cxnId'], 'String'], + ]); $this->cxns[$cxn['cxnId']] = $cxn; } @@ -82,9 +82,9 @@ public function add($cxn) { * @inheritDoc */ public function remove($cxnId) { - CRM_Core_DAO::executeQuery('DELETE FROM civicrm_cxn WHERE cxn_guid = %1', array( - 1 => array($cxnId, 'String'), - )); + CRM_Core_DAO::executeQuery('DELETE FROM civicrm_cxn WHERE cxn_guid = %1', [ + 1 => [$cxnId, 'String'], + ]); unset($this->cxns[$cxnId]); } @@ -95,14 +95,14 @@ public function remove($cxnId) { */ protected function convertDaoToCxn($dao) { $appMeta = json_decode($dao->app_meta, TRUE); - return array( + return [ 'cxnId' => $dao->cxn_guid, 'secret' => $dao->secret, 'appId' => $dao->app_guid, 'appUrl' => $appMeta['appUrl'], 'siteUrl' => CRM_Cxn_BAO_Cxn::getSiteCallbackUrl(), 'perm' => json_decode($dao->perm, TRUE), - ); + ]; } /** diff --git a/CRM/Dashlet/Page/AllCases.php b/CRM/Dashlet/Page/AllCases.php index bd0ac05422a5..50fc6f5cba5d 100644 --- a/CRM/Dashlet/Page/AllCases.php +++ b/CRM/Dashlet/Page/AllCases.php @@ -62,7 +62,7 @@ public function run() { $controller->process(); $controller->run(); - if (CRM_Case_BAO_Case::getCases(TRUE, array('type' => 'any'), 'dashboard', TRUE)) { + if (CRM_Case_BAO_Case::getCases(TRUE, ['type' => 'any'], 'dashboard', TRUE)) { $this->assign('casePresent', TRUE); } return parent::run(); diff --git a/CRM/Dashlet/Page/Blog.php b/CRM/Dashlet/Page/Blog.php index 5a8b9ac1ebe9..03ea32f1c443 100644 --- a/CRM/Dashlet/Page/Blog.php +++ b/CRM/Dashlet/Page/Blog.php @@ -95,7 +95,7 @@ protected function getFeeds() { $newsFeed = $this->getFeed($this->getNewsUrl()); // If unable to fetch the feed, return empty results. if (!$newsFeed) { - return array(); + return []; } $feeds = $this->formatItems($newsFeed); return $feeds; @@ -123,15 +123,15 @@ protected function getFeed($url) { * @return array */ protected function formatItems($feed) { - $result = array(); + $result = []; if ($feed && !empty($feed->channel)) { foreach ($feed->channel as $channel) { - $content = array( + $content = [ 'title' => (string) $channel->title, 'description' => (string) $channel->description, 'name' => strtolower(CRM_Utils_String::munge($channel->title, '-')), - 'items' => array(), - ); + 'items' => [], + ]; foreach ($channel->item as $item) { $item = (array) $item; $item['title'] = strip_tags($item['title']); diff --git a/CRM/Dashlet/Page/GettingStarted.php b/CRM/Dashlet/Page/GettingStarted.php index d6813370f2d5..29d1e105806a 100644 --- a/CRM/Dashlet/Page/GettingStarted.php +++ b/CRM/Dashlet/Page/GettingStarted.php @@ -45,11 +45,11 @@ class CRM_Dashlet_Page_GettingStarted extends CRM_Core_Page { /** * Define tokens available for getting started */ - static $_tokens = array( - 'crmurl' => array( + static $_tokens = [ + 'crmurl' => [ 'configbackend' => 'civicrm/admin/configtask', - ), - ); + ], + ]; /** * Get the final, usable URL string (after interpolating any variables) diff --git a/CRM/Dashlet/Page/MyCases.php b/CRM/Dashlet/Page/MyCases.php index c19c057b7d50..071102fa3b44 100644 --- a/CRM/Dashlet/Page/MyCases.php +++ b/CRM/Dashlet/Page/MyCases.php @@ -62,7 +62,7 @@ public function run() { $controller->process(); $controller->run(); - if (CRM_Case_BAO_Case::getCases(FALSE, array('type' => 'any'), $context, TRUE)) { + if (CRM_Case_BAO_Case::getCases(FALSE, ['type' => 'any'], $context, TRUE)) { $this->assign('casePresent', TRUE); } return parent::run(); diff --git a/CRM/Dedupe/BAO/QueryBuilder/IndividualGeneral.php b/CRM/Dedupe/BAO/QueryBuilder/IndividualGeneral.php index 00be6f40b0b3..5f9aa38dceff 100644 --- a/CRM/Dedupe/BAO/QueryBuilder/IndividualGeneral.php +++ b/CRM/Dedupe/BAO/QueryBuilder/IndividualGeneral.php @@ -41,7 +41,7 @@ public static function record($rg) { $query .= " AND (contact1.middle_name IS NULL or contact1.middle_name = '$middle_name')\n"; } - return array("civicrm_contact.{$rg->name}.{$rg->threshold}" => $query); + return ["civicrm_contact.{$rg->name}.{$rg->threshold}" => $query]; } /** @@ -66,7 +66,7 @@ public static function internal($rg) { AND (contact1.middle_name IS NULL OR contact2.middle_name IS NULL OR contact1.middle_name = contact2.middle_name) AND (contact1.birth_date IS NULL OR contact2.birth_date IS NULL OR contact1.birth_date = contact2.birth_date) AND " . self::internalFilters($rg); - return array("civicrm_contact.{$rg->name}.{$rg->threshold}" => $query); + return ["civicrm_contact.{$rg->name}.{$rg->threshold}" => $query]; } } diff --git a/CRM/Dedupe/BAO/QueryBuilder/IndividualSupervised.php b/CRM/Dedupe/BAO/QueryBuilder/IndividualSupervised.php index e150f44fd06a..4928fa0a3758 100644 --- a/CRM/Dedupe/BAO/QueryBuilder/IndividualSupervised.php +++ b/CRM/Dedupe/BAO/QueryBuilder/IndividualSupervised.php @@ -15,25 +15,25 @@ class CRM_Dedupe_BAO_QueryBuilder_IndividualSupervised extends CRM_Dedupe_BAO_Qu */ public static function record($rg) { - $civicrm_contact = CRM_Utils_Array::value('civicrm_contact', $rg->params, array()); - $civicrm_email = CRM_Utils_Array::value('civicrm_email', $rg->params, array()); + $civicrm_contact = CRM_Utils_Array::value('civicrm_contact', $rg->params, []); + $civicrm_email = CRM_Utils_Array::value('civicrm_email', $rg->params, []); - $params = array( - 1 => array( + $params = [ + 1 => [ CRM_Utils_Array::value('first_name', $civicrm_contact, ''), 'String', - ), - 2 => array( + ], + 2 => [ CRM_Utils_Array::value('last_name', $civicrm_contact, ''), 'String', - ), - 3 => array( + ], + 3 => [ CRM_Utils_Array::value('email', $civicrm_email, ''), 'String', - ), - ); + ], + ]; - return array( + return [ "civicrm_contact.{$rg->name}.{$rg->threshold}" => CRM_Core_DAO::composeQuery(" SELECT contact.id as id1, {$rg->threshold} as weight FROM civicrm_contact as contact @@ -42,7 +42,7 @@ public static function record($rg) { AND first_name = %1 AND last_name = %2 AND email = %3", $params, TRUE), - ); + ]; } /** @@ -65,9 +65,9 @@ public static function internal($rg) { email1.email=email2.email WHERE contact1.contact_type = 'Individual'"); - return array( + return [ "civicrm_contact.{$rg->name}.{$rg->threshold}" => $query, - ); + ]; } } diff --git a/CRM/Dedupe/BAO/QueryBuilder/IndividualUnsupervised.php b/CRM/Dedupe/BAO/QueryBuilder/IndividualUnsupervised.php index d3d931d22642..1c2e9b23735c 100644 --- a/CRM/Dedupe/BAO/QueryBuilder/IndividualUnsupervised.php +++ b/CRM/Dedupe/BAO/QueryBuilder/IndividualUnsupervised.php @@ -36,20 +36,20 @@ class CRM_Dedupe_BAO_QueryBuilder_IndividualUnsupervised extends CRM_Dedupe_BAO_ * @return array */ public static function record($rg) { - $civicrm_email = CRM_Utils_Array::value('civicrm_email', $rg->params, array()); + $civicrm_email = CRM_Utils_Array::value('civicrm_email', $rg->params, []); - $params = array( - 1 => array(CRM_Utils_Array::value('email', $civicrm_email, ''), 'String'), - ); + $params = [ + 1 => [CRM_Utils_Array::value('email', $civicrm_email, ''), 'String'], + ]; - return array( + return [ "civicrm_contact.{$rg->name}.{$rg->threshold}" => CRM_Core_DAO::composeQuery(" SELECT contact.id as id1, {$rg->threshold} as weight FROM civicrm_contact as contact JOIN civicrm_email as email ON email.contact_id=contact.id WHERE contact_type = 'Individual' AND email = %1", $params, TRUE), - ); + ]; } /** @@ -68,7 +68,7 @@ public static function internal($rg) { email1.email=email2.email WHERE contact1.contact_type = 'Individual' AND " . self::internalFilters($rg); - return array("civicrm_contact.{$rg->name}.{$rg->threshold}" => $query); + return ["civicrm_contact.{$rg->name}.{$rg->threshold}" => $query]; } /** @@ -109,7 +109,7 @@ public static function internalOptimized($rg) { AND contact2.contact_type='Individual' AND " . self::internalFilters($rg); - return array("civicrm_contact.{$rg->name}.{$rg->threshold}" => $query); + return ["civicrm_contact.{$rg->name}.{$rg->threshold}" => $query]; } } diff --git a/CRM/Dedupe/BAO/Rule.php b/CRM/Dedupe/BAO/Rule.php index 40c6a7444805..67ce966cb663 100644 --- a/CRM/Dedupe/BAO/Rule.php +++ b/CRM/Dedupe/BAO/Rule.php @@ -42,12 +42,12 @@ class CRM_Dedupe_BAO_Rule extends CRM_Dedupe_DAO_Rule { /** * Ids of the contacts to limit the SQL queries (whole-database queries otherwise) */ - var $contactIds = array(); + var $contactIds = []; /** * Params to dedupe against (queries against the whole contact set otherwise) */ - var $params = array(); + var $params = []; /** * Return the SQL query for the given rule - either for finding matching @@ -70,8 +70,8 @@ public function sql() { // extend them; $where is an array of required conditions, $on and // $using are arrays of required field matchings (for substring and // full matches, respectively) - $where = array(); - $on = array("SUBSTR(t1.{$this->rule_field}, 1, {$this->rule_length}) = SUBSTR(t2.{$this->rule_field}, 1, {$this->rule_length})"); + $where = []; + $on = ["SUBSTR(t1.{$this->rule_field}, 1, {$this->rule_length}) = SUBSTR(t2.{$this->rule_field}, 1, {$this->rule_length})"]; $entity = CRM_Core_DAO_AllCoreTables::getBriefName(CRM_Core_DAO_AllCoreTables::getClassForTable($this->rule_table)); $fields = civicrm_api3($entity, 'getfields', ['action' => 'create'])['values']; @@ -187,7 +187,7 @@ public function sql() { } $query = "SELECT $select FROM $from WHERE " . implode(' AND ', $where); if ($this->contactIds) { - $cids = array(); + $cids = []; foreach ($this->contactIds as $cid) { $cids[] = CRM_Utils_Type::escape($cid, 'Integer'); } @@ -223,7 +223,7 @@ public static function dedupeRuleFields($params) { $ruleBao = new CRM_Dedupe_BAO_Rule(); $ruleBao->dedupe_rule_group_id = $rgBao->id; $ruleBao->find(); - $ruleFields = array(); + $ruleFields = []; while ($ruleBao->fetch()) { $ruleFields[] = $ruleBao->rule_field; } diff --git a/CRM/Dedupe/BAO/RuleGroup.php b/CRM/Dedupe/BAO/RuleGroup.php index 2c01c60e133d..f1bfd1478bef 100644 --- a/CRM/Dedupe/BAO/RuleGroup.php +++ b/CRM/Dedupe/BAO/RuleGroup.php @@ -42,7 +42,7 @@ class CRM_Dedupe_BAO_RuleGroup extends CRM_Dedupe_DAO_RuleGroup { /** * Ids of the contacts to limit the SQL queries (whole-database queries otherwise) */ - var $contactIds = array(); + var $contactIds = []; /** * Set the contact IDs to restrict the dedupe to. @@ -56,7 +56,7 @@ public function setContactIds($contactIds) { /** * Params to dedupe against (queries against the whole contact set otherwise) */ - var $params = array(); + var $params = []; /** * If there are no rules in rule group. @@ -78,7 +78,7 @@ public static function supportedFields($requestedType) { static $fields = NULL; if (!$fields) { // this is needed, as we're piggy-backing importableFields() below - $replacements = array( + $replacements = [ 'civicrm_country.name' => 'civicrm_address.country_id', 'civicrm_county.name' => 'civicrm_address.county_id', 'civicrm_state_province.name' => 'civicrm_address.state_province_id', @@ -89,9 +89,9 @@ public static function supportedFields($requestedType) { 'email_greeting.label' => 'civicrm_contact.email_greeting_id', 'postal_greeting.label' => 'civicrm_contact.postal_greeting_id', 'civicrm_phone.phone' => 'civicrm_phone.phone_numeric', - ); + ]; // the table names we support in dedupe rules - a filter for importableFields() - $supportedTables = array( + $supportedTables = [ 'civicrm_address', 'civicrm_contact', 'civicrm_email', @@ -99,9 +99,9 @@ public static function supportedFields($requestedType) { 'civicrm_note', 'civicrm_openid', 'civicrm_phone', - ); + ]; - foreach (array('Individual', 'Organization', 'Household') as $ctype) { + foreach (['Individual', 'Organization', 'Household'] as $ctype) { // take the table.field pairs and their titles from importableFields() if the table is supported foreach (CRM_Contact_BAO_Contact::importableFields($ctype) as $iField) { if (isset($iField['where'])) { @@ -161,7 +161,7 @@ public function tableQuery() { CRM_Utils_File::isIncludable("CRM/Dedupe/BAO/QueryBuilder/{$this->name}.php") ) { $command = empty($this->params) ? 'internal' : 'record'; - $queries = call_user_func(array("CRM_Dedupe_BAO_QueryBuilder_{$this->name}", $command), $this); + $queries = call_user_func(["CRM_Dedupe_BAO_QueryBuilder_{$this->name}", $command], $this); } else { // All other rule groups have queries generated by the member dedupe @@ -176,7 +176,7 @@ public function tableQuery() { // Generate a SQL query for each rule in the rule group that is // tailored to respect the param and contactId options provided. - $queries = array(); + $queries = []; while ($bao->fetch()) { $bao->contactIds = $this->contactIds; $bao->params = $this->params; @@ -192,7 +192,7 @@ public function tableQuery() { // add an empty query fulfilling the pattern if (!$queries) { $this->noRules = TRUE; - return array(); + return []; } return $queries; @@ -219,7 +219,7 @@ public function fillTable() { $dupeCopyJoin = " JOIN dedupe_copy ON dedupe_copy.id1 = t1.column AND dedupe_copy.id2 = t2.column WHERE "; } $patternColumn = '/t1.(\w+)/'; - $exclWeightSum = array(); + $exclWeightSum = []; $dao = new CRM_Core_DAO(); CRM_Utils_Hook::dupeQuery($this, 'table', $tableQueries); @@ -275,7 +275,7 @@ public function fillTable() { // In an inclusive situation, failure of any query means no further processing - if ($affectedRows == 0) { // reset to make sure no further execution is done. - $tableQueries = array(); + $tableQueries = []; break; } $weightSum = substr($fieldWeight, strrpos($fieldWeight, '.') + 1) + $weightSum; @@ -309,8 +309,8 @@ public function fillTable() { * * @return array */ - public static function isQuerySetInclusive($tableQueries, $threshold, $exclWeightSum = array()) { - $input = array(); + public static function isQuerySetInclusive($tableQueries, $threshold, $exclWeightSum = []) { + $input = []; foreach ($tableQueries as $key => $query) { $input[] = substr($key, strrpos($key, '.') + 1); } @@ -321,12 +321,12 @@ public static function isQuerySetInclusive($tableQueries, $threshold, $exclWeigh } if (count($input) == 1) { - return array(FALSE, $input[0] < $threshold); + return [FALSE, $input[0] < $threshold]; } $totalCombinations = 0; for ($i = 0; $i < count($input); $i++) { - $combination = array($input[$i]); + $combination = [$input[$i]]; if (array_sum($combination) >= $threshold) { $totalCombinations++; continue; @@ -338,7 +338,7 @@ public static function isQuerySetInclusive($tableQueries, $threshold, $exclWeigh } } } - return array($totalCombinations == 1, $totalCombinations <= 0); + return [$totalCombinations == 1, $totalCombinations <= 0]; } /** @@ -346,9 +346,9 @@ public static function isQuerySetInclusive($tableQueries, $threshold, $exclWeigh * @param $tableQueries */ public static function orderByTableCount(&$tableQueries) { - static $tableCount = array(); + static $tableCount = []; - $tempArray = array(); + $tempArray = []; foreach ($tableQueries as $key => $query) { $table = explode(".", $key); $table = $table[0]; @@ -396,7 +396,7 @@ public function thresholdQuery($checkPermission = TRUE) { else { $this->_aclWhere = ' AND c1.is_deleted = 0 AND c2.is_deleted = 0'; if ($checkPermission) { - list($this->_aclFrom, $this->_aclWhere) = CRM_Contact_BAO_Contact_Permission::cacheClause(array('c1', 'c2')); + list($this->_aclFrom, $this->_aclWhere) = CRM_Contact_BAO_Contact_Permission::cacheClause(['c1', 'c2']); $this->_aclWhere = $this->_aclWhere ? "AND {$this->_aclWhere}" : ''; } $query = "SELECT IF({$this->temporaryTables['dedupe']}.id1 < {$this->temporaryTables['dedupe']}.id2, {$this->temporaryTables['dedupe']}.id1, {$this->temporaryTables['dedupe']}.id2) as id1, @@ -436,12 +436,12 @@ public static function dedupeRuleFieldsWeight($params) { $ruleBao = new CRM_Dedupe_BAO_Rule(); $ruleBao->dedupe_rule_group_id = $rgBao->id; $ruleBao->find(); - $ruleFields = array(); + $ruleFields = []; while ($ruleBao->fetch()) { $ruleFields[$ruleBao->rule_field] = $ruleBao->rule_weight; } - return array($ruleFields, $rgBao->threshold); + return [$ruleFields, $rgBao->threshold]; } /** @@ -452,7 +452,7 @@ public static function dedupeRuleFieldsWeight($params) { * @param array $combos * @param array $running */ - public static function combos($rgFields, $threshold, &$combos, $running = array()) { + public static function combos($rgFields, $threshold, &$combos, $running = []) { foreach ($rgFields as $rgField => $weight) { unset($rgFields[$rgField]); $diff = $threshold - $weight; @@ -487,7 +487,7 @@ public static function getByType($contactType = NULL) { } $dao->find(); - $result = array(); + $result = []; while ($dao->fetch()) { $title = !empty($dao->title) ? $dao->title : (!empty($dao->name) ? $dao->name : $dao->contact_type); @@ -507,7 +507,7 @@ public static function getByType($contactType = NULL) { */ public static function getContactTypeForRuleGroup($rule_group_id) { if (!isset(\Civi::$statics[__CLASS__]) || !isset(\Civi::$statics[__CLASS__]['rule_groups'])) { - \Civi::$statics[__CLASS__]['rule_groups'] = array(); + \Civi::$statics[__CLASS__]['rule_groups'] = []; } if (empty(\Civi::$statics[__CLASS__]['rule_groups'][$rule_group_id])) { \Civi::$statics[__CLASS__]['rule_groups'][$rule_group_id]['contact_type'] = CRM_Core_DAO::getFieldValue( diff --git a/CRM/Dedupe/Finder.php b/CRM/Dedupe/Finder.php index ef50af8ed03b..4926760db0ea 100644 --- a/CRM/Dedupe/Finder.php +++ b/CRM/Dedupe/Finder.php @@ -62,7 +62,7 @@ class CRM_Dedupe_Finder { * @throws CiviCRM_API3_Exception * @throws Exception */ - public static function dupes($rgid, $cids = array(), $checkPermissions = TRUE, $searchLimit = 0) { + public static function dupes($rgid, $cids = [], $checkPermissions = TRUE, $searchLimit = 0) { $rgBao = new CRM_Dedupe_BAO_RuleGroup(); $rgBao->id = $rgid; $rgBao->contactIds = $cids; @@ -70,20 +70,20 @@ public static function dupes($rgid, $cids = array(), $checkPermissions = TRUE, $ CRM_Core_Error::fatal("Dedupe rule not found for selected contacts"); } if (empty($rgBao->contactIds) && !empty($searchLimit)) { - $limitedContacts = civicrm_api3('Contact', 'get', array( + $limitedContacts = civicrm_api3('Contact', 'get', [ 'return' => 'id', 'contact_type' => $rgBao->contact_type, - 'options' => array('limit' => $searchLimit), - )); + 'options' => ['limit' => $searchLimit], + ]); $rgBao->contactIds = array_keys($limitedContacts['values']); } $rgBao->fillTable(); $dao = new CRM_Core_DAO(); $dao->query($rgBao->thresholdQuery($checkPermissions)); - $dupes = array(); + $dupes = []; while ($dao->fetch()) { - $dupes[] = array($dao->id1, $dao->id2, $dao->weight); + $dupes[] = [$dao->id1, $dao->id2, $dao->weight]; } $dao->query($rgBao->tableDropQuery()); @@ -118,12 +118,12 @@ public static function dupesByParams( $params, $ctype, $used = 'Unsupervised', - $except = array(), + $except = [], $ruleGroupID = NULL ) { // If $params is empty there is zero reason to proceed. if (!$params) { - return array(); + return []; } $checkPermission = CRM_Utils_Array::value('check_permission', $params, TRUE); // This may no longer be required - see https://github.com/civicrm/civicrm-core/pull/13176 @@ -156,7 +156,7 @@ public static function dupesByParams( $rgBao->fillTable(); $dao = new CRM_Core_DAO(); $dao->query($rgBao->thresholdQuery($checkPermission)); - $dupes = array(); + $dupes = []; while ($dao->fetch()) { if (isset($dao->id) && $dao->id) { $dupes[] = $dao->id; @@ -187,7 +187,7 @@ public static function dupesInGroup($rgid, $gid, $searchLimit = 0) { if (!empty($cids)) { return self::dupes($rgid, $cids); } - return array(); + return []; } /** @@ -203,16 +203,16 @@ public static function dupesInGroup($rgid, $gid, $searchLimit = 0) { * valid $params array for dedupe */ public static function formatParams($fields, $ctype) { - $flat = array(); + $flat = []; CRM_Utils_Array::flatten($fields, $flat); // FIXME: This may no longer be necessary - check inputs - $replace_these = array( + $replace_these = [ 'individual_prefix' => 'prefix_id', 'individual_suffix' => 'suffix_id', 'gender' => 'gender_id', - ); - foreach (array('individual_suffix', 'individual_prefix', 'gender') as $name) { + ]; + foreach (['individual_suffix', 'individual_prefix', 'gender'] as $name) { if (!empty($fields[$name])) { $flat[$replace_these[$name]] = $flat[$name]; unset($flat[$name]); @@ -220,10 +220,10 @@ public static function formatParams($fields, $ctype) { } // handle {birth,deceased}_date - foreach (array( + foreach ([ 'birth_date', 'deceased_date', - ) as $date) { + ] as $date) { if (!empty($fields[$date])) { $flat[$date] = $fields[$date]; if (is_array($flat[$date])) { @@ -240,7 +240,7 @@ public static function formatParams($fields, $ctype) { // handle preferred_communication_method if (!empty($fields['preferred_communication_method'])) { - $methods = array_intersect($fields['preferred_communication_method'], array('1')); + $methods = array_intersect($fields['preferred_communication_method'], ['1']); $methods = array_keys($methods); sort($methods); if ($methods) { @@ -277,7 +277,7 @@ public static function formatParams($fields, $ctype) { // FIXME: CRM-5026 should be fixed here; the below clobbers all address info; we should split off address fields and match // the -digit to civicrm_address.location_type_id and -Primary to civicrm_address.is_primary foreach ($flat as $key => $value) { - $matches = array(); + $matches = []; if (preg_match('/(.*)-(Primary-[\d+])$|(.*)-(\d+|Primary)$/', $key, $matches)) { $return = array_values(array_filter($matches)); $flat[$return[1]] = $value; @@ -285,7 +285,7 @@ public static function formatParams($fields, $ctype) { } } - $params = array(); + $params = []; $supportedFields = CRM_Dedupe_BAO_RuleGroup::supportedFields($ctype); if (is_array($supportedFields)) { foreach ($supportedFields as $table => $fields) { @@ -293,12 +293,12 @@ public static function formatParams($fields, $ctype) { // for matching on civicrm_address fields, we also need the location_type_id $fields['location_type_id'] = ''; // FIXME: we also need to do some hacking for id and name fields, see CRM-3902’s comments - $fixes = array( + $fixes = [ 'address_name' => 'name', 'country' => 'country_id', 'state_province' => 'state_province_id', 'county' => 'county_id', - ); + ]; foreach ($fixes as $orig => $target) { if (!empty($flat[$orig])) { $params[$table][$target] = $flat[$orig]; @@ -306,9 +306,9 @@ public static function formatParams($fields, $ctype) { } } if ($table == 'civicrm_phone') { - $fixes = array( + $fixes = [ 'phone' => 'phone_numeric', - ); + ]; foreach ($fixes as $orig => $target) { if (!empty($flat[$orig])) { $params[$table][$target] = $flat[$orig]; @@ -343,7 +343,7 @@ public static function formatParams($fields, $ctype) { * @throws CRM_Core_Exception */ public static function parseAndStoreDupePairs($foundDupes, $cacheKeyString) { - $cids = array(); + $cids = []; foreach ($foundDupes as $dupe) { $cids[$dupe[0]] = 1; $cids[$dupe[1]] = 1; @@ -351,7 +351,7 @@ public static function parseAndStoreDupePairs($foundDupes, $cacheKeyString) { $cidString = implode(', ', array_keys($cids)); $dao = CRM_Core_DAO::executeQuery("SELECT id, display_name FROM civicrm_contact WHERE id IN ($cidString) ORDER BY sort_name"); - $displayNames = array(); + $displayNames = []; while ($dao->fetch()) { $displayNames[$dao->id] = $dao->display_name; } @@ -366,14 +366,14 @@ public static function parseAndStoreDupePairs($foundDupes, $cacheKeyString) { $dstID = $userId; } - $mainContacts[] = $row = array( + $mainContacts[] = $row = [ 'dstID' => $dstID, 'dstName' => $displayNames[$dstID], 'srcID' => $srcID, 'srcName' => $displayNames[$srcID], 'weight' => $dupes[2], 'canMerge' => TRUE, - ); + ]; $data = CRM_Core_DAO::escapeString(serialize($row)); $values[] = " ( 'civicrm_contact', $dstID, $srcID, '$cacheKeyString', '$data' ) "; diff --git a/CRM/Event/ActionMapping.php b/CRM/Event/ActionMapping.php index 629e17438d18..3d34696b8562 100644 --- a/CRM/Event/ActionMapping.php +++ b/CRM/Event/ActionMapping.php @@ -53,7 +53,7 @@ class CRM_Event_ActionMapping extends \Civi\ActionSchedule\Mapping { * @param \Civi\ActionSchedule\Event\MappingRegisterEvent $registrations */ public static function onRegisterActionMappings(\Civi\ActionSchedule\Event\MappingRegisterEvent $registrations) { - $registrations->register(CRM_Event_ActionMapping::create(array( + $registrations->register(CRM_Event_ActionMapping::create([ 'id' => CRM_Event_ActionMapping::EVENT_TYPE_MAPPING_ID, 'entity' => 'civicrm_participant', 'entity_label' => ts('Event Type'), @@ -61,8 +61,8 @@ public static function onRegisterActionMappings(\Civi\ActionSchedule\Event\Mappi 'entity_value_label' => ts('Event Type'), 'entity_status' => 'civicrm_participant_status_type', 'entity_status_label' => ts('Participant Status'), - ))); - $registrations->register(CRM_Event_ActionMapping::create(array( + ])); + $registrations->register(CRM_Event_ActionMapping::create([ 'id' => CRM_Event_ActionMapping::EVENT_NAME_MAPPING_ID, 'entity' => 'civicrm_participant', 'entity_label' => ts('Event Name'), @@ -70,8 +70,8 @@ public static function onRegisterActionMappings(\Civi\ActionSchedule\Event\Mappi 'entity_value_label' => ts('Event Name'), 'entity_status' => 'civicrm_participant_status_type', 'entity_status_label' => ts('Participant Status'), - ))); - $registrations->register(CRM_Event_ActionMapping::create(array( + ])); + $registrations->register(CRM_Event_ActionMapping::create([ 'id' => CRM_Event_ActionMapping::EVENT_TPL_MAPPING_ID, 'entity' => 'civicrm_participant', 'entity_label' => ts('Event Template'), @@ -79,7 +79,7 @@ public static function onRegisterActionMappings(\Civi\ActionSchedule\Event\Mappi 'entity_value_label' => ts('Event Template'), 'entity_status' => 'civicrm_participant_status_type', 'entity_status_label' => ts('Participant Status'), - ))); + ])); } /** @@ -89,12 +89,12 @@ public static function onRegisterActionMappings(\Civi\ActionSchedule\Event\Mappi * Array(string $fieldName => string $fieldLabel). */ public function getDateFields() { - return array( + return [ 'start_date' => ts('Event Start Date'), 'end_date' => ts('Event End Date'), 'registration_start_date' => ts('Registration Start Date'), 'registration_end_date' => ts('Registration End Date'), - ); + ]; } /** @@ -130,7 +130,7 @@ public function getRecipientListing($recipientType) { return \CRM_Event_PseudoConstant::participantRole(); default: - return array(); + return []; } } diff --git a/CRM/Event/BAO/Event.php b/CRM/Event/BAO/Event.php index 755847c056ad..5a18b77c775a 100644 --- a/CRM/Event/BAO/Event.php +++ b/CRM/Event/BAO/Event.php @@ -148,12 +148,12 @@ public static function create(&$params) { } // Log the information on successful add/edit of Event - $logParams = array( + $logParams = [ 'entity_table' => 'civicrm_event', 'entity_id' => $event->id, 'modified_id' => $contactId, 'modified_date' => date('Ymd'), - ); + ]; CRM_Core_BAO_Log::add($logParams); @@ -183,28 +183,28 @@ public static function del($id) { CRM_Utils_Hook::pre('delete', 'Event', $id, CRM_Core_DAO::$_nullArray); - $extends = array('event'); + $extends = ['event']; $groupTree = CRM_Core_BAO_CustomGroup::getGroupDetail(NULL, NULL, $extends); foreach ($groupTree as $values) { $query = "DELETE FROM %1 WHERE entity_id = %2"; - CRM_Core_DAO::executeQuery($query, array( - 1 => array($values['table_name'], 'String', CRM_Core_DAO::QUERY_FORMAT_NO_QUOTES), - 2 => array($id, 'Integer'), - )); + CRM_Core_DAO::executeQuery($query, [ + 1 => [$values['table_name'], 'String', CRM_Core_DAO::QUERY_FORMAT_NO_QUOTES], + 2 => [$id, 'Integer'], + ]); } // Clean up references to profiles used by the event (CRM-20935) - $ufJoinParams = array( + $ufJoinParams = [ 'module' => 'CiviEvent', 'entity_table' => 'civicrm_event', 'entity_id' => $id, - ); + ]; CRM_Core_BAO_UFJoin::deleteAll($ufJoinParams); - $ufJoinParams = array( + $ufJoinParams = [ 'module' => 'CiviEvent_Additional', 'entity_table' => 'civicrm_event', 'entity_id' => $id, - ); + ]; CRM_Core_BAO_UFJoin::deleteAll($ufJoinParams); // price set cleanup, CRM-5527 @@ -306,7 +306,7 @@ public static function getEvents( } $query .= " ORDER BY title asc"; - $events = array(); + $events = []; $dao = CRM_Core_DAO::executeQuery($query); while ($dao->fetch()) { @@ -332,7 +332,7 @@ public static function getEvents( * Array of event summary values */ public static function getEventSummary() { - $eventSummary = $eventIds = array(); + $eventSummary = $eventIds = []; $config = CRM_Core_Config::singleton(); // get permission and include them here @@ -374,7 +374,7 @@ public static function getEventSummary() { $cpst = $cpstObject->getTableName(); $query = "SELECT id, name, label, class FROM $cpst"; $status = CRM_Core_DAO::executeQuery($query); - $statusValues = array(); + $statusValues = []; while ($status->fetch()) { $statusValues[$status->id]['id'] = $status->id; $statusValues[$status->id]['name'] = $status->name; @@ -421,9 +421,9 @@ public static function getEventSummary() { ORDER BY civicrm_event.start_date ASC $event_summary_limit "; - $eventParticipant = array(); + $eventParticipant = []; - $properties = array( + $properties = [ 'id' => 'id', 'eventTitle' => 'event_title', 'isPublic' => 'is_public', @@ -436,12 +436,12 @@ public static function getEventSummary() { 'notCountedDueToRole' => 'notCountedDueToRole', 'notCountedDueToStatus' => 'notCountedDueToStatus', 'notCountedParticipants' => 'notCountedParticipants', - ); + ]; - $params = array(1 => array($optionGroupId, 'Integer')); - $mapping = CRM_Utils_Array::first(CRM_Core_BAO_ActionSchedule::getMappings(array( + $params = [1 => [$optionGroupId, 'Integer']]; + $mapping = CRM_Utils_Array::first(CRM_Core_BAO_ActionSchedule::getMappings([ 'id' => CRM_Event_ActionMapping::EVENT_NAME_MAPPING_ID, - ))); + ])); $dao = CRM_Core_DAO::executeQuery($query, $params); while ($dao->fetch()) { foreach ($properties as $property => $name) { @@ -459,9 +459,9 @@ public static function getEventSummary() { case 'is_map': if ($dao->$name && $config->mapAPIKey) { - $values = array(); - $ids = array(); - $params = array('entity_id' => $dao->id, 'entity_table' => 'civicrm_event'); + $values = []; + $ids = []; + $params = ['entity_id' => $dao->id, 'entity_table' => 'civicrm_event']; $values['location'] = CRM_Core_BAO_Location::getValues($params, TRUE); if (is_numeric(CRM_Utils_Array::value('geo_code_1', $values['location']['address'][1])) || ( @@ -483,7 +483,7 @@ public static function getEventSummary() { case 'end_date': case 'start_date': $eventSummary['events'][$dao->id][$property] = CRM_Utils_Date::customFormat($dao->$name, - NULL, array('d') + NULL, ['d'] ); break; @@ -537,8 +537,8 @@ public static function getEventSummary() { } // prepare the area for per-status participant counts - $statusClasses = array('Positive', 'Pending', 'Waiting', 'Negative'); - $eventSummary['events'][$dao->id]['statuses'] = array_fill_keys($statusClasses, array()); + $statusClasses = ['Positive', 'Pending', 'Waiting', 'Negative']; + $eventSummary['events'][$dao->id]['statuses'] = array_fill_keys($statusClasses, []); $eventSummary['events'][$dao->id]['friend'] = $dao->is_friend_active; $eventSummary['events'][$dao->id]['is_monetary'] = $dao->is_monetary; @@ -558,12 +558,12 @@ public static function getEventSummary() { $statusCount = self::eventTotalSeats($dao->id, "( participant.status_id = {$statusId} )"); if ($statusCount) { $urlString = "reset=1&force=1&event={$dao->id}&status=$statusId"; - $statusInfo = array( + $statusInfo = [ 'url' => CRM_Utils_System::url('civicrm/event/search', $urlString), 'name' => $statusValue['name'], 'label' => $statusValue['label'], 'count' => $statusCount, - ); + ]; $eventSummary['events'][$dao->id]['statuses'][$class][] = $statusInfo; } } @@ -615,7 +615,7 @@ public static function getParticipantCount( if ($considerStatus && $considerRole && !$status && !$role) { $operator = " OR "; } - $clause = array(); + $clause = []; if ($considerStatus) { $statusTypes = CRM_Event_PseudoConstant::participantStatus(NULL, 'is_counted = 1'); $statusClause = 'NOT IN'; @@ -637,7 +637,7 @@ public static function getParticipantCount( } if (!empty($roleTypes)) { - $escapedRoles = array(); + $escapedRoles = []; foreach (array_keys($roleTypes) as $roleType) { $escapedRoles[] = CRM_Utils_Type::escape($roleType, 'String'); } @@ -692,24 +692,24 @@ public static function &getMapInfo(&$id) { $dao = new CRM_Core_DAO(); $dao->query($sql); - $locations = array(); + $locations = []; $config = CRM_Core_Config::singleton(); while ($dao->fetch()) { - $location = array(); + $location = []; $location['displayName'] = addslashes($dao->display_name); $location['lat'] = $dao->latitude; $location['marker_class'] = 'Event'; $location['lng'] = $dao->longitude; - $params = array('entity_id' => $id, 'entity_table' => 'civicrm_event'); + $params = ['entity_id' => $id, 'entity_table' => 'civicrm_event']; $addressValues = CRM_Core_BAO_Location::getValues($params, TRUE); - $location['address'] = str_replace(array( + $location['address'] = str_replace([ "\r", "\n", - ), '', addslashes(nl2br($addressValues['address'][1]['display_text']))); + ], '', addslashes(nl2br($addressValues['address'][1]['display_text']))); $location['url'] = CRM_Utils_System::url('civicrm/event/register', 'reset=1&id=' . $dao->event_id); $location['location_type'] = $dao->location_type; @@ -834,9 +834,9 @@ public static function &getCompleteInfo( } $query .= " ORDER BY civicrm_event.start_date ASC"; - $params = array(1 => array($optionGroupId, 'Integer')); + $params = [1 => [$optionGroupId, 'Integer']]; $dao = CRM_Core_DAO::executeQuery($query, $params); - $all = array(); + $all = []; $config = CRM_Core_Config::singleton(); $baseURL = parse_url($config->userFrameworkBaseURL); @@ -860,7 +860,7 @@ public static function &getCompleteInfo( } while ($dao->fetch()) { if (!empty($permissions) && in_array($dao->event_id, $permissions)) { - $info = array(); + $info = []; $info['uid'] = "CiviCRM_EventID_{$dao->event_id}_" . md5($config->userFrameworkBaseURL) . $url; $info['title'] = $dao->title; @@ -879,7 +879,7 @@ public static function &getCompleteInfo( $address = ''; - $addrFields = array( + $addrFields = [ 'address_name' => $dao->address_name, 'street_address' => $dao->street_address, 'supplemental_address_1' => $dao->supplemental_address_1, @@ -891,7 +891,7 @@ public static function &getCompleteInfo( 'postal_code_suffix' => $dao->postal_code_suffix, 'country' => $dao->country, 'county' => NULL, - ); + ]; CRM_Utils_String::append($address, ', ', CRM_Utils_Address::format($addrFields) @@ -925,66 +925,66 @@ public static function &getCompleteInfo( * @throws \CRM_Core_Exception */ public static function copy($id, $params = []) { - $eventValues = array(); + $eventValues = []; //get the require event values. - $eventParams = array('id' => $id); - $returnProperties = array( + $eventParams = ['id' => $id]; + $returnProperties = [ 'loc_block_id', 'is_show_location', 'default_fee_id', 'default_discount_fee_id', 'is_template', - ); + ]; CRM_Core_DAO::commonRetrieve('CRM_Event_DAO_Event', $eventParams, $eventValues, $returnProperties); - $fieldsFix = array('prefix' => array('title' => ts('Copy of') . ' ')); + $fieldsFix = ['prefix' => ['title' => ts('Copy of') . ' ']]; if (empty($eventValues['is_show_location'])) { $fieldsFix['prefix']['is_show_location'] = 0; } $copyEvent = CRM_Core_DAO::copyGeneric('CRM_Event_DAO_Event', - array('id' => $id), + ['id' => $id], // since the location is sharable, lets use the same loc_block_id. - array('loc_block_id' => CRM_Utils_Array::value('loc_block_id', $eventValues)) + $params, + ['loc_block_id' => CRM_Utils_Array::value('loc_block_id', $eventValues)] + $params, $fieldsFix ); CRM_Price_BAO_PriceSet::copyPriceSet('civicrm_event', $id, $copyEvent->id); CRM_Core_DAO::copyGeneric('CRM_Core_DAO_UFJoin', - array( + [ 'entity_id' => $id, 'entity_table' => 'civicrm_event', - ), - array('entity_id' => $copyEvent->id) + ], + ['entity_id' => $copyEvent->id] ); CRM_Core_DAO::copyGeneric('CRM_Friend_DAO_Friend', - array( + [ 'entity_id' => $id, 'entity_table' => 'civicrm_event', - ), - array('entity_id' => $copyEvent->id) + ], + ['entity_id' => $copyEvent->id] ); CRM_Core_DAO::copyGeneric('CRM_PCP_DAO_PCPBlock', - array( + [ 'entity_id' => $id, 'entity_table' => 'civicrm_event', - ), - array('entity_id' => $copyEvent->id), - array('replace' => array('target_entity_id' => $copyEvent->id)) + ], + ['entity_id' => $copyEvent->id], + ['replace' => ['target_entity_id' => $copyEvent->id]] ); - $oldMapping = CRM_Utils_Array::first(CRM_Core_BAO_ActionSchedule::getMappings(array( + $oldMapping = CRM_Utils_Array::first(CRM_Core_BAO_ActionSchedule::getMappings([ 'id' => ($eventValues['is_template'] ? CRM_Event_ActionMapping::EVENT_TPL_MAPPING_ID : CRM_Event_ActionMapping::EVENT_NAME_MAPPING_ID), - ))); - $copyMapping = CRM_Utils_Array::first(CRM_Core_BAO_ActionSchedule::getMappings(array( + ])); + $copyMapping = CRM_Utils_Array::first(CRM_Core_BAO_ActionSchedule::getMappings([ 'id' => ($copyEvent->is_template == 1 ? CRM_Event_ActionMapping::EVENT_TPL_MAPPING_ID : CRM_Event_ActionMapping::EVENT_NAME_MAPPING_ID), - ))); + ])); CRM_Core_DAO::copyGeneric('CRM_Core_DAO_ActionSchedule', - array('entity_value' => $id, 'mapping_id' => $oldMapping->getId()), - array('entity_value' => $copyEvent->id, 'mapping_id' => $copyMapping->getId()) + ['entity_value' => $id, 'mapping_id' => $oldMapping->getId()], + ['entity_value' => $copyEvent->id, 'mapping_id' => $copyMapping->getId()] ); self::copyCustomFields($id, $copyEvent->id); @@ -1006,7 +1006,7 @@ public static function copy($id, $params = []) { */ public static function copyCustomFields($oldEventID, $newCopyID) { // Obtain custom values for old event - $customParams = $htmlType = array(); + $customParams = $htmlType = []; $customValues = CRM_Core_BAO_CustomValueTable::getEntityValues($oldEventID, 'Event'); // If custom values present, we copy them @@ -1027,10 +1027,10 @@ public static function copyCustomFields($oldEventID, $newCopyID) { // Handle File type attributes if (in_array($field, $htmlType)) { $fileValues = CRM_Core_BAO_File::path($value, $oldEventID); - $customParams["custom_{$field}_-1"] = array( + $customParams["custom_{$field}_-1"] = [ 'name' => CRM_Utils_File::duplicate($fileValues[0]), 'type' => $fileValues[1], - ); + ]; } // Handle other types else { @@ -1057,7 +1057,7 @@ public static function copyCustomFields($oldEventID, $newCopyID) { * @return bool */ public static function isMonetary($id) { - static $isMonetary = array(); + static $isMonetary = []; if (!array_key_exists($id, $isMonetary)) { $isMonetary[$id] = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $id, @@ -1077,7 +1077,7 @@ public static function isMonetary($id) { * @return bool */ public static function usesPriceSet($id) { - static $usesPriceSet = array(); + static $usesPriceSet = []; if (!array_key_exists($id, $usesPriceSet)) { $usesPriceSet[$id] = CRM_Price_BAO_PriceSet::getFor('civicrm_event', $id); } @@ -1097,20 +1097,20 @@ public static function usesPriceSet($id) { public static function sendMail($contactID, &$values, $participantId, $isTest = FALSE, $returnMessageText = FALSE) { $template = CRM_Core_Smarty::singleton(); - $gIds = array( + $gIds = [ 'custom_pre_id' => $values['custom_pre_id'], 'custom_post_id' => $values['custom_post_id'], - ); + ]; //get the params submitted by participant. - $participantParams = CRM_Utils_Array::value($participantId, $values['params'], array()); + $participantParams = CRM_Utils_Array::value($participantId, $values['params'], []); if (!$returnMessageText) { //send notification email if field values are set (CRM-1941) foreach ($gIds as $key => $gIdValues) { if ($gIdValues) { if (!is_array($gIdValues)) { - $gIdValues = array($gIdValues); + $gIdValues = [$gIdValues]; } foreach ($gIdValues as $gId) { @@ -1127,11 +1127,11 @@ public static function sendMail($contactID, &$values, $participantId, $isTest = $participantParams ); list($profileValues) = $profileValues; - $val = array( + $val = [ 'id' => $gId, 'values' => $profileValues, 'email' => $email, - ); + ]; CRM_Core_BAO_UFGroup::commonSendMail($contactID, $val); } } @@ -1174,7 +1174,7 @@ public static function sendMail($contactID, &$values, $participantId, $isTest = $sessions = CRM_Event_Cart_BAO_Conference::get_participant_sessions($participantId); - $tplParams = array_merge($values, $participantParams, array( + $tplParams = array_merge($values, $participantParams, [ 'email' => $email, 'confirm_email_text' => CRM_Utils_Array::value('confirm_email_text', $values['event']), 'isShowLocation' => CRM_Utils_Array::value('is_show_location', $values['event']), @@ -1189,7 +1189,7 @@ public static function sendMail($contactID, &$values, $participantId, $isTest = CRM_Utils_Date::mysqlToIso( CRM_Utils_Date::format( CRM_Utils_Array::value('credit_card_exp_date', $participantParams))), - )); + ]); // CRM-13890 : NOTE wait list condition need to be given so that // wait list message is shown properly in email i.e. WRT online event registration template @@ -1202,14 +1202,14 @@ public static function sendMail($contactID, &$values, $participantId, $isTest = $tplParams['participant_status'] = CRM_Event_PseudoConstant::participantStatus($tplParams['participant_status'], NULL, 'label'); } - $sendTemplateParams = array( + $sendTemplateParams = [ 'groupName' => 'msg_tpl_workflow_event', 'valueName' => 'event_online_receipt', 'contactId' => $contactID, 'isTest' => $isTest, 'tplParams' => $tplParams, 'PDFFilename' => ts('confirmation') . '.pdf', - ); + ]; // address required during receipt processing (pdf and email receipt) if ($displayAddress = CRM_Utils_Array::value('address', $values)) { @@ -1223,7 +1223,7 @@ public static function sendMail($contactID, &$values, $participantId, $isTest = // check if additional participant, if so filter only to relevant ones // CRM-9902 if (!empty($values['params']['additionalParticipant'])) { - $ownLineItems = array(); + $ownLineItems = []; foreach ($lineItem as $liKey => $liValue) { $firstElement = array_pop($liValue); if ($firstElement['entity_id'] == $participantId) { @@ -1242,12 +1242,12 @@ public static function sendMail($contactID, &$values, $participantId, $isTest = if ($returnMessageText) { list($sent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams); - return array( + return [ 'subject' => $subject, 'body' => $message, 'to' => $displayName, 'html' => $html, - ); + ]; } else { $sendTemplateParams['from'] = CRM_Utils_Array::value('confirm_from_name', $values['event']) . " <" . CRM_Utils_Array::value('confirm_from_email', $values['event']) . ">"; @@ -1297,15 +1297,15 @@ public static function buildCustomDisplay( $participantId, $isTest, $isCustomProfile = FALSE, - $participantParams = array() + $participantParams = [] ) { if (!$id) { - return array(NULL, NULL); + return [NULL, NULL]; } if (!is_array($id)) { $id = CRM_Utils_Type::escape($id, 'Positive'); - $profileIds = array($id); + $profileIds = [$id]; } else { $profileIds = $id; @@ -1314,7 +1314,7 @@ public static function buildCustomDisplay( $val = $groupTitles = NULL; foreach ($profileIds as $gid) { if (CRM_Core_BAO_UFGroup::filterUFGroups($gid, $cid)) { - $values = array(); + $values = []; $fields = CRM_Core_BAO_UFGroup::getFields($gid, FALSE, CRM_Core_Action::VIEW, NULL, NULL, FALSE, NULL, FALSE, NULL, CRM_Core_Permission::CREATE, @@ -1322,16 +1322,16 @@ public static function buildCustomDisplay( ); //this condition is added, since same contact can have multiple event registrations.. - $params = array(array('participant_id', '=', $participantId, 0, 0)); + $params = [['participant_id', '=', $participantId, 0, 0]]; //add participant id - $fields['participant_id'] = array( + $fields['participant_id'] = [ 'name' => 'participant_id', 'title' => ts('Participant ID'), - ); + ]; //check whether its a text drive if ($isTest) { - $params[] = array('participant_test', '=', 1, 0, 0); + $params[] = ['participant_test', '=', 1, 0, 0]; } //display campaign on thankyou page. @@ -1371,7 +1371,7 @@ public static function buildCustomDisplay( if (($groups = CRM_Utils_Array::value('group', $participantParams)) && is_array($groups) ) { - $grpIds = array(); + $grpIds = []; foreach ($groups as $grpId => $isSelected) { if ($isSelected) { $grpIds[] = $grpId; @@ -1379,7 +1379,7 @@ public static function buildCustomDisplay( } if (!empty($grpIds)) { //get the group titles. - $grpTitles = array(); + $grpTitles = []; $query = 'SELECT title FROM civicrm_group where id IN ( ' . implode(',', $grpIds) . ' )'; $grp = CRM_Core_DAO::executeQuery($query); while ($grp->fetch()) { @@ -1400,7 +1400,7 @@ public static function buildCustomDisplay( isset($values[$fields['participant_status_id']['title']]) && is_numeric($values[$fields['participant_status_id']['title']]) ) { - $status = array(); + $status = []; $status = CRM_Event_PseudoConstant::participantStatus(); $values[$fields['participant_status_id']['title']] = $status[$values[$fields['participant_status_id']['title']]]; } @@ -1409,7 +1409,7 @@ public static function buildCustomDisplay( isset($values[$fields['participant_role_id']['title']]) && is_numeric($values[$fields['participant_role_id']['title']]) ) { - $roles = array(); + $roles = []; $roles = CRM_Event_PseudoConstant::participantRole(); $values[$fields['participant_role_id']['title']] = $roles[$values[$fields['participant_role_id']['title']]]; } @@ -1452,7 +1452,7 @@ public static function buildCustomDisplay( //return if we only require array of participant's info. if ($isCustomProfile) { if (count($val)) { - return array($val, $groupTitles); + return [$val, $groupTitles]; } else { return NULL; @@ -1474,7 +1474,7 @@ public static function buildCustomDisplay( * * @param array $profileFields */ - public static function displayProfile(&$params, $gid, &$groupTitle, &$values, &$profileFields = array()) { + public static function displayProfile(&$params, $gid, &$groupTitle, &$values, &$profileFields = []) { if ($gid) { $config = CRM_Core_Config::singleton(); $session = CRM_Core_Session::singleton(); @@ -1538,21 +1538,21 @@ public static function displayProfile(&$params, $gid, &$groupTitle, &$values, &$ $values[$index] = ''; } } - elseif (in_array(substr($name, 0, -3), array('gender', 'prefix', 'suffix', 'communication_style'))) { + elseif (in_array(substr($name, 0, -3), ['gender', 'prefix', 'suffix', 'communication_style'])) { $values[$index] = CRM_Core_PseudoConstant::getLabel('CRM_Contact_DAO_Contact', $name, $params[$name]); } - elseif (in_array($name, array( + elseif (in_array($name, [ 'addressee', 'email_greeting', 'postal_greeting', - ))) { - $filterCondition = array('greeting_type' => $name); + ])) { + $filterCondition = ['greeting_type' => $name]; $greeting = CRM_Core_PseudoConstant::greeting($filterCondition); $values[$index] = $greeting[$params[$name]]; } elseif ($name === 'preferred_communication_method') { $communicationFields = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'preferred_communication_method'); - $compref = array(); + $compref = []; $pref = $params[$name]; if (is_array($pref)) { foreach ($pref as $k => $v) { @@ -1568,7 +1568,7 @@ public static function displayProfile(&$params, $gid, &$groupTitle, &$values, &$ } elseif ($name == 'group') { $groups = CRM_Contact_BAO_GroupContact::getGroupList(); - $title = array(); + $title = []; foreach ($params[$name] as $gId => $dontCare) { if ($dontCare) { $title[] = $groups[$gId]; @@ -1578,8 +1578,8 @@ public static function displayProfile(&$params, $gid, &$groupTitle, &$values, &$ } elseif ($name == 'tag') { $entityTags = $params[$name]; - $allTags = CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', array('onlyActive' => FALSE)); - $title = array(); + $allTags = CRM_Core_PseudoConstant::get('CRM_Core_DAO_EntityTag', 'tag_id', ['onlyActive' => FALSE]); + $title = []; if (is_array($entityTags)) { foreach ($entityTags as $tagId => $dontCare) { $title[] = $allTags[$tagId]; @@ -1606,11 +1606,11 @@ public static function displayProfile(&$params, $gid, &$groupTitle, &$values, &$ elseif (strpos($name, '-') !== FALSE) { list($fieldName, $id) = CRM_Utils_System::explode('-', $name, 2); $detailName = str_replace(' ', '_', $name); - if (in_array($fieldName, array( + if (in_array($fieldName, [ 'state_province', 'country', 'county', - ))) { + ])) { $values[$index] = $params[$detailName]; $idx = $detailName . '_id'; $values[$index] = $params[$idx]; @@ -1692,7 +1692,7 @@ public static function displayProfile(&$params, $gid, &$groupTitle, &$values, &$ $customVal = $params[$name]; } //take the custom field options - $returnProperties = array($name => 1); + $returnProperties = [$name => 1]; $query = new CRM_Contact_BAO_Query($params, $returnProperties, $fields); if (!$skip) { $displayValue = CRM_Core_BAO_CustomField::displayValue($customVal, $cfID); @@ -1718,11 +1718,11 @@ public static function displayProfile(&$params, $gid, &$groupTitle, &$values, &$ $url = CRM_Utils_System::fixURL($params[$name]); $values[$index] = "{$params[$name]}"; } - elseif (in_array($name, array( + elseif (in_array($name, [ 'birth_date', 'deceased_date', 'participant_register_date', - ))) { + ])) { $values[$index] = CRM_Utils_Date::customFormat(CRM_Utils_Date::format($params[$name])); } else { @@ -1763,7 +1763,7 @@ public static function buildCustomProfile( $skipCancel = TRUE ) { - $customProfile = $additionalIDs = array(); + $customProfile = $additionalIDs = []; if (!$participantId) { CRM_Core_Error::fatal(ts('Cannot find participant ID')); } @@ -1805,12 +1805,12 @@ public static function buildCustomProfile( $isCustomProfile = TRUE; $i = 1; - $title = $groupTitles = array(); + $title = $groupTitles = []; foreach ($additionalIDs as $pId => $cId) { //get the params submitted by participant. $participantParams = NULL; if (isset($values['params'])) { - $participantParams = CRM_Utils_Array::value($pId, $values['params'], array()); + $participantParams = CRM_Utils_Array::value($pId, $values['params'], []); } list($profilePre, $groupTitles) = self::buildCustomDisplay($preProfileID, @@ -1872,8 +1872,8 @@ public static function buildCustomProfile( * @return array */ public static function getLocationEvents() { - $events = array(); - $ret = array( + $events = []; + $ret = [ 'loc_block_id', 'loc_block_id.address_id.name', 'loc_block_id.address_id.street_address', @@ -1882,16 +1882,16 @@ public static function getLocationEvents() { 'loc_block_id.address_id.supplemental_address_3', 'loc_block_id.address_id.city', 'loc_block_id.address_id.state_province_id.name', - ); + ]; - $result = civicrm_api3('Event', 'get', array( + $result = civicrm_api3('Event', 'get', [ 'check_permissions' => TRUE, 'return' => $ret, - 'loc_block_id.address_id' => array('IS NOT NULL' => 1), - 'options' => array( + 'loc_block_id.address_id' => ['IS NOT NULL' => 1], + 'options' => [ 'limit' => 0, - ), - )); + ], + ]); foreach ($result['values'] as $event) { $address = ''; @@ -1988,7 +1988,7 @@ public static function showHideRegistrationLink($values) { $alreadyRegistered = FALSE; if ($contactID) { - $params = array('contact_id' => $contactID); + $params = ['contact_id' => $contactID]; if ($eventId = CRM_Utils_Array::value('id', $values['event'])) { $params['event_id'] = $eventId; @@ -2187,7 +2187,7 @@ public static function getAllPermissions() { Civi::$statics[__CLASS__]['permissions'][CRM_Core_Permission::VIEW] = CRM_ACL_API::group(CRM_Core_Permission::VIEW, NULL, 'civicrm_event', $allEvents, $createdEvents); } - Civi::$statics[__CLASS__]['permissions'][CRM_Core_Permission::DELETE] = array(); + Civi::$statics[__CLASS__]['permissions'][CRM_Core_Permission::DELETE] = []; if (CRM_Core_Permission::check('delete in CiviEvent')) { // Note: we want to restrict the scope of delete permission to // events that are editable/viewable (usecase multisite). @@ -2216,19 +2216,19 @@ public static function getFromEmailIds($eventId = NULL) { if ($eventId) { // add the email id configured for the event - $params = array('id' => $eventId); - $returnProperties = array('confirm_from_name', 'confirm_from_email', 'cc_confirm', 'bcc_confirm'); - $eventEmail = array(); + $params = ['id' => $eventId]; + $returnProperties = ['confirm_from_name', 'confirm_from_email', 'cc_confirm', 'bcc_confirm']; + $eventEmail = []; CRM_Core_DAO::commonRetrieve('CRM_Event_DAO_Event', $params, $eventEmail, $returnProperties); if (!empty($eventEmail['confirm_from_name']) && !empty($eventEmail['confirm_from_email'])) { $eventEmailId = "{$eventEmail['confirm_from_name']} <{$eventEmail['confirm_from_email']}>"; $fromEmailValues['from_email_id'][$eventEmailId] = htmlspecialchars($eventEmailId); - $fromEmailId = array( + $fromEmailId = [ 'cc' => CRM_Utils_Array::value('cc_confirm', $eventEmail), 'bcc' => CRM_Utils_Array::value('bcc_confirm', $eventEmail), - ); + ]; $fromEmailValues = array_merge($fromEmailValues, $fromEmailId); } } @@ -2280,7 +2280,7 @@ public static function eventTotalSeats($eventId, $extraWhereClause = NULL) { {$extraWhereClause} GROUP BY participant.event_id"; - return (int) CRM_Core_DAO::singleValueQuery($query, array(1 => array($eventId, 'Positive'))); + return (int) CRM_Core_DAO::singleValueQuery($query, [1 => [$eventId, 'Positive']]); } /** @@ -2294,14 +2294,14 @@ public static function eventTotalSeats($eventId, $extraWhereClause = NULL) { * Array of custom data defaults. */ public static function getTemplateDefaultValues($templateId) { - $defaults = array(); + $defaults = []; if (!$templateId) { return $defaults; } - $templateParams = array('id' => $templateId); + $templateParams = ['id' => $templateId]; CRM_Event_BAO_Event::retrieve($templateParams, $defaults); - $fieldsToExclude = array( + $fieldsToExclude = [ 'id', 'default_fee_id', 'default_discount_fee_id', @@ -2309,7 +2309,7 @@ public static function getTemplateDefaultValues($templateId) { 'created_id', 'is_template', 'template_title', - ); + ]; $defaults = array_diff_key($defaults, array_flip($fieldsToExclude)); return $defaults; } @@ -2320,8 +2320,8 @@ public static function getTemplateDefaultValues($templateId) { * @return object */ public static function get_sub_events($event_id) { - $params = array('parent_event_id' => $event_id); - $defaults = array(); + $params = ['parent_event_id' => $event_id]; + $defaults = []; return CRM_Event_BAO_Event::retrieve($params, $defaults); } @@ -2334,15 +2334,15 @@ public static function get_sub_events($event_id) { * Campaign id of that event. */ public static function updateParticipantCampaignID($eventID, $eventCampaignID) { - $params = array(); - $params[1] = array($eventID, 'Integer'); + $params = []; + $params[1] = [$eventID, 'Integer']; if (empty($eventCampaignID)) { $query = "UPDATE civicrm_participant SET campaign_id = NULL WHERE event_id = %1"; } else { $query = "UPDATE civicrm_participant SET campaign_id = %2 WHERE event_id = %1"; - $params[2] = array($eventCampaignID, 'Integer'); + $params[2] = [$eventCampaignID, 'Integer']; } CRM_Core_DAO::executeQuery($query, $params); } @@ -2357,8 +2357,8 @@ public static function updateParticipantCampaignID($eventID, $eventCampaignID) { * * @return array|bool */ - public static function buildOptions($fieldName, $context = NULL, $props = array()) { - $params = array(); + public static function buildOptions($fieldName, $context = NULL, $props = []) { + $params = []; // Special logic for fields whose options depend on context or properties switch ($fieldName) { case 'financial_type_id': diff --git a/CRM/Event/BAO/Participant.php b/CRM/Event/BAO/Participant.php index a58eafc6ebb0..bb6f75f06dc7 100644 --- a/CRM/Event/BAO/Participant.php +++ b/CRM/Event/BAO/Participant.php @@ -51,14 +51,14 @@ class CRM_Event_BAO_Participant extends CRM_Event_DAO_Participant { * * @var array */ - static $_statusTransitionsRules = array( - 'Pending from pay later' => array('Registered', 'Cancelled'), - 'Pending from incomplete transaction' => array('Registered', 'Cancelled'), - 'On waitlist' => array('Cancelled', 'Pending from waitlist'), - 'Pending from waitlist' => array('Registered', 'Cancelled'), - 'Awaiting approval' => array('Cancelled', 'Pending from approval'), - 'Pending from approval' => array('Registered', 'Cancelled'), - ); + static $_statusTransitionsRules = [ + 'Pending from pay later' => ['Registered', 'Cancelled'], + 'Pending from incomplete transaction' => ['Registered', 'Cancelled'], + 'On waitlist' => ['Cancelled', 'Pending from waitlist'], + 'Pending from waitlist' => ['Registered', 'Cancelled'], + 'Awaiting approval' => ['Cancelled', 'Pending from approval'], + 'Pending from approval' => ['Registered', 'Cancelled'], + ]; /** */ @@ -168,7 +168,7 @@ public static function getValues(&$params, &$values, &$ids) { $participant = new CRM_Event_BAO_Participant(); $participant->copyValues($params); $participant->find(); - $participants = array(); + $participants = []; while ($participant->fetch()) { $ids['participant'] = $participant->id; CRM_Core_DAO::storeValues($participant, $values[$participant->id]); @@ -237,10 +237,10 @@ public static function create(&$params) { } $noteValue = NULL; $hasNoteField = FALSE; - foreach (array( + foreach ([ 'note', 'participant_note', - ) as $noteFld) { + ] as $noteFld) { if (array_key_exists($noteFld, $params)) { $noteValue = $params[$noteFld]; $hasNoteField = TRUE; @@ -249,14 +249,14 @@ public static function create(&$params) { } if ($noteId || $noteValue) { if ($noteValue) { - $noteParams = array( + $noteParams = [ 'entity_table' => 'civicrm_participant', 'note' => $noteValue, 'entity_id' => $participant->id, 'contact_id' => $id, 'modified_date' => date('Ymd'), - ); - $noteIDs = array(); + ]; + $noteIDs = []; if ($noteId) { $noteIDs['id'] = $noteId; } @@ -268,13 +268,13 @@ public static function create(&$params) { } // Log the information on successful add/edit of Participant data. - $logParams = array( + $logParams = [ 'entity_table' => 'civicrm_participant', 'entity_id' => $participant->id, 'data' => CRM_Event_PseudoConstant::participantStatus($participant->status_id), 'modified_id' => $id, 'modified_date' => date('Ymd'), - ); + ]; CRM_Core_BAO_Log::add($logParams); @@ -289,7 +289,7 @@ public static function create(&$params) { "action=view&reset=1&id={$participant->id}&cid={$participant->contact_id}&context=home" ); - $recentOther = array(); + $recentOther = []; if (CRM_Core_Permission::check('edit event participants')) { $recentOther['editUrl'] = CRM_Utils_System::url('civicrm/contact/view/participant', "action=update&reset=1&id={$participant->id}&cid={$participant->contact_id}&context=home" @@ -378,12 +378,12 @@ public static function eventFull( $allStatusIds = array_keys($countedStatuses); } - $where = array(' event.id = %1 '); + $where = [' event.id = %1 ']; if (!$considerTestParticipant) { $where[] = ' ( participant.is_test = 0 OR participant.is_test IS NULL ) '; } if (!empty($participantRoles)) { - $escapedRoles = array(); + $escapedRoles = []; foreach (array_keys($participantRoles) as $participantRole) { $escapedRoles[] = CRM_Utils_Type::escape($participantRole, 'String'); } @@ -391,7 +391,7 @@ public static function eventFull( $where[] = " participant.role_id IN ( '" . implode("', '", $escapedRoles) . "' ) "; } - $eventParams = array(1 => array($eventId, 'Positive')); + $eventParams = [1 => [$eventId, 'Positive']]; //in case any waiting, straight forward event is full. if ($includeWaitingList && $onWaitlistStatusId) { @@ -501,17 +501,17 @@ public static function eventFull( */ public static function priceSetOptionsCount( $eventId, - $skipParticipantIds = array(), + $skipParticipantIds = [], $considerCounted = TRUE, $considerWaiting = TRUE, $considerTestParticipants = FALSE ) { - $optionsCount = array(); + $optionsCount = []; if (!$eventId) { return $optionsCount; } - $allStatusIds = array(); + $allStatusIds = []; if ($considerCounted) { $countedStatuses = CRM_Event_PseudoConstant::participantStatus(NULL, 'is_counted = 1'); $allStatusIds = array_merge($allStatusIds, array_keys($countedStatuses)); @@ -553,7 +553,7 @@ public static function priceSetOptionsCount( {$isTestClause} {$skipParticipantClause}"; - $lineItem = CRM_Core_DAO::executeQuery($sql, array(1 => array($eventId, 'Positive'))); + $lineItem = CRM_Core_DAO::executeQuery($sql, [1 => [$eventId, 'Positive']]); while ($lineItem->fetch()) { $count = $lineItem->count; if (!$count) { @@ -633,67 +633,67 @@ public static function &importableFields($contactType = 'Individual', $status = if (!self::$_importableFields) { if (!$onlyParticipant) { if (!$status) { - $fields = array('' => array('title' => ts('- do not import -'))); + $fields = ['' => ['title' => ts('- do not import -')]]; } else { - $fields = array('' => array('title' => ts('- Participant Fields -'))); + $fields = ['' => ['title' => ts('- Participant Fields -')]]; } } else { - $fields = array(); + $fields = []; } $tmpFields = CRM_Event_DAO_Participant::import(); - $note = array( - 'participant_note' => array( + $note = [ + 'participant_note' => [ 'title' => ts('Participant Note'), 'name' => 'participant_note', 'headerPattern' => '/(participant.)?note$/i', 'data_type' => CRM_Utils_Type::T_TEXT, - ), - ); + ], + ]; // Split status and status id into 2 fields // Fixme: it would be better to leave as 1 field and intelligently handle both during import - $participantStatus = array( - 'participant_status' => array( + $participantStatus = [ + 'participant_status' => [ 'title' => ts('Participant Status'), 'name' => 'participant_status', 'data_type' => CRM_Utils_Type::T_STRING, - ), - ); + ], + ]; $tmpFields['participant_status_id']['title'] = ts('Participant Status Id'); // Split role and role id into 2 fields // Fixme: it would be better to leave as 1 field and intelligently handle both during import - $participantRole = array( - 'participant_role' => array( + $participantRole = [ + 'participant_role' => [ 'title' => ts('Participant Role'), 'name' => 'participant_role', 'data_type' => CRM_Utils_Type::T_STRING, - ), - ); + ], + ]; $tmpFields['participant_role_id']['title'] = ts('Participant Role Id'); - $eventType = array( - 'event_type' => array( + $eventType = [ + 'event_type' => [ 'title' => ts('Event Type'), 'name' => 'event_type', 'data_type' => CRM_Utils_Type::T_STRING, - ), - ); + ], + ]; - $tmpContactField = $contactFields = array(); - $contactFields = array(); + $tmpContactField = $contactFields = []; + $contactFields = []; if (!$onlyParticipant) { $contactFields = CRM_Contact_BAO_Contact::importableFields($contactType, NULL); // Using new Dedupe rule. - $ruleParams = array( + $ruleParams = [ 'contact_type' => $contactType, 'used' => 'Unsupervised', - ); + ]; $fieldsArray = CRM_Dedupe_BAO_Rule::dedupeRuleFields($ruleParams); if (is_array($fieldsArray)) { @@ -745,34 +745,34 @@ public static function &importableFields($contactType = 'Individual', $status = public static function &exportableFields($checkPermission = TRUE) { if (!self::$_exportableFields) { if (!self::$_exportableFields) { - self::$_exportableFields = array(); + self::$_exportableFields = []; } $participantFields = CRM_Event_DAO_Participant::export(); $eventFields = CRM_Event_DAO_Event::export(); - $noteField = array( - 'participant_note' => array( + $noteField = [ + 'participant_note' => [ 'title' => ts('Participant Note'), 'name' => 'participant_note', 'type' => CRM_Utils_Type::T_STRING, - ), - ); + ], + ]; - $participantStatus = array( - 'participant_status' => array( + $participantStatus = [ + 'participant_status' => [ 'title' => ts('Participant Status (label)'), 'name' => 'participant_status', 'type' => CRM_Utils_Type::T_STRING, - ), - ); + ], + ]; - $participantRole = array( - 'participant_role' => array( + $participantRole = [ + 'participant_role' => [ 'title' => ts('Participant Role (label)'), 'name' => 'participant_role', 'type' => CRM_Utils_Type::T_STRING, - ), - ); + ], + ]; $participantFields['participant_status_id']['title'] .= ' (ID)'; $participantFields['participant_role_id']['title'] .= ' (ID)'; @@ -808,7 +808,7 @@ public static function participantDetails($participantId) { "; $dao = CRM_Core_DAO::executeQuery($query); - $details = array(); + $details = []; while ($dao->fetch()) { $details['name'] = $dao->name; $details['title'] = $dao->title; @@ -886,22 +886,22 @@ public static function deleteParticipant($id) { $transaction = new CRM_Core_Transaction(); //delete activity record - $params = array( + $params = [ 'source_record_id' => $id, // activity type id for event registration 'activity_type_id' => 5, - ); + ]; CRM_Activity_BAO_Activity::deleteActivity($params); // delete the participant payment record // we need to do this since the cascaded constraints // dont work with join tables - $p = array('participant_id' => $id); + $p = ['participant_id' => $id]; CRM_Event_BAO_ParticipantPayment::deleteParticipantPayment($p); // cleanup line items. - $participantsId = array(); + $participantsId = []; $participantsId = self::getAdditionalParticipantIds($id); $participantsId[] = $id; CRM_Price_BAO_LineItem::deleteLineItems($participantsId, 'civicrm_participant'); @@ -920,10 +920,10 @@ public static function deleteParticipant($id) { CRM_Utils_Hook::post('delete', 'Participant', $participant->id, $participant); // delete the recently created Participant - $participantRecent = array( + $participantRecent = [ 'id' => $id, 'type' => 'Participant', - ); + ]; CRM_Utils_Recent::del($participantRecent); @@ -945,17 +945,17 @@ public static function checkDuplicate($input, &$duplicates) { $eventId = CRM_Utils_Array::value('event_id', $input); $contactId = CRM_Utils_Array::value('contact_id', $input); - $clause = array(); - $input = array(); + $clause = []; + $input = []; if ($eventId) { $clause[] = "event_id = %1"; - $input[1] = array($eventId, 'Integer'); + $input[1] = [$eventId, 'Integer']; } if ($contactId) { $clause[] = "contact_id = %2"; - $input[2] = array($contactId, 'Integer'); + $input[2] = [$contactId, 'Integer']; } if (empty($clause)) { @@ -1019,7 +1019,7 @@ public static function fixEventLevel(&$eventLevel) { * @return array */ public static function getAdditionalParticipantIds($primaryParticipantId, $excludeCancel = TRUE, $oldStatusId = NULL) { - $additionalParticipantIds = array(); + $additionalParticipantIds = []; if (!$primaryParticipantId) { return $additionalParticipantIds; } @@ -1061,21 +1061,21 @@ public static function getAdditionalParticipantIds($primaryParticipantId, $exclu */ public static function getUnDiscountedAmountForEventPriceSetFieldValue($eventID, $discountedPriceFieldOptionID, $feeLevel) { $priceSetId = CRM_Price_BAO_PriceSet::getFor('civicrm_event', $eventID, NULL); - $params = array( - 1 => array($priceSetId, 'Integer'), - ); + $params = [ + 1 => [$priceSetId, 'Integer'], + ]; if ($discountedPriceFieldOptionID) { $query = "SELECT cpfv.amount FROM `civicrm_price_field_value` cpfv LEFT JOIN civicrm_price_field cpf ON cpfv.price_field_id = cpf.id WHERE cpf.price_set_id = %1 AND cpfv.label = (SELECT label from civicrm_price_field_value WHERE id = %2)"; - $params[2] = array($discountedPriceFieldOptionID, 'Integer'); + $params[2] = [$discountedPriceFieldOptionID, 'Integer']; } else { $feeLevel = current($feeLevel); $query = "SELECT cpfv.amount FROM `civicrm_price_field_value` cpfv LEFT JOIN civicrm_price_field cpf ON cpfv.price_field_id = cpf.id WHERE cpf.price_set_id = %1 AND cpfv.label LIKE %2"; - $params[2] = array($feeLevel, 'String'); + $params[2] = [$feeLevel, 'String']; } return CRM_Core_DAO::singleValueQuery($query, $params); } @@ -1092,7 +1092,7 @@ public static function getUnDiscountedAmountForEventPriceSetFieldValue($eventID, * @return array */ public function getFeeDetails($participantIds, $hasLineItems = FALSE) { - $feeDetails = array(); + $feeDetails = []; if (!is_array($participantIds) || empty($participantIds)) { return $feeDetails; } @@ -1126,8 +1126,8 @@ public function getFeeDetails($participantIds, $hasLineItems = FALSE) { $query = "$select $from $where"; $feeInfo = CRM_Core_DAO::executeQuery($query); - $feeProperties = array('fee_level', 'fee_amount'); - $lineProperties = array( + $feeProperties = ['fee_level', 'fee_amount']; + $lineProperties = [ 'lineId', 'label', 'qty', @@ -1139,7 +1139,7 @@ public function getFeeDetails($participantIds, $hasLineItems = FALSE) { 'participant_count', 'price_field_value_id', 'description', - ); + ]; while ($feeInfo->fetch()) { if ($hasLineItems) { foreach ($lineProperties as $property) { @@ -1167,7 +1167,7 @@ public function getFeeDetails($participantIds, $hasLineItems = FALSE) { * $displayName => $viewUrl */ public static function getAdditionalParticipants($primaryParticipantID) { - $additionalParticipantIDs = array(); + $additionalParticipantIDs = []; $additionalParticipantIDs = self::getAdditionalParticipantIds($primaryParticipantID); if (!empty($additionalParticipantIDs)) { foreach ($additionalParticipantIDs as $additionalParticipantID) { @@ -1214,10 +1214,10 @@ public static function updateParticipantStatus($participantID, $oldStatusID, $ne if (!empty($cascadeAdditionalIds)) { try { foreach ($cascadeAdditionalIds as $id) { - $participantParams = array( + $participantParams = [ 'id' => $id, 'status_id' => $newStatusID, - ); + ]; civicrm_api3('Participant', 'create', $participantParams); } return TRUE; @@ -1286,7 +1286,7 @@ public static function transitionParticipants( } //thumb rule is if we triggering primary participant need to triggered additional - $allParticipantIds = $primaryANDAdditonalIds = array(); + $allParticipantIds = $primaryANDAdditonalIds = []; foreach ($participantIds as $id) { $allParticipantIds[] = $id; if (self::isPrimaryParticipant($id)) { @@ -1308,11 +1308,11 @@ public static function transitionParticipants( $allParticipantIds = array_unique($allParticipantIds); //pull required participants, contacts, events data, if not in hand - static $eventDetails = array(); - static $domainValues = array(); - static $contactDetails = array(); + static $eventDetails = []; + static $domainValues = []; + static $contactDetails = []; - $contactIds = $eventIds = $participantDetails = array(); + $contactIds = $eventIds = $participantDetails = []; $statusTypes = CRM_Event_PseudoConstant::participantStatus(); $participantRoles = CRM_Event_PseudoConstant::participantRole(); @@ -1327,7 +1327,7 @@ public static function transitionParticipants( $query = "SELECT * FROM civicrm_participant WHERE id IN {$participantIdClause}"; $dao = CRM_Core_DAO::executeQuery($query); while ($dao->fetch()) { - $participantDetails[$dao->id] = array( + $participantDetails[$dao->id] = [ 'id' => $dao->id, 'role' => $participantRoles[$dao->role_id], 'is_test' => $dao->is_test, @@ -1337,7 +1337,7 @@ public static function transitionParticipants( 'contact_id' => $dao->contact_id, 'register_date' => $dao->register_date, 'registered_by_id' => $dao->registered_by_id, - ); + ]; if (!array_key_exists($dao->contact_id, $contactDetails)) { $contactIds[$dao->contact_id] = $dao->contact_id; } @@ -1351,10 +1351,10 @@ public static function transitionParticipants( if (empty($domainValues)) { // making all tokens available to templates. $domain = CRM_Core_BAO_Domain::getDomain(); - $tokens = array( - 'domain' => array('name', 'phone', 'address', 'email'), + $tokens = [ + 'domain' => ['name', 'phone', 'address', 'email'], 'contact' => CRM_Core_SelectValues::contactTokens(), - ); + ]; foreach ($tokens['domain'] as $token) { $domainValues[$token] = CRM_Utils_Token::getDomainTokenReplacement($token, $domain); @@ -1366,7 +1366,7 @@ public static function transitionParticipants( // get the contact details. list($currentContactDetails) = CRM_Utils_Token::getTokenDetails($contactIds, NULL, FALSE, FALSE, NULL, - array(), + [], 'CRM_Event_BAO_Participant' ); foreach ($currentContactDetails as $contactId => $contactValues) { @@ -1378,14 +1378,14 @@ public static function transitionParticipants( if (!empty($eventIds)) { foreach ($eventIds as $eventId) { //retrieve event information - $eventParams = array('id' => $eventId); + $eventParams = ['id' => $eventId]; 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); //get the location info - $locParams = array('entity_id' => $eventId, 'entity_table' => 'civicrm_event'); + $locParams = ['entity_id' => $eventId, 'entity_table' => 'civicrm_event']; $eventDetails[$eventId]['location'] = CRM_Core_BAO_Location::getValues($locParams, TRUE); } } @@ -1421,12 +1421,12 @@ public static function transitionParticipants( //as we process additional w/ primary, there might be case if user //select primary as well as additionals, so avoid double processing. - $processedParticipantIds = array(); - $mailedParticipants = array(); + $processedParticipantIds = []; + $mailedParticipants = []; //send mails and update status. foreach ($participantDetails as $participantId => $participantValues) { - $updateParticipantIds = array(); + $updateParticipantIds = []; if (in_array($participantId, $processedParticipantIds)) { continue; } @@ -1485,10 +1485,10 @@ public static function transitionParticipants( //return result for cron. if ($returnResult) { - $results = array( + $results = [ 'mailedParticipants' => $mailedParticipants, 'updatedParticipantIds' => $processedParticipantIds, - ); + ]; return $results; } @@ -1555,11 +1555,11 @@ public static function sendTransitionParticipantMail( } list($mailSent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate( - array( + [ 'groupName' => 'msg_tpl_workflow_event', 'valueName' => 'participant_' . strtolower($mailType), 'contactId' => $contactId, - 'tplParams' => array( + 'tplParams' => [ 'contact' => $contactDetails, 'domain' => $domainValues, 'participant' => $participantValues, @@ -1570,20 +1570,20 @@ public static function sendTransitionParticipantMail( 'isExpired' => $mailType == 'Expired', 'isConfirm' => $mailType == 'Confirm', 'checksumValue' => $checksumValue, - ), + ], 'from' => $receiptFrom, 'toName' => $participantName, 'toEmail' => $toEmail, 'cc' => CRM_Utils_Array::value('cc_confirm', $eventDetails), 'bcc' => CRM_Utils_Array::value('bcc_confirm', $eventDetails), - ) + ] ); // 3. create activity record. if ($mailSent) { $now = date('YmdHis'); $activityType = 'Event Registration'; - $activityParams = array( + $activityParams = [ 'subject' => $subject, 'source_contact_id' => $contactId, 'source_record_id' => $participantId, @@ -1592,7 +1592,7 @@ public static function sendTransitionParticipantMail( 'due_date_time' => CRM_Utils_Date::isoToMysql($participantValues['register_date']), 'is_test' => $participantValues['is_test'], 'status_id' => 2, - ); + ]; if (is_a(CRM_Activity_BAO_Activity::create($activityParams), 'CRM_Core_Error')) { CRM_Core_Error::fatal('Failed creating Activity for expiration mail'); @@ -1614,7 +1614,7 @@ public static function sendTransitionParticipantMail( */ public function updateStatusMessage($participantId, $statusChangeTo, $fromStatusId) { $statusMsg = NULL; - $results = self::transitionParticipants(array($participantId), + $results = self::transitionParticipants([$participantId], $statusChangeTo, $fromStatusId, TRUE ); @@ -1627,10 +1627,10 @@ public function updateStatusMessage($participantId, $statusChangeTo, $fromStatus array_key_exists($processedId, $results['mailedParticipants']) ) { $statusMsg .= '
    ' . ts("Participant status has been updated to '%1'. An email has been sent to %2.", - array( + [ 1 => $allStatuses[$statusChangeTo], 2 => $results['mailedParticipants'][$processedId], - ) + ] ); } } @@ -1668,9 +1668,9 @@ public static function eventFullMessage($eventId, $participantId = NULL) { $emptySeats = self::eventFull($eventId, FALSE, FALSE); if (is_string($emptySeats) && $emptySeats !== NULL) { $maxParticipants = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $eventId, 'max_participants'); - $eventfullMsg = ts("This event currently has the maximum number of participants registered (%1). However, you can still override this limit and register additional participants using this form.", array( + $eventfullMsg = ts("This event currently has the maximum number of participants registered (%1). However, you can still override this limit and register additional participants using this form.", [ 1 => $maxParticipants, - )) . '
    '; + ]) . '
    '; } $hasWaiting = FALSE; @@ -1692,10 +1692,10 @@ public static function eventFullMessage($eventId, $participantId = NULL) { ); $eventfullMsg .= ts("There are %2 people currently on the waiting list for this event. You can view waitlisted registrations here, or you can continue and register additional participants using this form.", - array( + [ 1 => $viewWaitListUrl, 2 => $waitListedCount, - ) + ] ); } @@ -1736,9 +1736,9 @@ public static function isPrimaryParticipant($participantId) { */ public static function getValidAdditionalIds($participantId, $oldStatusId, $newStatusId) { - $additionalParticipantIds = array(); + $additionalParticipantIds = []; - static $participantStatuses = array(); + static $participantStatuses = []; if (empty($participantStatuses)) { $participantStatuses = CRM_Event_PseudoConstant::participantStatus(); @@ -1781,7 +1781,7 @@ public static function getContactParticipantCount($contactID) { */ public static function getParticipantIds($contributionId, $excludeCancelled = FALSE) { - $ids = array(); + $ids = []; if (!$contributionId) { return $ids; } @@ -1796,9 +1796,9 @@ public static function getParticipantIds($contributionId, $excludeCancelled = FA // get additional participant ids (including cancelled) while ($participantPayment->fetch()) { - $ids = array_merge($ids, array_merge(array( + $ids = array_merge($ids, array_merge([ $participantPayment->participant_id, - ), self::getAdditionalParticipantIds($participantPayment->participant_id, + ], self::getAdditionalParticipantIds($participantPayment->participant_id, $excludeCancelled ))); } @@ -1817,7 +1817,7 @@ public static function getParticipantIds($contributionId, $excludeCancelled = FA */ public static function getAdditionalParticipantUrl($participantIds) { foreach ($participantIds as $value) { - $links = array(); + $links = []; $details = self::participantDetails($value); $viewUrl = CRM_Utils_System::url('civicrm/contact/view/participant', "action=view&reset=1&id={$value}&cid={$details['cid']}" @@ -1898,7 +1898,7 @@ public static function addActivityForSelection($participantId, $activityType) { $subject = sprintf("Registration selections changed for %s", CRM_Utils_Array::value($eventId, $event)); // activity params - $activityParams = array( + $activityParams = [ 'source_contact_id' => $contactId, 'source_record_id' => $participantId, 'activity_type_id' => CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', $activityType), @@ -1906,7 +1906,7 @@ public static function addActivityForSelection($participantId, $activityType) { 'activity_date_time' => $date, 'status_id' => CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_status_id', 'Completed'), 'skipRecentView' => TRUE, - ); + ]; // create activity with target contacts $id = CRM_Core_Session::singleton()->getLoggedInContactID();; @@ -1930,8 +1930,8 @@ public static function addActivityForSelection($participantId, $activityType) { * * @return array|bool */ - public static function buildOptions($fieldName, $context = NULL, $props = array()) { - $params = array('condition' => array()); + public static function buildOptions($fieldName, $context = NULL, $props = []) { + $params = ['condition' => []]; if ($fieldName == 'status_id' && $context != 'validate') { // Get rid of cart-related option if disabled @@ -1953,9 +1953,9 @@ public static function formatFieldsAndSetProfileDefaults($contactId, &$form) { if (!$contactId) { return; } - $fields = array(); + $fields = []; if (!empty($form->_fields)) { - $removeCustomFieldTypes = array('Participant'); + $removeCustomFieldTypes = ['Participant']; foreach ($form->_fields as $name => $dontCare) { if ((substr($name, 0, 7) == 'custom_' && !$form->_allowConfirmation diff --git a/CRM/Event/BAO/ParticipantPayment.php b/CRM/Event/BAO/ParticipantPayment.php index f84e6b15ace4..a3383bfcadb8 100644 --- a/CRM/Event/BAO/ParticipantPayment.php +++ b/CRM/Event/BAO/ParticipantPayment.php @@ -79,20 +79,20 @@ public static function create(&$params, $ids = []) { //generally if people are creating participant_payments via the api they won't be setting the line item correctly - we can't help them if they are doing complex transactions // but if they have a single line item for the contribution we can assume it should refer to the participant line - $lineItemCount = CRM_Core_DAO::singleValueQuery("select count(*) FROM civicrm_line_item WHERE contribution_id = %1", array( - 1 => array( + $lineItemCount = CRM_Core_DAO::singleValueQuery("select count(*) FROM civicrm_line_item WHERE contribution_id = %1", [ + 1 => [ $participantPayment->contribution_id, 'Integer', - ), - )); + ], + ]); if ($lineItemCount == 1) { $sql = "UPDATE civicrm_line_item li SET entity_table = 'civicrm_participant', entity_id = %1 WHERE contribution_id = %2 AND entity_table = 'civicrm_contribution'"; - CRM_Core_DAO::executeQuery($sql, array( - 1 => array($participantPayment->participant_id, 'Integer'), - 2 => array($participantPayment->contribution_id, 'Integer'), - )); + CRM_Core_DAO::executeQuery($sql, [ + 1 => [$participantPayment->participant_id, 'Integer'], + 2 => [$participantPayment->contribution_id, 'Integer'], + ]); } return $participantPayment; diff --git a/CRM/Event/BAO/ParticipantStatusType.php b/CRM/Event/BAO/ParticipantStatusType.php index dcbe3a48ec01..b04b0fa1f82a 100644 --- a/CRM/Event/BAO/ParticipantStatusType.php +++ b/CRM/Event/BAO/ParticipantStatusType.php @@ -123,7 +123,7 @@ public static function setIsActive($id, $isActive) { */ public static function process($params) { - $returnMessages = array(); + $returnMessages = []; $pendingStatuses = CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Pending'"); $expiredStatuses = CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Negative'"); @@ -132,7 +132,7 @@ public static function process($params) { //build the required status ids. $statusIds = '(' . implode(',', array_merge(array_keys($pendingStatuses), array_keys($waitingStatuses))) . ')'; - $participantDetails = $fullEvents = array(); + $participantDetails = $fullEvents = []; $expiredParticipantCount = $waitingConfirmCount = $waitingApprovalCount = 0; //get all participant who's status in class pending and waiting @@ -158,7 +158,7 @@ public static function process($params) { "; $dao = CRM_Core_DAO::executeQuery($query); while ($dao->fetch()) { - $participantDetails[$dao->id] = array( + $participantDetails[$dao->id] = [ 'id' => $dao->id, 'event_id' => $dao->event_id, 'status_id' => $dao->status_id, @@ -171,7 +171,7 @@ public static function process($params) { 'end_date' => $dao->end_date, 'expiration_time' => $dao->expiration_time, 'requires_approval' => $dao->requires_approval, - ); + ]; } if (!empty($participantDetails)) { @@ -196,7 +196,7 @@ public static function process($params) { //lets get the transaction mechanism. $transaction = new CRM_Core_Transaction(); - $ids = array($participantId); + $ids = [$participantId]; $expiredId = array_search('Expired', $expiredStatuses); $results = CRM_Event_BAO_Participant::transitionParticipants($ids, $expiredId, $values['status_id'], TRUE, TRUE); $transaction->commit(); @@ -246,7 +246,7 @@ public static function process($params) { //get the additional participant if any. $additionalIds = CRM_Event_BAO_Participant::getAdditionalParticipantIds($participantId); - $allIds = array($participantId); + $allIds = [$participantId]; if (!empty($additionalIds)) { $allIds = array_merge($allIds, $additionalIds); } @@ -257,7 +257,7 @@ public static function process($params) { if (($requiredSpaces <= $eventOpenSpaces) || ($eventOpenSpaces === NULL)) { $transaction = new CRM_Core_Transaction(); - $ids = array($participantId); + $ids = [$participantId]; $updateStatusId = array_search('Pending from waitlist', $pendingStatuses); //lets take a call to make pending or need approval @@ -318,7 +318,7 @@ public static function process($params) { } } - return array('is_error' => 0, 'messages' => $returnMessages); + return ['is_error' => 0, 'messages' => $returnMessages]; } } diff --git a/CRM/Event/BAO/Query.php b/CRM/Event/BAO/Query.php index 8fb89c398ec8..5f7a1ecf7851 100644 --- a/CRM/Event/BAO/Query.php +++ b/CRM/Event/BAO/Query.php @@ -43,7 +43,7 @@ class CRM_Event_BAO_Query extends CRM_Core_BAO_Query { * Associative array of contribution fields */ public static function &getFields($checkPermission = TRUE) { - $fields = array(); + $fields = []; $fields = array_merge($fields, CRM_Event_DAO_Event::import()); $fields = array_merge($fields, self::getParticipantFields()); $fields = array_merge($fields, CRM_Core_DAO_Discount::export()); @@ -154,10 +154,10 @@ public static function select(&$query) { $query->_element['participant_role_id'] = 1; $query->_tables['civicrm_participant'] = 1; $query->_whereTables['civicrm_participant'] = 1; - $query->_pseudoConstantsSelect['participant_role_id'] = array( + $query->_pseudoConstantsSelect['participant_role_id'] = [ 'pseudoField' => 'participant_role_id', 'idCol' => 'participant_role_id', - ); + ]; } //add participant_role @@ -166,10 +166,10 @@ public static function select(&$query) { $query->_element['participant_role'] = 1; $query->_tables['participant_role'] = 1; $query->_whereTables['civicrm_participant'] = 1; - $query->_pseudoConstantsSelect['participant_role'] = array( + $query->_pseudoConstantsSelect['participant_role'] = [ 'pseudoField' => 'participant_role', 'idCol' => 'participant_role', - ); + ]; } //add register date @@ -305,7 +305,7 @@ public static function whereClauseSingle(&$values, &$query) { $thisEventHasParent = CRM_Core_BAO_RecurringEntity::getParentFor($value, 'civicrm_event'); if ($thisEventHasParent) { $getAllConnections = CRM_Core_BAO_RecurringEntity::getEntitiesForParent($thisEventHasParent, 'civicrm_event'); - $allEventIds = array(); + $allEventIds = []; foreach ($getAllConnections as $key => $val) { $allEventIds[] = $val['id']; } @@ -334,7 +334,7 @@ public static function whereClauseSingle(&$values, &$query) { ); $isTest = $value ? 'a Test' : 'not a Test'; - $query->_qill[$grouping][] = ts("Participant is %1", array(1 => $isTest)); + $query->_qill[$grouping][] = ts("Participant is %1", [1 => $isTest]); $query->_tables['civicrm_participant'] = $query->_whereTables['civicrm_participant'] = 1; } return; @@ -374,7 +374,7 @@ public static function whereClauseSingle(&$values, &$query) { case 'participant_registered_by_id': $qillName = $name; - if (in_array($name, array( + if (in_array($name, [ 'participant_status_id', 'participant_source', 'participant_id', @@ -384,7 +384,7 @@ public static function whereClauseSingle(&$values, &$query) { 'participant_is_pay_later', 'participant_campaign_id', 'participant_registered_by_id', - )) + ]) ) { $name = str_replace('participant_', '', $name); if ($name == 'is_pay_later') { @@ -404,7 +404,7 @@ public static function whereClauseSingle(&$values, &$query) { $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("$tableName.$name", $op, $value, $dataType); list($op, $value) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Event_DAO_Participant', $name, $value, $op); - $query->_qill[$grouping][] = ts('%1 %2 %3', array(1 => $fields[$qillName]['title'], 2 => $op, 3 => $value)); + $query->_qill[$grouping][] = ts('%1 %2 %3', [1 => $fields[$qillName]['title'], 2 => $op, 3 => $value]); $query->_tables['civicrm_participant'] = $query->_whereTables['civicrm_participant'] = 1; return; @@ -429,7 +429,7 @@ public static function whereClauseSingle(&$values, &$query) { } list($op, $value) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Event_DAO_Participant', $name, $value, $op); - $query->_qill[$grouping][] = ts('%1 %2 %3', array(1 => $fields[$qillName]['title'], 2 => $op, 3 => $value)); + $query->_qill[$grouping][] = ts('%1 %2 %3', [1 => $fields[$qillName]['title'], 2 => $op, 3 => $value]); $query->_tables['civicrm_participant'] = $query->_whereTables['civicrm_participant'] = 1; return; @@ -448,11 +448,11 @@ public static function whereClauseSingle(&$values, &$query) { case 'event_type_id': case 'event_title': $qillName = $name; - if (in_array($name, array( + if (in_array($name, [ 'event_id', 'event_title', 'event_is_public', - ) + ] ) ) { $name = str_replace('event_', '', $name); @@ -464,15 +464,15 @@ public static function whereClauseSingle(&$values, &$query) { if (!array_key_exists($qillName, $fields)) { break; } - list($op, $value) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Event_DAO_Event', $name, $value, $op, array('check_permission' => $checkPermission)); - $query->_qill[$grouping][] = ts('%1 %2 %3', array(1 => $fields[$qillName]['title'], 2 => $op, 3 => $value)); + list($op, $value) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Event_DAO_Event', $name, $value, $op, ['check_permission' => $checkPermission]); + $query->_qill[$grouping][] = ts('%1 %2 %3', [1 => $fields[$qillName]['title'], 2 => $op, 3 => $value]); return; case 'participant_note': $query->_tables['civicrm_participant'] = $query->_whereTables['civicrm_participant'] = 1; $query->_tables['participant_note'] = $query->_whereTables['participant_note'] = 1; $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause('participant_note.note', $op, $value, 'String'); - $query->_qill[$grouping][] = ts('%1 %2 %3', array(1 => $fields[$name]['title'], 2 => $op, 3 => $value)); + $query->_qill[$grouping][] = ts('%1 %2 %3', [1 => $fields[$name]['title'], 2 => $op, 3 => $value]); break; } } @@ -536,7 +536,7 @@ public static function defaultReturnProperties( ) { $properties = NULL; if ($mode & CRM_Contact_BAO_Query::MODE_EVENT) { - $properties = array( + $properties = [ 'contact_type' => 1, 'contact_sub_type' => 1, 'sort_name' => 1, @@ -562,7 +562,7 @@ public static function defaultReturnProperties( 'participant_fee_currency' => 1, 'participant_registered_by_id' => 1, 'participant_campaign_id' => 1, - ); + ]; if ($includeCustomFields) { // also get all the custom participant properties @@ -589,27 +589,27 @@ public static function buildSearchForm(&$form) { $form->assign('dataURLEventFee', $dataURLEventFee); - $form->addEntityRef('event_id', ts('Event Name'), array( + $form->addEntityRef('event_id', ts('Event Name'), [ 'entity' => 'Event', 'placeholder' => ts('- any -'), 'multiple' => 1, - 'select' => array('minimumInputLength' => 0), - ) + 'select' => ['minimumInputLength' => 0], + ] ); - $form->addEntityRef('event_type_id', ts('Event Type'), array( + $form->addEntityRef('event_type_id', ts('Event Type'), [ 'entity' => 'OptionValue', 'placeholder' => ts('- any -'), - 'select' => array('minimumInputLength' => 0), - 'api' => array( - 'params' => array('option_group_id' => 'event_type'), - ), - ) + 'select' => ['minimumInputLength' => 0], + 'api' => [ + 'params' => ['option_group_id' => 'event_type'], + ], + ] ); $obj = new CRM_Report_Form_Event_ParticipantListing(); $form->add('select', 'participant_fee_id', ts('Fee Level'), $obj->getPriceLevels(), - FALSE, array('class' => 'crm-select2', 'multiple' => 'multiple', 'placeholder' => ts('- any -')) + FALSE, ['class' => 'crm-select2', 'multiple' => 'multiple', 'placeholder' => ts('- any -')] ); CRM_Core_Form_Date::buildDateRange($form, 'event', 1, '_start_date_low', '_end_date_high', ts('From'), FALSE); @@ -618,44 +618,44 @@ public static function buildSearchForm(&$form) { $form->addElement('hidden', 'event_date_range_error'); $form->addElement('hidden', 'participant_date_range_error'); - $form->addFormRule(array('CRM_Event_BAO_Query', 'formRule'), $form); + $form->addFormRule(['CRM_Event_BAO_Query', 'formRule'], $form); - $form->addElement('checkbox', "event_include_repeating_events", NULL, ts('Include participants from all events in the %1 series', array(1 => '%1'))); + $form->addElement('checkbox', "event_include_repeating_events", NULL, ts('Include participants from all events in the %1 series', [1 => '%1'])); $form->addSelect('participant_status_id', - array( + [ 'entity' => 'participant', 'label' => ts('Participant Status'), 'multiple' => 'multiple', 'option_url' => NULL, 'placeholder' => ts('- any -'), - ) + ] ); $form->addSelect('participant_role_id', - array( + [ 'entity' => 'participant', 'label' => ts('Participant Role'), 'multiple' => 'multiple', 'option_url' => NULL, 'placeholder' => ts('- any -'), - ) + ] ); $form->addYesNo('participant_test', ts('Participant is a Test?'), TRUE); $form->addYesNo('participant_is_pay_later', ts('Participant is Pay Later?'), TRUE); - $form->addElement('text', 'participant_fee_amount_low', ts('From'), array('size' => 8, 'maxlength' => 8)); - $form->addElement('text', 'participant_fee_amount_high', ts('To'), array('size' => 8, 'maxlength' => 8)); + $form->addElement('text', 'participant_fee_amount_low', ts('From'), ['size' => 8, 'maxlength' => 8]); + $form->addElement('text', 'participant_fee_amount_high', ts('To'), ['size' => 8, 'maxlength' => 8]); $form->addRule('participant_fee_amount_low', ts('Please enter a valid money value.'), 'money'); $form->addRule('participant_fee_amount_high', ts('Please enter a valid money value.'), 'money'); - self::addCustomFormFields($form, array('Participant', 'Event')); + self::addCustomFormFields($form, ['Participant', 'Event']); CRM_Campaign_BAO_Campaign::addCampaignInComponentSearch($form, 'participant_campaign_id'); $form->assign('validCiviEvent', TRUE); - $form->setDefaults(array('participant_test' => 0)); + $form->setDefaults(['participant_test' => 0]); } /** @@ -664,7 +664,7 @@ public static function buildSearchForm(&$form) { public static function tableNames(&$tables) { //add participant table if (!empty($tables['civicrm_event'])) { - $tables = array_merge(array('civicrm_participant' => 1), $tables); + $tables = array_merge(['civicrm_participant' => 1], $tables); } } @@ -680,7 +680,7 @@ public static function tableNames(&$tables) { * @return bool|array */ public static function formRule($fields, $files, $form) { - $errors = array(); + $errors = []; if ((empty($fields['event_start_date_low']) || empty($fields['event_end_date_high'])) && (empty($fields['participant_register_date_low']) || empty($fields['participant_register_date_high']))) { return TRUE; diff --git a/CRM/Event/Badge.php b/CRM/Event/Badge.php index 94d51e15a8af..b485fe28720b 100644 --- a/CRM/Event/Badge.php +++ b/CRM/Event/Badge.php @@ -46,13 +46,13 @@ class CRM_Event_Badge { /** */ public function __construct() { - $this->style = array( + $this->style = [ 'width' => 0.1, 'cap' => 'round', 'join' => 'round', 'dash' => '2,2', - 'color' => array(0, 0, 200), - ); + 'color' => [0, 0, 200], + ]; $this->format = '5160'; $this->imgExtension = 'png'; $this->imgRes = 300; @@ -123,9 +123,9 @@ public function getImageFileName($eventID, $img = FALSE) { // CRM-13235 - leverage the Smarty path to get all templates directories $template = CRM_Core_Smarty::singleton(); if (isset($template->template_dir) && $template->template_dir) { - $dirs = is_array($template->template_dir) ? $template->template_dir : array($template->template_dir); + $dirs = is_array($template->template_dir) ? $template->template_dir : [$template->template_dir]; foreach ($dirs as $dir) { - foreach (array("$dir/$path/$eventID/$img", "$dir/$path/$img") as $imgFile) { + foreach (["$dir/$path/$eventID/$img", "$dir/$path/$img"] as $imgFile) { if (file_exists($imgFile)) { return $imgFile; } @@ -147,15 +147,15 @@ public function printBackground($img = FALSE) { $x = $this->pdf->GetAbsX(); $y = $this->pdf->GetY(); if ($this->debug) { - $this->pdf->Rect($x, $y, $this->pdf->width, $this->pdf->height, 'D', array( - 'all' => array( + $this->pdf->Rect($x, $y, $this->pdf->width, $this->pdf->height, 'D', [ + 'all' => [ 'width' => 1, 'cap' => 'round', 'join' => 'round', 'dash' => '2,10', - 'color' => array(255, 0, 0), - ), - )); + 'color' => [255, 0, 0], + ], + ]); } $img = $this->getImageFileName($this->event->id, $img); if ($img) { diff --git a/CRM/Event/Badge/Logo.php b/CRM/Event/Badge/Logo.php index b6ca8b1bf216..a397f838ab98 100644 --- a/CRM/Event/Badge/Logo.php +++ b/CRM/Event/Badge/Logo.php @@ -13,7 +13,7 @@ public function __construct() { $ph = 297; $h = 50; $w = 75; - $this->format = array( + $this->format = [ 'name' => 'Sigel 3C', 'paper-size' => 'A4', 'metric' => 'mm', @@ -26,7 +26,7 @@ public function __construct() { 'width' => $w, 'height' => $h, 'font-size' => 12, - ); + ]; $this->lMarginLogo = 20; $this->tMarginName = 20; // $this->setDebug (); @@ -39,13 +39,13 @@ public function generateLabel($participant) { $x = $this->pdf->GetAbsX(); $y = $this->pdf->GetY(); $this->printBackground(TRUE); - $this->pdf->SetLineStyle(array( + $this->pdf->SetLineStyle([ 'width' => 0.1, 'cap' => 'round', 'join' => 'round', 'dash' => '2,2', - 'color' => array(0, 0, 200), - )); + 'color' => [0, 0, 200], + ]); $this->pdf->SetFontSize(8); $this->pdf->MultiCell($this->pdf->width - $this->lMarginLogo, 0, $participant['event_title'], $this->border, "L", 0, 1, $x + $this->lMarginLogo, $y); diff --git a/CRM/Event/Badge/Logo5395.php b/CRM/Event/Badge/Logo5395.php index 411dfc74c59e..460b465c7042 100644 --- a/CRM/Event/Badge/Logo5395.php +++ b/CRM/Event/Badge/Logo5395.php @@ -13,7 +13,7 @@ public function __construct() { $ph = 297; $h = 59.2; $w = 85.7; - $this->format = array( + $this->format = [ 'name' => 'Avery 5395', 'paper-size' => 'A4', 'metric' => 'mm', @@ -26,7 +26,7 @@ public function __construct() { 'width' => $w, 'height' => $h, 'font-size' => 12, - ); + ]; $this->lMarginLogo = 20; $this->tMarginName = 20; // $this->setDebug (); @@ -39,13 +39,13 @@ public function generateLabel($participant) { $x = $this->pdf->GetAbsX(); $y = $this->pdf->GetY(); $this->printBackground(TRUE); - $this->pdf->SetLineStyle(array( + $this->pdf->SetLineStyle([ 'width' => 0.1, 'cap' => 'round', 'join' => 'round', 'dash' => '2,2', - 'color' => array(0, 0, 200), - )); + 'color' => [0, 0, 200], + ]); $this->pdf->SetFontSize(9); $this->pdf->MultiCell($this->pdf->width - $this->lMarginLogo, 0, $participant['event_title'], $this->border, "L", 0, 1, $x + $this->lMarginLogo, $y); diff --git a/CRM/Event/Badge/NameTent.php b/CRM/Event/Badge/NameTent.php index abfbc35a4460..33df180f6e66 100644 --- a/CRM/Event/Badge/NameTent.php +++ b/CRM/Event/Badge/NameTent.php @@ -49,7 +49,7 @@ public function __construct() { $this->tMargin = 0; $w = $pw - 2 * $this->lMargin; $h = $ph - 2 * $this->tMargin; - $this->format = array( + $this->format = [ 'name' => 'A4 horiz', 'paper-size' => 'A4', 'metric' => 'mm', @@ -62,7 +62,7 @@ public function __construct() { 'width' => $w, 'height' => $h, 'font-size' => 36, - ); + ]; // $this->setDebug (); } diff --git a/CRM/Event/Cart/BAO/Cart.php b/CRM/Event/Cart/BAO/Cart.php index 6477e6a9d2d7..e56a43ae9588 100644 --- a/CRM/Event/Cart/BAO/Cart.php +++ b/CRM/Event/Cart/BAO/Cart.php @@ -6,7 +6,7 @@ class CRM_Event_Cart_BAO_Cart extends CRM_Event_Cart_DAO_Cart { public $associations_loaded = FALSE; /* event_in_cart_id => $event_in_cart */ - public $events_in_carts = array(); + public $events_in_carts = []; /** * @param array $params @@ -32,10 +32,10 @@ public function add_event($event_id) { return $event_in_cart; } - $params = array( + $params = [ 'event_id' => $event_id, 'event_cart_id' => $this->id, - ); + ]; $event_in_cart = CRM_Event_Cart_BAO_EventInCart::create($params); $event_in_cart->load_associations($this); $this->events_in_carts[$event_in_cart->event_id] = $event_in_cart; @@ -81,7 +81,7 @@ public static function create($params) { * @return bool|CRM_Event_Cart_BAO_Cart */ public static function find_by_id($id) { - return self::find_by_params(array('id' => $id)); + return self::find_by_params(['id' => $id]); } /** @@ -127,12 +127,12 @@ public static function find_or_create_for_current_session() { } if ($cart === FALSE) { if (is_null($userID)) { - $cart = self::create(array()); + $cart = self::create([]); } else { $cart = self::find_uncompleted_by_user_id($userID); if ($cart === FALSE) { - $cart = self::create(array('user_id' => $userID)); + $cart = self::create(['user_id' => $userID]); } } $session->set('event_cart_id', $cart->id); @@ -146,7 +146,7 @@ public static function find_or_create_for_current_session() { * @return bool|CRM_Event_Cart_BAO_Cart */ public static function find_uncompleted_by_id($id) { - return self::find_by_params(array('id' => $id, 'completed' => 0)); + return self::find_by_params(['id' => $id, 'completed' => 0]); } /** @@ -155,7 +155,7 @@ public static function find_uncompleted_by_id($id) { * @return bool|CRM_Event_Cart_BAO_Cart */ public static function find_uncompleted_by_user_id($user_id) { - return self::find_by_params(array('user_id' => $user_id, 'completed' => 0)); + return self::find_by_params(['user_id' => $user_id, 'completed' => 0]); } /** @@ -163,7 +163,7 @@ public static function find_uncompleted_by_user_id($user_id) { */ public function get_main_events_in_carts() { //return CRM_Event_Cart_BAO_EventInCart::find_all_by_params( array('main_conference_event_id' - $all = array(); + $all = []; foreach ($this->events_in_carts as $event_in_cart) { if (!$event_in_cart->is_child_event()) { $all[] = $event_in_cart; @@ -178,7 +178,7 @@ public function get_main_events_in_carts() { * @return array */ public function get_events_in_carts_by_main_event_id($main_conference_event_id) { - $all = array(); + $all = []; if (!$main_conference_event_id) { return $all; } @@ -215,7 +215,7 @@ public static function compare_event_dates($event_in_cart_1, $event_in_cart_2) { * @return array */ public function get_subparticipants($main_participant) { - $subparticipants = array(); + $subparticipants = []; foreach ($this->events_in_carts as $event_in_cart) { if ($event_in_cart->is_child_event($main_participant->event_id)) { foreach ($event_in_cart->participants as $participant) { @@ -256,7 +256,7 @@ public function &get_event_in_cart_by_id($event_in_cart_id) { * @return array */ public function get_main_event_participants() { - $participants = array(); + $participants = []; foreach ($this->get_main_events_in_carts() as $event_in_cart) { $participants = array_merge($participants, $event_in_cart->participants); } @@ -321,7 +321,7 @@ public function get_participant_index_from_id($participant_id) { public static function retrieve(&$params, &$values) { $cart = self::find_by_params($params); if ($cart === FALSE) { - CRM_Core_Error::fatal(ts('Could not find cart matching %1', array(1 => var_export($params, TRUE)))); + CRM_Core_Error::fatal(ts('Could not find cart matching %1', [1 => var_export($params, TRUE)])); } CRM_Core_DAO::storeValues($cart, $values); return $values; @@ -332,10 +332,10 @@ public static function retrieve(&$params, &$values) { * @param int $from_cart_id */ public function adopt_participants($from_cart_id) { - $params = array( - 1 => array($this->id, 'Integer'), - 2 => array($from_cart_id, 'Integer'), - ); + $params = [ + 1 => [$this->id, 'Integer'], + 2 => [$from_cart_id, 'Integer'], + ]; $sql = "UPDATE civicrm_participant SET cart_id='%1' WHERE cart_id='%2'"; CRM_Core_DAO::executeQuery($sql, $params); diff --git a/CRM/Event/Cart/BAO/Conference.php b/CRM/Event/Cart/BAO/Conference.php index d332cfe70633..a9d9b38941c1 100644 --- a/CRM/Event/Cart/BAO/Conference.php +++ b/CRM/Event/Cart/BAO/Conference.php @@ -28,9 +28,9 @@ public static function get_participant_sessions($main_event_participant_id) { slot.weight, sub_event.start_date EOS; - $sql_args = array(1 => array($main_event_participant_id, 'Integer')); + $sql_args = [1 => [$main_event_participant_id, 'Integer']]; $dao = CRM_Core_DAO::executeQuery($sql, $sql_args); - $smarty_sessions = array(); + $smarty_sessions = []; while ($dao->fetch()) { $smarty_sessions[] = get_object_vars($dao); } diff --git a/CRM/Event/Cart/BAO/EventInCart.php b/CRM/Event/Cart/BAO/EventInCart.php index 05872c039564..aa33705627c0 100644 --- a/CRM/Event/Cart/BAO/EventInCart.php +++ b/CRM/Event/Cart/BAO/EventInCart.php @@ -8,7 +8,7 @@ class CRM_Event_Cart_BAO_EventInCart extends CRM_Event_Cart_DAO_EventInCart impl public $event; public $event_cart; public $location = NULL; - public $participants = array(); + public $participants = []; /** * Class constructor. @@ -55,10 +55,10 @@ public static function create(&$params) { */ public function delete($useWhere = FALSE) { $this->load_associations(); - $contacts_to_delete = array(); + $contacts_to_delete = []; foreach ($this->participants as $participant) { - $defaults = array(); - $params = array('id' => $participant->contact_id); + $defaults = []; + $params = ['id' => $participant->contact_id]; $temporary_contact = CRM_Contact_BAO_Contact::retrieve($params, $defaults); if ($temporary_contact->is_deleted) { @@ -78,7 +78,7 @@ public function delete($useWhere = FALSE) { * @return array */ public static function find_all_by_event_cart_id($event_cart_id) { - return self::find_all_by_params(array('event_cart_id' => $event_cart_id)); + return self::find_all_by_params(['event_cart_id' => $event_cart_id]); } /** @@ -89,7 +89,7 @@ public static function find_all_by_event_cart_id($event_cart_id) { public static function find_all_by_params($params) { $event_in_cart = new CRM_Event_Cart_BAO_EventInCart(); $event_in_cart->copyValues($params); - $result = array(); + $result = []; if ($event_in_cart->find()) { while ($event_in_cart->fetch()) { $result[$event_in_cart->event_id] = clone($event_in_cart); @@ -104,7 +104,7 @@ public static function find_all_by_params($params) { * @return bool|CRM_Event_Cart_BAO_EventInCart */ public static function find_by_id($id) { - return self::find_by_params(array('id' => $id)); + return self::find_by_params(['id' => $id]); } /** @@ -127,7 +127,7 @@ public static function find_by_params($params) { * @param int $contact_id */ public function remove_participant_by_contact_id($contact_id) { - $to_remove = array(); + $to_remove = []; foreach ($this->participants as $participant) { if ($participant->contact_id == $contact_id) { $to_remove[$participant->id] = 1; @@ -171,8 +171,8 @@ public function load_associations($event_cart = NULL) { return; } $this->assocations_loaded = TRUE; - $params = array('id' => $this->event_id); - $defaults = array(); + $params = ['id' => $this->event_id]; + $defaults = []; $this->event = CRM_Event_BAO_Event::retrieve($params, $defaults); if ($event_cart != NULL) { @@ -192,7 +192,7 @@ public function load_associations($event_cart = NULL) { public function load_location() { if ($this->location == NULL) { - $location_params = array('entity_id' => $this->event_id, 'entity_table' => 'civicrm_event'); + $location_params = ['entity_id' => $this->event_id, 'entity_table' => 'civicrm_event']; $this->location = CRM_Core_BAO_Location::getValues($location_params, TRUE); } } @@ -201,7 +201,7 @@ public function load_location() { * @return array */ public function not_waiting_participants() { - $result = array(); + $result = []; foreach ($this->participants as $participant) { if (!$participant->must_wait) { $result[] = $participant; @@ -231,7 +231,7 @@ public function num_waiting_participants() { * @return bool */ public function offsetExists($offset) { - return array_key_exists(array_merge($this->fields(), array('main_conference_event_id')), $offset); + return array_key_exists(array_merge($this->fields(), ['main_conference_event_id']), $offset); } /** @@ -270,7 +270,7 @@ public function offsetUnset($offset) { * @return array */ public function waiting_participants() { - $result = array(); + $result = []; foreach ($this->participants as $participant) { if ($participant->must_wait) { $result[] = $participant; @@ -290,18 +290,18 @@ public static function get_registration_link($event_id) { $event_in_cart = $cart->get_event_in_cart_by_event_id($event_id); if ($event_in_cart) { - return array( + return [ 'label' => ts("Remove from Cart"), 'path' => 'civicrm/event/remove_from_cart', 'query' => "reset=1&id={$event_id}", - ); + ]; } else { - return array( + return [ 'label' => ts("Add to Cart"), 'path' => 'civicrm/event/add_to_cart', 'query' => "reset=1&id={$event_id}", - ); + ]; } } diff --git a/CRM/Event/Cart/BAO/MerParticipant.php b/CRM/Event/Cart/BAO/MerParticipant.php index e80849616472..9717dea04b53 100644 --- a/CRM/Event/Cart/BAO/MerParticipant.php +++ b/CRM/Event/Cart/BAO/MerParticipant.php @@ -52,7 +52,7 @@ public function __construct($participant = NULL) { * @throws Exception */ public static function create(&$params) { - $participantParams = array( + $participantParams = [ 'id' => CRM_Utils_Array::value('id', $params), 'role_id' => self::get_attendee_role_id(), 'status_id' => self::get_pending_in_cart_status_id(), @@ -63,7 +63,7 @@ public static function create(&$params) { //'registered_by_id' => //'discount_amount' => //'fee_level' => $params['fee_level'], - ); + ]; $participant = CRM_Event_BAO_Participant::create($participantParams); if (is_a($participant, 'CRM_Core_Error')) { @@ -102,7 +102,7 @@ public static function find_all_by_cart_id($event_cart_id) { if ($event_cart_id == NULL) { return NULL; } - return self::find_all_by_params(array('cart_id' => $event_cart_id)); + return self::find_all_by_params(['cart_id' => $event_cart_id]); } /** @@ -115,7 +115,7 @@ public static function find_all_by_event_and_cart_id($event_id, $event_cart_id) if ($event_cart_id == NULL) { return NULL; } - return self::find_all_by_params(array('event_id' => $event_id, 'cart_id' => $event_cart_id)); + return self::find_all_by_params(['event_id' => $event_id, 'cart_id' => $event_cart_id]); } /** @@ -126,7 +126,7 @@ public static function find_all_by_event_and_cart_id($event_id, $event_cart_id) public static function find_all_by_params($params) { $participant = new CRM_Event_BAO_Participant(); $participant->copyValues($params); - $result = array(); + $result = []; if ($participant->find()) { while ($participant->fetch()) { $result[] = new CRM_Event_Cart_BAO_MerParticipant(clone($participant)); @@ -141,7 +141,7 @@ public static function find_all_by_params($params) { * @return mixed */ public static function get_by_id($id) { - $results = self::find_all_by_params(array('id' => $id)); + $results = self::find_all_by_params(['id' => $id]); return array_pop($results); } diff --git a/CRM/Event/Cart/Form/Cart.php b/CRM/Event/Cart/Form/Cart.php index 8b7fc363269b..6e16ac7a31a6 100644 --- a/CRM/Event/Cart/Form/Cart.php +++ b/CRM/Event/Cart/Form/Cart.php @@ -21,13 +21,13 @@ public function preProcess() { $this->assignBillingType(); - $event_titles = array(); + $event_titles = []; foreach ($this->cart->get_main_events_in_carts() as $event_in_cart) { $event_titles[] = $event_in_cart->event->title; } - $this->description = ts("Online Registration for %1", array(1 => implode(", ", $event_titles))); + $this->description = ts("Online Registration for %1", [1 => implode(", ", $event_titles)]); if (!isset($this->discounts)) { - $this->discounts = array(); + $this->discounts = []; } } @@ -47,11 +47,11 @@ public function stub_out_and_inherit() { foreach ($this->cart->get_main_events_in_carts() as $event_in_cart) { if (empty($event_in_cart->participants)) { - $participant_params = array( + $participant_params = [ 'cart_id' => $this->cart->id, 'event_id' => $event_in_cart->event_id, 'contact_id' => self::find_or_create_contact($this->getContactID()), - ); + ]; $participant = CRM_Event_Cart_BAO_MerParticipant::create($participant_params); $participant->save(); $event_in_cart->add_participant($participant); @@ -128,7 +128,7 @@ public function getContactID() { * @return mixed|null */ public static function find_contact($fields) { - return CRM_Contact_BAO_Contact::getFirstDuplicateContact($fields, 'Individual', 'Unsupervised', array(), FALSE); + return CRM_Contact_BAO_Contact::getFirstDuplicateContact($fields, 'Individual', 'Unsupervised', [], FALSE); } /** @@ -137,19 +137,19 @@ public static function find_contact($fields) { * * @return int|mixed|null */ - public static function find_or_create_contact($registeringContactID = NULL, $fields = array()) { + public static function find_or_create_contact($registeringContactID = NULL, $fields = []) { $contact_id = self::find_contact($fields); if ($contact_id) { return $contact_id; } - $contact_params = array( + $contact_params = [ 'email-Primary' => CRM_Utils_Array::value('email', $fields, NULL), 'first_name' => CRM_Utils_Array::value('first_name', $fields, NULL), 'last_name' => CRM_Utils_Array::value('last_name', $fields, NULL), 'is_deleted' => CRM_Utils_Array::value('is_deleted', $fields, TRUE), - ); - $no_fields = array(); + ]; + $no_fields = []; $contact_id = CRM_Contact_BAO_Contact::createProfileContact($contact_params, $no_fields, NULL); if (!$contact_id) { CRM_Core_Session::setStatus(ts("Could not create or match a contact with that email address. Please contact the webmaster."), '', 'error'); diff --git a/CRM/Event/Cart/Form/Checkout/ConferenceEvents.php b/CRM/Event/Cart/Form/Checkout/ConferenceEvents.php index f1299e3553cc..57e28b704550 100644 --- a/CRM/Event/Cart/Form/Checkout/ConferenceEvents.php +++ b/CRM/Event/Cart/Form/Checkout/ConferenceEvents.php @@ -5,13 +5,13 @@ */ class CRM_Event_Cart_Form_Checkout_ConferenceEvents extends CRM_Event_Cart_Form_Cart { public $conference_event = NULL; - public $events_by_slot = array(); + public $events_by_slot = []; public $main_participant = NULL; public $contact_id = NULL; public function preProcess() { parent::preProcess(); - $matches = array(); + $matches = []; preg_match("/.*_(\d+)_(\d+)/", $this->getAttribute('name'), $matches); $event_id = $matches[1]; $participant_id = $matches[2]; @@ -43,7 +43,7 @@ public function preProcess() { $events->query($query); while ($events->fetch()) { if (!array_key_exists($events->slot_label, $this->events_by_slot)) { - $this->events_by_slot[$events->slot_label] = array(); + $this->events_by_slot[$events->slot_label] = []; } $this->events_by_slot[$events->slot_label][] = clone($events); } @@ -55,13 +55,13 @@ public function buildQuickForm() { //jquery_ui_add('ui.dialog'); $slot_index = -1; - $slot_fields = array(); - $session_options = array(); - $defaults = array(); + $slot_fields = []; + $session_options = []; + $defaults = []; $previous_event_choices = $this->cart->get_subparticipants($this->main_participant); foreach ($this->events_by_slot as $slot_name => $events) { $slot_index++; - $slot_buttons = array(); + $slot_buttons = []; $group_name = "slot_$slot_index"; foreach ($events as $event) { $seats_available = $this->checkEventCapacity($event->id); @@ -70,12 +70,12 @@ public function buildQuickForm() { $slot_buttons[] = $radio; $event_description = ($event_is_full ? $event->event_full_text . "

    " : '') . $event->description; - $session_options[$radio->getAttribute('id')] = array( + $session_options[$radio->getAttribute('id')] = [ 'session_title' => $event->title, 'session_description' => $event_description, 'session_full' => $event_is_full, 'event_id' => $event->id, - ); + ]; foreach ($previous_event_choices as $choice) { if ($choice->event_id == $event->id) { $defaults[$group_name] = $event->id; @@ -95,18 +95,18 @@ public function buildQuickForm() { $this->assign('slot_fields', $slot_fields); $this->assign('session_options', json_encode($session_options)); - $buttons = array(); - $buttons[] = array( + $buttons = []; + $buttons[] = [ 'name' => ts('Go Back'), 'spacing' => '    ', 'type' => 'back', - ); - $buttons[] = array( + ]; + $buttons[] = [ 'isDefault' => TRUE, 'name' => ts('Continue'), 'spacing' => '                  ', 'type' => 'next', - ); + ]; $this->addButtons($buttons); } @@ -134,7 +134,7 @@ public function postProcess() { } $event_in_cart = $this->cart->add_event($session_event_id); - $values = array(); + $values = []; CRM_Core_DAO::storeValues($this->main_participant, $values); $values['id'] = NULL; $values['event_id'] = $event_in_cart->event_id; diff --git a/CRM/Event/Cart/Form/Checkout/ParticipantsAndPrices.php b/CRM/Event/Cart/Form/Checkout/ParticipantsAndPrices.php index c47306a84049..35722587e93d 100644 --- a/CRM/Event/Cart/Form/Checkout/ParticipantsAndPrices.php +++ b/CRM/Event/Cart/Form/Checkout/ParticipantsAndPrices.php @@ -24,7 +24,7 @@ public function preProcess() { * Build quick form. */ public function buildQuickForm() { - $this->price_fields_for_event = array(); + $this->price_fields_for_event = []; foreach ($this->cart->get_main_event_participants() as $participant) { $form = new CRM_Event_Cart_Form_MerParticipant($participant); $form->appendQuickForm($this); @@ -37,20 +37,20 @@ public function buildQuickForm() { $this->assign('events_in_carts', $this->cart->get_main_events_in_carts()); $this->assign('price_fields_for_event', $this->price_fields_for_event); $this->addButtons( - array( - array( + [ + [ 'type' => 'upload', 'name' => ts('Continue'), 'spacing' => '         ', 'isDefault' => TRUE, - ), - ) + ], + ] ); if ($this->cid) { - $params = array('id' => $this->cid); + $params = ['id' => $this->cid]; $contact = CRM_Contact_BAO_Contact::retrieve($params, $defaults); - $contact_values = array(); + $contact_values = []; CRM_Core_DAO::storeValues($contact, $contact_values); $this->assign('contact', $contact_values); } @@ -81,7 +81,7 @@ public static function primary_email_from_contact($contact) { * @return array */ public function build_price_options($event) { - $price_fields_for_event = array(); + $price_fields_for_event = []; $base_field_name = "event_{$event->id}_amount"; $price_set_id = CRM_Price_BAO_PriceSet::getFor('civicrm_event', $event->id); //CRM-14492 display admin fields only if user is admin @@ -128,7 +128,7 @@ public function validate() { $priceField->price_set_id = $price_set_id; $priceField->find(); - $check = array(); + $check = []; while ($priceField->fetch()) { if (!empty($fields["event_{$event_in_cart->event_id}_price_{$priceField->id}"])) { @@ -141,7 +141,7 @@ public function validate() { $this->_errors['_qf_default'] = ts("Select at least one option from Price Levels."); } - $lineItem = array(); + $lineItem = []; if (is_array($this->_values['fee']['fields'])) { CRM_Price_BAO_PriceSet::processAmount($this->_values['fee']['fields'], $fields, $lineItem); //XXX total... @@ -165,11 +165,11 @@ public function validate() { while ($participant->fetch()) { if (array_key_exists($participant->status_id, $statusTypes)) { $form = $mer_participant->get_form(); - $this->_errors[$form->html_field_name('email')] = ts("The participant %1 is already registered for %2 (%3).", array( + $this->_errors[$form->html_field_name('email')] = ts("The participant %1 is already registered for %2 (%3).", [ 1 => $participant_fields['email'], 2 => $event_in_cart->event->title, 3 => $event_in_cart->event->start_date, - )); + ]); } } } @@ -186,7 +186,7 @@ public function validate() { public function setDefaultValues() { $this->loadCart(); - $defaults = array(); + $defaults = []; foreach ($this->cart->get_main_event_participants() as $participant) { $form = $participant->get_form(); if (empty($participant->email) @@ -194,8 +194,8 @@ public function setDefaultValues() { && ($participant->get_participant_index() == 1) && ($this->cid != 0) ) { - $defaults = array(); - $params = array('id' => $this->cid); + $defaults = []; + $params = ['id' => $this->cid]; $contact = CRM_Contact_BAO_Contact::retrieve($params, $defaults); $participant->contact_id = $this->cid; $participant->save(); @@ -246,7 +246,7 @@ public function postProcess() { return; } // XXX de facto primary key - $email_to_contact_id = array(); + $email_to_contact_id = []; foreach ($this->_submitValues['event'] as $event_id => $participants) { foreach ($participants['participant'] as $participant_id => $fields) { if (array_key_exists($fields['email'], $email_to_contact_id)) { @@ -259,8 +259,8 @@ public function postProcess() { $participant = $this->cart->get_event_in_cart_by_event_id($event_id)->get_participant_by_id($participant_id); if ($participant->contact_id && $contact_id != $participant->contact_id) { - $defaults = array(); - $params = array('id' => $participant->contact_id); + $defaults = []; + $params = ['id' => $participant->contact_id]; $temporary_contact = CRM_Contact_BAO_Contact::retrieve($params, $defaults); foreach ($this->cart->get_subparticipants($participant) as $subparticipant) { @@ -280,14 +280,14 @@ public function postProcess() { } //TODO security check that participant ids are already in this cart - $participant_params = array( + $participant_params = [ 'id' => $participant_id, 'cart_id' => $this->cart->id, 'event_id' => $event_id, 'contact_id' => $contact_id, //'registered_by_id' => $this->cart->user_id, 'email' => $fields['email'], - ); + ]; $participant = new CRM_Event_Cart_BAO_MerParticipant($participant_params); $participant->save(); $this->cart->add_participant_to_cart($participant); diff --git a/CRM/Event/Cart/Form/Checkout/Payment.php b/CRM/Event/Cart/Form/Checkout/Payment.php index a1a2e850188b..d6906fd94ce6 100644 --- a/CRM/Event/Cart/Form/Checkout/Payment.php +++ b/CRM/Event/Cart/Form/Checkout/Payment.php @@ -8,7 +8,7 @@ class CRM_Event_Cart_Form_Checkout_Payment extends CRM_Event_Cart_Form_Cart { public $financial_type_id; public $description; public $line_items; - public $_fields = array(); + public $_fields = []; public $_paymentProcessor; public $total; public $sub_total; @@ -31,7 +31,7 @@ public function registerParticipant($params, &$participant, $event) { // handle register date CRM-4320 $registerDate = date('YmdHis'); - $participantParams = array( + $participantParams = [ 'id' => $participant->id, 'event_id' => $event->id, 'register_date' => $registerDate, @@ -42,7 +42,7 @@ public function registerParticipant($params, &$participant, $event) { //XXX why is this a ref to participant and not contact?: //'registered_by_id' => $this->payer_contact_id, 'fee_currency' => CRM_Utils_Array::value('currencyID', $params), - ); + ]; if ($participant->must_wait) { $participant_status = 'On waitlist'; @@ -69,11 +69,11 @@ public function registerParticipant($params, &$participant, $event) { if (self::is_administrator()) { if (!empty($params['note'])) { - $note_params = array( + $note_params = [ 'participant_id' => $participant->id, 'contact_id' => self::getContactID(), 'note' => $params['note'], - ); + ]; CRM_Event_BAO_Participant::update_note($note_params); } } @@ -82,48 +82,48 @@ public function registerParticipant($params, &$participant, $event) { $participant->save(); if (!empty($params['contributionID'])) { - $payment_params = array( + $payment_params = [ 'participant_id' => $participant->id, 'contribution_id' => $params['contributionID'], - ); + ]; CRM_Event_BAO_ParticipantPayment::create($payment_params); } $transaction->commit(); - $event_values = array(); + $event_values = []; CRM_Core_DAO::storeValues($event, $event_values); - $location = array(); + $location = []; if (CRM_Utils_Array::value('is_show_location', $event_values) == 1) { - $locationParams = array( + $locationParams = [ 'entity_id' => $participant->event_id, 'entity_table' => 'civicrm_event', - ); + ]; $location = CRM_Core_BAO_Location::getValues($locationParams, TRUE); CRM_Core_BAO_Address::fixAddress($location['address'][1]); } list($pre_id, $post_id) = CRM_Event_Cart_Form_MerParticipant::get_profile_groups($participant->event_id); - $payer_values = array( + $payer_values = [ 'email' => '', 'name' => '', - ); + ]; if ($this->payer_contact_id) { $payer_contact_details = CRM_Contact_BAO_Contact::getContactDetails($this->payer_contact_id); - $payer_values = array( + $payer_values = [ 'email' => $payer_contact_details[1], 'name' => $payer_contact_details[0], - ); + ]; } - $values = array( - 'params' => array($participant->id => $participantParams), + $values = [ + 'params' => [$participant->id => $participantParams], 'event' => $event_values, 'location' => $location, 'custom_pre_id' => $pre_id, 'custom_post_id' => $post_id, 'payer' => $payer_values, - ); + ]; CRM_Event_BAO_Event::sendMail($participant->contact_id, $values, $participant->id); return $participant; @@ -182,7 +182,7 @@ public function buildPaymentFields() { */ public function buildQuickForm() { - $this->line_items = array(); + $this->line_items = []; $this->sub_total = 0; $this->_price_values = $this->getValuesForPage('ParticipantsAndPrices'); @@ -200,18 +200,18 @@ public function buildQuickForm() { $this->assign('line_items', $this->line_items); $this->assign('sub_total', $this->sub_total); $this->assign('total', $this->total); - $buttons = array(); - $buttons[] = array( + $buttons = []; + $buttons[] = [ 'name' => ts('Go Back'), 'spacing' => '    ', 'type' => 'back', - ); - $buttons[] = array( + ]; + $buttons[] = [ 'isDefault' => TRUE, 'name' => ts('Complete Transaction'), 'spacing' => '                  ', 'type' => 'next', - ); + ]; if ($this->total) { $this->add('text', 'billing_contact_email', 'Billing Email', '', TRUE); @@ -219,22 +219,22 @@ public function buildQuickForm() { } if (self::is_administrator()) { $this->add('textarea', 'note', 'Note'); - $this->add('text', 'source', 'Source', array('size' => 80)); - $instruments = array(); + $this->add('text', 'source', 'Source', ['size' => 80]); + $instruments = []; CRM_Core_OptionGroup::getAssoc('payment_instrument', $instruments, TRUE); - $options = array(); + $options = []; foreach ($instruments as $type) { $options[] = $this->createElement('radio', NULL, '', $type['label'], $type['value']); } $this->addGroup($options, 'payment_type', ts("Alternative Payment Type")); - $this->add('text', 'check_number', ts('Check No.'), array('size' => 20)); + $this->add('text', 'check_number', ts('Check No.'), ['size' => 20]); $this->addElement('checkbox', 'is_pending', ts('Create a pending registration')); $this->assign('administrator', TRUE); } $this->addButtons($buttons); - $this->addFormRule(array('CRM_Event_Cart_Form_Checkout_Payment', 'formRule'), $this); + $this->addFormRule(['CRM_Event_Cart_Form_Checkout_Payment', 'formRule'], $this); if ($this->payment_required) { $this->buildPaymentFields(); @@ -252,7 +252,7 @@ public function process_event_line_item(&$event_in_cart, $class = NULL) { $price_set_id = CRM_Price_BAO_PriceSet::getFor("civicrm_event", $event_in_cart->event_id); $amount_level = NULL; if ($price_set_id) { - $event_price_values = array(); + $event_price_values = []; foreach ($this->_price_values as $key => $value) { if (preg_match("/event_{$event_in_cart->event_id}_(price.*)/", $key, $matches)) { $event_price_values[$matches[1]] = $value; @@ -260,7 +260,7 @@ public function process_event_line_item(&$event_in_cart, $class = NULL) { } $price_sets = CRM_Price_BAO_PriceSet::getSetDetail($price_set_id, TRUE); $price_set = $price_sets[$price_set_id]; - $price_set_amount = array(); + $price_set_amount = []; CRM_Price_BAO_PriceSet::processAmount($price_set['fields'], $event_price_values, $price_set_amount); $discountCode = $this->_price_values['discountcode']; if (!empty($discountCode)) { @@ -299,21 +299,21 @@ public function process_event_line_item(&$event_in_cart, $class = NULL) { public function add_line_item($event_in_cart, $class = NULL) { $amount = 0; $cost = 0; - $not_waiting_participants = array(); + $not_waiting_participants = []; foreach ($event_in_cart->not_waiting_participants() as $participant) { $amount += $participant->cost; $cost = max($cost, $participant->cost); - $not_waiting_participants[] = array( + $not_waiting_participants[] = [ 'display_name' => CRM_Contact_BAO_Contact::displayName($participant->contact_id), - ); + ]; } - $waiting_participants = array(); + $waiting_participants = []; foreach ($event_in_cart->waiting_participants() as $participant) { - $waiting_participants[] = array( + $waiting_participants[] = [ 'display_name' => CRM_Contact_BAO_Contact::displayName($participant->contact_id), - ); + ]; } - $this->line_items[] = array( + $this->line_items[] = [ 'amount' => $amount, 'cost' => $cost, 'event' => $event_in_cart->event, @@ -322,7 +322,7 @@ public function add_line_item($event_in_cart, $class = NULL) { 'num_waiting_participants' => count($waiting_participants), 'waiting_participants' => $waiting_participants, 'class' => $class, - ); + ]; $this->sub_total += $amount; } @@ -344,11 +344,11 @@ public function emailReceipt($events_in_cart, $params) { $country->find(); $country->fetch(); foreach ($this->line_items as & $line_item) { - $location_params = array('entity_id' => $line_item['event']->id, 'entity_table' => 'civicrm_event'); + $location_params = ['entity_id' => $line_item['event']->id, 'entity_table' => 'civicrm_event']; $line_item['location'] = CRM_Core_BAO_Location::getValues($location_params, TRUE); CRM_Core_BAO_Address::fixAddress($line_item['location']['address'][1]); } - $send_template_params = array( + $send_template_params = [ 'table' => 'civicrm_msg_template', 'contactId' => $this->payer_contact_id, 'from' => CRM_Core_BAO_Domain::getNameAndEmail(TRUE, TRUE), @@ -356,7 +356,7 @@ public function emailReceipt($events_in_cart, $params) { 'isTest' => FALSE, 'toEmail' => $contact_details[1], 'toName' => $contact_details[0], - 'tplParams' => array( + 'tplParams' => [ 'billing_name' => "{$params['billing_first_name']} {$params['billing_last_name']}", 'billing_city' => $params["billing_city-{$this->_bltID}"], 'billing_country' => $country->name, @@ -376,11 +376,11 @@ public function emailReceipt($events_in_cart, $params) { 'transaction_date' => $params['trxn_date'], 'is_pay_later' => $this->is_pay_later, 'pay_later_receipt' => $this->pay_later_receipt, - ), + ], 'valueName' => 'event_registration_receipt', 'PDFFilename' => ts('confirmation') . '.pdf', - ); - $template_params_to_copy = array( + ]; + $template_params_to_copy = [ 'billing_name', 'billing_city', 'billing_country', @@ -390,7 +390,7 @@ public function emailReceipt($events_in_cart, $params) { 'credit_card_exp_date', 'credit_card_type', 'credit_card_number', - ); + ]; foreach ($template_params_to_copy as $template_param_to_copy) { $this->set($template_param_to_copy, $send_template_params['tplParams'][$template_param_to_copy]); } @@ -408,7 +408,7 @@ public function emailReceipt($events_in_cart, $params) { * @return array|bool */ public static function formRule($fields, $files, $self) { - $errors = array(); + $errors = []; if ($self->payment_required && empty($self->_submitValues['is_pay_later'])) { CRM_Core_Form::validateMandatoryFields($self->_fields, $fields, $errors); @@ -457,8 +457,8 @@ public function postProcess() { $main_participants = $this->cart->get_main_event_participants(); foreach ($main_participants as $participant) { - $defaults = array(); - $ids = array('contact_id' => $participant->contact_id); + $defaults = []; + $ids = ['contact_id' => $participant->contact_id]; $contact = CRM_Contact_BAO_Contact::retrieve($ids, $defaults); $contact->is_deleted = 0; $contact->save(); @@ -466,18 +466,18 @@ public function postProcess() { $trxn_prefix = 'VR'; if (array_key_exists('billing_contact_email', $params)) { - $this->payer_contact_id = self::find_or_create_contact($this->getContactID(), array( + $this->payer_contact_id = self::find_or_create_contact($this->getContactID(), [ 'email' => $params['billing_contact_email'], 'first_name' => $params['billing_first_name'], 'last_name' => $params['billing_last_name'], 'is_deleted' => FALSE, - )); + ]); $ctype = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->payer_contact_id, 'contact_type' ); - $billing_fields = array( + $billing_fields = [ "billing_first_name" => 1, "billing_middle_name" => 1, "billing_last_name" => 1, @@ -488,7 +488,7 @@ public function postProcess() { "billing_country_id-{$this->_bltID}" => 1, "address_name-{$this->_bltID}" => 1, "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); @@ -547,7 +547,7 @@ public function postProcess() { // n.b. we need to process the subparticipants before main event // participants so that session attendance can be included in the email $main_participants = $this->cart->get_main_event_participants(); - $this->all_participants = array(); + $this->all_participants = []; foreach ($main_participants as $main_participant) { $this->all_participants = array_merge($this->all_participants, $this->cart->get_subparticipants($main_participant)); } @@ -614,11 +614,11 @@ public function make_payment(&$params) { CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/event/cart_checkout', "_qf_Payment_display=1&qfKey={$this->controller->_key}", TRUE, NULL, FALSE)); } - $trxnDetails = array( + $trxnDetails = [ 'trxn_id' => $result['trxn_id'], 'trxn_date' => $result['now'], 'currency' => CRM_Utils_Array::value('currencyID', $result), - ); + ]; return $trxnDetails; } @@ -647,7 +647,7 @@ public function record_contribution(&$mer_participant, &$params, $event) { $payer = $params['participant_contact_id']; } - $contribParams = array( + $contribParams = [ 'contact_id' => $payer, 'financial_type_id' => $params['financial_type_id'], 'receive_date' => $params['now'], @@ -663,7 +663,7 @@ public function record_contribution(&$mer_participant, &$params, $event) { 'payment_instrument_id' => $params['payment_instrument_id'], 'check_number' => CRM_Utils_Array::value('check_number', $params), 'skipLineItem' => 1, - ); + ]; if (is_array($this->_paymentProcessor)) { $contribParams['payment_processor'] = $this->_paymentProcessor['id']; @@ -680,9 +680,9 @@ public function record_contribution(&$mer_participant, &$params, $event) { * Save data to session. */ public function saveDataToSession() { - $session_line_items = array(); + $session_line_items = []; foreach ($this->line_items as $line_item) { - $session_line_item = array(); + $session_line_item = []; $session_line_item['amount'] = $line_item['amount']; $session_line_item['cost'] = $line_item['cost']; $session_line_item['event_id'] = $line_item['event']->id; @@ -713,7 +713,7 @@ public function setDefaultValues() { $defaults["billing_country_id-{$this->_bltID}"] = $default_country->id; if (self::getContactID() && !self::is_administrator()) { - $params = array('id' => self::getContactID()); + $params = ['id' => self::getContactID()]; $contact = CRM_Contact_BAO_Contact::retrieve($params, $defaults); foreach ($contact->email as $email) { @@ -761,7 +761,7 @@ public function setDefaultValues() { */ protected function apply_discount($discountCode, &$price_set_amount, &$cost, $event_id) { //need better way to determine if cividiscount installed - $autoDiscount = array(); + $autoDiscount = []; $sql = "select is_active from civicrm_extension where name like 'CiviDiscount%'"; $dao = CRM_Core_DAO::executeQuery($sql, ''); while ($dao->fetch()) { diff --git a/CRM/Event/Cart/Form/Checkout/ThankYou.php b/CRM/Event/Cart/Form/Checkout/ThankYou.php index 0b1b8d10b42c..991e3724e99e 100644 --- a/CRM/Event/Cart/Form/Checkout/ThankYou.php +++ b/CRM/Event/Cart/Form/Checkout/ThankYou.php @@ -15,17 +15,17 @@ public function buildLineItems() { foreach ($line_items as $line_item) { $event_in_cart = $this->cart->get_event_in_cart_by_event_id($line_item['event_id']); - $not_waiting_participants = array(); + $not_waiting_participants = []; foreach ($event_in_cart->not_waiting_participants() as $participant) { - $not_waiting_participants[] = array( + $not_waiting_participants[] = [ 'display_name' => CRM_Contact_BAO_Contact::displayName($participant->contact_id), - ); + ]; } - $waiting_participants = array(); + $waiting_participants = []; foreach ($event_in_cart->waiting_participants() as $participant) { - $waiting_participants[] = array( + $waiting_participants[] = [ 'display_name' => CRM_Contact_BAO_Contact::displayName($participant->contact_id), - ); + ]; } $line_item['event'] = $event_in_cart->event; @@ -43,9 +43,9 @@ public function buildLineItems() { } public function buildQuickForm() { - $defaults = array(); - $ids = array(); - $template_params_to_copy = array( + $defaults = []; + $ids = []; + $template_params_to_copy = [ 'billing_name', 'billing_city', 'billing_country', @@ -55,7 +55,7 @@ public function buildQuickForm() { 'credit_card_exp_date', 'credit_card_type', 'credit_card_number', - ); + ]; foreach ($template_params_to_copy as $template_param_to_copy) { $this->assign($template_param_to_copy, $this->get($template_param_to_copy)); } diff --git a/CRM/Event/Cart/Form/MerParticipant.php b/CRM/Event/Cart/Form/MerParticipant.php index b618e7886023..b8340e44f501 100644 --- a/CRM/Event/Cart/Form/MerParticipant.php +++ b/CRM/Event/Cart/Form/MerParticipant.php @@ -19,7 +19,7 @@ public function __construct($participant) { * @param CRM_Core_Form $form */ public function appendQuickForm(&$form) { - $textarea_size = array('size' => 30, 'maxlength' => 60); + $textarea_size = ['size' => 30, 'maxlength' => 60]; $form->add('text', $this->email_field_name(), ts('Email Address'), $textarea_size, TRUE); list( @@ -33,12 +33,12 @@ public function appendQuickForm(&$form) { foreach ($custom_fields_post as $key => $field) { CRM_Core_BAO_UFGroup::buildProfile($form, $field, CRM_Profile_Form::MODE_CREATE, $this->participant->id); } - $custom = CRM_Utils_Array::value('custom', $form->getTemplate()->_tpl_vars, array()); - $form->assign('custom', array_merge($custom, array( + $custom = CRM_Utils_Array::value('custom', $form->getTemplate()->_tpl_vars, []); + $form->assign('custom', array_merge($custom, [ $this->html_field_name('customPre') => $custom_fields_pre, $this->html_field_name('customPost') => $custom_fields_post, $this->html_field_name('number') => $this->name(), - ))); + ])); } /** @@ -47,11 +47,11 @@ public function appendQuickForm(&$form) { * @return array */ public static function get_profile_groups($event_id) { - $ufJoinParams = array( + $ufJoinParams = [ 'entity_table' => 'civicrm_event', 'module' => 'CiviEvent', 'entity_id' => $event_id, - ); + ]; $group_ids = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams); return $group_ids; } @@ -62,7 +62,7 @@ public static function get_profile_groups($event_id) { public function get_participant_custom_data_fields() { list($custom_pre_id, $custom_post_id) = self::get_profile_groups($this->participant->event_id); - $pre_fields = $post_fields = array(); + $pre_fields = $post_fields = []; if ($custom_pre_id && CRM_Core_BAO_UFGroup::filterUFGroups($custom_pre_id, $this->participant->contact_id)) { $pre_fields = CRM_Core_BAO_UFGroup::getFields($custom_pre_id, FALSE, CRM_Core_Action::ADD); } @@ -70,7 +70,7 @@ public function get_participant_custom_data_fields() { $post_fields = CRM_Core_BAO_UFGroup::getFields($custom_post_id, FALSE, CRM_Core_Action::ADD); } - return array($pre_fields, $post_fields); + return [$pre_fields, $post_fields]; } /** @@ -121,12 +121,12 @@ static public function get_form($participant) { * @return array */ public function setDefaultValues() { - $defaults = array( + $defaults = [ $this->html_field_name('email') => $this->participant->email, - ); + ]; list($custom_fields_pre, $custom_fields_post) = $this->get_participant_custom_data_fields($this->participant->event_id); $all_fields = $custom_fields_pre + $custom_fields_post; - $flat = array(); + $flat = []; CRM_Core_BAO_UFGroup::setProfileDefaults($this->participant->contact_id, $all_fields, $flat); foreach ($flat as $name => $field) { $defaults["field[{$this->participant->id}][{$name}]"] = $field; diff --git a/CRM/Event/Cart/Page/AddToCart.php b/CRM/Event/Cart/Page/AddToCart.php index 045d77dbc7ea..9b3d61554f45 100644 --- a/CRM/Event/Cart/Page/AddToCart.php +++ b/CRM/Event/Cart/Page/AddToCart.php @@ -21,10 +21,10 @@ public function run() { $event_in_cart = $cart->add_event($this->_id); $url = CRM_Utils_System::url('civicrm/event/view_cart'); - CRM_Utils_System::setUFMessage(ts("%1 has been added to your cart. View your cart.", array( + CRM_Utils_System::setUFMessage(ts("%1 has been added to your cart. View your cart.", [ 1 => $event_in_cart->event->title, 2 => $url, - ))); + ])); $transaction->commit(); diff --git a/CRM/Event/Cart/Page/CheckoutAJAX.php b/CRM/Event/Cart/Page/CheckoutAJAX.php index 73f0982923ab..fa12bcbc46a9 100644 --- a/CRM/Event/Cart/Page/CheckoutAJAX.php +++ b/CRM/Event/Cart/Page/CheckoutAJAX.php @@ -11,11 +11,11 @@ public function add_participant_to_cart() { $cart = CRM_Event_Cart_BAO_Cart::find_by_id($cart_id); - $params_array = array( + $params_array = [ 'cart_id' => $cart->id, 'contact_id' => CRM_Event_Cart_Form_Cart::find_or_create_contact(), 'event_id' => $event_id, - ); + ]; //XXX security? $participant = CRM_Event_Cart_BAO_MerParticipant::create($params_array); diff --git a/CRM/Event/Cart/Page/RemoveFromCart.php b/CRM/Event/Cart/Page/RemoveFromCart.php index b9d7efbec483..e25ebbd26bec 100644 --- a/CRM/Event/Cart/Page/RemoveFromCart.php +++ b/CRM/Event/Cart/Page/RemoveFromCart.php @@ -17,7 +17,7 @@ public function run() { $event_in_cart = $cart->get_event_in_cart_by_event_id($this->_id); $removed_event = $cart->remove_event_in_cart($event_in_cart->id); $removed_event_title = $removed_event->event->title; - CRM_Core_Session::setStatus(ts("%1 has been removed from your cart.", array(1 => $removed_event_title)), '', 'success'); + CRM_Core_Session::setStatus(ts("%1 has been removed from your cart.", [1 => $removed_event_title]), '', 'success'); $transaction->commit(); return CRM_Utils_System::redirect($_SERVER['HTTP_REFERER']); } diff --git a/CRM/Event/Cart/StateMachine/Checkout.php b/CRM/Event/Cart/StateMachine/Checkout.php index 337a68a8cb88..8ba98dc22d2c 100644 --- a/CRM/Event/Cart/StateMachine/Checkout.php +++ b/CRM/Event/Cart/StateMachine/Checkout.php @@ -17,7 +17,7 @@ public function __construct($controller, $action = CRM_Core_Action::NONE) { CRM_Core_Error::statusBounce(ts("You don't have any events in you cart. Please add some events."), CRM_Utils_System::url('civicrm/event')); } - $pages = array(); + $pages = []; $is_monetary = FALSE; $is_conference = FALSE; foreach ($cart->events_in_carts as $event_in_cart) { @@ -29,10 +29,10 @@ public function __construct($controller, $action = CRM_Core_Action::NONE) { foreach ($cart->events_in_carts as $event_in_cart) { if ($event_in_cart->is_parent_event()) { foreach ($event_in_cart->participants as $participant) { - $pages["CRM_Event_Cart_Form_Checkout_ConferenceEvents_{$event_in_cart->event_id}_{$participant->id}"] = array( + $pages["CRM_Event_Cart_Form_Checkout_ConferenceEvents_{$event_in_cart->event_id}_{$participant->id}"] = [ 'className' => 'CRM_Event_Cart_Form_Checkout_ConferenceEvents', 'title' => "Select {$event_in_cart->event->title} Events For {$participant->email}", - ); + ]; } } } diff --git a/CRM/Event/Form/EventFees.php b/CRM/Event/Form/EventFees.php index f4caf280f5ac..655a7b93b2f1 100644 --- a/CRM/Event/Form/EventFees.php +++ b/CRM/Event/Form/EventFees.php @@ -71,12 +71,12 @@ public static function preProcess(&$form) { * @return array */ public static function setDefaultValues(&$form) { - $defaults = array(); + $defaults = []; if ($form->_eventId) { //get receipt text and financial type - $returnProperities = array('confirm_email_text', 'financial_type_id', 'campaign_id', 'start_date'); - $details = array(); + $returnProperities = ['confirm_email_text', 'financial_type_id', 'campaign_id', 'start_date']; + $details = []; CRM_Core_DAO::commonRetrieveAll('CRM_Event_DAO_Event', 'id', $form->_eventId, $details, $returnProperities); if (!empty($details[$form->_eventId]['financial_type_id'])) { $defaults[$form->_pId]['financial_type_id'] = $details[$form->_eventId]['financial_type_id']; @@ -84,12 +84,12 @@ public static function setDefaultValues(&$form) { } if ($form->_pId) { - $ids = array(); - $params = array('id' => $form->_pId); + $ids = []; + $params = ['id' => $form->_pId]; CRM_Event_BAO_Participant::getValues($params, $defaults, $ids); if ($form->_action == CRM_Core_Action::UPDATE) { - $discounts = array(); + $discounts = []; if (!empty($form->_values['discount'])) { foreach ($form->_values['discount'] as $key => $value) { $value = current($value); @@ -173,11 +173,11 @@ public static function setDefaultValues(&$form) { if ($priceSetId) { // get price set default values, CRM-4090 if (in_array(get_class($form), - array( + [ 'CRM_Event_Form_Participant', 'CRM_Event_Form_Registration_Register', 'CRM_Event_Form_Registration_AdditionalParticipant', - ) + ] )) { $priceSetValues = self::setDefaultPriceSet($form->_pId, $form->_eventId); if (!empty($priceSetValues)) { @@ -224,13 +224,13 @@ public static function setDefaultValues(&$form) { $contribution = new CRM_Contribute_DAO_Contribution(); $contribution->id = $contriId; $contribution->find(TRUE); - foreach (array( + foreach ([ 'financial_type_id', 'payment_instrument_id', 'contribution_status_id', 'receive_date', 'total_amount', - ) as $f) { + ] as $f) { $defaults[$form->_pId][$f] = $contribution->$f; } } @@ -247,7 +247,7 @@ public static function setDefaultValues(&$form) { * @return array */ public static function setDefaultPriceSet($participantID, $eventID = NULL, $includeQtyZero = TRUE) { - $defaults = array(); + $defaults = []; if (!$eventID && $participantID) { $eventID = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Participant', $participantID, 'event_id'); } @@ -268,7 +268,7 @@ public static function setDefaultPriceSet($participantID, $eventID = NULL, $incl !CRM_Utils_System::isNull($lineItems[$participantID]) ) { - $priceFields = $htmlTypes = $optionValues = array(); + $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); @@ -338,7 +338,7 @@ public static function buildQuickForm(&$form) { // make sure this is for backoffice registration. if ($form->getName() == 'Participant') { $eventfullMsg = CRM_Event_BAO_Participant::eventFullMessage($form->_eventId, $form->_pId); - $form->addElement('hidden', 'hidden_eventFullMsg', $eventfullMsg, array('id' => 'hidden_eventFullMsg')); + $form->addElement('hidden', 'hidden_eventFullMsg', $eventfullMsg, ['id' => 'hidden_eventFullMsg']); } } @@ -352,14 +352,14 @@ public static function buildQuickForm(&$form) { } if ($form->_isPaidEvent) { - $params = array('id' => $form->_eventId); + $params = ['id' => $form->_eventId]; CRM_Event_BAO_Event::retrieve($params, $event); //retrieve custom information - $form->_values = array(); + $form->_values = []; CRM_Event_Form_Registration::initEventFee($form, $event['id']); CRM_Event_Form_Registration_Register::buildAmount($form, TRUE, $form->_discountId); - $lineItem = array(); + $lineItem = []; $invoiceSettings = Civi::settings()->get('contribution_invoice_settings'); $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings); $totalTaxAmount = 0; @@ -373,7 +373,7 @@ public static function buildQuickForm(&$form) { $form->assign('totalTaxAmount', $totalTaxAmount); } $form->assign('lineItem', empty($lineItem) ? FALSE : $lineItem); - $discounts = array(); + $discounts = []; if (!empty($form->_values['discount'])) { foreach ($form->_values['discount'] as $key => $value) { $value = current($value); @@ -382,11 +382,11 @@ public static function buildQuickForm(&$form) { $element = $form->add('select', 'discount_id', ts('Discount Set'), - array( + [ 0 => ts('- select -'), - ) + $discounts, + ] + $discounts, FALSE, - array('class' => "crm-select2") + ['class' => "crm-select2"] ); if ($form->_online) { @@ -404,7 +404,7 @@ public static function buildQuickForm(&$form) { CRM_Core_Payment_Form::buildPaymentForm($form, $form->_paymentProcessor, FALSE, TRUE, self::getDefaultPaymentInstrumentId()); if (!$form->_mode) { $form->addElement('checkbox', 'record_contribution', ts('Record Payment?'), NULL, - array('onclick' => "return showHideByValue('record_contribution','','payment_information','table-row','radio',false);") + ['onclick' => "return showHideByValue('record_contribution','','payment_information','table-row','radio',false);"] ); // Check permissions for financial type first if (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus()) { @@ -416,15 +416,15 @@ public static function buildQuickForm(&$form) { $form->add('select', 'financial_type_id', ts('Financial Type'), - array('' => ts('- select -')) + $financialTypes + ['' => ts('- select -')] + $financialTypes ); - $form->add('datepicker', 'receive_date', ts('Received'), array(), FALSE, array('time' => TRUE)); + $form->add('datepicker', 'receive_date', ts('Received'), [], FALSE, ['time' => TRUE]); $form->add('select', 'payment_instrument_id', ts('Payment Method'), - array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(), - FALSE, array('onChange' => "return showHideByValue('payment_instrument_id','4','checkNumber','table-row','select',false);") + ['' => ts('- select -')] + CRM_Contribute_PseudoConstant::paymentInstrument(), + FALSE, ['onChange' => "return showHideByValue('payment_instrument_id','4','checkNumber','table-row','select',false);"] ); // don't show transaction id in batch update mode $path = CRM_Utils_System::currentPath(); @@ -432,7 +432,7 @@ public static function buildQuickForm(&$form) { if ($path != 'civicrm/contact/search/basic') { $form->add('text', 'trxn_id', ts('Transaction ID')); $form->addRule('trxn_id', ts('Transaction ID already exists in Database.'), - 'objectExists', array('CRM_Contribute_DAO_Contribution', $form->_eventId, 'trxn_id') + 'objectExists', ['CRM_Contribute_DAO_Contribution', $form->_eventId, 'trxn_id'] ); $form->assign('showTransactionId', TRUE); } @@ -460,7 +460,7 @@ public static function buildQuickForm(&$form) { $form->addElement('checkbox', 'send_receipt', ts('Send Confirmation?'), NULL, - array('onclick' => "showHideByValue('send_receipt','','notice','table-row','radio',false); showHideByValue('send_receipt','','from-email','table-row','radio',false);") + ['onclick' => "showHideByValue('send_receipt','','notice','table-row','radio',false); showHideByValue('send_receipt','','from-email','table-row','radio',false);"] ); $form->add('select', 'from_email_address', ts('Receipt From'), $form->_fromEmails['from_email_id']); diff --git a/CRM/Event/Form/ManageEvent.php b/CRM/Event/Form/ManageEvent.php index 065f499237e3..08dedbe50987 100644 --- a/CRM/Event/Form/ManageEvent.php +++ b/CRM/Event/Form/ManageEvent.php @@ -120,7 +120,7 @@ public function preProcess() { } $this->_single = TRUE; - $params = array('id' => $this->_id); + $params = ['id' => $this->_id]; CRM_Event_BAO_Event::retrieve($params, $eventInfo); // its an update mode, do a permission check @@ -203,12 +203,12 @@ public function preProcess() { $ufGroups = CRM_Core_PseudoConstant::get('CRM_Core_DAO_UFField', 'uf_group_id'); $ufCreate = CRM_ACL_API::group(CRM_Core_Permission::CREATE, NULL, 'civicrm_uf_group', $ufGroups); $ufEdit = CRM_ACL_API::group(CRM_Core_Permission::EDIT, NULL, 'civicrm_uf_group', $ufGroups); - $checkPermission = array( - array( + $checkPermission = [ + [ 'administer CiviCRM', 'manage event profiles', - ), - ); + ], + ]; if (CRM_Core_Permission::check($checkPermission) || !empty($ufCreate) || !empty($ufEdit)) { $this->assign('perm', TRUE); } @@ -218,7 +218,7 @@ public function preProcess() { // Set Done button URL and breadcrumb. Templates go back to Manage Templates, // otherwise go to Manage Event for new event or ManageEventEdit if event if exists. - $breadCrumb = array(); + $breadCrumb = []; if (!$this->_isTemplate) { if ($this->_id) { $this->_doneUrl = CRM_Utils_System::url(CRM_Utils_System::currentPath(), @@ -229,22 +229,22 @@ public function preProcess() { $this->_doneUrl = CRM_Utils_System::url('civicrm/event/manage', 'reset=1' ); - $breadCrumb = array( - array( + $breadCrumb = [ + [ 'title' => ts('Manage Events'), 'url' => $this->_doneUrl, - ), - ); + ], + ]; } } else { $this->_doneUrl = CRM_Utils_System::url('civicrm/admin/eventTemplate', 'reset=1'); - $breadCrumb = array( - array( + $breadCrumb = [ + [ 'title' => ts('Manage Event Templates'), 'url' => $this->_doneUrl, - ), - ); + ], + ]; } CRM_Utils_System::appendBreadCrumb($breadCrumb); } @@ -255,15 +255,15 @@ public function preProcess() { * For edit/view mode the default values are retrieved from the database. */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; if (isset($this->_id)) { - $params = array('id' => $this->_id); + $params = ['id' => $this->_id]; CRM_Event_BAO_Event::retrieve($params, $defaults); $this->_campaignID = CRM_Utils_Array::value('campaign_id', $defaults); } elseif ($this->_templateId) { - $params = array('id' => $this->_templateId); + $params = ['id' => $this->_templateId]; CRM_Event_BAO_Event::retrieve($params, $defaults); $defaults['is_template'] = $this->_isTemplate; $defaults['template_id'] = $defaults['id']; @@ -303,44 +303,44 @@ public function buildQuickForm() { } if ($this->_single) { - $buttons = array( - array( + $buttons = [ + [ 'type' => 'upload', 'name' => ts('Save'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'upload', 'name' => ts('Save and Done'), 'spacing' => '                 ', 'subName' => 'done', - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ); + ], + ]; $this->addButtons($buttons); } else { - $buttons = array(); + $buttons = []; if (!$this->_first) { - $buttons[] = array( + $buttons[] = [ 'type' => 'back', 'name' => ts('Previous'), 'spacing' => '     ', - ); + ]; } - $buttons[] = array( + $buttons[] = [ 'type' => 'upload', 'name' => ts('Continue'), 'spacing' => '         ', 'isDefault' => TRUE, - ); - $buttons[] = array( + ]; + $buttons[] = [ 'type' => 'cancel', 'name' => ts('Cancel'), - ); + ]; $this->addButtons($buttons); } @@ -374,7 +374,7 @@ public function endPostProcess() { } CRM_Core_Session::setStatus(ts("'%1' information has been saved.", - array(1 => CRM_Utils_Array::value('title', CRM_Utils_Array::value($subPage, $this->get('tabHeader')), $className)) + [1 => CRM_Utils_Array::value('title', CRM_Utils_Array::value($subPage, $this->get('tabHeader')), $className)] ), ts('Saved'), 'success'); $config = CRM_Core_Config::singleton(); @@ -423,7 +423,7 @@ public function getTemplateFileName() { */ public static function addProfileEditScripts() { CRM_UF_Page_ProfileEditor::registerProfileScripts(); - CRM_UF_Page_ProfileEditor::registerSchemas(array('IndividualModel', 'ParticipantModel')); + CRM_UF_Page_ProfileEditor::registerSchemas(['IndividualModel', 'ParticipantModel']); } } diff --git a/CRM/Event/Form/ManageEvent/Conference.php b/CRM/Event/Form/ManageEvent/Conference.php index cd4b3e67e610..e03b13a756d4 100644 --- a/CRM/Event/Form/ManageEvent/Conference.php +++ b/CRM/Event/Form/ManageEvent/Conference.php @@ -50,17 +50,17 @@ public function buildQuickForm() { $this->add('select', 'slot_label_id', ts('Conference Slot'), - array( + [ '' => ts('- select -'), - ) + $slots, + ] + $slots, FALSE ); - $this->addEntityRef('parent_event_id', ts('Parent Event'), array( + $this->addEntityRef('parent_event_id', ts('Parent Event'), [ 'entity' => 'Event', 'placeholder' => ts('- any -'), - 'select' => array('minimumInputLength' => 0), - ) + 'select' => ['minimumInputLength' => 0], + ] ); parent::buildQuickForm(); diff --git a/CRM/Event/Form/ManageEvent/Delete.php b/CRM/Event/Form/ManageEvent/Delete.php index 52770c6cd1e7..9259d1d7b4fb 100644 --- a/CRM/Event/Form/ManageEvent/Delete.php +++ b/CRM/Event/Form/ManageEvent/Delete.php @@ -67,17 +67,17 @@ public function preProcess() { public function buildQuickForm() { $this->assign('title', $this->_title); - $buttons = array( - array( + $buttons = [ + [ 'type' => 'next', 'name' => $this->_isTemplate ? ts('Delete Event Template') : ts('Delete Event'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ); + ], + ]; $this->addButtons($buttons); } @@ -91,17 +91,17 @@ public function postProcess() { if ($participant->find()) { $searchURL = CRM_Utils_System::url('civicrm/event/search', 'reset=1'); CRM_Core_Session::setStatus(ts('This event cannot be deleted because there are participant records linked to it. If you want to delete this event, you must first find the participants linked to this event and delete them. You can use use CiviEvent >> Find Participants page .', - array(1 => $searchURL) + [1 => $searchURL] ), ts('Deletion Error'), 'error'); return; } CRM_Event_BAO_Event::del($this->_id); if ($this->_isTemplate) { - CRM_Core_Session::setStatus(ts("'%1' has been deleted.", array(1 => $this->_title)), ts('Template Deleted'), 'success'); + CRM_Core_Session::setStatus(ts("'%1' has been deleted.", [1 => $this->_title]), ts('Template Deleted'), 'success'); CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin/eventTemplate', 'reset=1')); } else { - CRM_Core_Session::setStatus(ts("'%1' has been deleted.", array(1 => $this->_title)), ts('Event Deleted'), 'success'); + CRM_Core_Session::setStatus(ts("'%1' has been deleted.", [1 => $this->_title]), ts('Event Deleted'), 'success'); } } diff --git a/CRM/Event/Form/ManageEvent/EventInfo.php b/CRM/Event/Form/ManageEvent/EventInfo.php index 6fc7fac1c264..c51030db06a1 100644 --- a/CRM/Event/Form/ManageEvent/EventInfo.php +++ b/CRM/Event/Form/ManageEvent/EventInfo.php @@ -139,11 +139,11 @@ public function buildQuickForm() { if ($this->_action & CRM_Core_Action::ADD) { $eventTemplates = CRM_Event_PseudoConstant::eventTemplates(); if (CRM_Utils_System::isNull($eventTemplates) && !$this->_isTemplate) { - $url = CRM_Utils_System::url('civicrm/admin/eventTemplate', array('reset' => 1)); - CRM_Core_Session::setStatus(ts('If you find that you are creating multiple events with similar settings, you may want to use the Event Templates feature to streamline your workflow.', array(1 => $url)), ts('Tip'), 'info'); + $url = CRM_Utils_System::url('civicrm/admin/eventTemplate', ['reset' => 1]); + CRM_Core_Session::setStatus(ts('If you find that you are creating multiple events with similar settings, you may want to use the Event Templates feature to streamline your workflow.', [1 => $url]), ts('Tip'), 'info'); } if (!CRM_Utils_System::isNull($eventTemplates)) { - $this->add('select', 'template_id', ts('From Template'), array('' => ts('- select -')) + $eventTemplates, FALSE, array('class' => 'crm-select2 huge')); + $this->add('select', 'template_id', ts('From Template'), ['' => ts('- select -')] + $eventTemplates, FALSE, ['class' => 'crm-select2 huge']); } // Make sure this form redirects properly $this->preventAjaxSubmit(); @@ -153,7 +153,7 @@ public function buildQuickForm() { $this->add('text', 'title', ts('Event Title'), $attributes['event_title'], !$this->_isTemplate); $this->addSelect('event_type_id', - array('onChange' => "CRM.buildCustomData( 'Event', this.value );"), + ['onChange' => "CRM.buildCustomData( 'Event', this.value );"], TRUE ); @@ -164,12 +164,12 @@ public function buildQuickForm() { } CRM_Campaign_BAO_Campaign::addCampaign($this, $campaignId); - $this->addSelect('default_role_id', array(), TRUE); + $this->addSelect('default_role_id', [], TRUE); - $this->addSelect('participant_listing_id', array('placeholder' => ts('Disabled'), 'option_url' => NULL)); + $this->addSelect('participant_listing_id', ['placeholder' => ts('Disabled'), 'option_url' => NULL]); $this->add('textarea', 'summary', ts('Event Summary'), $attributes['summary']); - $this->add('wysiwyg', 'description', ts('Complete Description'), $attributes['event_description'] + array('preset' => 'civievent')); + $this->add('wysiwyg', 'description', ts('Complete Description'), $attributes['event_description'] + ['preset' => 'civievent']); $this->addElement('checkbox', 'is_public', ts('Public Event')); $this->addElement('checkbox', 'is_share', ts('Allow sharing through social media?')); $this->addElement('checkbox', 'is_map', ts('Include Map to Event Location')); @@ -178,14 +178,14 @@ public function buildQuickForm() { $this->add('datepicker', 'end_date', ts('End'), [], FALSE, ['time' => TRUE]); $this->add('number', 'max_participants', ts('Max Number of Participants'), - array('onchange' => "if (this.value != '') {cj('#id-waitlist').show(); showHideByValue('has_waitlist','0','id-waitlist-text','table-row','radio',false); showHideByValue('has_waitlist','0','id-event_full','table-row','radio',true); return;} else {cj('#id-event_full, #id-waitlist, #id-waitlist-text').hide(); return;}") + ['onchange' => "if (this.value != '') {cj('#id-waitlist').show(); showHideByValue('has_waitlist','0','id-waitlist-text','table-row','radio',false); showHideByValue('has_waitlist','0','id-event_full','table-row','radio',true); return;} else {cj('#id-event_full, #id-waitlist, #id-waitlist-text').hide(); return;}"] ); $this->addRule('max_participants', ts('Max participants should be a positive number'), 'positiveInteger'); $participantStatuses = CRM_Event_PseudoConstant::participantStatus(); $waitlist = 0; if (in_array('On waitlist', $participantStatuses) and in_array('Pending from waitlist', $participantStatuses)) { - $this->addElement('checkbox', 'has_waitlist', ts('Offer a Waitlist?'), NULL, array('onclick' => "showHideByValue('has_waitlist','0','id-event_full','table-row','radio',true); showHideByValue('has_waitlist','0','id-waitlist-text','table-row','radio',false);")); + $this->addElement('checkbox', 'has_waitlist', ts('Offer a Waitlist?'), NULL, ['onclick' => "showHideByValue('has_waitlist','0','id-event_full','table-row','radio',true); showHideByValue('has_waitlist','0','id-waitlist-text','table-row','radio',false);"]); $this->add('textarea', 'waitlist_text', ts('Waitlist Message'), $attributes['waitlist_text']); $waitlist = 1; } @@ -195,7 +195,7 @@ public function buildQuickForm() { $this->addElement('checkbox', 'is_active', ts('Is this Event Active?')); - $this->addFormRule(array('CRM_Event_Form_ManageEvent_EventInfo', 'formRule')); + $this->addFormRule(['CRM_Event_Form_ManageEvent_EventInfo', 'formRule']); parent::buildQuickForm(); } @@ -209,7 +209,7 @@ public function buildQuickForm() { * list of errors to be posted back to the form */ public static function formRule($values) { - $errors = array(); + $errors = []; if (!empty($values['end_date']) && ($values['end_date'] < $values['start_date'])) { $errors['end_date'] = ts('End date should be after Start date.'); @@ -273,7 +273,7 @@ public function postProcess() { $url = 'civicrm/event/manage'; $urlParams = 'reset=1'; CRM_Core_Session::setStatus(ts("'%1' information has been saved.", - array(1 => $this->getTitle()) + [1 => $this->getTitle()] ), ts('Saved'), 'success'); } diff --git a/CRM/Event/Form/ManageEvent/Fee.php b/CRM/Event/Form/ManageEvent/Fee.php index c69627a46463..7c79b05846ca 100644 --- a/CRM/Event/Form/ManageEvent/Fee.php +++ b/CRM/Event/Form/ManageEvent/Fee.php @@ -72,10 +72,10 @@ public function setDefaultValues() { parent::setDefaultValues(); $eventId = $this->_id; - $params = array(); - $defaults = array(); + $params = []; + $defaults = []; if (isset($eventId)) { - $params = array('id' => $eventId); + $params = ['id' => $eventId]; } CRM_Event_BAO_Event::retrieve($params, $defaults); @@ -92,7 +92,7 @@ public function setDefaultValues() { if ($isQuick = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $priceSetId, 'is_quick_config')) { $this->assign('isQuick', $isQuick); $priceField = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', $priceSetId, 'id', 'price_set_id'); - $options = array(); + $options = []; $priceFieldOptions = CRM_Price_BAO_PriceFieldValue::getValues($priceField, $options, 'weight', TRUE); $defaults['price_field_id'] = $priceField; $countRow = 0; @@ -116,7 +116,7 @@ public function setDefaultValues() { $discountedEvent = CRM_Core_BAO_Discount::getOptionGroup($this->_id, 'civicrm_event'); if (!empty($discountedEvent)) { $defaults['is_discount'] = $i = 1; - $totalLables = $maxSize = $defaultDiscounts = array(); + $totalLables = $maxSize = $defaultDiscounts = []; foreach ($discountedEvent as $optionGroupId) { $defaults['discount_price_set'][] = $optionGroupId; $defaults["discount_name[$i]"] = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $optionGroupId, 'title'); @@ -244,7 +244,7 @@ public function buildQuickForm() { ts('Paid Event'), NULL, NULL, - array('onclick' => "return showHideByValue('is_monetary','0','event-fees','block','radio',false);") + ['onclick' => "return showHideByValue('is_monetary','0','event-fees','block','radio',false);"] ); //add currency element. @@ -256,7 +256,7 @@ public function buildQuickForm() { $this->addCheckBox('payment_processor', ts('Payment Processor'), array_flip($paymentProcessor), NULL, NULL, NULL, NULL, - array('  ', '  ', '  ', '
    ') + ['  ', '  ', '  ', '
    '] ); // financial type @@ -266,11 +266,11 @@ public function buildQuickForm() { } else { CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($financialTypes, CRM_Core_Action::ADD); - $this->addSelect('financial_type_id', array('context' => 'search', 'options' => $financialTypes)); + $this->addSelect('financial_type_id', ['context' => 'search', 'options' => $financialTypes]); } // add pay later options $this->addElement('checkbox', 'is_pay_later', ts('Enable Pay Later option?'), NULL, - array('onclick' => "return showHideByValue('is_pay_later','','payLaterOptions','block','radio',false);") + ['onclick' => "return showHideByValue('is_pay_later','','payLaterOptions','block','radio',false);"] ); $this->addElement('textarea', 'pay_later_text', ts('Pay Later Label'), CRM_Core_DAO::getAttribute('CRM_Event_DAO_Event', 'pay_later_text'), @@ -289,21 +289,21 @@ public function buildQuickForm() { $this->assign('price', TRUE); } $this->add('select', 'price_set_id', ts('Price Set'), - array( + [ '' => ts('- none -'), - ) + $price, - NULL, array('onchange' => "return showHideByValue('price_set_id', '', 'map-field', 'block', 'select', false);") + ] + $price, + NULL, ['onchange' => "return showHideByValue('price_set_id', '', 'map-field', 'block', 'select', false);"] ); - $default = array($this->createElement('radio', NULL, NULL, NULL, 0)); - $this->add('hidden', 'price_field_id', '', array('id' => 'price_field_id')); + $default = [$this->createElement('radio', NULL, NULL, NULL, 0)]; + $this->add('hidden', 'price_field_id', '', ['id' => 'price_field_id']); for ($i = 1; $i <= self::NUM_OPTION; $i++) { // label $this->add('text', "label[$i]", ts('Label'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'label')); - $this->add('hidden', "price_field_value[$i]", '', array('id' => "price_field_value[$i]")); + $this->add('hidden', "price_field_value[$i]", '', ['id' => "price_field_value[$i]"]); // value $this->add('text', "value[$i]", ts('Value'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'value')); - $this->addRule("value[$i]", ts('Please enter a valid money value for this field (e.g. %1).', array(1 => CRM_Utils_Money::format('99.99', ' '))), 'money'); + $this->addRule("value[$i]", ts('Please enter a valid money value for this field (e.g. %1).', [1 => CRM_Utils_Money::format('99.99', ' ')]), 'money'); // default $default[] = $this->createElement('radio', NULL, NULL, NULL, $i); @@ -312,14 +312,14 @@ public function buildQuickForm() { $this->addGroup($default, 'default'); $this->addElement('checkbox', 'is_discount', ts('Discounts by Signup Date?'), NULL, - array('onclick' => "warnDiscountDel(); return showHideByValue('is_discount','','discount','block','radio',false);") + ['onclick' => "warnDiscountDel(); return showHideByValue('is_discount','','discount','block','radio',false);"] ); $discountSection = $this->get('discountSection'); $this->assign('discountSection', $discountSection); // form fields of Discount sets - $defaultOption = array(); + $defaultOption = []; $_showHide = new CRM_Core_ShowHideBlocks('', ''); for ($i = 1; $i <= self::NUM_DISCOUNT; $i++) { @@ -364,13 +364,13 @@ public function buildQuickForm() { $this->add('text', 'discount_name[' . $i . ']', ts('Discount Name'), CRM_Core_DAO::getAttribute('CRM_Price_DAO_PriceSet', 'title') ); - $this->add('hidden', "discount_price_set[$i]", '', array('id' => "discount_price_set[$i]")); - $this->add('datepicker', 'discount_start_date[' . $i . ']', ts('Discount Start Date'), [], FALSE, array('time' => FALSE)); - $this->add('datepicker', 'discount_end_date[' . $i . ']', ts('Discount End Date'), [], FALSE, array('time' => FALSE)); + $this->add('hidden', "discount_price_set[$i]", '', ['id' => "discount_price_set[$i]"]); + $this->add('datepicker', 'discount_start_date[' . $i . ']', ts('Discount Start Date'), [], FALSE, ['time' => FALSE]); + $this->add('datepicker', 'discount_end_date[' . $i . ']', ts('Discount End Date'), [], FALSE, ['time' => FALSE]); } $_showHide->addToTemplate(); $this->addElement('submit', $this->getButtonName('submit'), ts('Add Discount Set to Fee Table'), - array('class' => 'crm-form-submit cancel') + ['class' => 'crm-form-submit cancel'] ); if (CRM_Contribute_BAO_Contribution::checkContributeSettings('deferred_revenue_enabled')) { $deferredFinancialType = CRM_Financial_BAO_FinancialAccount::getDeferredFinancialType(); @@ -384,7 +384,7 @@ public function buildQuickForm() { * Add local and global form rules. */ public function addRules() { - $this->addFormRule(array('CRM_Event_Form_ManageEvent_Fee', 'formRule')); + $this->addFormRule(['CRM_Event_Form_ManageEvent_Fee', 'formRule']); } /** @@ -397,7 +397,7 @@ public function addRules() { * list of errors to be posted back to the form */ public static function formRule($values) { - $errors = array(); + $errors = []; if (!empty($values['is_discount'])) { $occurDiscount = array_count_values($values['discount_name']); $countemptyrows = 0; @@ -434,7 +434,7 @@ public static function formRule($values) { foreach ($occurDiscount as $key => $value) { if ($value > 1 && $key <> '') { if ($key == $values['discount_name'][$i]) { - $errors['discount_name[' . $i . ']'] = ts('%1 is already used for Discount Name.', array(1 => $key)); + $errors['discount_name[' . $i . ']'] = ts('%1 is already used for Discount Name.', [1 => $key]); } } } @@ -482,7 +482,7 @@ public static function formRule($values) { if (empty($values['price_set_id'])) { //check fee label and amount $check = 0; - $optionKeys = array(); + $optionKeys = []; foreach ($values['label'] as $key => $val) { if (trim($val) && trim($values['value'][$key])) { $optionKeys[$key] = $key; @@ -522,14 +522,14 @@ public static function formRule($values) { } public function buildAmountLabel() { - $default = array(); + $default = []; for ($i = 1; $i <= self::NUM_OPTION; $i++) { // label $this->add('text', "discounted_label[$i]", ts('Label'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'label')); // value for ($j = 1; $j <= self::NUM_DISCOUNT; $j++) { - $this->add('text', "discounted_value[$i][$j]", ts('Value'), array('size' => 10)); - $this->addRule("discounted_value[$i][$j]", ts('Please enter a valid money value for this field (e.g. %1).', array(1 => CRM_Utils_Money::format('99.99', ' '))), 'money'); + $this->add('text', "discounted_value[$i][$j]", ts('Value'), ['size' => 10]); + $this->addRule("discounted_value[$i][$j]", ts('Please enter a valid money value for this field (e.g. %1).', [1 => CRM_Utils_Money::format('99.99', ' ')]), 'money'); } // default @@ -594,17 +594,17 @@ public function postProcess() { $labels = CRM_Utils_Array::value('label', $params); $values = CRM_Utils_Array::value('value', $params); $default = CRM_Utils_Array::value('default', $params); - $options = array(); + $options = []; if (!CRM_Utils_System::isNull($labels) && !CRM_Utils_System::isNull($values)) { for ($i = 1; $i < self::NUM_OPTION; $i++) { if (!empty($labels[$i]) && !CRM_Utils_System::isNull($values[$i])) { - $options[] = array( + $options[] = [ 'label' => trim($labels[$i]), 'value' => $values[$i], 'weight' => $i, 'is_active' => 1, 'is_default' => $default == $i, - ); + ]; } } if (!empty($options)) { @@ -663,8 +663,8 @@ public function postProcess() { } } - $discountPriceSets = !empty($this->_defaultValues['discount_price_set']) ? $this->_defaultValues['discount_price_set'] : array(); - $discountFieldIDs = !empty($this->_defaultValues['discount_option_id']) ? $this->_defaultValues['discount_option_id'] : array(); + $discountPriceSets = !empty($this->_defaultValues['discount_price_set']) ? $this->_defaultValues['discount_price_set'] : []; + $discountFieldIDs = !empty($this->_defaultValues['discount_option_id']) ? $this->_defaultValues['discount_option_id'] : []; if (CRM_Utils_Array::value('is_discount', $params) == 1) { // if there are discounted set of label / values, // create custom options for them @@ -674,26 +674,26 @@ public function postProcess() { if (!CRM_Utils_System::isNull($labels) && !CRM_Utils_System::isNull($values)) { for ($j = 1; $j <= self::NUM_DISCOUNT; $j++) { - $discountOptions = array(); + $discountOptions = []; for ($i = 1; $i < self::NUM_OPTION; $i++) { if (!empty($labels[$i]) && !CRM_Utils_System::isNull(CRM_Utils_Array::value($j, $values[$i])) ) { - $discountOptions[] = array( + $discountOptions[] = [ 'label' => trim($labels[$i]), 'value' => $values[$i][$j], 'weight' => $i, 'is_active' => 1, 'is_default' => $default == $i, - ); + ]; } } if (!empty($discountOptions)) { - $fieldParams = array(); + $fieldParams = []; $params['default_discount_fee_id'] = NULL; $keyCheck = $j - 1; - $setParams = array(); + $setParams = []; if (empty($discountPriceSets[$keyCheck])) { if (!$eventTitle) { $eventTitle = strtolower(CRM_Utils_String::munge($this->_defaultValues['title'], '_', 200)); @@ -717,10 +717,10 @@ public function postProcess() { } else { $priceSetID = $discountPriceSets[$j - 1]; - $setParams = array( + $setParams = [ 'title' => $params['discount_name'][$j], 'id' => $priceSetID, - ); + ]; if ($this->_defaultValues['financial_type_id'] != $params['financial_type_id']) { $setParams['financial_type_id'] = $params['financial_type_id']; } @@ -754,13 +754,13 @@ public function postProcess() { } } - $discountParams = array( + $discountParams = [ 'entity_table' => 'civicrm_event', 'entity_id' => $this->_id, 'price_set_id' => $priceSetID, 'start_date' => $params['discount_start_date'][$j], 'end_date' => $params['discount_end_date'][$j], - ); + ]; CRM_Core_BAO_Discount::add($discountParams); } } diff --git a/CRM/Event/Form/ManageEvent/Location.php b/CRM/Event/Form/ManageEvent/Location.php index 50d853972a9a..e51f1a3f45ab 100644 --- a/CRM/Event/Form/ManageEvent/Location.php +++ b/CRM/Event/Form/ManageEvent/Location.php @@ -53,7 +53,7 @@ class CRM_Event_Form_ManageEvent_Location extends CRM_Event_Form_ManageEvent { * * @var array */ - protected $_locationIds = array(); + protected $_locationIds = []; /** * The variable, for storing location block id with event @@ -65,7 +65,7 @@ class CRM_Event_Form_ManageEvent_Location extends CRM_Event_Form_ManageEvent { /** * Get the db values for this form. */ - public $_values = array(); + public $_values = []; /** * Set variables up before form is built. @@ -77,14 +77,14 @@ public function preProcess() { $this->_values = $this->get('values'); if ($this->_id && empty($this->_values)) { //get location values. - $params = array( + $params = [ 'entity_id' => $this->_id, 'entity_table' => 'civicrm_event', - ); + ]; $this->_values = CRM_Core_BAO_Location::getValues($params); //get event values. - $params = array('id' => $this->_id); + $params = ['id' => $this->_id]; CRM_Event_BAO_Event::retrieve($params, $this->_values); $this->set('values', $this->_values); } @@ -125,7 +125,7 @@ public function setDefaultValues() { * Add local and global form rules. */ public function addRules() { - $this->addFormRule(array('CRM_Event_Form_ManageEvent_Location', 'formRule')); + $this->addFormRule(['CRM_Event_Form_ManageEvent_Location', 'formRule']); } /** @@ -184,17 +184,17 @@ public function buildQuickForm() { if (!empty($locationEvents)) { $this->assign('locEvents', TRUE); - $optionTypes = array( + $optionTypes = [ '1' => ts('Create new location'), '2' => ts('Use existing location'), - ); + ]; $this->addRadio('location_option', ts("Choose Location"), $optionTypes); if (!isset($locationEvents[$this->_oldLocBlockId]) || (!$this->_oldLocBlockId)) { - $locationEvents = array('' => ts('- select -')) + $locationEvents; + $locationEvents = ['' => ts('- select -')] + $locationEvents; } - $this->add('select', 'loc_event_id', ts('Use Location'), $locationEvents, FALSE, array('class' => 'crm-select2')); + $this->add('select', 'loc_event_id', ts('Use Location'), $locationEvents, FALSE, ['class' => 'crm-select2']); } $this->addElement('advcheckbox', 'is_show_location', ts('Show Location?')); parent::buildQuickForm(); @@ -228,7 +228,7 @@ public function postProcess() { ); } - $this->_values['address'] = $this->_values['phone'] = $this->_values['email'] = array(); + $this->_values['address'] = $this->_values['phone'] = $this->_values['email'] = []; // if 'create new loc' option is selected OR selected new loc is different // from old one, go ahead and delete the old loc provided thats not being // used by any other event @@ -241,11 +241,11 @@ public function postProcess() { $params['entity_id'] = $this->_id; $defaultLocationType = CRM_Core_BAO_LocationType::getDefault(); - foreach (array( + foreach ([ 'address', 'phone', 'email', - ) as $block) { + ] as $block) { if (empty($params[$block]) || !is_array($params[$block])) { continue; } diff --git a/CRM/Event/Form/ManageEvent/Registration.php b/CRM/Event/Form/ManageEvent/Registration.php index e224a19acf64..a3441f82a75e 100644 --- a/CRM/Event/Form/ManageEvent/Registration.php +++ b/CRM/Event/Form/ManageEvent/Registration.php @@ -42,8 +42,8 @@ class CRM_Event_Form_ManageEvent_Registration extends CRM_Event_Form_ManageEvent */ protected $_showHide; - protected $_profilePostMultiple = array(); - protected $_profilePostMultipleAdd = array(); + protected $_profilePostMultiple = []; + protected $_profilePostMultipleAdd = []; /** * Set variables up before form is built. @@ -97,23 +97,23 @@ public function setDefaultValues() { $this->setShowHide($defaults); if (isset($eventId)) { - $params = array('id' => $eventId); + $params = ['id' => $eventId]; CRM_Event_BAO_Event::retrieve($params, $defaults); - $ufJoinParams = array( + $ufJoinParams = [ 'entity_table' => 'civicrm_event', 'module' => 'CiviEvent', 'entity_id' => $eventId, - ); + ]; list($defaults['custom_pre_id'], $defaults['custom_post'] ) = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams); // Get the id for the event registration profile - $eventRegistrationIdParams = $eventRegistrationIdDefaults = array( + $eventRegistrationIdParams = $eventRegistrationIdDefaults = [ 'name' => 'event_registration', - ); + ]; CRM_Core_BAO_UFGroup::retrieve($eventRegistrationIdParams, $eventRegistrationIdDefaults); // Set event registration as the default profile if none selected @@ -143,11 +143,11 @@ public function setDefaultValues() { if (!empty($defaults['is_multiple_registrations'])) { // CRM-4377: set additional participants’ profiles – set to ‘none’ if explicitly unset (non-active) - $ufJoinAddParams = array( + $ufJoinAddParams = [ 'entity_table' => 'civicrm_event', 'module' => 'CiviEvent_Additional', 'entity_id' => $eventId, - ); + ]; list($defaults['additional_custom_pre_id'], $defaults['additional_custom_post'] @@ -191,7 +191,7 @@ public function setDefaultValues() { * @return void */ public function setShowHide($defaults) { - $this->_showHide = new CRM_Core_ShowHideBlocks(array('registration' => 1), + $this->_showHide = new CRM_Core_ShowHideBlocks(['registration' => 1], '' ); if (empty($defaults)) { @@ -228,27 +228,27 @@ public function buildQuickForm() { 'is_online_registration', ts('Allow Online Registration'), NULL, - array( + [ 'onclick' => "return showHideByValue('is_online_registration'," . "''," . "'registration_blocks'," . "'block'," . "'radio'," . "false );", - ) + ] ); $this->add('text', 'registration_link_text', ts('Registration Link Text')); if (!$this->_isTemplate) { - $this->add('datepicker', 'registration_start_date', ts('Registration Start Date'), [], FALSE, array('time' => TRUE)); - $this->add('datepicker', 'registration_end_date', ts('Registration End Date'), [], FALSE, array('time' => TRUE)); + $this->add('datepicker', 'registration_start_date', ts('Registration Start Date'), [], FALSE, ['time' => TRUE]); + $this->add('datepicker', 'registration_end_date', ts('Registration End Date'), [], FALSE, ['time' => TRUE]); } - $params = array( + $params = [ 'used' => 'Supervised', 'contact_type' => 'Individual', - ); + ]; $dedupeRuleFields = CRM_Dedupe_BAO_Rule::dedupeRuleFields($params); foreach ($dedupeRuleFields as $key => $fields) { @@ -262,7 +262,7 @@ public function buildQuickForm() { // CRM-17745: Make maximum additional participants configurable $numericOptions = CRM_Core_SelectValues::getNumericOptions(1, 9); - $this->add('select', 'max_additional_participants', ts('Maximum additional participants'), $numericOptions, FALSE, array('class' => 'required')); + $this->add('select', 'max_additional_participants', ts('Maximum additional participants'), $numericOptions, FALSE, ['class' => 'required']); $this->addElement('checkbox', 'allow_same_participant_emails', @@ -270,9 +270,9 @@ public function buildQuickForm() { ); $this->assign('ruleFields', json_encode($ruleFields)); - $dedupeRules = array( + $dedupeRules = [ '' => '- Unsupervised rule -', - ); + ]; $dedupeRules += CRM_Dedupe_BAO_RuleGroup::getByType('Individual'); $this->add('select', 'dedupe_rule_group_id', ts('Duplicate matching rule'), $dedupeRules); @@ -282,14 +282,14 @@ public function buildQuickForm() { 'requires_approval', ts('Require participant approval?'), NULL, - array('onclick' => "return showHideByValue('requires_approval', '', 'id-approval-text', 'table-row', 'radio', false);") + ['onclick' => "return showHideByValue('requires_approval', '', 'id-approval-text', 'table-row', 'radio', false);"] ); $this->add('textarea', 'approval_req_text', ts('Approval message'), $attributes['approval_req_text']); } $this->add('text', 'expiration_time', ts('Pending participant expiration (hours)')); $this->addRule('expiration_time', ts('Please enter the number of hours (as an integer).'), 'integer'); - $this->addField('allow_selfcancelxfer', array('label' => ts('Allow self-service cancellation or transfer?'), 'type' => 'advcheckbox')); + $this->addField('allow_selfcancelxfer', ['label' => ts('Allow self-service cancellation or transfer?'), 'type' => 'advcheckbox']); $this->add('text', 'selfcancelxfer_time', ts('Cancellation or transfer time limit (hours)')); $this->addRule('selfcancelxfer_time', ts('Please enter the number of hours (as an integer).'), 'integer'); self::buildRegistrationBlock($this); @@ -307,7 +307,7 @@ public function buildQuickForm() { * */ public function buildRegistrationBlock(&$form) { - $attributes = CRM_Core_DAO::getAttribute('CRM_Event_DAO_Event', 'intro_text') + array('class' => 'collapsed', 'preset' => 'civievent'); + $attributes = CRM_Core_DAO::getAttribute('CRM_Event_DAO_Event', 'intro_text') + ['class' => 'collapsed', 'preset' => 'civievent']; $form->add('wysiwyg', 'intro_text', ts('Introductory Text'), $attributes); $form->add('wysiwyg', 'footer_text', ts('Footer Text'), $attributes); @@ -348,17 +348,17 @@ public function buildMultipleProfileBottom(&$form, $count, $prefix = '', $label * ['allowCoreTypes' => array, 'allowSubTypes' => array, 'profileEntities' => array] */ public static function getProfileSelectorTypes() { - $configs = array( - 'allowCoreTypes' => array(), - 'allowSubTypes' => array(), - 'profileEntities' => array(), - 'usedFor' => array(), - ); - - $configs['allowCoreTypes'] = array_merge(array( + $configs = [ + 'allowCoreTypes' => [], + 'allowSubTypes' => [], + 'profileEntities' => [], + 'usedFor' => [], + ]; + + $configs['allowCoreTypes'] = array_merge([ 'Contact', 'Individual', - ), CRM_Contact_BAO_ContactType::subTypes('Individual')); + ], CRM_Contact_BAO_ContactType::subTypes('Individual')); $configs['allowCoreTypes'][] = 'Participant'; if (CRM_Core_Permission::check('manage event profiles') && !CRM_Core_Permission::check('administer CiviCRM')) { $configs['usedFor'][] = 'CiviEvent'; @@ -368,16 +368,16 @@ public static function getProfileSelectorTypes() { if ($id) { $participantEventType = CRM_Core_DAO::getFieldValue("CRM_Event_DAO_Event", $id, 'event_type_id', 'id'); $participantRole = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $id, 'default_role_id'); - $configs['allowSubTypes']['ParticipantEventName'] = array($id); - $configs['allowSubTypes']['ParticipantEventType'] = array($participantEventType); - $configs['allowSubTypes']['ParticipantRole'] = array($participantRole); + $configs['allowSubTypes']['ParticipantEventName'] = [$id]; + $configs['allowSubTypes']['ParticipantEventType'] = [$participantEventType]; + $configs['allowSubTypes']['ParticipantRole'] = [$participantRole]; } - $configs['profileEntities'][] = array('entity_name' => 'contact_1', 'entity_type' => 'IndividualModel'); - $configs['profileEntities'][] = array( + $configs['profileEntities'][] = ['entity_name' => 'contact_1', 'entity_type' => 'IndividualModel']; + $configs['profileEntities'][] = [ 'entity_name' => 'participant_1', 'entity_type' => 'ParticipantModel', 'entity_sub_type' => '*', - ); + ]; return $configs; } @@ -394,11 +394,11 @@ public function buildConfirmationBlock(&$form) { $is_monetary = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $form->_id, 'is_monetary'); $form->assign('is_monetary', $is_monetary); if ($is_monetary == "0") { - $form->addYesNo('is_confirm_enabled', ts('Use a confirmation screen?'), NULL, NULL, array('onclick' => "return showHideByValue('is_confirm_enabled','','confirm_screen_settings','block','radio',false);")); + $form->addYesNo('is_confirm_enabled', ts('Use a confirmation screen?'), NULL, NULL, ['onclick' => "return showHideByValue('is_confirm_enabled','','confirm_screen_settings','block','radio',false);"]); } $form->add('text', 'confirm_title', ts('Title'), $attributes['confirm_title']); - $form->add('wysiwyg', 'confirm_text', ts('Introductory Text'), $attributes['confirm_text'] + array('class' => 'collapsed', 'preset' => 'civievent')); - $form->add('wysiwyg', 'confirm_footer_text', ts('Footer Text'), $attributes['confirm_text'] + array('class' => 'collapsed', 'preset' => 'civievent')); + $form->add('wysiwyg', 'confirm_text', ts('Introductory Text'), $attributes['confirm_text'] + ['class' => 'collapsed', 'preset' => 'civievent']); + $form->add('wysiwyg', 'confirm_footer_text', ts('Footer Text'), $attributes['confirm_text'] + ['class' => 'collapsed', 'preset' => 'civievent']); } /** @@ -410,7 +410,7 @@ public function buildConfirmationBlock(&$form) { public function buildMailBlock(&$form) { $form->registerRule('emailList', 'callback', 'emailList', 'CRM_Utils_Rule'); $attributes = CRM_Core_DAO::getAttribute('CRM_Event_DAO_Event'); - $form->addYesNo('is_email_confirm', ts('Send Confirmation Email?'), NULL, NULL, array('onclick' => "return showHideByValue('is_email_confirm','','confirmEmail','block','radio',false);")); + $form->addYesNo('is_email_confirm', ts('Send Confirmation Email?'), NULL, NULL, ['onclick' => "return showHideByValue('is_email_confirm','','confirmEmail','block','radio',false);"]); $form->add('textarea', 'confirm_email_text', ts('Text'), $attributes['confirm_email_text']); $form->add('text', 'cc_confirm', ts('CC Confirmation To'), CRM_Core_DAO::getAttribute('CRM_Event_DAO_Event', 'cc_confirm')); $form->addRule('cc_confirm', ts('Please enter a valid list of comma delimited email addresses'), 'emailList'); @@ -427,8 +427,8 @@ public function buildMailBlock(&$form) { public function buildThankYouBlock(&$form) { $attributes = CRM_Core_DAO::getAttribute('CRM_Event_DAO_Event'); $form->add('text', 'thankyou_title', ts('Title'), $attributes['thankyou_title']); - $form->add('wysiwyg', 'thankyou_text', ts('Introductory Text'), $attributes['thankyou_text'] + array('class' => 'collapsed', 'preset' => 'civievent')); - $form->add('wysiwyg', 'thankyou_footer_text', ts('Footer Text'), $attributes['thankyou_text'] + array('class' => 'collapsed', 'preset' => 'civievent')); + $form->add('wysiwyg', 'thankyou_text', ts('Introductory Text'), $attributes['thankyou_text'] + ['class' => 'collapsed', 'preset' => 'civievent']); + $form->add('wysiwyg', 'thankyou_footer_text', ts('Footer Text'), $attributes['thankyou_text'] + ['class' => 'collapsed', 'preset' => 'civievent']); } /** @@ -441,7 +441,7 @@ public function addRules() { if ($this->_addProfileBottom || $this->_addProfileBottomAdd) { return; } - $this->addFormRule(array('CRM_Event_Form_ManageEvent_Registration', 'formRule'), $this); + $this->addFormRule(['CRM_Event_Form_ManageEvent_Registration', 'formRule'], $this); } /** @@ -480,14 +480,14 @@ public static function formRule($values, $files, $form) { } //check that the selected profiles have either firstname+lastname or email required - $profileIds = array( + $profileIds = [ CRM_Utils_Array::value('custom_pre_id', $values), CRM_Utils_Array::value('custom_post_id', $values), - ); - $additionalProfileIds = array( + ]; + $additionalProfileIds = [ CRM_Utils_Array::value('additional_custom_pre_id', $values), CRM_Utils_Array::value('additional_custom_post_id', $values), - ); + ]; //additional profile fields default to main if not set if (!is_numeric($additionalProfileIds[0])) { $additionalProfileIds[0] = $profileIds[0]; @@ -511,7 +511,7 @@ public static function formRule($values, $files, $form) { $additionalCustomPreId = $additionalCustomPostId = NULL; $isPreError = $isPostError = TRUE; if (!empty($values['allow_same_participant_emails']) && !empty($values['is_multiple_registrations'])) { - $types = array_merge(array('Individual'), CRM_Contact_BAO_ContactType::subTypes('Individual')); + $types = array_merge(['Individual'], CRM_Contact_BAO_ContactType::subTypes('Individual')); $profiles = CRM_Core_BAO_UFGroup::getProfiles($types); //check for additional custom pre profile @@ -637,7 +637,7 @@ public static function formRule($values, $files, $form) { * @return bool */ public static function getEmailFields($profileIds) { - $emailFields = array(); + $emailFields = []; foreach ($profileIds as $profileId) { if ($profileId && is_numeric($profileId)) { $fields = CRM_Core_BAO_UFGroup::getFields($profileId); @@ -658,7 +658,7 @@ public static function getEmailFields($profileIds) { * @return bool */ public static function isProfileComplete($profileIds) { - $profileReqFields = array(); + $profileReqFields = []; foreach ($profileIds as $profileId) { if ($profileId && is_numeric($profileId)) { $fields = CRM_Core_BAO_UFGroup::getFields($profileId); @@ -694,21 +694,21 @@ public static function isProfileComplete($profileIds) { */ public static function canProfilesDedupe($profileIds, $rgId = 0) { // find the unsupervised rule - $rgParams = array( + $rgParams = [ 'used' => 'Unsupervised', 'contact_type' => 'Individual', - ); + ]; if ($rgId > 0) { $rgParams['id'] = $rgId; } $activeRg = CRM_Dedupe_BAO_RuleGroup::dedupeRuleFieldsWeight($rgParams); // get the combinations that could be a match for the rule - $okCombos = $combos = array(); + $okCombos = $combos = []; CRM_Dedupe_BAO_RuleGroup::combos($activeRg[0], $activeRg[1], $combos); // create an index of what combinations involve each field - $index = array(); + $index = []; foreach ($combos as $comboid => $combo) { foreach ($combo as $cfield) { $index[$cfield][$comboid] = TRUE; @@ -718,7 +718,7 @@ public static function canProfilesDedupe($profileIds, $rgId = 0) { } // get profiles and see if they have the necessary combos - $profileReqFields = array(); + $profileReqFields = []; foreach ($profileIds as $profileId) { if ($profileId && is_numeric($profileId)) { $fields = CRM_Core_BAO_UFGroup::getFields($profileId); @@ -810,17 +810,17 @@ public function postProcess() { CRM_Event_BAO_Event::add($params); // also update the ProfileModule tables - $ufJoinParams = array( + $ufJoinParams = [ 'is_active' => 1, 'module' => 'CiviEvent', 'entity_table' => 'civicrm_event', 'entity_id' => $this->_id, - ); + ]; // first delete all past entries CRM_Core_BAO_UFJoin::deleteAll($ufJoinParams); - $uf = array(); + $uf = []; $wt = 2; if (!empty($params['custom_pre_id'])) { $uf[1] = $params['custom_pre_id']; @@ -844,17 +844,17 @@ public function postProcess() { } } // also update the ProfileModule tables - $ufJoinParamsAdd = array( + $ufJoinParamsAdd = [ 'is_active' => 1, 'module' => 'CiviEvent_Additional', 'entity_table' => 'civicrm_event', 'entity_id' => $this->_id, - ); + ]; // first delete all past entries CRM_Core_BAO_UFJoin::deleteAll($ufJoinParamsAdd); if (!empty($params['is_multiple_registrations'])) { - $ufAdd = array(); + $ufAdd = []; $wtAdd = 2; if (array_key_exists('additional_custom_pre_id', $params)) { @@ -882,7 +882,7 @@ public function postProcess() { } if (!empty($params['additional_custom_post_id_multiple'])) { - $additionalPostMultiple = array(); + $additionalPostMultiple = []; foreach ($params['additional_custom_post_id_multiple'] as $key => $value) { if (is_null($value) && !empty($params['custom_post_id'])) { $additionalPostMultiple[$key] = $params['custom_post_id']; @@ -911,14 +911,14 @@ public function postProcess() { } // get the profiles to evaluate what they collect - $profileIds = array( + $profileIds = [ CRM_Utils_Array::value('custom_pre_id', $params), CRM_Utils_Array::value('custom_post_id', $params), - ); - $additionalProfileIds = array( + ]; + $additionalProfileIds = [ CRM_Utils_Array::value('additional_custom_pre_id', $params), CRM_Utils_Array::value('additional_custom_post_id', $params), - ); + ]; // additional profile fields default to main if not set if (!is_numeric($additionalProfileIds[0])) { $additionalProfileIds[0] = $profileIds[0]; @@ -963,7 +963,7 @@ public function postProcess() { } } if ($cantDedupe) { - CRM_Core_Session::setStatus($cantDedupe, $dedupeTitle, 'alert dedupenotify', array('expires' => 0)); + CRM_Core_Session::setStatus($cantDedupe, $dedupeTitle, 'alert dedupenotify', ['expires' => 0]); } // Update tab "disabled" css class diff --git a/CRM/Event/Form/ManageEvent/Repeat.php b/CRM/Event/Form/ManageEvent/Repeat.php index e95c2245a0dc..58ef8f6e2061 100644 --- a/CRM/Event/Form/ManageEvent/Repeat.php +++ b/CRM/Event/Form/ManageEvent/Repeat.php @@ -36,13 +36,13 @@ public function preProcess() { */ //Get all connected event ids $allEventIdsArray = CRM_Core_BAO_RecurringEntity::getEntitiesForParent($checkParentExistsForThisId, 'civicrm_event'); - $allEventIds = array(); + $allEventIds = []; if (!empty($allEventIdsArray)) { foreach ($allEventIdsArray as $key => $val) { $allEventIds[] = $val['id']; } if (!empty($allEventIds)) { - $params = array(); + $params = []; $query = " SELECT * FROM civicrm_event @@ -54,7 +54,7 @@ public function preProcess() { $permissions = CRM_Event_BAO_Event::checkPermission(); while ($dao->fetch()) { if (in_array($dao->id, $permissions[CRM_Core_Permission::VIEW])) { - $manageEvent[$dao->id] = array(); + $manageEvent[$dao->id] = []; CRM_Core_DAO::storeValues($dao, $manageEvent[$dao->id]); } } @@ -63,9 +63,9 @@ public function preProcess() { } } - $parentEventParams = array('id' => $this->_id); - $parentEventValues = array(); - $parentEventReturnProperties = array('start_date', 'end_date'); + $parentEventParams = ['id' => $this->_id]; + $parentEventValues = []; + $parentEventReturnProperties = ['start_date', 'end_date']; $parentEventAttributes = CRM_Core_DAO::commonRetrieve('CRM_Event_DAO_Event', $parentEventParams, $parentEventValues, $parentEventReturnProperties); $this->_parentEventStartDate = $parentEventAttributes->start_date; $this->_parentEventEndDate = $parentEventAttributes->end_date; @@ -79,7 +79,7 @@ public function preProcess() { * @return array */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; //Always pass current event's start date by default $defaults['repetition_start_date'] = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_id, 'start_date', 'id'); @@ -96,10 +96,10 @@ public function postProcess() { $params = $this->controller->exportValues($this->_name); if ($this->_parentEventStartDate && $this->_parentEventEndDate) { $interval = CRM_Core_BAO_RecurringEntity::getInterval($this->_parentEventStartDate, $this->_parentEventEndDate); - $params['intervalDateColumns'] = array('end_date' => $interval); + $params['intervalDateColumns'] = ['end_date' => $interval]; } - $params['dateColumns'] = array('start_date'); - $params['excludeDateRangeColumns'] = array('start_date', 'end_date'); + $params['dateColumns'] = ['start_date']; + $params['excludeDateRangeColumns'] = ['start_date', 'end_date']; $params['entity_table'] = 'civicrm_event'; $params['entity_id'] = $this->_id; @@ -112,44 +112,44 @@ public function postProcess() { $url = 'civicrm/event/manage/repeat'; $urlParams = "action=update&reset=1&id={$this->_id}&selectedChild=repeat"; - $linkedEntities = array( - array( + $linkedEntities = [ + [ 'table' => 'civicrm_price_set_entity', - 'findCriteria' => array( + 'findCriteria' => [ 'entity_id' => $this->_id, 'entity_table' => 'civicrm_event', - ), - 'linkedColumns' => array('entity_id'), + ], + 'linkedColumns' => ['entity_id'], 'isRecurringEntityRecord' => FALSE, - ), - array( + ], + [ 'table' => 'civicrm_uf_join', - 'findCriteria' => array( + 'findCriteria' => [ 'entity_id' => $this->_id, 'entity_table' => 'civicrm_event', - ), - 'linkedColumns' => array('entity_id'), + ], + 'linkedColumns' => ['entity_id'], 'isRecurringEntityRecord' => FALSE, - ), - array( + ], + [ 'table' => 'civicrm_tell_friend', - 'findCriteria' => array( + 'findCriteria' => [ 'entity_id' => $this->_id, 'entity_table' => 'civicrm_event', - ), - 'linkedColumns' => array('entity_id'), + ], + 'linkedColumns' => ['entity_id'], 'isRecurringEntityRecord' => TRUE, - ), - array( + ], + [ 'table' => 'civicrm_pcp_block', - 'findCriteria' => array( + 'findCriteria' => [ 'entity_id' => $this->_id, 'entity_table' => 'civicrm_event', - ), - 'linkedColumns' => array('entity_id'), + ], + 'linkedColumns' => ['entity_id'], 'isRecurringEntityRecord' => TRUE, - ), - ); + ], + ]; CRM_Core_Form_RecurringEntity::postProcess($params, 'civicrm_event', $linkedEntities); CRM_Utils_System::redirect(CRM_Utils_System::url($url, $urlParams)); } @@ -168,8 +168,8 @@ public function postProcess() { * * @return array */ - static public function getParticipantCountforEvent($listOfRelatedEntities = array()) { - $participantDetails = array(); + static public function getParticipantCountforEvent($listOfRelatedEntities = []) { + $participantDetails = []; if (!empty($listOfRelatedEntities)) { $implodeRelatedEntities = implode(',', array_map(function ($entity) { return $entity['id']; @@ -200,7 +200,7 @@ static public function getParticipantCountforEvent($listOfRelatedEntities = arra * @return array */ public static function checkRegistrationForEvents($eventID) { - $eventIdsWithNoRegistration = array(); + $eventIdsWithNoRegistration = []; if ($eventID) { $getRelatedEntities = CRM_Core_BAO_RecurringEntity::getEntitiesFor($eventID, 'civicrm_event', TRUE); $participantDetails = CRM_Event_Form_ManageEvent_Repeat::getParticipantCountforEvent($getRelatedEntities); diff --git a/CRM/Event/Form/ManageEvent/ScheduleReminders.php b/CRM/Event/Form/ManageEvent/ScheduleReminders.php index b00f01834e56..483f275de624 100644 --- a/CRM/Event/Form/ManageEvent/ScheduleReminders.php +++ b/CRM/Event/Form/ManageEvent/ScheduleReminders.php @@ -50,9 +50,9 @@ public function preProcess() { $this->assign('selectedChild', 'reminder'); $setTab = CRM_Utils_Request::retrieve('setTab', 'Int', $this, FALSE, 0); - $mapping = CRM_Utils_Array::first(CRM_Core_BAO_ActionSchedule::getMappings(array( + $mapping = CRM_Utils_Array::first(CRM_Core_BAO_ActionSchedule::getMappings([ 'id' => ($this->_isTemplate ? CRM_Event_ActionMapping::EVENT_TPL_MAPPING_ID : CRM_Event_ActionMapping::EVENT_NAME_MAPPING_ID), - ))); + ])); $reminderList = CRM_Core_BAO_ActionSchedule::getList(FALSE, $mapping, $this->_id); if ($reminderList && is_array($reminderList)) { // Add action links to each of the reminders @@ -71,7 +71,7 @@ public function preProcess() { $format['action'] = CRM_Core_Action::formLink( $links, $action, - array('id' => $format['id']), + ['id' => $format['id']], ts('more'), FALSE, 'actionSchedule.manage.action', diff --git a/CRM/Event/Form/ManageEvent/TabHeader.php b/CRM/Event/Form/ManageEvent/TabHeader.php index 4e20c16f4175..c966147e4fc7 100644 --- a/CRM/Event/Form/ManageEvent/TabHeader.php +++ b/CRM/Event/Form/ManageEvent/TabHeader.php @@ -55,11 +55,11 @@ public static function build(&$form) { $form->assign_by_ref('tabHeader', $tabs); CRM_Core_Resources::singleton() ->addScriptFile('civicrm', 'templates/CRM/common/TabHeader.js', 1, 'html-header') - ->addSetting(array( - 'tabSettings' => array( + ->addSetting([ + 'tabSettings' => [ 'active' => self::getCurrentTab($tabs), - ), - )); + ], + ]); CRM_Event_Form_ManageEvent::addProfileEditScripts(); return $tabs; } @@ -75,26 +75,26 @@ public static function process(&$form) { return NULL; } - $default = array( + $default = [ 'link' => NULL, 'valid' => TRUE, 'active' => TRUE, 'current' => FALSE, 'class' => 'ajaxForm', - ); + ]; - $tabs = array(); - $tabs['settings'] = array('title' => ts('Info and Settings'), 'class' => 'ajaxForm livePage') + $default; - $tabs['location'] = array('title' => ts('Event Location')) + $default; - $tabs['fee'] = array('title' => ts('Fees')) + $default; - $tabs['registration'] = array('title' => ts('Online Registration')) + $default; + $tabs = []; + $tabs['settings'] = ['title' => ts('Info and Settings'), 'class' => 'ajaxForm livePage'] + $default; + $tabs['location'] = ['title' => ts('Event Location')] + $default; + $tabs['fee'] = ['title' => ts('Fees')] + $default; + $tabs['registration'] = ['title' => ts('Online Registration')] + $default; if (CRM_Core_Permission::check('administer CiviCRM') || CRM_Event_BAO_Event::checkPermission(NULL, CRM_Core_Permission::EDIT)) { - $tabs['reminder'] = array('title' => ts('Schedule Reminders'), 'class' => 'livePage') + $default; + $tabs['reminder'] = ['title' => ts('Schedule Reminders'), 'class' => 'livePage'] + $default; } - $tabs['conference'] = array('title' => ts('Conference Slots')) + $default; - $tabs['friend'] = array('title' => ts('Tell a Friend')) + $default; - $tabs['pcp'] = array('title' => ts('Personal Campaigns')) + $default; - $tabs['repeat'] = array('title' => ts('Repeat')) + $default; + $tabs['conference'] = ['title' => ts('Conference Slots')] + $default; + $tabs['friend'] = ['title' => ts('Tell a Friend')] + $default; + $tabs['pcp'] = ['title' => ts('Personal Campaigns')] + $default; + $tabs['repeat'] = ['title' => ts('Repeat')] + $default; // Repeat tab must refresh page when switching repeat mode so js & vars will get set-up if (!$form->_isRepeatingEvent) { @@ -110,9 +110,9 @@ public static function process(&$form) { $eventID = $form->getVar('_id'); if ($eventID) { // disable tabs based on their configuration status - $eventNameMapping = CRM_Utils_Array::first(CRM_Core_BAO_ActionSchedule::getMappings(array( + $eventNameMapping = CRM_Utils_Array::first(CRM_Core_BAO_ActionSchedule::getMappings([ 'id' => CRM_Event_ActionMapping::EVENT_NAME_MAPPING_ID, - ))); + ])); $sql = " SELECT e.loc_block_id as is_location, e.is_online_registration, e.is_monetary, taf.is_active, pcp.is_active as is_pcp, sch.id as is_reminder, re.id as is_repeating_event FROM civicrm_event e @@ -124,10 +124,10 @@ public static function process(&$form) { "; //Check if repeat is configured $eventHasParent = CRM_Core_BAO_RecurringEntity::getParentFor($eventID, 'civicrm_event'); - $params = array( - 1 => array($eventID, 'Integer'), - 2 => array($eventNameMapping->getId(), 'Integer'), - ); + $params = [ + 1 => [$eventID, 'Integer'], + 2 => [$eventNameMapping->getId(), 'Integer'], + ]; $dao = CRM_Core_DAO::executeQuery($sql, $params); if (!$dao->fetch()) { CRM_Core_Error::fatal(); @@ -158,7 +158,7 @@ public static function process(&$form) { // see if any other modules want to add any tabs // note: status of 'valid' flag of any injected tab, needs to be taken care in the hook implementation. CRM_Utils_Hook::tabset('civicrm/event/manage', $tabs, - array('event_id' => $eventID)); + ['event_id' => $eventID]); $fullName = $form->getVar('_name'); $className = CRM_Utils_String::getClassName($fullName); diff --git a/CRM/Event/Form/Participant.php b/CRM/Event/Form/Participant.php index ee2621e60123..70b2a84c075e 100644 --- a/CRM/Event/Form/Participant.php +++ b/CRM/Event/Form/Participant.php @@ -228,7 +228,7 @@ public function preProcess() { $this->assign('context', $this->_context); if ($this->_contactID) { - $this->setPageTitle(ts('Event Registration for %1', array(1 => $this->userDisplayName))); + $this->setPageTitle(ts('Event Registration for %1', [1 => $this->userDisplayName])); } else { $this->setPageTitle(ts('Event Registration')); @@ -292,12 +292,12 @@ public function preProcess() { $this->_single = TRUE; $this->assign('urlPath', 'civicrm/contact/view/participant'); if (!$this->_id && !$this->_contactId) { - $breadCrumbs = array( - array( + $breadCrumbs = [ + [ 'title' => ts('CiviEvent Dashboard'), 'url' => CRM_Utils_System::url('civicrm/event', 'reset=1'), - ), - ); + ], + ]; CRM_Utils_System::appendBreadCrumb($breadCrumbs); } @@ -429,15 +429,15 @@ public function setDefaultValues() { return CRM_Event_Form_EventFees::setDefaultValues($this); } - $defaults = array(); + $defaults = []; if ($this->_action & CRM_Core_Action::DELETE) { return $defaults; } if ($this->_id) { - $ids = array(); - $params = array('id' => $this->_id); + $ids = []; + $params = ['id' => $this->_id]; CRM_Event_BAO_Participant::getValues($params, $defaults, $ids); $sep = CRM_Core_DAO::VALUE_SEPARATOR; @@ -602,45 +602,45 @@ public function buildQuickForm() { TRUE )) - 1; if ($additionalParticipant) { - $deleteParticipants = array( + $deleteParticipants = [ 1 => ts('Delete this participant record along with associated participant record(s).'), 2 => ts('Delete only this participant record.'), - ); + ]; $this->addRadio('delete_participant', NULL, $deleteParticipants, NULL, '
    '); - $this->setDefaults(array('delete_participant' => 1)); + $this->setDefaults(['delete_participant' => 1]); $this->assign('additionalParticipant', $additionalParticipant); } } - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => ts('Delete'), 'spacing' => '         ', 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); return; } if ($this->_single && $this->_context == 'standalone') { - $this->addEntityRef('contact_id', ts('Contact'), array( + $this->addEntityRef('contact_id', ts('Contact'), [ 'create' => TRUE, - 'api' => array('extra' => array('email')), - ), TRUE); + 'api' => ['extra' => ['email']], + ], TRUE); } - $eventFieldParams = array( + $eventFieldParams = [ 'entity' => 'Event', - 'select' => array('minimumInputLength' => 0), - 'api' => array( - 'extra' => array('campaign_id', 'default_role_id', 'event_type_id'), - ), - ); + 'select' => ['minimumInputLength' => 0], + 'api' => [ + 'extra' => ['campaign_id', 'default_role_id', 'event_type_id'], + ], + ]; if ($this->_mode) { // exclude events which are not monetary when credit card registration is used @@ -672,25 +672,25 @@ public function buildQuickForm() { } } CRM_Campaign_BAO_Campaign::addCampaign($this, $campaignId); - $this->add('datepicker', 'register_date', ts('Registration Date'), [], TRUE, array('time' => TRUE)); + $this->add('datepicker', 'register_date', ts('Registration Date'), [], TRUE, ['time' => TRUE]); if ($this->_id) { $this->assign('entityID', $this->_id); } - $this->addSelect('role_id', array('multiple' => TRUE, 'class' => 'huge'), TRUE); + $this->addSelect('role_id', ['multiple' => TRUE, 'class' => 'huge'], TRUE); // CRM-4395 - $checkCancelledJs = array('onchange' => "return sendNotification( );"); + $checkCancelledJs = ['onchange' => "return sendNotification( );"]; $confirmJS = NULL; if ($this->_onlinePendingContributionId) { $cancelledparticipantStatusId = array_search('Cancelled', CRM_Event_PseudoConstant::participantStatus()); $cancelledContributionStatusId = array_search('Cancelled', CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name') ); - $checkCancelledJs = array( + $checkCancelledJs = [ 'onchange' => "checkCancelled( this.value, {$cancelledparticipantStatusId},{$cancelledContributionStatusId});", - ); + ]; $participantStatusId = array_search('Pending from pay later', CRM_Event_PseudoConstant::participantStatus() @@ -698,18 +698,18 @@ public function buildQuickForm() { $contributionStatusId = array_search('Completed', CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name') ); - $confirmJS = array('onclick' => "return confirmStatus( {$participantStatusId}, {$contributionStatusId} );"); + $confirmJS = ['onclick' => "return confirmStatus( {$participantStatusId}, {$contributionStatusId} );"]; } // get the participant status names to build special status array which is used to show notification // checkbox below participant status select $participantStatusName = CRM_Event_PseudoConstant::participantStatus(); - $notificationStatuses = array( + $notificationStatuses = [ 'Cancelled', 'Pending from waitlist', 'Pending from approval', 'Expired', - ); + ]; // get the required status and then implode only ids $notificationStatusIds = implode(',', array_keys(array_intersect($participantStatusName, $notificationStatuses))); @@ -725,42 +725,42 @@ public function buildQuickForm() { } } - $this->addSelect('status_id', $checkCancelledJs + array( + $this->addSelect('status_id', $checkCancelledJs + [ 'options' => $statusOptions, 'option_url' => 'civicrm/admin/participant_status', - ), TRUE); + ], TRUE); $this->addElement('checkbox', 'is_notify', ts('Send Notification'), NULL); - $this->addField('source', array('entity' => 'Participant', 'name' => 'source')); + $this->addField('source', ['entity' => 'Participant', 'name' => 'source']); $noteAttributes = CRM_Core_DAO::getAttribute('CRM_Core_DAO_Note'); $this->add('textarea', 'note', ts('Notes'), $noteAttributes['note']); - $buttons[] = array( + $buttons[] = [ 'type' => 'upload', 'name' => ts('Save'), 'isDefault' => TRUE, 'js' => $confirmJS, - ); + ]; $path = CRM_Utils_System::currentPath(); - $excludeForPaths = array( + $excludeForPaths = [ 'civicrm/contact/search', 'civicrm/group/search', - ); + ]; if (!in_array($path, $excludeForPaths)) { - $buttons[] = array( + $buttons[] = [ 'type' => 'upload', 'name' => ts('Save and New'), 'subName' => 'new', 'js' => $confirmJS, - ); + ]; } - $buttons[] = array( + $buttons[] = [ 'type' => 'cancel', 'name' => ts('Cancel'), - ); + ]; $this->addButtons($buttons); if ($this->_action == CRM_Core_Action::VIEW) { @@ -774,7 +774,7 @@ public function buildQuickForm() { * @return void */ public function addRules() { - $this->addFormRule(array('CRM_Event_Form_Participant', 'formRule'), $this); + $this->addFormRule(['CRM_Event_Form_Participant', 'formRule'], $this); } /** @@ -799,7 +799,7 @@ public static function formRule($values, $files, $self) { return TRUE; } - $errorMsg = array(); + $errorMsg = []; if (!empty($values['payment_processor_id'])) { // make sure that payment instrument values (e.g. credit card number and cvv) are valid @@ -914,7 +914,7 @@ public function postProcess() { if ($duplicateContacts > 0) { $msg = ts( "%1 contacts have already been assigned to this event. They were not added a second time.", - array(1 => $duplicateContacts) + [1 => $duplicateContacts] ); CRM_Core_Session::setStatus($msg); } @@ -986,9 +986,9 @@ public function submit($params) { } if ($this->_isPaidEvent) { - $contributionParams = array('skipCleanMoney' => TRUE); - $lineItem = array(); - $additionalParticipantDetails = array(); + $contributionParams = ['skipCleanMoney' => TRUE]; + $lineItem = []; + $additionalParticipantDetails = []; if (CRM_Contribute_BAO_Contribution::checkContributeSettings('deferred_revenue_enabled')) { $eventStartDate = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_eventId, 'start_date'); if (strtotime($eventStartDate) > strtotime(date('Ymt'))) { @@ -1027,7 +1027,7 @@ public function submit($params) { //lets carry currency, CRM-4453 $params['fee_currency'] = $config->defaultCurrency; if (!isset($lineItem[0])) { - $lineItem[0] = array(); + $lineItem[0] = []; } CRM_Price_BAO_PriceSet::processAmount($this->_values['fee'], $params, $lineItem[0] @@ -1063,7 +1063,7 @@ public function submit($params) { $this->_lineItem = $lineItem; $lineItem = array_merge($lineItem, $additionalParticipantDetails); - $participantCount = array(); + $participantCount = []; foreach ($lineItem as $k) { foreach ($k as $v) { if (CRM_Utils_Array::value('participant_count', $v) > 0) { @@ -1126,10 +1126,10 @@ public function submit($params) { // set source if not set if (empty($params['source'])) { - $this->_params['participant_source'] = ts('Offline Registration for Event: %2 by: %1', array( + $this->_params['participant_source'] = ts('Offline Registration for Event: %2 by: %1', [ 1 => $userName, 2 => $eventTitle, - )); + ]); } else { $this->_params['participant_source'] = $params['source']; @@ -1139,7 +1139,7 @@ public function submit($params) { $this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($this->_params['payment_processor_id'], $this->_mode ); - $fields = array(); + $fields = []; // set email for primary location. $fields['email-Primary'] = 1; @@ -1163,7 +1163,7 @@ public function submit($params) { $fields["email-{$this->_bltID}"] = 1; $ctype = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_contactId, 'contact_type'); - $nameFields = array('first_name', 'middle_name', 'last_name'); + $nameFields = ['first_name', 'middle_name', 'last_name']; foreach ($nameFields as $name) { $fields[$name] = 1; @@ -1176,7 +1176,7 @@ public function submit($params) { } if (!empty($this->_params['participant_role_id'])) { - $customFieldsRole = array(); + $customFieldsRole = []; foreach ($this->_params['participant_role_id'] as $roleKey) { $customFieldsRole = CRM_Utils_Array::crmArrayMerge(CRM_Core_BAO_CustomField::getFields('Participant', FALSE, FALSE, $roleKey, $this->_roleCustomDataTypeID), $customFieldsRole); @@ -1230,7 +1230,7 @@ public function submit($params) { // so more conservative approach is called for. // In fact the use of $params and $this->_params & $this->_contactId vs $contactID // needs rationalising. - $mapParams = array_merge(array('contact_id' => $contactID), $this->_params); + $mapParams = array_merge(['contact_id' => $contactID], $this->_params); CRM_Core_Payment_Form::mapParams($this->_bltID, $mapParams, $paymentParams, TRUE); $payment = $this->_paymentProcessor['object']; @@ -1277,7 +1277,7 @@ public function submit($params) { ); // add participant record - $participants = array(); + $participants = []; if (!empty($this->_params['role_id']) && is_array($this->_params['role_id'])) { $this->_params['role_id'] = implode(CRM_Core_DAO::VALUE_SEPARATOR, $this->_params['role_id'] @@ -1296,16 +1296,16 @@ public function submit($params) { 'Participant' ); //add participant payment - $paymentParticipant = array( + $paymentParticipant = [ 'participant_id' => $participants[0]->id, 'contribution_id' => $contribution->id, - ); + ]; CRM_Event_BAO_ParticipantPayment::create($paymentParticipant); $this->_contactIds[] = $this->_contactId; } else { - $participants = array(); + $participants = []; if ($this->_single) { if ($params['role_id']) { $params['role_id'] = $roleIdWithSeparator; @@ -1340,7 +1340,7 @@ public function submit($params) { $this->_contactIds[] = $this->_contactId; } - $contributions = array(); + $contributions = []; if (!empty($params['record_contribution'])) { if (!empty($params['id'])) { if ($this->_onlinePendingContributionId) { @@ -1359,10 +1359,10 @@ public function submit($params) { //build contribution params if (!$this->_onlinePendingContributionId) { if (empty($params['source'])) { - $contributionParams['source'] = ts('%1 : Offline registration (by %2)', array( + $contributionParams['source'] = ts('%1 : Offline registration (by %2)', [ 1 => $eventTitle, 2 => $userName, - )); + ]); } else { $contributionParams['source'] = $params['source']; @@ -1375,7 +1375,7 @@ public function submit($params) { $contributionParams['contact_id'] = $this->_contactID; $contributionParams['receive_date'] = CRM_Utils_Array::value('receive_date', $params, 'null'); - $recordContribution = array( + $recordContribution = [ 'financial_type_id', 'payment_instrument_id', 'trxn_id', @@ -1384,7 +1384,7 @@ public function submit($params) { 'campaign_id', 'pan_truncation', 'card_type_id', - ); + ]; foreach ($recordContribution as $f) { $contributionParams[$f] = CRM_Utils_Array::value($f, $this->_params); @@ -1439,12 +1439,12 @@ public function submit($params) { if ($this->_single) { if (empty($ids)) { - $ids = array(); + $ids = []; } $contributions[] = CRM_Contribute_BAO_Contribution::create($contributionParams, $ids); } else { - $ids = array(); + $ids = []; foreach ($this->_contactIds as $contactID) { $contributionParams['contact_id'] = $contactID; $contributions[] = CRM_Contribute_BAO_Contribution::create($contributionParams, $ids); @@ -1515,8 +1515,8 @@ public function submit($params) { ); } - $sent = array(); - $notSent = array(); + $sent = []; + $notSent = []; if (!empty($params['send_receipt'])) { if (array_key_exists($params['from_email_address'], $this->_fromEmails['from_email_id'])) { $receiptFrom = $params['from_email_address']; @@ -1524,8 +1524,8 @@ public function submit($params) { $this->assign('module', 'Event Registration'); //use of the message template below requires variables in different format - $event = $events = array(); - $returnProperties = array('event_type_id', 'fee_label', 'start_date', 'end_date', 'is_show_location', 'title'); + $event = $events = []; + $returnProperties = ['event_type_id', 'fee_label', 'start_date', 'end_date', 'is_show_location', 'title']; //get all event details. CRM_Core_DAO::commonRetrieveAll('CRM_Event_DAO_Event', 'id', $params['event_id'], $events, $returnProperties); @@ -1536,7 +1536,7 @@ public function submit($params) { $role = CRM_Event_PseudoConstant::participantRole(); $participantRoles = CRM_Utils_Array::value('role_id', $params); if (is_array($participantRoles)) { - $selectedRoles = array(); + $selectedRoles = []; foreach ($participantRoles as $roleId) { $selectedRoles[] = $role[$roleId]; } @@ -1556,10 +1556,10 @@ public function submit($params) { $this->assign('isShowLocation', $event['is_show_location']); if (CRM_Utils_Array::value('is_show_location', $event) == 1) { - $locationParams = array( + $locationParams = [ 'entity_id' => $params['event_id'], 'entity_table' => 'civicrm_event', - ); + ]; $location = CRM_Core_BAO_Location::getValues($locationParams, TRUE); $this->assign('location', $location); } @@ -1612,13 +1612,13 @@ public function submit($params) { $this->assign('receive_date', $params['receive_date']); } - $participant = array(array('participant_id', '=', $participants[0]->id, 0, 0)); + $participant = [['participant_id', '=', $participants[0]->id, 0, 0]]; // check whether its a test drive ref CRM-3075 if (!empty($this->_defaultValues['is_test'])) { - $participant[] = array('participant_test', '=', 1, 0, 0); + $participant[] = ['participant_test', '=', 1, 0, 0]; } - $customGroup = array(); + $customGroup = []; //format submitted data foreach ($params['custom'] as $fieldID => $values) { foreach ($values as $fieldValue) { @@ -1650,15 +1650,15 @@ public function submit($params) { if ($this->_isPaidEvent) { // fix amount for each of participants ( for bulk mode ) - $eventAmount = array(); + $eventAmount = []; $invoiceSettings = Civi::settings()->get('contribution_invoice_settings'); $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings); $totalTaxAmount = 0; //add dataArray in the receipts in ADD and UPDATE condition - $dataArray = array(); + $dataArray = []; if ($this->_action & CRM_Core_Action::ADD) { - $line = isset($lineItem[0]) ? $lineItem[0] : array(); + $line = isset($lineItem[0]) ? $lineItem[0] : []; } elseif ($this->_action & CRM_Core_Action::UPDATE) { $line = $this->_values['line_items']; @@ -1683,23 +1683,23 @@ public function submit($params) { $params['amount_level'] = preg_replace('//', '', $params['amount_level']) . ' - ' . $this->_contributorDisplayName; } - $eventAmount[$num] = array( + $eventAmount[$num] = [ 'label' => preg_replace('//', '', $params['amount_level']), 'amount' => $params['fee_amount'], - ); + ]; //as we are using same template for online & offline registration. //So we have to build amount as array. $eventAmount = array_merge($eventAmount, $additionalParticipantDetails); $this->assign('amount', $eventAmount); } - $sendTemplateParams = array( + $sendTemplateParams = [ 'groupName' => 'msg_tpl_workflow_event', 'valueName' => 'event_offline_receipt', 'contactId' => $contactID, 'isTest' => !empty($this->_defaultValues['is_test']), 'PDFFilename' => ts('confirmation') . '.pdf', - ); + ]; // try to send emails only if email id is present // and the do-not-email option is not checked for that contact @@ -1774,9 +1774,9 @@ public function setCustomDataTypes() { protected function getStatusMsg($params, $sent, $updateStatusMsg, $notSent) { $statusMsg = ''; if (($this->_action & CRM_Core_Action::UPDATE)) { - $statusMsg = ts('Event registration information for %1 has been updated.', array(1 => $this->_contributorDisplayName)); + $statusMsg = ts('Event registration information for %1 has been updated.', [1 => $this->_contributorDisplayName]); if (!empty($params['send_receipt']) && count($sent)) { - $statusMsg .= ' ' . ts('A confirmation email has been sent to %1', array(1 => $this->_contributorEmail)); + $statusMsg .= ' ' . ts('A confirmation email has been sent to %1', [1 => $this->_contributorEmail]); } if ($updateStatusMsg) { @@ -1785,15 +1785,15 @@ protected function getStatusMsg($params, $sent, $updateStatusMsg, $notSent) { } elseif ($this->_action & CRM_Core_Action::ADD) { if ($this->_single) { - $statusMsg = ts('Event registration for %1 has been added.', array(1 => $this->_contributorDisplayName)); + $statusMsg = ts('Event registration for %1 has been added.', [1 => $this->_contributorDisplayName]); if (!empty($params['send_receipt']) && count($sent)) { - $statusMsg .= ' ' . ts('A confirmation email has been sent to %1.', array(1 => $this->_contributorEmail)); + $statusMsg .= ' ' . ts('A confirmation email has been sent to %1.', [1 => $this->_contributorEmail]); } } else { - $statusMsg = ts('Total Participant(s) added to event: %1.', array(1 => count($this->_contactIds))); + $statusMsg = ts('Total Participant(s) added to event: %1.', [1 => count($this->_contactIds)]); if (count($notSent) > 0) { - $statusMsg .= ' ' . ts('Email has NOT been sent to %1 contact(s) - communication preferences specify DO NOT EMAIL OR valid Email is NOT present. ', array(1 => count($notSent))); + $statusMsg .= ' ' . ts('Email has NOT been sent to %1 contact(s) - communication preferences specify DO NOT EMAIL OR valid Email is NOT present. ', [1 => count($notSent)]); } elseif (isset($params['send_receipt'])) { $statusMsg .= ' ' . ts('A confirmation email has been sent to ALL participants'); diff --git a/CRM/Event/Form/ParticipantFeeSelection.php b/CRM/Event/Form/ParticipantFeeSelection.php index e6df3cf3ae03..50511fba177e 100644 --- a/CRM/Event/Form/ParticipantFeeSelection.php +++ b/CRM/Event/Form/ParticipantFeeSelection.php @@ -111,7 +111,7 @@ public function preProcess() { $this->assign('lineItemTotal', $total); } - $title = ts("Change selections for %1", array(1 => $this->_contributorDisplayName)); + $title = ts("Change selections for %1", [1 => $this->_contributorDisplayName]); if ($title) { CRM_Utils_System::setTitle($title); } @@ -123,7 +123,7 @@ public function preProcess() { * @return array */ public function setDefaultValues() { - $params = array('id' => $this->_participantId); + $params = ['id' => $this->_participantId]; CRM_Event_BAO_Participant::getValues($params, $defaults, $ids); $priceSetId = CRM_Price_BAO_PriceSet::getFor('civicrm_event', $this->_eventId); @@ -163,12 +163,12 @@ public function buildQuickForm() { $this->assign('currencySymbol', $config->defaultCurrencySymbol); // line items block - $lineItem = $event = array(); - $params = array('id' => $this->_eventId); + $lineItem = $event = []; + $params = ['id' => $this->_eventId]; CRM_Event_BAO_Event::retrieve($params, $event); //retrieve custom information - $this->_values = array(); + $this->_values = []; CRM_Event_Form_Registration::initEventFee($this, $event['id']); CRM_Event_Form_Registration_Register::buildAmount($this, TRUE); @@ -181,16 +181,16 @@ public function buildQuickForm() { $statusOptions = CRM_Event_PseudoConstant::participantStatus(NULL, NULL, 'label'); $this->add('select', 'status_id', ts('Participant Status'), - array( + [ '' => ts('- select -'), - ) + $statusOptions, + ] + $statusOptions, TRUE ); $this->addElement('checkbox', 'send_receipt', ts('Send Confirmation?'), NULL, - array('onclick' => "showHideByValue('send_receipt','','notice','table-row','radio',false); showHideByValue('send_receipt','','from-email','table-row','radio',false);") + ['onclick' => "showHideByValue('send_receipt','','notice','table-row','radio',false); showHideByValue('send_receipt','','from-email','table-row','radio',false);"] ); $this->add('select', 'from_email_address', ts('Receipt From'), $this->_fromEmails['from_email_id']); @@ -200,26 +200,26 @@ public function buildQuickForm() { $noteAttributes = CRM_Core_DAO::getAttribute('CRM_Core_DAO_Note'); $this->add('textarea', 'note', ts('Notes'), $noteAttributes['note']); - $buttons[] = array( + $buttons[] = [ 'type' => 'upload', 'name' => ts('Save'), 'isDefault' => TRUE, - ); + ]; if (CRM_Event_BAO_Participant::isPrimaryParticipant($this->_participantId)) { - $buttons[] = array( + $buttons[] = [ 'type' => 'upload', 'name' => ts('Save and Record Payment'), 'subName' => 'new', - ); + ]; } - $buttons[] = array( + $buttons[] = [ 'type' => 'cancel', 'name' => ts('Cancel'), - ); + ]; $this->addButtons($buttons); - $this->addFormRule(array('CRM_Event_Form_ParticipantFeeSelection', 'formRule'), $this); + $this->addFormRule(['CRM_Event_Form_ParticipantFeeSelection', 'formRule'], $this); } /** @@ -230,7 +230,7 @@ public function buildQuickForm() { * @return array */ public static function formRule($fields, $files, $self) { - $errors = array(); + $errors = []; return $errors; } @@ -243,7 +243,7 @@ public function postProcess() { $this->contributionAmt = CRM_Core_DAO::getFieldValue('CRM_Contribute_BAO_Contribution', $this->_contributionId, 'total_amount'); // email sending if (!empty($params['send_receipt'])) { - $fetchParticipantVals = array('id' => $this->_participantId); + $fetchParticipantVals = ['id' => $this->_participantId]; CRM_Event_BAO_Participant::getValues($fetchParticipantVals, $participantDetails, CRM_Core_DAO::$_nullArray); $participantParams = array_merge($params, $participantDetails[$this->_participantId]); $mailSent = $this->emailReceipt($participantParams); @@ -252,13 +252,13 @@ public function postProcess() { // update participant CRM_Core_DAO::setFieldValue('CRM_Event_DAO_Participant', $this->_participantId, 'status_id', $params['status_id']); if (!empty($params['note'])) { - $noteParams = array( + $noteParams = [ 'entity_table' => 'civicrm_participant', 'note' => $params['note'], 'entity_id' => $this->_participantId, 'contact_id' => $this->_contactId, 'modified_date' => date('Ymd'), - ); + ]; CRM_Core_BAO_Note::add($noteParams); } CRM_Core_Session::setStatus(ts("The fee selection has been changed for this participant"), ts('Saved'), 'success'); @@ -279,7 +279,7 @@ public function postProcess() { */ public function emailReceipt(&$params) { $updatedLineItem = CRM_Price_BAO_LineItem::getLineItems($this->_participantId, 'participant', FALSE, FALSE); - $lineItem = array(); + $lineItem = []; if ($updatedLineItem) { $lineItem[] = $updatedLineItem; } @@ -292,8 +292,8 @@ public function emailReceipt(&$params) { $this->assign('module', 'Event Registration'); //use of the message template below requires variables in different format - $event = $events = array(); - $returnProperties = array('fee_label', 'start_date', 'end_date', 'is_show_location', 'title'); + $event = $events = []; + $returnProperties = ['fee_label', 'start_date', 'end_date', 'is_show_location', 'title']; //get all event details. CRM_Core_DAO::commonRetrieveAll('CRM_Event_DAO_Event', 'id', $params['event_id'], $events, $returnProperties); @@ -304,7 +304,7 @@ public function emailReceipt(&$params) { $role = CRM_Event_PseudoConstant::participantRole(); $participantRoles = CRM_Utils_Array::value('role_id', $params); if (is_array($participantRoles)) { - $selectedRoles = array(); + $selectedRoles = []; foreach (array_keys($participantRoles) as $roleId) { $selectedRoles[] = $role[$roleId]; } @@ -324,10 +324,10 @@ public function emailReceipt(&$params) { $this->assign('isShowLocation', $event['is_show_location']); if (CRM_Utils_Array::value('is_show_location', $event) == 1) { - $locationParams = array( + $locationParams = [ 'entity_id' => $params['event_id'], 'entity_table' => 'civicrm_event', - ); + ]; $location = CRM_Core_BAO_Location::getValues($locationParams, TRUE); $this->assign('location', $location); } @@ -366,13 +366,13 @@ public function emailReceipt(&$params) { $this->assign('contactID', $this->_contactId); $this->assign('participantID', $this->_participantId); - $sendTemplateParams = array( + $sendTemplateParams = [ 'groupName' => 'msg_tpl_workflow_event', 'valueName' => 'event_offline_receipt', 'contactId' => $this->_contactId, 'isTest' => FALSE, 'PDFFilename' => ts('confirmation') . '.pdf', - ); + ]; // try to send emails only if email id is present // and the do-not-email option is not checked for that contact diff --git a/CRM/Event/Form/ParticipantView.php b/CRM/Event/Form/ParticipantView.php index f5f22bdc44c2..ddafbc922602 100644 --- a/CRM/Event/Form/ParticipantView.php +++ b/CRM/Event/Form/ParticipantView.php @@ -47,10 +47,10 @@ class CRM_Event_Form_ParticipantView extends CRM_Core_Form { * @return void */ public function preProcess() { - $values = $ids = array(); + $values = $ids = []; $participantID = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE); $contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE); - $params = array('id' => $participantID); + $params = ['id' => $participantID]; CRM_Event_BAO_Participant::getValues($params, $values, @@ -103,16 +103,16 @@ public function preProcess() { // CRM-20879: Show 'Transfer or Cancel' option beside 'Change fee selection' // only if logged in user have 'edit event participants' permission and // participant status is not Cancelled or Transferred - if (CRM_Core_Permission::check('edit event participants') && !in_array($status, array('Cancelled', 'Transferred'))) { + if (CRM_Core_Permission::check('edit event participants') && !in_array($status, ['Cancelled', 'Transferred'])) { $this->assign('transferOrCancelLink', CRM_Utils_System::url( 'civicrm/event/selfsvcupdate', - array( + [ 'reset' => 1, 'is_backoffice' => 1, 'pid' => $participantID, 'cs' => CRM_Contact_BAO_Contact_Utils::generateChecksum($contactID, NULL, 'inf'), - ) + ] ) ); } @@ -155,8 +155,8 @@ public function preProcess() { $eventNameCustomDataTypeID = array_search('ParticipantEventName', $customDataType); $eventTypeCustomDataTypeID = array_search('ParticipantEventType', $customDataType); $allRoleIDs = explode(CRM_Core_DAO::VALUE_SEPARATOR, $values[$participantID]['role_id']); - $groupTree = array(); - $finalTree = array(); + $groupTree = []; + $finalTree = []; foreach ($allRoleIDs as $k => $v) { $roleGroupTree = CRM_Core_BAO_CustomGroup::getTree('Participant', NULL, $participantID, NULL, $v, $roleCustomDataTypeID); @@ -192,7 +192,7 @@ public function preProcess() { "action=view&reset=1&id={$values[$participantID]['id']}&cid={$values[$participantID]['contact_id']}&context=home" ); - $recentOther = array(); + $recentOther = []; if (CRM_Core_Permission::check('edit event participants')) { $recentOther['editUrl'] = CRM_Utils_System::url('civicrm/contact/view/participant', "action=update&reset=1&id={$values[$participantID]['id']}&cid={$values[$participantID]['contact_id']}&context=home" @@ -207,7 +207,7 @@ public function preProcess() { $participantRoles = CRM_Event_PseudoConstant::participantRole(); $displayName = CRM_Contact_BAO_Contact::displayName($values[$participantID]['contact_id']); - $participantCount = array(); + $participantCount = []; $invoiceSettings = Civi::settings()->get('contribution_invoice_settings'); $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings); $totalTaxAmount = 0; @@ -231,7 +231,7 @@ public function preProcess() { $title = $displayName . ' (' . CRM_Utils_Array::value($roleId, $participantRoles) . ' - ' . $eventTitle . ')'; $sep = CRM_Core_DAO::VALUE_SEPARATOR; - $viewRoles = array(); + $viewRoles = []; foreach (explode($sep, $values[$participantID]['role_id']) as $k => $v) { $viewRoles[] = $participantRoles[$v]; } @@ -254,14 +254,14 @@ public function preProcess() { * @return void */ public function buildQuickForm() { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'cancel', 'name' => ts('Done'), 'spacing' => '         ', 'isDefault' => TRUE, - ), - ) + ], + ] ); } diff --git a/CRM/Event/Form/Registration/AdditionalParticipant.php b/CRM/Event/Form/Registration/AdditionalParticipant.php index 7162150bee97..0d3fd08099c6 100644 --- a/CRM/Event/Form/Registration/AdditionalParticipant.php +++ b/CRM/Event/Form/Registration/AdditionalParticipant.php @@ -59,7 +59,7 @@ public function preProcess() { $participantCnt = $participantNo + 1; $this->assign('formId', $participantNo); - $this->_params = array(); + $this->_params = []; $this->_params = $this->get('params'); $participantTot = $this->_params[0]['additional_participants'] + 1; @@ -67,7 +67,7 @@ public function preProcess() { if ($skipCount) { $this->assign('skipCount', $skipCount); } - CRM_Utils_System::setTitle(ts('Register Participant %1 of %2', array(1 => $participantCnt, 2 => $participantTot))); + CRM_Utils_System::setTitle(ts('Register Participant %1 of %2', [1 => $participantCnt, 2 => $participantTot])); //CRM-4320, hack to check last participant. $this->_lastParticipant = FALSE; @@ -85,7 +85,7 @@ public function preProcess() { * @return void */ public function setDefaultValues() { - $defaults = $unsetSubmittedOptions = array(); + $defaults = $unsetSubmittedOptions = []; $discountId = NULL; //fix for CRM-3088, default value for discount set. if (!empty($this->_values['discount'])) { @@ -102,7 +102,7 @@ public function setDefaultValues() { continue; } - $optionsFull = CRM_Utils_Array::value('option_full_ids', $val, array()); + $optionsFull = CRM_Utils_Array::value('option_full_ids', $val, []); foreach ($val['options'] as $keys => $values) { if ($values['is_default'] && !in_array($keys, $optionsFull)) { if ($val['html_type'] == 'CheckBox') { @@ -180,19 +180,19 @@ public function buildQuickForm() { CRM_Event_Form_Registration_Register::buildAmount($this); } $first_name = $last_name = NULL; - $pre = $post = array(); - foreach (array( + $pre = $post = []; + foreach ([ 'pre', 'post', - ) as $keys) { + ] as $keys) { if (isset($this->_values['additional_custom_' . $keys . '_id'])) { $this->buildCustom($this->_values['additional_custom_' . $keys . '_id'], 'additionalCustom' . ucfirst($keys)); $$keys = CRM_Core_BAO_UFGroup::getFields($this->_values['additional_custom_' . $keys . '_id']); } - foreach (array( + foreach ([ 'first_name', 'last_name', - ) as $name) { + ] as $name) { if (array_key_exists($name, $$keys) && CRM_Utils_Array::value('is_required', CRM_Utils_Array::value($name, $$keys)) ) { @@ -209,7 +209,7 @@ public function buildQuickForm() { //add buttons $js = NULL; if ($this->isLastParticipant(TRUE) && empty($this->_values['event']['is_monetary'])) { - $js = array('onclick' => "return submitOnce(this,'" . $this->_name . "','" . ts('Processing') . "');"); + $js = ['onclick' => "return submitOnce(this,'" . $this->_name . "','" . ts('Processing') . "');"]; } //handle case where user might sart with waiting by group @@ -262,23 +262,23 @@ public function buildQuickForm() { $this->_allowWaitlist = FALSE; $this->set('allowWaitlist', $this->_allowWaitlist); if ($this->_requireApproval) { - $statusMessage = ts("It looks like you are now registering a group of %1 participants. The event has %2 available spaces (you will not be wait listed). Registration for this event requires approval. You will receive an email once your registration has been reviewed.", array( + $statusMessage = ts("It looks like you are now registering a group of %1 participants. The event has %2 available spaces (you will not be wait listed). Registration for this event requires approval. You will receive an email once your registration has been reviewed.", [ 1 => ++$processedCnt, 2 => $spaces, - )); + ]); } else { - $statusMessage = ts("It looks like you are now registering a group of %1 participants. The event has %2 available spaces (you will not be wait listed).", array( + $statusMessage = ts("It looks like you are now registering a group of %1 participants. The event has %2 available spaces (you will not be wait listed).", [ 1 => ++$processedCnt, 2 => $spaces, - )); + ]); } } else { - $statusMessage = ts("It looks like you are now registering a group of %1 participants. The event has %2 available spaces (you will not be wait listed). Please go back to the main registration page and reduce the number of additional people. You will also need to complete payment information.", array( + $statusMessage = ts("It looks like you are now registering a group of %1 participants. The event has %2 available spaces (you will not be wait listed). Please go back to the main registration page and reduce the number of additional people. You will also need to complete payment information.", [ 1 => ++$processedCnt, 2 => $spaces, - )); + ]); $allowToProceed = FALSE; } CRM_Core_Session::setStatus($statusMessage, ts('Registration Error'), 'error'); @@ -344,40 +344,40 @@ public function buildQuickForm() { $this->assign('statusMessage', $statusMessage); - $buttons = array( - array( + $buttons = [ + [ 'type' => 'back', 'name' => ts('Go Back'), 'spacing' => '    ', - ), - ); + ], + ]; //CRM-4320 if ($allowToProceed) { - $buttons = array_merge($buttons, array( - array( + $buttons = array_merge($buttons, [ + [ 'type' => 'upload', 'name' => ts('Continue'), 'spacing' => '                  ', 'isDefault' => TRUE, 'js' => $js, - ), - ) + ], + ] ); if ($includeSkipButton) { - $buttons = array_merge($buttons, array( - array( + $buttons = array_merge($buttons, [ + [ 'type' => 'next', 'name' => ts('Skip Participant'), 'subName' => 'skip', 'icon' => 'fa-fast-forward', - ), - ) + ], + ] ); } } $this->addButtons($buttons); - $this->addFormRule(array('CRM_Event_Form_Registration_AdditionalParticipant', 'formRule'), $this); + $this->addFormRule(['CRM_Event_Form_Registration_AdditionalParticipant', 'formRule'], $this); $this->unsavedChangesWarn = TRUE; } @@ -395,7 +395,7 @@ public function buildQuickForm() { * true if no errors, else array of errors */ public static function formRule($fields, $files, $self) { - $errors = array(); + $errors = []; //get the button name. $button = substr($self->controller->getButtonName(), -4); @@ -430,8 +430,8 @@ public static function formRule($fields, $files, $self) { if ($key != $addParticipantNum) { if (!$self->_values['event']['allow_same_participant_emails']) { //collect all email fields - $existingEmails = array(); - $additionalParticipantEmails = array(); + $existingEmails = []; + $additionalParticipantEmails = []; if (is_array($value)) { foreach ($value as $key => $val) { if (substr($key, 0, 6) == 'email-' && $val) { @@ -474,7 +474,7 @@ public static function formRule($fields, $files, $self) { //validate price field params. $priceSetErrors = self::validatePriceSet($self, $allParticipantParams); - $errors = array_merge($errors, CRM_Utils_Array::value($addParticipantNum, $priceSetErrors, array())); + $errors = array_merge($errors, CRM_Utils_Array::value($addParticipantNum, $priceSetErrors, [])); if (!$self->_allowConfirmation && is_numeric($self->_availableRegistrations) @@ -492,10 +492,10 @@ public static function formRule($fields, $files, $self) { if (!$self->_allowConfirmation && empty($self->_values['event']['has_waitlist']) && $totalParticipants > $self->_availableRegistrations ) { - $errors['_qf_default'] = ts('Sorry, it looks like this event only has %2 spaces available, and you are trying to register %1 participants. Please change your selections accordingly.', array( + $errors['_qf_default'] = ts('Sorry, it looks like this event only has %2 spaces available, and you are trying to register %1 participants. Please change your selections accordingly.', [ 1 => $totalParticipants, 2 => $self->_availableRegistrations, - )); + ]); } } } @@ -550,7 +550,7 @@ public function validatePaymentValues($self, $fields) { $validatePayement = FALSE; if (!empty($fields['priceSetId'])) { - $lineItem = array(); + $lineItem = []; CRM_Price_BAO_PriceSet::processAmount($self->_values['fee'], $fields, $lineItem); if ($fields['amount'] > 0) { $validatePayement = TRUE; @@ -568,7 +568,7 @@ public function validatePaymentValues($self, $fields) { return TRUE; } - $errors = array(); + $errors = []; CRM_Core_Form::validateMandatoryFields($self->_fields, $fields, $errors); @@ -688,7 +688,7 @@ public function postProcess() { $params['amount'] = $this->_values['fee'][$params['amount']]['value']; } else { - $lineItem = array(); + $lineItem = []; CRM_Price_BAO_PriceSet::processAmount($this->_values['fee'], $params, $lineItem); //build line item array.. @@ -733,7 +733,7 @@ public function postProcess() { $participantNo = count($this->_params); if ($button != 'skip') { - $statusMsg = ts('Registration information for participant %1 has been saved.', array(1 => $participantNo)); + $statusMsg = ts('Registration information for participant %1 has been saved.', [1 => $participantNo]); CRM_Core_Session::setStatus($statusMsg, ts('Registration Saved'), 'success'); } @@ -754,12 +754,12 @@ public function postProcess() { * @return array */ public static function &getPages($additionalParticipant) { - $details = array(); + $details = []; for ($i = 1; $i <= $additionalParticipant; $i++) { - $details["Participant_{$i}"] = array( + $details["Participant_{$i}"] = [ 'className' => 'CRM_Event_Form_Registration_AdditionalParticipant', 'title' => "Register Additional Participant {$i}", - ); + ]; } return $details; } diff --git a/CRM/Event/Form/Registration/Confirm.php b/CRM/Event/Form/Registration/Confirm.php index 3284eb437f52..cdff40124f85 100644 --- a/CRM/Event/Form/Registration/Confirm.php +++ b/CRM/Event/Form/Registration/Confirm.php @@ -85,7 +85,7 @@ public function preProcess() { // The concept of contributeMode is deprecated. if ($this->_contributeMode == 'express') { - $params = array(); + $params = []; // rfp == redirect from paypal // rfp is probably not required - the getPreApprovalDetails should deal with any payment-processor specific 'stuff' $rfp = CRM_Utils_Request::retrieve('rfp', 'Boolean', @@ -114,14 +114,14 @@ public function preProcess() { // also merge all the other values from the profile fields $values = $this->controller->exportValues('Register'); - $skipFields = array( + $skipFields = [ 'amount', "street_address-{$this->_bltID}", "city-{$this->_bltID}", "state_province_id-{$this->_bltID}", "postal_code-{$this->_bltID}", "country_id-{$this->_bltID}", - ); + ]; foreach ($values as $name => $value) { // skip amount field @@ -211,7 +211,7 @@ public function buildQuickForm() { ($this->_params[0]['amount'] || $this->_params[0]['amount'] == 0) && !$this->_requireApproval ) { - $this->_amount = array(); + $this->_amount = []; $taxAmount = 0; foreach ($this->_params as $k => $v) { @@ -223,10 +223,10 @@ public function buildQuickForm() { $taxAmount += $v['tax_amount']; if (is_array($v)) { $this->cleanMoneyFields($v); - foreach (array( + foreach ([ 'first_name', 'last_name', - ) as $name) { + ] as $name) { if (isset($v['billing_' . $name]) && !isset($v[$name]) ) { @@ -285,7 +285,7 @@ public function buildQuickForm() { } if ($this->_priceSetId && !CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_priceSetId, 'is_quick_config')) { - $lineItemForTemplate = array(); + $lineItemForTemplate = []; $getTaxDetails = FALSE; if (!empty($this->_lineItem) && is_array($this->_lineItem)) { foreach ($this->_lineItem as $key => $value) { @@ -314,22 +314,22 @@ public function buildQuickForm() { $this->assign('isAmountzero', ($this->_totalAmount <= 0) ? TRUE : FALSE); $contribButton = ts('Continue'); - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'back', 'name' => ts('Go Back'), - ), - array( + ], + [ 'type' => 'next', 'name' => $contribButton, 'isDefault' => TRUE, - 'js' => array('onclick' => "return submitOnce(this,'" . $this->_name . "','" . ts('Processing') . "');"), - ), - ) + 'js' => ['onclick' => "return submitOnce(this,'" . $this->_name . "','" . ts('Processing') . "');"], + ], + ] ); - $defaults = array(); - $fields = array(); + $defaults = []; + $fields = []; if (!empty($this->_fields)) { foreach ($this->_fields as $name => $dontCare) { $fields[$name] = 1; @@ -365,7 +365,7 @@ public function buildQuickForm() { // Assign Participant Count to Lineitem Table $this->assign('pricesetFieldsCount', CRM_Price_BAO_PriceSet::getPricesetCount($this->_priceSetId)); - $this->addFormRule(array('CRM_Event_Form_Registration_Confirm', 'formRule'), $this); + $this->addFormRule(['CRM_Event_Form_Registration_Confirm', 'formRule'], $this); } /** @@ -378,7 +378,7 @@ public function buildQuickForm() { * @return array|bool */ public static function formRule($fields, $files, $self) { - $errors = array(); + $errors = []; $eventFull = CRM_Event_BAO_Participant::eventFull($self->_eventId, FALSE, CRM_Utils_Array::value('has_waitlist', $self->_values['event'])); if ($eventFull && empty($self->_allowConfirmation)) { if (empty($self->_allowWaitlist)) { @@ -442,7 +442,7 @@ public function postProcess() { if ($this->_values['event']['is_monetary']) { $this->set('finalAmount', $this->_amount); } - $participantCount = array(); + $participantCount = []; $taxAmount = $totalTaxAmount = 0; //unset the skip participant from params. @@ -472,8 +472,8 @@ public function postProcess() { $payment = $registerByID = $primaryCurrencyID = $contribution = NULL; $paymentObjError = ts('The system did not record payment details for this payment and so could not process the transaction. Please report this error to the site administrator.'); - $this->participantIDS = array(); - $fields = array(); + $this->participantIDS = []; + $fields = []; foreach ($params as $key => $value) { CRM_Event_Form_Registration_Confirm::fixLocationFields($value, $fields, $this); //unset the billing parameters if it is pay later mode @@ -486,7 +486,7 @@ public function postProcess() { || (!empty($value['is_pay_later']) && !$this->_isBillingAddressRequiredForPayLater) || empty($value['is_primary']) ) { - $billingFields = array( + $billingFields = [ "email-{$this->_bltID}", 'billing_first_name', 'billing_middle_name', @@ -499,7 +499,7 @@ public function postProcess() { "billing_country-{$this->_bltID}", "billing_country_id-{$this->_bltID}", "address_name-{$this->_bltID}", - ); + ]; foreach ($billingFields as $field) { unset($value[$field]); } @@ -696,14 +696,14 @@ public function postProcess() { if ($this->_allowConfirmation && !empty($this->_additionalParticipantIds) ) { - $allParticipantIds = array_merge(array($registerByID), $this->_additionalParticipantIds); + $allParticipantIds = array_merge([$registerByID], $this->_additionalParticipantIds); } $entityTable = 'civicrm_participant'; $invoiceSettings = Civi::settings()->get('contribution_invoice_settings'); $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings); $totalTaxAmount = 0; - $dataArray = array(); + $dataArray = []; foreach ($this->_lineItem as $key => $value) { if ($value == 'skip') { continue; @@ -803,7 +803,7 @@ public function postProcess() { } // get values of line items if ($this->_amount) { - $amount = array(); + $amount = []; $amount[$participantNum]['label'] = preg_replace('//', '', $params[$participantNum]['amount_level']); $amount[$participantNum]['amount'] = $params[$participantNum]['amount']; $params[$participantNum]['amounts'] = $amount; @@ -811,7 +811,7 @@ public function postProcess() { if (!empty($this->_lineItem)) { $lineItems = $this->_lineItem; - $lineItem = array(); + $lineItem = []; if ($lineItemValue = CRM_Utils_Array::value($participantNum, $lineItems)) { $lineItem[] = $lineItemValue; } @@ -893,8 +893,8 @@ public function postProcess() { unset($participantCount[$participantNum]); } // Change $this->_values['participant'] to include additional participant values - $ids = $participantValues = array(); - $participantParams = array('id' => $participantID); + $ids = $participantValues = []; + $participantParams = ['id' => $participantID]; CRM_Event_BAO_Participant::getValues($participantParams, $participantValues, $ids); $this->_values['participant'] = $participantValues[$participantID]; @@ -902,7 +902,7 @@ public function postProcess() { $this->assign('customProfile', NULL); //Additional Participant should get only it's payment information if (!empty($this->_amount)) { - $amount = array(); + $amount = []; $params = $this->get('params'); $amount[$participantNum]['label'] = preg_replace('//', '', $params[$participantNum]['amount_level']); $amount[$participantNum]['amount'] = $params[$participantNum]['amount']; @@ -910,7 +910,7 @@ public function postProcess() { } if ($this->_lineItem) { $lineItems = $this->_lineItem; - $lineItem = array(); + $lineItem = []; if ($lineItemValue = CRM_Utils_Array::value($participantNum, $lineItems)) { $lineItem[] = $lineItemValue; } @@ -920,7 +920,7 @@ public function postProcess() { $this->assign('dataArray', $dataArray); $this->assign('totalAmount', $individual[$participantNum]['totalAmtWithTax']); $this->assign('totalTaxAmount', $individual[$participantNum]['totalTaxAmt']); - $this->assign('individual', array($individual[$participantNum])); + $this->assign('individual', [$individual[$participantNum]]); } $this->assign('lineItem', $lineItem); } @@ -975,7 +975,7 @@ public static function processContribution( // CRM-20264: fetch CC type ID and number (last 4 digit) and assign it back to $params CRM_Contribute_Form_AbstractEditPayment::formatCreditCardDetails($params); - $contribParams = array( + $contribParams = [ 'contact_id' => $contactID, 'financial_type_id' => !empty($form->_values['event']['financial_type_id']) ? $form->_values['event']['financial_type_id'] : $params['financial_type_id'], 'receive_date' => $now, @@ -989,7 +989,7 @@ public static function processContribution( 'campaign_id' => CRM_Utils_Array::value('campaign_id', $params), 'card_type_id' => CRM_Utils_Array::value('card_type_id', $params), 'pan_truncation' => CRM_Utils_Array::value('pan_truncation', $params), - ); + ]; if ($paymentProcessor) { $contribParams['payment_instrument_id'] = $paymentProcessor['payment_instrument_id']; @@ -997,12 +997,12 @@ public static function processContribution( } if (!$pending && $result) { - $contribParams += array( + $contribParams += [ 'fee_amount' => CRM_Utils_Array::value('fee_amount', $result), 'net_amount' => CRM_Utils_Array::value('net_amount', $result, $params['amount']), 'trxn_id' => $result['trxn_id'], 'receipt_date' => $receiptDate, - ); + ]; } $allStatuses = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name'); @@ -1084,7 +1084,7 @@ public static function fixLocationFields(&$params, &$fields, &$form) { // the billing fields (if they are set) if (is_array($fields)) { if (!array_key_exists('first_name', $fields)) { - $nameFields = array('first_name', 'middle_name', 'last_name'); + $nameFields = ['first_name', 'middle_name', 'last_name']; foreach ($nameFields as $name) { $fields[$name] = 1; if (array_key_exists("billing_$name", $params)) { @@ -1130,7 +1130,7 @@ public static function updateContactFields($contactID, $params, $fields, &$form) //particular uf group // get the add to groups - $addToGroups = array(); + $addToGroups = []; if (!empty($form->_fields)) { foreach ($form->_fields as $key => $value) { @@ -1202,7 +1202,7 @@ public static function updateContactFields($contactID, $params, $fields, &$form) } //get email primary first if exist - $subscribtionEmail = array('email' => CRM_Utils_Array::value('email-Primary', $params)); + $subscribtionEmail = ['email' => CRM_Utils_Array::value('email-Primary', $params)]; if (!$subscribtionEmail['email']) { $subscribtionEmail['email'] = CRM_Utils_Array::value("email-{$form->_bltID}", $params); } @@ -1221,7 +1221,7 @@ public static function updateContactFields($contactID, $params, $fields, &$form) */ public static function assignProfiles(&$form) { $participantParams = $form->_params; - $formattedValues = $profileFields = array(); + $formattedValues = $profileFields = []; $count = 1; foreach ($participantParams as $participantNum => $participantValue) { if ($participantNum) { @@ -1235,7 +1235,7 @@ public static function assignProfiles(&$form) { if ($participantValue != 'skip') { //get the customPre profile info if (!empty($form->_values[$prefix2 . 'custom_pre_id'])) { - $values = $groupName = array(); + $values = $groupName = []; CRM_Event_BAO_Event::displayProfile($participantValue, $form->_values[$prefix2 . 'custom_pre_id'], $groupName, @@ -1250,9 +1250,9 @@ public static function assignProfiles(&$form) { } //get the customPost profile info if (!empty($form->_values[$prefix2 . 'custom_post_id'])) { - $values = $groupName = array(); + $values = $groupName = []; foreach ($form->_values[$prefix2 . 'custom_post_id'] as $gids) { - $val = array(); + $val = []; CRM_Event_BAO_Event::displayProfile($participantValue, $gids, $group, @@ -1305,11 +1305,11 @@ 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'] = array(); - $form->_values['custom_post_id'] = array(); + $form->_values['custom_pre_id'] = []; + $form->_values['custom_post_id'] = []; $form->_values['event'] = CRM_Utils_Array::value('event', $params); $form->_contributeMode = $params['contributeMode']; - $eventParams = array('id' => $params['id']); + $eventParams = ['id' => $params['id']]; CRM_Event_BAO_Event::retrieve($eventParams, $form->_values['event']); $form->set('registerByID', $params['registerByID']); if (!empty($params['paymentProcessorObj'])) { @@ -1329,14 +1329,14 @@ public static function testSubmit($params) { private function processPayment($payment, $value) { try { $result = $payment->doPayment($value, 'event'); - return array($result, $value); + return [$result, $value]; } catch (\Civi\Payment\Exception\PaymentProcessorException $e) { Civi::log()->error('Payment processor exception: ' . $e->getMessage()); CRM_Core_Session::singleton()->setStatus($e->getMessage()); CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/event/register', "id={$this->_eventId}")); } - return array(); + return []; } /** diff --git a/CRM/Event/Form/Registration/ParticipantConfirm.php b/CRM/Event/Form/Registration/ParticipantConfirm.php index cb7afb0277f4..d672a1e95646 100644 --- a/CRM/Event/Form/Registration/ParticipantConfirm.php +++ b/CRM/Event/Form/Registration/ParticipantConfirm.php @@ -54,12 +54,12 @@ public function preProcess() { $this->_cc = CRM_Utils_Request::retrieve('cc', 'String', $this); //get the contact and event id and assing to session. - $values = array(); + $values = []; $csContactID = NULL; if ($this->_participantId) { - $params = array('id' => $this->_participantId); + $params = ['id' => $this->_participantId]; CRM_Core_DAO::commonRetrieve('CRM_Event_DAO_Participant', $params, $values, - array('contact_id', 'event_id', 'status_id') + ['contact_id', 'event_id', 'status_id'] ); } @@ -95,13 +95,13 @@ public function preProcess() { * @return void */ public function buildQuickForm() { - $params = array('id' => $this->_eventId); - $values = array(); + $params = ['id' => $this->_eventId]; + $values = []; CRM_Core_DAO::commonRetrieve('CRM_Event_DAO_Event', $params, $values, - array('title') + ['title'] ); - $buttons = array(); + $buttons = []; // only pending status class family able to confirm. $statusMsg = NULL; @@ -115,27 +115,27 @@ public function buildQuickForm() { $additonalIds = CRM_Event_BAO_Participant::getAdditionalParticipantIds($this->_participantId); $requireSpace = 1 + count($additonalIds); if ($emptySeats !== NULL && ($requireSpace > $emptySeats)) { - $statusMsg = ts("Oops, it looks like there are currently no available spaces for the %1 event.", array(1 => $values['title'])); + $statusMsg = ts("Oops, it looks like there are currently no available spaces for the %1 event.", [1 => $values['title']]); } else { if ($this->_cc == 'fail') { - $statusMsg = '

    ' . ts('Your Credit Card transaction was not successful. No money has yet been charged to your card.') . '

    ' . ts('Click the "Confirm Registration" button to complete your registration in %1, or click "Cancel Registration" if you are no longer interested in attending this event.', array( + $statusMsg = '
    ' . ts('Your Credit Card transaction was not successful. No money has yet been charged to your card.') . '

    ' . ts('Click the "Confirm Registration" button to complete your registration in %1, or click "Cancel Registration" if you are no longer interested in attending this event.', [ 1 => $values['title'], - )) . '
    '; + ]) . '
    '; } else { - $statusMsg = '
    ' . ts('Confirm your registration for %1.', array( + $statusMsg = '
    ' . ts('Confirm your registration for %1.', [ 1 => $values['title'], - )) . '

    ' . ts('Click the "Confirm Registration" button to begin, or click "Cancel Registration" if you are no longer interested in attending this event.') . '
    '; + ]) . '

    ' . ts('Click the "Confirm Registration" button to begin, or click "Cancel Registration" if you are no longer interested in attending this event.') . '
    '; } - $buttons = array_merge($buttons, array( - array( + $buttons = array_merge($buttons, [ + [ 'type' => 'next', 'name' => ts('Confirm Registration'), 'spacing' => '         ', 'isDefault' => TRUE, - ), - )); + ], + ]); } } @@ -144,21 +144,21 @@ public function buildQuickForm() { CRM_Event_PseudoConstant::participantStatus(NULL, "class != 'Negative'") )) { $cancelConfirm = ts('Are you sure you want to cancel your registration for this event?'); - $buttons = array_merge($buttons, array( - array( + $buttons = array_merge($buttons, [ + [ 'type' => 'submit', 'name' => ts('Cancel Registration'), 'spacing' => '         ', - 'js' => array('onclick' => 'return confirm(\'' . $cancelConfirm . '\');'), - ), - )); + 'js' => ['onclick' => 'return confirm(\'' . $cancelConfirm . '\');'], + ], + ]); if (!$statusMsg) { - $statusMsg = ts('You can cancel your registration for %1 by clicking "Cancel Registration".', array(1 => $values['title'])); + $statusMsg = ts('You can cancel your registration for %1 by clicking "Cancel Registration".', [1 => $values['title']]); } } if (!$statusMsg) { $statusMsg = ts("Oops, it looks like your registration for %1 has already been cancelled.", - array(1 => $values['title']) + [1 => $values['title']] ); } $this->assign('statusMsg', $statusMsg); @@ -196,11 +196,11 @@ public function postProcess() { $cancelledId = array_search('Cancelled', CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Negative'")); $additionalParticipantIds = CRM_Event_BAO_Participant::getAdditionalParticipantIds($participantId); - $participantIds = array_merge(array($participantId), $additionalParticipantIds); + $participantIds = array_merge([$participantId], $additionalParticipantIds); $results = CRM_Event_BAO_Participant::transitionParticipants($participantIds, $cancelledId, NULL, TRUE); if (count($participantIds) > 1) { - $statusMessage = ts("%1 Event registration(s) have been cancelled.", array(1 => count($participantIds))); + $statusMessage = ts("%1 Event registration(s) have been cancelled.", [1 => count($participantIds)]); } else { $statusMessage = ts("Your Event Registration has been cancelled."); @@ -208,7 +208,7 @@ public function postProcess() { if (!empty($results['mailedParticipants'])) { foreach ($results['mailedParticipants'] as $key => $displayName) { - $statusMessage .= "
    " . ts("Email has been sent to : %1", array(1 => $displayName)); + $statusMessage .= "
    " . ts("Email has been sent to : %1", [1 => $displayName]); } } diff --git a/CRM/Event/Form/Registration/Register.php b/CRM/Event/Form/Registration/Register.php index 22025fd50a0e..98f2e6ddd4e4 100644 --- a/CRM/Event/Form/Registration/Register.php +++ b/CRM/Event/Form/Registration/Register.php @@ -82,7 +82,7 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration { * * @var array */ - public $_paymentFields = array(); + public $_paymentFields = []; /** * Get the contact id for the registration. @@ -120,7 +120,7 @@ public function preProcess() { // We hide the payment fields if the event is full or requires approval, // and the current user has not yet been approved CRM-12279 $this->_noFees = (($eventFull || $this->_requireApproval) && !$this->_allowConfirmation); - $this->_paymentProcessors = $this->_noFees ? array() : $this->get('paymentProcessors'); + $this->_paymentProcessors = $this->_noFees ? [] : $this->get('paymentProcessors'); $this->preProcessPaymentOptions(); $this->_allowWaitlist = FALSE; @@ -150,7 +150,7 @@ public function preProcess() { * Set default values for the form. */ public function setDefaultValues() { - $this->_defaults = array(); + $this->_defaults = []; if (!$this->_allowConfirmation && $this->_requireApproval) { $this->_defaults['bypass_payment'] = 1; } @@ -227,7 +227,7 @@ public function setDefaultValues() { if (empty($val['options'])) { continue; } - $optionFullIds = CRM_Utils_Array::value('option_full_ids', $val, array()); + $optionFullIds = CRM_Utils_Array::value('option_full_ids', $val, []); foreach ($val['options'] as $keys => $values) { if ($values['is_default'] && empty($values['is_full'])) { @@ -305,7 +305,7 @@ public function buildQuickForm() { if (!$this->_allowConfirmation || $this->_additionalParticipantIds) { // CRM-17745: Make maximum additional participants configurable // Label is value + 1, since the code sees this is ADDITIONAL participants (in addition to "self") - $additionalOptions = array(); + $additionalOptions = []; $additionalOptions[''] = 1; for ($i = 1; $i <= $this->_values['event']['max_additional_participants']; $i++) { $additionalOptions[$i] = $i + 1; @@ -314,7 +314,7 @@ public function buildQuickForm() { ts('How many people are you registering?'), $additionalOptions, NULL, - array('onChange' => "allowParticipant()") + ['onChange' => "allowParticipant()"] ); $isAdditionalParticipants = TRUE; } @@ -335,7 +335,7 @@ public function buildQuickForm() { //case might be group become as a part of waitlist. //If not waitlist then they require admin approve. $allowGroupOnWaitlist = TRUE; - $this->_waitlistMsg = ts("This event has only %1 space(s) left. If you continue and register more than %1 people (including yourself ), the whole group will be wait listed. Or, you can reduce the number of people you are registering to %1 to avoid being put on the waiting list.", array(1 => $this->_availableRegistrations)); + $this->_waitlistMsg = ts("This event has only %1 space(s) left. If you continue and register more than %1 people (including yourself ), the whole group will be wait listed. Or, you can reduce the number of people you are registering to %1 to avoid being put on the waiting list.", [1 => $this->_availableRegistrations]); if ($this->_requireApproval) { $this->_requireApprovalMsg = CRM_Utils_Array::value('approval_req_text', $this->_values['event'], @@ -363,7 +363,7 @@ public function buildQuickForm() { self::buildAmount($this); } - $pps = array(); + $pps = []; //@todo this processor adding fn is another one duplicated on contribute - a shared // common class would make this sort of thing extractable $onlinePaymentProcessorEnabled = FALSE; @@ -398,7 +398,7 @@ public function buildQuickForm() { } } - $this->addElement('hidden', 'bypass_payment', NULL, array('id' => 'bypass_payment')); + $this->addElement('hidden', 'bypass_payment', NULL, ['id' => 'bypass_payment']); $this->assign('bypassPayment', $bypassPayment); @@ -416,7 +416,7 @@ public function buildQuickForm() { $this->_values['custom_post_id'] ) { if (!is_array($this->_values['custom_post_id'])) { - $profileIDs = array($this->_values['custom_post_id']); + $profileIDs = [$this->_values['custom_post_id']]; } else { $profileIDs = $this->_values['custom_post_id']; @@ -461,7 +461,7 @@ public function buildQuickForm() { $js = NULL; if (empty($this->_values['event']['is_monetary'])) { - $js = array('onclick' => "return submitOnce(this,'" . $this->_name . "','" . ts('Processing') . "');"); + $js = ['onclick' => "return submitOnce(this,'" . $this->_name . "','" . ts('Processing') . "');"]; } // CRM-11182 - Optional confirmation screen @@ -477,19 +477,19 @@ public function buildQuickForm() { $buttonLabel = ts('Continue'); } - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'upload', 'name' => $buttonLabel, 'spacing' => '         ', 'isDefault' => TRUE, 'js' => $js, - ), - ) + ], + ] ); } - $this->addFormRule(array('CRM_Event_Form_Registration_Register', 'formRule'), $this); + $this->addFormRule(['CRM_Event_Form_Registration_Register', 'formRule'], $this); $this->unsavedChangesWarn = TRUE; // add pcp fields @@ -539,7 +539,7 @@ static public function buildAmount(&$form, $required = TRUE, $discountId = NULL) } } if (!is_array($form->_feeBlock)) { - $form->_feeBlock = array(); + $form->_feeBlock = []; } //its time to call the hook. @@ -592,7 +592,7 @@ static public function buildAmount(&$form, $required = TRUE, $discountId = NULL) //user might modified w/ hook. $options = CRM_Utils_Array::value('options', $field); - $formClasses = array('CRM_Event_Form_Participant', 'CRM_Event_Form_ParticipantFeeSelection'); + $formClasses = ['CRM_Event_Form_Participant', 'CRM_Event_Form_ParticipantFeeSelection']; if (!is_array($options)) { continue; @@ -609,7 +609,7 @@ static public function buildAmount(&$form, $required = TRUE, $discountId = NULL) } } - $optionFullIds = CRM_Utils_Array::value('option_full_ids', $field, array()); + $optionFullIds = CRM_Utils_Array::value('option_full_ids', $field, []); //soft suppress required rule when option is full. if (!empty($optionFullIds) && (count($options) == count($optionFullIds))) { @@ -632,14 +632,14 @@ static public function buildAmount(&$form, $required = TRUE, $discountId = NULL) $form->assign('priceSet', $form->_priceSet); } else { - $eventFeeBlockValues = array(); + $eventFeeBlockValues = []; foreach ($form->_feeBlock as $fee) { if (is_array($fee)) { //CRM-7632, CRM-6201 $totalAmountJs = NULL; if ($className == 'CRM_Event_Form_Participant') { - $totalAmountJs = array('onClick' => "fillTotalAmount(" . $fee['value'] . ")"); + $totalAmountJs = ['onClick' => "fillTotalAmount(" . $fee['value'] . ")"]; } $eventFeeBlockValues['amount_id_' . $fee['amount_id']] = $fee['value']; @@ -670,7 +670,7 @@ static public function buildAmount(&$form, $required = TRUE, $discountId = NULL) public static function formatFieldsForOptionFull(&$form) { $priceSet = $form->get('priceSet'); $priceSetId = $form->get('priceSetId'); - $defaultPricefieldIds = array(); + $defaultPricefieldIds = []; if (!empty($form->_values['line_items'])) { foreach ($form->_values['line_items'] as $lineItem) { $defaultPricefieldIds[] = $lineItem['price_field_value_id']; @@ -683,7 +683,7 @@ public static function formatFieldsForOptionFull(&$form) { return; } - $skipParticipants = $formattedPriceSetDefaults = array(); + $skipParticipants = $formattedPriceSetDefaults = []; if (!empty($form->_allowConfirmation) && (isset($form->_pId) || isset($form->_additionalParticipantId))) { $participantId = isset($form->_pId) ? $form->_pId : $form->_additionalParticipantId; $pricesetDefaults = CRM_Event_Form_EventFees::setDefaultPriceSet($participantId, @@ -708,7 +708,7 @@ public static function formatFieldsForOptionFull(&$form) { $optionFullTotalAmount = 0; $currentParticipantNo = (int) substr($form->_name, 12); foreach ($form->_feeBlock as & $field) { - $optionFullIds = array(); + $optionFullIds = []; $fieldId = $field['id']; if (!is_array($field['options'])) { continue; @@ -758,7 +758,7 @@ public static function formatFieldsForOptionFull(&$form) { //ignore option full for offline registration. if ($className == 'CRM_Event_Form_Participant') { - $optionFullIds = array(); + $optionFullIds = []; } //finally get option ids in. @@ -781,7 +781,7 @@ public static function formatFieldsForOptionFull(&$form) { * true if no errors, else array of errors */ public static function formRule($fields, $files, $form) { - $errors = array(); + $errors = []; //check that either an email or firstname+lastname is included in the form(CRM-9587) self::checkProfileComplete($fields, $errors, $form->_eventId); //To check if the user is already registered for the event(CRM-2426) @@ -793,7 +793,7 @@ public static function formRule($fields, $files, $form) { is_numeric($form->_availableRegistrations) && CRM_Utils_Array::value('additional_participants', $fields) >= $form->_availableRegistrations ) { - $errors['additional_participants'] = ts("There is only enough space left on this event for %1 participant(s).", array(1 => $form->_availableRegistrations)); + $errors['additional_participants'] = ts("There is only enough space left on this event for %1 participant(s).", [1 => $form->_availableRegistrations]); } // during confirmation don't allow to increase additional participants, CRM-4320 @@ -801,7 +801,7 @@ public static function formRule($fields, $files, $form) { is_array($form->_additionalParticipantIds) && $fields['additional_participants'] > count($form->_additionalParticipantIds) ) { - $errors['additional_participants'] = ts("Oops. It looks like you are trying to increase the number of additional people you are registering for. You can confirm registration for a maximum of %1 additional people.", array(1 => count($form->_additionalParticipantIds))); + $errors['additional_participants'] = ts("Oops. It looks like you are trying to increase the number of additional people you are registering for. You can confirm registration for a maximum of %1 additional people.", [1 => count($form->_additionalParticipantIds)]); } //don't allow to register w/ waiting if enough spaces available. @@ -825,12 +825,12 @@ public static function formRule($fields, $files, $form) { ) { //format params. $formatted = self::formatPriceSetParams($form, $fields); - $ppParams = array($formatted); + $ppParams = [$formatted]; $priceSetErrors = self::validatePriceSet($form, $ppParams); $primaryParticipantCount = self::getParticipantCount($form, $ppParams); //get price set fields errors in. - $errors = array_merge($errors, CRM_Utils_Array::value(0, $priceSetErrors, array())); + $errors = array_merge($errors, CRM_Utils_Array::value(0, $priceSetErrors, [])); $totalParticipants = $primaryParticipantCount; if (!empty($fields['additional_participants'])) { @@ -842,10 +842,10 @@ public static function formRule($fields, $files, $form) { is_numeric($form->_availableRegistrations) && $form->_availableRegistrations < $totalParticipants ) { - $errors['_qf_default'] = ts("Only %1 Registrations available.", array(1 => $form->_availableRegistrations)); + $errors['_qf_default'] = ts("Only %1 Registrations available.", [1 => $form->_availableRegistrations]); } - $lineItem = array(); + $lineItem = []; CRM_Price_BAO_PriceSet::processAmount($form->_values['fee'], $fields, $lineItem); $minAmt = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $fields['priceSetId'], 'min_amount'); @@ -853,9 +853,9 @@ public static function formRule($fields, $files, $form) { $errors['_qf_default'] = ts('Event Fee(s) can not be less than zero. Please select the options accordingly'); } elseif (!empty($minAmt) && $fields['amount'] < $minAmt) { - $errors['_qf_default'] = ts('A minimum amount of %1 should be selected from Event Fee(s).', array( + $errors['_qf_default'] = ts('A minimum amount of %1 should be selected from Event Fee(s).', [ 1 => CRM_Utils_Money::format($minAmt), - )); + ]); } } @@ -911,7 +911,7 @@ public static function formRule($fields, $files, $form) { $customizedValue = CRM_Core_PseudoConstant::getKey('CRM_Contact_BAO_Contact', $greeting . '_id', 'Customized'); if ($customizedValue == $greetingType && empty($fields[$greeting . '_custom'])) { $errors[$greeting . '_custom'] = ts('Custom %1 is a required field if %1 is of type Customized.', - array(1 => ucwords(str_replace('_', ' ', $greeting))) + [1 => ucwords(str_replace('_', ' ', $greeting))] ); } } @@ -935,7 +935,7 @@ public static function checkProfileComplete($fields, &$errors, $eventId) { } if (!$email && !(!empty($fields['first_name']) && !empty($fields['last_name']))) { - $defaults = $params = array('id' => $eventId); + $defaults = $params = ['id' => $eventId]; CRM_Event_BAO_Event::retrieve($params, $defaults); $message = ts("Mandatory fields (first name and last name, OR email address) are missing from this form."); $errors['_qf_default'] = $message; @@ -1047,7 +1047,7 @@ public function postProcess() { } } else { - $lineItem = array(); + $lineItem = []; CRM_Price_BAO_PriceSet::processAmount($this->_values['fee'], $params, $lineItem); if ($params['tax_amount']) { $this->set('tax_amount', $params['tax_amount']); @@ -1057,11 +1057,11 @@ public function postProcess() { $submittedLineItems[0] = $lineItem; } else { - $submittedLineItems = array($lineItem); + $submittedLineItems = [$lineItem]; } $submittedLineItems = array_filter($submittedLineItems); $this->set('lineItem', $submittedLineItems); - $this->set('lineItemParticipantsCount', array($primaryParticipantCount)); + $this->set('lineItemParticipantsCount', [$primaryParticipantCount]); } $this->set('amount', $params['amount']); @@ -1108,7 +1108,7 @@ public function postProcess() { $this->_params[0] = $params; } else { - $this->_params = array(); + $this->_params = []; $this->_params[] = $params; } $this->set('params', $this->_params); @@ -1156,7 +1156,7 @@ public function postProcess() { else { $params['description'] = ts('Online Event Registration') . ' ' . $this->_values['event']['title']; - $this->_params = array(); + $this->_params = []; $this->_params[] = $params; $this->set('params', $this->_params); @@ -1222,7 +1222,7 @@ public static function checkRegistration($fields, $form, $isAdditional = FALSE) $registerUrl .= '&pcpId=' . $form->_pcpId; } - $status = ts("It looks like you are already registered for this event. If you want to change your registration, or you feel that you've received this message in error, please contact the site administrator.") . ' ' . ts('You can also register another participant.', array(1 => $registerUrl)); + $status = ts("It looks like you are already registered for this event. If you want to change your registration, or you feel that you've received this message in error, please contact the site administrator.") . ' ' . ts('You can also register another participant.', [1 => $registerUrl]); CRM_Core_Session::singleton()->setStatus($status, ts('Oops.'), 'alert'); $url = CRM_Utils_System::url('civicrm/event/info', "reset=1&id={$form->_values['event']['id']}&noFullMsg=true" diff --git a/CRM/Event/Form/Registration/ThankYou.php b/CRM/Event/Form/Registration/ThankYou.php index 600f4891b65d..7c13ada6f6a8 100644 --- a/CRM/Event/Form/Registration/ThankYou.php +++ b/CRM/Event/Form/Registration/ThankYou.php @@ -100,7 +100,7 @@ public function buildQuickForm() { $getTaxDetails = FALSE; $taxAmount = 0; - $lineItemForTemplate = array(); + $lineItemForTemplate = []; if (!empty($this->_lineItem) && is_array($this->_lineItem)) { foreach ($this->_lineItem as $key => $value) { if (!empty($value) && $value != 'skip') { @@ -146,8 +146,8 @@ public function buildQuickForm() { if (CRM_Utils_Array::value('defaultRole', $this->_params[0]) == 1) { $this->assign('defaultRole', TRUE); } - $defaults = array(); - $fields = array(); + $defaults = []; + $fields = []; if (!empty($this->_fields)) { foreach ($this->_fields as $name => $dontCare) { $fields[$name] = 1; @@ -177,7 +177,7 @@ public function buildQuickForm() { $params['entity_id'] = $this->_eventId; $params['entity_table'] = 'civicrm_event'; - $data = array(); + $data = []; CRM_Friend_BAO_Friend::retrieve($params, $data); if (!empty($data['is_active'])) { $friendText = $data['title']; diff --git a/CRM/Event/Form/Search.php b/CRM/Event/Form/Search.php index 3f475d417f11..d6c28eac5bd7 100644 --- a/CRM/Event/Form/Search.php +++ b/CRM/Event/Form/Search.php @@ -104,7 +104,7 @@ public function preProcess() { ); } - $this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues, 0, FALSE, NULL, array('event_id')); + $this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues, 0, FALSE, NULL, ['event_id']); $selector = new CRM_Event_Selector_Search($this->_queryParams, $this->_action, NULL, @@ -148,7 +148,7 @@ public function buildQuickForm() { $rows = $this->get('rows'); if (is_array($rows)) { - $lineItems = $eventIds = array(); + $lineItems = $eventIds = []; if (!$this->_single) { $this->addRowSelectors($rows); } @@ -164,7 +164,7 @@ public function buildQuickForm() { $participantCount = 0; if (count($eventIds) == 1) { //convert form values to clause. - $seatClause = array(); + $seatClause = []; if (CRM_Utils_Array::value('participant_test', $this->_formValues) == '1' || CRM_Utils_Array::value('participant_test', $this->_formValues) == '0') { $seatClause[] = "( participant.is_test = {$this->_formValues['participant_test']} )"; } @@ -175,7 +175,7 @@ public function buildQuickForm() { } } if (!empty($this->_formValues['participant_role_id'])) { - $escapedRoles = array(); + $escapedRoles = []; foreach ((array) $this->_formValues['participant_role_id'] as $participantRole) { $escapedRoles[] = CRM_Utils_Type::escape($participantRole, 'String'); } @@ -205,10 +205,10 @@ public function buildQuickForm() { $tasks = CRM_Event_Task::permissionedTaskTitles(CRM_Core_Permission::getPermission(), $taskParams); if (isset($this->_ssID)) { - $savedSearchValues = array( + $savedSearchValues = [ 'id' => $this->_ssID, 'name' => CRM_Contact_BAO_SavedSearch::getName($this->_ssID, 'title'), - ); + ]; $this->assign_by_ref('savedSearch', $savedSearchValues); $this->assign('ssID', $this->_ssID); } @@ -299,7 +299,7 @@ private function submit($formValues) { CRM_Core_BAO_CustomValue::fixCustomFieldValue($this->_formValues); - $this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues, 0, FALSE, NULL, array('event_id')); + $this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues, 0, FALSE, NULL, ['event_id']); $this->set('formValues', $this->_formValues); $this->set('queryParams', $this->_queryParams); @@ -322,7 +322,7 @@ private function submit($formValues) { ); } - $this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues, 0, FALSE, NULL, array('event_id')); + $this->_queryParams = CRM_Contact_BAO_Query::convertFormValues($this->_formValues, 0, FALSE, NULL, ['event_id']); $selector = new CRM_Event_Selector_Search($this->_queryParams, $this->_action, @@ -381,11 +381,11 @@ public function postProcess() { } $this->_done = TRUE; - $formValues = array(); + $formValues = []; if (!empty($_POST)) { $formValues = $this->controller->exportValues($this->_name); - CRM_Contact_BAO_Query::processSpecialFormValue($this->_formValues, array('participant_status_id')); + CRM_Contact_BAO_Query::processSpecialFormValue($this->_formValues, ['participant_status_id']); } if (empty($this->_formValues)) { @@ -413,7 +413,7 @@ public function addRules() { * the default array reference */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; $defaults = $this->_formValues; return $defaults; } @@ -443,7 +443,7 @@ public function fixFormValues() { elseif (is_array($status) && !array_key_exists('IN', $status)) { $statusTypes = array_keys($status); } - $this->_formValues['participant_status_id'] = is_array($statusTypes) ? array('IN' => array_keys($statusTypes)) : $statusTypes; + $this->_formValues['participant_status_id'] = is_array($statusTypes) ? ['IN' => array_keys($statusTypes)] : $statusTypes; } $role = CRM_Utils_Request::retrieve('role', 'String'); diff --git a/CRM/Event/Form/SearchEvent.php b/CRM/Event/Form/SearchEvent.php index c8910ab05f1b..402535ceb893 100644 --- a/CRM/Event/Form/SearchEvent.php +++ b/CRM/Event/Form/SearchEvent.php @@ -45,7 +45,7 @@ public function getDefaultEntity() { * @return array */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; $defaults['eventsByDates'] = 0; $this->_showHide = new CRM_Core_ShowHideBlocks(); @@ -64,27 +64,27 @@ public function setDefaultValues() { */ public function buildQuickForm() { $this->add('text', 'title', ts('Event Name'), - array(CRM_Core_DAO::getAttribute('CRM_Event_DAO_Event', 'title')) + [CRM_Core_DAO::getAttribute('CRM_Event_DAO_Event', 'title')] ); - $this->addSelect('event_type_id', array('multiple' => TRUE, 'context' => 'search')); + $this->addSelect('event_type_id', ['multiple' => TRUE, 'context' => 'search']); - $eventsByDates = array(); - $searchOption = array(ts('Show Current and Upcoming Events'), ts('Search All or by Date Range')); - $this->addRadio('eventsByDates', ts('Events by Dates'), $searchOption, array('onclick' => "return showHideByValue('eventsByDates','1','id_fromToDates','block','radio',true);"), ' '); + $eventsByDates = []; + $searchOption = [ts('Show Current and Upcoming Events'), ts('Search All or by Date Range')]; + $this->addRadio('eventsByDates', ts('Events by Dates'), $searchOption, ['onclick' => "return showHideByValue('eventsByDates','1','id_fromToDates','block','radio',true);"], ' '); $this->add('datepicker', 'start_date', ts('From'), [], FALSE, ['time' => FALSE]); $this->add('datepicker', 'end_date', ts('To'), [], FALSE, ['time' => FALSE]); CRM_Campaign_BAO_Campaign::addCampaignInComponentSearch($this); - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'refresh', 'name' => ts('Search'), 'isDefault' => TRUE, - ), - )); + ], + ]); } public function postProcess() { @@ -92,7 +92,7 @@ public function postProcess() { $parent = $this->controller->getParent(); $parent->set('searchResult', 1); if (!empty($params)) { - $fields = array('title', 'event_type_id', 'start_date', 'end_date', 'eventsByDates', 'campaign_id'); + $fields = ['title', 'event_type_id', 'start_date', 'end_date', 'eventsByDates', 'campaign_id']; foreach ($fields as $field) { if (isset($params[$field]) && !CRM_Utils_System::isNull($params[$field]) diff --git a/CRM/Event/Form/SelfSvcTransfer.php b/CRM/Event/Form/SelfSvcTransfer.php index 8fd10a2127b9..57821565f1a0 100644 --- a/CRM/Event/Form/SelfSvcTransfer.php +++ b/CRM/Event/Form/SelfSvcTransfer.php @@ -109,7 +109,7 @@ class CRM_Event_Form_SelfSvcTransfer extends CRM_Core_Form { * * @var string */ - protected $_participant = array(); + protected $_participant = []; /** * particpant values * @@ -121,13 +121,13 @@ class CRM_Event_Form_SelfSvcTransfer extends CRM_Core_Form { * * @array string */ - protected $_details = array(); + protected $_details = []; /** * line items * * @array string */ - protected $_line_items = array(); + protected $_line_items = []; /** * contact_id * @@ -155,8 +155,8 @@ public function preProcess() { $this->_from_participant_id = CRM_Utils_Request::retrieve('pid', 'Positive', $this, FALSE, NULL, 'REQUEST'); $this->_userChecksum = CRM_Utils_Request::retrieve('cs', 'String', $this, FALSE, NULL, 'REQUEST'); $this->isBackoffice = CRM_Utils_Request::retrieve('is_backoffice', 'String', $this, FALSE, NULL, 'REQUEST'); - $params = array('id' => $this->_from_participant_id); - $participant = $values = array(); + $params = ['id' => $this->_from_participant_id]; + $participant = $values = []; $this->_participant = CRM_Event_BAO_Participant::getValues($params, $values, $participant); $this->_part_values = $values[$this->_from_participant_id]; $this->set('values', $this->_part_values); @@ -171,7 +171,7 @@ public function preProcess() { if ($this->_from_participant_id) { $this->assign('participantId', $this->_from_participant_id); } - $event = array(); + $event = []; $daoName = 'title'; $this->_event_title = CRM_Event_BAO_Event::getFieldValue('CRM_Event_DAO_Event', $this->_event_id, $daoName); $daoName = 'start_date'; @@ -179,7 +179,7 @@ public function preProcess() { list($displayName, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($this->_from_contact_id); $this->_contact_name = $displayName; $this->_contact_email = $email; - $details = array(); + $details = []; $details = CRM_Event_BAO_Participant::participantDetails($this->_from_participant_id); $optionGroupId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'participant_role', 'id', 'name'); $query = " @@ -214,7 +214,7 @@ public function preProcess() { public function buildQuickForm() { // use entityRef select field for contact when this form is used by staff/admin user if ($this->isBackoffice) { - $this->addEntityRef("contact_id", ts('Select Contact'), array('create' => TRUE), TRUE); + $this->addEntityRef("contact_id", ts('Select Contact'), ['create' => TRUE], TRUE); } // for front-end user show and use the basic three fields used to create a contact else { @@ -223,13 +223,13 @@ public function buildQuickForm() { $this->add('text', 'first_name', ts('To First Name'), ts($this->_to_contact_first_name), TRUE); } - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'submit', - 'name' => ts('Transfer Registration'),), - ) - ); - $this->addFormRule(array('CRM_Event_Form_SelfSvcTransfer', 'formRule'), $this); + 'name' => ts('Transfer Registration'), + ], + ]); + $this->addFormRule(['CRM_Event_Form_SelfSvcTransfer', 'formRule'], $this); parent::buildQuickForm(); } @@ -239,7 +239,7 @@ public function buildQuickForm() { * return @array _defaults */ public function setDefaultValues() { - $this->_defaults = array(); + $this->_defaults = []; return $this->_defaults; } @@ -249,7 +249,7 @@ public function setDefaultValues() { * return array $errors */ public static function formRule($fields, $files, $self) { - $errors = array(); + $errors = []; if (!empty($fields['contact_id'])) { $to_contact_id = $fields['contact_id']; } @@ -279,7 +279,7 @@ public static function checkProfileComplete($fields, &$errors, $self) { } if (!$email && !(CRM_Utils_Array::value('first_name', $fields) && CRM_Utils_Array::value('last_name', $fields))) { - $defaults = $params = array('id' => $eventId); + $defaults = $params = ['id' => $eventId]; CRM_Event_BAO_Event::retrieve($params, $defaults); $message = ts("Mandatory fields (first name and last name, OR email address) are missing from this form."); $errors['_qf_default'] = $message; @@ -290,11 +290,12 @@ public static function checkProfileComplete($fields, &$errors, $self) { $errors['email'] = ts('Enter valid email address.'); } if (empty($errors) && empty($contact_id)) { - $params = array( + $params = [ 'email-Primary' => CRM_Utils_Array::value('email', $fields, NULL), 'first_name' => CRM_Utils_Array::value('first_name', $fields, NULL), 'last_name' => CRM_Utils_Array::value('last_name', $fields, NULL), - 'is_deleted' => CRM_Utils_Array::value('is_deleted', $fields, FALSE),); + 'is_deleted' => CRM_Utils_Array::value('is_deleted', $fields, FALSE), + ]; //create new contact for this name/email pair //if new contact, no need to check for contact already registered $contact_id = CRM_Contact_BAO_Contact::createProfileContact($params, $fields, $contact_id); @@ -337,12 +338,12 @@ public function postProcess() { } else { //cancel 'from' participant row - $contact_id_result = civicrm_api3('Contact', 'get', array( + $contact_id_result = civicrm_api3('Contact', 'get', [ 'sequential' => 1, - 'return' => array("id"), + 'return' => ["id"], 'email' => $params['email'], - 'options' => array('limit' => 1), - )); + 'options' => ['limit' => 1], + ]); $contact_id_result = $contact_id_result['values'][0]; $contact_id = $contact_id_result['contact_id']; $contact_is_deleted = $contact_id_result['contact_is_deleted']; @@ -350,10 +351,10 @@ public function postProcess() { CRM_Core_Error::statusBounce(ts('Contact does not exist.')); } } - $from_participant = $params = array(); + $from_participant = $params = []; $query = "select role_id, source, fee_level, is_test, is_pay_later, fee_amount, discount_id, fee_currency,campaign_id, discount_amount from civicrm_participant where id = " . $this->_from_participant_id; $dao = CRM_Core_DAO::executeQuery($query); - $value_to = array(); + $value_to = []; while ($dao->fetch()) { $value_to['role_id'] = $dao->role_id; $value_to['source'] = $dao->source; @@ -372,7 +373,7 @@ public function postProcess() { $this->participantTransfer($participant); //now update registered_by_id $query = "UPDATE civicrm_participant cp SET cp.registered_by_id = %1 WHERE cp.id = ({$participant->id})"; - $params = array(1 => array($this->_from_participant_id, 'Integer')); + $params = [1 => [$this->_from_participant_id, 'Integer']]; $dao = CRM_Core_DAO::executeQuery($query, $params); //copy line items to new participant $line_items = CRM_Price_BAO_LineItem::getLineItems($this->_from_participant_id); @@ -383,7 +384,7 @@ public function postProcess() { $new_item = CRM_Price_BAO_LineItem::create($item); } //now cancel the from participant record, leaving the original line-item(s) - $value_from = array(); + $value_from = []; $value_from['id'] = $this->_from_participant_id; $tansferId = array_search('Transferred', CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Negative'")); $value_from['status_id'] = $tansferId; @@ -394,8 +395,8 @@ public function postProcess() { CRM_Event_BAO_Participant::create($value_from); $this->sendCancellation(); list($displayName, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($contact_id); - $statusMsg = ts('Event registration information for %1 has been updated.', array(1 => $displayName)); - $statusMsg .= ' ' . ts('A confirmation email has been sent to %1.', array(1 => $email)); + $statusMsg = ts('Event registration information for %1 has been updated.', [1 => $displayName]); + $statusMsg .= ' ' . ts('A confirmation email has been sent to %1.', [1 => $email]); CRM_Core_Session::setStatus($statusMsg, ts('Registration Transferred'), 'success'); if ($this->isBackoffice) { return; @@ -410,19 +411,19 @@ public function postProcess() { * return @ void */ public function participantTransfer($participant) { - $contactDetails = array(); + $contactDetails = []; $contactIds[] = $participant->contact_id; list($currentContactDetails) = CRM_Utils_Token::getTokenDetails($contactIds, NULL, - FALSE, FALSE, NULL, array(), 'CRM_Event_BAO_Participant'); + FALSE, FALSE, NULL, [], 'CRM_Event_BAO_Participant'); foreach ($currentContactDetails as $contactId => $contactValues) { $contactDetails[$contactId] = $contactValues; } $participantRoles = CRM_Event_PseudoConstant::participantRole(); - $participantDetails = array(); + $participantDetails = []; $query = "SELECT * FROM civicrm_participant WHERE id = " . $participant->id; $dao = CRM_Core_DAO::executeQuery($query); while ($dao->fetch()) { - $participantDetails[$dao->id] = array( + $participantDetails[$dao->id] = [ 'id' => $dao->id, 'role' => $participantRoles[$dao->role_id], 'is_test' => $dao->is_test, @@ -432,35 +433,35 @@ public function participantTransfer($participant) { 'contact_id' => $dao->contact_id, 'register_date' => $dao->register_date, 'registered_by_id' => $dao->registered_by_id, - ); + ]; } - $domainValues = array(); + $domainValues = []; if (empty($domainValues)) { $domain = CRM_Core_BAO_Domain::getDomain(); - $tokens = array( + $tokens = [ 'domain' => - array( + [ 'name', 'phone', 'address', 'email', - ), + ], 'contact' => CRM_Core_SelectValues::contactTokens(), - ); + ]; foreach ($tokens['domain'] as $token) { $domainValues[$token] = CRM_Utils_Token::getDomainTokenReplacement($token, $domain); } } - $eventDetails = array(); - $eventParams = array('id' => $participant->event_id); + $eventDetails = []; + $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); //get the location info - $locParams = array( + $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]); if ($toEmail) { @@ -470,14 +471,14 @@ public function participantTransfer($participant) { $receiptFrom = $eventDetails['confirm_from_name'] . ' <' . $eventDetails['confirm_from_email'] . '>'; } $participantName = $contactDetails[$participant->contact_id]['display_name']; - $tplParams = array( + $tplParams = [ 'event' => $eventDetails, 'participant' => $participantDetails[$participant->id], 'participantID' => $participant->id, 'participant_status' => 'Registered', - ); + ]; - $sendTemplateParams = array( + $sendTemplateParams = [ 'groupName' => 'msg_tpl_workflow_event', 'valueName' => 'event_online_receipt', 'contactId' => $participantDetails[$participant->id]['contact_id'], @@ -487,7 +488,7 @@ public function participantTransfer($participant) { 'toEmail' => $toEmail, 'cc' => CRM_Utils_Array::value('cc_confirm', $eventDetails), 'bcc' => CRM_Utils_Array::value('bcc_confirm', $eventDetails), - ); + ]; CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams); } } @@ -498,28 +499,28 @@ public function participantTransfer($participant) { * return @ void */ public function sendCancellation() { - $domainValues = array(); + $domainValues = []; $domain = CRM_Core_BAO_Domain::getDomain(); - $tokens = array( + $tokens = [ 'domain' => - array( + [ 'name', 'phone', 'address', 'email', - ), + ], 'contact' => CRM_Core_SelectValues::contactTokens(), - ); + ]; foreach ($tokens['domain'] as $token) { $domainValues[$token] = CRM_Utils_Token::getDomainTokenReplacement($token, $domain); } - $participantRoles = array(); + $participantRoles = []; $participantRoles = CRM_Event_PseudoConstant::participantRole(); - $participantDetails = array(); + $participantDetails = []; $query = "SELECT * FROM civicrm_participant WHERE id = {$this->_from_participant_id}"; $dao = CRM_Core_DAO::executeQuery($query); while ($dao->fetch()) { - $participantDetails[$dao->id] = array( + $participantDetails[$dao->id] = [ 'id' => $dao->id, 'role' => $participantRoles[$dao->role_id], 'is_test' => $dao->is_test, @@ -529,20 +530,20 @@ public function sendCancellation() { 'contact_id' => $dao->contact_id, 'register_date' => $dao->register_date, 'registered_by_id' => $dao->registered_by_id, - ); + ]; } - $eventDetails = array(); - $eventParams = array('id' => $this->_event_id); + $eventDetails = []; + $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); //get the location info - $locParams = array('entity_id' => $this->_event_id, 'entity_table' => 'civicrm_event'); + $locParams = ['entity_id' => $this->_event_id, 'entity_table' => 'civicrm_event']; $eventDetails[$this->_event_id]['location'] = CRM_Core_BAO_Location::getValues($locParams, TRUE); //get contact details $contactIds[$this->_from_contact_id] = $this->_from_contact_id; list($currentContactDetails) = CRM_Utils_Token::getTokenDetails($contactIds, NULL, - FALSE, FALSE, NULL, array(), + FALSE, FALSE, NULL, [], 'CRM_Event_BAO_Participant' ); foreach ($currentContactDetails as $contactId => $contactValues) { @@ -557,8 +558,8 @@ public function sendCancellation() { "Transferred", "" ); - $statusMsg = ts('Event registration information for %1 has been updated.', array(1 => $this->_contact_name)); - $statusMsg .= ' ' . ts('A cancellation email has been sent to %1.', array(1 => $this->_contact_email)); + $statusMsg = ts('Event registration information for %1 has been updated.', [1 => $this->_contact_name]); + $statusMsg .= ' ' . ts('A cancellation email has been sent to %1.', [1 => $this->_contact_email]); CRM_Core_Session::setStatus($statusMsg, ts('Thanks'), 'success'); } diff --git a/CRM/Event/Form/SelfSvcUpdate.php b/CRM/Event/Form/SelfSvcUpdate.php index 4ef7afc0f568..189cc5b88f78 100644 --- a/CRM/Event/Form/SelfSvcUpdate.php +++ b/CRM/Event/Form/SelfSvcUpdate.php @@ -94,7 +94,7 @@ class CRM_Event_Form_SelfSvcUpdate extends CRM_Core_Form { * * @var string */ - protected $_participant = array(); + protected $_participant = []; /** * particpant values * @@ -106,7 +106,7 @@ class CRM_Event_Form_SelfSvcUpdate extends CRM_Core_Form { * * @var array */ - protected $_details = array(); + protected $_details = []; /** * Is backoffice form? * @@ -122,11 +122,11 @@ public function preProcess() { $config = CRM_Core_Config::singleton(); $session = CRM_Core_Session::singleton(); $this->_userContext = $session->readUserContext(); - $participant = $values = array(); + $participant = $values = []; $this->_participant_id = CRM_Utils_Request::retrieve('pid', 'Positive', $this, FALSE, NULL, 'REQUEST'); $this->_userChecksum = CRM_Utils_Request::retrieve('cs', 'String', $this, FALSE, NULL, 'REQUEST'); $this->isBackoffice = CRM_Utils_Request::retrieve('is_backoffice', 'String', $this, FALSE, NULL, 'REQUEST'); - $params = array('id' => $this->_participant_id); + $params = ['id' => $this->_participant_id]; $this->_participant = CRM_Event_BAO_Participant::getValues($params, $values, $participant); $this->_part_values = $values[$this->_participant_id]; $this->set('values', $this->_part_values); @@ -142,7 +142,7 @@ public function preProcess() { if ($this->_participant_id) { $this->assign('participantId', $this->_participant_id); } - $event = array(); + $event = []; $daoName = 'title'; $this->_event_title = CRM_Event_BAO_Event::getFieldValue('CRM_Event_DAO_Event', $this->_event_id, $daoName); $daoName = 'start_date'; @@ -150,7 +150,7 @@ public function preProcess() { list($displayName, $email) = CRM_Contact_BAO_Contact_Location::getEmailDetails($this->_contact_id); $this->_contact_name = $displayName; $this->_contact_email = $email; - $details = array(); + $details = []; $details = CRM_Event_BAO_Participant::participantDetails($this->_participant_id); $optionGroupId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'participant_role', 'id', 'name'); $contributionId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $this->_participant_id, 'contribution_id', 'participant_id'); @@ -194,7 +194,7 @@ public function preProcess() { $days = $interval->format('%d'); $hours = $interval->format('%h'); if ($hours <= $time_limit && $days < 1) { - $status = ts("Registration for this event cannot be cancelled or transferred less than %1 hours prior to the event's start time. Contact the event organizer if you have questions.", array(1 => $time_limit)); + $status = ts("Registration for this event cannot be cancelled or transferred less than %1 hours prior to the event's start time. Contact the event organizer if you have questions.", [1 => $time_limit]); CRM_Core_Error::statusBounce($status, $url, ts('Sorry')); } } @@ -213,14 +213,14 @@ public function preProcess() { * return @void */ public function buildQuickForm() { - $this->add('select', 'action', ts('Transfer or Cancel Registration'), array(ts('-select-'), ts('Transfer'), ts('Cancel')), TRUE); - $this->addButtons(array( - array( + $this->add('select', 'action', ts('Transfer or Cancel Registration'), [ts('-select-'), ts('Transfer'), ts('Cancel')], TRUE); + $this->addButtons([ + [ 'type' => 'submit', 'name' => ts('Submit'), - ), - )); - $this->addFormRule(array('CRM_Event_Form_SelfSvcUpdate', 'formRule'), $this); + ], + ]); + $this->addFormRule(['CRM_Event_Form_SelfSvcUpdate', 'formRule'], $this); parent::buildQuickForm(); } @@ -230,7 +230,7 @@ public function buildQuickForm() { * return @void */ public function setDefaultValues() { - $this->_defaults = array(); + $this->_defaults = []; $this->_defaults['details'] = $this->_details; return $this->_defaults; } @@ -246,7 +246,7 @@ public function setDefaultValues() { * list of errors to be posted back to the form */ public static function formRule($fields, $files, $self) { - $errors = array(); + $errors = []; if (empty($fields['action'])) { $errors['action'] = ts("Please select Transfer OR Cancel action."); } @@ -284,12 +284,12 @@ public function transferParticipant($params) { $isBackOfficeArg = $this->isBackoffice ? '&is_backoffice=1' : ''; CRM_Utils_System::redirect(CRM_Utils_System::url( 'civicrm/event/selfsvctransfer', - array( + [ 'reset' => 1, 'action' => 'add', 'pid' => $this->_participant_id, 'cs' => $this->_userChecksum, - ) + ] )); } @@ -302,34 +302,34 @@ public function transferParticipant($params) { public function cancelParticipant($params) { //set participant record status to Cancelled, refund payment if possible // send email to participant and admin, and log Activity - $value = array(); + $value = []; $value['id'] = $this->_participant_id; $cancelledId = array_search('Cancelled', CRM_Event_PseudoConstant::participantStatus(NULL, "class = 'Negative'")); $value['status_id'] = $cancelledId; CRM_Event_BAO_Participant::create($value); - $domainValues = array(); + $domainValues = []; $domain = CRM_Core_BAO_Domain::getDomain(); - $tokens = array( + $tokens = [ 'domain' => - array( + [ 'name', 'phone', 'address', 'email', - ), + ], 'contact' => CRM_Core_SelectValues::contactTokens(), - ); + ]; foreach ($tokens['domain'] as $token) { $domainValues[$token] = CRM_Utils_Token::getDomainTokenReplacement($token, $domain); } - $participantRoles = array(); + $participantRoles = []; $participantRoles = CRM_Event_PseudoConstant::participantRole(); - $participantDetails = array(); + $participantDetails = []; $query = "SELECT * FROM civicrm_participant WHERE id = {$this->_participant_id}"; $dao = CRM_Core_DAO::executeQuery($query); while ($dao->fetch()) { - $participantDetails[$dao->id] = array( + $participantDetails[$dao->id] = [ 'id' => $dao->id, 'role' => $participantRoles[$dao->role_id], 'is_test' => $dao->is_test, @@ -339,20 +339,20 @@ public function cancelParticipant($params) { 'contact_id' => $dao->contact_id, 'register_date' => $dao->register_date, 'registered_by_id' => $dao->registered_by_id, - ); + ]; } - $eventDetails = array(); - $eventParams = array('id' => $this->_event_id); + $eventDetails = []; + $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); //get the location info - $locParams = array('entity_id' => $this->_event_id, 'entity_table' => 'civicrm_event'); + $locParams = ['entity_id' => $this->_event_id, 'entity_table' => 'civicrm_event']; $eventDetails[$this->_event_id]['location'] = CRM_Core_BAO_Location::getValues($locParams, TRUE); //get contact details $contactIds[$this->_contact_id] = $this->_contact_id; list($currentContactDetails) = CRM_Utils_Token::getTokenDetails($contactIds, NULL, - FALSE, FALSE, NULL, array(), + FALSE, FALSE, NULL, [], 'CRM_Event_BAO_Participant' ); foreach ($currentContactDetails as $contactId => $contactValues) { @@ -367,8 +367,8 @@ public function cancelParticipant($params) { "Cancelled", "" ); - $statusMsg = ts('Event registration information for %1 has been updated.', array(1 => $this->_contact_name)); - $statusMsg .= ' ' . ts('A cancellation email has been sent to %1.', array(1 => $this->_contact_email)); + $statusMsg = ts('Event registration information for %1 has been updated.', [1 => $this->_contact_name]); + $statusMsg .= ' ' . ts('A cancellation email has been sent to %1.', [1 => $this->_contact_email]); CRM_Core_Session::setStatus($statusMsg, ts('Thanks'), 'success'); if (!empty($this->isBackoffice)) { return; diff --git a/CRM/Event/Form/Task.php b/CRM/Event/Form/Task.php index 4d6b5532a43e..038e8276d23a 100644 --- a/CRM/Event/Form/Task.php +++ b/CRM/Event/Form/Task.php @@ -61,7 +61,7 @@ public function preProcess() { * @param CRM_Core_Form $form */ public static function preProcessCommon(&$form) { - $form->_participantIds = array(); + $form->_participantIds = []; $values = $form->controller->exportValues($form->get('searchFormName')); @@ -72,7 +72,7 @@ public static function preProcessCommon(&$form) { } $form->assign('taskName', $tasks[$form->_task]); - $ids = array(); + $ids = []; if ($values['radio_ts'] == 'ts_sel') { foreach ($values as $name => $value) { if (substr($name, 0, CRM_Core_Form::CB_PREFIX_LEN) == CRM_Core_Form::CB_PREFIX) { @@ -148,17 +148,17 @@ public function setContactIDs() { * @return void */ public function addDefaultButtons($title, $nextType = 'next', $backType = 'back', $submitOnce = FALSE) { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => $nextType, 'name' => $title, 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => $backType, 'name' => ts('Cancel'), - ), - ) + ], + ] ); } diff --git a/CRM/Event/Form/Task/AddToGroup.php b/CRM/Event/Form/Task/AddToGroup.php index d6412472d3eb..79f3d5dce6af 100644 --- a/CRM/Event/Form/Task/AddToGroup.php +++ b/CRM/Event/Form/Task/AddToGroup.php @@ -84,16 +84,16 @@ public function preProcess() { public function buildQuickForm() { //create radio buttons to select existing group or add a new group - $options = array(ts('Add Contact To Existing Group'), ts('Create New Group')); + $options = [ts('Add Contact To Existing Group'), ts('Create New Group')]; if (!$this->_id) { - $this->addRadio('group_option', ts('Group Options'), $options, array('onclick' => "return showElements();")); + $this->addRadio('group_option', ts('Group Options'), $options, ['onclick' => "return showElements();"]); $this->add('text', 'title', ts('Group Name:') . ' ', CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Group', 'title') ); $this->addRule('title', ts('Name already exists in Database.'), - 'objectExists', array('CRM_Contact_DAO_Group', $this->_id, 'title') + 'objectExists', ['CRM_Contact_DAO_Group', $this->_id, 'title'] ); $this->add('textarea', 'description', ts('Description:') . ' ', @@ -122,7 +122,7 @@ public function buildQuickForm() { } // add select for groups - $group = array('' => ts('- select group -')) + CRM_Core_PseudoConstant::group(); + $group = ['' => ts('- select group -')] + CRM_Core_PseudoConstant::group(); $groupElement = $this->add('select', 'group_id', ts('Select Group'), $group); @@ -132,13 +132,13 @@ public function buildQuickForm() { $groupElement->freeze(); // also set the group title - $groupValues = array('id' => $this->_id, 'title' => $this->_title); + $groupValues = ['id' => $this->_id, 'title' => $this->_title]; $this->assign_by_ref('group', $groupValues); } // Set dynamic page title for 'Add Members Group (confirm)' if ($this->_id) { - CRM_Utils_System::setTitle(ts('Add Contacts: %1', array(1 => $this->_title))); + CRM_Utils_System::setTitle(ts('Add Contacts: %1', [1 => $this->_title])); } else { CRM_Utils_System::setTitle(ts('Add Contacts to A Group')); @@ -155,7 +155,7 @@ public function buildQuickForm() { * the default array reference */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; if ($this->_context === 'amtg') { $defaults['group_id'] = $this->_id; @@ -172,7 +172,7 @@ public function setDefaultValues() { * @return void */ public function addRules() { - $this->addFormRule(array('CRM_Event_Form_Task_AddToGroup', 'formRule')); + $this->addFormRule(['CRM_Event_Form_Task_AddToGroup', 'formRule']); } /** @@ -185,7 +185,7 @@ public function addRules() { * list of errors to be posted back to the form */ public static function formRule($params) { - $errors = array(); + $errors = []; if (!empty($params['group_option']) && empty($params['title'])) { $errors['title'] = "Group Name is a required field"; @@ -207,7 +207,7 @@ public function postProcess() { $params = $this->controller->exportValues(); $groupOption = CRM_Utils_Array::value('group_option', $params, NULL); if ($groupOption) { - $groupParams = array(); + $groupParams = []; $groupParams['title'] = $params['title']; $groupParams['description'] = $params['description']; $groupParams['visibility'] = "User and User Admin Only"; @@ -233,24 +233,24 @@ public function postProcess() { list($total, $added, $notAdded) = CRM_Contact_BAO_GroupContact::addContactsToGroup($this->_contactIds, $groupID); - $status = array( - ts('%count contact added to group', array( + $status = [ + ts('%count contact added to group', [ 'count' => $added, 'plural' => '%count contacts added to group', - )), - ); + ]), + ]; if ($notAdded) { - $status[] = ts('%count contact was already in group', array( + $status[] = ts('%count contact was already in group', [ 'count' => $notAdded, 'plural' => '%count contacts were already in group', - )); + ]); } $status = '
    • ' . implode('
    • ', $status) . '
    '; - CRM_Core_Session::setStatus($status, ts('Added Contact to %1', array( + CRM_Core_Session::setStatus($status, ts('Added Contact to %1', [ 1 => $groupName, 'count' => $added, 'plural' => 'Added Contacts to %1', - )), 'success', array('expires' => 0)); + ]), 'success', ['expires' => 0]); } } diff --git a/CRM/Event/Form/Task/Badge.php b/CRM/Event/Form/Task/Badge.php index 62dbfdc05ac5..836e9364b80b 100644 --- a/CRM/Event/Form/Task/Badge.php +++ b/CRM/Event/Form/Task/Badge.php @@ -63,7 +63,7 @@ public function preProcess() { $participantID = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE); $contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE); - $this->_participantIds = array($participantID); + $this->_participantIds = [$participantID]; $this->_componentClause = " civicrm_participant.id = $participantID "; $this->assign('totalSelectedParticipants', 1); @@ -93,9 +93,9 @@ public function buildQuickForm() { $this->add('select', 'badge_id', ts('Name Badge Format'), - array( + [ '' => ts('- select -'), - ) + $label, TRUE + ] + $label, TRUE ); $next = 'next'; diff --git a/CRM/Event/Form/Task/Batch.php b/CRM/Event/Form/Task/Batch.php index 73b324d9cbee..ce01d3ab39d5 100644 --- a/CRM/Event/Form/Task/Batch.php +++ b/CRM/Event/Form/Task/Batch.php @@ -70,7 +70,7 @@ public function preProcess() { parent::preProcess(); //get the contact read only fields to display. - $readOnlyFields = array_merge(array('sort_name' => ts('Name')), + $readOnlyFields = array_merge(['sort_name' => ts('Name')], CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_autocomplete_options', TRUE, NULL, FALSE, 'name', TRUE @@ -100,7 +100,7 @@ public function buildQuickForm() { $this->_title = ts('Update multiple participants') . ' - ' . CRM_Core_BAO_UFGroup::getTitle($ufGroupId); CRM_Utils_System::setTitle($this->_title); $this->addDefaultButtons(ts('Save')); - $this->_fields = array(); + $this->_fields = []; $this->_fields = CRM_Core_BAO_UFGroup::getFields($ufGroupId, FALSE, CRM_Core_Action::VIEW); if (array_key_exists('participant_status', $this->_fields)) { $this->assign('statusProfile', 1); @@ -109,7 +109,7 @@ public function buildQuickForm() { // remove file type field and then limit fields $suppressFields = FALSE; - $removehtmlTypes = array('File'); + $removehtmlTypes = ['File']; foreach ($this->_fields as $name => $field) { if ($cfID = CRM_Core_BAO_CustomField::getKeyID($name) && in_array($this->_fields[$name]['html_type'], $removehtmlTypes) @@ -127,17 +127,17 @@ public function buildQuickForm() { $this->_fields = array_slice($this->_fields, 0, $this->_maxFields); - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'submit', 'name' => ts('Update Participant(s)'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); $this->assign('profileTitle', $this->_title); @@ -146,7 +146,7 @@ public function buildQuickForm() { //load all campaigns. if (array_key_exists('participant_campaign_id', $this->_fields)) { - $this->_componentCampaigns = array(); + $this->_componentCampaigns = []; CRM_Core_PseudoConstant::populate($this->_componentCampaigns, 'CRM_Event_DAO_Participant', TRUE, 'campaign_id', 'id', @@ -180,7 +180,7 @@ public function buildQuickForm() { foreach ($this->_fields as $name => $field) { if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($name)) { $customValue = CRM_Utils_Array::value($customFieldID, $this->_customFields); - $entityColumnValue = array(); + $entityColumnValue = []; if (!empty($customValue['extends_entity_column_value'])) { $entityColumnValue = explode(CRM_Core_DAO::VALUE_SEPARATOR, $customValue['extends_entity_column_value'] @@ -240,9 +240,9 @@ public function setDefaultValues() { return; } - $defaults = array(); + $defaults = []; foreach ($this->_participantIds as $participantId) { - $details[$participantId] = array(); + $details[$participantId] = []; $details[$participantId] = CRM_Event_BAO_Participant::participantDetails($participantId); CRM_Core_BAO_UFGroup::setProfileDefaults(NULL, $this->_fields, $defaults, FALSE, $participantId, 'Event'); @@ -312,13 +312,13 @@ public static function updatePendingOnlineContribution($participantId, $statusId return; } - $params = array( + $params = [ 'component_id' => $participantId, 'componentName' => 'Event', 'contribution_id' => $contributionId, 'contribution_status_id' => $contributionStatusId, 'IAmAHorribleNastyBeyondExcusableHackInTheCRMEventFORMTaskClassThatNeedsToBERemoved' => 1, - ); + ]; //change related contribution status. $updatedStatusId = self::updateContributionStatus($params); @@ -348,7 +348,7 @@ public static function updateContributionStatus($params) { return NULL; } - $input = $ids = $objects = array(); + $input = $ids = $objects = []; //get the required ids. $ids['contribution'] = $contributionId; @@ -393,10 +393,10 @@ public static function updateContributionStatus($params) { $contribution = &$objects['contribution']; - $contributionStatuses = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'contribution_status_id', array( + $contributionStatuses = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'contribution_status_id', [ 'labelColumn' => 'name', 'flip' => 1, - )); + ]); $input['IAmAHorribleNastyBeyondExcusableHackInTheCRMEventFORMTaskClassThatNeedsToBERemoved'] = CRM_Utils_Array::value('IAmAHorribleNastyBeyondExcusableHackInTheCRMEventFORMTaskClassThatNeedsToBERemoved', $params); if ($statusId == $contributionStatuses['Cancelled']) { $baseIPN->cancelled($objects, $transaction, $input); @@ -416,11 +416,11 @@ public static function updateContributionStatus($params) { } //set values for ipn code. - foreach (array( + foreach ([ 'fee_amount', 'check_number', 'payment_instrument_id', - ) as $field) { + ] as $field) { if (!$input[$field] = CRM_Utils_Array::value($field, $params)) { $input[$field] = $contribution->$field; } @@ -452,7 +452,7 @@ public static function updateContributionStatus($params) { * Assign the minimal set of variables to the template. */ public function assignToTemplate() { - $notifyingStatuses = array('Pending from waitlist', 'Pending from approval', 'Expired', 'Cancelled'); + $notifyingStatuses = ['Pending from waitlist', 'Pending from approval', 'Expired', 'Cancelled']; $notifyingStatuses = array_intersect($notifyingStatuses, CRM_Event_PseudoConstant::participantStatus()); $this->assign('status', TRUE); if (!empty($notifyingStatuses)) { @@ -520,7 +520,7 @@ public function submit($params) { //need to trigger mails when we change status if ($statusChange) { - CRM_Event_BAO_Participant::transitionParticipants(array($key), $value['status_id'], $fromStatusId); + CRM_Event_BAO_Participant::transitionParticipants([$key], $value['status_id'], $fromStatusId); } if ($relatedStatusChange) { //update related contribution status, CRM-4395 diff --git a/CRM/Event/Form/Task/Cancel.php b/CRM/Event/Form/Task/Cancel.php index 4c1567fe8d9d..3dd82dbcb83f 100644 --- a/CRM/Event/Form/Task/Cancel.php +++ b/CRM/Event/Form/Task/Cancel.php @@ -76,7 +76,7 @@ public function buildQuickForm() { */ public function postProcess() { $params = $this->exportValues(); - $value = array(); + $value = []; foreach ($this->_participantIds as $participantId) { $value['id'] = $participantId; diff --git a/CRM/Event/Form/Task/Delete.php b/CRM/Event/Form/Task/Delete.php index a55b5907e36b..ad9acdbddb70 100644 --- a/CRM/Event/Form/Task/Delete.php +++ b/CRM/Event/Form/Task/Delete.php @@ -74,13 +74,13 @@ public function preProcess() { * @return void */ public function buildQuickForm() { - $deleteParticipants = array( + $deleteParticipants = [ 1 => ts('Delete this participant record along with associated participant record(s).'), 2 => ts('Delete only this participant record.'), - ); + ]; $this->addRadio('delete_participant', NULL, $deleteParticipants, NULL, '
    '); - $this->setDefaults(array('delete_participant' => 1)); + $this->setDefaults(['delete_participant' => 1]); $this->addDefaultButtons(ts('Delete Participations'), 'done'); } @@ -96,7 +96,7 @@ public function postProcess() { $participantLinks = NULL; if (CRM_Utils_Array::value('delete_participant', $params) == 2) { - $links = array(); + $links = []; foreach ($this->_participantIds as $participantId) { $additionalId = (CRM_Event_BAO_Participant::getAdditionalParticipantIds($participantId)); $participantLinks = (CRM_Event_BAO_Participant::getAdditionalParticipantUrl($additionalId)); @@ -131,7 +131,7 @@ public function postProcess() { $deletedParticipants += $additionalCount; } - $status = ts('%count participant deleted.', array('plural' => '%count participants deleted.', 'count' => $deletedParticipants)); + $status = ts('%count participant deleted.', ['plural' => '%count participants deleted.', 'count' => $deletedParticipants]); if ($participantLinks) { $status .= '

    ' . ts('The following participants no longer have an event fee recorded. You can edit their registration and record a replacement contribution by clicking the links below:') diff --git a/CRM/Event/Form/Task/ParticipantStatus.php b/CRM/Event/Form/Task/ParticipantStatus.php index c5b91a46171c..aafe0bfceb93 100644 --- a/CRM/Event/Form/Task/ParticipantStatus.php +++ b/CRM/Event/Form/Task/ParticipantStatus.php @@ -44,9 +44,9 @@ public function buildQuickForm() { $statuses = CRM_Event_PseudoConstant::participantStatus(NULL, NULL, 'label'); asort($statuses, SORT_STRING); $this->add('select', 'status_change', ts('Change All Statuses'), - array( + [ '' => ts('- select status -'), - ) + $statuses + ] + $statuses ); $this->assign('context', 'statusChange'); diff --git a/CRM/Event/Form/Task/PickProfile.php b/CRM/Event/Form/Task/PickProfile.php index a7842b027b93..0bb08aca8b74 100644 --- a/CRM/Event/Form/Task/PickProfile.php +++ b/CRM/Event/Form/Task/PickProfile.php @@ -89,7 +89,7 @@ public function preProcess() { * @return void */ public function buildQuickForm() { - $types = array('Participant'); + $types = ['Participant']; $profiles = CRM_Core_BAO_UFGroup::getProfiles($types, TRUE); if (empty($profiles)) { @@ -98,9 +98,9 @@ public function buildQuickForm() { } $ufGroupElement = $this->add('select', 'uf_group_id', ts('Select Profile'), - array( + [ '' => ts('- select profile -'), - ) + $profiles, TRUE + ] + $profiles, TRUE ); $this->addDefaultButtons(ts('Continue')); } @@ -112,7 +112,7 @@ public function buildQuickForm() { * @return void */ public function addRules() { - $this->addFormRule(array('CRM_Event_Form_Task_PickProfile', 'formRule')); + $this->addFormRule(['CRM_Event_Form_Task_PickProfile', 'formRule']); } /** diff --git a/CRM/Event/Form/Task/Print.php b/CRM/Event/Form/Task/Print.php index 45b5e2c9570e..9cc1d1992bbb 100644 --- a/CRM/Event/Form/Task/Print.php +++ b/CRM/Event/Form/Task/Print.php @@ -77,18 +77,18 @@ public function buildQuickForm() { // // just need to add a javacript to popup the window for printing // - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => ts('Print Participant List'), - 'js' => array('onclick' => 'window.print()'), + 'js' => ['onclick' => 'window.print()'], 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'back', 'name' => ts('Done'), - ), - ) + ], + ] ); } diff --git a/CRM/Event/Form/Task/SaveSearch.php b/CRM/Event/Form/Task/SaveSearch.php index ae48092c2ec1..91c22676f3b8 100644 --- a/CRM/Event/Form/Task/SaveSearch.php +++ b/CRM/Event/Form/Task/SaveSearch.php @@ -89,7 +89,7 @@ public function buildQuickForm() { // get the group id for the saved search $groupId = NULL; if (isset($this->_id)) { - $params = array('saved_search_id' => $this->_id); + $params = ['saved_search_id' => $this->_id]; CRM_Contact_BAO_Group::retrieve($params, $values); $groupId = $values['id']; @@ -101,7 +101,7 @@ public function buildQuickForm() { } $this->addRule('title', ts('Name already exists in Database.'), - 'objectExists', array('CRM_Contact_DAO_Group', $groupId, 'title') + 'objectExists', ['CRM_Contact_DAO_Group', $groupId, 'title'] ); } @@ -123,10 +123,10 @@ public function postProcess() { $savedSearch->form_values = serialize($this->get('formValues')); $savedSearch->save(); $this->set('ssID', $savedSearch->id); - CRM_Core_Session::setStatus(ts("Your smart group has been saved as '%1'.", array(1 => $formValues['title'])), ts('Saved'), 'success'); + CRM_Core_Session::setStatus(ts("Your smart group has been saved as '%1'.", [1 => $formValues['title']]), ts('Saved'), 'success'); // also create a group that is associated with this saved search only if new saved search - $params = array(); + $params = []; $params['title'] = $formValues['title']; $params['description'] = $formValues['description']; $params['visibility'] = 'User and User Admin Only'; diff --git a/CRM/Event/Form/Task/SaveSearch/Update.php b/CRM/Event/Form/Task/SaveSearch/Update.php index e2576f965c77..a57171606987 100644 --- a/CRM/Event/Form/Task/SaveSearch/Update.php +++ b/CRM/Event/Form/Task/SaveSearch/Update.php @@ -64,10 +64,10 @@ public function preProcess() { */ public function setDefaultValues() { - $defaults = array(); - $params = array(); + $defaults = []; + $params = []; - $params = array('saved_search_id' => $this->_id); + $params = ['saved_search_id' => $this->_id]; CRM_Contact_BAO_Group::retrieve($params, $defaults); return $defaults; diff --git a/CRM/Event/Form/Task/SearchTaskHookSample.php b/CRM/Event/Form/Task/SearchTaskHookSample.php index f08ac877b76f..e0bf5f553159 100644 --- a/CRM/Event/Form/Task/SearchTaskHookSample.php +++ b/CRM/Event/Form/Task/SearchTaskHookSample.php @@ -46,7 +46,7 @@ class CRM_Event_Form_Task_SearchTaskHookSample extends CRM_Event_Form_Task { */ public function preProcess() { parent::preProcess(); - $rows = array(); + $rows = []; // display name and participation details of participants $participantIDs = implode(',', $this->_participantIds); @@ -61,12 +61,12 @@ public function preProcess() { $dao = CRM_Core_DAO::executeQuery($query); while ($dao->fetch()) { - $rows[] = array( + $rows[] = [ 'display_name' => $dao->display_name, 'amount' => $dao->amount, 'register_date' => CRM_Utils_Date::customFormat($dao->register_date), 'source' => $dao->source, - ); + ]; } $this->assign('rows', $rows); } @@ -77,13 +77,13 @@ public function preProcess() { * @return void */ public function buildQuickForm() { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'done', 'name' => ts('Done'), 'isDefault' => TRUE, - ), - ) + ], + ] ); } diff --git a/CRM/Event/Import/Controller.php b/CRM/Event/Import/Controller.php index 608626f3f42b..e916a4b0e214 100644 --- a/CRM/Event/Import/Controller.php +++ b/CRM/Event/Import/Controller.php @@ -56,7 +56,7 @@ public function __construct($title = NULL, $action = CRM_Core_Action::NONE, $mod // add all the actions $config = CRM_Core_Config::singleton(); - $this->addActions($config->uploadDir, array('uploadFile')); + $this->addActions($config->uploadDir, ['uploadFile']); } } diff --git a/CRM/Event/Import/Form/DataSource.php b/CRM/Event/Import/Form/DataSource.php index f46c6c0dc512..76ebd3b450a5 100644 --- a/CRM/Event/Import/Form/DataSource.php +++ b/CRM/Event/Import/Form/DataSource.php @@ -50,7 +50,7 @@ class CRM_Event_Import_Form_DataSource extends CRM_Import_Form_DataSource { public function buildQuickForm() { parent::buildQuickForm(); - $duplicateOptions = array(); + $duplicateOptions = []; $duplicateOptions[] = $this->createElement('radio', NULL, NULL, ts('Skip'), CRM_Import_Parser::DUPLICATE_SKIP ); @@ -64,7 +64,7 @@ public function buildQuickForm() { ts('On Duplicate Entries') ); - $this->setDefaults(array('onDuplicate' => CRM_Import_Parser::DUPLICATE_SKIP)); + $this->setDefaults(['onDuplicate' => CRM_Import_Parser::DUPLICATE_SKIP]); $this->addContactTypeSelector(); } @@ -75,12 +75,12 @@ public function buildQuickForm() { * @return void */ public function postProcess() { - $this->storeFormValues(array( + $this->storeFormValues([ 'onDuplicate', 'contactType', 'dateFormats', 'savedMapping', - )); + ]); $this->submitFileForMapping('CRM_Event_Import_Parser_Participant'); } diff --git a/CRM/Event/Import/Form/Preview.php b/CRM/Event/Import/Form/Preview.php index 901d656efae1..c2e32386fd06 100644 --- a/CRM/Event/Import/Form/Preview.php +++ b/CRM/Event/Import/Form/Preview.php @@ -87,7 +87,7 @@ public function preProcess() { $this->set('downloadMismatchRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams)); } - $properties = array( + $properties = [ 'mapper', 'dataValues', 'columnCount', @@ -98,7 +98,7 @@ public function preProcess() { 'downloadErrorRecordsUrl', 'downloadConflictRecordsUrl', 'downloadMismatchRecordsUrl', - ); + ]; foreach ($properties as $property) { $this->assign($property, $this->get($property)); @@ -120,7 +120,7 @@ public function postProcess() { $onDuplicate = $this->get('onDuplicate'); $mapper = $this->controller->exportValue('MapField', 'mapper'); - $mapperKeys = array(); + $mapperKeys = []; foreach ($mapper as $key => $value) { $mapperKeys[$key] = $mapper[$key][0]; @@ -131,7 +131,7 @@ public function postProcess() { $mapFields = $this->get('fields'); foreach ($mapper as $key => $value) { - $header = array(); + $header = []; if (isset($mapFields[$mapper[$key][0]])) { $header[] = $mapFields[$mapper[$key][0]]; } @@ -152,7 +152,7 @@ public function postProcess() { $errorStack = CRM_Core_Error::singleton(); $errors = $errorStack->getErrors(); - $errorMessage = array(); + $errorMessage = []; if (is_array($errors)) { foreach ($errors as $key => $value) { diff --git a/CRM/Event/Import/Form/Summary.php b/CRM/Event/Import/Form/Summary.php index 503c1f1dd525..df860af8a0b9 100644 --- a/CRM/Event/Import/Form/Summary.php +++ b/CRM/Event/Import/Form/Summary.php @@ -93,7 +93,7 @@ public function preProcess() { } $this->assign('dupeActionString', $dupeActionString); - $properties = array( + $properties = [ 'totalRowCount', 'validRowCount', 'invalidRowCount', @@ -105,7 +105,7 @@ public function preProcess() { 'downloadMismatchRecordsUrl', 'groupAdditions', 'unMatchCount', - ); + ]; foreach ($properties as $property) { $this->assign($property, $this->get($property)); } diff --git a/CRM/Event/Import/Parser.php b/CRM/Event/Import/Parser.php index ad644a34073c..000d96db6ba2 100644 --- a/CRM/Event/Import/Parser.php +++ b/CRM/Event/Import/Parser.php @@ -116,14 +116,14 @@ public function run( $this->_invalidRowCount = $this->_validCount = 0; $this->_totalCount = $this->_conflictCount = 0; - $this->_errors = array(); - $this->_warnings = array(); - $this->_conflicts = array(); + $this->_errors = []; + $this->_warnings = []; + $this->_conflicts = []; $this->_fileSize = number_format(filesize($fileName) / 1024.0, 2); if ($mode == self::MODE_MAPFIELD) { - $this->_rows = array(); + $this->_rows = []; } else { $this->_activeFieldCount = count($this->_activeFields); @@ -253,30 +253,30 @@ public function run( if ($this->_invalidRowCount) { // removed view url for invlaid contacts - $headers = array_merge(array( + $headers = array_merge([ ts('Line Number'), ts('Reason'), - ), + ], $customHeaders ); $this->_errorFileName = self::errorFileName(self::ERROR); self::exportCSV($this->_errorFileName, $headers, $this->_errors); } if ($this->_conflictCount) { - $headers = array_merge(array( + $headers = array_merge([ ts('Line Number'), ts('Reason'), - ), + ], $customHeaders ); $this->_conflictFileName = self::errorFileName(self::CONFLICT); self::exportCSV($this->_conflictFileName, $headers, $this->_conflicts); } if ($this->_duplicateCount) { - $headers = array_merge(array( + $headers = array_merge([ ts('Line Number'), ts('View Participant URL'), - ), + ], $customHeaders ); @@ -314,7 +314,7 @@ public function setActiveFields($fieldKeys) { * (reference ) associative array of name/value pairs */ public function &getActiveFieldParams() { - $params = array(); + $params = []; for ($i = 0; $i < $this->_activeFieldCount; $i++) { if (isset($this->_activeFields[$i]->_value) && !isset($params[$this->_activeFields[$i]->_name]) @@ -419,7 +419,7 @@ public function set($store, $mode = self::MODE_SUMMARY) { * @return void */ public static function exportCSV($fileName, $header, $data) { - $output = array(); + $output = []; $fd = fopen($fileName, 'w'); foreach ($header as $key => $value) { diff --git a/CRM/Event/Import/Parser/Participant.php b/CRM/Event/Import/Parser/Participant.php index ba0cf6dd989f..3c328d7e0814 100644 --- a/CRM/Event/Import/Parser/Participant.php +++ b/CRM/Event/Import/Parser/Participant.php @@ -82,7 +82,7 @@ public function init() { $this->addField($name, $field['title'], $field['type'], $field['headerPattern'], $field['dataPattern']); } - $this->_newParticipants = array(); + $this->_newParticipants = []; $this->setActiveFields($this->_mapperKeys); // FIXME: we should do this in one place together with Form/MapField.php @@ -284,7 +284,7 @@ public function import($onDuplicate, &$values) { $params = &$this->getActiveFieldParams(); $session = CRM_Core_Session::singleton(); $dateType = $session->get('dateTypes'); - $formatted = array('version' => 3); + $formatted = ['version' => 3]; $customFields = CRM_Core_BAO_CustomField::getFields('Participant'); // don't add to recent items, CRM-4399 @@ -314,7 +314,7 @@ public function import($onDuplicate, &$values) { } else { $eventTitle = $params['event_title']; - $qParams = array(); + $qParams = []; $dao = new CRM_Core_DAO(); $params['participant_role_id'] = $dao->singleValueQuery("SELECT default_role_id FROM civicrm_event WHERE title = '$eventTitle' ", $qParams @@ -328,7 +328,7 @@ public function import($onDuplicate, &$values) { $indieFields = CRM_Event_BAO_Participant::import(); } - $formatValues = array(); + $formatValues = []; foreach ($params as $key => $field) { if ($field == NULL || $field === '') { continue; @@ -365,11 +365,11 @@ public function import($onDuplicate, &$values) { 'Participant' ); if ($dao->find(TRUE)) { - $ids = array( + $ids = [ 'participant' => $formatValues['participant_id'], 'userId' => $session->get('userID'), - ); - $participantValues = array(); + ]; + $participantValues = []; //@todo calling api functions directly is not supported $newParticipant = _civicrm_api3_deprecated_participant_check_params($formatted, $participantValues, FALSE); if ($newParticipant['error_message']) { @@ -378,10 +378,10 @@ public function import($onDuplicate, &$values) { } $newParticipant = CRM_Event_BAO_Participant::create($formatted, $ids); if (!empty($formatted['fee_level'])) { - $otherParams = array( + $otherParams = [ 'fee_label' => $formatted['fee_level'], 'event_id' => $newParticipant->event_id, - ); + ]; CRM_Price_BAO_LineItem::syncLineItems($newParticipant->id, 'civicrm_participant', $newParticipant->fee_amount, $otherParams); } @@ -410,10 +410,10 @@ public function import($onDuplicate, &$values) { } else { // Using new Dedupe rule. - $ruleParams = array( + $ruleParams = [ 'contact_type' => $this->_contactType, 'used' => 'Unsupervised', - ); + ]; $fieldsArray = CRM_Dedupe_BAO_Rule::dedupeRuleFields($ruleParams); $disp = ''; @@ -531,7 +531,7 @@ protected function formatValues(&$values, $params) { if ($type == 'CheckBox' || $type == 'Multi-Select') { $mulValues = explode(',', $value); $customOption = CRM_Core_BAO_CustomOption::getCustomOption($customFieldID, TRUE); - $values[$key] = array(); + $values[$key] = []; foreach ($mulValues as $v1) { foreach ($customOption as $customValueID => $customLabel) { $customValue = $customLabel['value']; @@ -590,7 +590,7 @@ protected function formatValues(&$values, $params) { return civicrm_api3_create_error("Event ID is not valid: $value"); } $dao = new CRM_Core_DAO(); - $qParams = array(); + $qParams = []; $svq = $dao->singleValueQuery("SELECT id FROM civicrm_event WHERE id = $value", $qParams ); @@ -640,7 +640,7 @@ protected function formatValues(&$values, $params) { // status_id and source. So, if $values contains // participant_register_date, participant_status_id or participant_source, // convert it to register_date, status_id or source - $changes = array( + $changes = [ 'participant_register_date' => 'register_date', 'participant_source' => 'source', 'participant_status_id' => 'status_id', @@ -648,7 +648,7 @@ protected function formatValues(&$values, $params) { 'participant_fee_level' => 'fee_level', 'participant_fee_amount' => 'fee_amount', 'participant_id' => 'id', - ); + ]; foreach ($changes as $orgVal => $changeVal) { if (isset($values[$orgVal])) { diff --git a/CRM/Event/Info.php b/CRM/Event/Info.php index 3d59c3f4529f..098d6351a8bf 100644 --- a/CRM/Event/Info.php +++ b/CRM/Event/Info.php @@ -47,13 +47,13 @@ class CRM_Event_Info extends CRM_Core_Component_Info { * @return array */ public function getInfo() { - return array( + return [ 'name' => 'CiviEvent', 'translatedName' => ts('CiviEvent'), 'title' => ts('CiviCRM Event Engine'), 'search' => 1, 'showActivitiesInCore' => 1, - ); + ]; } /** @@ -65,39 +65,39 @@ public function getInfo() { * @return array */ public function getPermissions($getAllUnconditionally = FALSE, $descriptions = FALSE) { - $permissions = array( - 'access CiviEvent' => array( + $permissions = [ + 'access CiviEvent' => [ ts('access CiviEvent'), ts('Create events, view all events, and view participant records (for visible contacts)'), - ), - 'edit event participants' => array( + ], + 'edit event participants' => [ ts('edit event participants'), ts('Record and update backend event registrations'), - ), - 'edit all events' => array( + ], + 'edit all events' => [ ts('edit all events'), ts('Edit events even without specific ACL granted'), - ), - 'register for events' => array( + ], + 'register for events' => [ ts('register for events'), ts('Register for events online'), - ), - 'view event info' => array( + ], + 'view event info' => [ ts('view event info'), ts('View online event information pages'), - ), - 'view event participants' => array( + ], + 'view event participants' => [ ts('view event participants'), - ), - 'delete in CiviEvent' => array( + ], + 'delete in CiviEvent' => [ ts('delete in CiviEvent'), ts('Delete participants and events that you can edit'), - ), - 'manage event profiles' => array( + ], + 'manage event profiles' => [ ts('manage event profiles'), ts('Allow users to create, edit and copy event-related profile forms used for online event registration.'), - ), - ); + ], + ]; if (!$descriptions) { foreach ($permissions as $name => $attr) { @@ -112,9 +112,9 @@ public function getPermissions($getAllUnconditionally = FALSE, $descriptions = F * @return array */ public function getAnonymousPermissionWarnings() { - return array( + return [ 'access CiviEvent', - ); + ]; } /** @@ -122,12 +122,12 @@ public function getAnonymousPermissionWarnings() { * @return array */ public function getUserDashboardElement() { - return array( + return [ 'name' => ts('Events'), 'title' => ts('Your Event(s)'), - 'perm' => array('register for events'), + 'perm' => ['register for events'], 'weight' => 20, - ); + ]; } /** @@ -135,12 +135,12 @@ public function getUserDashboardElement() { * @return array */ public function registerTab() { - return array( + return [ 'title' => ts('Events'), 'id' => 'participant', 'url' => 'participant', 'weight' => 40, - ); + ]; } /** @@ -156,10 +156,10 @@ public function getIcon() { * @return array */ public function registerAdvancedSearchPane() { - return array( + return [ 'title' => ts('Events'), 'weight' => 40, - ); + ]; } /** @@ -167,11 +167,11 @@ public function registerAdvancedSearchPane() { * @return array */ public function getActivityTypes() { - $types = array(); - $types['Event'] = array( + $types = []; + $types['Event'] = [ 'title' => ts('Event'), 'callback' => 'CRM_Event_Page_EventInfo::run()', - ); + ]; return $types; } @@ -184,20 +184,20 @@ public function creatNewShortcut(&$shortCuts, $newCredit) { if (CRM_Core_Permission::check('access CiviEvent') && CRM_Core_Permission::check('edit event participants') ) { - $shortCut[] = array( + $shortCut[] = [ 'path' => 'civicrm/participant/add', 'query' => "reset=1&action=add&context=standalone", 'ref' => 'new-participant', 'title' => ts('Event Registration'), - ); + ]; if ($newCredit) { $title = ts('Event Registration') . '
      (' . ts('credit card') . ')'; - $shortCut[0]['shortCuts'][] = array( + $shortCut[0]['shortCuts'][] = [ 'path' => 'civicrm/participant/add', 'query' => "reset=1&action=add&context=standalone&mode=live", 'ref' => 'new-participant-cc', 'title' => $title, - ); + ]; } $shortCuts = array_merge($shortCuts, $shortCut); } diff --git a/CRM/Event/Page/AJAX.php b/CRM/Event/Page/AJAX.php index 841be6a2825c..7227988671db 100644 --- a/CRM/Event/Page/AJAX.php +++ b/CRM/Event/Page/AJAX.php @@ -60,9 +60,9 @@ public function eventFee() { WHERE ce.entity_table = 'civicrm_event' AND {$whereClause}"; $dao = CRM_Core_DAO::executeQuery($query); - $results = array(); + $results = []; while ($dao->fetch()) { - $results[] = array('id' => $dao->id, 'text' => $dao->label); + $results[] = ['id' => $dao->id, 'text' => $dao->label]; } CRM_Utils_JSON::output($results); } diff --git a/CRM/Event/Page/EventInfo.php b/CRM/Event/Page/EventInfo.php index a9ba940f8d68..6cdcab5bdddc 100644 --- a/CRM/Event/Page/EventInfo.php +++ b/CRM/Event/Page/EventInfo.php @@ -71,7 +71,7 @@ public function run() { ); //retrieve event information - $params = array('id' => $this->_id); + $params = ['id' => $this->_id]; CRM_Event_BAO_Event::retrieve($params, $values['event']); if (!$values['event']['is_active']) { @@ -178,7 +178,7 @@ public function run() { } } - $params = array('entity_id' => $this->_id, 'entity_table' => 'civicrm_event'); + $params = ['entity_id' => $this->_id, 'entity_table' => 'civicrm_event']; $values['location'] = CRM_Core_BAO_Location::getValues($params, TRUE); // fix phone type labels @@ -223,14 +223,14 @@ public function run() { } } - $center = array( + $center = [ 'lat' => (float ) $sumLat / count($locations), 'lng' => (float ) $sumLng / count($locations), - ); - $span = array( + ]; + $span = [ 'lat' => (float ) ($maxLat - $minLat), 'lng' => (float ) ($maxLng - $minLng), - ); + ]; $this->assign_by_ref('center', $center); $this->assign_by_ref('span', $span); if ($action == CRM_Core_Action::PREVIEW) { @@ -317,11 +317,11 @@ public function run() { $this->assign('allowRegistration', $allowRegistration); $session = CRM_Core_Session::singleton(); - $params = array( + $params = [ 'contact_id' => $session->get('userID'), 'event_id' => CRM_Utils_Array::value('id', $values['event']), 'role_id' => CRM_Utils_Array::value('default_role_id', $values['event']), - ); + ]; if ($eventFullMessage && ($noFullMsg == 'false') || CRM_Event_BAO_Event::checkRegistration($params)) { $statusMessage = $eventFullMessage; @@ -334,7 +334,7 @@ public function run() { $registerUrl = CRM_Utils_System::url('civicrm/event/register', "reset=1&id={$values['event']['id']}&cid=0" ); - $statusMessage = ts("It looks like you are already registered for this event. If you want to change your registration, or you feel that you've gotten this message in error, please contact the site administrator.") . ' ' . ts('You can also register another participant.', array(1 => $registerUrl)); + $statusMessage = ts("It looks like you are already registered for this event. If you want to change your registration, or you feel that you've gotten this message in error, please contact the site administrator.") . ' ' . ts('You can also register another participant.', [1 => $registerUrl]); } } } diff --git a/CRM/Event/Page/ManageEvent.php b/CRM/Event/Page/ManageEvent.php index 3ca63e8f0253..03dfcebc0b09 100644 --- a/CRM/Event/Page/ManageEvent.php +++ b/CRM/Event/Page/ManageEvent.php @@ -73,32 +73,32 @@ public function &links() { $copyExtra = ts('Are you sure you want to make a copy of this Event?'); $deleteExtra = ts('Are you sure you want to delete this Event?'); - self::$_actionLinks = array( - CRM_Core_Action::DISABLE => array( + self::$_actionLinks = [ + CRM_Core_Action::DISABLE => [ 'name' => ts('Disable'), 'ref' => 'crm-enable-disable', 'title' => ts('Disable Event'), - ), - CRM_Core_Action::ENABLE => array( + ], + CRM_Core_Action::ENABLE => [ 'name' => ts('Enable'), 'ref' => 'crm-enable-disable', 'title' => ts('Enable Event'), - ), - CRM_Core_Action::DELETE => array( + ], + CRM_Core_Action::DELETE => [ 'name' => ts('Delete'), 'url' => CRM_Utils_System::currentPath(), 'qs' => 'action=delete&id=%%id%%', 'extra' => 'onclick = "return confirm(\'' . $deleteExtra . '\');"', 'title' => ts('Delete Event'), - ), - CRM_Core_Action::COPY => array( + ], + CRM_Core_Action::COPY => [ 'name' => ts('Copy'), 'url' => CRM_Utils_System::currentPath(), 'qs' => 'reset=1&action=copy&id=%%id%%', 'extra' => 'onclick = "return confirm(\'' . $copyExtra . '\');"', 'title' => ts('Copy Event'), - ), - ); + ], + ]; } return self::$_actionLinks; } @@ -149,74 +149,74 @@ public function eventLinks() { public static function &tabs($enableCart) { $cacheKey = $enableCart ? 1 : 0; if (!(self::$_tabLinks)) { - self::$_tabLinks = array(); + self::$_tabLinks = []; } if (!isset(self::$_tabLinks[$cacheKey])) { self::$_tabLinks[$cacheKey]['settings'] - = array( + = [ 'title' => ts('Info and Settings'), 'url' => 'civicrm/event/manage/settings', 'field' => 'id', - ); + ]; self::$_tabLinks[$cacheKey]['location'] - = array( + = [ 'title' => ts('Location'), 'url' => 'civicrm/event/manage/location', 'field' => 'loc_block_id', - ); + ]; self::$_tabLinks[$cacheKey]['fee'] - = array( + = [ 'title' => ts('Fees'), 'url' => 'civicrm/event/manage/fee', 'field' => 'is_monetary', - ); + ]; self::$_tabLinks[$cacheKey]['registration'] - = array( + = [ 'title' => ts('Online Registration'), 'url' => 'civicrm/event/manage/registration', 'field' => 'is_online_registration', - ); + ]; if (CRM_Core_Permission::check('administer CiviCRM') || CRM_Event_BAO_Event::checkPermission(NULL, CRM_Core_Permission::EDIT)) { self::$_tabLinks[$cacheKey]['reminder'] - = array( + = [ 'title' => ts('Schedule Reminders'), 'url' => 'civicrm/event/manage/reminder', 'field' => 'reminder', - ); + ]; } self::$_tabLinks[$cacheKey]['conference'] - = array( + = [ 'title' => ts('Conference Slots'), 'url' => 'civicrm/event/manage/conference', 'field' => 'slot_label_id', - ); + ]; self::$_tabLinks[$cacheKey]['friend'] - = array( + = [ 'title' => ts('Tell a Friend'), 'url' => 'civicrm/event/manage/friend', 'field' => 'friend', - ); + ]; self::$_tabLinks[$cacheKey]['pcp'] - = array( + = [ 'title' => ts('Personal Campaign Pages'), 'url' => 'civicrm/event/manage/pcp', 'field' => 'is_pcp_enabled', - ); + ]; self::$_tabLinks[$cacheKey]['repeat'] - = array( + = [ 'title' => ts('Repeat'), 'url' => 'civicrm/event/manage/repeat', 'field' => 'is_repeating_event', - ); + ]; } if (!$enableCart) { unset(self::$_tabLinks[$cacheKey]['conference']); } - CRM_Utils_Hook::tabset('civicrm/event/manage', self::$_tabLinks[$cacheKey], array()); + CRM_Utils_Hook::tabset('civicrm/event/manage', self::$_tabLinks[$cacheKey], []); return self::$_tabLinks[$cacheKey]; } @@ -251,12 +251,12 @@ public function run() { } if (!$this->_isTemplate && $id) { - $breadCrumb = array( - array( + $breadCrumb = [ + [ 'title' => ts('Manage Events'), 'url' => CRM_Utils_System::url(CRM_Utils_System::currentPath(), 'reset=1'), - ), - ); + ], + ]; CRM_Utils_System::appendBreadCrumb($breadCrumb); } @@ -307,7 +307,7 @@ public function browse() { $this->search(); - $params = array(); + $params = []; $this->_force = CRM_Utils_Request::retrieve('force', 'Boolean', $this, FALSE ); @@ -316,7 +316,7 @@ public function browse() { $whereClause = $this->whereClause($params, FALSE, $this->_force); $this->pagerAToZ($whereClause, $params); - $params = array(); + $params = []; $whereClause = $this->whereClause($params, TRUE, $this->_force); // because is_template != 1 would be to simple $whereClause .= ' AND (is_template = 0 OR is_template IS NULL)'; @@ -326,7 +326,7 @@ public function browse() { list($offset, $rowCount) = $this->_pager->getOffsetAndRowCount(); // get all custom groups sorted by weight - $manageEvent = array(); + $manageEvent = []; $query = " SELECT * @@ -342,7 +342,7 @@ public function browse() { $allCampaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE); // get the list of active event pcps - $eventPCPS = array(); + $eventPCPS = []; $pcpDao = new CRM_PCP_DAO_PCPBlock(); $pcpDao->entity_table = 'civicrm_event'; @@ -354,17 +354,17 @@ public function browse() { // check if we're in shopping cart mode for events $enableCart = Civi::settings()->get('enable_cart'); $this->assign('eventCartEnabled', $enableCart); - $mapping = CRM_Utils_Array::first(CRM_Core_BAO_ActionSchedule::getMappings(array( + $mapping = CRM_Utils_Array::first(CRM_Core_BAO_ActionSchedule::getMappings([ 'id' => CRM_Event_ActionMapping::EVENT_NAME_MAPPING_ID, - ))); + ])); $eventType = CRM_Core_OptionGroup::values('event_type'); while ($dao->fetch()) { if (in_array($dao->id, $permittedEventsByAction[CRM_Core_Permission::VIEW])) { - $manageEvent[$dao->id] = array(); + $manageEvent[$dao->id] = []; $repeat = CRM_Core_BAO_RecurringEntity::getPositionAndCount($dao->id, 'civicrm_event'); $manageEvent[$dao->id]['repeat'] = ''; if ($repeat) { - $manageEvent[$dao->id]['repeat'] = ts('Repeating (%1 of %2)', array(1 => $repeat[0], 2 => $repeat[1])); + $manageEvent[$dao->id]['repeat'] = ts('Repeating (%1 of %2)', [1 => $repeat[0], 2 => $repeat[1]]); } CRM_Core_DAO::storeValues($dao, $manageEvent[$dao->id]); @@ -392,7 +392,7 @@ public function browse() { $manageEvent[$dao->id]['eventlinks'] = CRM_Core_Action::formLink($eventLinks, NULL, - array('id' => $dao->id), + ['id' => $dao->id], ts('Event Links'), TRUE, 'event.manage.eventlinks', @@ -401,7 +401,7 @@ public function browse() { ); $manageEvent[$dao->id]['action'] = CRM_Core_Action::formLink(self::links(), $action, - array('id' => $dao->id), + ['id' => $dao->id], ts('more'), TRUE, 'event.manage.list', @@ -409,11 +409,11 @@ public function browse() { $dao->id ); - $params = array( + $params = [ 'entity_id' => $dao->id, 'entity_table' => 'civicrm_event', 'is_active' => 1, - ); + ]; $defaults['location'] = CRM_Core_BAO_Location::getValues($params, TRUE); @@ -433,7 +433,7 @@ public function browse() { $manageEvent[$dao->id]['event_type'] = CRM_Utils_Array::value($manageEvent[$dao->id]['event_type_id'], $eventType); $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, array('event_id' => $dao->id)); + CRM_Utils_Hook::tabset('civicrm/event/manage/rows', $manageEvent, ['event_id' => $dao->id]); } } @@ -493,8 +493,8 @@ public function search() { * @return string */ public function whereClause(&$params, $sortBy = TRUE, $force) { - $values = array(); - $clauses = array(); + $values = []; + $clauses = []; $title = $this->get('title'); $createdId = $this->get('cid'); @@ -505,10 +505,10 @@ public function whereClause(&$params, $sortBy = TRUE, $force) { if ($title) { $clauses[] = "title LIKE %1"; if (strpos($title, '%') !== FALSE) { - $params[1] = array(trim($title), 'String', FALSE); + $params[1] = [trim($title), 'String', FALSE]; } else { - $params[1] = array(trim($title), 'String', TRUE); + $params[1] = [trim($title), 'String', TRUE]; } } @@ -527,13 +527,13 @@ public function whereClause(&$params, $sortBy = TRUE, $force) { $from = $this->get('start_date'); if (!CRM_Utils_System::isNull($from)) { $clauses[] = '( end_date >= %3 OR end_date IS NULL )'; - $params[3] = array($from, 'String'); + $params[3] = [$from, 'String']; } $to = $this->get('end_date'); if (!CRM_Utils_System::isNull($to)) { $clauses[] = '( start_date <= %4 OR start_date IS NULL )'; - $params[4] = array($to, 'String'); + $params[4] = [$to, 'String']; } } else { @@ -555,7 +555,7 @@ public function whereClause(&$params, $sortBy = TRUE, $force) { $campaignIds = $this->get('campaign_id'); if (!CRM_Utils_System::isNull($campaignIds)) { if (!is_array($campaignIds)) { - $campaignIds = array($campaignIds); + $campaignIds = [$campaignIds]; } $clauses[] = '( campaign_id IN ( ' . implode(' , ', array_values($campaignIds)) . ' ) )'; } diff --git a/CRM/Event/Page/ParticipantListing/NameStatusAndDate.php b/CRM/Event/Page/ParticipantListing/NameStatusAndDate.php index 57756abe857b..c2bf4eb3e229 100644 --- a/CRM/Event/Page/ParticipantListing/NameStatusAndDate.php +++ b/CRM/Event/Page/ParticipantListing/NameStatusAndDate.php @@ -59,7 +59,7 @@ public function preProcess() { $this->_id, 'title' ); - CRM_Utils_System::setTitle(ts('%1 - Participants', array(1 => $this->_eventTitle))); + CRM_Utils_System::setTitle(ts('%1 - Participants', [1 => $this->_eventTitle])); // we do not want to display recently viewed contacts since this is potentially a public page $this->assign('displayRecent', FALSE); @@ -80,7 +80,7 @@ public function run() { $whereClause = " WHERE civicrm_event.id = %1"; - $params = array(1 => array($this->_id, 'Integer')); + $params = [1 => [$this->_id, 'Integer']]; $this->pager($fromClause, $whereClause, $params); $orderBy = $this->orderBy(); @@ -98,7 +98,7 @@ public function run() { ORDER BY $orderBy LIMIT $offset, $rowCount"; - $rows = array(); + $rows = []; $object = CRM_Core_DAO::executeQuery($query, $params); $statusLookup = CRM_Event_PseudoConstant::participantStatus(); while ($object->fetch()) { @@ -106,13 +106,13 @@ public function run() { if ($status) { $status = ts($status); } - $row = array( + $row = [ 'id' => $object->contact_id, 'participantID' => $object->participant_id, 'name' => $object->name, 'status' => $status, 'date' => $object->register_date, - ); + ]; $rows[] = $row; } $this->assign_by_ref('rows', $rows); @@ -127,7 +127,7 @@ public function run() { */ public function pager($fromClause, $whereClause, $whereParams) { - $params = array(); + $params = []; $params['status'] = ts('Group') . ' %%StatusMessage%%'; $params['csvString'] = NULL; @@ -154,22 +154,22 @@ public function pager($fromClause, $whereClause, $whereParams) { public function orderBy() { static $headers = NULL; if (!$headers) { - $headers = array(); - $headers[1] = array( + $headers = []; + $headers[1] = [ 'name' => ts('Name'), 'sort' => 'civicrm_contact.sort_name', 'direction' => CRM_Utils_Sort::ASCENDING, - ); - $headers[2] = array( + ]; + $headers[2] = [ 'name' => ts('Status'), 'sort' => 'civicrm_participant.status_id', 'direction' => CRM_Utils_Sort::DONTCARE, - ); - $headers[3] = array( + ]; + $headers[3] = [ 'name' => ts('Register Date'), 'sort' => 'civicrm_participant.register_date', 'direction' => CRM_Utils_Sort::DONTCARE, - ); + ]; } $sortID = NULL; if ($this->get(CRM_Utils_Sort::SORT_ID)) { diff --git a/CRM/Event/Page/ParticipantListing/Simple.php b/CRM/Event/Page/ParticipantListing/Simple.php index e6677539a677..c2db2255ee19 100644 --- a/CRM/Event/Page/ParticipantListing/Simple.php +++ b/CRM/Event/Page/ParticipantListing/Simple.php @@ -50,7 +50,7 @@ public function preProcess() { $this->_id, 'title' ); - CRM_Utils_System::setTitle(ts('%1 - Participants', array(1 => $this->_eventTitle))); + CRM_Utils_System::setTitle(ts('%1 - Participants', [1 => $this->_eventTitle])); // we do not want to display recently viewed contacts since this is potentially a public page $this->assign('displayRecent', FALSE); @@ -74,7 +74,7 @@ public function run() { WHERE civicrm_event.id = %1 AND civicrm_participant.is_test = 0 AND civicrm_participant.status_id IN ( 1, 2 )"; - $params = array(1 => array($this->_id, 'Integer')); + $params = [1 => [$this->_id, 'Integer']]; $this->pager($fromClause, $whereClause, $params); $orderBy = $this->orderBy(); @@ -91,15 +91,15 @@ public function run() { ORDER BY $orderBy LIMIT $offset, $rowCount"; - $rows = array(); + $rows = []; $object = CRM_Core_DAO::executeQuery($query, $params); while ($object->fetch()) { - $row = array( + $row = [ 'id' => $object->contact_id, 'participantID' => $object->participant_id, 'name' => $object->name, 'email' => $object->email, - ); + ]; $rows[] = $row; } $this->assign_by_ref('rows', $rows); @@ -114,7 +114,7 @@ public function run() { */ public function pager($fromClause, $whereClause, $whereParams) { - $params = array(); + $params = []; $params['status'] = ts('Group') . ' %%StatusMessage%%'; $params['csvString'] = NULL; @@ -142,18 +142,18 @@ public function pager($fromClause, $whereClause, $whereParams) { public function orderBy() { static $headers = NULL; if (!$headers) { - $headers = array(); - $headers[1] = array( + $headers = []; + $headers[1] = [ 'name' => ts('Name'), 'sort' => 'civicrm_contact.sort_name', 'direction' => CRM_Utils_Sort::ASCENDING, - ); + ]; if ($this->_participantListingType == 'Name and Email') { - $headers[2] = array( + $headers[2] = [ 'name' => ts('Email'), 'sort' => 'civicrm_email.email', 'direction' => CRM_Utils_Sort::DONTCARE, - ); + ]; } } $sortID = NULL; diff --git a/CRM/Event/Page/Tab.php b/CRM/Event/Page/Tab.php index d2d4db40c829..dadc9244d9e6 100644 --- a/CRM/Event/Page/Tab.php +++ b/CRM/Event/Page/Tab.php @@ -58,9 +58,9 @@ public function browse() { $this->assign('displayName', $displayName); $this->ajaxResponse['tabCount'] = CRM_Contact_BAO_Contact::getCountComponent('participant', $this->_contactId); // Refresh other tabs with related data - $this->ajaxResponse['updateTabs'] = array( + $this->ajaxResponse['updateTabs'] = [ '#tab_activity' => CRM_Contact_BAO_Contact::getCountComponent('activity', $this->_contactId), - ); + ]; if (CRM_Core_Permission::access('CiviContribute')) { $this->ajaxResponse['updateTabs']['#tab_contribute'] = CRM_Contact_BAO_Contact::getCountComponent('contribution', $this->_contactId); } diff --git a/CRM/Event/PseudoConstant.php b/CRM/Event/PseudoConstant.php index abdcb05708b7..23143f637d0b 100644 --- a/CRM/Event/PseudoConstant.php +++ b/CRM/Event/PseudoConstant.php @@ -101,7 +101,7 @@ public static function event($id = NULL, $all = FALSE, $condition = NULL) { $key = "{$id}_{$all}_{$condition}"; if (!isset(self::$event[$key])) { - self::$event[$key] = array(); + self::$event[$key] = []; } if (!self::$event[$key]) { @@ -136,13 +136,13 @@ public static function event($id = NULL, $all = FALSE, $condition = NULL) { */ public static function &participantStatus($id = NULL, $cond = NULL, $retColumn = 'name') { if (self::$participantStatus === NULL) { - self::$participantStatus = array(); + self::$participantStatus = []; } $index = $cond ? $cond : 'No Condition'; $index = "{$index}_{$retColumn}"; if (!CRM_Utils_Array::value($index, self::$participantStatus)) { - self::$participantStatus[$index] = array(); + self::$participantStatus[$index] = []; CRM_Core_PseudoConstant::populate(self::$participantStatus[$index], 'CRM_Event_DAO_ParticipantStatusType', FALSE, $retColumn, 'is_active', $cond, 'weight' @@ -162,12 +162,12 @@ public static function &participantStatus($id = NULL, $cond = NULL, $retColumn = * @return array */ public static function participantStatusClassOptions() { - return array( + return [ 'Positive' => ts('Positive'), 'Pending' => ts('Pending'), 'Waiting' => ts('Waiting'), 'Negative' => ts('Negative'), - ); + ]; } /** @@ -199,7 +199,7 @@ public static function &participantStatusClass() { public static function &participantRole($id = NULL, $cond = NULL) { $index = $cond ? $cond : 'No Condition'; if (!CRM_Utils_Array::value($index, self::$participantRole)) { - self::$participantRole[$index] = array(); + self::$participantRole[$index] = []; $condition = NULL; @@ -229,7 +229,7 @@ public static function &participantRole($id = NULL, $cond = NULL) { */ public static function &participantListing($id = NULL) { if (!self::$participantListing) { - self::$participantListing = array(); + self::$participantListing = []; self::$participantListing = CRM_Core_OptionGroup::values('participant_listing'); } @@ -250,7 +250,7 @@ public static function &participantListing($id = NULL) { */ public static function &eventType($id = NULL) { if (!self::$eventType) { - self::$eventType = array(); + self::$eventType = []; self::$eventType = CRM_Core_OptionGroup::values('event_type'); } diff --git a/CRM/Event/Selector/Search.php b/CRM/Event/Selector/Search.php index 521c14349979..2e6532adcba3 100644 --- a/CRM/Event/Selector/Search.php +++ b/CRM/Event/Selector/Search.php @@ -59,7 +59,7 @@ class CRM_Event_Selector_Search extends CRM_Core_Selector_Base implements CRM_Co * Properties of contact we're interested in displaying * @var array */ - static $_properties = array( + static $_properties = [ 'contact_id', 'contact_type', 'sort_name', @@ -80,7 +80,7 @@ class CRM_Event_Selector_Search extends CRM_Core_Selector_Base implements CRM_Co 'participant_status', 'participant_role', 'participant_campaign_id', - ); + ]; /** * Are we restricting ourselves to a single contact @@ -227,26 +227,26 @@ public static function &links($qfKey = NULL, $context = NULL, $compContext = NUL } if (!(self::$_links)) { - self::$_links = array( - CRM_Core_Action::VIEW => array( + self::$_links = [ + CRM_Core_Action::VIEW => [ 'name' => ts('View'), 'url' => 'civicrm/contact/view/participant', 'qs' => 'reset=1&id=%%id%%&cid=%%cid%%&action=view&context=%%cxt%%&selectedChild=event' . $extraParams, 'title' => ts('View Participation'), - ), - CRM_Core_Action::UPDATE => array( + ], + CRM_Core_Action::UPDATE => [ 'name' => ts('Edit'), 'url' => 'civicrm/contact/view/participant', 'qs' => 'reset=1&action=update&id=%%id%%&cid=%%cid%%&context=%%cxt%%' . $extraParams, 'title' => ts('Edit Participation'), - ), - CRM_Core_Action::DELETE => array( + ], + CRM_Core_Action::DELETE => [ 'name' => ts('Delete'), 'url' => 'civicrm/contact/view/participant', 'qs' => 'reset=1&action=delete&id=%%id%%&cid=%%cid%%&context=%%cxt%%' . $extraParams, 'title' => ts('Delete Participation'), - ), - ); + ], + ]; } return self::$_links; } @@ -313,10 +313,10 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { $this->_eventClause ); // process the result of the query - $rows = array(); + $rows = []; //lets handle view, edit and delete separately. CRM-4418 - $permissions = array(CRM_Core_Permission::VIEW); + $permissions = [CRM_Core_Permission::VIEW]; if (CRM_Core_Permission::check('edit event participants')) { $permissions[] = CRM_Core_Permission::EDIT; } @@ -334,7 +334,7 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { $allCampaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE); while ($result->fetch()) { - $row = array(); + $row = []; // the columns we are interested in foreach (self::$_properties as $property) { if (isset($result->$property)) { @@ -370,52 +370,52 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { $links = self::links($this->_key, $this->_context, $this->_compContext); if ($statusTypes[$row['participant_status_id']] == 'Partially paid') { - $links[CRM_Core_Action::ADD] = array( + $links[CRM_Core_Action::ADD] = [ 'name' => ts('Record Payment'), 'url' => 'civicrm/payment', 'qs' => 'reset=1&id=%%id%%&cid=%%cid%%&action=add&component=event', 'title' => ts('Record Payment'), - ); + ]; if (CRM_Core_Config::isEnabledBackOfficeCreditCardPayments()) { - $links[CRM_Core_Action::BASIC] = array( + $links[CRM_Core_Action::BASIC] = [ 'name' => ts('Submit Credit Card payment'), 'url' => 'civicrm/payment/add', 'qs' => 'reset=1&id=%%id%%&cid=%%cid%%&action=add&component=event&mode=live', 'title' => ts('Submit Credit Card payment'), - ); + ]; } } if ($statusTypes[$row['participant_status_id']] == 'Pending refund') { - $links[CRM_Core_Action::ADD] = array( + $links[CRM_Core_Action::ADD] = [ 'name' => ts('Record Refund'), 'url' => 'civicrm/payment', 'qs' => 'reset=1&id=%%id%%&cid=%%cid%%&action=add&component=event', 'title' => ts('Record Refund'), - ); + ]; } // CRM-20879: Show 'Transfer or Cancel' action only if logged in user // have 'edit event participants' permission and participant status // is not Cancelled or Transferred if (in_array(CRM_Core_Permission::EDIT, $permissions) && - !in_array($statusTypes[$row['participant_status_id']], array('Cancelled', 'Transferred')) + !in_array($statusTypes[$row['participant_status_id']], ['Cancelled', 'Transferred']) ) { - $links[] = array( + $links[] = [ 'name' => ts('Transfer or Cancel'), 'url' => 'civicrm/event/selfsvcupdate', 'qs' => 'reset=1&pid=%%id%%&is_backoffice=1&cs=' . CRM_Contact_BAO_Contact_Utils::generateChecksum($result->contact_id, NULL, 'inf'), 'title' => ts('Transfer or Cancel'), - ); + ]; } $row['action'] = CRM_Core_Action::formLink($links, $mask, - array( + [ 'id' => $result->participant_id, 'cid' => $result->contact_id, 'cxt' => $this->_context, - ), + ], ts('more'), FALSE, 'participant.selector.row', @@ -438,7 +438,7 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { } if (!empty($row['participant_role_id'])) { - $viewRoles = array(); + $viewRoles = []; foreach (explode($sep, $row['participant_role_id']) as $k => $v) { $viewRoles[] = $participantRoles[$v]; } @@ -472,54 +472,54 @@ public function getQILL() { */ public function &getColumnHeaders($action = NULL, $output = NULL) { if (!isset(self::$_columnHeaders)) { - self::$_columnHeaders = array( - array( + self::$_columnHeaders = [ + [ 'name' => ts('Event'), 'sort' => 'event_title', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - array( + ], + [ 'name' => ts('Fee Level'), 'sort' => 'participant_fee_level', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - array( + ], + [ 'name' => ts('Amount'), 'sort' => 'participant_fee_amount', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - array( + ], + [ 'name' => ts('Registered'), 'sort' => 'participant_register_date', 'direction' => CRM_Utils_Sort::DESCENDING, - ), - array( + ], + [ 'name' => ts('Event Date(s)'), 'sort' => 'event_start_date', 'direction' => CRM_Utils_Sort::DESCENDING, - ), - array( + ], + [ 'name' => ts('Status'), 'sort' => 'participant_status', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - array( + ], + [ 'name' => ts('Role'), 'sort' => 'participant_role_id', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - array('desc' => ts('Actions')), - ); + ], + ['desc' => ts('Actions')], + ]; if (!$this->_single) { - $pre = array( - array('desc' => ts('Contact Type')), - array( + $pre = [ + ['desc' => ts('Contact Type')], + [ 'name' => ts('Participant'), 'sort' => 'sort_name', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - ); + ], + ]; self::$_columnHeaders = array_merge($pre, self::$_columnHeaders); } } diff --git a/CRM/Event/StateMachine/Registration.php b/CRM/Event/StateMachine/Registration.php index 7d325f17f8cf..d3120fb61c34 100644 --- a/CRM/Event/StateMachine/Registration.php +++ b/CRM/Event/StateMachine/Registration.php @@ -53,7 +53,7 @@ public function __construct($controller, $action = CRM_Core_Action::NONE) { $is_monetary = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $id, 'is_monetary'); $is_confirm_enabled = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $id, 'is_confirm_enabled'); - $pages = array('CRM_Event_Form_Registration_Register' => NULL); + $pages = ['CRM_Event_Form_Registration_Register' => NULL]; //handle additional participant scenario, where we need to insert participant pages on runtime $additionalParticipant = NULL; @@ -83,10 +83,10 @@ public function __construct($controller, $action = CRM_Core_Action::NONE) { $pages = array_merge($pages, $extraPages); } - $additionalPages = array( + $additionalPages = [ 'CRM_Event_Form_Registration_Confirm' => NULL, 'CRM_Event_Form_Registration_ThankYou' => NULL, - ); + ]; $pages = array_merge($pages, $additionalPages); diff --git a/CRM/Event/StateMachine/Search.php b/CRM/Event/StateMachine/Search.php index a2af360cb058..f31b006fbadc 100644 --- a/CRM/Event/StateMachine/Search.php +++ b/CRM/Event/StateMachine/Search.php @@ -50,7 +50,7 @@ class CRM_Event_StateMachine_Search extends CRM_Core_StateMachine { public function __construct($controller, $action = CRM_Core_Action::NONE) { parent::__construct($controller, $action); - $this->_pages = array(); + $this->_pages = []; $this->_pages['CRM_Event_Form_Search'] = NULL; list($task, $result) = $this->taskName($controller, 'Search'); diff --git a/CRM/Event/Task.php b/CRM/Event/Task.php index be00a64122dd..9e8542e103b5 100644 --- a/CRM/Event/Task.php +++ b/CRM/Event/Task.php @@ -57,77 +57,77 @@ class CRM_Event_Task extends CRM_Core_Task { */ public static function tasks() { if (!self::$_tasks) { - self::$_tasks = array( - self::TASK_DELETE => array( + self::$_tasks = [ + self::TASK_DELETE => [ 'title' => ts('Delete participants from event'), 'class' => 'CRM_Event_Form_Task_Delete', 'result' => FALSE, - ), - self::TASK_PRINT => array( + ], + self::TASK_PRINT => [ 'title' => ts('Print selected rows'), 'class' => 'CRM_Event_Form_Task_Print', 'result' => FALSE, - ), - self::TASK_EXPORT => array( + ], + self::TASK_EXPORT => [ 'title' => ts('Export participants'), - 'class' => array( + 'class' => [ 'CRM_Export_Form_Select', 'CRM_Export_Form_Map', - ), + ], 'result' => FALSE, - ), - self::BATCH_UPDATE => array( + ], + self::BATCH_UPDATE => [ 'title' => ts('Update multiple participants'), - 'class' => array( + 'class' => [ 'CRM_Event_Form_Task_PickProfile', 'CRM_Event_Form_Task_Batch', - ), + ], 'result' => TRUE, - ), - self::CANCEL_REGISTRATION => array( + ], + self::CANCEL_REGISTRATION => [ 'title' => ts('Cancel registration'), 'class' => 'CRM_Event_Form_Task_Cancel', 'result' => FALSE, - ), - self::TASK_EMAIL => array( - 'title' => ts('Email - send now (to %1 or less)', array( + ], + self::TASK_EMAIL => [ + 'title' => ts('Email - send now (to %1 or less)', [ 1 => Civi::settings() ->get('simple_mail_limit'), - )), + ]), 'class' => 'CRM_Event_Form_Task_Email', 'result' => TRUE, - ), - self::SAVE_SEARCH => array( + ], + self::SAVE_SEARCH => [ 'title' => ts('Group - create smart group'), 'class' => 'CRM_Event_Form_Task_SaveSearch', 'result' => TRUE, - ), - self::SAVE_SEARCH_UPDATE => array( + ], + self::SAVE_SEARCH_UPDATE => [ 'title' => ts('Group - update smart group'), 'class' => 'CRM_Event_Form_Task_SaveSearch_Update', 'result' => TRUE, - ), - self::PARTICIPANT_STATUS => array( + ], + self::PARTICIPANT_STATUS => [ 'title' => ts('Participant status - change'), 'class' => 'CRM_Event_Form_Task_ParticipantStatus', 'result' => TRUE, - ), - self::LABEL_CONTACTS => array( + ], + self::LABEL_CONTACTS => [ 'title' => ts('Name badges - print'), 'class' => 'CRM_Event_Form_Task_Badge', 'result' => FALSE, - ), - self::PDF_LETTER => array( + ], + self::PDF_LETTER => [ 'title' => ts('PDF letter - print for participants'), 'class' => 'CRM_Event_Form_Task_PDF', 'result' => TRUE, - ), - self::GROUP_ADD => array( + ], + self::GROUP_ADD => [ 'title' => ts('Group - add contacts'), 'class' => 'CRM_Event_Form_Task_AddToGroup', 'result' => FALSE, - ), - ); + ], + ]; //CRM-4418, check for delete if (!CRM_Core_Permission::check('delete in CiviEvent')) { @@ -154,17 +154,17 @@ public static function tasks() { * @return array * set of tasks that are valid for the user */ - public static function permissionedTaskTitles($permission, $params = array()) { + public static function permissionedTaskTitles($permission, $params = []) { if (($permission == CRM_Core_Permission::EDIT) || CRM_Core_Permission::check('edit event participants') ) { $tasks = self::taskTitles(); } else { - $tasks = array( + $tasks = [ self::TASK_EXPORT => self::$_tasks[self::TASK_EXPORT]['title'], self::TASK_EMAIL => self::$_tasks[self::TASK_EMAIL]['title'], - ); + ]; //CRM-4418, if (CRM_Core_Permission::check('delete in CiviEvent')) { diff --git a/CRM/Event/Tokens.php b/CRM/Event/Tokens.php index d399cbe8f9ba..fa26f56b613f 100644 --- a/CRM/Event/Tokens.php +++ b/CRM/Event/Tokens.php @@ -45,7 +45,7 @@ class CRM_Event_Tokens extends \Civi\Token\AbstractTokenSubscriber { */ public function __construct() { parent::__construct('event', array_merge( - array( + [ 'event_type' => ts('Event Type'), 'title' => ts('Event Title'), 'event_id' => ts('Event ID'), @@ -60,7 +60,7 @@ public function __construct() { 'contact_email' => ts('Event Contact (Email)'), 'contact_phone' => ts('Event Contact (Phone)'), 'balance' => ts('Event Balance'), - ), + ], CRM_Utils_Token::getCustomFieldTokens('Event') )); } @@ -105,7 +105,7 @@ public function evaluateToken(\Civi\Token\TokenRow $row, $entity, $field, $prefe $actionSearchResult = $row->context['actionSearchResult']; if ($field == 'location') { - $loc = array(); + $loc = []; $stateProvince = \CRM_Core_PseudoConstant::stateProvince(); $loc['street_address'] = $actionSearchResult->street_address; $loc['city'] = $actionSearchResult->city; @@ -122,7 +122,7 @@ public function evaluateToken(\Civi\Token\TokenRow $row, $entity, $field, $prefe $row ->tokens($entity, $field, \CRM_Utils_System::url('civicrm/event/register', 'reset=1&id=' . $actionSearchResult->event_id, TRUE, NULL, FALSE)); } - elseif (in_array($field, array('start_date', 'end_date'))) { + elseif (in_array($field, ['start_date', 'end_date'])) { $row->tokens($entity, $field, \CRM_Utils_Date::customFormat($actionSearchResult->$field)); } elseif ($field == 'balance') { diff --git a/CRM/Export/BAO/Export.php b/CRM/Export/BAO/Export.php index 7e83f46da9de..ceaa4cb4ab9d 100644 --- a/CRM/Export/BAO/Export.php +++ b/CRM/Export/BAO/Export.php @@ -206,7 +206,7 @@ public static function exportComponents( $componentTable = NULL, $mergeSameAddress = FALSE, $mergeSameHousehold = FALSE, - $exportParams = array(), + $exportParams = [], $queryOperator = 'AND' ) { @@ -216,7 +216,7 @@ public static function exportComponents( ); $processor = new CRM_Export_BAO_ExportProcessor($exportMode, $fields, $queryOperator, $mergeSameHousehold, $isPostalOnly); - $returnProperties = array(); + $returnProperties = []; if ($fields) { foreach ($fields as $key => $value) { @@ -276,8 +276,8 @@ public static function exportComponents( $returnProperties['state_province'] = 1; // some columns are required for assistance incase they are not already present - $exportParams['merge_same_address']['temp_columns'] = array(); - $tempColumns = array('id', 'master_id', 'state_province_id', 'postal_greeting_id', 'addressee_id'); + $exportParams['merge_same_address']['temp_columns'] = []; + $tempColumns = ['id', 'master_id', 'state_province_id', 'postal_greeting_id', 'addressee_id']; foreach ($tempColumns as $column) { if (!array_key_exists($column, $returnProperties)) { $returnProperties[$column] = 1; @@ -304,12 +304,12 @@ public static function exportComponents( $returnProperties = array_merge($returnProperties, $moreReturnProperties); } - $exportParams['postal_mailing_export']['temp_columns'] = array(); + $exportParams['postal_mailing_export']['temp_columns'] = []; if ($exportParams['exportOption'] == 2 && isset($exportParams['postal_mailing_export']) && CRM_Utils_Array::value('postal_mailing_export', $exportParams['postal_mailing_export']) == 1 ) { - $postalColumns = array('is_deceased', 'do_not_mail', 'street_address', 'supplemental_address_1'); + $postalColumns = ['is_deceased', 'do_not_mail', 'street_address', 'supplemental_address_1']; foreach ($postalColumns as $column) { if (!array_key_exists($column, $returnProperties)) { $returnProperties[$column] = 1; @@ -428,7 +428,7 @@ public static function exportComponents( } } - $componentDetails = array(); + $componentDetails = []; $rowCount = self::EXPORT_ROW_COUNT; $offset = 0; @@ -466,7 +466,7 @@ public static function exportComponents( // output every $tempRowCount rows if ($count % $tempRowCount == 0) { self::writeDetailsToTable($exportTempTable, $componentDetails, $sqlColumns); - $componentDetails = array(); + $componentDetails = []; } } if ($rowsThisIteration < self::EXPORT_ROW_COUNT) { @@ -493,7 +493,7 @@ public static function exportComponents( } else { // return tableName sqlColumns headerRows in test context - return array($exportTempTable, $sqlColumns, $headerRows, $processor); + return [$exportTempTable, $sqlColumns, $headerRows, $processor]; } // delete the export temp table and component table @@ -575,14 +575,14 @@ public static function exportCustom($customSearchClass, $formValues, $order) { $header = array_keys($columns); $fields = array_values($columns); - $rows = array(); + $rows = []; $dao = CRM_Core_DAO::executeQuery($sql); $alterRow = FALSE; if (method_exists($search, 'alterRow')) { $alterRow = TRUE; } while ($dao->fetch()) { - $row = array(); + $row = []; foreach ($fields as $field) { $unqualified_field = CRM_Utils_Array::First(array_slice(explode('.', $field), -1)); @@ -618,11 +618,11 @@ public static function writeDetailsToTable($tableName, $details, $sqlColumns) { $id = 0; } - $sqlClause = array(); + $sqlClause = []; foreach ($details as $row) { $id++; - $valueString = array($id); + $valueString = [$id]; foreach ($row as $value) { if (empty($value)) { $valueString[] = "''"; @@ -665,11 +665,11 @@ public static function createTempTable($sqlColumns) { $sql .= "\n PRIMARY KEY ( id )"; // add indexes for street_address and household_name if present - $addIndices = array( + $addIndices = [ 'street_address', 'household_name', 'civicrm_primary_id', - ); + ]; foreach ($addIndices as $index) { if (isset($sqlColumns[$index])) { @@ -739,7 +739,7 @@ public static function mergeSameAddress($tableName, &$sqlColumns, $exportParams) // unset ids from $merge already present in $linkedMerge foreach ($linkedMerge as $masterID => $values) { - $keys = array($masterID); + $keys = [$masterID]; $keys = array_merge($keys, array_keys($values['copy'])); foreach ($merge as $mid => $vals) { if (in_array($mid, $keys)) { @@ -762,12 +762,12 @@ public static function mergeSameAddress($tableName, &$sqlColumns, $exportParams) SET addressee = %1, postal_greeting = %2, email_greeting = %3 WHERE id = %4 "; - $params = array( - 1 => array($values['addressee'], 'String'), - 2 => array($values['postalGreeting'], 'String'), - 3 => array($values['emailGreeting'], 'String'), - 4 => array($masterID, 'Integer'), - ); + $params = [ + 1 => [$values['addressee'], 'String'], + 2 => [$values['postalGreeting'], 'String'], + 3 => [$values['emailGreeting'], 'String'], + 4 => [$masterID, 'Integer'], + ]; CRM_Core_DAO::executeQuery($sql, $params); // delete all copies @@ -799,21 +799,21 @@ public static function mergeSameAddress($tableName, &$sqlColumns, $exportParams) * @return array */ public static function _replaceMergeTokens($contactId, $exportParams) { - $greetings = array(); + $greetings = []; $contact = NULL; - $greetingFields = array( + $greetingFields = [ 'postal_greeting', 'addressee', - ); + ]; foreach ($greetingFields as $greeting) { if (!empty($exportParams[$greeting])) { $greetingLabel = $exportParams[$greeting]; if (empty($contact)) { - $values = array( + $values = [ 'id' => $contactId, 'version' => 3, - ); + ]; $contact = civicrm_api('contact', 'get', $values); if (!empty($contact['is_error'])) { @@ -822,7 +822,7 @@ public static function _replaceMergeTokens($contactId, $exportParams) { $contact = $contact['values'][$contact['id']]; } - $tokens = array('contact' => $greetingLabel); + $tokens = ['contact' => $greetingLabel]; $greetings[$greeting] = CRM_Utils_Token::replaceContactTokens($greetingLabel, $contact, NULL, $tokens); } } @@ -870,12 +870,12 @@ public static function _trimNonTokens( * @return array */ public static function _buildMasterCopyArray($sql, $exportParams, $sharedAddress = FALSE) { - static $contactGreetingTokens = array(); + static $contactGreetingTokens = []; $addresseeOptions = CRM_Core_OptionGroup::values('addressee'); $postalOptions = CRM_Core_OptionGroup::values('postal_greeting'); - $merge = $parents = array(); + $merge = $parents = []; $dao = CRM_Core_DAO::executeQuery($sql); while ($dao->fetch()) { @@ -917,11 +917,11 @@ public static function _buildMasterCopyArray($sql, $exportParams, $sharedAddress $masterID = $parents[$masterID]; } else { - $merge[$masterID] = array( + $merge[$masterID] = [ 'addressee' => $masterAddressee, - 'copy' => array(), + 'copy' => [], 'postalGreeting' => $masterPostalGreeting, - ); + ]; $merge[$masterID]['emailGreeting'] = &$merge[$masterID]['postalGreeting']; } } @@ -989,9 +989,9 @@ public static function writeCSVFromTable($exportTempTable, $headerRows, $sqlColu break; } - $componentDetails = array(); + $componentDetails = []; while ($dao->fetch()) { - $row = array(); + $row = []; foreach ($sqlColumns as $column => $dontCare) { $row[$column] = $dao->$column; @@ -1021,13 +1021,13 @@ public static function writeCSVFromTable($exportTempTable, $headerRows, $sqlColu public static function componentPaymentFields() { static $componentPaymentFields; if (!isset($componentPaymentFields)) { - $componentPaymentFields = array( + $componentPaymentFields = [ 'componentPaymentField_total_amount' => ts('Total Amount'), 'componentPaymentField_contribution_status' => ts('Contribution Status'), 'componentPaymentField_received_date' => ts('Date Received'), 'componentPaymentField_payment_instrument' => ts('Payment Method'), 'componentPaymentField_transaction_id' => ts('Transaction ID'), - ); + ]; } return $componentPaymentFields; } @@ -1061,7 +1061,7 @@ public static function componentPaymentFields() { * yet find a way to comment them for posterity. */ public static function getExportStructureArrays($returnProperties, $processor) { - $outputColumns = $metadata = array(); + $outputColumns = $metadata = []; $queryFields = $processor->getQueryFields(); foreach ($returnProperties as $key => $value) { if (($key != 'location' || !is_array($value)) && !$processor->isRelationshipTypeKey($key)) { @@ -1104,7 +1104,7 @@ public static function getExportStructureArrays($returnProperties, $processor) { } } } - return array($outputColumns, $metadata); + return [$outputColumns, $metadata]; } /** @@ -1131,11 +1131,11 @@ private static function fetchRelationshipDetails($relDAO, $value, $field, &$row) $fieldValue = CRM_Utils_Array::value($relationValue, $imProviders); } // CRM-13995 - elseif (is_object($relDAO) && in_array($relationField, array( + elseif (is_object($relDAO) && in_array($relationField, [ 'email_greeting', 'postal_greeting', 'addressee', - )) + ]) ) { //special case for greeting replacement $fldValue = "{$relationField}_display"; @@ -1178,13 +1178,13 @@ private static function fetchRelationshipDetails($relDAO, $value, $field, &$row) case in_array('country', $type): case in_array('world_region', $type): $row[$field . '_' . $fldValue] = $i18n->crm_translate($relDAO->$fldValue, - array('context' => 'country') + ['context' => 'country'] ); break; case in_array('state_province', $type): $row[$field . '_' . $fldValue] = $i18n->crm_translate($relDAO->$fldValue, - array('context' => 'province') + ['context' => 'province'] ); break; @@ -1206,11 +1206,11 @@ private static function fetchRelationshipDetails($relDAO, $value, $field, &$row) switch ($relationField) { case 'country': case 'world_region': - $row[$relPrefix] = $i18n->crm_translate($fieldValue, array('context' => 'country')); + $row[$relPrefix] = $i18n->crm_translate($fieldValue, ['context' => 'country']); break; case 'state_province': - $row[$relPrefix] = $i18n->crm_translate($fieldValue, array('context' => 'province')); + $row[$relPrefix] = $i18n->crm_translate($fieldValue, ['context' => 'province']); break; default: @@ -1269,12 +1269,12 @@ protected static function getIDsForRelatedContact($ids, $exportMode) { * @param $componentTable */ protected static function buildRelatedContactArray($selectAll, $ids, $processor, $componentTable) { - $allRelContactArray = $relationQuery = array(); + $allRelContactArray = $relationQuery = []; $queryMode = $processor->getQueryMode(); $exportMode = $processor->getExportMode(); foreach ($processor->getRelationshipReturnProperties() as $relationshipKey => $relationReturnProperties) { - $allRelContactArray[$relationshipKey] = array(); + $allRelContactArray[$relationshipKey] = []; // build Query for each relationship $relationQuery = new CRM_Contact_BAO_Query(NULL, $relationReturnProperties, NULL, FALSE, FALSE, $queryMode diff --git a/CRM/Export/BAO/ExportProcessor.php b/CRM/Export/BAO/ExportProcessor.php index 35968fdd67e0..6efa6bd41381 100644 --- a/CRM/Export/BAO/ExportProcessor.php +++ b/CRM/Export/BAO/ExportProcessor.php @@ -516,7 +516,7 @@ public function runQuery($params, $order, $returnProperties) { $query->_sort = $order; list($select, $from, $where, $having) = $query->query(); $this->setQueryFields($query->_fields); - return array($query, $select, $from, $where . $addressWhere, $having); + return [$query, $select, $from, $where . $addressWhere, $having]; } /** @@ -783,11 +783,11 @@ public function getTransformedFieldValue($field, $iterationDAO, $fieldValue, $me return CRM_Core_BAO_CustomField::displayValue($fieldValue, $cfID); } - elseif (in_array($field, array( + elseif (in_array($field, [ 'email_greeting', 'postal_greeting', 'addressee', - ))) { + ])) { //special case for greeting replacement $fldValue = "{$field}_display"; return $iterationDAO->$fldValue; @@ -797,10 +797,10 @@ public function getTransformedFieldValue($field, $iterationDAO, $fieldValue, $me switch ($field) { case 'country': case 'world_region': - return $i18n->crm_translate($fieldValue, array('context' => 'country')); + return $i18n->crm_translate($fieldValue, ['context' => 'country']); case 'state_province': - return $i18n->crm_translate($fieldValue, array('context' => 'province')); + return $i18n->crm_translate($fieldValue, ['context' => 'province']); case 'gender': case 'preferred_communication_method': @@ -842,13 +842,13 @@ 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); - $payFieldMapper = array( + $payFieldMapper = [ 'componentPaymentField_total_amount' => 'total_amount', 'componentPaymentField_contribution_status' => 'contribution_status', 'componentPaymentField_payment_instrument' => 'pay_instru', 'componentPaymentField_transaction_id' => 'trxn_id', 'componentPaymentField_received_date' => 'receive_date', - ); + ]; return CRM_Utils_Array::value($payFieldMapper[$field], $paymentData, ''); } else { diff --git a/CRM/Export/Controller/Standalone.php b/CRM/Export/Controller/Standalone.php index b0ef9c555070..f91363906faf 100644 --- a/CRM/Export/Controller/Standalone.php +++ b/CRM/Export/Controller/Standalone.php @@ -46,12 +46,12 @@ public function __construct($title = NULL, $action = CRM_Core_Action::NONE, $mod $id = explode(',', CRM_Utils_Request::retrieve('id', 'CommaSeparatedIntegers', $this, TRUE)); // Check permissions - $perm = civicrm_api3($entity, 'get', array( + $perm = civicrm_api3($entity, 'get', [ 'return' => 'id', - 'options' => array('limit' => 0), + 'options' => ['limit' => 0], 'check_permissions' => 1, - 'id' => array('IN' => $id), - )); + 'id' => ['IN' => $id], + ]); $this->set('id', implode(',', array_keys($perm['values']))); if ($entity == 'Contact') { diff --git a/CRM/Export/Form/Map.php b/CRM/Export/Form/Map.php index 0b6de9777139..0d4b16235d5d 100644 --- a/CRM/Export/Form/Map.php +++ b/CRM/Export/Form/Map.php @@ -93,22 +93,22 @@ public function buildQuickForm() { $this->get('exportMode') ); - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'back', 'name' => ts('Previous'), - ), - array( + ], + [ 'type' => 'next', 'name' => ts('Export'), 'spacing' => '          ', - ), - array( + ], + [ 'type' => 'done', 'icon' => 'fa-times', 'name' => ts('Done'), - ), - ) + ], + ] ); } @@ -125,7 +125,7 @@ public function buildQuickForm() { * list of errors to be posted back to the form */ public static function formRule($fields, $values, $mappingTypeId) { - $errors = array(); + $errors = []; if (!empty($fields['saveMapping']) && !empty($fields['_qf_Map_next'])) { $nameField = CRM_Utils_Array::value('saveMappingName', $fields); @@ -221,11 +221,11 @@ public function postProcess() { } if (!empty($params['saveMapping'])) { - $mappingParams = array( + $mappingParams = [ 'name' => $params['saveMappingName'], 'description' => $params['saveMappingDesc'], 'mapping_type_id' => $this->get('mappingTypeId'), - ); + ]; $saveMapping = CRM_Core_BAO_Mapping::add($mappingParams); diff --git a/CRM/Export/Form/Select.php b/CRM/Export/Form/Select.php index 34a06734bd85..5ce06d9976ce 100644 --- a/CRM/Export/Form/Select.php +++ b/CRM/Export/Form/Select.php @@ -91,11 +91,11 @@ public function preProcess() { $this->_selectAll = FALSE; $this->_exportMode = self::CONTACT_EXPORT; - $this->_componentIds = array(); + $this->_componentIds = []; $this->_componentClause = NULL; // we need to determine component export - $components = array('Contact', 'Contribute', 'Member', 'Event', 'Pledge', 'Case', 'Grant', 'Activity'); + $components = ['Contact', 'Contribute', 'Member', 'Event', 'Pledge', 'Case', 'Grant', 'Activity']; // FIXME: This should use a modified version of CRM_Contact_Form_Search::getModeValue but it doesn't have all the contexts // FIXME: Or better still, use CRM_Core_DAO_AllCoreTables::getBriefName($daoName) to get the $entityShortName @@ -140,7 +140,7 @@ public function preProcess() { $formName = CRM_Utils_System::getClassName($this->controller->getStateMachine()); $componentName = explode('_', $formName); if ($formName == 'CRM_Export_StateMachine_Standalone') { - $componentName = array('CRM', $this->controller->get('entity')); + $componentName = ['CRM', $this->controller->get('entity')]; } $entityShortname = $componentName[1]; // Contact $entityDAOName = $entityShortname; @@ -245,37 +245,37 @@ public function preProcess() { */ public function buildQuickForm() { //export option - $exportOptions = $mergeOptions = $postalMailing = array(); + $exportOptions = $mergeOptions = $postalMailing = []; $exportOptions[] = $this->createElement('radio', NULL, NULL, ts('Export PRIMARY fields'), self::EXPORT_ALL, - array('onClick' => 'showMappingOption( );') + ['onClick' => 'showMappingOption( );'] ); $exportOptions[] = $this->createElement('radio', NULL, NULL, ts('Select fields for export'), self::EXPORT_SELECTED, - array('onClick' => 'showMappingOption( );') + ['onClick' => 'showMappingOption( );'] ); $mergeOptions[] = $this->createElement('radio', NULL, NULL, ts('Do not merge'), self::EXPORT_MERGE_DO_NOT_MERGE, - array('onclick' => 'showGreetingOptions( );') + ['onclick' => 'showGreetingOptions( );'] ); $mergeOptions[] = $this->createElement('radio', NULL, NULL, ts('Merge All Contacts with the Same Address'), self::EXPORT_MERGE_SAME_ADDRESS, - array('onclick' => 'showGreetingOptions( );') + ['onclick' => 'showGreetingOptions( );'] ); $mergeOptions[] = $this->createElement('radio', NULL, NULL, ts('Merge Household Members into their Households'), self::EXPORT_MERGE_HOUSEHOLD, - array('onclick' => 'showGreetingOptions( );') + ['onclick' => 'showGreetingOptions( );'] ); $postalMailing[] = $this->createElement('advcheckbox', @@ -290,9 +290,9 @@ public function buildQuickForm() { $this->_greetingOptions = self::getGreetingOptions(); foreach ($this->_greetingOptions as $key => $value) { - $fieldLabel = ts('%1 (merging > 2 contacts)', array(1 => ucwords(str_replace('_', ' ', $key)))); + $fieldLabel = ts('%1 (merging > 2 contacts)', [1 => ucwords(str_replace('_', ' ', $key))]); $this->addElement('select', $key, $fieldLabel, - $value, array('onchange' => "showOther(this);") + $value, ['onchange' => "showOther(this);"] ); $this->addElement('text', "{$key}_other", ''); } @@ -303,33 +303,33 @@ public function buildQuickForm() { $this->addGroup($postalMailing, 'postal_mailing_export', ts('Postal Mailing Export'), '
    '); $this->addElement('select', 'additional_group', ts('Additional Group for Export'), - array('' => ts('- select group -')) + CRM_Core_PseudoConstant::nestedGroup(), - array('class' => 'crm-select2 huge') + ['' => ts('- select group -')] + CRM_Core_PseudoConstant::nestedGroup(), + ['class' => 'crm-select2 huge'] ); } $this->buildMapping(); - $this->setDefaults(array( + $this->setDefaults([ 'exportOption' => self::EXPORT_ALL, 'mergeOption' => self::EXPORT_MERGE_DO_NOT_MERGE, - )); + ]); - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => ts('Continue'), 'spacing' => '          ', 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); - $this->addFormRule(array('CRM_Export_Form_Select', 'formRule'), $this); + $this->addFormRule(['CRM_Export_Form_Select', 'formRule'], $this); } /** @@ -345,15 +345,15 @@ public function buildQuickForm() { * mixed true or array of errors */ public static function formRule($params, $files, $self) { - $errors = array(); + $errors = []; if (CRM_Utils_Array::value('mergeOption', $params) == self::EXPORT_MERGE_SAME_ADDRESS && $self->_matchingContacts ) { - $greetings = array( + $greetings = [ 'postal_greeting' => 'postal_greeting_other', 'addressee' => 'addressee_other', - ); + ]; foreach ($greetings as $key => $value) { $otherOption = CRM_Utils_Array::value($key, $params); @@ -361,7 +361,7 @@ public static function formRule($params, $files, $self) { if ((CRM_Utils_Array::value($otherOption, $self->_greetingOptions[$key]) == ts('Other')) && empty($params[$value])) { $label = ucwords(str_replace('_', ' ', $key)); - $errors[$value] = ts('Please enter a value for %1 (merging > 2 contacts), or select a pre-configured option from the list.', array(1 => $label)); + $errors[$value] = ts('Please enter a value for %1 (merging > 2 contacts), or select a pre-configured option from the list.', [1 => $label]); } } } @@ -484,7 +484,7 @@ public function buildMapping() { $mappings = CRM_Core_BAO_Mapping::getMappings($exportType); if (!empty($mappings)) { - $this->add('select', 'mapping', ts('Use Saved Field Mapping'), array('' => '-select-') + $mappings); + $this->add('select', 'mapping', ts('Use Saved Field Mapping'), ['' => '-select-'] + $mappings); } } @@ -492,22 +492,22 @@ public function buildMapping() { * @return array */ public static function getGreetingOptions() { - $options = array(); - $greetings = array( + $options = []; + $greetings = [ 'postal_greeting' => 'postal_greeting_other', 'addressee' => 'addressee_other', - ); + ]; foreach ($greetings as $key => $value) { - $params = array(); + $params = []; $optionGroupId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', $key, 'id', 'name'); CRM_Core_DAO::commonRetrieveAll('CRM_Core_DAO_OptionValue', 'option_group_id', $optionGroupId, - $params, array('label', 'filter') + $params, ['label', 'filter'] ); $greetingCount = 1; - $options[$key] = array("$greetingCount" => ts('List of names')); + $options[$key] = ["$greetingCount" => ts('List of names')]; foreach ($params as $id => $field) { if (CRM_Utils_Array::value('filter', $field) == 4) { diff --git a/CRM/Export/StateMachine/Standalone.php b/CRM/Export/StateMachine/Standalone.php index 137750e86b6e..375013a7f73d 100644 --- a/CRM/Export/StateMachine/Standalone.php +++ b/CRM/Export/StateMachine/Standalone.php @@ -41,10 +41,10 @@ class CRM_Export_StateMachine_Standalone extends CRM_Core_StateMachine { public function __construct($controller, $action = CRM_Core_Action::NONE) { parent::__construct($controller, $action); - $this->_pages = array( + $this->_pages = [ 'CRM_Export_Form_Select' => NULL, 'CRM_Export_Form_Map' => NULL, - ); + ]; $this->addSequentialPages($this->_pages, $action); } diff --git a/CRM/Extension/Container/Basic.php b/CRM/Extension/Container/Basic.php index 925b27444e91..42277242767a 100644 --- a/CRM/Extension/Container/Basic.php +++ b/CRM/Extension/Container/Basic.php @@ -105,19 +105,19 @@ public function __construct($baseDir, $baseUrl, CRM_Utils_Cache_Interface $cache * @return array */ public function checkRequirements() { - $errors = array(); + $errors = []; if (empty($this->baseDir) || !is_dir($this->baseDir)) { - $errors[] = array( + $errors[] = [ 'title' => ts('Invalid Base Directory'), 'message' => ts('An extension container has been defined with a blank directory.'), - ); + ]; } if (empty($this->baseUrl)) { - $errors[] = array( + $errors[] = [ 'title' => ts('Invalid Base URL'), 'message' => ts('An extension container has been defined with a blank URL.'), - ); + ]; } return $errors; @@ -146,10 +146,10 @@ public function getResUrl($key) { if (!$this->baseUrl) { CRM_Core_Session::setStatus( ts('Failed to determine URL for extension (%1). Please update Resource URLs.', - array( + [ 1 => $key, 2 => CRM_Utils_System::url('civicrm/admin/setting/url', 'reset=1'), - ) + ] ) ); } @@ -202,7 +202,7 @@ protected function getRelPaths() { $this->relPaths = $this->cache->get($this->cacheKey); } if (!is_array($this->relPaths)) { - $this->relPaths = array(); + $this->relPaths = []; $infoPaths = CRM_Utils_File::findFiles($this->baseDir, 'info.xml'); foreach ($infoPaths as $infoPath) { $relPath = CRM_Utils_File::relativize(dirname($infoPath), $this->baseDir); @@ -210,9 +210,9 @@ protected function getRelPaths() { $info = CRM_Extension_Info::loadFromFile($infoPath); } catch (CRM_Extension_Exception_ParseException $e) { - CRM_Core_Session::setStatus(ts('Parse error in extension: %1', array( + CRM_Core_Session::setStatus(ts('Parse error in extension: %1', [ 1 => $e->getMessage(), - )), '', 'error'); + ]), '', 'error'); CRM_Core_Error::debug_log_message("Parse error in extension: " . $e->getMessage()); continue; } @@ -272,7 +272,7 @@ protected function getRelUrls() { * Array($key => $relUrl). */ public static function convertPathsToUrls($dirSep, $relPaths) { - $relUrls = array(); + $relUrls = []; foreach ($relPaths as $key => $relPath) { $relUrls[$key] = str_replace($dirSep, '/', $relPath); } diff --git a/CRM/Extension/Container/Collection.php b/CRM/Extension/Container/Collection.php index a3f541cbf281..0258c3689690 100644 --- a/CRM/Extension/Container/Collection.php +++ b/CRM/Extension/Container/Collection.php @@ -85,7 +85,7 @@ public function __construct($containers, CRM_Utils_Cache_Interface $cache = NULL * @return array */ public function checkRequirements() { - $errors = array(); + $errors = []; foreach ($this->containers as $container) { $errors = array_merge($errors, $container->checkRequirements()); } @@ -163,7 +163,7 @@ public function getKeysToContainer() { $k2c = $this->cache->get($this->cacheKey); } if (!isset($k2c) || !is_array($k2c)) { - $k2c = array(); + $k2c = []; $containerNames = array_reverse(array_keys($this->containers)); foreach ($containerNames as $name) { $keys = $this->containers[$name]->getKeys(); diff --git a/CRM/Extension/Container/Static.php b/CRM/Extension/Container/Static.php index 667b0bfd1d15..d0d6c55a9d68 100644 --- a/CRM/Extension/Container/Static.php +++ b/CRM/Extension/Container/Static.php @@ -47,7 +47,7 @@ public function __construct($exts) { * @inheritDoc */ public function checkRequirements() { - return array(); + return []; } /** diff --git a/CRM/Extension/Info.php b/CRM/Extension/Info.php index aa8e4ba7a95c..06b40588ec6d 100644 --- a/CRM/Extension/Info.php +++ b/CRM/Extension/Info.php @@ -49,13 +49,13 @@ class CRM_Extension_Info { * Each item is a specification like: * array('type'=>'psr4', 'namespace'=>'Foo\Bar', 'path'=>'/foo/bar'). */ - public $classloader = array(); + public $classloader = []; /** * @var array * Each item is they key-name of an extension required by this extension. */ - public $requires = array(); + public $requires = []; /** * Load extension info an XML file. @@ -108,7 +108,7 @@ public static function loadFromString($string) { * Array(string $key => array $requiredBys). */ public static function buildReverseMap($infos) { - $revMap = array(); + $revMap = []; foreach ($infos as $info) { foreach ($info->requires as $key) { $revMap[$key][] = $info; @@ -151,7 +151,7 @@ public function parse($info) { $this->$attr = (string) $val; } elseif ($attr === 'urls') { - $this->urls = array(); + $this->urls = []; foreach ($val->url as $url) { $urlAttr = (string) $url->attributes()->desc; $this->urls[$urlAttr] = (string) $url; @@ -159,13 +159,13 @@ public function parse($info) { ksort($this->urls); } elseif ($attr === 'classloader') { - $this->classloader = array(); + $this->classloader = []; foreach ($val->psr4 as $psr4) { - $this->classloader[] = array( + $this->classloader[] = [ 'type' => 'psr4', 'prefix' => (string) $psr4->attributes()->prefix, 'path' => (string) $psr4->attributes()->path, - ); + ]; } } elseif ($attr === 'requires') { diff --git a/CRM/Extension/Manager.php b/CRM/Extension/Manager.php index 6a7cefeda0d9..6524c0a16fae 100644 --- a/CRM/Extension/Manager.php +++ b/CRM/Extension/Manager.php @@ -141,10 +141,10 @@ public function replace($tmpCodeDir) { // force installation in the default-container $oldPath = $tgtPath; $tgtPath = $this->defaultContainer->getBaseDir() . DIRECTORY_SEPARATOR . $newInfo->key; - CRM_Core_Session::setStatus(ts('A copy of the extension (%1) is in a system folder (%2). The system copy will be preserved, but the new copy will be used.', array( + CRM_Core_Session::setStatus(ts('A copy of the extension (%1) is in a system folder (%2). The system copy will be preserved, but the new copy will be used.', [ 1 => $newInfo->key, 2 => $oldPath, - ))); + ])); } break; @@ -418,7 +418,7 @@ public function getStatus($key) { */ public function getStatuses() { if (!is_array($this->statuses)) { - $this->statuses = array(); + $this->statuses = []; foreach ($this->fullContainer->getKeys() as $key) { $this->statuses[$key] = self::STATUS_UNINSTALLED; @@ -468,7 +468,7 @@ public function refresh() { private function _getInfoTypeHandler($key) { $info = $this->mapper->keyToInfo($key); // throws Exception if (array_key_exists($info->type, $this->typeManagers)) { - return array($info, $this->typeManagers[$info->type]); + return [$info, $this->typeManagers[$info->type]]; } else { throw new CRM_Extension_Exception("Unrecognized extension type: " . $info->type); @@ -488,7 +488,7 @@ private function _getMissingInfoTypeHandler($key) { $info = $this->createInfoFromDB($key); if ($info) { if (array_key_exists($info->type, $this->typeManagers)) { - return array($info, $this->typeManagers[$info->type]); + return [$info, $this->typeManagers[$info->type]]; } else { throw new CRM_Extension_Exception("Unrecognized extension type: " . $info->type); @@ -560,10 +560,10 @@ private function _removeExtensionEntry(CRM_Extension_Info $info) { * @param $isActive */ private function _setExtensionActive(CRM_Extension_Info $info, $isActive) { - CRM_Core_DAO::executeQuery('UPDATE civicrm_extension SET is_active = %1 where full_name = %2', array( - 1 => array($isActive, 'Integer'), - 2 => array($info->key, 'String'), - )); + CRM_Core_DAO::executeQuery('UPDATE civicrm_extension SET is_active = %1 where full_name = %2', [ + 1 => [$isActive, 'Integer'], + 2 => [$info->key, 'String'], + ]); } /** @@ -596,7 +596,7 @@ public function createInfoFromDB($key) { public function findInstallRequirements($keys) { $infos = $this->mapper->getAllInfos(); $todoKeys = array_unique($keys); // array(string $key). - $doneKeys = array(); // array(string $key => 1); + $doneKeys = []; // array(string $key => 1); $sorter = new \MJS\TopSort\Implementations\FixedArraySort(); while (!empty($todoKeys)) { @@ -610,14 +610,14 @@ public function findInstallRequirements($keys) { $info = @$infos[$key]; if ($this->getStatus($key) === self::STATUS_INSTALLED) { - $sorter->add($key, array()); + $sorter->add($key, []); } elseif ($info && $info->requires) { $sorter->add($key, $info->requires); $todoKeys = array_merge($todoKeys, $info->requires); } else { - $sorter->add($key, array()); + $sorter->add($key, []); } } return $sorter->sort(); @@ -632,14 +632,14 @@ public function findInstallRequirements($keys) { * List of extension keys, including dependencies, in order of removal. */ public function findDisableRequirements($keys) { - $INSTALLED = array( + $INSTALLED = [ self::STATUS_INSTALLED, self::STATUS_INSTALLED_MISSING, - ); + ]; $installedInfos = $this->filterInfosByStatus($this->mapper->getAllInfos(), $INSTALLED); $revMap = CRM_Extension_Info::buildReverseMap($installedInfos); $todoKeys = array_unique($keys); - $doneKeys = array(); + $doneKeys = []; $sorter = new \MJS\TopSort\Implementations\FixedArraySort(); while (!empty($todoKeys)) { @@ -656,7 +656,7 @@ public function findDisableRequirements($keys) { $todoKeys = array_merge($todoKeys, $requiredBys); } else { - $sorter->add($key, array()); + $sorter->add($key, []); } } return $sorter->sort(); @@ -668,7 +668,7 @@ public function findDisableRequirements($keys) { * @return array */ protected function filterInfosByStatus($infos, $filterStatuses) { - $matches = array(); + $matches = []; foreach ($infos as $k => $v) { if (in_array($this->getStatus($v->key), $filterStatuses)) { $matches[$k] = $v; diff --git a/CRM/Extension/Manager/Payment.php b/CRM/Extension/Manager/Payment.php index 54cd41a94f28..9d2349a7f4c7 100644 --- a/CRM/Extension/Manager/Payment.php +++ b/CRM/Extension/Manager/Payment.php @@ -178,7 +178,7 @@ public function onPostEnable(CRM_Extension_Info $info) { * ($attr => $id) */ private function _getAllPaymentProcessorTypes($attr) { - $ppt = array(); + $ppt = []; $dao = new CRM_Financial_DAO_PaymentProcessorType(); $dao->find(); while ($dao->fetch()) { @@ -204,11 +204,11 @@ private function _runPaymentHook(CRM_Extension_Info $info, $method) { $paymentClass = $this->mapper->keyToClass($info->key, 'payment'); $file = $this->mapper->classToPath($paymentClass); if (!file_exists($file)) { - CRM_Core_Session::setStatus(ts('Failed to load file (%3) for payment processor (%1) while running "%2"', array( + CRM_Core_Session::setStatus(ts('Failed to load file (%3) for payment processor (%1) while running "%2"', [ 1 => $info->key, 2 => $method, 3 => $file, - )), '', 'error'); + ]), '', 'error'); return; } else { @@ -216,10 +216,10 @@ private function _runPaymentHook(CRM_Extension_Info $info, $method) { } } catch (CRM_Extension_Exception $e) { - CRM_Core_Session::setStatus(ts('Failed to determine file path for payment processor (%1) while running "%2"', array( + CRM_Core_Session::setStatus(ts('Failed to determine file path for payment processor (%1) while running "%2"', [ 1 => $info->key, 2 => $method, - )), '', 'error'); + ]), '', 'error'); return; } @@ -233,9 +233,9 @@ private function _runPaymentHook(CRM_Extension_Info $info, $method) { WHERE ext.type = 'payment' AND ext.full_name = %1 ", - array( - 1 => array($info->key, 'String'), - ) + [ + 1 => [$info->key, 'String'], + ] ); while ($processorDAO->fetch()) { @@ -262,10 +262,10 @@ private function _runPaymentHook(CRM_Extension_Info $info, $method) { $processorInstance = Civi\Payment\System::singleton()->getByClass($class_name); // Does PP implement this method, and can we call it? - if (method_exists($processorInstance, $method) && is_callable(array( + if (method_exists($processorInstance, $method) && is_callable([ $processorInstance, $method, - )) + ]) ) { // If so, call it ... $processorInstance->$method(); @@ -274,7 +274,7 @@ private function _runPaymentHook(CRM_Extension_Info $info, $method) { default: CRM_Core_Session::setStatus(ts("Unrecognized payment hook (%1) in %2::%3", - array(1 => $method, 2 => __CLASS__, 3 => __METHOD__)), + [1 => $method, 2 => __CLASS__, 3 => __METHOD__]), '', 'error'); } } diff --git a/CRM/Extension/Manager/Report.php b/CRM/Extension/Manager/Report.php index 4d61b9d5e876..3302ec291824 100644 --- a/CRM/Extension/Manager/Report.php +++ b/CRM/Extension/Manager/Report.php @@ -67,10 +67,10 @@ public function onPreInstall(CRM_Extension_Info $info) { CRM_Core_Error::fatal("Component for which you're trying to install the extension (" . $info->typeInfo['component'] . ") is currently disabled."); } $weight = CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_OptionValue', - array('option_group_id' => $this->groupId) + ['option_group_id' => $this->groupId] ); - $ids = array(); - $params = array( + $ids = []; + $params = [ 'label' => $info->label . ' (' . $info->key . ')', 'value' => $info->typeInfo['reportUrl'], 'name' => $info->key, @@ -79,7 +79,7 @@ public function onPreInstall(CRM_Extension_Info $info) { 'component_id' => $compId, 'option_group_id' => $this->groupId, 'is_active' => 1, - ); + ]; $optionValue = CRM_Core_BAO_OptionValue::add($params, $ids); } diff --git a/CRM/Extension/Manager/Search.php b/CRM/Extension/Manager/Search.php index 10ce827ff69f..1f0b291bf80c 100644 --- a/CRM/Extension/Manager/Search.php +++ b/CRM/Extension/Manager/Search.php @@ -58,10 +58,10 @@ public function onPreInstall(CRM_Extension_Info $info) { } $weight = CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_OptionValue', - array('option_group_id' => $this->groupId) + ['option_group_id' => $this->groupId] ); - $params = array( + $params = [ 'option_group_id' => $this->groupId, 'weight' => $weight, 'description' => $info->label . ' (' . $info->key . ')', @@ -69,9 +69,9 @@ public function onPreInstall(CRM_Extension_Info $info) { 'value' => max($customSearchesByName) + 1, 'label' => $info->key, 'is_active' => 1, - ); + ]; - $ids = array(); + $ids = []; $optionValue = CRM_Core_BAO_OptionValue::add($params, $ids); return $optionValue ? TRUE : FALSE; diff --git a/CRM/Extension/Mapper.php b/CRM/Extension/Mapper.php index 926d7086c3f9..358d3a910323 100644 --- a/CRM/Extension/Mapper.php +++ b/CRM/Extension/Mapper.php @@ -63,7 +63,7 @@ class CRM_Extension_Mapper { /** * @var array (key => CRM_Extension_Info) */ - protected $infos = array(); + protected $infos = []; /** * @var array @@ -277,7 +277,7 @@ public function keyToUrl($key) { public function getActiveModuleFiles($fresh = FALSE) { $config = CRM_Core_Config::singleton(); if ($config->isUpgradeMode() || !defined('CIVICRM_DSN')) { - return array(); // hmm, ok + return []; // hmm, ok } $moduleExtensions = NULL; @@ -287,7 +287,7 @@ public function getActiveModuleFiles($fresh = FALSE) { if (!is_array($moduleExtensions)) { // Check canonical module list - $moduleExtensions = array(); + $moduleExtensions = []; $sql = ' SELECT full_name, file FROM civicrm_extension @@ -297,20 +297,20 @@ public function getActiveModuleFiles($fresh = FALSE) { $dao = CRM_Core_DAO::executeQuery($sql); while ($dao->fetch()) { try { - $moduleExtensions[] = array( + $moduleExtensions[] = [ 'prefix' => $dao->file, 'filePath' => $this->keyToPath($dao->full_name), - ); + ]; } catch (CRM_Extension_Exception $e) { // Putting a stub here provides more consistency // in how getActiveModuleFiles when racing between // dirty file-removals and cache-clears. CRM_Core_Session::setStatus($e->getMessage(), '', 'error'); - $moduleExtensions[] = array( + $moduleExtensions[] = [ 'prefix' => $dao->file, 'filePath' => NULL, - ); + ]; } } @@ -329,7 +329,7 @@ public function getActiveModuleFiles($fresh = FALSE) { */ public function getActiveModuleUrls() { // TODO optimization/caching - $urls = array(); + $urls = []; $urls['civicrm'] = $this->keyToUrl('civicrm'); foreach ($this->getModules() as $module) { /** @var $module CRM_Core_Module */ @@ -352,7 +352,7 @@ public function getActiveModuleUrls() { * Ex: array("org.foo.bar"). */ public function getKeysByPath($pattern) { - $keys = array(); + $keys = []; if (CRM_Utils_String::endsWith($pattern, '*')) { $prefix = rtrim($pattern, '*'); @@ -410,7 +410,7 @@ public function isActiveModule($name) { * CRM_Core_Module */ public function getModules() { - $result = array(); + $result = []; $dao = new CRM_Core_DAO_Extension(); $dao->type = 'module'; $dao->find(); @@ -458,7 +458,7 @@ public function getTemplateName($clazz) { } public function refresh() { - $this->infos = array(); + $this->infos = []; $this->moduleExtensions = NULL; if ($this->cache) { $this->cache->delete($this->cacheKey . '_moduleFiles'); diff --git a/CRM/Extension/System.php b/CRM/Extension/System.php index e1b0b0852db6..0a521e77e4f4 100644 --- a/CRM/Extension/System.php +++ b/CRM/Extension/System.php @@ -93,7 +93,7 @@ public static function setSingleton(CRM_Extension_System $singleton) { * List of configuration values required by the extension system. * Missing values will be guessed based on $config. */ - public function __construct($parameters = array()) { + public function __construct($parameters = []) { $config = CRM_Core_Config::singleton(); $parameters['extensionsDir'] = CRM_Utils_Array::value('extensionsDir', $parameters, $config->extensionsDir); $parameters['extensionsURL'] = CRM_Utils_Array::value('extensionsURL', $parameters, $config->extensionsURL); @@ -121,7 +121,7 @@ public function __construct($parameters = array()) { */ public function getFullContainer() { if ($this->fullContainer === NULL) { - $containers = array(); + $containers = []; if ($this->getDefaultContainer()) { $containers['default'] = $this->getDefaultContainer(); @@ -205,12 +205,12 @@ public function getClassLoader() { */ public function getManager() { if ($this->manager === NULL) { - $typeManagers = array( + $typeManagers = [ 'payment' => new CRM_Extension_Manager_Payment($this->getMapper()), 'report' => new CRM_Extension_Manager_Report(), 'search' => new CRM_Extension_Manager_Search(), 'module' => new CRM_Extension_Manager_Module($this->getMapper()), - ); + ]; $this->manager = new CRM_Extension_Manager($this->getFullContainer(), $this->getDefaultContainer(), $this->getMapper(), $typeManagers); } return $this->manager; @@ -254,13 +254,13 @@ public function getDownloader() { */ public function getCache() { if ($this->cache === NULL) { - $cacheGroup = md5(serialize(array('ext', $this->parameters))); + $cacheGroup = md5(serialize(['ext', $this->parameters])); // Extension system starts before container. Manage our own cache. - $this->cache = CRM_Utils_Cache::create(array( + $this->cache = CRM_Utils_Cache::create([ 'name' => $cacheGroup, - 'type' => array('*memory*', 'SqlGroup', 'ArrayCache'), + 'type' => ['*memory*', 'SqlGroup', 'ArrayCache'], 'prefetch' => TRUE, - )); + ]); } return $this->cache; } diff --git a/CRM/Extension/Upgrades.php b/CRM/Extension/Upgrades.php index 8202478248b0..a81a5b65f768 100644 --- a/CRM/Extension/Upgrades.php +++ b/CRM/Extension/Upgrades.php @@ -59,11 +59,11 @@ public static function hasPending() { * @return CRM_Queue_Queue */ public static function createQueue() { - $queue = CRM_Queue_Service::singleton()->create(array( + $queue = CRM_Queue_Service::singleton()->create([ 'type' => 'Sql', 'name' => self::QUEUE_NAME, 'reset' => TRUE, - )); + ]); CRM_Utils_Hook::upgrade('enqueue', $queue); diff --git a/CRM/Financial/BAO/ExportFormat.php b/CRM/Financial/BAO/ExportFormat.php index 774fddcef3bf..ac50f54cbdd1 100644 --- a/CRM/Financial/BAO/ExportFormat.php +++ b/CRM/Financial/BAO/ExportFormat.php @@ -185,8 +185,8 @@ public function initiateDownload() { */ public static function createActivityExport($batchIds, $fileName) { $session = CRM_Core_Session::singleton(); - $values = array(); - $params = array('id' => $batchIds); + $values = []; + $params = ['id' => $batchIds]; CRM_Batch_BAO_Batch::retrieve($params, $values); $createdBy = CRM_Contact_BAO_Contact::displayName($values['created_id']); $modifiedBy = CRM_Contact_BAO_Contact::displayName($values['modified_id']); @@ -208,7 +208,7 @@ public static function createActivityExport($batchIds, $fileName) { // create activity. $subject .= ' ' . ts('Batch') . '[' . $values['title'] . ']'; $activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, FALSE, FALSE, 'name'); - $activityParams = array( + $activityParams = [ 'activity_type_id' => array_search('Export Accounting Batch', $activityTypes), 'subject' => $subject, 'status_id' => 2, @@ -217,13 +217,13 @@ public static function createActivityExport($batchIds, $fileName) { 'source_record_id' => $values['id'], 'target_contact_id' => $session->get('userID'), 'details' => $details, - 'attachFile_1' => array( + 'attachFile_1' => [ 'uri' => $fileName, 'type' => 'text/csv', 'location' => $fileName, 'upload_date' => date('YmdHis'), - ), - ); + ], + ]; CRM_Activity_BAO_Activity::create($activityParams); } @@ -235,12 +235,12 @@ public static function createActivityExport($batchIds, $fileName) { * * @return bool */ - public function createZip($files = array(), $destination = NULL, $overwrite = FALSE) { + public function createZip($files = [], $destination = NULL, $overwrite = FALSE) { // if the zip file already exists and overwrite is false, return false if (file_exists($destination) && !$overwrite) { return FALSE; } - $valid_files = array(); + $valid_files = []; if (is_array($files)) { foreach ($files as $file) { // make sure the file exists diff --git a/CRM/Financial/BAO/ExportFormat/CSV.php b/CRM/Financial/BAO/ExportFormat/CSV.php index f0ae5ce83e2b..ab830e1839e1 100644 --- a/CRM/Financial/BAO/ExportFormat/CSV.php +++ b/CRM/Financial/BAO/ExportFormat/CSV.php @@ -42,10 +42,10 @@ class CRM_Financial_BAO_ExportFormat_CSV extends CRM_Financial_BAO_ExportFormat * * Possibly in the future this could be selected by the user. */ - public static $complementaryTables = array( + public static $complementaryTables = [ 'ACCNT', 'CUST', - ); + ]; /** * Class constructor. @@ -123,7 +123,7 @@ public function generateExportQuery($batchId) { CRM_Utils_Hook::batchQuery($sql); - $params = array(1 => array($batchId, 'String')); + $params = [1 => [$batchId, 'String']]; $dao = CRM_Core_DAO::executeQuery($sql, $params); return $dao; @@ -160,7 +160,7 @@ public function putFile($export) { */ public function formatHeaders($values) { $arrayKeys = array_keys($values); - $headers = array(); + $headers = []; if (!empty($arrayKeys)) { foreach ($values[$arrayKeys[0]] as $title => $value) { $headers[] = $title; @@ -179,10 +179,10 @@ public function makeExport($export) { $prefixValue = Civi::settings()->get('contribution_invoice_settings'); foreach ($export as $batchId => $dao) { - $financialItems = array(); + $financialItems = []; $this->_batchIds = $batchId; - $queryResults = array(); + $queryResults = []; while ($dao->fetch()) { $creditAccountName = $creditAccountType = $creditAccount = NULL; @@ -199,7 +199,7 @@ public function makeExport($export) { $invoiceNo = CRM_Utils_Array::value('invoice_prefix', $prefixValue) . "" . $dao->contribution_id; - $financialItems[] = array( + $financialItems[] = [ 'Batch ID' => $dao->batch_id, 'Invoice No' => $invoiceNo, 'Contact ID' => $dao->contact_id, @@ -221,7 +221,7 @@ public function makeExport($export) { 'Credit Account Name' => $creditAccountName, 'Credit Account Type' => $creditAccountType, 'Item Description' => $dao->item_description, - ); + ]; end($financialItems); $queryResults[] = get_object_vars($dao); diff --git a/CRM/Financial/BAO/ExportFormat/IIF.php b/CRM/Financial/BAO/ExportFormat/IIF.php index 653abb5d0cbe..920089c5b687 100644 --- a/CRM/Financial/BAO/ExportFormat/IIF.php +++ b/CRM/Financial/BAO/ExportFormat/IIF.php @@ -48,10 +48,10 @@ class CRM_Financial_BAO_ExportFormat_IIF extends CRM_Financial_BAO_ExportFormat * * Possibly in the future this could be selected by the user. */ - public static $complementaryTables = array( + public static $complementaryTables = [ 'ACCNT', 'CUST', - ); + ]; /** * Class constructor. @@ -151,7 +151,7 @@ public function generateExportQuery($batchId) { LEFT JOIN civicrm_financial_item fi ON fi.id = efti.entity_id WHERE eb.batch_id = ( %1 )"; - $params = array(1 => array($batchId, 'String')); + $params = [1 => [$batchId, 'String']]; $dao = CRM_Core_DAO::executeQuery($sql, $params); return $dao; @@ -165,47 +165,47 @@ public function makeExport($export) { // include those in the output. Only want to include ones used in the batch, not everything in the db, // since would increase the chance of messing up user's existing Quickbooks entries. foreach ($export as $batchId => $dao) { - $accounts = $contacts = $journalEntries = $exportParams = array(); + $accounts = $contacts = $journalEntries = $exportParams = []; $this->_batchIds = $batchId; while ($dao->fetch()) { // add to running list of accounts if (!empty($dao->from_account_id) && !isset($accounts[$dao->from_account_id])) { - $accounts[$dao->from_account_id] = array( + $accounts[$dao->from_account_id] = [ 'name' => $this->format($dao->from_account_name), 'account_code' => $this->format($dao->from_account_code), 'description' => $this->format($dao->from_account_description), 'type' => $this->format($dao->from_account_type_code), - ); + ]; } if (!empty($dao->to_account_id) && !isset($accounts[$dao->to_account_id])) { - $accounts[$dao->to_account_id] = array( + $accounts[$dao->to_account_id] = [ 'name' => $this->format($dao->to_account_name), 'account_code' => $this->format($dao->to_account_code), 'description' => $this->format($dao->to_account_description), 'type' => $this->format($dao->to_account_type_code), - ); + ]; } // add to running list of contacts if (!empty($dao->contact_from_id) && !isset($contacts[$dao->contact_from_id])) { - $contacts[$dao->contact_from_id] = array( + $contacts[$dao->contact_from_id] = [ 'name' => $this->format($dao->contact_from_name), 'first_name' => $this->format($dao->contact_from_first_name), 'last_name' => $this->format($dao->contact_from_last_name), - ); + ]; } if (!empty($dao->contact_to_id) && !isset($contacts[$dao->contact_to_id])) { - $contacts[$dao->contact_to_id] = array( + $contacts[$dao->contact_to_id] = [ 'name' => $this->format($dao->contact_to_name), 'first_name' => $this->format($dao->contact_to_first_name), 'last_name' => $this->format($dao->contact_to_last_name), - ); + ]; } // set up the journal entries for this financial trxn - $journalEntries[$dao->financial_trxn_id] = array( - 'to_account' => array( + $journalEntries[$dao->financial_trxn_id] = [ + 'to_account' => [ 'trxn_date' => $this->format($dao->trxn_date, 'date'), 'trxn_id' => $this->format($dao->trxn_id), 'account_name' => $this->format($dao->to_account_name), @@ -213,9 +213,9 @@ public function makeExport($export) { 'contact_name' => $this->format($dao->contact_to_name), 'payment_instrument' => $this->format($dao->payment_instrument), 'check_number' => $this->format($dao->check_number), - ), - 'splits' => array(), - ); + ], + 'splits' => [], + ]; /* * splits has two possibilities depending on FROM account @@ -249,30 +249,30 @@ public function makeExport($export) { WHERE eft.entity_table = 'civicrm_financial_item' AND eft.financial_trxn_id = %1"; - $itemParams = array(1 => array($dao->financial_trxn_id, 'Integer')); + $itemParams = [1 => [$dao->financial_trxn_id, 'Integer']]; $itemDAO = CRM_Core_DAO::executeQuery($item_sql, $itemParams); while ($itemDAO->fetch()) { // add to running list of accounts if (!empty($itemDAO->account_id) && !isset($accounts[$itemDAO->account_id])) { - $accounts[$itemDAO->account_id] = array( + $accounts[$itemDAO->account_id] = [ 'name' => $this->format($itemDAO->account_name), 'account_code' => $this->format($itemDAO->account_code), 'description' => $this->format($itemDAO->account_description), 'type' => $this->format($itemDAO->account_type_code), - ); + ]; } if (!empty($itemDAO->contact_id) && !isset($contacts[$itemDAO->contact_id])) { - $contacts[$itemDAO->contact_id] = array( + $contacts[$itemDAO->contact_id] = [ 'name' => $this->format($itemDAO->contact_name), 'first_name' => $this->format($itemDAO->contact_first_name), 'last_name' => $this->format($itemDAO->contact_last_name), - ); + ]; } // add split line for this item - $journalEntries[$dao->financial_trxn_id]['splits'][$itemDAO->financial_item_id] = array( + $journalEntries[$dao->financial_trxn_id]['splits'][$itemDAO->financial_item_id] = [ 'trxn_date' => $this->format($itemDAO->transaction_date, 'date'), 'spl_id' => $this->format($itemDAO->financial_item_id), 'account_name' => $this->format($itemDAO->account_name), @@ -282,13 +282,13 @@ public function makeExport($export) { 'description' => $this->format($itemDAO->description), 'check_number' => $this->format($itemDAO->check_number), 'currency' => $this->format($itemDAO->currency), - ); + ]; } // end items loop $itemDAO->free(); } else { // In this case, split record just uses the FROM account from the trxn, and there's only one record here - $journalEntries[$dao->financial_trxn_id]['splits'][] = array( + $journalEntries[$dao->financial_trxn_id]['splits'][] = [ 'trxn_date' => $this->format($dao->trxn_date, 'date'), 'spl_id' => $this->format($dao->financial_trxn_id), 'account_name' => $this->format($dao->from_account_name), @@ -298,14 +298,14 @@ public function makeExport($export) { 'payment_instrument' => $this->format($dao->payment_instrument), 'check_number' => $this->format($dao->check_number), 'currency' => $this->format($dao->currency), - ); + ]; } } - $exportParams = array( + $exportParams = [ 'accounts' => $accounts, 'contacts' => $contacts, 'journalEntries' => $journalEntries, - ); + ]; self::export($exportParams); } parent::initiateDownload(); diff --git a/CRM/Financial/BAO/FinancialItem.php b/CRM/Financial/BAO/FinancialItem.php index 60afb3f99843..4e5ff50bbcf5 100644 --- a/CRM/Financial/BAO/FinancialItem.php +++ b/CRM/Financial/BAO/FinancialItem.php @@ -89,7 +89,7 @@ public static function add($lineItem, $contribution, $taxTrxnID = FALSE, $trxnId elseif ($contribution->contribution_status_id == array_search('Partially paid', $contributionStatuses)) { $itemStatus = array_search('Partially paid', $financialItemStatus); } - $params = array( + $params = [ 'transaction_date' => CRM_Utils_Date::isoToMysql($contribution->receive_date), 'contact_id' => $contribution->contact_id, 'amount' => $lineItem->line_total, @@ -98,7 +98,7 @@ public static function add($lineItem, $contribution, $taxTrxnID = FALSE, $trxnId 'entity_id' => $lineItem->id, 'description' => ($lineItem->qty != 1 ? $lineItem->qty . ' of ' : '') . $lineItem->label, 'status_id' => $itemStatus, - ); + ]; if ($taxTrxnID) { $invoiceSettings = Civi::settings()->get('contribution_invoice_settings'); @@ -161,15 +161,15 @@ public static function create(&$params, $ids = NULL, $trxnIds = NULL) { $financialtrxnIDS = CRM_Utils_Array::value('id', $trxnIds); if (!empty($financialtrxnIDS)) { if (!is_array($financialtrxnIDS)) { - $financialtrxnIDS = array($financialtrxnIDS); + $financialtrxnIDS = [$financialtrxnIDS]; } foreach ($financialtrxnIDS as $tID) { - $entity_financial_trxn_params = array( + $entity_financial_trxn_params = [ 'entity_table' => "civicrm_financial_item", 'entity_id' => $financialItem->id, 'financial_trxn_id' => $tID, 'amount' => $params['amount'], - ); + ]; if (!empty($ids['entityFinancialTrxnId'])) { $entity_financial_trxn_params['id'] = $ids['entityFinancialTrxnId']; } @@ -220,13 +220,13 @@ public static function retrieveEntityFinancialTrxn($params, $maxId = FALSE) { } $financialItem->find(); while ($financialItem->fetch()) { - $financialItems[$financialItem->id] = array( + $financialItems[$financialItem->id] = [ 'id' => $financialItem->id, 'entity_table' => $financialItem->entity_table, 'entity_id' => $financialItem->entity_id, 'financial_trxn_id' => $financialItem->financial_trxn_id, 'amount' => $financialItem->amount, - ); + ]; } if (!empty($financialItems)) { return $financialItems; @@ -289,14 +289,14 @@ public static function checkContactPresent($contactIds, &$error) { * @return array */ public static function getPreviousFinancialItem($entityId) { - $params = array( + $params = [ 'entity_id' => $entityId, 'entity_table' => 'civicrm_line_item', - 'options' => array('limit' => 1, 'sort' => 'id DESC'), - ); - $salesTaxFinancialAccounts = civicrm_api3('FinancialAccount', 'get', array('is_tax' => 1)); + 'options' => ['limit' => 1, 'sort' => 'id DESC'], + ]; + $salesTaxFinancialAccounts = civicrm_api3('FinancialAccount', 'get', ['is_tax' => 1]); if ($salesTaxFinancialAccounts['count']) { - $params['financial_account_id'] = array('NOT IN' => array_keys($salesTaxFinancialAccounts['values'])); + $params['financial_account_id'] = ['NOT IN' => array_keys($salesTaxFinancialAccounts['values'])]; } return civicrm_api3('FinancialItem', 'getsingle', $params); } diff --git a/CRM/Financial/BAO/FinancialType.php b/CRM/Financial/BAO/FinancialType.php index 445475e29585..3b09c7cdd17b 100644 --- a/CRM/Financial/BAO/FinancialType.php +++ b/CRM/Financial/BAO/FinancialType.php @@ -35,11 +35,11 @@ class CRM_Financial_BAO_FinancialType extends CRM_Financial_DAO_FinancialType { /** * Static cache holder of available financial types for this session */ - static $_availableFinancialTypes = array(); + static $_availableFinancialTypes = []; /** * Static cache holder of status of ACL-FT enabled/disabled for this session */ - static $_statusACLFt = array(); + static $_statusACLFt = []; /** * Class constructor. @@ -92,7 +92,7 @@ public static function setIsActive($id, $is_active) { * * @return object */ - public static function add(&$params, &$ids = array()) { + public static function add(&$params, &$ids = []) { if (empty($params['id'])) { $params['is_active'] = CRM_Utils_Array::value('is_active', $params, FALSE); $params['is_deductible'] = CRM_Utils_Array::value('is_deductible', $params, FALSE); @@ -135,14 +135,14 @@ public static function del($financialTypeId) { $financialType->id = $financialTypeId; $financialType->find(TRUE); // tables to ignore checks for financial_type_id - $ignoreTables = array('CRM_Financial_DAO_EntityFinancialAccount'); + $ignoreTables = ['CRM_Financial_DAO_EntityFinancialAccount']; // TODO: if (!$financialType->find(true)) { // ensure that we have no objects that have an FK to this financial type id TODO: that cannot be null $occurrences = $financialType->findReferences(); if ($occurrences) { - $tables = array(); + $tables = []; foreach ($occurrences as $occurrence) { $className = get_class($occurrence); if (!in_array($className, $tables) && !in_array($className, $ignoreTables)) { @@ -150,9 +150,9 @@ public static function del($financialTypeId) { } } if (!empty($tables)) { - $message = ts('The following tables have an entry for this financial type: %1', array('%1' => implode(', ', $tables))); + $message = ts('The following tables have an entry for this financial type: %1', ['%1' => implode(', ', $tables)]); - $errors = array(); + $errors = []; $errors['is_error'] = 1; $errors['error_message'] = $message; return $errors; @@ -179,7 +179,7 @@ public static function del($financialTypeId) { public static function getIncomeFinancialType() { // Financial Type $financialType = CRM_Contribute_PseudoConstant::financialType(); - $revenueFinancialType = array(); + $revenueFinancialType = []; $relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Income Account is' ")); CRM_Core_PseudoConstant::populate( $revenueFinancialType, @@ -215,14 +215,14 @@ public static function permissionedFinancialTypes(&$permissions, $descriptions) } $financialTypes = CRM_Contribute_PseudoConstant::financialType(); $prefix = ts('CiviCRM') . ': '; - $actions = array('add', 'view', 'edit', 'delete'); + $actions = ['add', 'view', 'edit', 'delete']; foreach ($financialTypes as $id => $type) { foreach ($actions as $action) { if ($descriptions) { - $permissions[$action . ' contributions of type ' . $type] = array( + $permissions[$action . ' contributions of type ' . $type] = [ $prefix . ts($action . ' contributions of type ') . $type, ts(ucfirst($action) . ' contributions of type ') . $type, - ); + ]; } else { $permissions[$action . ' contributions of type ' . $type] = $prefix . ts($action . ' contributions of type ') . $type; @@ -233,10 +233,10 @@ public static function permissionedFinancialTypes(&$permissions, $descriptions) $permissions['administer CiviCRM Financial Types'] = $prefix . ts('administer CiviCRM Financial Types'); } else { - $permissions['administer CiviCRM Financial Types'] = array( + $permissions['administer CiviCRM Financial Types'] = [ $prefix . ts('administer CiviCRM Financial Types'), ts('Administer access to Financial Types'), - ); + ]; } } @@ -293,12 +293,12 @@ public static function getAvailableFinancialTypes(&$financialTypes = NULL, $acti if (!self::isACLFinancialTypeStatus()) { return $financialTypes; } - $actions = array( + $actions = [ CRM_Core_Action::VIEW => 'view', CRM_Core_Action::UPDATE => 'edit', CRM_Core_Action::ADD => 'add', CRM_Core_Action::DELETE => 'delete', - ); + ]; if (!isset(\Civi::$statics[__CLASS__]['available_types_' . $action])) { foreach ($financialTypes as $finTypeId => $type) { @@ -329,12 +329,12 @@ public static function getAvailableMembershipTypes(&$membershipTypes = NULL, $ac if (!self::isACLFinancialTypeStatus()) { return $membershipTypes; } - $actions = array( + $actions = [ CRM_Core_Action::VIEW => 'view', CRM_Core_Action::UPDATE => 'edit', CRM_Core_Action::ADD => 'add', CRM_Core_Action::DELETE => 'delete', - ); + ]; foreach ($membershipTypes as $memTypeId => $type) { $finTypeId = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $memTypeId, 'financial_type_id'); $finType = CRM_Contribute_PseudoConstant::financialType($finTypeId); diff --git a/CRM/Financial/BAO/FinancialTypeAccount.php b/CRM/Financial/BAO/FinancialTypeAccount.php index c6c324e0122a..faa84e3f69f6 100644 --- a/CRM/Financial/BAO/FinancialTypeAccount.php +++ b/CRM/Financial/BAO/FinancialTypeAccount.php @@ -51,7 +51,7 @@ public function __construct() { * * @return CRM_Contribute_BAO_ContributionType */ - public static function retrieve(&$params, &$defaults, &$allValues = array()) { + public static function retrieve(&$params, &$defaults, &$allValues = []) { $financialTypeAccount = new CRM_Financial_DAO_EntityFinancialAccount(); $financialTypeAccount->copyValues($params); $financialTypeAccount->find(); @@ -105,16 +105,16 @@ public static function del($financialTypeAccountId, $accountId = NULL) { $financialTypeId = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_EntityFinancialAccount', $financialTypeAccountId, 'entity_id'); // check dependencies // FIXME more table containing financial_type_id to come - $dependency = array( - array('Contribute', 'Contribution'), - array('Contribute', 'ContributionPage'), - array('Member', 'MembershipType'), - array('Price', 'PriceFieldValue'), - array('Grant', 'Grant'), - array('Contribute', 'PremiumsProduct'), - array('Contribute', 'Product'), - array('Price', 'LineItem'), - ); + $dependency = [ + ['Contribute', 'Contribution'], + ['Contribute', 'ContributionPage'], + ['Member', 'MembershipType'], + ['Price', 'PriceFieldValue'], + ['Grant', 'Grant'], + ['Contribute', 'PremiumsProduct'], + ['Contribute', 'Product'], + ['Price', 'LineItem'], + ]; foreach ($dependency as $name) { $daoString = 'CRM_' . $name[0] . '_DAO_' . $name[1]; @@ -128,11 +128,11 @@ public static function del($financialTypeAccountId, $accountId = NULL) { if ($check) { if ($name[1] == 'PremiumsProduct' || $name[1] == 'Product') { - CRM_Core_Session::setStatus(ts('You cannot remove an account with a %1 relationship while the Financial Type is used for a Premium.', array(1 => $relationValues[$financialTypeAccountId]))); + CRM_Core_Session::setStatus(ts('You cannot remove an account with a %1 relationship while the Financial Type is used for a Premium.', [1 => $relationValues[$financialTypeAccountId]])); } else { $accountRelationShipId = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_EntityFinancialAccount', $financialTypeAccountId, 'account_relationship'); - CRM_Core_Session::setStatus(ts('You cannot remove an account with a %1 relationship because it is being referenced by one or more of the following types of records: Contributions, Contribution Pages, or Membership Types. Consider disabling this type instead if you no longer want it used.', array(1 => $relationValues[$accountRelationShipId])), NULL, 'error'); + CRM_Core_Session::setStatus(ts('You cannot remove an account with a %1 relationship because it is being referenced by one or more of the following types of records: Contributions, Contribution Pages, or Membership Types. Consider disabling this type instead if you no longer want it used.', [1 => $relationValues[$accountRelationShipId]]), NULL, 'error'); } return CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin/financial/financialType/accounts', "reset=1&action=browse&aid={$accountId}")); } @@ -142,7 +142,7 @@ public static function del($financialTypeAccountId, $accountId = NULL) { $financialType->id = $financialTypeAccountId; $financialType->find(TRUE); $financialType->delete(); - CRM_Core_Session::setStatus(ts('Unbalanced transactions may be created if you delete the account of type: %1.', array(1 => $relationValues[$financialType->account_relationship]))); + CRM_Core_Session::setStatus(ts('Unbalanced transactions may be created if you delete the account of type: %1.', [1 => $relationValues[$financialType->account_relationship]])); } /** @@ -155,11 +155,11 @@ public static function del($financialTypeAccountId, $accountId = NULL) { */ public static function getInstrumentFinancialAccount($paymentInstrumentValue) { if (!isset(\Civi::$statics[__CLASS__]['instrument_financial_accounts'][$paymentInstrumentValue])) { - $paymentInstrumentID = civicrm_api3('OptionValue', 'getvalue', array( + $paymentInstrumentID = civicrm_api3('OptionValue', 'getvalue', [ 'return' => 'id', 'value' => $paymentInstrumentValue, 'option_group_id' => "payment_instrument", - )); + ]); $accounts = civicrm_api3('EntityFinancialAccount', 'get', [ 'return' => 'financial_account_id', 'entity_table' => 'civicrm_option_value', @@ -187,40 +187,40 @@ public static function getInstrumentFinancialAccount($paymentInstrumentValue) { * @return array */ public static function createDefaultFinancialAccounts($financialType) { - $titles = array(); + $titles = []; $financialAccountTypeID = CRM_Core_OptionGroup::values('financial_account_type', FALSE, FALSE, FALSE, NULL, 'name'); $accountRelationship = CRM_Core_OptionGroup::values('account_relationship', FALSE, FALSE, FALSE, NULL, 'name'); - $relationships = array( + $relationships = [ array_search('Accounts Receivable Account is', $accountRelationship) => array_search('Asset', $financialAccountTypeID), array_search('Expense Account is', $accountRelationship) => array_search('Expenses', $financialAccountTypeID), array_search('Cost of Sales Account is', $accountRelationship) => array_search('Cost of Sales', $financialAccountTypeID), array_search('Income Account is', $accountRelationship) => array_search('Revenue', $financialAccountTypeID), - ); + ]; $dao = CRM_Core_DAO::executeQuery('SELECT id, financial_account_type_id FROM civicrm_financial_account WHERE name LIKE %1', - array(1 => array($financialType->name, 'String')) + [1 => [$financialType->name, 'String']] ); $dao->fetch(); - $existingFinancialAccount = array(); + $existingFinancialAccount = []; if (!$dao->N) { - $params = array( + $params = [ 'name' => $financialType->name, 'contact_id' => CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Domain', CRM_Core_Config::domainID(), 'contact_id'), 'financial_account_type_id' => array_search('Revenue', $financialAccountTypeID), 'description' => $financialType->description, 'account_type_code' => 'INC', 'is_active' => 1, - ); + ]; $financialAccount = CRM_Financial_BAO_FinancialAccount::add($params); } else { $existingFinancialAccount[$dao->financial_account_type_id] = $dao->id; } - $params = array( + $params = [ 'entity_table' => 'civicrm_financial_type', 'entity_id' => $financialType->id, - ); + ]; foreach ($relationships as $key => $value) { if (!array_key_exists($value, $existingFinancialAccount)) { if ($accountRelationship[$key] == 'Accounts Receivable Account is') { @@ -257,7 +257,7 @@ public static function createDefaultFinancialAccounts($financialType) { self::add($params); } if (!empty($existingFinancialAccount)) { - $titles = array(); + $titles = []; } return $titles; } @@ -274,9 +274,9 @@ public static function validateRelationship($financialTypeAccount) { $financialAccountType = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialAccount', $financialTypeAccount->financial_account_id, 'financial_account_type_id'); if (CRM_Utils_Array::value($financialTypeAccount->account_relationship, $financialAccountLinks) != $financialAccountType) { $accountRelationships = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_EntityFinancialAccount', 'account_relationship'); - $params = array( + $params = [ 1 => $accountRelationships[$financialTypeAccount->account_relationship], - ); + ]; throw new CRM_Core_Exception(ts("This financial account cannot have '%1' relationship.", $params)); } } diff --git a/CRM/Financial/BAO/Payment.php b/CRM/Financial/BAO/Payment.php index 84e01390b827..ed84d2538d26 100644 --- a/CRM/Financial/BAO/Payment.php +++ b/CRM/Financial/BAO/Payment.php @@ -101,7 +101,7 @@ public static function create($params) { } if ($isPaymentCompletesContribution) { - civicrm_api3('Contribution', 'completetransaction', array('id' => $contribution['id'])); + civicrm_api3('Contribution', 'completetransaction', ['id' => $contribution['id']]); // Get the trxn $trxnId = CRM_Core_BAO_FinancialTrxn::getFinancialTrxnId($contribution['id'], 'DESC'); $ftParams = ['id' => $trxnId['financialTrxnId']]; @@ -129,7 +129,7 @@ public static function create($params) { public static function sendConfirmation($params) { $entities = self::loadRelatedEntities($params['id']); - $sendTemplateParams = array( + $sendTemplateParams = [ 'groupName' => 'msg_tpl_workflow_contribution', 'valueName' => 'payment_or_refund_notification', 'PDFFilename' => ts('notification') . '.pdf', @@ -137,7 +137,7 @@ public static function sendConfirmation($params) { 'toName' => $entities['contact']['display_name'], 'toEmail' => $entities['contact']['email'], 'tplParams' => self::getConfirmationTemplateParameters($entities), - ); + ]; return CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams); } diff --git a/CRM/Financial/BAO/PaymentProcessor.php b/CRM/Financial/BAO/PaymentProcessor.php index 7a0e9f806f14..584d1b1068e9 100644 --- a/CRM/Financial/BAO/PaymentProcessor.php +++ b/CRM/Financial/BAO/PaymentProcessor.php @@ -72,12 +72,12 @@ public static function create($params) { // if financial_account_id is not NULL if (!empty($params['financial_account_id'])) { $relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Asset Account is' ")); - $values = array( + $values = [ 'entity_table' => 'civicrm_payment_processor', 'entity_id' => $processor->id, 'account_relationship' => $relationTypeId, 'financial_account_id' => $params['financial_account_id'], - ); + ]; CRM_Financial_BAO_FinancialTypeAccount::add($values); } @@ -116,7 +116,7 @@ public static function getCreditCards($paymentProcessorID = NULL) { $cards = json_decode($processor->accepted_credit_cards, TRUE); return $cards; } - return array(); + return []; } /** @@ -166,8 +166,8 @@ public static function setIsActive($id, $is_active) { */ public static function &getDefault() { if (self::$_defaultPaymentProcessor == NULL) { - $params = array('is_default' => 1); - $defaults = array(); + $params = ['is_default' => 1]; + $defaults = []; self::$_defaultPaymentProcessor = self::retrieve($params, $defaults); } return self::$_defaultPaymentProcessor; @@ -215,8 +215,8 @@ public static function del($paymentProcessorID) { * associated array with payment processor related fields */ public static function getPayment($paymentProcessorID, $mode = 'based_on_id') { - $capabilities = ($mode == 'test') ? array('TestMode') : array(); - $processors = self::getPaymentProcessors($capabilities, array($paymentProcessorID)); + $capabilities = ($mode == 'test') ? ['TestMode'] : []; + $processors = self::getPaymentProcessors($capabilities, [$paymentProcessorID]); return $processors[$paymentProcessorID]; } @@ -229,16 +229,16 @@ public static function getPayment($paymentProcessorID, $mode = 'based_on_id') { * Test payment processor ID. */ public static function getTestProcessorId($id) { - $liveProcessorName = civicrm_api3('payment_processor', 'getvalue', array( + $liveProcessorName = civicrm_api3('payment_processor', 'getvalue', [ 'id' => $id, 'return' => 'name', - )); - return civicrm_api3('payment_processor', 'getvalue', array( + ]); + return civicrm_api3('payment_processor', 'getvalue', [ 'return' => 'id', 'name' => $liveProcessorName, 'is_test' => 1, 'domain_id' => CRM_Core_Config::domainID(), - )); + ]); } /** @@ -280,11 +280,11 @@ public static function getAllPaymentProcessors($mode = 'all', $reset = FALSE, $i } } - $retrievalParameters = array( + $retrievalParameters = [ 'is_active' => TRUE, - 'options' => array('sort' => 'is_default DESC, name', 'limit' => 0), + 'options' => ['sort' => 'is_default DESC, name', 'limit' => 0], 'api.payment_processor_type.getsingle' => 1, - ); + ]; if ($isCurrentDomainOnly) { $retrievalParameters['domain_id'] = CRM_Core_Config::domainID(); } @@ -297,7 +297,7 @@ public static function getAllPaymentProcessors($mode = 'all', $reset = FALSE, $i $processors = civicrm_api3('payment_processor', 'get', $retrievalParameters); foreach ($processors['values'] as $processor) { - $fieldsToProvide = array( + $fieldsToProvide = [ 'id', 'name', 'payment_processor_type_id', @@ -315,7 +315,7 @@ public static function getAllPaymentProcessors($mode = 'all', $reset = FALSE, $i 'is_test', 'payment_type', 'is_default', - ); + ]; foreach ($fieldsToProvide as $field) { // Prevent e-notices in processor classes when not configured. if (!isset($processor[$field])) { @@ -327,7 +327,7 @@ public static function getAllPaymentProcessors($mode = 'all', $reset = FALSE, $i } // Add the pay-later pseudo-processor. - $processors['values'][0] = array( + $processors['values'][0] = [ 'object' => new CRM_Core_Payment_Manual(), 'id' => 0, 'payment_processor_type_id' => 0, @@ -342,7 +342,7 @@ public static function getAllPaymentProcessors($mode = 'all', $reset = FALSE, $i // be a row in the payment processor table before we do that. 'is_recur' => FALSE, 'is_test' => FALSE, - ); + ]; CRM_Utils_Cache::singleton()->set($cacheKey, $processors['values']); @@ -366,8 +366,8 @@ public static function getAllPaymentProcessors($mode = 'all', $reset = FALSE, $i * @return array * available processors */ - public static function getPaymentProcessors($capabilities = array(), $ids = FALSE) { - $testProcessors = in_array('TestMode', $capabilities) ? self::getAllPaymentProcessors('test') : array(); + public static function getPaymentProcessors($capabilities = [], $ids = FALSE) { + $testProcessors = in_array('TestMode', $capabilities) ? self::getAllPaymentProcessors('test') : []; if (is_array($ids)) { $processors = self::getAllPaymentProcessors('all', FALSE, FALSE); } @@ -433,11 +433,11 @@ public static function getPaymentProcessors($capabilities = array(), $ids = FALS * * @return bool */ - public static function hasPaymentProcessorSupporting($capabilities = array()) { + public static function hasPaymentProcessorSupporting($capabilities = []) { $capabilitiesString = implode('', $capabilities); if (!isset(\Civi::$statics[__CLASS__]['supported_capabilities'][$capabilitiesString])) { $result = self::getPaymentProcessors($capabilities); - \Civi::$statics[__CLASS__]['supported_capabilities'][$capabilitiesString] = (!empty($result) && array_keys($result) !== array(0)) ? TRUE : FALSE; + \Civi::$statics[__CLASS__]['supported_capabilities'][$capabilitiesString] = (!empty($result) && array_keys($result) !== [0]) ? TRUE : FALSE; } return \Civi::$statics[__CLASS__]['supported_capabilities'][$capabilitiesString]; } @@ -474,11 +474,11 @@ public static function hasPaymentProcessorSupporting($capabilities = array()) { */ public static function getProcessorForEntity($entityID, $component = 'contribute', $type = 'id') { $result = NULL; - if (!in_array($component, array( + if (!in_array($component, [ 'membership', 'contribute', 'recur', - )) + ]) ) { return $result; } @@ -512,7 +512,7 @@ public static function getProcessorForEntity($entityID, $component = 'contribute // We are interested in a single record. $sql .= ' LIMIT 1'; - $params = array(1 => array($entityID, 'Integer')); + $params = [1 => [$entityID, 'Integer']]; $dao = CRM_Core_DAO::executeQuery($sql, $params); if (!$dao->fetch()) { @@ -531,7 +531,7 @@ public static function getProcessorForEntity($entityID, $component = 'contribute } elseif ($type == 'obj' && is_numeric($ppID)) { try { - $paymentProcessor = civicrm_api3('PaymentProcessor', 'getsingle', array('id' => $ppID)); + $paymentProcessor = civicrm_api3('PaymentProcessor', 'getsingle', ['id' => $ppID]); } catch (API_Exception $e) { // Unable to load the processor because this function uses an unreliable method to derive it. @@ -553,10 +553,10 @@ public static function getProcessorForEntity($entityID, $component = 'contribute * @return \CRM_Core_Payment */ public static function getPaymentProcessorForRecurringContribution($contributionRecurID) { - $paymentProcessorId = civicrm_api3('ContributionRecur', 'getvalue', array( + $paymentProcessorId = civicrm_api3('ContributionRecur', 'getvalue', [ 'id' => $contributionRecurID, 'return' => 'payment_processor_id', - )); + ]); return Civi\Payment\System::singleton()->getById($paymentProcessorId); } @@ -569,10 +569,10 @@ public static function getPaymentProcessorForRecurringContribution($contribution */ public static function getPaymentProcessorName($paymentProcessorId) { try { - $paymentProcessor = civicrm_api3('PaymentProcessor', 'getsingle', array( - 'return' => array('name'), + $paymentProcessor = civicrm_api3('PaymentProcessor', 'getsingle', [ + 'return' => ['name'], 'id' => $paymentProcessorId, - )); + ]); return $paymentProcessor['name']; } catch (Exception $e) { diff --git a/CRM/Financial/BAO/PaymentProcessorType.php b/CRM/Financial/BAO/PaymentProcessorType.php index 88b7102b34d4..89ca29f15999 100644 --- a/CRM/Financial/BAO/PaymentProcessorType.php +++ b/CRM/Financial/BAO/PaymentProcessorType.php @@ -89,8 +89,8 @@ public static function setIsActive($id, $is_active) { */ public static function &getDefault() { if (self::$_defaultPaymentProcessorType == NULL) { - $params = array('is_default' => 1); - $defaults = array(); + $params = ['is_default' => 1]; + $defaults = []; self::$_defaultPaymentProcessorType = self::retrieve($params, $defaults); } return self::$_defaultPaymentProcessorType; @@ -178,7 +178,7 @@ public static function del($paymentProcessorTypeId) { FROM civicrm_payment_processor pp, civicrm_payment_processor_type ppt WHERE pp.payment_processor_type_id = ppt.id AND ppt.id = %1"; - $params = array(1 => array($paymentProcessorTypeId, 'Integer')); + $params = [1 => [$paymentProcessorTypeId, 'Integer']]; $dao = CRM_Core_DAO::executeQuery($query, $params); if ($dao->fetch()) { @@ -200,7 +200,7 @@ public static function del($paymentProcessorTypeId) { * @return array */ static private function getAllPaymentProcessorTypes($attr) { - $ppt = array(); + $ppt = []; $dao = new CRM_Financial_DAO_PaymentProcessorType(); $dao->find(); while ($dao->fetch()) { diff --git a/CRM/Financial/Form/BatchTransaction.php b/CRM/Financial/Form/BatchTransaction.php index 2691cacad69c..0063079379cb 100644 --- a/CRM/Financial/Form/BatchTransaction.php +++ b/CRM/Financial/Form/BatchTransaction.php @@ -58,20 +58,20 @@ public function preProcess() { $this->assign('entityID', self::$_entityID); if (isset(self::$_entityID)) { $this->_batchStatusId = CRM_Core_DAO::getFieldValue('CRM_Batch_BAO_Batch', self::$_entityID, 'status_id'); - $batchStatuses = CRM_Core_PseudoConstant::get('CRM_Batch_DAO_Batch', 'status_id', array('labelColumn' => 'name', 'condition' => " v.value={$this->_batchStatusId}")); + $batchStatuses = CRM_Core_PseudoConstant::get('CRM_Batch_DAO_Batch', 'status_id', ['labelColumn' => 'name', 'condition' => " v.value={$this->_batchStatusId}"]); $this->_batchStatus = $batchStatuses[$this->_batchStatusId]; $this->assign('statusID', $this->_batchStatusId); $this->assign('batchStatus', $this->_batchStatus); $validStatus = FALSE; - if (in_array($this->_batchStatus, array('Open', 'Reopened'))) { + if (in_array($this->_batchStatus, ['Open', 'Reopened'])) { $validStatus = TRUE; } $this->assign('validStatus', $validStatus); - $this->_values = civicrm_api3('Batch', 'getSingle', array('id' => self::$_entityID)); + $this->_values = civicrm_api3('Batch', 'getSingle', ['id' => self::$_entityID]); $batchTitle = CRM_Core_DAO::getFieldValue('CRM_Batch_BAO_Batch', self::$_entityID, 'title'); - CRM_Utils_System::setTitle(ts('Accounting Batch - %1', array(1 => $batchTitle))); + CRM_Utils_System::setTitle(ts('Accounting Batch - %1', [1 => $batchTitle])); - $columnHeaders = array( + $columnHeaders = [ 'created_by' => ts('Created By'), 'status' => ts('Status'), 'description' => ts('Description'), @@ -81,7 +81,7 @@ public function preProcess() { 'total' => ts('Expected Total Amount'), 'assigned_total' => ts('Actual Total Amount'), 'opened_date' => ts('Opened'), - ); + ]; $this->assign('columnHeaders', $columnHeaders); } } @@ -95,7 +95,7 @@ public function buildQuickForm() { } // do not build rest of form unless it is open/reopened batch - if (!in_array($this->_batchStatus, array('Open', 'Reopened'))) { + if (!in_array($this->_batchStatus, ['Open', 'Reopened'])) { return; } @@ -121,14 +121,14 @@ public function buildQuickForm() { // multiselect for groups if ($this->_group) { $this->add('select', 'group', ts('Groups'), $this->_group, FALSE, - array('id' => 'group', 'multiple' => 'multiple', 'class' => 'crm-select2') + ['id' => 'group', 'multiple' => 'multiple', 'class' => 'crm-select2'] ); } $contactTags = CRM_Core_BAO_Tag::getTags(); if ($contactTags) { $this->add('select', 'contact_tags', ts('Tags'), $contactTags, FALSE, - array('id' => 'contact_tags', 'multiple' => 'multiple', 'class' => 'crm-select2') + ['id' => 'contact_tags', 'multiple' => 'multiple', 'class' => 'crm-select2'] ); } CRM_Contribute_BAO_Query::buildSearchForm($this); @@ -137,37 +137,37 @@ public function buildQuickForm() { $this->add('select', 'trans_remove', ts('Task'), - array('' => ts('- actions -')) + array('Remove' => ts('Remove from Batch'))); + ['' => ts('- actions -')] + ['Remove' => ts('Remove from Batch')]); $this->add('submit', 'rSubmit', ts('Go'), - array( + [ 'class' => 'crm-form-submit', 'id' => 'GoRemove', - )); + ]); self::$_entityID = CRM_Utils_Request::retrieve('bid', 'Positive'); $this->addButtons( - array( - array( + [ + [ 'type' => 'submit', 'name' => ts('Search'), 'isDefault' => TRUE, - ), - ) + ], + ] ); $this->addElement('checkbox', 'toggleSelect', NULL, NULL); $this->add('select', 'trans_assign', ts('Task'), - array('' => ts('- actions -')) + array('Assign' => ts('Assign to Batch'))); + ['' => ts('- actions -')] + ['Assign' => ts('Assign to Batch')]); $this->add('submit', 'submit', ts('Go'), - array( + [ 'class' => 'crm-form-submit', 'id' => 'Go', - )); + ]); $this->applyFilter('__ALL__', 'trim'); $this->addElement('hidden', 'batch_id', self::$_entityID); @@ -180,7 +180,7 @@ public function buildQuickForm() { */ public function setDefaultValues() { // do not setdefault unless it is open/reopened batch - if (!in_array($this->_batchStatus, array('Open', 'Reopened'))) { + if (!in_array($this->_batchStatus, ['Open', 'Reopened'])) { return; } if (isset(self::$_entityID)) { @@ -198,20 +198,20 @@ public function setDefaultValues() { */ public function &links() { if (!(self::$_links)) { - self::$_links = array( - 'view' => array( + self::$_links = [ + 'view' => [ 'name' => ts('View'), 'url' => 'civicrm/contact/view/contribution', 'qs' => 'reset=1&id=%%contid%%&cid=%%cid%%&action=view&context=contribution&selectedChild=contribute', 'title' => ts('View Contribution'), - ), - 'assign' => array( + ], + 'assign' => [ 'name' => ts('Assign'), 'ref' => 'disable-action', 'title' => ts('Assign Transaction'), 'extra' => 'onclick = "assignRemove( %%id%%,\'' . 'assign' . '\' );"', - ), - ); + ], + ]; } return self::$_links; } diff --git a/CRM/Financial/Form/Export.php b/CRM/Financial/Form/Export.php index 3aac7a2537d3..47cb220617dc 100644 --- a/CRM/Financial/Form/Export.php +++ b/CRM/Financial/Form/Export.php @@ -48,7 +48,7 @@ class CRM_Financial_Form_Export extends CRM_Core_Form { /** * Financial batch ids. */ - protected $_batchIds = array(); + protected $_batchIds = []; /** * Export status id. @@ -86,7 +86,7 @@ public function preProcess() { else { $this->_batchIds = $this->get('batchIds'); } - if (!empty($_GET['export_format']) && in_array($_GET['export_format'], array('IIF', 'CSV'))) { + if (!empty($_GET['export_format']) && in_array($_GET['export_format'], ['IIF', 'CSV'])) { $this->_exportFormat = $_GET['export_format']; } } @@ -125,26 +125,26 @@ public function buildQuickForm() { } } - $optionTypes = array( + $optionTypes = [ 'IIF' => ts('Export to IIF'), 'CSV' => ts('Export to CSV'), - ); + ]; $this->addRadio('export_format', NULL, $optionTypes, NULL, '
    ', TRUE); $this->addButtons( - array( - array( + [ + [ 'type' => 'next', 'name' => ts('Export Batch'), 'spacing' => '         ', 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); } @@ -158,7 +158,7 @@ public function postProcess() { } if ($this->_id) { - $batchIds = array($this->_id); + $batchIds = [$this->_id]; } elseif (!empty($this->_batchIds)) { $batchIds = explode(',', $this->_batchIds); diff --git a/CRM/Financial/Form/FinancialAccount.php b/CRM/Financial/Form/FinancialAccount.php index 24fc8d43b962..d0627d6b2bde 100644 --- a/CRM/Financial/Form/FinancialAccount.php +++ b/CRM/Financial/Form/FinancialAccount.php @@ -51,9 +51,9 @@ public function preProcess() { parent::preProcess(); if ($this->_id) { - $params = array( + $params = [ 'id' => $this->_id, - ); + ]; $financialAccount = CRM_Financial_BAO_FinancialAccount::retrieve($params, CRM_Core_DAO::$_nullArray); $financialAccountTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('financial_account_type', NULL, " AND v.name LIKE 'Asset' ")); if ($financialAccount->financial_account_type_id == $financialAccountTypeId @@ -84,15 +84,15 @@ public function buildQuickForm() { $attributes = CRM_Core_DAO::getAttribute('CRM_Financial_DAO_FinancialAccount'); $this->add('text', 'name', ts('Name'), $attributes['name'], TRUE); $this->addRule('name', ts('A financial type with this name already exists. Please select another name.'), - 'objectExists', array('CRM_Financial_DAO_FinancialAccount', $this->_id)); + 'objectExists', ['CRM_Financial_DAO_FinancialAccount', $this->_id]); $this->add('text', 'description', ts('Description'), $attributes['description']); $this->add('text', 'accounting_code', ts('Accounting Code'), $attributes['accounting_code']); $elementAccounting = $this->add('text', 'account_type_code', ts('Account Type Code'), $attributes['account_type_code']); - $this->addEntityRef('contact_id', ts('Owner'), array( - 'api' => array('params' => array('contact_type' => 'Organization')), + $this->addEntityRef('contact_id', ts('Owner'), [ + 'api' => ['params' => ['contact_type' => 'Organization']], 'create' => TRUE, - )); + ]); $this->add('text', 'tax_rate', ts('Tax Rate'), $attributes['tax_rate']); $this->add('checkbox', 'is_deductible', ts('Tax-Deductible?')); $elementActive = $this->add('checkbox', 'is_active', ts('Enabled?')); @@ -107,7 +107,7 @@ public function buildQuickForm() { $financialAccountType = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_FinancialAccount', 'financial_account_type_id'); if (!empty($financialAccountType)) { $element = $this->add('select', 'financial_account_type_id', ts('Financial Account Type'), - array('' => '- select -') + $financialAccountType, TRUE, array('class' => 'crm-select2 huge')); + ['' => '- select -'] + $financialAccountType, TRUE, ['class' => 'crm-select2 huge']); if ($this->_isARFlag) { $element->freeze(); $elementAccounting->freeze(); @@ -121,9 +121,9 @@ public function buildQuickForm() { if ($this->_action == CRM_Core_Action::UPDATE && CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialAccount', $this->_id, 'is_reserved') ) { - $this->freeze(array('name', 'description', 'is_active')); + $this->freeze(['name', 'description', 'is_active']); } - $this->addFormRule(array('CRM_Financial_Form_FinancialAccount', 'formRule'), $this); + $this->addFormRule(['CRM_Financial_Form_FinancialAccount', 'formRule'], $this); } /** @@ -138,7 +138,7 @@ public function buildQuickForm() { * list of errors to be posted back to the form */ public static function formRule($values, $files, $self) { - $errorMsg = array(); + $errorMsg = []; $financialAccountTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('financial_account_type', NULL, " AND v.name LIKE 'Liability' ")); if (isset($values['is_tax'])) { if ($values['financial_account_type_id'] != $financialAccountTypeId) { @@ -156,10 +156,10 @@ public static function formRule($values, $files, $self) { if ($self->_action & CRM_Core_Action::UPDATE) { if (!(isset($values['is_tax']))) { $relationshipId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Sales Tax Account is' ")); - $params = array( + $params = [ 'financial_account_id' => $self->_id, 'account_relationship' => $relationshipId, - ); + ]; $result = CRM_Financial_BAO_FinancialTypeAccount::retrieve($params, $defaults); if ($result) { $errorMsg['is_tax'] = ts('Is Tax? must be set for this financial account'); @@ -209,7 +209,7 @@ public function postProcess() { $params[$field] = CRM_Utils_Array::value($field, $params, FALSE); } $financialAccount = CRM_Financial_BAO_FinancialAccount::add($params); - CRM_Core_Session::setStatus(ts('The Financial Account \'%1\' has been saved.', array(1 => $financialAccount->name)), ts('Saved'), 'success'); + CRM_Core_Session::setStatus(ts('The Financial Account \'%1\' has been saved.', [1 => $financialAccount->name]), ts('Saved'), 'success'); } } diff --git a/CRM/Financial/Form/FinancialBatch.php b/CRM/Financial/Form/FinancialBatch.php index ab7727a65d3b..283db9a3a241 100644 --- a/CRM/Financial/Form/FinancialBatch.php +++ b/CRM/Financial/Form/FinancialBatch.php @@ -53,22 +53,22 @@ public function preProcess() { parent::preProcess(); $session = CRM_Core_Session::singleton(); if ($this->_id) { - $permissions = array( - CRM_Core_Action::UPDATE => array( - 'permission' => array( + $permissions = [ + CRM_Core_Action::UPDATE => [ + 'permission' => [ 'edit own manual batches', 'edit all manual batches', - ), + ], 'actionName' => 'edit', - ), - CRM_Core_Action::DELETE => array( - 'permission' => array( + ], + CRM_Core_Action::DELETE => [ + 'permission' => [ 'delete own manual batches', 'delete all manual batches', - ), + ], 'actionName' => 'delete', - ), - ); + ], + ]; $createdID = CRM_Core_DAO::getFieldValue('CRM_Batch_DAO_Batch', $this->_id, 'created_id'); if (!empty($permissions[$this->_action])) { @@ -95,22 +95,22 @@ public function buildQuickForm() { $this->applyFilter('__ALL__', 'trim'); $this->addButtons( - array( - array( + [ + [ 'type' => 'next', 'name' => ts('Save'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'next', 'name' => ts('Save and New'), 'subName' => 'new', - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); if ($this->_action & CRM_Core_Action::UPDATE && $this->_id) { @@ -119,8 +119,8 @@ public function buildQuickForm() { // unset exported status $exportedStatusId = CRM_Core_PseudoConstant::getKey('CRM_Batch_BAO_Batch', 'status_id', 'Exported'); unset($batchStatus[$exportedStatusId]); - $this->add('select', 'status_id', ts('Batch Status'), array('' => ts('- select -')) + $batchStatus, TRUE); - $this->freeze(array('status_id')); + $this->add('select', 'status_id', ts('Batch Status'), ['' => ts('- select -')] + $batchStatus, TRUE); + $this->freeze(['status_id']); } $attributes = CRM_Core_DAO::getAttribute('CRM_Batch_DAO_Batch'); @@ -130,14 +130,14 @@ public function buildQuickForm() { $this->add('textarea', 'description', ts('Description'), $attributes['description']); $this->add('select', 'payment_instrument_id', ts('Payment Method'), - array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(), + ['' => ts('- select -')] + CRM_Contribute_PseudoConstant::paymentInstrument(), FALSE ); $this->add('text', 'total', ts('Total Amount'), $attributes['total']); $this->add('text', 'item_count', ts('Number of Transactions'), $attributes['item_count']); - $this->addFormRule(array('CRM_Financial_Form_FinancialBatch', 'formRule'), $this); + $this->addFormRule(['CRM_Financial_Form_FinancialBatch', 'formRule'], $this); } /** @@ -170,7 +170,7 @@ public function setDefaultValues() { * list of errors to be posted back to the form */ public static function formRule($values, $files, $self) { - $errors = array(); + $errors = []; if (!empty($values['contact_name']) && !is_numeric($values['created_id'])) { $errors['contact_name'] = ts('Please select a valid contact.'); } @@ -234,7 +234,7 @@ public function postProcess() { $this->_id = $batch->id; // create activity. - $activityParams = array( + $activityParams = [ 'activity_type_id' => CRM_Core_PseudoConstant::getKey('CRM_Activity_DAO_Activity', 'activity_type_id', $activityTypeName), 'subject' => $batch->title . "- Batch", 'status_id' => CRM_Core_PseudoConstant::getKey('CRM_Activity_DAO_Activity', 'activity_status_id', 'Completed'), @@ -243,7 +243,7 @@ public function postProcess() { 'source_contact_id' => $session->get('userID'), 'source_contact_qid' => $session->get('userID'), 'details' => $details, - ); + ]; CRM_Activity_BAO_Activity::create($activityParams); @@ -251,7 +251,7 @@ public function postProcess() { $context = $this->get("context"); if ($batch->title) { - CRM_Core_Session::setStatus(ts("'%1' batch has been saved.", array(1 => $batch->title)), ts('Saved'), 'success'); + CRM_Core_Session::setStatus(ts("'%1' batch has been saved.", [1 => $batch->title]), ts('Saved'), 'success'); } if ($buttonName == $this->getButtonName('next', 'new') & $this->_action == CRM_Core_Action::UPDATE) { $session->replaceUserContext(CRM_Utils_System::url('civicrm/financial/batch', @@ -290,11 +290,11 @@ public function postProcess() { public function checkPermissions($action, $permissions, $createdID, $userContactID, $actionName) { if ((CRM_Core_Permission::check($permissions[0]) || CRM_Core_Permission::check($permissions[1]))) { if (CRM_Core_Permission::check($permissions[0]) && $userContactID != $createdID && !CRM_Core_Permission::check($permissions[1])) { - CRM_Core_Error::statusBounce(ts('You dont have permission to %1 this batch'), array(1 => $actionName)); + CRM_Core_Error::statusBounce(ts('You dont have permission to %1 this batch'), [1 => $actionName]); } } else { - CRM_Core_Error::statusBounce(ts('You dont have permission to %1 this batch'), array(1 => $actionName)); + CRM_Core_Error::statusBounce(ts('You dont have permission to %1 this batch'), [1 => $actionName]); } } diff --git a/CRM/Financial/Form/FinancialTypeAccount.php b/CRM/Financial/Form/FinancialTypeAccount.php index 959e9912ee93..231d91dcdeb2 100644 --- a/CRM/Financial/Form/FinancialTypeAccount.php +++ b/CRM/Financial/Form/FinancialTypeAccount.php @@ -104,12 +104,12 @@ public function preProcess() { CRM_Utils_System::setTitle($fieldTitle . ' - ' . ts('Financial Type Accounts')); } - $breadCrumb = array( - array( + $breadCrumb = [ + [ 'title' => ts('Financial Type Accounts'), 'url' => $url, - ), - ); + ], + ]; CRM_Utils_System::appendBreadCrumb($breadCrumb); } @@ -125,7 +125,7 @@ public function buildQuickForm() { } if (isset($this->_id)) { - $params = array('id' => $this->_id); + $params = ['id' => $this->_id]; CRM_Financial_BAO_FinancialTypeAccount::retrieve($params, $defaults); $this->setDefaults($defaults); $financialAccountTitle = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialAccount', $defaults['financial_account_id'], 'name'); @@ -147,7 +147,7 @@ public function buildQuickForm() { $element = $this->add('select', 'account_relationship', ts('Financial Account Relationship'), - array('select' => ts('- Select Financial Account Relationship -')) + $AccountTypeRelationship, + ['select' => ts('- Select Financial Account Relationship -')] + $AccountTypeRelationship, TRUE ); } @@ -162,12 +162,12 @@ public function buildQuickForm() { $financialAccountType = CRM_Utils_Array::value($this->_submitValues['account_relationship'], $financialAccountType); $result = CRM_Contribute_PseudoConstant::financialAccount(NULL, $financialAccountType); - $financialAccountSelect = array('' => ts('- select -')) + $result; + $financialAccountSelect = ['' => ts('- select -')] + $result; } else { - $financialAccountSelect = array( + $financialAccountSelect = [ 'select' => ts('- select -'), - ) + CRM_Contribute_PseudoConstant::financialAccount(); + ] + CRM_Contribute_PseudoConstant::financialAccount(); } } if ($this->_action == CRM_Core_Action::UPDATE) { @@ -175,7 +175,7 @@ public function buildQuickForm() { $financialAccountType = $financialAccountType[$this->_defaultValues['account_relationship']]; $result = CRM_Contribute_PseudoConstant::financialAccount(NULL, $financialAccountType); - $financialAccountSelect = array('' => ts('- select -')) + $result; + $financialAccountSelect = ['' => ts('- select -')] + $result; } $this->add('select', @@ -185,24 +185,24 @@ public function buildQuickForm() { TRUE ); - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => ts('Save'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'next', 'name' => ts('Save and New'), 'subName' => 'new', - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); - $this->addFormRule(array('CRM_Financial_Form_FinancialTypeAccount', 'formRule'), $this); + $this->addFormRule(['CRM_Financial_Form_FinancialTypeAccount', 'formRule'], $this); } /** @@ -217,7 +217,7 @@ public function buildQuickForm() { * list of errors to be posted back to the form */ public static function formRule($values, $files, $self) { - $errorMsg = array(); + $errorMsg = []; $errorFlag = FALSE; if ($self->_action == CRM_Core_Action::DELETE) { $relationValues = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_EntityFinancialAccount', 'account_relationship'); @@ -238,12 +238,12 @@ public static function formRule($values, $files, $self) { $errorMsg['financial_account_id'] = 'Financial Account is a required field.'; } if (!empty($values['account_relationship']) && !empty($values['financial_account_id'])) { - $params = array( + $params = [ 'account_relationship' => $values['account_relationship'], 'entity_id' => $self->_aid, 'entity_table' => 'civicrm_financial_type', - ); - $defaults = array(); + ]; + $defaults = []; if ($self->_action == CRM_Core_Action::ADD) { $relationshipId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Sales Tax Account is' ")); $isTax = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialAccount', $values['financial_account_id'], 'is_tax'); @@ -286,7 +286,7 @@ public function postProcess() { CRM_Core_Session::setStatus(ts('Selected financial type account has been deleted.')); } else { - $params = $ids = array(); + $params = $ids = []; // store the submitted values in an array $params = $this->exportValues(); diff --git a/CRM/Financial/Form/Payment.php b/CRM/Financial/Form/Payment.php index 9221234fe1fb..a559e5ec9274 100644 --- a/CRM/Financial/Form/Payment.php +++ b/CRM/Financial/Form/Payment.php @@ -38,7 +38,7 @@ class CRM_Financial_Form_Payment extends CRM_Core_Form { protected $_paymentProcessorID; protected $currency; - public $_values = array(); + public $_values = []; /** * @var array @@ -96,7 +96,7 @@ public function preProcess() { * * @return string */ - public function getCurrency($submittedValues = array()) { + public function getCurrency($submittedValues = []) { return $this->currency; } diff --git a/CRM/Financial/Form/PaymentEdit.php b/CRM/Financial/Form/PaymentEdit.php index 9a09eaeb63b1..245173ada705 100644 --- a/CRM/Financial/Form/PaymentEdit.php +++ b/CRM/Financial/Form/PaymentEdit.php @@ -69,7 +69,7 @@ public function preProcess() { $this->assign('id', $this->_id); $this->_contributionID = CRM_Utils_Request::retrieve('contribution_id', 'Positive', $this); - $this->_values = civicrm_api3('FinancialTrxn', 'getsingle', array('id' => $this->_id)); + $this->_values = civicrm_api3('FinancialTrxn', 'getsingle', ['id' => $this->_id]); if (!empty($this->_values['payment_processor_id'])) { CRM_Core_Error::statusBounce(ts('You cannot update this payment as it is tied to a payment processor')); } @@ -100,10 +100,10 @@ public function buildQuickForm() { $this->assign('paymentFields', $paymentFields); foreach ($paymentFields as $name => $paymentField) { if (!empty($paymentField['add_field'])) { - $attributes = array( + $attributes = [ 'entity' => 'FinancialTrxn', 'name' => $name, - ); + ]; $this->addField($name, $attributes, $paymentField['is_required']); } else { @@ -117,19 +117,19 @@ public function buildQuickForm() { } $this->assign('currency', CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_Currency', $this->_values['currency'], 'symbol', 'name')); - $this->addFormRule(array(__CLASS__, 'formRule'), $this); + $this->addFormRule([__CLASS__, 'formRule'], $this); - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'submit', 'name' => ts('Update'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - )); + ], + ]); } /** @@ -145,7 +145,7 @@ public function buildQuickForm() { * true if no errors, else array of errors */ public static function formRule($fields, $files, $self) { - $errors = array(); + $errors = []; // if Credit Card is chosen and pan_truncation is not NULL ensure that it's value is numeric else throw validation error if (CRM_Core_PseudoConstant::getName('CRM_Financial_DAO_FinancialTrxn', 'payment_instrument_id', $fields['payment_instrument_id']) == 'Credit Card' && @@ -162,12 +162,12 @@ public static function formRule($fields, $files, $self) { * Process the form submission. */ public function postProcess() { - $params = array( + $params = [ 'id' => $this->_id, 'payment_instrument_id' => $this->_submitValues['payment_instrument_id'], 'trxn_id' => CRM_Utils_Array::value('trxn_id', $this->_submitValues), 'trxn_date' => CRM_Utils_Array::value('trxn_date', $this->_submitValues, date('YmdHis')), - ); + ]; $paymentInstrumentName = CRM_Core_PseudoConstant::getName('CRM_Financial_DAO_FinancialTrxn', 'payment_instrument_id', $params['payment_instrument_id']); if ($paymentInstrumentName == 'Credit Card') { @@ -205,16 +205,16 @@ protected function submit($submittedValues) { $previousFinanciaTrxn['contribution_id'] = $newFinancialTrxn['contribution_id'] = $this->_contributionID; $newFinancialTrxn['to_financial_account_id'] = CRM_Financial_BAO_FinancialTypeAccount::getInstrumentFinancialAccount($submittedValues['payment_instrument_id']); - foreach (array('total_amount', 'fee_amount', 'net_amount', 'currency', 'is_payment', 'status_id') as $fieldName) { + foreach (['total_amount', 'fee_amount', 'net_amount', 'currency', 'is_payment', 'status_id'] as $fieldName) { $newFinancialTrxn[$fieldName] = $this->_values[$fieldName]; } - foreach (array($previousFinanciaTrxn, $newFinancialTrxn) as $financialTrxnParams) { + foreach ([$previousFinanciaTrxn, $newFinancialTrxn] as $financialTrxnParams) { $financialTrxn = civicrm_api3('FinancialTrxn', 'create', $financialTrxnParams); - $trxnParams = array( + $trxnParams = [ 'total_amount' => $financialTrxnParams['total_amount'], 'contribution_id' => $this->_contributionID, - ); + ]; $contributionTotalAmount = CRM_Core_DAO::getFieldValue('CRM_Contribute_BAO_Contribution', $this->_contributionID, 'total_amount'); CRM_Contribute_BAO_Contribution::assignProportionalLineItems($trxnParams, $financialTrxn['id'], $contributionTotalAmount); } @@ -235,7 +235,7 @@ protected function submit($submittedValues) { public function testSubmit($params) { $this->_id = $params['id']; $this->_contributionID = $params['contribution_id']; - $this->_values = civicrm_api3('FinancialTrxn', 'getsingle', array('id' => $params['id'])); + $this->_values = civicrm_api3('FinancialTrxn', 'getsingle', ['id' => $params['id']]); $this->submit($params); } @@ -252,7 +252,7 @@ public static function updateRelatedContribution($params, $contributionID) { $contributionDAO->id = $contributionID; $contributionDAO->find(TRUE); - foreach (array('trxn_id', 'check_number') as $fieldName) { + foreach (['trxn_id', 'check_number'] as $fieldName) { if (!empty($params[$fieldName])) { if (!empty($contributionDAO->$fieldName)) { $values = explode(',', $contributionDAO->$fieldName); @@ -273,49 +273,49 @@ public static function updateRelatedContribution($params, $contributionID) { * Get payment fields */ public function getPaymentFields() { - $paymentFields = array( - 'payment_instrument_id' => array( + $paymentFields = [ + 'payment_instrument_id' => [ 'is_required' => TRUE, 'add_field' => TRUE, - ), - 'check_number' => array( + ], + 'check_number' => [ 'is_required' => FALSE, 'add_field' => TRUE, - ), + ], // @TODO we need to show card type icon in place of select field - 'card_type_id' => array( + 'card_type_id' => [ 'is_required' => FALSE, 'add_field' => TRUE, - ), - 'pan_truncation' => array( + ], + 'pan_truncation' => [ 'is_required' => FALSE, 'add_field' => TRUE, - ), - 'trxn_id' => array( + ], + 'trxn_id' => [ 'add_field' => TRUE, 'is_required' => FALSE, - ), - 'trxn_date' => array( + ], + 'trxn_date' => [ 'htmlType' => 'datepicker', 'name' => 'trxn_date', 'title' => ts('Transaction Date'), 'is_required' => TRUE, - 'attributes' => array( + 'attributes' => [ 'date' => 'yyyy-mm-dd', 'time' => 24, - ), - ), - 'total_amount' => array( + ], + ], + 'total_amount' => [ 'htmlType' => 'text', 'name' => 'total_amount', 'title' => ts('Total Amount'), 'is_required' => TRUE, - 'attributes' => array( + 'attributes' => [ 'readonly' => TRUE, 'size' => 6, - ), - ), - ); + ], + ], + ]; return $paymentFields; } diff --git a/CRM/Financial/Form/Search.php b/CRM/Financial/Form/Search.php index e810640e9718..30de0e886610 100644 --- a/CRM/Financial/Form/Search.php +++ b/CRM/Financial/Form/Search.php @@ -47,7 +47,7 @@ public function preProcess() { * @return array */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; $status = CRM_Utils_Request::retrieve('status', 'Positive', CRM_Core_DAO::$_nullObject, FALSE, 1); $defaults['batch_update'] = $status; if ($this->_batchStatus) { @@ -63,17 +63,17 @@ public function buildQuickForm() { $attributes['total']['class'] = $attributes['item_count']['class'] = 'number'; $this->add('text', 'title', ts('Batch Name'), $attributes['title']); - $batchStatus = CRM_Core_PseudoConstant::get('CRM_Batch_DAO_Batch', 'status_id', array('labelColumn' => 'name')); + $batchStatus = CRM_Core_PseudoConstant::get('CRM_Batch_DAO_Batch', 'status_id', ['labelColumn' => 'name']); $this->add( 'select', 'status_id', ts('Batch Status'), - array( + [ '' => ts('- any -'), array_search('Open', $batchStatus) => ts('Open'), array_search('Closed', $batchStatus) => ts('Closed'), array_search('Exported', $batchStatus) => ts('Exported'), - ), + ], FALSE ); @@ -81,7 +81,7 @@ public function buildQuickForm() { 'select', 'payment_instrument_id', ts('Payment Method'), - array('' => ts('- any -')) + CRM_Contribute_PseudoConstant::paymentInstrument(), + ['' => ts('- any -')] + CRM_Contribute_PseudoConstant::paymentInstrument(), FALSE ); @@ -90,14 +90,14 @@ public function buildQuickForm() { $this->add('text', 'item_count', ts('Number of Items'), $attributes['item_count']); $this->add('text', 'sort_name', ts('Created By'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name')); - $this->assign('elements', array('status_id', 'title', 'sort_name', 'payment_instrument_id', 'item_count', 'total')); - $this->addElement('checkbox', 'toggleSelect', NULL, NULL, array('class' => 'select-rows')); - $batchAction = array( + $this->assign('elements', ['status_id', 'title', 'sort_name', 'payment_instrument_id', 'item_count', 'total']); + $this->addElement('checkbox', 'toggleSelect', NULL, NULL, ['class' => 'select-rows']); + $batchAction = [ 'reopen' => ts('Re-open'), 'close' => ts('Close'), 'export' => ts('Export'), 'delete' => ts('Delete'), - ); + ]; foreach ($batchAction as $action => $ignore) { if (!CRM_Batch_BAO_Batch::checkBatchPermission($action)) { @@ -107,28 +107,28 @@ public function buildQuickForm() { $this->add('select', 'batch_update', ts('Task'), - array('' => ts('- actions -')) + $batchAction); + ['' => ts('- actions -')] + $batchAction); $this->add('submit', 'submit', ts('Go'), - array( + [ 'class' => 'crm-form-submit', 'id' => 'Go', - )); + ]); $this->addButtons( - array( - array( + [ + [ 'type' => 'refresh', 'name' => ts('Search'), 'isDefault' => TRUE, - ), - ) + ], + ] ); parent::buildQuickForm(); } public function postProcess() { - $batchIds = array(); + $batchIds = []; foreach ($_POST as $key => $value) { if (substr($key, 0, 6) == "check_") { $batch = explode("_", $key); diff --git a/CRM/Financial/Page/AJAX.php b/CRM/Financial/Page/AJAX.php index 7634b5a0c345..27b4b347ca28 100644 --- a/CRM/Financial/Page/AJAX.php +++ b/CRM/Financial/Page/AJAX.php @@ -60,23 +60,23 @@ public static function jqFinancial($config) { $defaultId = CRM_Core_DAO::singleValueQuery("SELECT id FROM civicrm_financial_account WHERE is_default = 1 AND financial_account_type_id = $financialAccountType"); } } - $elements = array( - array( + $elements = [ + [ 'name' => ts('- select -'), 'value' => 'select', - ), - ); + ], + ]; if (!empty($result)) { foreach ($result as $id => $name) { - $selectedArray = array(); + $selectedArray = []; if ($id == $defaultId) { $selectedArray['selected'] = 'Selected'; } - $elements[] = array( + $elements[] = [ 'name' => $name, 'value' => $id, - ) + $selectedArray; + ] + $selectedArray; } } CRM_Utils_JSON::output($elements); @@ -100,36 +100,36 @@ public static function jqFinancialRelation($config) { $params['orderColumn'] = 'label'; $result = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_EntityFinancialAccount', 'account_relationship', $params); - $elements = array( - array( + $elements = [ + [ 'name' => ts('- Select Financial Account Relationship -'), 'value' => 'select', - ), - ); + ], + ]; $countResult = count($financialAccountType[$financialAccountTypeId]); if (!empty($result)) { foreach ($result as $id => $name) { if (in_array($id, $financialAccountType[$financialAccountTypeId]) && $_GET['_value'] != 'select') { if ($countResult != 1) { - $elements[] = array( + $elements[] = [ 'name' => $name, 'value' => $id, - ); + ]; } else { - $elements[] = array( + $elements[] = [ 'name' => $name, 'value' => $id, 'selected' => 'Selected', - ); + ]; } } elseif ($_GET['_value'] == 'select') { - $elements[] = array( + $elements[] = [ 'name' => $name, 'value' => $id, - ); + ]; } } } @@ -164,17 +164,17 @@ public static function assignRemove() { } $entityID = CRM_Utils_Request::retrieve('entityID', 'Positive', CRM_Core_DAO::$_nullObject, FALSE, NULL, 'POST'); - $methods = array( + $methods = [ 'assign' => 'create', 'remove' => 'del', 'reopen' => 'create', 'close' => 'create', 'delete' => 'deleteBatch', - ); + ]; if ($op == 'close') { $totals = CRM_Batch_BAO_Batch::batchTotals($records); } - $response = array('status' => 'record-updated-fail'); + $response = ['status' => 'record-updated-fail']; // first munge and clean the recordBAO and get rid of any non alpha numeric characters $recordBAO = CRM_Utils_String::munge($recordBAO); $recordClass = explode('_', $recordBAO); @@ -182,7 +182,7 @@ public static function assignRemove() { // at least 3 levels deep if ($recordClass[0] == 'CRM' && count($recordClass) >= 3) { foreach ($records as $recordID) { - $params = array(); + $params = []; switch ($op) { case 'assign': case 'remove': @@ -190,14 +190,14 @@ public static function assignRemove() { $batchPID = CRM_Core_DAO::getFieldValue('CRM_Batch_DAO_Batch', $entityID, 'payment_instrument_id'); $paymentInstrument = CRM_Core_PseudoConstant::getLabel('CRM_Batch_BAO_Batch', 'payment_instrument_id', $batchPID); if ($op == 'remove' || ($recordPID == $batchPID && $op == 'assign') || !isset($batchPID)) { - $params = array( + $params = [ 'entity_id' => $recordID, 'entity_table' => 'civicrm_financial_trxn', 'batch_id' => $entityID, - ); + ]; } else { - $response = array('status' => ts("This batch is configured to include only transactions using %1 payment method. If you want to include other transactions, please edit the batch first and modify the Payment Method.", array(1 => $paymentInstrument))); + $response = ['status' => ts("This batch is configured to include only transactions using %1 payment method. If you want to include other transactions, please edit the batch first and modify the Payment Method.", [1 => $paymentInstrument])]; } break; @@ -206,7 +206,7 @@ public static function assignRemove() { $params = $totals[$recordID]; case 'reopen': $status = $op == 'close' ? 'Closed' : 'Reopened'; - $batchStatus = CRM_Core_PseudoConstant::get('CRM_Batch_DAO_Batch', 'status_id', array('labelColumn' => 'name')); + $batchStatus = CRM_Core_PseudoConstant::get('CRM_Batch_DAO_Batch', 'status_id', ['labelColumn' => 'name']); $params['status_id'] = CRM_Utils_Array::key($status, $batchStatus); $session = CRM_Core_Session::singleton(); $params['modified_date'] = date('YmdHis'); @@ -230,10 +230,10 @@ public static function assignRemove() { if ($batchStatus[$updated->status_id] == "Reopened") { $redirectStatus = array_search("Open", $batchStatus); } - $response = array( + $response = [ 'status' => 'record-updated-success', 'status_id' => $redirectStatus, - ); + ]; } } } @@ -248,7 +248,7 @@ public static function assignRemove() { * @return string|wtf?? */ public static function getFinancialTransactionsList() { - $sortMapper = array( + $sortMapper = [ 0 => '', 1 => '', 2 => 'sort_name', @@ -259,7 +259,7 @@ public static function getFinancialTransactionsList() { 7 => 'payment_method', 8 => 'status', 9 => 'name', - ); + ]; $sEcho = CRM_Utils_Type::escape($_REQUEST['sEcho'], 'Integer'); $return = isset($_REQUEST['return']) ? CRM_Utils_Type::escape($_REQUEST['return'], 'Boolean') : FALSE; @@ -278,7 +278,7 @@ public static function getFinancialTransactionsList() { $params['sortBy'] = $sort . ' ' . $sortOrder; } - $returnvalues = array( + $returnvalues = [ 'civicrm_financial_trxn.payment_instrument_id as payment_method', 'civicrm_contribution.contact_id as contact_id', 'civicrm_contribution.id as contributionID', @@ -295,9 +295,9 @@ public static function getFinancialTransactionsList() { 'civicrm_financial_trxn.check_number as check_number', 'civicrm_financial_trxn.card_type_id', 'civicrm_financial_trxn.pan_truncation', - ); + ]; - $columnHeader = array( + $columnHeader = [ 'contact_type' => '', 'sort_name' => ts('Contact Name'), 'amount' => ts('Amount'), @@ -307,7 +307,7 @@ public static function getFinancialTransactionsList() { 'payment_method' => ts('Payment Method'), 'status' => ts('Status'), 'name' => ts('Type'), - ); + ]; if ($sort && $sortOrder) { $params['sortBy'] = $sort . ' ' . $sortOrder; @@ -349,13 +349,13 @@ public static function getFinancialTransactionsList() { $params['total'] = count($assignedTransactionsCount); } } - $financialitems = array(); + $financialitems = []; if ($statusID) { - $batchStatuses = CRM_Core_PseudoConstant::get('CRM_Batch_DAO_Batch', 'status_id', array('labelColumn' => 'name', 'condition' => " v.value={$statusID}")); + $batchStatuses = CRM_Core_PseudoConstant::get('CRM_Batch_DAO_Batch', 'status_id', ['labelColumn' => 'name', 'condition' => " v.value={$statusID}"]); $batchStatus = $batchStatuses[$statusID]; } while ($financialItem->fetch()) { - $row[$financialItem->id] = array(); + $row[$financialItem->id] = []; foreach ($columnHeader as $columnKey => $columnValue) { if ($financialItem->contact_sub_type && $columnKey == 'contact_type') { $row[$financialItem->id][$columnKey] = $financialItem->contact_sub_type; @@ -386,18 +386,18 @@ public static function getFinancialTransactionsList() { $row[$financialItem->id][$columnKey] = CRM_Core_PseudoConstant::getLabel('CRM_Contribute_BAO_Contribution', 'contribution_status_id', $financialItem->$columnKey); } } - if (isset($batchStatus) && in_array($batchStatus, array('Open', 'Reopened'))) { + if (isset($batchStatus) && in_array($batchStatus, ['Open', 'Reopened'])) { if (isset($notPresent)) { $js = "enableActions('x')"; $row[$financialItem->id]['check'] = ""; $row[$financialItem->id]['action'] = CRM_Core_Action::formLink( CRM_Financial_Form_BatchTransaction::links(), NULL, - array( + [ 'id' => $financialItem->id, 'contid' => $financialItem->contributionID, 'cid' => $financialItem->contact_id, - ), + ], ts('more'), FALSE, 'financialItem.batch.row', @@ -411,11 +411,11 @@ public static function getFinancialTransactionsList() { $row[$financialItem->id]['action'] = CRM_Core_Action::formLink( CRM_Financial_Page_BatchTransaction::links(), NULL, - array( + [ 'id' => $financialItem->id, 'contid' => $financialItem->contributionID, 'cid' => $financialItem->contact_id, - ), + ], ts('more'), FALSE, 'financialItem.batch.row', @@ -432,11 +432,11 @@ public static function getFinancialTransactionsList() { $row[$financialItem->id]['action'] = CRM_Core_Action::formLink( $links, NULL, - array( + [ 'id' => $financialItem->id, 'contid' => $financialItem->contributionID, 'cid' => $financialItem->contact_id, - ), + ], ts('more'), FALSE, 'financialItem.batch.row', @@ -451,7 +451,7 @@ public static function getFinancialTransactionsList() { } $iFilteredTotal = $iTotal = $params['total']; - $selectorElements = array( + $selectorElements = [ 'check', 'contact_type', 'sort_name', @@ -463,7 +463,7 @@ public static function getFinancialTransactionsList() { 'status', 'name', 'action', - ); + ]; if ($return) { return CRM_Utils_JSON::encodeDataTableSelector($financialitems, $sEcho, $iTotal, $iFilteredTotal, $selectorElements); @@ -489,11 +489,11 @@ public static function bulkAssignRemove() { foreach ($cIDs as $key => $value) { $recordPID = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialTrxn', $value, 'payment_instrument_id'); if ($action == 'Remove' || ($recordPID == $batchPID && $action == 'Assign') || !isset($batchPID)) { - $params = array( + $params = [ 'entity_id' => $value, 'entity_table' => 'civicrm_financial_trxn', 'batch_id' => $entityID, - ); + ]; if ($action == 'Assign') { $updated = CRM_Batch_BAO_EntityBatch::create($params); } @@ -503,17 +503,17 @@ public static function bulkAssignRemove() { } } if ($updated) { - $status = array('status' => 'record-updated-success'); + $status = ['status' => 'record-updated-success']; } else { - $status = array('status' => ts("This batch is configured to include only transactions using %1 payment method. If you want to include other transactions, please edit the batch first and modify the Payment Method.", array(1 => $paymentInstrument))); + $status = ['status' => ts("This batch is configured to include only transactions using %1 payment method. If you want to include other transactions, please edit the batch first and modify the Payment Method.", [1 => $paymentInstrument])]; } CRM_Utils_JSON::output($status); } public static function getBatchSummary() { $batchID = CRM_Utils_Type::escape($_REQUEST['batchID'], 'String'); - $params = array('id' => $batchID); + $params = ['id' => $batchID]; $batchSummary = self::makeBatchSummary($batchID, $params); @@ -530,8 +530,8 @@ public static function getBatchSummary() { */ public static function makeBatchSummary($batchID, $params) { $batchInfo = CRM_Batch_BAO_Batch::retrieve($params, $value); - $batchTotals = CRM_Batch_BAO_Batch::batchTotals(array($batchID)); - $batchSummary = array( + $batchTotals = CRM_Batch_BAO_Batch::batchTotals([$batchID]); + $batchSummary = [ 'created_by' => CRM_Contact_BAO_Contact::displayName($batchInfo->created_id), 'status' => CRM_Core_PseudoConstant::getLabel('CRM_Batch_BAO_Batch', 'status_id', $batchInfo->status_id), 'description' => $batchInfo->description, @@ -541,7 +541,7 @@ public static function makeBatchSummary($batchID, $params) { 'total' => CRM_Utils_Money::format($batchInfo->total), 'assigned_total' => CRM_Utils_Money::format($batchTotals[$batchID]['total']), 'opened_date' => CRM_Utils_Date::customFormat($batchInfo->created_date), - ); + ]; return $batchSummary; } diff --git a/CRM/Financial/Page/BatchTransaction.php b/CRM/Financial/Page/BatchTransaction.php index 2816593292bf..d9e7c42fc0d8 100644 --- a/CRM/Financial/Page/BatchTransaction.php +++ b/CRM/Financial/Page/BatchTransaction.php @@ -65,19 +65,19 @@ public function getBAOName() { */ public function &links() { if (!(self::$_links)) { - self::$_links = array( - 'view' => array( + self::$_links = [ + 'view' => [ 'name' => ts('View'), 'url' => 'civicrm/contact/view/contribution', 'qs' => 'reset=1&id=%%contid%%&cid=%%cid%%&action=view&context=contribution&selectedChild=contribute', 'title' => ts('View Contribution'), - ), - 'remove' => array( + ], + 'remove' => [ 'name' => ts('Remove'), 'title' => ts('Remove Transaction'), 'extra' => 'onclick = "assignRemove( %%id%%,\'' . 'remove' . '\' );"', - ), - ); + ], + ]; } return self::$_links; } @@ -102,13 +102,13 @@ public function run() { $statusID = CRM_Core_DAO::getFieldValue('CRM_Batch_BAO_Batch', self::$_entityID, 'status_id'); } $breadCrumb - = array( - array( + = [ + [ 'title' => ts('Accounting Batches'), 'url' => CRM_Utils_System::url('civicrm/financial/financialbatches', "reset=1&batchStatus=$statusID"), - ), - ); + ], + ]; CRM_Utils_System::appendBreadCrumb($breadCrumb); $this->edit($action, self::$_entityID); diff --git a/CRM/Financial/Page/FinancialAccount.php b/CRM/Financial/Page/FinancialAccount.php index 187bd9895155..b455f27b6bf9 100644 --- a/CRM/Financial/Page/FinancialAccount.php +++ b/CRM/Financial/Page/FinancialAccount.php @@ -62,30 +62,30 @@ public function getBAOName() { */ public function &links() { if (!(self::$_links)) { - self::$_links = array( - CRM_Core_Action::UPDATE => array( + self::$_links = [ + CRM_Core_Action::UPDATE => [ 'name' => ts('Edit'), 'url' => 'civicrm/admin/financial/financialAccount', 'qs' => 'action=update&id=%%id%%&reset=1', 'title' => ts('Edit Financial Type'), - ), - CRM_Core_Action::DISABLE => array( + ], + CRM_Core_Action::DISABLE => [ 'name' => ts('Disable'), 'ref' => 'crm-enable-disable', 'title' => ts('Disable Financial Type'), - ), - CRM_Core_Action::ENABLE => array( + ], + CRM_Core_Action::ENABLE => [ 'name' => ts('Enable'), 'ref' => 'crm-enable-disable', 'title' => ts('Enable Financial Type'), - ), - CRM_Core_Action::DELETE => array( + ], + CRM_Core_Action::DELETE => [ 'name' => ts('Delete'), 'url' => 'civicrm/admin/financial/financialAccount', 'qs' => 'action=delete&id=%%id%%', 'title' => ts('Delete Financial Type'), - ), - ); + ], + ]; } return self::$_links; } @@ -95,14 +95,14 @@ public function &links() { */ public function browse() { // get all custom groups sorted by weight - $contributionType = array(); + $contributionType = []; $dao = new CRM_Financial_DAO_FinancialAccount(); $dao->orderBy('financial_account_type_id, name'); $dao->find(); $financialAccountType = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_FinancialAccount', 'financial_account_type_id'); while ($dao->fetch()) { - $contributionType[$dao->id] = array(); + $contributionType[$dao->id] = []; CRM_Core_DAO::storeValues($dao, $contributionType[$dao->id]); $contributionType[$dao->id]['financial_account_type_id'] = $financialAccountType[$dao->financial_account_type_id]; // form all action links @@ -122,7 +122,7 @@ public function browse() { } $contributionType[$dao->id]['action'] = CRM_Core_Action::formLink(self::links(), $action, - array('id' => $dao->id), + ['id' => $dao->id], ts('more'), FALSE, 'financialAccount.manage.action', diff --git a/CRM/Financial/Page/FinancialBatch.php b/CRM/Financial/Page/FinancialBatch.php index dadd7116bb29..2fdd43d00c63 100644 --- a/CRM/Financial/Page/FinancialBatch.php +++ b/CRM/Financial/Page/FinancialBatch.php @@ -61,7 +61,7 @@ public function getBAOName() { */ public function &links() { if (!(self::$_links)) { - self::$_links = array(); + self::$_links = []; } return self::$_links; } diff --git a/CRM/Financial/Page/FinancialType.php b/CRM/Financial/Page/FinancialType.php index d768e3a6bac3..638bb412f6ec 100644 --- a/CRM/Financial/Page/FinancialType.php +++ b/CRM/Financial/Page/FinancialType.php @@ -62,36 +62,36 @@ public function getBAOName() { */ public function &links() { if (!(self::$_links)) { - self::$_links = array( - CRM_Core_Action::BROWSE => array( + self::$_links = [ + CRM_Core_Action::BROWSE => [ 'name' => ts('Accounts'), 'url' => 'civicrm/admin/financial/financialType/accounts', 'qs' => 'reset=1&action=browse&aid=%%id%%', 'title' => ts('Accounts'), - ), - CRM_Core_Action::UPDATE => array( + ], + CRM_Core_Action::UPDATE => [ 'name' => ts('Edit'), 'url' => 'civicrm/admin/financial/financialType', 'qs' => 'action=update&id=%%id%%&reset=1', 'title' => ts('Edit Financial Type'), - ), - CRM_Core_Action::DISABLE => array( + ], + CRM_Core_Action::DISABLE => [ 'name' => ts('Disable'), 'ref' => 'crm-enable-disable', 'title' => ts('Disable Financial Type'), - ), - CRM_Core_Action::ENABLE => array( + ], + CRM_Core_Action::ENABLE => [ 'name' => ts('Enable'), 'ref' => 'crm-enable-disable', 'title' => ts('Enable Financial Type'), - ), - CRM_Core_Action::DELETE => array( + ], + CRM_Core_Action::DELETE => [ 'name' => ts('Delete'), 'url' => 'civicrm/admin/financial/financialType', 'qs' => 'action=delete&id=%%id%%', 'title' => ts('Delete Financial Type'), - ), - ); + ], + ]; } return self::$_links; } @@ -107,17 +107,17 @@ public function browse() { CRM_Core_Error::fatal(ts('You do not have permission to access this page.')); } // get all financial types sorted by weight - $financialType = array(); + $financialType = []; $dao = new CRM_Financial_DAO_FinancialType(); $dao->orderBy('name'); $dao->find(); while ($dao->fetch()) { - $financialType[$dao->id] = array(); + $financialType[$dao->id] = []; CRM_Core_DAO::storeValues($dao, $financialType[$dao->id]); - $defaults = $financialAccountId = array(); + $defaults = $financialAccountId = []; $financialAccounts = CRM_Contribute_PseudoConstant::financialAccount(); - $financialAccountIds = array(); + $financialAccountIds = []; $params['entity_id'] = $dao->id; $params['entity_table'] = 'civicrm_financial_type'; @@ -153,7 +153,7 @@ public function browse() { } $financialType[$dao->id]['action'] = CRM_Core_Action::formLink(self::links(), $action, - array('id' => $dao->id), + ['id' => $dao->id], ts('more'), FALSE, 'financialType.manage.action', diff --git a/CRM/Financial/Page/FinancialTypeAccount.php b/CRM/Financial/Page/FinancialTypeAccount.php index 867db38c75fa..a0c17c3109fd 100644 --- a/CRM/Financial/Page/FinancialTypeAccount.php +++ b/CRM/Financial/Page/FinancialTypeAccount.php @@ -67,20 +67,20 @@ public function getBAOName() { */ public function &links() { if (!(self::$_links)) { - self::$_links = array( - CRM_Core_Action::UPDATE => array( + self::$_links = [ + CRM_Core_Action::UPDATE => [ 'name' => ts('Edit'), 'url' => 'civicrm/admin/financial/financialType/accounts', 'qs' => 'action=update&id=%%id%%&aid=%%aid%%&reset=1', 'title' => ts('Edit Financial Type Account'), - ), - CRM_Core_Action::DELETE => array( + ], + CRM_Core_Action::DELETE => [ 'name' => ts('Delete'), 'url' => 'civicrm/admin/financial/financialType/accounts', 'qs' => 'action=delete&id=%%id%%&aid=%%aid%%', 'title' => ts('Delete Financial Type Account'), - ), - ); + ], + ]; } return self::$_links; } @@ -118,8 +118,8 @@ public function run() { */ public function browse() { // get all Financial Type Account data sorted by weight - $financialType = array(); - $params = array(); + $financialType = []; + $params = []; $dao = new CRM_Financial_DAO_EntityFinancialAccount(); $params['entity_id'] = $this->_aid; $params['entity_table'] = 'civicrm_financial_type'; @@ -132,11 +132,11 @@ public function browse() { $dao->copyValues($params); $dao->find(); while ($dao->fetch()) { - $financialType[$dao->id] = array(); + $financialType[$dao->id] = []; CRM_Core_DAO::storeValues($dao, $financialType[$dao->id]); - $params = array('id' => $dao->financial_account_id); - $defaults = array(); + $params = ['id' => $dao->financial_account_id]; + $defaults = []; $financialAccount = CRM_Financial_BAO_FinancialAccount::retrieve($params, $defaults); if (!empty($financialAccount)) { $financialType[$dao->id]['financial_account'] = $financialAccount->name; @@ -165,10 +165,10 @@ public function browse() { unset($links[CRM_Core_Action::DELETE]); } $financialType[$dao->id]['action'] = CRM_Core_Action::formLink($links, $action, - array( + [ 'id' => $dao->id, 'aid' => $dao->entity_id, - ), + ], ts('more'), FALSE, 'financialTypeAccount.manage.action', diff --git a/CRM/Friend/BAO/Friend.php b/CRM/Friend/BAO/Friend.php index 0daf23ae528e..b817cae90911 100644 --- a/CRM/Friend/BAO/Friend.php +++ b/CRM/Friend/BAO/Friend.php @@ -98,18 +98,18 @@ public static function retrieve(&$params, &$values) { public static function create(&$params) { $transaction = new CRM_Core_Transaction(); - $mailParams = array(); - $contactParams = array(); + $mailParams = []; + $contactParams = []; // create contact corresponding to each friend foreach ($params['friend'] as $key => $details) { if ($details["first_name"]) { - $contactParams[$key] = array( + $contactParams[$key] = [ 'first_name' => $details["first_name"], 'last_name' => $details["last_name"], 'contact_source' => ts('Tell a Friend') . ": {$params['title']}", 'email-Primary' => $details["email"], - ); + ]; $displayName = $details["first_name"] . " " . $details["last_name"]; $mailParams['email'][$displayName] = $details["email"]; @@ -125,7 +125,7 @@ public static function create(&$params) { $activityTypeId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', 'Tell a Friend', 'value', 'name'); // create activity - $activityParams = array( + $activityParams = [ 'source_contact_id' => $params['source_contact_id'], 'source_record_id' => NULL, 'activity_type_id' => $activityTypeId, @@ -136,7 +136,7 @@ public static function create(&$params) { 'status_id' => CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_status_id', 'Completed'), 'is_test' => $params['is_test'], 'campaign_id' => CRM_Utils_Array::value('campaign_id', $params), - ); + ]; // activity creation $activity = CRM_Activity_BAO_Activity::create($activityParams); @@ -147,18 +147,18 @@ public static function create(&$params) { foreach ($contactParams as $key => $value) { // create contact only if it does not exits in db $value['email'] = $value['email-Primary']; - $contactID = CRM_Contact_BAO_Contact::getFirstDuplicateContact($value, 'Individual', 'Supervised', array(), FALSE); + $contactID = CRM_Contact_BAO_Contact::getFirstDuplicateContact($value, 'Individual', 'Supervised', [], FALSE); if (!$contactID) { $contactID = self::add($value); } // attempt to save activity targets - $targetParams = array( + $targetParams = [ 'activity_id' => $activity->id, 'contact_id' => $contactID, 'record_type_id' => $targetID, - ); + ]; // See if it already exists $activityContact = new CRM_Activity_DAO_ActivityContact(); @@ -181,11 +181,11 @@ public static function create(&$params) { list($_, $mailParams['email_from']) = CRM_Core_BAO_Domain::getNameAndEmail(); list($username, $mailParams['domain']) = explode('@', $mailParams['email_from']); - $default = array(); - $findProperties = array('id' => $params['entity_id']); + $default = []; + $findProperties = ['id' => $params['entity_id']]; if ($params['entity_table'] == 'civicrm_contribution_page') { - $returnProperties = array('receipt_from_email', 'is_email_receipt'); + $returnProperties = ['receipt_from_email', 'is_email_receipt']; CRM_Core_DAO::commonRetrieve('CRM_Contribute_DAO_ContributionPage', $findProperties, $default, @@ -201,7 +201,7 @@ public static function create(&$params) { $mailParams['module'] = 'contribute'; } elseif ($params['entity_table'] == 'civicrm_event') { - $returnProperties = array('confirm_from_email', 'is_email_confirm'); + $returnProperties = ['confirm_from_email', 'is_email_confirm']; CRM_Core_DAO::commonRetrieve('CRM_Event_DAO_Event', $findProperties, $default, @@ -241,12 +241,12 @@ public static function create(&$params) { * @return void */ public static function buildFriendForm($form) { - $form->addElement('checkbox', 'tf_is_active', ts('Tell a Friend enabled?'), NULL, array('onclick' => "friendBlock(this)")); + $form->addElement('checkbox', 'tf_is_active', ts('Tell a Friend enabled?'), NULL, ['onclick' => "friendBlock(this)"]); // name $form->add('text', 'tf_title', ts('Title'), CRM_Core_DAO::getAttribute('CRM_Friend_DAO_Friend', 'title'), TRUE); // intro-text and thank-you text - $form->add('wysiwyg', 'intro', ts('Introduction'), CRM_Core_DAO::getAttribute('CRM_Friend_DAO_Friend', 'intro') + array('class' => 'collapsed')); + $form->add('wysiwyg', 'intro', ts('Introduction'), CRM_Core_DAO::getAttribute('CRM_Friend_DAO_Friend', 'intro') + ['class' => 'collapsed']); $form->add('textarea', 'suggested_message', ts('Suggested Message'), CRM_Core_DAO::getAttribute('CRM_Friend_DAO_Friend', 'suggested_message'), FALSE @@ -256,7 +256,7 @@ public static function buildFriendForm($form) { $form->add('text', 'tf_thankyou_title', ts('Thank-you Title'), CRM_Core_DAO::getAttribute('CRM_Friend_DAO_Friend', 'thankyou_title'), TRUE); - $form->add('wysiwyg', 'tf_thankyou_text', ts('Thank-you Message'), CRM_Core_DAO::getAttribute('CRM_Friend_DAO_Friend', 'thankyou_text') + array('class' => 'collapsed')); + $form->add('wysiwyg', 'tf_thankyou_text', ts('Thank-you Message'), CRM_Core_DAO::getAttribute('CRM_Friend_DAO_Friend', 'thankyou_text') + ['class' => 'collapsed']); if ($form->_friendId) { // CRM-14200 the i18n dialogs need this for translation @@ -313,21 +313,21 @@ public static function sendMail($contactID, &$values) { $values['domain'] = $domainFromName; } - $templateParams = array( + $templateParams = [ 'groupName' => 'msg_tpl_workflow_friend', 'valueName' => 'friend', 'contactId' => $contactID, - 'tplParams' => array( + 'tplParams' => [ $values['module'] => $values['module'], 'senderContactName' => $fromName, 'title' => $values['title'], 'generalLink' => $values['general_link'], 'pageURL' => $values['page_url'], 'senderMessage' => $values['message'], - ), + ], 'from' => "$fromName (via {$values['domain']}) <{$values['email_from']}>", 'replyTo' => $email, - ); + ]; foreach ($values['email'] as $displayName => $emailTo) { if ($emailTo) { diff --git a/CRM/Friend/Form.php b/CRM/Friend/Form.php index 56753c967789..d8d7263b6126 100644 --- a/CRM/Friend/Form.php +++ b/CRM/Friend/Form.php @@ -80,14 +80,14 @@ public function preProcess() { $pcomponent = CRM_Utils_Request::retrieve('pcomponent', 'String', $this, TRUE); - if (in_array($pcomponent, array( + if (in_array($pcomponent, [ 'contribute', 'event', - ))) { - $values = array(); - $params = array('id' => $this->_entityId); + ])) { + $values = []; + $params = ['id' => $this->_entityId]; CRM_Core_DAO::commonRetrieve('CRM_Contribute_DAO_ContributionPage', - $params, $values, array('title', 'campaign_id', 'is_share') + $params, $values, ['title', 'campaign_id', 'is_share'] ); $this->_title = CRM_Utils_Array::value('title', $values); $this->_campaignId = CRM_Utils_Array::value('campaign_id', $values); @@ -106,10 +106,10 @@ public function preProcess() { elseif ($pcomponent == 'pcp') { $this->_pcpBlockId = CRM_Utils_Request::retrieve('blockId', 'Positive', $this, TRUE); - $values = array(); - $params = array('id' => $this->_pcpBlockId); + $values = []; + $params = ['id' => $this->_pcpBlockId]; CRM_Core_DAO::commonRetrieve('CRM_PCP_DAO_PCPBlock', - $params, $values, array('is_tellfriend_enabled', 'tellfriend_limit') + $params, $values, ['is_tellfriend_enabled', 'tellfriend_limit'] ); if (empty($values['is_tellfriend_enabled'])) { @@ -125,7 +125,7 @@ public function preProcess() { FROM civicrm_pcp pcp INNER JOIN civicrm_contribution_page contrib ON ( pcp.page_id = contrib.id AND pcp.page_type = "contribute" ) WHERE pcp.id = %1'; - $pcp = CRM_Core_DAO::executeQuery($sql, array(1 => array($this->_entityId, 'Positive'))); + $pcp = CRM_Core_DAO::executeQuery($sql, [1 => [$this->_entityId, 'Positive']]); while ($pcp->fetch()) { $this->_title = $pcp->title; $this->_campaignId = $pcp->campaign_id; @@ -160,7 +160,7 @@ public function preProcess() { * @return void */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; $defaults['entity_id'] = $this->_entityId; $defaults['entity_table'] = $this->_entityTable; @@ -205,7 +205,7 @@ public function buildQuickForm() { $email->freeze(); $this->add('wysiwyg', 'suggested_message', ts('Your Message'), CRM_Core_DAO::getAttribute('CRM_Friend_DAO_Friend', 'suggested_message')); - $friend = array(); + $friend = []; $mailLimit = self::NUM_OPTION; if ($this->_entityTable == 'civicrm_pcp') { $mailLimit = $this->_mailLimit; @@ -218,21 +218,21 @@ public function buildQuickForm() { $this->addRule("friend[$i][email]", ts('The format of this email address is not valid.'), 'email'); } - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'submit', 'name' => ts('Send Your Message'), 'spacing' => '         ', 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); - $this->addFormRule(array('CRM_Friend_Form', 'formRule')); + $this->addFormRule(['CRM_Friend_Form', 'formRule']); } /** @@ -245,7 +245,7 @@ public function buildQuickForm() { */ public static function formRule($fields) { - $errors = array(); + $errors = []; $valid = FALSE; foreach ($fields['friend'] as $key => $val) { @@ -293,7 +293,7 @@ public function postProcess() { CRM_Friend_BAO_Friend::create($formValues); $this->assign('status', 'thankyou'); - $defaults = array(); + $defaults = []; $defaults['entity_id'] = $this->_entityId; $defaults['entity_table'] = $this->_entityTable; diff --git a/CRM/Friend/Form/Contribute.php b/CRM/Friend/Form/Contribute.php index ecb04541614c..f4bb3971944b 100644 --- a/CRM/Friend/Form/Contribute.php +++ b/CRM/Friend/Form/Contribute.php @@ -58,7 +58,7 @@ public function preProcess() { * @return void */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; if (isset($this->_id)) { $defaults['entity_table'] = 'civicrm_contribution_page'; diff --git a/CRM/Friend/Form/Event.php b/CRM/Friend/Form/Event.php index 3c901fc1b107..bf5b6cb51828 100644 --- a/CRM/Friend/Form/Event.php +++ b/CRM/Friend/Form/Event.php @@ -58,7 +58,7 @@ public function preProcess() { * @return void */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; if (isset($this->_id)) { $defaults['entity_table'] = 'civicrm_event'; diff --git a/CRM/Grant/BAO/Grant.php b/CRM/Grant/BAO/Grant.php index 154e130286be..4db6f2a3c23f 100644 --- a/CRM/Grant/BAO/Grant.php +++ b/CRM/Grant/BAO/Grant.php @@ -57,23 +57,23 @@ public static function getGrantSummary($admin = FALSE) { $dao = CRM_Core_DAO::executeQuery($query); - $status = array(); - $summary = array(); + $status = []; + $summary = []; $summary['total_grants'] = NULL; $status = CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'status_id'); foreach ($status as $id => $name) { - $stats[$id] = array( + $stats[$id] = [ 'label' => $name, 'total' => 0, - ); + ]; } while ($dao->fetch()) { - $stats[$dao->status_id] = array( + $stats[$dao->status_id] = [ 'label' => $status[$dao->status_id], 'total' => $dao->status_total, - ); + ]; $summary['total_grants'] += $dao->status_total; } @@ -90,10 +90,10 @@ public static function getGrantSummary($admin = FALSE) { */ public static function getGrantStatusOptGroup() { - $params = array(); + $params = []; $params['name'] = CRM_Grant_BAO_Grant::$statusGroupName; - $defaults = array(); + $defaults = []; $og = CRM_Core_BAO_OptionGroup::retrieve($params, $defaults); if (!$og) { @@ -144,23 +144,23 @@ public static function add(&$params, &$ids) { } // first clean up all the money fields - $moneyFields = array( + $moneyFields = [ 'amount_total', 'amount_granted', 'amount_requested', - ); + ]; foreach ($moneyFields as $field) { if (isset($params[$field])) { $params[$field] = CRM_Utils_Rule::cleanMoney($params[$field]); } } // convert dates to mysql format - $dates = array( + $dates = [ 'application_received_date', 'decision_date', 'money_transfer_date', 'grant_due_date', - ); + ]; foreach ($dates as $d) { if (isset($params[$d])) { @@ -191,7 +191,7 @@ public static function add(&$params, &$ids) { } $title = CRM_Contact_BAO_Contact::displayName($grant->contact_id) . ' - ' . ts('Grant') . ': ' . $grantTypes[$grant->grant_type_id]; - $recentOther = array(); + $recentOther = []; if (CRM_Core_Permission::checkActionPermission('CiviGrant', CRM_Core_Action::UPDATE)) { $recentOther['editUrl'] = CRM_Utils_System::url('civicrm/contact/view/grant', "action=update&reset=1&id={$grant->id}&cid={$grant->contact_id}&context=home" @@ -250,23 +250,23 @@ public static function create(&$params, &$ids) { $id = CRM_Utils_Array::value('contact_id', $params); } if (!empty($params['note']) || CRM_Utils_Array::value('id', CRM_Utils_Array::value('note', $ids))) { - $noteParams = array( + $noteParams = [ 'entity_table' => 'civicrm_grant', 'note' => $params['note'] = $params['note'] ? $params['note'] : "null", 'entity_id' => $grant->id, 'contact_id' => $id, 'modified_date' => date('Ymd'), - ); + ]; CRM_Core_BAO_Note::add($noteParams, (array) CRM_Utils_Array::value('note', $ids)); } // Log the information on successful add/edit of Grant - $logParams = array( + $logParams = [ 'entity_table' => 'civicrm_grant', 'entity_id' => $grant->id, 'modified_id' => $id, 'modified_date' => date('Ymd'), - ); + ]; CRM_Core_BAO_Log::add($logParams); @@ -319,10 +319,10 @@ public static function del($id) { $grant->find(); // delete the recently created Grant - $grantRecent = array( + $grantRecent = [ 'id' => $id, 'type' => 'Grant', - ); + ]; CRM_Utils_Recent::del($grantRecent); if ($grant->fetch()) { @@ -341,13 +341,13 @@ public static function del($id) { */ public static function &exportableFields() { $fields = CRM_Grant_DAO_Grant::export(); - $grantNote = array( - 'grant_note' => array( + $grantNote = [ + 'grant_note' => [ 'title' => ts('Grant Note'), 'name' => 'grant_note', 'data_type' => CRM_Utils_Type::T_TEXT, - ), - ); + ], + ]; $fields = array_merge($fields, $grantNote, CRM_Core_BAO_CustomField::getFieldsForImport('Grant') ); diff --git a/CRM/Grant/BAO/Query.php b/CRM/Grant/BAO/Query.php index 8825dc72e5b3..eae47c5b47ed 100644 --- a/CRM/Grant/BAO/Query.php +++ b/CRM/Grant/BAO/Query.php @@ -37,7 +37,7 @@ class CRM_Grant_BAO_Query extends CRM_Core_BAO_Query { * @return array */ public static function &getFields() { - $fields = array(); + $fields = []; $fields = CRM_Grant_BAO_Grant::exportableFields(); return $fields; } @@ -198,7 +198,7 @@ public static function whereClauseSingle(&$values, &$query) { $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_grant.$name", $op, $value, "Integer"); list($qillop, $qillVal) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Grant_DAO_Grant', $name, $value, $op); - $query->_qill[$grouping][] = ts("%1 %2 %3", array(1 => $label, 2 => $qillop, 3 => $qillVal)); + $query->_qill[$grouping][] = ts("%1 %2 %3", [1 => $label, 2 => $qillop, 3 => $qillVal]); $query->_tables['civicrm_grant'] = $query->_whereTables['civicrm_grant'] = 1; return; @@ -214,7 +214,7 @@ public static function whereClauseSingle(&$values, &$query) { $query->_where[$grouping][] = "civicrm_grant.grant_report_received IS NULL"; } - $query->_qill[$grouping][] = ts('Grant Report Received = %1', array(1 => $yesNo)); + $query->_qill[$grouping][] = ts('Grant Report Received = %1', [1 => $yesNo]); $query->_tables['civicrm_grant'] = $query->_whereTables['civicrm_grant'] = 1; return; @@ -277,7 +277,7 @@ public static function defaultReturnProperties( ) { $properties = NULL; if ($mode & CRM_Contact_BAO_Query::MODE_GRANT) { - $properties = array( + $properties = [ 'contact_type' => 1, 'contact_sub_type' => 1, 'sort_name' => 1, @@ -289,7 +289,7 @@ public static function defaultReturnProperties( 'grant_report_received' => 1, 'grant_money_transfer_date' => 1, 'grant_note' => 1, - ); + ]; } return $properties; @@ -332,25 +332,25 @@ public static function buildSearchForm(&$form) { $form->addFormFieldsFromMetadata(); $form->assign('grantSearchFields', self::getTemplateHandlableSearchFields()); $form->add('select', 'grant_type_id', ts('Grant Type'), $grantType, FALSE, - array('id' => 'grant_type_id', 'multiple' => 'multiple', 'class' => 'crm-select2') + ['id' => 'grant_type_id', 'multiple' => 'multiple', 'class' => 'crm-select2'] ); $grantStatus = CRM_Core_OptionGroup::values('grant_status'); $form->add('select', 'grant_status_id', ts('Grant Status'), $grantStatus, FALSE, - array('id' => 'grant_status_id', 'multiple' => 'multiple', 'class' => 'crm-select2') + ['id' => 'grant_status_id', 'multiple' => 'multiple', 'class' => 'crm-select2'] ); $form->addElement('checkbox', 'grant_application_received_date_notset', ts('Date is not set'), NULL); $form->addElement('checkbox', 'grant_money_transfer_date_notset', ts('Date is not set'), NULL); $form->addElement('checkbox', 'grant_due_date_notset', ts('Date is not set'), NULL); $form->addElement('checkbox', 'grant_decision_date_notset', ts('Date is not set'), NULL); - $form->add('text', 'grant_amount_low', ts('Minimum Amount'), array('size' => 8, 'maxlength' => 8)); - $form->addRule('grant_amount_low', ts('Please enter a valid money value (e.g. %1).', array(1 => CRM_Utils_Money::format('9.99', ' '))), 'money'); + $form->add('text', 'grant_amount_low', ts('Minimum Amount'), ['size' => 8, 'maxlength' => 8]); + $form->addRule('grant_amount_low', ts('Please enter a valid money value (e.g. %1).', [1 => CRM_Utils_Money::format('9.99', ' ')]), 'money'); - $form->add('text', 'grant_amount_high', ts('Maximum Amount'), array('size' => 8, 'maxlength' => 8)); - $form->addRule('grant_amount_high', ts('Please enter a valid money value (e.g. %1).', array(1 => CRM_Utils_Money::format('99.99', ' '))), 'money'); + $form->add('text', 'grant_amount_high', ts('Maximum Amount'), ['size' => 8, 'maxlength' => 8]); + $form->addRule('grant_amount_high', ts('Please enter a valid money value (e.g. %1).', [1 => CRM_Utils_Money::format('99.99', ' ')]), 'money'); - self::addCustomFormFields($form, array('Grant')); + self::addCustomFormFields($form, ['Grant']); $form->assign('validGrant', TRUE); } diff --git a/CRM/Grant/Form/Grant.php b/CRM/Grant/Form/Grant.php index d6ce411b174c..980366983746 100644 --- a/CRM/Grant/Form/Grant.php +++ b/CRM/Grant/Form/Grant.php @@ -154,31 +154,31 @@ public function setDefaultValues() { public function buildQuickForm() { if ($this->_action & CRM_Core_Action::DELETE) { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => ts('Delete'), 'spacing' => '         ', 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); return; } $attributes = CRM_Core_DAO::getAttribute('CRM_Grant_DAO_Grant'); - $this->addSelect('grant_type_id', array('onChange' => "CRM.buildCustomData( 'Grant', this.value );"), TRUE); + $this->addSelect('grant_type_id', ['onChange' => "CRM.buildCustomData( 'Grant', this.value );"], TRUE); //need to assign custom data type and subtype to the template $this->assign('customDataType', 'Grant'); $this->assign('customDataSubType', $this->_grantType); $this->assign('entityID', $this->_id); - $this->addSelect('status_id', array(), TRUE); + $this->addSelect('status_id', [], TRUE); $this->add('datepicker', 'application_received_date', ts('Application Received'), [], FALSE, ['time' => FALSE]); $this->add('datepicker', 'decision_date', ts('Grant Decision'), [], FALSE, ['time' => FALSE]); @@ -207,27 +207,27 @@ public function buildQuickForm() { // make this form an upload since we dont know if the custom data injected dynamically // is of type file etc $uploadNames = $this->get( 'uploadNames' ); - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'upload', 'name' => ts('Save'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'upload', 'name' => ts('Save and New'), - 'js' => array('onclick' => "return verify( );"), + 'js' => ['onclick' => "return verify( );"], 'subName' => 'new', - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); if ($this->_context == 'standalone') { - $this->addEntityRef('contact_id', ts('Applicant'), array('create' => TRUE), TRUE); + $this->addEntityRef('contact_id', ts('Applicant'), ['create' => TRUE], TRUE); } } @@ -260,7 +260,7 @@ public function postProcess() { } $params['contact_id'] = $this->_contactID; - $ids['note'] = array(); + $ids['note'] = []; if ($this->_noteId) { $ids['note']['id'] = $this->_noteId; } diff --git a/CRM/Grant/Form/GrantView.php b/CRM/Grant/Form/GrantView.php index 4f5fc9f93830..8dbd187efba1 100644 --- a/CRM/Grant/Form/GrantView.php +++ b/CRM/Grant/Form/GrantView.php @@ -50,14 +50,14 @@ public function preProcess() { $context = CRM_Utils_Request::retrieve('context', 'Alphanumeric', $this); $this->assign('context', $context); - $values = array(); + $values = []; $params['id'] = $this->_id; CRM_Grant_BAO_Grant::retrieve($params, $values); $grantType = CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'grant_type_id'); $grantStatus = CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'status_id'); $this->assign('grantType', $grantType[$values['grant_type_id']]); $this->assign('grantStatus', $grantStatus[$values['status_id']]); - $grantTokens = array( + $grantTokens = [ 'amount_total', 'amount_requested', 'amount_granted', @@ -67,7 +67,7 @@ public function preProcess() { 'decision_date', 'money_transfer_date', 'grant_due_date', - ); + ]; foreach ($grantTokens as $token) { $this->assign($token, CRM_Utils_Array::value($token, $values)); @@ -93,7 +93,7 @@ public function preProcess() { $title = CRM_Contact_BAO_Contact::displayName($values['contact_id']) . ' - ' . ts('Grant') . ': ' . CRM_Utils_Money::format($values['amount_total']) . ' (' . $grantType[$values['grant_type_id']] . ')'; - $recentOther = array(); + $recentOther = []; if (CRM_Core_Permission::checkActionPermission('CiviGrant', CRM_Core_Action::UPDATE)) { $recentOther['editUrl'] = CRM_Utils_System::url('civicrm/contact/view/grant', "action=update&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home" @@ -131,14 +131,14 @@ public function preProcess() { * @return void */ public function buildQuickForm() { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'cancel', 'name' => ts('Done'), 'spacing' => '         ', 'isDefault' => TRUE, - ), - ) + ], + ] ); } diff --git a/CRM/Grant/Form/Task.php b/CRM/Grant/Form/Task.php index 26ce02f77bd8..da5458e84918 100644 --- a/CRM/Grant/Form/Task.php +++ b/CRM/Grant/Form/Task.php @@ -61,7 +61,7 @@ public function preProcess() { * @param CRM_Core_Form $form */ public static function preProcessCommon(&$form) { - $form->_grantIds = array(); + $form->_grantIds = []; $values = $form->controller->exportValues('Search'); @@ -72,7 +72,7 @@ public static function preProcessCommon(&$form) { } $form->assign('taskName', $tasks[$form->_task]); - $ids = array(); + $ids = []; if ($values['radio_ts'] == 'ts_sel') { foreach ($values as $name => $value) { if (substr($name, 0, CRM_Core_Form::CB_PREFIX_LEN) == CRM_Core_Form::CB_PREFIX) { @@ -137,17 +137,17 @@ public function setContactIDs() { * @param bool $submitOnce */ public function addDefaultButtons($title, $nextType = 'next', $backType = 'back', $submitOnce = FALSE) { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => $nextType, 'name' => $title, 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => $backType, 'name' => ts('Cancel'), - ), - ) + ], + ] ); } diff --git a/CRM/Grant/Form/Task/Delete.php b/CRM/Grant/Form/Task/Delete.php index 905b59e6ea5a..925da7565f62 100644 --- a/CRM/Grant/Form/Task/Delete.php +++ b/CRM/Grant/Form/Task/Delete.php @@ -90,12 +90,12 @@ public function postProcess() { } if ($deleted) { - $msg = ts('%count grant deleted.', array('plural' => '%count grants deleted.', 'count' => $deleted)); + $msg = ts('%count grant deleted.', ['plural' => '%count grants deleted.', 'count' => $deleted]); CRM_Core_Session::setStatus($msg, ts('Removed'), 'success'); } if ($failed) { - CRM_Core_Session::setStatus(ts('1 could not be deleted.', array('plural' => '%count could not be deleted.', 'count' => $failed)), ts('Error'), 'error'); + CRM_Core_Session::setStatus(ts('1 could not be deleted.', ['plural' => '%count could not be deleted.', 'count' => $failed]), ts('Error'), 'error'); } } diff --git a/CRM/Grant/Form/Task/Print.php b/CRM/Grant/Form/Task/Print.php index 3af6fdae68a0..34d3f2b2413a 100644 --- a/CRM/Grant/Form/Task/Print.php +++ b/CRM/Grant/Form/Task/Print.php @@ -77,18 +77,18 @@ public function buildQuickForm() { // // just need to add a javacript to popup the window for printing // - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => ts('Print Grant List'), - 'js' => array('onclick' => 'window.print()'), + 'js' => ['onclick' => 'window.print()'], 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'back', 'name' => ts('Done'), - ), - ) + ], + ] ); } diff --git a/CRM/Grant/Form/Task/Result.php b/CRM/Grant/Form/Task/Result.php index fb11fe6224e4..5c9f719c100d 100644 --- a/CRM/Grant/Form/Task/Result.php +++ b/CRM/Grant/Form/Task/Result.php @@ -70,13 +70,13 @@ public function preProcess() { * @return void */ public function buildQuickForm() { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'done', 'name' => ts('Done'), 'isDefault' => TRUE, - ), - ) + ], + ] ); } diff --git a/CRM/Grant/Form/Task/SearchTaskHookSample.php b/CRM/Grant/Form/Task/SearchTaskHookSample.php index c6b03d7bde8e..8d448b841234 100644 --- a/CRM/Grant/Form/Task/SearchTaskHookSample.php +++ b/CRM/Grant/Form/Task/SearchTaskHookSample.php @@ -46,7 +46,7 @@ class CRM_Grant_Form_Task_SearchTaskHookSample extends CRM_Grant_Form_Task { */ public function preProcess() { parent::preProcess(); - $rows = array(); + $rows = []; // display name and grant details of all selectced contacts $grantIDs = implode(',', $this->_grantIds); @@ -62,12 +62,12 @@ public function preProcess() { $dao = CRM_Core_DAO::executeQuery($query); while ($dao->fetch()) { - $rows[] = array( + $rows[] = [ 'display_name' => $dao->display_name, 'decision_date' => $dao->decision_date, 'amount_requested' => $dao->amount_total, 'amount_granted' => $dao->amount_granted, - ); + ]; } $this->assign('rows', $rows); } @@ -78,13 +78,13 @@ public function preProcess() { * @return void */ public function buildQuickForm() { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'done', 'name' => ts('Done'), 'isDefault' => TRUE, - ), - ) + ], + ] ); } diff --git a/CRM/Grant/Form/Task/Update.php b/CRM/Grant/Form/Task/Update.php index 283cde0596ec..c1d9b4ad3784 100644 --- a/CRM/Grant/Form/Task/Update.php +++ b/CRM/Grant/Form/Task/Update.php @@ -62,14 +62,14 @@ public function preProcess() { */ public function buildQuickForm() { $grantStatus = CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'status_id'); - $this->addElement('select', 'status_id', ts('Grant Status'), array('' => '') + $grantStatus); + $this->addElement('select', 'status_id', ts('Grant Status'), ['' => ''] + $grantStatus); $this->addElement('text', 'amount_granted', ts('Amount Granted')); $this->addRule('amount_granted', ts('Please enter a valid amount.'), 'money'); $this->add('datepicker', 'decision_date', ts('Grant Decision'), [], FALSE, ['time' => FALSE]); - $this->assign('elements', array('status_id', 'amount_granted', 'decision_date')); + $this->assign('elements', ['status_id', 'amount_granted', 'decision_date']); $this->assign('totalSelectedGrants', count($this->_grantIds)); $this->addDefaultButtons(ts('Update Grants'), 'done'); @@ -105,7 +105,7 @@ public function postProcess() { } } - $status = ts('Updated Grant(s): %1 (Total Selected: %2)', array(1 => $updatedGrants, 2 => count($this->_grantIds))); + $status = ts('Updated Grant(s): %1 (Total Selected: %2)', [1 => $updatedGrants, 2 => count($this->_grantIds)]); CRM_Core_Session::setStatus($status, '', 'info'); CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/grant/search', 'force=1&qfKey=' . $qfKey)); } diff --git a/CRM/Grant/Info.php b/CRM/Grant/Info.php index ba61b19666fb..b947cbd5c7b8 100644 --- a/CRM/Grant/Info.php +++ b/CRM/Grant/Info.php @@ -47,14 +47,14 @@ class CRM_Grant_Info extends CRM_Core_Component_Info { * @return array */ public function getInfo() { - return array( + return [ 'name' => 'CiviGrant', 'translatedName' => ts('CiviGrant'), 'title' => 'CiviCRM Grant Management Engine', 'path' => 'CRM_Grant_', 'search' => 1, 'showActivitiesInCore' => 1, - ); + ]; } @@ -67,20 +67,20 @@ public function getInfo() { * @return array */ public function getPermissions($getAllUnconditionally = FALSE, $descriptions = FALSE) { - $permissions = array( - 'access CiviGrant' => array( + $permissions = [ + 'access CiviGrant' => [ ts('access CiviGrant'), ts('View all grants'), - ), - 'edit grants' => array( + ], + 'edit grants' => [ ts('edit grants'), ts('Create and update grants'), - ), - 'delete in CiviGrant' => array( + ], + 'delete in CiviGrant' => [ ts('delete in CiviGrant'), ts('Delete grants'), - ), - ); + ], + ]; if (!$descriptions) { foreach ($permissions as $name => $attr) { @@ -114,11 +114,11 @@ public function getUserDashboardObject() { * @return array */ public function registerTab() { - return array( + return [ 'title' => ts('Grants'), 'url' => 'grant', 'weight' => 60, - ); + ]; } /** @@ -134,10 +134,10 @@ public function getIcon() { * @return array */ public function registerAdvancedSearchPane() { - return array( + return [ 'title' => ts('Grants'), 'weight' => 50, - ); + ]; } /** @@ -156,14 +156,14 @@ public function creatNewShortcut(&$shortCuts) { if (CRM_Core_Permission::check('access CiviGrant') && CRM_Core_Permission::check('edit grants') ) { - $shortCuts = array_merge($shortCuts, array( - array( + $shortCuts = array_merge($shortCuts, [ + [ 'path' => 'civicrm/grant/add', 'query' => "reset=1&action=add&context=standalone", 'ref' => 'new-grant', 'title' => ts('Grant'), - ), - )); + ], + ]); } } diff --git a/CRM/Grant/Selector/Search.php b/CRM/Grant/Selector/Search.php index 94c24feab73a..561261cd0959 100644 --- a/CRM/Grant/Selector/Search.php +++ b/CRM/Grant/Selector/Search.php @@ -59,7 +59,7 @@ class CRM_Grant_Selector_Search extends CRM_Core_Selector_Base implements CRM_Co * Properties of contact we're interested in displaying * @var array */ - static $_properties = array( + static $_properties = [ 'contact_id', 'contact_type', 'sort_name', @@ -74,7 +74,7 @@ class CRM_Grant_Selector_Search extends CRM_Core_Selector_Base implements CRM_Co 'grant_application_received_date', 'grant_report_received', 'grant_money_transfer_date', - ); + ]; /** * Are we restricting ourselves to a single contact. @@ -186,30 +186,30 @@ public static function &links($key = NULL) { $extraParams = ($key) ? "&key={$key}" : NULL; if (!(self::$_links)) { - self::$_links = array( - CRM_Core_Action::VIEW => array( + self::$_links = [ + CRM_Core_Action::VIEW => [ 'name' => ts('View'), 'url' => 'civicrm/contact/view/grant', 'qs' => 'reset=1&id=%%id%%&cid=%%cid%%&action=view&context=%%cxt%%&selectedChild=grant' . $extraParams, 'title' => ts('View Grant'), - ), - CRM_Core_Action::UPDATE => array( + ], + CRM_Core_Action::UPDATE => [ 'name' => ts('Edit'), 'url' => 'civicrm/contact/view/grant', 'qs' => 'reset=1&action=update&id=%%id%%&cid=%%cid%%&context=%%cxt%%' . $extraParams, 'title' => ts('Edit Grant'), - ), - ); + ], + ]; if ($cid) { - $delLink = array( - CRM_Core_Action::DELETE => array( + $delLink = [ + CRM_Core_Action::DELETE => [ 'name' => ts('Delete'), 'url' => 'civicrm/contact/view/grant', 'qs' => 'action=delete&reset=1&cid=%%cid%%&id=%%id%%&selectedChild=grant' . $extraParams, 'title' => ts('Delete Grant'), - ), - ); + ], + ]; self::$_links = self::$_links + $delLink; } } @@ -279,10 +279,10 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { ); // process the result of the query - $rows = array(); + $rows = []; //CRM-4418 check for view, edit, delete - $permissions = array(CRM_Core_Permission::VIEW); + $permissions = [CRM_Core_Permission::VIEW]; if (CRM_Core_Permission::check('edit grants')) { $permissions[] = CRM_Core_Permission::EDIT; } @@ -292,7 +292,7 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { $mask = CRM_Core_Action::mask($permissions); while ($result->fetch()) { - $row = array(); + $row = []; // the columns we are interested in foreach (self::$_properties as $property) { if (isset($result->$property)) { @@ -306,11 +306,11 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { $row['action'] = CRM_Core_Action::formLink(self::links($this->_key), $mask, - array( + [ 'id' => $result->grant_id, 'cid' => $result->contact_id, 'cxt' => $this->_context, - ), + ], ts('more'), FALSE, 'grant.selector.row', @@ -348,54 +348,54 @@ public function getQILL() { */ public function &getColumnHeaders($action = NULL, $output = NULL) { if (!isset(self::$_columnHeaders)) { - self::$_columnHeaders = array( - array( + self::$_columnHeaders = [ + [ 'name' => ts('Status'), 'sort' => 'grant_status', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - array( + ], + [ 'name' => ts('Type'), 'sort' => 'grant_type_id', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - array( + ], + [ 'name' => ts('Requested'), 'sort' => 'grant_amount_total', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - array( + ], + [ 'name' => ts('Granted'), 'sort' => 'grant_amount_granted', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - array( + ], + [ 'name' => ts('Application Received'), 'sort' => 'grant_application_received_date', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - array( + ], + [ 'name' => ts('Report Received'), 'sort' => 'grant_report_received', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - array( + ], + [ 'name' => ts('Money Transferred'), 'sort' => 'money_transfer_date', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - array('desc' => ts('Actions')), - ); + ], + ['desc' => ts('Actions')], + ]; if (!$this->_single) { - $pre = array( - array('desc' => ts('Contact Type')), - array( + $pre = [ + ['desc' => ts('Contact Type')], + [ 'name' => ts('Name'), 'sort' => 'sort_name', 'direction' => CRM_Utils_Sort::ASCENDING, - ), - ); + ], + ]; self::$_columnHeaders = array_merge($pre, self::$_columnHeaders); } } diff --git a/CRM/Grant/StateMachine/Search.php b/CRM/Grant/StateMachine/Search.php index dc30689ab4e5..6e5890336684 100644 --- a/CRM/Grant/StateMachine/Search.php +++ b/CRM/Grant/StateMachine/Search.php @@ -50,7 +50,7 @@ class CRM_Grant_StateMachine_Search extends CRM_Core_StateMachine { public function __construct($controller, $action = CRM_Core_Action::NONE) { parent::__construct($controller, $action); - $this->_pages = array(); + $this->_pages = []; $this->_pages['CRM_Grant_Form_Search'] = NULL; list($task, $result) = $this->taskName($controller, 'Search'); diff --git a/CRM/Grant/Task.php b/CRM/Grant/Task.php index 134878629570..e9a14e59c832 100644 --- a/CRM/Grant/Task.php +++ b/CRM/Grant/Task.php @@ -55,31 +55,31 @@ class CRM_Grant_Task extends CRM_Core_Task { */ public static function tasks() { if (!(self::$_tasks)) { - self::$_tasks = array( - self::TASK_DELETE => array( + self::$_tasks = [ + self::TASK_DELETE => [ 'title' => ts('Delete grants'), 'class' => 'CRM_Grant_Form_Task_Delete', 'result' => FALSE, - ), - self::TASK_PRINT => array( + ], + self::TASK_PRINT => [ 'title' => ts('Print selected rows'), 'class' => 'CRM_Grant_Form_Task_Print', 'result' => FALSE, - ), - self::TASK_EXPORT => array( + ], + self::TASK_EXPORT => [ 'title' => ts('Export grants'), - 'class' => array( + 'class' => [ 'CRM_Export_Form_Select', 'CRM_Export_Form_Map', - ), + ], 'result' => FALSE, - ), - self::UPDATE_GRANTS => array( + ], + self::UPDATE_GRANTS => [ 'title' => ts('Update grants'), 'class' => 'CRM_Grant_Form_Task_Update', 'result' => FALSE, - ), - ); + ], + ]; if (!CRM_Core_Permission::check('delete in CiviGrant')) { unset(self::$_tasks[self::TASK_DELETE]); @@ -101,16 +101,16 @@ public static function tasks() { * @return array * set of tasks that are valid for the user */ - public static function permissionedTaskTitles($permission, $params = array()) { + public static function permissionedTaskTitles($permission, $params = []) { if (($permission == CRM_Core_Permission::EDIT) || CRM_Core_Permission::check('edit grants') ) { $tasks = self::taskTitles(); } else { - $tasks = array( + $tasks = [ self::TASK_EXPORT => self::$_tasks[self::TASK_EXPORT]['title'], - ); + ]; //CRM-4418, if (CRM_Core_Permission::check('delete in CiviGrant')) { $tasks[self::TASK_DELETE] = self::$_tasks[self::TASK_DELETE]['title']; diff --git a/CRM/Group/Form/Search.php b/CRM/Group/Form/Search.php index d03fef56970b..8de0d8beaa58 100644 --- a/CRM/Group/Form/Search.php +++ b/CRM/Group/Form/Search.php @@ -44,7 +44,7 @@ public function preProcess() { * @return array */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; $defaults['group_status[1]'] = 1; return $defaults; } @@ -71,10 +71,10 @@ public function buildQuickForm() { ); $this->add('select', 'visibility', ts('Visibility'), - array('' => ts('- any visibility -')) + CRM_Core_SelectValues::ufVisibility(TRUE) + ['' => ts('- any visibility -')] + CRM_Core_SelectValues::ufVisibility(TRUE) ); - $groupStatuses = array(ts('Enabled') => 1, ts('Disabled') => 2); + $groupStatuses = [ts('Enabled') => 1, ts('Disabled') => 2]; $this->addCheckBox('group_status', ts('Status'), $groupStatuses, @@ -88,17 +88,17 @@ public function buildQuickForm() { ts('View Results As'), $componentModes, FALSE, - array('class' => 'crm-select2') + ['class' => 'crm-select2'] ); } - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'refresh', 'name' => ts('Search'), 'isDefault' => TRUE, - ), - )); + ], + ]); parent::buildQuickForm(); $this->assign('suppressForm', TRUE); @@ -108,7 +108,7 @@ public function postProcess() { $params = $this->controller->exportValues($this->_name); $parent = $this->controller->getParent(); if (!empty($params)) { - $fields = array('title', 'created_by', 'group_type', 'visibility', 'active_status', 'inactive_status', 'component_mode'); + $fields = ['title', 'created_by', 'group_type', 'visibility', 'active_status', 'inactive_status', 'component_mode']; foreach ($fields as $field) { if (isset($params[$field]) && !CRM_Utils_System::isNull($params[$field]) diff --git a/CRM/Group/Page/AJAX.php b/CRM/Group/Page/AJAX.php index ba76b3c6fa18..f1bf656f619d 100644 --- a/CRM/Group/Page/AJAX.php +++ b/CRM/Group/Page/AJAX.php @@ -48,8 +48,8 @@ public static function getGroupList() { $groups = CRM_Contact_BAO_Group::getGroupListSelector($params); } else { - $requiredParams = array(); - $optionalParams = array( + $requiredParams = []; + $optionalParams = [ 'title' => 'String', 'created_by' => 'String', 'group_type' => 'String', @@ -59,7 +59,7 @@ public static function getGroupList() { 'parentsOnly' => 'Integer', 'showOrgInfo' => 'Boolean', // Ignore 'parent_id' as that case is handled above - ); + ]; $params = CRM_Core_Page_AJAX::defaultSortAndPagerParams(); $params += CRM_Core_Page_AJAX::validateParams($requiredParams, $optionalParams); diff --git a/CRM/Group/StateMachine.php b/CRM/Group/StateMachine.php index e61b00361819..83e86b2c8a37 100644 --- a/CRM/Group/StateMachine.php +++ b/CRM/Group/StateMachine.php @@ -43,12 +43,12 @@ class CRM_Group_StateMachine extends CRM_Core_StateMachine { public function __construct($controller, $action = CRM_Core_Action::NONE) { parent::__construct($controller, $action); - $this->_pages = array( + $this->_pages = [ 'CRM_Group_Form_Edit' => NULL, 'CRM_Contact_Form_Search_Basic' => NULL, 'CRM_Contact_Form_Task_AddToGroup' => NULL, 'CRM_Contact_Form_Task_Result' => NULL, - ); + ]; $this->addSequentialPages($this->_pages, $action); } diff --git a/CRM/Import/DataSource/CSV.php b/CRM/Import/DataSource/CSV.php index 9d5e460c18c4..d51acd596219 100644 --- a/CRM/Import/DataSource/CSV.php +++ b/CRM/Import/DataSource/CSV.php @@ -41,7 +41,7 @@ class CRM_Import_DataSource_CSV extends CRM_Import_DataSource { * collection of info about this data source */ public function getInfo() { - return array('title' => ts('Comma-Separated Values (CSV)')); + return ['title' => ts('Comma-Separated Values (CSV)')]; } /** @@ -74,10 +74,10 @@ public function buildQuickForm(&$form) { $form->assign('uploadSize', $uploadSize); $form->add('File', 'uploadFile', ts('Import Data File'), 'size=30 maxlength=255', TRUE); $form->setMaxFileSize($uploadFileSize); - $form->addRule('uploadFile', ts('File size should be less than %1 MBytes (%2 bytes)', array( + $form->addRule('uploadFile', ts('File size should be less than %1 MBytes (%2 bytes)', [ 1 => $uploadSize, 2 => $uploadFileSize, - )), 'maxfilesize', $uploadFileSize); + ]), 'maxfilesize', $uploadFileSize); $form->addRule('uploadFile', ts('Input file must be in CSV format'), 'utf8File'); $form->addRule('uploadFile', ts('A valid file must be uploaded.'), 'uploadedfile'); @@ -131,7 +131,7 @@ private static function _CsvToTable( $table = NULL, $fieldSeparator = ',' ) { - $result = array(); + $result = []; $fd = fopen($file, 'r'); if (!$fd) { CRM_Core_Error::fatal("Could not read $file"); @@ -192,7 +192,7 @@ private static function _CsvToTable( } } else { - $columns = array(); + $columns = []; foreach ($firstrow as $i => $_) { $columns[] = "col_$i"; } @@ -239,7 +239,7 @@ private static function _CsvToTable( function($string) { return trim($string, chr(0xC2) . chr(0xA0)); }, $row); - $row = array_map(array('CRM_Core_DAO', 'escapeString'), $row); + $row = array_map(['CRM_Core_DAO', 'escapeString'], $row); $sql .= "('" . implode("', '", $row) . "')"; $count++; diff --git a/CRM/Import/DataSource/SQL.php b/CRM/Import/DataSource/SQL.php index 69bbff1064bb..0017b5c55af3 100644 --- a/CRM/Import/DataSource/SQL.php +++ b/CRM/Import/DataSource/SQL.php @@ -41,10 +41,10 @@ class CRM_Import_DataSource_SQL extends CRM_Import_DataSource { * collection of info about this data source */ public function getInfo() { - return array( + return [ 'title' => ts('SQL Query'), - 'permissions' => array('import SQL datasource'), - ); + 'permissions' => ['import SQL datasource'], + ]; } /** @@ -68,7 +68,7 @@ public function preProcess(&$form) { public function buildQuickForm(&$form) { $form->add('hidden', 'hidden_dataSource', 'CRM_Import_DataSource_SQL'); $form->add('textarea', 'sqlQuery', ts('Specify SQL Query'), 'rows=10 cols=45', TRUE); - $form->addFormRule(array('CRM_Import_DataSource_SQL', 'formRule'), $form); + $form->addFormRule(['CRM_Import_DataSource_SQL', 'formRule'], $form); } /** @@ -79,13 +79,13 @@ public function buildQuickForm(&$form) { * @return array|bool */ public static function formRule($fields, $files, $form) { - $errors = array(); + $errors = []; // Makeshift query validation (case-insensitive regex matching on word boundaries) - $forbidden = array('ALTER', 'CREATE', 'DELETE', 'DESCRIBE', 'DROP', 'SHOW', 'UPDATE', 'information_schema'); + $forbidden = ['ALTER', 'CREATE', 'DELETE', 'DESCRIBE', 'DROP', 'SHOW', 'UPDATE', 'information_schema']; foreach ($forbidden as $pattern) { if (preg_match("/\\b$pattern\\b/i", $fields['sqlQuery'])) { - $errors['sqlQuery'] = ts('The query contains the forbidden %1 command.', array(1 => $pattern)); + $errors['sqlQuery'] = ts('The query contains the forbidden %1 command.', [1 => $pattern]); } } diff --git a/CRM/Import/Form/DataSource.php b/CRM/Import/Form/DataSource.php index 61f8044a99f9..bbce16843453 100644 --- a/CRM/Import/Form/DataSource.php +++ b/CRM/Import/Form/DataSource.php @@ -68,42 +68,42 @@ public function buildQuickForm() { $this->add('File', 'uploadFile', ts('Import Data File'), 'size=30 maxlength=255', TRUE); $this->setMaxFileSize($uploadFileSize); - $this->addRule('uploadFile', ts('File size should be less than %1 MBytes (%2 bytes)', array( + $this->addRule('uploadFile', ts('File size should be less than %1 MBytes (%2 bytes)', [ 1 => $uploadSize, 2 => $uploadFileSize, - )), 'maxfilesize', $uploadFileSize); + ]), 'maxfilesize', $uploadFileSize); $this->addRule('uploadFile', ts('A valid file must be uploaded.'), 'uploadedfile'); $this->addRule('uploadFile', ts('Input file must be in CSV format'), 'utf8File'); $this->addElement('checkbox', 'skipColumnHeader', ts('First row contains column headers')); - $this->add('text', 'fieldSeparator', ts('Import Field Separator'), array('size' => 2), TRUE); - $this->setDefaults(array('fieldSeparator' => $config->fieldSeparator)); + $this->add('text', 'fieldSeparator', ts('Import Field Separator'), ['size' => 2], TRUE); + $this->setDefaults(['fieldSeparator' => $config->fieldSeparator]); $mappingArray = CRM_Core_BAO_Mapping::getCreateMappingValues('Import ' . static::IMPORT_ENTITY); $this->assign('savedMapping', $mappingArray); - $this->add('select', 'savedMapping', ts('Mapping Option'), array('' => ts('- select -')) + $mappingArray); + $this->add('select', 'savedMapping', ts('Mapping Option'), ['' => ts('- select -')] + $mappingArray); if ($loadedMapping = $this->get('loadedMapping')) { $this->assign('loadedMapping', $loadedMapping); - $this->setDefaults(array('savedMapping' => $loadedMapping)); + $this->setDefaults(['savedMapping' => $loadedMapping]); } //build date formats CRM_Core_Form_Date::buildAllowedDateFormats($this); - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'upload', 'name' => ts('Continue'), 'spacing' => '          ', 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); } @@ -112,7 +112,7 @@ public function buildQuickForm() { */ protected function addContactTypeSelector() { //contact types option - $contactOptions = array(); + $contactOptions = []; if (CRM_Contact_BAO_ContactType::isActive('Individual')) { $contactOptions[] = $this->createElement('radio', NULL, NULL, ts('Individual'), CRM_Import_Parser::CONTACT_INDIVIDUAL @@ -133,9 +133,9 @@ protected function addContactTypeSelector() { ts('Contact Type') ); - $this->setDefaults(array( + $this->setDefaults([ 'contactType' => CRM_Import_Parser::CONTACT_INDIVIDUAL, - )); + ]); } /** @@ -168,7 +168,7 @@ protected function submitFileForMapping($parserClassName, $entity = NULL) { $separator = $this->controller->exportValue($this->_name, 'fieldSeparator'); - $mapper = array(); + $mapper = []; $parser = new $parserClassName($mapper); if ($entity) { diff --git a/CRM/Import/Form/Preview.php b/CRM/Import/Form/Preview.php index bed412784b04..4e9dcf71ce41 100644 --- a/CRM/Import/Form/Preview.php +++ b/CRM/Import/Form/Preview.php @@ -51,22 +51,22 @@ public function getTitle() { * Build the form object. */ public function buildQuickForm() { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'back', 'name' => ts('Previous'), - ), - array( + ], + [ 'type' => 'next', 'name' => ts('Import Now'), 'spacing' => '          ', 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); } diff --git a/CRM/Import/Parser.php b/CRM/Import/Parser.php index c37bc4daf2c7..70628323096c 100644 --- a/CRM/Import/Parser.php +++ b/CRM/Import/Parser.php @@ -273,7 +273,7 @@ public function setActiveFieldValues($elements, &$erroneousField) { * (reference) associative array of name/value pairs */ public function &getActiveFieldParams() { - $params = array(); + $params = []; for ($i = 0; $i < $this->_activeFieldCount; $i++) { if (isset($this->_activeFields[$i]->_value) && !isset($params[$this->_activeFields[$i]->_name]) @@ -309,7 +309,7 @@ public function progressImport($statusID, $startImport = TRUE, $startTimestamp = if ($startImport) { $status = "

      " . ts('No processing status reported yet.') . "
    "; //do not force the browser to display the save dialog, CRM-7640 - $contents = json_encode(array(0, $status)); + $contents = json_encode([0, $status]); file_put_contents($statusFile, $contents); } else { @@ -331,10 +331,10 @@ public function progressImport($statusID, $startImport = TRUE, $startTimestamp = $timeFormatted .= round($estimatedTime) . ' ' . ts('seconds'); $processedPercent = (int ) (($rowCount * 100) / $totalRowCount); $statusMsg = ts('%1 of %2 records - %3 remaining', - array(1 => $rowCount, 2 => $totalRowCount, 3 => $timeFormatted) + [1 => $rowCount, 2 => $totalRowCount, 3 => $timeFormatted] ); $status = "
      {$statusMsg}
    "; - $contents = json_encode(array($processedPercent, $status)); + $contents = json_encode([$processedPercent, $status]); file_put_contents($statusFile, $contents); return $currTimestamp; @@ -345,7 +345,7 @@ public function progressImport($statusID, $startImport = TRUE, $startTimestamp = * @return array */ public function getSelectValues() { - $values = array(); + $values = []; foreach ($this->_fields as $name => $field) { $values[$name] = $field->_title; } @@ -356,7 +356,7 @@ public function getSelectValues() { * @return array */ public function getSelectTypes() { - $values = array(); + $values = []; foreach ($this->_fields as $name => $field) { if (isset($field->_hasLocationType)) { $values[$name] = $field->_hasLocationType; @@ -369,7 +369,7 @@ public function getSelectTypes() { * @return array */ public function getHeaderPatterns() { - $values = array(); + $values = []; foreach ($this->_fields as $name => $field) { if (isset($field->_headerPattern)) { $values[$name] = $field->_headerPattern; @@ -382,7 +382,7 @@ public function getHeaderPatterns() { * @return array */ public function getDataPatterns() { - $values = array(); + $values = []; foreach ($this->_fields as $name => $field) { $values[$name] = $field->_dataPattern; } diff --git a/CRM/Import/StateMachine.php b/CRM/Import/StateMachine.php index 17329b8f2872..2f213198db61 100644 --- a/CRM/Import/StateMachine.php +++ b/CRM/Import/StateMachine.php @@ -46,12 +46,12 @@ public function __construct($controller, $action = CRM_Core_Action::NONE) { parent::__construct($controller, $action); $classType = str_replace('_Controller', '', get_class($controller)); - $this->_pages = array( + $this->_pages = [ $classType . '_Form_DataSource' => NULL, $classType . '_Form_MapField' => NULL, $classType . '_Form_Preview' => NULL, $classType . '_Form_Summary' => NULL, - ); + ]; $this->addSequentialPages($this->_pages, $action); } diff --git a/CRM/Logging/Differ.php b/CRM/Logging/Differ.php index 18d84739707a..59e1330c37f9 100644 --- a/CRM/Logging/Differ.php +++ b/CRM/Logging/Differ.php @@ -59,7 +59,7 @@ public function __construct($log_conn_id, $log_date, $interval = '10 SECOND') { * @return array */ public function diffsInTables($tables) { - $diffs = array(); + $diffs = []; foreach ($tables as $table) { $diff = $this->diffsInTable($table); if (!empty($diff)) { @@ -76,18 +76,18 @@ public function diffsInTables($tables) { * @return array */ public function diffsInTable($table, $contactID = NULL) { - $diffs = array(); + $diffs = []; - $params = array( - 1 => array($this->log_conn_id, 'String'), - ); + $params = [ + 1 => [$this->log_conn_id, 'String'], + ]; $logging = new CRM_Logging_Schema(); $addressCustomTables = $logging->entityCustomDataLogTables('Address'); $contactIdClause = $join = ''; if ($contactID) { - $params[3] = array($contactID, 'Integer'); + $params[3] = [$contactID, 'Integer']; switch ($table) { case 'civicrm_contact': $contactIdClause = "AND id = %3"; @@ -143,7 +143,7 @@ public function diffsInTable($table, $contactID = NULL) { $logDateClause = ''; if ($this->log_date) { - $params[2] = array($this->log_date, 'String'); + $params[2] = [$this->log_date, 'String']; $logDateClause = " AND lt.log_date BETWEEN DATE_SUB(%2, INTERVAL {$this->interval}) AND DATE_ADD(%2, INTERVAL {$this->interval}) "; @@ -172,18 +172,18 @@ public function diffsInTable($table, $contactID = NULL) { * @throws \CRM_Core_Exception */ private function diffsInTableForId($table, $id) { - $diffs = array(); + $diffs = []; - $params = array( - 1 => array($this->log_conn_id, 'String'), - 3 => array($id, 'Integer'), - ); + $params = [ + 1 => [$this->log_conn_id, 'String'], + 3 => [$id, 'Integer'], + ]; // look for all the changes in the given connection that happened less than {$this->interval} s later than log_date to the given id to catch multi-query changes $logDateClause = ""; if ($this->log_date && $this->interval) { $logDateClause = " AND log_date >= %2 AND log_date < DATE_ADD(%2, INTERVAL {$this->interval})"; - $params[2] = array($this->log_date, 'String'); + $params[2] = [$this->log_date, 'String']; } $changedSQL = "SELECT * FROM `{$this->db}`.`log_$table` WHERE log_conn_id = %1 $logDateClause AND id = %3 ORDER BY log_date DESC LIMIT 1"; @@ -212,11 +212,11 @@ private function diffsInTableForId($table, $id) { case 'Insert': // the previous state does not exist - $original = array(); + $original = []; break; case 'Update': - $params[2] = array($changedDAO->log_date, 'String'); + $params[2] = [$changedDAO->log_date, 'String']; // look for the previous state (different log_conn_id) of the given id $originalSQL = "SELECT * FROM `{$this->db}`.`log_$table` WHERE log_conn_id != %1 AND log_date < %2 AND id = %3 ORDER BY log_date DESC LIMIT 1"; $original = $this->sqlToArray($originalSQL, $params); @@ -230,7 +230,7 @@ private function diffsInTableForId($table, $id) { } // populate $diffs with only the differences between $changed and $original - $skipped = array('log_action', 'log_conn_id', 'log_date', 'log_user_id'); + $skipped = ['log_action', 'log_conn_id', 'log_date', 'log_user_id']; foreach (array_keys(array_diff_assoc($changed, $original)) as $diff) { if (in_array($diff, $skipped)) { continue; @@ -243,7 +243,7 @@ private function diffsInTableForId($table, $id) { // hack: case_type_id column is a varchar with separator. For proper mapping to type labels, // we need to make sure separators are trimmed if ($diff == 'case_type_id') { - foreach (array('original', 'changed') as $var) { + foreach (['original', 'changed'] as $var) { if (!empty(${$var[$diff]})) { $holder =& $$var; $val = explode(CRM_Case_BAO_Case::VALUE_SEPARATOR, $holder[$diff]); @@ -252,7 +252,7 @@ private function diffsInTableForId($table, $id) { } } - $diffs[] = array( + $diffs[] = [ 'action' => $changed['log_action'], 'id' => $id, 'field' => $diff, @@ -261,7 +261,7 @@ private function diffsInTableForId($table, $id) { 'table' => $table, 'log_date' => $changed['log_date'], 'log_conn_id' => $changed['log_conn_id'], - ); + ]; } } @@ -280,15 +280,15 @@ private function diffsInTableForId($table, $id) { */ public function titlesAndValuesForTable($table, $referenceDate) { // static caches for subsequent calls with the same $table - static $titles = array(); - static $values = array(); + static $titles = []; + static $values = []; if (!isset($titles[$table]) or !isset($values[$table])) { if (($tableDAO = CRM_Core_DAO_AllCoreTables::getClassForTable($table)) != FALSE) { // FIXME: these should be populated with pseudo constants as they // were at the time of logging rather than their current values // FIXME: Use *_BAO:buildOptions() method rather than pseudoconstants & fetch programmatically - $values[$table] = array( + $values[$table] = [ 'contribution_page_id' => CRM_Contribute_PseudoConstant::contributionPage(), 'contribution_status_id' => CRM_Contribute_PseudoConstant::contributionStatus(), 'financial_type_id' => CRM_Contribute_PseudoConstant::financialType(), @@ -307,7 +307,7 @@ public function titlesAndValuesForTable($table, $referenceDate) { 'activity_type_id' => CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE), 'case_type_id' => CRM_Case_PseudoConstant::caseType('title', FALSE), 'priority_id' => CRM_Core_PseudoConstant::get('CRM_Activity_DAO_Activity', 'priority_id'), - ); + ]; // for columns that appear in more than 1 table switch ($table) { @@ -325,7 +325,7 @@ public function titlesAndValuesForTable($table, $referenceDate) { $titles[$table][$field['name']] = CRM_Utils_Array::value('title', $field); if ($field['type'] == CRM_Utils_Type::T_BOOLEAN) { - $values[$table][$field['name']] = array('0' => ts('false'), '1' => ts('true')); + $values[$table][$field['name']] = ['0' => ts('false'), '1' => ts('true')]; } } } @@ -333,11 +333,11 @@ public function titlesAndValuesForTable($table, $referenceDate) { list($titles[$table], $values[$table]) = $this->titlesAndValuesForCustomDataTable($table, $referenceDate); } else { - $titles[$table] = $values[$table] = array(); + $titles[$table] = $values[$table] = []; } } - return array($titles[$table], $values[$table]); + return [$titles[$table], $values[$table]]; } /** @@ -361,20 +361,20 @@ private function sqlToArray($sql, $params) { * @return array */ private function titlesAndValuesForCustomDataTable($table, $referenceDate) { - $titles = array(); - $values = array(); + $titles = []; + $values = []; - $params = array( - 1 => array($this->log_conn_id, 'String'), - 2 => array($referenceDate, 'String'), - 3 => array($table, 'String'), - ); + $params = [ + 1 => [$this->log_conn_id, 'String'], + 2 => [$referenceDate, 'String'], + 3 => [$table, 'String'], + ]; $sql = "SELECT id, title FROM `{$this->db}`.log_civicrm_custom_group WHERE log_date <= %2 AND table_name = %3 ORDER BY log_date DESC LIMIT 1"; $cgDao = CRM_Core_DAO::executeQuery($sql, $params); $cgDao->fetch(); - $params[3] = array($cgDao->id, 'Integer'); + $params[3] = [$cgDao->id, 'Integer']; $sql = " SELECT column_name, data_type, label, name, option_group_id FROM `{$this->db}`.log_civicrm_custom_field @@ -389,13 +389,13 @@ private function titlesAndValuesForCustomDataTable($table, $referenceDate) { switch ($cfDao->data_type) { case 'Boolean': - $values[$cfDao->column_name] = array('0' => ts('false'), '1' => ts('true')); + $values[$cfDao->column_name] = ['0' => ts('false'), '1' => ts('true')]; break; case 'String': - $values[$cfDao->column_name] = array(); + $values[$cfDao->column_name] = []; if (!empty($cfDao->option_group_id)) { - $params[3] = array($cfDao->option_group_id, 'Integer'); + $params[3] = [$cfDao->option_group_id, 'Integer']; $sql = " SELECT label, value FROM `{$this->db}`.log_civicrm_option_value @@ -412,7 +412,7 @@ private function titlesAndValuesForCustomDataTable($table, $referenceDate) { } } - return array($titles, $values); + return [$titles, $values]; } /** @@ -424,7 +424,7 @@ private function titlesAndValuesForCustomDataTable($table, $referenceDate) { * @return array */ public function getAllChangesForConnection($tables) { - $params = array(1 => array($this->log_conn_id, 'String')); + $params = [1 => [$this->log_conn_id, 'String']]; foreach ($tables as $table) { if (empty($sql)) { $sql = " SELECT '{$table}' as table_name, id FROM {$this->db}.log_{$table} WHERE log_conn_id = %1"; @@ -433,7 +433,7 @@ public function getAllChangesForConnection($tables) { $sql .= " UNION SELECT '{$table}' as table_name, id FROM {$this->db}.log_{$table} WHERE log_conn_id = %1"; } } - $diffs = array(); + $diffs = []; $dao = CRM_Core_DAO::executeQuery($sql, $params); while ($dao->fetch()) { if (empty($this->log_date)) { @@ -461,13 +461,13 @@ public function getAllChangesForConnection($tables) { */ public static function checkLogCanBeUsedWithNoLogDate($change_date) { - if (civicrm_api3('Setting', 'getvalue', array('name' => 'logging_all_tables_uniquid', 'group' => 'CiviCRM Preferences'))) { + if (civicrm_api3('Setting', 'getvalue', ['name' => 'logging_all_tables_uniquid', 'group' => 'CiviCRM Preferences'])) { return TRUE; }; - $uniqueDate = civicrm_api3('Setting', 'getvalue', array( + $uniqueDate = civicrm_api3('Setting', 'getvalue', [ 'name' => 'logging_uniqueid_date', 'group' => 'CiviCRM Preferences', - )); + ]); if (strtotime($uniqueDate) <= strtotime($change_date)) { return TRUE; } @@ -492,7 +492,7 @@ private static function filterInterval($interval) { return $interval; } - $units = array('MICROSECOND', 'SECOND', 'MINUTE', 'HOUR', 'DAY', 'WEEK', 'MONTH', 'QUARTER', 'YEAR'); + $units = ['MICROSECOND', 'SECOND', 'MINUTE', 'HOUR', 'DAY', 'WEEK', 'MONTH', 'QUARTER', 'YEAR']; $interval = strtoupper($interval); if (preg_match('/^([0-9]+) ([A-Z]+)$/', $interval, $matches)) { if (in_array($matches[2], $units)) { diff --git a/CRM/Logging/ReportDetail.php b/CRM/Logging/ReportDetail.php index dc985b323f93..3200b4482b68 100644 --- a/CRM/Logging/ReportDetail.php +++ b/CRM/Logging/ReportDetail.php @@ -45,7 +45,7 @@ class CRM_Logging_ReportDetail extends CRM_Report_Form { protected $log_conn_id; protected $log_date; protected $raw; - protected $tables = array(); + protected $tables = []; protected $interval = '10 SECOND'; protected $altered_name; @@ -68,7 +68,7 @@ class CRM_Logging_ReportDetail extends CRM_Report_Form { * * @var array */ - protected $diffs = array(); + protected $diffs = []; /** * Don't display the Add these contacts to Group button. @@ -89,35 +89,35 @@ public function __construct() { parent::__construct(); CRM_Utils_System::resetBreadCrumb(); - $breadcrumb = array( - array( + $breadcrumb = [ + [ 'title' => ts('Home'), 'url' => CRM_Utils_System::url(), - ), - array( + ], + [ 'title' => ts('CiviCRM'), 'url' => CRM_Utils_System::url('civicrm', 'reset=1'), - ), - array( + ], + [ 'title' => ts('View Contact'), 'url' => CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$this->cid}"), - ), - array( + ], + [ 'title' => ts('Search Results'), 'url' => CRM_Utils_System::url('civicrm/contact/search', "force=1"), - ), - ); + ], + ]; CRM_Utils_System::appendBreadCrumb($breadcrumb); if (CRM_Utils_Request::retrieve('revert', 'Boolean')) { $this->revert(); } - $this->_columnHeaders = array( - 'field' => array('title' => ts('Field')), - 'from' => array('title' => ts('Changed From')), - 'to' => array('title' => ts('Changed To')), - ); + $this->_columnHeaders = [ + 'field' => ['title' => ts('Field')], + 'from' => ['title' => ts('Changed From')], + 'to' => ['title' => ts('Changed To')], + ]; } /** @@ -180,17 +180,17 @@ protected function diffsInTable($table) { protected function convertDiffsToRows() { // return early if nothing found if (empty($this->diffs)) { - return array(); + return []; } // populate $rows with only the differences between $changed and $original (skipping certain columns and NULL ↔ empty changes unless raw requested) - $skipped = array('id'); + $skipped = ['id']; foreach ($this->diffs as $diff) { $table = $diff['table']; if (empty($metadata[$table])) { list($metadata[$table]['titles'], $metadata[$table]['values']) = $this->differ->titlesAndValuesForTable($table, $diff['log_date']); } - $values = CRM_Utils_Array::value('values', $metadata[$diff['table']], array()); + $values = CRM_Utils_Array::value('values', $metadata[$diff['table']], []); $titles = $metadata[$diff['table']]['titles']; $field = $diff['field']; $from = $diff['from']; @@ -214,7 +214,7 @@ protected function convertDiffsToRows() { (substr($to, 0, 1) == CRM_Core_DAO::VALUE_SEPARATOR && substr($to, -1, 1) == CRM_Core_DAO::VALUE_SEPARATOR) ) { - $froms = $tos = array(); + $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]); } @@ -242,7 +242,7 @@ protected function convertDiffsToRows() { } } - $rows[] = array('field' => $field . " (id: {$diff['id']})", 'from' => $from, 'to' => $to); + $rows[] = ['field' => $field . " (id: {$diff['id']})", 'from' => $from, 'to' => $to]; } return $rows; @@ -289,7 +289,7 @@ protected function calculateContactDiffs() { */ public function getAllContactChangesForConnection() { if (empty($this->log_conn_id)) { - return array(); + return []; } $this->setDiffer(); try { diff --git a/CRM/Logging/ReportSummary.php b/CRM/Logging/ReportSummary.php index 396c61f34f52..c42f6b3179a1 100644 --- a/CRM/Logging/ReportSummary.php +++ b/CRM/Logging/ReportSummary.php @@ -34,7 +34,7 @@ class CRM_Logging_ReportSummary extends CRM_Report_Form { protected $cid; - protected $_logTables = array(); + protected $_logTables = []; protected $loggingDB; @@ -67,123 +67,123 @@ public function __construct() { // used for redirect back to contact summary $this->cid = CRM_Utils_Request::retrieve('cid', 'Integer'); - $this->_logTables = array( - 'log_civicrm_contact' => array( + $this->_logTables = [ + 'log_civicrm_contact' => [ 'fk' => 'id', - ), - 'log_civicrm_email' => array( + ], + 'log_civicrm_email' => [ 'fk' => 'contact_id', 'log_type' => 'Contact', - ), - 'log_civicrm_phone' => array( + ], + 'log_civicrm_phone' => [ 'fk' => 'contact_id', 'log_type' => 'Contact', - ), - 'log_civicrm_address' => array( + ], + 'log_civicrm_address' => [ 'fk' => 'contact_id', 'log_type' => 'Contact', - ), - 'log_civicrm_note' => array( + ], + 'log_civicrm_note' => [ 'fk' => 'entity_id', 'entity_table' => TRUE, - 'bracket_info' => array( + 'bracket_info' => [ 'table' => 'log_civicrm_note', 'column' => 'subject', - ), - ), - 'log_civicrm_note_comment' => array( + ], + ], + 'log_civicrm_note_comment' => [ 'fk' => 'entity_id', 'table_name' => 'log_civicrm_note', - 'joins' => array( + 'joins' => [ 'table' => 'log_civicrm_note', 'join' => "entity_log_civireport.entity_id = fk_table.id AND entity_log_civireport.entity_table = 'civicrm_note'", - ), + ], 'entity_table' => TRUE, - 'bracket_info' => array( + 'bracket_info' => [ 'table' => 'log_civicrm_note', 'column' => 'subject', - ), - ), - 'log_civicrm_group_contact' => array( + ], + ], + 'log_civicrm_group_contact' => [ 'fk' => 'contact_id', - 'bracket_info' => array( + 'bracket_info' => [ 'entity_column' => 'group_id', 'table' => 'log_civicrm_group', 'column' => 'title', - ), + ], 'action_column' => 'status', 'log_type' => 'Group', - ), - 'log_civicrm_entity_tag' => array( + ], + 'log_civicrm_entity_tag' => [ 'fk' => 'entity_id', - 'bracket_info' => array( + 'bracket_info' => [ 'entity_column' => 'tag_id', 'table' => 'log_civicrm_tag', 'column' => 'name', - ), + ], 'entity_table' => TRUE, - ), - 'log_civicrm_relationship' => array( + ], + 'log_civicrm_relationship' => [ 'fk' => 'contact_id_a', - 'bracket_info' => array( + 'bracket_info' => [ 'entity_column' => 'relationship_type_id', 'table' => 'log_civicrm_relationship_type', 'column' => 'label_a_b', - ), - ), - 'log_civicrm_activity_contact' => array( + ], + ], + 'log_civicrm_activity_contact' => [ 'fk' => 'contact_id', 'table_name' => 'log_civicrm_activity_contact', 'log_type' => 'Activity', 'field' => 'activity_id', - 'extra_joins' => array( + 'extra_joins' => [ 'table' => 'log_civicrm_activity', 'join' => 'extra_table.id = entity_log_civireport.activity_id', - ), + ], - 'bracket_info' => array( + 'bracket_info' => [ 'entity_column' => 'activity_type_id', 'options' => CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE), 'lookup_table' => 'log_civicrm_activity', - ), - ), - 'log_civicrm_case' => array( + ], + ], + 'log_civicrm_case' => [ 'fk' => 'contact_id', - 'joins' => array( + 'joins' => [ 'table' => 'log_civicrm_case_contact', 'join' => 'entity_log_civireport.id = fk_table.case_id', - ), - 'bracket_info' => array( + ], + 'bracket_info' => [ 'entity_column' => 'case_type_id', 'options' => CRM_Case_BAO_Case::buildOptions('case_type_id', 'search'), - ), - ), - ); + ], + ], + ]; $logging = new CRM_Logging_Schema(); // build _logTables for contact custom tables $customTables = $logging->entityCustomDataLogTables('Contact'); foreach ($customTables as $table) { - $this->_logTables[$table] = array( + $this->_logTables[$table] = [ 'fk' => 'entity_id', 'log_type' => 'Contact', - ); + ]; } // build _logTables for address custom tables $customTables = $logging->entityCustomDataLogTables('Address'); foreach ($customTables as $table) { - $this->_logTables[$table] = array( + $this->_logTables[$table] = [ // For join of fk_table with contact table. 'fk' => 'contact_id', - 'joins' => array( + 'joins' => [ // fk_table 'table' => 'log_civicrm_address', 'join' => 'entity_log_civireport.entity_id = fk_table.id', - ), + ], 'log_type' => 'Contact', - ); + ]; } // Allow log tables to be extended via report hooks. @@ -226,7 +226,7 @@ public function selectClause(&$tableName, $tableKey, &$fieldName, &$field) { public function where() { // reset where clause as its called multiple times, every time insert sql is built. - $this->_whereClauses = array(); + $this->_whereClauses = []; parent::where(); $this->_where .= " AND (entity_log_civireport.log_action != 'Initialization')"; @@ -268,13 +268,13 @@ public function getEntityValue($id, $entity, $logDate) { FROM `{$this->loggingDB}`.{$logTable} WHERE log_date <= %1 AND id = %2 ORDER BY log_date DESC LIMIT 1"; - $entityID = CRM_Core_DAO::singleValueQuery($sql, array( - 1 => array( + $entityID = CRM_Core_DAO::singleValueQuery($sql, [ + 1 => [ CRM_Utils_Date::isoToMysql($logDate), 'Timestamp', - ), - 2 => array($id, 'Integer'), - )); + ], + 2 => [$id, 'Integer'], + ]); } else { $entityID = $id; @@ -287,10 +287,10 @@ public function getEntityValue($id, $entity, $logDate) { SELECT {$this->_logTables[$entity]['bracket_info']['column']} FROM `{$this->loggingDB}`.{$this->_logTables[$entity]['bracket_info']['table']} WHERE log_date <= %1 AND id = %2 ORDER BY log_date DESC LIMIT 1"; - return CRM_Core_DAO::singleValueQuery($sql, array( - 1 => array(CRM_Utils_Date::isoToMysql($logDate), 'Timestamp'), - 2 => array($entityID, 'Integer'), - )); + return CRM_Core_DAO::singleValueQuery($sql, [ + 1 => [CRM_Utils_Date::isoToMysql($logDate), 'Timestamp'], + 2 => [$entityID, 'Integer'], + ]); } else { if (array_key_exists('options', $this->_logTables[$entity]['bracket_info']) && @@ -316,10 +316,10 @@ public function getEntityValue($id, $entity, $logDate) { public function getEntityAction($id, $connId, $entity, $oldAction) { if (!empty($this->_logTables[$entity]['action_column'])) { $sql = "select {$this->_logTables[$entity]['action_column']} from `{$this->loggingDB}`.{$entity} where id = %1 AND log_conn_id = %2"; - $newAction = CRM_Core_DAO::singleValueQuery($sql, array( - 1 => array($id, 'Integer'), - 2 => array($connId, 'String'), - )); + $newAction = CRM_Core_DAO::singleValueQuery($sql, [ + 1 => [$id, 'Integer'], + 2 => [$connId, 'String'], + ]); switch ($entity) { case 'log_civicrm_group_contact': @@ -398,11 +398,11 @@ protected function buildTemporaryTables() { $sql = "SELECT DISTINCT log_type FROM civicrm_temp_civireport_logsummary"; $dao = CRM_Core_DAO::executeQuery($sql); $this->addToDeveloperTab($sql); - $replaceWith = array(); + $replaceWith = []; while ($dao->fetch()) { $type = $this->getLogType($dao->log_type); if (!array_key_exists($type, $replaceWith)) { - $replaceWith[$type] = array(); + $replaceWith[$type] = []; } $replaceWith[$type][] = $dao->log_type; } @@ -455,10 +455,10 @@ public function buildQuery($applyLimit = TRUE) { {$this->_limit} "; $sql = str_replace('modified_contact_civireport.display_name', 'entity_log_civireport.altered_contact', $sql); $sql = str_replace('modified_contact_civireport.id', 'entity_log_civireport.altered_contact_id', $sql); - $sql = str_replace(array( + $sql = str_replace([ 'modified_contact_civireport.', 'altered_by_contact_civireport.', - ), 'entity_log_civireport.', $sql); + ], 'entity_log_civireport.', $sql); return $sql; } diff --git a/CRM/Logging/Reverter.php b/CRM/Logging/Reverter.php index 61d87c6d4a3b..7a1085f24621 100644 --- a/CRM/Logging/Reverter.php +++ b/CRM/Logging/Reverter.php @@ -40,7 +40,7 @@ class CRM_Logging_Reverter { * * @var array */ - private $diffs = array(); + private $diffs = []; /** * Class constructor. @@ -81,24 +81,24 @@ public function setDiffs($diffs) { public function revert() { // get custom data tables, columns and types - $ctypes = array(); + $ctypes = []; $dao = CRM_Core_DAO::executeQuery('SELECT table_name, column_name, data_type FROM civicrm_custom_group cg JOIN civicrm_custom_field cf ON (cf.custom_group_id = cg.id)'); while ($dao->fetch()) { if (!isset($ctypes[$dao->table_name])) { - $ctypes[$dao->table_name] = array('entity_id' => 'Integer'); + $ctypes[$dao->table_name] = ['entity_id' => 'Integer']; } $ctypes[$dao->table_name][$dao->column_name] = $dao->data_type; } $diffs = $this->diffs; - $deletes = array(); - $reverts = array(); + $deletes = []; + $reverts = []; foreach ($diffs as $table => $changes) { foreach ($changes as $change) { switch ($change['action']) { case 'Insert': if (!isset($deletes[$table])) { - $deletes[$table] = array(); + $deletes[$table] = []; } $deletes[$table][] = $change['id']; break; @@ -106,10 +106,10 @@ public function revert() { case 'Delete': case 'Update': if (!isset($reverts[$table])) { - $reverts[$table] = array(); + $reverts[$table] = []; } if (!isset($reverts[$table][$change['id']])) { - $reverts[$table][$change['id']] = array('log_action' => $change['action']); + $reverts[$table][$change['id']] = ['log_action' => $change['action']]; } $reverts[$table][$change['id']][$change['field']] = $change['from']; break; @@ -157,9 +157,9 @@ public function revert() { case in_array($table, array_keys($ctypes)): foreach ($row as $id => $changes) { - $inserts = array('id' => '%1'); - $updates = array(); - $params = array(1 => array($id, 'Integer')); + $inserts = ['id' => '%1']; + $updates = []; + $params = [1 => [$id, 'Integer']]; $counter = 2; foreach ($changes as $field => $value) { // don’t try reverting a field that’s no longer there @@ -184,7 +184,7 @@ public function revert() { $inserts[$field] = "%$counter"; $updates[] = "{$field} = {$fldVal}"; if ($fldVal != 'DEFAULT') { - $params[$counter] = array($value, $ctypes[$table][$field]); + $params[$counter] = [$value, $ctypes[$table][$field]]; } $counter++; } diff --git a/CRM/Logging/Schema.php b/CRM/Logging/Schema.php index c75652fa784c..149d405516f9 100644 --- a/CRM/Logging/Schema.php +++ b/CRM/Logging/Schema.php @@ -31,18 +31,18 @@ * @copyright CiviCRM LLC (c) 2004-2019 */ class CRM_Logging_Schema { - private $logs = array(); - private $tables = array(); + private $logs = []; + private $tables = []; private $db; private $useDBPrefix = TRUE; - private $reports = array( + private $reports = [ 'logging/contact/detail', 'logging/contact/summary', 'logging/contribute/detail', 'logging/contribute/summary', - ); + ]; /** * Columns that should never be subject to logging. @@ -51,10 +51,10 @@ class CRM_Logging_Schema { * * @var array */ - private $exceptions = array( - 'civicrm_job' => array('last_run'), - 'civicrm_group' => array('cache_date', 'refresh_date'), - ); + private $exceptions = [ + 'civicrm_job' => ['last_run'], + 'civicrm_group' => ['cache_date', 'refresh_date'], + ]; /** * Specifications of all log table including @@ -68,7 +68,7 @@ class CRM_Logging_Schema { * * @var array */ - private $logTableSpec = array(); + private $logTableSpec = []; /** * Setting Callback - Validate. @@ -151,8 +151,8 @@ public function __construct() { $this->tables = preg_grep('/^civicrm_mailing_event_/', $this->tables, PREG_GREP_INVERT); // do not log civicrm_mailing_recipients table, CRM-16193 - $this->tables = array_diff($this->tables, array('civicrm_mailing_recipients')); - $this->logTableSpec = array_fill_keys($this->tables, array()); + $this->tables = array_diff($this->tables, ['civicrm_mailing_recipients']); + $this->logTableSpec = array_fill_keys($this->tables, []); foreach ($this->exceptions as $tableName => $fields) { $this->logTableSpec[$tableName]['exceptions'] = $fields; } @@ -198,7 +198,7 @@ public function customDataLogTables() { * @return array */ public function entityCustomDataLogTables($extends) { - $customGroupTables = array(); + $customGroupTables = []; $customGroupDAO = CRM_Core_BAO_CustomGroup::getAllCustomGroupsByBaseEntity($extends); $customGroupDAO->find(); while ($customGroupDAO->fetch()) { @@ -237,7 +237,7 @@ public function dropTriggers($tableName = NULL) { $dao = new CRM_Core_DAO(); if ($tableName) { - $tableNames = array($tableName); + $tableNames = [$tableName]; } else { $tableNames = $this->tables; @@ -308,7 +308,7 @@ public function fixSchemaDifferences($enableLogging = FALSE) { public function updateLogTableSchema() { $updateLogConn = FALSE; foreach ($this->logs as $mainTable => $logTable) { - $alterSql = array(); + $alterSql = []; $tableSpec = $this->logTableSpec[$mainTable]; if (isset($tableSpec['engine']) && strtoupper($tableSpec['engine']) != $this->getEngineForLogTable($logTable)) { $alterSql[] = "ENGINE=" . $tableSpec['engine'] . " " . CRM_Utils_Array::value('engine_config', $tableSpec); @@ -337,7 +337,7 @@ public function updateLogTableSchema() { } } if ($updateLogConn) { - civicrm_api3('Setting', 'create', array('logging_uniqueid_date' => date('Y-m-d H:i:s'))); + civicrm_api3('Setting', 'create', ['logging_uniqueid_date' => date('Y-m-d H:i:s')]); } } @@ -352,7 +352,7 @@ public function getEngineForLogTable($table) { return strtoupper(CRM_Core_DAO::singleValueQuery(" SELECT ENGINE FROM information_schema.tables WHERE TABLE_NAME = %1 AND table_schema = %2 - ", array(1 => array($table, 'String'), 2 => array($this->db, 'String')))); + ", [1 => [$table, 'String'], 2 => [$this->db, 'String']])); } /** @@ -373,7 +373,7 @@ public function getIndexesForTable($table) { FROM information_schema.statistics WHERE table_schema = %2 AND table_name = %1 ", - array(1 => array($table, 'String'), 2 => array($this->db, 'String')) + [1 => [$table, 'String'], 2 => [$this->db, 'String']] ); while ($result->fetch()) { $indexes[] = $result->index_name; @@ -393,7 +393,7 @@ public function getIndexesForTable($table) { * * @return bool */ - public function fixSchemaDifferencesFor($table, $cols = array(), $rebuildTrigger = FALSE) { + public function fixSchemaDifferencesFor($table, $cols = [], $rebuildTrigger = FALSE) { if (empty($table)) { return FALSE; } @@ -408,11 +408,11 @@ public function fixSchemaDifferencesFor($table, $cols = array(), $rebuildTrigger // use the relevant lines from CREATE TABLE to add colums to the log table $create = $this->_getCreateQuery($table); - foreach ((array('ADD', 'MODIFY')) as $alterType) { + foreach ((['ADD', 'MODIFY']) as $alterType) { if (!empty($cols[$alterType])) { foreach ($cols[$alterType] as $col) { $line = $this->_getColumnQuery($col, $create); - CRM_Core_DAO::executeQuery("ALTER TABLE `{$this->db}`.log_$table {$alterType} {$line}", array(), TRUE, NULL, FALSE, FALSE); + CRM_Core_DAO::executeQuery("ALTER TABLE `{$this->db}`.log_$table {$alterType} {$line}", [], TRUE, NULL, FALSE, FALSE); } } } @@ -423,7 +423,7 @@ public function fixSchemaDifferencesFor($table, $cols = array(), $rebuildTrigger foreach ($cols['OBSOLETE'] as $col) { $line = $this->_getColumnQuery($col, $create); // This is just going to make a not null column to nullable - CRM_Core_DAO::executeQuery("ALTER TABLE `{$this->db}`.log_$table MODIFY {$line}", array(), TRUE, NULL, FALSE, FALSE); + CRM_Core_DAO::executeQuery("ALTER TABLE `{$this->db}`.log_$table MODIFY {$line}", [], TRUE, NULL, FALSE, FALSE); } } @@ -442,7 +442,7 @@ public function fixSchemaDifferencesFor($table, $cols = array(), $rebuildTrigger * @return array */ private function _getCreateQuery($table) { - $dao = CRM_Core_DAO::executeQuery("SHOW CREATE TABLE {$table}", array(), TRUE, NULL, FALSE, FALSE); + $dao = CRM_Core_DAO::executeQuery("SHOW CREATE TABLE {$table}", [], TRUE, NULL, FALSE, FALSE); $dao->fetch(); $create = explode("\n", $dao->Create_Table); return $create; @@ -470,7 +470,7 @@ private function _getColumnQuery($col, $createQuery) { * @param bool $rebuildTrigger */ public function fixSchemaDifferencesForAll($rebuildTrigger = FALSE) { - $diffs = array(); + $diffs = []; foreach ($this->tables as $table) { if (empty($this->logs[$table])) { $this->createLogTableFor($table); @@ -515,12 +515,12 @@ public static function fixTimeStampAndNotNullSQL($query) { * Add reports. */ private function addReports() { - $titles = array( + $titles = [ 'logging/contact/detail' => ts('Logging Details'), 'logging/contact/summary' => ts('Contact Logging Report (Summary)'), 'logging/contribute/detail' => ts('Contribution Logging Report (Detail)'), 'logging/contribute/summary' => ts('Contribution Logging Report (Summary)'), - ); + ]; // enable logging templates CRM_Core_DAO::executeQuery(" UPDATE civicrm_option_value @@ -557,9 +557,9 @@ private function columnsOf($table, $force = FALSE) { CRM_Core_TemporaryErrorScope::ignoreException(); $dao = CRM_Core_DAO::executeQuery("SHOW COLUMNS FROM $from", CRM_Core_DAO::$_nullArray, TRUE, NULL, FALSE, FALSE); if (is_a($dao, 'DB_Error')) { - return array(); + return []; } - \Civi::$statics[__CLASS__]['columnsOf'][$table] = array(); + \Civi::$statics[__CLASS__]['columnsOf'][$table] = []; while ($dao->fetch()) { \Civi::$statics[__CLASS__]['columnsOf'][$table][] = CRM_Utils_type::escape($dao->Field, 'MysqlColumnNameOrAlias'); } @@ -577,7 +577,7 @@ private function columnsOf($table, $force = FALSE) { private function columnSpecsOf($table) { static $civiDB = NULL; if (empty(\Civi::$statics[__CLASS__]['columnSpecs'])) { - \Civi::$statics[__CLASS__]['columnSpecs'] = array(); + \Civi::$statics[__CLASS__]['columnSpecs'] = []; } if (empty(\Civi::$statics[__CLASS__]['columnSpecs']) || !isset(\Civi::$statics[__CLASS__]['columnSpecs'][$table])) { if (!$civiDB) { @@ -593,19 +593,19 @@ private function columnSpecsOf($table) { WHERE table_schema IN ('{$this->db}', '{$civiDB}')"; $dao = CRM_Core_DAO::executeQuery($query); if (is_a($dao, 'DB_Error')) { - return array(); + return []; } while ($dao->fetch()) { if (!array_key_exists($dao->TABLE_NAME, \Civi::$statics[__CLASS__]['columnSpecs'])) { - \Civi::$statics[__CLASS__]['columnSpecs'][$dao->TABLE_NAME] = array(); + \Civi::$statics[__CLASS__]['columnSpecs'][$dao->TABLE_NAME] = []; } - \Civi::$statics[__CLASS__]['columnSpecs'][$dao->TABLE_NAME][$dao->COLUMN_NAME] = array( + \Civi::$statics[__CLASS__]['columnSpecs'][$dao->TABLE_NAME][$dao->COLUMN_NAME] = [ 'COLUMN_NAME' => $dao->COLUMN_NAME, 'DATA_TYPE' => $dao->DATA_TYPE, 'IS_NULLABLE' => $dao->IS_NULLABLE, 'COLUMN_DEFAULT' => $dao->COLUMN_DEFAULT, 'EXTRA' => $dao->EXTRA, - ); + ]; if (($first = strpos($dao->COLUMN_TYPE, '(')) != 0) { // this extracts the value between parentheses after the column type. // it could be the column length, i.e. "int(8)", "decimal(20,2)") @@ -639,7 +639,7 @@ public function columnsWithDiffSpecs($civiTable, $logTable) { $civiTableSpecs = $this->columnSpecsOf($civiTable); $logTableSpecs = $this->columnSpecsOf($logTable); - $diff = array('ADD' => array(), 'MODIFY' => array(), 'OBSOLETE' => array()); + $diff = ['ADD' => [], 'MODIFY' => [], 'OBSOLETE' => []]; // columns to be added $diff['ADD'] = array_diff(array_keys($civiTableSpecs), array_keys($logTableSpecs)); // columns to be modified @@ -647,7 +647,7 @@ public function columnsWithDiffSpecs($civiTable, $logTable) { // wasn't deliberately modified by fixTimeStampAndNotNullSQL() method. foreach ($civiTableSpecs as $col => $colSpecs) { if (!isset($logTableSpecs[$col]) || !is_array($logTableSpecs[$col])) { - $logTableSpecs[$col] = array(); + $logTableSpecs[$col] = []; } $specDiff = array_diff($civiTableSpecs[$col], $logTableSpecs[$col]); if (!empty($specDiff) && $col != 'id' && !in_array($col, $diff['ADD'])) { @@ -685,7 +685,7 @@ public function columnsWithDiffSpecs($civiTable, $logTable) { // columns to made obsolete by turning into not-null $oldCols = array_diff(array_keys($logTableSpecs), array_keys($civiTableSpecs)); foreach ($oldCols as $col) { - if (!in_array($col, array('log_date', 'log_conn_id', 'log_user_id', 'log_action')) && + if (!in_array($col, ['log_date', 'log_conn_id', 'log_user_id', 'log_action']) && $logTableSpecs[$col]['IS_NULLABLE'] == 'NO' ) { // if its a column present only in log table, not among those used by log tables for special purpose, and not-null @@ -766,8 +766,8 @@ private function createLogTableFor($table) { $this->tables[] = $table; if (empty($this->logs)) { - civicrm_api3('Setting', 'create', array('logging_uniqueid_date' => date('Y-m-d H:i:s'))); - civicrm_api3('Setting', 'create', array('logging_all_tables_uniquid' => 1)); + civicrm_api3('Setting', 'create', ['logging_uniqueid_date' => date('Y-m-d H:i:s')]); + civicrm_api3('Setting', 'create', ['logging_all_tables_uniquid' => 1]); } $this->logs[$table] = "log_$table"; } @@ -837,7 +837,7 @@ public function getNonStandardTableNameFilterString() { if (empty($nonStandardTableNames)) { return ''; } - $nonStandardTableLogs = array(); + $nonStandardTableLogs = []; foreach ($nonStandardTableNames as $nonStandardTableName) { $nonStandardTableLogs[] = "'log_{$nonStandardTableName}'"; } @@ -865,12 +865,12 @@ public function triggerInfo(&$info, $tableName = NULL, $force = FALSE) { return; } - $insert = array('INSERT'); - $update = array('UPDATE'); - $delete = array('DELETE'); + $insert = ['INSERT']; + $update = ['UPDATE']; + $delete = ['DELETE']; if ($tableName) { - $tableNames = array($tableName); + $tableNames = [$tableName]; } else { $tableNames = $this->tables; @@ -881,9 +881,9 @@ public function triggerInfo(&$info, $tableName = NULL, $force = FALSE) { $columns = $this->columnsOf($table, $force); // only do the change if any data has changed - $cond = array(); + $cond = []; foreach ($columns as $column) { - $tableExceptions = array_key_exists('exceptions', $this->logTableSpec[$table]) ? $this->logTableSpec[$table]['exceptions'] : array(); + $tableExceptions = array_key_exists('exceptions', $this->logTableSpec[$table]) ? $this->logTableSpec[$table]['exceptions'] : []; // ignore modified_date changes $tableExceptions[] = 'modified_date'; // exceptions may be provided with or without backticks @@ -915,7 +915,7 @@ public function triggerInfo(&$info, $tableName = NULL, $force = FALSE) { $sqlStmt .= "NEW.$column, "; $deleteSQL .= "OLD.$column, "; } - if (civicrm_api3('Setting', 'getvalue', array('name' => 'logging_uniqueid_date'))) { + if (civicrm_api3('Setting', 'getvalue', ['name' => 'logging_uniqueid_date'])) { // Note that when connecting directly via mysql @uniqueID may not be set so a fallback is // 'c_' to identify a non-CRM connection + timestamp to the hour + connection_id // If the connection_id is longer than 6 chars it will be truncated. @@ -935,26 +935,26 @@ public function triggerInfo(&$info, $tableName = NULL, $force = FALSE) { $insertSQL .= $sqlStmt; $updateSQL .= $sqlStmt; - $info[] = array( - 'table' => array($table), + $info[] = [ + 'table' => [$table], 'when' => 'AFTER', 'event' => $insert, 'sql' => $insertSQL, - ); + ]; - $info[] = array( - 'table' => array($table), + $info[] = [ + 'table' => [$table], 'when' => 'AFTER', 'event' => $update, 'sql' => $updateSQL, - ); + ]; - $info[] = array( - 'table' => array($table), + $info[] = [ + 'table' => [$table], 'when' => 'AFTER', 'event' => $delete, 'sql' => $deleteSQL, - ); + ]; } } @@ -991,7 +991,7 @@ public function getMissingLogTables() { if ($this->tablesExist()) { return array_diff($this->tables, array_keys($this->logs)); } - return array(); + return []; } } diff --git a/CRM/Mailing/ActionTokens.php b/CRM/Mailing/ActionTokens.php index e8a4c0b11b24..85e893ca4dfd 100644 --- a/CRM/Mailing/ActionTokens.php +++ b/CRM/Mailing/ActionTokens.php @@ -47,7 +47,7 @@ class CRM_Mailing_ActionTokens extends \Civi\Token\AbstractTokenSubscriber { */ public function __construct() { // TODO: Think about supporting dynamic tokens like "{action.subscribe.\d+}" - parent::__construct('action', array( + parent::__construct('action', [ 'subscribeUrl' => ts('Subscribe URL (Action)'), 'forward' => ts('Forward URL (Action)'), 'optOut' => ts('Opt-Out (Action)'), @@ -58,7 +58,7 @@ public function __construct() { 'resubscribe' => ts('Resubscribe (Action)'), 'resubscribeUrl' => ts('Resubscribe URL (Action)'), 'eventQueueId' => ts('Event Queue ID'), - )); + ]); } /** diff --git a/CRM/Mailing/BAO/BouncePattern.php b/CRM/Mailing/BAO/BouncePattern.php index 5a502f6c6234..5a255b5c11f2 100644 --- a/CRM/Mailing/BAO/BouncePattern.php +++ b/CRM/Mailing/BAO/BouncePattern.php @@ -48,7 +48,7 @@ public function __construct() { * Build the static pattern array. */ public static function buildPatterns() { - self::$_patterns = array(); + self::$_patterns = []; $bp = new CRM_Mailing_BAO_BouncePattern(); $bp->find(); @@ -85,18 +85,18 @@ public static function &match(&$message) { foreach (self::$_patterns as $type => $re) { if (preg_match($re, $message, $matches)) { - $bounce = array( + $bounce = [ 'bounce_type_id' => $type, 'bounce_reason' => $message, - ); + ]; return $bounce; } } - $bounce = array( + $bounce = [ 'bounce_type_id' => NULL, 'bounce_reason' => $message, - ); + ]; return $bounce; } diff --git a/CRM/Mailing/BAO/MailingAB.php b/CRM/Mailing/BAO/MailingAB.php index 99646d592a4c..e2ff2fbdbbc5 100644 --- a/CRM/Mailing/BAO/MailingAB.php +++ b/CRM/Mailing/BAO/MailingAB.php @@ -55,7 +55,7 @@ public function __construct() { * @return object * $mailingab The new mailingab object */ - public static function create(&$params, $ids = array()) { + public static function create(&$params, $ids = []) { $transaction = new CRM_Core_Transaction(); $mailingab = self::add($params, $ids); @@ -79,7 +79,7 @@ public static function create(&$params, $ids = array()) { * * @return object */ - public static function add(&$params, $ids = array()) { + public static function add(&$params, $ids = []) { $id = CRM_Utils_Array::value('mailingab_id', $ids, CRM_Utils_Array::value('id', $params)); if ($id) { @@ -126,7 +126,7 @@ public static function del($id) { $dao = new CRM_Mailing_DAO_MailingAB(); $dao->id = $id; if ($dao->find(TRUE)) { - $mailing_ids = array($dao->mailing_id_a, $dao->mailing_id_b, $dao->mailing_id_c); + $mailing_ids = [$dao->mailing_id_a, $dao->mailing_id_b, $dao->mailing_id_c]; $dao->delete(); foreach ($mailing_ids as $mailing_id) { if ($mailing_id) { @@ -153,10 +153,10 @@ public static function distributeRecipients(CRM_Mailing_DAO_MailingAB $dao) { $totalCount = CRM_Mailing_BAO_Recipients::mailingSize($dao->mailing_id_a); $totalSelected = max(1, round(($totalCount * $dao->group_percentage) / 100)); - CRM_Mailing_BAO_Recipients::reassign($dao->mailing_id_a, array( + CRM_Mailing_BAO_Recipients::reassign($dao->mailing_id_a, [ $dao->mailing_id_b => (2 * $totalSelected <= $totalCount) ? $totalSelected : $totalCount - $totalSelected, $dao->mailing_id_c => max(0, $totalCount - $totalSelected - $totalSelected), - )); + ]); } @@ -174,7 +174,7 @@ public static function getABTest($mailingID) { OR ab.mailing_id_b = %1 OR ab.mailing_id_c = %1) GROUP BY ab.id"; - $params = array(1 => array($mailingID, 'Integer')); + $params = [1 => [$mailingID, 'Integer']]; $abTest = CRM_Core_DAO::executeQuery($query, $params); $abTest->fetch(); return $abTest; diff --git a/CRM/Mailing/BAO/MailingComponent.php b/CRM/Mailing/BAO/MailingComponent.php index bd0e8139f3b1..2fa8b553181d 100644 --- a/CRM/Mailing/BAO/MailingComponent.php +++ b/CRM/Mailing/BAO/MailingComponent.php @@ -77,7 +77,7 @@ public static function setIsActive($id, $is_active) { * * @return CRM_Mailing_BAO_MailingComponent */ - public static function add(&$params, $ids = array()) { + public static function add(&$params, $ids = []) { $id = CRM_Utils_Array::value('id', $params, CRM_Utils_Array::value('id', $ids)); $component = new CRM_Mailing_BAO_MailingComponent(); if ($id) { @@ -93,16 +93,16 @@ public static function add(&$params, $ids = array()) { if ($component->is_default) { if (!empty($id)) { $sql = 'UPDATE civicrm_mailing_component SET is_default = 0 WHERE component_type = %1 AND id <> %2'; - $sqlParams = array( - 1 => array($component->component_type, 'String'), - 2 => array($id, 'Positive'), - ); + $sqlParams = [ + 1 => [$component->component_type, 'String'], + 2 => [$id, 'Positive'], + ]; } else { $sql = 'UPDATE civicrm_mailing_component SET is_default = 0 WHERE component_type = %1'; - $sqlParams = array( - 1 => array($component->component_type, 'String'), - ); + $sqlParams = [ + 1 => [$component->component_type, 'String'], + ]; } CRM_Core_DAO::executeQuery($sql, $sqlParams); } diff --git a/CRM/Mailing/BAO/MailingJob.php b/CRM/Mailing/BAO/MailingJob.php index 7c8eefcceaf7..c74785568e56 100644 --- a/CRM/Mailing/BAO/MailingJob.php +++ b/CRM/Mailing/BAO/MailingJob.php @@ -188,12 +188,12 @@ public static function runJobs($testParams = NULL, $mode = NULL) { $mailer = \Civi::service('pear_mail'); } elseif ($mode == 'sms') { - $mailer = CRM_SMS_Provider::singleton(array('mailing_id' => $job->mailing_id)); + $mailer = CRM_SMS_Provider::singleton(['mailing_id' => $job->mailing_id]); } // Compose and deliver each child job if (\CRM_Utils_Constant::value('CIVICRM_FLEXMAILER_HACK_DELIVER')) { - $isComplete = Civi\Core\Resolver::singleton()->call(CIVICRM_FLEXMAILER_HACK_DELIVER, array($job, $mailer, $testParams)); + $isComplete = Civi\Core\Resolver::singleton()->call(CIVICRM_FLEXMAILER_HACK_DELIVER, [$job, $mailer, $testParams]); } else { $isComplete = $job->deliver($mailer, $testParams); @@ -273,7 +273,7 @@ public static function runJobs_post($mode = NULL) { AND j.job_type = 'child' AND j.parent_id = %1 AND j.status <> 'Complete'"; - $params = array(1 => array($job->id, 'Integer')); + $params = [1 => [$job->id, 'Integer']]; $anyChildLeft = CRM_Core_DAO::singleValueQuery($child_job_sql, $params); @@ -399,15 +399,15 @@ public function split_job($offset = 200) { (`mailing_id`, `scheduled_date`, `status`, `job_type`, `parent_id`, `job_offset`, `job_limit`) VALUES (%1, %2, %3, %4, %5, %6, %7) "; - $params = array( - 1 => array($this->mailing_id, 'Integer'), - 2 => array($this->scheduled_date, 'String'), - 3 => array('Scheduled', 'String'), - 4 => array('child', 'String'), - 5 => array($this->id, 'Integer'), - 6 => array(0, 'Integer'), - 7 => array($recipient_count, 'Integer'), - ); + $params = [ + 1 => [$this->mailing_id, 'Integer'], + 2 => [$this->scheduled_date, 'String'], + 3 => ['Scheduled', 'String'], + 4 => ['child', 'String'], + 5 => [$this->id, 'Integer'], + 6 => [0, 'Integer'], + 7 => [$recipient_count, 'Integer'], + ]; // create one child job if the mailing size is less than the offset // probably use a CRM_Mailing_DAO_MailingJob( ); @@ -447,7 +447,7 @@ public function queue($testParams = NULL) { // INSERT INTO ... SELECT FROM .. // the thing we need to figure out is how to generate the hash automatically $now = time(); - $params = array(); + $params = []; $count = 0; while ($recipients->fetch()) { // CRM-18543: there are situations when both the email and phone are null. @@ -463,17 +463,17 @@ public function queue($testParams = NULL) { $recipients->phone_id = "null"; } - $params[] = array( + $params[] = [ $this->id, $recipients->email_id, $recipients->contact_id, $recipients->phone_id, - ); + ]; $count++; if ($count % CRM_Mailing_Config::BULK_MAIL_INSERT_COUNT == 0) { CRM_Mailing_Event_BAO_Queue::bulkCreate($params, $now); $count = 0; - $params = array(); + $params = []; } } @@ -515,7 +515,7 @@ public function deliver(&$mailer, $testParams = NULL) { } $job_date = CRM_Utils_Date::isoToMysql($this->scheduled_date); - $fields = array(); + $fields = []; if (!empty($testParams)) { $mailing->subject = ts('[CiviMail Draft]') . ' ' . $mailing->subject; @@ -548,20 +548,20 @@ public function deliver(&$mailer, $testParams = NULL) { } self::$mailsProcessed++; - $fields[] = array( + $fields[] = [ 'id' => $eq->id, 'hash' => $eq->hash, 'contact_id' => $eq->contact_id, 'email' => $eq->email, 'phone' => $eq->phone, - ); + ]; if (count($fields) == self::MAX_CONTACTS_TO_PROCESS) { $isDelivered = $this->deliverGroup($fields, $mailing, $mailer, $job_date, $attachments); if (!$isDelivered) { $eq->free(); return $isDelivered; } - $fields = array(); + $fields = []; } } @@ -596,7 +596,7 @@ public function deliverGroup(&$fields, &$mailing, &$mailer, &$job_date, &$attach // get the return properties $returnProperties = $mailing->getReturnProperties(); - $params = $targetParams = $deliveredParams = array(); + $params = $targetParams = $deliveredParams = []; $count = 0; $retryGroup = FALSE; @@ -624,7 +624,7 @@ public function deliverGroup(&$fields, &$mailing, &$mailer, &$job_date, &$attach foreach ($fields as $key => $field) { $contactID = $field['contact_id']; if (!array_key_exists($contactID, $details[0])) { - $details[0][$contactID] = array(); + $details[0][$contactID] = []; } // Compose the mailing. @@ -653,7 +653,7 @@ public function deliverGroup(&$fields, &$mailing, &$mailer, &$job_date, &$attach $headers = $message->headers(); if ($mailing->sms_provider_id) { - $provider = CRM_SMS_Provider::singleton(array('mailing_id' => $mailing->id)); + $provider = CRM_SMS_Provider::singleton(['mailing_id' => $mailing->id]); $body = $provider->getMessage($message, $field['contact_id'], $details[0][$contactID]); $headers = $provider->getRecipientDetails($field, $details[0][$contactID]); } @@ -705,11 +705,11 @@ public function deliverGroup(&$fields, &$mailing, &$mailer, &$job_date, &$attach // Register the bounce event. - $params = array( + $params = [ 'event_queue_id' => $field['id'], 'job_id' => $this->id, 'hash' => $field['hash'], - ); + ]; $params = array_merge($params, CRM_Mailing_BAO_BouncePattern::match($result->getMessage()) ); @@ -835,10 +835,10 @@ public static function cancel($mailingId) { AND ( ( job_type IS NULL ) OR job_type <> 'child' ) "; - $params = array(1 => array($mailingId, 'Integer')); + $params = [1 => [$mailingId, 'Integer']]; $job = CRM_Core_DAO::executeQuery($sql, $params); if ($job->fetch() && - in_array($job->status, array('Scheduled', 'Running', 'Paused')) + in_array($job->status, ['Scheduled', 'Running', 'Paused']) ) { self::create(['id' => $job->id, 'end_date' => date('YmdHis'), 'status' => 'Canceled']); @@ -853,10 +853,10 @@ public static function cancel($mailingId) { AND job_type = 'child' AND status IN ( 'Scheduled', 'Running', 'Paused' ) "; - $params = array( - 1 => array($job->id, 'Integer'), - 2 => array(date('YmdHis'), 'Timestamp'), - ); + $params = [ + 1 => [$job->id, 'Integer'], + 2 => [date('YmdHis'), 'Timestamp'], + ]; CRM_Core_DAO::executeQuery($sql, $params); } } @@ -875,7 +875,7 @@ public static function pause($mailingID) { AND is_test = 0 AND status IN ('Scheduled', 'Running') "; - CRM_Core_DAO::executeQuery($sql, array(1 => array($mailingID, 'Integer'))); + CRM_Core_DAO::executeQuery($sql, [1 => [$mailingID, 'Integer']]); } /** @@ -893,7 +893,7 @@ public static function resume($mailingID) { AND start_date IS NULL AND status = 'Paused' "; - CRM_Core_DAO::executeQuery($sql, array(1 => array($mailingID, 'Integer'))); + CRM_Core_DAO::executeQuery($sql, [1 => [$mailingID, 'Integer']]); $sql = " UPDATE civicrm_mailing_job @@ -903,7 +903,7 @@ public static function resume($mailingID) { AND start_date IS NOT NULL AND status = 'Paused' "; - CRM_Core_DAO::executeQuery($sql, array(1 => array($mailingID, 'Integer'))); + CRM_Core_DAO::executeQuery($sql, [1 => [$mailingID, 'Integer']]); } /** @@ -919,13 +919,13 @@ public static function status($status) { static $translation = NULL; if (empty($translation)) { - $translation = array( + $translation = [ 'Scheduled' => ts('Scheduled'), 'Running' => ts('Running'), 'Complete' => ts('Complete'), 'Paused' => ts('Paused'), 'Canceled' => ts('Canceled'), - ); + ]; } return CRM_Utils_Array::value($status, $translation, ts('Not scheduled')); } @@ -970,7 +970,7 @@ public function writeToDB( if (!empty($deliveredParams)) { CRM_Mailing_Event_BAO_Delivered::bulkCreate($deliveredParams); - $deliveredParams = array(); + $deliveredParams = []; } if ($writeActivity === NULL) { @@ -997,7 +997,7 @@ public function writeToDB( } } - $activity = array( + $activity = [ 'source_contact_id' => $mailing->scheduled_id, // CRM-9519 'target_contact_id' => array_unique($targetParams), @@ -1008,7 +1008,7 @@ public function writeToDB( 'status_id' => 2, 'deleteActivityTarget' => FALSE, 'campaign_id' => $mailing->campaign_id, - ); + ]; //check whether activity is already created for this mailing. //if yes then create only target contact record. @@ -1019,10 +1019,10 @@ public function writeToDB( AND civicrm_activity.source_record_id = %2 "; - $queryParams = array( - 1 => array($activityTypeID, 'Integer'), - 2 => array($this->mailing_id, 'Integer'), - ); + $queryParams = [ + 1 => [$activityTypeID, 'Integer'], + 2 => [$this->mailing_id, 'Integer'], + ]; $activityID = CRM_Core_DAO::singleValueQuery($query, $queryParams); if ($activityID) { @@ -1056,7 +1056,7 @@ public function writeToDB( $result = FALSE; } - $targetParams = array(); + $targetParams = []; } return $result; diff --git a/CRM/Mailing/BAO/Query.php b/CRM/Mailing/BAO/Query.php index 031a1cb22908..329d9b79326d 100644 --- a/CRM/Mailing/BAO/Query.php +++ b/CRM/Mailing/BAO/Query.php @@ -39,12 +39,12 @@ class CRM_Mailing_BAO_Query { */ public static function &getFields() { if (!self::$_mailingFields) { - self::$_mailingFields = array(); - $_mailingFields['mailing_id'] = array( + self::$_mailingFields = []; + $_mailingFields['mailing_id'] = [ 'name' => 'mailing_id', 'title' => ts('Mailing ID'), 'where' => 'civicrm_mailing.id', - ); + ]; } return self::$_mailingFields; } @@ -211,7 +211,7 @@ public static function defaultReturnProperties( $properties = NULL; if ($mode & CRM_Contact_BAO_Query::MODE_MAILING) { - $properties = array( + $properties = [ 'mailing_id' => 1, 'mailing_campaign_id' => 1, 'mailing_name' => 1, @@ -225,7 +225,7 @@ public static function defaultReturnProperties( 'contact_type' => 1, 'contact_sub_type' => 1, 'mailing_recipients_id' => 1, - ); + ]; } return $properties; } @@ -295,7 +295,7 @@ public static function whereClauseSingle(&$values, &$query) { } elseif ($value == 'N') { $options['Y'] = $options['N']; - $values = array($name, $op, 'Y', $grouping, $wildcard); + $values = [$name, $op, 'Y', $grouping, $wildcard]; self::mailingEventQueryBuilder($query, $values, 'civicrm_mailing_event_bounce', 'mailing_delivery_status', @@ -307,15 +307,15 @@ public static function whereClauseSingle(&$values, &$query) { case 'mailing_bounce_types': $op = 'IN'; - $values = array($name, $op, $value, $grouping, $wildcard); + $values = [$name, $op, $value, $grouping, $wildcard]; self::mailingEventQueryBuilder($query, $values, 'civicrm_mailing_event_bounce', 'bounce_type_id', ts('Bounce type(s)'), - CRM_Core_PseudoConstant::get('CRM_Mailing_Event_DAO_Bounce', 'bounce_type_id', array( + CRM_Core_PseudoConstant::get('CRM_Mailing_Event_DAO_Bounce', 'bounce_type_id', [ 'keyColumn' => 'id', 'labelColumn' => 'name', - )) + ]) ); return; @@ -338,7 +338,7 @@ public static function whereClauseSingle(&$values, &$query) { return; case 'mailing_optout': - $valueTitle = array(1 => ts('Opt-out Requests')); + $valueTitle = [1 => ts('Opt-out Requests')]; // include opt-out events only $query->_where[$grouping][] = "civicrm_mailing_event_unsubscribe.org_unsubscribe = 1"; self::mailingEventQueryBuilder($query, $values, @@ -348,7 +348,7 @@ public static function whereClauseSingle(&$values, &$query) { return; case 'mailing_unsubscribe': - $valueTitle = array(1 => ts('Unsubscribe Requests')); + $valueTitle = [1 => ts('Unsubscribe Requests')]; // exclude opt-out events $query->_where[$grouping][] = "civicrm_mailing_event_unsubscribe.org_unsubscribe = 0"; self::mailingEventQueryBuilder($query, $values, @@ -358,7 +358,7 @@ public static function whereClauseSingle(&$values, &$query) { return; case 'mailing_forward': - $valueTitle = array('Y' => ts('Forwards')); + $valueTitle = ['Y' => ts('Forwards')]; // since its a checkbox $values[2] = 'Y'; self::mailingEventQueryBuilder($query, $values, @@ -385,7 +385,7 @@ public static function whereClauseSingle(&$values, &$query) { $name = 'campaign_id'; $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_mailing.$name", $op, $value, 'Integer'); list($op, $value) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Mailing_DAO_Mailing', $name, $value, $op); - $query->_qill[$grouping][] = ts('Campaign %1 %2', array(1 => $op, 2 => $value)); + $query->_qill[$grouping][] = ts('Campaign %1 %2', [1 => $op, 2 => $value]); $query->_tables['civicrm_mailing'] = $query->_whereTables['civicrm_mailing'] = 1; $query->_tables['civicrm_mailing_recipients'] = $query->_whereTables['civicrm_mailing_recipients'] = 1; return; @@ -404,36 +404,36 @@ public static function buildSearchForm(&$form) { if (!empty($mailings)) { $form->add('select', 'mailing_id', ts('Mailing Name(s)'), $mailings, FALSE, - array('id' => 'mailing_id', 'multiple' => 'multiple', 'class' => 'crm-select2') + ['id' => 'mailing_id', 'multiple' => 'multiple', 'class' => 'crm-select2'] ); } CRM_Core_Form_Date::buildDateRange($form, 'mailing_date', 1, '_low', '_high', ts('From'), FALSE); $form->addElement('hidden', 'mailing_date_range_error'); - $form->addFormRule(array('CRM_Mailing_BAO_Query', 'formRule'), $form); + $form->addFormRule(['CRM_Mailing_BAO_Query', 'formRule'], $form); - $mailingJobStatuses = array( + $mailingJobStatuses = [ '' => ts('- select -'), 'Complete' => 'Complete', 'Scheduled' => 'Scheduled', 'Running' => 'Running', 'Canceled' => 'Canceled', - ); + ]; $form->addElement('select', 'mailing_job_status', ts('Mailing Job Status'), $mailingJobStatuses, FALSE); $mailingBounceTypes = CRM_Core_PseudoConstant::get( 'CRM_Mailing_Event_DAO_Bounce', 'bounce_type_id', - array('keyColumn' => 'id', 'labelColumn' => 'name') + ['keyColumn' => 'id', 'labelColumn' => 'name'] ); $form->add('select', 'mailing_bounce_types', ts('Bounce Types'), $mailingBounceTypes, FALSE, - array('id' => 'mailing_bounce_types', 'multiple' => 'multiple', 'class' => 'crm-select2') + ['id' => 'mailing_bounce_types', 'multiple' => 'multiple', 'class' => 'crm-select2'] ); // event filters - $form->addRadio('mailing_delivery_status', ts('Delivery Status'), CRM_Mailing_PseudoConstant::yesNoOptions('delivered'), array('allowClear' => TRUE)); - $form->addRadio('mailing_open_status', ts('Trackable Opens'), CRM_Mailing_PseudoConstant::yesNoOptions('open'), array('allowClear' => TRUE)); - $form->addRadio('mailing_click_status', ts('Trackable URLs'), CRM_Mailing_PseudoConstant::yesNoOptions('click'), array('allowClear' => TRUE)); - $form->addRadio('mailing_reply_status', ts('Trackable Replies'), CRM_Mailing_PseudoConstant::yesNoOptions('reply'), array('allowClear' => TRUE)); + $form->addRadio('mailing_delivery_status', ts('Delivery Status'), CRM_Mailing_PseudoConstant::yesNoOptions('delivered'), ['allowClear' => TRUE]); + $form->addRadio('mailing_open_status', ts('Trackable Opens'), CRM_Mailing_PseudoConstant::yesNoOptions('open'), ['allowClear' => TRUE]); + $form->addRadio('mailing_click_status', ts('Trackable URLs'), CRM_Mailing_PseudoConstant::yesNoOptions('click'), ['allowClear' => TRUE]); + $form->addRadio('mailing_reply_status', ts('Trackable Replies'), CRM_Mailing_PseudoConstant::yesNoOptions('reply'), ['allowClear' => TRUE]); $form->add('checkbox', 'mailing_unsubscribe', ts('Unsubscribe Requests')); $form->add('checkbox', 'mailing_optout', ts('Opt-out Requests')); @@ -508,7 +508,7 @@ public static function mailingEventQueryBuilder(&$query, &$values, $tableName, $ * @return bool|array */ public static function formRule($fields, $files, $form) { - $errors = array(); + $errors = []; if (empty($fields['mailing_date_high']) || empty($fields['mailing_date_low'])) { return TRUE; diff --git a/CRM/Mailing/BAO/Recipients.php b/CRM/Mailing/BAO/Recipients.php index 356a6271a281..608f83db67f5 100644 --- a/CRM/Mailing/BAO/Recipients.php +++ b/CRM/Mailing/BAO/Recipients.php @@ -50,7 +50,7 @@ public static function mailingSize($mailingID) { FROM civicrm_mailing_recipients WHERE mailing_id = %1 "; - $params = array(1 => array($mailingID, 'Integer')); + $params = [1 => [$mailingID, 'Integer']]; return CRM_Core_DAO::singleValueQuery($sql, $params); } @@ -79,7 +79,7 @@ public static function mailingQuery( WHERE mailing_id = %1 $limitString "; - $params = array(1 => array($mailingID, 'Integer')); + $params = [1 => [$mailingID, 'Integer']]; return CRM_Core_DAO::executeQuery($sql, $params); } diff --git a/CRM/Mailing/BAO/Spool.php b/CRM/Mailing/BAO/Spool.php index 43f962cf9b90..26eb8d3ea3a9 100644 --- a/CRM/Mailing/BAO/Spool.php +++ b/CRM/Mailing/BAO/Spool.php @@ -60,7 +60,7 @@ public function __construct() { * true if successful */ public function send($recipient, $headers, $body, $job_id = NULL) { - $headerStr = array(); + $headerStr = []; foreach ($headers as $name => $value) { $headerStr[] = "$name: $value"; } @@ -70,7 +70,7 @@ public function send($recipient, $headers, $body, $job_id = NULL) { // This is not a bulk mailing. Create a dummy job for it. $session = CRM_Core_Session::singleton(); - $params = array(); + $params = []; $params['created_id'] = $session->get('userID'); $params['created_date'] = date('YmdHis'); $params['scheduled_id'] = $params['created_id']; @@ -80,7 +80,7 @@ public function send($recipient, $headers, $body, $job_id = NULL) { $params['body_html'] = htmlspecialchars($headerStr) . "\n\n" . $body; $params['subject'] = $headers['Subject']; $params['name'] = $headers['Subject']; - $ids = array(); + $ids = []; $mailing = CRM_Mailing_BAO_Mailing::create($params, $ids); if (empty($mailing) || is_a($mailing, 'CRM_Core_Error')) { @@ -116,14 +116,14 @@ public function send($recipient, $headers, $body, $job_id = NULL) { $session = CRM_Core_Session::singleton(); - $params = array( + $params = [ 'job_id' => $job_id, 'recipient_email' => $recipient, 'headers' => $headerStr, 'body' => $body, 'added_at' => date("YmdHis"), 'removed_at' => NULL, - ); + ]; $spoolMail = new CRM_Mailing_DAO_Spool(); $spoolMail->copyValues($params); diff --git a/CRM/Mailing/BAO/TrackableURL.php b/CRM/Mailing/BAO/TrackableURL.php index 0c087ae8efe4..6c5b6590f2d9 100644 --- a/CRM/Mailing/BAO/TrackableURL.php +++ b/CRM/Mailing/BAO/TrackableURL.php @@ -55,7 +55,7 @@ public function __construct() { */ public static function getTrackerURL($url, $mailing_id, $queue_id) { - static $urlCache = array(); + static $urlCache = []; if (array_key_exists($mailing_id . $url, $urlCache)) { return $urlCache[$mailing_id . $url] . "&qid=$queue_id"; diff --git a/CRM/Mailing/Controller/Send.php b/CRM/Mailing/Controller/Send.php index d62d1fe715e0..4681c6d283e7 100644 --- a/CRM/Mailing/Controller/Send.php +++ b/CRM/Mailing/Controller/Send.php @@ -64,7 +64,7 @@ public function __construct($title = NULL, $action = CRM_Core_Action::NONE, $mod CRM_Utils_System::redirect($redirect); } if ($mid && !$continue) { - $clone = civicrm_api3('Mailing', 'clone', array('id' => $mid)); + $clone = civicrm_api3('Mailing', 'clone', ['id' => $mid]); CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/a/', NULL, TRUE, '/mailing/' . $clone['id'])); } } diff --git a/CRM/Mailing/Event/BAO/Confirm.php b/CRM/Mailing/Event/BAO/Confirm.php index 5de98c8c3c30..16b974429a9e 100644 --- a/CRM/Mailing/Event/BAO/Confirm.php +++ b/CRM/Mailing/Event/BAO/Confirm.php @@ -91,7 +91,7 @@ public static function confirm($contact_id, $subscribe_id, $hash) { $ce->save(); CRM_Contact_BAO_GroupContact::addContactsToGroup( - array($contact_id), + [$contact_id], $se->group_id, 'Email', 'Added', @@ -138,7 +138,7 @@ public static function confirm($contact_id, $subscribe_id, $hash) { $text = CRM_Utils_Token::replaceDomainTokens($text, $domain, FALSE, $tokens['text']); $text = CRM_Utils_Token::replaceWelcomeTokens($text, $group->title, FALSE); - $mailParams = array( + $mailParams = [ 'groupName' => 'Mailing Event ' . $component->component_type, 'subject' => $component->subject, 'from' => "\"$domainEmailName\" <" . CRM_Core_BAO_Domain::getNoReplyEmailAddress() . '>', @@ -148,7 +148,7 @@ public static function confirm($contact_id, $subscribe_id, $hash) { 'returnPath' => CRM_Core_BAO_Domain::getNoReplyEmailAddress(), 'html' => $html, 'text' => $text, - ); + ]; // send - ignore errors because the desired status change has already been successful $unused_result = CRM_Utils_Mail::send($mailParams); diff --git a/CRM/Mailing/Event/BAO/Delivered.php b/CRM/Mailing/Event/BAO/Delivered.php index 62f6cbc811f3..706a65d2151e 100644 --- a/CRM/Mailing/Event/BAO/Delivered.php +++ b/CRM/Mailing/Event/BAO/Delivered.php @@ -225,18 +225,18 @@ public static function &getRows( $dao->query($query); - $results = array(); + $results = []; while ($dao->fetch()) { $url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$dao->contact_id}" ); - $results[$dao->id] = array( + $results[$dao->id] = [ 'contact_id' => $dao->contact_id, 'name' => "{$dao->display_name}", 'email' => $dao->email, 'date' => CRM_Utils_Date::customFormat($dao->date), - ); + ]; } return $results; } @@ -251,7 +251,7 @@ public static function bulkCreate($eventQueueIDs, $time = NULL) { } // construct a bulk insert statement - $values = array(); + $values = []; foreach ($eventQueueIDs as $eqID) { $values[] = "( $eqID, '{$time}' )"; } diff --git a/CRM/Mailing/Event/BAO/Forward.php b/CRM/Mailing/Event/BAO/Forward.php index 1d1589a08377..8d8532ea8da7 100644 --- a/CRM/Mailing/Event/BAO/Forward.php +++ b/CRM/Mailing/Event/BAO/Forward.php @@ -105,25 +105,25 @@ public static function &forward($job_id, $queue_id, $hash, $forward_email, $from } require_once 'api/api.php'; - $contactParams = array( + $contactParams = [ 'email' => $forward_email, 'version' => 3, - ); + ]; $contactValues = civicrm_api('contact', 'get', $contactParams); $count = $contactValues['count']; if ($count == 0) { // If the contact does not exist, create one. - $formatted = array( + $formatted = [ 'contact_type' => 'Individual', 'version' => 3, - ); + ]; $locationType = CRM_Core_BAO_LocationType::getDefault(); - $value = array( + $value = [ 'email' => $forward_email, 'location_type_id' => $locationType->id, - ); + ]; require_once 'CRM/Utils/DeprecatedUtils.php'; _civicrm_api3_deprecated_add_formatted_param($value, $formatted); $formatted['onDuplicate'] = CRM_Import_Parser::DUPLICATE_SKIP; @@ -144,11 +144,11 @@ public static function &forward($job_id, $queue_id, $hash, $forward_email, $from // Create a new queue event. - $queue_params = array( + $queue_params = [ 'email_id' => $email_id, 'contact_id' => $contact_id, 'job_id' => $job_id, - ); + ]; $queue = CRM_Mailing_Event_BAO_Queue::create($queue_params); @@ -195,11 +195,11 @@ public static function &forward($job_id, $queue_id, $hash, $forward_email, $from unset($errorScope); } - $params = array( + $params = [ 'event_queue_id' => $queue->id, 'job_id' => $job_id, 'hash' => $queue->hash, - ); + ]; if (is_a($result, 'PEAR_Error')) { // Register the bounce event. @@ -362,7 +362,7 @@ public static function &getRows( $dao->query($query); - $results = array(); + $results = []; while ($dao->fetch()) { $from_url = CRM_Utils_System::url('civicrm/contact/view', @@ -371,12 +371,12 @@ public static function &getRows( $dest_url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$dao->dest_id}" ); - $results[] = array( + $results[] = [ 'from_name' => "{$dao->from_name}", 'from_email' => $dao->from_email, 'dest_email' => "{$dao->dest_email}", 'date' => CRM_Utils_Date::customFormat($dao->date), - ); + ]; } return $results; } diff --git a/CRM/Mailing/Event/BAO/Opened.php b/CRM/Mailing/Event/BAO/Opened.php index 3e88468c4e02..a2a1e01b30ed 100644 --- a/CRM/Mailing/Event/BAO/Opened.php +++ b/CRM/Mailing/Event/BAO/Opened.php @@ -138,7 +138,7 @@ public static function getTotalCount( */ public static function getMailingTotalCount($mailingIDs) { $dao = new CRM_Core_DAO(); - $openedCount = array(); + $openedCount = []; $open = self::getTableName(); $queue = CRM_Mailing_Event_BAO_Queue::getTableName(); @@ -178,7 +178,7 @@ public static function getMailingTotalCount($mailingIDs) { */ public static function getMailingContactCount($mailingIDs, $contactID) { $dao = new CRM_Core_DAO(); - $openedCount = array(); + $openedCount = []; $open = self::getTableName(); $queue = CRM_Mailing_Event_BAO_Queue::getTableName(); @@ -241,12 +241,12 @@ public static function &getRows( $contact = CRM_Contact_BAO_Contact::getTableName(); $email = CRM_Core_BAO_Email::getTableName(); - $selectClauses = array( + $selectClauses = [ "$contact.display_name as display_name", "$contact.id as contact_id", "$email.email as email", ($is_distinct) ? "MIN({$open}.time_stamp) as date" : "{$open}.time_stamp as date", - ); + ]; if ($is_distinct) { $groupBy = " GROUP BY $queue.id "; @@ -306,17 +306,17 @@ public static function &getRows( $dao->query($query); - $results = array(); + $results = []; while ($dao->fetch()) { $url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$dao->contact_id}" ); - $results[] = array( + $results[] = [ 'name' => "{$dao->display_name}", 'email' => $dao->email, 'date' => CRM_Utils_Date::customFormat($dao->date), - ); + ]; } return $results; } diff --git a/CRM/Mailing/Event/BAO/Queue.php b/CRM/Mailing/Event/BAO/Queue.php index 5b68838d0c82..41cefaf8ee45 100644 --- a/CRM/Mailing/Event/BAO/Queue.php +++ b/CRM/Mailing/Event/BAO/Queue.php @@ -236,17 +236,17 @@ public static function &getRows( $dao->query($query); - $results = array(); + $results = []; while ($dao->fetch()) { $url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$dao->contact_id}" ); - $results[$dao->queue_id] = array( + $results[$dao->queue_id] = [ 'name' => "{$dao->display_name}", 'email' => $dao->email, 'date' => CRM_Utils_Date::customFormat($dao->date), - ); + ]; } return $results; } @@ -303,7 +303,7 @@ public static function getContactInfo($queueID) { $email = $dao->email; } - return array($displayName, $email); + return [$displayName, $email]; } /** @@ -316,7 +316,7 @@ public static function bulkCreate($params, $now = NULL) { } // construct a bulk insert statement - $values = array(); + $values = []; foreach ($params as $param) { $values[] = "( {$param[0]}, {$param[1]}, {$param[2]}, {$param[3]}, '" . substr(sha1("{$param[0]}:{$param[1]}:{$param[2]}:{$param[3]}:{$now}"), 0, 16 diff --git a/CRM/Mailing/Event/BAO/Reply.php b/CRM/Mailing/Event/BAO/Reply.php index 3bfc00710406..03a54c9431e6 100644 --- a/CRM/Mailing/Event/BAO/Reply.php +++ b/CRM/Mailing/Event/BAO/Reply.php @@ -118,7 +118,7 @@ public static function send($queue_id, &$mailing, &$bodyTxt, $replyto, &$bodyHTM $queue = CRM_Mailing_Event_BAO_Queue::getTableName(); $contacts = CRM_Contact_BAO_Contact::getTableName(); $domain_id = CRM_Core_Config::domainID(); - $domainValues = civicrm_api3('Domain', 'get', array('sequential' => 1, 'id' => $domain_id)); + $domainValues = civicrm_api3('Domain', 'get', ['sequential' => 1, 'id' => $domain_id]); $fromEmail = CRM_Core_BAO_Domain::getNoReplyEmailAddress(); $eq = new CRM_Core_DAO(); @@ -140,7 +140,7 @@ public static function send($queue_id, &$mailing, &$bodyTxt, $replyto, &$bodyHTM $parser = new ezcMailParser(); $set = new ezcMailVariableSet($fullEmail); $parsed = array_shift($parser->parseMail($set)); - $parsed->to = array(new ezcMailAddress($mailing->replyto_email)); + $parsed->to = [new ezcMailAddress($mailing->replyto_email)]; // CRM-5567: we need to set Reply-To: so that any response // to the forward goes to the sender of the reply @@ -167,7 +167,7 @@ public static function send($queue_id, &$mailing, &$bodyTxt, $replyto, &$bodyHTM // the body and make the boundary in the header match it $ct = $h['Content-Type']; if (substr_count($ct, 'boundary=')) { - $matches = array(); + $matches = []; preg_match('/^--(.*)$/m', $b, $matches); $boundary = rtrim($matches[1]); $parts = explode('boundary=', $ct); @@ -179,7 +179,7 @@ public static function send($queue_id, &$mailing, &$bodyTxt, $replyto, &$bodyHTM $message = new Mail_mime("\n"); - $headers = array( + $headers = [ 'Subject' => "Re: {$mailing->subject}", 'To' => $mailing->replyto_email, 'From' => "\"$fromName\" <$fromEmail>", @@ -188,7 +188,7 @@ public static function send($queue_id, &$mailing, &$bodyTxt, $replyto, &$bodyHTM // CRM-17754 Include re-sent headers to indicate that we have forwarded on the email 'Resent-From' => $domainValues['values'][0]['from_email'], 'Resent-Date' => date('r'), - ); + ]; $message->setTxtBody($bodyTxt); $message->setHTMLBody($bodyHTML); @@ -248,13 +248,13 @@ private static function autoRespond(&$mailing, $queue_id, $replyto) { $domain = CRM_Core_BAO_Domain::getDomain(); list($domainEmailName, $_) = CRM_Core_BAO_Domain::getNameAndEmail(); - $headers = array( + $headers = [ 'Subject' => $component->subject, 'To' => $to, 'From' => "\"$domainEmailName\" <" . CRM_Core_BAO_Domain::getNoReplyEmailAddress() . '>', 'Reply-To' => CRM_Core_BAO_Domain::getNoReplyEmailAddress(), 'Return-Path' => CRM_Core_BAO_Domain::getNoReplyEmailAddress(), - ); + ]; // TODO: do we need reply tokens? $html = $component->body_html; @@ -427,17 +427,17 @@ public static function &getRows( $dao->query($query); - $results = array(); + $results = []; while ($dao->fetch()) { $url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$dao->contact_id}" ); - $results[] = array( + $results[] = [ 'name' => "{$dao->display_name}", 'email' => $dao->email, 'date' => CRM_Utils_Date::customFormat($dao->date), - ); + ]; } return $results; } diff --git a/CRM/Mailing/Event/BAO/Resubscribe.php b/CRM/Mailing/Event/BAO/Resubscribe.php index d37d492f930e..f7b05d127ad1 100644 --- a/CRM/Mailing/Event/BAO/Resubscribe.php +++ b/CRM/Mailing/Event/BAO/Resubscribe.php @@ -101,8 +101,8 @@ public static function &resub_to_mailing($job_id, $queue_id, $hash) { // Make a list of groups and a list of prior mailings that received // this mailing. - $groups = array(); - $mailings = array(); + $groups = []; + $mailings = []; while ($do->fetch()) { if ($do->entity_table == $group) { @@ -123,7 +123,7 @@ public static function &resub_to_mailing($job_id, $queue_id, $hash) { WHERE $mg.mailing_id IN (" . implode(', ', $mailings) . ") AND $mg.group_type = 'Include'"); - $mailings = array(); + $mailings = []; while ($do->fetch()) { if ($do->entity_table == $group) { @@ -157,7 +157,7 @@ public static function &resub_to_mailing($job_id, $queue_id, $hash) { $groups[$do->group_id] = $do->title; } - $contacts = array($contact_id); + $contacts = [$contact_id]; foreach ($groups as $group_id => $group_name) { $notadded = 0; if ($group_name) { @@ -267,13 +267,13 @@ public static function send_resub_response($queue_id, $groups, $is_domain = FALS $message->setTxtBody($text); } - $headers = array( + $headers = [ 'Subject' => $component->subject, 'From' => "\"$domainEmailName\" <" . CRM_Core_BAO_Domain::getNoReplyEmailAddress() . '>', 'To' => $eq->email, 'Reply-To' => CRM_Core_BAO_Domain::getNoReplyEmailAddress(), 'Return-Path' => CRM_Core_BAO_Domain::getNoReplyEmailAddress(), - ); + ]; CRM_Mailing_BAO_Mailing::addMessageIdHeader($headers, 'e', $job, $queue_id, $eq->hash); $b = CRM_Utils_Mail::setMimeParams($message); $h = $message->headers($headers); diff --git a/CRM/Mailing/Event/BAO/Subscribe.php b/CRM/Mailing/Event/BAO/Subscribe.php index 86bf73e7ba64..2df4893a8f57 100644 --- a/CRM/Mailing/Event/BAO/Subscribe.php +++ b/CRM/Mailing/Event/BAO/Subscribe.php @@ -65,8 +65,8 @@ public function __construct() { */ public static function &subscribe($group_id, $email, $contactId = NULL, $context = NULL) { // CRM-1797 - allow subscription only to public groups - $params = array('id' => (int) $group_id); - $defaults = array(); + $params = ['id' => (int) $group_id]; + $defaults = []; $contact_id = NULL; $success = NULL; @@ -91,7 +91,7 @@ public static function &subscribe($group_id, $email, $contactId = NULL, $context LEFT JOIN civicrm_email ON contact_a.id = civicrm_email.contact_id WHERE civicrm_email.email = %1 AND contact_a.is_deleted = 0"; - $params = array(1 => array($email, 'String')); + $params = [1 => [$email, 'String']]; $dao = CRM_Core_DAO::executeQuery($query, $params); // lets just use the first contact id we got if ($dao->fetch()) { @@ -104,11 +104,11 @@ public static function &subscribe($group_id, $email, $contactId = NULL, $context if (!$contact_id) { $locationType = CRM_Core_BAO_LocationType::getDefault(); - $formatted = array( + $formatted = [ 'contact_type' => 'Individual', 'email' => $email, 'location_type_id' => $locationType->id, - ); + ]; $formatted['onDuplicate'] = CRM_Import_Parser::DUPLICATE_SKIP; $formatted['fixAddress'] = TRUE; @@ -131,10 +131,10 @@ public static function &subscribe($group_id, $email, $contactId = NULL, $context FROM civicrm_email WHERE civicrm_email.email = %1 AND civicrm_email.contact_id = %2"; - $params = array( - 1 => array($email, 'String'), - 2 => array($contact_id, 'Integer'), - ); + $params = [ + 1 => [$email, 'String'], + 2 => [$contact_id, 'Integer'], + ]; $dao = CRM_Core_DAO::executeQuery($query, $params); if (!$dao->fetch()) { @@ -151,7 +151,7 @@ public static function &subscribe($group_id, $email, $contactId = NULL, $context ); $se->save(); - $contacts = array($contact_id); + $contacts = [$contact_id]; CRM_Contact_BAO_GroupContact::addContactsToGroup($contacts, $group_id, 'Email', 'Pending', $se->id ); @@ -203,12 +203,12 @@ public function send_confirm_request($email) { $emailDomain = CRM_Core_BAO_MailSettings::defaultDomain(); $confirm = implode($config->verpSeparator, - array( + [ $localpart . 'c', $this->contact_id, $this->id, $this->hash, - ) + ] ) . "@$emailDomain"; $group = new CRM_Contact_BAO_Group(); @@ -222,13 +222,13 @@ public function send_confirm_request($email) { $component->find(TRUE); - $headers = array( + $headers = [ 'Subject' => $component->subject, 'From' => "\"{$domainEmailName}\" <{$domainEmailAddress}>", 'To' => $email, 'Reply-To' => $confirm, 'Return-Path' => CRM_Core_BAO_Domain::getNoReplyEmailAddress(), - ); + ]; $url = CRM_Utils_System::url('civicrm/mailing/confirm', "reset=1&cid={$this->contact_id}&sid={$this->id}&h={$this->hash}", @@ -316,7 +316,7 @@ public static function getContactGroups($email, $contactID = NULL) { LEFT JOIN civicrm_contact ON ( group_a.contact_id = civicrm_contact.id ) WHERE civicrm_contact.id = %1"; - $params = array(1 => array($contactID, 'Integer')); + $params = [1 => [$contactID, 'Integer']]; } else { $strtolower = function_exists('mb_strtolower') ? 'mb_strtolower' : 'strtolower'; @@ -330,17 +330,17 @@ public static function getContactGroups($email, $contactID = NULL) { LEFT JOIN civicrm_email ON civicrm_contact.id = civicrm_email.contact_id WHERE civicrm_email.email = %1"; - $params = array(1 => array($email, 'String')); + $params = [1 => [$email, 'String']]; } $dao = CRM_Core_DAO::executeQuery($query, $params); - $groups = array(); + $groups = []; while ($dao->fetch()) { - $groups[$dao->group_id] = array( + $groups[$dao->group_id] = [ 'id' => $dao->group_id, 'title' => $dao->title, 'status' => $dao->status, - ); + ]; } $dao->free(); @@ -362,7 +362,7 @@ public static function getContactGroups($email, $contactID = NULL) { */ public static function commonSubscribe(&$groups, &$params, $contactId = NULL, $context = NULL) { $contactGroups = CRM_Mailing_Event_BAO_Subscribe::getContactGroups($params['email'], $contactId); - $group = array(); + $group = []; $success = NULL; foreach ($groups as $groupID) { $title = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $groupID, 'title'); @@ -370,10 +370,10 @@ public static function commonSubscribe(&$groups, &$params, $contactId = NULL, $c $group[$groupID]['title'] = $contactGroups[$groupID]['title']; $group[$groupID]['status'] = $contactGroups[$groupID]['status']; - $status = ts('You are already subscribed in %1, your subscription is %2.', array( + $status = ts('You are already subscribed in %1, your subscription is %2.', [ 1 => $group[$groupID]['title'], 2 => ts($group[$groupID]['status']), - )); + ]); CRM_Utils_System::setUFMessage($status); continue; } @@ -395,11 +395,11 @@ public static function commonSubscribe(&$groups, &$params, $contactId = NULL, $c } if ($success) { $groupTitle = implode(', ', $groupAdded); - CRM_Utils_System::setUFMessage(ts('Your subscription request has been submitted for %1. Check your inbox shortly for the confirmation email(s). If you do not see a confirmation email, please check your spam/junk mail folder.', array(1 => $groupTitle))); + CRM_Utils_System::setUFMessage(ts('Your subscription request has been submitted for %1. Check your inbox shortly for the confirmation email(s). If you do not see a confirmation email, please check your spam/junk mail folder.', [1 => $groupTitle])); } elseif ($success === FALSE) { $groupTitle = implode(',', $groupFailed); - CRM_Utils_System::setUFMessage(ts('We had a problem processing your subscription request for %1. You have tried to subscribe to a private group and/or we encountered a database error. Please contact the site administrator.', array(1 => $groupTitle))); + CRM_Utils_System::setUFMessage(ts('We had a problem processing your subscription request for %1. You have tried to subscribe to a private group and/or we encountered a database error. Please contact the site administrator.', [1 => $groupTitle])); } } diff --git a/CRM/Mailing/Event/BAO/TrackableURLOpen.php b/CRM/Mailing/Event/BAO/TrackableURLOpen.php index 4e6709dfc72d..29a907d29afe 100644 --- a/CRM/Mailing/Event/BAO/TrackableURLOpen.php +++ b/CRM/Mailing/Event/BAO/TrackableURLOpen.php @@ -64,9 +64,9 @@ public static function track($queue_id, $url_id) { "SELECT url FROM $turl WHERE $turl.id = %1", - array( - 1 => array($url_id, 'Integer'), - ) + [ + 1 => [$url_id, 'Integer'], + ] ); if (!$search->fetch()) { @@ -82,10 +82,10 @@ public static function track($queue_id, $url_id) { INNER JOIN $job ON $turl.mailing_id = $job.mailing_id INNER JOIN $eq ON $job.id = $eq.job_id WHERE $eq.id = %1 AND $turl.id = %2", - array( - 1 => array($queue_id, 'Integer'), - 2 => array($url_id, 'Integer'), - ) + [ + 1 => [$queue_id, 'Integer'], + 2 => [$url_id, 'Integer'], + ] ); if (!$search->fetch()) { @@ -95,9 +95,9 @@ public static function track($queue_id, $url_id) { "SELECT $turl.url as url FROM $turl WHERE $turl.id = %1", - array( - 1 => array($url_id, 'Integer'), - ) + [ + 1 => [$url_id, 'Integer'], + ] ); if (!$search->fetch()) { @@ -194,7 +194,7 @@ public static function getTotalCount( */ public static function getMailingTotalCount($mailingIDs) { $dao = new CRM_Core_DAO(); - $clickCount = array(); + $clickCount = []; $click = self::getTableName(); $queue = CRM_Mailing_Event_BAO_Queue::getTableName(); @@ -234,7 +234,7 @@ public static function getMailingTotalCount($mailingIDs) { */ public static function getMailingContactCount($mailingIDs, $contactID) { $dao = new CRM_Core_DAO(); - $clickCount = array(); + $clickCount = []; $click = self::getTableName(); $queue = CRM_Mailing_Event_BAO_Queue::getTableName(); @@ -367,18 +367,18 @@ public static function &getRows( CRM_Core_DAO::disableFullGroupByMode(); $dao->query($query); CRM_Core_DAO::reenableFullGroupByMode(); - $results = array(); + $results = []; while ($dao->fetch()) { $url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$dao->contact_id}" ); - $results[] = array( + $results[] = [ 'name' => "{$dao->display_name}", 'email' => $dao->email, 'url' => $dao->url, 'date' => CRM_Utils_Date::customFormat($dao->date), - ); + ]; } return $results; } diff --git a/CRM/Mailing/Event/BAO/Unsubscribe.php b/CRM/Mailing/Event/BAO/Unsubscribe.php index f596a5d26473..415ae8535064 100644 --- a/CRM/Mailing/Event/BAO/Unsubscribe.php +++ b/CRM/Mailing/Event/BAO/Unsubscribe.php @@ -77,10 +77,10 @@ public static function unsub_from_domain($job_id, $queue_id, $hash) { hold_date = %1 WHERE email = %2 "; - $sqlParams = array( - 1 => array($now, 'Timestamp'), - 2 => array($email->email, 'String'), - ); + $sqlParams = [ + 1 => [$now, 'Timestamp'], + 2 => [$email->email, 'String'], + ]; CRM_Core_DAO::executeQuery($sql, $sqlParams); } } @@ -97,13 +97,13 @@ public static function unsub_from_domain($job_id, $queue_id, $hash) { $ue->time_stamp = $now; $ue->save(); - $shParams = array( + $shParams = [ 'contact_id' => $q->contact_id, 'group_id' => NULL, 'status' => 'Removed', 'method' => 'Email', 'tracking' => $ue->id, - ); + ]; CRM_Contact_BAO_SubscriptionHistory::create($shParams); $transaction->commit(); @@ -162,7 +162,7 @@ public static function &unsub_from_mailing($job_id, $queue_id, $hash, $return = $entity = CRM_Core_DAO::getFieldValue('CRM_Mailing_DAO_MailingGroup', $mailing_id, 'entity_table', 'mailing_id'); // If $entity is null and $mailing_Type is either winner or experiment then we are deailing with an AB test - $abtest_types = array('experiment', 'winner'); + $abtest_types = ['experiment', 'winner']; if (empty($entity) && in_array($mailing_type, $abtest_types)) { $mailing_id_a = CRM_Core_DAO::getFieldValue('CRM_Mailing_DAO_MailingAB', $mailing_id, 'mailing_id_a', 'mailing_id_b'); $field = 'mailing_id_b'; @@ -198,9 +198,9 @@ public static function &unsub_from_mailing($job_id, $queue_id, $hash, $return = // Make a list of groups and a list of prior mailings that received // this mailing. - $groups = array(); - $base_groups = array(); - $mailings = array(); + $groups = []; + $base_groups = []; + $mailings = []; while ($do->fetch()) { if ($do->entity_table == $group) { @@ -227,7 +227,7 @@ public static function &unsub_from_mailing($job_id, $queue_id, $hash, $return = WHERE $mg.mailing_id IN (" . implode(', ', $mailings) . ") AND $mg.group_type = 'Include'"); - $mailings = array(); + $mailings = []; while ($do->fetch()) { if ($do->entity_table == $group) { @@ -274,12 +274,12 @@ public static function &unsub_from_mailing($job_id, $queue_id, $hash, $return = )"); if ($return) { - $returnGroups = array(); + $returnGroups = []; while ($do->fetch()) { - $returnGroups[$do->group_id] = array( + $returnGroups[$do->group_id] = [ 'title' => $do->title, 'description' => $do->description, - ); + ]; } return $returnGroups; } @@ -289,7 +289,7 @@ public static function &unsub_from_mailing($job_id, $queue_id, $hash, $return = } } - $contacts = array($contact_id); + $contacts = [$contact_id]; foreach ($groups as $group_id => $group_name) { $notremoved = FALSE; if ($group_name) { @@ -416,13 +416,13 @@ public static function send_unsub_response($queue_id, $groups, $is_domain = FALS $emailDomain = CRM_Core_BAO_MailSettings::defaultDomain(); - $headers = array( + $headers = [ 'Subject' => $component->subject, 'From' => "\"$domainEmailName\" <" . CRM_Core_BAO_Domain::getNoReplyEmailAddress() . '>', 'To' => $eq->email, 'Reply-To' => CRM_Core_BAO_Domain::getNoReplyEmailAddress(), 'Return-Path' => CRM_Core_BAO_Domain::getNoReplyEmailAddress(), - ); + ]; CRM_Mailing_BAO_Mailing::addMessageIdHeader($headers, 'u', $job, $queue_id, $eq->hash); $b = CRM_Utils_Mail::setMimeParams($message); @@ -598,19 +598,19 @@ public static function &getRows( $dao->query($query); - $results = array(); + $results = []; while ($dao->fetch()) { $url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$dao->contact_id}" ); - $results[] = array( + $results[] = [ 'name' => "{$dao->display_name}", 'email' => $dao->email, // Next value displays in selector under either Unsubscribe OR Optout column header, so always s/b Yes. 'unsubOrOptout' => ts('Yes'), 'date' => CRM_Utils_Date::customFormat($dao->date), - ); + ]; } return $results; } @@ -641,7 +641,7 @@ public static function getContactInfo($queueID) { $email = $dao->email; } - return array($displayName, $email); + return [$displayName, $email]; } } diff --git a/CRM/Mailing/Form/Approve.php b/CRM/Mailing/Form/Approve.php index 7490ae65810b..acf0b9218f3b 100644 --- a/CRM/Mailing/Form/Approve.php +++ b/CRM/Mailing/Form/Approve.php @@ -75,7 +75,7 @@ public function preProcess() { * Set default values for the form. */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; if ($this->_mailingID) { $defaults['approval_status_id'] = $this->_mailing->approval_status_id; $defaults['approval_note'] = $this->_mailing->approval_note; @@ -101,25 +101,25 @@ public function buildQuickform() { unset($mailApprovalStatus[$noneOptionID]); } - $this->addRadio('approval_status_id', ts('Approval Status'), $mailApprovalStatus, array(), NULL, TRUE); + $this->addRadio('approval_status_id', ts('Approval Status'), $mailApprovalStatus, [], NULL, TRUE); - $buttons = array( - array( + $buttons = [ + [ 'type' => 'next', 'name' => ts('Save'), 'spacing' => '                 ', 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ); + ], + ]; $this->addButtons($buttons); // add the preview elements - $preview = array(); + $preview = []; $preview['subject'] = CRM_Core_DAO::getFieldValue('CRM_Mailing_DAO_Mailing', $this->_mailingID, @@ -145,7 +145,7 @@ public function postProcess() { // get the submitted form values. $params = $this->controller->exportValues($this->_name); - $ids = array(); + $ids = []; if (isset($this->_mailingID)) { $ids['mailing_id'] = $this->_mailingID; } diff --git a/CRM/Mailing/Form/Browse.php b/CRM/Mailing/Form/Browse.php index 12d51b337ed3..d0c1f8d9c88f 100644 --- a/CRM/Mailing/Form/Browse.php +++ b/CRM/Mailing/Form/Browse.php @@ -62,17 +62,17 @@ public function preProcess() { * Build the form object. */ public function buildQuickForm() { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => ts('Confirm'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); } diff --git a/CRM/Mailing/Form/Component.php b/CRM/Mailing/Form/Component.php index 3dcc63b0ff51..beb2efee2142 100644 --- a/CRM/Mailing/Form/Component.php +++ b/CRM/Mailing/Form/Component.php @@ -59,15 +59,15 @@ public function preProcess() { * Build the form object. */ public function buildQuickForm() { - $this->applyFilter(array('name', 'subject', 'body_html'), 'trim'); + $this->applyFilter(['name', 'subject', 'body_html'], 'trim'); $this->add('text', 'name', ts('Name'), CRM_Core_DAO::getAttribute('CRM_Mailing_BAO_MailingComponent', 'name'), TRUE ); - $this->addRule('name', ts('Name already exists in Database.'), 'objectExists', array( + $this->addRule('name', ts('Name already exists in Database.'), 'objectExists', [ 'CRM_Mailing_BAO_MailingComponent', $this->_id, - )); + ]); $this->add('select', 'component_type', ts('Component Type'), CRM_Core_SelectValues::mailingComponents()); @@ -85,20 +85,20 @@ public function buildQuickForm() { $this->addYesNo('is_default', ts('Default?')); $this->addYesNo('is_active', ts('Enabled?')); - $this->addFormRule(array('CRM_Mailing_Form_Component', 'formRule')); - $this->addFormRule(array('CRM_Mailing_Form_Component', 'dataRule')); + $this->addFormRule(['CRM_Mailing_Form_Component', 'formRule']); + $this->addFormRule(['CRM_Mailing_Form_Component', 'dataRule']); - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => ts('Save'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); } @@ -106,11 +106,11 @@ public function buildQuickForm() { * Set default values for the form. */ public function setDefaultValues() { - $defaults = array(); - $params = array(); + $defaults = []; + $params = []; if (isset($this->_id)) { - $params = array('id' => $this->_id); + $params = ['id' => $this->_id]; $baoName = $this->_BAOName; $baoName::retrieve($params, $defaults); } @@ -133,9 +133,9 @@ public function postProcess() { } $component = CRM_Mailing_BAO_MailingComponent::add($params); - CRM_Core_Session::setStatus(ts('The mailing component \'%1\' has been saved.', array( + CRM_Core_Session::setStatus(ts('The mailing component \'%1\' has been saved.', [ 1 => $component->name, - ) + ] ), ts('Saved'), 'success'); } @@ -154,31 +154,31 @@ public function postProcess() { */ public static function dataRule($params, $files, $options) { if ($params['component_type'] == 'Header' || $params['component_type'] == 'Footer') { - $InvalidTokens = array(); + $InvalidTokens = []; } else { - $InvalidTokens = array('action.forward' => ts("This token can only be used in send mailing context (body, header, footer)..")); + $InvalidTokens = ['action.forward' => ts("This token can only be used in send mailing context (body, header, footer)..")]; } - $errors = array(); - foreach (array( + $errors = []; + foreach ([ 'text', 'html', - ) as $type) { - $dataErrors = array(); + ] as $type) { + $dataErrors = []; foreach ($InvalidTokens as $token => $desc) { if ($params['body_' . $type]) { if (preg_match('/' . preg_quote('{' . $token . '}') . '/', $params['body_' . $type])) { - $dataErrors[] = '
  • ' . ts('This message is having a invalid token - %1: %2', array( + $dataErrors[] = '
  • ' . ts('This message is having a invalid token - %1: %2', [ 1 => $token, 2 => $desc, - )) . '
  • '; + ]) . ''; } } } if (!empty($dataErrors)) { - $errors['body_' . $type] = ts('The following errors were detected in %1 message:', array( + $errors['body_' . $type] = ts('The following errors were detected in %1 message:', [ 1 => $type, - )) . '
      ' . implode('', $dataErrors) . '

    ' . ts('More information on tokens...') . ''; + ]) . '
      ' . implode('', $dataErrors) . '

    ' . ts('More information on tokens...') . ''; } } return empty($errors) ? TRUE : $errors; @@ -196,7 +196,7 @@ public static function dataRule($params, $files, $options) { * mixed true or array of errors */ public static function formRule($params, $files, $options) { - $errors = array(); + $errors = []; if (empty($params['body_text']) && empty($params['body_html'])) { $errors['body_text'] = ts("Please provide either HTML or TEXT format for the Body."); $errors['body_html'] = ts("Please provide either HTML or TEXT format for the Body."); diff --git a/CRM/Mailing/Form/ForwardMailing.php b/CRM/Mailing/Form/ForwardMailing.php index f499c381db3c..0fa6966707a5 100644 --- a/CRM/Mailing/Form/ForwardMailing.php +++ b/CRM/Mailing/Form/ForwardMailing.php @@ -61,7 +61,7 @@ public function preProcess() { // Show the subject instead of the name here, since it's being // displayed to external contacts/users. - CRM_Utils_System::setTitle(ts('Forward Mailing: %1', array(1 => $mailing->subject))); + CRM_Utils_System::setTitle(ts('Forward Mailing: %1', [1 => $mailing->subject])); $this->set('queue_id', $queue_id); $this->set('job_id', $job_id); @@ -73,28 +73,28 @@ public function preProcess() { */ public function buildQuickForm() { for ($i = 0; $i < 5; $i++) { - $this->add('text', "email_$i", ts('Email %1', array(1 => $i + 1))); + $this->add('text', "email_$i", ts('Email %1', [1 => $i + 1])); $this->addRule("email_$i", ts('Email is not valid.'), 'email'); } //insert message Text by selecting "Select Template option" - $this->add('textarea', 'forward_comment', ts('Comment'), array('cols' => '80', 'rows' => '8')); + $this->add('textarea', 'forward_comment', ts('Comment'), ['cols' => '80', 'rows' => '8']); $this->add('wysiwyg', 'html_comment', ts('HTML Message'), - array('cols' => '80', 'rows' => '8') + ['cols' => '80', 'rows' => '8'] ); - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => ts('Forward'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - )); + ], + ]); } /** @@ -107,12 +107,12 @@ public function postProcess() { $timeStamp = date('YmdHis'); $formValues = $this->controller->exportValues($this->_name); - $params = array(); + $params = []; $params['body_text'] = $formValues['forward_comment']; $html_comment = $formValues['html_comment']; $params['body_html'] = str_replace('%7B', '{', str_replace('%7D', '}', $html_comment)); - $emails = array(); + $emails = []; for ($i = 0; $i < 5; $i++) { $email = $this->controller->exportValue($this->_name, "email_$i"); if (!empty($email)) { @@ -122,7 +122,7 @@ public function postProcess() { $forwarded = NULL; foreach ($emails as $email) { - $params = array( + $params = [ 'version' => 3, 'job_id' => $job_id, 'event_queue_id' => $queue_id, @@ -131,22 +131,22 @@ public function postProcess() { 'time_stamp' => $timeStamp, 'fromEmail' => $this->_fromEmail, 'params' => $params, - ); + ]; $result = civicrm_api('Mailing', 'event_forward', $params); if (!civicrm_error($result)) { $forwarded++; } } - $status = ts('Mailing is not forwarded to the given email address.', array( + $status = ts('Mailing is not forwarded to the given email address.', [ 'count' => count($emails), 'plural' => 'Mailing is not forwarded to the given email addresses.', - )); + ]); if ($forwarded) { - $status = ts('Mailing is forwarded successfully to %count email address.', array( + $status = ts('Mailing is forwarded successfully to %count email address.', [ 'count' => $forwarded, 'plural' => 'Mailing is forwarded successfully to %count email addresses.', - )); + ]); } CRM_Utils_System::setUFMessage($status); diff --git a/CRM/Mailing/Form/Optout.php b/CRM/Mailing/Form/Optout.php index 97c951cc40e5..7473fe3af3bc 100644 --- a/CRM/Mailing/Form/Optout.php +++ b/CRM/Mailing/Form/Optout.php @@ -68,17 +68,17 @@ public function buildQuickForm() { $this->add('text', 'email_confirm', ts('Verify email address to opt out:')); $this->addRule('email_confirm', ts('Email address is required to opt out.'), 'required'); - $buttons = array( - array( + $buttons = [ + [ 'type' => 'next', 'name' => ts('Opt Out'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ); + ], + ]; $this->addButtons($buttons); } @@ -106,7 +106,7 @@ public function postProcess() { } $statusMsg = ts('Email: %1 has been successfully opted out', - array(1 => $values['email_confirm']) + [1 => $values['email_confirm']] ); CRM_Core_Session::setStatus($statusMsg, '', 'success'); @@ -114,7 +114,7 @@ public function postProcess() { elseif ($result == FALSE) { // Email address not verified $statusMsg = ts('The email address: %1 you have entered does not match the email associated with this opt out request.', - array(1 => $values['email_confirm']) + [1 => $values['email_confirm']] ); CRM_Core_Session::setStatus($statusMsg, '', 'error'); diff --git a/CRM/Mailing/Form/Search.php b/CRM/Mailing/Form/Search.php index f9080be13fd6..c7c3d42eaefc 100644 --- a/CRM/Mailing/Form/Search.php +++ b/CRM/Mailing/Form/Search.php @@ -64,7 +64,7 @@ public function buildQuickForm() { $enabledLanguages = CRM_Core_I18n::languages(TRUE); if (count($enabledLanguages) > 1) { - $this->addElement('select', 'language', ts('Language'), array('' => ts('- all languages -')) + $enabledLanguages, array('class' => 'crm-select2')); + $this->addElement('select', 'language', ts('Language'), ['' => ts('- all languages -')] + $enabledLanguages, ['class' => 'crm-select2']); } if ($parent->_sms) { @@ -72,20 +72,20 @@ public function buildQuickForm() { } $this->add('hidden', 'hidden_find_mailings', 1); - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'refresh', 'name' => ts('Search'), 'isDefault' => TRUE, - ), - )); + ], + ]); } /** * @return array */ public function setDefaultValues() { - $defaults = $statusVals = array(); + $defaults = $statusVals = []; $parent = $this->controller->getParent(); if ($parent->get('unscheduled')) { @@ -115,7 +115,7 @@ public function postProcess() { $parent = $this->controller->getParent(); if (!empty($params)) { - $fields = array( + $fields = [ 'mailing_name', 'mailing_from', 'mailing_to', @@ -127,15 +127,15 @@ public function postProcess() { 'is_archived', 'language', 'hidden_find_mailings', - ); + ]; foreach ($fields as $field) { if (isset($params[$field]) && !CRM_Utils_System::isNull($params[$field]) ) { - if (in_array($field, array( + if (in_array($field, [ 'mailing_from', 'mailing_to', - )) && !$params["mailing_relative"] + ]) && !$params["mailing_relative"] ) { $time = ($field == 'mailing_to') ? '235959' : NULL; $parent->set($field, CRM_Utils_Date::processDate($params[$field], $time)); diff --git a/CRM/Mailing/Form/Subscribe.php b/CRM/Mailing/Form/Subscribe.php index fa6404943adf..91b79e81a39b 100644 --- a/CRM/Mailing/Form/Subscribe.php +++ b/CRM/Mailing/Form/Subscribe.php @@ -59,7 +59,7 @@ public function preProcess() { $dao = CRM_Core_DAO::executeQuery($query); if ($dao->fetch()) { $this->assign('groupName', $dao->title); - CRM_Utils_System::setTitle(ts('Subscribe to Mailing List - %1', array(1 => $dao->title))); + CRM_Utils_System::setTitle(ts('Subscribe to Mailing List - %1', [1 => $dao->title])); } else { CRM_Core_Error::statusBounce("The specified group is not configured for this action OR The group doesn't exist."); @@ -101,9 +101,9 @@ public function buildQuickForm() { AND $groupTypeCondition ORDER BY title"; $dao = CRM_Core_DAO::executeQuery($query); - $rows = array(); + $rows = []; while ($dao->fetch()) { - $row = array(); + $row = []; $row['id'] = $dao->id; $row['title'] = $dao->title; $row['description'] = $dao->description; @@ -118,7 +118,7 @@ public function buildQuickForm() { CRM_Core_Error::fatal(ts('There are no public mailing list groups to display.')); } $this->assign('rows', $rows); - $this->addFormRule(array('CRM_Mailing_Form_Subscribe', 'formRule')); + $this->addFormRule(['CRM_Mailing_Form_Subscribe', 'formRule']); } $addCaptcha = TRUE; @@ -153,17 +153,17 @@ public function buildQuickForm() { $this->assign('isCaptcha', TRUE); } - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => ts('Subscribe'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); } @@ -178,13 +178,13 @@ public static function formRule($fields) { return TRUE; } } - return array('_qf_default' => 'Please select one or more mailing lists.'); + return ['_qf_default' => 'Please select one or more mailing lists.']; } public function postProcess() { $params = $this->controller->exportValues($this->_name); - $groups = array(); + $groups = []; if ($this->_groupID) { $groups[] = $this->_groupID; } diff --git a/CRM/Mailing/Form/Task.php b/CRM/Mailing/Form/Task.php index 3ccb5e1804e1..e06b8cc1a197 100644 --- a/CRM/Mailing/Form/Task.php +++ b/CRM/Mailing/Form/Task.php @@ -55,7 +55,7 @@ public static function preProcessCommon(&$form) { $form->assign('taskName', CRM_Utils_Array::value('task', $values)); // ids are mailing event queue ids - $ids = array(); + $ids = []; if ($values['radio_ts'] == 'ts_sel') { foreach ($values as $name => $value) { if (substr($name, 0, CRM_Core_Form::CB_PREFIX_LEN) == CRM_Core_Form::CB_PREFIX) { @@ -115,17 +115,17 @@ public static function preProcessCommon(&$form) { * @param bool $submitOnce */ public function addDefaultButtons($title, $nextType = 'next', $backType = 'back', $submitOnce = FALSE) { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => $nextType, 'name' => $title, 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => $backType, 'name' => ts('Cancel'), - ), - ) + ], + ] ); } diff --git a/CRM/Mailing/Form/Task/AdhocMailing.php b/CRM/Mailing/Form/Task/AdhocMailing.php index 6dca0f44f120..f08cf4993984 100644 --- a/CRM/Mailing/Form/Task/AdhocMailing.php +++ b/CRM/Mailing/Form/Task/AdhocMailing.php @@ -40,25 +40,25 @@ public function preProcess() { parent::preProcess(); $templateTypes = CRM_Mailing_BAO_Mailing::getTemplateTypes(); list ($groupId, $ssId) = $this->createHiddenGroup(); - $mailing = civicrm_api3('Mailing', 'create', array( + $mailing = civicrm_api3('Mailing', 'create', [ 'name' => "", 'campaign_id' => NULL, 'replyto_email' => "", 'template_type' => $templateTypes[0]['name'], - 'template_options' => array('nonce' => 1), + 'template_options' => ['nonce' => 1], 'subject' => "", 'body_html' => "", 'body_text' => "", - 'groups' => array( - 'include' => array($groupId), - 'exclude' => array(), - 'base' => array(), - ), - 'mailings' => array( - 'include' => array(), - 'exclude' => array(), - ), - )); + 'groups' => [ + 'include' => [$groupId], + 'exclude' => [], + 'base' => [], + ], + 'mailings' => [ + 'include' => [], + 'exclude' => [], + ], + ]); CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/a/', NULL, TRUE, '/mailing/' . $mailing['id'])); } diff --git a/CRM/Mailing/Form/Task/Print.php b/CRM/Mailing/Form/Task/Print.php index ec97850167fb..a57f21a40af0 100644 --- a/CRM/Mailing/Form/Task/Print.php +++ b/CRM/Mailing/Form/Task/Print.php @@ -70,18 +70,18 @@ public function buildQuickForm() { // // just need to add a javacript to popup the window for printing // - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => ts('Print Mailing Recipients'), - 'js' => array('onclick' => 'window.print()'), + 'js' => ['onclick' => 'window.print()'], 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'back', 'name' => ts('Done'), - ), - ) + ], + ] ); } diff --git a/CRM/Mailing/Form/Unsubscribe.php b/CRM/Mailing/Form/Unsubscribe.php index a348b4076072..33cee130f289 100644 --- a/CRM/Mailing/Form/Unsubscribe.php +++ b/CRM/Mailing/Form/Unsubscribe.php @@ -70,7 +70,7 @@ public function preProcess() { } if (!$groupExist) { $statusMsg = ts('Email: %1 has been successfully unsubscribed from this Mailing List/Group.', - array(1 => $email) + [1 => $email] ); CRM_Core_Session::setStatus($statusMsg, '', 'error'); } @@ -85,17 +85,17 @@ public function buildQuickForm() { $this->add('text', 'email_confirm', ts('Verify email address to unsubscribe:')); $this->addRule('email_confirm', ts('Email address is required to unsubscribe.'), 'required'); - $buttons = array( - array( + $buttons = [ + [ 'type' => 'next', 'name' => ts('Unsubscribe'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ); + ], + ]; $this->addButtons($buttons); } @@ -123,7 +123,7 @@ public function postProcess() { } $statusMsg = ts('Email: %1 has been successfully unsubscribed from this Mailing List/Group.', - array(1 => $values['email_confirm']) + [1 => $values['email_confirm']] ); CRM_Core_Session::setStatus($statusMsg, '', 'success'); @@ -131,7 +131,7 @@ public function postProcess() { elseif ($result == FALSE) { // Email address not verified $statusMsg = ts('The email address: %1 you have entered does not match the email associated with this unsubscribe request.', - array(1 => $values['email_confirm']) + [1 => $values['email_confirm']] ); CRM_Core_Session::setStatus($statusMsg, '', 'error'); diff --git a/CRM/Mailing/Info.php b/CRM/Mailing/Info.php index 0361dfbaf7f2..7ed725507dda 100644 --- a/CRM/Mailing/Info.php +++ b/CRM/Mailing/Info.php @@ -46,13 +46,13 @@ class CRM_Mailing_Info extends CRM_Core_Component_Info { * @return array */ public function getInfo() { - return array( + return [ 'name' => 'CiviMail', 'translatedName' => ts('CiviMail'), 'title' => ts('CiviCRM Mailing Engine'), 'search' => 1, 'showActivitiesInCore' => 1, - ); + ]; } /** @@ -69,21 +69,21 @@ public function getAngularModules() { && !CRM_Core_Permission::check('schedule mailings') && !CRM_Core_Permission::check('approve mailings') ) { - return array(); + return []; } global $civicrm_root; - $reportIds = array(); - $reportTypes = array('detail', 'opened', 'bounce', 'clicks'); + $reportIds = []; + $reportTypes = ['detail', 'opened', 'bounce', 'clicks']; foreach ($reportTypes as $report) { - $result = civicrm_api3('ReportInstance', 'get', array( + $result = civicrm_api3('ReportInstance', 'get', [ 'sequential' => 1, - 'report_id' => 'mailing/' . $report)); + 'report_id' => 'mailing/' . $report]); if (!empty($result['values'])) { $reportIds[$report] = $result['values'][0]['id']; } } - $result = array(); + $result = []; $result['crmMailing'] = include "$civicrm_root/ang/crmMailing.ang.php"; $result['crmMailingAB'] = include "$civicrm_root/ang/crmMailingAB.ang.php"; $result['crmD3'] = include "$civicrm_root/ang/crmD3.ang.php"; @@ -93,51 +93,51 @@ public function getAngularModules() { $contactID = $session->get('userID'); // Generic params. - $params = array( - 'options' => array('limit' => 0), + $params = [ + 'options' => ['limit' => 0], 'sequential' => 1, - ); - $groupNames = civicrm_api3('Group', 'get', $params + array( + ]; + $groupNames = civicrm_api3('Group', 'get', $params + [ 'is_active' => 1, 'check_permissions' => TRUE, - 'return' => array('title', 'visibility', 'group_type', 'is_hidden'), - )); - $headerfooterList = civicrm_api3('MailingComponent', 'get', $params + array( + 'return' => ['title', 'visibility', 'group_type', 'is_hidden'], + ]); + $headerfooterList = civicrm_api3('MailingComponent', 'get', $params + [ 'is_active' => 1, - 'return' => array('name', 'component_type', 'is_default', 'body_html', 'body_text'), - )); + 'return' => ['name', 'component_type', 'is_default', 'body_html', 'body_text'], + ]); - $emailAdd = civicrm_api3('Email', 'get', array( + $emailAdd = civicrm_api3('Email', 'get', [ 'sequential' => 1, 'return' => "email", 'contact_id' => $contactID, - )); + ]); - $mesTemplate = civicrm_api3('MessageTemplate', 'get', $params + array( + $mesTemplate = civicrm_api3('MessageTemplate', 'get', $params + [ 'sequential' => 1, 'is_active' => 1, - 'return' => array("id", "msg_title"), - 'workflow_id' => array('IS NULL' => ""), - )); - $mailTokens = civicrm_api3('Mailing', 'gettokens', array( - 'entity' => array('contact', 'mailing'), + 'return' => ["id", "msg_title"], + 'workflow_id' => ['IS NULL' => ""], + ]); + $mailTokens = civicrm_api3('Mailing', 'gettokens', [ + 'entity' => ['contact', 'mailing'], 'sequential' => 1, - )); - $fromAddress = civicrm_api3('OptionValue', 'get', $params + array( + ]); + $fromAddress = civicrm_api3('OptionValue', 'get', $params + [ 'option_group_id' => "from_email_address", 'domain_id' => CRM_Core_Config::domainID(), - )); + ]); $enabledLanguages = CRM_Core_I18n::languages(TRUE); $isMultiLingual = (count($enabledLanguages) > 1); // FlexMailer is a refactoring of CiviMail which provides new hooks/APIs/docs. If the sysadmin has opted to enable it, then use that instead of CiviMail. - $requiredTokens = defined('CIVICRM_FLEXMAILER_HACK_REQUIRED_TOKENS') ? Civi\Core\Resolver::singleton()->call(CIVICRM_FLEXMAILER_HACK_REQUIRED_TOKENS, array()) : CRM_Utils_Token::getRequiredTokens(); + $requiredTokens = defined('CIVICRM_FLEXMAILER_HACK_REQUIRED_TOKENS') ? Civi\Core\Resolver::singleton()->call(CIVICRM_FLEXMAILER_HACK_REQUIRED_TOKENS, []) : CRM_Utils_Token::getRequiredTokens(); CRM_Core_Resources::singleton() - ->addSetting(array( - 'crmMailing' => array( + ->addSetting([ + 'crmMailing' => [ 'templateTypes' => CRM_Mailing_BAO_Mailing::getTemplateTypes(), - 'civiMails' => array(), + 'civiMails' => [], 'campaignEnabled' => in_array('CiviCampaign', $config->enableComponents), - 'groupNames' => array(), + 'groupNames' => [], // @todo this is not used in core. Remove once Mosaico no longer depends on it. 'testGroupNames' => $groupNames['values'], 'headerfooterList' => $headerfooterList['values'], @@ -149,18 +149,18 @@ public function getAngularModules() { 'enableReplyTo' => (int) Civi::settings()->get('replyTo'), 'disableMandatoryTokensCheck' => (int) Civi::settings()->get('disable_mandatory_tokens_check'), 'fromAddress' => $fromAddress['values'], - 'defaultTestEmail' => civicrm_api3('Contact', 'getvalue', array( + 'defaultTestEmail' => civicrm_api3('Contact', 'getvalue', [ 'id' => 'user_contact_id', 'return' => 'email', - )), + ]), 'visibility' => CRM_Utils_Array::makeNonAssociative(CRM_Core_SelectValues::groupVisibility()), 'workflowEnabled' => CRM_Mailing_Info::workflowEnabled(), 'reportIds' => $reportIds, 'enabledLanguages' => $enabledLanguages, 'isMultiLingual' => $isMultiLingual, - ), - )) - ->addPermissions(array( + ], + ]) + ->addPermissions([ 'view all contacts', 'edit all contacts', 'access CiviMail', @@ -169,7 +169,7 @@ public function getAngularModules() { 'approve mailings', 'delete in CiviMail', 'edit message templates', - )); + ]); return $result; } @@ -207,33 +207,33 @@ public static function workflowEnabled() { * @return array */ public function getPermissions($getAllUnconditionally = FALSE, $descriptions = FALSE) { - $permissions = array( - 'access CiviMail' => array( + $permissions = [ + 'access CiviMail' => [ ts('access CiviMail'), - ), - 'access CiviMail subscribe/unsubscribe pages' => array( + ], + 'access CiviMail subscribe/unsubscribe pages' => [ ts('access CiviMail subscribe/unsubscribe pages'), ts('Subscribe/unsubscribe from mailing list group'), - ), - 'delete in CiviMail' => array( + ], + 'delete in CiviMail' => [ ts('delete in CiviMail'), ts('Delete Mailing'), - ), - 'view public CiviMail content' => array( + ], + 'view public CiviMail content' => [ ts('view public CiviMail content'), - ), - ); + ], + ]; if (self::workflowEnabled() || $getAllUnconditionally) { - $permissions['create mailings'] = array( + $permissions['create mailings'] = [ ts('create mailings'), - ); - $permissions['schedule mailings'] = array( + ]; + $permissions['schedule mailings'] = [ ts('schedule mailings'), - ); - $permissions['approve mailings'] = array( + ]; + $permissions['approve mailings'] = [ ts('approve mailings'), - ); + ]; } if (!$descriptions) { @@ -268,12 +268,12 @@ public function getUserDashboardObject() { * @return array */ public function registerTab() { - return array( + return [ 'title' => ts('Mailings'), 'id' => 'mailing', 'url' => 'mailing', 'weight' => 45, - ); + ]; } /** @@ -289,10 +289,10 @@ public function getIcon() { * @return array */ public function registerAdvancedSearchPane() { - return array( + return [ 'title' => ts('Mailings'), 'weight' => 20, - ); + ]; } /** diff --git a/CRM/Mailing/MailStore.php b/CRM/Mailing/MailStore.php index c2745c63bea0..bb94c529a161 100644 --- a/CRM/Mailing/MailStore.php +++ b/CRM/Mailing/MailStore.php @@ -122,9 +122,9 @@ public function fetchNext($count = 1) { if ($this->_debug) { print "got to the end of the mailbox\n"; } - return array(); + return []; } - $mails = array(); + $mails = []; $parser = new ezcMailParser(); //set property text attachment as file CRM-5408 $parser->options->parseTextAttachmentsAsFiles = TRUE; @@ -152,11 +152,11 @@ public function fetchNext($count = 1) { public function maildir($name) { $config = CRM_Core_Config::singleton(); $dir = $config->customFileUploadDir . DIRECTORY_SEPARATOR . $name; - foreach (array( + foreach ([ 'cur', 'new', 'tmp', - ) as $sub) { + ] as $sub) { if (!file_exists($dir . DIRECTORY_SEPARATOR . $sub)) { if ($this->_debug) { print "creating $dir/$sub\n"; diff --git a/CRM/Mailing/MailStore/Imap.php b/CRM/Mailing/MailStore/Imap.php index eef954a3d15d..a805ee43a222 100644 --- a/CRM/Mailing/MailStore/Imap.php +++ b/CRM/Mailing/MailStore/Imap.php @@ -64,13 +64,13 @@ public function __construct($host, $username, $password, $ssl = TRUE, $folder = } - $options = array('ssl' => $ssl, 'uidReferencing' => TRUE); + $options = ['ssl' => $ssl, 'uidReferencing' => TRUE]; $this->_transport = new ezcMailImapTransport($host, NULL, $options); $this->_transport->authenticate($username, $password); $this->_transport->selectMailbox($folder); - $this->_ignored = implode($this->_transport->getHierarchyDelimiter(), array($folder, 'CiviMail', 'ignored')); - $this->_processed = implode($this->_transport->getHierarchyDelimiter(), array($folder, 'CiviMail', 'processed')); + $this->_ignored = implode($this->_transport->getHierarchyDelimiter(), [$folder, 'CiviMail', 'ignored']); + $this->_processed = implode($this->_transport->getHierarchyDelimiter(), [$folder, 'CiviMail', 'processed']); $boxes = $this->_transport->listMailboxes(); if ($this->_debug) { diff --git a/CRM/Mailing/MailStore/Localdir.php b/CRM/Mailing/MailStore/Localdir.php index 9f46a149026c..87a0a4f1856a 100644 --- a/CRM/Mailing/MailStore/Localdir.php +++ b/CRM/Mailing/MailStore/Localdir.php @@ -47,18 +47,18 @@ class CRM_Mailing_MailStore_Localdir extends CRM_Mailing_MailStore { public function __construct($dir) { $this->_dir = $dir; - $this->_ignored = $this->maildir(implode(DIRECTORY_SEPARATOR, array( + $this->_ignored = $this->maildir(implode(DIRECTORY_SEPARATOR, [ 'CiviMail.ignored', date('Y'), date('m'), date('d'), - ))); - $this->_processed = $this->maildir(implode(DIRECTORY_SEPARATOR, array( + ])); + $this->_processed = $this->maildir(implode(DIRECTORY_SEPARATOR, [ 'CiviMail.processed', date('Y'), date('m'), date('d'), - ))); + ])); } /** @@ -72,7 +72,7 @@ public function __construct($dir) { * array of ezcMail objects */ public function fetchNext($count = 0) { - $mails = array(); + $mails = []; $path = rtrim($this->_dir, DIRECTORY_SEPARATOR); if ($this->_debug) { @@ -95,7 +95,7 @@ public function fetchNext($count = 0) { print "retrieving message $file\n"; } - $set = new ezcMailFileSet(array($file)); + $set = new ezcMailFileSet([$file]); $parser = new ezcMailParser(); // set property text attachment as file CRM-5408 $parser->options->parseTextAttachmentsAsFiles = TRUE; @@ -104,7 +104,7 @@ public function fetchNext($count = 0) { if (!$mail) { return CRM_Core_Error::createAPIError(ts('%1 could not be parsed', - array(1 => $file) + [1 => $file] )); } $mails[$file] = $mail[0]; diff --git a/CRM/Mailing/MailStore/Maildir.php b/CRM/Mailing/MailStore/Maildir.php index 0ff416c04f56..c0b585539566 100644 --- a/CRM/Mailing/MailStore/Maildir.php +++ b/CRM/Mailing/MailStore/Maildir.php @@ -47,18 +47,18 @@ class CRM_Mailing_MailStore_Maildir extends CRM_Mailing_MailStore { public function __construct($dir) { $this->_dir = $dir; - $this->_ignored = $this->maildir(implode(DIRECTORY_SEPARATOR, array( + $this->_ignored = $this->maildir(implode(DIRECTORY_SEPARATOR, [ 'CiviMail.ignored', date('Y'), date('m'), date('d'), - ))); - $this->_processed = $this->maildir(implode(DIRECTORY_SEPARATOR, array( + ])); + $this->_processed = $this->maildir(implode(DIRECTORY_SEPARATOR, [ 'CiviMail.processed', date('Y'), date('m'), date('d'), - ))); + ])); } /** @@ -72,15 +72,15 @@ public function __construct($dir) { * array of ezcMail objects */ public function fetchNext($count = 0) { - $mails = array(); + $mails = []; $parser = new ezcMailParser(); // set property text attachment as file CRM-5408 $parser->options->parseTextAttachmentsAsFiles = TRUE; - foreach (array( + foreach ([ 'cur', 'new', - ) as $subdir) { + ] as $subdir) { $dir = $this->_dir . DIRECTORY_SEPARATOR . $subdir; foreach (scandir($dir) as $file) { if ($file == '.' or $file == '..') { @@ -94,7 +94,7 @@ public function fetchNext($count = 0) { } - $set = new ezcMailFileSet(array($path)); + $set = new ezcMailFileSet([$path]); $single = $parser->parseMail($set); $mails[$path] = $single[0]; } diff --git a/CRM/Mailing/MailStore/Mbox.php b/CRM/Mailing/MailStore/Mbox.php index 7f0f466c7680..c1679a4aaf55 100644 --- a/CRM/Mailing/MailStore/Mbox.php +++ b/CRM/Mailing/MailStore/Mbox.php @@ -50,18 +50,18 @@ public function __construct($file) { $this->_leftToProcess = count($this->_transport->listMessages()); - $this->_ignored = $this->maildir(implode(DIRECTORY_SEPARATOR, array( + $this->_ignored = $this->maildir(implode(DIRECTORY_SEPARATOR, [ 'CiviMail.ignored', date('Y'), date('m'), date('d'), - ))); - $this->_processed = $this->maildir(implode(DIRECTORY_SEPARATOR, array( + ])); + $this->_processed = $this->maildir(implode(DIRECTORY_SEPARATOR, [ 'CiviMail.processed', date('Y'), date('m'), date('d'), - ))); + ])); } /** diff --git a/CRM/Mailing/MailStore/Pop3.php b/CRM/Mailing/MailStore/Pop3.php index 1d244ec001e5..f30f741a9866 100644 --- a/CRM/Mailing/MailStore/Pop3.php +++ b/CRM/Mailing/MailStore/Pop3.php @@ -55,22 +55,22 @@ public function __construct($host, $username, $password, $ssl = TRUE) { print "connecting to $host and authenticating as $username\n"; } - $options = array('ssl' => $ssl); + $options = ['ssl' => $ssl]; $this->_transport = new ezcMailPop3Transport($host, NULL, $options); $this->_transport->authenticate($username, $password); - $this->_ignored = $this->maildir(implode(DIRECTORY_SEPARATOR, array( + $this->_ignored = $this->maildir(implode(DIRECTORY_SEPARATOR, [ 'CiviMail.ignored', date('Y'), date('m'), date('d'), - ))); - $this->_processed = $this->maildir(implode(DIRECTORY_SEPARATOR, array( + ])); + $this->_processed = $this->maildir(implode(DIRECTORY_SEPARATOR, [ 'CiviMail.processed', date('Y'), date('m'), date('d'), - ))); + ])); } /** diff --git a/CRM/Mailing/Page/AJAX.php b/CRM/Mailing/Page/AJAX.php index 77cf97467cd1..c2586c25071f 100644 --- a/CRM/Mailing/Page/AJAX.php +++ b/CRM/Mailing/Page/AJAX.php @@ -47,12 +47,12 @@ public static function template() { $messageTemplate->selectAdd(); $messageTemplate->selectAdd('msg_text, msg_html, msg_subject, pdf_format_id'); $messageTemplate->find(TRUE); - $messages = array( + $messages = [ 'subject' => $messageTemplate->msg_subject, 'msg_text' => $messageTemplate->msg_text, 'msg_html' => $messageTemplate->msg_html, 'pdf_format_id' => $messageTemplate->pdf_format_id, - ); + ]; $documentInfo = CRM_Core_BAO_File::getEntityFile('civicrm_msg_template', $templateId); foreach ((array) $documentInfo as $info) { @@ -67,7 +67,7 @@ public static function template() { */ public static function getContactMailings() { $params = CRM_Core_Page_AJAX::defaultSortAndPagerParams(); - $params += CRM_Core_Page_AJAX::validateParams(array('contact_id' => 'Integer')); + $params += CRM_Core_Page_AJAX::validateParams(['contact_id' => 'Integer']); // get the contact mailings $mailings = CRM_Mailing_BAO_Mailing::getContactMailingSelector($params); diff --git a/CRM/Mailing/Page/Browse.php b/CRM/Mailing/Page/Browse.php index 166a50fe7fe3..65bf2de542df 100644 --- a/CRM/Mailing/Page/Browse.php +++ b/CRM/Mailing/Page/Browse.php @@ -94,7 +94,7 @@ public function preProcess() { // If this is not an SMS page, check that the user has an appropriate // permission (specific permissions have been copied from // CRM/Mailing/xml/Menu/Mailing.xml) - if (!CRM_Core_Permission::check(array(array('access CiviMail', 'approve mailings', 'create mailings', 'schedule mailings')))) { + if (!CRM_Core_Permission::check([['access CiviMail', 'approve mailings', 'create mailings', 'schedule mailings']])) { CRM_Core_Error::fatal(ts('You do not have permission to view this page.')); } } @@ -337,18 +337,18 @@ public function search() { * @return string */ public function whereClause(&$params, $sortBy = TRUE) { - $values = array(); + $values = []; - $clauses = array(); + $clauses = []; $title = $this->get('mailing_name'); // echo " name=$title "; if ($title) { $clauses[] = 'name LIKE %1'; if (strpos($title, '%') !== FALSE) { - $params[1] = array($title, 'String', FALSE); + $params[1] = [$title, 'String', FALSE]; } else { - $params[1] = array($title, 'String', TRUE); + $params[1] = [$title, 'String', TRUE]; } } @@ -361,7 +361,7 @@ public function whereClause(&$params, $sortBy = TRUE) { $campainIds = $this->get('campaign_id'); if (!CRM_Utils_System::isNull($campainIds)) { if (!is_array($campainIds)) { - $campaignIds = array($campaignIds); + $campaignIds = [$campaignIds]; } $clauses[] = '( campaign_id IN ( ' . implode(' , ', array_values($campainIds)) . ' ) )'; } diff --git a/CRM/Mailing/Page/Component.php b/CRM/Mailing/Page/Component.php index bf4e9832de50..24d90b338689 100644 --- a/CRM/Mailing/Page/Component.php +++ b/CRM/Mailing/Page/Component.php @@ -62,24 +62,24 @@ public function getBAOName() { */ public function &links() { if (!(self::$_links)) { - self::$_links = array( - CRM_Core_Action::UPDATE => array( + self::$_links = [ + CRM_Core_Action::UPDATE => [ 'name' => ts('Edit'), 'url' => CRM_Utils_System::currentPath(), 'qs' => 'action=update&id=%%id%%', 'title' => ts('Edit Mailing Component'), - ), - CRM_Core_Action::DISABLE => array( + ], + CRM_Core_Action::DISABLE => [ 'name' => ts('Disable'), 'ref' => 'crm-enable-disable', 'title' => ts('Disable Mailing Component'), - ), - CRM_Core_Action::ENABLE => array( + ], + CRM_Core_Action::ENABLE => [ 'name' => ts('Enable'), 'ref' => 'crm-enable-disable', 'title' => ts('Enable Mailing Component'), - ), - ); + ], + ]; } return self::$_links; } diff --git a/CRM/Mailing/Page/Preview.php b/CRM/Mailing/Page/Preview.php index 9c51fbdd7df1..cbcf3675000e 100644 --- a/CRM/Mailing/Page/Preview.php +++ b/CRM/Mailing/Page/Preview.php @@ -46,7 +46,7 @@ public function run() { $qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', CRM_Core_DAO::$_nullObject, FALSE, 'text'); $type = CRM_Utils_Request::retrieve('type', 'String', CRM_Core_DAO::$_nullObject, FALSE, 'text'); - $options = array(); + $options = []; $session->getVars($options, "CRM_Mailing_Controller_Send_$qfKey"); // get the options if control come from search context, CRM-3711 @@ -74,7 +74,7 @@ public function run() { // get details of contact with token value including Custom Field Token Values.CRM-3734 $returnProperties = $mailing->getReturnProperties(); - $params = array('contact_id' => $session->get('userID')); + $params = ['contact_id' => $session->get('userID')]; $details = CRM_Utils_Token::getTokenDetails($params, $returnProperties, diff --git a/CRM/Mailing/Page/Report.php b/CRM/Mailing/Page/Report.php index 6c57a7500993..628672a01ede 100644 --- a/CRM/Mailing/Page/Report.php +++ b/CRM/Mailing/Page/Report.php @@ -139,7 +139,7 @@ public function run() { $this->assign('report', $report); CRM_Utils_System::setTitle(ts('CiviMail Report: %1', - array(1 => $report['mailing']['name']) + [1 => $report['mailing']['name']] )); $this->assign('public_url', CRM_Mailing_BAO_Mailing::getPublicViewUrl($this->_mailing_id)); diff --git a/CRM/Mailing/Page/Tab.php b/CRM/Mailing/Page/Tab.php index c5caf8940232..66a7200f1c3b 100644 --- a/CRM/Mailing/Page/Tab.php +++ b/CRM/Mailing/Page/Tab.php @@ -66,7 +66,7 @@ public function preProcess() { // Check logged in url permission. CRM_Contact_Page_View::checkUserPermission($this); - CRM_Utils_System::setTitle(ts('Mailings sent to %1', array(1 => $displayName))); + CRM_Utils_System::setTitle(ts('Mailings sent to %1', [1 => $displayName])); } /** diff --git a/CRM/Mailing/Page/View.php b/CRM/Mailing/Page/View.php index 91f9164b5765..b8282405a3e5 100644 --- a/CRM/Mailing/Page/View.php +++ b/CRM/Mailing/Page/View.php @@ -143,7 +143,7 @@ public function run($id = NULL, $contactID = NULL, $print = TRUE, $allowID = FAL $returnProperties = $this->_mailing->getReturnProperties(); if (isset($this->_contactID)) { // get details of contact with token value including Custom Field Token Values.CRM-3734 - $params = array('contact_id' => $this->_contactID); + $params = ['contact_id' => $this->_contactID]; $details = CRM_Utils_Token::getTokenDetails($params, $returnProperties, FALSE, TRUE, NULL, @@ -155,7 +155,7 @@ public function run($id = NULL, $contactID = NULL, $print = TRUE, $allowID = FAL } else { // get tokens that are not contact specific resolved - $params = array('contact_id' => 0); + $params = ['contact_id' => 0]; $details = CRM_Utils_Token::getAnonymousTokenDetails($params, $returnProperties, TRUE, TRUE, NULL, diff --git a/CRM/Mailing/PseudoConstant.php b/CRM/Mailing/PseudoConstant.php index 84dbc6aa0bc1..d6186b9d342a 100644 --- a/CRM/Mailing/PseudoConstant.php +++ b/CRM/Mailing/PseudoConstant.php @@ -89,11 +89,11 @@ class CRM_Mailing_PseudoConstant extends CRM_Core_PseudoConstant { */ public static function abStatus() { if (!is_array(self::$abStatus)) { - self::$abStatus = array( + self::$abStatus = [ 'Draft' => ts('Draft'), 'Testing' => ts('Testing'), 'Final' => ts('Final'), - ); + ]; } return self::$abStatus; } @@ -103,11 +103,11 @@ public static function abStatus() { */ public static function abTestCriteria() { if (!is_array(self::$abTestCriteria)) { - self::$abTestCriteria = array( + self::$abTestCriteria = [ 'subject' => ts('Test different "Subject" lines'), 'from' => ts('Test different "From" lines'), 'full_email' => ts('Test entirely different emails'), - ); + ]; } return self::$abTestCriteria; } @@ -117,11 +117,11 @@ public static function abTestCriteria() { */ public static function abWinnerCriteria() { if (!is_array(self::$abWinnerCriteria)) { - self::$abWinnerCriteria = array( + self::$abWinnerCriteria = [ 'open' => ts('Open'), 'unique_click' => ts('Total Unique Clicks'), 'link_click' => ts('Total Clicks on a particular link'), - ); + ]; } return self::$abWinnerCriteria; } @@ -131,11 +131,11 @@ public static function abWinnerCriteria() { */ public static function mailingTypes() { if (!is_array(self::$mailingTypes)) { - self::$mailingTypes = array( + self::$mailingTypes = [ 'standalone' => ts('Standalone'), 'experiment' => ts('Experimental'), 'winner' => ts('Winner'), - ); + ]; } return self::$mailingTypes; } @@ -154,7 +154,7 @@ public static function &component($type = NULL) { if (!self::$component || !array_key_exists($name, self::$component)) { if (!self::$component) { - self::$component = array(); + self::$component = []; } if (!$type) { self::$component[$name] = NULL; @@ -162,7 +162,7 @@ public static function &component($type = NULL) { } else { // we need to add an additional filter for $type - self::$component[$name] = array(); + self::$component[$name] = []; $object = new CRM_Mailing_BAO_MailingComponent(); $object->component_type = $type; @@ -200,7 +200,7 @@ public static function &defaultComponent($type, $undefined = NULL) { $dao = CRM_Core_DAO::executeQuery($queryDefaultComponents); - self::$defaultComponent = array(); + self::$defaultComponent = []; while ($dao->fetch()) { self::$defaultComponent[$dao->component_type] = $dao->id; } @@ -258,28 +258,28 @@ public static function &completed($mode = NULL) { public static function &yesNoOptions($field) { static $options; if (!$options) { - $options = array( - 'bounce' => array( + $options = [ + 'bounce' => [ 'N' => ts('Successful '), 'Y' => ts('Bounced '), - ), - 'delivered' => array( + ], + 'delivered' => [ 'Y' => ts('Successful '), 'N' => ts('Bounced '), - ), - 'open' => array( + ], + 'open' => [ 'Y' => ts('Opened '), 'N' => ts('Unopened/Hidden '), - ), - 'click' => array( + ], + 'click' => [ 'Y' => ts('Clicked '), 'N' => ts('Not Clicked '), - ), - 'reply' => array( + ], + 'reply' => [ 'Y' => ts('Replied '), 'N' => ts('No Reply '), - ), - ); + ], + ]; } return $options[$field]; } diff --git a/CRM/Mailing/Selector/Browse.php b/CRM/Mailing/Selector/Browse.php index b99adbf033f3..84014a0b1b30 100644 --- a/CRM/Mailing/Selector/Browse.php +++ b/CRM/Mailing/Selector/Browse.php @@ -116,78 +116,78 @@ public function &getColumnHeaders($action = NULL, $output = NULL) { } $nameHeaderLabel = ($this->_parent->get('sms')) ? ts('SMS Name') : ts('Mailing Name'); - self::$_columnHeaders = array( - array( + self::$_columnHeaders = [ + [ 'name' => $nameHeaderLabel, 'sort' => 'name', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - ); + ], + ]; if (CRM_Core_I18n::isMultilingual()) { self::$_columnHeaders = array_merge( self::$_columnHeaders, - array( - array( + [ + [ 'name' => ts('Language'), 'sort' => 'language', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - ) + ], + ] ); } self::$_columnHeaders = array_merge( self::$_columnHeaders, - array( - array( + [ + [ 'name' => ts('Status'), 'sort' => 'status', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - array( + ], + [ 'name' => ts('Created By'), 'sort' => 'created_by', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - array( + ], + [ 'name' => ts('Created Date'), 'sort' => 'created_date', 'direction' => $unscheduledOrder, - ), - array( + ], + [ 'name' => ts('Sent By'), 'sort' => 'scheduled_by', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - array( + ], + [ 'name' => ts('Scheduled'), 'sort' => 'scheduled_date', 'direction' => $scheduledOrder, - ), - array( + ], + [ 'name' => ts('Started'), 'sort' => 'start_date', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - array( + ], + [ 'name' => ts('Completed'), 'sort' => 'end_date', 'direction' => $completedOrder, - ), - ) + ], + ] ); if (CRM_Campaign_BAO_Campaign::isCampaignEnable()) { - self::$_columnHeaders[] = array( + self::$_columnHeaders[] = [ 'name' => ts('Campaign'), 'sort' => 'campaign_id', 'direction' => CRM_Utils_Sort::DONTCARE, - ); + ]; } if ($output != CRM_Core_Selector_Controller::EXPORT) { - self::$_columnHeaders[] = array('name' => ts('Action')); + self::$_columnHeaders[] = ['name' => ts('Action')]; } } @@ -209,7 +209,7 @@ public function getTotalCount($action) { $mailingACL = CRM_Mailing_BAO_Mailing::mailingACL(); // get the where clause. - $params = array(); + $params = []; $whereClause = "$mailingACL AND " . $this->whereClause($params); // CRM-11919 added addition ON clauses to mailing_job to match getRows @@ -248,65 +248,65 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { $deleteExtra = ts('Are you sure you want to delete this mailing?'); $archiveExtra = ts('Are you sure you want to archive this mailing?'); - $actionLinks = array( - CRM_Core_Action::ENABLE => array( + $actionLinks = [ + CRM_Core_Action::ENABLE => [ 'name' => ts('Approve/Reject'), 'url' => 'civicrm/mailing/approve', 'qs' => 'mid=%%mid%%&reset=1', 'title' => ts('Approve/Reject Mailing'), - ), - CRM_Core_Action::VIEW => array( + ], + CRM_Core_Action::VIEW => [ 'name' => ts('Report'), 'url' => 'civicrm/mailing/report', 'qs' => 'mid=%%mid%%&reset=1', 'title' => ts('View Mailing Report'), - ), - CRM_Core_Action::UPDATE => array( + ], + CRM_Core_Action::UPDATE => [ 'name' => ts('Re-Use'), 'url' => 'civicrm/mailing/send', 'qs' => 'mid=%%mid%%&reset=1', 'title' => ts('Re-Send Mailing'), - ), - CRM_Core_Action::DISABLE => array( + ], + CRM_Core_Action::DISABLE => [ 'name' => ts('Cancel'), 'url' => 'civicrm/mailing/browse', 'qs' => 'action=disable&mid=%%mid%%&reset=1', 'extra' => 'onclick="if (confirm(\'' . $cancelExtra . '\')) this.href+=\'&confirmed=1\'; else return false;"', 'title' => ts('Cancel Mailing'), - ), - CRM_Core_Action::PREVIEW => array( + ], + CRM_Core_Action::PREVIEW => [ 'name' => ts('Continue'), 'url' => 'civicrm/mailing/send', 'qs' => 'mid=%%mid%%&continue=true&reset=1', 'title' => ts('Continue Mailing'), - ), - CRM_Core_Action::DELETE => array( + ], + CRM_Core_Action::DELETE => [ 'name' => ts('Delete'), 'url' => 'civicrm/mailing/browse', 'qs' => 'action=delete&mid=%%mid%%&reset=1', 'extra' => 'onclick="if (confirm(\'' . $deleteExtra . '\')) this.href+=\'&confirmed=1\'; else return false;"', 'title' => ts('Delete Mailing'), - ), - CRM_Core_Action::RENEW => array( + ], + CRM_Core_Action::RENEW => [ 'name' => ts('Archive'), 'url' => 'civicrm/mailing/browse/archived', 'qs' => 'action=renew&mid=%%mid%%&reset=1', 'extra' => 'onclick="if (confirm(\'' . $archiveExtra . '\')) this.href+=\'&confirmed=1\'; else return false;"', 'title' => ts('Archive Mailing'), - ), - CRM_Core_Action::REOPEN => array( + ], + CRM_Core_Action::REOPEN => [ 'name' => ts('Resume'), 'url' => 'civicrm/mailing/browse', 'qs' => 'action=reopen&mid=%%mid%%&reset=1', 'title' => ts('Resume mailing'), - ), - CRM_Core_Action::CLOSE => array( + ], + CRM_Core_Action::CLOSE => [ 'name' => ts('Pause'), 'url' => 'civicrm/mailing/browse', 'qs' => 'action=close&mid=%%mid%%&reset=1', 'title' => ts('Pause mailing'), - ), - ); + ], + ]; } $allAccess = TRUE; @@ -333,7 +333,7 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { } $mailing = new CRM_Mailing_BAO_Mailing(); - $params = array(); + $params = []; $whereClause = ' AND ' . $this->whereClause($params); @@ -354,7 +354,7 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { if ($output != CRM_Core_Selector_Controller::EXPORT) { // create the appropriate $op to use for hook_civicrm_links - $pageTypes = array('view', 'mailing', 'browse'); + $pageTypes = ['view', 'mailing', 'browse']; if ($this->_parent->_unscheduled) { $pageTypes[] = 'unscheduled'; } @@ -391,11 +391,11 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { $actionMask = CRM_Core_Action::PREVIEW; } } - if (in_array($row['status'], array( + if (in_array($row['status'], [ 'Scheduled', 'Running', 'Paused', - ))) { + ])) { if ($allAccess || ($showApprovalLinks && $showCreateLinks && $showScheduleLinks) ) { @@ -417,7 +417,7 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { } } - if (in_array($row['status'], array('Complete', 'Canceled')) && + if (in_array($row['status'], ['Complete', 'Canceled']) && !$row['archived'] ) { if ($allAccess || $showCreateLinks) { @@ -441,20 +441,20 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { $validLinks = $actionLinks; if (($mailingUrl = CRM_Mailing_BAO_Mailing::getPublicViewUrl($row['id'])) != FALSE) { - $validLinks[CRM_Core_Action::BROWSE] = array( + $validLinks[CRM_Core_Action::BROWSE] = [ 'name' => ts('Public View'), 'url' => 'civicrm/mailing/view', 'qs' => 'id=%%mid%%&reset=1', 'title' => ts('Public View'), 'fe' => TRUE, - ); + ]; $actionMask |= CRM_Core_Action::BROWSE; } $rows[$key]['action'] = CRM_Core_Action::formLink( $validLinks, $actionMask, - array('mid' => $row['id']), + ['mid' => $row['id']], "more", FALSE, $opString, @@ -503,21 +503,21 @@ public function setParent($parent) { * @return int|string */ public function whereClause(&$params, $sortBy = TRUE) { - $values = $clauses = array(); + $values = $clauses = []; $isFormSubmitted = $this->_parent->get('hidden_find_mailings'); $title = $this->_parent->get('mailing_name'); if ($title) { $clauses[] = 'name LIKE %1'; if (strpos($title, '%') !== FALSE) { - $params[1] = array($title, 'String', FALSE); + $params[1] = [$title, 'String', FALSE]; } else { - $params[1] = array($title, 'String', TRUE); + $params[1] = [$title, 'String', TRUE]; } } - $dateClause1 = $dateClause2 = array(); + $dateClause1 = $dateClause2 = []; $from = $this->_parent->get('mailing_from'); if (!CRM_Utils_System::isNull($from)) { if ($this->_parent->get('unscheduled')) { @@ -527,7 +527,7 @@ public function whereClause(&$params, $sortBy = TRUE) { $dateClause1[] = 'civicrm_mailing_job.start_date >= %2'; $dateClause2[] = 'civicrm_mailing_job.scheduled_date >= %2'; } - $params[2] = array($from, 'String'); + $params[2] = [$from, 'String']; } $to = $this->_parent->get('mailing_to'); @@ -539,10 +539,10 @@ public function whereClause(&$params, $sortBy = TRUE) { $dateClause1[] = 'civicrm_mailing_job.start_date <= %3'; $dateClause2[] = 'civicrm_mailing_job.scheduled_date <= %3'; } - $params[3] = array($to, 'String'); + $params[3] = [$to, 'String']; } - $dateClauses = array(); + $dateClauses = []; if (!empty($dateClause1)) { $dateClauses[] = implode(' AND ', $dateClause1); } @@ -569,7 +569,7 @@ public function whereClause(&$params, $sortBy = TRUE) { if (!$isFormSubmitted && $this->_parent->get('scheduled')) { // mimic default behavior for scheduled screen $isArchived = 0; - $mailingStatus = array('Scheduled' => 1, 'Complete' => 1, 'Running' => 1, 'Paused' => 1, 'Canceled' => 1); + $mailingStatus = ['Scheduled' => 1, 'Complete' => 1, 'Running' => 1, 'Paused' => 1, 'Canceled' => 1]; } if (!$isFormSubmitted && $this->_parent->get('archived')) { // mimic default behavior for archived screen @@ -580,7 +580,7 @@ public function whereClause(&$params, $sortBy = TRUE) { $isDraft = 1; } - $statusClauses = array(); + $statusClauses = []; if ($isDraft) { $statusClauses[] = "civicrm_mailing.scheduled_id IS NULL"; } @@ -620,26 +620,26 @@ public function whereClause(&$params, $sortBy = TRUE) { $createOrSentBy = $this->_parent->get('sort_name'); if (!CRM_Utils_System::isNull($createOrSentBy)) { $clauses[] = '(createdContact.sort_name LIKE %4 OR scheduledContact.sort_name LIKE %4)'; - $params[4] = array('%' . $createOrSentBy . '%', 'String'); + $params[4] = ['%' . $createOrSentBy . '%', 'String']; } $createdId = $this->_parent->get('createdId'); if ($createdId) { $clauses[] = "(created_id = {$createdId})"; - $params[5] = array($createdId, 'Integer'); + $params[5] = [$createdId, 'Integer']; } $campainIds = $this->_parent->get('campaign_id'); if (!CRM_Utils_System::isNull($campainIds)) { if (!is_array($campainIds)) { - $campaignIds = array($campaignIds); + $campaignIds = [$campaignIds]; } $clauses[] = '( campaign_id IN ( ' . implode(' , ', array_values($campainIds)) . ' ) )'; } if ($language = $this->_parent->get('language')) { $clauses[] = "civicrm_mailing.language = %6"; - $params[6] = array($language, 'String'); + $params[6] = [$language, 'String']; } if (empty($clauses)) { @@ -651,7 +651,7 @@ public function whereClause(&$params, $sortBy = TRUE) { public function pagerAtoZ() { - $params = array(); + $params = []; $whereClause = $this->whereClause($params, FALSE); $query = " diff --git a/CRM/Mailing/Selector/Event.php b/CRM/Mailing/Selector/Event.php index 84b31f19fe34..0354321a92c6 100644 --- a/CRM/Mailing/Selector/Event.php +++ b/CRM/Mailing/Selector/Event.php @@ -119,7 +119,7 @@ public static function &links() { public function getPagerParams($action, &$params) { $params['csvString'] = NULL; $params['rowCount'] = CRM_Utils_Pager::ROWCOUNT; - $params['status'] = ts('%1 %%StatusMessage%%', array(1 => $this->eventToTitle())); + $params['status'] = ts('%1 %%StatusMessage%%', [1 => $this->eventToTitle()]); $params['buttonTop'] = 'PagerTopButton'; $params['buttonBottom'] = 'PagerBottomButton'; } @@ -146,18 +146,18 @@ public function &getColumnHeaders($action = NULL, $output = NULL) { $job = CRM_Mailing_BAO_MailingJob::getTableName(); if (!isset($this->_columnHeaders)) { - $this->_columnHeaders = array( - 'sort_name' => array( + $this->_columnHeaders = [ + 'sort_name' => [ 'name' => ts('Contact'), 'sort' => $contact . '.sort_name', 'direction' => CRM_Utils_Sort::ASCENDING, - ), - 'email' => array( + ], + 'email' => [ 'name' => ts('Email Address'), 'sort' => $email . '.email', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - ); + ], + ]; switch ($this->_event_type) { case 'queue': @@ -165,13 +165,13 @@ public function &getColumnHeaders($action = NULL, $output = NULL) { break; case 'delivered': - $this->_columnHeaders = array( - 'contact_id' => array( + $this->_columnHeaders = [ + 'contact_id' => [ 'name' => ts('Internal Contact ID'), 'sort' => $contact . '.id', 'direction' => CRM_Utils_Sort::ASCENDING, - ), - ) + $this->_columnHeaders; + ], + ] + $this->_columnHeaders; $dateSort = CRM_Mailing_Event_BAO_Delivered::getTableName() . '.time_stamp'; break; @@ -182,14 +182,14 @@ public function &getColumnHeaders($action = NULL, $output = NULL) { case 'bounce': $dateSort = CRM_Mailing_Event_BAO_Bounce::getTableName() . '.time_stamp'; $this->_columnHeaders = array_merge($this->_columnHeaders, - array( - array( + [ + [ 'name' => ts('Bounce Type'), - ), - array( + ], + [ 'name' => ts('Bounce Reason'), - ), - ) + ], + ] ); break; @@ -197,11 +197,11 @@ public function &getColumnHeaders($action = NULL, $output = NULL) { $dateSort = CRM_Mailing_Event_BAO_Forward::getTableName() . '.time_stamp'; $this->_columnHeaders = array_merge($this->_columnHeaders, - array( - array( + [ + [ 'name' => ts('Forwarded Email'), - ), - ) + ], + ] ); break; @@ -211,42 +211,42 @@ public function &getColumnHeaders($action = NULL, $output = NULL) { case 'unsubscribe': $dateSort = CRM_Mailing_Event_BAO_Unsubscribe::getTableName() . '.time_stamp'; - $this->_columnHeaders = array_merge($this->_columnHeaders, array( - array( + $this->_columnHeaders = array_merge($this->_columnHeaders, [ + [ 'name' => ts('Unsubscribe'), - ), - )); + ], + ]); break; case 'optout': $dateSort = CRM_Mailing_Event_BAO_Unsubscribe::getTableName() . '.time_stamp'; - $this->_columnHeaders = array_merge($this->_columnHeaders, array( - array( + $this->_columnHeaders = array_merge($this->_columnHeaders, [ + [ 'name' => ts('Opt-Out'), - ), - )); + ], + ]); break; case 'click': $dateSort = CRM_Mailing_Event_BAO_TrackableURLOpen::getTableName() . '.time_stamp'; - $this->_columnHeaders = array_merge($this->_columnHeaders, array( - array( + $this->_columnHeaders = array_merge($this->_columnHeaders, [ + [ 'name' => ts('URL'), - ), - )); + ], + ]); break; default: return 0; } - $this->_columnHeaders = array_merge($this->_columnHeaders, array( - 'date' => array( + $this->_columnHeaders = array_merge($this->_columnHeaders, [ + 'date' => [ 'name' => ts('Date'), 'sort' => $dateSort, 'direction' => CRM_Utils_Sort::DESCENDING, - ), - )); + ], + ]); } return $this->_columnHeaders; } @@ -448,7 +448,7 @@ public function eventToTitle() { static $events = NULL; if (empty($events)) { - $events = array( + $events = [ 'queue' => ts('Intended Recipients'), 'delivered' => ts('Successful Deliveries'), 'bounce' => ts('Bounces'), @@ -458,7 +458,7 @@ public function eventToTitle() { 'optout' => ts('Opt-out Requests'), 'click' => $this->_is_distinct ? ts('Unique Click-throughs') : ts('Click-throughs'), 'opened' => $this->_is_distinct ? ts('Unique Tracked Opens') : ts('Total Tracked Opens'), - ); + ]; } return $events[$this->_event_type]; } diff --git a/CRM/Mailing/Selector/Search.php b/CRM/Mailing/Selector/Search.php index 51f41f469d2b..2417a7ed2a9a 100644 --- a/CRM/Mailing/Selector/Search.php +++ b/CRM/Mailing/Selector/Search.php @@ -56,7 +56,7 @@ class CRM_Mailing_Selector_Search extends CRM_Core_Selector_Base implements CRM_ * Properties of contact we're interested in displaying * @var array */ - static $_properties = array( + static $_properties = [ 'contact_id', 'mailing_id', 'mailing_name', @@ -68,7 +68,7 @@ class CRM_Mailing_Selector_Search extends CRM_Core_Selector_Base implements CRM_ 'contact_opt_out', 'mailing_job_status', 'mailing_job_end_date', - ); + ]; /** * Are we restricting ourselves to a single contact @@ -192,26 +192,26 @@ public static function &links() { $extraParams = ($key) ? "&key={$key}" : NULL; $searchContext = ($context) ? "&context=$context" : NULL; - self::$_links = array( - CRM_Core_Action::VIEW => array( + self::$_links = [ + CRM_Core_Action::VIEW => [ 'name' => ts('View'), 'url' => 'civicrm/contact/view', 'qs' => "reset=1&cid=%%cid%%{$searchContext}{$extraParams}", 'title' => ts('View Contact Details'), - ), - CRM_Core_Action::UPDATE => array( + ], + CRM_Core_Action::UPDATE => [ 'name' => ts('Edit'), 'url' => 'civicrm/contact/add', 'qs' => "reset=1&action=update&cid=%%cid%%{$searchContext}{$extraParams}", 'title' => ts('Edit Contact Details'), - ), - CRM_Core_Action::DELETE => array( + ], + CRM_Core_Action::DELETE => [ 'name' => ts('Delete'), 'url' => 'civicrm/contact/view/delete', 'qs' => "reset=1&delete=1&cid=%%cid%%{$searchContext}{$extraParams}", 'title' => ts('Delete Contact'), - ), - ); + ], + ]; } return self::$_links; } @@ -279,8 +279,8 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { ); // process the result of the query - $rows = array(); - $permissions = array(CRM_Core_Permission::getPermission()); + $rows = []; + $permissions = [CRM_Core_Permission::getPermission()]; if (CRM_Core_Permission::check('delete contacts')) { $permissions[] = CRM_Core_Permission::DELETE; } @@ -288,7 +288,7 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { $qfKey = $this->_key; while ($result->fetch()) { - $row = array(); + $row = []; // the columns we are interested in foreach (self::$_properties as $property) { if (property_exists($result, $property)) { @@ -298,10 +298,10 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { $row['checkbox'] = CRM_Core_Form::CB_PREFIX . $result->mailing_recipients_id; - $actions = array( + $actions = [ 'cid' => $result->contact_id, 'cxt' => $this->_context, - ); + ]; $row['action'] = CRM_Core_Action::formLink( self::links($qfKey, $this->_context), @@ -342,45 +342,45 @@ public function getQILL() { */ public function &getColumnHeaders($action = NULL, $output = NULL) { if (!isset(self::$_columnHeaders)) { - self::$_columnHeaders = array( - array('desc' => ts('Contact Type')), - array( + self::$_columnHeaders = [ + ['desc' => ts('Contact Type')], + [ 'name' => ts('Name'), 'sort' => 'sort_name', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - array( + ], + [ 'name' => ts('Email'), 'sort' => 'email', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - array( + ], + [ 'name' => ts('Mailing Name'), 'sort' => 'mailing_name', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - array( + ], + [ 'name' => ts('Language'), 'sort' => 'language', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - array( + ], + [ 'name' => ts('Mailing Subject'), 'sort' => 'mailing_subject', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - array( + ], + [ 'name' => ts('Mailing Status'), 'sort' => 'mailing_job_status', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - array( + ], + [ 'name' => ts('Completed Date'), 'sort' => 'mailing_job_end_date', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - array('desc' => ts('Actions')), - ); + ], + ['desc' => ts('Actions')], + ]; } return self::$_columnHeaders; } diff --git a/CRM/Mailing/Task.php b/CRM/Mailing/Task.php index fbfd6077cb70..65664796e6a3 100644 --- a/CRM/Mailing/Task.php +++ b/CRM/Mailing/Task.php @@ -49,13 +49,13 @@ class CRM_Mailing_Task extends CRM_Core_Task { */ public static function tasks() { if (!(self::$_tasks)) { - self::$_tasks = array( - self::TASK_PRINT => array( + self::$_tasks = [ + self::TASK_PRINT => [ 'title' => ts('Print Mailing Recipients'), 'class' => 'CRM_Mailing_Form_Task_Print', 'result' => FALSE, - ), - ); + ], + ]; parent::tasks(); } @@ -73,8 +73,8 @@ public static function tasks() { * @return array * set of tasks that are valid for the user */ - public static function permissionedTaskTitles($permission, $params = array()) { - $tasks = array(); + public static function permissionedTaskTitles($permission, $params = []) { + $tasks = []; $tasks = parent::corePermissionedTaskTitles($tasks, $permission, $params); return $tasks; @@ -96,10 +96,10 @@ public static function getTask($value) { $value = self::TASK_PRINT; } - return array( + return [ self::$_tasks[$value]['class'], self::$_tasks[$value]['result'], - ); + ]; } } diff --git a/CRM/Mailing/Tokens.php b/CRM/Mailing/Tokens.php index 8069d8335e69..74cd6adee41d 100644 --- a/CRM/Mailing/Tokens.php +++ b/CRM/Mailing/Tokens.php @@ -40,7 +40,7 @@ class CRM_Mailing_Tokens extends \Civi\Token\AbstractTokenSubscriber { * Class constructor. */ public function __construct() { - parent::__construct('mailing', array( + parent::__construct('mailing', [ 'id' => ts('Mailing ID'), 'name' => ts('Mailing Name'), 'group' => ts('Mailing Group(s)'), @@ -54,7 +54,7 @@ public function __construct() { 'approveUrl' => ts('Mailing Approval URL'), 'creator' => ts('Mailing Creator (Name)'), 'creatorEmail' => ts('Mailing Creator (Email)'), - )); + ]); } /** @@ -78,9 +78,9 @@ public function prefetch(\Civi\Token\Event\TokenValueEvent $e) { ? $processor->context['mailing'] : CRM_Mailing_BAO_Mailing::findById($processor->context['mailingId']); - return array( + return [ 'mailing' => $mailing, - ); + ]; } /** diff --git a/CRM/Member/ActionMapping.php b/CRM/Member/ActionMapping.php index a33e55887136..3546c48f9086 100644 --- a/CRM/Member/ActionMapping.php +++ b/CRM/Member/ActionMapping.php @@ -50,7 +50,7 @@ class CRM_Member_ActionMapping extends \Civi\ActionSchedule\Mapping { * @param \Civi\ActionSchedule\Event\MappingRegisterEvent $registrations */ public static function onRegisterActionMappings(\Civi\ActionSchedule\Event\MappingRegisterEvent $registrations) { - $registrations->register(CRM_Member_ActionMapping::create(array( + $registrations->register(CRM_Member_ActionMapping::create([ 'id' => CRM_Member_ActionMapping::MEMBERSHIP_TYPE_MAPPING_ID, 'entity' => 'civicrm_membership', 'entity_label' => ts('Membership'), @@ -58,7 +58,7 @@ public static function onRegisterActionMappings(\Civi\ActionSchedule\Event\Mappi 'entity_value_label' => ts('Membership Type'), 'entity_status' => 'auto_renew_options', 'entity_status_label' => ts('Auto Renew Options'), - ))); + ])); } /** @@ -68,11 +68,11 @@ public static function onRegisterActionMappings(\Civi\ActionSchedule\Event\Mappi * Array(string $fieldName => string $fieldLabel). */ public function getDateFields() { - return array( + return [ 'join_date' => ts('Membership Join Date'), 'start_date' => ts('Membership Start Date'), 'end_date' => ts('Membership End Date'), - ); + ]; } /** diff --git a/CRM/Member/BAO/MembershipLog.php b/CRM/Member/BAO/MembershipLog.php index 37544276768b..d80a05d5e4bf 100644 --- a/CRM/Member/BAO/MembershipLog.php +++ b/CRM/Member/BAO/MembershipLog.php @@ -74,7 +74,7 @@ public static function resetModifiedID($contactID) { SET modified_id = null WHERE modified_id = %1"; - $params = array(1 => array($contactID, 'Integer')); + $params = [1 => [$contactID, 'Integer']]; CRM_Core_DAO::executeQuery($query, $params); } diff --git a/CRM/Member/BAO/MembershipPayment.php b/CRM/Member/BAO/MembershipPayment.php index 0241b7c454c2..bacf50d2f770 100644 --- a/CRM/Member/BAO/MembershipPayment.php +++ b/CRM/Member/BAO/MembershipPayment.php @@ -59,7 +59,7 @@ public static function create($params) { // We check for membership_id in case we are being called too early in the process. This is // cludgey but is part of the deprecation process (ie. we are trying to do everything // from LineItem::create with a view to eventually removing this fn & the table. - if (!civicrm_api3('Membership', 'getcount', array('id' => $params['membership_id']))) { + if (!civicrm_api3('Membership', 'getcount', ['id' => $params['membership_id']])) { return $dao; } @@ -74,10 +74,10 @@ public static function create($params) { // however, we can assume at this stage that any contribution id will have only one line item with that membership type in the line item table // OR the caller will have taken responsibility for updating the line items themselves so we will update using SQL here if (!isset($params['membership_type_id'])) { - $membership_type_id = civicrm_api3('membership', 'getvalue', array( + $membership_type_id = civicrm_api3('membership', 'getvalue', [ 'id' => $dao->membership_id, 'return' => 'membership_type_id', - )); + ]); } else { $membership_type_id = $params['membership_type_id']; @@ -87,11 +87,11 @@ public static function create($params) { SET entity_table = 'civicrm_membership', entity_id = %1 WHERE pv.membership_type_id = %2 AND contribution_id = %3"; - CRM_Core_DAO::executeQuery($sql, array( - 1 => array($dao->membership_id, 'Integer'), - 2 => array($membership_type_id, 'Integer'), - 3 => array($dao->contribution_id, 'Integer'), - )); + CRM_Core_DAO::executeQuery($sql, [ + 1 => [$dao->membership_id, 'Integer'], + 2 => [$membership_type_id, 'Integer'], + 3 => [$dao->contribution_id, 'Integer'], + ]); return $dao; } diff --git a/CRM/Member/BAO/MembershipStatus.php b/CRM/Member/BAO/MembershipStatus.php index 0f7f8ae41970..8b4b5329014b 100644 --- a/CRM/Member/BAO/MembershipStatus.php +++ b/CRM/Member/BAO/MembershipStatus.php @@ -92,7 +92,7 @@ public static function setIsActive($id, $is_active) { * @return CRM_Member_BAO_MembershipStatus */ public static function create($params) { - $ids = array(); + $ids = []; if (!empty($params['id'])) { $ids['membershipStatus'] = $params['id']; } @@ -119,7 +119,7 @@ public static function create($params) { * * @return object */ - public static function add(&$params, $ids = array()) { + public static function add(&$params, $ids = []) { $id = CRM_Utils_Array::value('id', $params, CRM_Utils_Array::value('membershipStatus', $ids)); if (!$id) { CRM_Core_DAO::setCreateDefaults($params, self::getDefaults()); @@ -157,12 +157,12 @@ public static function add(&$params, $ids = array()) { * @return array */ public static function getDefaults() { - return array( + return [ 'is_active' => FALSE, 'is_current_member' => FALSE, 'is_admin' => FALSE, 'is_default' => FALSE, - ); + ]; } /** @@ -173,7 +173,7 @@ public static function getDefaults() { * @return array */ public static function getMembershipStatus($membershipStatusId) { - $statusDetails = array(); + $statusDetails = []; $membershipStatus = new CRM_Member_DAO_MembershipStatus(); $membershipStatus->id = $membershipStatusId; if ($membershipStatus->find(TRUE)) { @@ -194,7 +194,7 @@ public static function del($membershipStatusId) { //checking if membership status is present in some other table $check = FALSE; - $dependency = array('Membership', 'MembershipLog'); + $dependency = ['Membership', 'MembershipLog']; foreach ($dependency as $name) { $baoString = 'CRM_Member_BAO_' . $name; $dao = new $baoString(); @@ -234,9 +234,9 @@ public static function del($membershipStatusId) { */ public static function getMembershipStatusByDate( $startDate, $endDate, $joinDate, - $statusDate = 'today', $excludeIsAdmin = FALSE, $membershipTypeID, $membership = array() + $statusDate = 'today', $excludeIsAdmin = FALSE, $membershipTypeID, $membership = [] ) { - $membershipDetails = array(); + $membershipDetails = []; if (!$statusDate || $statusDate == 'today') { $statusDate = getdate(); @@ -254,8 +254,8 @@ public static function getMembershipStatusByDate( $statusDate = CRM_Utils_Date::customFormat($statusDate, '%Y%m%d'); } - $dates = array('start', 'end', 'join'); - $events = array('start', 'end'); + $dates = ['start', 'end', 'join']; + $events = ['start', 'end']; foreach ($dates as $dat) { if (${$dat . 'Date'} && ${$dat . 'Date'} != "null") { @@ -362,7 +362,7 @@ public static function getMembershipStatusByDate( //we bundle the arguments into an array as we can't pass 8 variables to the hook otherwise // the membership array might contain the pre-altered settings so we don't want to merge this - $arguments = array( + $arguments = [ 'start_date' => $startDate, 'end_date' => $endDate, 'join_date' => $joinDate, @@ -371,7 +371,7 @@ public static function getMembershipStatusByDate( 'membership_type_id' => $membershipTypeID, 'start_event' => $startEvent, 'end_event' => $endEvent, - ); + ]; CRM_Utils_Hook::alterCalculatedMembershipStatus($membershipDetails, $arguments, $membership); return $membershipDetails; } @@ -382,7 +382,7 @@ public static function getMembershipStatusByDate( * @return array */ public static function getMembershipStatusCurrent() { - $statusIds = array(); + $statusIds = []; $membershipStatus = new CRM_Member_DAO_MembershipStatus(); $membershipStatus->is_current_member = 1; $membershipStatus->find(); diff --git a/CRM/Member/BAO/MembershipType.php b/CRM/Member/BAO/MembershipType.php index 6438cff3c0ec..521fa621cd91 100644 --- a/CRM/Member/BAO/MembershipType.php +++ b/CRM/Member/BAO/MembershipType.php @@ -39,7 +39,7 @@ class CRM_Member_BAO_MembershipType extends CRM_Member_DAO_MembershipType { */ static $_defaultMembershipType = NULL; - static $_membershipTypeInfo = array(); + static $_membershipTypeInfo = []; /** * Class constructor. @@ -94,7 +94,7 @@ public static function setIsActive($id, $is_active) { * @return \CRM_Member_DAO_MembershipType * @throws \CiviCRM_API3_Exception */ - public static function add(&$params, $ids = array()) { + public static function add(&$params, $ids = []) { // DEPRECATED Check if membershipType ID was passed in via $ids if (empty($params['id'])) { if (isset($ids['membershipType'])) { @@ -132,7 +132,7 @@ public static function add(&$params, $ids = array()) { if ($membershipTypeId) { // on update we may need to retrieve some details for the price field function - otherwise we get e-notices on attempts to retrieve // name etc - the presence of previous id tells us this is an update - $params = array_merge(civicrm_api3('membership_type', 'getsingle', array('id' => $membershipType->id)), $params); + $params = array_merge(civicrm_api3('membership_type', 'getsingle', ['id' => $membershipType->id]), $params); } self::createMembershipPriceField($params, $previousID, $membershipType->id); // update all price field value for quick config when membership type is set CRM-11718 @@ -153,8 +153,8 @@ public static function add(&$params, $ids = array()) { */ public static function flush() { CRM_Member_PseudoConstant::membershipType(NULL, TRUE); - civicrm_api3('membership', 'getfields', array('cache_clear' => 1, 'fieldname' => 'membership_type_id')); - civicrm_api3('profile', 'getfields', array('action' => 'submit', 'cache_clear' => 1)); + civicrm_api3('membership', 'getfields', ['cache_clear' => 1, 'fieldname' => 'membership_type_id']); + civicrm_api3('profile', 'getfields', ['action' => 'submit', 'cache_clear' => 1]); } /** @@ -168,11 +168,11 @@ public static function flush() { public static function del($membershipTypeId) { // Check dependencies. $check = FALSE; - $status = array(); - $dependency = array( + $status = []; + $dependency = [ 'Membership' => 'membership_type_id', 'MembershipBlock' => 'membership_type_default', - ); + ]; foreach ($dependency as $name => $field) { $baoString = 'CRM_Member_BAO_' . $name; @@ -190,20 +190,20 @@ public static function del($membershipTypeId) { if (in_array('Membership', $status)) { $findMembersURL = CRM_Utils_System::url('civicrm/member/search', 'reset=1'); $deleteURL = CRM_Utils_System::url('civicrm/contact/search/advanced', 'reset=1'); - $message .= '
    ' . ts('%3. There are some contacts who have this membership type assigned to them. Search for contacts with this membership type from Find Members. If you are still getting this message after deleting these memberships, there may be contacts in the Trash (deleted) with this membership type. Try using Advanced Search and checking "Search in Trash".', array( + $message .= '
    ' . ts('%3. There are some contacts who have this membership type assigned to them. Search for contacts with this membership type from Find Members. If you are still getting this message after deleting these memberships, there may be contacts in the Trash (deleted) with this membership type. Try using Advanced Search and checking "Search in Trash".', [ 1 => $findMembersURL, 2 => $deleteURL, 3 => $cnt, - )); + ]); $cnt++; } if (in_array('MembershipBlock', $status)) { $deleteURL = CRM_Utils_System::url('civicrm/admin/contribute', 'reset=1'); - $message .= ts('%2. This Membership Type is used in an Online Contribution page. Uncheck this membership type in the Memberships tab.', array( + $message .= ts('%2. This Membership Type is used in an Online Contribution page. Uncheck this membership type in the Memberships tab.', [ 1 => $deleteURL, 2 => $cnt, - )); + ]); throw new CRM_Core_Exception($message); } } @@ -228,17 +228,17 @@ public static function del($membershipTypeId) { * An array of membershipType-details. */ public static function convertDayFormat(&$membershipType) { - $periodDays = array( + $periodDays = [ 'fixed_period_start_day', 'fixed_period_rollover_day', - ); + ]; foreach ($membershipType as $id => $details) { foreach ($periodDays as $pDay) { if (!empty($details[$pDay])) { if ($details[$pDay] > 31) { $month = substr($details[$pDay], 0, strlen($details[$pDay]) - 2); $day = substr($details[$pDay], -2); - $monthMap = array( + $monthMap = [ '1' => 'Jan', '2' => 'Feb', '3' => 'Mar', @@ -251,7 +251,7 @@ public static function convertDayFormat(&$membershipType) { '10' => 'Oct', '11' => 'Nov', '12' => 'Dec', - ); + ]; $membershipType[$id][$pDay] = $monthMap[$month] . ' ' . $day; } else { @@ -270,7 +270,7 @@ public static function convertDayFormat(&$membershipType) { * @return array */ public static function getMembershipTypes($public = TRUE) { - $membershipTypes = array(); + $membershipTypes = []; $membershipType = new CRM_Member_DAO_MembershipType(); $membershipType->is_active = 1; if ($public) { @@ -292,7 +292,7 @@ public static function getMembershipTypes($public = TRUE) { * @return array|null */ public static function getMembershipTypeDetails($membershipTypeId) { - $membershipTypeDetails = array(); + $membershipTypeDetails = []; $membershipType = new CRM_Member_DAO_MembershipType(); $membershipType->is_active = 1; @@ -326,11 +326,11 @@ public static function getDatesForMembershipType($membershipTypeId, $joinDate = $membershipTypeDetails = self::getMembershipTypeDetails($membershipTypeId); // Convert all dates to 'Y-m-d' format. - foreach (array( + foreach ([ 'joinDate', 'startDate', 'endDate', - ) as $dateParam) { + ] as $dateParam) { if (!empty($$dateParam)) { $$dateParam = CRM_Utils_Date::processDate($$dateParam, NULL, FALSE, 'Y-m-d'); } @@ -438,11 +438,11 @@ public static function getDatesForMembershipType($membershipTypeId, $joinDate = } } - $membershipDates = array( + $membershipDates = [ 'start_date' => CRM_Utils_Date::customFormat($startDate, '%Y%m%d'), 'end_date' => CRM_Utils_Date::customFormat($endDate, '%Y%m%d'), 'join_date' => CRM_Utils_Date::customFormat($joinDate, '%Y%m%d'), - ); + ]; return $membershipDates; } @@ -517,11 +517,11 @@ public static function isDuringFixedAnnualRolloverPeriod($startDate, $membership * array fo the start date, end date and join date of the membership */ public static function getRenewalDatesForMembershipType($membershipId, $changeToday = NULL, $membershipTypeID = NULL, $numRenewTerms = 1) { - $params = array('id' => $membershipId); + $params = ['id' => $membershipId]; $membershipDetails = CRM_Member_BAO_Membership::getValues($params, $values); $membershipDetails = $membershipDetails[$membershipId]; $statusID = $membershipDetails->status_id; - $membershipDates = array(); + $membershipDates = []; if (!empty($membershipDetails->join_date)) { $membershipDates['join_date'] = CRM_Utils_Date::customFormat($membershipDetails->join_date, '%Y%m%d'); } @@ -636,13 +636,13 @@ public static function getRenewalDatesForMembershipType($membershipId, $changeTo */ public static function getMembershipTypesByOrg($orgID) { CRM_Core_Error::deprecatedFunctionWarning('membership_type api'); - $memberTypesSameParentOrg = civicrm_api3('MembershipType', 'get', array( + $memberTypesSameParentOrg = civicrm_api3('MembershipType', 'get', [ 'member_of_contact_id' => $orgID, - 'options' => array( + 'options' => [ 'limit' => 0, - ), - )); - return CRM_Utils_Array::value('values', $memberTypesSameParentOrg, array()); + ], + ]); + return CRM_Utils_Array::value('values', $memberTypesSameParentOrg, []); } /** @@ -654,7 +654,7 @@ public static function getMembershipTypesByOrg($orgID) { * array of the details of membership types with Member of Contact id */ public static function getMemberOfContactByMemTypes($membershipTypes) { - $memTypeOrganizations = array(); + $memTypeOrganizations = []; if (empty($membershipTypes)) { return $memTypeOrganizations; } @@ -675,7 +675,7 @@ public static function getMemberOfContactByMemTypes($membershipTypes) { * @return array */ public static function getMembershipTypeOrganization($membershipTypeId = NULL) { - $allMembershipTypes = array(); + $allMembershipTypes = []; $membershipType = new CRM_Member_DAO_MembershipType(); @@ -700,7 +700,7 @@ public static function getMembershipTypeOrganization($membershipTypeId = NULL) { */ public static function getMembershipTypeInfo() { if (!self::$_membershipTypeInfo) { - $orgs = $types = array(); + $orgs = $types = []; $query = 'SELECT memType.id, memType.name, memType.member_of_contact_id, c.sort_name FROM civicrm_membership_type memType INNER JOIN civicrm_contact c ON c.id = memType.member_of_contact_id @@ -711,7 +711,7 @@ public static function getMembershipTypeInfo() { $types[$dao->member_of_contact_id][$dao->id] = $dao->name; } - self::$_membershipTypeInfo = array($orgs, $types); + self::$_membershipTypeInfo = [$orgs, $types]; } return self::$_membershipTypeInfo; } @@ -734,14 +734,14 @@ public static function createMembershipPriceField($params, $previousID, $members } $fieldLabel = 'Membership Amount'; $optionsIds = NULL; - $fieldParams = array( + $fieldParams = [ 'price_set_id ' => $priceSetId, 'name' => $fieldName, - ); - $results = array(); + ]; + $results = []; CRM_Price_BAO_PriceField::retrieve($fieldParams, $results); if (empty($results)) { - $fieldParams = array(); + $fieldParams = []; $fieldParams['label'] = $fieldLabel; $fieldParams['name'] = $fieldName; $fieldParams['price_set_id'] = $priceSetId; @@ -763,11 +763,11 @@ public static function createMembershipPriceField($params, $previousID, $members } else { $fieldID = $results['id']; - $fieldValueParams = array( + $fieldValueParams = [ 'price_field_id' => $fieldID, 'membership_type_id' => $membershipTypeId, - ); - $results = array(); + ]; + $results = []; CRM_Price_BAO_PriceFieldValue::retrieve($fieldValueParams, $results); if (!empty($results)) { $results['label'] = $results['name'] = $params['name']; @@ -775,14 +775,14 @@ public static function createMembershipPriceField($params, $previousID, $members $optionsIds['id'] = $results['id']; } else { - $results = array( + $results = [ 'price_field_id' => $fieldID, 'name' => $params['name'], 'label' => $params['name'], 'amount' => empty($params['minimum_fee']) ? 0 : $params['minimum_fee'], 'membership_type_id' => $membershipTypeId, 'is_active' => 1, - ); + ]; } if ($previousID) { @@ -806,26 +806,26 @@ public static function createMembershipPriceField($params, $previousID, $members * @param array $params */ public static function updateAllPriceFieldValue($membershipTypeId, $params) { - $defaults = array(); - $fieldsToUpdate = array( + $defaults = []; + $fieldsToUpdate = [ 'financial_type_id' => 'financial_type_id', 'name' => 'label', 'minimum_fee' => 'amount', 'description' => 'description', 'visibility' => 'visibility_id', - ); + ]; $priceFieldValueBAO = new CRM_Price_BAO_PriceFieldValue(); $priceFieldValueBAO->membership_type_id = $membershipTypeId; $priceFieldValueBAO->find(); while ($priceFieldValueBAO->fetch()) { - $updateParams = array( + $updateParams = [ 'id' => $priceFieldValueBAO->id, 'price_field_id' => $priceFieldValueBAO->price_field_id, - ); + ]; //Get priceset details. - $fieldParams = array('fid' => $priceFieldValueBAO->price_field_id); + $fieldParams = ['fid' => $priceFieldValueBAO->price_field_id]; $setID = CRM_Price_BAO_PriceSet::getSetId($fieldParams); - $setParams = array('id' => $setID); + $setParams = ['id' => $setID]; $setValues = CRM_Price_BAO_PriceSet::retrieve($setParams, $defaults); if (!empty($setValues->is_quick_config) && $setValues->name != 'default_membership_type_amount') { foreach ($fieldsToUpdate as $key => $value) { diff --git a/CRM/Member/BAO/Query.php b/CRM/Member/BAO/Query.php index 23a3e5d05073..19a526d7f86e 100644 --- a/CRM/Member/BAO/Query.php +++ b/CRM/Member/BAO/Query.php @@ -174,7 +174,7 @@ public static function whereClauseSingle(&$values, &$query) { case 'membership_start_date': case 'member_start_date_low': case 'member_start_date_high': - $fldName = str_replace(array('_low', '_high'), '', $name); + $fldName = str_replace(['_low', '_high'], '', $name); $query->dateQueryBuilder($values, 'civicrm_membership', $fldName, 'start_date', 'Start Date' @@ -184,7 +184,7 @@ public static function whereClauseSingle(&$values, &$query) { case 'membership_end_date': case 'member_end_date_low': case 'member_end_date_high': - $fldName = str_replace(array('_low', '_high'), '', $name); + $fldName = str_replace(['_low', '_high'], '', $name); $query->dateQueryBuilder($values, 'civicrm_membership', $fldName, 'end_date', 'End Date' @@ -197,7 +197,7 @@ public static function whereClauseSingle(&$values, &$query) { if ($date) { $query->_where[$grouping][] = "civicrm_membership.join_date {$op} {$date}"; $format = CRM_Utils_Date::customFormat(CRM_Utils_Date::format(array_reverse($value), '-')); - $query->_qill[$grouping][] = ts('Member Since %2 %1', array(1 => $format, 2 => $op)); + $query->_qill[$grouping][] = ts('Member Since %2 %1', [1 => $format, 2 => $op]); } return; @@ -208,7 +208,7 @@ public static function whereClauseSingle(&$values, &$query) { $value = $strtolower(CRM_Core_DAO::escapeString(trim($value))); $query->_where[$grouping][] = "civicrm_membership.source $op '{$value}'"; - $query->_qill[$grouping][] = ts('Source %2 %1', array(1 => $value, 2 => $op)); + $query->_qill[$grouping][] = ts('Source %2 %1', [1 => $value, 2 => $op]); $query->_tables['civicrm_membership'] = $query->_whereTables['civicrm_membership'] = 1; return; @@ -230,7 +230,7 @@ public static function whereClauseSingle(&$values, &$query) { // the load function. The where clause and the whereTables are saved so they should suffice to generate the query // to get a contact list. But, better to deal with in 4.8 now... if (is_string($value) && strpos($value, ',') && $op == '=') { - $value = array('IN' => explode(',', $value)); + $value = ['IN' => explode(',', $value)]; } case 'membership_id': case 'member_id': // CRM-18523 Updated to membership_id but kept member_id case for backwards compatibility @@ -282,7 +282,7 @@ public static function whereClauseSingle(&$values, &$query) { case 'member_auto_renew': $op = '='; - $where = $qill = array(); + $where = $qill = []; foreach ($value as $val) { if ($val == 1) { $where[] = ' civicrm_membership.contribution_recur_id IS NULL'; @@ -434,7 +434,7 @@ public static function defaultReturnProperties( ) { $properties = NULL; if ($mode & CRM_Contact_BAO_Query::MODE_MEMBER) { - $properties = array( + $properties = [ 'contact_type' => 1, 'contact_sub_type' => 1, 'sort_name' => 1, @@ -454,7 +454,7 @@ public static function defaultReturnProperties( 'member_campaign_id' => 1, 'member_is_override' => 1, 'member_auto_renew' => 1, - ); + ]; if ($includeCustomFields) { // also get all the custom membership properties @@ -477,21 +477,21 @@ public static function defaultReturnProperties( */ public static function buildSearchForm(&$form) { $membershipStatus = CRM_Member_PseudoConstant::membershipStatus(NULL, NULL, 'label', FALSE, FALSE); - $form->add('select', 'membership_status_id', ts('Membership Status'), $membershipStatus, FALSE, array( + $form->add('select', 'membership_status_id', ts('Membership Status'), $membershipStatus, FALSE, [ 'id' => 'membership_status_id', 'multiple' => 'multiple', 'class' => 'crm-select2', - )); + ]); - $form->addEntityRef('membership_type_id', ts('Membership Type'), array( + $form->addEntityRef('membership_type_id', ts('Membership Type'), [ 'entity' => 'MembershipType', 'multiple' => TRUE, 'placeholder' => ts('- any -'), - 'select' => array('minimumInputLength' => 0), - )); + 'select' => ['minimumInputLength' => 0], + ]); $form->addElement('text', 'member_source', ts('Source')); - $form->add('number', 'membership_id', ts('Membership ID'), array('class' => 'four', 'min' => 1)); + $form->add('number', 'membership_id', ts('Membership ID'), ['class' => 'four', 'min' => 1]); CRM_Core_Form_Date::buildDateRange($form, 'member_join_date', 1, '_low', '_high', ts('From'), FALSE); $form->addElement('hidden', 'member_join_date_range_error'); @@ -502,7 +502,7 @@ public static function buildSearchForm(&$form) { CRM_Core_Form_Date::buildDateRange($form, 'member_end_date', 1, '_low', '_high', ts('From'), FALSE); $form->addElement('hidden', 'member_end_date_range_error'); - $form->addFormRule(array('CRM_Member_BAO_Query', 'formRule'), $form); + $form->addFormRule(['CRM_Member_BAO_Query', 'formRule'], $form); $form->addYesNo('membership_is_current_member', ts('Current Member?'), TRUE); $form->addYesNo('member_is_primary', ts('Primary Member?'), TRUE); @@ -510,26 +510,26 @@ public static function buildSearchForm(&$form) { $form->add('select', 'member_auto_renew', ts('Auto-Renew Subscription Status?'), - array( + [ '1' => ts('- None -'), '2' => ts('In Progress'), '3' => ts('Failed'), '4' => ts('Cancelled'), '5' => ts('Ended'), '6' => ts('Any'), - ), - FALSE, array('class' => 'crm-select2', 'multiple' => 'multiple', 'placeholder' => ts('- any -')) + ], + FALSE, ['class' => 'crm-select2', 'multiple' => 'multiple', 'placeholder' => ts('- any -')] ); $form->addYesNo('member_test', ts('Membership is a Test?'), TRUE); $form->addYesNo('member_is_override', ts('Membership Status Is Overriden?'), TRUE); - self::addCustomFormFields($form, array('Membership')); + self::addCustomFormFields($form, ['Membership']); CRM_Campaign_BAO_Campaign::addCampaignInComponentSearch($form, 'member_campaign_id'); $form->assign('validCiviMember', TRUE); - $form->setDefaults(array('member_test' => 0)); + $form->setDefaults(['member_test' => 0]); } /** @@ -539,7 +539,7 @@ public static function buildSearchForm(&$form) { */ public static function tableNames(&$tables) { if (!empty($tables['civicrm_membership_log']) || !empty($tables['civicrm_membership_status']) || CRM_Utils_Array::value('civicrm_membership_type', $tables)) { - $tables = array_merge(array('civicrm_membership' => 1), $tables); + $tables = array_merge(['civicrm_membership' => 1], $tables); } } @@ -553,7 +553,7 @@ public static function tableNames(&$tables) { * @return bool|array */ public static function formRule($fields, $files, $form) { - $errors = array(); + $errors = []; if ((empty($fields['member_join_date_low']) || empty($fields['member_join_date_high'])) && (empty($fields['member_start_date_low']) || empty($fields['member_start_date_high'])) && (empty($fields['member_end_date_low']) || empty($fields['member_end_date_high']))) { return TRUE; diff --git a/CRM/Member/Form.php b/CRM/Member/Form.php index 602a54da655f..724aeed5528e 100644 --- a/CRM/Member/Form.php +++ b/CRM/Member/Form.php @@ -55,21 +55,21 @@ class CRM_Member_Form extends CRM_Contribute_Form_AbstractEditPayment { * Array of from email ids * @var array */ - protected $_fromEmails = array(); + protected $_fromEmails = []; /** * Details of all enabled membership types. * * @var array */ - protected $allMembershipTypeDetails = array(); + protected $allMembershipTypeDetails = []; /** * Array of membership type IDs and whether they permit autorenewal. * * @var array */ - protected $membershipTypeRenewalStatus = array(); + protected $membershipTypeRenewalStatus = []; /** * Price set ID configured for the form. @@ -120,7 +120,7 @@ protected function getStatusMessage() { * * @var array */ - protected $_params = array(); + protected $_params = []; /** * Fields for the entity to be assigned to the template. @@ -151,7 +151,7 @@ public function preProcess() { } parent::preProcess(); - $params = array(); + $params = []; $params['context'] = CRM_Utils_Request::retrieve('context', 'Alphanumeric', $this, FALSE, 'membership'); $params['id'] = CRM_Utils_Request::retrieve('id', 'Positive', $this); $params['mode'] = CRM_Utils_Request::retrieve('mode', 'Alphanumeric', $this); @@ -160,7 +160,7 @@ public function preProcess() { $this->assign('context', $this->_context); $this->assign('membershipMode', $this->_mode); - $this->allMembershipTypeDetails = CRM_Member_BAO_Membership::buildMembershipTypeValues($this, array(), TRUE); + $this->allMembershipTypeDetails = CRM_Member_BAO_Membership::buildMembershipTypeValues($this, [], TRUE); foreach ($this->allMembershipTypeDetails as $index => $membershipType) { if ($membershipType['auto_renew']) { $this->_recurMembershipTypes[$index] = $membershipType; @@ -178,9 +178,9 @@ public function preProcess() { * defaults */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; if (isset($this->_id)) { - $params = array('id' => $this->_id); + $params = ['id' => $this->_id]; CRM_Member_BAO_Membership::retrieve($params, $defaults); if (isset($defaults['minimum_fee'])) { $defaults['minimum_fee'] = CRM_Utils_Money::format($defaults['minimum_fee'], NULL, '%a'); @@ -213,7 +213,7 @@ public function setDefaultValues() { $this->_memType = $defaults['membership_type_id']; } if (is_numeric($this->_memType)) { - $defaults['membership_type_id'] = array(); + $defaults['membership_type_id'] = []; $defaults['membership_type_id'][0] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $this->_memType, 'member_of_contact_id', @@ -243,7 +243,7 @@ public function buildQuickForm() { } $autoRenewElement = $this->addElement('checkbox', 'auto_renew', ts('Membership renewed automatically'), - NULL, array('onclick' => "showHideByValue('auto_renew','','send-receipt','table-row','radio',true); showHideNotice( );") + NULL, ['onclick' => "showHideByValue('auto_renew','','send-receipt','table-row','radio',true); showHideNotice( );"] ); if ($this->_action & CRM_Core_Action::UPDATE) { $autoRenewElement->freeze(); @@ -259,48 +259,48 @@ public function buildQuickForm() { $this->assign('autoRenewOptions', json_encode($this->membershipTypeRenewalStatus)); if ($this->_action & CRM_Core_Action::RENEW) { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'upload', 'name' => ts('Renew'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - )); + ], + ]); } elseif ($this->_action & CRM_Core_Action::DELETE) { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => ts('Delete'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - )); + ], + ]); } else { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'upload', 'name' => ts('Save'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'upload', 'name' => ts('Save and New'), 'subName' => 'new', - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - )); + ], + ]); } } @@ -355,13 +355,13 @@ public function storeContactFields($formValues) { * @param array $params */ protected function setContextVariables($params) { - $variables = array( + $variables = [ 'action' => '_action', 'context' => '_context', 'id' => '_id', 'cid' => '_contactID', 'mode' => '_mode', - ); + ]; foreach ($variables as $paramKey => $classVar) { if (isset($params[$paramKey]) && !isset($this->$classVar)) { $this->$classVar = $params[$paramKey]; @@ -388,7 +388,7 @@ protected function setContextVariables($params) { */ protected function processRecurringContribution($paymentParams) { $membershipID = $paymentParams['membership_type_id'][1]; - $contributionRecurParams = array( + $contributionRecurParams = [ 'contact_id' => $paymentParams['contactID'], 'amount' => $paymentParams['total_amount'], 'contribution_status_id' => 'Pending', @@ -398,18 +398,18 @@ protected function processRecurringContribution($paymentParams) { 'is_email_receipt' => $paymentParams['is_email_receipt'], 'payment_instrument_id' => $paymentParams['payment_instrument_id'], 'invoice_id' => $paymentParams['invoice_id'], - ); + ]; - $mapping = array( + $mapping = [ 'frequency_interval' => 'duration_interval', 'frequency_unit' => 'duration_unit', - ); - $membershipType = civicrm_api3('MembershipType', 'getsingle', array( + ]; + $membershipType = civicrm_api3('MembershipType', 'getsingle', [ 'id' => $membershipID, 'return' => $mapping, - )); + ]); - $returnParams = array('is_recur' => TRUE); + $returnParams = ['is_recur' => TRUE]; foreach ($mapping as $recurringFieldName => $membershipTypeFieldName) { $contributionRecurParams[$recurringFieldName] = $membershipType[$membershipTypeFieldName]; $returnParams[$recurringFieldName] = $membershipType[$membershipTypeFieldName]; diff --git a/CRM/Member/Form/Membership.php b/CRM/Member/Form/Membership.php index c7df8f5bf1ff..bbf97b31cd59 100644 --- a/CRM/Member/Form/Membership.php +++ b/CRM/Member/Form/Membership.php @@ -99,7 +99,7 @@ class CRM_Member_Form_Membership extends CRM_Member_Form { * * @var array */ - protected $_membershipIDs = array(); + protected $_membershipIDs = []; /** * Set entity fields to be assigned to the form. @@ -159,10 +159,10 @@ public function addFormButtons() {} * @return array */ public static function getSelectedMemberships($priceSet, $params) { - $memTypeSelected = array(); + $memTypeSelected = []; $priceFieldIDS = self::getPriceFieldIDs($params, $priceSet); if (isset($params['membership_type_id']) && !empty($params['membership_type_id'][1])) { - $memTypeSelected = array($params['membership_type_id'][1] => $params['membership_type_id'][1]); + $memTypeSelected = [$params['membership_type_id'][1] => $params['membership_type_id'][1]]; } else { foreach ($priceFieldIDS as $priceFieldId) { @@ -183,7 +183,7 @@ public static function getSelectedMemberships($priceSet, $params) { * @return array */ public static function getPriceFieldIDs($params, $priceSet) { - $priceFieldIDS = array(); + $priceFieldIDS = []; if (isset($priceSet['fields']) && is_array($priceSet['fields'])) { foreach ($priceSet['fields'] as $fieldId => $field) { if (!empty($params['price_' . $fieldId])) { @@ -231,16 +231,16 @@ public function preProcess() { if ($this->_action & CRM_Core_Action::ADD) { if ($this->_contactID) { //check whether contact has a current membership so we can alert user that they may want to do a renewal instead - $contactMemberships = array(); - $memParams = array('contact_id' => $this->_contactID); + $contactMemberships = []; + $memParams = ['contact_id' => $this->_contactID]; CRM_Member_BAO_Membership::getValues($memParams, $contactMemberships, TRUE); - $cMemTypes = array(); + $cMemTypes = []; foreach ($contactMemberships as $mem) { $cMemTypes[] = $mem['membership_type_id']; } if (count($cMemTypes) > 0) { $memberorgs = CRM_Member_BAO_MembershipType::getMemberOfContactByMemTypes($cMemTypes); - $mems_by_org = array(); + $mems_by_org = []; foreach ($contactMemberships as $mem) { $mem['member_of_contact_id'] = CRM_Utils_Array::value($mem['membership_type_id'], $memberorgs); if (!empty($mem['membership_end_date'])) { @@ -270,12 +270,12 @@ public function preProcess() { // In standalone mode we don't have a contact id yet so lookup will be done client-side with this script: $resources = CRM_Core_Resources::singleton(); $resources->addScriptFile('civicrm', 'templates/CRM/Member/Form/MembershipStandalone.js'); - $passthru = array( + $passthru = [ 'typeorgs' => CRM_Member_BAO_MembershipType::getMembershipTypeOrganization(), 'memtypes' => CRM_Core_PseudoConstant::get('CRM_Member_BAO_Membership', 'membership_type_id'), 'statuses' => CRM_Core_PseudoConstant::get('CRM_Member_BAO_Membership', 'status_id'), - ); - $resources->addSetting(array('existingMems' => $passthru)); + ]; + $resources->addSetting(['existingMems' => $passthru]); } } @@ -342,8 +342,8 @@ public function setDefaultValues() { $defaults['soft_credit_type_id'] = CRM_Utils_Array::value(ts('Gift'), array_flip($scTypes)); if (!empty($defaults['record_contribution']) && !$this->_mode) { - $contributionParams = array('id' => $defaults['record_contribution']); - $contributionIds = array(); + $contributionParams = ['id' => $defaults['record_contribution']]; + $contributionIds = []; //keep main object campaign in hand. $memberCampaignId = CRM_Utils_Array::value('campaign_id', $defaults); @@ -434,7 +434,7 @@ public function buildQuickForm() { $this->set('priceSetId', $this->_priceSetId); CRM_Price_BAO_PriceSet::buildPriceSet($this); - $optionsMembershipTypes = array(); + $optionsMembershipTypes = []; foreach ($this->_priceSet['fields'] as $pField) { if (empty($pField['options'])) { continue; @@ -467,36 +467,36 @@ public function buildQuickForm() { if ($buildPriceSet) { $this->add('select', 'price_set_id', ts('Choose price set'), - array( + [ '' => ts('Choose price set'), - ) + $priceSets, - NULL, array('onchange' => "buildAmount( this.value );") + ] + $priceSets, + NULL, ['onchange' => "buildAmount( this.value );"] ); } $this->assign('hasPriceSets', $buildPriceSet); } if ($this->_action & CRM_Core_Action::DELETE) { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => ts('Delete'), 'spacing' => '         ', 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - )); + ], + ]); return; } if ($this->_context == 'standalone') { - $this->addEntityRef('contact_id', ts('Contact'), array( + $this->addEntityRef('contact_id', ts('Contact'), [ 'create' => TRUE, - 'api' => array('extra' => array('email')), - ), TRUE); + 'api' => ['extra' => ['email']], + ], TRUE); } $selOrgMemType[0][0] = $selMemTypeOrg[0] = ts('- select -'); @@ -508,7 +508,7 @@ public function buildQuickForm() { CRM_Core_Error::statusBounce(ts('You do not have all the permissions needed for this page.')); } // retrieve all memberships - $allMembershipInfo = array(); + $allMembershipInfo = []; foreach ($this->allMembershipTypeDetails as $key => $values) { if ($this->_mode && empty($values['minimum_fee'])) { continue; @@ -536,14 +536,14 @@ public function buildQuickForm() { // build membership info array, which is used when membership type is selected to: // - set the payment information block // - set the max related block - $allMembershipInfo[$key] = array( + $allMembershipInfo[$key] = [ 'financial_type_id' => CRM_Utils_Array::value('financial_type_id', $values), 'total_amount' => CRM_Utils_Money::format($totalAmount, NULL, '%a'), 'total_amount_numeric' => $totalAmount, 'auto_renew' => CRM_Utils_Array::value('auto_renew', $values), 'has_related' => isset($values['relationship_type_id']), 'max_related' => CRM_Utils_Array::value('max_related', $values), - ); + ]; } $this->assign('allMembershipInfo', json_encode($allMembershipInfo)); @@ -560,9 +560,9 @@ public function buildQuickForm() { $selOrgMemType[$index] = $orgMembershipType; } - $memTypeJs = array( + $memTypeJs = [ 'onChange' => "buildMaxRelated(this.value,true); CRM.buildCustomData('Membership', this.value);", - ); + ]; if (!empty($this->_recurPaymentProcessors)) { $memTypeJs['onChange'] = "" . $memTypeJs['onChange'] . " buildAutoRenew(this.value, null, '{$this->_mode}');"; @@ -578,13 +578,13 @@ public function buildQuickForm() { $memTypeJs ); - $sel->setOptions(array($selMemTypeOrg, $selOrgMemType)); + $sel->setOptions([$selMemTypeOrg, $selOrgMemType]); if ($isUpdateToExistingRecurringMembership) { $sel->freeze(); } if ($this->_action & CRM_Core_Action::ADD) { - $this->add('number', 'num_terms', ts('Number of Terms'), array('size' => 6)); + $this->add('number', 'num_terms', ts('Number of Terms'), ['size' => 6]); } $this->add('text', 'source', ts('Source'), @@ -600,7 +600,7 @@ public function buildQuickForm() { if (!$this->_mode) { $this->add('select', 'status_id', ts('Membership Status'), - array('' => ts('- select -')) + CRM_Member_PseudoConstant::membershipStatus(NULL, NULL, 'label') + ['' => ts('- select -')] + CRM_Member_PseudoConstant::membershipStatus(NULL, NULL, 'label') ); $statusOverride = $this->addElement('select', 'is_override', ts('Status Override?'), @@ -610,7 +610,7 @@ public function buildQuickForm() { $statusOverride->freeze(); } - $this->add('datepicker', 'status_override_end_date', ts('Status Override End Date'), '', FALSE, array('minDate' => time(), 'time' => FALSE)); + $this->add('datepicker', 'status_override_end_date', ts('Status Override End Date'), '', FALSE, ['minDate' => time(), 'time' => FALSE]); $this->addElement('checkbox', 'record_contribution', ts('Record Membership Payment?')); @@ -621,16 +621,16 @@ public function buildQuickForm() { $this->add('select', 'payment_instrument_id', ts('Payment Method'), - array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(), - FALSE, array('onChange' => "return showHideByValue('payment_instrument_id','4','checkNumber','table-row','select',false);") + ['' => ts('- select -')] + CRM_Contribute_PseudoConstant::paymentInstrument(), + FALSE, ['onChange' => "return showHideByValue('payment_instrument_id','4','checkNumber','table-row','select',false);"] ); $this->add('text', 'trxn_id', ts('Transaction ID')); $this->addRule('trxn_id', ts('Transaction ID already exists in Database.'), - 'objectExists', array( + 'objectExists', [ 'CRM_Contribute_DAO_Contribution', $this->_id, 'trxn_id', - ) + ] ); $this->add('select', 'contribution_status_id', @@ -646,18 +646,18 @@ public function buildQuickForm() { } $this->add('select', 'financial_type_id', ts('Financial Type'), - array('' => ts('- select -')) + CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($financialTypes, $this->_action) + ['' => ts('- select -')] + CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($financialTypes, $this->_action) ); $this->addElement('checkbox', 'is_different_contribution_contact', ts('Record Payment from a Different Contact?')); - $this->addSelect('soft_credit_type_id', array('entity' => 'contribution_soft')); - $this->addEntityRef('soft_credit_contact_id', ts('Payment From'), array('create' => TRUE)); + $this->addSelect('soft_credit_type_id', ['entity' => 'contribution_soft']); + $this->addEntityRef('soft_credit_contact_id', ts('Payment From'), ['create' => TRUE]); $this->addElement('checkbox', 'send_receipt', ts('Send Confirmation and Receipt?'), NULL, - array('onclick' => "showEmailOptions()") + ['onclick' => "showEmailOptions()"] ); $this->add('select', 'from_email_address', ts('Receipt From'), $this->_fromEmails); @@ -682,7 +682,7 @@ public function buildQuickForm() { $this->assign('isRecur', $isUpdateToExistingRecurringMembership); - $this->addFormRule(array('CRM_Member_Form_Membership', 'formRule'), $this); + $this->addFormRule(['CRM_Member_Form_Membership', 'formRule'], $this); $mailingInfo = Civi::settings()->get('mailing_backend'); $this->assign('isEmailEnabledForSite', ($mailingInfo['outBound_option'] != 2)); @@ -703,7 +703,7 @@ public function buildQuickForm() { * mixed true or array of errors */ public static function formRule($params, $files, $self) { - $errors = array(); + $errors = []; $priceSetId = self::getPriceSetID($params); $priceSetDetails = self::getPriceSetDetails($params); @@ -809,12 +809,12 @@ public static function formRule($params, $files, $self) { if ($membershipDetails['duration_unit'] == 'lifetime') { // Check if status is NOT cancelled or similar. For lifetime memberships, there is no automated // process to update status based on end-date. The user must change the status now. - $result = civicrm_api3('MembershipStatus', 'get', array( + $result = civicrm_api3('MembershipStatus', 'get', [ 'sequential' => 1, 'is_current_member' => 0, - )); + ]); $tmp_statuses = $result['values']; - $status_ids = array(); + $status_ids = []; foreach ($tmp_statuses as $cur_stat) { $status_ids[] = $cur_stat['id']; } @@ -868,7 +868,7 @@ public static function formRule($params, $files, $self) { if (empty($calcStatus)) { $url = CRM_Utils_System::url('civicrm/admin/member/membershipStatus', 'reset=1&action=browse'); $errors['_qf_default'] = ts('There is no valid Membership Status available for selected membership dates.'); - $status = ts('Oops, it looks like there is no valid membership status available for the given membership dates. You can Configure Membership Status Rules.', array(1 => $url)); + $status = ts('Oops, it looks like there is no valid membership status available for the given membership dates. You can Configure Membership Status Rules.', [1 => $url]); if (!$self->_mode) { $status .= ' ' . ts('OR You can sign up by setting Status Override? to something other than "NO".'); } @@ -1066,7 +1066,7 @@ public static function emailReceipt(&$form, &$formValues, &$membership, $customV } list($mailSend, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate( - array( + [ 'groupName' => 'msg_tpl_workflow_membership', 'valueName' => 'membership_offline_receipt', 'contactId' => $form->_receiptContactId, @@ -1077,7 +1077,7 @@ public static function emailReceipt(&$form, &$formValues, &$membership, $customV 'isEmailPdf' => $isEmailPdf, 'contributionId' => $formValues['contribution_id'], 'isTest' => (bool) ($form->_action & CRM_Core_Action::PREVIEW), - ) + ] ); return TRUE; @@ -1093,10 +1093,10 @@ public function submit() { $this->storeContactFields($this->_params); $this->beginPostProcess(); $joinDate = $startDate = $endDate = NULL; - $membershipTypes = $membership = $calcDate = array(); + $membershipTypes = $membership = $calcDate = []; $membershipType = NULL; $paymentInstrumentID = $this->_paymentProcessor['object']->getPaymentInstrumentID(); - $params = $softParams = $ids = array(); + $params = $softParams = $ids = []; $mailSend = FALSE; $this->processBillingAddress(); @@ -1123,7 +1123,7 @@ public function submit() { $config = CRM_Core_Config::singleton(); - $membershipTypeValues = array(); + $membershipTypeValues = []; foreach ($this->_memTypeSelected as $memType) { $membershipTypeValues[$memType]['membership_type_id'] = $memType; } @@ -1131,15 +1131,15 @@ public function submit() { //take the required membership recur values. if ($this->_mode && !empty($formValues['auto_renew'])) { $params['is_recur'] = $formValues['is_recur'] = TRUE; - $mapping = array( + $mapping = [ 'frequency_interval' => 'duration_interval', 'frequency_unit' => 'duration_unit', - ); + ]; $count = 0; foreach ($this->_memTypeSelected as $memType) { $recurMembershipTypeValues = CRM_Utils_Array::value($memType, - $this->_recurMembershipTypes, array() + $this->_recurMembershipTypes, [] ); foreach ($mapping as $mapVal => $mapParam) { $membershipTypeValues[$memType][$mapVal] = CRM_Utils_Array::value($mapParam, @@ -1157,9 +1157,9 @@ public function submit() { $isQuickConfig = $this->_priceSet['is_quick_config']; - $termsByType = array(); + $termsByType = []; - $lineItem = array($this->_priceSetId => array()); + $lineItem = [$this->_priceSetId => []]; CRM_Price_BAO_PriceSet::processAmount($this->_priceSet['fields'], $formValues, $lineItem[$this->_priceSetId], NULL, $this->_priceSetId); @@ -1188,13 +1188,13 @@ public function submit() { $params['contact_id'] = $this->_contactID; - $fields = array( + $fields = [ 'status_id', 'source', 'is_override', 'status_override_end_date', 'campaign_id', - ); + ]; foreach ($fields as $f) { $params[$f] = CRM_Utils_Array::value($f, $formValues); @@ -1208,18 +1208,18 @@ public function submit() { } // process date params to mysql date format. - $dateTypes = array( + $dateTypes = [ 'join_date' => 'joinDate', 'start_date' => 'startDate', 'end_date' => 'endDate', - ); + ]; foreach ($dateTypes as $dateField => $dateVariable) { $$dateVariable = CRM_Utils_Date::processDate($formValues[$dateField]); } $memTypeNumTerms = empty($termsByType) ? CRM_Utils_Array::value('num_terms', $formValues) : NULL; - $calcDates = array(); + $calcDates = []; foreach ($this->_memTypeSelected as $memType) { if (empty($memTypeNumTerms)) { $memTypeNumTerms = CRM_Utils_Array::value($memType, $termsByType, 1); @@ -1272,7 +1272,7 @@ public function submit() { $pendingMembershipStatusId = CRM_Core_PseudoConstant::getKey('CRM_Member_BAO_Membership', 'status_id', 'Pending'); if (!empty($formValues['record_contribution'])) { - $recordContribution = array( + $recordContribution = [ 'total_amount', 'financial_type_id', 'payment_instrument_id', @@ -1283,7 +1283,7 @@ public function submit() { 'receive_date', 'card_type_id', 'pan_truncation', - ); + ]; foreach ($recordContribution as $f) { $params[$f] = CRM_Utils_Array::value($f, $formValues); @@ -1291,10 +1291,10 @@ public function submit() { if (!$this->_onlinePendingContributionId) { if (empty($formValues['source'])) { - $params['contribution_source'] = ts('%1 Membership: Offline signup (by %2)', array( + $params['contribution_source'] = ts('%1 Membership: Offline signup (by %2)', [ 1 => $membershipType, 2 => $userName, - )); + ]); } else { $params['contribution_source'] = $formValues['source']; @@ -1326,7 +1326,7 @@ public function submit() { $params['lineItems'] = $lineItem; $params['processPriceSet'] = TRUE; } - $createdMemberships = array(); + $createdMemberships = []; if ($this->_mode) { $params['total_amount'] = CRM_Utils_Array::value('total_amount', $formValues, 0); @@ -1388,7 +1388,7 @@ public function submit() { $contribution = CRM_Contribute_Form_Contribution_Confirm::processFormContribution($this, $paymentParams, NULL, - array( + [ 'contact_id' => $this->_contributorContactID, 'line_item' => $lineItem, 'is_test' => $isTest, @@ -1397,7 +1397,7 @@ public function submit() { 'source' => CRM_Utils_Array::value('source', $paymentParams, CRM_Utils_Array::value('description', $paymentParams)), 'thankyou_date' => CRM_Utils_Array::value('thankyou_date', $paymentParams), 'payment_instrument_id' => $paymentInstrumentID, - ), + ], $financialType, FALSE, $this->_bltID, @@ -1454,11 +1454,11 @@ public function submit() { // unset send-receipt option, since receipt will be sent when ipn is received. unset($formValues['send_receipt'], $formValues['send_receipt']); //as membership is pending set dates to null. - $memberDates = array( + $memberDates = [ 'join_date' => 'joinDate', 'start_date' => 'startDate', 'end_date' => 'endDate', - ); + ]; foreach ($memberDates as $dv) { $$dv = NULL; foreach ($this->_memTypeSelected as $memType) { @@ -1470,7 +1470,7 @@ public function submit() { $params['receive_date'] = date('Y-m-d H:i:s'); $params['invoice_id'] = $formValues['invoiceID']; $params['contribution_source'] = ts('%1 Membership Signup: Credit card or direct debit (by %2)', - array(1 => $membershipType, 2 => $userName) + [1 => $membershipType, 2 => $userName] ); $params['source'] = $formValues['source'] ? $formValues['source'] : $params['contribution_source']; $params['trxn_id'] = CRM_Utils_Array::value('trxn_id', $result); @@ -1540,7 +1540,7 @@ public function submit() { $params['componentName'] = 'contribute'; $result = CRM_Contribute_BAO_Contribution::transitionComponents($params, TRUE); if (!empty($result) && !empty($params['contribution_id'])) { - $lineItem = array(); + $lineItem = []; $lineItems = CRM_Price_BAO_LineItem::getLineItemsByContributionID($params['contribution_id']); $itemId = key($lineItems); $priceSetId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', $lineItems[$itemId]['price_field_id'], 'price_set_id'); @@ -1576,11 +1576,11 @@ public function submit() { //display end date w/ status message. $endDate = $membership->end_date; - if (!in_array($membership->status_id, array( + if (!in_array($membership->status_id, [ // CRM-15475 array_search('Cancelled', CRM_Member_PseudoConstant::membershipStatus(NULL, " name = 'Cancelled' ", 'name', FALSE, TRUE)), array_search('Expired', CRM_Member_PseudoConstant::membershipStatus()), - )) + ]) ) { $cancelled = FALSE; } @@ -1605,7 +1605,7 @@ public function submit() { } $membershipParams = array_merge($params, $membershipTypeValues[$memType]); if (!empty($formValues['int_amount'])) { - $init_amount = array(); + $init_amount = []; foreach ($formValues as $key => $value) { if (strstr($key, 'txt-price')) { $init_amount[$key] = $value; @@ -1658,7 +1658,7 @@ public function submit() { } } if ($invoicing) { - $dataArray = array(); + $dataArray = []; foreach ($lineItem[$this->_priceSetId] as $key => $value) { if (isset($value['tax_amount']) && isset($value['tax_rate'])) { if (isset($dataArray[$value['tax_rate']])) { @@ -1711,7 +1711,7 @@ public function submit() { $this->updateContributionOnMembershipTypeChange($params, $membership); if ($receiptSent && $mailSend) { - $this->addStatusMessage(ts('A membership confirmation and receipt has been sent to %1.', array(1 => $this->_contributorEmail))); + $this->addStatusMessage(ts('A membership confirmation and receipt has been sent to %1.', [1 => $this->_contributorEmail])); } CRM_Core_Session::setStatus($this->getStatusMessage(), ts('Complete'), 'success'); @@ -1835,10 +1835,10 @@ protected function getStatusMessageForUpdate($membership, $endDate) { // End date can be modified by hooks, so if end date is set then use it. $endDate = ($membership->end_date) ? $membership->end_date : $endDate; - $statusMsg = ts('Membership for %1 has been updated.', array(1 => $this->_memberDisplayName)); + $statusMsg = ts('Membership for %1 has been updated.', [1 => $this->_memberDisplayName]); if ($endDate && $endDate !== 'null') { $endDate = CRM_Utils_Date::customFormat($endDate); - $statusMsg .= ' ' . ts('The membership End Date is %1.', array(1 => $endDate)); + $statusMsg .= ' ' . ts('The membership End Date is %1.', [1 => $endDate]); } return $statusMsg; } @@ -1858,12 +1858,12 @@ protected function getStatusMessageForCreate($endDate, $membershipTypes, $create $isRecur, $calcDates) { // FIX ME: fix status messages - $statusMsg = array(); + $statusMsg = []; foreach ($membershipTypes as $memType => $membershipType) { - $statusMsg[$memType] = ts('%1 membership for %2 has been added.', array( + $statusMsg[$memType] = ts('%1 membership for %2 has been added.', [ 1 => $membershipType, 2 => $this->_memberDisplayName, - )); + ]); $membership = $createdMemberships[$memType]; $memEndDate = ($membership->end_date) ? $membership->end_date : $endDate; @@ -1875,7 +1875,7 @@ protected function getStatusMessageForCreate($endDate, $membershipTypes, $create if ($memEndDate && $memEndDate !== 'null') { $memEndDate = CRM_Utils_Date::customFormat($memEndDate); - $statusMsg[$memType] .= ' ' . ts('The new membership End Date is %1.', array(1 => $memEndDate)); + $statusMsg[$memType] .= ' ' . ts('The new membership End Date is %1.', [1 => $memEndDate]); } } $statusMsg = implode('
    ', $statusMsg); diff --git a/CRM/Member/Form/MembershipBlock.php b/CRM/Member/Form/MembershipBlock.php index c34e535fef64..bf0f4554b686 100644 --- a/CRM/Member/Form/MembershipBlock.php +++ b/CRM/Member/Form/MembershipBlock.php @@ -50,7 +50,7 @@ class CRM_Member_Form_MembershipBlock extends CRM_Contribute_Form_ContributionPa */ public function setDefaultValues() { //parent::setDefaultValues(); - $defaults = array(); + $defaults = []; if (isset($this->_id)) { $defaults = CRM_Member_BAO_Membership::getMembershipBlock($this->_id); } @@ -75,13 +75,13 @@ public function setDefaultValues() { $priceSetId = CRM_Price_BAO_PriceSet::getFor('civicrm_contribution_page', $this->_id, 3); $this->assign('isQuick', 1); $this->_memPriceSetId = $priceSetId; - $pFIDs = array(); + $pFIDs = []; if ($priceSetId) { - CRM_Core_DAO::commonRetrieveAll('CRM_Price_DAO_PriceField', 'price_set_id', $priceSetId, $pFIDs, $return = array( + CRM_Core_DAO::commonRetrieveAll('CRM_Price_DAO_PriceField', 'price_set_id', $priceSetId, $pFIDs, $return = [ 'html_type', 'name', 'label', - )); + ]); foreach ($pFIDs as $pid => $pValue) { if ($pValue['html_type'] == 'Radio' && $pValue['name'] == 'membership_amount') { $defaults['mem_price_field_id'] = $pValue['id']; @@ -90,7 +90,7 @@ public function setDefaultValues() { } if (!empty($defaults['mem_price_field_id'])) { - $options = array(); + $options = []; $priceFieldOptions = CRM_Price_BAO_PriceFieldValue::getValues($defaults['mem_price_field_id'], $options, 'id', 1); foreach ($options as $k => $v) { $newMembershipType[$v['membership_type_id']] = 1; @@ -128,7 +128,7 @@ public function buildQuickForm() { $this->addElement('checkbox', 'is_required', ts('Require Membership Signup')); $this->addElement('checkbox', 'display_min_fee', ts('Display Membership Fee')); $this->addElement('checkbox', 'is_separate_payment', ts('Separate Membership Payment')); - $this->addElement('text', 'membership_type_label', ts('Membership Types Label'), array('placeholder' => ts('Membership'))); + $this->addElement('text', 'membership_type_label', ts('Membership Types Label'), ['placeholder' => ts('Membership')]); $paymentProcessor = CRM_Core_PseudoConstant::paymentProcessor(FALSE, FALSE, 'is_recur = 1'); $paymentProcessorIds = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', @@ -143,7 +143,7 @@ public function buildQuickForm() { } } - $membership = $membershipDefault = $params = array(); + $membership = $membershipDefault = $params = []; foreach ($membershipTypes as $k => $v) { $membership[] = $this->createElement('advcheckbox', $k, NULL, $v); $membershipDefault[] = $this->createElement('radio', NULL, NULL, NULL, $k); @@ -151,9 +151,9 @@ public function buildQuickForm() { if ($isRecur) { $autoRenew = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $k, 'auto_renew'); $membershipRequired[$k] = $autoRenew; - $autoRenewOptions = array(); + $autoRenewOptions = []; if ($autoRenew) { - $autoRenewOptions = array(ts('Not offered'), ts('Give option'), ts('Required')); + $autoRenewOptions = [ts('Not offered'), ts('Give option'), ts('Required')]; $this->addElement('select', "auto_renew_$k", ts('Auto-renew'), $autoRenewOptions); //CRM-15573 if ($autoRenew == 2) { @@ -170,7 +170,7 @@ public function buildQuickForm() { $params['membership_types'] = serialize($membershipRequired); CRM_Member_BAO_MembershipBlock::create($params); } - $this->add('hidden', "mem_price_field_id", '', array('id' => "mem_price_field_id")); + $this->add('hidden', "mem_price_field_id", '', ['id' => "mem_price_field_id"]); $this->assign('is_recur', $isRecur); if (isset($this->_renewOption)) { $this->assign('auto_renew', $this->_renewOption); @@ -179,7 +179,7 @@ public function buildQuickForm() { $this->addGroup($membershipDefault, 'membership_type_default', ts('Membership Types Default')) ->setAttribute('allowClear', TRUE); - $this->addFormRule(array('CRM_Member_Form_MembershipBlock', 'formRule'), $this->_id); + $this->addFormRule(['CRM_Member_Form_MembershipBlock', 'formRule'], $this->_id); } $price = CRM_Price_BAO_PriceSet::getAssoc(FALSE, 'CiviMember'); if (CRM_Utils_System::isNull($price)) { @@ -188,23 +188,23 @@ public function buildQuickForm() { else { $this->assign('price', TRUE); } - $this->add('select', 'member_price_set_id', ts('Membership Price Set'), (array('' => ts('- none -')) + $price)); + $this->add('select', 'member_price_set_id', ts('Membership Price Set'), (['' => ts('- none -')] + $price)); $session = CRM_Core_Session::singleton(); $single = $session->get('singleForm'); if ($single) { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => ts('Save'), 'spacing' => '         ', 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - )); + ], + ]); } else { parent::buildQuickForm(); @@ -224,7 +224,7 @@ public function buildQuickForm() { * mixed true or array of errors */ public static function formRule($params, $files, $contributionPageId = NULL) { - $errors = array(); + $errors = []; if (!empty($params['member_price_set_id'])) { //check if this price set has membership type both auto-renew and non-auto-renew memberships. @@ -280,7 +280,7 @@ public static function formRule($params, $files, $contributionPageId = NULL) { } elseif (array_sum($membershipType) > CRM_Price_Form_Field::NUM_OPTION) { // for CRM-13079 - $errors['membership_type'] = ts('You cannot select more than %1 choices. For more complex functionality, please use a Price Set.', array(1 => CRM_Price_Form_Field::NUM_OPTION)); + $errors['membership_type'] = ts('You cannot select more than %1 choices. For more complex functionality, please use a Price Set.', [1 => CRM_Price_Form_Field::NUM_OPTION]); } elseif ($isRecur) { if (empty($params['is_separate_payment']) && array_sum($membershipType) != 0) { @@ -342,7 +342,7 @@ public function postProcess() { $params['id'] = $membershipID; } - $membershipTypes = array(); + $membershipTypes = []; if (is_array($params['membership_type'])) { foreach ($params['membership_type'] as $k => $v) { if ($v) { @@ -391,16 +391,16 @@ public function postProcess() { $fieldParams['id'] = CRM_Utils_Array::value('mem_price_field_id', $params); $priceSetID = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', CRM_Utils_Array::value('mem_price_field_id', $params), 'price_set_id'); } - $editedFieldParams = array( + $editedFieldParams = [ 'price_set_id' => $priceSetID, 'name' => 'membership_amount', - ); - $editedResults = array(); + ]; + $editedResults = []; CRM_Price_BAO_PriceField::retrieve($editedFieldParams, $editedResults); if (empty($editedResults['id'])) { $fieldParams['name'] = strtolower(CRM_Utils_String::munge('Membership Amount', '_', 245)); if (empty($params['mem_price_field_id'])) { - CRM_Utils_Weight::updateOtherWeights('CRM_Price_DAO_PriceField', 0, 1, array('price_set_id' => $priceSetID)); + CRM_Utils_Weight::updateOtherWeights('CRM_Price_DAO_PriceField', 0, 1, ['price_set_id' => $priceSetID]); } $fieldParams['weight'] = 1; } @@ -414,7 +414,7 @@ public function postProcess() { $fieldParams['is_required'] = !empty($params['is_required']) ? 1 : 0; $fieldParams['is_display_amounts'] = !empty($params['display_min_fee']) ? 1 : 0; $rowCount = 1; - $options = array(); + $options = []; if (!empty($fieldParams['id'])) { CRM_Core_PseudoConstant::populate($options, 'CRM_Price_DAO_PriceFieldValue', TRUE, 'membership_type_id', NULL, " price_field_id = {$fieldParams['id']} "); } @@ -469,12 +469,12 @@ public function postProcess() { if ($deletePriceSet || !CRM_Utils_Array::value('member_is_active', $params, FALSE)) { if ($this->_memPriceSetId) { - $pFIDs = array(); - $conditionParams = array( + $pFIDs = []; + $conditionParams = [ 'price_set_id' => $this->_memPriceSetId, 'html_type' => 'radio', 'name' => 'contribution_amount', - ); + ]; CRM_Core_DAO::commonRetrieve('CRM_Price_DAO_PriceField', $conditionParams, $pFIDs); if (empty($pFIDs['id'])) { diff --git a/CRM/Member/Form/MembershipConfig.php b/CRM/Member/Form/MembershipConfig.php index b123c0c06490..60dc0a36a051 100644 --- a/CRM/Member/Form/MembershipConfig.php +++ b/CRM/Member/Form/MembershipConfig.php @@ -61,10 +61,10 @@ class CRM_Member_Form_MembershipConfig extends CRM_Core_Form { * defaults */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; if (isset($this->_id)) { - $params = array('id' => $this->_id); + $params = ['id' => $this->_id]; $baoName = $this->_BAOName; $baoName::retrieve($params, $defaults); } @@ -98,48 +98,48 @@ public function setDefaultValues() { */ public function buildQuickForm() { if ($this->_action & CRM_Core_Action::RENEW) { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'upload', 'name' => ts('Renew'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - )); + ], + ]); } elseif ($this->_action & CRM_Core_Action::DELETE) { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => ts('Delete'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - )); + ], + ]); } else { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'upload', 'name' => ts('Save'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'upload', 'name' => ts('Save and New'), 'subName' => 'new', - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - )); + ], + ]); } } diff --git a/CRM/Member/Form/MembershipRenewal.php b/CRM/Member/Form/MembershipRenewal.php index d90ea044e77b..e3857d1a5d15 100644 --- a/CRM/Member/Form/MembershipRenewal.php +++ b/CRM/Member/Form/MembershipRenewal.php @@ -235,7 +235,7 @@ public function buildQuickForm() { $this->assign('entityID', $this->_id); $selOrgMemType[0][0] = $selMemTypeOrg[0] = ts('- select -'); - $allMembershipInfo = array(); + $allMembershipInfo = []; // CRM-21485 if (is_array($defaults['membership_type_id'])) { @@ -280,12 +280,12 @@ public function buildQuickForm() { // build membership info array, which is used to set the payment information block when // membership type is selected. - $allMembershipInfo[$key] = array( + $allMembershipInfo[$key] = [ 'financial_type_id' => CRM_Utils_Array::value('financial_type_id', $values), 'total_amount' => CRM_Utils_Money::format($totalAmount, NULL, '%a'), 'total_amount_numeric' => $totalAmount, - 'tax_message' => $taxAmount ? ts("Includes %1 amount of %2", array(1 => $this->getSalesTaxTerm(), 2 => CRM_Utils_Money::format($taxAmount))) : $taxAmount, - ); + 'tax_message' => $taxAmount ? ts("Includes %1 amount of %2", [1 => $this->getSalesTaxTerm(), 2 => CRM_Utils_Money::format($taxAmount)]) : $taxAmount, + ]; if (!empty($values['auto_renew'])) { $allMembershipInfo[$key]['auto_renew'] = $options[$values['auto_renew']]; @@ -312,14 +312,14 @@ public function buildQuickForm() { $selOrgMemType[$index] = $orgMembershipType; } - $js = array('onChange' => "setPaymentBlock(); CRM.buildCustomData('Membership', this.value);"); + $js = ['onChange' => "setPaymentBlock(); CRM.buildCustomData('Membership', this.value);"]; $sel = &$this->addElement('hierselect', 'membership_type_id', ts('Renewal Membership Organization and Type'), $js ); - $sel->setOptions(array($selMemTypeOrg, $selOrgMemType)); - $elements = array(); + $sel->setOptions([$selMemTypeOrg, $selOrgMemType]); + $elements = []; if ($sel) { $elements[] = $sel; } @@ -329,14 +329,14 @@ public function buildQuickForm() { $this->add('datepicker', 'renewal_date', ts('Date Renewal Entered'), [], FALSE, ['time' => FALSE]); $this->add('select', 'financial_type_id', ts('Financial Type'), - array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::financialType() + ['' => ts('- select -')] + CRM_Contribute_PseudoConstant::financialType() ); - $this->add('number', 'num_terms', ts('Extend Membership by'), array('onchange' => "setPaymentBlock();"), TRUE); + $this->add('number', 'num_terms', ts('Extend Membership by'), ['onchange' => "setPaymentBlock();"], TRUE); $this->addRule('num_terms', ts('Please enter a whole number for how many periods to renew.'), 'integer'); if (CRM_Core_Permission::access('CiviContribute') && !$this->_mode) { - $this->addElement('checkbox', 'record_contribution', ts('Record Renewal Payment?'), NULL, array('onclick' => "checkPayment();")); + $this->addElement('checkbox', 'record_contribution', ts('Record Renewal Payment?'), NULL, ['onclick' => "checkPayment();"]); $this->add('text', 'total_amount', ts('Amount')); $this->addRule('total_amount', ts('Please enter a valid amount.'), 'money'); @@ -344,13 +344,13 @@ public function buildQuickForm() { $this->add('datepicker', 'receive_date', ts('Received'), [], FALSE, ['time' => TRUE]); $this->add('select', 'payment_instrument_id', ts('Payment Method'), - array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(), - FALSE, array('onChange' => "return showHideByValue('payment_instrument_id','4','checkNumber','table-row','select',false);") + ['' => ts('- select -')] + CRM_Contribute_PseudoConstant::paymentInstrument(), + FALSE, ['onChange' => "return showHideByValue('payment_instrument_id','4','checkNumber','table-row','select',false);"] ); $this->add('text', 'trxn_id', ts('Transaction ID')); $this->addRule('trxn_id', ts('Transaction ID already exists in Database.'), - 'objectExists', array('CRM_Contribute_DAO_Contribution', $this->_id, 'trxn_id') + 'objectExists', ['CRM_Contribute_DAO_Contribution', $this->_id, 'trxn_id'] ); $this->add('select', 'contribution_status_id', ts('Payment Status'), @@ -366,7 +366,7 @@ public function buildQuickForm() { $this->addRule('total_amount', ts('Please enter a valid amount.'), 'money'); } $this->addElement('checkbox', 'send_receipt', ts('Send Confirmation and Receipt?'), NULL, - array('onclick' => "showHideByValue( 'send_receipt', '', 'notice', 'table-row', 'radio', false ); showHideByValue( 'send_receipt', '', 'fromEmail', 'table-row', 'radio',false);") + ['onclick' => "showHideByValue( 'send_receipt', '', 'notice', 'table-row', 'radio', false ); showHideByValue( 'send_receipt', '', 'fromEmail', 'table-row', 'radio',false);"] ); $this->add('select', 'from_email_address', ts('Receipt From'), $this->_fromEmails); @@ -391,10 +391,10 @@ public function buildQuickForm() { ); } } - $this->addFormRule(array('CRM_Member_Form_MembershipRenewal', 'formRule'), $this); + $this->addFormRule(['CRM_Member_Form_MembershipRenewal', 'formRule'], $this); $this->addElement('checkbox', 'is_different_contribution_contact', ts('Record Payment from a Different Contact?')); - $this->addSelect('soft_credit_type_id', array('entity' => 'contribution_soft')); - $this->addEntityRef('soft_credit_contact_id', ts('Payment From'), array('create' => TRUE)); + $this->addSelect('soft_credit_type_id', ['entity' => 'contribution_soft']); + $this->addEntityRef('soft_credit_contact_id', ts('Payment From'), ['create' => TRUE]); } /** @@ -407,7 +407,7 @@ public function buildQuickForm() { * mixed true or array of errors */ public static function formRule($params, $files, $self) { - $errors = array(); + $errors = []; if ($params['membership_type_id'][0] == 0) { $errors['membership_type_id'] = ts('Oops. It looks like you are trying to change the membership type while renewing the membership. Please click the "change membership type" link, and select a Membership Organization.'); } @@ -454,18 +454,18 @@ public function postProcess() { try { $this->submit(); - $statusMsg = ts('%1 membership for %2 has been renewed.', array(1 => $this->membershipTypeName, 2 => $this->_memberDisplayName)); + $statusMsg = ts('%1 membership for %2 has been renewed.', [1 => $this->membershipTypeName, 2 => $this->_memberDisplayName]); if ($this->endDate) { - $statusMsg .= ' ' . ts('The new membership End Date is %1.', array( + $statusMsg .= ' ' . ts('The new membership End Date is %1.', [ 1 => CRM_Utils_Date::customFormat(substr($this->endDate, 0, 8)), - )); + ]); } if ($this->isMailSent) { - $statusMsg .= ' ' . ts('A renewal confirmation and receipt has been sent to %1.', array( + $statusMsg .= ' ' . ts('A renewal confirmation and receipt has been sent to %1.', [ 1 => $this->_contributorEmail, - )); + ]); return $statusMsg; } return $statusMsg; @@ -600,7 +600,7 @@ protected function submit() { $this->_params['contribution_source'] = "{$this->membershipTypeName} Membership: Offline membership renewal (by {$userName})"; //create line items - $lineItem = array(); + $lineItem = []; $this->_params = $this->setPriceSetParameters($this->_params); CRM_Price_BAO_PriceSet::processAmount($this->_priceSet['fields'], $this->_params, $lineItem[$this->_priceSetId], NULL, $this->_priceSetId @@ -623,10 +623,10 @@ protected function submit() { if ($this->_contributorContactID != $this->_contactID) { $this->_params['contribution_contact_id'] = $this->_contributorContactID; if (!empty($this->_params['soft_credit_type_id'])) { - $this->_params['soft_credit'] = array( + $this->_params['soft_credit'] = [ 'soft_credit_type_id' => $this->_params['soft_credit_type_id'], 'contact_id' => $this->_contactID, - ); + ]; } } $this->_params['contact_id'] = $this->_contactID; @@ -634,10 +634,10 @@ protected function submit() { // not a great pattern & ideally it would not receive as a reference. We assign our params as a // temporary variable to avoid e-notice & to make it clear to future refactorer that // this function is NOT reliant on that var being set - $temporaryParams = array_merge($this->_params, array( + $temporaryParams = array_merge($this->_params, [ 'membership_id' => $membership->id, 'contribution_recur_id' => $contributionRecurID, - )); + ]); //Remove `tax_amount` if it is not calculated. if (CRM_Utils_Array::value('tax_amount', $temporaryParams) === 0) { unset($temporaryParams['tax_amount']); @@ -657,7 +657,7 @@ protected function submit() { $this->_groupTree = CRM_Core_BAO_CustomGroup::getTree('Membership', NULL, $this->_id, FALSE, $this->_memType); // retrieve custom data - $customFields = $customValues = $fo = array(); + $customFields = $customValues = $fo = []; foreach ($this->_groupTree as $groupID => $group) { if ($groupID == 'info') { continue; @@ -667,10 +667,10 @@ protected function submit() { $customFields["custom_{$k}"] = $field; } } - $members = array(array('member_id', '=', $this->_membershipId, 0, 0)); + $members = [['member_id', '=', $this->_membershipId, 0, 0]]; // check whether its a test drive if ($this->_mode == 'test') { - $members[] = array('member_test', '=', 1, 0, 0); + $members[] = ['member_test', '=', 1, 0, 0]; } CRM_Core_BAO_UFGroup::getValues($this->_contactID, $customFields, $customValues, FALSE, $members); @@ -701,7 +701,7 @@ protected function submit() { } list($this->isMailSent) = CRM_Core_BAO_MessageTemplate::sendTemplate( - array( + [ 'groupName' => 'msg_tpl_workflow_membership', 'valueName' => 'membership_offline_receipt', 'contactId' => $this->_receiptContactId, @@ -709,7 +709,7 @@ protected function submit() { 'toName' => $this->_contributorDisplayName, 'toEmail' => $this->_contributorEmail, 'isTest' => $this->_mode == 'test', - ) + ] ); } } diff --git a/CRM/Member/Form/MembershipStatus.php b/CRM/Member/Form/MembershipStatus.php index ef768a078225..030ff03cd992 100644 --- a/CRM/Member/Form/MembershipStatus.php +++ b/CRM/Member/Form/MembershipStatus.php @@ -138,16 +138,16 @@ public function buildQuickForm() { $this->assign('id', $this->_id); } $this->addRule('label', ts('A membership status with this label already exists. Please select another label.'), - 'objectExists', array('CRM_Member_DAO_MembershipStatus', $this->_id, 'name') + 'objectExists', ['CRM_Member_DAO_MembershipStatus', $this->_id, 'name'] ); $this->add('select', 'start_event', ts('Start Event'), CRM_Core_SelectValues::eventDate(), TRUE); - $this->add('select', 'start_event_adjust_unit', ts('Start Event Adjustment'), array('' => ts('- select -')) + CRM_Core_SelectValues::unitList()); + $this->add('select', 'start_event_adjust_unit', ts('Start Event Adjustment'), ['' => ts('- select -')] + CRM_Core_SelectValues::unitList()); $this->add('text', 'start_event_adjust_interval', ts('Start Event Adjust Interval'), CRM_Core_DAO::getAttribute('CRM_Member_DAO_MembershipStatus', 'start_event_adjust_interval') ); - $this->add('select', 'end_event', ts('End Event'), array('' => ts('- select -')) + CRM_Core_SelectValues::eventDate()); - $this->add('select', 'end_event_adjust_unit', ts('End Event Adjustment'), array('' => ts('- select -')) + CRM_Core_SelectValues::unitList()); + $this->add('select', 'end_event', ts('End Event'), ['' => ts('- select -')] + CRM_Core_SelectValues::eventDate()); + $this->add('select', 'end_event_adjust_unit', ts('End Event Adjustment'), ['' => ts('- select -')] + CRM_Core_SelectValues::unitList()); $this->add('text', 'end_event_adjust_interval', ts('End Event Adjust Interval'), CRM_Core_DAO::getAttribute('CRM_Member_DAO_MembershipStatus', 'end_event_adjust_interval') ); @@ -197,7 +197,7 @@ public function postProcess() { $membershipStatus = CRM_Member_BAO_MembershipStatus::add($params); CRM_Core_Session::setStatus(ts('The membership status \'%1\' has been saved.', - array(1 => $membershipStatus->label) + [1 => $membershipStatus->label] ), ts('Saved'), 'success'); } } diff --git a/CRM/Member/Form/MembershipType.php b/CRM/Member/Form/MembershipType.php index be97a0881080..3e1c01588ee3 100644 --- a/CRM/Member/Form/MembershipType.php +++ b/CRM/Member/Form/MembershipType.php @@ -132,7 +132,7 @@ protected function setEntityFields() { ], ]; - if (!CRM_Financial_BAO_PaymentProcessor::hasPaymentProcessorSupporting(array('Recurring'))) { + if (!CRM_Financial_BAO_PaymentProcessor::hasPaymentProcessorSupporting(['Recurring'])) { $this->entityFields['auto_renew']['not-auto-addable'] = TRUE; $this->entityFields['auto_renew']['documentation_link'] = ['page' => 'user/contributions/payment-processors']; } @@ -206,19 +206,19 @@ public function setDefaultValues() { // Set values for relation type select box $relTypeIds = explode(CRM_Core_DAO::VALUE_SEPARATOR, $defaults['relationship_type_id']); $relDirections = explode(CRM_Core_DAO::VALUE_SEPARATOR, $defaults['relationship_direction']); - $defaults['relationship_type_id'] = array(); + $defaults['relationship_type_id'] = []; foreach ($relTypeIds as $key => $value) { $defaults['relationship_type_id'][] = $value . '_' . $relDirections[$key]; } } //setting default fixed_period_start_day & fixed_period_rollover_day - $periods = array('fixed_period_start_day', 'fixed_period_rollover_day'); + $periods = ['fixed_period_start_day', 'fixed_period_rollover_day']; foreach ($periods as $per) { if (isset($defaults[$per])) { $date = $defaults[$per]; - $defaults[$per] = array(); + $defaults[$per] = []; if ($date > 31) { $date = ($date < 999) ? '0' . $date : $date; $defaults[$per]['M'] = substr($date, 0, 2); @@ -254,11 +254,11 @@ public function buildQuickForm() { $this->assign('tpl_standardised_fields', ['name', 'description', 'member_of_contact_id', 'minimum_fee']); $this->addRule('name', ts('A membership type with this name already exists. Please select another name.'), - 'objectExists', array('CRM_Member_DAO_MembershipType', $this->_id) + 'objectExists', ['CRM_Member_DAO_MembershipType', $this->_id] ); $this->addRule('minimum_fee', ts('Please enter a monetary value for the Minimum Fee.'), 'money'); - $props = array('api' => array('params' => array('contact_type' => 'Organization'))); + $props = ['api' => ['params' => ['contact_type' => 'Organization']]]; $this->addEntityRef('member_of_contact_id', ts('Membership Organization'), $props, TRUE); //start day @@ -268,8 +268,8 @@ public function buildQuickForm() { // Add Auto-renew options if we have a payment processor that supports recurring contributions $isAuthorize = FALSE; - $options = array(); - if (CRM_Financial_BAO_PaymentProcessor::hasPaymentProcessorSupporting(array('Recurring'))) { + $options = []; + if (CRM_Financial_BAO_PaymentProcessor::hasPaymentProcessorSupporting(['Recurring'])) { $isAuthorize = TRUE; $options = CRM_Core_SelectValues::memberAutoRenew(); } @@ -285,7 +285,7 @@ public function buildQuickForm() { CRM_Core_SelectValues::date(NULL, 'd'), FALSE ); $this->add('select', 'financial_type_id', ts('Financial Type'), - array('' => ts('- select -')) + CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($financialTypes, $this->_action), TRUE, array('class' => 'crm-select2') + ['' => ts('- select -')] + CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($financialTypes, $this->_action), TRUE, ['class' => 'crm-select2'] ); $relTypeInd = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, NULL, NULL, NULL, TRUE); @@ -293,13 +293,13 @@ public function buildQuickForm() { asort($relTypeInd); } $memberRel = $this->add('select', 'relationship_type_id', ts('Relationship Type'), - $relTypeInd, FALSE, array('class' => 'crm-select2 huge', 'multiple' => 1)); + $relTypeInd, FALSE, ['class' => 'crm-select2 huge', 'multiple' => 1]); - $this->addField('visibility', array('placeholder' => NULL, 'option_url' => NULL)); + $this->addField('visibility', ['placeholder' => NULL, 'option_url' => NULL]); $membershipRecords = FALSE; if ($this->_action & CRM_Core_Action::UPDATE) { - $result = civicrm_api3("Membership", "get", array("membership_type_id" => $this->_id, "options" => array("limit" => 1))); + $result = civicrm_api3("Membership", "get", ["membership_type_id" => $this->_id, "options" => ["limit" => 1]]); $membershipRecords = ($result["count"] > 0); if ($membershipRecords) { $memberRel->freeze(); @@ -308,7 +308,7 @@ public function buildQuickForm() { $this->assign('membershipRecordsExists', $membershipRecords); - $this->addFormRule(array('CRM_Member_Form_MembershipType', 'formRule')); + $this->addFormRule(['CRM_Member_Form_MembershipType', 'formRule']); $this->assign('membershipTypeId', $this->_id); @@ -328,7 +328,7 @@ public function buildQuickForm() { * mixed true or array of errors */ public static function formRule($params) { - $errors = array(); + $errors = []; if (!$params['name']) { $errors['name'] = ts('Please enter a membership type name.'); @@ -342,10 +342,10 @@ public static function formRule($params) { $errors['duration_interval'] = ts('Please enter a duration interval.'); } - if (in_array(CRM_Utils_Array::value('auto_renew', $params), array( + if (in_array(CRM_Utils_Array::value('auto_renew', $params), [ 1, 2, - ))) { + ])) { if (($params['duration_interval'] > 1 && $params['duration_unit'] == 'year') || ($params['duration_interval'] > 12 && $params['duration_unit'] == 'month') ) { @@ -362,7 +362,7 @@ public static function formRule($params) { if (($params['period_type'] == 'fixed') && ($params['duration_unit'] == 'year') ) { - $periods = array('fixed_period_start_day', 'fixed_period_rollover_day'); + $periods = ['fixed_period_start_day', 'fixed_period_rollover_day']; foreach ($periods as $period) { $month = $params[$period]['M']; $date = $params[$period]['d']; @@ -423,7 +423,7 @@ public function postProcess() { if (!CRM_Utils_System::isNull($params['relationship_type_id'])) { // To insert relation ids and directions with value separator $relTypeDirs = $params['relationship_type_id']; - $relIds = $relDirection = array(); + $relIds = $relDirection = []; foreach ($relTypeDirs as $key => $value) { $relationId = explode('_', $value); if (count($relationId) == 3 && @@ -449,7 +449,7 @@ public function postProcess() { $params['duration_interval'] = 1; } - $periods = array('fixed_period_start_day', 'fixed_period_rollover_day'); + $periods = ['fixed_period_start_day', 'fixed_period_rollover_day']; foreach ($periods as $period) { if (!empty($params[$period]['M']) && !empty($params[$period]['d'])) { $mon = $params[$period]['M']; @@ -485,7 +485,7 @@ public function postProcess() { $membershipTypeName = $membershipTypeResult['values'][$membershipTypeResult['id']]['name']; CRM_Core_Session::setStatus(ts("The membership type '%1' has been saved.", - array(1 => $membershipTypeName) + [1 => $membershipTypeName] ), ts('Saved'), 'success'); $session = CRM_Core_Session::singleton(); $buttonName = $this->controller->getButtonName(); @@ -505,18 +505,18 @@ public function postProcess() { */ public static function checkPreviousPriceField($previousID, $priceSetId, $membershipTypeId, &$optionsIds) { if ($previousID) { - $editedFieldParams = array( + $editedFieldParams = [ 'price_set_id ' => $priceSetId, 'name' => $previousID, - ); - $editedResults = array(); + ]; + $editedResults = []; CRM_Price_BAO_PriceField::retrieve($editedFieldParams, $editedResults); if (!empty($editedResults)) { - $editedFieldParams = array( + $editedFieldParams = [ 'price_field_id' => $editedResults['id'], 'membership_type_id' => $membershipTypeId, - ); - $editedResults = array(); + ]; + $editedResults = []; CRM_Price_BAO_PriceFieldValue::retrieve($editedFieldParams, $editedResults); $optionsIds['option_id'][1] = CRM_Utils_Array::value('id', $editedResults); } diff --git a/CRM/Member/Form/MembershipView.php b/CRM/Member/Form/MembershipView.php index b5ac8470107c..3d60d9a9b652 100644 --- a/CRM/Member/Form/MembershipView.php +++ b/CRM/Member/Form/MembershipView.php @@ -67,7 +67,7 @@ class CRM_Member_Form_MembershipView extends CRM_Core_Form { */ public function addContext() { $extra = ''; - foreach (array('context', 'selectedChild') as $arg) { + foreach (['context', 'selectedChild'] as $arg) { if ($value = CRM_Utils_Request::retrieve($arg, 'String', $this)) { $extra .= "&{$arg}={$value}"; } @@ -83,20 +83,20 @@ public function addContext() { */ public function &links() { if (!(self::$_links)) { - self::$_links = array( - CRM_Core_Action::DELETE => array( + self::$_links = [ + CRM_Core_Action::DELETE => [ 'name' => ts('Delete'), 'url' => 'civicrm/contact/view/membership', 'qs' => 'action=view&id=%%id%%&cid=%%cid%%&relAction=delete&mid=%%mid%%&reset=1' . $this->addContext(), 'title' => ts('Cancel Related Membership'), - ), - CRM_Core_Action::ADD => array( + ], + CRM_Core_Action::ADD => [ 'name' => ts('Create'), 'url' => 'civicrm/contact/view/membership', 'qs' => 'action=view&id=%%id%%&cid=%%cid%%&relAction=create&rid=%%rid%%&reset=1' . $this->addContext(), 'title' => ts('Create Related Membership'), - ), - ); + ], + ]; } return self::$_links; } @@ -116,13 +116,13 @@ public function relAction($action, $owner) { $relatedContactId = CRM_Utils_Request::retrieve('cid', 'Positive', $this); $relatedDisplayName = CRM_Contact_BAO_Contact::displayName($relatedContactId); CRM_Member_BAO_Membership::del($id); - CRM_Core_Session::setStatus(ts('Related membership for %1 has been deleted.', array(1 => $relatedDisplayName)), + CRM_Core_Session::setStatus(ts('Related membership for %1 has been deleted.', [1 => $relatedDisplayName]), ts('Membership Deleted'), 'success'); break; case 'create': - $ids = array(); - $params = array( + $ids = []; + $params = [ 'contact_id' => CRM_Utils_Request::retrieve('rid', 'Positive', $this), 'membership_type_id' => $owner['membership_type_id'], 'owner_membership_id' => $owner['id'], @@ -135,10 +135,10 @@ public function relAction($action, $owner) { 'status_id' => $owner['status_id'], 'skipStatusCal' => TRUE, 'createActivity' => TRUE, - ); + ]; CRM_Member_BAO_Membership::create($params, $ids); $relatedDisplayName = CRM_Contact_BAO_Contact::displayName($params['contact_id']); - CRM_Core_Session::setStatus(ts('Related membership for %1 has been created.', array(1 => $relatedDisplayName)), + CRM_Core_Session::setStatus(ts('Related membership for %1 has been created.', [1 => $relatedDisplayName]), ts('Membership Added'), 'success'); break; @@ -161,7 +161,7 @@ public function relAction($action, $owner) { * @return void */ public function preProcess() { - $values = array(); + $values = []; $this->membershipID = CRM_Utils_Request::retrieve('id', 'Positive', $this); $this->contactID = CRM_Utils_Request::retrieve('cid', 'Positive', $this); @@ -170,7 +170,7 @@ public function preProcess() { $this->assign('context', $context); if ($this->membershipID) { - $params = array('id' => $this->membershipID); + $params = ['id' => $this->membershipID]; CRM_Member_BAO_Membership::retrieve($params, $values); if (CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus()) { $finTypeId = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $values['membership_type_id'], 'financial_type_id'); @@ -272,7 +272,7 @@ public function preProcess() { LEFT JOIN civicrm_membership_status ms ON ms.id = m.status_id WHERE r.contact_id_y = {$values['contact_id']} AND r.is_active = 1 AND c.is_deleted = 0"; $query = ''; - foreach (array('a', 'b') as $dir) { + foreach (['a', 'b'] as $dir) { if (isset($relTypeDir[$dir])) { $query .= ($query ? ' UNION ' : '') . str_replace('_y', '_' . $dir, str_replace('_x', '_' . ($dir == 'a' ? 'b' : 'a'), $select)) @@ -281,9 +281,9 @@ public function preProcess() { } $query .= " ORDER BY is_current_member DESC"; $dao = CRM_Core_DAO::executeQuery($query); - $related = array(); + $related = []; $relatedRemaining = CRM_Utils_Array::value('max_related', $values, PHP_INT_MAX); - $rowElememts = array( + $rowElememts = [ 'id', 'cid', 'name', @@ -294,21 +294,21 @@ public function preProcess() { 'end_date', 'is_current_member', 'status', - ); + ]; while ($dao->fetch()) { - $row = array(); + $row = []; foreach ($rowElememts as $field) { $row[$field] = $dao->$field; } if ($row['mid'] && ($row['is_current_member'] == 1)) { $relatedRemaining--; $row['action'] = CRM_Core_Action::formLink(self::links(), CRM_Core_Action::DELETE, - array( + [ 'id' => CRM_Utils_Request::retrieve('id', 'Positive', $this), 'cid' => $row['cid'], 'mid' => $row['mid'], - ), + ], ts('more'), FALSE, 'membership.relationship.action', @@ -319,11 +319,11 @@ public function preProcess() { else { if ($relatedRemaining > 0) { $row['action'] = CRM_Core_Action::formLink(self::links(), CRM_Core_Action::ADD, - array( + [ 'id' => CRM_Utils_Request::retrieve('id', 'Positive', $this), 'cid' => $row['cid'], 'rid' => $row['cid'], - ), + ], ts('more'), FALSE, 'membership.relationship.action', @@ -340,10 +340,10 @@ public function preProcess() { } else { if ($relatedRemaining < 100000) { - $this->assign('related_text', ts('%1 available', array(1 => $relatedRemaining))); + $this->assign('related_text', ts('%1 available', [1 => $relatedRemaining])); } else { - $this->assign('related_text', ts('Unlimited', array(1 => $relatedRemaining))); + $this->assign('related_text', ts('Unlimited', [1 => $relatedRemaining])); } } } @@ -365,7 +365,7 @@ public function preProcess() { "action=view&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home" ); - $recentOther = array(); + $recentOther = []; if (CRM_Core_Permission::checkActionPermission('CiviMember', CRM_Core_Action::UPDATE)) { $recentOther['editUrl'] = CRM_Utils_System::url('civicrm/contact/view/membership', "action=update&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home" @@ -419,14 +419,14 @@ public function preProcess() { * @return void */ public function buildQuickForm() { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'cancel', 'name' => ts('Done'), 'spacing' => '         ', 'isDefault' => TRUE, - ), - )); + ], + ]); } } diff --git a/CRM/Member/Form/Search.php b/CRM/Member/Form/Search.php index 3f98247a5c8e..46a4acad2f43 100644 --- a/CRM/Member/Form/Search.php +++ b/CRM/Member/Form/Search.php @@ -69,7 +69,7 @@ class CRM_Member_Form_Search extends CRM_Core_Form_Search { * * @var array */ - protected $entityReferenceFields = array('membership_type_id'); + protected $entityReferenceFields = ['membership_type_id']; /** * Processing needed for buildForm and later. @@ -321,8 +321,8 @@ public function fixFormValues() { $membershipType = CRM_Utils_Request::retrieve('type', 'String'); if ($membershipType) { - $this->_formValues['membership_type_id'] = array($membershipType); - $this->_defaults['membership_type_id'] = array($membershipType); + $this->_formValues['membership_type_id'] = [$membershipType]; + $this->_defaults['membership_type_id'] = [$membershipType]; } $cid = CRM_Utils_Request::retrieve('cid', 'Positive'); @@ -369,7 +369,7 @@ public function fixFormValues() { //LCD also allow restrictions to membership owner via GET $owner = CRM_Utils_Request::retrieve('owner', 'String'); - if (in_array($owner, array('0', '1'))) { + if (in_array($owner, ['0', '1'])) { $this->_formValues['member_is_primary'] = $this->_defaults['member_is_primary'] = $owner; } } diff --git a/CRM/Member/Form/Task.php b/CRM/Member/Form/Task.php index b83496d8947d..7cc08118ee44 100644 --- a/CRM/Member/Form/Task.php +++ b/CRM/Member/Form/Task.php @@ -61,7 +61,7 @@ public function preProcess() { * @param CRM_Core_Form $form */ public static function preProcessCommon(&$form) { - $form->_memberIds = array(); + $form->_memberIds = []; $values = $form->controller->exportValues($form->get('searchFormName')); @@ -72,7 +72,7 @@ public static function preProcessCommon(&$form) { } $form->assign('taskName', $tasks[$form->_task]); - $ids = array(); + $ids = []; if ($values['radio_ts'] == 'ts_sel') { foreach ($values as $name => $value) { if (substr($name, 0, CRM_Core_Form::CB_PREFIX_LEN) == CRM_Core_Form::CB_PREFIX) { @@ -148,17 +148,17 @@ public function setContactIDs() { * @return void */ public function addDefaultButtons($title, $nextType = 'next', $backType = 'back', $submitOnce = FALSE) { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => $nextType, 'name' => $title, 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => $backType, 'name' => ts('Cancel'), - ), - )); + ], + ]); } } diff --git a/CRM/Member/Form/Task/Batch.php b/CRM/Member/Form/Task/Batch.php index 126c66970b21..232595017bbc 100644 --- a/CRM/Member/Form/Task/Batch.php +++ b/CRM/Member/Form/Task/Batch.php @@ -63,7 +63,7 @@ public function preProcess() { parent::preProcess(); //get the contact read only fields to display. - $readOnlyFields = array_merge(array('sort_name' => ts('Name')), + $readOnlyFields = array_merge(['sort_name' => ts('Name')], CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_autocomplete_options', TRUE, NULL, FALSE, 'name', TRUE @@ -94,12 +94,12 @@ public function buildQuickForm() { CRM_Utils_System::setTitle($this->_title); $this->addDefaultButtons(ts('Save')); - $this->_fields = array(); + $this->_fields = []; $this->_fields = CRM_Core_BAO_UFGroup::getFields($ufGroupId, FALSE, CRM_Core_Action::VIEW); // remove file type field and then limit fields $suppressFields = FALSE; - $removehtmlTypes = array('File'); + $removehtmlTypes = ['File']; foreach ($this->_fields as $name => $field) { if ($cfID = CRM_Core_BAO_CustomField::getKeyID($name) && in_array($this->_fields[$name]['html_type'], $removehtmlTypes) @@ -117,24 +117,24 @@ public function buildQuickForm() { $this->_fields = array_slice($this->_fields, 0, $this->_maxFields); - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'submit', 'name' => ts('Update Members(s)'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - )); + ], + ]); $this->assign('profileTitle', $this->_title); $this->assign('componentIds', $this->_memberIds); //load all campaigns. if (array_key_exists('member_campaign_id', $this->_fields)) { - $this->_componentCampaigns = array(); + $this->_componentCampaigns = []; CRM_Core_PseudoConstant::populate($this->_componentCampaigns, 'CRM_Member_DAO_Membership', TRUE, 'campaign_id', 'id', @@ -148,7 +148,7 @@ public function buildQuickForm() { foreach ($this->_fields as $name => $field) { if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($name)) { $customValue = CRM_Utils_Array::value($customFieldID, $customFields); - $entityColumnValue = array(); + $entityColumnValue = []; if (!empty($customValue['extends_entity_column_value'])) { $entityColumnValue = explode(CRM_Core_DAO::VALUE_SEPARATOR, $customValue['extends_entity_column_value'] @@ -190,7 +190,7 @@ public function setDefaultValues() { return; } - $defaults = array(); + $defaults = []; foreach ($this->_memberIds as $memberId) { CRM_Core_BAO_UFGroup::setProfileDefaults(NULL, $this->_fields, $defaults, FALSE, $memberId, 'Membership'); } @@ -209,13 +209,13 @@ public function postProcess() { // @todo extract submit functions & // extend CRM_Event_Form_Task_BatchTest::testSubmit with a data provider to test // handling of custom data, specifically checkbox fields. - $dates = array( + $dates = [ 'join_date', 'membership_start_date', 'membership_end_date', - ); + ]; if (isset($params['field'])) { - $customFields = array(); + $customFields = []; foreach ($params['field'] as $key => $value) { $ids['membership'] = $key; if (!empty($value['membership_source'])) { diff --git a/CRM/Member/Form/Task/Delete.php b/CRM/Member/Form/Task/Delete.php index 543e87e03ae0..a6cbf2235b9b 100644 --- a/CRM/Member/Form/Task/Delete.php +++ b/CRM/Member/Form/Task/Delete.php @@ -89,12 +89,12 @@ public function postProcess() { } if ($deleted) { - $msg = ts('%count membership deleted.', array('plural' => '%count memberships deleted.', 'count' => $deleted)); + $msg = ts('%count membership deleted.', ['plural' => '%count memberships deleted.', 'count' => $deleted]); CRM_Core_Session::setStatus($msg, ts('Removed'), 'success'); } if ($failed) { - CRM_Core_Session::setStatus(ts('1 could not be deleted.', array('plural' => '%count could not be deleted.', 'count' => $failed)), ts('Error'), 'error'); + CRM_Core_Session::setStatus(ts('1 could not be deleted.', ['plural' => '%count could not be deleted.', 'count' => $failed]), ts('Error'), 'error'); } } diff --git a/CRM/Member/Form/Task/Label.php b/CRM/Member/Form/Task/Label.php index 098063395a22..b1fa2e453aa4 100644 --- a/CRM/Member/Form/Task/Label.php +++ b/CRM/Member/Form/Task/Label.php @@ -68,7 +68,7 @@ public function buildQuickForm() { * array of default values */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; $format = CRM_Core_BAO_LabelFormat::getDefaultValues(); $defaults['label_name'] = CRM_Utils_Array::value('name', $format); $defaults['merge_same_address'] = 0; @@ -115,7 +115,7 @@ public function postProcess() { if ($commMethods = CRM_Utils_Array::value('preferred_communication_method', $row)) { $val = array_filter(explode(CRM_Core_DAO::VALUE_SEPARATOR, $commMethods)); $comm = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'preferred_communication_method'); - $temp = array(); + $temp = []; foreach ($val as $vals) { $temp[] = $comm[$vals]; } @@ -123,14 +123,14 @@ public function postProcess() { } $row['id'] = $id; $formatted = CRM_Utils_Address::format($row, 'mailing_format', FALSE, TRUE, $tokenFields); - $rows[$id] = array($formatted); + $rows[$id] = [$formatted]; } if ($isPerMembership) { - $labelRows = array(); - $memberships = civicrm_api3('membership', 'get', array( - 'id' => array('IN' => $this->_memberIds), + $labelRows = []; + $memberships = civicrm_api3('membership', 'get', [ + 'id' => ['IN' => $this->_memberIds], 'return' => 'contact_id', - )); + ]); foreach ($memberships['values'] as $id => $membership) { if (isset($rows[$membership['contact_id']])) { $labelRows[$id] = $rows[$membership['contact_id']]; diff --git a/CRM/Member/Form/Task/PDFLetterCommon.php b/CRM/Member/Form/Task/PDFLetterCommon.php index c1db72017091..80c83e8f11b0 100644 --- a/CRM/Member/Form/Task/PDFLetterCommon.php +++ b/CRM/Member/Form/Task/PDFLetterCommon.php @@ -55,13 +55,13 @@ public static function postProcessMembers(&$form, $membershipIDs, $skipOnHold, $ */ public static function generateHTML($membershipIDs, $returnProperties, $skipOnHold, $skipDeceased, $messageToken, $html_message, $categories) { $memberships = CRM_Utils_Token::getMembershipTokenDetails($membershipIDs); - $html = array(); + $html = []; foreach ($membershipIDs as $membershipID) { $membership = $memberships[$membershipID]; // get contact information $contactId = $membership['contact_id']; - $params = array('contact_id' => $contactId); + $params = ['contact_id' => $contactId]; //getTokenDetails is much like calling the api contact.get function - but - with some minor // special handlings. It precedes the existence of the api list($contacts) = CRM_Utils_Token::getTokenDetails( diff --git a/CRM/Member/Form/Task/PickProfile.php b/CRM/Member/Form/Task/PickProfile.php index c2e38a05d0d5..6648dadadbea 100644 --- a/CRM/Member/Form/Task/PickProfile.php +++ b/CRM/Member/Form/Task/PickProfile.php @@ -71,10 +71,10 @@ public function preProcess() { $validate = FALSE; //validations if (count($this->_memberIds) > $this->_maxMembers) { - CRM_Core_Session::setStatus(ts("The maximum number of members you can select for Update multiple memberships is %1. You have selected %2. Please select fewer members from your search results and try again.", array( + CRM_Core_Session::setStatus(ts("The maximum number of members you can select for Update multiple memberships is %1. You have selected %2. Please select fewer members from your search results and try again.", [ 1 => $this->_maxMembers, 2 => count($this->_memberIds), - )), ts('Update multiple records error'), 'error'); + ]), ts('Update multiple records error'), 'error'); $validate = TRUE; } @@ -91,18 +91,18 @@ public function preProcess() { * @return void */ public function buildQuickForm() { - $types = array('Membership'); + $types = ['Membership']; $profiles = CRM_Core_BAO_UFGroup::getProfiles($types, TRUE); if (empty($profiles)) { - CRM_Core_Session::setStatus(ts("You will need to create a Profile containing the %1 fields you want to edit before you can use Update multiple memberships. Navigate to Administer CiviCRM >> CiviCRM Profile to configure a Profile. Consult the online Administrator documentation for more information.", array(1 => $types[0])), ts('Update multiple records error'), 'error'); + CRM_Core_Session::setStatus(ts("You will need to create a Profile containing the %1 fields you want to edit before you can use Update multiple memberships. Navigate to Administer CiviCRM >> CiviCRM Profile to configure a Profile. Consult the online Administrator documentation for more information.", [1 => $types[0]]), ts('Update multiple records error'), 'error'); CRM_Utils_System::redirect($this->_userContext); } $ufGroupElement = $this->add('select', 'uf_group_id', ts('Select Profile'), - array( + [ '' => ts('- select profile -'), - ) + $profiles, TRUE + ] + $profiles, TRUE ); $this->addDefaultButtons(ts('Continue')); } @@ -114,7 +114,7 @@ public function buildQuickForm() { * @return void */ public function addRules() { - $this->addFormRule(array('CRM_Member_Form_Task_PickProfile', 'formRule')); + $this->addFormRule(['CRM_Member_Form_Task_PickProfile', 'formRule']); } /** diff --git a/CRM/Member/Form/Task/Print.php b/CRM/Member/Form/Task/Print.php index c6b41ea70424..423a3d588bbb 100644 --- a/CRM/Member/Form/Task/Print.php +++ b/CRM/Member/Form/Task/Print.php @@ -77,18 +77,18 @@ public function buildQuickForm() { // // just need to add a javacript to popup the window for printing // - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => ts('Print Members'), - 'js' => array('onclick' => 'window.print()'), + 'js' => ['onclick' => 'window.print()'], 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'back', 'name' => ts('Done'), - ), - )); + ], + ]); } /** diff --git a/CRM/Member/Form/Task/Result.php b/CRM/Member/Form/Task/Result.php index e517bb02d8ca..7f68f5c76f38 100644 --- a/CRM/Member/Form/Task/Result.php +++ b/CRM/Member/Form/Task/Result.php @@ -54,13 +54,13 @@ public function preProcess() { * @return void */ public function buildQuickForm() { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'done', 'name' => ts('Done'), 'isDefault' => TRUE, - ), - )); + ], + ]); } } diff --git a/CRM/Member/Form/Task/SearchTaskHookSample.php b/CRM/Member/Form/Task/SearchTaskHookSample.php index 5121a69f40c8..9a780079f66e 100644 --- a/CRM/Member/Form/Task/SearchTaskHookSample.php +++ b/CRM/Member/Form/Task/SearchTaskHookSample.php @@ -46,7 +46,7 @@ class CRM_Member_Form_Task_SearchTaskHookSample extends CRM_Member_Form_Task { */ public function preProcess() { parent::preProcess(); - $rows = array(); + $rows = []; // display name and membership details of all selected contacts $memberIDs = implode(',', $this->_memberIds); @@ -61,12 +61,12 @@ public function preProcess() { $dao = CRM_Core_DAO::executeQuery($query); while ($dao->fetch()) { - $rows[] = array( + $rows[] = [ 'display_name' => $dao->display_name, 'start_date' => CRM_Utils_Date::customFormat($dao->start_date), 'end_date' => CRM_Utils_Date::customFormat($dao->end_date), 'source' => $dao->source, - ); + ]; } $this->assign('rows', $rows); } @@ -77,13 +77,13 @@ public function preProcess() { * @return void */ public function buildQuickForm() { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'done', 'name' => ts('Done'), 'isDefault' => TRUE, - ), - )); + ], + ]); } } diff --git a/CRM/Member/Import/Controller.php b/CRM/Member/Import/Controller.php index 0b68d13679f3..f0483d0284f7 100644 --- a/CRM/Member/Import/Controller.php +++ b/CRM/Member/Import/Controller.php @@ -56,7 +56,7 @@ public function __construct($title = NULL, $action = CRM_Core_Action::NONE, $mod // add all the actions $config = CRM_Core_Config::singleton(); - $this->addActions($config->uploadDir, array('uploadFile')); + $this->addActions($config->uploadDir, ['uploadFile']); } } diff --git a/CRM/Member/Import/Field.php b/CRM/Member/Import/Field.php index c2fa363f93ea..fe6448043083 100644 --- a/CRM/Member/Import/Field.php +++ b/CRM/Member/Import/Field.php @@ -143,7 +143,7 @@ public function validate() { return CRM_Utils_Rule::money($this->_value); case 'trxn_id': - static $seenTrxnIds = array(); + static $seenTrxnIds = []; if (in_array($this->_value, $seenTrxnIds)) { return FALSE; } diff --git a/CRM/Member/Import/Form/DataSource.php b/CRM/Member/Import/Form/DataSource.php index 76e56da1c103..46342000a65b 100644 --- a/CRM/Member/Import/Form/DataSource.php +++ b/CRM/Member/Import/Form/DataSource.php @@ -50,7 +50,7 @@ class CRM_Member_Import_Form_DataSource extends CRM_Import_Form_DataSource { public function buildQuickForm() { parent::buildQuickForm(); - $duplicateOptions = array(); + $duplicateOptions = []; $duplicateOptions[] = $this->createElement('radio', NULL, NULL, ts('Insert new Membership'), CRM_Import_Parser::DUPLICATE_SKIP ); @@ -61,9 +61,9 @@ public function buildQuickForm() { $this->addGroup($duplicateOptions, 'onDuplicate', ts('Import mode') ); - $this->setDefaults(array( + $this->setDefaults([ 'onDuplicate' => CRM_Import_Parser::DUPLICATE_SKIP, - )); + ]); $this->addContactTypeSelector(); } @@ -74,12 +74,12 @@ public function buildQuickForm() { * @return void */ public function postProcess() { - $this->storeFormValues(array( + $this->storeFormValues([ 'onDuplicate', 'contactType', 'dateFormats', 'savedMapping', - )); + ]); $this->submitFileForMapping('CRM_Member_Import_Parser_Membership'); } diff --git a/CRM/Member/Import/Form/Preview.php b/CRM/Member/Import/Form/Preview.php index 7073ebb5d2b7..33eba538071a 100644 --- a/CRM/Member/Import/Form/Preview.php +++ b/CRM/Member/Import/Form/Preview.php @@ -87,7 +87,7 @@ public function preProcess() { $this->set('downloadMismatchRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams)); } - $properties = array( + $properties = [ 'mapper', 'dataValues', 'columnCount', @@ -98,7 +98,7 @@ public function preProcess() { 'downloadErrorRecordsUrl', 'downloadConflictRecordsUrl', 'downloadMismatchRecordsUrl', - ); + ]; $this->setStatusUrl(); foreach ($properties as $property) { @@ -121,9 +121,9 @@ public function postProcess() { $onDuplicate = $this->get('onDuplicate'); $mapper = $this->controller->exportValue('MapField', 'mapper'); - $mapperKeys = array(); - $mapperLocType = array(); - $mapperPhoneType = array(); + $mapperKeys = []; + $mapperLocType = []; + $mapperPhoneType = []; // Note: we keep the multi-dimension array (even thought it's not // needed in the case of memberships import) so that we can merge // the common code with contacts import later and subclass contact @@ -151,7 +151,7 @@ public function postProcess() { $mapFields = $this->get('fields'); foreach ($mapper as $key => $value) { - $header = array(); + $header = []; if (isset($mapFields[$mapper[$key][0]])) { $header[] = $mapFields[$mapper[$key][0]]; } @@ -173,7 +173,7 @@ public function postProcess() { // check if there is any error occurred $errorStack = CRM_Core_Error::singleton(); $errors = $errorStack->getErrors(); - $errorMessage = array(); + $errorMessage = []; if (is_array($errors)) { foreach ($errors as $key => $value) { diff --git a/CRM/Member/Import/Form/Summary.php b/CRM/Member/Import/Form/Summary.php index 6e87346165ea..f4940ff02c9d 100644 --- a/CRM/Member/Import/Form/Summary.php +++ b/CRM/Member/Import/Form/Summary.php @@ -93,7 +93,7 @@ public function preProcess() { } $this->assign('dupeActionString', $dupeActionString); - $properties = array( + $properties = [ 'totalRowCount', 'validRowCount', 'invalidRowCount', @@ -105,7 +105,7 @@ public function preProcess() { 'downloadMismatchRecordsUrl', 'groupAdditions', 'unMatchCount', - ); + ]; foreach ($properties as $property) { $this->assign($property, $this->get($property)); } diff --git a/CRM/Member/Import/Parser.php b/CRM/Member/Import/Parser.php index b36197bbac79..d8e631cc97a3 100644 --- a/CRM/Member/Import/Parser.php +++ b/CRM/Member/Import/Parser.php @@ -118,14 +118,14 @@ public function run( $this->_invalidRowCount = $this->_validCount = 0; $this->_totalCount = $this->_conflictCount = 0; - $this->_errors = array(); - $this->_warnings = array(); - $this->_conflicts = array(); + $this->_errors = []; + $this->_warnings = []; + $this->_conflicts = []; $this->_fileSize = number_format(filesize($fileName) / 1024.0, 2); if ($mode == self::MODE_MAPFIELD) { - $this->_rows = array(); + $this->_rows = []; } else { $this->_activeFieldCount = count($this->_activeFields); @@ -250,27 +250,27 @@ public function run( } if ($this->_invalidRowCount) { // removed view url for invlaid contacts - $headers = array_merge(array( + $headers = array_merge([ ts('Line Number'), ts('Reason'), - ), $customHeaders); + ], $customHeaders); $this->_errorFileName = self::errorFileName(self::ERROR); self::exportCSV($this->_errorFileName, $headers, $this->_errors); } if ($this->_conflictCount) { - $headers = array_merge(array( + $headers = array_merge([ ts('Line Number'), ts('Reason'), - ), $customHeaders); + ], $customHeaders); $this->_conflictFileName = self::errorFileName(self::CONFLICT); self::exportCSV($this->_conflictFileName, $headers, $this->_conflicts); } if ($this->_duplicateCount) { - $headers = array_merge(array( + $headers = array_merge([ ts('Line Number'), ts('View Membership URL'), - ), $customHeaders); + ], $customHeaders); $this->_duplicateFileName = self::errorFileName(self::DUPLICATE); self::exportCSV($this->_duplicateFileName, $headers, $this->_duplicates); @@ -306,7 +306,7 @@ public function setActiveFields($fieldKeys) { * (reference ) associative array of name/value pairs */ public function &getActiveFieldParams() { - $params = array(); + $params = []; for ($i = 0; $i < $this->_activeFieldCount; $i++) { if (isset($this->_activeFields[$i]->_value) && !isset($params[$this->_activeFields[$i]->_name]) @@ -411,7 +411,7 @@ public function set($store, $mode = self::MODE_SUMMARY) { * @return void */ public static function exportCSV($fileName, $header, $data) { - $output = array(); + $output = []; $fd = fopen($fileName, 'w'); foreach ($header as $key => $value) { diff --git a/CRM/Member/Import/Parser/Membership.php b/CRM/Member/Import/Parser/Membership.php index 9d4a2b65da2c..974c4294debd 100644 --- a/CRM/Member/Import/Parser/Membership.php +++ b/CRM/Member/Import/Parser/Membership.php @@ -82,7 +82,7 @@ public function init() { $this->addField($name, $field['title'], $field['type'], $field['headerPattern'], $field['dataPattern']); } - $this->_newMemberships = array(); + $this->_newMemberships = []; $this->setActiveFields($this->_mapperKeys); @@ -289,17 +289,17 @@ public function import($onDuplicate, &$values) { $session = CRM_Core_Session::singleton(); $dateType = $session->get('dateTypes'); - $formatted = array(); + $formatted = []; $customDataType = !empty($params['contact_type']) ? $params['contact_type'] : 'Membership'; $customFields = CRM_Core_BAO_CustomField::getFields($customDataType); // don't add to recent items, CRM-4399 $formatted['skipRecentView'] = TRUE; - $dateLabels = array( + $dateLabels = [ 'join_date' => ts('Member Since'), 'membership_start_date' => ts('Start Date'), 'membership_end_date' => ts('End Date'), - ); + ]; foreach ($params as $key => $val) { if ($val) { switch ($key) { @@ -353,7 +353,7 @@ public function import($onDuplicate, &$values) { $indieFields = $tempIndieFields; } - $formatValues = array(); + $formatValues = []; foreach ($params as $key => $field) { if ($field == NULL || $field === '') { continue; @@ -383,7 +383,7 @@ public function import($onDuplicate, &$values) { if (!empty($formatValues['membership_id'])) { $dao = new CRM_Member_BAO_Membership(); $dao->id = $formatValues['membership_id']; - $dates = array('join_date', 'start_date', 'end_date'); + $dates = ['join_date', 'start_date', 'end_date']; foreach ($dates as $v) { if (empty($formatted[$v])) { $formatted[$v] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $formatValues['membership_id'], $v); @@ -395,10 +395,10 @@ public function import($onDuplicate, &$values) { 'Membership' ); if ($dao->find(TRUE)) { - $ids = array( + $ids = [ 'membership' => $formatValues['membership_id'], 'userId' => $session->get('userID'), - ); + ]; if (empty($params['line_item']) && !empty($formatted['membership_type_id'])) { CRM_Price_BAO_LineItem::getLineItemArray($formatted, NULL, 'membership', $formatted['membership_type_id']); @@ -485,10 +485,10 @@ public function import($onDuplicate, &$values) { } else { // Using new Dedupe rule. - $ruleParams = array( + $ruleParams = [ 'contact_type' => $this->_contactType, 'used' => 'Unsupervised', - ); + ]; $fieldsArray = CRM_Dedupe_BAO_Rule::dedupeRuleFields($ruleParams); $disp = ''; @@ -605,11 +605,11 @@ public function fini() { * */ public function formattedDates($calcDates, &$formatted) { - $dates = array( + $dates = [ 'join_date', 'start_date', 'end_date', - ); + ]; foreach ($dates as $d) { if (isset($formatted[$d]) && @@ -661,7 +661,7 @@ public function membership_format_params($params, &$values, $create = FALSE) { if ($type == 'CheckBox' || $type == 'Multi-Select') { $mulValues = explode(',', $value); $customOption = CRM_Core_BAO_CustomOption::getCustomOption($customFieldID, TRUE); - $values[$key] = array(); + $values[$key] = []; foreach ($mulValues as $v1) { foreach ($customOption as $customValueID => $customLabel) { $customValue = $customLabel['value']; @@ -686,7 +686,7 @@ public function membership_format_params($params, &$values, $create = FALSE) { throw new Exception("contact_id not valid: $value"); } $dao = new CRM_Core_DAO(); - $qParams = array(); + $qParams = []; $svq = $dao->singleValueQuery("SELECT id FROM civicrm_contact WHERE id = $value", $qParams ); @@ -757,11 +757,11 @@ public function membership_format_params($params, &$values, $create = FALSE) { // membership_end_date and membership_source. So, if $values contains // membership_start_date, membership_end_date or membership_source, // convert it to start_date, end_date or source - $changes = array( + $changes = [ 'membership_start_date' => 'start_date', 'membership_end_date' => 'end_date', 'membership_source' => 'source', - ); + ]; foreach ($changes as $orgVal => $changeVal) { if (isset($values[$orgVal])) { diff --git a/CRM/Member/Info.php b/CRM/Member/Info.php index 868db37b185d..c0f177ca2c02 100644 --- a/CRM/Member/Info.php +++ b/CRM/Member/Info.php @@ -55,13 +55,13 @@ class CRM_Member_Info extends CRM_Core_Component_Info { * @return array */ public function getInfo() { - return array( + return [ 'name' => 'CiviMember', 'translatedName' => ts('CiviMember'), 'title' => ts('CiviCRM Membership Engine'), 'search' => 1, 'showActivitiesInCore' => 1, - ); + ]; } @@ -82,20 +82,20 @@ public function getInfo() { * collection of permissions, null if none */ public function getPermissions($getAllUnconditionally = FALSE, $descriptions = FALSE) { - $permissions = array( - 'access CiviMember' => array( + $permissions = [ + 'access CiviMember' => [ ts('access CiviMember'), ts('View memberships'), - ), - 'edit memberships' => array( + ], + 'edit memberships' => [ ts('edit memberships'), ts('Create and update memberships'), - ), - 'delete in CiviMember' => array( + ], + 'delete in CiviMember' => [ ts('delete in CiviMember'), ts('Delete memberships'), - ), - ); + ], + ]; if (!$descriptions) { foreach ($permissions as $name => $attr) { @@ -119,15 +119,15 @@ public function getPermissions($getAllUnconditionally = FALSE, $descriptions = F * @return array|null */ public function getUserDashboardElement() { - return array( + return [ 'name' => ts('Memberships'), 'title' => ts('Your Membership(s)'), // this is CiviContribute specific permission, since // there is no permission that could be checked for // CiviMember - 'perm' => array('make online contributions'), + 'perm' => ['make online contributions'], 'weight' => 30, - ); + ]; } /** @@ -143,11 +143,11 @@ public function getUserDashboardElement() { * @return array|null */ public function registerTab() { - return array( + return [ 'title' => ts('Memberships'), 'url' => 'membership', 'weight' => 30, - ); + ]; } /** @@ -171,10 +171,10 @@ public function getIcon() { * @return array|null */ public function registerAdvancedSearchPane() { - return array( + return [ 'title' => ts('Memberships'), 'weight' => 30, - ); + ]; } /** @@ -203,20 +203,20 @@ public function creatNewShortcut(&$shortCuts, $newCredit) { if (CRM_Core_Permission::check('access CiviMember') && CRM_Core_Permission::check('edit memberships') ) { - $shortCut[] = array( + $shortCut[] = [ 'path' => 'civicrm/member/add', 'query' => "reset=1&action=add&context=standalone", 'ref' => 'new-membership', 'title' => ts('Membership'), - ); + ]; if ($newCredit) { $title = ts('Membership') . '
      (' . ts('credit card') . ')'; - $shortCut[0]['shortCuts'][] = array( + $shortCut[0]['shortCuts'][] = [ 'path' => 'civicrm/member/add', 'query' => "reset=1&action=add&context=standalone&mode=live", 'ref' => 'new-membership-cc', 'title' => $title, - ); + ]; } $shortCuts = array_merge($shortCuts, $shortCut); } diff --git a/CRM/Member/Page/AJAX.php b/CRM/Member/Page/AJAX.php index 922bc80489c6..b309dc37f480 100644 --- a/CRM/Member/Page/AJAX.php +++ b/CRM/Member/Page/AJAX.php @@ -55,8 +55,8 @@ public static function getMemberTypeDefaults() { FROM civicrm_membership_type WHERE id = %1"; - $dao = CRM_Core_DAO::executeQuery($query, array(1 => array($memType, 'Positive'))); - $properties = array('financial_type_id', 'total_amount', 'name', 'auto_renew'); + $dao = CRM_Core_DAO::executeQuery($query, [1 => [$memType, 'Positive']]); + $properties = ['financial_type_id', 'total_amount', 'name', 'auto_renew']; while ($dao->fetch()) { foreach ($properties as $property) { $details[$property] = $dao->$property; diff --git a/CRM/Member/Page/MembershipStatus.php b/CRM/Member/Page/MembershipStatus.php index 0289d93bee96..9cf874424068 100644 --- a/CRM/Member/Page/MembershipStatus.php +++ b/CRM/Member/Page/MembershipStatus.php @@ -65,30 +65,30 @@ public function getBAOName() { */ public function &links() { if (!(self::$_links)) { - self::$_links = array( - CRM_Core_Action::UPDATE => array( + self::$_links = [ + CRM_Core_Action::UPDATE => [ 'name' => ts('Edit'), 'url' => 'civicrm/admin/member/membershipStatus', 'qs' => 'action=update&id=%%id%%&reset=1', 'title' => ts('Edit Membership Status'), - ), - CRM_Core_Action::DISABLE => array( + ], + CRM_Core_Action::DISABLE => [ 'name' => ts('Disable'), 'ref' => 'crm-enable-disable', 'title' => ts('Disable Membership Status'), - ), - CRM_Core_Action::ENABLE => array( + ], + CRM_Core_Action::ENABLE => [ 'name' => ts('Enable'), 'ref' => 'crm-enable-disable', 'title' => ts('Enable Membership Status'), - ), - CRM_Core_Action::DELETE => array( + ], + CRM_Core_Action::DELETE => [ 'name' => ts('Delete'), 'url' => 'civicrm/admin/member/membershipStatus', 'qs' => 'action=delete&id=%%id%%', 'title' => ts('Delete Membership Status'), - ), - ); + ], + ]; } return self::$_links; } @@ -101,14 +101,14 @@ public function &links() { */ public function browse() { // get all custom groups sorted by weight - $membershipStatus = array(); + $membershipStatus = []; $dao = new CRM_Member_DAO_MembershipStatus(); $dao->orderBy('weight'); $dao->find(); while ($dao->fetch()) { - $membershipStatus[$dao->id] = array(); + $membershipStatus[$dao->id] = []; CRM_Core_DAO::storeValues($dao, $membershipStatus[$dao->id]); // form all action links @@ -122,7 +122,7 @@ public function browse() { $action -= CRM_Core_Action::DISABLE; } $membershipStatus[$dao->id]['action'] = CRM_Core_Action::formLink(self::links(), $action, - array('id' => $dao->id), + ['id' => $dao->id], ts('more'), FALSE, 'membershipStatus.manage.action', diff --git a/CRM/Member/Page/MembershipType.php b/CRM/Member/Page/MembershipType.php index 502411051725..96c16a60a8ee 100644 --- a/CRM/Member/Page/MembershipType.php +++ b/CRM/Member/Page/MembershipType.php @@ -55,30 +55,30 @@ class CRM_Member_Page_MembershipType extends CRM_Core_Page { */ public function &links() { if (!(self::$_links)) { - self::$_links = array( - CRM_Core_Action::UPDATE => array( + self::$_links = [ + CRM_Core_Action::UPDATE => [ 'name' => ts('Edit'), 'url' => 'civicrm/admin/member/membershipType/add', 'qs' => 'action=update&id=%%id%%&reset=1', 'title' => ts('Edit Membership Type'), - ), - CRM_Core_Action::DISABLE => array( + ], + CRM_Core_Action::DISABLE => [ 'name' => ts('Disable'), 'ref' => 'crm-enable-disable', 'title' => ts('Disable Membership Type'), - ), - CRM_Core_Action::ENABLE => array( + ], + CRM_Core_Action::ENABLE => [ 'name' => ts('Enable'), 'ref' => 'crm-enable-disable', 'title' => ts('Enable Membership Type'), - ), - CRM_Core_Action::DELETE => array( + ], + CRM_Core_Action::DELETE => [ 'name' => ts('Delete'), 'url' => 'civicrm/admin/member/membershipType/add', 'qs' => 'action=delete&id=%%id%%', 'title' => ts('Delete Membership Type'), - ), - ); + ], + ]; } return self::$_links; } @@ -107,7 +107,7 @@ public function run() { */ public function browse() { // get all membership types sorted by weight - $membershipType = array(); + $membershipType = []; $dao = new CRM_Member_DAO_MembershipType(); $dao->orderBy('weight'); @@ -120,7 +120,7 @@ public function browse() { continue; } $links = self::links(); - $membershipType[$dao->id] = array(); + $membershipType[$dao->id] = []; CRM_Core_DAO::storeValues($dao, $membershipType[$dao->id]); $membershipType[$dao->id]['period_type'] = CRM_Utils_Array::value($dao->period_type, CRM_Core_SelectValues::periodType(), ''); @@ -162,7 +162,7 @@ public function browse() { } $membershipType[$dao->id]['order'] = $membershipType[$dao->id]['weight']; $membershipType[$dao->id]['action'] = CRM_Core_Action::formLink($links, $action, - array('id' => $dao->id), + ['id' => $dao->id], ts('more'), FALSE, 'membershipType.manage.action', diff --git a/CRM/Member/Page/RecurringContributions.php b/CRM/Member/Page/RecurringContributions.php index 7567aa3694ad..07661c9fb7f9 100644 --- a/CRM/Member/Page/RecurringContributions.php +++ b/CRM/Member/Page/RecurringContributions.php @@ -54,11 +54,11 @@ private function loadRecurringContributions() { * @return array */ private function getRecurContributions($membershipID) { - $result = civicrm_api3('MembershipPayment', 'get', array( + $result = civicrm_api3('MembershipPayment', 'get', [ 'sequential' => 1, 'contribution_id.contribution_recur_id.id' => ['IS NOT NULL' => TRUE], 'options' => ['limit' => 0], - 'return' => array( + 'return' => [ 'contribution_id.contribution_recur_id.id', 'contribution_id.contribution_recur_id.contact_id', 'contribution_id.contribution_recur_id.start_date', @@ -72,10 +72,10 @@ private function getRecurContributions($membershipID) { 'contribution_id.contribution_recur_id.contribution_status_id', 'contribution_id.contribution_recur_id.is_test', 'contribution_id.contribution_recur_id.payment_processor_id', - ), + ], 'membership_id' => $membershipID, - )); - $recurringContributions = array(); + ]); + $recurringContributions = []; $contributionStatuses = CRM_Contribute_PseudoConstant::contributionStatus(); foreach ($result['values'] as $payment) { @@ -87,7 +87,7 @@ private function getRecurContributions($membershipID) { } foreach ($payment as $field => $value) { - $key = strtr($field, array('contribution_id.contribution_recur_id.' => '')); + $key = strtr($field, ['contribution_id.contribution_recur_id.' => '']); $recurringContributions[$recurringContributionID][$key] = $value; } @@ -127,11 +127,11 @@ private function setActionsForRecurringContribution($recurID, &$recurringContrib $recurringContribution['action'] = CRM_Core_Action::formLink( CRM_Contribute_Page_Tab::recurLinks($recurID, 'contribution'), $action, - array( + [ 'cid' => $this->contactID, 'crid' => $recurID, 'cxt' => 'contribution', - ), + ], ts('more'), FALSE, 'contribution.selector.recurring', diff --git a/CRM/Member/Page/Tab.php b/CRM/Member/Page/Tab.php index d646c719f657..f51fdc13254a 100644 --- a/CRM/Member/Page/Tab.php +++ b/CRM/Member/Page/Tab.php @@ -56,14 +56,14 @@ public function browse() { $addWhere = "membership_type_id IN (" . implode(',', array_keys($membershipTypes)) . ")"; } - $membership = array(); + $membership = []; $dao = new CRM_Member_DAO_Membership(); $dao->contact_id = $this->_contactId; $dao->whereAdd($addWhere); $dao->find(); //CRM--4418, check for view, edit, delete - $permissions = array(CRM_Core_Permission::VIEW); + $permissions = [CRM_Core_Permission::VIEW]; if (CRM_Core_Permission::check('edit memberships')) { $permissions[] = CRM_Core_Permission::EDIT; } @@ -81,7 +81,7 @@ public function browse() { //checks membership of contact itself while ($dao->fetch()) { - $membership[$dao->id] = array(); + $membership[$dao->id] = []; CRM_Core_DAO::storeValues($dao, $membership[$dao->id]); //carry campaign. @@ -89,7 +89,7 @@ public function browse() { //get the membership status and type values. $statusANDType = CRM_Member_BAO_Membership::getStatusANDTypeValues($dao->id); - foreach (array('status', 'membership_type') as $fld) { + foreach (['status', 'membership_type'] as $fld) { $membership[$dao->id][$fld] = CRM_Utils_Array::value($fld, $statusANDType[$dao->id]); } if (!empty($statusANDType[$dao->id]['is_current_member'])) { @@ -124,10 +124,10 @@ public function browse() { self::getPermissionedLinks($dao->membership_type_id, $links); $membership[$dao->id]['action'] = CRM_Core_Action::formLink($links, $currentMask, - array( + [ 'id' => $dao->id, 'cid' => $this->_contactId, - ), + ], ts('Renew') . '...', FALSE, 'membership.tab.row', @@ -140,10 +140,10 @@ public function browse() { self::getPermissionedLinks($dao->membership_type_id, $links); $membership[$dao->id]['action'] = CRM_Core_Action::formLink($links, $mask, - array( + [ 'id' => $dao->id, 'cid' => $this->_contactId, - ), + ], ts('more'), FALSE, 'membership.tab.row', @@ -179,10 +179,10 @@ public function browse() { 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]); - $membership[$dao->id]['related_count'] = ($max_related == '' ? ts('%1 created', array(1 => $num_related)) : ts('%1 out of %2', array( + $membership[$dao->id]['related_count'] = ($max_related == '' ? ts('%1 created', [1 => $num_related]) : ts('%1 out of %2', [ 1 => $num_related, 2 => $max_related, - ))); + ])); } else { $membership[$dao->id]['related_count'] = ts('N/A'); @@ -191,21 +191,21 @@ public function browse() { //Below code gives list of all Membership Types associated //with an Organization(CRM-2016) - $membershipTypesResult = civicrm_api3('MembershipType', 'get', array( + $membershipTypesResult = civicrm_api3('MembershipType', 'get', [ 'member_of_contact_id' => $this->_contactId, - 'options' => array( + 'options' => [ 'limit' => 0, - ), - )); + ], + ]); $membershipTypes = CRM_Utils_Array::value('values', $membershipTypesResult, NULL); foreach ($membershipTypes as $key => $value) { $membershipTypes[$key]['action'] = CRM_Core_Action::formLink(self::membershipTypeslinks(), $mask, - array( + [ 'id' => $value['id'], 'cid' => $this->_contactId, - ), + ], ts('more'), FALSE, 'membershipType.organization.action', @@ -225,10 +225,10 @@ public function browse() { $this->assign('displayName', $displayName); $this->ajaxResponse['tabCount'] = CRM_Contact_BAO_Contact::getCountComponent('membership', $this->_contactId); // Refresh other tabs with related data - $this->ajaxResponse['updateTabs'] = array( + $this->ajaxResponse['updateTabs'] = [ '#tab_activity' => CRM_Contact_BAO_Contact::getCountComponent('activity', $this->_contactId), '#tab_rel' => CRM_Contact_BAO_Contact::getCountComponent('rel', $this->_contactId), - ); + ]; if (CRM_Core_Permission::access('CiviContribute')) { $this->ajaxResponse['updateTabs']['#tab_contribute'] = CRM_Contact_BAO_Contact::getCountComponent('contribution', $this->_contactId); } @@ -492,43 +492,43 @@ public static function &links( $isUpdateBilling = FALSE ) { if (!CRM_Utils_Array::value('view', self::$_links)) { - self::$_links['view'] = array( - CRM_Core_Action::VIEW => array( + self::$_links['view'] = [ + CRM_Core_Action::VIEW => [ 'name' => ts('View'), 'url' => 'civicrm/contact/view/membership', 'qs' => 'action=view&reset=1&cid=%%cid%%&id=%%id%%&context=membership&selectedChild=member', 'title' => ts('View Membership'), - ), - ); + ], + ]; } if (!CRM_Utils_Array::value('all', self::$_links)) { - $extraLinks = array( - CRM_Core_Action::UPDATE => array( + $extraLinks = [ + CRM_Core_Action::UPDATE => [ 'name' => ts('Edit'), 'url' => 'civicrm/contact/view/membership', 'qs' => 'action=update&reset=1&cid=%%cid%%&id=%%id%%&context=membership&selectedChild=member', 'title' => ts('Edit Membership'), - ), - CRM_Core_Action::RENEW => array( + ], + CRM_Core_Action::RENEW => [ 'name' => ts('Renew'), 'url' => 'civicrm/contact/view/membership', 'qs' => 'action=renew&reset=1&cid=%%cid%%&id=%%id%%&context=membership&selectedChild=member', 'title' => ts('Renew Membership'), - ), - CRM_Core_Action::FOLLOWUP => array( + ], + CRM_Core_Action::FOLLOWUP => [ 'name' => ts('Renew-Credit Card'), 'url' => 'civicrm/contact/view/membership', 'qs' => 'action=renew&reset=1&cid=%%cid%%&id=%%id%%&context=membership&selectedChild=member&mode=live', 'title' => ts('Renew Membership Using Credit Card'), - ), - CRM_Core_Action::DELETE => array( + ], + CRM_Core_Action::DELETE => [ 'name' => ts('Delete'), 'url' => 'civicrm/contact/view/membership', 'qs' => 'action=delete&reset=1&cid=%%cid%%&id=%%id%%&context=membership&selectedChild=member', 'title' => ts('Delete Membership'), - ), - ); + ], + ]; if (!$isPaymentProcessor || !$accessContribution) { //unset the renew with credit card when payment //processor is not available or user is not permitted to create contributions @@ -539,25 +539,25 @@ public static function &links( if ($isCancelSupported) { $cancelMessage = ts('WARNING: If you cancel the recurring contribution associated with this membership, the membership will no longer be renewed automatically. However, the current membership status will not be affected.'); - self::$_links['all'][CRM_Core_Action::DISABLE] = array( + self::$_links['all'][CRM_Core_Action::DISABLE] = [ 'name' => ts('Cancel Auto-renewal'), 'url' => 'civicrm/contribute/unsubscribe', 'qs' => 'reset=1&cid=%%cid%%&mid=%%id%%&context=membership&selectedChild=member', 'title' => ts('Cancel Auto Renew Subscription'), 'extra' => 'onclick = "if (confirm(\'' . $cancelMessage . '\') ) { return true; else return false;}"', - ); + ]; } elseif (isset(self::$_links['all'][CRM_Core_Action::DISABLE])) { unset(self::$_links['all'][CRM_Core_Action::DISABLE]); } if ($isUpdateBilling) { - self::$_links['all'][CRM_Core_Action::MAP] = array( + self::$_links['all'][CRM_Core_Action::MAP] = [ 'name' => ts('Change Billing Details'), 'url' => 'civicrm/contribute/updatebilling', 'qs' => 'reset=1&cid=%%cid%%&mid=%%id%%&context=membership&selectedChild=member', 'title' => ts('Change Billing Details'), - ); + ]; } elseif (isset(self::$_links['all'][CRM_Core_Action::MAP])) { unset(self::$_links['all'][CRM_Core_Action::MAP]); @@ -573,20 +573,20 @@ public static function &links( */ public static function &membershipTypesLinks() { if (!self::$_membershipTypesLinks) { - self::$_membershipTypesLinks = array( - CRM_Core_Action::VIEW => array( + self::$_membershipTypesLinks = [ + CRM_Core_Action::VIEW => [ 'name' => ts('Members'), 'url' => 'civicrm/member/search/', 'qs' => 'reset=1&force=1&type=%%id%%', 'title' => ts('Search'), - ), - CRM_Core_Action::UPDATE => array( + ], + CRM_Core_Action::UPDATE => [ 'name' => ts('Edit'), 'url' => 'civicrm/admin/member/membershipType', 'qs' => 'action=update&id=%%id%%&reset=1', 'title' => ts('Edit Membership Type'), - ), - ); + ], + ]; } return self::$_membershipTypesLinks; } diff --git a/CRM/Member/Page/UserDashboard.php b/CRM/Member/Page/UserDashboard.php index 26d23e99b7e1..5240ee9d818a 100644 --- a/CRM/Member/Page/UserDashboard.php +++ b/CRM/Member/Page/UserDashboard.php @@ -43,22 +43,22 @@ class CRM_Member_Page_UserDashboard extends CRM_Contact_Page_View_UserDashBoard * */ public function listMemberships() { - $membership = array(); + $membership = []; $dao = new CRM_Member_DAO_Membership(); $dao->contact_id = $this->_contactId; $dao->is_test = 0; $dao->find(); while ($dao->fetch()) { - $membership[$dao->id] = array(); + $membership[$dao->id] = []; CRM_Core_DAO::storeValues($dao, $membership[$dao->id]); //get the membership status and type values. $statusANDType = CRM_Member_BAO_Membership::getStatusANDTypeValues($dao->id); - foreach (array( + foreach ([ 'status', 'membership_type', - ) as $fld) { + ] as $fld) { $membership[$dao->id][$fld] = CRM_Utils_Array::value($fld, $statusANDType[$dao->id]); } if (!empty($statusANDType[$dao->id]['is_current_member'])) { diff --git a/CRM/Member/PseudoConstant.php b/CRM/Member/PseudoConstant.php index b95c78aa03e0..af904929f7cf 100644 --- a/CRM/Member/PseudoConstant.php +++ b/CRM/Member/PseudoConstant.php @@ -96,7 +96,7 @@ public static function membershipType($id = NULL, $force = TRUE) { */ public static function &membershipStatus($id = NULL, $cond = NULL, $column = 'name', $force = FALSE, $allStatus = FALSE) { if (self::$membershipStatus === NULL) { - self::$membershipStatus = array(); + self::$membershipStatus = []; } $cacheKey = $column; diff --git a/CRM/Member/Selector/Search.php b/CRM/Member/Selector/Search.php index 0d7c3639c0f8..7775ecde8c56 100644 --- a/CRM/Member/Selector/Search.php +++ b/CRM/Member/Selector/Search.php @@ -56,7 +56,7 @@ class CRM_Member_Selector_Search extends CRM_Core_Selector_Base implements CRM_C * Properties of contact we're interested in displaying * @var array */ - static $_properties = array( + static $_properties = [ 'contact_id', 'membership_id', 'contact_type', @@ -71,7 +71,7 @@ class CRM_Member_Selector_Search extends CRM_Core_Selector_Base implements CRM_C 'owner_membership_id', 'membership_status', 'member_campaign_id', - ); + ]; /** * Are we restricting ourselves to a single contact @@ -205,42 +205,42 @@ public static function &links( } if (!self::$_links['view']) { - self::$_links['view'] = array( - CRM_Core_Action::VIEW => array( + self::$_links['view'] = [ + CRM_Core_Action::VIEW => [ 'name' => ts('View'), 'url' => 'civicrm/contact/view/membership', 'qs' => 'reset=1&id=%%id%%&cid=%%cid%%&action=view&context=%%cxt%%&selectedChild=member' . $extraParams, 'title' => ts('View Membership'), - ), - ); + ], + ]; } if (!isset(self::$_links['all']) || !self::$_links['all']) { - $extraLinks = array( - CRM_Core_Action::UPDATE => array( + $extraLinks = [ + CRM_Core_Action::UPDATE => [ 'name' => ts('Edit'), 'url' => 'civicrm/contact/view/membership', 'qs' => 'reset=1&action=update&id=%%id%%&cid=%%cid%%&context=%%cxt%%' . $extraParams, 'title' => ts('Edit Membership'), - ), - CRM_Core_Action::DELETE => array( + ], + CRM_Core_Action::DELETE => [ 'name' => ts('Delete'), 'url' => 'civicrm/contact/view/membership', 'qs' => 'reset=1&action=delete&id=%%id%%&cid=%%cid%%&context=%%cxt%%' . $extraParams, 'title' => ts('Delete Membership'), - ), - CRM_Core_Action::RENEW => array( + ], + CRM_Core_Action::RENEW => [ 'name' => ts('Renew'), 'url' => 'civicrm/contact/view/membership', 'qs' => 'reset=1&action=renew&id=%%id%%&cid=%%cid%%&context=%%cxt%%' . $extraParams, 'title' => ts('Renew Membership'), - ), - CRM_Core_Action::FOLLOWUP => array( + ], + CRM_Core_Action::FOLLOWUP => [ 'name' => ts('Renew-Credit Card'), 'url' => 'civicrm/contact/view/membership', 'qs' => 'action=renew&reset=1&cid=%%cid%%&id=%%id%%&context=%%cxt%%&mode=live' . $extraParams, 'title' => ts('Renew Membership Using Credit Card'), - ), - ); + ], + ]; if (!$isPaymentProcessor || !$accessContribution) { //unset the renew with credit card when payment //processor is not available or user not permitted to make contributions @@ -251,12 +251,12 @@ public static function &links( } if ($isCancelSupported) { - self::$_links['all'][CRM_Core_Action::DISABLE] = array( + self::$_links['all'][CRM_Core_Action::DISABLE] = [ 'name' => ts('Cancel Auto-renewal'), 'url' => 'civicrm/contribute/unsubscribe', 'qs' => 'reset=1&mid=%%id%%&context=%%cxt%%' . $extraParams, 'title' => ts('Cancel Auto Renew Subscription'), - ); + ]; } elseif (isset(self::$_links['all'][CRM_Core_Action::DISABLE])) { unset(self::$_links['all'][CRM_Core_Action::DISABLE]); @@ -350,10 +350,10 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { ); // process the result of the query - $rows = array(); + $rows = []; //CRM-4418 check for view, edit, delete - $permissions = array(CRM_Core_Permission::VIEW); + $permissions = [CRM_Core_Permission::VIEW]; if (CRM_Core_Permission::check('edit memberships')) { $permissions[] = CRM_Core_Permission::EDIT; } @@ -363,7 +363,7 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { $mask = CRM_Core_Action::mask($permissions); while ($result->fetch()) { - $row = array(); + $row = []; // the columns we are interested in foreach (self::$_properties as $property) { @@ -413,11 +413,11 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { } $row['action'] = CRM_Core_Action::formLink($links, $currentMask, - array( + [ 'id' => $result->membership_id, 'cid' => $result->contact_id, 'cxt' => $this->_context, - ), + ], ts('Renew') . '...', FALSE, 'membership.selector.row', @@ -428,11 +428,11 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { else { $links = self::links('view'); $row['action'] = CRM_Core_Action::formLink($links, $mask, - array( + [ 'id' => $result->membership_id, 'cid' => $result->contact_id, 'cxt' => $this->_context, - ), + ], ts('more'), FALSE, 'membership.selector.row', @@ -485,52 +485,52 @@ public function getQILL() { */ public function &getColumnHeaders($action = NULL, $output = NULL) { if (!isset(self::$_columnHeaders)) { - self::$_columnHeaders = array( - array( + self::$_columnHeaders = [ + [ 'name' => ts('Type'), 'sort' => 'membership_type', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - array( + ], + [ 'name' => ts('Member Since'), 'sort' => 'join_date', 'direction' => CRM_Utils_Sort::DESCENDING, - ), - array( + ], + [ 'name' => ts('Start Date'), 'sort' => 'membership_start_date', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - array( + ], + [ 'name' => ts('End Date'), 'sort' => 'membership_end_date', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - array( + ], + [ 'name' => ts('Source'), 'sort' => 'membership_source', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - array( + ], + [ 'name' => ts('Status'), 'sort' => 'membership_status', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - array( + ], + [ 'name' => ts('Auto-renew?'), - ), - array('desc' => ts('Actions')), - ); + ], + ['desc' => ts('Actions')], + ]; if (!$this->_single) { - $pre = array( - array('desc' => ts('Contact Type')), - array( + $pre = [ + ['desc' => ts('Contact Type')], + [ 'name' => ts('Name'), 'sort' => 'sort_name', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - ); + ], + ]; self::$_columnHeaders = array_merge($pre, self::$_columnHeaders); } } diff --git a/CRM/Member/StateMachine/Search.php b/CRM/Member/StateMachine/Search.php index ad8bee4fd46c..fe95f9dcab7b 100644 --- a/CRM/Member/StateMachine/Search.php +++ b/CRM/Member/StateMachine/Search.php @@ -50,7 +50,7 @@ class CRM_Member_StateMachine_Search extends CRM_Core_StateMachine { public function __construct($controller, $action = CRM_Core_Action::NONE) { parent::__construct($controller, $action); - $this->_pages = array(); + $this->_pages = []; $this->_pages['CRM_Member_Form_Search'] = NULL; list($task, $result) = $this->taskName($controller, 'Search'); diff --git a/CRM/Member/StatusOverrideTypes.php b/CRM/Member/StatusOverrideTypes.php index 8d2cef129762..05770d4da2d4 100644 --- a/CRM/Member/StatusOverrideTypes.php +++ b/CRM/Member/StatusOverrideTypes.php @@ -64,11 +64,11 @@ class CRM_Member_StatusOverrideTypes { * In ['Type 1 Value' => 'Type 1 Label'] format */ public static function getSelectOptions() { - return array( + return [ self::NO => ts('No'), self::PERMANENT => ts('Override Permanently'), self::UNTIL_DATE => ts('Override Until Selected Date'), - ); + ]; } /** diff --git a/CRM/Member/Task.php b/CRM/Member/Task.php index 5e3dbf4d09b6..0827a267800e 100644 --- a/CRM/Member/Task.php +++ b/CRM/Member/Task.php @@ -55,64 +55,64 @@ class CRM_Member_Task extends CRM_Core_Task { */ public static function tasks() { if (!self::$_tasks) { - self::$_tasks = array( - self::TASK_DELETE => array( + self::$_tasks = [ + self::TASK_DELETE => [ 'title' => ts('Delete memberships'), 'class' => 'CRM_Member_Form_Task_Delete', 'result' => FALSE, - ), - self::TASK_PRINT => array( + ], + self::TASK_PRINT => [ 'title' => ts('Print selected rows'), 'class' => 'CRM_Member_Form_Task_Print', 'result' => FALSE, - ), - self::TASK_EXPORT => array( + ], + self::TASK_EXPORT => [ 'title' => ts('Export members'), - 'class' => array( + 'class' => [ 'CRM_Export_Form_Select', 'CRM_Export_Form_Map', - ), + ], 'result' => FALSE, - ), - self::TASK_EMAIL => array( - 'title' => ts('Email - send now (to %1 or less)', array( + ], + self::TASK_EMAIL => [ + 'title' => ts('Email - send now (to %1 or less)', [ 1 => Civi::settings() ->get('simple_mail_limit'), - )), + ]), 'class' => 'CRM_Member_Form_Task_Email', 'result' => TRUE, - ), - self::BATCH_UPDATE => array( + ], + self::BATCH_UPDATE => [ 'title' => ts('Update multiple memberships'), - 'class' => array( + 'class' => [ 'CRM_Member_Form_Task_PickProfile', 'CRM_Member_Form_Task_Batch', - ), + ], 'result' => TRUE, - ), - self::LABEL_MEMBERS => array( + ], + self::LABEL_MEMBERS => [ 'title' => ts('Mailing labels - print'), - 'class' => array( + 'class' => [ 'CRM_Member_Form_Task_Label', - ), + ], 'result' => TRUE, - ), - self::PDF_LETTER => array( + ], + self::PDF_LETTER => [ 'title' => ts('Print/merge document for memberships'), 'class' => 'CRM_Member_Form_Task_PDFLetter', 'result' => FALSE, - ), - self::SAVE_SEARCH => array( + ], + self::SAVE_SEARCH => [ 'title' => ts('Group - create smart group'), 'class' => 'CRM_Contact_Form_Task_SaveSearch', 'result' => TRUE, - ), - self::SAVE_SEARCH_UPDATE => array( + ], + self::SAVE_SEARCH_UPDATE => [ 'title' => ts('Group - update smart group'), 'class' => 'CRM_Contact_Form_Task_SaveSearch_Update', 'result' => TRUE, - ), - ); + ], + ]; //CRM-4418, check for delete if (!CRM_Core_Permission::check('delete in CiviMember')) { @@ -150,17 +150,17 @@ public static function taskTitles() { * @return array * set of tasks that are valid for the user */ - public static function permissionedTaskTitles($permission, $params = array()) { + public static function permissionedTaskTitles($permission, $params = []) { if (($permission == CRM_Core_Permission::EDIT) || CRM_Core_Permission::check('edit memberships') ) { $tasks = self::taskTitles(); } else { - $tasks = array( + $tasks = [ self::TASK_EXPORT => self::$_tasks[self::TASK_EXPORT]['title'], self::TASK_EMAIL => self::$_tasks[self::TASK_EMAIL]['title'], - ); + ]; //CRM-4418, if (CRM_Core_Permission::check('delete in CiviMember')) { $tasks[self::TASK_DELETE] = self::$_tasks[self::TASK_DELETE]['title']; diff --git a/CRM/Member/Tokens.php b/CRM/Member/Tokens.php index 1e22252cdad6..3e2dc921f80a 100644 --- a/CRM/Member/Tokens.php +++ b/CRM/Member/Tokens.php @@ -45,7 +45,7 @@ class CRM_Member_Tokens extends \Civi\Token\AbstractTokenSubscriber { */ public function __construct() { parent::__construct('membership', array_merge( - array( + [ 'fee' => ts('Membership Fee'), 'id' => ts('Membership ID'), 'join_date' => ts('Membership Join Date'), @@ -53,7 +53,7 @@ public function __construct() { 'end_date' => ts('Membership End Date'), 'status' => ts('Membership Status'), 'type' => ts('Membership Type'), - ), + ], CRM_Utils_Token::getCustomFieldTokens('Membership') )); } @@ -92,7 +92,7 @@ public function alterActionScheduleQuery(\Civi\ActionSchedule\Event\MailingQuery public function evaluateToken(\Civi\Token\TokenRow $row, $entity, $field, $prefetch = NULL) { $actionSearchResult = $row->context['actionSearchResult']; - if (in_array($field, array('start_date', 'end_date', 'join_date'))) { + if (in_array($field, ['start_date', 'end_date', 'join_date'])) { $row->tokens($entity, $field, \CRM_Utils_Date::customFormat($actionSearchResult->$field)); } elseif (isset($actionSearchResult->$field)) { diff --git a/CRM/Note/Form/Note.php b/CRM/Note/Form/Note.php index e2d65e1c10f5..2b7478d64d57 100644 --- a/CRM/Note/Form/Note.php +++ b/CRM/Note/Form/Note.php @@ -94,7 +94,7 @@ public function preProcess() { * @return void */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; if ($this->_action & CRM_Core_Action::UPDATE) { if (isset($this->_id)) { @@ -133,17 +133,17 @@ public function getDefaultContext() { */ public function buildQuickForm() { if ($this->_action & CRM_Core_Action::DELETE) { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => ts('Delete'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); return; } @@ -156,17 +156,17 @@ public function buildQuickForm() { // add attachments part CRM_Core_BAO_File::buildAttachment($this, 'civicrm_note', $this->_id, NULL, TRUE); - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'upload', 'name' => ts('Save'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); } @@ -203,7 +203,7 @@ public function postProcess() { // add attachments as needed CRM_Core_BAO_File::formatAttachment($params, $params, 'civicrm_note', $params['id']); - $ids = array(); + $ids = []; $note = CRM_Core_BAO_Note::add($params, $ids); CRM_Core_Session::setStatus(ts('Your Note has been saved.'), ts('Saved'), 'success'); diff --git a/CRM/PCP/BAO/PCP.php b/CRM/PCP/BAO/PCP.php index 970ae473b55c..f5674c558bff 100644 --- a/CRM/PCP/BAO/PCP.php +++ b/CRM/PCP/BAO/PCP.php @@ -113,12 +113,12 @@ public static function getPcpDashboardInfo($contactId) { AND pcp.contact_id = %1 ORDER BY page_type, page_id"; - $params = array(1 => array($contactId, 'Integer')); + $params = [1 => [$contactId, 'Integer']]; $pcpInfoDao = CRM_Core_DAO::executeQuery($query, $params); - $pcpInfo = array(); + $pcpInfo = []; $hide = $mask = array_sum(array_keys($links['all'])); - $contactPCPPages = array(); + $contactPCPPages = []; $event = CRM_Event_PseudoConstant::event(NULL, FALSE, "( is_template IS NULL OR is_template != 1 )"); $contribute = CRM_Contribute_PseudoConstant::contributionPage(); @@ -128,11 +128,11 @@ public static function getPcpDashboardInfo($contactId) { while ($pcpInfoDao->fetch()) { $mask = $hide; if ($links) { - $replace = array( + $replace = [ 'pcpId' => $pcpInfoDao->id, 'pcpBlock' => $pcpInfoDao->pcp_block_id, 'pageComponent' => $pcpInfoDao->page_type, - ); + ]; } $pcpLink = $links['all']; @@ -156,14 +156,14 @@ public static function getPcpDashboardInfo($contactId) { $component = $pcpInfoDao->page_type; $pageTitle = CRM_Utils_Array::value($pcpInfoDao->page_id, $$component); - $pcpInfo[] = array( + $pcpInfo[] = [ 'pageTitle' => $pageTitle, 'pcpId' => $pcpInfoDao->id, 'pcpTitle' => $pcpInfoDao->title, 'pcpStatus' => $pcpStatus[$pcpInfoDao->status_id], 'action' => $action, 'class' => $class, - ); + ]; $contactPCPPages[$pcpInfoDao->page_type][] = $pcpInfoDao->page_id; } @@ -188,30 +188,30 @@ public static function getPcpDashboardInfo($contactId) { ORDER BY target_entity_type, target_entity_id "; $pcpBlockDao = CRM_Core_DAO::executeQuery($query); - $pcpBlock = array(); + $pcpBlock = []; $mask = 0; while ($pcpBlockDao->fetch()) { if ($links) { - $replace = array( + $replace = [ 'pageId' => $pcpBlockDao->target_entity_id, 'pageComponent' => $pcpBlockDao->target_entity_type, - ); + ]; } $pcpLink = $links['add']; $action = CRM_Core_Action::formLink($pcpLink, $mask, $replace, ts('more'), FALSE, 'pcp.dashboard.other', "{$pcpBlockDao->target_entity_type}_PCP", $pcpBlockDao->target_entity_id); $component = $pcpBlockDao->target_entity_type; if ($pageTitle = CRM_Utils_Array::value($pcpBlockDao->target_entity_id, $$component)) { - $pcpBlock[] = array( + $pcpBlock[] = [ 'pageId' => $pcpBlockDao->target_entity_id, 'pageTitle' => $pageTitle, 'action' => $action, - ); + ]; } } - return array($pcpBlock, $pcpInfo); + return [$pcpBlock, $pcpInfo]; } /** @@ -231,7 +231,7 @@ public static function thermoMeter($pcpId) { LEFT JOIN civicrm_contribution cc ON ( cs.contribution_id = cc.id) WHERE pcp.id = %1 AND cc.contribution_status_id =1 AND cc.is_test = 0"; - $params = array(1 => array($pcpId, 'Integer')); + $params = [1 => [$pcpId, 'Integer']]; return CRM_Core_DAO::singleValueQuery($query, $params); } @@ -254,7 +254,7 @@ public static function honorRoll($pcpId) { AND contribution_status_id = 1 AND is_test = 0"; $dao = CRM_Core_DAO::executeQuery($query); - $honor = array(); + $honor = []; while ($dao->fetch()) { $honor[$dao->id]['nickname'] = ucwords($dao->pcp_roll_nickname); $honor[$dao->id]['total_amount'] = CRM_Utils_Money::format($dao->total_amount, $dao->currency); @@ -273,61 +273,61 @@ public static function &pcpLinks() { if (!(self::$_pcpLinks)) { $deleteExtra = ts('Are you sure you want to delete this Personal Campaign Page?') . '\n' . ts('This action cannot be undone.'); - self::$_pcpLinks['add'] = array( - CRM_Core_Action::ADD => array( + self::$_pcpLinks['add'] = [ + CRM_Core_Action::ADD => [ 'name' => ts('Create a Personal Campaign Page'), 'class' => 'no-popup', 'url' => 'civicrm/contribute/campaign', 'qs' => 'action=add&reset=1&pageId=%%pageId%%&component=%%pageComponent%%', 'title' => ts('Configure'), - ), - ); + ], + ]; - self::$_pcpLinks['all'] = array( - CRM_Core_Action::UPDATE => array( + self::$_pcpLinks['all'] = [ + CRM_Core_Action::UPDATE => [ 'name' => ts('Edit Your Page'), 'url' => 'civicrm/pcp/info', 'qs' => 'action=update&reset=1&id=%%pcpId%%&component=%%pageComponent%%', 'title' => ts('Configure'), - ), - CRM_Core_Action::DETACH => array( + ], + CRM_Core_Action::DETACH => [ 'name' => ts('Tell Friends'), 'url' => 'civicrm/friend', 'qs' => 'eid=%%pcpId%%&blockId=%%pcpBlock%%&reset=1&pcomponent=pcp&component=%%pageComponent%%', 'title' => ts('Tell Friends'), - ), - CRM_Core_Action::VIEW => array( + ], + CRM_Core_Action::VIEW => [ 'name' => ts('URL for this Page'), 'url' => 'civicrm/pcp/info', 'qs' => 'reset=1&id=%%pcpId%%&component=%%pageComponent%%', 'title' => ts('URL for this Page'), - ), - CRM_Core_Action::BROWSE => array( + ], + CRM_Core_Action::BROWSE => [ 'name' => ts('Update Contact Information'), 'url' => 'civicrm/pcp/info', 'qs' => 'action=browse&reset=1&id=%%pcpId%%&component=%%pageComponent%%', 'title' => ts('Update Contact Information'), - ), - CRM_Core_Action::ENABLE => array( + ], + CRM_Core_Action::ENABLE => [ 'name' => ts('Enable'), 'url' => 'civicrm/pcp', 'qs' => 'action=enable&reset=1&id=%%pcpId%%&component=%%pageComponent%%', 'title' => ts('Enable'), - ), - CRM_Core_Action::DISABLE => array( + ], + CRM_Core_Action::DISABLE => [ 'name' => ts('Disable'), 'url' => 'civicrm/pcp', 'qs' => 'action=disable&reset=1&id=%%pcpId%%&component=%%pageComponent%%', 'title' => ts('Disable'), - ), - CRM_Core_Action::DELETE => array( + ], + CRM_Core_Action::DELETE => [ 'name' => ts('Delete'), 'url' => 'civicrm/pcp', 'qs' => 'action=delete&reset=1&id=%%pcpId%%&component=%%pageComponent%%', 'extra' => 'onclick = "return confirm(\'' . $deleteExtra . '\');"', 'title' => ts('Delete'), - ), - ); + ], + ]; } return self::$_pcpLinks; } @@ -360,20 +360,20 @@ public static function deleteById($id) { * Form object. */ public static function buildPCPForm($form) { - $form->addElement('checkbox', 'pcp_active', ts('Enable Personal Campaign Pages?'), NULL, array('onclick' => "return showHideByValue('pcp_active',true,'pcpFields','block','radio',false);")); + $form->addElement('checkbox', 'pcp_active', ts('Enable Personal Campaign Pages?'), NULL, ['onclick' => "return showHideByValue('pcp_active',true,'pcpFields','block','radio',false);"]); $form->addElement('checkbox', 'is_approval_needed', ts('Approval required')); - $profile = array(); + $profile = []; $isUserRequired = NULL; $config = CRM_Core_Config::singleton(); if ($config->userFramework != 'Standalone') { $isUserRequired = 2; } - CRM_Core_DAO::commonRetrieveAll('CRM_Core_DAO_UFGroup', 'is_cms_user', $isUserRequired, $profiles, array( + CRM_Core_DAO::commonRetrieveAll('CRM_Core_DAO_UFGroup', 'is_cms_user', $isUserRequired, $profiles, [ 'title', 'is_active', - )); + ]); if (!empty($profiles)) { foreach ($profiles as $key => $value) { if ($value['is_active']) { @@ -383,13 +383,13 @@ public static function buildPCPForm($form) { $form->assign('profile', $profile); } - $form->add('select', 'supporter_profile_id', ts('Supporter Profile'), array('' => ts('- select -')) + $profile, TRUE); + $form->add('select', 'supporter_profile_id', ts('Supporter Profile'), ['' => ts('- select -')] + $profile, TRUE); //CRM-15821 - To add new option for PCP "Owner" notification $ownerNotifications = CRM_Core_OptionGroup::values('pcp_owner_notify'); $form->addRadio('owner_notify_id', ts('Owner Email Notification'), $ownerNotifications, NULL, '
    ', TRUE); - $form->addElement('checkbox', 'is_tellfriend_enabled', ts("Allow 'Tell a friend' functionality"), NULL, array('onclick' => "return showHideByValue('is_tellfriend_enabled',true,'tflimit','table-row','radio',false);")); + $form->addElement('checkbox', 'is_tellfriend_enabled', ts("Allow 'Tell a friend' functionality"), NULL, ['onclick' => "return showHideByValue('is_tellfriend_enabled',true,'tflimit','table-row','radio',false);"]); $form->add('number', 'tellfriend_limit', @@ -417,18 +417,18 @@ public static function buildPCPForm($form) { */ public static function buildPcp($pcpId, &$page, &$elements = NULL) { - $prms = array('id' => $pcpId); + $prms = ['id' => $pcpId]; CRM_Core_DAO::commonRetrieve('CRM_PCP_DAO_PCP', $prms, $pcpInfo); if ($pcpSupporter = CRM_PCP_BAO_PCP::displayName($pcpId)) { if ($pcpInfo['page_type'] == 'event') { - $pcp_supporter_text = ts('This event registration is being made thanks to the efforts of %1, who supports our campaign. ', array(1 => $pcpSupporter)); + $pcp_supporter_text = ts('This event registration is being made thanks to the efforts of %1, who supports our campaign. ', [1 => $pcpSupporter]); $text = CRM_PCP_BAO_PCP::getPcpBlockStatus($pcpInfo['page_id'], 'event'); if (!empty($text)) { $pcp_supporter_text .= "You can support it as well - once you complete the registration, you will be able to create your own Personal Campaign Page!"; } } else { - $pcp_supporter_text = ts('This contribution is being made thanks to the efforts of %1, who supports our campaign. ', array(1 => $pcpSupporter)); + $pcp_supporter_text = ts('This contribution is being made thanks to the efforts of %1, who supports our campaign. ', [1 => $pcpSupporter]); $text = CRM_PCP_BAO_PCP::getPcpBlockStatus($pcpInfo['page_id'], 'contribute'); if (!empty($text)) { $pcp_supporter_text .= "You can support it as well - once you complete the donation, you will be able to create your own Personal Campaign Page!"; @@ -443,17 +443,17 @@ public static function buildPcp($pcpId, &$page, &$elements = NULL) { if ($pcpInfo['is_honor_roll']) { $page->assign('is_honor_roll', TRUE); $page->add('checkbox', 'pcp_display_in_roll', ts('Show my support in the public honor roll'), NULL, NULL, - array('onclick' => "showHideByValue('pcp_display_in_roll','','nameID|nickID|personalNoteID','block','radio',false); pcpAnonymous( );") + ['onclick' => "showHideByValue('pcp_display_in_roll','','nameID|nickID|personalNoteID','block','radio',false); pcpAnonymous( );"] ); - $extraOption = array('onclick' => "return pcpAnonymous( );"); - $elements = array(); + $extraOption = ['onclick' => "return pcpAnonymous( );"]; + $elements = []; $elements[] = &$page->createElement('radio', NULL, '', ts('Include my name and message'), 0, $extraOption); $elements[] = &$page->createElement('radio', NULL, '', ts('List my support anonymously'), 1, $extraOption); $page->addGroup($elements, 'pcp_is_anonymous', NULL, '   '); $page->_defaults['pcp_is_anonymous'] = 0; - $page->add('text', 'pcp_roll_nickname', ts('Name'), array('maxlength' => 30)); - $page->addField('pcp_personal_note', array('entity' => 'ContributionSoft', 'context' => 'create', 'style' => 'height: 3em; width: 40em;')); + $page->add('text', 'pcp_roll_nickname', ts('Name'), ['maxlength' => 30]); + $page->addField('pcp_personal_note', ['entity' => 'ContributionSoft', 'context' => 'create', 'style' => 'height: 3em; width: 40em;']); } else { $page->assign('is_honor_roll', FALSE); @@ -480,13 +480,13 @@ public static function handlePcp($pcpId, $component, $entity) { $pcpStatus = CRM_Core_PseudoConstant::get('CRM_PCP_BAO_PCP', 'status_id'); $approvedId = array_search('Approved', $pcpStatus); - $params = array('id' => $pcpId); + $params = ['id' => $pcpId]; CRM_Core_DAO::commonRetrieve('CRM_PCP_DAO_PCP', $params, $pcpInfo); - $params = array('id' => $pcpInfo['pcp_block_id']); + $params = ['id' => $pcpInfo['pcp_block_id']]; CRM_Core_DAO::commonRetrieve('CRM_PCP_DAO_PCPBlock', $params, $pcpBlock); - $params = array('id' => $pcpInfo['page_id']); + $params = ['id' => $pcpInfo['page_id']]; $now = time(); if ($component == 'event') { @@ -513,7 +513,7 @@ public static function handlePcp($pcpId, $component, $entity) { CRM_Core_Error::statusBounce($statusMessage, $url); } elseif ($currentPCPStatus !== 'Approved') { - $statusMessage = ts('The Personal Campaign Page you have just visited is currently %1. However you can still support the campaign here.', array(1 => $pcpStatus[$pcpInfo['status_id']])); + $statusMessage = ts('The Personal Campaign Page you have just visited is currently %1. However you can still support the campaign here.', [1 => $pcpStatus[$pcpInfo['status_id']]]); CRM_Core_Error::statusBounce($statusMessage, $url); } elseif (empty($pcpBlock['is_active'])) { @@ -530,12 +530,12 @@ public static function handlePcp($pcpId, $component, $entity) { $customEndDate = CRM_Utils_Date::customFormat(CRM_Utils_Array::value('end_date', $entity)); if ($startDate && $endDate) { $statusMessage = ts('The Personal Campaign Page you have just visited is only active from %1 to %2. However you can still support the campaign here.', - array(1 => $customStartDate, 2 => $customEndDate) + [1 => $customStartDate, 2 => $customEndDate] ); CRM_Core_Error::statusBounce($statusMessage, $url); } elseif ($startDate) { - $statusMessage = ts('The Personal Campaign Page you have just visited will be active beginning on %1. However you can still support the campaign here.', array(1 => $customStartDate)); + $statusMessage = ts('The Personal Campaign Page you have just visited will be active beginning on %1. However you can still support the campaign here.', [1 => $customStartDate]); CRM_Core_Error::statusBounce($statusMessage, $url); } elseif ($endDate) { @@ -545,21 +545,21 @@ public static function handlePcp($pcpId, $component, $entity) { "reset=1&id={$pcpBlock['entity_id']}", FALSE, NULL, FALSE, TRUE ); - $statusMessage = ts('The event linked to the Personal Campaign Page you have just visited is over (as of %1).', array(1 => $customEndDate)); + $statusMessage = ts('The event linked to the Personal Campaign Page you have just visited is over (as of %1).', [1 => $customEndDate]); CRM_Core_Error::statusBounce($statusMessage, $url); } else { - $statusMessage = ts('The Personal Campaign Page you have just visited is no longer active (as of %1). However you can still support the campaign here.', array(1 => $customEndDate)); + $statusMessage = ts('The Personal Campaign Page you have just visited is no longer active (as of %1). However you can still support the campaign here.', [1 => $customEndDate]); CRM_Core_Error::statusBounce($statusMessage, $url); } } } - return array( + return [ 'pcpId' => $pcpId, 'pcpBlock' => $pcpBlock, 'pcpInfo' => $pcpInfo, - ); + ]; } /** @@ -589,10 +589,10 @@ public static function setIsActive($id, $is_active) { $pcpStatus = CRM_Core_OptionGroup::values("pcp_status"); $pcpStatus = $pcpStatus[$is_active]; - CRM_Core_Session::setStatus(ts("%1 status has been updated to %2.", array( + CRM_Core_Session::setStatus(ts("%1 status has been updated to %2.", [ 1 => $pcpTitle, 2 => $pcpStatus, - )), 'Status Updated', 'success'); + ]), 'Status Updated', 'success'); // send status change mail $result = self::sendStatusUpdate($id, $is_active, FALSE, $pcpPageType); @@ -636,30 +636,30 @@ public static function sendStatusUpdate($pcpId, $newStatus, $isInitial = FALSE, // used in subject templates $contribPageTitle = self::getPcpPageTitle($pcpId, $component); - $tplParams = array( + $tplParams = [ 'loginUrl' => $loginURL, 'contribPageTitle' => $contribPageTitle, 'pcpId' => $pcpId, - ); + ]; //get the default domain email address. list($domainEmailName, $domainEmailAddress) = CRM_Core_BAO_Domain::getNameAndEmail(); if (!$domainEmailAddress || $domainEmailAddress == 'info@EXAMPLE.ORG') { $fixUrl = CRM_Utils_System::url("civicrm/admin/domain", 'action=update&reset=1'); - CRM_Core_Error::fatal(ts('The site administrator needs to enter a valid \'FROM Email Address\' in Administer CiviCRM » Communications » FROM Email Addresses. The email address used may need to be a valid mail account with your email service provider.', array(1 => $fixUrl))); + CRM_Core_Error::fatal(ts('The site administrator needs to enter a valid \'FROM Email Address\' in Administer CiviCRM » Communications » FROM Email Addresses. The email address used may need to be a valid mail account with your email service provider.', [1 => $fixUrl])); } $receiptFrom = '"' . $domainEmailName . '" <' . $domainEmailAddress . '>'; // get recipient (supporter) name and email - $params = array('id' => $pcpId); + $params = ['id' => $pcpId]; CRM_Core_DAO::commonRetrieve('CRM_PCP_DAO_PCP', $params, $pcpInfo); list($name, $address) = CRM_Contact_BAO_Contact_Location::getEmailDetails($pcpInfo['contact_id']); // get pcp block info list($blockId, $eid) = self::getPcpBlockEntityId($pcpId, $component); - $params = array('id' => $blockId); + $params = ['id' => $blockId]; CRM_Core_DAO::commonRetrieve('CRM_PCP_DAO_PCPBlock', $params, $pcpBlockInfo); // assign urls required in email template @@ -689,7 +689,7 @@ public static function sendStatusUpdate($pcpId, $newStatus, $isInitial = FALSE, $tplName = $isInitial ? 'pcp_supporter_notify' : 'pcp_status_change'; list($sent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate( - array( + [ 'groupName' => 'msg_tpl_workflow_contribution', 'valueName' => $tplName, 'contactId' => $pcpInfo['contact_id'], @@ -697,7 +697,7 @@ public static function sendStatusUpdate($pcpId, $newStatus, $isInitial = FALSE, 'from' => $receiptFrom, 'toName' => $name, 'toEmail' => $address, - ) + ] ); return $sent; } @@ -735,7 +735,7 @@ public static function getStatus($pcpId, $component) { $entity_table = self::getPcpEntityTable($component); - $params = array(1 => array($pcpId, 'Integer'), 2 => array($entity_table, 'String')); + $params = [1 => [$pcpId, 'Integer'], 2 => [$entity_table, 'String']]; return CRM_Core_DAO::singleValueQuery($query, $params); } @@ -757,7 +757,7 @@ public static function getPcpBlockStatus($pageId, $component) { $entity_table = self::getPcpEntityTable($component); - $params = array(1 => array($pageId, 'Integer'), 2 => array($entity_table, 'String')); + $params = [1 => [$pageId, 'Integer'], 2 => [$entity_table, 'String']]; return CRM_Core_DAO::singleValueQuery($query, $params); } @@ -775,7 +775,7 @@ public static function getPcpBlockInUse($id) { FROM civicrm_pcp pcp WHERE pcp.pcp_block_id = %1"; - $params = array(1 => array($id, 'Integer')); + $params = [1 => [$id, 'Integer']]; $result = CRM_Core_DAO::singleValueQuery($query, $params); return $result > 0; } @@ -794,7 +794,7 @@ public static function checkEmailProfile($profileId) { FROM civicrm_uf_field WHERE field_name like 'email%' And is_active = 1 And uf_group_id = %1"; - $params = array(1 => array($profileId, 'Integer')); + $params = [1 => [$profileId, 'Integer']]; $dao = CRM_Core_DAO::executeQuery($query, $params); if (!$dao->fetch()) { return TRUE; @@ -826,7 +826,7 @@ public static function getPcpPageTitle($pcpId, $component) { WHERE pcp.id = %1"; } - $params = array(1 => array($pcpId, 'Integer')); + $params = [1 => [$pcpId, 'Integer']]; return CRM_Core_DAO::singleValueQuery($query, $params); } @@ -847,13 +847,13 @@ public static function getPcpBlockEntityId($pcpId, $component) { LEFT JOIN civicrm_pcp_block pb ON ( pb.entity_id = pcp.page_id AND pb.entity_table = %2 ) WHERE pcp.id = %1"; - $params = array(1 => array($pcpId, 'Integer'), 2 => array($entity_table, 'String')); + $params = [1 => [$pcpId, 'Integer'], 2 => [$entity_table, 'String']]; $dao = CRM_Core_DAO::executeQuery($query, $params); if ($dao->fetch()) { - return array($dao->pcpBlockId, $dao->entity_id); + return [$dao->pcpBlockId, $dao->entity_id]; } - return array(); + return []; } /** @@ -864,12 +864,12 @@ public static function getPcpBlockEntityId($pcpId, $component) { * @return string */ public static function getPcpEntityTable($component) { - $entity_table_map = array( + $entity_table_map = [ 'event' => 'civicrm_event', 'civicrm_event' => 'civicrm_event', 'contribute' => 'civicrm_contribution_page', 'civicrm_contribution_page' => 'civicrm_contribution_page', - ); + ]; return isset($entity_table_map[$component]) ? $entity_table_map[$component] : FALSE; } @@ -893,7 +893,7 @@ public static function getSupporterProfileId($component_id, $component = 'contri AND pcp.entity_table = %2 AND ufgroup.is_active = 1"; - $params = array(1 => array($component_id, 'Integer'), 2 => array($entity_table, 'String')); + $params = [1 => [$component_id, 'Integer'], 2 => [$entity_table, 'String']]; if (!$supporterProfileId = CRM_Core_DAO::singleValueQuery($query, $params)) { CRM_Core_Error::fatal(ts('Supporter profile is not set for this Personal Campaign Page or the profile is disabled. Please contact the site administrator if you need assistance.')); } @@ -916,7 +916,7 @@ public static function getOwnerNotificationId($component_id, $component = 'contr SELECT pb.owner_notify_id FROM civicrm_pcp_block pb WHERE pb.entity_id = %1 AND pb.entity_table = %2"; - $params = array(1 => array($component_id, 'Integer'), 2 => array($entity_table, 'String')); + $params = [1 => [$component_id, 'Integer'], 2 => [$entity_table, 'String']]; if (!$ownerNotificationId = CRM_Core_DAO::singleValueQuery($query, $params)) { CRM_Core_Error::fatal(ts('Owner Notification is not set for this Personal Campaign Page. Please contact the site administrator if you need assistance.')); } diff --git a/CRM/PCP/Form/Campaign.php b/CRM/PCP/Form/Campaign.php index b8edaa03cf73..fe2bb9880fa9 100644 --- a/CRM/PCP/Form/Campaign.php +++ b/CRM/PCP/Form/Campaign.php @@ -71,7 +71,7 @@ public function preProcess() { * Default values for the form. */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; $dao = new CRM_PCP_DAO_PCP(); if ($this->_pageId) { @@ -110,21 +110,21 @@ public function buildQuickForm() { $this->add('text', 'goal_amount', ts('Your Goal'), NULL, TRUE); $this->addRule('goal_amount', ts('Goal Amount should be a numeric value'), 'money'); - $attributes = array(); + $attributes = []; if ($this->_component == 'event') { if ($this->get('action') & CRM_Core_Action::ADD) { - $attributes = array('value' => ts('Join Us'), 'onClick' => 'select();'); + $attributes = ['value' => ts('Join Us'), 'onClick' => 'select();']; } $this->add('text', 'donate_link_text', ts('Sign up Button'), $attributes); } else { if ($this->get('action') & CRM_Core_Action::ADD) { - $attributes = array('value' => ts('Donate Now'), 'onClick' => 'select();'); + $attributes = ['value' => ts('Donate Now'), 'onClick' => 'select();']; } $this->add('text', 'donate_link_text', ts('Donation Button'), $attributes); } - $attrib = array('rows' => 8, 'cols' => 60); + $attrib = ['rows' => 8, 'cols' => 60]; $this->add('textarea', 'page_text', ts('Your Message'), NULL, FALSE); $maxAttachments = 1; @@ -133,7 +133,7 @@ public function buildQuickForm() { $this->addElement('checkbox', 'is_thermometer', ts('Progress Bar')); $this->addElement('checkbox', 'is_honor_roll', ts('Honor Roll'), NULL); if ($this->_pageId) { - $params = array('id' => $this->_pageId); + $params = ['id' => $this->_pageId]; CRM_Core_DAO::commonRetrieve('CRM_PCP_DAO_PCP', $params, $pcpInfo); $owner_notification_option = CRM_Core_DAO::getFieldValue('CRM_PCP_BAO_PCPBlock', $pcpInfo['pcp_block_id'], 'owner_notify_id'); } @@ -151,19 +151,19 @@ public function buildQuickForm() { } $this->addButtons( - array( - array( + [ + [ 'type' => 'upload', 'name' => ts('Save'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); - $this->addFormRule(array('CRM_PCP_Form_Campaign', 'formRule'), $this); + $this->addFormRule(['CRM_PCP_Form_Campaign', 'formRule'], $this); } /** @@ -180,7 +180,7 @@ public function buildQuickForm() { * true if no errors, else array of errors */ public static function formRule($fields, $files, $self) { - $errors = array(); + $errors = []; if ($fields['goal_amount'] <= 0) { $errors['goal_amount'] = ts('Goal Amount should be a numeric value greater than zero.'); } @@ -195,7 +195,7 @@ public static function formRule($fields, $files, $self) { */ public function postProcess() { $params = $this->controller->exportValues($this->_name); - $checkBoxes = array('is_thermometer', 'is_honor_roll', 'is_active', 'is_notify'); + $checkBoxes = ['is_thermometer', 'is_honor_roll', 'is_active', 'is_notify']; foreach ($checkBoxes as $key) { if (!isset($params[$key])) { @@ -215,7 +215,7 @@ public function postProcess() { // since we are allowing html input from the user // we also need to purify it, so lets clean it up - $htmlFields = array('intro_text', 'page_text', 'title'); + $htmlFields = ['intro_text', 'page_text', 'title']; foreach ($htmlFields as $field) { if (!empty($params[$field])) { $params[$field] = CRM_Utils_String::purifyHTML($params[$field]); @@ -256,10 +256,10 @@ public function postProcess() { $statusId = CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCP', $pcp->id, 'status_id'); //send notification of PCP create/update. - $pcpParams = array('entity_table' => $entity_table, 'entity_id' => $pcp->page_id); - $notifyParams = array(); + $pcpParams = ['entity_table' => $entity_table, 'entity_id' => $pcp->page_id]; + $notifyParams = []; $notifyStatus = ""; - CRM_Core_DAO::commonRetrieve('CRM_PCP_DAO_PCPBlock', $pcpParams, $notifyParams, array('notify_email')); + CRM_Core_DAO::commonRetrieve('CRM_PCP_DAO_PCPBlock', $pcpParams, $notifyParams, ['notify_email']); if ($emails = $pcpBlock->notify_email) { $this->assign('pcpTitle', $pcp->title); @@ -316,7 +316,7 @@ public function postProcess() { if (!$domainEmailAddress || $domainEmailAddress == 'info@EXAMPLE.ORG') { $fixUrl = CRM_Utils_System::url('civicrm/admin/domain', 'action=update&reset=1'); - CRM_Core_Error::fatal(ts('The site administrator needs to enter a valid \'FROM Email Address\' in Administer CiviCRM » Communications » FROM Email Addresses. The email address used may need to be a valid mail account with your email service provider.', array(1 => $fixUrl))); + CRM_Core_Error::fatal(ts('The site administrator needs to enter a valid \'FROM Email Address\' in Administer CiviCRM » Communications » FROM Email Addresses. The email address used may need to be a valid mail account with your email service provider.', [1 => $fixUrl])); } //if more than one email present for PCP notification , @@ -329,14 +329,14 @@ public function postProcess() { $cc = implode(',', $emailArray); list($sent, $subject, $message, $html) = CRM_Core_BAO_MessageTemplate::sendTemplate( - array( + [ 'groupName' => 'msg_tpl_workflow_contribution', 'valueName' => 'pcp_notify', 'contactId' => $contactID, 'from' => "$domainEmailName <$domainEmailAddress>", 'toEmail' => $to, 'cc' => $cc, - ) + ] ); if ($sent) { @@ -361,7 +361,7 @@ public function postProcess() { } CRM_Core_Session::setStatus(ts("Your Personal Campaign Page has been %1 %2 %3", - array(1 => $pageStatus, 2 => $approvalMessage, 3 => $notifyStatus) + [1 => $pageStatus, 2 => $approvalMessage, 3 => $notifyStatus] ), '', 'info'); if (!$this->_pageId) { $session->pushUserContext(CRM_Utils_System::url('civicrm/pcp/info', "reset=1&id={$pcp->id}&ap={$anonymousPCP}")); diff --git a/CRM/PCP/Form/Contribute.php b/CRM/PCP/Form/Contribute.php index a27e35ae36cf..4a09ff4cda2e 100644 --- a/CRM/PCP/Form/Contribute.php +++ b/CRM/PCP/Form/Contribute.php @@ -58,10 +58,10 @@ public function preProcess() { * @return void */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; if (isset($this->_id)) { - $params = array('entity_id' => $this->_id, 'entity_table' => 'civicrm_contribution_page'); + $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); // Assign contribution page ID to pageId for referencing in PCP.hlp - since $id is overwritten there. dgg @@ -92,10 +92,10 @@ public function buildQuickForm() { $this->_last = TRUE; CRM_PCP_BAO_PCP::buildPCPForm($this); - $this->addElement('checkbox', 'pcp_active', ts('Enable Personal Campaign Pages? (for this contribution page)'), NULL, array('onclick' => "return showHideByValue('pcp_active',true,'pcpFields','table-row','radio',false);")); + $this->addElement('checkbox', 'pcp_active', ts('Enable Personal Campaign Pages? (for this contribution page)'), NULL, ['onclick' => "return showHideByValue('pcp_active',true,'pcpFields','table-row','radio',false);"]); parent::buildQuickForm(); - $this->addFormRule(array('CRM_PCP_Form_Contribute', 'formRule'), $this); + $this->addFormRule(['CRM_PCP_Form_Contribute', 'formRule'], $this); } /** @@ -111,7 +111,7 @@ public function buildQuickForm() { * mixed true or array of errors */ public static function formRule($params, $files, $self) { - $errors = array(); + $errors = []; if (!empty($params['is_active'])) { if (!empty($params['is_tellfriend_enabled']) && diff --git a/CRM/PCP/Form/Event.php b/CRM/PCP/Form/Event.php index 32b0cfd25d0e..0be13e2b77cd 100644 --- a/CRM/PCP/Form/Event.php +++ b/CRM/PCP/Form/Event.php @@ -58,12 +58,12 @@ public function preProcess() { * @return array */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; if (isset($this->_id)) { $title = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_id, 'title'); - CRM_Utils_System::setTitle(ts('Personal Campaign Page Settings (%1)', array(1 => $title))); + CRM_Utils_System::setTitle(ts('Personal Campaign Page Settings (%1)', [1 => $title])); - $params = array('entity_id' => $this->_id, 'entity_table' => 'civicrm_event'); + $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); // Assign contribution page ID to pageId for referencing in PCP.hlp - since $id is overwritten there. dgg @@ -95,18 +95,18 @@ public function setDefaultValues() { public function buildQuickForm() { CRM_PCP_BAO_PCP::buildPCPForm($this); - $this->addElement('checkbox', 'pcp_active', ts('Enable Personal Campaign Pages? (for this event)'), NULL, array('onclick' => "return showHideByValue('pcp_active',true,'pcpFields','table-row','radio',false);")); + $this->addElement('checkbox', 'pcp_active', ts('Enable Personal Campaign Pages? (for this event)'), NULL, ['onclick' => "return showHideByValue('pcp_active',true,'pcpFields','table-row','radio',false);"]); $this->add('select', 'target_entity_type', ts('Campaign Type'), - array('' => ts('- select -'), 'event' => ts('Event'), 'contribute' => ts('Contribution')), - NULL, array('onchange' => "return showHideByValue('target_entity_type','contribute','pcpDetailFields','block','select',false);") + ['' => ts('- select -'), 'event' => ts('Event'), 'contribute' => ts('Contribution')], + NULL, ['onchange' => "return showHideByValue('target_entity_type','contribute','pcpDetailFields','block','select',false);"] ); $this->add('select', 'target_entity_id', ts('Online Contribution Page'), - array( + [ '' => ts('- select -'), - ) + + ] + CRM_Contribute_PseudoConstant::contributionPage() ); @@ -119,15 +119,15 @@ public function buildQuickForm() { $pcpBlock->find(TRUE); if (!empty($pcpBlock->id) && CRM_PCP_BAO_PCP::getPcpBlockInUse($pcpBlock->id)) { - foreach (array( + foreach ([ 'target_entity_type', 'target_entity_id', - ) as $element_name) { + ] as $element_name) { $element = $this->getElement($element_name); $element->freeze(); } } - $this->addFormRule(array('CRM_PCP_Form_Event', 'formRule'), $this); + $this->addFormRule(['CRM_PCP_Form_Event', 'formRule'], $this); } /** @@ -143,7 +143,7 @@ public function buildQuickForm() { * mixed true or array of errors */ public static function formRule($params, $files, $self) { - $errors = array(); + $errors = []; if (!empty($params['is_active'])) { if (!empty($params['is_tellfriend_enabled']) && diff --git a/CRM/PCP/Form/PCP.php b/CRM/PCP/Form/PCP.php index 7992a24e1b9d..cf0550415267 100644 --- a/CRM/PCP/Form/PCP.php +++ b/CRM/PCP/Form/PCP.php @@ -92,19 +92,19 @@ public function preProcess() { case CRM_Core_Action::DELETE: case 'delete': CRM_PCP_BAO_PCP::deleteById($this->_id); - CRM_Core_Session::setStatus(ts("The Campaign Page '%1' has been deleted.", array(1 => $this->_title)), ts('Page Deleted'), 'success'); + CRM_Core_Session::setStatus(ts("The Campaign Page '%1' has been deleted.", [1 => $this->_title]), ts('Page Deleted'), 'success'); break; case CRM_Core_Action::DISABLE: case 'disable': CRM_PCP_BAO_PCP::setDisable($this->_id, '0'); - CRM_Core_Session::setStatus(ts("The Campaign Page '%1' has been disabled.", array(1 => $this->_title)), ts('Page Disabled'), 'success'); + CRM_Core_Session::setStatus(ts("The Campaign Page '%1' has been disabled.", [1 => $this->_title]), ts('Page Disabled'), 'success'); break; case CRM_Core_Action::ENABLE: case 'enable': CRM_PCP_BAO_PCP::setDisable($this->_id, '1'); - CRM_Core_Session::setStatus(ts("The Campaign Page '%1' has been enabled.", array(1 => $this->_title)), ts('Page Enabled'), 'success'); + CRM_Core_Session::setStatus(ts("The Campaign Page '%1' has been enabled.", [1 => $this->_title]), ts('Page Enabled'), 'success'); break; } @@ -122,7 +122,7 @@ public function preProcess() { * array of default values */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; $pageType = CRM_Utils_Request::retrieve('page_type', 'String', $this); $defaults['page_type'] = !empty($pageType) ? $pageType : ''; @@ -135,42 +135,42 @@ public function setDefaultValues() { */ public function buildQuickForm() { if ($this->_action & CRM_Core_Action::DELETE) { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => ts('Delete Campaign'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); } else { - $status = array('' => ts('- select -')) + CRM_Core_OptionGroup::values("pcp_status"); - $types = array( + $status = ['' => ts('- select -')] + CRM_Core_OptionGroup::values("pcp_status"); + $types = [ '' => ts('- select -'), 'contribute' => ts('Contribution'), 'event' => ts('Event'), - ); - $contribPages = array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::contributionPage(); - $eventPages = array('' => ts('- select -')) + CRM_Event_PseudoConstant::event(NULL, FALSE, "( is_template IS NULL OR is_template != 1 )"); + ]; + $contribPages = ['' => ts('- select -')] + CRM_Contribute_PseudoConstant::contributionPage(); + $eventPages = ['' => ts('- select -')] + CRM_Event_PseudoConstant::event(NULL, FALSE, "( is_template IS NULL OR is_template != 1 )"); $this->addElement('select', 'status_id', ts('Status'), $status); $this->addElement('select', 'page_type', ts('Source Type'), $types); $this->addElement('select', 'page_id', ts('Contribution Page'), $contribPages); $this->addElement('select', 'event_id', ts('Event Page'), $eventPages); - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'refresh', 'name' => ts('Search'), 'spacing' => '         ', 'isDefault' => TRUE, - ), - ) + ], + ] ); parent::buildQuickForm(); } @@ -197,14 +197,14 @@ public static function formRule($fields, $files, $form) { public function postProcess() { if ($this->_action & CRM_Core_Action::DELETE) { CRM_PCP_BAO_PCP::deleteById($this->_id); - CRM_Core_Session::setStatus(ts("The Campaign Page '%1' has been deleted.", array(1 => $this->_title)), ts('Page Deleted'), 'success'); + CRM_Core_Session::setStatus(ts("The Campaign Page '%1' has been deleted.", [1 => $this->_title]), ts('Page Deleted'), 'success'); } else { $params = $this->controller->exportValues($this->_name); $parent = $this->controller->getParent(); if (!empty($params)) { - $fields = array('status_id', 'page_id'); + $fields = ['status_id', 'page_id']; foreach ($fields as $field) { if (isset($params[$field]) && !CRM_Utils_System::isNull($params[$field]) diff --git a/CRM/PCP/Form/PCPAccount.php b/CRM/PCP/Form/PCPAccount.php index 7607dd9106a5..84c9b316a1ae 100644 --- a/CRM/PCP/Form/PCPAccount.php +++ b/CRM/PCP/Form/PCPAccount.php @@ -107,7 +107,7 @@ public function preProcess() { * @return array */ public function setDefaultValues() { - $this->_defaults = array(); + $this->_defaults = []; if ($this->_contactID) { foreach ($this->_fields as $name => $dontcare) { $fields[$name] = 1; @@ -143,7 +143,7 @@ public function buildQuickForm() { if (CRM_Core_BAO_UFGroup::filterUFGroups($id, $this->_contactID)) { $fields = CRM_Core_BAO_UFGroup::getFields($id, FALSE, CRM_Core_Action::ADD); } - $this->addFormRule(array('CRM_PCP_Form_PCPAccount', 'formRule'), $this); + $this->addFormRule(['CRM_PCP_Form_PCPAccount', 'formRule'], $this); } else { CRM_Core_BAO_CMSUser::buildForm($this, $id, TRUE); @@ -183,28 +183,28 @@ public function buildQuickForm() { } if ($this->_single) { - $button = array( - array( + $button = [ + [ 'type' => 'next', 'name' => ts('Save'), 'spacing' => '         ', 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ); + ], + ]; } else { - $button[] = array( + $button[] = [ 'type' => 'next', 'name' => ts('Continue'), 'spacing' => '         ', 'isDefault' => TRUE, - ); + ]; } - $this->addFormRule(array('CRM_PCP_Form_PCPAccount', 'formRule'), $this); + $this->addFormRule(['CRM_PCP_Form_PCPAccount', 'formRule'], $this); $this->addButtons($button); } @@ -222,7 +222,7 @@ public function buildQuickForm() { * true if no errors, else array of errors */ public static function formRule($fields, $files, $self) { - $errors = array(); + $errors = []; foreach ($fields as $key => $value) { if (strpos($key, 'email-') !== FALSE && !empty($value)) { $ufContactId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFMatch', $value, 'contact_id', 'uf_name'); @@ -257,7 +257,7 @@ public function postProcess() { $isPrimary = 1; } - $params['email'] = array(); + $params['email'] = []; $params['email'][1]['email'] = $value; $params['email'][1]['location_type_id'] = $locTypeId; $params['email'][1]['is_primary'] = $isPrimary; @@ -265,7 +265,7 @@ public function postProcess() { } } - $this->_contactID = CRM_Contact_BAO_Contact::getFirstDuplicateContact($params, 'Individual', 'Unsupervised', array(), FALSE); + $this->_contactID = CRM_Contact_BAO_Contact::getFirstDuplicateContact($params, 'Individual', 'Unsupervised', [], FALSE); $contactID = CRM_Contact_BAO_Contact::createProfileContact($params, $this->_fields, $this->_contactID); $this->set('contactID', $contactID); diff --git a/CRM/PCP/Page/PCPInfo.php b/CRM/PCP/Page/PCPInfo.php index 3a3c2b34bf91..1327de5a63a6 100644 --- a/CRM/PCP/Page/PCPInfo.php +++ b/CRM/PCP/Page/PCPInfo.php @@ -61,7 +61,7 @@ public function run() { $action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE); - $prms = array('id' => $this->_id); + $prms = ['id' => $this->_id]; CRM_Core_DAO::commonRetrieve('CRM_PCP_DAO_PCP', $prms, $pcpInfo); $this->_component = $pcpInfo['page_type']; @@ -83,7 +83,7 @@ public function run() { $anonymousPCP = CRM_Utils_Request::retrieve('ap', 'Boolean', $this); if ($anonymousPCP) { $loginURL = $config->userSystem->getLoginURL(); - $anonMessage = ts('Once you\'ve received your new account welcome email, you can click here to login and promote your campaign page.', array(1 => $loginURL)); + $anonMessage = ts('Once you\'ve received your new account welcome email, you can click here to login and promote your campaign page.', [1 => $loginURL]); CRM_Core_Session::setStatus($anonMessage, ts('Success'), 'success'); } else { @@ -122,7 +122,7 @@ public function run() { } } - $default = array(); + $default = []; if ($pcpBlock->target_entity_type == 'contribute') { $urlBase = 'civicrm/contribute/transact'; @@ -135,19 +135,19 @@ public function run() { $page_class = 'CRM_Event_DAO_Event'; $this->assign('pageName', CRM_Event_PseudoConstant::event($pcpInfo['page_id'])); CRM_Core_DAO::commonRetrieveAll($page_class, 'id', - $pcpInfo['page_id'], $default, array( + $pcpInfo['page_id'], $default, [ 'start_date', 'end_date', 'registration_start_date', 'registration_end_date', - ) + ] ); } elseif ($pcpBlock->entity_table == 'civicrm_contribution_page') { $page_class = 'CRM_Contribute_DAO_ContributionPage'; $this->assign('pageName', CRM_Contribute_PseudoConstant::contributionPage($pcpInfo['page_id'], TRUE)); CRM_Core_DAO::commonRetrieveAll($page_class, 'id', - $pcpInfo['page_id'], $default, array('start_date', 'end_date') + $pcpInfo['page_id'], $default, ['start_date', 'end_date'] ); } @@ -161,7 +161,7 @@ public function run() { $link = CRM_PCP_BAO_PCP::pcpLinks(); - $hints = array( + $hints = [ CRM_Core_Action::UPDATE => ts('Change the content and appearance of your page'), CRM_Core_Action::DETACH => ts('Send emails inviting your friends to support your campaign!'), CRM_Core_Action::VIEW => ts('Copy this link to share directly with your network!'), @@ -169,13 +169,13 @@ public function run() { CRM_Core_Action::DISABLE => ts('De-activate the page (you can re-activate it later)'), CRM_Core_Action::ENABLE => ts('Activate the page (you can de-activate it later)'), CRM_Core_Action::DELETE => ts('Remove the page (this cannot be undone!)'), - ); + ]; - $replace = array( + $replace = [ 'id' => $this->_id, 'block' => $pcpBlock->id, 'pageComponent' => $this->_component, - ); + ]; if (!$pcpBlock->is_tellfriend_enabled || CRM_Utils_Array::value('status_id', $pcpInfo) != $approvedId) { unset($link['all'][CRM_Core_Action::DETACH]); diff --git a/CRM/PCP/StateMachine/PCP.php b/CRM/PCP/StateMachine/PCP.php index 91f6a3b5ea3a..a1040ffe45a8 100644 --- a/CRM/PCP/StateMachine/PCP.php +++ b/CRM/PCP/StateMachine/PCP.php @@ -54,10 +54,10 @@ public function __construct($controller, $action = CRM_Core_Action::NONE) { $session = CRM_Core_Session::singleton(); $session->set('singleForm', FALSE); - $this->_pages = array( + $this->_pages = [ 'CRM_PCP_Form_PCPAccount' => NULL, 'CRM_PCP_Form_Campaign' => NULL, - ); + ]; $this->addSequentialPages($this->_pages, $action); } diff --git a/CRM/Pledge/BAO/PledgePayment.php b/CRM/Pledge/BAO/PledgePayment.php index a2f7ec9ecc9c..ec637d58b70b 100644 --- a/CRM/Pledge/BAO/PledgePayment.php +++ b/CRM/Pledge/BAO/PledgePayment.php @@ -70,10 +70,10 @@ public static function getPledgePayments($pledgeId) { WHERE pledge_id = %1 "; - $params[1] = array($pledgeId, 'Integer'); + $params[1] = [$pledgeId, 'Integer']; $payment = CRM_Core_DAO::executeQuery($query, $params); - $paymentDetails = array(); + $paymentDetails = []; while ($payment->fetch()) { $paymentDetails[$payment->id]['scheduled_amount'] = $payment->scheduled_amount; $paymentDetails[$payment->id]['scheduled_date'] = $payment->scheduled_date; @@ -103,7 +103,7 @@ public static function create($params) { //calculate the scheduled date for every installment $now = date('Ymd') . '000000'; - $statues = $prevScheduledDate = array(); + $statues = $prevScheduledDate = []; $prevScheduledDate[1] = CRM_Utils_Date::processDate($params['scheduled_date']); if (CRM_Utils_Date::overdue($prevScheduledDate[1], $now)) { @@ -418,12 +418,12 @@ public static function updatePledgePaymentStatus( $ScheduledDate = CRM_Utils_Date::format(CRM_Utils_Date::intervalAdd($pledgeFrequencyUnit, $pledgeFrequencyInterval, $newDate )); - $pledgeParams = array( + $pledgeParams = [ 'status_id' => array_search('Pending', $allStatus), 'pledge_id' => $pledgeID, 'scheduled_amount' => ($pledgeScheduledAmount - $actualAmount), 'scheduled_date' => $ScheduledDate, - ); + ]; $payment = self::add($pledgeParams); // while editing schedule, after adding a new pledge payemnt update the scheduled amount of the current payment if (!$paymentContributionId) { @@ -451,7 +451,7 @@ public static function updatePledgePaymentStatus( WHERE civicrm_pledge_payment.pledge_id = %1 AND civicrm_pledge_payment.status_id = 1 "; - $totalPaidParams = array(1 => array($pledgeID, 'Integer')); + $totalPaidParams = [1 => [$pledgeID, 'Integer']]; $totalPaidAmount = CRM_Core_DAO::singleValueQuery($balanceQuery, $totalPaidParams); $remainingTotalAmount = ($actualPledgeAmount - $totalPaidAmount); if (($pledgeStatusId && $pledgeStatusId == array_search('Completed', $allStatus)) && (($actualAmount > $remainingTotalAmount) || ($actualAmount >= $actualPledgeAmount))) { @@ -490,10 +490,10 @@ public static function updatePledgePaymentStatus( WHERE civicrm_pledge.id = %2 "; - $params = array( - 1 => array($pledgeStatusID, 'Integer'), - 2 => array($pledgeID, 'Integer'), - ); + $params = [ + 1 => [$pledgeStatusID, 'Integer'], + 2 => [$pledgeID, 'Integer'], + ]; CRM_Core_DAO::executeQuery($query, $params); @@ -512,7 +512,7 @@ public static function updatePledgePaymentStatus( * Next scheduled date as an array */ public static function calculateBaseScheduleDate(&$params) { - $date = array(); + $date = []; $scheduled_date = CRM_Utils_Date::processDate($params['scheduled_date']); $date['year'] = (int) substr($scheduled_date, 0, 4); $date['month'] = (int) substr($scheduled_date, 4, 2); @@ -568,20 +568,20 @@ public static function calculateNextScheduledDate(&$params, $paymentNo, $basePay } //CRM-18316 - change $basePaymentDate for the end dates of the month eg: 29, 30 or 31. - if ($params['frequency_unit'] == 'month' && in_array($params['frequency_day'], array(29, 30, 31))) { + if ($params['frequency_unit'] == 'month' && in_array($params['frequency_day'], [29, 30, 31])) { $frequency = $params['frequency_day']; extract(date_parse($basePaymentDate)); $lastDayOfMonth = date('t', mktime($hour, $minute, $second, $month + $interval, 1, $year)); // Take the last day in case the current month is Feb or frequency_day is set to 31. - if (in_array($lastDayOfMonth, array(28, 29)) || $frequency == 31) { + if (in_array($lastDayOfMonth, [28, 29]) || $frequency == 31) { $frequency = 0; $interval++; } - $basePaymentDate = array( + $basePaymentDate = [ 'M' => $month, 'd' => $frequency, 'Y' => $year, - ); + ]; } return CRM_Utils_Date::format( @@ -613,8 +613,8 @@ public static function calculatePledgeStatus($pledgeId) { } // retrieve all pledge payments for this particular pledge - $allPledgePayments = $allStatus = array(); - $returnProperties = array('status_id'); + $allPledgePayments = $allStatus = []; + $returnProperties = ['status_id']; CRM_Core_DAO::commonRetrieveAll('CRM_Pledge_DAO_PledgePayment', 'pledge_id', $pledgeId, $allPledgePayments, $returnProperties); // build pledge payment statuses @@ -689,7 +689,7 @@ public static function updatePledgePayments( {$paymentClause} "; - CRM_Core_DAO::executeQuery($query, array(1 => array($pledgeId, 'Integer'))); + CRM_Core_DAO::executeQuery($query, [1 => [$pledgeId, 'Integer']]); } /** @@ -741,20 +741,20 @@ public static function getOldestPledgePayment($pledgeID, $limit = 1) { LIMIT 0, %2 "; - $params[1] = array($pledgeID, 'Integer'); - $params[2] = array($limit, 'Integer'); + $params[1] = [$pledgeID, 'Integer']; + $params[2] = [$limit, 'Integer']; $payment = CRM_Core_DAO::executeQuery($query, $params); $count = 1; - $paymentDetails = array(); + $paymentDetails = []; while ($payment->fetch()) { - $paymentDetails[] = array( + $paymentDetails[] = [ 'id' => $payment->id, 'amount' => $payment->amount, 'currency' => $payment->currency, 'schedule_date' => $payment->scheduled_date, 'financial_type_id' => $payment->financial_type_id, 'count' => $count, - ); + ]; $count++; } return end($paymentDetails); @@ -778,7 +778,7 @@ public static function adjustPledgePayment($pledgeID, $actualAmount, $pledgeSche WHERE civicrm_pledge_payment.contribution_id = {$paymentContributionId} "; $paymentsAffected = CRM_Core_DAO::executeQuery($query); - $paymentIDs = array(); + $paymentIDs = []; while ($paymentsAffected->fetch()) { $paymentIDs[] = $paymentsAffected->id; } @@ -814,12 +814,12 @@ public static function adjustPledgePayment($pledgeID, $actualAmount, $pledgeSche $date['day'] = (int) substr($scheduled_date, 6, 2); $newDate = date('YmdHis', mktime(0, 0, 0, $date['month'], $date['day'], $date['year'])); $ScheduledDate = CRM_Utils_Date::format(CRM_Utils_Date::intervalAdd($pledgeFrequencyUnit, $pledgeFrequencyInterval, $newDate)); - $pledgeParams = array( + $pledgeParams = [ 'status_id' => array_search('Pending', $allStatus), 'pledge_id' => $pledgeID, 'scheduled_amount' => $pledgeScheduledAmount, 'scheduled_date' => $ScheduledDate, - ); + ]; $payment = self::add($pledgeParams); } else { @@ -854,7 +854,7 @@ public static function adjustPledgePayment($pledgeID, $actualAmount, $pledgeSche elseif (($actualAmount > $pledgeScheduledAmount) && (($actualAmount - $pledgeScheduledAmount) >= $nextPledgeInstallmentDue['amount'])) { // here the actual amount is greater than expected and also greater than the next installment amount, so update the next installment as complete and again add it to next subsequent pending payment // set the actual amount of the next pending to '0', set contribution Id to current contribution Id and status as completed - $paymentId = array($nextPledgeInstallmentDue['id']); + $paymentId = [$nextPledgeInstallmentDue['id']]; self::updatePledgePayments($pledgeID, array_search('Completed', $allStatus), $paymentId, 0, $paymentContributionId); CRM_Core_DAO::setFieldValue('CRM_Pledge_DAO_PledgePayment', $nextPledgeInstallmentDue['id'], 'scheduled_amount', 0, 'id'); if (!$paymentContributionId) { @@ -892,11 +892,11 @@ public static function adjustPledgePayment($pledgeID, $actualAmount, $pledgeSche * * @return array|bool */ - public static function buildOptions($fieldName, $context = NULL, $props = array()) { + public static function buildOptions($fieldName, $context = NULL, $props = []) { $result = parent::buildOptions($fieldName, $context, $props); if ($fieldName == 'status_id') { $result = CRM_Pledge_BAO_Pledge::buildOptions($fieldName, $context, $props); - $result = array_diff($result, array('Failed', 'In Progress')); + $result = array_diff($result, ['Failed', 'In Progress']); } return $result; } diff --git a/CRM/Pledge/BAO/Query.php b/CRM/Pledge/BAO/Query.php index fd0f831939d7..960d67c29d6a 100644 --- a/CRM/Pledge/BAO/Query.php +++ b/CRM/Pledge/BAO/Query.php @@ -322,7 +322,7 @@ public static function whereClauseSingle(&$values, &$query) { } $name = 'status_id'; if (!empty($value) && is_array($value) && !in_array(key($value), CRM_Core_DAO::acceptedSQLOperators(), TRUE)) { - $value = array('IN' => $value); + $value = ['IN' => $value]; } $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("$tableName.$name", @@ -331,7 +331,7 @@ public static function whereClauseSingle(&$values, &$query) { 'Integer' ); list($qillop, $qillVal) = CRM_Contact_BAO_Query::buildQillForFieldValue($qillDAO, $qillField, $value, $op); - $query->_qill[$grouping][] = ts('%1 %2 %3', array(1 => $label, 2 => $qillop, 3 => $qillVal)); + $query->_qill[$grouping][] = ts('%1 %2 %3', [1 => $label, 2 => $qillop, 3 => $qillVal]); return; case 'pledge_test': @@ -357,7 +357,7 @@ public static function whereClauseSingle(&$values, &$query) { $value, 'Integer' ); - $query->_qill[$grouping][] = ts('Financial Type - %1', array(1 => $type)); + $query->_qill[$grouping][] = ts('Financial Type - %1', [1 => $type]); $query->_tables['civicrm_pledge'] = $query->_whereTables['civicrm_pledge'] = 1; return; @@ -368,7 +368,7 @@ public static function whereClauseSingle(&$values, &$query) { $value, 'Integer' ); - $query->_qill[$grouping][] = ts('Financial Page - %1', array(1 => $page)); + $query->_qill[$grouping][] = ts('Financial Page - %1', [1 => $page]); $query->_tables['civicrm_pledge'] = $query->_whereTables['civicrm_pledge'] = 1; return; @@ -397,7 +397,7 @@ public static function whereClauseSingle(&$values, &$query) { $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_pledge.$name", $op, $value, 'Integer'); list($op, $value) = CRM_Contact_BAO_Query::buildQillForFieldValue('CRM_Pledge_DAO_Pledge', $name, $value, $op); $label = ($name == 'campaign_id') ? 'Campaign' : 'Contact ID'; - $query->_qill[$grouping][] = ts('%1 %2 %3', array(1 => $label, 2 => $op, 3 => $value)); + $query->_qill[$grouping][] = ts('%1 %2 %3', [1 => $label, 2 => $op, 3 => $value]); $query->_tables['civicrm_pledge'] = $query->_whereTables['civicrm_pledge'] = 1; return; } @@ -461,7 +461,7 @@ public static function defaultReturnProperties( $properties = NULL; if ($mode & CRM_Contact_BAO_Query::MODE_PLEDGE) { - $properties = array( + $properties = [ 'contact_type' => 1, 'contact_sub_type' => 1, 'sort_name' => 1, @@ -482,7 +482,7 @@ public static function defaultReturnProperties( 'pledge_frequency_unit' => 1, 'pledge_currency' => 1, 'pledge_campaign_id' => 1, - ); + ]; } return $properties; } @@ -498,7 +498,7 @@ public static function extraReturnProperties($mode) { $properties = NULL; if ($mode & CRM_Contact_BAO_Query::MODE_PLEDGE) { - $properties = array( + $properties = [ 'pledge_balance_amount' => 1, 'pledge_payment_id' => 1, 'pledge_payment_scheduled_amount' => 1, @@ -509,7 +509,7 @@ public static function extraReturnProperties($mode) { 'pledge_payment_reminder_count' => 1, 'pledge_payment_status_id' => 1, 'pledge_payment_status' => 1, - ); + ]; // also get all the custom pledge properties $fields = CRM_Core_BAO_CustomField::getFieldsForImport('Pledge'); @@ -535,61 +535,61 @@ public static function buildSearchForm(&$form) { CRM_Core_Form_Date::buildDateRange($form, 'pledge_payment_date', 1, '_low', '_high', ts('From'), FALSE); $form->addYesNo('pledge_test', ts('Pledge is a Test?'), TRUE); - $form->add('text', 'pledge_amount_low', ts('From'), array('size' => 8, 'maxlength' => 8)); - $form->addRule('pledge_amount_low', ts('Please enter a valid money value (e.g. %1).', array(1 => CRM_Utils_Money::format('9.99', ' '))), 'money'); + $form->add('text', 'pledge_amount_low', ts('From'), ['size' => 8, 'maxlength' => 8]); + $form->addRule('pledge_amount_low', ts('Please enter a valid money value (e.g. %1).', [1 => CRM_Utils_Money::format('9.99', ' ')]), 'money'); - $form->add('text', 'pledge_amount_high', ts('To'), array('size' => 8, 'maxlength' => 8)); - $form->addRule('pledge_amount_high', ts('Please enter a valid money value (e.g. %1).', array(1 => CRM_Utils_Money::format('99.99', ' '))), 'money'); + $form->add('text', 'pledge_amount_high', ts('To'), ['size' => 8, 'maxlength' => 8]); + $form->addRule('pledge_amount_high', ts('Please enter a valid money value (e.g. %1).', [1 => CRM_Utils_Money::format('99.99', ' ')]), 'money'); $form->add('select', 'pledge_status_id', ts('Pledge Status'), CRM_Pledge_BAO_Pledge::buildOptions('status_id'), - FALSE, array('class' => 'crm-select2', 'multiple' => 'multiple') + FALSE, ['class' => 'crm-select2', 'multiple' => 'multiple'] ); $form->addYesNo('pledge_acknowledge_date_is_not_null', ts('Acknowledgement sent?'), TRUE); - $form->add('text', 'pledge_installments_low', ts('From'), array('size' => 8, 'maxlength' => 8)); + $form->add('text', 'pledge_installments_low', ts('From'), ['size' => 8, 'maxlength' => 8]); $form->addRule('pledge_installments_low', ts('Please enter a number'), 'integer'); - $form->add('text', 'pledge_installments_high', ts('To'), array('size' => 8, 'maxlength' => 8)); + $form->add('text', 'pledge_installments_high', ts('To'), ['size' => 8, 'maxlength' => 8]); $form->addRule('pledge_installments_high', ts('Please enter number.'), 'integer'); $form->add('select', 'pledge_payment_status_id', ts('Pledge Payment Status'), CRM_Pledge_BAO_PledgePayment::buildOptions('status_id'), - FALSE, array('class' => 'crm-select2', 'multiple' => 'multiple') + FALSE, ['class' => 'crm-select2', 'multiple' => 'multiple'] ); $form->add('select', 'pledge_financial_type_id', ts('Financial Type'), - array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::financialType(), - FALSE, array('class' => 'crm-select2') + ['' => ts('- select -')] + CRM_Contribute_PseudoConstant::financialType(), + FALSE, ['class' => 'crm-select2'] ); $form->add('select', 'pledge_contribution_page_id', ts('Contribution Page'), - array('' => ts('- any -')) + CRM_Contribute_PseudoConstant::contributionPage(), - FALSE, array('class' => 'crm-select2') + ['' => ts('- any -')] + CRM_Contribute_PseudoConstant::contributionPage(), + FALSE, ['class' => 'crm-select2'] ); // add fields for pledge frequency - $form->add('text', 'pledge_frequency_interval', ts('Every'), array('size' => 8, 'maxlength' => 8)); + $form->add('text', 'pledge_frequency_interval', ts('Every'), ['size' => 8, 'maxlength' => 8]); $form->addRule('pledge_frequency_interval', ts('Please enter valid Pledge Frequency Interval'), 'integer'); $frequencies = CRM_Core_OptionGroup::values('recur_frequency_units'); foreach ($frequencies as $val => $label) { - $freqUnitsDisplay["'{$val}'"] = ts('%1(s)', array(1 => $label)); + $freqUnitsDisplay["'{$val}'"] = ts('%1(s)', [1 => $label]); } $form->add('select', 'pledge_frequency_unit', ts('Pledge Frequency'), - array('' => ts('- any -')) + $freqUnitsDisplay + ['' => ts('- any -')] + $freqUnitsDisplay ); - self::addCustomFormFields($form, array('Pledge')); + self::addCustomFormFields($form, ['Pledge']); CRM_Campaign_BAO_Campaign::addCampaignInComponentSearch($form, 'pledge_campaign_id'); $form->assign('validCiviPledge', TRUE); - $form->setDefaults(array('pledge_test' => 0)); + $form->setDefaults(['pledge_test' => 0]); } /** @@ -598,7 +598,7 @@ public static function buildSearchForm(&$form) { public static function tableNames(&$tables) { // add status table if (!empty($tables['pledge_status']) || !empty($tables['civicrm_pledge_payment'])) { - $tables = array_merge(array('civicrm_pledge' => 1), $tables); + $tables = array_merge(['civicrm_pledge' => 1], $tables); } } diff --git a/CRM/Pledge/Form/Payment.php b/CRM/Pledge/Form/Payment.php index 9cfbf05e5cd7..d56b4907bfac 100644 --- a/CRM/Pledge/Form/Payment.php +++ b/CRM/Pledge/Form/Payment.php @@ -76,7 +76,7 @@ public function preProcess() { * the default values are retrieved from the database. */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; if ($this->_id) { $params['id'] = $this->_id; CRM_Pledge_BAO_PledgePayment::retrieve($params, $defaults); @@ -99,35 +99,35 @@ public function buildQuickForm() { $this->addMoney('scheduled_amount', ts('Scheduled Amount'), TRUE, - array('readonly' => TRUE), + ['readonly' => TRUE], TRUE, 'currency', NULL, TRUE ); - $optionTypes = array( + $optionTypes = [ '1' => ts('Adjust Pledge Payment Schedule?'), '2' => ts('Adjust Total Pledge Amount?'), - ); + ]; $element = $this->addRadio('option_type', NULL, $optionTypes, - array(), '
    ' + [], '
    ' ); - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => ts('Save'), 'spacing' => '         ', 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); } @@ -169,7 +169,7 @@ public function postProcess() { } // update pledge status CRM_Pledge_BAO_PledgePayment::updatePledgePaymentStatus($pledgeId, - array($params['id']), + [$params['id']], $params['status_id'], NULL, $formValues['scheduled_amount'], diff --git a/CRM/Pledge/Form/Pledge.php b/CRM/Pledge/Form/Pledge.php index ac23c1b27cdf..7f4710d9a2a6 100644 --- a/CRM/Pledge/Form/Pledge.php +++ b/CRM/Pledge/Form/Pledge.php @@ -100,14 +100,14 @@ public function preProcess() { // build custom data CRM_Custom_Form_CustomData::preProcess($this, NULL, NULL, 1, 'Pledge', $this->_id); - $this->_values = array(); + $this->_values = []; // current pledge id if ($this->_id) { // get the contribution id $this->_contributionID = CRM_Core_DAO::getFieldValue('CRM_Pledge_DAO_PledgePayment', $this->_id, 'contribution_id', 'pledge_id' ); - $params = array('id' => $this->_id); + $params = ['id' => $this->_id]; CRM_Pledge_BAO_Pledge::getValues($params, $this->_values); $this->_isPending = (CRM_Pledge_BAO_Pledge::pledgeHasFinancialTransactions($this->_id, CRM_Utils_Array::value('status_id', $this->_values))) ? FALSE : TRUE; @@ -194,44 +194,44 @@ public function setDefaultValues() { */ public function buildQuickForm() { if ($this->_action & CRM_Core_Action::DELETE) { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => ts('Delete'), 'spacing' => '         ', 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); return; } if ($this->_context == 'standalone') { - $this->addEntityRef('contact_id', ts('Contact'), array( + $this->addEntityRef('contact_id', ts('Contact'), [ 'create' => TRUE, - 'api' => array('extra' => array('email')), - ), TRUE); + 'api' => ['extra' => ['email']], + ], TRUE); } $showAdditionalInfo = FALSE; $this->_formType = CRM_Utils_Array::value('formType', $_GET); - $defaults = array(); + $defaults = []; - $paneNames = array( + $paneNames = [ 'Payment Reminders' => 'PaymentReminders', - ); + ]; foreach ($paneNames as $name => $type) { $urlParams = "snippet=4&formType={$type}"; - $allPanes[$name] = array( + $allPanes[$name] = [ 'url' => CRM_Utils_System::url('civicrm/contact/view/pledge', $urlParams), 'open' => 'false', 'id' => $type, - ); + ]; // see if we need to include this paneName in the current form if ($this->_formType == $type || !empty($_POST["hidden_{$type}"]) || CRM_Utils_Array::value("hidden_{$type}", $defaults) @@ -258,10 +258,10 @@ public function buildQuickForm() { $this->assign('isPending', $this->_isPending); - $js = array( + $js = [ 'onblur' => "calculatedPaymentAmount( );", 'onkeyup' => "calculatedPaymentAmount( );", - ); + ]; $amount = $this->addMoney('amount', ts('Total Pledge Amount'), TRUE, array_merge($attributes['pledge_amount'], $js), TRUE, @@ -279,24 +279,24 @@ public function buildQuickForm() { $this->addRule('frequency_interval', ts('Please enter a number for frequency (e.g. every "3" months).'), 'positiveInteger'); // Fix frequency unit display for use with frequency_interval - $freqUnitsDisplay = array(); + $freqUnitsDisplay = []; foreach ($this->_freqUnits as $val => $label) { - $freqUnitsDisplay[$val] = ts('%1(s)', array(1 => $label)); + $freqUnitsDisplay[$val] = ts('%1(s)', [1 => $label]); } $frequencyUnit = $this->add('select', 'frequency_unit', ts('Frequency'), - array('' => ts('- select -')) + $freqUnitsDisplay, + ['' => ts('- select -')] + $freqUnitsDisplay, TRUE ); $frequencyDay = $this->add('number', 'frequency_day', ts('Payments are due on the'), $attributes['frequency_day'], TRUE); $this->addRule('frequency_day', ts('Please enter a valid payment due day.'), 'positiveInteger'); - $this->add('text', 'eachPaymentAmount', ts('each'), array( + $this->add('text', 'eachPaymentAmount', ts('each'), [ 'size' => 10, 'style' => "background-color:#EBECE4", 0 => 'READONLY', // WTF, preserved because its inexplicable - )); + ]); // add various dates $createDate = $this->add('datepicker', 'create_date', ts('Pledge Made'), [], TRUE, ['time' => FALSE]); @@ -326,7 +326,7 @@ public function buildQuickForm() { ) { $this->addElement('checkbox', 'is_acknowledge', ts('Send Acknowledgment?'), NULL, - array('onclick' => "showHideByValue( 'is_acknowledge', '', 'acknowledgeDate', 'table-row', 'radio', true); showHideByValue( 'is_acknowledge', '', 'fromEmail', 'table-row', 'radio', false );") + ['onclick' => "showHideByValue( 'is_acknowledge', '', 'acknowledgeDate', 'table-row', 'radio', true); showHideByValue( 'is_acknowledge', '', 'fromEmail', 'table-row', 'radio', false );"] ); $this->add('select', 'from_email_address', ts('Receipt From'), $this->_fromEmails); @@ -336,24 +336,24 @@ public function buildQuickForm() { $this->add('select', 'financial_type_id', ts('Financial Type'), - array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::financialType(), + ['' => ts('- select -')] + CRM_Contribute_PseudoConstant::financialType(), TRUE ); // CRM-7362 --add campaigns. CRM_Campaign_BAO_Campaign::addCampaign($this, CRM_Utils_Array::value('campaign_id', $this->_values)); - $pageIds = array(); + $pageIds = []; CRM_Core_DAO::commonRetrieveAll('CRM_Pledge_DAO_PledgeBlock', 'entity_table', - 'civicrm_contribution_page', $pageIds, array('entity_id') + 'civicrm_contribution_page', $pageIds, ['entity_id'] ); $pages = CRM_Contribute_PseudoConstant::contributionPage(); - $pledgePages = array(); + $pledgePages = []; foreach ($pageIds as $key => $value) { $pledgePages[$value['entity_id']] = $pages[$value['entity_id']]; } $this->add('select', 'contribution_page_id', ts('Self-service Payments Page'), - array('' => ts('- select -')) + $pledgePages + ['' => ts('- select -')] + $pledgePages ); $mailingInfo = Civi::settings()->get('mailing_backend'); @@ -364,27 +364,27 @@ public function buildQuickForm() { // make this form an upload since we dont know if the custom data injected dynamically // is of type file etc $uploadNames = $this->get( 'uploadNames' ); - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'upload', 'name' => ts('Save'), - 'js' => array('onclick' => "return verify( );"), + 'js' => ['onclick' => "return verify( );"], 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'upload', 'name' => ts('Save and New'), - 'js' => array('onclick' => "return verify( );"), + 'js' => ['onclick' => "return verify( );"], 'subName' => 'new', - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); - $this->addFormRule(array('CRM_Pledge_Form_Pledge', 'formRule'), $this); + $this->addFormRule(['CRM_Pledge_Form_Pledge', 'formRule'], $this); if ($this->_action & CRM_Core_Action::VIEW) { $this->freeze(); @@ -405,7 +405,7 @@ public function buildQuickForm() { * true if no errors, else array of errors */ public static function formRule($fields, $files, $self) { - $errors = array(); + $errors = []; if ($fields['amount'] <= 0) { $errors['amount'] = ts('Total Pledge Amount should be greater than zero.'); @@ -446,7 +446,7 @@ public function postProcess() { $session = CRM_Core_Session::singleton(); - $fields = array( + $fields = [ 'frequency_unit', 'frequency_interval', 'frequency_day', @@ -457,7 +457,7 @@ public function postProcess() { 'additional_reminder_day', 'contribution_page_id', 'campaign_id', - ); + ]; foreach ($fields as $f) { $params[$f] = CRM_Utils_Array::value($f, $formValues); } @@ -467,7 +467,7 @@ public function postProcess() { $params['currency'] = CRM_Utils_Array::value('currency', $formValues); $params['original_installment_amount'] = ($params['amount'] / $params['installments']); - $dates = array('create_date', 'start_date', 'acknowledge_date', 'cancel_date'); + $dates = ['create_date', 'start_date', 'acknowledge_date', 'cancel_date']; foreach ($dates as $d) { if ($this->_id && (!$this->_isPending) && !empty($this->_values[$d])) { if ($d == 'start_date') { @@ -550,7 +550,7 @@ public function postProcess() { ) = CRM_Contact_BAO_Contact_Location::getEmailDetails($this->_contactID); } - $statusMsg .= ' ' . ts("An acknowledgment email has been sent to %1.
    ", array(1 => $this->userEmail)); + $statusMsg .= ' ' . ts("An acknowledgment email has been sent to %1.
    ", [1 => $this->userEmail]); // build the payment urls. if ($this->paymentId) { @@ -564,13 +564,13 @@ public function postProcess() { "billing_mode IN ( 1, 3 )" ); if (count($processors) > 0) { - $statusMsg .= ' ' . ts("If a payment is due now, you can record a check, EFT, or cash payment for this pledge OR submit a credit card payment.", array( + $statusMsg .= ' ' . ts("If a payment is due now, you can record a check, EFT, or cash payment for this pledge OR submit a credit card payment.", [ 1 => $contribURL, 2 => $creditURL, - )); + ]); } else { - $statusMsg .= ' ' . ts("If a payment is due now, you can record a check, EFT, or cash payment for this pledge.", array(1 => $contribURL)); + $statusMsg .= ' ' . ts("If a payment is due now, you can record a check, EFT, or cash payment for this pledge.", [1 => $contribURL]); } } } diff --git a/CRM/Pledge/Form/PledgeView.php b/CRM/Pledge/Form/PledgeView.php index 8c98b88190d8..3120a7488d99 100644 --- a/CRM/Pledge/Form/PledgeView.php +++ b/CRM/Pledge/Form/PledgeView.php @@ -41,14 +41,14 @@ class CRM_Pledge_Form_PledgeView extends CRM_Core_Form { */ public function preProcess() { - $values = $ids = array(); - $params = array('id' => $this->get('id')); + $values = $ids = []; + $params = ['id' => $this->get('id')]; CRM_Pledge_BAO_Pledge::getValues($params, $values, $ids ); - $values['frequencyUnit'] = ts('%1(s)', array(1 => $values['frequency_unit'])); + $values['frequencyUnit'] = ts('%1(s)', [1 => $values['frequency_unit']]); if (isset($values["honor_contact_id"]) && $values["honor_contact_id"]) { $sql = "SELECT display_name FROM civicrm_contact WHERE id = " . $values["honor_contact_id"]; @@ -80,7 +80,7 @@ public function preProcess() { "action=view&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home" ); - $recentOther = array(); + $recentOther = []; if (CRM_Core_Permission::checkActionPermission('CiviPledge', CRM_Core_Action::UPDATE)) { $recentOther['editUrl'] = CRM_Utils_System::url('civicrm/contact/view/pledge', "action=update&reset=1&id={$values['id']}&cid={$values['contact_id']}&context=home" @@ -129,14 +129,14 @@ public function preProcess() { * Build the form object. */ public function buildQuickForm() { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => ts('Done'), 'spacing' => '         ', 'isDefault' => TRUE, - ), - ) + ], + ] ); } diff --git a/CRM/Pledge/Form/Search.php b/CRM/Pledge/Form/Search.php index 0073fabcf5d2..3f9bb872efe4 100644 --- a/CRM/Pledge/Form/Search.php +++ b/CRM/Pledge/Form/Search.php @@ -231,7 +231,7 @@ public function postProcess() { $this->_formValues["pledge_test"] = 0; } - foreach (array('pledge_amount_low', 'pledge_amount_high') as $f) { + foreach (['pledge_amount_low', 'pledge_amount_high'] as $f) { if (isset($this->_formValues[$f])) { $this->_formValues[$f] = CRM_Utils_Rule::cleanMoney($this->_formValues[$f]); } @@ -310,7 +310,7 @@ public function postProcess() { * @see valid_date */ public function addRules() { - $this->addFormRule(array('CRM_Pledge_Form_Search', 'formRule')); + $this->addFormRule(['CRM_Pledge_Form_Search', 'formRule']); } /** @@ -321,7 +321,7 @@ public function addRules() { * the default array reference */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; $defaults = $this->_formValues; return $defaults; } @@ -334,8 +334,8 @@ public function fixFormValues() { // set pledge payment related fields $status = CRM_Utils_Request::retrieve('status', 'String'); if ($status) { - $this->_formValues['pledge_payment_status_id'] = array($status => 1); - $this->_defaults['pledge_payment_status_id'] = array($status => 1); + $this->_formValues['pledge_payment_status_id'] = [$status => 1]; + $this->_defaults['pledge_payment_status_id'] = [$status => 1]; } $fromDate = CRM_Utils_Request::retrieve('start', 'Date'); @@ -361,7 +361,7 @@ public function fixFormValues() { // we need set all statuses except Cancelled unset($statusValues[$pledgeStatus]); - $statuses = array(); + $statuses = []; foreach ($statusValues as $statusId => $value) { $statuses[$statusId] = 1; } diff --git a/CRM/Pledge/Form/Task.php b/CRM/Pledge/Form/Task.php index 18a910c99846..c6716dff0d9a 100644 --- a/CRM/Pledge/Form/Task.php +++ b/CRM/Pledge/Form/Task.php @@ -57,7 +57,7 @@ public function preProcess() { * @param CRM_Core_Form $form */ public static function preProcessCommon(&$form) { - $form->_pledgeIds = array(); + $form->_pledgeIds = []; $values = $form->controller->exportValues('Search'); @@ -65,7 +65,7 @@ public static function preProcessCommon(&$form) { $pledgeTasks = CRM_Pledge_Task::tasks(); $form->assign('taskName', $pledgeTasks[$form->_task]); - $ids = array(); + $ids = []; if ($values['radio_ts'] == 'ts_sel') { foreach ($values as $name => $value) { if (substr($name, 0, CRM_Core_Form::CB_PREFIX_LEN) == CRM_Core_Form::CB_PREFIX) { @@ -130,17 +130,17 @@ public function setContactIDs() { * @param bool $submitOnce */ public function addDefaultButtons($title, $nextType = 'next', $backType = 'back', $submitOnce = FALSE) { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => $nextType, 'name' => $title, 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => $backType, 'name' => ts('Cancel'), - ), - ) + ], + ] ); } diff --git a/CRM/Pledge/Form/Task/Delete.php b/CRM/Pledge/Form/Task/Delete.php index d3c4c7fc949a..deb28e3e3911 100644 --- a/CRM/Pledge/Form/Task/Delete.php +++ b/CRM/Pledge/Form/Task/Delete.php @@ -79,12 +79,12 @@ public function postProcess() { } if ($deleted) { - $msg = ts('%count pledge deleted.', array('plural' => '%count pledges deleted.', 'count' => $deleted)); + $msg = ts('%count pledge deleted.', ['plural' => '%count pledges deleted.', 'count' => $deleted]); CRM_Core_Session::setStatus($msg, ts('Removed'), 'success'); } if ($failed) { - CRM_Core_Session::setStatus(ts('1 could not be deleted.', array('plural' => '%count could not be deleted.', 'count' => $failed)), ts('Error'), 'error'); + CRM_Core_Session::setStatus(ts('1 could not be deleted.', ['plural' => '%count could not be deleted.', 'count' => $failed]), ts('Error'), 'error'); } } diff --git a/CRM/Pledge/Form/Task/Print.php b/CRM/Pledge/Form/Task/Print.php index aedbacc1dfd7..3b5cb4357fab 100644 --- a/CRM/Pledge/Form/Task/Print.php +++ b/CRM/Pledge/Form/Task/Print.php @@ -69,18 +69,18 @@ public function preProcess() { */ public function buildQuickForm() { // just need to add a javacript to popup the window for printing - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => ts('Print Pledge List'), - 'js' => array('onclick' => 'window.print()'), + 'js' => ['onclick' => 'window.print()'], 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'back', 'name' => ts('Done'), - ), - ) + ], + ] ); } diff --git a/CRM/Pledge/Form/Task/Result.php b/CRM/Pledge/Form/Task/Result.php index 5301b1bbda37..4a4994bfa00a 100644 --- a/CRM/Pledge/Form/Task/Result.php +++ b/CRM/Pledge/Form/Task/Result.php @@ -46,13 +46,13 @@ public function preProcess() { * Build the form object. */ public function buildQuickForm() { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'done', 'name' => ts('Done'), 'isDefault' => TRUE, - ), - ) + ], + ] ); } diff --git a/CRM/Pledge/Form/Task/SearchTaskHookSample.php b/CRM/Pledge/Form/Task/SearchTaskHookSample.php index 5cc27c7e8337..255a0e4b3a3a 100644 --- a/CRM/Pledge/Form/Task/SearchTaskHookSample.php +++ b/CRM/Pledge/Form/Task/SearchTaskHookSample.php @@ -42,7 +42,7 @@ class CRM_Pledge_Form_Task_SearchTaskHookSample extends CRM_Pledge_Form_Task { */ public function preProcess() { parent::preProcess(); - $rows = array(); + $rows = []; // display name and pledge details of all selected contacts $pledgeIDs = implode(',', $this->_pledgeIds); @@ -56,11 +56,11 @@ public function preProcess() { $dao = CRM_Core_DAO::executeQuery($query); while ($dao->fetch()) { - $rows[] = array( + $rows[] = [ 'display_name' => $dao->display_name, 'amount' => $dao->amount, 'create_date' => CRM_Utils_Date::customFormat($dao->create_date), - ); + ]; } $this->assign('rows', $rows); } @@ -69,13 +69,13 @@ public function preProcess() { * Build the form object. */ public function buildQuickForm() { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'done', 'name' => ts('Done'), 'isDefault' => TRUE, - ), - ) + ], + ] ); } diff --git a/CRM/Pledge/Info.php b/CRM/Pledge/Info.php index 169b67b48582..d920df827e47 100644 --- a/CRM/Pledge/Info.php +++ b/CRM/Pledge/Info.php @@ -49,13 +49,13 @@ class CRM_Pledge_Info extends CRM_Core_Component_Info { * collection of required component settings */ public function getInfo() { - return array( + return [ 'name' => 'CiviPledge', 'translatedName' => ts('CiviPledge'), 'title' => ts('CiviCRM Pledge Engine'), 'search' => 1, 'showActivitiesInCore' => 1, - ); + ]; } @@ -76,20 +76,20 @@ public function getInfo() { * collection of permissions, null if none */ public function getPermissions($getAllUnconditionally = FALSE, $descriptions = FALSE) { - $permissions = array( - 'access CiviPledge' => array( + $permissions = [ + 'access CiviPledge' => [ ts('access CiviPledge'), ts('View pledges'), - ), - 'edit pledges' => array( + ], + 'edit pledges' => [ ts('edit pledges'), ts('Create and update pledges'), - ), - 'delete in CiviPledge' => array( + ], + 'delete in CiviPledge' => [ ts('delete in CiviPledge'), ts('Delete pledges'), - ), - ); + ], + ]; if (!$descriptions) { foreach ($permissions as $name => $attr) { @@ -110,13 +110,13 @@ public function getPermissions($getAllUnconditionally = FALSE, $descriptions = F * null if no element offered */ public function getUserDashboardElement() { - return array( + return [ 'name' => ts('Pledges'), 'title' => ts('Your Pledge(s)'), // we need to check this permission since you can click on contribution page link for making payment - 'perm' => array('make online contributions'), + 'perm' => ['make online contributions'], 'weight' => 15, - ); + ]; } /** @@ -129,11 +129,11 @@ public function getUserDashboardElement() { * null if no element offered */ public function registerTab() { - return array( + return [ 'title' => ts('Pledges'), 'url' => 'pledge', 'weight' => 25, - ); + ]; } /** @@ -154,10 +154,10 @@ public function getIcon() { * null if no element offered */ public function registerAdvancedSearchPane() { - return array( + return [ 'title' => ts('Pledges'), 'weight' => 25, - ); + ]; } /** @@ -182,14 +182,14 @@ public function creatNewShortcut(&$shortCuts) { if (CRM_Core_Permission::check('access CiviPledge') && CRM_Core_Permission::check('edit pledges') ) { - $shortCuts = array_merge($shortCuts, array( - array( + $shortCuts = array_merge($shortCuts, [ + [ 'path' => 'civicrm/pledge/add', 'query' => 'reset=1&action=add&context=standalone', 'ref' => 'new-pledge', 'title' => ts('Pledge'), - ), - )); + ], + ]); } } diff --git a/CRM/Pledge/Page/AJAX.php b/CRM/Pledge/Page/AJAX.php index d2a95d617e3b..fc3532cc57a6 100644 --- a/CRM/Pledge/Page/AJAX.php +++ b/CRM/Pledge/Page/AJAX.php @@ -41,7 +41,7 @@ class CRM_Pledge_Page_AJAX { * for batch entry pledges */ public function getPledgeDefaults() { - $details = array(); + $details = []; if (!empty($_POST['pid'])) { $pledgeID = CRM_Utils_Type::escape($_POST['pid'], 'Integer'); $details = CRM_Pledge_BAO_PledgePayment::getOldestPledgePayment($pledgeID); diff --git a/CRM/Pledge/Page/DashBoard.php b/CRM/Pledge/Page/DashBoard.php index 2c78ca9f3a7a..c488e86d46fc 100644 --- a/CRM/Pledge/Page/DashBoard.php +++ b/CRM/Pledge/Page/DashBoard.php @@ -44,13 +44,13 @@ class CRM_Pledge_Page_DashBoard extends CRM_Core_Page { public function preProcess() { CRM_Utils_System::setTitle(ts('CiviPledge')); - $startToDate = array(); - $yearToDate = array(); - $monthToDate = array(); - $previousToDate = array(); + $startToDate = []; + $yearToDate = []; + $monthToDate = []; + $previousToDate = []; - $prefixes = array('start', 'month', 'year', 'previous'); - $status = array('Completed', 'Cancelled', 'Pending', 'In Progress', 'Overdue'); + $prefixes = ['start', 'month', 'year', 'previous']; + $status = ['Completed', 'Cancelled', 'Pending', 'In Progress', 'Overdue']; // cumulative (since inception) - prefix = 'start' $startDate = NULL; @@ -58,7 +58,7 @@ public function preProcess() { // current year - prefix = 'year' $yearDate = \Civi::settings()->get('fiscalYearStart'); - $year = array('Y' => date('Y')); + $year = ['Y' => date('Y')]; $this->assign('curYear', $year['Y']); $yearDate = array_merge($year, $yearDate); $yearDate = CRM_Utils_Date::format($yearDate); diff --git a/CRM/Pledge/Page/Tab.php b/CRM/Pledge/Page/Tab.php index 6feb99e24668..3c44c2344bcf 100644 --- a/CRM/Pledge/Page/Tab.php +++ b/CRM/Pledge/Page/Tab.php @@ -52,10 +52,10 @@ public function browse() { $this->assign('displayName', $displayName); $this->ajaxResponse['tabCount'] = CRM_Contact_BAO_Contact::getCountComponent('pledge', $this->_contactId); // Refresh other tabs with related data - $this->ajaxResponse['updateTabs'] = array( + $this->ajaxResponse['updateTabs'] = [ '#tab_contribute' => CRM_Contact_BAO_Contact::getCountComponent('contribution', $this->_contactId), '#tab_activity' => CRM_Contact_BAO_Contact::getCountComponent('activity', $this->_contactId), - ); + ]; } } diff --git a/CRM/Pledge/Page/UserDashboard.php b/CRM/Pledge/Page/UserDashboard.php index 7b3e151c8e3d..82a091391d66 100644 --- a/CRM/Pledge/Page/UserDashboard.php +++ b/CRM/Pledge/Page/UserDashboard.php @@ -52,7 +52,7 @@ public function listPledges() { $controller->run(); // add honor block. - $honorParams = array(); + $honorParams = []; $honorParams = CRM_Pledge_BAO_Pledge::getHonorContacts($this->_contactId); if (!empty($honorParams)) { // assign vars to templates diff --git a/CRM/Pledge/Selector/Search.php b/CRM/Pledge/Selector/Search.php index f7548ed4d7a8..5c87aae324a1 100644 --- a/CRM/Pledge/Selector/Search.php +++ b/CRM/Pledge/Selector/Search.php @@ -57,7 +57,7 @@ class CRM_Pledge_Selector_Search extends CRM_Core_Selector_Base { * * @var array */ - static $_properties = array( + static $_properties = [ 'contact_id', 'sort_name', 'display_name', @@ -75,7 +75,7 @@ class CRM_Pledge_Selector_Search extends CRM_Core_Selector_Base { 'pledge_financial_type', 'pledge_campaign_id', 'pledge_currency', - ); + ]; /** * Are we restricting ourselves to a single contact @@ -189,33 +189,33 @@ public static function &links() { $extraParams = ($key) ? "&key={$key}" : NULL; $cancelExtra = ts('Cancelling this pledge will also cancel any scheduled (and not completed) pledge payments.') . ' ' . ts('This action cannot be undone.') . ' ' . ts('Do you want to continue?'); - self::$_links = array( - CRM_Core_Action::VIEW => array( + self::$_links = [ + CRM_Core_Action::VIEW => [ 'name' => ts('View'), 'url' => 'civicrm/contact/view/pledge', 'qs' => 'reset=1&id=%%id%%&cid=%%cid%%&action=view&context=%%cxt%%&selectedChild=pledge' . $extraParams, 'title' => ts('View Pledge'), - ), - CRM_Core_Action::UPDATE => array( + ], + CRM_Core_Action::UPDATE => [ 'name' => ts('Edit'), 'url' => 'civicrm/contact/view/pledge', 'qs' => 'reset=1&action=update&id=%%id%%&cid=%%cid%%&context=%%cxt%%' . $extraParams, 'title' => ts('Edit Pledge'), - ), - CRM_Core_Action::DETACH => array( + ], + CRM_Core_Action::DETACH => [ 'name' => ts('Cancel'), 'url' => 'civicrm/contact/view/pledge', 'qs' => 'reset=1&action=detach&id=%%id%%&cid=%%cid%%&context=%%cxt%%' . $extraParams, 'extra' => 'onclick = "return confirm(\'' . $cancelExtra . '\');"', 'title' => ts('Cancel Pledge'), - ), - CRM_Core_Action::DELETE => array( + ], + CRM_Core_Action::DELETE => [ 'name' => ts('Delete'), 'url' => 'civicrm/contact/view/pledge', 'qs' => 'reset=1&action=delete&id=%%id%%&cid=%%cid%%&context=%%cxt%%' . $extraParams, 'title' => ts('Delete Pledge'), - ), - ); + ], + ]; if (in_array('Cancel', $hideOption)) { unset(self::$_links[CRM_Core_Action::DETACH]); @@ -287,7 +287,7 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { ); // process the result of the query - $rows = array(); + $rows = []; // get all pledge status $pledgeStatuses = CRM_Pledge_BAO_Pledge::buildOptions('status_id'); @@ -296,7 +296,7 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { $allCampaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE); // CRM-4418 check for view, edit and delete - $permissions = array(CRM_Core_Permission::VIEW); + $permissions = [CRM_Core_Permission::VIEW]; if (CRM_Core_Permission::check('edit pledges')) { $permissions[] = CRM_Core_Permission::EDIT; } @@ -306,7 +306,7 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { $mask = CRM_Core_Action::mask($permissions); while ($result->fetch()) { - $row = array(); + $row = []; // the columns we are interested in foreach (self::$_properties as $property) { if (isset($result->$property)) { @@ -329,7 +329,7 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { $row['pledge_status'] = CRM_Core_TestEntity::appendTestText($row['pledge_status']); } - $hideOption = array(); + $hideOption = []; if (CRM_Utils_Array::key('Cancelled', $row) || CRM_Utils_Array::key('Completed', $row) ) { @@ -340,11 +340,11 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL) { $row['action'] = CRM_Core_Action::formLink(self::links($hideOption, $this->_key), $mask, - array( + [ 'id' => $result->pledge_id, 'cid' => $result->contact_id, 'cxt' => $this->_context, - ), + ], ts('more'), FALSE, 'pledge.selector.row', @@ -383,57 +383,57 @@ public function getQILL() { */ public function &getColumnHeaders($action = NULL, $output = NULL) { if (!isset(self::$_columnHeaders)) { - self::$_columnHeaders = array( - array( + self::$_columnHeaders = [ + [ 'name' => ts('Pledged'), 'sort' => 'pledge_amount', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - array( + ], + [ 'name' => ts('Total Paid'), 'sort' => 'pledge_total_paid', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - array( + ], + [ 'name' => ts('Balance'), - ), - array( + ], + [ 'name' => ts('Pledged For'), 'sort' => 'pledge_financial_type', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - array( + ], + [ 'name' => ts('Pledge Made'), 'sort' => 'pledge_create_date', 'direction' => CRM_Utils_Sort::DESCENDING, - ), - array( + ], + [ 'name' => ts('Next Pay Date'), 'sort' => 'pledge_next_pay_date', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - array( + ], + [ 'name' => ts('Next Amount'), 'sort' => 'pledge_next_pay_amount', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - array( + ], + [ 'name' => ts('Status'), 'sort' => 'pledge_status', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - array('desc' => ts('Actions')), - ); + ], + ['desc' => ts('Actions')], + ]; if (!$this->_single) { - $pre = array( - array('desc' => ts('Contact ID')), - array( + $pre = [ + ['desc' => ts('Contact ID')], + [ 'name' => ts('Name'), 'sort' => 'sort_name', 'direction' => CRM_Utils_Sort::DONTCARE, - ), - ); + ], + ]; self::$_columnHeaders = array_merge($pre, self::$_columnHeaders); } diff --git a/CRM/Pledge/StateMachine/Search.php b/CRM/Pledge/StateMachine/Search.php index 3be9a36a75d1..1bf31c5c09b4 100644 --- a/CRM/Pledge/StateMachine/Search.php +++ b/CRM/Pledge/StateMachine/Search.php @@ -48,7 +48,7 @@ class CRM_Pledge_StateMachine_Search extends CRM_Core_StateMachine { public function __construct($controller, $action = CRM_Core_Action::NONE) { parent::__construct($controller, $action); - $this->_pages = array(); + $this->_pages = []; $this->_pages['CRM_Pledge_Form_Search'] = NULL; list($task, $result) = $this->taskName($controller, 'Search'); diff --git a/CRM/Pledge/Task.php b/CRM/Pledge/Task.php index 92001631ca04..7becb5a000cc 100644 --- a/CRM/Pledge/Task.php +++ b/CRM/Pledge/Task.php @@ -47,26 +47,26 @@ class CRM_Pledge_Task extends CRM_Core_Task { */ public static function tasks() { if (!self::$_tasks) { - self::$_tasks = array( - self::TASK_DELETE => array( + self::$_tasks = [ + self::TASK_DELETE => [ 'title' => ts('Delete pledges'), 'class' => 'CRM_Pledge_Form_Task_Delete', 'result' => FALSE, - ), - self::TASK_PRINT => array( + ], + self::TASK_PRINT => [ 'title' => ts('Print selected rows'), 'class' => 'CRM_Pledge_Form_Task_Print', 'result' => FALSE, - ), - self::TASK_EXPORT => array( + ], + self::TASK_EXPORT => [ 'title' => ts('Export pledges'), - 'class' => array( + 'class' => [ 'CRM_Export_Form_Select', 'CRM_Export_Form_Map', - ), + ], 'result' => FALSE, - ), - ); + ], + ]; // CRM-4418, check for delete if (!CRM_Core_Permission::check('delete in CiviPledge')) { @@ -89,16 +89,16 @@ public static function tasks() { * @return array * set of tasks that are valid for the user */ - public static function permissionedTaskTitles($permission, $params = array()) { + public static function permissionedTaskTitles($permission, $params = []) { if (($permission == CRM_Core_Permission::EDIT) || CRM_Core_Permission::check('edit pledges') ) { $tasks = self::taskTitles(); } else { - $tasks = array( + $tasks = [ self::TASK_EXPORT => self::$_tasks[self::TASK_EXPORT]['title'], - ); + ]; //CRM-4418, if (CRM_Core_Permission::check('delete in CiviPledge')) { $tasks[self::TASK_DELETE] = self::$_tasks[self::TASK_DELETE]['title']; diff --git a/CRM/Price/BAO/LineItem.php b/CRM/Price/BAO/LineItem.php index b54bd5b77564..55af3bcca800 100644 --- a/CRM/Price/BAO/LineItem.php +++ b/CRM/Price/BAO/LineItem.php @@ -85,10 +85,10 @@ public static function create(&$params) { $return = $lineItemBAO->save(); if ($lineItemBAO->entity_table == 'civicrm_membership' && $lineItemBAO->contribution_id && $lineItemBAO->entity_id) { - $membershipPaymentParams = array( + $membershipPaymentParams = [ 'membership_id' => $lineItemBAO->entity_id, 'contribution_id' => $lineItemBAO->contribution_id, - ); + ]; if (!civicrm_api3('MembershipPayment', 'getcount', $membershipPaymentParams)) { civicrm_api3('MembershipPayment', 'create', $membershipPaymentParams); } @@ -139,7 +139,7 @@ public static function retrieve(&$params, &$defaults) { public static function getAPILineItemParams(&$params) { CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($types); if ($types && empty($params['financial_type_id'])) { - $params['financial_type_id'] = array('IN' => array_keys($types)); + $params['financial_type_id'] = ['IN' => array_keys($types)]; } elseif ($types) { if (is_array($params['financial_type_id'])) { @@ -149,7 +149,7 @@ public static function getAPILineItemParams(&$params) { $invalidFts = $params['financial_type_id']; } if ($invalidFts) { - $params['financial_type_id'] = array('NOT IN' => $invalidFts); + $params['financial_type_id'] = ['NOT IN' => $invalidFts]; } } else { @@ -166,7 +166,7 @@ public static function getLineTotal($contributionId) { $sqlLineItemTotal = "SELECT SUM(li.line_total + COALESCE(li.tax_amount,0)) FROM civicrm_line_item li WHERE li.contribution_id = %1"; - $params = array(1 => array($contributionId, 'Integer')); + $params = [1 => [$contributionId, 'Integer']]; $lineItemTotal = CRM_Core_DAO::singleValueQuery($sqlLineItemTotal, $params); return $lineItemTotal; } @@ -253,16 +253,16 @@ public static function getLineItems($entityId, $entity = 'participant', $isQuick $whereClause .= " and li.qty != 0"; } - $lineItems = array(); + $lineItems = []; if (!$entityId || !$entity || !$fromClause) { return $lineItems; } - $params = array( - 1 => array($entityId, 'Integer'), - 2 => array($entity, 'Text'), - ); + $params = [ + 1 => [$entityId, 'Integer'], + 2 => [$entity, 'Text'], + ]; $getTaxDetails = FALSE; $invoiceSettings = Civi::settings()->get('contribution_invoice_settings'); @@ -273,7 +273,7 @@ public static function getLineItems($entityId, $entity = 'participant', $isQuick if (!$dao->id) { continue; } - $lineItems[$dao->id] = array( + $lineItems[$dao->id] = [ 'qty' => (float) $dao->qty, 'label' => $dao->label, 'unit_price' => $dao->unit_price, @@ -293,7 +293,7 @@ public static function getLineItems($entityId, $entity = 'participant', $isQuick 'membership_num_terms' => $dao->membership_num_terms, 'tax_amount' => $dao->tax_amount, 'price_set_id' => $dao->price_set_id, - ); + ]; $taxRates = CRM_Core_PseudoConstant::getTaxRates(); if (isset($lineItems[$dao->id]['financial_type_id']) && array_key_exists($lineItems[$dao->id]['financial_type_id'], $taxRates)) { // Cast to float so trailing zero decimals are removed for display. @@ -346,7 +346,7 @@ public static function format($fid, $params, $fields, &$values, $amount_override //lets first check in fun parameter, //since user might modified w/ hooks. - $options = array(); + $options = []; if (array_key_exists('options', $fields)) { $options = $fields['options']; } @@ -363,7 +363,7 @@ public static function format($fid, $params, $fields, &$values, $amount_override $participantsPerField = CRM_Utils_Array::value('count', $options[$oid], 0); - $values[$oid] = array( + $values[$oid] = [ 'price_field_id' => $fid, 'price_field_value_id' => $oid, 'label' => CRM_Utils_Array::value('label', $options[$oid]), @@ -381,7 +381,7 @@ public static function format($fid, $params, $fields, &$values, $amount_override 'financial_type_id' => CRM_Utils_Array::value('financial_type_id', $options[$oid]), 'tax_amount' => CRM_Utils_Array::value('tax_amount', $options[$oid]), 'non_deductible_amount' => CRM_Utils_Array::value('non_deductible_amount', $options[$oid]), - ); + ]; if ($values[$oid]['membership_type_id'] && empty($values[$oid]['auto_renew'])) { $values[$oid]['auto_renew'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $values[$oid]['membership_type_id'], 'auto_renew'); @@ -403,7 +403,7 @@ public static function deleteLineItems($entityId, $entityTable) { } if ($entityId && !is_array($entityId)) { - $entityId = array($entityId); + $entityId = [$entityId]; } $query = "DELETE FROM civicrm_line_item where entity_id IN ('" . implode("','", $entityId) . "') AND entity_table = '$entityTable'"; @@ -458,7 +458,7 @@ public static function processPriceSet($entityId, $lineItem, $contributionDetail $membershipId = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipPayment', $contributionDetails->id, 'membership_id', 'contribution_id'); if ($membershipId && (int) $membershipId !== (int) $line['entity_id']) { $line['entity_id'] = $membershipId; - Civi::log()->warning('Per https://lab.civicrm.org/dev/core/issues/15 this data fix should not be required. Please log a ticket at https://lab.civicrm.org/dev/core with steps to get this.', array('civi.tag' => 'deprecated')); + Civi::log()->warning('Per https://lab.civicrm.org/dev/core/issues/15 this data fix should not be required. Please log a ticket at https://lab.civicrm.org/dev/core with steps to get this.', ['civi.tag' => 'deprecated']); } } } @@ -504,16 +504,16 @@ public static function syncLineItems($entityId, $entityTable = 'civicrm_contribu $where = " li.entity_id = %1 AND li.entity_table = %2 "; - $params = array( - 1 => array($entityId, 'Integer'), - 2 => array($entityTable, 'String'), - 3 => array($amount, 'Float'), - ); + $params = [ + 1 => [$entityId, 'Integer'], + 2 => [$entityTable, 'String'], + 3 => [$amount, 'Float'], + ]; if ($entityTable == 'civicrm_contribution') { $entityName = 'default_contribution_amount'; $where .= " AND ps.name = %4 "; - $params[4] = array($entityName, 'String'); + $params[4] = [$entityName, 'String']; } elseif ($entityTable == 'civicrm_participant') { $from .= " @@ -523,10 +523,10 @@ public static function syncLineItems($entityId, $entityTable = 'civicrm_contribu li.price_field_value_id = cpfv.id "; $where .= " AND cpse.entity_table = 'civicrm_event' AND cpse.entity_id = %5 "; $amount = empty($amount) ? 0 : $amount; - $params += array( - 4 => array($otherParams['fee_label'], 'String'), - 5 => array($otherParams['event_id'], 'String'), - ); + $params += [ + 4 => [$otherParams['fee_label'], 'String'], + 5 => [$otherParams['event_id'], 'String'], + ]; } $query = " @@ -567,7 +567,7 @@ public static function getLineItemArray(&$params, $entityId = NULL, $entityTable } $financialType = $values['financial_type_id']; } - $params['line_item'][$values['setID']][$values['priceFieldID']] = array( + $params['line_item'][$values['setID']][$values['priceFieldID']] = [ 'price_field_id' => $values['priceFieldID'], 'price_field_value_id' => $values['priceFieldValueID'], 'label' => $values['label'], @@ -576,7 +576,7 @@ public static function getLineItemArray(&$params, $entityId = NULL, $entityTable 'line_total' => $totalAmount, 'financial_type_id' => $financialType, 'membership_type_id' => $values['membership_type_id'], - ); + ]; break; } } @@ -629,7 +629,7 @@ public static function getLineItemArray(&$params, $entityId = NULL, $entityTable * */ public static function buildLineItemsForSubmittedPriceField($priceParams, $overrideAmount = NULL, $financialTypeID = NULL) { - $lineItems = array(); + $lineItems = []; foreach ($priceParams as $key => $value) { $priceField = self::getPriceFieldMetaData($key); @@ -702,7 +702,7 @@ public static function changeFeeSelections( // update line item with changed line total and other information $totalParticipant = $participantCount = 0; - $amountLevel = array(); + $amountLevel = []; if (!empty($requiredChanges['line_items_to_update'])) { foreach ($requiredChanges['line_items_to_update'] as $priceFieldValueID => $value) { $amountLevel[] = $value['label'] . ' - ' . (float) $value['qty']; @@ -724,7 +724,7 @@ public static function changeFeeSelections( $count = count(CRM_Event_BAO_Participant::getParticipantIds($contributionId)); } else { - $count = CRM_Utils_Array::value('count', civicrm_api3('MembershipPayment', 'getcount', array('contribution_id' => $contributionId))); + $count = CRM_Utils_Array::value('count', civicrm_api3('MembershipPayment', 'getcount', ['contribution_id' => $contributionId])); } if ($count > 1) { $updatedAmount = CRM_Price_BAO_LineItem::getLineTotal($contributionId); @@ -755,34 +755,34 @@ public static function changeFeeSelections( // record reverse transaction only if Contribution is Completed because for pending refund or // partially paid we are already recording the surplus owed or refund amount if (!empty($updateFinancialItemInfoValues['financialTrxn']) && ($contributionStatus == 'Completed')) { - $updateFinancialItemInfoValues = array_merge($updateFinancialItemInfoValues['financialTrxn'], array( + $updateFinancialItemInfoValues = array_merge($updateFinancialItemInfoValues['financialTrxn'], [ 'entity_id' => $newFinancialItem->id, 'entity_table' => 'civicrm_financial_item', - )); + ]); $reverseTrxn = CRM_Core_BAO_FinancialTrxn::create($updateFinancialItemInfoValues); // record reverse entity financial trxn linked to membership's related contribution - civicrm_api3('EntityFinancialTrxn', 'create', array( + civicrm_api3('EntityFinancialTrxn', 'create', [ 'entity_table' => "civicrm_contribution", 'entity_id' => $contributionId, 'financial_trxn_id' => $reverseTrxn->id, 'amount' => $reverseTrxn->total_amount, - )); + ]); unset($updateFinancialItemInfoValues['financialTrxn']); } elseif (!empty($updateFinancialItemInfoValues['link-financial-trxn']) && $newFinancialItem->amount != 0) { - civicrm_api3('EntityFinancialTrxn', 'create', array( + civicrm_api3('EntityFinancialTrxn', 'create', [ 'entity_id' => $newFinancialItem->id, 'entity_table' => 'civicrm_financial_item', 'financial_trxn_id' => $trxn->id, 'amount' => $newFinancialItem->amount, - )); + ]); unset($updateFinancialItemInfoValues['link-financial-trxn']); } } } // @todo - it may be that trxn_id is always empty - flush out scenarios. Add tests. - $trxnId = !empty($trxn->id) ? array('id' => $trxn->id) : array(); + $trxnId = !empty($trxn->id) ? ['id' => $trxn->id] : []; $lineItemObj->addFinancialItemsOnLineItemsChange(array_merge($requiredChanges['line_items_to_add'], $requiredChanges['line_items_to_resurrect']), $entityID, $entityTable, $contributionId, $trxnId); // update participant fee_amount column @@ -804,7 +804,7 @@ public static function changeFeeSelections( protected function getAdjustedFinancialItemsToRecord($entityID, $entityTable, $contributionID, $priceFieldValueIDsToCancel, $lineItemsToUpdate) { $previousLineItems = CRM_Price_BAO_LineItem::getLineItems($entityID, str_replace('civicrm_', '', $entityTable)); - $financialItemsArray = array(); + $financialItemsArray = []; $financialItemResult = $this->getNonCancelledFinancialItems($entityID, $entityTable); foreach ($financialItemResult as $updateFinancialItemInfoValues) { $updateFinancialItemInfoValues['transaction_date'] = date('YmdHis'); @@ -875,7 +875,7 @@ protected function checkFinancialItemTotalAmountByLineItemID($lineItemID) { * List of submitted line items */ protected function getSubmittedLineItems($inputParams, $feeBlock) { - $submittedLineItems = array(); + $submittedLineItems = []; foreach ($feeBlock as $id => $values) { CRM_Price_BAO_LineItem::format($id, $inputParams, $values, $submittedLineItems); } @@ -910,9 +910,9 @@ protected function getLineItemsToAlter($submittedLineItems, $entityID, $entity) $previousLineItems = CRM_Price_BAO_LineItem::getLineItems($entityID, $entity); $lineItemsToAdd = $submittedLineItems; - $lineItemsToUpdate = array(); + $lineItemsToUpdate = []; $submittedPriceFieldValueIDs = array_keys($submittedLineItems); - $lineItemsToCancel = $lineItemsToResurrect = array(); + $lineItemsToCancel = $lineItemsToResurrect = []; foreach ($previousLineItems as $id => $previousLineItem) { if (in_array($previousLineItem['price_field_value_id'], $submittedPriceFieldValueIDs)) { @@ -921,7 +921,7 @@ protected function getLineItemsToAlter($submittedLineItems, $entityID, $entity) // If a 'Text' price field was updated by changing qty value, then we are not adding new line-item but updating the existing one, // because unlike other kind of price-field, it's related price-field-value-id isn't changed and thats why we need to make an // exception here by adding financial item for updated line-item and will reverse any previous financial item entries. - $lineItemsToUpdate[$previousLineItem['price_field_value_id']] = array_merge($submittedLineItem, array('id' => $id)); + $lineItemsToUpdate[$previousLineItem['price_field_value_id']] = array_merge($submittedLineItem, ['id' => $id]); unset($lineItemsToAdd[$previousLineItem['price_field_value_id']]); } else { @@ -953,19 +953,19 @@ protected function getLineItemsToAlter($submittedLineItems, $entityID, $entity) } else { if (!$this->isCancelled($previousLineItem)) { - $cancelParams = array('qty' => 0, 'line_total' => 0, 'tax_amount' => 0, 'participant_count' => 0, 'non_deductible_amount' => 0, 'id' => $id); + $cancelParams = ['qty' => 0, 'line_total' => 0, 'tax_amount' => 0, 'participant_count' => 0, 'non_deductible_amount' => 0, 'id' => $id]; $lineItemsToCancel[$previousLineItem['price_field_value_id']] = array_merge($previousLineItem, $cancelParams); } } } - return array( + return [ 'line_items_to_add' => $lineItemsToAdd, 'line_items_to_update' => $lineItemsToUpdate, 'line_items_to_cancel' => $lineItemsToCancel, 'line_items_to_resurrect' => $lineItemsToResurrect, - ); + ]; } /** @@ -1004,11 +1004,11 @@ protected function addLineItemOnChangeFeeSelection( $updatedContribution->id = (int) $contributionID; // insert financial items foreach ($lineItemsToAdd as $priceFieldValueID => $lineParams) { - $lineParams = array_merge($lineParams, array( + $lineParams = array_merge($lineParams, [ 'entity_table' => $entityTable, 'entity_id' => $entityID, 'contribution_id' => $contributionID, - )); + ]); if (!array_key_exists('skip', $lineParams)) { self::create($lineParams); } @@ -1036,11 +1036,11 @@ protected function addFinancialItemsOnLineItemsChange($lineItemsToAdd, $entityID $updatedContribution->find(TRUE); foreach ($lineItemsToAdd as $priceFieldValueID => $lineParams) { - $lineParams = array_merge($lineParams, array( + $lineParams = array_merge($lineParams, [ 'entity_table' => $entityTable, 'entity_id' => $entityID, 'contribution_id' => $contributionID, - )); + ]); $this->addFinancialItemsOnLineItemChange($isCreateAdditionalFinancialTrxn, $lineParams, $updatedContribution); } } @@ -1057,12 +1057,12 @@ protected function updateEntityRecordOnChangeFeeSelection($inputParams, $entityI $entityTable = "civicrm_{$entity}"; if ($entity == 'participant') { - $partUpdateFeeAmt = array('id' => $entityID); + $partUpdateFeeAmt = ['id' => $entityID]; $getUpdatedLineItems = "SELECT * FROM civicrm_line_item WHERE (entity_table = '{$entityTable}' AND entity_id = {$entityID} AND qty > 0)"; $getUpdatedLineItemsDAO = CRM_Core_DAO::executeQuery($getUpdatedLineItems); - $line = array(); + $line = []; while ($getUpdatedLineItemsDAO->fetch()) { $line[$getUpdatedLineItemsDAO->price_field_value_id] = $getUpdatedLineItemsDAO->label . ' - ' . (float) $getUpdatedLineItemsDAO->qty; } @@ -1134,29 +1134,29 @@ protected static function getPriceFieldMetaData($key) { */ protected function _getRelatedCancelFinancialTrxn($financialItemID) { try { - $financialTrxn = civicrm_api3('EntityFinancialTrxn', 'getsingle', array( + $financialTrxn = civicrm_api3('EntityFinancialTrxn', 'getsingle', [ 'entity_table' => 'civicrm_financial_item', 'entity_id' => $financialItemID, - 'options' => array( + 'options' => [ 'sort' => 'id DESC', 'limit' => 1, - ), - 'api.FinancialTrxn.getsingle' => array( + ], + 'api.FinancialTrxn.getsingle' => [ 'id' => "\$value.financial_trxn_id", - ), - )); + ], + ]); } catch (CiviCRM_API3_Exception $e) { - return array(); + return []; } - $financialTrxn = array_merge($financialTrxn['api.FinancialTrxn.getsingle'], array( + $financialTrxn = array_merge($financialTrxn['api.FinancialTrxn.getsingle'], [ 'trxn_date' => date('YmdHis'), 'total_amount' => -$financialTrxn['api.FinancialTrxn.getsingle']['total_amount'], 'net_amount' => -$financialTrxn['api.FinancialTrxn.getsingle']['net_amount'], 'entity_table' => 'civicrm_financial_item', 'entity_id' => $financialItemID, - )); + ]); unset($financialTrxn['id']); return $financialTrxn; @@ -1211,12 +1211,12 @@ protected function _recordAdjustedAmt($updatedAmount, $contributionId, $taxAmoun $updatedContributionDAO->save(); // adjusted amount financial_trxn creation $updatedContribution = CRM_Contribute_BAO_Contribution::getValues( - array('id' => $contributionId), + ['id' => $contributionId], CRM_Core_DAO::$_nullArray, CRM_Core_DAO::$_nullArray ); $toFinancialAccount = CRM_Contribute_PseudoConstant::getRelationalFinancialAccount($updatedContribution->financial_type_id, 'Accounts Receivable Account is'); - $adjustedTrxnValues = array( + $adjustedTrxnValues = [ 'from_financial_account_id' => NULL, 'to_financial_account_id' => $toFinancialAccount, 'total_amount' => $balanceAmt, @@ -1226,7 +1226,7 @@ protected function _recordAdjustedAmt($updatedAmount, $contributionId, $taxAmoun 'contribution_id' => $updatedContribution->id, 'trxn_date' => date('YmdHis'), 'currency' => $updatedContribution->currency, - ); + ]; $adjustedTrxn = CRM_Core_BAO_FinancialTrxn::create($adjustedTrxnValues); } // CRM-17151: Update the contribution status to completed if balance is zero, @@ -1261,7 +1261,7 @@ protected function addFinancialItemsOnLineItemChange($isCreateAdditionalFinancia // original comment : add financial item if ONLY financial type is changed if ($lineParams['financial_type_id'] != $updatedContribution->financial_type_id) { $changedFinancialTypeID = (int) $lineParams['financial_type_id']; - $adjustedTrxnValues = array( + $adjustedTrxnValues = [ 'from_financial_account_id' => NULL, 'to_financial_account_id' => CRM_Financial_BAO_FinancialTypeAccount::getInstrumentFinancialAccount($updatedContribution->payment_instrument_id), 'total_amount' => $lineParams['line_total'], @@ -1273,9 +1273,9 @@ protected function addFinancialItemsOnLineItemChange($isCreateAdditionalFinancia // since balance is 0, which means contribution is completed 'trxn_date' => date('YmdHis'), 'currency' => $updatedContribution->currency, - ); + ]; $adjustedTrxn = CRM_Core_BAO_FinancialTrxn::create($adjustedTrxnValues); - $tempFinancialTrxnID = array('id' => $adjustedTrxn->id); + $tempFinancialTrxnID = ['id' => $adjustedTrxn->id]; } } $lineObj = CRM_Price_BAO_LineItem::retrieve($lineParams, CRM_Core_DAO::$_nullArray); @@ -1307,7 +1307,7 @@ protected function getNonCancelledFinancialItems($entityID, $entityTable) { $updateFinancialItemInfoDAO = CRM_Core_DAO::executeQuery($updateFinancialItem); $financialItemResult = $updateFinancialItemInfoDAO->fetchAll(); - $items = array(); + $items = []; foreach ($financialItemResult as $index => $financialItem) { $items[$financialItem['price_field_value_id']][$index] = $financialItem['amount']; diff --git a/CRM/Price/BAO/PriceField.php b/CRM/Price/BAO/PriceField.php index a35726009010..f6bb64992194 100644 --- a/CRM/Price/BAO/PriceField.php +++ b/CRM/Price/BAO/PriceField.php @@ -100,14 +100,14 @@ public static function create(&$params) { if (!empty($params['id']) && empty($priceField->html_type)) { $priceField->html_type = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', $params['id'], 'html_type'); } - $optionsIds = array(); + $optionsIds = []; $maxIndex = CRM_Price_Form_Field::NUM_OPTION; if ($priceField->html_type == 'Text') { $maxIndex = 1; - $fieldOptions = civicrm_api3('price_field_value', 'get', array( + $fieldOptions = civicrm_api3('price_field_value', 'get', [ 'price_field_id' => $priceField->id, 'sequential' => 1, - )); + ]); foreach ($fieldOptions['values'] as $option) { $optionsIds['id'] = $option['id']; // CRM-19741 If we are dealing with price fields that are Text only set the field value label to match @@ -119,7 +119,7 @@ public static function create(&$params) { } } } - $defaultArray = array(); + $defaultArray = []; //html type would be empty in update scenario not sure what would happen ... if (!empty($params['html_type']) && $params['html_type'] == 'CheckBox' && isset($params['default_checkbox_option'])) { $tempArray = array_keys($params['default_checkbox_option']); @@ -141,7 +141,7 @@ public static function create(&$params) { (CRM_Utils_Array::value($index, CRM_Utils_Array::value('option_label', $params)) || !empty($params['is_quick_config'])) && !CRM_Utils_System::isNull($params['option_amount'][$index]) ) { - $options = array( + $options = [ 'price_field_id' => $priceField->id, 'label' => trim($params['option_label'][$index]), 'name' => CRM_Utils_String::munge($params['option_label'][$index], '_', 64), @@ -156,7 +156,7 @@ public static function create(&$params) { 'membership_num_terms' => NULL, 'non_deductible_amount' => CRM_Utils_Array::value('non_deductible_amount', $params), 'visibility_id' => CRM_Utils_Array::value($index, CRM_Utils_Array::value('option_visibility_id', $params), self::getVisibilityOptionID('public')), - ); + ]; if ($options['membership_type_id']) { $options['membership_num_terms'] = CRM_Utils_Array::value($index, CRM_Utils_Array::value('membership_num_terms', $params), 1); @@ -186,7 +186,7 @@ public static function create(&$params) { } } elseif (!empty($optionsIds) && !empty($optionsIds['id'])) { - $optionsLoad = civicrm_api3('price_field_value', 'get', array('id' => $optionsIds['id'])); + $optionsLoad = civicrm_api3('price_field_value', 'get', ['id' => $optionsIds['id']]); $options = $optionsLoad['values'][$optionsIds['id']]; $options['is_active'] = CRM_Utils_Array::value('is_active', $params, 1); try { @@ -288,7 +288,7 @@ public static function addQuickFormElement( $useRequired = TRUE, $label = NULL, $fieldOptions = NULL, - $freezeOptions = array() + $freezeOptions = [] ) { $field = new CRM_Price_DAO_PriceField(); @@ -348,13 +348,13 @@ public static function addQuickFormElement( $qf->assign('taxTerm', $taxTerm); $qf->assign('invoicing', $invoicing); } - $priceVal = implode($seperator, array( + $priceVal = implode($seperator, [ $customOption[$optionKey][$valueFieldName] + $taxAmount, $count, $max_value, - )); + ]); - $extra = array(); + $extra = []; if (!empty($qf->_membershipBlock) && !empty($qf->_quickConfig) && $field->name == 'other_amount' && empty($qf->_contributionAmount)) { $useRequired = 0; } @@ -364,21 +364,21 @@ public static function addQuickFormElement( if (!empty($qf->_quickConfig) && !empty($qf->_contributionAmount) && strtolower($fieldOptions[$optionKey]['name']) == 'other_amount') { $label .= ' ' . $currencySymbol; $qf->assign('priceset', $elementName); - $extra = array('onclick' => 'useAmountOther();'); + $extra = ['onclick' => 'useAmountOther();']; } } $element = &$qf->add('text', $elementName, $label, array_merge($extra, - array( - 'price' => json_encode(array($optionKey, $priceVal)), + [ + 'price' => json_encode([$optionKey, $priceVal]), 'size' => '4', - ) + ] ), $useRequired && $field->is_required ); if ($is_pay_later) { - $qf->add('text', 'txt-' . $elementName, $label, array('size' => '4')); + $qf->add('text', 'txt-' . $elementName, $label, ['size' => '4']); } // CRM-6902 - Add "max" option for a price set field @@ -394,7 +394,7 @@ public static function addQuickFormElement( $type = 'money'; } else { - $message = ts('%1 must be a number (with or without decimal point).', array(1 => $label)); + $message = ts('%1 must be a number (with or without decimal point).', [1 => $label]); $type = 'numeric'; } // integers will have numeric rule applied to them. @@ -402,7 +402,7 @@ public static function addQuickFormElement( break; case 'Radio': - $choice = array(); + $choice = []; if (!empty($qf->_quickConfig) && !empty($qf->_contributionAmount)) { $qf->assign('contriPriceset', $elementName); @@ -439,34 +439,34 @@ public static function addQuickFormElement( } $count = CRM_Utils_Array::value('count', $opt, ''); $max_value = CRM_Utils_Array::value('max_value', $opt, ''); - $priceVal = implode($seperator, array($opt[$valueFieldName] + $taxAmount, $count, $max_value)); + $priceVal = implode($seperator, [$opt[$valueFieldName] + $taxAmount, $count, $max_value]); if (isset($opt['visibility_id'])) { $visibility_id = $opt['visibility_id']; } else { $visibility_id = self::getVisibilityOptionID('public'); } - $extra = array( - 'price' => json_encode(array($elementName, $priceVal)), + $extra = [ + 'price' => json_encode([$elementName, $priceVal]), 'data-amount' => $opt[$valueFieldName], 'data-currency' => $currencyName, 'data-price-field-values' => json_encode($customOption), 'visibility' => $visibility_id, - ); + ]; if (!empty($qf->_quickConfig) && $field->name == 'contribution_amount') { - $extra += array('onclick' => 'clearAmountOther();'); + $extra += ['onclick' => 'clearAmountOther();']; } if ($field->name == 'membership_amount') { - $extra += array( + $extra += [ 'onclick' => "return showHideAutoRenew({$opt['membership_type_id']});", 'membership-type' => $opt['membership_type_id'], - ); + ]; $qf->assign('membershipFieldID', $field->id); } $choice[$opId] = $qf->createElement('radio', NULL, '', $opt['label'], $opt['id'], $extra); if ($is_pay_later) { - $qf->add('text', 'txt-' . $elementName, $label, array('size' => '4')); + $qf->add('text', 'txt-' . $elementName, $label, ['size' => '4']); } // CRM-6902 - Add "max" option for a price set field @@ -478,11 +478,11 @@ public static function addQuickFormElement( } if (!empty($qf->_membershipBlock) && $field->name == 'contribution_amount') { $choice[] = $qf->createElement('radio', NULL, '', ts('No thank you'), '-1', - array( - 'price' => json_encode(array($elementName, '0|0')), + [ + 'price' => json_encode([$elementName, '0|0']), 'data-currency' => $currencyName, 'onclick' => 'clearAmountOther();', - ) + ] ); } @@ -499,7 +499,7 @@ public static function addQuickFormElement( } $choice[] = $qf->createElement('radio', NULL, '', $none, '0', - array('price' => json_encode(array($elementName, '0'))) + ['price' => json_encode([$elementName, '0'])] ); } @@ -513,12 +513,12 @@ public static function addQuickFormElement( } if ($useRequired && $field->is_required) { - $qf->addRule($elementName, ts('%1 is a required field.', array(1 => $label)), 'required'); + $qf->addRule($elementName, ts('%1 is a required field.', [1 => $label]), 'required'); } break; case 'Select': - $selectOption = $allowedOptions = $priceVal = array(); + $selectOption = $allowedOptions = $priceVal = []; foreach ($customOption as $opt) { $taxAmount = CRM_Utils_Array::value('tax_amount', $opt); @@ -535,7 +535,7 @@ public static function addQuickFormElement( } } - $priceVal[$opt['id']] = implode($seperator, array($opt[$valueFieldName] + $taxAmount, $count, $max_value)); + $priceVal[$opt['id']] = implode($seperator, [$opt[$valueFieldName] + $taxAmount, $count, $max_value]); if (!in_array($opt['id'], $freezeOptions)) { $allowedOptions[] = $opt['id']; @@ -549,7 +549,7 @@ public static function addQuickFormElement( $selectOption[$opt['id']] = $opt['label']; if ($is_pay_later) { - $qf->add('text', 'txt-' . $elementName, $label, array('size' => '4')); + $qf->add('text', 'txt-' . $elementName, $label, ['size' => '4']); } } if (isset($opt['visibility_id'])) { @@ -559,11 +559,11 @@ public static function addQuickFormElement( $visibility_id = self::getVisibilityOptionID('public'); } $element = &$qf->add('select', $elementName, $label, - array( + [ '' => ts('- select -'), - ) + $selectOption, + ] + $selectOption, $useRequired && $field->is_required, - array('price' => json_encode($priceVal), 'class' => 'crm-select2', 'data-price-field-values' => json_encode($customOption)) + ['price' => json_encode($priceVal), 'class' => 'crm-select2', 'data-price-field-values' => json_encode($customOption)] ); // CRM-6902 - Add "max" option for a price set field @@ -575,7 +575,7 @@ public static function addQuickFormElement( case 'CheckBox': - $check = array(); + $check = []; foreach ($customOption as $opId => $opt) { $taxAmount = CRM_Utils_Array::value('tax_amount', $opt); $count = CRM_Utils_Array::value('count', $opt, ''); @@ -598,17 +598,17 @@ public static function addQuickFormElement( } $opt['label'] = $preHelpText . $opt['label'] . $postHelpText; } - $priceVal = implode($seperator, array($opt[$valueFieldName] + $taxAmount, $count, $max_value)); + $priceVal = implode($seperator, [$opt[$valueFieldName] + $taxAmount, $count, $max_value]); $check[$opId] = &$qf->createElement('checkbox', $opt['id'], NULL, $opt['label'], - array( - 'price' => json_encode(array($opt['id'], $priceVal)), + [ + 'price' => json_encode([$opt['id'], $priceVal]), 'data-amount' => $opt[$valueFieldName], 'data-currency' => $currencyName, 'visibility' => $opt['visibility_id'], - ) + ] ); if ($is_pay_later) { - $txtcheck[$opId] =& $qf->createElement('text', $opId, $opt['label'], array('size' => '4')); + $txtcheck[$opId] =& $qf->createElement('text', $opId, $opt['label'], ['size' => '4']); $qf->addGroup($txtcheck, 'txt-' . $elementName, $label); } // CRM-6902 - Add "max" option for a price set field @@ -620,7 +620,7 @@ public static function addQuickFormElement( } $element = &$qf->addGroup($check, $elementName, $label); if ($useRequired && $field->is_required) { - $qf->addRule($elementName, ts('%1 is a required field.', array(1 => $label)), 'required'); + $qf->addRule($elementName, ts('%1 is a required field.', [1 => $label]), 'required'); } break; } @@ -646,15 +646,15 @@ public static function addQuickFormElement( */ public static function getOptions($fieldId, $inactiveNeeded = FALSE, $reset = FALSE, $isDefaultContributionPriceSet = FALSE) { if ($reset || !isset(Civi::$statics[__CLASS__]['priceOptions'])) { - Civi::$statics[__CLASS__]['priceOptions'] = array(); + Civi::$statics[__CLASS__]['priceOptions'] = []; // This would happen if the function was only called to clear the cache. if (empty($fieldId)) { - return array(); + return []; } } if (empty(Civi::$statics[__CLASS__]['priceOptions'][$fieldId])) { - $values = $options = array(); + $values = $options = []; CRM_Price_BAO_PriceFieldValue::getValues($fieldId, $values, 'weight', !$inactiveNeeded); $options[$fieldId] = $values; $taxRates = CRM_Core_PseudoConstant::getTaxRates(); @@ -698,10 +698,10 @@ public static function getOptionId($optionLabel, $fid) { AND option_group.id = option_value.option_group_id AND option_value.label = %2"; - $dao = CRM_Core_DAO::executeQuery($query, array( - 1 => array($optionGroupName, 'String'), - 2 => array($optionLabel, 'String'), - )); + $dao = CRM_Core_DAO::executeQuery($query, [ + 1 => [$optionGroupName, 'String'], + 2 => [$optionLabel, 'String'], + ]); while ($dao->fetch()) { return $dao->id; @@ -726,7 +726,7 @@ public static function deleteField($id) { CRM_Price_BAO_PriceFieldValue::deleteValues($id); // reorder the weight before delete - $fieldValues = array('price_set_id' => $field->price_set_id); + $fieldValues = ['price_set_id' => $field->price_set_id]; CRM_Utils_Weight::delWeight('CRM_Price_DAO_PriceField', $field->id, $fieldValues); @@ -743,12 +743,12 @@ public static function deleteField($id) { public static function &htmlTypes() { static $htmlTypes = NULL; if (!$htmlTypes) { - $htmlTypes = array( + $htmlTypes = [ 'Text' => ts('Text / Numeric Quantity'), 'Select' => ts('Select'), 'Radio' => ts('Radio'), 'CheckBox' => ts('CheckBox'), - ); + ]; } return $htmlTypes; } @@ -773,10 +773,10 @@ public static function priceSetValidation($priceSetId, $fields, &$error, $allowN $priceField->price_set_id = $priceSetId; $priceField->find(); - $priceFields = array(); + $priceFields = []; if ($allowNoneSelection) { - $noneSelectedPriceFields = array(); + $noneSelectedPriceFields = []; } while ($priceField->fetch()) { @@ -802,15 +802,15 @@ public static function priceSetValidation($priceSetId, $fields, &$error, $allowN FROM civicrm_price_field WHERE id IN (" . implode(',', array_keys($priceFields)) . ')'; $fieldDAO = CRM_Core_DAO::executeQuery($sql); - $htmlTypes = array(); + $htmlTypes = []; while ($fieldDAO->fetch()) { $htmlTypes[$fieldDAO->id] = $fieldDAO->html_type; } - $selectedAmounts = array(); + $selectedAmounts = []; foreach ($htmlTypes as $fieldId => $type) { - $options = array(); + $options = []; CRM_Price_BAO_PriceFieldValue::getValues($fieldId, $options); if (empty($options)) { @@ -839,7 +839,7 @@ public static function priceSetValidation($priceSetId, $fields, &$error, $allowN // The form offers a field to enter the amount paid. This may differ from the amount that is due to complete the purchase $totalPaymentAmountEnteredOnForm = CRM_Utils_Array::value('partial_payment_total', $fields, CRM_Utils_Array::value('total_amount', $fields)); if ($totalAmount < 0) { - $error['_qf_default'] = ts('%1 amount can not be less than zero. Please select the options accordingly.', array(1 => $componentName)); + $error['_qf_default'] = ts('%1 amount can not be less than zero. Please select the options accordingly.', [1 => $componentName]); } elseif ($totalAmount > 0 && $totalPaymentAmountEnteredOnForm >= $totalAmount && // if total amount is equal to all selected amount in hand @@ -903,10 +903,10 @@ public static function getVisibilityOptionID($visibilityName) { self::$visibilityOptionsKeys = CRM_Price_BAO_PriceField::buildOptions( 'visibility_id', NULL, - array( + [ 'labelColumn' => 'name', 'flip' => TRUE, - ) + ] ); } diff --git a/CRM/Price/BAO/PriceFieldValue.php b/CRM/Price/BAO/PriceFieldValue.php index 0aed6a2dbe3a..071d879aa36b 100644 --- a/CRM/Price/BAO/PriceFieldValue.php +++ b/CRM/Price/BAO/PriceFieldValue.php @@ -47,7 +47,7 @@ class CRM_Price_BAO_PriceFieldValue extends CRM_Price_DAO_PriceFieldValue { * * @return CRM_Price_DAO_PriceFieldValue */ - public static function add(&$params, $ids = array()) { + public static function add(&$params, $ids = []) { $fieldValueBAO = new CRM_Price_BAO_PriceFieldValue(); $fieldValueBAO->copyValues($params); @@ -66,7 +66,7 @@ public static function add(&$params, $ids = array()) { } if (!empty($params['is_default'])) { $query = 'UPDATE civicrm_price_field_value SET is_default = 0 WHERE price_field_id = %1'; - $p = array(1 => array($params['price_field_id'], 'Integer')); + $p = [1 => [$params['price_field_id'], 'Integer']]; CRM_Core_DAO::executeQuery($query, $p); } @@ -86,7 +86,7 @@ public static function add(&$params, $ids = array()) { * * @return CRM_Price_DAO_PriceFieldValue */ - public static function create(&$params, $ids = array()) { + public static function create(&$params, $ids = []) { $id = CRM_Utils_Array::value('id', $params, CRM_Utils_Array::value('id', $ids)); if (!is_array($params) || empty($params)) { return NULL; @@ -104,7 +104,7 @@ public static function create(&$params, $ids = array()) { if ($id) { $oldWeight = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceFieldValue', $id, 'weight', 'id'); } - $fieldValues = array('price_field_id' => CRM_Utils_Array::value('price_field_id', $params, 0)); + $fieldValues = ['price_field_id' => CRM_Utils_Array::value('price_field_id', $params, 0)]; $params['weight'] = CRM_Utils_Weight::updateOtherWeights('CRM_Price_DAO_PriceFieldValue', $oldWeight, $params['weight'], $fieldValues); } else { @@ -132,10 +132,10 @@ public static function create(&$params, $ids = array()) { * @return array */ public static function getDefaults() { - return array( + return [ 'is_active' => 1, 'weight' => 1, - ); + ]; } @@ -283,11 +283,11 @@ public static function updateFinancialType($entityId, $entityTable, $financialTy if (!$entityId || !$entityTable || !$financialTypeID) { return; } - $params = array( - 1 => array($entityId, 'Integer'), - 2 => array($entityTable, 'String'), - 3 => array($financialTypeID, 'Integer'), - ); + $params = [ + 1 => [$entityId, 'Integer'], + 2 => [$entityTable, 'String'], + 3 => [$financialTypeID, 'Integer'], + ]; // for event discount $join = $where = ''; if ($entityTable == 'civicrm_event') { @@ -330,10 +330,10 @@ public static function updateAmountAndFeeLevel($id, $prevLabel, $newLabel) { CRM_Price_BAO_LineItem::create($lineItemParams); // update amount and fee level in civicrm_contribution and civicrm_participant - $params = array( - 1 => array(CRM_Core_DAO::VALUE_SEPARATOR . $prevLabel . ' -', 'String'), - 2 => array(CRM_Core_DAO::VALUE_SEPARATOR . $newLabel . ' -', 'String'), - ); + $params = [ + 1 => [CRM_Core_DAO::VALUE_SEPARATOR . $prevLabel . ' -', 'String'], + 2 => [CRM_Core_DAO::VALUE_SEPARATOR . $newLabel . ' -', 'String'], + ]; // Update contribution if (!empty($lineItem->contribution_id)) { CRM_Core_DAO::executeQuery("UPDATE `civicrm_contribution` SET `amount_level` = REPLACE(amount_level, %1, %2) WHERE id = {$lineItem->contribution_id}", $params); diff --git a/CRM/Price/BAO/PriceSet.php b/CRM/Price/BAO/PriceSet.php index 1cb42be5f16e..cd2908f7b633 100644 --- a/CRM/Price/BAO/PriceSet.php +++ b/CRM/Price/BAO/PriceSet.php @@ -140,9 +140,9 @@ public static function getDefaultPriceSet($entity = 'contribution') { "; $dao = CRM_Core_DAO::executeQuery($sql); - self::$_defaultPriceSet[$entity] = array(); + self::$_defaultPriceSet[$entity] = []; while ($dao->fetch()) { - self::$_defaultPriceSet[$entity][$dao->priceFieldValueID] = array( + self::$_defaultPriceSet[$entity][$dao->priceFieldValueID] = [ 'setID' => $dao->setID, 'priceFieldID' => $dao->priceFieldID, 'name' => $dao->name, @@ -151,7 +151,7 @@ public static function getDefaultPriceSet($entity = 'contribution') { 'membership_type_id' => $dao->membership_type_id, 'amount' => $dao->amount, 'financial_type_id' => $dao->financial_type_id, - ); + ]; } return self::$_defaultPriceSet[$entity]; @@ -181,7 +181,7 @@ public static function getTitle($id) { * @return array */ public static function getUsedBy($id, $simpleReturn = FALSE) { - $usedBy = array(); + $usedBy = []; $forms = self::getFormsUsingPriceSet($id); $tables = array_keys($forms); // @todo - this is really clumsy overloading the signature like this. Instead @@ -197,7 +197,7 @@ public static function getUsedBy($id, $simpleReturn = FALSE) { FROM civicrm_line_item cli LEFT JOIN civicrm_price_field cpf ON cli.price_field_id = cpf.id WHERE cpf.price_set_id = %1"; - $params = array(1 => array($id, 'Integer')); + $params = [1 => [$id, 'Integer']]; $crmFormDAO = CRM_Core_DAO::executeQuery($queryString, $params); while ($crmFormDAO->fetch()) { $forms[$crmFormDAO->entity_table][] = $crmFormDAO->entity_id; @@ -313,13 +313,13 @@ public static function getFor($entityTable, $entityId, $usedFor = NULL, $isQuick if ($isQuickConfig) { $sql .= ' AND ps.is_quick_config = 0 '; } - $params = array( - 1 => array($entityTable, 'String'), - 2 => array($entityId, 'Integer'), - ); + $params = [ + 1 => [$entityTable, 'String'], + 2 => [$entityId, 'Integer'], + ]; if ($usedFor) { $sql .= " AND ps.extends LIKE '%%3%' "; - $params[3] = array($usedFor, 'Integer'); + $params[3] = [$usedFor, 'Integer']; } $dao = CRM_Core_DAO::executeQuery($sql, $params); @@ -390,7 +390,7 @@ public static function getAssoc($withInactive = FALSE, $extendComponentName = FA $query .= ' AND s.domain_id = ' . CRM_Core_Config::domainID(); } - $priceSets = array(); + $priceSets = []; if ($extendComponentName) { $componentId = CRM_Core_Component::getComponentID($extendComponentName); @@ -434,9 +434,9 @@ public static function getAssoc($withInactive = FALSE, $extendComponentName = FA */ public static function getSetDetail($setID, $required = TRUE, $validOnly = FALSE) { // create a new tree - $setTree = array(); + $setTree = []; - $priceFields = array( + $priceFields = [ 'id', 'name', 'label', @@ -453,7 +453,7 @@ public static function getSetDetail($setID, $required = TRUE, $validOnly = FALSE 'javascript', 'visibility_id', 'is_required', - ); + ]; if ($required == TRUE) { $priceFields[] = 'is_required'; } @@ -462,9 +462,9 @@ public static function getSetDetail($setID, $required = TRUE, $validOnly = FALSE $select = 'SELECT ' . implode(',', $priceFields); $from = ' FROM civicrm_price_field'; - $params = array( - 1 => array($setID, 'Integer'), - ); + $params = [ + 1 => [$setID, 'Integer'], + ]; $currentTime = date('YmdHis'); $where = " WHERE price_set_id = %1 @@ -493,7 +493,7 @@ public static function getSetDetail($setID, $required = TRUE, $validOnly = FALSE while ($dao->fetch()) { $fieldID = $dao->id; - $setTree[$setID]['fields'][$fieldID] = array(); + $setTree[$setID]['fields'][$fieldID] = []; $setTree[$setID]['fields'][$fieldID]['id'] = $fieldID; foreach ($priceFields as $field) { @@ -628,7 +628,7 @@ public static function initSet(&$form, $id, $entityTable = 'civicrm_event', $val //get option count info. $form->_priceSet['optionsCountTotal'] = self::getPricesetCount($priceSetId); if ($form->_priceSet['optionsCountTotal']) { - $optionsCountDetails = array(); + $optionsCountDetails = []; if (!empty($form->_priceSet['fields'])) { foreach ($form->_priceSet['fields'] as $field) { foreach ($field['options'] as $option) { @@ -642,7 +642,7 @@ public static function initSet(&$form, $id, $entityTable = 'civicrm_event', $val //get option max value info. $optionsMaxValueTotal = 0; - $optionsMaxValueDetails = array(); + $optionsMaxValueDetails = []; if (!empty($form->_priceSet['fields'])) { foreach ($form->_priceSet['fields'] as $field) { @@ -696,7 +696,7 @@ public static function processAmount($fields, &$params, &$lineItem, $component = $amount_override = NULL; if ($component) { - $autoRenew = array(); + $autoRenew = []; $autoRenew[0] = $autoRenew[1] = $autoRenew[2] = 0; } if ($priceSetID) { @@ -716,7 +716,7 @@ public static function processAmount($fields, &$params, &$lineItem, $component = switch ($field['html_type']) { case 'Text': $firstOption = reset($field['options']); - $params["price_{$id}"] = array($firstOption['id'] => $params["price_{$id}"]); + $params["price_{$id}"] = [$firstOption['id'] => $params["price_{$id}"]]; CRM_Price_BAO_LineItem::format($id, $params, $field, $lineItem, CRM_Utils_Array::value('partial_payment_total', $params)); $optionValueId = key($field['options']); @@ -739,7 +739,7 @@ public static function processAmount($fields, &$params, &$lineItem, $component = if ($params["price_{$id}"] <= 0) { break; } - $params["price_{$id}"] = array($params["price_{$id}"] => 1); + $params["price_{$id}"] = [$params["price_{$id}"] => 1]; $optionValueId = CRM_Utils_Array::key(1, $params["price_{$id}"]); CRM_Price_BAO_LineItem::format($id, $params, $field, $lineItem, $amount_override); @@ -762,7 +762,7 @@ public static function processAmount($fields, &$params, &$lineItem, $component = break; case 'Select': - $params["price_{$id}"] = array($params["price_{$id}"] => 1); + $params["price_{$id}"] = [$params["price_{$id}"] => 1]; $optionValueId = CRM_Utils_Array::key(1, $params["price_{$id}"]); CRM_Price_BAO_LineItem::format($id, $params, $field, $lineItem, CRM_Utils_Array::value('partial_payment_total', $params)); @@ -799,7 +799,7 @@ public static function processAmount($fields, &$params, &$lineItem, $component = } } - $amount_level = array(); + $amount_level = []; $totalParticipant = 0; if (is_array($lineItem)) { foreach ($lineItem as $values) { @@ -869,7 +869,7 @@ public static function getAmountLevelText($params) { $priceFieldMetadata = self::getCachedPriceSetDetail($priceSetID); $displayParticipantCount = NULL; - $amount_level = array(); + $amount_level = []; foreach ($priceFieldMetadata['fields'] as $field) { if (!empty($priceFieldSelection[$field['id']])) { $qtyString = ''; @@ -900,7 +900,7 @@ public static function getAmountLevelText($params) { */ public static function filterPriceFieldsFromParams($priceSetID, $params) { $priceSet = self::getCachedPriceSetDetail($priceSetID); - $return = array(); + $return = []; foreach ($priceSet['fields'] as $field) { if (!empty($params['price_' . $field['id']])) { $return[$field['id']] = $params['price_' . $field['id']]; @@ -951,10 +951,10 @@ public static function buildPriceSet(&$form) { $validFieldsOnly = TRUE; $className = CRM_Utils_System::getClassName($form); - if (in_array($className, array( + if (in_array($className, [ 'CRM_Contribute_Form_Contribution', 'CRM_Member_Form_Membership', - ))) { + ])) { $validFieldsOnly = FALSE; } @@ -973,7 +973,7 @@ public static function buildPriceSet(&$form) { // Mark which field should have the auto-renew checkbox, if any. CRM-18305 if (!empty($form->_membershipTypeValues) && is_array($form->_membershipTypeValues)) { - $autoRenewMembershipTypes = array(); + $autoRenewMembershipTypes = []; foreach ($form->_membershipTypeValues as $membershiptTypeValue) { if ($membershiptTypeValue['auto_renew']) { $autoRenewMembershipTypes[] = $membershiptTypeValue['id']; @@ -1049,7 +1049,7 @@ public static function buildPriceSet(&$form) { } } - $formClasses = array('CRM_Contribute_Form_Contribution', 'CRM_Member_Form_Membership'); + $formClasses = ['CRM_Contribute_Form_Contribution', 'CRM_Member_Form_Membership']; if (!is_array($options) || !in_array($id, $validPriceFieldIds)) { continue; @@ -1088,7 +1088,7 @@ public static function checkCurrentMembership(&$options, $userid) { if (!$userid || empty($options)) { return FALSE; } - static $_contact_memberships = array(); + static $_contact_memberships = []; $checkLifetime = FALSE; foreach ($options as $key => $value) { if (!empty($value['membership_type_id'])) { @@ -1252,27 +1252,27 @@ public static function getFieldIds($id) { */ public static function copy($id) { $maxId = CRM_Core_DAO::singleValueQuery("SELECT max(id) FROM civicrm_price_set"); - $priceSet = civicrm_api3('PriceSet', 'getsingle', array('id' => $id)); + $priceSet = civicrm_api3('PriceSet', 'getsingle', ['id' => $id]); $newTitle = preg_replace('/\[Copy id \d+\]$/', "", $priceSet['title']); - $title = ts('[Copy id %1]', array(1 => $maxId + 1)); - $fieldsFix = array( - 'replace' => array( + $title = ts('[Copy id %1]', [1 => $maxId + 1]); + $fieldsFix = [ + 'replace' => [ 'title' => trim($newTitle) . ' ' . $title, 'name' => substr($priceSet['name'], 0, 20) . 'price_set_' . ($maxId + 1), - ), - ); + ], + ]; $copy = CRM_Core_DAO::copyGeneric('CRM_Price_DAO_PriceSet', - array('id' => $id), + ['id' => $id], NULL, $fieldsFix ); //copying all the blocks pertaining to the price set $copyPriceField = CRM_Core_DAO::copyGeneric('CRM_Price_DAO_PriceField', - array('price_set_id' => $id), - array('price_set_id' => $copy->id) + ['price_set_id' => $id], + ['price_set_id' => $copy->id] ); if (!empty($copyPriceField)) { $price = array_combine(self::getFieldIds($id), self::getFieldIds($copy->id)); @@ -1280,8 +1280,8 @@ public static function copy($id) { //copy option group and values foreach ($price as $originalId => $copyId) { CRM_Core_DAO::copyGeneric('CRM_Price_DAO_PriceFieldValue', - array('price_field_id' => $originalId), - array('price_field_id' => $copyId) + ['price_field_id' => $originalId], + ['price_field_id' => $copyId] ); } } @@ -1331,7 +1331,7 @@ public static function getPricesetCount($sid, $onlyActive = TRUE) { $where = 'AND value.is_active = 1 AND field.is_active = 1'; } - static $pricesetFieldCount = array(); + static $pricesetFieldCount = []; if (!isset($pricesetFieldCount[$sid])) { $sql = " SELECT sum(value.count) as totalCount @@ -1341,7 +1341,7 @@ public static function getPricesetCount($sid, $onlyActive = TRUE) { WHERE pset.id = %1 $where"; - $count = CRM_Core_DAO::singleValueQuery($sql, array(1 => array($sid, 'Positive'))); + $count = CRM_Core_DAO::singleValueQuery($sql, [1 => [$sid, 'Positive']]); $pricesetFieldCount[$sid] = ($count) ? $count : 0; } @@ -1362,7 +1362,7 @@ public static function getMembershipCount($ids) { GROUP BY mt.member_of_contact_id "; $crmDAO = CRM_Core_DAO::executeQuery($queryString); - $count = array(); + $count = []; while ($crmDAO->fetch()) { $count[$crmDAO->id] = $crmDAO->count; @@ -1396,7 +1396,7 @@ public static function checkAutoRenewForPriceSet($priceSetId) { AND pfv.is_active = 1 ORDER BY price_field_id'; - $params = array(1 => array($priceSetId, 'Integer')); + $params = [1 => [$priceSetId, 'Integer']]; $dao = CRM_Core_DAO::executeQuery($query, $params); @@ -1407,7 +1407,7 @@ public static function checkAutoRenewForPriceSet($priceSetId) { } $autoRenewOption = 2; - $priceFields = array(); + $priceFields = []; while ($dao->fetch()) { if (!$dao->auto_renew) { // If any one can't be renewed none can. @@ -1450,10 +1450,10 @@ public static function getRecurDetails($priceSetId) { INNER JOIN civicrm_price_field pf ON pfv.price_field_id = pf.id WHERE pf.price_set_id = %1 LIMIT 1'; - $params = array(1 => array($priceSetId, 'Integer')); + $params = [1 => [$priceSetId, 'Integer']]; $dao = CRM_Core_DAO::executeQuery($query, $params); $dao->fetch(); - return array($dao->duration_interval, $dao->duration_unit); + return [$dao->duration_interval, $dao->duration_unit]; } /** @@ -1511,15 +1511,15 @@ public static function getMembershipTypesFromPriceSet($id) { WHERE ps.id = %1 "; - $params = array(1 => array($id, 'Integer')); + $params = [1 => [$id, 'Integer']]; $dao = CRM_Core_DAO::executeQuery($query, $params); - $membershipTypes = array( - 'all' => array(), - 'autorenew' => array(), - 'autorenew_required' => array(), - 'autorenew_optional' => array(), - ); + $membershipTypes = [ + 'all' => [], + 'autorenew' => [], + 'autorenew_required' => [], + 'autorenew_optional' => [], + ]; while ($dao->fetch()) { if (empty($dao->membership_type_id)) { continue; @@ -1561,11 +1561,11 @@ public static function copyPriceSet($baoName, $id, $newId) { } else { $copyPriceSet = &CRM_Core_DAO::copyGeneric('CRM_Price_DAO_PriceSetEntity', - array( + [ 'entity_id' => $id, 'entity_table' => $baoName, - ), - array('entity_id' => $newId) + ], + ['entity_id' => $newId] ); } // copy event discount @@ -1577,13 +1577,13 @@ public static function copyPriceSet($baoName, $id, $newId) { CRM_Core_DAO::copyGeneric( 'CRM_Core_DAO_Discount', - array( + [ 'id' => $discountId, - ), - array( + ], + [ 'entity_id' => $newId, 'price_set_id' => $copyPriceSet->id, - ) + ] ); } } @@ -1640,7 +1640,7 @@ public static function parseFirstPriceSetValueIDFromParams($params) { */ public static function parsePriceSetValueIDsFromParams($params) { $priceSetParams = self::parsePriceSetArrayFromParams($params); - $priceSetValueIDs = array(); + $priceSetValueIDs = []; foreach ($priceSetParams as $priceSetParam) { foreach (array_keys($priceSetParam) as $priceValueID) { $priceSetValueIDs[] = $priceValueID; @@ -1658,7 +1658,7 @@ public static function parsePriceSetValueIDsFromParams($params) { * Array of price fields filtered from the params. */ public static function parsePriceSetArrayFromParams($params) { - $priceSetParams = array(); + $priceSetParams = []; foreach ($params as $field => $value) { $parts = explode('_', $field); if (count($parts) == 2 && $parts[0] == 'price' && is_numeric($parts[1]) && is_array($value)) { @@ -1702,12 +1702,12 @@ public static function getNonDeductibleAmountFromPriceSet($priceSetId, $lineItem * ) */ public static function getFormsUsingPriceSet($id) { - $forms = array(); + $forms = []; $queryString = " SELECT entity_table, entity_id FROM civicrm_price_set_entity WHERE price_set_id = %1"; - $params = array(1 => array($id, 'Integer')); + $params = [1 => [$id, 'Integer']]; $crmFormDAO = CRM_Core_DAO::executeQuery($queryString, $params); while ($crmFormDAO->fetch()) { @@ -1733,7 +1733,7 @@ public static function getFormsUsingPriceSet($id) { * @throws \Exception */ protected static function reformatUsedByFormsWithEntityData($forms) { - $usedBy = array(); + $usedBy = []; foreach ($forms as $table => $entities) { switch ($table) { case 'civicrm_event': diff --git a/CRM/Price/Form/DeleteField.php b/CRM/Price/Form/DeleteField.php index 2f690fe84711..23c5dbda7048 100644 --- a/CRM/Price/Form/DeleteField.php +++ b/CRM/Price/Form/DeleteField.php @@ -77,17 +77,17 @@ public function preProcess() { * @return void */ public function buildQuickForm() { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => ts('Delete Price Field'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - )); + ], + ]); } /** @@ -97,7 +97,7 @@ public function buildQuickForm() { */ public function postProcess() { if (CRM_Price_BAO_PriceField::deleteField($this->_fid)) { - CRM_Core_Session::setStatus(ts('The Price Field \'%1\' has been deleted.', array(1 => $this->_title)), '', 'success'); + CRM_Core_Session::setStatus(ts('The Price Field \'%1\' has been deleted.', [1 => $this->_title]), '', 'success'); } } diff --git a/CRM/Price/Form/DeleteSet.php b/CRM/Price/Form/DeleteSet.php index 278cc47a7000..a9045f3da35d 100644 --- a/CRM/Price/Form/DeleteSet.php +++ b/CRM/Price/Form/DeleteSet.php @@ -70,17 +70,17 @@ public function preProcess() { */ public function buildQuickForm() { $this->assign('title', $this->_title); - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => ts('Delete Price Set'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - )); + ], + ]); } /** @@ -91,12 +91,12 @@ public function buildQuickForm() { public function postProcess() { if (CRM_Price_BAO_PriceSet::deleteSet($this->_sid)) { CRM_Core_Session::setStatus(ts('The Price Set \'%1\' has been deleted.', - array(1 => $this->_title), ts('Deleted'), 'success' + [1 => $this->_title], ts('Deleted'), 'success' )); } else { CRM_Core_Session::setStatus(ts('The Price Set \'%1\' has not been deleted! You must delete all price fields in this set prior to deleting the set.', - array(1 => $this->_title) + [1 => $this->_title] ), 'Unable to Delete', 'error'); } } diff --git a/CRM/Price/Form/Field.php b/CRM/Price/Form/Field.php index 2dbc229fe711..3888e781e896 100644 --- a/CRM/Price/Form/Field.php +++ b/CRM/Price/Form/Field.php @@ -75,9 +75,9 @@ public function preProcess() { $this->_sid = CRM_Utils_Request::retrieve('sid', 'Positive', $this, FALSE, NULL, 'REQUEST'); $this->_fid = CRM_Utils_Request::retrieve('fid', 'Positive', $this, FALSE, NULL, 'REQUEST'); $url = CRM_Utils_System::url('civicrm/admin/price/field', "reset=1&action=browse&sid={$this->_sid}"); - $breadCrumb = array(array('title' => ts('Price Set Fields'), 'url' => $url)); + $breadCrumb = [['title' => ts('Price Set Fields'), 'url' => $url]]; - $this->_extendComponentId = array(); + $this->_extendComponentId = []; $extendComponentId = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_sid, 'extends', 'id'); if ($extendComponentId) { $this->_extendComponentId = explode(CRM_Core_DAO::VALUE_SEPARATOR, $extendComponentId); @@ -95,10 +95,10 @@ public function preProcess() { * array of default values */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; // is it an edit operation ? if (isset($this->_fid)) { - $params = array('id' => $this->_fid); + $params = ['id' => $this->_fid]; $this->assign('fid', $this->_fid); CRM_Price_BAO_PriceField::retrieve($params, $defaults); $this->_sid = $defaults['price_set_id']; @@ -106,7 +106,7 @@ public function setDefaultValues() { // if text, retrieve price if ($defaults['html_type'] == 'Text') { $isActive = $defaults['is_active']; - $valueParams = array('price_field_id' => $this->_fid); + $valueParams = ['price_field_id' => $this->_fid]; CRM_Price_BAO_PriceFieldValue::retrieve($valueParams, $defaults); @@ -126,7 +126,7 @@ public function setDefaultValues() { } if ($this->_action & CRM_Core_Action::ADD) { - $fieldValues = array('price_set_id' => $this->_sid); + $fieldValues = ['price_set_id' => $this->_sid]; $defaults['weight'] = CRM_Utils_Weight::getDefaultWeight('CRM_Price_DAO_PriceField', $fieldValues); $defaults['options_per_line'] = 1; $defaults['is_display_amounts'] = 1; @@ -199,7 +199,7 @@ public function buildQuickForm() { $this->add('select', 'financial_type_id', ts('Financial Type'), - array(' ' => ts('- select -')) + $financialType + [' ' => ts('- select -')] + $financialType ); $this->assign('useForMember', FALSE); @@ -267,7 +267,7 @@ public function buildQuickForm() { 'select', 'option_financial_type_id[' . $i . ']', ts('Financial Type'), - array('' => ts('- select -')) + $financialType + ['' => ts('- select -')] + $financialType ); if (in_array($eventComponentId, $this->_extendComponentId)) { // count @@ -283,10 +283,10 @@ public function buildQuickForm() { } elseif (in_array($memberComponentId, $this->_extendComponentId)) { $membershipTypes = CRM_Member_PseudoConstant::membershipType(); - $js = array('onchange' => "calculateRowValues( $i );"); + $js = ['onchange' => "calculateRowValues( $i );"]; $this->add('select', 'membership_type_id[' . $i . ']', ts('Membership Type'), - array('' => ' ') + $membershipTypes, FALSE, $js + ['' => ' '] + $membershipTypes, FALSE, $js ); $this->add('text', 'membership_num_terms[' . $i . ']', ts('Number of Terms'), CRM_Utils_Array::value('membership_num_terms', $attributes)); } @@ -327,10 +327,10 @@ public function buildQuickForm() { CRM_Core_DAO::getAttribute('CRM_Price_DAO_PriceField', 'help_post') ); - $this->add('datepicker', 'active_on', ts('Active On'), [], FALSE, array('time' => TRUE)); + $this->add('datepicker', 'active_on', ts('Active On'), [], FALSE, ['time' => TRUE]); // expire_on - $this->add('datepicker', 'expire_on', ts('Expire On'), [], FALSE, array('time' => TRUE)); + $this->add('datepicker', 'expire_on', ts('Expire On'), [], FALSE, ['time' => TRUE]); // is required ? $this->add('checkbox', 'is_required', ts('Required?')); @@ -339,27 +339,27 @@ public function buildQuickForm() { $this->add('checkbox', 'is_active', ts('Active?')); // add buttons - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => ts('Save'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'next', 'name' => ts('Save and New'), 'subName' => 'new', - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - )); + ], + ]); // is public? $this->add('select', 'visibility_id', ts('Visibility'), CRM_Core_PseudoConstant::visibility()); // add a form rule to check default value - $this->addFormRule(array('CRM_Price_Form_Field', 'formRule'), $this); + $this->addFormRule(['CRM_Price_Form_Field', 'formRule'], $this); // if view mode pls freeze it with the done button. if ($this->_action & CRM_Core_Action::VIEW) { @@ -368,7 +368,7 @@ public function buildQuickForm() { $this->addElement('button', 'done', ts('Done'), - array('onclick' => "location.href='$url'") + ['onclick' => "location.href='$url'"] ); } } @@ -389,7 +389,7 @@ public function buildQuickForm() { public static function formRule($fields, $files, $form) { // all option fields are of type "money" - $errors = array(); + $errors = []; /** Check the option values entered * Appropriate values are required for the selected datatype @@ -434,7 +434,7 @@ public static function formRule($fields, $files, $form) { $publicOptionCount = $_flagOption = $_rowError = 0; $_showHide = new CRM_Core_ShowHideBlocks('', ''); - $visibilityOptions = CRM_Price_BAO_PriceFieldValue::buildOptions('visibility_id', NULL, array('labelColumn' => 'name')); + $visibilityOptions = CRM_Price_BAO_PriceFieldValue::buildOptions('visibility_id', NULL, ['labelColumn' => 'name']); for ($index = 1; $index <= self::NUM_OPTION; $index++) { @@ -533,7 +533,7 @@ public static function formRule($fields, $files, $form) { // check for checkboxes allowing user to select multiple memberships from same membership organization if ($fields['html_type'] == 'CheckBox') { $foundDuplicate = FALSE; - $orgIds = array(); + $orgIds = []; foreach ($memTypesIDS as $key => $val) { $org = CRM_Member_BAO_MembershipType::getMembershipTypeOrganization($val); if (in_array($org[$val], $orgIds)) { @@ -610,11 +610,11 @@ public static function formRule($fields, $files, $form) { } if (empty($fields['option_name'])) { - $fields['option_amount'] = array(); + $fields['option_amount'] = []; } if (empty($fields['option_label'])) { - $fields['option_label'] = array(); + $fields['option_label'] = []; } } @@ -639,7 +639,7 @@ public function postProcess() { $params['price_set_id'] = $this->_sid; if ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD)) { - $fieldValues = array('price_set_id' => $this->_sid); + $fieldValues = ['price_set_id' => $this->_sid]; $oldWeight = NULL; if ($this->_fid) { $oldWeight = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', $this->_fid, 'weight', 'id'); @@ -658,14 +658,14 @@ public function postProcess() { $params['is_enter_qty'] = 1; // modify params values as per the option group and option // value - $params['option_amount'] = array(1 => $params['price']); - $params['option_label'] = array(1 => $params['label']); - $params['option_count'] = array(1 => $params['count']); - $params['option_max_value'] = array(1 => CRM_Utils_Array::value('max_value', $params)); + $params['option_amount'] = [1 => $params['price']]; + $params['option_label'] = [1 => $params['label']]; + $params['option_count'] = [1 => $params['count']]; + $params['option_max_value'] = [1 => CRM_Utils_Array::value('max_value', $params)]; //$params['option_description'] = array( 1 => $params['description'] ); - $params['option_weight'] = array(1 => $params['weight']); - $params['option_financial_type_id'] = array(1 => $params['financial_type_id']); - $params['option_visibility_id'] = array(1 => CRM_Utils_Array::value('visibility_id', $params)); + $params['option_weight'] = [1 => $params['weight']]; + $params['option_financial_type_id'] = [1 => $params['financial_type_id']]; + $params['option_visibility_id'] = [1 => CRM_Utils_Array::value('visibility_id', $params)]; } if ($this->_fid) { @@ -677,7 +677,7 @@ public function postProcess() { $priceField = CRM_Price_BAO_PriceField::create($params); if (!is_a($priceField, 'CRM_Core_Error')) { - CRM_Core_Session::setStatus(ts('Price Field \'%1\' has been saved.', array(1 => $priceField->label)), ts('Saved'), 'success'); + CRM_Core_Session::setStatus(ts('Price Field \'%1\' has been saved.', [1 => $priceField->label]), ts('Saved'), 'success'); } $buttonName = $this->controller->getButtonName(); $session = CRM_Core_Session::singleton(); diff --git a/CRM/Price/Form/Option.php b/CRM/Price/Form/Option.php index d83eb9d2f3db..f159c37bdc94 100644 --- a/CRM/Price/Form/Option.php +++ b/CRM/Price/Form/Option.php @@ -84,10 +84,10 @@ public function setDefaultValues() { if ($this->_action == CRM_Core_Action::DELETE) { return NULL; } - $defaults = array(); + $defaults = []; if (isset($this->_oid)) { - $params = array('id' => $this->_oid); + $params = ['id' => $this->_oid]; CRM_Price_BAO_PriceFieldValue::retrieve($params, $defaults); @@ -108,7 +108,7 @@ public function setDefaultValues() { $defaults['financial_type_id'] = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $this->_sid, 'financial_type_id', 'id');; } if (!isset($defaults['weight']) || !$defaults['weight']) { - $fieldValues = array('price_field_id' => $this->_fid); + $fieldValues = ['price_field_id' => $this->_fid]; $defaults['weight'] = CRM_Utils_Weight::getDefaultWeight('CRM_Price_DAO_PriceFieldValue', $fieldValues); $defaults['is_active'] = 1; } @@ -129,16 +129,16 @@ public function buildQuickForm() { } } if ($this->_action == CRM_Core_Action::DELETE) { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => ts('Delete'), - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - )); + ], + ]); return NULL; } else { @@ -172,10 +172,10 @@ public function buildQuickForm() { if ($memberComponentId == $extendComponentId) { $this->assign('showMember', TRUE); $membershipTypes = CRM_Member_PseudoConstant::membershipType(); - $this->add('select', 'membership_type_id', ts('Membership Type'), array( + $this->add('select', 'membership_type_id', ts('Membership Type'), [ '' => ' ', - ) + $membershipTypes, FALSE, - array('onClick' => "calculateRowValues( );")); + ] + $membershipTypes, FALSE, + ['onClick' => "calculateRowValues( );"]); $this->add('number', 'membership_num_terms', ts('Number of Terms'), $attributes['membership_num_terms']); } else { @@ -202,7 +202,7 @@ public function buildQuickForm() { 'select', 'financial_type_id', ts('Financial Type'), - array('' => ts('- select -')) + $financialType, + ['' => ts('- select -')] + $financialType, TRUE ); @@ -253,31 +253,31 @@ public function buildQuickForm() { } } // add buttons - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => ts('Save'), - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - )); + ], + ]); // if view mode pls freeze it with the done button. if ($this->_action & CRM_Core_Action::VIEW) { $this->freeze(); - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'cancel', 'name' => ts('Done'), 'isDefault' => TRUE, - ), - )); + ], + ]); } } - $this->addFormRule(array('CRM_Price_Form_Option', 'formRule'), $this); + $this->addFormRule(['CRM_Price_Form_Option', 'formRule'], $this); } /** @@ -294,7 +294,7 @@ public function buildQuickForm() { * true otherwise */ public static function formRule($fields, $files, $form) { - $errors = array(); + $errors = []; if (!empty($fields['count']) && !empty($fields['max_value']) && $fields['count'] > $fields['max_value'] ) { @@ -302,7 +302,7 @@ public static function formRule($fields, $files, $form) { } $priceField = CRM_Price_BAO_PriceField::findById($fields['fieldId']); - $visibilityOptions = CRM_Price_BAO_PriceFieldValue::buildOptions('visibility_id', NULL, array('labelColumn' => 'name')); + $visibilityOptions = CRM_Price_BAO_PriceFieldValue::buildOptions('visibility_id', NULL, ['labelColumn' => 'name']); $publicCount = 0; $options = CRM_Price_BAO_PriceField::getOptions($priceField->id); @@ -331,7 +331,7 @@ public static function formRule($fields, $files, $form) { */ public function postProcess() { if ($this->_action == CRM_Core_Action::DELETE) { - $fieldValues = array('price_field_id' => $this->_fid); + $fieldValues = ['price_field_id' => $this->_fid]; $wt = CRM_Utils_Weight::delWeight('CRM_Price_DAO_PriceFieldValue', $this->_oid, $fieldValues); $label = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceFieldValue', $this->_oid, @@ -339,12 +339,12 @@ public function postProcess() { ); if (CRM_Price_BAO_PriceFieldValue::del($this->_oid)) { - CRM_Core_Session::setStatus(ts('%1 option has been deleted.', array(1 => $label)), ts('Record Deleted'), 'success'); + CRM_Core_Session::setStatus(ts('%1 option has been deleted.', [1 => $label]), ts('Record Deleted'), 'success'); } return NULL; } else { - $params = $ids = array(); + $params = $ids = []; $params = $this->controller->exportValues('Option'); $fieldLabel = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceField', $this->_fid, 'label'); @@ -355,13 +355,13 @@ public function postProcess() { $params['is_default'] = CRM_Utils_Array::value('is_default', $params, FALSE); $params['is_active'] = CRM_Utils_Array::value('is_active', $params, FALSE); $params['visibility_id'] = CRM_Utils_Array::value('visibility_id', $params, FALSE); - $ids = array(); + $ids = []; if ($this->_oid) { $ids['id'] = $this->_oid; } $optionValue = CRM_Price_BAO_PriceFieldValue::create($params, $ids); - CRM_Core_Session::setStatus(ts("The option '%1' has been saved.", array(1 => $params['label'])), ts('Value Saved'), 'success'); + CRM_Core_Session::setStatus(ts("The option '%1' has been saved.", [1 => $params['label']]), ts('Value Saved'), 'success'); } } diff --git a/CRM/Price/Form/Preview.php b/CRM/Price/Form/Preview.php index ce97044bfa85..4d3cad25e525 100644 --- a/CRM/Price/Form/Preview.php +++ b/CRM/Price/Form/Preview.php @@ -67,12 +67,12 @@ public function preProcess() { $this->_groupTree[$groupId]['fields'][$fieldId] = $groupTree[$groupId]['fields'][$fieldId]; $this->assign('preview_type', 'field'); $url = CRM_Utils_System::url('civicrm/admin/price/field', "reset=1&action=browse&sid={$groupId}"); - $breadCrumb = array( - array( + $breadCrumb = [ + [ 'title' => ts('Price Set Fields'), 'url' => $url, - ), - ); + ], + ]; } else { // group preview @@ -80,12 +80,12 @@ public function preProcess() { $this->assign('preview_type', 'group'); $this->assign('setTitle', CRM_Price_BAO_PriceSet::getTitle($groupId)); $url = CRM_Utils_System::url('civicrm/admin/price', 'reset=1'); - $breadCrumb = array( - array( + $breadCrumb = [ + [ 'title' => ts('Price Sets'), 'url' => $url, - ), - ); + ], + ]; } CRM_Utils_System::appendBreadCrumb($breadCrumb); } @@ -97,7 +97,7 @@ public function preProcess() { * the default array reference */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; $groupId = $this->get('groupId'); $fieldId = $this->get('fieldId'); if (!empty($this->_groupTree[$groupId]['fields'])) { @@ -139,13 +139,13 @@ public function buildQuickForm() { } } - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'cancel', 'name' => ts('Done with Preview'), 'isDefault' => TRUE, - ), - )); + ], + ]); } } diff --git a/CRM/Price/Form/Set.php b/CRM/Price/Form/Set.php index 03cd7f385ecd..1f49fa4e0461 100644 --- a/CRM/Price/Form/Set.php +++ b/CRM/Price/Form/Set.php @@ -119,20 +119,20 @@ public function preProcess() { $title = CRM_Price_BAO_PriceSet::getTitle($this->getEntityId()); } if ($this->_action & CRM_Core_Action::UPDATE) { - $title = ts('Edit %1', array(1 => $title)); + $title = ts('Edit %1', [1 => $title]); } elseif ($this->_action & CRM_Core_Action::VIEW) { - $title = ts('Preview %1', array(1 => $title)); + $title = ts('Preview %1', [1 => $title]); } CRM_Utils_System::setTitle($title); $url = CRM_Utils_System::url('civicrm/admin/price', 'reset=1'); - $breadCrumb = array( - array( + $breadCrumb = [ + [ 'title' => ts('Price Sets'), 'url' => $url, - ), - ); + ], + ]; CRM_Utils_System::appendBreadCrumb($breadCrumb); } @@ -150,7 +150,7 @@ public function preProcess() { * true if no errors, else array of errors */ public static function formRule($fields, $files, $options) { - $errors = array(); + $errors = []; $count = count(CRM_Utils_Array::value('extends', $fields)); //price sets configured for membership if ($count && array_key_exists(CRM_Core_Component::getComponentID('CiviMember'), $fields['extends'])) { @@ -173,10 +173,10 @@ public function buildQuickForm() { $this->assign('sid', $this->getEntityId()); $this->addRule('title', ts('Name already exists in Database.'), - 'objectExists', array('CRM_Price_DAO_PriceSet', $this->getEntityId(), 'title') + 'objectExists', ['CRM_Price_DAO_PriceSet', $this->getEntityId(), 'title'] ); - $priceSetUsedTables = $extends = array(); + $priceSetUsedTables = $extends = []; if ($this->_action == CRM_Core_Action::UPDATE && $this->getEntityId()) { $priceSetUsedTables = CRM_Price_BAO_PriceSet::getUsedBy($this->getEntityId(), 'table'); } @@ -188,7 +188,7 @@ public function buildQuickForm() { case 'CiviEvent': $option = $this->createElement('checkbox', $compObj->componentID, NULL, ts('Event')); if (!empty($priceSetUsedTables)) { - foreach (array('civicrm_event', 'civicrm_participant') as $table) { + foreach (['civicrm_event', 'civicrm_participant'] as $table) { if (in_array($table, $priceSetUsedTables)) { $option->freeze(); break; @@ -201,7 +201,7 @@ public function buildQuickForm() { case 'CiviContribute': $option = $this->createElement('checkbox', $compObj->componentID, NULL, ts('Contribution')); if (!empty($priceSetUsedTables)) { - foreach (array('civicrm_contribution', 'civicrm_contribution_page') as $table) { + foreach (['civicrm_contribution', 'civicrm_contribution_page'] as $table) { if (in_array($table, $priceSetUsedTables)) { $option->freeze(); break; @@ -214,7 +214,7 @@ public function buildQuickForm() { case 'CiviMember': $option = $this->createElement('checkbox', $compObj->componentID, NULL, ts('Membership')); if (!empty($priceSetUsedTables)) { - foreach (array('civicrm_membership', 'civicrm_contribution_page') as $table) { + foreach (['civicrm_membership', 'civicrm_contribution_page'] as $table) { if (in_array($table, $priceSetUsedTables)) { $option->freeze(); break; @@ -235,17 +235,17 @@ public function buildQuickForm() { $this->addGroup($extends, 'extends', ts('Used For'), ' ', TRUE); - $this->addRule('extends', ts('%1 is a required field.', array(1 => ts('Used For'))), 'required'); + $this->addRule('extends', ts('%1 is a required field.', [1 => ts('Used For')]), 'required'); // financial type $financialType = CRM_Financial_BAO_FinancialType::getIncomeFinancialType(); $this->add('select', 'financial_type_id', ts('Default Financial Type'), - array('' => ts('- select -')) + $financialType, 'required' + ['' => ts('- select -')] + $financialType, 'required' ); - $this->addFormRule(array('CRM_Price_Form_Set', 'formRule')); + $this->addFormRule(['CRM_Price_Form_Set', 'formRule']); // views are implemented as frozen form if ($this->_action & CRM_Core_Action::VIEW) { @@ -262,9 +262,9 @@ public function buildQuickForm() { * array of default values */ public function setDefaultValues() { - $defaults = array('is_active' => TRUE); + $defaults = ['is_active' => TRUE]; if ($this->getEntityId()) { - $params = array('id' => $this->getEntityId()); + $params = ['id' => $this->getEntityId()]; CRM_Price_BAO_PriceSet::retrieve($params, $defaults); $extends = explode(CRM_Core_DAO::VALUE_SEPARATOR, $defaults['extends']); unset($defaults['extends']); @@ -286,7 +286,7 @@ public function postProcess() { $params['is_active'] = CRM_Utils_Array::value('is_active', $params, FALSE); $params['financial_type_id'] = CRM_Utils_Array::value('financial_type_id', $params, FALSE); - $compIds = array(); + $compIds = []; $extends = CRM_Utils_Array::value('extends', $params); if (is_array($extends)) { foreach ($extends as $compId => $selected) { @@ -307,19 +307,19 @@ public function postProcess() { $set = CRM_Price_BAO_PriceSet::create($params); if ($this->_action & CRM_Core_Action::UPDATE) { - CRM_Core_Session::setStatus(ts('The Set \'%1\' has been saved.', array(1 => $set->title)), ts('Saved'), 'success'); + CRM_Core_Session::setStatus(ts('The Set \'%1\' has been saved.', [1 => $set->title]), ts('Saved'), 'success'); } else { // Jump directly to adding a field if popups are disabled $action = CRM_Core_Resources::singleton()->ajaxPopupsEnabled ? 'browse' : 'add'; - $url = CRM_Utils_System::url('civicrm/admin/price/field', array( + $url = CRM_Utils_System::url('civicrm/admin/price/field', [ 'reset' => 1, 'action' => $action, 'sid' => $set->id, 'new' => 1, - )); + ]); CRM_Core_Session::setStatus(ts("Your Set '%1' has been added. You can add fields to this set now.", - array(1 => $set->title) + [1 => $set->title] ), ts('Saved'), 'success'); $session = CRM_Core_Session::singleton(); $session->replaceUserContext($url); diff --git a/CRM/Price/Page/Field.php b/CRM/Price/Page/Field.php index 3a13ffb547ae..47e1cb1c93dc 100644 --- a/CRM/Price/Page/Field.php +++ b/CRM/Price/Page/Field.php @@ -74,36 +74,36 @@ class CRM_Price_Page_Field extends CRM_Core_Page { */ public static function &actionLinks() { if (!isset(self::$_actionLinks)) { - self::$_actionLinks = array( - CRM_Core_Action::UPDATE => array( + self::$_actionLinks = [ + CRM_Core_Action::UPDATE => [ 'name' => ts('Edit Price Field'), 'url' => 'civicrm/admin/price/field', 'qs' => 'action=update&reset=1&sid=%%sid%%&fid=%%fid%%', 'title' => ts('Edit Price'), - ), - CRM_Core_Action::PREVIEW => array( + ], + CRM_Core_Action::PREVIEW => [ 'name' => ts('Preview Field'), 'url' => 'civicrm/admin/price/field', 'qs' => 'action=preview&reset=1&sid=%%sid%%&fid=%%fid%%', 'title' => ts('Preview Price'), - ), - CRM_Core_Action::DISABLE => array( + ], + CRM_Core_Action::DISABLE => [ 'name' => ts('Disable'), 'ref' => 'crm-enable-disable', 'title' => ts('Disable Price'), - ), - CRM_Core_Action::ENABLE => array( + ], + CRM_Core_Action::ENABLE => [ 'name' => ts('Enable'), 'ref' => 'crm-enable-disable', 'title' => ts('Enable Price'), - ), - CRM_Core_Action::DELETE => array( + ], + CRM_Core_Action::DELETE => [ 'name' => ts('Delete'), 'url' => 'civicrm/admin/price/field', 'qs' => 'action=delete&reset=1&sid=%%sid%%&fid=%%fid%%', 'title' => ts('Delete Price'), - ), - ); + ], + ]; } return self::$_actionLinks; } @@ -117,7 +117,7 @@ public function browse() { $resourceManager->addScriptFile('civicrm', 'js/crm.addNew.js', 999, 'html-header'); } - $priceField = array(); + $priceField = []; $priceFieldBAO = new CRM_Price_BAO_PriceField(); // fkey is sid @@ -133,13 +133,13 @@ public function browse() { $taxRate = CRM_Core_PseudoConstant::getTaxRates(); CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($financialTypes); while ($priceFieldBAO->fetch()) { - $priceField[$priceFieldBAO->id] = array(); + $priceField[$priceFieldBAO->id] = []; CRM_Core_DAO::storeValues($priceFieldBAO, $priceField[$priceFieldBAO->id]); // get price if it's a text field if ($priceFieldBAO->html_type == 'Text') { - $optionValues = array(); - $params = array('price_field_id' => $priceFieldBAO->id); + $optionValues = []; + $params = ['price_field_id' => $priceFieldBAO->id]; CRM_Price_BAO_PriceFieldValue::retrieve($params, $optionValues); $priceField[$priceFieldBAO->id]['price'] = CRM_Utils_Array::value('amount', $optionValues); @@ -183,10 +183,10 @@ public function browse() { $priceField[$priceFieldBAO->id]['action'] = CRM_Core_Action::formLink( self::actionLinks(), $action, - array( + [ 'fid' => $priceFieldBAO->id, 'sid' => $this->_sid, - ), + ], ts('more'), FALSE, 'priceField.row.actions', @@ -256,12 +256,12 @@ public function run() { $this->assign('isReserved', $this->_isSetReserved); CRM_Price_BAO_PriceSet::checkPermission($this->_sid); - $comps = array( + $comps = [ 'Event' => 'civicrm_event', 'Contribution' => 'civicrm_contribution_page', 'EventTemplate' => 'civicrm_event_template', - ); - $priceSetContexts = array(); + ]; + $priceSetContexts = []; foreach ($comps as $name => $table) { if (array_key_exists($table, $usedBy)) { $priceSetContexts[] = $name; @@ -298,7 +298,7 @@ public function run() { $groupTitle = CRM_Price_BAO_PriceSet::getTitle($this->_sid); $this->assign('sid', $this->_sid); $this->assign('groupTitle', $groupTitle); - CRM_Utils_System::setTitle(ts('%1 - Price Fields', array(1 => $groupTitle))); + CRM_Utils_System::setTitle(ts('%1 - Price Fields', [1 => $groupTitle])); } // assign vars to templates diff --git a/CRM/Price/Page/Option.php b/CRM/Price/Page/Option.php index 44acb2bcd54a..a8ec96fb8d3e 100644 --- a/CRM/Price/Page/Option.php +++ b/CRM/Price/Page/Option.php @@ -81,36 +81,36 @@ class CRM_Price_Page_Option extends CRM_Core_Page { */ public static function &actionLinks() { if (!isset(self::$_actionLinks)) { - self::$_actionLinks = array( - CRM_Core_Action::UPDATE => array( + self::$_actionLinks = [ + CRM_Core_Action::UPDATE => [ 'name' => ts('Edit Option'), 'url' => 'civicrm/admin/price/field/option', 'qs' => 'reset=1&action=update&oid=%%oid%%&fid=%%fid%%&sid=%%sid%%', 'title' => ts('Edit Price Option'), - ), - CRM_Core_Action::VIEW => array( + ], + CRM_Core_Action::VIEW => [ 'name' => ts('View'), 'url' => 'civicrm/admin/price/field/option', 'qs' => 'action=view&oid=%%oid%%', 'title' => ts('View Price Option'), - ), - CRM_Core_Action::DISABLE => array( + ], + CRM_Core_Action::DISABLE => [ 'name' => ts('Disable'), 'ref' => 'crm-enable-disable', 'title' => ts('Disable Price Option'), - ), - CRM_Core_Action::ENABLE => array( + ], + CRM_Core_Action::ENABLE => [ 'name' => ts('Enable'), 'ref' => 'crm-enable-disable', 'title' => ts('Enable Price Option'), - ), - CRM_Core_Action::DELETE => array( + ], + CRM_Core_Action::DELETE => [ 'name' => ts('Delete'), 'url' => 'civicrm/admin/price/field/option', 'qs' => 'action=delete&oid=%%oid%%', 'title' => ts('Disable Price Option'), - ), - ); + ], + ]; } return self::$_actionLinks; } @@ -121,16 +121,16 @@ public static function &actionLinks() { * @return void */ public function browse() { - $priceOptions = civicrm_api3('PriceFieldValue', 'get', array( + $priceOptions = civicrm_api3('PriceFieldValue', 'get', [ 'price_field_id' => $this->_fid, // Explicitly do not check permissions so we are not // restricted by financial type, so we can change them. 'check_permissions' => FALSE, - 'options' => array( + 'options' => [ 'limit' => 0, - 'sort' => array('weight', 'label'), - ), - )); + 'sort' => ['weight', 'label'], + ], + ]); $customOption = $priceOptions['values']; // CRM-15378 - check if these price options are in an Event price set @@ -184,11 +184,11 @@ public function browse() { } $customOption[$id]['order'] = $customOption[$id]['weight']; $customOption[$id]['action'] = CRM_Core_Action::formLink(self::actionLinks(), $action, - array( + [ 'oid' => $id, 'fid' => $this->_fid, 'sid' => $this->_sid, - ), + ], ts('more'), FALSE, 'priceFieldValue.row.actions', @@ -224,7 +224,7 @@ public function edit($action) { $oid = CRM_Utils_Request::retrieve('oid', 'Positive', $this, FALSE, 0 ); - $params = array(); + $params = []; if ($oid) { $params['oid'] = $oid; $sid = CRM_Price_BAO_PriceSet::getSetId($params); @@ -251,11 +251,11 @@ public function edit($action) { ); $this->assign('usedPriceSetTitle', CRM_Price_BAO_PriceFieldValue::getOptionLabel($oid)); $this->assign('usedBy', $usedBy); - $comps = array( + $comps = [ "Event" => "civicrm_event", "Contribution" => "civicrm_contribution_page", - ); - $priceSetContexts = array(); + ]; + $priceSetContexts = []; foreach ($comps as $name => $table) { if (array_key_exists($table, $usedBy)) { $priceSetContexts[] = $name; @@ -289,19 +289,19 @@ public function run() { $this->assign('isReserved', $this->_isSetReserved); } //as url contain $sid so append breadcrumb dynamically. - $breadcrumb = array( - array( + $breadcrumb = [ + [ 'title' => ts('Price Fields'), 'url' => CRM_Utils_System::url('civicrm/admin/price/field', 'reset=1&sid=' . $this->_sid), - ), - ); + ], + ]; CRM_Utils_System::appendBreadCrumb($breadcrumb); if ($this->_fid) { $fieldTitle = CRM_Price_BAO_PriceField::getTitle($this->_fid); $this->assign('fid', $this->_fid); $this->assign('fieldTitle', $fieldTitle); - CRM_Utils_System::setTitle(ts('%1 - Price Options', array(1 => $fieldTitle))); + CRM_Utils_System::setTitle(ts('%1 - Price Options', [1 => $fieldTitle])); $htmlType = CRM_Core_DAO::getFieldValue('CRM_Price_BAO_PriceField', $this->_fid, 'html_type'); $this->assign('addMoreFields', TRUE); diff --git a/CRM/Price/Page/Set.php b/CRM/Price/Page/Set.php index 88ff0aa1d603..accc307829e5 100644 --- a/CRM/Price/Page/Set.php +++ b/CRM/Price/Page/Set.php @@ -62,50 +62,50 @@ public function &actionLinks() { // helper variable for nicer formatting $deleteExtra = ts('Are you sure you want to delete this price set?'); $copyExtra = ts('Are you sure you want to make a copy of this price set?'); - self::$_actionLinks = array( - CRM_Core_Action::BROWSE => array( + self::$_actionLinks = [ + CRM_Core_Action::BROWSE => [ 'name' => ts('View and Edit Price Fields'), 'url' => 'civicrm/admin/price/field', 'qs' => 'reset=1&action=browse&sid=%%sid%%', 'title' => ts('View and Edit Price Fields'), - ), - CRM_Core_Action::PREVIEW => array( + ], + CRM_Core_Action::PREVIEW => [ 'name' => ts('Preview'), 'url' => 'civicrm/admin/price', 'qs' => 'action=preview&reset=1&sid=%%sid%%', 'title' => ts('Preview Price Set'), - ), - CRM_Core_Action::UPDATE => array( + ], + CRM_Core_Action::UPDATE => [ 'name' => ts('Settings'), 'url' => 'civicrm/admin/price', 'qs' => 'action=update&reset=1&sid=%%sid%%', 'title' => ts('Edit Price Set'), - ), - CRM_Core_Action::DISABLE => array( + ], + CRM_Core_Action::DISABLE => [ 'name' => ts('Disable'), 'ref' => 'crm-enable-disable', 'title' => ts('Disable Price Set'), - ), - CRM_Core_Action::ENABLE => array( + ], + CRM_Core_Action::ENABLE => [ 'name' => ts('Enable'), 'ref' => 'crm-enable-disable', 'title' => ts('Enable Price Set'), - ), - CRM_Core_Action::DELETE => array( + ], + CRM_Core_Action::DELETE => [ 'name' => ts('Delete'), 'url' => 'civicrm/admin/price', 'qs' => 'action=delete&reset=1&sid=%%sid%%', 'title' => ts('Delete Price Set'), 'extra' => 'onclick = "return confirm(\'' . $deleteExtra . '\');"', - ), - CRM_Core_Action::COPY => array( + ], + CRM_Core_Action::COPY => [ 'name' => ts('Copy Price Set'), 'url' => CRM_Utils_System::currentPath(), 'qs' => 'action=copy&sid=%%sid%%', 'title' => ts('Make a Copy of Price Set'), 'extra' => 'onclick = "return confirm(\'' . $copyExtra . '\');"', - ), - ); + ], + ]; } return self::$_actionLinks; } @@ -168,12 +168,12 @@ public function run() { $this->assign('usedPriceSetTitle', CRM_Price_BAO_PriceSet::getTitle($sid)); $this->assign('usedBy', $usedBy); - $comps = array( + $comps = [ 'Event' => 'civicrm_event', 'Contribution' => 'civicrm_contribution_page', 'EventTemplate' => 'civicrm_event_template', - ); - $priceSetContexts = array(); + ]; + $priceSetContexts = []; foreach ($comps as $name => $table) { if (array_key_exists($table, $usedBy)) { $priceSetContexts[] = $name; @@ -247,12 +247,12 @@ public function preview($sid) { */ public function browse($action = NULL) { // get all price sets - $priceSet = array(); - $comps = array( + $priceSet = []; + $comps = [ 'CiviEvent' => ts('Event'), 'CiviContribute' => ts('Contribution'), 'CiviMember' => ts('Membership'), - ); + ]; $dao = new CRM_Price_DAO_PriceSet(); if (CRM_Price_BAO_PriceSet::eventPriceSetDomainID()) { @@ -261,13 +261,13 @@ public function browse($action = NULL) { $dao->is_quick_config = 0; $dao->find(); while ($dao->fetch()) { - $priceSet[$dao->id] = array(); + $priceSet[$dao->id] = []; CRM_Core_DAO::storeValues($dao, $priceSet[$dao->id]); $compIds = explode(CRM_Core_DAO::VALUE_SEPARATOR, CRM_Utils_Array::value('extends', $priceSet[$dao->id]) ); - $extends = array(); + $extends = []; //CRM-10225 foreach ($compIds as $compId) { if (!empty($comps[CRM_Core_Component::getComponentName($compId)])) { @@ -297,7 +297,7 @@ public function browse($action = NULL) { $actionLinks[CRM_Core_Action::BROWSE]['name'] = ts('View Price Fields'); } $priceSet[$dao->id]['action'] = CRM_Core_Action::formLink($actionLinks, $action, - array('sid' => $dao->id), + ['sid' => $dao->id], ts('more'), FALSE, 'priceSet.row.actions', diff --git a/CRM/Profile/Form.php b/CRM/Profile/Form.php index ac050c485da1..647e86ae9c99 100644 --- a/CRM/Profile/Form.php +++ b/CRM/Profile/Form.php @@ -68,7 +68,7 @@ class CRM_Profile_Form extends CRM_Core_Form { /** * @var array details of the UFGroup used on this page */ - protected $_ufGroup = array('name' => 'unknown'); + protected $_ufGroup = ['name' => 'unknown']; /** * The group id that we are passing in url. @@ -138,7 +138,7 @@ class CRM_Profile_Form extends CRM_Core_Form { * Store profile ids if multiple profile ids are passed using comma separated. * Currently lets implement this functionality only for dialog mode. */ - protected $_profileIds = array(); + protected $_profileIds = []; /** * Contact profile having activity fields? @@ -318,7 +318,7 @@ public function preProcess() { } if ($this->_multiRecord && - !in_array($this->_multiRecord, array(CRM_Core_Action::UPDATE, CRM_Core_Action::ADD, CRM_Core_Action::DELETE)) + !in_array($this->_multiRecord, [CRM_Core_Action::UPDATE, CRM_Core_Action::ADD, CRM_Core_Action::DELETE]) ) { CRM_Core_Error::fatal(ts('Proper action not specified for this custom value record profile')); } @@ -373,9 +373,9 @@ public function preProcess() { $dao->free(); if (!CRM_Utils_Array::value('is_active', $this->_ufGroup)) { - CRM_Core_Error::fatal(ts('The requested profile (gid=%1) is inactive or does not exist.', array( + CRM_Core_Error::fatal(ts('The requested profile (gid=%1) is inactive or does not exist.', [ 1 => $this->_gid, - ))); + ])); } } $this->assign('ufGroupName', $this->_ufGroup['name']); @@ -423,17 +423,17 @@ public function preProcess() { && ($this->_multiRecord == CRM_Core_Action::UPDATE || $this->_multiRecord == CRM_Core_Action::DELETE) ) { CRM_Core_Error::fatal(ts('The requested Profile (gid=%1) requires record id while performing this action', - array(1 => $this->_gid) + [1 => $this->_gid] )); } elseif (empty($this->_multiRecordFields)) { CRM_Core_Error::fatal(ts('No Multi-Record Fields configured for this profile (gid=%1)', - array(1 => $this->_gid) + [1 => $this->_gid] )); } $fieldId = CRM_Core_BAO_CustomField::getKeyID(key($this->_multiRecordFields)); - $customGroupDetails = CRM_Core_BAO_CustomGroup::getGroupTitles(array($fieldId)); + $customGroupDetails = CRM_Core_BAO_CustomGroup::getGroupTitles([$fieldId]); $this->_customGroupTitle = $customGroupDetails[$fieldId]['groupTitle']; $this->_customGroupId = $customGroupDetails[$fieldId]['groupID']; @@ -450,7 +450,7 @@ public function preProcess() { else { $this->_recordExists = FALSE; if ($this->_multiRecord & CRM_Core_Action::UPDATE) { - CRM_Core_Session::setStatus(ts('Note: The record %1 doesnot exists. Upon save a new record will be create', array(1 => $this->_recordId)), ts('Record doesnot exist'), 'alert'); + CRM_Core_Session::setStatus(ts('Note: The record %1 doesnot exists. Upon save a new record will be create', [1 => $this->_recordId]), ts('Record doesnot exist'), 'alert'); } } } @@ -463,10 +463,10 @@ public function preProcess() { } elseif (!empty($this->_multiRecordFields) - && (!$this->_multiRecord || !in_array($this->_multiRecord, array( + && (!$this->_multiRecord || !in_array($this->_multiRecord, [ CRM_Core_Action::DELETE, CRM_Core_Action::UPDATE, - ))) + ])) ) { CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js', 1, 'html-header'); //multi-record listing page @@ -523,7 +523,7 @@ public function preProcess() { * */ public function setDefaultsValues() { - $this->_defaults = array(); + $this->_defaults = []; if ($this->_multiRecordProfile && ($this->_multiRecord == CRM_Core_Action::DELETE)) { return; } @@ -535,7 +535,7 @@ public function setDefaultsValues() { if ($this->_id && !$this->_multiRecordProfile) { if ($this->_isContactActivityProfile) { - $contactFields = $activityFields = array(); + $contactFields = $activityFields = []; foreach ($this->_fields as $fieldName => $field) { if (CRM_Utils_Array::value('field_type', $field) == 'Activity') { $activityFields[$fieldName] = $field; @@ -561,7 +561,7 @@ public function setDefaultsValues() { $fieldIds[] = CRM_Core_BAO_CustomField::getKeyID($key); } - $defaultValues = array(); + $defaultValues = []; if ($this->_multiRecord && $this->_multiRecord == CRM_Core_Action::UPDATE) { $defaultValues = CRM_Core_BAO_CustomValueTable::getEntityValues($this->_id, NULL, $fieldIds, TRUE); if ($this->_recordExists == TRUE) { @@ -711,7 +711,7 @@ public function buildQuickForm() { if (($this->_multiRecord & CRM_Core_Action::DELETE)) { if (!$this->_recordExists) { - CRM_Core_Session::setStatus(ts('The record %1 doesnot exists', array(1 => $this->_recordId)), ts('Record doesnot exists'), 'alert'); + CRM_Core_Session::setStatus(ts('The record %1 doesnot exists', [1 => $this->_recordId]), ts('Record doesnot exists'), 'alert'); } else { $this->assign('deleteRecord', TRUE); @@ -761,7 +761,7 @@ public function buildQuickForm() { $return = TRUE; if (!$statusMessage) { $statusMessage = ts("This profile is configured for contact type '%1'. It cannot be used to edit contacts of other types.", - array(1 => $profileSubType ? $profileSubType : $profileType)); + [1 => $profileSubType ? $profileSubType : $profileType]); } } } @@ -769,7 +769,7 @@ public function buildQuickForm() { if ( in_array( $profileType, - array("Membership", "Participant", "Contribution") + ["Membership", "Participant", "Contribution"] ) ) { $return = TRUE; @@ -825,7 +825,7 @@ public function buildQuickForm() { } $this->assign('anonUser', $anonUser); - $addCaptcha = array(); + $addCaptcha = []; $emailPresent = FALSE; // add the form elements @@ -939,14 +939,14 @@ public function buildQuickForm() { * @return array */ public static function validateContactActivityProfile($activityId, $contactId, $gid) { - $errors = array(); + $errors = []; if (!$activityId) { $errors[] = ts('Profile is using one or more activity fields, and is missing the activity Id (aid) in the URL.'); return $errors; } - $activityDetails = array(); - $activityParams = array('id' => $activityId); + $activityDetails = []; + $activityParams = ['id' => $activityId]; CRM_Activity_BAO_Activity::retrieve($activityParams, $activityDetails); if (empty($activityDetails)) { @@ -1069,7 +1069,7 @@ public static function formRule($fields, $files, $form) { $customizedValue = CRM_Core_PseudoConstant::getKey('CRM_Contact_BAO_Contact', $greeting . '_id', 'Customized'); if ($customizedValue == $greetingType && empty($fields[$greeting . '_custom'])) { $errors[$greeting . '_custom'] = ts('Custom %1 is a required field if %1 is of type Customized.', - array(1 => ucwords(str_replace('_', ' ', $greeting))) + [1 => ucwords(str_replace('_', ' ', $greeting))] ); } } @@ -1089,15 +1089,15 @@ public function postProcess() { if ($this->_deleteButtonName) { if (!empty($_POST[$this->_deleteButtonName]) && $this->_recordId) { $filterParams['id'] = $this->_customGroupId; - $returnProperties = array('is_multiple', 'table_name'); + $returnProperties = ['is_multiple', 'table_name']; CRM_Core_DAO::commonRetrieve("CRM_Core_DAO_CustomGroup", $filterParams, $returnValues, $returnProperties); if (!empty($returnValues['is_multiple'])) { if ($tableName = CRM_Utils_Array::value('table_name', $returnValues)) { $sql = "DELETE FROM {$tableName} WHERE id = %1 AND entity_id = %2"; - $sqlParams = array( - 1 => array($this->_recordId, 'Integer'), - 2 => array($this->_id, 'Integer'), - ); + $sqlParams = [ + 1 => [$this->_recordId, 'Integer'], + 2 => [$this->_id, 'Integer'], + ]; CRM_Core_DAO::executeQuery($sql, $sqlParams); CRM_Core_Session::setStatus(ts('Your record has been deleted.'), ts('Deleted'), 'success'); } @@ -1110,13 +1110,13 @@ public function postProcess() { CRM_Contact_BAO_Contact::processImageParams($params); } - $greetingTypes = array( + $greetingTypes = [ 'addressee' => 'addressee_id', 'email_greeting' => 'email_greeting_id', 'postal_greeting' => 'postal_greeting_id', - ); + ]; - $details = array(); + $details = []; if ($this->_id) { $contactDetails = CRM_Contact_BAO_Contact::getHierContactDetails($this->_id, $greetingTypes @@ -1153,7 +1153,7 @@ public function postProcess() { //used to send subscribe mail to the group which user want. //if the profile double option in is enabled - $mailingType = array(); + $mailingType = []; $result = NULL; foreach ($params as $name => $values) { @@ -1163,18 +1163,18 @@ public function postProcess() { } //array of group id, subscribed by contact - $contactGroup = array(); + $contactGroup = []; if (!empty($params['group']) && CRM_Core_BAO_UFGroup::isProfileDoubleOptin() ) { - $groupSubscribed = array(); + $groupSubscribed = []; if (!empty($result['email'])) { if ($this->_id) { $contactGroups = new CRM_Contact_DAO_GroupContact(); $contactGroups->contact_id = $this->_id; $contactGroups->status = 'Added'; $contactGroups->find(); - $contactGroup = array(); + $contactGroup = []; while ($contactGroups->fetch()) { $contactGroup[] = $contactGroups->group_id; $groupSubscribed[$contactGroups->group_id] = 1; @@ -1219,13 +1219,13 @@ public function postProcess() { ) { if (!count($contactGroup)) { //array of group id, subscribed by contact - $contactGroup = array(); + $contactGroup = []; if ($this->_id) { $contactGroups = new CRM_Contact_DAO_GroupContact(); $contactGroups->contact_id = $this->_id; $contactGroups->status = 'Added'; $contactGroups->find(); - $contactGroup = array(); + $contactGroup = []; while ($contactGroups->fetch()) { $contactGroup[] = $contactGroups->group_id; $groupSubscribed[$contactGroups->group_id] = 1; @@ -1258,7 +1258,7 @@ public function postProcess() { $profileFields = $this->_fields; if (($this->_mode & self::MODE_EDIT) && $this->_activityId && $this->_isContactActivityProfile) { - $profileFields = $activityParams = array(); + $profileFields = $activityParams = []; foreach ($this->_fields as $fieldName => $field) { if (CRM_Utils_Array::value('field_type', $field) == 'Activity') { if (isset($params[$fieldName])) { @@ -1305,7 +1305,7 @@ public function postProcess() { CRM_Mailing_Event_BAO_Subscribe::commonSubscribe($mailingType, $result, $this->_id, 'profile'); } - $ufGroups = array(); + $ufGroups = []; if ($this->_gid) { $ufGroups[$this->_gid] = 1; } diff --git a/CRM/Profile/Form/Dynamic.php b/CRM/Profile/Form/Dynamic.php index 1ecb44a34fb3..c1e6c50ac595 100644 --- a/CRM/Profile/Form/Dynamic.php +++ b/CRM/Profile/Form/Dynamic.php @@ -71,19 +71,19 @@ public function preProcess() { * */ public function buildQuickForm() { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'upload', 'name' => ts('Save'), 'isDefault' => TRUE, - ), - )); + ], + ]); // also add a hidden element for to trick drupal $this->addElement('hidden', "edit[civicrm_dummy_field]", "CiviCRM Dummy Field for Drupal"); parent::buildQuickForm(); - $this->addFormRule(array('CRM_Profile_Form_Dynamic', 'formRule'), $this); + $this->addFormRule(['CRM_Profile_Form_Dynamic', 'formRule'], $this); } /** @@ -100,7 +100,7 @@ public function buildQuickForm() { * true if no errors, else array of errors */ public static function formRule($fields, $files, $form) { - $errors = array(); + $errors = []; // if no values, return if (empty($fields) || empty($fields['edit'])) { diff --git a/CRM/Profile/Form/Edit.php b/CRM/Profile/Form/Edit.php index 2e54add70236..c5d493bacf88 100644 --- a/CRM/Profile/Form/Edit.php +++ b/CRM/Profile/Form/Edit.php @@ -128,7 +128,7 @@ public function preProcess() { WHERE civicrm_uf_group.id = %1 "; - $params = array(1 => array($this->_gid, 'Integer')); + $params = [1 => [$this->_gid, 'Integer']]; $dao = CRM_Core_DAO::executeQuery($query, $params); $isProfile = FALSE; @@ -142,7 +142,7 @@ public function preProcess() { //Remove need for Profile module type when using reserved profiles [CRM-14488] if (!$dao->N || (!$isProfile && !($dao->is_reserved && $canAdd))) { CRM_Core_Error::fatal(ts('The requested Profile (gid=%1) is not configured to be used for \'Profile\' edit and view forms in its Settings. Contact the site administrator if you need assistance.', - array(1 => $this->_gid) + [1 => $this->_gid] )); } } @@ -242,15 +242,15 @@ public function buildQuickForm() { $buttonName = 'next'; } - $buttons[] = array( + $buttons[] = [ 'type' => $buttonName, 'name' => !empty($this->_ufGroup['submit_button_text']) ? $this->_ufGroup['submit_button_text'] : ts('Save'), 'isDefault' => TRUE, - ); + ]; $this->addButtons($buttons); - $this->addFormRule(array('CRM_Profile_Form', 'formRule'), $this); + $this->addFormRule(['CRM_Profile_Form', 'formRule'], $this); } /** @@ -262,10 +262,10 @@ public function postProcess() { // Send back data for the EntityRef widget if ($this->returnExtra) { - $contact = civicrm_api3('Contact', 'getsingle', array( + $contact = civicrm_api3('Contact', 'getsingle', [ 'id' => $this->_id, 'return' => $this->returnExtra, - )); + ]); foreach (explode(',', $this->returnExtra) as $field) { $field = trim($field); $this->ajaxResponse['extra'][$field] = CRM_Utils_Array::value($field, $contact); @@ -301,10 +301,10 @@ public function postProcess() { } else { // Replace tokens from post URL - $contactParams = array( + $contactParams = [ 'contact_id' => $this->_id, 'version' => 3, - ); + ]; $contact = civicrm_api('contact', 'get', $contactParams); $contact = reset($contact['values']); diff --git a/CRM/Profile/Form/Search.php b/CRM/Profile/Form/Search.php index ad8a63da5bf6..c674f74280fb 100644 --- a/CRM/Profile/Form/Search.php +++ b/CRM/Profile/Form/Search.php @@ -55,7 +55,7 @@ public function preProcess() { * the default array reference */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; // note we intentionally overwrite value since we use it as defaults // and its all pass by value // we need to figure out the type, so we can either set an array element @@ -64,7 +64,7 @@ public function setDefaultValues() { if (substr($key, 0, 7) == 'custom_' || $key == "preferred_communication_method") { if (strpos($value, CRM_Core_DAO::VALUE_SEPARATOR) !== FALSE) { $v = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value); - $value = array(); + $value = []; foreach ($v as $item) { if ($item) { $value[$item] = $item; @@ -74,15 +74,15 @@ public function setDefaultValues() { } elseif ($key == 'group' || $key == 'tag') { $v = explode(',', $value); - $value = array(); + $value = []; foreach ($v as $item) { $value[$item] = 1; } } - elseif (in_array($key, array( + elseif (in_array($key, [ 'birth_date', 'deceased_date', - ))) { + ])) { list($value) = CRM_Utils_Date::setDateDefaults($value); } @@ -104,13 +104,13 @@ public function buildQuickForm() { CRM_Contact_Form_Task_ProximityCommon::buildQuickForm($this, $proxSearch); } - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'refresh', 'name' => ts('Search'), 'isDefault' => TRUE, - ), - )); + ], + ]); parent::buildQuickForm(); } diff --git a/CRM/Profile/Page/Dynamic.php b/CRM/Profile/Page/Dynamic.php index 4b265f89edec..a373d151470a 100644 --- a/CRM/Profile/Page/Dynamic.php +++ b/CRM/Profile/Page/Dynamic.php @@ -73,7 +73,7 @@ class CRM_Profile_Page_Dynamic extends CRM_Core_Page { * Store profile ids if multiple profile ids are passed using comma separated. * Currently lets implement this functionality only for dialog mode */ - protected $_profileIds = array(); + protected $_profileIds = []; /** * Contact profile having activity fields? @@ -147,7 +147,7 @@ public function __construct($id, $gid, $restrict, $skipPermission = FALSE, $prof $this->_profileIds = $profileIds; } else { - $this->_profileIds = array($gid); + $this->_profileIds = [$gid]; } $this->_activityId = CRM_Utils_Request::retrieve('aid', 'Positive', $this, FALSE, 0, 'GET'); @@ -236,7 +236,7 @@ public function run() { $admin = TRUE; } - $values = array(); + $values = []; $fields = CRM_Core_BAO_UFGroup::getFields($this->_profileIds, FALSE, CRM_Core_Action::VIEW, NULL, NULL, FALSE, $this->_restrict, $this->_skipPermission, NULL, @@ -268,7 +268,7 @@ public function run() { } if ($this->_isContactActivityProfile) { - $contactFields = $activityFields = array(); + $contactFields = $activityFields = []; foreach ($fields as $fieldName => $field) { if (CRM_Utils_Array::value('field_type', $field) == 'Activity') { @@ -286,7 +286,7 @@ public function run() { $activityFields, $values, TRUE, - array(array('activity_id', '=', $this->_activityId, 0, 0)) + [['activity_id', '=', $this->_activityId, 0, 0]] ); } } @@ -311,8 +311,8 @@ public function run() { } // $profileFields array can be used for customized display of field labels and values in Profile/View.tpl - $profileFields = array(); - $labels = array(); + $profileFields = []; + $labels = []; foreach ($fields as $name => $field) { //CRM-14338 @@ -329,10 +329,10 @@ public function run() { } foreach ($values as $title => $value) { - $profileFields[$labels[$title]] = array( + $profileFields[$labels[$title]] = [ 'label' => $title, 'value' => $value, - ); + ]; } $template->assign_by_ref('row', $values); @@ -350,7 +350,7 @@ public function run() { if (($this->_multiRecord & CRM_Core_Action::VIEW) && $this->_recordId && !$this->_allFields) { $fieldDetail = reset($fields); $fieldId = CRM_Core_BAO_CustomField::getKeyID($fieldDetail['name']); - $customGroupDetails = CRM_Core_BAO_CustomGroup::getGroupTitles(array($fieldId)); + $customGroupDetails = CRM_Core_BAO_CustomGroup::getGroupTitles([$fieldId]); $multiRecTitle = $customGroupDetails[$fieldId]['groupTitle']; } else { @@ -374,7 +374,7 @@ public function run() { $title .= ' - ' . $displayName; } - $title = isset($multiRecTitle) ? ts('View %1 Record', array(1 => $multiRecTitle)) : $title; + $title = isset($multiRecTitle) ? ts('View %1 Record', [1 => $multiRecTitle]) : $title; CRM_Utils_System::setTitle($title); // invoke the pagRun hook, CRM-3906 diff --git a/CRM/Profile/Page/Listings.php b/CRM/Profile/Page/Listings.php index 0b5329cd7bc1..d5e3c4a116d2 100644 --- a/CRM/Profile/Page/Listings.php +++ b/CRM/Profile/Page/Listings.php @@ -85,7 +85,7 @@ class CRM_Profile_Page_Listings extends CRM_Core_Page { * Store profile ids if multiple profile ids are passed using comma separated. * Currently lets implement this functionality only for dialog mode */ - protected $_profileIds = array(); + protected $_profileIds = []; /** * Extracts the parameters from the request and constructs information for @@ -141,9 +141,9 @@ public function preProcess() { ); $this->_customFields = CRM_Core_BAO_CustomField::getFieldsForImport(NULL, FALSE, FALSE, FALSE, TRUE, TRUE); - $this->_params = array(); + $this->_params = []; - $resetArray = array( + $resetArray = [ 'group', 'tag', 'preferred_communication_method', @@ -153,13 +153,13 @@ public function preProcess() { 'do_not_sms', 'do_not_trade', 'gender', - ); + ]; foreach ($this->_fields as $name => $field) { if ((substr($name, 0, 6) == 'custom') && !empty($field['is_search_range'])) { $from = CRM_Utils_Request::retrieve($name . '_from', 'String', $this); $to = CRM_Utils_Request::retrieve($name . '_to', 'String', $this); - $value = array(); + $value = []; if ($from && $to) { $value[$name . '_from'] = $from; $value[$name . '_to'] = $to; @@ -214,7 +214,7 @@ public function preProcess() { if (($name == 'group' || $name == 'tag') && !empty($value) && !is_array($value)) { $v = explode(',', $value); - $value = array(); + $value = []; foreach ($v as $item) { $value[$item] = 1; } @@ -226,7 +226,7 @@ public function preProcess() { if ($customField) { // reset checkbox/radio because a form does not send null checkbox values if (in_array($customField['html_type'], - array('Multi-Select', 'CheckBox', 'Multi-Select State/Province', 'Multi-Select Country', 'Radio', 'Select') + ['Multi-Select', 'CheckBox', 'Multi-Select State/Province', 'Multi-Select Country', 'Radio', 'Select'] )) { // only reset on a POST submission if we don't see any value $value = NULL; @@ -258,7 +258,7 @@ public function preProcess() { // set the prox params // need to ensure proximity searching is enabled - $proximityVars = array( + $proximityVars = [ 'street_address', 'city', 'postal_code', @@ -266,7 +266,7 @@ public function preProcess() { 'country_id', 'distance', 'distance_unit', - ); + ]; foreach ($proximityVars as $var) { $value = CRM_Utils_Request::retrieve("prox_{$var}", 'String', @@ -416,8 +416,8 @@ public static function getProfileContact($gid) { $session = CRM_Core_Session::singleton(); $params = $session->get('profileParams'); - $details = array(); - $ufGroupParam = array('id' => $gid); + $details = []; + $ufGroupParam = ['id' => $gid]; CRM_Core_BAO_UFGroup::retrieve($ufGroupParam, $details); // make sure this group can be mapped @@ -433,7 +433,7 @@ public static function getProfileContact($gid) { $params['group'][$groupId] = 1; } else { - $params['group'] = array($groupId => 1); + $params['group'] = [$groupId => 1]; } } diff --git a/CRM/Profile/Page/MultipleRecordFieldsListing.php b/CRM/Profile/Page/MultipleRecordFieldsListing.php index 8b04c9462930..6d50d65b20a7 100644 --- a/CRM/Profile/Page/MultipleRecordFieldsListing.php +++ b/CRM/Profile/Page/MultipleRecordFieldsListing.php @@ -71,27 +71,27 @@ public function getBAOName() { public function &links() { if (!(self::$_links[$this->_pageViewType])) { // helper variable for nicer formatting - $links = array(); + $links = []; $view = array_search(CRM_Core_Action::VIEW, CRM_Core_Action::$_names); $update = array_search(CRM_Core_Action::UPDATE, CRM_Core_Action::$_names); $delete = array_search(CRM_Core_Action::DELETE, CRM_Core_Action::$_names); // names and titles - $links[CRM_Core_Action::VIEW] = array( + $links[CRM_Core_Action::VIEW] = [ 'name' => ts('View'), - 'title' => ts('View %1', array(1 => $this->_customGroupTitle . ' record')), - ); + 'title' => ts('View %1', [1 => $this->_customGroupTitle . ' record']), + ]; - $links[CRM_Core_Action::UPDATE] = array( + $links[CRM_Core_Action::UPDATE] = [ 'name' => ts('Edit'), - 'title' => ts('Edit %1', array(1 => $this->_customGroupTitle . ' record')), - ); + 'title' => ts('Edit %1', [1 => $this->_customGroupTitle . ' record']), + ]; - $links[CRM_Core_Action::DELETE] = array( + $links[CRM_Core_Action::DELETE] = [ 'name' => ts('Delete'), - 'title' => ts('Delete %1', array(1 => $this->_customGroupTitle . ' record')), - ); + 'title' => ts('Delete %1', [1 => $this->_customGroupTitle . ' record']), + ]; // urls and queryStrings if ($this->_pageViewType == 'profileDataView') { @@ -116,12 +116,12 @@ public function &links() { // NOTE : links for DELETE action for customDataView is handled in browse // copy action - $links[CRM_Core_Action::COPY] = array( + $links[CRM_Core_Action::COPY] = [ 'name' => ts('Copy'), - 'title' => ts('Copy %1', array(1 => $this->_customGroupTitle . ' record')), + 'title' => ts('Copy %1', [1 => $this->_customGroupTitle . ' record']), 'url' => 'civicrm/contact/view/cd/edit', 'qs' => 'reset=1&type=%%type%%&groupID=%%groupID%%&entityID=%%entityID%%&cgcount=%%newCgCount%%&multiRecordDisplay=single©ValueId=%%cgcount%%&mode=copy', - ); + ]; } self::$_links[$this->_pageViewType] = $links; @@ -168,7 +168,7 @@ public function run() { public function browse() { $dateFields = NULL; $newCgCount = $cgcount = 0; - $attributes = $result = $headerAttr = array(); + $attributes = $result = $headerAttr = []; $dateFieldsVals = NULL; if ($this->_pageViewType == 'profileDataView' && $this->_profileId) { $fields = CRM_Core_BAO_UFGroup::getFields($this->_profileId, FALSE, NULL, @@ -178,7 +178,7 @@ public function browse() { NULL, CRM_Core_Permission::EDIT ); - $multiRecordFields = array(); + $multiRecordFields = []; $fieldIDs = NULL; $result = NULL; $multiRecordFieldsWithSummaryListing = CRM_Core_BAO_UFGroup::shiftMultiRecordFields($fields, $multiRecordFields, TRUE); @@ -217,8 +217,8 @@ public function browse() { $this->_customGroupTitle = $groupDetail[$customGroupId]['title']; } if (!empty($fieldIDs) && $this->_contactId) { - $options = array(); - $returnProperities = array( + $options = []; + $returnProperities = [ 'html_type', 'data_type', 'date_format', @@ -226,11 +226,11 @@ public function browse() { 'default_value', 'is_required', 'is_view', - ); + ]; foreach ($fieldIDs as $key => $fieldID) { $fieldIDs[$key] = !is_numeric($fieldID) ? CRM_Core_BAO_CustomField::getKeyID($fieldID) : $fieldID; - $param = array('id' => $fieldIDs[$key]); - $returnValues = array(); + $param = ['id' => $fieldIDs[$key]]; + $returnValues = []; CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_CustomField', $param, $returnValues, $returnProperities); if ($returnValues['data_type'] == 'Date') { $dateFields[$fieldIDs[$key]] = 1; @@ -264,7 +264,7 @@ public function browse() { // commonly used for both views i.e profile listing view (profileDataView) and custom data listing view (customDataView) $result = CRM_Core_BAO_CustomValueTable::getEntityValues($this->_contactId, NULL, $fieldIDs, TRUE, $DTparams); $resultCount = !empty($result['count']) ? $result['count'] : count($result); - $sortedResult = !empty($result['sortedResult']) ? $result['sortedResult'] : array(); + $sortedResult = !empty($result['sortedResult']) ? $result['sortedResult'] : []; unset($result['count']); unset($result['sortedResult']); @@ -279,7 +279,7 @@ public function browse() { $nonListingFieldIds = array_keys($multiRecordFields); $singleField = CRM_Core_BAO_CustomField::getKeyID($nonListingFieldIds[0]); $fieldIdInput = $singleField; - $singleField = array($singleField); + $singleField = [$singleField]; $fieldInput = $singleField; } $customGroupInfo = CRM_Core_BAO_CustomGroup::getGroupTitles($fieldInput); @@ -339,7 +339,7 @@ public function browse() { // Set field attributes to support crmEditable // Note that $fieldAttributes[data-type] actually refers to the html type not the sql data type // TODO: Not all widget types and validation rules are supported by crmEditable so some fields will not be in-place editable - $fieldAttributes = array('class' => "crmf-custom_{$fieldId}_$recId"); + $fieldAttributes = ['class' => "crmf-custom_{$fieldId}_$recId"]; $editable = FALSE; if (!$options[$fieldId]['attributes']['is_view'] && $this->_pageViewType == 'customDataView' && $linkAction & CRM_Core_Action::UPDATE) { $spec = $options[$fieldId]['attributes']; @@ -347,7 +347,7 @@ public function browse() { case 'Text': // Other data types like money would require some extra validation // FIXME: crmEditable currently does not support any validation rules :( - $supportedDataTypes = array('Float', 'String', 'Int'); + $supportedDataTypes = ['Float', 'String', 'Int']; $editable = in_array($spec['data_type'], $supportedDataTypes); break; @@ -375,11 +375,11 @@ public function browse() { $op = NULL; if ($this->_pageViewType == 'profileDataView') { - $actionParams = array( + $actionParams = [ 'recordId' => $recId, 'gid' => $this->_profileId, 'id' => $this->_contactId, - ); + ]; $op = 'profile.multiValue.row'; } else { @@ -392,12 +392,12 @@ public function browse() { $actionParams['newCgCount'] = $newCgCount; // DELETE action links - $deleteData = array( + $deleteData = [ 'valueID' => $recId, 'groupID' => $this->_customGroupId, 'contactId' => $this->_contactId, 'key' => CRM_Core_Key::get('civicrm/ajax/customvalue'), - ); + ]; $links[CRM_Core_Action::DELETE]['url'] = '#'; $links[CRM_Core_Action::DELETE]['extra'] = ' data-delete_params="' . htmlspecialchars(json_encode($deleteData)) . '"'; $links[CRM_Core_Action::DELETE]['class'] = 'delete-custom-row'; @@ -423,9 +423,9 @@ public function browse() { } } - $headers = array(); + $headers = []; if (!empty($fieldIDs)) { - $fields = array('Radio', 'Select', 'Select Country', 'Select State/Province'); + $fields = ['Radio', 'Select', 'Select Country', 'Select State/Province']; foreach ($fieldIDs as $fieldID) { if ($this->_pageViewType == 'profileDataView') { $headers[$fieldID] = $customGroupInfo[$fieldID]['fieldLabel']; @@ -461,7 +461,7 @@ public function browse() { $this->assign('records', $result); $this->assign('attributes', $attributes); - return array($result, $attributes); + return [$result, $attributes]; } /** diff --git a/CRM/Profile/Page/Router.php b/CRM/Profile/Page/Router.php index 194afdd5a23b..668739537943 100644 --- a/CRM/Profile/Page/Router.php +++ b/CRM/Profile/Page/Router.php @@ -111,10 +111,10 @@ public function run($args = NULL) { $wrapper = new CRM_Utils_Wrapper(); return $wrapper->run('CRM_Profile_Form_Edit', ts('Create Profile'), - array( + [ 'mode' => CRM_Core_Action::ADD, 'ignoreKey' => $allowRemoteSubmit, - ) + ] ); } } diff --git a/CRM/Profile/Page/View.php b/CRM/Profile/Page/View.php index 772969bf7725..593d656d4110 100644 --- a/CRM/Profile/Page/View.php +++ b/CRM/Profile/Page/View.php @@ -72,7 +72,7 @@ public function preProcess() { $gids = explode(',', CRM_Utils_Request::retrieve('gid', 'String', CRM_Core_DAO::$_nullObject, FALSE, 0, 'GET')); - $profileIds = array(); + $profileIds = []; if (count($gids) > 1) { if (!empty($gids)) { foreach ($gids as $pfId) { @@ -95,7 +95,7 @@ public function preProcess() { $anyContent = TRUE; if ($this->_gid) { $page = new CRM_Profile_Page_Dynamic($this->_id, $this->_gid, 'Profile', FALSE, $profileIds); - $profileGroup = array(); + $profileGroup = []; $profileGroup['title'] = NULL; $profileGroup['content'] = $page->run(); if (empty($profileGroup['content'])) { @@ -130,10 +130,10 @@ public function preProcess() { else { $ufGroups = CRM_Core_BAO_UFGroup::getModuleUFGroup('Profile'); - $profileGroups = array(); + $profileGroups = []; foreach ($ufGroups as $groupid => $group) { $page = new CRM_Profile_Page_Dynamic($this->_id, $groupid, 'Profile', FALSE, $profileIds); - $profileGroup = array(); + $profileGroup = []; $profileGroup['title'] = $group['title']; $profileGroup['content'] = $page->run(); if (empty($profileGroup['content'])) { diff --git a/CRM/Profile/Selector/Listings.php b/CRM/Profile/Selector/Listings.php index 4ef71b13116e..4d5a2034de4b 100644 --- a/CRM/Profile/Selector/Listings.php +++ b/CRM/Profile/Selector/Listings.php @@ -120,7 +120,7 @@ class CRM_Profile_Selector_Listings extends CRM_Core_Selector_Base implements CR * Store profile ids if multiple profile ids are passed using comma separated. * Currently lets implement this functionality only for dialog mode */ - protected $_profileIds = array(); + protected $_profileIds = []; protected $_multiRecordTableName = NULL; @@ -151,7 +151,7 @@ public function __construct( $this->_gid = $ufGroupIds[0]; } else { - $this->_profileIds = array($ufGroupIds); + $this->_profileIds = [$ufGroupIds]; $this->_gid = $ufGroupIds; } @@ -172,7 +172,7 @@ public function __construct( $this->_params['group'][$groupId] = 1; } else { - $this->_params['group'] = array($groupId => 1); + $this->_params['group'] = [$groupId => 1]; } } @@ -211,7 +211,7 @@ public function __construct( */ public static function &links($map = FALSE, $editLink = FALSE, $ufLink = FALSE, $gids = NULL) { if (!self::$_links) { - self::$_links = array(); + self::$_links = []; $viewPermission = TRUE; if ($gids) { @@ -226,39 +226,39 @@ public static function &links($map = FALSE, $editLink = FALSE, $ufLink = FALSE, } if ($viewPermission) { - self::$_links[CRM_Core_Action::VIEW] = array( + self::$_links[CRM_Core_Action::VIEW] = [ 'name' => ts('View'), 'url' => 'civicrm/profile/view', 'qs' => 'reset=1&id=%%id%%&gid=%%gid%%', 'title' => ts('View Profile Details'), - ); + ]; } if ($editLink) { - self::$_links[CRM_Core_Action::UPDATE] = array( + self::$_links[CRM_Core_Action::UPDATE] = [ 'name' => ts('Edit'), 'url' => 'civicrm/profile/edit', 'qs' => 'reset=1&id=%%id%%&gid=%%gid%%', 'title' => ts('Edit'), - ); + ]; } if ($ufLink) { - self::$_links[CRM_Core_Action::PROFILE] = array( + self::$_links[CRM_Core_Action::PROFILE] = [ 'name' => ts('Website Profile'), 'url' => 'user/%%ufID%%', 'qs' => ' ', 'title' => ts('View Website Profile'), - ); + ]; } if ($map) { - self::$_links[CRM_Core_Action::MAP] = array( + self::$_links[CRM_Core_Action::MAP] = [ 'name' => ts('Map'), 'url' => 'civicrm/profile/map', 'qs' => 'reset=1&cid=%%id%%&gid=%%gid%%', 'title' => ts('Map'), - ); + ]; } } return self::$_links; @@ -293,20 +293,20 @@ public function getPagerParams($action, &$params) { * the column headers that need to be displayed */ public function &getColumnHeaders($action = NULL, $output = NULL) { - static $skipFields = array('group', 'tag'); - $multipleFields = array('url'); + static $skipFields = ['group', 'tag']; + $multipleFields = ['url']; $direction = CRM_Utils_Sort::ASCENDING; $empty = TRUE; if (!isset(self::$_columnHeaders)) { - self::$_columnHeaders = array( - array('name' => ''), - array( + self::$_columnHeaders = [ + ['name' => ''], + [ 'name' => ts('Name'), 'sort' => 'sort_name', 'direction' => CRM_Utils_Sort::ASCENDING, 'field_name' => 'sort_name', - ), - ); + ], + ]; $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'); @@ -334,11 +334,11 @@ public function &getColumnHeaders($action = NULL, $output = NULL) { $locationTypeName = $locationTypes[$lType]; } - if (in_array($fieldName, array( + if (in_array($fieldName, [ 'phone', 'im', 'email', - ))) { + ])) { if ($type) { $name = "`$locationTypeName-$fieldName-$type`"; } @@ -355,12 +355,12 @@ public function &getColumnHeaders($action = NULL, $output = NULL) { } } - self::$_columnHeaders[] = array( + self::$_columnHeaders[] = [ 'name' => $field['title'], 'sort' => $name, 'direction' => $direction, 'field_name' => CRM_Core_BAO_UFField::isValidFieldName($name) ? $name : $fieldName, - ); + ]; $direction = CRM_Utils_Sort::DONTCARE; $empty = FALSE; @@ -370,10 +370,10 @@ public function &getColumnHeaders($action = NULL, $output = NULL) { // if we don't have any valid columns, don't add the implicit ones // this allows the template to check on emptiness of column headers if ($empty) { - self::$_columnHeaders = array(); + self::$_columnHeaders = []; } else { - self::$_columnHeaders[] = array('desc' => ts('Actions')); + self::$_columnHeaders[] = ['desc' => ts('Actions')]; } } return self::$_columnHeaders; @@ -443,11 +443,11 @@ public function getQill() { */ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL, $extraWhereClause = NULL) { - $multipleFields = array('url'); + $multipleFields = ['url']; //$sort object processing for location fields if ($sort) { $vars = $sort->_vars; - $varArray = array(); + $varArray = []; foreach ($vars as $key => $field) { $field = $vars[$key]; $fieldArray = explode('-', $field['name']); @@ -494,7 +494,7 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL, $ex } // process the result of the query - $rows = array(); + $rows = []; // check if edit is configured in profile settings if ($this->_gid) { @@ -502,7 +502,7 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL, $ex } //FIXME : make sure to handle delete separately. CRM-4418 - $mask = CRM_Core_Action::mask(array(CRM_Core_Permission::getPermission())); + $mask = CRM_Core_Action::mask([CRM_Core_Permission::getPermission()]); if ($editLink && ($mask & CRM_Core_Permission::EDIT)) { // do not allow edit for anon users in joomla frontend, CRM-4668 $config = CRM_Core_Config::singleton(); @@ -514,8 +514,8 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL, $ex $locationTypes = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id'); - $names = array(); - static $skipFields = array('group', 'tag'); + $names = []; + static $skipFields = ['group', 'tag']; foreach ($this->_fields as $key => $field) { // skip pseudo fields @@ -547,11 +547,11 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL, $ex continue; } $locationTypeName = str_replace(' ', '_', $locationTypeName); - if (in_array($fieldName, array( + if (in_array($fieldName, [ 'phone', 'im', 'email', - ))) { + ])) { if ($type) { $names[] = "{$locationTypeName}-{$fieldName}-{$type}"; } @@ -576,7 +576,7 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL, $ex } } - $multipleSelectFields = array('preferred_communication_method' => 1); + $multipleSelectFields = ['preferred_communication_method' => 1]; $multiRecordTableId = NULL; if ($this->_multiRecordTableName) { $multiRecordTableId = "{$this->_multiRecordTableName}_id"; @@ -593,7 +593,7 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL, $ex $i18n = CRM_Core_I18n::singleton(); $result->country = $i18n->translate($result->country); } - $row = array(); + $row = []; $empty = TRUE; $row[] = CRM_Contact_BAO_Contact_Utils::getImage($result->contact_sub_type ? $result->contact_sub_type : $result->contact_type, FALSE, @@ -634,8 +634,8 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL, $ex elseif ($multipleSelectFields && array_key_exists($name, $multipleSelectFields) ) { - $paramsNew = array($name => $result->$name); - $name = array($name => array('newName' => $name, 'groupName' => $name)); + $paramsNew = [$name => $result->$name]; + $name = [$name => ['newName' => $name, 'groupName' => $name]]; CRM_Core_OptionGroup::lookupValues($paramsNew, $name, FALSE); $row[] = $paramsNew[$key]; @@ -659,18 +659,18 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL, $ex $row[] = $result->$name; } } - elseif (in_array($name, array( + elseif (in_array($name, [ 'addressee', 'email_greeting', 'postal_greeting', - ))) { + ])) { $dname = $name . '_display'; $row[] = $result->$dname; } - elseif (in_array($name, array( + elseif (in_array($name, [ 'birth_date', 'deceased_date', - ))) { + ])) { $row[] = CRM_Utils_Date::customFormat($result->$name); } elseif (isset($result->$name)) { @@ -686,10 +686,10 @@ public function &getRows($action, $offset, $rowCount, $sort, $output = NULL, $ex } $newLinks = $links; - $params = array( + $params = [ 'id' => $result->contact_id, 'gid' => implode(',', $this->_profileIds), - ); + ]; // pass record id param to view url for multi record view if ($multiRecordTableId && $newLinks) { diff --git a/CRM/Queue/ErrorPolicy.php b/CRM/Queue/ErrorPolicy.php index fc8a08195b2e..f87c5df7738a 100644 --- a/CRM/Queue/ErrorPolicy.php +++ b/CRM/Queue/ErrorPolicy.php @@ -49,7 +49,7 @@ class CRM_Queue_ErrorPolicy { * PHP error level to capture (e.g. E_PARSE|E_USER_ERROR). */ public function __construct($level = NULL) { - register_shutdown_function(array($this, 'onShutdown')); + register_shutdown_function([$this, 'onShutdown']); if ($level === NULL) { $level = E_ERROR | E_PARSE | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR; } @@ -61,16 +61,16 @@ public function __construct($level = NULL) { */ public function activate() { $this->active = TRUE; - $this->backup = array(); - foreach (array( + $this->backup = []; + foreach ([ 'display_errors', 'html_errors', 'xmlrpc_errors', - ) as $key) { + ] as $key) { $this->backup[$key] = ini_get($key); ini_set($key, 0); } - set_error_handler(array($this, 'onError'), $this->level); + set_error_handler([$this, 'onError'], $this->level); // FIXME make this temporary/reversible $this->errorScope = CRM_Core_TemporaryErrorScope::useException(); } @@ -81,11 +81,11 @@ public function activate() { public function deactivate() { $this->errorScope = NULL; restore_error_handler(); - foreach (array( + foreach ([ 'display_errors', 'html_errors', 'xmlrpc_errors', - ) as $key) { + ] as $key) { ini_set($key, $this->backup[$key]); } $this->active = FALSE; @@ -155,11 +155,11 @@ public function onShutdown() { * The PHP error (with "type", "message", etc). */ public function reportError($error) { - $response = array( + $response = [ 'is_error' => 1, 'is_continue' => 0, 'exception' => htmlentities(sprintf('Error %s: %s in %s, line %s', $error['type'], $error['message'], $error['file'], $error['line'])), - ); + ]; global $activeQueueRunner; if (is_object($activeQueueRunner)) { $response['last_task_title'] = $activeQueueRunner->lastTaskTitle; @@ -178,10 +178,10 @@ public function reportError($error) { public function reportException(Exception $e) { CRM_Core_Error::debug_var('CRM_Queue_ErrorPolicy_reportException', CRM_Core_Error::formatTextException($e)); - $response = array( + $response = [ 'is_error' => 1, 'is_continue' => 0, - ); + ]; $config = CRM_Core_Config::singleton(); if ($config->backtrace || CRM_Core_Config::isUpgradeMode()) { diff --git a/CRM/Queue/Menu.php b/CRM/Queue/Menu.php index 684313e50a73..43671437fac8 100644 --- a/CRM/Queue/Menu.php +++ b/CRM/Queue/Menu.php @@ -56,31 +56,31 @@ public static function alter($path, &$menuPath) { $menuPath['title'] = 'Queue Runner'; $menuPath['page_callback'] = 'CRM_Queue_Page_Runner'; $menuPath['access_arguments'][0][] = 'access CiviCRM'; - $menuPath['access_callback'] = array('CRM_Core_Permission', 'checkMenu'); + $menuPath['access_callback'] = ['CRM_Core_Permission', 'checkMenu']; break; case 'civicrm/queue/ajax/runNext': case 'civicrm/upgrade/queue/ajax/runNext': $menuPath['path'] = $path; - $menuPath['page_callback'] = array('CRM_Queue_Page_AJAX', 'runNext'); + $menuPath['page_callback'] = ['CRM_Queue_Page_AJAX', 'runNext']; $menuPath['access_arguments'][0][] = 'access CiviCRM'; - $menuPath['access_callback'] = array('CRM_Core_Permission', 'checkMenu'); + $menuPath['access_callback'] = ['CRM_Core_Permission', 'checkMenu']; break; case 'civicrm/queue/ajax/skipNext': case 'civicrm/upgrade/queue/ajax/skipNext': $menuPath['path'] = $path; - $menuPath['page_callback'] = array('CRM_Queue_Page_AJAX', 'skipNext'); + $menuPath['page_callback'] = ['CRM_Queue_Page_AJAX', 'skipNext']; $menuPath['access_arguments'][0][] = 'access CiviCRM'; - $menuPath['access_callback'] = array('CRM_Core_Permission', 'checkMenu'); + $menuPath['access_callback'] = ['CRM_Core_Permission', 'checkMenu']; break; case 'civicrm/queue/ajax/onEnd': case 'civicrm/upgrade/queue/ajax/onEnd': $menuPath['path'] = $path; - $menuPath['page_callback'] = array('CRM_Queue_Page_AJAX', 'onEnd'); + $menuPath['page_callback'] = ['CRM_Queue_Page_AJAX', 'onEnd']; $menuPath['access_arguments'][0][] = 'access CiviCRM'; - $menuPath['access_callback'] = array('CRM_Core_Permission', 'checkMenu'); + $menuPath['access_callback'] = ['CRM_Core_Permission', 'checkMenu']; break; default: diff --git a/CRM/Queue/Page/Runner.php b/CRM/Queue/Page/Runner.php index 20d3893182ea..eeffd9fc6efb 100644 --- a/CRM/Queue/Page/Runner.php +++ b/CRM/Queue/Page/Runner.php @@ -56,7 +56,7 @@ public function run() { } CRM_Utils_System::setTitle($runner->title); - $this->assign('queueRunnerData', array( + $this->assign('queueRunnerData', [ 'qrid' => $runner->qrid, 'runNextAjax' => CRM_Utils_System::url($runner->pathPrefix . '/ajax/runNext', NULL, FALSE, NULL, FALSE), 'skipNextAjax' => CRM_Utils_System::url($runner->pathPrefix . '/ajax/skipNext', NULL, FALSE, NULL, FALSE), @@ -64,7 +64,7 @@ public function run() { 'completed' => 0, 'numberOfItems' => $runner->queue->numberOfItems(), 'buttons' => $runner->buttons, - )); + ]); if ($runner->isMinimal) { // Render page header diff --git a/CRM/Queue/Queue.php b/CRM/Queue/Queue.php index f9266a7e2bf9..d8c7df0848bd 100644 --- a/CRM/Queue/Queue.php +++ b/CRM/Queue/Queue.php @@ -99,7 +99,7 @@ public abstract function existsQueue(); * Queue-dependent options; for example, if this is a * priority-queue, then $options might specify the item's priority. */ - public abstract function createItem($data, $options = array()); + public abstract function createItem($data, $options = []); /** * Determine number of items remaining in the queue. diff --git a/CRM/Queue/Queue/Memory.php b/CRM/Queue/Queue/Memory.php index 886638dc0b1b..0c840c1c366d 100644 --- a/CRM/Queue/Queue/Memory.php +++ b/CRM/Queue/Queue/Memory.php @@ -66,8 +66,8 @@ public function __construct($queueSpec) { * Perform any registation or resource-allocation for a new queue */ public function createQueue() { - $this->items = array(); - $this->releaseTimes = array(); + $this->items = []; + $this->releaseTimes = []; } /** @@ -104,7 +104,7 @@ public function existsQueue() { * Queue-dependent options; for example, if this is a * priority-queue, then $options might specify the item's priority. */ - public function createItem($data, $options = array()) { + public function createItem($data, $options = []) { $id = $this->nextQueueItemId++; // force copy, no unintendedsharing effects from pointers $this->items[$id] = serialize($data); diff --git a/CRM/Queue/Queue/Sql.php b/CRM/Queue/Queue/Sql.php index 056d2062f4fa..6be0e23aa275 100644 --- a/CRM/Queue/Queue/Sql.php +++ b/CRM/Queue/Queue/Sql.php @@ -69,9 +69,9 @@ public function deleteQueue() { return CRM_Core_DAO::singleValueQuery(" DELETE FROM civicrm_queue_item WHERE queue_name = %1 - ", array( - 1 => array($this->getName(), 'String'), - )); + ", [ + 1 => [$this->getName(), 'String'], + ]); } /** @@ -92,7 +92,7 @@ public function existsQueue() { * Queue-dependent options; for example, if this is a * priority-queue, then $options might specify the item's priority. */ - public function createItem($data, $options = array()) { + public function createItem($data, $options = []) { $dao = new CRM_Queue_DAO_QueueItem(); $dao->queue_name = $this->getName(); $dao->submit_time = CRM_Utils_Time::getTime('YmdHis'); @@ -111,9 +111,9 @@ public function numberOfItems() { SELECT count(*) FROM civicrm_queue_item WHERE queue_name = %1 - ", array( - 1 => array($this->getName(), 'String'), - )); + ", [ + 1 => [$this->getName(), 'String'], + ]); } /** @@ -133,9 +133,9 @@ public function claimItem($lease_time = 3600) { ORDER BY weight ASC, id ASC LIMIT 1 "; - $params = array( - 1 => array($this->getName(), 'String'), - ); + $params = [ + 1 => [$this->getName(), 'String'], + ]; $dao = CRM_Core_DAO::executeQuery($sql, $params, TRUE, 'CRM_Queue_DAO_QueueItem'); if (is_a($dao, 'DB_Error')) { // FIXME - Adding code to allow tests to pass @@ -145,10 +145,10 @@ public function claimItem($lease_time = 3600) { if ($dao->fetch()) { $nowEpoch = CRM_Utils_Time::getTimeRaw(); if ($dao->release_time === NULL || strtotime($dao->release_time) < $nowEpoch) { - CRM_Core_DAO::executeQuery("UPDATE civicrm_queue_item SET release_time = %1 WHERE id = %2", array( - '1' => array(date('YmdHis', $nowEpoch + $lease_time), 'String'), - '2' => array($dao->id, 'Integer'), - )); + CRM_Core_DAO::executeQuery("UPDATE civicrm_queue_item SET release_time = %1 WHERE id = %2", [ + '1' => [date('YmdHis', $nowEpoch + $lease_time), 'String'], + '2' => [$dao->id, 'Integer'], + ]); // work-around: inconsistent date-formatting causes unintentional breakage # $dao->submit_time = date('YmdHis', strtotime($dao->submit_time)); # $dao->release_time = date('YmdHis', $nowEpoch + $lease_time); @@ -176,16 +176,16 @@ public function stealItem($lease_time = 3600) { ORDER BY weight ASC, id ASC LIMIT 1 "; - $params = array( - 1 => array($this->getName(), 'String'), - ); + $params = [ + 1 => [$this->getName(), 'String'], + ]; $dao = CRM_Core_DAO::executeQuery($sql, $params, TRUE, 'CRM_Queue_DAO_QueueItem'); if ($dao->fetch()) { $nowEpoch = CRM_Utils_Time::getTimeRaw(); - CRM_Core_DAO::executeQuery("UPDATE civicrm_queue_item SET release_time = %1 WHERE id = %2", array( - '1' => array(date('YmdHis', $nowEpoch + $lease_time), 'String'), - '2' => array($dao->id, 'Integer'), - )); + CRM_Core_DAO::executeQuery("UPDATE civicrm_queue_item SET release_time = %1 WHERE id = %2", [ + '1' => [date('YmdHis', $nowEpoch + $lease_time), 'String'], + '2' => [$dao->id, 'Integer'], + ]); $dao->data = unserialize($dao->data); return $dao; } @@ -210,9 +210,9 @@ public function deleteItem($dao) { */ public function releaseItem($dao) { $sql = "UPDATE civicrm_queue_item SET release_time = NULL WHERE id = %1"; - $params = array( - 1 => array($dao->id, 'Integer'), - ); + $params = [ + 1 => [$dao->id, 'Integer'], + ]; CRM_Core_DAO::executeQuery($sql, $params); $dao->free(); } diff --git a/CRM/Queue/Runner.php b/CRM/Queue/Runner.php index 3015e36336ea..837a77f8d882 100644 --- a/CRM/Queue/Runner.php +++ b/CRM/Queue/Runner.php @@ -112,7 +112,7 @@ public function __construct($runnerSpec) { $this->onEnd = CRM_Utils_Array::value('onEnd', $runnerSpec, NULL); $this->onEndUrl = CRM_Utils_Array::value('onEndUrl', $runnerSpec, NULL); $this->pathPrefix = CRM_Utils_Array::value('pathPrefix', $runnerSpec, 'civicrm/queue'); - $this->buttons = CRM_Utils_Array::value('buttons', $runnerSpec, array('retry' => TRUE, 'skip' => TRUE)); + $this->buttons = CRM_Utils_Array::value('buttons', $runnerSpec, ['retry' => TRUE, 'skip' => TRUE]); // perhaps this value should be randomized? $this->qrid = $this->queue->getName(); } @@ -122,7 +122,7 @@ public function __construct($runnerSpec) { */ public function __sleep() { // exclude taskCtx - return array( + return [ 'title', 'queue', 'errorMode', @@ -132,7 +132,7 @@ public function __sleep() { 'pathPrefix', 'qrid', 'buttons', - ); + ]; } /** @@ -300,7 +300,7 @@ public function handleEnd() { } // Fallback; web UI does redirect in Javascript - $result = array(); + $result = []; $result['is_error'] = 0; $result['numberOfItems'] = 0; $result['is_continue'] = 0; @@ -324,7 +324,7 @@ public function handleEnd() { public function formatTaskResult($isOK, $exception = NULL) { $numberOfItems = $this->queue->numberOfItems(); - $result = array(); + $result = []; $result['is_error'] = $isOK ? 0 : 1; $result['exception'] = $exception; $result['last_task_title'] = isset($this->lastTaskTitle) ? $this->lastTaskTitle : ''; diff --git a/CRM/Queue/Service.php b/CRM/Queue/Service.php index d49c64f8541e..abb0738f850f 100644 --- a/CRM/Queue/Service.php +++ b/CRM/Queue/Service.php @@ -77,7 +77,7 @@ public static function &singleton($forceNew = FALSE) { /** */ public function __construct() { - $this->queues = array(); + $this->queues = []; } /** diff --git a/CRM/Report/BAO/Hook.php b/CRM/Report/BAO/Hook.php index 4521d65d1a9d..06e1c6421098 100644 --- a/CRM/Report/BAO/Hook.php +++ b/CRM/Report/BAO/Hook.php @@ -65,7 +65,7 @@ public static function singleton() { */ public function getSearchQueryObjects() { if ($this->_queryObjects === NULL) { - $this->_queryObjects = array(); + $this->_queryObjects = []; CRM_Utils_Hook::queryObjects($this->_queryObjects, 'Report'); } return $this->_queryObjects; @@ -98,7 +98,7 @@ public function logDiffClause(&$reportObj, $table) { $contactIdClause .= $cidClause; } } - return array($contactIdClause, $join); + return [$contactIdClause, $join]; } } diff --git a/CRM/Report/BAO/HookInterface.php b/CRM/Report/BAO/HookInterface.php index a581f657a311..3b8820c50dac 100644 --- a/CRM/Report/BAO/HookInterface.php +++ b/CRM/Report/BAO/HookInterface.php @@ -55,7 +55,7 @@ public function alterLogTables(&$reportObj, &$logTables) { * @return array */ public function logDiffClause(&$reportObj, $table) { - return array(); + return []; } } diff --git a/CRM/Report/BAO/ReportInstance.php b/CRM/Report/BAO/ReportInstance.php index abbbd67f5685..da56063bc76d 100644 --- a/CRM/Report/BAO/ReportInstance.php +++ b/CRM/Report/BAO/ReportInstance.php @@ -53,7 +53,7 @@ public static function add(&$params) { // convert roles array to string if (isset($params['grouprole']) && is_array($params['grouprole'])) { - $grouprole_array = array(); + $grouprole_array = []; foreach ($params['grouprole'] as $key => $value) { $grouprole_array[$value] = $value; } @@ -139,11 +139,11 @@ public static function &create(&$params) { // build navigation parameters if (!empty($params['is_navigation'])) { if (!array_key_exists('navigation', $params)) { - $params['navigation'] = array(); + $params['navigation'] = []; } $navigationParams =& $params['navigation']; - $navigationParams['permission'] = array(); + $navigationParams['permission'] = []; $navigationParams['label'] = $params['title']; $navigationParams['name'] = $params['title']; @@ -167,12 +167,12 @@ public static function &create(&$params) { } // add to dashboard - $dashletParams = array(); + $dashletParams = []; if (!empty($params['addToDashboard'])) { - $dashletParams = array( + $dashletParams = [ 'label' => $params['title'], 'is_active' => 1, - ); + ]; if ($permission = CRM_Utils_Array::value('permission', $params)) { $dashletParams['permission'][] = $permission; } @@ -363,43 +363,43 @@ public static function doFormDelete($instanceId, $bounceTo = 'civicrm/report/lis * - general script-add. */ public static function getActionMetadata() { - $actions = array(); + $actions = []; if (CRM_Core_Permission::check('save Report Criteria')) { - $actions['report_instance.save'] = array('title' => ts('Save')); - $actions['report_instance.copy'] = array( + $actions['report_instance.save'] = ['title' => ts('Save')]; + $actions['report_instance.copy'] = [ 'title' => ts('Save a Copy'), - 'data' => array( + 'data' => [ 'is_confirm' => TRUE, 'confirm_title' => ts('Save a copy...'), - 'confirm_refresh_fields' => json_encode(array( - 'title' => array( + 'confirm_refresh_fields' => json_encode([ + 'title' => [ 'selector' => '.crm-report-instanceForm-form-block-title', 'prepend' => ts('(Copy) '), - ), - 'description' => array( + ], + 'description' => [ 'selector' => '.crm-report-instanceForm-form-block-description', 'prepend' => '', - ), - 'parent_id' => array( + ], + 'parent_id' => [ 'selector' => '.crm-report-instanceForm-form-block-parent_id', 'prepend' => '', - ), - )), - ), - ); + ], + ]), + ], + ]; } - $actions['report_instance.print'] = array('title' => ts('Print Report')); - $actions['report_instance.pdf'] = array('title' => ts('Print to PDF')); - $actions['report_instance.csv'] = array('title' => ts('Export as CSV')); + $actions['report_instance.print'] = ['title' => ts('Print Report')]; + $actions['report_instance.pdf'] = ['title' => ts('Print to PDF')]; + $actions['report_instance.csv'] = ['title' => ts('Export as CSV')]; if (CRM_Core_Permission::check('administer Reports')) { - $actions['report_instance.delete'] = array( + $actions['report_instance.delete'] = [ 'title' => ts('Delete report'), - 'data' => array( + 'data' => [ 'is_confirm' => TRUE, 'confirm_message' => ts('Are you sure you want delete this report? This action cannot be undone.'), - ), - ); + ], + ]; } return $actions; } diff --git a/CRM/Report/Form.php b/CRM/Report/Form.php index 56e056fb3f4c..389e7769db2a 100644 --- a/CRM/Report/Form.php +++ b/CRM/Report/Form.php @@ -74,21 +74,21 @@ class CRM_Report_Form extends CRM_Core_Form { * * @var array */ - protected $_columns = array(); + protected $_columns = []; /** * The set of filters in the report * * @var array */ - protected $_filters = array(); + protected $_filters = []; /** * The set of optional columns in the report * * @var array */ - public $_options = array(); + public $_options = []; /** * By default most reports hide contact id. @@ -101,28 +101,28 @@ class CRM_Report_Form extends CRM_Core_Form { * * @var array */ - protected $_statFields = array(); + protected $_statFields = []; /** * Set of statistics data * * @var array */ - protected $_statistics = array(); + protected $_statistics = []; /** * List of fields not to be repeated during display * * @var array */ - protected $_noRepeats = array(); + protected $_noRepeats = []; /** * List of fields not to be displayed * * @var array */ - protected $_noDisplay = array(); + protected $_noDisplay = []; /** * Object type that a custom group extends @@ -130,7 +130,7 @@ class CRM_Report_Form extends CRM_Core_Form { * @var null */ protected $_customGroupExtends = NULL; - protected $_customGroupExtendsJoin = array(); + protected $_customGroupExtendsJoin = []; protected $_customGroupFilters = TRUE; protected $_customGroupGroupBy = FALSE; protected $_customGroupJoin = 'LEFT JOIN'; @@ -177,9 +177,9 @@ class CRM_Report_Form extends CRM_Core_Form { * * @var array */ - public $_navigation = array(); + public $_navigation = []; - public $_drilldownReport = array(); + public $_drilldownReport = []; /** * Array of tabs to display on report. @@ -194,7 +194,7 @@ class CRM_Report_Form extends CRM_Core_Form { * * @var array */ - protected $tabs = array(); + protected $tabs = []; /** * Should we add paging. @@ -212,12 +212,12 @@ class CRM_Report_Form extends CRM_Core_Form { * * @var array */ - protected $_fourColumnAttribute = array( + protected $_fourColumnAttribute = [ '', '', '', '', - ); + ]; protected $_force = 1; @@ -240,7 +240,7 @@ class CRM_Report_Form extends CRM_Core_Form { protected $_groups = NULL; protected $_grandFlag = FALSE; protected $_rowsFound = NULL; - protected $_selectAliases = array(); + protected $_selectAliases = []; protected $_rollup = NULL; /** @@ -253,7 +253,7 @@ class CRM_Report_Form extends CRM_Core_Form { /** * @var array */ - protected $_aliases = array(); + protected $_aliases = []; /** * @var string @@ -306,19 +306,19 @@ class CRM_Report_Form extends CRM_Core_Form { * * @var boolean */ - protected $_resultSet = array(); + protected $_resultSet = []; /** * To what frequency group-by a date column * * @var array */ - protected $_groupByDateFreq = array( + protected $_groupByDateFreq = [ 'MONTH' => 'Month', 'YEARWEEK' => 'Week', 'QUARTER' => 'Quarter', 'YEAR' => 'Year', - ); + ]; /** * Variables to hold the acl inner join and where clause @@ -333,7 +333,7 @@ class CRM_Report_Form extends CRM_Core_Form { * * @var array */ - protected $_selectedTables = array(); + protected $_selectedTables = []; /** * Array of DAO tables having columns included in WHERE or HAVING clause @@ -360,20 +360,20 @@ class CRM_Report_Form extends CRM_Core_Form { public $_having = NULL; public $_select = NULL; - public $_selectClauses = array(); - public $_columnHeaders = array(); + public $_selectClauses = []; + public $_columnHeaders = []; public $_orderBy = NULL; - public $_orderByFields = array(); - public $_orderByArray = array(); + public $_orderByFields = []; + public $_orderByArray = []; /** * Array of clauses to group by. * * @var array */ - protected $_groupByArray = array(); + protected $_groupByArray = []; public $_groupBy = NULL; - public $_whereClauses = array(); - public $_havingClauses = array(); + public $_whereClauses = []; + public $_havingClauses = []; /** * DashBoardRowCount Dashboard row count @@ -449,7 +449,7 @@ class CRM_Report_Form extends CRM_Core_Form { * * This allows us to access it from the stats function and avoid recalculating. */ - protected $rollupRow = array(); + protected $rollupRow = []; /** * @var string Database attributes - character set and collation @@ -514,11 +514,11 @@ public function __construct() { } if ($this->_exposeContactID) { if (array_key_exists('civicrm_contact', $this->_columns)) { - $this->_columns['civicrm_contact']['fields']['exposed_id'] = array( + $this->_columns['civicrm_contact']['fields']['exposed_id'] = [ 'name' => 'id', 'title' => ts('Contact ID'), 'no_repeat' => TRUE, - ); + ]; } } @@ -532,13 +532,13 @@ public function __construct() { // Get the custom groupIds for which the user has VIEW permission // If the user has 'access all custom data' permission, we'll leave $permCustomGroupIds empty // and addCustomDataToColumns() will allow access to all custom groups. - $permCustomGroupIds = array(); + $permCustomGroupIds = []; if (!CRM_Core_Permission::check('access all custom data')) { $permCustomGroupIds = CRM_ACL_API::group(CRM_Core_Permission::VIEW, NULL, 'civicrm_custom_group', $allGroups, NULL); // do not allow custom data for reports if user doesn't have // permission to access custom data. if (!empty($this->_customGroupExtends) && empty($permCustomGroupIds)) { - $this->_customGroupExtends = array(); + $this->_customGroupExtends = []; } } @@ -567,9 +567,9 @@ public function preProcessCommon() { $this->_section = CRM_Utils_Request::retrieve('section', 'Integer'); $this->assign('section', $this->_section); - CRM_Core_Region::instance('page-header')->add(array( + CRM_Core_Region::instance('page-header')->add([ 'markup' => sprintf('', htmlentities(get_class($this))), - )); + ]); if (!$this->noController) { $this->setID($this->get('instanceId')); @@ -587,8 +587,8 @@ public function preProcessCommon() { if ($this->_id) { $this->assign('instanceId', $this->_id); - $params = array('id' => $this->_id); - $this->_instanceValues = array(); + $params = ['id' => $this->_id]; + $this->_instanceValues = []; CRM_Core_DAO::commonRetrieve('CRM_Report_DAO_ReportInstance', $params, $this->_instanceValues @@ -620,10 +620,10 @@ public function preProcessCommon() { $this->_createNew = TRUE; $this->_params = $this->_formValues; $this->_params['view_mode'] = 'criteria'; - $this->_params['title'] = $this->getTitle() . ts(' (copy created by %1 on %2)', array( + $this->_params['title'] = $this->getTitle() . ts(' (copy created by %1 on %2)', [ CRM_Core_Session::singleton()->getLoggedInContactDisplayName(), CRM_Utils_Date::customFormat(date('Y-m-d H:i')), - )); + ]); // Do not pass go. Do not collect another chance to re-run the same query. CRM_Report_Form_Instance::postProcess($this); } @@ -632,7 +632,7 @@ public function preProcessCommon() { // Hey why not? see CRM-17225 for more about this. The use of reset to be force is historical for reasons stated // in the comment line above these 2. if (!empty($_REQUEST['reset']) - && !in_array(CRM_Utils_Request::retrieve('output', 'String'), array('save', 'criteria'))) { + && !in_array(CRM_Utils_Request::retrieve('output', 'String'), ['save', 'criteria'])) { $this->_force = 1; } @@ -703,12 +703,12 @@ public function preProcessCommon() { */ public function addBreadCrumb() { $breadCrumbs - = array( - array( + = [ + [ 'title' => ts('Report Templates'), 'url' => CRM_Utils_System::url('civicrm/admin/report/template/list', 'reset=1'), - ), - ); + ], + ]; CRM_Utils_System::appendBreadCrumb($breadCrumbs); } @@ -728,7 +728,7 @@ public function preProcess() { foreach ($this->_columns as $tableName => $table) { $this->setTableAlias($table, $tableName); - $expFields = array(); + $expFields = []; // higher preference to bao object $daoOrBaoName = CRM_Utils_Array::value('bao', $table, CRM_Utils_Array::value('dao', $table)); @@ -741,9 +741,9 @@ public function preProcess() { } } - $doNotCopy = array('required', 'default'); + $doNotCopy = ['required', 'default']; - $fieldGroups = array('fields', 'filters', 'group_bys', 'order_bys'); + $fieldGroups = ['fields', 'filters', 'group_bys', 'order_bys']; foreach ($fieldGroups as $fieldGrp) { if (!empty($table[$fieldGrp]) && is_array($table[$fieldGrp])) { foreach ($table[$fieldGrp] as $fieldName => $field) { @@ -825,11 +825,11 @@ public function preProcess() { $this->_columns[$tableName][$fieldGrp][$fieldName]['operatorType'] = CRM_Report_Form::OP_SELECT; if (!array_key_exists('options', $this->_columns[$tableName][$fieldGrp][$fieldName])) { $this->_columns[$tableName][$fieldGrp][$fieldName]['options'] - = array( + = [ '' => ts('Any'), '0' => ts('No'), '1' => ts('Yes'), - ); + ]; } break; @@ -895,7 +895,7 @@ public function preProcess() { * @return array */ public function setDefaultValues($freeze = TRUE) { - $freezeGroup = array(); + $freezeGroup = []; // FIXME: generalizing form field naming conventions would reduce // Lots of lines below. @@ -984,18 +984,18 @@ public function setDefaultValues($freeze = TRUE) { is_array($table['order_bys'])) ) { if (!array_key_exists('order_bys', $this->_defaults)) { - $this->_defaults['order_bys'] = array(); + $this->_defaults['order_bys'] = []; } foreach ($table['order_bys'] as $fieldName => $field) { if (!empty($field['default']) || !empty($field['default_order']) || CRM_Utils_Array::value('default_is_section', $field) || !empty($field['default_weight']) ) { - $order_by = array( + $order_by = [ 'column' => $fieldName, 'order' => CRM_Utils_Array::value('default_order', $field, 'ASC'), 'section' => CRM_Utils_Array::value('default_is_section', $field, 0), - ); + ]; if (!empty($field['default_weight'])) { $this->_defaults['order_bys'][(int) $field['default_weight']] = $order_by; @@ -1179,14 +1179,14 @@ public function createTemporaryTable($identifier, $sql, $isColumns = FALSE, $isM * Add columns to report. */ public function addColumns() { - $options = array(); + $options = []; $colGroups = NULL; foreach ($this->_columns as $tableName => $table) { if (array_key_exists('fields', $table)) { foreach ($table['fields'] as $fieldName => $field) { $groupTitle = ''; if (empty($field['no_display'])) { - foreach (array('table', 'field') as $var) { + foreach (['table', 'field'] as $var) { if (!empty(${$var}['grouping'])) { if (!is_array(${$var}['grouping'])) { $tableName = ${$var}['grouping']; @@ -1222,11 +1222,11 @@ public function addColumns() { NULL, NULL, NULL, $this->_fourColumnAttribute, TRUE ); if (!empty($colGroups)) { - $this->tabs['FieldSelection'] = array( + $this->tabs['FieldSelection'] = [ 'title' => ts('Columns'), 'tpl' => 'FieldSelection', 'div_label' => 'col-groups', - ); + ]; // Note this assignment is only really required in buildForm. It is being 'over-called' // to reduce risk of being missed due to overridden functions. @@ -1240,7 +1240,7 @@ public function addColumns() { * Add filters to report. */ public function addFilters() { - $filters = $filterGroups = array(); + $filters = $filterGroups = []; $count = 1; foreach ($this->_filters as $table => $attributes) { @@ -1248,11 +1248,11 @@ public function addFilters() { // The presence of 'group_title' is secret code for 'is_a_custom_table' // which magically means to 'display in an accordian' // here we make this explicit. - $filterGroups[$table] = array( + $filterGroups[$table] = [ 'group_title' => $this->_columns[$table]['group_title'], 'use_accordian_for_field_selection' => TRUE, - ); + ]; } foreach ($attributes as $fieldName => $field) { // get ready with option value pair @@ -1270,7 +1270,7 @@ public function addFilters() { !is_array($field['options']) || empty($field['options']) ) { // If there's no option list for this filter, define one. - $field['options'] = array( + $field['options'] = [ 1 => ts('January'), 2 => ts('February'), 3 => ts('March'), @@ -1283,7 +1283,7 @@ public function addFilters() { 10 => ts('October'), 11 => ts('November'), 12 => ts('December'), - ); + ]; // Add this option list to this column _columns. This is // required so that filter statistics show properly. $this->_columns[$table]['filters'][$fieldName]['options'] = $field['options']; @@ -1301,19 +1301,19 @@ public function addFilters() { if ($fieldName == 'state_province_id' || $fieldName == 'county_id' ) { - $this->addChainSelect($fieldName . '_value', array( + $this->addChainSelect($fieldName . '_value', [ 'multiple' => TRUE, 'label' => NULL, 'class' => 'huge', - )); + ]); } else { - $this->addElement('select', "{$fieldName}_value", NULL, $field['options'], array( + $this->addElement('select', "{$fieldName}_value", NULL, $field['options'], [ 'style' => 'min-width:250px', 'class' => 'crm-select2 huge', 'multiple' => TRUE, 'placeholder' => ts('- select -'), - )); + ]); } } break; @@ -1353,20 +1353,20 @@ public function addFilters() { default: // default type is string $this->addElement('select', "{$fieldName}_op", ts('Operator:'), $operations, - array('onchange' => "return showHideMaxMinVal( '$fieldName', this.value );") + ['onchange' => "return showHideMaxMinVal( '$fieldName', this.value );"] ); // we need text box for value input - $this->add('text', "{$fieldName}_value", NULL, array('class' => 'huge')); + $this->add('text', "{$fieldName}_value", NULL, ['class' => 'huge']); break; } } } if (!empty($filters)) { - $this->tabs['Filters'] = array( + $this->tabs['Filters'] = [ 'title' => ts('Filters'), 'tpl' => 'Filters', 'div_label' => 'set-filters', - ); + ]; } $this->assign('filters', $filters); $this->assign('filterGroups', $filterGroups); @@ -1384,13 +1384,13 @@ public function addFilters() { * - Filters */ protected function assignTabs() { - $order = array( + $order = [ 'FieldSelection', 'GroupBy', 'OrderBy', 'ReportOptions', 'Filters', - ); + ]; $order = array_intersect_key(array_fill_keys($order, 1), $this->tabs); $order = array_merge($order, $this->tabs); $this->assign('tabs', $order); @@ -1407,23 +1407,23 @@ public function addToDeveloperTab($sql) { if (!CRM_Core_Permission::check('view report sql')) { return; } - $ignored_output_modes = array('pdf', 'csv', 'print'); + $ignored_output_modes = ['pdf', 'csv', 'print']; if (in_array($this->_outputMode, $ignored_output_modes)) { return; } - $this->tabs['Developer'] = array( + $this->tabs['Developer'] = [ 'title' => ts('Developer'), 'tpl' => 'Developer', 'div_label' => 'set-developer', - ); + ]; $this->assignTabs(); $this->sqlArray[] = $sql; foreach ($this->sqlArray as $sql) { - foreach (array('LEFT JOIN') as $term) { + foreach (['LEFT JOIN'] as $term) { $sql = str_replace($term, '
    ' . $term, $sql); } - foreach (array('FROM', 'WHERE', 'GROUP BY', 'ORDER BY', 'LIMIT', ';') as $term) { + foreach (['FROM', 'WHERE', 'GROUP BY', 'ORDER BY', 'LIMIT', ';'] as $term) { $sql = str_replace($term, '

    ' . $term, $sql); } $this->sqlFormattedArray[] = $sql; @@ -1442,7 +1442,7 @@ public function addOptions() { // Once we clear with the format we can build elements based on type foreach ($this->_options as $fieldName => $field) { - $options = array(); + $options = []; if ($field['type'] == 'select') { $this->addElement('select', "{$fieldName}", $field['title'], $field['options']); @@ -1460,11 +1460,11 @@ public function addOptions() { (!$this->_id || ($this->_id && CRM_Report_BAO_ReportInstance::contactCanAdministerReport($this->_id))) ) { - $this->tabs['ReportOptions'] = array( + $this->tabs['ReportOptions'] = [ 'title' => ts('Display Options'), 'tpl' => 'ReportOptions', 'div_label' => 'other-options', - ); + ]; } $this->assign('otherOptions', $this->_options); } @@ -1484,7 +1484,7 @@ public function addChartOptions() { * Add group by options to the report. */ public function addGroupBys() { - $options = $freqElements = array(); + $options = $freqElements = []; foreach ($this->_columns as $tableName => $table) { if (array_key_exists('group_bys', $table)) { @@ -1503,11 +1503,11 @@ public function addGroupBys() { ); $this->assign('groupByElements', $options); if (!empty($options)) { - $this->tabs['GroupBy'] = array( + $this->tabs['GroupBy'] = [ 'title' => ts('Grouping'), 'tpl' => 'GroupBy', 'div_label' => 'group-by-elements', - ); + ]; } foreach ($freqElements as $name) { @@ -1521,7 +1521,7 @@ public function addGroupBys() { * Add data for order by tab. */ public function addOrderBys() { - $options = array(); + $options = []; foreach ($this->_columns as $tableName => $table) { // Report developer may define any column to order by; include these as order-by options. @@ -1551,25 +1551,25 @@ public function addOrderBys() { $this->assign('orderByOptions', $options); if (!empty($options)) { - $this->tabs['OrderBy'] = array( + $this->tabs['OrderBy'] = [ 'title' => ts('Sorting'), 'tpl' => 'OrderBy', 'div_label' => 'order-by-elements', - ); + ]; } if (!empty($options)) { - $options = array( + $options = [ '-' => ' - none - ', - ) + $options; + ] + $options; for ($i = 1; $i <= 5; $i++) { $this->addElement('select', "order_bys[{$i}][column]", ts('Order by Column'), $options); - $this->addElement('select', "order_bys[{$i}][order]", ts('Order by Order'), array( + $this->addElement('select', "order_bys[{$i}][order]", ts('Order by Order'), [ 'ASC' => ts('Ascending'), 'DESC' => ts('Descending'), - )); - $this->addElement('checkbox', "order_bys[{$i}][section]", ts('Order by Section'), FALSE, array('id' => "order_by_section_$i")); - $this->addElement('checkbox', "order_bys[{$i}][pageBreak]", ts('Page Break'), FALSE, array('id' => "order_by_pagebreak_$i")); + ]); + $this->addElement('checkbox', "order_bys[{$i}][section]", ts('Order by Section'), FALSE, ['id' => "order_by_section_$i"]); + $this->addElement('checkbox', "order_bys[{$i}][pageBreak]", ts('Page Break'), FALSE, ['id' => "order_by_pagebreak_$i"]); } } } @@ -1594,24 +1594,24 @@ public function buildInstanceAndButtons() { $this->_add2groupSupported ) { $this->addElement('select', 'groups', ts('Group'), - array('' => ts('Add Contacts to Group')) + + ['' => ts('Add Contacts to Group')] + CRM_Core_PseudoConstant::nestedGroup(), - array('class' => 'crm-select2 crm-action-menu fa-plus huge') + ['class' => 'crm-select2 crm-action-menu fa-plus huge'] ); $this->assign('group', TRUE); } - $this->addElement('submit', $this->_groupButtonName, '', array('style' => 'display: none;')); + $this->addElement('submit', $this->_groupButtonName, '', ['style' => 'display: none;']); $this->addChartOptions(); $showResultsLabel = $this->getResultsLabel(); - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'submit', 'name' => $showResultsLabel, 'isDefault' => TRUE, - ), - ) + ], + ] ); } @@ -1635,17 +1635,17 @@ public function resultsDisplayed() { protected function getActions($instanceId) { $actions = CRM_Report_BAO_ReportInstance::getActionMetadata(); if (empty($instanceId)) { - $actions['report_instance.save'] = array( + $actions['report_instance.save'] = [ 'title' => ts('Create Report'), - 'data' => array( + 'data' => [ 'is_confirm' => TRUE, 'confirm_title' => ts('Create Report'), - 'confirm_refresh_fields' => json_encode(array( - 'title' => array('selector' => '.crm-report-instanceForm-form-block-title', 'prepend' => ''), - 'description' => array('selector' => '.crm-report-instanceForm-form-block-description', 'prepend' => ''), - )), - ), - ); + 'confirm_refresh_fields' => json_encode([ + 'title' => ['selector' => '.crm-report-instanceForm-form-block-title', 'prepend' => ''], + 'description' => ['selector' => '.crm-report-instanceForm-form-block-description', 'prepend' => ''], + ]), + ], + ]; unset($actions['report_instance.delete']); } @@ -1673,11 +1673,11 @@ public function buildQuickForm() { $this->buildInstanceAndButtons(); // Add form rule for report. - if (is_callable(array( + if (is_callable([ $this, 'formRule', - ))) { - $this->addFormRule(array(get_class($this), 'formRule'), $this); + ])) { + $this->addFormRule([get_class($this), 'formRule'], $this); } $this->assignTabs(); } @@ -1694,8 +1694,8 @@ public function buildQuickForm() { * * @return array */ - public function customDataFormRule($fields, $ignoreFields = array()) { - $errors = array(); + public function customDataFormRule($fields, $ignoreFields = []) { + $errors = []; if (!empty($this->_customGroupExtends) && $this->_customGroupGroupBy && !empty($fields['group_bys']) ) { @@ -1743,7 +1743,7 @@ public function getOperationPair($type = "string", $fieldName = NULL) { case CRM_Report_Form::OP_INT: case CRM_Report_Form::OP_FLOAT: - $result = array( + $result = [ 'lte' => ts('Is less than or equal to'), 'gte' => ts('Is greater than or equal to'), 'bw' => ts('Is between'), @@ -1754,45 +1754,45 @@ public function getOperationPair($type = "string", $fieldName = NULL) { 'nbw' => ts('Is not between'), 'nll' => ts('Is empty (Null)'), 'nnll' => ts('Is not empty (Null)'), - ); + ]; return $result; case CRM_Report_Form::OP_SELECT: - $result = array( + $result = [ 'eq' => ts('Is equal to'), - ); + ]; return $result; case CRM_Report_Form::OP_MONTH: case CRM_Report_Form::OP_MULTISELECT: case CRM_Report_Form::OP_ENTITYREF: - $result = array( + $result = [ 'in' => ts('Is one of'), 'notin' => ts('Is not one of'), - ); + ]; return $result; case CRM_Report_Form::OP_DATE: - $result = array( + $result = [ 'nll' => ts('Is empty (Null)'), 'nnll' => ts('Is not empty (Null)'), - ); + ]; return $result; case CRM_Report_Form::OP_MULTISELECT_SEPARATOR: // use this operator for the values, concatenated with separator. For e.g if // multiple options for a column is stored as ^A{val1}^A{val2}^A - $result = array( + $result = [ 'mhas' => ts('Is one of'), 'mnot' => ts('Is not one of'), - ); + ]; return $result; default: // type is string - $result = array( + $result = [ 'has' => ts('Contains'), 'sw' => ts('Starts with'), 'ew' => ts('Ends with'), @@ -1801,7 +1801,7 @@ public function getOperationPair($type = "string", $fieldName = NULL) { 'neq' => ts('Is not equal to'), 'nll' => ts('Is empty (Null)'), 'nnll' => ts('Is not empty (Null)'), - ); + ]; return $result; } } @@ -1812,19 +1812,19 @@ public function getOperationPair($type = "string", $fieldName = NULL) { public function buildTagFilter() { $contactTags = CRM_Core_BAO_Tag::getTags($this->_tagFilterTable); if (!empty($contactTags)) { - $this->_columns['civicrm_tag'] = array( + $this->_columns['civicrm_tag'] = [ 'dao' => 'CRM_Core_DAO_Tag', - 'filters' => array( - 'tagid' => array( + 'filters' => [ + 'tagid' => [ 'name' => 'tag_id', 'title' => ts('Tag'), 'type' => CRM_Utils_Type::T_INT, 'tag' => TRUE, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $contactTags, - ), - ), - ); + ], + ], + ]; } } @@ -1832,16 +1832,16 @@ public function buildTagFilter() { * Adds group filters to _columns (called from _Construct). */ public function buildGroupFilter() { - $this->_columns['civicrm_group']['filters'] = array( - 'gid' => array( + $this->_columns['civicrm_group']['filters'] = [ + 'gid' => [ 'name' => 'group_id', 'title' => ts('Group'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'group' => TRUE, 'options' => CRM_Core_PseudoConstant::nestedGroup(), - ), - ); + ], + ]; if (empty($this->_columns['civicrm_group']['dao'])) { $this->_columns['civicrm_group']['dao'] = 'CRM_Contact_DAO_GroupContact'; } @@ -1928,7 +1928,7 @@ public function whereClause(&$field, $op, $value, $min, $max) { if (($min !== NULL && strlen($min) > 0) || ($max !== NULL && strlen($max) > 0) ) { - $clauses = array(); + $clauses = []; if ($min) { $min = CRM_Utils_Type::escape($min, $type); if ($op == 'bw') { @@ -2130,7 +2130,7 @@ public function dateClause( $fieldName, $relative, $from, $to, $type = NULL, $fromTime = NULL, $toTime = NULL ) { - $clauses = array(); + $clauses = []; if (in_array($relative, array_keys($this->getOperationPair(CRM_Report_Form::OP_DATE)))) { $sqlOP = $this->getSQLOperator($relative); return "( {$fieldName} {$sqlOP} )"; @@ -2199,8 +2199,8 @@ public function alterCustomDataDisplay(&$rows) { return; } - $customFields = array(); - $customFieldIds = array(); + $customFields = []; + $customFieldIds = []; foreach ($this->_params['fields'] as $fieldAlias => $value) { if ($fieldId = CRM_Core_BAO_CustomField::getKeyID($fieldAlias)) { $customFieldIds[$fieldAlias] = $fieldId; @@ -2254,7 +2254,7 @@ public function removeDuplicates(&$rows) { if (empty($this->_noRepeats)) { return; } - $checkList = array(); + $checkList = []; foreach ($rows as $key => $list) { foreach ($list as $colName => $colVal) { @@ -2377,7 +2377,7 @@ public function formatDisplay(&$rows, $pager = TRUE) { $firstRow = reset($rows); if ($firstRow) { $selectedFields = array_keys($firstRow); - $alterFunctions = $alterMap = $alterSpecs = array(); + $alterFunctions = $alterMap = $alterSpecs = []; foreach ($this->_columns as $tableName => $table) { if (array_key_exists('metadata', $table)) { foreach ($table['metadata'] as $field => $specs) { @@ -2428,9 +2428,9 @@ public function formatDisplay(&$rows, $pager = TRUE) { protected function alterStateProvinceID($value, &$row, $selectedfield, $criteriaFieldName) { $url = CRM_Utils_System::url(CRM_Utils_System::currentPath(), "reset=1&force=1&{$criteriaFieldName}_op=in&{$criteriaFieldName}_value={$value}", $this->_absoluteUrl); $row[$selectedfield . '_link'] = $url; - $row[$selectedfield . '_hover'] = ts("%1 for this state.", array( + $row[$selectedfield . '_hover'] = ts("%1 for this state.", [ 1 => $value, - )); + ]); $states = CRM_Core_PseudoConstant::stateProvince($value, FALSE); if (!is_array($states)) { @@ -2449,9 +2449,9 @@ protected function alterStateProvinceID($value, &$row, $selectedfield, $criteria protected function alterCountryID($value, &$row, $selectedField, $criteriaFieldName) { $url = CRM_Utils_System::url(CRM_Utils_System::currentPath(), "reset=1&force=1&{$criteriaFieldName}_op=in&{$criteriaFieldName}_value={$value}", $this->_absoluteUrl); $row[$selectedField . '_link'] = $url; - $row[$selectedField . '_hover'] = ts("%1 for this country.", array( + $row[$selectedField . '_hover'] = ts("%1 for this country.", [ 1 => $value, - )); + ]); $countries = CRM_Core_PseudoConstant::country($value, FALSE); if (!is_array($countries)) { return $countries; @@ -2469,9 +2469,9 @@ protected function alterCountryID($value, &$row, $selectedField, $criteriaFieldN protected function alterCountyID($value, &$row, $selectedfield, $criteriaFieldName) { $url = CRM_Utils_System::url(CRM_Utils_System::currentPath(), "reset=1&force=1&{$criteriaFieldName}_op=in&{$criteriaFieldName}_value={$value}", $this->_absoluteUrl); $row[$selectedfield . '_link'] = $url; - $row[$selectedfield . '_hover'] = ts("%1 for this county.", array( + $row[$selectedfield . '_hover'] = ts("%1 for this county.", [ 1 => $value, - )); + ]); $counties = CRM_Core_PseudoConstant::county($value, FALSE); if (!is_array($counties)) { return $counties; @@ -2523,7 +2523,7 @@ protected function alterContactID($value, &$row, $fieldname) { * @return mixed */ protected function alterBoolean($value) { - $options = array(0 => '', 1 => ts('Yes')); + $options = [0 => '', 1 => ts('Yes')]; if (isset($options[$value])) { return $options[$value]; } @@ -2547,7 +2547,7 @@ public function buildChart(&$rows) { * Generate the SELECT clause and set class variable $_select. */ public function select() { - $select = $this->_selectAliases = array(); + $select = $this->_selectAliases = []; $this->storeGroupByArray(); foreach ($this->_columns as $tableName => $table) { @@ -2663,8 +2663,8 @@ public function select() { // just to make sure these values are transferred to rows. // since we 'll need them for calculation purpose, // e.g making subtotals look nicer or graphs - $this->_columnHeaders["{$tableName}_{$fieldName}_interval"] = array('no_display' => TRUE); - $this->_columnHeaders["{$tableName}_{$fieldName}_subtotal"] = array('no_display' => TRUE); + $this->_columnHeaders["{$tableName}_{$fieldName}_interval"] = ['no_display' => TRUE]; + $this->_columnHeaders["{$tableName}_{$fieldName}_subtotal"] = ['no_display' => TRUE]; } } } @@ -2673,7 +2673,7 @@ public function select() { if (empty($select)) { // CRM-21412 Do not give fatal error on report when no fields selected - $select = array(1); + $select = [1]; } $this->_selectClauses = $select; @@ -2919,7 +2919,7 @@ public function groupBy() { */ public function orderBy() { $this->_orderBy = ""; - $this->_sections = array(); + $this->_sections = []; $this->storeOrderByArray(); if (!empty($this->_orderByArray) && !$this->_rollup == 'WITH ROLLUP') { $this->_orderBy = "ORDER BY " . implode(', ', $this->_orderByArray); @@ -2935,7 +2935,7 @@ public function orderBy() { * the order by clause */ public function storeOrderByArray() { - $orderBys = array(); + $orderBys = []; if (!empty($this->_params['order_bys']) && is_array($this->_params['order_bys']) && @@ -2944,7 +2944,7 @@ public function storeOrderByArray() { // Process order_bys in user-specified order foreach ($this->_params['order_bys'] as $orderBy) { - $orderByField = array(); + $orderByField = []; foreach ($this->_columns as $tableName => $table) { if (array_key_exists('order_bys', $table)) { // For DAO columns defined in $this->_columns @@ -2952,7 +2952,7 @@ public function storeOrderByArray() { } elseif (array_key_exists('extends', $table)) { // For custom fields referenced in $this->_customGroupExtends - $fields = CRM_Utils_Array::value('fields', $table, array()); + $fields = CRM_Utils_Array::value('fields', $table, []); } else { continue; @@ -3014,7 +3014,7 @@ public function unselectedSectionColumns() { return array_diff_key($this->_sections, $this->getSelectColumns()); } else { - return array(); + return []; } } @@ -3034,7 +3034,7 @@ public function buildRows($sql, &$rows) { } CRM_Core_DAO::reenableFullGroupByMode(); if (!is_array($rows)) { - $rows = array(); + $rows = []; } // use this method to modify $this->_columnHeaders @@ -3043,7 +3043,7 @@ public function buildRows($sql, &$rows) { $unselectedSectionColumns = $this->unselectedSectionColumns(); while ($dao->fetch()) { - $row = array(); + $row = []; foreach ($this->_columnHeaders as $key => $value) { if (property_exists($dao, $key)) { $row[$key] = $dao->$key; @@ -3083,7 +3083,7 @@ public function sectionTotals() { // pull section aliases out of $this->_sections $sectionAliases = array_keys($this->_sections); - $ifnulls = array(); + $ifnulls = []; foreach (array_merge($sectionAliases, $this->_selectAliases) as $alias) { $ifnulls[] = "ifnull($alias, '') as $alias"; } @@ -3099,7 +3099,7 @@ public function sectionTotals() { implode(", ", $sectionAliases); // initialize array of total counts - $totals = array(); + $totals = []; $dao = CRM_Core_DAO::executeQuery($query); while ($dao->fetch()) { @@ -3109,7 +3109,7 @@ public function sectionTotals() { $row = $rows[0]; // add totals for all permutations of section values - $values = array(); + $values = []; $i = 1; $aliasCount = count($sectionAliases); foreach ($sectionAliases as $alias) { @@ -3168,7 +3168,7 @@ public function doTemplateAssignment(&$rows) { * @return array */ public function statistics(&$rows) { - $statistics = array(); + $statistics = []; $count = count($rows); // Why do we increment the count for rollup seems to artificially inflate the count. @@ -3194,16 +3194,16 @@ public function statistics(&$rows) { * @param int $count */ public function countStat(&$statistics, $count) { - $statistics['counts']['rowCount'] = array( + $statistics['counts']['rowCount'] = [ 'title' => ts('Row(s) Listed'), 'value' => $count, - ); + ]; if ($this->_rowsFound && ($this->_rowsFound > $count)) { - $statistics['counts']['rowsFound'] = array( + $statistics['counts']['rowsFound'] = [ 'title' => ts('Total Row(s)'), 'value' => $this->_rowsFound, - ); + ]; } } @@ -3226,10 +3226,10 @@ public function groupByStat(&$statistics) { } } } - $statistics['groups'][] = array( + $statistics['groups'][] = [ 'title' => ts('Grouping(s)'), 'value' => implode(' & ', $combinations), - ); + ]; } } @@ -3256,25 +3256,25 @@ public function filterStat(&$statistics) { CRM_Utils_Array::value("{$fieldName}_to_time", $this->_params) ); $from_time_format = !empty($this->_params["{$fieldName}_from_time"]) ? 'h' : 'd'; - $from = CRM_Utils_Date::customFormat($from, NULL, array($from_time_format)); + $from = CRM_Utils_Date::customFormat($from, NULL, [$from_time_format]); $to_time_format = !empty($this->_params["{$fieldName}_to_time"]) ? 'h' : 'd'; - $to = CRM_Utils_Date::customFormat($to, NULL, array($to_time_format)); + $to = CRM_Utils_Date::customFormat($to, NULL, [$to_time_format]); if ($from || $to) { - $statistics['filters'][] = array( + $statistics['filters'][] = [ 'title' => $field['title'], - 'value' => ts("Between %1 and %2", array(1 => $from, 2 => $to)), - ); + 'value' => ts("Between %1 and %2", [1 => $from, 2 => $to]), + ]; } elseif (in_array($rel = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params), array_keys($this->getOperationPair(CRM_Report_Form::OP_DATE)) )) { $pair = $this->getOperationPair(CRM_Report_Form::OP_DATE); - $statistics['filters'][] = array( + $statistics['filters'][] = [ 'title' => $field['title'], 'value' => $pair[$rel], - ); + ]; } } else { @@ -3288,15 +3288,15 @@ public function filterStat(&$statistics) { $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); - if (in_array($op, array('bw', 'nbw')) && ($min || $max)) { + if (in_array($op, ['bw', 'nbw']) && ($min || $max)) { $value = "{$pair[$op]} $min " . ts('and') . " $max"; } elseif ($val && CRM_Utils_Array::value('operatorType', $field) & self::OP_ENTITYREF) { $this->setEntityRefDefaults($field, $tableName); $result = civicrm_api3($field['attributes']['entity'], 'getlist', - array('id' => $val) + - CRM_Utils_Array::value('api', $field['attributes'], array())); - $values = array(); + ['id' => $val] + + CRM_Utils_Array::value('api', $field['attributes'], [])); + $values = []; foreach ($result['values'] as $v) { $values[] = $v['label']; } @@ -3306,7 +3306,7 @@ public function filterStat(&$statistics) { $value = $pair[$op]; } elseif (is_array($val) && (!empty($val))) { - $options = CRM_Utils_Array::value('options', $field, array()); + $options = CRM_Utils_Array::value('options', $field, []); foreach ($val as $key => $valIds) { if (isset($options[$valIds])) { $val[$key] = $options[$valIds]; @@ -3329,10 +3329,10 @@ public function filterStat(&$statistics) { } } if ($value && empty($field['no_display'])) { - $statistics['filters'][] = array( + $statistics['filters'][] = [ 'title' => CRM_Utils_Array::value('title', $field), 'value' => $value, - ); + ]; } } } @@ -3363,7 +3363,7 @@ public function endPostProcess(&$rows = NULL) { if ($this->_sendmail) { $config = CRM_Core_Config::singleton(); - $attachments = array(); + $attachments = []; if ($this->_outputMode == 'csv') { $content @@ -3376,11 +3376,11 @@ public function endPostProcess(&$rows = NULL) { CRM_Utils_File::makeFileName('CiviReport.csv'); $csvContent = CRM_Report_Utils_Report::makeCsv($this, $rows); file_put_contents($csvFullFilename, $csvContent); - $attachments[] = array( + $attachments[] = [ 'fullPath' => $csvFullFilename, 'mime_type' => 'text/csv', 'cleanName' => 'CiviReport.csv', - ); + ]; } if ($this->_outputMode == 'pdf') { // generate PDF content @@ -3388,7 +3388,7 @@ public function endPostProcess(&$rows = NULL) { CRM_Utils_File::makeFileName('CiviReport.pdf'); file_put_contents($pdfFullFilename, CRM_Utils_PDF_Utils::html2pdf($content, "CiviReport.pdf", - TRUE, array('orientation' => 'landscape') + TRUE, ['orientation' => 'landscape'] ) ); // generate Email Content @@ -3398,11 +3398,11 @@ public function endPostProcess(&$rows = NULL) { ts('The report is attached as a PDF file.') . '

    ' . $this->_formValues['report_footer']; - $attachments[] = array( + $attachments[] = [ 'fullPath' => $pdfFullFilename, 'mime_type' => 'application/pdf', 'cleanName' => 'CiviReport.pdf', - ); + ]; } if (CRM_Report_Utils_Report::mailReport($content, $this->_id, @@ -3442,7 +3442,7 @@ public function endPostProcess(&$rows = NULL) { //delete the object imagedestroy($chart); } - CRM_Utils_PDF_Utils::html2pdf($content, "CiviReport.pdf", FALSE, array('orientation' => 'landscape')); + CRM_Utils_PDF_Utils::html2pdf($content, "CiviReport.pdf", FALSE, ['orientation' => 'landscape']); } CRM_Utils_System::civiExit(); } @@ -3523,7 +3523,7 @@ public function postProcess() { // build array of result based on column headers. This method also allows // modifying column headers before using it to build result set i.e $rows. - $rows = array(); + $rows = []; $this->buildRows($sql, $rows); // format result set. @@ -3576,7 +3576,7 @@ public function limit($rowCount = self::ROW_COUNT_LIMIT) { $rowCount = CRM_Utils_Type::escape($rowCount, 'Int'); $this->_limit = " LIMIT $offset, $rowCount"; - return array($offset, $rowCount); + return [$offset, $rowCount]; } if ($this->_limitValue) { if ($this->_offsetValue) { @@ -3604,13 +3604,13 @@ public function setPager($rowCount = self::ROW_COUNT_LIMIT) { $sql = "SELECT FOUND_ROWS();"; $this->_rowsFound = CRM_Core_DAO::singleValueQuery($sql); } - $params = array( + $params = [ 'total' => $this->_rowsFound, 'rowCount' => $rowCount, 'status' => ts('Records') . ' %%StatusMessage%%', 'buttonBottom' => 'PagerBottomButton', 'buttonTop' => 'PagerTopButton', - ); + ]; if (!empty($this->controller)) { // This happens when being called from the api Really we want the api to be able to // pass paging parameters, but at this stage just preventing test crashes. @@ -3643,7 +3643,7 @@ public function legacySlowGroupFilterClause($field, $value, $op) { $group = new CRM_Contact_DAO_Group(); $group->is_active = 1; $group->find(); - $smartGroups = array(); + $smartGroups = []; while ($group->fetch()) { if (in_array($group->id, (array) $this->_params['gid_value']) && $group->saved_search_id @@ -3665,7 +3665,7 @@ public function legacySlowGroupFilterClause($field, $value, $op) { $sqlOp = $this->getSQLOperator($op); if (!is_array($value)) { - $value = array($value); + $value = [$value]; } //include child groups if any $value = array_merge($value, CRM_Contact_BAO_Group::getChildGroupIds($value)); @@ -3715,12 +3715,12 @@ public function buildGroupTempTable() { } $filteredGroups = (array) $this->_params['gid_value']; - $groups = civicrm_api3('Group', 'get', array( + $groups = civicrm_api3('Group', 'get', [ 'is_active' => 1, - 'id' => array('IN' => $filteredGroups), - 'saved_search_id' => array('>' => 0), + 'id' => ['IN' => $filteredGroups], + 'saved_search_id' => ['>' => 0], 'return' => 'id', - )); + ]); $smartGroups = array_keys($groups['values']); $query = " @@ -3751,7 +3751,7 @@ public function buildGroupTempTable() { * * @return \CRM_Core_DAO|object */ - protected function executeReportQuery($query, $params = array()) { + protected function executeReportQuery($query, $params = []) { $this->addToDeveloperTab($query); return CRM_Core_DAO::executeQuery($query, $params); } @@ -3771,7 +3771,7 @@ public function whereTagClause($field, $value, $op) { // entries. $sqlOp = $this->getSQLOperator($op); if (!is_array($value)) { - $value = array($value); + $value = [$value]; } $clause = "{$field['dbAlias']} IN (" . implode(', ', $value) . ")"; $entity_table = $this->_tagFilterTable; @@ -3792,7 +3792,7 @@ public function whereTagClause($field, $value, $op) { public function whereMembershipOrgClause($value, $op) { $sqlOp = $this->getSQLOperator($op); if (!is_array($value)) { - $value = array($value); + $value = [$value]; } $tmp_membership_org_sql_list = implode(', ', $value); @@ -3820,7 +3820,7 @@ public function whereMembershipOrgClause($value, $op) { public function whereMembershipTypeClause($value, $op) { $sqlOp = $this->getSQLOperator($op); if (!is_array($value)) { - $value = array($value); + $value = [$value]; } $tmp_membership_sql_list = implode(', ', $value); @@ -3850,7 +3850,7 @@ public function buildACLClause($tableAlias = 'contact_a') { * Build the permision clause for all entities in this report */ public function buildPermissionClause() { - $ret = array(); + $ret = []; foreach ($this->selectedTables() as $tableName) { $baoName = str_replace('_DAO_', '_BAO_', CRM_Core_DAO_AllCoreTables::getClassForTable($tableName)); if ($baoName && class_exists($baoName) && !empty($this->_columns[$tableName]['alias'])) { @@ -3875,12 +3875,12 @@ public function buildPermissionClause() { * @param bool $addFields * @param array $permCustomGroupIds */ - public function addCustomDataToColumns($addFields = TRUE, $permCustomGroupIds = array()) { + public function addCustomDataToColumns($addFields = TRUE, $permCustomGroupIds = []) { if (empty($this->_customGroupExtends)) { return; } if (!is_array($this->_customGroupExtends)) { - $this->_customGroupExtends = array($this->_customGroupExtends); + $this->_customGroupExtends = [$this->_customGroupExtends]; } $customGroupWhere = ''; if (!empty($permCustomGroupIds)) { @@ -3904,7 +3904,7 @@ public function addCustomDataToColumns($addFields = TRUE, $permCustomGroupIds = while ($customDAO->fetch()) { if ($customDAO->table_name != $curTable) { $curTable = $customDAO->table_name; - $curFields = $curFilters = array(); + $curFields = $curFilters = []; // dummy dao object $this->_columns[$curTable]['dao'] = 'CRM_Contact_DAO_Contact'; @@ -3912,9 +3912,9 @@ public function addCustomDataToColumns($addFields = TRUE, $permCustomGroupIds = $this->_columns[$curTable]['grouping'] = $customDAO->table_name; $this->_columns[$curTable]['group_title'] = $customDAO->title; - foreach (array('fields', 'filters', 'group_bys') as $colKey) { + foreach (['fields', 'filters', 'group_bys'] as $colKey) { if (!array_key_exists($colKey, $this->_columns[$curTable])) { - $this->_columns[$curTable][$colKey] = array(); + $this->_columns[$curTable][$colKey] = []; } } } @@ -3922,21 +3922,21 @@ public function addCustomDataToColumns($addFields = TRUE, $permCustomGroupIds = if ($addFields) { // this makes aliasing work in favor - $curFields[$fieldName] = array( + $curFields[$fieldName] = [ 'name' => $customDAO->column_name, 'title' => $customDAO->label, 'dataType' => $customDAO->data_type, 'htmlType' => $customDAO->html_type, - ); + ]; } if ($this->_customGroupFilters) { // this makes aliasing work in favor - $curFilters[$fieldName] = array( + $curFilters[$fieldName] = [ 'name' => $customDAO->column_name, 'title' => $customDAO->label, 'dataType' => $customDAO->data_type, 'htmlType' => $customDAO->html_type, - ); + ]; } switch ($customDAO->data_type) { @@ -3952,7 +3952,7 @@ public function addCustomDataToColumns($addFields = TRUE, $permCustomGroupIds = case 'Boolean': $curFilters[$fieldName]['operatorType'] = CRM_Report_Form::OP_SELECT; - $curFilters[$fieldName]['options'] = array('' => ts('- select -')) + CRM_Core_PseudoConstant::get('CRM_Core_BAO_CustomField', 'custom_' . $customDAO->cf_id, array(), 'search'); + $curFilters[$fieldName]['options'] = ['' => ts('- select -')] + CRM_Core_PseudoConstant::get('CRM_Core_BAO_CustomField', 'custom_' . $customDAO->cf_id, [], 'search'); $curFilters[$fieldName]['type'] = CRM_Utils_Type::T_INT; break; @@ -3977,7 +3977,7 @@ public function addCustomDataToColumns($addFields = TRUE, $permCustomGroupIds = case 'Country': $curFilters[$fieldName]['type'] = CRM_Utils_Type::T_STRING; - $options = CRM_Core_PseudoConstant::get('CRM_Core_BAO_CustomField', 'custom_' . $customDAO->cf_id, array(), 'search'); + $options = CRM_Core_PseudoConstant::get('CRM_Core_BAO_CustomField', 'custom_' . $customDAO->cf_id, [], 'search'); if ((is_array($options) && count($options) != 0) || (!is_array($options) && $options !== FALSE)) { $curFilters[$fieldName]['operatorType'] = CRM_Core_BAO_CustomField::isSerialized($customDAO) ? CRM_Report_Form::OP_MULTISELECT_SEPARATOR : CRM_Report_Form::OP_MULTISELECT; $curFilters[$fieldName]['options'] = $options; @@ -4001,7 +4001,7 @@ public function addCustomDataToColumns($addFields = TRUE, $permCustomGroupIds = // CRM-19401 fix if ($customDAO->html_type == 'Select' && !array_key_exists('options', $curFilters[$fieldName])) { - $options = CRM_Core_PseudoConstant::get('CRM_Core_BAO_CustomField', 'custom_' . $customDAO->cf_id, array(), 'search'); + $options = CRM_Core_PseudoConstant::get('CRM_Core_BAO_CustomField', 'custom_' . $customDAO->cf_id, [], 'search'); if ($options !== FALSE) { $curFilters[$fieldName]['operatorType'] = CRM_Core_BAO_CustomField::isSerialized($customDAO) ? CRM_Report_Form::OP_MULTISELECT_SEPARATOR : CRM_Report_Form::OP_MULTISELECT; $curFilters[$fieldName]['options'] = $options; @@ -4009,7 +4009,7 @@ public function addCustomDataToColumns($addFields = TRUE, $permCustomGroupIds = } if (!array_key_exists('type', $curFields[$fieldName])) { - $curFields[$fieldName]['type'] = CRM_Utils_Array::value('type', $curFilters[$fieldName], array()); + $curFields[$fieldName]['type'] = CRM_Utils_Array::value('type', $curFilters[$fieldName], []); } if ($addFields) { @@ -4037,7 +4037,7 @@ public function customDataFrom($joinsForFiltersOnly = FALSE) { $mapper = CRM_Core_BAO_CustomQuery::$extendsMap; //CRM-18276 GROUP_CONCAT could be used with singleValueQuery and then exploded, //but by default that truncates to 1024 characters, which causes errors with installs with lots of custom field sets - $customTables = array(); + $customTables = []; $customTablesDAO = CRM_Core_DAO::executeQuery("SELECT table_name FROM civicrm_custom_group"); while ($customTablesDAO->fetch()) { $customTables[] = $customTablesDAO->table_name; @@ -4136,14 +4136,14 @@ public function isFieldSelected($prop) { protected function isFieldFiltered($prop) { if (!empty($prop['filters']) && $this->_customGroupFilters) { foreach ($prop['filters'] as $fieldAlias => $val) { - foreach (array( + foreach ([ 'value', 'min', 'max', 'relative', 'from', 'to', - ) as $attach) { + ] as $attach) { if (isset($this->_params[$fieldAlias . '_' . $attach]) && (!empty($this->_params[$fieldAlias . '_' . $attach]) || ($attach != 'relative' && @@ -4154,7 +4154,7 @@ protected function isFieldFiltered($prop) { } } if (!empty($this->_params[$fieldAlias . '_op']) && - in_array($this->_params[$fieldAlias . '_op'], array('nll', 'nnll')) + in_array($this->_params[$fieldAlias . '_op'], ['nll', 'nnll']) ) { return TRUE; } @@ -4200,7 +4200,7 @@ public function preProcessOrderBy(&$formValues) { $formValues['order_bys'] = $orderBys; } else { - $formValues['order_bys'] = array(1 => array('column' => '-')); + $formValues['order_bys'] = [1 => ['column' => '-']]; } // assign show/hide data to template @@ -4245,7 +4245,7 @@ public function isTableFiltered($tableName) { */ public function selectedTables() { if (!$this->_selectedTables) { - $orderByColumns = array(); + $orderByColumns = []; if (array_key_exists('order_bys', $this->_params) && is_array($this->_params['order_bys']) ) { @@ -4313,22 +4313,22 @@ public function addCampaignFields($entityTable = 'civicrm_contribution', $groupB if (!empty($getCampaigns['campaigns'])) { $this->campaigns = $getCampaigns['campaigns']; asort($this->campaigns); - $this->_columns[$entityTable]['fields']['campaign_id'] = array('title' => ts('Campaign'), 'default' => 'false'); + $this->_columns[$entityTable]['fields']['campaign_id'] = ['title' => ts('Campaign'), 'default' => 'false']; if ($filters) { - $this->_columns[$entityTable]['filters']['campaign_id'] = array( + $this->_columns[$entityTable]['filters']['campaign_id'] = [ 'title' => ts('Campaign'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->campaigns, 'type' => CRM_Utils_Type::T_INT, - ); + ]; } if ($groupBy) { - $this->_columns[$entityTable]['group_bys']['campaign_id'] = array('title' => ts('Campaign')); + $this->_columns[$entityTable]['group_bys']['campaign_id'] = ['title' => ts('Campaign')]; } if ($orderBy) { - $this->_columns[$entityTable]['order_bys']['campaign_id'] = array('title' => ts('Campaign')); + $this->_columns[$entityTable]['order_bys']['campaign_id'] = ['title' => ts('Campaign')]; } } } @@ -4352,8 +4352,8 @@ public function addCampaignFields($entityTable = 'civicrm_contribution', $groupB * @return array * address fields for construct clause */ - public function addAddressFields($groupBy = TRUE, $orderBy = FALSE, $filters = TRUE, $defaults = array('country_id' => TRUE)) { - $defaultAddressFields = array( + public function addAddressFields($groupBy = TRUE, $orderBy = FALSE, $filters = TRUE, $defaults = ['country_id' => TRUE]) { + $defaultAddressFields = [ 'street_address' => ts('Street Address'), 'supplemental_address_1' => ts('Supplementary Address Field 1'), 'supplemental_address_2' => ts('Supplementary Address Field 2'), @@ -4367,28 +4367,28 @@ public function addAddressFields($groupBy = TRUE, $orderBy = FALSE, $filters = T 'country_id' => ts('Country'), 'state_province_id' => ts('State/Province'), 'county_id' => ts('County'), - ); - $addressFields = array( - 'civicrm_address' => array( + ]; + $addressFields = [ + 'civicrm_address' => [ 'dao' => 'CRM_Core_DAO_Address', - 'fields' => array( - 'address_name' => array( + 'fields' => [ + 'address_name' => [ 'title' => ts('Address Name'), 'default' => CRM_Utils_Array::value('name', $defaults, FALSE), 'name' => 'name', - ), - ), + ], + ], 'grouping' => 'location-fields', - ), - ); + ], + ]; foreach ($defaultAddressFields as $fieldName => $fieldLabel) { - $addressFields['civicrm_address']['fields'][$fieldName] = array( + $addressFields['civicrm_address']['fields'][$fieldName] = [ 'title' => $fieldLabel, 'default' => CRM_Utils_Array::value($fieldName, $defaults, FALSE), - ); + ]; } - $street_address_filters = $general_address_filters = array(); + $street_address_filters = $general_address_filters = []; if ($filters) { // Address filter depends on whether street address parsing is enabled. // (CRM-18696) @@ -4396,91 +4396,91 @@ public function addAddressFields($groupBy = TRUE, $orderBy = FALSE, $filters = T 'address_options' ); if ($addressOptions['street_address_parsing']) { - $street_address_filters = array( - 'street_number' => array( + $street_address_filters = [ + 'street_number' => [ 'title' => ts('Street Number'), 'type' => CRM_Utils_Type::T_INT, 'name' => 'street_number', - ), - 'street_name' => array( + ], + 'street_name' => [ 'title' => ts('Street Name'), 'name' => 'street_name', 'type' => CRM_Utils_Type::T_STRING, - ), - ); + ], + ]; } else { - $street_address_filters = array( - 'street_address' => array( + $street_address_filters = [ + 'street_address' => [ 'title' => ts('Street Address'), 'type' => CRM_Utils_Type::T_STRING, 'name' => 'street_address', - ), - ); + ], + ]; } - $general_address_filters = array( - 'postal_code' => array( + $general_address_filters = [ + 'postal_code' => [ 'title' => ts('Postal Code'), 'type' => CRM_Utils_Type::T_STRING, 'name' => 'postal_code', - ), - 'city' => array( + ], + 'city' => [ 'title' => ts('City'), 'type' => CRM_Utils_Type::T_STRING, 'name' => 'city', - ), - 'country_id' => array( + ], + 'country_id' => [ 'name' => 'country_id', 'title' => ts('Country'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::country(), - ), - 'state_province_id' => array( + ], + 'state_province_id' => [ 'name' => 'state_province_id', 'title' => ts('State/Province'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => array(), - ), - 'county_id' => array( + 'options' => [], + ], + 'county_id' => [ 'name' => 'county_id', 'title' => ts('County'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => array(), - ), - ); + 'options' => [], + ], + ]; } $addressFields['civicrm_address']['filters'] = array_merge( $street_address_filters, $general_address_filters); if ($orderBy) { - $addressFields['civicrm_address']['order_bys'] = array( - 'street_name' => array('title' => ts('Street Name')), - 'street_number' => array('title' => ts('Odd / Even Street Number')), + $addressFields['civicrm_address']['order_bys'] = [ + 'street_name' => ['title' => ts('Street Name')], + 'street_number' => ['title' => ts('Odd / Even Street Number')], 'street_address' => NULL, 'city' => NULL, 'postal_code' => NULL, - ); + ]; } if ($groupBy) { - $addressFields['civicrm_address']['group_bys'] = array( + $addressFields['civicrm_address']['group_bys'] = [ 'street_address' => NULL, 'city' => NULL, 'postal_code' => NULL, - 'state_province_id' => array( + 'state_province_id' => [ 'title' => ts('State/Province'), - ), - 'country_id' => array( + ], + 'country_id' => [ 'title' => ts('Country'), - ), - 'county_id' => array( + ], + 'county_id' => [ 'title' => ts('County'), - ), - ); + ], + ]; } return $addressFields; } @@ -4502,11 +4502,11 @@ public function addAddressFields($groupBy = TRUE, $orderBy = FALSE, $filters = T public function alterDisplayAddressFields(&$row, &$rows, &$rowNum, $baseUrl, $linkText, $separator = ',') { $criteriaQueryParams = CRM_Report_Utils_Report::getPreviewCriteriaQueryParams($this->_defaults, $this->_params); $entryFound = FALSE; - $columnMap = array( + $columnMap = [ 'civicrm_address_country_id' => 'country', 'civicrm_address_county_id' => 'county', 'civicrm_address_state_province_id' => 'stateProvince', - ); + ]; foreach ($columnMap as $fieldName => $fnName) { if (array_key_exists($fieldName, $row)) { if ($values = $row[$fieldName]) { @@ -4527,7 +4527,7 @@ public function alterDisplayAddressFields(&$row, &$rows, &$rowNum, $baseUrl, $li ), $this->_absoluteUrl, $this->_id ); $rows[$rowNum]["{$fieldName}_link"] = $url; - $rows[$rowNum]["{$fieldName}_hover"] = ts("%1 for this %2.", array(1 => $linkText, 2 => $addressField)); + $rows[$rowNum]["{$fieldName}_hover"] = ts("%1 for this %2.", [1 => $linkText, 2 => $addressField]); } } $entryFound = TRUE; @@ -4552,12 +4552,12 @@ public function alterDisplayContactFields(&$row, &$rows, &$rowNum, $baseUrl, $li $entryFound = FALSE; // There is no reason not to add links for all fields but it seems a bit odd to be able to click on // 'Mrs'. Also, we don't have metadata about the title. So, add selectively to addLinks. - $addLinks = array('gender_id' => 'Gender'); - foreach (array('prefix_id', 'suffix_id', 'gender_id', 'contact_sub_type', 'preferred_language') as $fieldName) { + $addLinks = ['gender_id' => 'Gender']; + foreach (['prefix_id', 'suffix_id', 'gender_id', 'contact_sub_type', 'preferred_language'] as $fieldName) { if (array_key_exists('civicrm_contact_' . $fieldName, $row)) { if (($value = $row['civicrm_contact_' . $fieldName]) != FALSE) { $rowValues = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value); - $rowLabels = array(); + $rowLabels = []; foreach ($rowValues as $rowValue) { if ($rowValue) { $rowLabels[] = CRM_Core_PseudoConstant::getLabel('CRM_Contact_BAO_Contact', $fieldName, $rowValue); @@ -4571,9 +4571,9 @@ public function alterDisplayContactFields(&$row, &$rows, &$rowNum, $baseUrl, $li $entryFound = TRUE; } } - $yesNoFields = array( + $yesNoFields = [ 'do_not_email', 'is_deceased', 'do_not_phone', 'do_not_sms', 'do_not_mail', 'is_opt_out', - ); + ]; foreach ($yesNoFields as $fieldName) { if (array_key_exists('civicrm_contact_' . $fieldName, $row)) { // Since these are essentially 'negative fields' it feels like it @@ -4666,7 +4666,7 @@ public function addPhoneFromClause() { * @param array $extra Additional options. * Not currently used in core but may be used in override extensions. */ - protected function joinAddressFromContact($prefix = '', $extra = array()) { + protected function joinAddressFromContact($prefix = '', $extra = []) { $addressTables = ['civicrm_address', 'civicrm_country', 'civicrm_worldregion', 'civicrm_state_province']; $isJoinRequired = $this->_addressField; foreach ($addressTables as $addressTable) { @@ -4693,7 +4693,7 @@ protected function joinAddressFromContact($prefix = '', $extra = array()) { * @param array $extra Additional options. * Not currently used in core but may be used in override extensions. */ - protected function joinCountryFromAddress($prefix = '', $extra = array()) { + protected function joinCountryFromAddress($prefix = '', $extra = []) { // include country field if country column is to be included if ($this->isTableSelected($prefix . 'civicrm_country') || $this->isTableSelected($prefix . 'civicrm_worldregion')) { if (empty($this->_aliases[$prefix . 'civicrm_country'])) { @@ -4716,7 +4716,7 @@ protected function joinCountryFromAddress($prefix = '', $extra = array()) { * @param array $extra Additional options. * Not currently used in core but may be used in override extensions. */ - protected function joinPhoneFromContact($prefix = '', $extra = array()) { + protected function joinPhoneFromContact($prefix = '', $extra = []) { // include phone field if phone column is to be included if ($this->isTableSelected($prefix . 'civicrm_phone')) { $this->_from .= " @@ -4736,7 +4736,7 @@ protected function joinPhoneFromContact($prefix = '', $extra = array()) { * @param array $extra Additional options. * Not currently used in core but may be used in override extensions. */ - protected function joinEmailFromContact($prefix = '', $extra = array()) { + protected function joinEmailFromContact($prefix = '', $extra = []) { // include email field if email column is to be included if ($this->isTableSelected($prefix . 'civicrm_email')) { $this->_from .= " @@ -4770,25 +4770,25 @@ public function addFinancialTrxnFromClause() { * @return array * phone columns definition */ - public function getPhoneColumns($options = array()) { - $defaultOptions = array( + public function getPhoneColumns($options = []) { + $defaultOptions = [ 'prefix' => '', 'prefix_label' => '', - ); + ]; $options = array_merge($defaultOptions, $options); - $fields = array( - $options['prefix'] . 'civicrm_phone' => array( + $fields = [ + $options['prefix'] . 'civicrm_phone' => [ 'dao' => 'CRM_Core_DAO_Phone', - 'fields' => array( - $options['prefix'] . 'phone' => array( + 'fields' => [ + $options['prefix'] . 'phone' => [ 'title' => $options['prefix_label'] . ts('Phone'), 'name' => 'phone', - ), - ), - ), - ); + ], + ], + ], + ]; return $fields; } @@ -4798,73 +4798,73 @@ public function getPhoneColumns($options = array()) { * @return array */ public function getBasicContactFields() { - return array( - 'sort_name' => array( + return [ + 'sort_name' => [ 'title' => ts('Contact Name'), 'required' => TRUE, 'default' => TRUE, - ), - 'id' => array( + ], + 'id' => [ 'no_display' => TRUE, 'required' => TRUE, - ), - 'prefix_id' => array( + ], + 'prefix_id' => [ 'title' => ts('Contact Prefix'), - ), - 'first_name' => array( + ], + 'first_name' => [ 'title' => ts('First Name'), - ), - 'nick_name' => array( + ], + 'nick_name' => [ 'title' => ts('Nick Name'), - ), - 'middle_name' => array( + ], + 'middle_name' => [ 'title' => ts('Middle Name'), - ), - 'last_name' => array( + ], + 'last_name' => [ 'title' => ts('Last Name'), - ), - 'suffix_id' => array( + ], + 'suffix_id' => [ 'title' => ts('Contact Suffix'), - ), - 'postal_greeting_display' => array('title' => ts('Postal Greeting')), - 'email_greeting_display' => array('title' => ts('Email Greeting')), - 'addressee_display' => array('title' => ts('Addressee')), - 'contact_type' => array( + ], + 'postal_greeting_display' => ['title' => ts('Postal Greeting')], + 'email_greeting_display' => ['title' => ts('Email Greeting')], + 'addressee_display' => ['title' => ts('Addressee')], + 'contact_type' => [ 'title' => ts('Contact Type'), - ), - 'contact_sub_type' => array( + ], + 'contact_sub_type' => [ 'title' => ts('Contact Subtype'), - ), - 'gender_id' => array( + ], + 'gender_id' => [ 'title' => ts('Gender'), - ), - 'birth_date' => array( + ], + 'birth_date' => [ 'title' => ts('Birth Date'), - ), - 'age' => array( + ], + 'age' => [ 'title' => ts('Age'), 'dbAlias' => 'TIMESTAMPDIFF(YEAR, contact_civireport.birth_date, CURDATE())', - ), - 'job_title' => array( + ], + 'job_title' => [ 'title' => ts('Contact Job title'), - ), - 'organization_name' => array( + ], + 'organization_name' => [ 'title' => ts('Organization Name'), - ), - 'external_identifier' => array( + ], + 'external_identifier' => [ 'title' => ts('Contact identifier from external system'), - ), - 'do_not_email' => array(), - 'do_not_phone' => array(), - 'do_not_mail' => array(), - 'do_not_sms' => array(), - 'is_opt_out' => array(), - 'is_deceased' => array(), - 'preferred_language' => array(), - 'employer_id' => array( + ], + 'do_not_email' => [], + 'do_not_phone' => [], + 'do_not_mail' => [], + 'do_not_sms' => [], + 'is_opt_out' => [], + 'is_deceased' => [], + 'preferred_language' => [], + 'employer_id' => [ 'title' => ts('Current Employer'), - ), - ); + ], + ]; } /** @@ -4874,73 +4874,73 @@ public function getBasicContactFields() { * * @return array */ - public function getBasicContactFilters($defaults = array()) { - return array( - 'sort_name' => array( + public function getBasicContactFilters($defaults = []) { + return [ + 'sort_name' => [ 'title' => ts('Contact Name'), - ), - 'source' => array( + ], + 'source' => [ 'title' => ts('Contact Source'), 'type' => CRM_Utils_Type::T_STRING, - ), - 'id' => array( + ], + 'id' => [ 'title' => ts('Contact ID'), 'no_display' => TRUE, - ), - 'gender_id' => array( + ], + 'gender_id' => [ 'title' => ts('Gender'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id'), - ), - 'birth_date' => array( + ], + 'birth_date' => [ 'title' => ts('Birth Date'), 'operatorType' => CRM_Report_Form::OP_DATE, - ), - 'contact_type' => array( + ], + 'contact_type' => [ 'title' => ts('Contact Type'), - ), - 'contact_sub_type' => array( + ], + 'contact_sub_type' => [ 'title' => ts('Contact Subtype'), - ), - 'modified_date' => array( + ], + 'modified_date' => [ 'title' => ts('Contact Modified'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE, - ), - 'is_deceased' => array( + ], + 'is_deceased' => [ 'title' => ts('Deceased'), 'type' => CRM_Utils_Type::T_BOOLEAN, 'default' => CRM_Utils_Array::value('deceased', $defaults, 0), - ), - 'do_not_email' => array( + ], + 'do_not_email' => [ 'title' => ts('Do not email'), 'type' => CRM_Utils_Type::T_BOOLEAN, - ), - 'do_not_phone' => array( + ], + 'do_not_phone' => [ 'title' => ts('Do not phone'), 'type' => CRM_Utils_Type::T_BOOLEAN, - ), - 'do_not_mail' => array( + ], + 'do_not_mail' => [ 'title' => ts('Do not mail'), 'type' => CRM_Utils_Type::T_BOOLEAN, - ), - 'do_not_sms' => array( + ], + 'do_not_sms' => [ 'title' => ts('Do not SMS'), 'type' => CRM_Utils_Type::T_BOOLEAN, - ), - 'is_opt_out' => array( + ], + 'is_opt_out' => [ 'title' => ts('Do not bulk email'), 'type' => CRM_Utils_Type::T_BOOLEAN, - ), - 'preferred_language' => array( + ], + 'preferred_language' => [ 'title' => ts('Preferred Language'), - ), - 'is_deleted' => array( + ], + 'is_deleted' => [ 'no_display' => TRUE, 'default' => 0, 'type' => CRM_Utils_Type::T_BOOLEAN, - ), - ); + ], + ]; } /** @@ -4956,7 +4956,7 @@ public function add2group($groupID) { $sql = str_replace('WITH ROLLUP', '', $sql); $dao = CRM_Core_DAO::executeQuery($sql); - $contact_ids = array(); + $contact_ids = []; // Add resulting contacts to group while ($dao->fetch()) { if ($dao->addtogroup_contact_id) { @@ -5012,12 +5012,12 @@ public static function uploadChartImage() { * @param string $table */ public function setEntityRefDefaults(&$field, $table) { - $field['attributes'] = $field['attributes'] ? $field['attributes'] : array(); - $field['attributes'] += array( + $field['attributes'] = $field['attributes'] ? $field['attributes'] : []; + $field['attributes'] += [ 'entity' => CRM_Core_DAO_AllCoreTables::getBriefName(CRM_Core_DAO_AllCoreTables::getClassForTable($table)), 'multiple' => TRUE, 'placeholder' => ts('- select -'), - ); + ]; } /** @@ -5044,7 +5044,7 @@ protected function addLinkToRow(&$row, $baseUrl, $linkText, $value, $fieldName, ); $row["{$tablePrefix}_{$fieldName}_link"] = $url; $row["{$tablePrefix}_{$fieldName}_hover"] = ts("%1 for this %2.", - array(1 => $linkText, 2 => $fieldLabel) + [1 => $linkText, 2 => $fieldLabel] ); } @@ -5114,7 +5114,7 @@ public function alterSectionHeaderForDateTime($tempTable, $columnName) { * @return array */ public function getSelectColumns() { - $selectColumns = array(); + $selectColumns = []; foreach ($this->_columns as $tableName => $table) { if (array_key_exists('fields', $table)) { foreach ($table['fields'] as $fieldName => $field) { @@ -5212,7 +5212,7 @@ public function joinGroupTempTable($baseTable, $field, $tableAlias) { */ public function getLabels($options, $baoName, $fieldName) { $types = explode(',', $options); - $labels = array(); + $labels = []; foreach ($types as $value) { $labels[$value] = CRM_Core_PseudoConstant::getLabel($baoName, $fieldName, $value); } @@ -5340,8 +5340,8 @@ protected function setTableAlias($table, $tableName) { * * @return array */ - protected function getColumns($type, $options = array()) { - $defaultOptions = array( + protected function getColumns($type, $options = []) { + $defaultOptions = [ 'prefix' => '', 'prefix_label' => '', 'fields' => TRUE, @@ -5349,11 +5349,11 @@ protected function getColumns($type, $options = array()) { 'order_bys' => TRUE, 'filters' => TRUE, 'join_filters' => FALSE, - 'fields_defaults' => array(), - 'filters_defaults' => array(), - 'group_bys_defaults' => array(), - 'order_bys_defaults' => array(), - ); + 'fields_defaults' => [], + 'filters_defaults' => [], + 'group_bys_defaults' => [], + 'order_bys_defaults' => [], + ]; $options = array_merge($defaultOptions, $options); $fn = 'get' . $type . 'Columns'; @@ -5367,32 +5367,32 @@ protected function getColumns($type, $options = array()) { * * @return array */ - protected function getContactColumns($options = array()) { - $defaultOptions = array( - 'custom_fields' => array('Individual', 'Contact', 'Organization'), - 'fields_defaults' => array('display_name', 'id'), - 'order_bys_defaults' => array('sort_name ASC'), + protected function getContactColumns($options = []) { + $defaultOptions = [ + 'custom_fields' => ['Individual', 'Contact', 'Organization'], + 'fields_defaults' => ['display_name', 'id'], + 'order_bys_defaults' => ['sort_name ASC'], 'contact_type' => NULL, - ); + ]; $options = array_merge($defaultOptions, $options); $tableAlias = $options['prefix'] . 'contact'; - $spec = array( - $options['prefix'] . 'display_name' => array( + $spec = [ + $options['prefix'] . 'display_name' => [ 'name' => 'display_name', 'title' => $options['prefix_label'] . ts('Contact Name'), 'is_fields' => TRUE, - ), - $options['prefix'] . 'sort_name' => array( + ], + $options['prefix'] . 'sort_name' => [ 'name' => 'sort_name', 'title' => $options['prefix_label'] . ts('Contact Name (in sort format)'), 'is_fields' => TRUE, 'is_filters' => TRUE, 'is_order_bys' => TRUE, - ), - $options['prefix'] . 'id' => array( + ], + $options['prefix'] . 'id' => [ 'name' => 'id', 'title' => $options['prefix_label'] . ts('Contact ID'), 'alter_display' => 'alterContactID', @@ -5401,14 +5401,14 @@ protected function getContactColumns($options = array()) { 'is_group_bys' => TRUE, 'is_fields' => TRUE, 'is_filters' => TRUE, - ), - $options['prefix'] . 'external_identifier' => array( + ], + $options['prefix'] . 'external_identifier' => [ 'name' => 'external_identifier', 'title' => $options['prefix_label'] . ts('External ID'), 'type' => CRM_Utils_Type::T_INT, 'is_fields' => TRUE, - ), - $options['prefix'] . 'contact_type' => array( + ], + $options['prefix'] . 'contact_type' => [ 'title' => $options['prefix_label'] . ts('Contact Type'), 'name' => 'contact_type', 'operatorType' => CRM_Report_Form::OP_MULTISELECT, @@ -5416,8 +5416,8 @@ protected function getContactColumns($options = array()) { 'is_fields' => TRUE, 'is_filters' => TRUE, 'is_group_bys' => TRUE, - ), - $options['prefix'] . 'contact_sub_type' => array( + ], + $options['prefix'] . 'contact_sub_type' => [ 'title' => $options['prefix_label'] . ts('Contact Sub Type'), 'name' => 'contact_sub_type', 'operatorType' => CRM_Report_Form::OP_MULTISELECT, @@ -5425,44 +5425,44 @@ protected function getContactColumns($options = array()) { 'is_fields' => TRUE, 'is_filters' => TRUE, 'is_group_bys' => TRUE, - ), - $options['prefix'] . 'is_deleted' => array( + ], + $options['prefix'] . 'is_deleted' => [ 'title' => $options['prefix_label'] . ts('Is deleted'), 'name' => 'is_deleted', 'type' => CRM_Utils_Type::T_BOOLEAN, 'is_fields' => FALSE, 'is_filters' => TRUE, 'is_group_bys' => FALSE, - ), - $options['prefix'] . 'external_identifier' => array( + ], + $options['prefix'] . 'external_identifier' => [ 'title' => $options['prefix_label'] . ts('Contact identifier from external system'), 'name' => 'external_identifier', 'is_fields' => TRUE, 'is_filters' => FALSE, 'is_group_bys' => FALSE, 'is_order_bys' => TRUE, - ), - $options['prefix'] . 'preferred_language' => array( + ], + $options['prefix'] . 'preferred_language' => [ 'title' => $options['prefix_label'] . ts('Preferred Language'), 'name' => 'preferred_language', 'is_fields' => TRUE, 'is_filters' => TRUE, 'is_group_bys' => TRUE, 'is_order_bys' => TRUE, - ), - ); + ], + ]; foreach ([ 'postal_greeting_display' => 'Postal Greeting', 'email_greeting_display' => 'Email Greeting', 'addressee_display' => 'Addressee', ] as $field => $title) { - $spec[$options['prefix'] . $field] = array( + $spec[$options['prefix'] . $field] = [ 'title' => $options['prefix_label'] . ts($title), 'name' => $field, 'is_fields' => TRUE, 'is_filters' => FALSE, 'is_group_bys' => FALSE, - ); + ]; } foreach (['do_not_email', 'do_not_phone', 'do_not_mail', 'do_not_sms', 'is_opt_out'] as $field) { $spec[$options['prefix'] . $field] = [ @@ -5473,102 +5473,102 @@ protected function getContactColumns($options = array()) { 'is_group_bys' => FALSE, ]; } - $individualFields = array( - $options['prefix'] . 'first_name' => array( + $individualFields = [ + $options['prefix'] . 'first_name' => [ 'name' => 'first_name', 'title' => $options['prefix_label'] . ts('First Name'), 'is_fields' => TRUE, 'is_filters' => TRUE, 'is_order_bys' => TRUE, - ), - $options['prefix'] . 'middle_name' => array( + ], + $options['prefix'] . 'middle_name' => [ 'name' => 'middle_name', 'title' => $options['prefix_label'] . ts('Middle Name'), 'is_fields' => TRUE, - ), - $options['prefix'] . 'last_name' => array( + ], + $options['prefix'] . 'last_name' => [ 'name' => 'last_name', 'title' => $options['prefix_label'] . ts('Last Name'), 'default_order' => 'ASC', 'is_fields' => TRUE, - ), - $options['prefix'] . 'nick_name' => array( + ], + $options['prefix'] . 'nick_name' => [ 'name' => 'nick_name', 'title' => $options['prefix_label'] . ts('Nick Name'), 'is_fields' => TRUE, - ), - $options['prefix'] . 'prefix_id' => array( + ], + $options['prefix'] . 'prefix_id' => [ 'name' => 'prefix_id', 'title' => $options['prefix_label'] . ts('Prefix'), 'options' => CRM_Contact_BAO_Contact::buildOptions('prefix_id'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'is_fields' => TRUE, 'is_filters' => TRUE, - ), - $options['prefix'] . 'suffix_id' => array( + ], + $options['prefix'] . 'suffix_id' => [ 'name' => 'suffix_id', 'title' => $options['prefix_label'] . ts('Suffix'), 'options' => CRM_Contact_BAO_Contact::buildOptions('suffix_id'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'is_fields' => TRUE, 'is_filters' => TRUE, - ), - $options['prefix'] . 'gender_id' => array( + ], + $options['prefix'] . 'gender_id' => [ 'name' => 'gender_id', 'title' => $options['prefix_label'] . ts('Gender'), 'options' => CRM_Contact_BAO_Contact::buildOptions('gender_id'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'is_fields' => TRUE, 'is_filters' => TRUE, - ), - 'birth_date' => array( + ], + 'birth_date' => [ 'title' => $options['prefix_label'] . ts('Birth Date'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE, 'is_fields' => TRUE, 'is_filters' => TRUE, - ), - 'age' => array( + ], + 'age' => [ 'title' => $options['prefix_label'] . ts('Age'), 'dbAlias' => 'TIMESTAMPDIFF(YEAR, ' . $tableAlias . '_civireport.birth_date, CURDATE())', 'type' => CRM_Utils_Type::T_INT, 'is_fields' => TRUE, - ), - $options['prefix'] . 'is_deceased' => array( + ], + $options['prefix'] . 'is_deceased' => [ 'title' => $options['prefix_label'] . ts('Is deceased'), 'name' => 'is_deceased', 'type' => CRM_Utils_Type::T_BOOLEAN, 'is_fields' => FALSE, 'is_filters' => TRUE, 'is_group_bys' => FALSE, - ), - $options['prefix'] . 'job_title' => array( + ], + $options['prefix'] . 'job_title' => [ 'name' => 'job_title', 'is_fields' => TRUE, 'is_filters' => FALSE, 'is_group_bys' => FALSE, - ), - $options['prefix'] . 'employer_id' => array( + ], + $options['prefix'] . 'employer_id' => [ 'title' => $options['prefix_label'] . ts('Current Employer'), 'type' => CRM_Utils_Type::T_INT, 'name' => 'employer_id', 'is_fields' => TRUE, 'is_filters' => FALSE, 'is_group_bys' => TRUE, - ), - ); + ], + ]; if (!$options['contact_type'] || $options['contact_type'] === 'Individual') { $spec = array_merge($spec, $individualFields); } if (!empty($options['custom_fields'])) { - $this->_customGroupExtended[$options['prefix'] . 'civicrm_contact'] = array( + $this->_customGroupExtended[$options['prefix'] . 'civicrm_contact'] = [ 'extends' => $options['custom_fields'], 'title' => $options['prefix_label'], 'filters' => $options['filters'], 'prefix' => $options['prefix'], 'prefix_label' => $options['prefix_label'], - ); + ]; } return $this->buildColumns($spec, $options['prefix'] . 'civicrm_contact', 'CRM_Contact_DAO_Contact', $tableAlias, $this->getDefaultsFromOptions($options), $options); @@ -5586,8 +5586,8 @@ protected function getContactColumns($options = array()) { * * @return array address columns definition */ - protected function getAddressColumns($options = array()) { - $defaultOptions = array( + protected function getAddressColumns($options = []) { + $defaultOptions = [ 'prefix' => '', 'prefix_label' => '', 'fields' => TRUE, @@ -5595,29 +5595,29 @@ protected function getAddressColumns($options = array()) { 'order_bys' => TRUE, 'filters' => TRUE, 'join_filters' => FALSE, - 'fields_defaults' => array(), - 'filters_defaults' => array(), - 'group_bys_defaults' => array(), - 'order_bys_defaults' => array(), - ); + 'fields_defaults' => [], + 'filters_defaults' => [], + 'group_bys_defaults' => [], + 'order_bys_defaults' => [], + ]; $options = array_merge($defaultOptions, $options); $defaults = $this->getDefaultsFromOptions($options); $tableAlias = $options['prefix'] . 'address'; - $spec = array( - $options['prefix'] . 'name' => array( + $spec = [ + $options['prefix'] . 'name' => [ 'title' => ts($options['prefix_label'] . 'Address Name'), 'name' => 'name', 'is_fields' => TRUE, - ), - $options['prefix'] . 'street_number' => array( + ], + $options['prefix'] . 'street_number' => [ 'name' => 'street_number', 'title' => ts($options['prefix_label'] . 'Street Number'), 'type' => 1, 'is_fields' => TRUE, - ), - $options['prefix'] . 'odd_street_number' => array( + ], + $options['prefix'] . 'odd_street_number' => [ 'title' => ts('Odd / Even Street Number'), 'name' => 'odd_street_number', 'type' => CRM_Utils_Type::T_INT, @@ -5626,8 +5626,8 @@ protected function getAddressColumns($options = array()) { 'dbAlias' => '(address_civireport.street_number % 2)', 'is_fields' => TRUE, 'is_order_bys' => TRUE, - ), - $options['prefix'] . 'street_name' => array( + ], + $options['prefix'] . 'street_name' => [ 'name' => 'street_name', 'title' => ts($options['prefix_label'] . 'Street Name'), 'type' => 1, @@ -5635,44 +5635,44 @@ protected function getAddressColumns($options = array()) { 'is_filters' => TRUE, 'operator' => 'like', 'is_order_bys' => TRUE, - ), - $options['prefix'] . 'street_address' => array( + ], + $options['prefix'] . 'street_address' => [ 'title' => ts($options['prefix_label'] . 'Street Address'), 'name' => 'street_address', 'is_fields' => TRUE, 'is_filters' => TRUE, 'is_group_bys' => TRUE, - ), - $options['prefix'] . 'supplemental_address_1' => array( + ], + $options['prefix'] . 'supplemental_address_1' => [ 'title' => ts($options['prefix_label'] . 'Supplementary Address Field 1'), 'name' => 'supplemental_address_1', 'is_fields' => TRUE, - ), - $options['prefix'] . 'supplemental_address_2' => array( + ], + $options['prefix'] . 'supplemental_address_2' => [ 'title' => ts($options['prefix_label'] . 'Supplementary Address Field 2'), 'name' => 'supplemental_address_2', 'is_fields' => TRUE, - ), - $options['prefix'] . 'supplemental_address_3' => array( + ], + $options['prefix'] . 'supplemental_address_3' => [ 'title' => ts($options['prefix_label'] . 'Supplementary Address Field 3'), 'name' => 'supplemental_address_3', 'is_fields' => TRUE, - ), - $options['prefix'] . 'street_number' => array( + ], + $options['prefix'] . 'street_number' => [ 'name' => 'street_number', 'title' => ts($options['prefix_label'] . 'Street Number'), 'type' => 1, 'is_order_bys' => TRUE, 'is_filters' => TRUE, 'is_fields' => TRUE, - ), - $options['prefix'] . 'street_unit' => array( + ], + $options['prefix'] . 'street_unit' => [ 'name' => 'street_unit', 'title' => ts($options['prefix_label'] . 'Street Unit'), 'type' => 1, 'is_fields' => TRUE, - ), - $options['prefix'] . 'city' => array( + ], + $options['prefix'] . 'city' => [ 'title' => ts($options['prefix_label'] . 'City'), 'name' => 'city', 'operator' => 'like', @@ -5680,8 +5680,8 @@ protected function getAddressColumns($options = array()) { 'is_filters' => TRUE, 'is_group_bys' => TRUE, 'is_order_bys' => TRUE, - ), - $options['prefix'] . 'postal_code' => array( + ], + $options['prefix'] . 'postal_code' => [ 'title' => ts($options['prefix_label'] . 'Postal Code'), 'name' => 'postal_code', 'type' => 1, @@ -5689,8 +5689,8 @@ protected function getAddressColumns($options = array()) { 'is_filters' => TRUE, 'is_group_bys' => TRUE, 'is_order_bys' => TRUE, - ), - $options['prefix'] . 'postal_code_suffix' => array( + ], + $options['prefix'] . 'postal_code_suffix' => [ 'title' => ts($options['prefix_label'] . 'Postal Code Suffix'), 'name' => 'postal_code', 'type' => 1, @@ -5698,8 +5698,8 @@ protected function getAddressColumns($options = array()) { 'is_filters' => TRUE, 'is_group_bys' => TRUE, 'is_order_bys' => TRUE, - ), - $options['prefix'] . 'county_id' => array( + ], + $options['prefix'] . 'county_id' => [ 'title' => ts($options['prefix_label'] . 'County'), 'alter_display' => 'alterCountyID', 'name' => 'county_id', @@ -5709,8 +5709,8 @@ protected function getAddressColumns($options = array()) { 'is_fields' => TRUE, 'is_filters' => TRUE, 'is_group_bys' => TRUE, - ), - $options['prefix'] . 'state_province_id' => array( + ], + $options['prefix'] . 'state_province_id' => [ 'title' => ts($options['prefix_label'] . 'State/Province'), 'alter_display' => 'alterStateProvinceID', 'name' => 'state_province_id', @@ -5720,8 +5720,8 @@ protected function getAddressColumns($options = array()) { 'is_fields' => TRUE, 'is_filters' => TRUE, 'is_group_bys' => TRUE, - ), - $options['prefix'] . 'country_id' => array( + ], + $options['prefix'] . 'country_id' => [ 'title' => ts($options['prefix_label'] . 'Country'), 'alter_display' => 'alterCountryID', 'name' => 'country_id', @@ -5731,26 +5731,26 @@ protected function getAddressColumns($options = array()) { 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::country(), - ), - $options['prefix'] . 'location_type_id' => array( + ], + $options['prefix'] . 'location_type_id' => [ 'name' => 'is_primary', 'title' => ts($options['prefix_label'] . 'Location Type'), 'type' => CRM_Utils_Type::T_INT, 'is_fields' => TRUE, 'alter_display' => 'alterLocationTypeID', - ), - $options['prefix'] . 'id' => array( + ], + $options['prefix'] . 'id' => [ 'title' => ts($options['prefix_label'] . 'ID'), 'name' => 'id', 'is_fields' => TRUE, - ), - $options['prefix'] . 'is_primary' => array( + ], + $options['prefix'] . 'is_primary' => [ 'name' => 'is_primary', 'title' => ts($options['prefix_label'] . 'Primary Address?'), 'type' => CRM_Utils_Type::T_BOOLEAN, 'is_fields' => TRUE, - ), - ); + ], + ]; return $this->buildColumns($spec, $options['prefix'] . 'civicrm_address', 'CRM_Core_DAO_Address', $tableAlias, $defaults, $options); } @@ -5782,12 +5782,12 @@ protected function getAddressColumns($options = array()) { * * @return array */ - protected function buildColumns($specs, $tableName, $daoName = NULL, $tableAlias = NULL, $defaults = array(), $options = array()) { + protected function buildColumns($specs, $tableName, $daoName = NULL, $tableAlias = NULL, $defaults = [], $options = []) { if (!$tableAlias) { $tableAlias = str_replace('civicrm_', '', $tableName); } - $types = array('filters', 'group_bys', 'order_bys', 'join_filters'); - $columns = array($tableName => array_fill_keys($types, array())); + $types = ['filters', 'group_bys', 'order_bys', 'join_filters']; + $columns = [$tableName => array_fill_keys($types, [])]; // The code that uses this no longer cares if it is a DAO or BAO so just call it a DAO. $columns[$tableName]['dao'] = $daoName; $columns[$tableName]['alias'] = $tableAlias; @@ -5878,12 +5878,12 @@ protected function storeGroupByArray() { * @return array */ protected function getDefaultsFromOptions($options) { - $defaults = array( + $defaults = [ 'fields_defaults' => $options['fields_defaults'], 'filters_defaults' => $options['filters_defaults'], 'group_bys_defaults' => $options['group_bys_defaults'], 'order_bys_defaults' => $options['order_bys_defaults'], - ); + ]; return $defaults; } diff --git a/CRM/Report/Form/Activity.php b/CRM/Report/Form/Activity.php index b85b2b73efb2..0f4facd7cffc 100644 --- a/CRM/Report/Form/Activity.php +++ b/CRM/Report/Form/Activity.php @@ -31,13 +31,13 @@ * @copyright CiviCRM LLC (c) 2004-2019 */ class CRM_Report_Form_Activity extends CRM_Report_Form { - protected $_selectAliasesTotal = array(); + protected $_selectAliasesTotal = []; - protected $_customGroupExtends = array( + protected $_customGroupExtends = [ 'Activity', - ); + ]; - protected $_nonDisplayFields = array(); + protected $_nonDisplayFields = []; /** * This report has not been optimised for group filtering. @@ -91,271 +91,271 @@ public function __construct() { // @todo split the 3 different contact tables into their own array items. // this will massively simplify the needs of this report. - $this->_columns = array( - 'civicrm_contact' => array( + $this->_columns = [ + 'civicrm_contact' => [ 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => array( - 'contact_source' => array( + 'fields' => [ + 'contact_source' => [ 'name' => 'sort_name', 'title' => ts('Source Name'), 'alias' => 'civicrm_contact_source', 'no_repeat' => TRUE, - ), - 'contact_assignee' => array( + ], + 'contact_assignee' => [ 'name' => 'sort_name', 'title' => ts('Assignee Name'), 'alias' => 'civicrm_contact_assignee', 'dbAlias' => "civicrm_contact_assignee.sort_name", 'default' => TRUE, - ), - 'contact_target' => array( + ], + 'contact_target' => [ 'name' => 'sort_name', 'title' => ts('Target Name'), 'alias' => 'civicrm_contact_target', 'dbAlias' => "civicrm_contact_target.sort_name", 'default' => TRUE, - ), - 'contact_source_id' => array( + ], + 'contact_source_id' => [ 'name' => 'id', 'alias' => 'civicrm_contact_source', 'dbAlias' => "civicrm_contact_source.id", 'no_display' => TRUE, 'default' => TRUE, 'required' => TRUE, - ), - 'contact_assignee_id' => array( + ], + 'contact_assignee_id' => [ 'name' => 'id', 'alias' => 'civicrm_contact_assignee', 'dbAlias' => "civicrm_contact_assignee.id", 'no_display' => TRUE, 'default' => TRUE, 'required' => TRUE, - ), - 'contact_target_id' => array( + ], + 'contact_target_id' => [ 'name' => 'id', 'alias' => 'civicrm_contact_target', 'dbAlias' => "civicrm_contact_target.id", 'no_display' => TRUE, 'default' => TRUE, 'required' => TRUE, - ), - ), - 'filters' => array( - 'contact_source' => array( + ], + ], + 'filters' => [ + 'contact_source' => [ 'name' => 'sort_name', 'alias' => 'civicrm_contact_source', 'title' => ts('Source Name'), 'operator' => 'like', 'type' => CRM_Report_Form::OP_STRING, - ), - 'contact_assignee' => array( + ], + 'contact_assignee' => [ 'name' => 'sort_name', 'alias' => 'civicrm_contact_assignee', 'title' => ts('Assignee Name'), 'operator' => 'like', 'type' => CRM_Report_Form::OP_STRING, - ), - 'contact_target' => array( + ], + 'contact_target' => [ 'name' => 'sort_name', 'alias' => 'civicrm_contact_target', 'title' => ts('Target Name'), 'operator' => 'like', 'type' => CRM_Report_Form::OP_STRING, - ), - 'current_user' => array( + ], + 'current_user' => [ 'name' => 'current_user', 'title' => ts('Limit To Current User'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_SELECT, - 'options' => array('0' => ts('No'), '1' => ts('Yes')), - ), - ), + 'options' => ['0' => ts('No'), '1' => ts('Yes')], + ], + ], 'grouping' => 'contact-fields', - ), - 'civicrm_email' => array( + ], + 'civicrm_email' => [ 'dao' => 'CRM_Core_DAO_Email', - 'fields' => array( - 'contact_source_email' => array( + 'fields' => [ + 'contact_source_email' => [ 'name' => 'email', 'title' => ts('Source Email'), 'alias' => 'civicrm_email_source', - ), - 'contact_assignee_email' => array( + ], + 'contact_assignee_email' => [ 'name' => 'email', 'title' => ts('Assignee Email'), 'alias' => 'civicrm_email_assignee', - ), - 'contact_target_email' => array( + ], + 'contact_target_email' => [ 'name' => 'email', 'title' => ts('Target Email'), 'alias' => 'civicrm_email_target', - ), - ), - 'order_bys' => array( - 'source_contact_email' => array( + ], + ], + 'order_bys' => [ + 'source_contact_email' => [ 'name' => 'email', 'title' => ts('Source Email'), 'dbAlias' => 'civicrm_email_contact_source_email', - ), - ), - ), - 'civicrm_phone' => array( + ], + ], + ], + 'civicrm_phone' => [ 'dao' => 'CRM_Core_DAO_Phone', - 'fields' => array( - 'contact_source_phone' => array( + 'fields' => [ + 'contact_source_phone' => [ 'name' => 'phone', 'title' => ts('Source Phone'), 'alias' => 'civicrm_phone_source', - ), - 'contact_assignee_phone' => array( + ], + 'contact_assignee_phone' => [ 'name' => 'phone', 'title' => ts('Assignee Phone'), 'alias' => 'civicrm_phone_assignee', - ), - 'contact_target_phone' => array( + ], + 'contact_target_phone' => [ 'name' => 'phone', 'title' => ts('Target Phone'), 'alias' => 'civicrm_phone_target', - ), - ), - ), - 'civicrm_activity' => array( + ], + ], + ], + 'civicrm_activity' => [ 'dao' => 'CRM_Activity_DAO_Activity', - 'fields' => array( - 'id' => array( + 'fields' => [ + 'id' => [ 'no_display' => TRUE, 'title' => ts('Activity ID'), 'required' => TRUE, - ), - 'source_record_id' => array( + ], + 'source_record_id' => [ 'no_display' => TRUE, 'required' => TRUE, - ), - 'activity_type_id' => array( + ], + 'activity_type_id' => [ 'title' => ts('Activity Type'), 'required' => TRUE, 'type' => CRM_Utils_Type::T_STRING, - ), - 'activity_subject' => array( + ], + 'activity_subject' => [ 'title' => ts('Subject'), 'default' => TRUE, - ), - 'activity_date_time' => array( + ], + 'activity_date_time' => [ 'title' => ts('Activity Date'), 'required' => TRUE, - ), - 'status_id' => array( + ], + 'status_id' => [ 'title' => ts('Activity Status'), 'default' => TRUE, 'type' => CRM_Utils_Type::T_STRING, - ), - 'duration' => array( + ], + 'duration' => [ 'title' => ts('Duration'), 'type' => CRM_Utils_Type::T_INT, - ), - 'location' => array( + ], + 'location' => [ 'title' => ts('Location'), 'type' => CRM_Utils_Type::T_STRING, - ), - 'details' => array( + ], + 'details' => [ 'title' => ts('Activity Details'), - ), - 'priority_id' => array( + ], + 'priority_id' => [ 'title' => ts('Priority'), 'default' => TRUE, 'type' => CRM_Utils_Type::T_STRING, - ), - ), - 'filters' => array( - 'activity_date_time' => array( + ], + ], + 'filters' => [ + 'activity_date_time' => [ 'default' => 'this.month', 'operatorType' => CRM_Report_Form::OP_DATE, - ), - 'activity_subject' => array('title' => ts('Activity Subject')), - 'activity_type_id' => array( + ], + 'activity_subject' => ['title' => ts('Activity Subject')], + 'activity_type_id' => [ 'title' => ts('Activity Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->activityTypes, - ), - 'status_id' => array( + ], + 'status_id' => [ 'title' => ts('Activity Status'), 'type' => CRM_Utils_Type::T_STRING, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::activityStatus(), - ), - 'location' => array( + ], + 'location' => [ 'title' => ts('Location'), 'type' => CRM_Utils_Type::T_TEXT, - ), - 'details' => array( + ], + 'details' => [ 'title' => ts('Activity Details'), 'type' => CRM_Utils_Type::T_TEXT, - ), - 'priority_id' => array( + ], + 'priority_id' => [ 'title' => ts('Activity Priority'), 'type' => CRM_Utils_Type::T_STRING, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::get('CRM_Activity_DAO_Activity', 'priority_id'), - ), - ), - 'order_bys' => array( - 'activity_date_time' => array( + ], + ], + 'order_bys' => [ + 'activity_date_time' => [ 'title' => ts('Activity Date'), 'default_weight' => '1', 'dbAlias' => 'civicrm_activity_activity_date_time', - ), - 'activity_type_id' => array( + ], + 'activity_type_id' => [ 'title' => ts('Activity Type'), 'default_weight' => '2', 'dbAlias' => 'field(civicrm_activity_activity_type_id, ' . implode(', ', array_keys($this->activityTypes)) . ')', - ), - ), + ], + ], 'grouping' => 'activity-fields', 'alias' => 'activity', - ), + ], // Hack to get $this->_alias populated for the table. - 'civicrm_activity_contact' => array( + 'civicrm_activity_contact' => [ 'dao' => 'CRM_Activity_DAO_ActivityContact', - 'fields' => array(), - ), - ) + $this->addressFields(TRUE); + 'fields' => [], + ], + ] + $this->addressFields(TRUE); if ($caseEnabled && CRM_Core_Permission::check('access all cases and activities')) { - $this->_columns['civicrm_activity']['filters']['include_case_activities'] = array( + $this->_columns['civicrm_activity']['filters']['include_case_activities'] = [ 'name' => 'include_case_activities', 'title' => ts('Include Case Activities'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_SELECT, - 'options' => array('0' => ts('No'), '1' => ts('Yes')), - ); + 'options' => ['0' => ts('No'), '1' => ts('Yes')], + ]; } if ($campaignEnabled) { // Add display column and filter for Survey Results, Campaign and Engagement Index if CiviCampaign is enabled - $this->_columns['civicrm_activity']['fields']['result'] = array( + $this->_columns['civicrm_activity']['fields']['result'] = [ 'title' => ts('Survey Result'), 'default' => 'false', - ); - $this->_columns['civicrm_activity']['filters']['result'] = array( + ]; + $this->_columns['civicrm_activity']['filters']['result'] = [ 'title' => ts('Survey Result'), 'operator' => 'like', 'type' => CRM_Utils_Type::T_STRING, - ); + ]; // If we have campaigns enabled, add those elements to both the fields, filters. $this->addCampaignFields('civicrm_activity'); if (!empty($this->engagementLevels)) { - $this->_columns['civicrm_activity']['fields']['engagement_level'] = array( + $this->_columns['civicrm_activity']['fields']['engagement_level'] = [ 'title' => ts('Engagement Index'), 'default' => 'false', - ); - $this->_columns['civicrm_activity']['filters']['engagement_level'] = array( + ]; + $this->_columns['civicrm_activity']['filters']['engagement_level'] = [ 'title' => ts('Engagement Index'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->engagementLevels, - ); + ]; } } $this->_groupFilter = TRUE; @@ -410,7 +410,7 @@ public function select($recordType = 'target') { $this->_selectAliasesTotal = $this->_selectAliases; } - $removeKeys = array(); + $removeKeys = []; if ($recordType == 'target') { // @todo - fix up the way the tables are declared in construct & remove this. foreach ($this->_selectClauses as $key => $clause) { @@ -545,7 +545,7 @@ public function where($recordType = NULL) { {$this->_aliases['civicrm_activity']}.is_deleted = 0 AND {$this->_aliases['civicrm_activity']}.is_current_revision = 1"; - $clauses = array(); + $clauses = []; foreach ($this->_columns as $tableName => $table) { if (array_key_exists('filters', $table)) { @@ -657,7 +657,7 @@ public function buildACLClause($tableAlias = 'contact_a') { $contactID = CRM_Utils_Type::escape($contactID, 'Integer'); CRM_Contact_BAO_Contact_Permission::cache($contactID); - $clauses = array(); + $clauses = []; foreach ($tableAlias as $k => $alias) { $clauses[] = " INNER JOIN civicrm_acl_contact_cache aclContactCache_{$k} ON ( {$alias}.id = aclContactCache_{$k}.contact_id OR {$alias}.id IS NULL ) AND aclContactCache_{$k}.user_id = $contactID "; } @@ -689,7 +689,7 @@ public function add2group($groupID) { $dao = $this->executeReportQuery($query); CRM_Core_DAO::reenableFullGroupByMode(); - $contactIDs = array(); + $contactIDs = []; // Add resulting contacts to group while ($dao->fetch()) { if ($dao->addtogroup_contact_id) { @@ -717,7 +717,7 @@ public function add2group($groupID) { * @return array */ public static function formRule($fields, $files, $self) { - $errors = array(); + $errors = []; $config = CRM_Core_Config::singleton(); if (in_array("CiviCase", $config->enableComponents)) { $componentId = CRM_Core_Component::getComponentID('CiviCase'); @@ -743,8 +743,8 @@ public function buildQuery($applyLimit = TRUE) { $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts); //Assign those recordtype to array which have filter operator as 'Is not empty' or 'Is empty' - $nullFilters = array(); - foreach (array('target', 'source', 'assignee') as $type) { + $nullFilters = []; + foreach (['target', 'source', 'assignee'] as $type) { if (CRM_Utils_Array::value("contact_{$type}_op", $this->_params) == 'nnll' || !empty($this->_params["contact_{$type}_value"]) ) { @@ -761,7 +761,7 @@ public function buildQuery($applyLimit = TRUE) { // form did not exist. // Fixing the way the construct method declares them will make all this redundant. // 1. fill temp table with target results - $this->buildACLClause(array('civicrm_contact_target')); + $this->buildACLClause(['civicrm_contact_target']); $this->select('target'); $this->from(); $this->customDataFrom(); @@ -784,7 +784,7 @@ public function buildQuery($applyLimit = TRUE) { $this->executeReportQuery($tempQuery); // 3. fill temp table with assignee results - $this->buildACLClause(array('civicrm_contact_assignee')); + $this->buildACLClause(['civicrm_contact_assignee']); $this->select('assignee'); $this->buildAssigneeFrom(); @@ -797,7 +797,7 @@ public function buildQuery($applyLimit = TRUE) { $this->executeReportQuery($tempQuery); // 4. fill temp table with source results - $this->buildACLClause(array('civicrm_contact_source')); + $this->buildACLClause(['civicrm_contact_source']); $this->select('source'); $this->buildSourceFrom(); $this->customDataFrom(); @@ -809,7 +809,7 @@ public function buildQuery($applyLimit = TRUE) { $this->executeReportQuery($tempQuery); // 5. show final result set from temp table - $rows = array(); + $rows = []; $this->select('final'); $this->_having = ""; if (!empty($nullFilters)) { @@ -915,11 +915,11 @@ public function alterDisplay(&$rows) { $rows[$rowNum]['civicrm_activity_id'] ); - $actLinkValues = array( + $actLinkValues = [ 'id' => $rows[$rowNum]['civicrm_activity_id'], 'cid' => $cid, 'cxt' => $context, - ); + ]; $actUrl = CRM_Utils_System::url($actActionLinks[CRM_Core_Action::VIEW]['url'], CRM_Core_Action::replace($actActionLinks[CRM_Core_Action::VIEW]['qs'], $actLinkValues), TRUE ); @@ -943,7 +943,7 @@ public function alterDisplay(&$rows) { $assigneeNames = explode(';', $row['civicrm_contact_contact_assignee']); if ($value = $row['civicrm_contact_contact_assignee_id']) { $assigneeContactIds = explode(';', $value); - $link = array(); + $link = []; if ($viewLinks) { foreach ($assigneeContactIds as $id => $value) { if (isset($value) && isset($assigneeNames[$id])) { @@ -965,7 +965,7 @@ public function alterDisplay(&$rows) { $targetNames = explode(';', $row['civicrm_contact_contact_target']); if ($value = $row['civicrm_contact_contact_target_id']) { $targetContactIds = explode(';', $value); - $link = array(); + $link = []; if ($viewLinks) { foreach ($targetContactIds as $id => $value) { if (isset($value) && isset($targetNames[$id])) { @@ -1062,7 +1062,7 @@ public function sectionTotals() { // pull section aliases out of $this->_sections $sectionAliases = array_keys($this->_sections); - $ifnulls = array(); + $ifnulls = []; foreach (array_merge($sectionAliases, $this->_selectAliases) as $alias) { $ifnulls[] = "ifnull($alias, '') as $alias"; } @@ -1074,7 +1074,7 @@ public function sectionTotals() { implode(", ", $sectionAliases); // initialize array of total counts - $totals = array(); + $totals = []; $dao = $this->executeReportQuery($query); while ($dao->fetch()) { // let $this->_alterDisplay translate any integer ids to human-readable values. @@ -1083,7 +1083,7 @@ public function sectionTotals() { $row = $rows[0]; // add totals for all permutations of section values - $values = array(); + $values = []; $i = 1; $aliasCount = count($sectionAliases); foreach ($sectionAliases as $alias) { diff --git a/CRM/Report/Form/ActivitySummary.php b/CRM/Report/Form/ActivitySummary.php index 2450a20eb628..dcf879b60c22 100644 --- a/CRM/Report/Form/ActivitySummary.php +++ b/CRM/Report/Form/ActivitySummary.php @@ -54,147 +54,147 @@ class CRM_Report_Form_ActivitySummary extends CRM_Report_Form { * Class constructor. */ public function __construct() { - $this->_columns = array( - 'civicrm_contact' => array( + $this->_columns = [ + 'civicrm_contact' => [ 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => array( - 'id' => array( + 'fields' => [ + 'id' => [ 'required' => TRUE, 'no_display' => TRUE, - ), - 'sort_name' => array( + ], + 'sort_name' => [ 'title' => ts('Contact Name'), 'no_repeat' => TRUE, - ), - ), - 'filters' => array( - 'sort_name' => array( + ], + ], + 'filters' => [ + 'sort_name' => [ 'title' => ts('Contact Name'), - ), - ), - 'group_bys' => array( - 'sort_name' => array( + ], + ], + 'group_bys' => [ + 'sort_name' => [ 'name' => 'id', 'title' => ts('Contact'), - ), - ), - 'order_bys' => array( - 'sort_name' => array( + ], + ], + 'order_bys' => [ + 'sort_name' => [ 'title' => ts('Contact Name'), - ), - ), + ], + ], 'grouping' => 'contact-fields', - ), - 'civicrm_email' => array( + ], + 'civicrm_email' => [ 'dao' => 'CRM_Core_DAO_Email', - 'fields' => array( - 'email' => array( + 'fields' => [ + 'email' => [ 'title' => ts('Email'), - ), - ), - 'order_bys' => array( - 'email' => array( + ], + ], + 'order_bys' => [ + 'email' => [ 'title' => ts('Email'), - ), - ), + ], + ], 'grouping' => 'contact-fields', - ), - 'civicrm_phone' => array( + ], + 'civicrm_phone' => [ 'dao' => 'CRM_Core_DAO_Email', - 'fields' => array( - 'phone' => array( + 'fields' => [ + 'phone' => [ 'title' => ts('Phone'), - ), - ), + ], + ], 'grouping' => 'contact-fields', - ), - 'civicrm_activity' => array( + ], + 'civicrm_activity' => [ 'dao' => 'CRM_Activity_DAO_Activity', - 'fields' => array( - 'activity_type_id' => array( + 'fields' => [ + 'activity_type_id' => [ 'title' => ts('Activity Type'), 'required' => TRUE, 'type' => CRM_Utils_Type::T_STRING, - ), - 'status_id' => array( + ], + 'status_id' => [ 'title' => ts('Activity Status'), 'default' => TRUE, 'type' => CRM_Utils_Type::T_STRING, - ), - 'duration' => array( + ], + 'duration' => [ 'title' => ts('Duration'), 'default' => TRUE, - ), - 'priority_id' => array( + ], + 'priority_id' => [ 'title' => ts('Priority'), 'default' => TRUE, 'type' => CRM_Utils_Type::T_STRING, - ), - 'id' => array( + ], + 'id' => [ 'title' => ts('Total Activities'), 'required' => TRUE, - 'statistics' => array( + 'statistics' => [ 'count' => ts('Count'), - ), - ), - ), - 'filters' => array( - 'activity_date_time' => array( + ], + ], + ], + 'filters' => [ + 'activity_date_time' => [ 'operatorType' => CRM_Report_Form::OP_DATE, - ), - 'activity_type_id' => array( + ], + 'activity_type_id' => [ 'title' => ts('Activity Type'), 'default' => 0, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE), - ), - 'status_id' => array( + ], + 'status_id' => [ 'title' => ts('Activity Status'), 'type' => CRM_Utils_Type::T_STRING, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::activityStatus(), - ), - 'priority_id' => array( + ], + 'priority_id' => [ 'title' => ts('Activity Priority'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::get('CRM_Activity_DAO_Activity', 'priority_id'), - ), - ), - 'group_bys' => array( - 'activity_date_time' => array( + ], + ], + 'group_bys' => [ + 'activity_date_time' => [ 'title' => ts('Activity Date'), 'frequency' => TRUE, - ), - 'activity_type_id' => array( + ], + 'activity_type_id' => [ 'title' => ts('Activity Type'), 'default' => TRUE, - ), - 'status_id' => array( + ], + 'status_id' => [ 'title' => ts('Activity Status'), 'default' => TRUE, - ), - ), - 'order_bys' => array( - 'activity_date_time' => array( + ], + ], + 'order_bys' => [ + 'activity_date_time' => [ 'title' => ts('Activity Date'), - ), - 'activity_type_id' => array( + ], + 'activity_type_id' => [ 'title' => ts('Activity Type'), - ), - ), + ], + ], 'grouping' => 'activity-fields', 'alias' => 'activity', - ), - ); + ], + ]; $this->_groupFilter = TRUE; parent::__construct(); } public function select() { - $select = array(); - $this->_columnHeaders = array(); + $select = []; + $this->_columnHeaders = []; foreach ($this->_columns as $tableName => $table) { if (array_key_exists('group_bys', $table)) { foreach ($table['group_bys'] as $fieldName => $field) { @@ -242,8 +242,8 @@ public function select() { // just to make sure these values are transferred to rows. // since we need that for calculation purpose, // e.g making subtotals look nicer or graphs - $this->_columnHeaders["{$tableName}_{$fieldName}_interval"] = array('no_display' => TRUE); - $this->_columnHeaders["{$tableName}_{$fieldName}_subtotal"] = array('no_display' => TRUE); + $this->_columnHeaders["{$tableName}_{$fieldName}_interval"] = ['no_display' => TRUE]; + $this->_columnHeaders["{$tableName}_{$fieldName}_subtotal"] = ['no_display' => TRUE]; } } } @@ -368,7 +368,7 @@ public function where($durationMode = FALSE) { {$this->_aliases['civicrm_activity']}.is_deleted = 0 AND {$this->_aliases['civicrm_activity']}.is_current_revision = 1"; - $clauses = array(); + $clauses = []; foreach ($this->_columns as $tableName => $table) { if (array_key_exists('filters', $table)) { @@ -418,7 +418,7 @@ public function where($durationMode = FALSE) { * @param bool $includeSelectCol */ public function groupBy($includeSelectCol = TRUE) { - $this->_groupBy = array(); + $this->_groupBy = []; if (!empty($this->_params['group_bys']) && is_array($this->_params['group_bys'])) { foreach ($this->_columns as $tableName => $table) { @@ -434,7 +434,7 @@ public function groupBy($includeSelectCol = TRUE) { $append = "YEAR({$field['dbAlias']}),"; if (in_array(strtolower($this->_params['group_bys_freq'][$fieldName]), - array('year') + ['year'] )) { $append = ''; } @@ -468,8 +468,8 @@ public function groupBy($includeSelectCol = TRUE) { * @return array */ public static function formRule($fields, $files, $self) { - $errors = array(); - $contactFields = array('sort_name', 'email', 'phone'); + $errors = []; + $contactFields = ['sort_name', 'email', 'phone']; if (!empty($fields['group_bys'])) { if (!empty($fields['group_bys']['activity_date_time'])) { if (!empty($fields['group_bys']['sort_name'])) { @@ -533,7 +533,7 @@ public function postProcess() { CRM_Utils_Hook::alterReportVar('sql', $this, $this); // build temporary table column names base on column headers of result - $dbColumns = array(); + $dbColumns = []; foreach ($this->_columnHeaders as $fieldName => $dontCare) { $dbColumns[] = $fieldName . ' VARCHAR(128)'; } @@ -572,13 +572,13 @@ public function postProcess() { // build array of result based on column headers. This method also allows // modifying column headers before using it to build result set i.e $rows. - $rows = array(); + $rows = []; $query = "SELECT {$this->_tempTableName}.*, {$this->_tempDurationSumTableName}.civicrm_activity_duration_total FROM {$this->_tempTableName} INNER JOIN {$this->_tempDurationSumTableName} ON ({$this->_tempTableName}.id = {$this->_tempDurationSumTableName}.id)"; // finally add duration total to column headers - $this->_columnHeaders['civicrm_activity_duration_total'] = array('no_display' => 1); + $this->_columnHeaders['civicrm_activity_duration_total'] = ['no_display' => 1]; $this->buildRows($query, $rows); @@ -614,7 +614,7 @@ public function statistics(&$rows) { $actDAO = CRM_Core_DAO::executeQuery($query); - $activityTypesCount = array(); + $activityTypesCount = []; while ($actDAO->fetch()) { if (!in_array($actDAO->civicrm_activity_activity_type_id, $activityTypesCount)) { $activityTypesCount[] = $actDAO->civicrm_activity_activity_type_id; @@ -626,18 +626,18 @@ public function statistics(&$rows) { $totalType = count($activityTypesCount); - $statistics['counts']['type'] = array( + $statistics['counts']['type'] = [ 'title' => ts('Total Types'), 'value' => $totalType, - ); - $statistics['counts']['activities'] = array( + ]; + $statistics['counts']['activities'] = [ 'title' => ts('Total Number of Activities'), 'value' => $totalActivity, - ); - $statistics['counts']['duration'] = array( + ]; + $statistics['counts']['duration'] = [ 'title' => ts('Total Duration (in Minutes)'), 'value' => $totalDuration, - ); + ]; return $statistics; } @@ -666,8 +666,8 @@ public function alterDisplay(&$rows) { foreach ($rows as $rowNum => $row) { // make count columns point to activity detail report if (!empty($row['civicrm_activity_id_count'])) { - $url = array(); - $urlParams = array('activity_type_id', 'gid', 'status_id', 'contact_id'); + $url = []; + $urlParams = ['activity_type_id', 'gid', 'status_id', 'contact_id']; foreach ($urlParams as $field) { if (!empty($row['civicrm_activity_' . $field])) { $url[] = "{$field}_op=in&{$field}_value={$row['civicrm_activity_'.$field]}"; @@ -677,7 +677,7 @@ public function alterDisplay(&$rows) { $url[] = "{$field}_op=in&{$field}_value={$val}"; } } - $date_suffixes = array('relative', 'from', 'to'); + $date_suffixes = ['relative', 'from', 'to']; foreach ($date_suffixes as $suffix) { if (!empty($this->_params['activity_date_time_' . $suffix])) { list($from, $to) diff --git a/CRM/Report/Form/Case/Demographics.php b/CRM/Report/Form/Case/Demographics.php index 901ce3452941..75c3bd83f8f7 100644 --- a/CRM/Report/Form/Case/Demographics.php +++ b/CRM/Report/Form/Case/Demographics.php @@ -54,83 +54,83 @@ class CRM_Report_Form_Case_Demographics extends CRM_Report_Form { * Class constructor. */ public function __construct() { - $this->_columns = array( - 'civicrm_contact' => array( + $this->_columns = [ + 'civicrm_contact' => [ 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => array( - 'sort_name' => array( + 'fields' => [ + 'sort_name' => [ 'title' => ts('Contact Name'), 'required' => TRUE, 'no_repeat' => TRUE, - ), - 'gender_id' => array( + ], + 'gender_id' => [ 'title' => ts('Gender'), 'default' => TRUE, - ), - 'birth_date' => array( + ], + 'birth_date' => [ 'title' => ts('Birthdate'), 'default' => FALSE, - ), - 'id' => array( + ], + 'id' => [ 'no_display' => TRUE, 'required' => TRUE, - ), - ), - 'filters' => array( - 'sort_name' => array( + ], + ], + 'filters' => [ + 'sort_name' => [ 'title' => ts('Contact Name'), 'operatorType' => CRM_Report_Form::OP_STRING, - ), - 'contact_type' => array( + ], + 'contact_type' => [ 'title' => ts('Contact Type'), 'operatorType' => CRM_Report_Form::OP_SELECT, - 'options' => array( + 'options' => [ '' => ts('-select-'), 'Individual' => ts('Individual'), 'Organization' => ts('Organization'), 'Household' => ts('Household'), - ), + ], 'default' => 'Individual', - ), - 'id' => array( + ], + 'id' => [ 'title' => ts('Contact ID'), 'no_display' => TRUE, - ), - ), - 'order_bys' => array( - 'sort_name' => array( + ], + ], + 'order_bys' => [ + 'sort_name' => [ 'title' => ts('Contact Name'), 'default_weight' => '1', 'dbAlias' => 'civicrm_contact_sort_name', - ), - ), + ], + ], 'grouping' => 'contact-fields', - ), - 'civicrm_email' => array( + ], + 'civicrm_email' => [ 'dao' => 'CRM_Core_DAO_Email', - 'fields' => array( - 'email' => array( + 'fields' => [ + 'email' => [ 'title' => ts('Email'), 'no_repeat' => TRUE, - ), - ), + ], + ], 'grouping' => 'contact-fields', - ), - 'civicrm_address' => array( + ], + 'civicrm_address' => [ 'dao' => 'CRM_Core_DAO_Address', 'grouping' => 'contact-fields', - 'fields' => array( - 'street_address' => array('default' => FALSE), - 'city' => array('default' => TRUE), + 'fields' => [ + 'street_address' => ['default' => FALSE], + 'city' => ['default' => TRUE], 'postal_code' => NULL, - 'state_province_id' => array( + 'state_province_id' => [ 'title' => ts('State/Province'), - ), - 'country_id' => array( + ], + 'country_id' => [ 'title' => ts('Country'), 'default' => FALSE, - ), - ), + ], + ], /* 'filters' => array( 'country_id' => array( 'title' => ts( 'Country' ), @@ -142,68 +142,68 @@ public function __construct() { 'options' => CRM_Core_PseudoConstant::stateProvince( ), ), ), */ - ), - 'civicrm_phone' => array( + ], + 'civicrm_phone' => [ 'dao' => 'CRM_Core_DAO_Phone', - 'fields' => array('phone' => NULL), + 'fields' => ['phone' => NULL], 'grouping' => 'contact-fields', - ), - 'civicrm_activity' => array( + ], + 'civicrm_activity' => [ 'dao' => 'CRM_Activity_DAO_Activity', - 'fields' => array( - 'id' => array( + 'fields' => [ + 'id' => [ 'title' => ts('Activity ID'), 'no_display' => TRUE, 'required' => TRUE, - ), - ), - ), - 'civicrm_case' => array( + ], + ], + ], + 'civicrm_case' => [ 'dao' => 'CRM_Case_DAO_Case', - 'fields' => array( - 'id' => array( + 'fields' => [ + 'id' => [ 'title' => ts('Case ID'), 'required' => TRUE, - ), - 'start_date' => array( + ], + 'start_date' => [ 'title' => ts('Case Start'), 'required' => TRUE, - ), - 'end_date' => array( + ], + 'end_date' => [ 'title' => ts('Case End'), 'required' => TRUE, - ), - ), - 'filters' => array( - 'case_id_filter' => array( + ], + ], + 'filters' => [ + 'case_id_filter' => [ 'name' => 'id', 'title' => ts('Cases?'), 'operatorType' => CRM_Report_Form::OP_SELECT, - 'options' => array( + 'options' => [ 1 => ts('Exclude non-case'), 2 => ts('Exclude cases'), 3 => ts('Include Both'), - ), + ], 'default' => 3, - ), - 'start_date' => array( + ], + 'start_date' => [ 'title' => ts('Case Start'), 'operatorType' => CRM_Report_Form::OP_DATE, - ), - 'end_date' => array( + ], + 'end_date' => [ 'title' => ts('Case End'), 'operatorType' => CRM_Report_Form::OP_DATE, - ), - ), - 'order_bys' => array( - 'id' => array( + ], + ], + 'order_bys' => [ + 'id' => [ 'title' => ts('Case ID'), 'default_weight' => '2', 'dbAlias' => 'civicrm_case_id', - ), - ), - ), - ); + ], + ], + ], + ]; $this->_groupFilter = TRUE; $this->_tagFilter = TRUE; @@ -213,7 +213,7 @@ public function __construct() { where (cg.extends='Contact' OR cg.extends='Individual' OR cg.extends_entity_column_value='$open_case_val') AND cg.is_active=1 AND cf.is_active=1 ORDER BY cg.table_name"); $curTable = ''; $curExt = ''; - $curFields = array(); + $curFields = []; while ($crmDAO->fetch()) { if ($curTable == '') { $curTable = $crmDAO->table_name; @@ -221,25 +221,25 @@ public function __construct() { } elseif ($curTable != $crmDAO->table_name) { // dummy DAO - $this->_columns[$curTable] = array( + $this->_columns[$curTable] = [ 'dao' => 'CRM_Contact_DAO_Contact', 'fields' => $curFields, 'ext' => $curExt, - ); + ]; $curTable = $crmDAO->table_name; $curExt = $crmDAO->ext; - $curFields = array(); + $curFields = []; } - $curFields[$crmDAO->column_name] = array('title' => $crmDAO->label); + $curFields[$crmDAO->column_name] = ['title' => $crmDAO->label]; } if (!empty($curFields)) { // dummy DAO - $this->_columns[$curTable] = array( + $this->_columns[$curTable] = [ 'dao' => 'CRM_Contact_DAO_Contact', 'fields' => $curFields, 'ext' => $curExt, - ); + ]; } $this->_genders = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id'); @@ -252,8 +252,8 @@ public function preProcess() { } public function select() { - $select = array(); - $this->_columnHeaders = array(); + $select = []; + $this->_columnHeaders = []; foreach ($this->_columns as $tableName => $table) { if (array_key_exists('fields', $table)) { foreach ($table['fields'] as $fieldName => $field) { @@ -287,7 +287,7 @@ public function select() { * @return array */ public static function formRule($fields, $files, $self) { - $errors = $grouping = array(); + $errors = $grouping = []; return $errors; } @@ -319,7 +319,7 @@ public function from() { } public function where() { - $clauses = array(); + $clauses = []; $this->_having = ''; foreach ($this->_columns as $tableName => $table) { if (array_key_exists('filters', $table)) { @@ -371,7 +371,7 @@ public function where() { } public function groupBy() { - $groupBy = array("{$this->_aliases['civicrm_contact']}.id", "{$this->_aliases['civicrm_case']}.id"); + $groupBy = ["{$this->_aliases['civicrm_contact']}.id", "{$this->_aliases['civicrm_case']}.id"]; $this->_groupBy = CRM_Contact_BAO_Query::getGroupByFromSelectColumns($this->_selectClauses, $groupBy); } @@ -380,7 +380,7 @@ public function postProcess() { $this->beginPostProcess(); $sql = $this->buildQuery(TRUE); - $rows = $graphRows = array(); + $rows = $graphRows = []; $this->buildRows($sql, $rows); $this->formatDisplay($rows); @@ -459,10 +459,10 @@ public function getCustomFieldLabel($fname, $val) { INNER JOIN civicrm_option_group g ON cf.option_group_id = g.id INNER JOIN civicrm_option_value v ON g.id = v.option_group_id WHERE CONCAT(cg.table_name, '_', cf.column_name) = %1 AND v.value = %2"; - $params = array( - 1 => array($fname, 'String'), - 2 => array($val, 'String'), - ); + $params = [ + 1 => [$fname, 'String'], + 2 => [$val, 'String'], + ]; return CRM_Core_DAO::singleValueQuery($query, $params); } diff --git a/CRM/Report/Form/Case/Summary.php b/CRM/Report/Form/Case/Summary.php index 33204494aaaf..ee0bc8150ba4 100644 --- a/CRM/Report/Form/Case/Summary.php +++ b/CRM/Report/Form/Case/Summary.php @@ -36,7 +36,7 @@ class CRM_Report_Form_Case_Summary extends CRM_Report_Form { protected $_relField = FALSE; protected $_exposeContactID = FALSE; - protected $_customGroupExtends = array('Case'); + protected $_customGroupExtends = ['Case']; /** * Class constructor. @@ -49,161 +49,161 @@ public function __construct() { $this->rel_types[$relid] = $v['label_b_a']; } - $this->deleted_labels = array( + $this->deleted_labels = [ '' => ts('- select -'), 0 => ts('No'), 1 => ts('Yes'), - ); + ]; - $this->_columns = array( - 'civicrm_c2' => array( + $this->_columns = [ + 'civicrm_c2' => [ 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => array( - 'client_name' => array( + 'fields' => [ + 'client_name' => [ 'name' => 'sort_name', 'title' => ts('Contact Name'), 'required' => TRUE, - ), - 'id' => array( + ], + 'id' => [ 'no_display' => TRUE, 'required' => TRUE, - ), - ), - 'order_bys' => array( - 'client_name' => array( + ], + ], + 'order_bys' => [ + 'client_name' => [ 'title' => ts('Contact Name'), 'name' => 'sort_name', - ), - ), + ], + ], 'grouping' => 'case-fields', - ), - 'civicrm_case' => array( + ], + 'civicrm_case' => [ 'dao' => 'CRM_Case_DAO_Case', - 'fields' => array( - 'id' => array( + 'fields' => [ + 'id' => [ 'title' => ts('Case ID'), 'required' => TRUE, - ), - 'subject' => array( + ], + 'subject' => [ 'title' => ts('Case Subject'), 'default' => TRUE, - ), - 'status_id' => array( + ], + 'status_id' => [ 'title' => ts('Status'), 'default' => TRUE, - ), - 'case_type_id' => array( + ], + 'case_type_id' => [ 'title' => ts('Case Type'), 'default' => TRUE, - ), - 'start_date' => array( + ], + 'start_date' => [ 'title' => ts('Start Date'), 'default' => TRUE, 'type' => CRM_Utils_Type::T_DATE, - ), - 'end_date' => array( + ], + 'end_date' => [ 'title' => ts('End Date'), 'default' => TRUE, 'type' => CRM_Utils_Type::T_DATE, - ), - 'duration' => array( + ], + 'duration' => [ 'title' => ts('Duration (Days)'), 'default' => FALSE, - ), - 'is_deleted' => array( + ], + 'is_deleted' => [ 'title' => ts('Deleted?'), 'default' => FALSE, 'type' => CRM_Utils_Type::T_INT, - ), - ), - 'filters' => array( - 'start_date' => array( + ], + ], + 'filters' => [ + 'start_date' => [ 'title' => ts('Start Date'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE, - ), - 'end_date' => array( + ], + 'end_date' => [ 'title' => ts('End Date'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE, - ), - 'case_type_id' => array( + ], + 'case_type_id' => [ 'title' => ts('Case Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Case_BAO_Case::buildOptions('case_type_id', 'search'), - ), - 'status_id' => array( + ], + 'status_id' => [ 'title' => ts('Status'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Case_BAO_Case::buildOptions('status_id', 'search'), - ), - 'is_deleted' => array( + ], + 'is_deleted' => [ 'title' => ts('Deleted?'), 'type' => CRM_Report_Form::OP_INT, 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => $this->deleted_labels, 'default' => 0, - ), - ), - 'order_bys' => array( - 'start_date' => array( + ], + ], + 'order_bys' => [ + 'start_date' => [ 'title' => ts('Start Date'), - ), - 'end_date' => array( + ], + 'end_date' => [ 'title' => ts('End Date'), - ), - 'status_id' => array( + ], + 'status_id' => [ 'title' => ts('Status'), - ), - ), + ], + ], 'grouping' => 'case-fields', - ), - 'civicrm_contact' => array( + ], + 'civicrm_contact' => [ 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => array( - 'sort_name' => array( + 'fields' => [ + 'sort_name' => [ 'title' => ts('Staff Member'), 'default' => TRUE, - ), - ), - 'filters' => array( - 'sort_name' => array( + ], + ], + 'filters' => [ + 'sort_name' => [ 'title' => ts('Staff Member'), - ), - ), - ), - 'civicrm_relationship' => array( + ], + ], + ], + 'civicrm_relationship' => [ 'dao' => 'CRM_Contact_DAO_Relationship', - 'filters' => array( - 'relationship_type_id' => array( + 'filters' => [ + 'relationship_type_id' => [ 'title' => ts('Staff Relationship'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->rel_types, - ), - 'is_active' => array( + ], + 'is_active' => [ 'title' => ts('Active Relationship?'), 'type' => CRM_Utils_Type::T_BOOLEAN, //MV dev/core#603, not set default values Yes/No, this cause issue when relationship fields are not selected // 'default' => TRUE, - 'options' => array('' => ts('- Select -')) + CRM_Core_SelectValues::boolean(), - ), - ), - ), - 'civicrm_relationship_type' => array( + 'options' => ['' => ts('- Select -')] + CRM_Core_SelectValues::boolean(), + ], + ], + ], + 'civicrm_relationship_type' => [ 'dao' => 'CRM_Contact_DAO_RelationshipType', - 'fields' => array( - 'label_b_a' => array( + 'fields' => [ + 'label_b_a' => [ 'title' => ts('Relationship'), 'default' => TRUE, - ), - ), - ), - 'civicrm_case_contact' => array( + ], + ], + ], + 'civicrm_case_contact' => [ 'dao' => 'CRM_Case_DAO_CaseContact', - ), - ); + ], + ]; parent::__construct(); } @@ -213,8 +213,8 @@ public function preProcess() { } public function select() { - $select = array(); - $this->_columnHeaders = array(); + $select = []; + $this->_columnHeaders = []; foreach ($this->_columns as $tableName => $table) { if (array_key_exists('fields', $table)) { foreach ($table['fields'] as $fieldName => $field) { @@ -251,7 +251,7 @@ public function select() { * @return array */ public static function formRule($fields, $files, $self) { - $errors = $grouping = array(); + $errors = $grouping = []; if (empty($fields['relationship_type_id_value']) && (array_key_exists('sort_name', $fields['fields']) || array_key_exists('label_b_a', $fields['fields'])) @@ -304,7 +304,7 @@ public function from() { } public function where() { - $clauses = array(); + $clauses = []; $this->_having = ''; foreach ($this->_columns as $tableName => $table) { if (array_key_exists('filters', $table)) { @@ -372,7 +372,7 @@ public function postProcess() { $sql = $this->buildQuery(TRUE); - $rows = $graphRows = array(); + $rows = $graphRows = []; $this->buildRows($sql, $rows); $this->formatDisplay($rows); @@ -404,7 +404,7 @@ public function alterDisplay(&$rows) { ) { $value = $row['civicrm_case_case_type_id']; $typeIds = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value); - $value = array(); + $value = []; foreach ($typeIds as $typeId) { if ($typeId) { $value[$typeId] = $this->case_types[$typeId]; diff --git a/CRM/Report/Form/Case/TimeSpent.php b/CRM/Report/Form/Case/TimeSpent.php index 3be70f87eff5..17169bf7ab0e 100644 --- a/CRM/Report/Form/Case/TimeSpent.php +++ b/CRM/Report/Form/Case/TimeSpent.php @@ -41,150 +41,150 @@ public function __construct() { asort($this->activityTypes); $this->activityStatuses = CRM_Core_PseudoConstant::activityStatus(); - $this->_columns = array( - 'civicrm_contact' => array( + $this->_columns = [ + 'civicrm_contact' => [ 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => array( - 'id' => array( + 'fields' => [ + 'id' => [ 'title' => ts('Contact ID'), 'no_display' => TRUE, 'required' => TRUE, - ), - 'sort_name' => array( + ], + 'sort_name' => [ 'title' => ts('Contact Name'), 'required' => TRUE, 'no_repeat' => TRUE, - ), - ), - 'filters' => array( - 'sort_name' => array( + ], + ], + 'filters' => [ + 'sort_name' => [ 'title' => ts('Contact Name'), 'operator' => 'like', 'type' => CRM_Report_Form::OP_STRING, - ), - ), - 'order_bys' => array( - 'sort_name' => array( + ], + ], + 'order_bys' => [ + 'sort_name' => [ 'title' => ts('Contact Name'), 'default_weight' => '1', - ), - ), - ), - 'civicrm_activity' => array( + ], + ], + ], + 'civicrm_activity' => [ 'dao' => 'CRM_Activity_DAO_Activity', - 'fields' => array( - 'activity_type_id' => array( + 'fields' => [ + 'activity_type_id' => [ 'title' => ts('Activity Type'), 'default' => TRUE, 'type' => CRM_Utils_Type::T_STRING, - ), - 'activity_date_time' => array( + ], + 'activity_date_time' => [ 'title' => ts('Activity Date'), 'default' => TRUE, - ), - 'status_id' => array( + ], + 'status_id' => [ 'title' => ts('Activity Status'), 'default' => FALSE, 'type' => CRM_Utils_Type::T_STRING, - ), - 'id' => array( + ], + 'id' => [ 'title' => ts('Activity ID'), 'default' => TRUE, - ), - 'duration' => array( + ], + 'duration' => [ 'title' => ts('Duration'), 'default' => TRUE, 'type' => CRM_Utils_Type::T_INT, - ), - 'subject' => array( + ], + 'subject' => [ 'title' => ts('Activity Subject'), 'default' => FALSE, - ), - ), - 'filters' => array( - 'activity_date_time' => array( + ], + ], + 'filters' => [ + 'activity_date_time' => [ 'operatorType' => CRM_Report_Form::OP_DATE, - ), - 'subject' => array( + ], + 'subject' => [ 'title' => ts('Activity Subject'), 'type' => CRM_Utils_Type::T_STRING, 'operator' => 'like', - ), - 'activity_type_id' => array( + ], + 'activity_type_id' => [ 'title' => ts('Activity Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->activityTypes, - ), - 'status_id' => array( + ], + 'status_id' => [ 'title' => ts('Activity Status'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->activityStatuses, - ), - ), - 'order_bys' => array( - 'subject' => array( + ], + ], + 'order_bys' => [ + 'subject' => [ 'title' => ts('Activity Subject'), - ), - 'activity_type_id' => array( + ], + 'activity_type_id' => [ 'title' => ts('Activity Type'), - ), - 'activity_date_time' => array( + ], + 'activity_date_time' => [ 'title' => ts('Activity Date'), - ), - 'status_id' => array( + ], + 'status_id' => [ 'title' => ts('Activity Status'), - ), - ), + ], + ], 'grouping' => 'case-fields', - ), - 'civicrm_activity_source' => array( + ], + 'civicrm_activity_source' => [ 'dao' => 'CRM_Activity_DAO_ActivityContact', - 'fields' => array( - 'contact_id' => array( + 'fields' => [ + 'contact_id' => [ 'title' => ts('Contact ID'), 'default' => TRUE, 'no_display' => TRUE, - ), - ), - 'group_bys' => array( - 'contact_id' => array( + ], + ], + 'group_bys' => [ + 'contact_id' => [ 'title' => ts('Totals Only'), 'default' => TRUE, - ), - ), + ], + ], 'grouping' => 'activity-fields', - ), - 'civicrm_case_activity' => array( + ], + 'civicrm_case_activity' => [ 'dao' => 'CRM_Case_DAO_CaseActivity', - 'fields' => array( - 'case_id' => array( + 'fields' => [ + 'case_id' => [ 'title' => ts('Case ID'), 'default' => FALSE, - ), - ), - 'filters' => array( - 'case_id_filter' => array( + ], + ], + 'filters' => [ + 'case_id_filter' => [ 'name' => 'case_id', 'title' => ts('Cases?'), 'operatorType' => CRM_Report_Form::OP_SELECT, - 'options' => array( + 'options' => [ 1 => ts('Exclude non-case'), 2 => ts('Exclude cases'), 3 => ts('Include Both'), - ), + ], 'default' => 3, - ), - ), - ), - ); + ], + ], + ], + ]; parent::__construct(); } public function select() { - $select = array(); - $this->_columnHeaders = array(); + $select = []; + $this->_columnHeaders = []; $this->has_grouping = !empty($this->_params['group_bys']); $this->has_activity_type = FALSE; @@ -195,7 +195,7 @@ public function select() { if (!empty($field['required']) || (!empty($this->_params['fields'][$fieldName]) && ((!$this->has_grouping) || - !in_array($fieldName, array('case_id', 'subject', 'status_id'))) + !in_array($fieldName, ['case_id', 'subject', 'status_id'])) ) ) { @@ -249,7 +249,7 @@ public function where() { $this->_where = " WHERE {$this->_aliases['civicrm_activity']}.is_current_revision = 1 AND {$this->_aliases['civicrm_activity']}.is_deleted = 0 AND {$this->_aliases['civicrm_activity']}.is_test = 0"; - $clauses = array(); + $clauses = []; foreach ($this->_columns as $tableName => $table) { if (array_key_exists('filters', $table)) { @@ -304,10 +304,10 @@ public function where() { public function groupBy() { $this->_groupBy = ''; if ($this->has_grouping) { - $groupBy = array( + $groupBy = [ "{$this->_aliases['civicrm_contact']}.id", "civicrm_activity_activity_date_time", - ); + ]; if ($this->has_activity_type) { $groupBy[] = "{$this->_aliases['civicrm_activity']}.activity_type_id"; } @@ -328,7 +328,7 @@ public function postProcess() { * @return array */ public static function formRule($fields, $files, $self) { - $errors = array(); + $errors = []; if (!empty($fields['group_bys']) && (!array_key_exists('id', $fields['fields']) || !array_key_exists('activity_date_time', $fields['fields']) || diff --git a/CRM/Report/Form/Contact/CurrentEmployer.php b/CRM/Report/Form/Contact/CurrentEmployer.php index d61aa5d5e679..b1780c73c99e 100644 --- a/CRM/Report/Form/Contact/CurrentEmployer.php +++ b/CRM/Report/Form/Contact/CurrentEmployer.php @@ -47,149 +47,149 @@ class CRM_Report_Form_Contact_CurrentEmployer extends CRM_Report_Form { protected $_summary = NULL; - protected $_customGroupExtends = array( + protected $_customGroupExtends = [ 'Contact', 'Individual', - ); + ]; - public $_drilldownReport = array('contact/detail' => 'Link to Detail Report'); + public $_drilldownReport = ['contact/detail' => 'Link to Detail Report']; /** * Class constructor. */ public function __construct() { - $this->_columns = array( - 'civicrm_employer' => array( + $this->_columns = [ + 'civicrm_employer' => [ 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => array( - 'organization_name' => array( + 'fields' => [ + 'organization_name' => [ 'title' => ts('Employer Name'), 'required' => TRUE, 'no_repeat' => TRUE, - ), - 'id' => array( + ], + 'id' => [ 'no_display' => TRUE, 'required' => TRUE, - ), - ), - 'filters' => array( - 'organization_name' => array( + ], + ], + 'filters' => [ + 'organization_name' => [ 'title' => ts('Employer Name'), 'operatorType' => CRM_Report_Form::OP_STRING, - ), - ), - ), - 'civicrm_contact' => array( + ], + ], + ], + 'civicrm_contact' => [ 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => array( - 'sort_name' => array( + 'fields' => [ + 'sort_name' => [ 'title' => ts('Employee Name'), 'required' => TRUE, - ), - 'first_name' => array( + ], + 'first_name' => [ 'title' => ts('First Name'), - ), - 'middle_name' => array( + ], + 'middle_name' => [ 'title' => ts('Middle Name'), - ), - 'last_name' => array( + ], + 'last_name' => [ 'title' => ts('Last Name'), - ), - 'id' => array( + ], + 'id' => [ 'no_display' => TRUE, 'required' => TRUE, - ), - 'job_title' => array( + ], + 'job_title' => [ 'title' => ts('Job Title'), 'default' => TRUE, - ), - 'gender_id' => array( + ], + 'gender_id' => [ 'title' => ts('Gender'), - ), - 'birth_date' => array( + ], + 'birth_date' => [ 'title' => ts('Birth Date'), - ), - 'age' => array( + ], + 'age' => [ 'title' => ts('Age'), 'dbAlias' => 'TIMESTAMPDIFF(YEAR, contact_civireport.birth_date, CURDATE())', - ), - 'contact_type' => array( + ], + 'contact_type' => [ 'title' => ts('Contact Type'), - ), - 'contact_sub_type' => array( + ], + 'contact_sub_type' => [ 'title' => ts('Contact Subtype'), - ), - ), - 'filters' => array_merge($this->getBasicContactFilters(), array('sort_name' => array('title' => ts('Employee Name')))), + ], + ], + 'filters' => array_merge($this->getBasicContactFilters(), ['sort_name' => ['title' => ts('Employee Name')]]), 'grouping' => 'contact-fields', - ), - 'civicrm_relationship' => array( + ], + 'civicrm_relationship' => [ 'dao' => 'CRM_Contact_DAO_Relationship', - 'fields' => array( - 'start_date' => array( + 'fields' => [ + 'start_date' => [ 'title' => ts('Employee Since'), 'default' => TRUE, - ), - ), - 'filters' => array( - 'start_date' => array( + ], + ], + 'filters' => [ + 'start_date' => [ 'title' => ts('Employee Since'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE, - ), - ), - ), - 'civicrm_phone' => array( + ], + ], + ], + 'civicrm_phone' => [ 'dao' => 'CRM_Core_DAO_Phone', 'grouping' => 'contact-fields', - 'fields' => array( - 'phone' => array( + 'fields' => [ + 'phone' => [ 'title' => ts('Phone'), 'default' => TRUE, - ), - ), - ), - 'civicrm_email' => array( + ], + ], + ], + 'civicrm_email' => [ 'dao' => 'CRM_Core_DAO_Email', 'grouping' => 'contact-fields', - 'fields' => array( - 'email' => array( + 'fields' => [ + 'email' => [ 'title' => ts('Email'), 'default' => TRUE, - ), - ), - ), - 'civicrm_address' => array( + ], + ], + ], + 'civicrm_address' => [ 'dao' => 'CRM_Core_DAO_Address', 'grouping' => 'contact-fields', - 'fields' => array( + 'fields' => [ 'street_address' => NULL, 'city' => NULL, 'postal_code' => NULL, - 'state_province_id' => array( + 'state_province_id' => [ 'title' => ts('State/Province'), - ), - 'country_id' => array( + ], + 'country_id' => [ 'title' => ts('Country'), - ), - ), - 'filters' => array( - 'country_id' => array( + ], + ], + 'filters' => [ + 'country_id' => [ 'title' => ts('Country'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::country(NULL, FALSE), - ), - 'state_province_id' => array( + ], + 'state_province_id' => [ 'title' => ts('State/Province'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::stateProvince(), - ), - ), - ), - ); + ], + ], + ], + ]; $this->_groupFilter = TRUE; $this->_tagFilter = TRUE; @@ -202,7 +202,7 @@ public function preProcess() { public function select() { - $select = $this->_columnHeaders = array(); + $select = $this->_columnHeaders = []; foreach ($this->_columns as $tableName => $table) { if (array_key_exists('fields', $table)) { @@ -224,11 +224,11 @@ public function select() { } public function from() { - $relType = civicrm_api3('RelationshipType', 'getvalue', array( + $relType = civicrm_api3('RelationshipType', 'getvalue', [ 'return' => "id", 'name_a_b' => "Employee of", 'name_b_a' => "Employer of", - )); + ]); $this->_from = " FROM civicrm_contact {$this->_aliases['civicrm_contact']} @@ -248,7 +248,7 @@ public function from() { public function where() { - $clauses = array(); + $clauses = []; foreach ($this->_columns as $tableName => $table) { if (array_key_exists('filters', $table)) { foreach ($table['filters'] as $fieldName => $field) { @@ -293,10 +293,10 @@ public function where() { } public function groupBy() { - $groupBy = array( + $groupBy = [ "{$this->_aliases['civicrm_employer']}.id", "{$this->_aliases['civicrm_contact']}.id", - ); + ]; $this->_groupBy = CRM_Contact_BAO_Query::getGroupByFromSelectColumns($this->_selectClauses, $groupBy); } @@ -307,10 +307,10 @@ public function orderBy() { public function postProcess() { // get the acl clauses built before we assemble the query - $this->buildACLClause(array( + $this->buildACLClause([ $this->_aliases['civicrm_contact'], $this->_aliases['civicrm_employer'], - )); + ]); parent::postProcess(); } @@ -324,7 +324,7 @@ public function postProcess() { * Rows generated by SQL, with an array for each row. */ public function alterDisplay(&$rows) { - $checkList = array(); + $checkList = []; $entryFound = FALSE; foreach ($rows as $rowNum => $row) { diff --git a/CRM/Report/Form/Contact/Detail.php b/CRM/Report/Form/Contact/Detail.php index e7e6b46085ca..e4546491d7be 100644 --- a/CRM/Report/Form/Contact/Detail.php +++ b/CRM/Report/Form/Contact/Detail.php @@ -35,12 +35,12 @@ class CRM_Report_Form_Contact_Detail extends CRM_Report_Form { protected $_summary = NULL; - protected $_customGroupExtends = array( + protected $_customGroupExtends = [ 'Contact', 'Individual', 'Household', 'Organization', - ); + ]; /** * This report has not been optimised for group filtering. @@ -60,310 +60,310 @@ class CRM_Report_Form_Contact_Detail extends CRM_Report_Form { */ public function __construct() { $this->_autoIncludeIndexedFieldsAsOrderBys = 1; - $this->_columns = array( - 'civicrm_contact' => array( + $this->_columns = [ + 'civicrm_contact' => [ 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => array( - 'sort_name' => array( + 'fields' => [ + 'sort_name' => [ 'title' => ts('Contact Name'), 'required' => TRUE, 'no_repeat' => TRUE, - ), - 'first_name' => array( + ], + 'first_name' => [ 'title' => ts('First Name'), - ), - 'middle_name' => array( + ], + 'middle_name' => [ 'title' => ts('Middle Name'), - ), - 'last_name' => array( + ], + 'last_name' => [ 'title' => ts('Last Name'), - ), - 'id' => array( + ], + 'id' => [ 'no_display' => TRUE, 'required' => TRUE, - ), - 'gender_id' => array( + ], + 'gender_id' => [ 'title' => ts('Gender'), - ), - 'birth_date' => array( + ], + 'birth_date' => [ 'title' => ts('Birth Date'), - ), - 'age' => array( + ], + 'age' => [ 'title' => ts('Age'), 'dbAlias' => 'TIMESTAMPDIFF(YEAR, contact_civireport.birth_date, CURDATE())', - ), - 'contact_type' => array( + ], + 'contact_type' => [ 'title' => ts('Contact Type'), - ), - 'contact_sub_type' => array( + ], + 'contact_sub_type' => [ 'title' => ts('Contact Subtype'), - ), - ), + ], + ], 'filters' => $this->getBasicContactFilters(), 'grouping' => 'contact-fields', - 'order_bys' => array( - 'sort_name' => array( + 'order_bys' => [ + 'sort_name' => [ 'title' => ts('Last Name, First Name'), 'default' => '1', 'default_weight' => '0', 'default_order' => 'ASC', - ), - 'first_name' => array( + ], + 'first_name' => [ 'title' => ts('First Name'), - ), - 'gender_id' => array( + ], + 'gender_id' => [ 'name' => 'gender_id', 'title' => ts('Gender'), - ), - 'birth_date' => array( + ], + 'birth_date' => [ 'name' => 'birth_date', 'title' => ts('Birth Date'), - ), - 'contact_type' => array( + ], + 'contact_type' => [ 'title' => ts('Contact Type'), - ), - 'contact_sub_type' => array( + ], + 'contact_sub_type' => [ 'title' => ts('Contact Subtype'), - ), - ), - ), - 'civicrm_address' => array( + ], + ], + ], + 'civicrm_address' => [ 'dao' => 'CRM_Core_DAO_Address', 'grouping' => 'contact-fields', - 'fields' => array( + 'fields' => [ 'street_address' => NULL, 'city' => NULL, 'postal_code' => NULL, - 'state_province_id' => array( + 'state_province_id' => [ 'title' => ts('State/Province'), - ), - ), - 'order_bys' => array( - 'state_province_id' => array('title' => ts('State/Province')), - 'city' => array('title' => ts('City')), - 'postal_code' => array('title' => ts('Postal Code')), - ), - ), - 'civicrm_country' => array( + ], + ], + 'order_bys' => [ + 'state_province_id' => ['title' => ts('State/Province')], + 'city' => ['title' => ts('City')], + 'postal_code' => ['title' => ts('Postal Code')], + ], + ], + 'civicrm_country' => [ 'dao' => 'CRM_Core_DAO_Country', - 'fields' => array( - 'name' => array('title' => ts('Country'), 'default' => TRUE), - ), - 'order_bys' => array( - 'name' => array('title' => ts('Country')), - ), + 'fields' => [ + 'name' => ['title' => ts('Country'), 'default' => TRUE], + ], + 'order_bys' => [ + 'name' => ['title' => ts('Country')], + ], 'grouping' => 'contact-fields', - ), - 'civicrm_email' => array( + ], + 'civicrm_email' => [ 'dao' => 'CRM_Core_DAO_Email', - 'fields' => array( - 'email' => array( + 'fields' => [ + 'email' => [ 'title' => ts('Email'), 'no_repeat' => TRUE, - ), - ), + ], + ], 'grouping' => 'contact-fields', - 'order_bys' => array( - 'email' => array( + 'order_bys' => [ + 'email' => [ 'title' => ts('Email'), - ), - ), - ), - 'civicrm_contribution' => array( + ], + ], + ], + 'civicrm_contribution' => [ 'dao' => 'CRM_Contribute_DAO_Contribution', - 'fields' => array( - 'contact_id' => array( + 'fields' => [ + 'contact_id' => [ 'no_display' => TRUE, 'required' => TRUE, - ), - 'contribution_id' => array( + ], + 'contribution_id' => [ 'title' => ts('Contribution'), 'no_repeat' => TRUE, 'default' => TRUE, - ), - 'total_amount' => array('default' => TRUE), - 'financial_type_id' => array( + ], + 'total_amount' => ['default' => TRUE], + 'financial_type_id' => [ 'title' => ts('Financial Type'), 'default' => TRUE, - ), + ], 'trxn_id' => NULL, - 'receive_date' => array('default' => TRUE), + 'receive_date' => ['default' => TRUE], 'receipt_date' => NULL, - 'contribution_status_id' => array( + 'contribution_status_id' => [ 'title' => ts('Contribution Status'), 'default' => TRUE, - ), + ], 'contribution_source' => NULL, - ), - ), - 'civicrm_membership' => array( + ], + ], + 'civicrm_membership' => [ 'dao' => 'CRM_Member_DAO_Membership', - 'fields' => array( - 'contact_id' => array( + 'fields' => [ + 'contact_id' => [ 'no_display' => TRUE, 'required' => TRUE, - ), - 'membership_id' => array( + ], + 'membership_id' => [ 'title' => ts('Membership'), 'no_repeat' => TRUE, 'default' => TRUE, - ), - 'membership_type_id' => array( + ], + 'membership_type_id' => [ 'title' => ts('Membership Type'), 'default' => TRUE, - ), + ], 'join_date' => NULL, - 'membership_start_date' => array( + 'membership_start_date' => [ 'title' => ts('Start Date'), 'default' => TRUE, - ), - 'membership_end_date' => array( + ], + 'membership_end_date' => [ 'title' => ts('End Date'), 'default' => TRUE, - ), - 'membership_status_id' => array( + ], + 'membership_status_id' => [ 'name' => 'status_id', 'title' => ts('Membership Status'), 'default' => TRUE, - ), - 'source' => array('title' => ts('Membership Source')), - ), - ), - 'civicrm_participant' => array( + ], + 'source' => ['title' => ts('Membership Source')], + ], + ], + 'civicrm_participant' => [ 'dao' => 'CRM_Event_DAO_Participant', - 'fields' => array( - 'contact_id' => array( + 'fields' => [ + 'contact_id' => [ 'no_display' => TRUE, 'required' => TRUE, - ), - 'participant_id' => array( + ], + 'participant_id' => [ 'title' => ts('Participant'), 'no_repeat' => TRUE, 'default' => TRUE, - ), - 'event_id' => array('default' => TRUE), - 'participant_status_id' => array( + ], + 'event_id' => ['default' => TRUE], + 'participant_status_id' => [ 'name' => 'status_id', 'title' => ts('Participant Status'), 'default' => TRUE, - ), - 'role_id' => array( + ], + 'role_id' => [ 'title' => ts('Role'), 'default' => TRUE, - ), - 'participant_register_date' => array( + ], + 'participant_register_date' => [ 'title' => ts('Register Date'), 'default' => TRUE, - ), - 'fee_level' => array( + ], + 'fee_level' => [ 'title' => ts('Fee Level'), 'default' => TRUE, - ), - 'fee_amount' => array( + ], + 'fee_amount' => [ 'title' => ts('Fee Amount'), 'default' => TRUE, - ), - ), - ), - 'civicrm_relationship' => array( + ], + ], + ], + 'civicrm_relationship' => [ 'dao' => 'CRM_Contact_DAO_Relationship', - 'fields' => array( - 'relationship_id' => array( + 'fields' => [ + 'relationship_id' => [ 'name' => 'id', 'title' => ts('Relationship'), 'no_repeat' => TRUE, 'default' => TRUE, - ), - 'relationship_type_id' => array( + ], + 'relationship_type_id' => [ 'title' => ts('Relationship Type'), 'default' => TRUE, - ), - 'contact_id_b' => array( + ], + 'contact_id_b' => [ 'title' => ts('Relationship With'), 'default' => TRUE, - ), - 'start_date' => array( + ], + 'start_date' => [ 'title' => ts('Start Date'), 'type' => CRM_Report_Form::OP_DATE, - ), - 'end_date' => array( + ], + 'end_date' => [ 'title' => ts('End Date'), 'type' => CRM_Report_Form::OP_DATE, - ), - ), - ), - 'civicrm_activity' => array( + ], + ], + ], + 'civicrm_activity' => [ 'dao' => 'CRM_Activity_DAO_Activity', - 'fields' => array( - 'id' => array( + 'fields' => [ + 'id' => [ 'title' => ts('Activity'), 'no_repeat' => TRUE, 'default' => TRUE, - ), - 'activity_type_id' => array( + ], + 'activity_type_id' => [ 'title' => ts('Activity Type'), 'default' => TRUE, - ), - 'subject' => array( + ], + 'subject' => [ 'title' => ts('Subject'), 'default' => TRUE, - ), - 'activity_date_time' => array( + ], + 'activity_date_time' => [ 'title' => ts('Activity Date'), 'default' => TRUE, - ), - 'activity_status_id' => array( + ], + 'activity_status_id' => [ 'name' => 'status_id', 'title' => ts('Activity Status'), 'default' => TRUE, - ), - ), + ], + ], 'grouping' => 'activity-fields', - ), - 'civicrm_activity_target' => array( + ], + 'civicrm_activity_target' => [ 'dao' => 'CRM_Activity_DAO_ActivityContact', - 'fields' => array( - 'target_contact_id' => array( + 'fields' => [ + 'target_contact_id' => [ 'title' => ts('With Contact'), 'name' => 'contact_id', 'default' => TRUE, - ), - ), + ], + ], 'grouping' => 'activity-fields', - ), - 'civicrm_activity_assignment' => array( + ], + 'civicrm_activity_assignment' => [ 'dao' => 'CRM_Activity_DAO_ActivityContact', - 'fields' => array( - 'assignee_contact_id' => array( + 'fields' => [ + 'assignee_contact_id' => [ 'title' => ts('Assigned to'), 'name' => 'contact_id', 'default' => TRUE, - ), - ), + ], + ], 'grouping' => 'activity-fields', - ), - 'civicrm_activity_source' => array( + ], + 'civicrm_activity_source' => [ 'dao' => 'CRM_Activity_DAO_ActivityContact', - 'fields' => array( - 'source_contact_id' => array( + 'fields' => [ + 'source_contact_id' => [ 'title' => ts('Added By'), 'name' => 'contact_id', 'default' => TRUE, - ), - ), + ], + ], 'grouping' => 'activity-fields', - ), - 'civicrm_phone' => array( + ], + 'civicrm_phone' => [ 'dao' => 'CRM_Core_DAO_Phone', - 'fields' => array( + 'fields' => [ 'phone' => NULL, - 'phone_ext' => array( + 'phone_ext' => [ 'title' => ts('Phone Extension'), - ), - ), + ], + ], 'grouping' => 'contact-fields', - ), - ); + ], + ]; $this->_groupFilter = TRUE; $this->_tagFilter = TRUE; parent::__construct(); @@ -375,15 +375,15 @@ public function preProcess() { } public function select() { - $select = array(); - $this->_columnHeaders = array(); - $this->_component = array( + $select = []; + $this->_columnHeaders = []; + $this->_component = [ 'contribution_civireport', 'membership_civireport', 'participant_civireport', 'relationship_civireport', 'activity_civireport', - ); + ]; foreach ($this->_columns as $tableName => $table) { if (array_key_exists('fields', $table)) { foreach ($table['fields'] as $fieldName => $field) { @@ -448,7 +448,7 @@ public function select() { * @return array */ public static function formRule($fields, $files, $self) { - $errors = array(); + $errors = []; return $errors; } @@ -537,7 +537,7 @@ public function from() { } public function where() { - $clauses = array(); + $clauses = []; foreach ($this->_columns as $tableName => $table) { if (array_key_exists('filters', $table)) { @@ -585,7 +585,7 @@ public function where() { public function clauseComponent() { $selectedContacts = implode(',', $this->_contactSelected); $contribution = $membership = $participant = NULL; - $eligibleResult = $rows = $tempArray = array(); + $eligibleResult = $rows = $tempArray = []; foreach ($this->_component as $val) { if (!empty($this->_selectComponent[$val]) && ($val != 'activity_civireport' && $val != 'relationship_civireport') @@ -599,7 +599,7 @@ public function clauseComponent() { $countRecord = 0; $eligibleResult[$val] = $val; $CC = 'civicrm_' . substr_replace($val, '', -11, 11) . '_contact_id'; - $row = array(); + $row = []; foreach ($this->_columnHeadersComponent[$val] as $key => $value) { $countRecord++; $row[$key] = $dao->$key; @@ -726,7 +726,7 @@ public function clauseComponent() { * @return array */ public function statistics(&$rows) { - $statistics = array(); + $statistics = []; $count = count($rows); if ($this->_rollup && ($this->_rollup != '')) { @@ -764,7 +764,7 @@ public function postProcess() { $sql = $this->buildQuery(TRUE); - $rows = $graphRows = $this->_contactSelected = array(); + $rows = $graphRows = $this->_contactSelected = []; $this->buildRows($sql, $rows); foreach ($rows as $key => $val) { $rows[$key]['contactID'] = $val['civicrm_contact_id']; @@ -903,7 +903,7 @@ public function alterComponentDisplay(&$componentRows) { } if ($val = CRM_Utils_Array::value('civicrm_participant_role_id', $row)) { $roles = explode(CRM_Core_DAO::VALUE_SEPARATOR, $val); - $value = array(); + $value = []; foreach ($roles as $role) { $value[$role] = CRM_Event_PseudoConstant::participantRole($role, FALSE); } diff --git a/CRM/Report/Form/Contact/Log.php b/CRM/Report/Form/Contact/Log.php index 7617ad503d03..22c5ca634a60 100644 --- a/CRM/Report/Form/Contact/Log.php +++ b/CRM/Report/Form/Contact/Log.php @@ -42,97 +42,97 @@ public function __construct() { $this->activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, TRUE); asort($this->activityTypes); - $this->_columns = array( - 'civicrm_contact' => array( + $this->_columns = [ + 'civicrm_contact' => [ 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => array( - 'sort_name' => array( + 'fields' => [ + 'sort_name' => [ 'title' => ts('Modified By'), 'required' => TRUE, - ), - 'id' => array( + ], + 'id' => [ 'no_display' => TRUE, 'required' => TRUE, - ), - ), - 'filters' => array( - 'sort_name' => array( + ], + ], + 'filters' => [ + 'sort_name' => [ 'title' => ts('Modified By'), 'type' => CRM_Utils_Type::T_STRING, - ), - ), + ], + ], 'grouping' => 'contact-fields', - ), - 'civicrm_contact_touched' => array( + ], + 'civicrm_contact_touched' => [ 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => array( - 'sort_name_touched' => array( + 'fields' => [ + 'sort_name_touched' => [ 'title' => ts('Touched Contact'), 'name' => 'sort_name', 'required' => TRUE, - ), - 'id' => array( + ], + 'id' => [ 'no_display' => TRUE, 'required' => TRUE, - ), - ), - 'filters' => array( - 'sort_name_touched' => array( + ], + ], + 'filters' => [ + 'sort_name_touched' => [ 'title' => ts('Touched Contact'), 'name' => 'sort_name', 'type' => CRM_Utils_Type::T_STRING, - ), - ), + ], + ], 'grouping' => 'contact-fields', - ), - 'civicrm_activity' => array( + ], + 'civicrm_activity' => [ 'dao' => 'CRM_Activity_DAO_Activity', - 'fields' => array( - 'id' => array( + 'fields' => [ + 'id' => [ 'title' => ts('Activity ID'), 'no_display' => TRUE, 'required' => TRUE, - ), - 'subject' => array( + ], + 'subject' => [ 'title' => ts('Touched Activity'), 'required' => TRUE, - ), - 'activity_type_id' => array( + ], + 'activity_type_id' => [ 'title' => ts('Activity Type'), 'required' => TRUE, - ), - ), - ), - 'civicrm_activity_source' => array( + ], + ], + ], + 'civicrm_activity_source' => [ 'dao' => 'CRM_Activity_DAO_ActivityContact', - 'fields' => array( - 'contact_id' => array( + 'fields' => [ + 'contact_id' => [ 'no_display' => TRUE, 'required' => TRUE, - ), - ), - ), - 'civicrm_log' => array( + ], + ], + ], + 'civicrm_log' => [ 'dao' => 'CRM_Core_DAO_Log', - 'fields' => array( - 'modified_date' => array( + 'fields' => [ + 'modified_date' => [ 'title' => ts('Modified Date'), 'required' => TRUE, - ), - 'data' => array( + ], + 'data' => [ 'title' => ts('Description'), - ), - ), - 'filters' => array( - 'modified_date' => array( + ], + ], + 'filters' => [ + 'modified_date' => [ 'title' => ts('Modified Date'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE, 'default' => 'this.week', - ), - ), - ), - ); + ], + ], + ], + ]; parent::__construct(); } @@ -142,8 +142,8 @@ public function preProcess() { } public function select() { - $select = array(); - $this->_columnHeaders = array(); + $select = []; + $this->_columnHeaders = []; foreach ($this->_columns as $tableName => $table) { if (array_key_exists('fields', $table)) { foreach ($table['fields'] as $fieldName => $field) { @@ -170,7 +170,7 @@ public function select() { * @return array */ public static function formRule($fields, $files, $self) { - $errors = $grouping = array(); + $errors = $grouping = []; return $errors; } @@ -189,7 +189,7 @@ public function from() { } public function where() { - $clauses = array(); + $clauses = []; $this->_having = ''; foreach ($this->_columns as $tableName => $table) { if (array_key_exists('filters', $table)) { diff --git a/CRM/Report/Form/Contact/LoggingSummary.php b/CRM/Report/Form/Contact/LoggingSummary.php index 27fad501647f..61d255fdc9cd 100644 --- a/CRM/Report/Form/Contact/LoggingSummary.php +++ b/CRM/Report/Form/Contact/LoggingSummary.php @@ -39,150 +39,150 @@ class CRM_Report_Form_Contact_LoggingSummary extends CRM_Logging_ReportSummary { public function __construct() { parent::__construct(); - $logTypes = array(); + $logTypes = []; foreach (array_keys($this->_logTables) as $table) { $type = $this->getLogType($table); $logTypes[$type] = $type; } asort($logTypes); - $this->_columns = array( - 'log_civicrm_entity' => array( + $this->_columns = [ + 'log_civicrm_entity' => [ 'dao' => 'CRM_Contact_DAO_Contact', 'alias' => 'entity_log', - 'fields' => array( - 'id' => array( + 'fields' => [ + 'id' => [ 'no_display' => TRUE, 'required' => TRUE, - ), - 'log_grouping' => array( + ], + 'log_grouping' => [ 'required' => TRUE, 'title' => ts('Extra information to control grouping'), 'no_display' => TRUE, - ), - 'log_action' => array( + ], + 'log_action' => [ 'default' => TRUE, 'title' => ts('Action'), - ), - 'log_type' => array( + ], + 'log_type' => [ 'required' => TRUE, 'title' => ts('Log Type'), - ), - 'log_user_id' => array( + ], + 'log_user_id' => [ 'no_display' => TRUE, 'required' => TRUE, - ), - 'log_date' => array( + ], + 'log_date' => [ 'default' => TRUE, 'required' => TRUE, 'type' => CRM_Utils_Type::T_TIME, 'title' => ts('When'), - ), - 'altered_contact' => array( + ], + 'altered_contact' => [ 'default' => TRUE, 'name' => 'display_name', 'title' => ts('Altered Contact'), 'alias' => 'modified_contact_civireport', - ), - 'altered_contact_id' => array( + ], + 'altered_contact_id' => [ 'name' => 'id', 'no_display' => TRUE, 'required' => TRUE, 'alias' => 'modified_contact_civireport', - ), - 'log_conn_id' => array( + ], + 'log_conn_id' => [ 'no_display' => TRUE, 'required' => TRUE, - ), - 'is_deleted' => array( + ], + 'is_deleted' => [ 'no_display' => TRUE, 'required' => TRUE, 'alias' => 'modified_contact_civireport', - ), - ), - 'filters' => array( - 'log_date' => array( + ], + ], + 'filters' => [ + 'log_date' => [ 'title' => ts('When'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE, - ), - 'altered_contact' => array( + ], + 'altered_contact' => [ 'name' => 'display_name', 'title' => ts('Altered Contact'), 'type' => CRM_Utils_Type::T_STRING, 'alias' => 'modified_contact_civireport', - ), - 'altered_contact_id' => array( + ], + 'altered_contact_id' => [ 'name' => 'id', 'type' => CRM_Utils_Type::T_INT, 'alias' => 'modified_contact_civireport', 'no_display' => TRUE, - ), - 'log_type' => array( + ], + 'log_type' => [ 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $logTypes, 'title' => ts('Log Type'), 'type' => CRM_Utils_Type::T_STRING, - ), - 'log_type_table' => array( + ], + 'log_type_table' => [ 'name' => 'log_type', 'title' => ts('Log Type Table'), 'type' => CRM_Utils_Type::T_STRING, - ), - 'log_action' => array( + ], + 'log_action' => [ 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => array( + 'options' => [ 'Insert' => ts('Insert'), 'Update' => ts('Update'), 'Delete' => ts('Delete'), - ), + ], 'title' => ts('Action'), 'type' => CRM_Utils_Type::T_STRING, - ), - 'id' => array( + ], + 'id' => [ 'no_display' => TRUE, 'type' => CRM_Utils_Type::T_INT, - ), - ), - 'order_bys' => array( - 'log_date' => array( + ], + ], + 'order_bys' => [ + 'log_date' => [ 'title' => ts('Log Date (When)'), 'default' => TRUE, 'default_weight' => '0', 'default_order' => 'DESC', - ), - 'altered_contact' => array( + ], + 'altered_contact' => [ 'name' => 'display_name', 'title' => ts('Altered Contact'), 'alias' => 'modified_contact_civireport', - ), - ), - ), - 'altered_by_contact' => array( + ], + ], + ], + 'altered_by_contact' => [ 'dao' => 'CRM_Contact_DAO_Contact', 'alias' => 'altered_by_contact', - 'fields' => array( - 'display_name' => array( + 'fields' => [ + 'display_name' => [ 'default' => TRUE, 'name' => 'display_name', 'title' => ts('Altered By'), - ), - ), - 'filters' => array( - 'display_name' => array( + ], + ], + 'filters' => [ + 'display_name' => [ 'name' => 'display_name', 'title' => ts('Altered By'), 'type' => CRM_Utils_Type::T_STRING, - ), - ), - 'order_bys' => array( - 'altered_by_contact' => array( + ], + ], + 'order_bys' => [ + 'altered_by_contact' => [ 'name' => 'display_name', 'title' => ts('Altered by'), - ), - ), - ), - ); + ], + ], + ], + ]; } /** @@ -196,8 +196,8 @@ public function __construct() { */ public function alterDisplay(&$rows) { // cache for id → is_deleted mapping - $isDeleted = array(); - $newRows = array(); + $isDeleted = []; + $newRows = []; foreach ($rows as $key => &$row) { $isMerge = 0; diff --git a/CRM/Report/Form/Contact/Relationship.php b/CRM/Report/Form/Contact/Relationship.php index 2188114f258f..c29ec8e5058c 100644 --- a/CRM/Report/Form/Contact/Relationship.php +++ b/CRM/Report/Form/Contact/Relationship.php @@ -39,10 +39,10 @@ class CRM_Report_Form_Contact_Relationship extends CRM_Report_Form { protected $_emailField_b = FALSE; protected $_phoneField_a = FALSE; protected $_phoneField_b = FALSE; - protected $_customGroupExtends = array( + protected $_customGroupExtends = [ 'Relationship', - ); - public $_drilldownReport = array('contact/detail' => 'Link to Detail Report'); + ]; + public $_drilldownReport = ['contact/detail' => 'Link to Detail Report']; /** * This report has not been optimised for group filtering. @@ -71,284 +71,284 @@ public function __construct() { $contact_type = CRM_Contact_BAO_ContactType::getSelectElements(FALSE, TRUE, '_'); - $this->_columns = array( - 'civicrm_contact' => array( + $this->_columns = [ + 'civicrm_contact' => [ 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => array( - 'sort_name_a' => array( + 'fields' => [ + 'sort_name_a' => [ 'title' => ts('Contact A'), 'name' => 'sort_name', 'required' => TRUE, - ), - 'display_name_a' => array( + ], + 'display_name_a' => [ 'title' => ts('Contact A Full Name'), 'name' => 'display_name', - ), - 'id' => array( + ], + 'id' => [ 'no_display' => TRUE, 'required' => TRUE, - ), - 'contact_type_a' => array( + ], + 'contact_type_a' => [ 'title' => ts('Contact Type (Contact A)'), 'name' => 'contact_type', - ), - 'contact_sub_type_a' => array( + ], + 'contact_sub_type_a' => [ 'title' => ts('Contact Subtype (Contact A)'), 'name' => 'contact_sub_type', - ), - ), - 'filters' => array( - 'sort_name_a' => array( + ], + ], + 'filters' => [ + 'sort_name_a' => [ 'title' => ts('Contact A'), 'name' => 'sort_name', 'operator' => 'like', 'type' => CRM_Report_Form::OP_STRING, - ), - 'contact_type_a' => array( + ], + 'contact_type_a' => [ 'title' => ts('Contact Type A'), 'name' => 'contact_type', 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $contact_type, 'type' => CRM_Utils_Type::T_STRING, - ), - ), - 'order_bys' => array( - 'sort_name_a' => array( + ], + ], + 'order_bys' => [ + 'sort_name_a' => [ 'title' => ts('Contact A'), 'name' => 'sort_name', 'default_weight' => '1', - ), - ), + ], + ], 'grouping' => 'contact_a_fields', - ), - 'civicrm_contact_b' => array( + ], + 'civicrm_contact_b' => [ 'dao' => 'CRM_Contact_DAO_Contact', 'alias' => 'contact_b', - 'fields' => array( - 'sort_name_b' => array( + 'fields' => [ + 'sort_name_b' => [ 'title' => ts('Contact B'), 'name' => 'sort_name', 'required' => TRUE, - ), - 'display_name_b' => array( + ], + 'display_name_b' => [ 'title' => ts('Contact B Full Name'), 'name' => 'display_name', - ), - 'id' => array( + ], + 'id' => [ 'no_display' => TRUE, 'required' => TRUE, - ), - 'contact_type_b' => array( + ], + 'contact_type_b' => [ 'title' => ts('Contact Type (Contact B)'), 'name' => 'contact_type', - ), - 'contact_sub_type_b' => array( + ], + 'contact_sub_type_b' => [ 'title' => ts('Contact Subtype (Contact B)'), 'name' => 'contact_sub_type', - ), - ), - 'filters' => array( - 'sort_name_b' => array( + ], + ], + 'filters' => [ + 'sort_name_b' => [ 'title' => ts('Contact B'), 'name' => 'sort_name', 'operator' => 'like', 'type' => CRM_Report_Form::OP_STRING, - ), - 'contact_type_b' => array( + ], + 'contact_type_b' => [ 'title' => ts('Contact Type B'), 'name' => 'contact_type', 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $contact_type, 'type' => CRM_Utils_Type::T_STRING, - ), - ), - 'order_bys' => array( - 'sort_name_b' => array( + ], + ], + 'order_bys' => [ + 'sort_name_b' => [ 'title' => ts('Contact B'), 'name' => 'sort_name', 'default_weight' => '2', - ), - ), + ], + ], 'grouping' => 'contact_b_fields', - ), - 'civicrm_email' => array( + ], + 'civicrm_email' => [ 'dao' => 'CRM_Core_DAO_Email', - 'fields' => array( - 'email_a' => array( + 'fields' => [ + 'email_a' => [ 'title' => ts('Email (Contact A)'), 'name' => 'email', - ), - ), + ], + ], 'grouping' => 'contact_a_fields', - ), - 'civicrm_email_b' => array( + ], + 'civicrm_email_b' => [ 'dao' => 'CRM_Core_DAO_Email', 'alias' => 'email_b', - 'fields' => array( - 'email_b' => array( + 'fields' => [ + 'email_b' => [ 'title' => ts('Email (Contact B)'), 'name' => 'email', - ), - ), + ], + ], 'grouping' => 'contact_b_fields', - ), - 'civicrm_phone' => array( + ], + 'civicrm_phone' => [ 'dao' => 'CRM_Core_DAO_Phone', 'alias' => 'phone_a', - 'fields' => array( - 'phone_a' => array( + 'fields' => [ + 'phone_a' => [ 'title' => ts('Phone (Contact A)'), 'name' => 'phone', - ), - 'phone_ext_a' => array( + ], + 'phone_ext_a' => [ 'title' => ts('Phone Ext (Contact A)'), 'name' => 'phone_ext', - ), - ), + ], + ], 'grouping' => 'contact_a_fields', - ), - 'civicrm_phone_b' => array( + ], + 'civicrm_phone_b' => [ 'dao' => 'CRM_Core_DAO_Phone', 'alias' => 'phone_b', - 'fields' => array( - 'phone_b' => array( + 'fields' => [ + 'phone_b' => [ 'title' => ts('Phone (Contact B)'), 'name' => 'phone', - ), - 'phone_ext_b' => array( + ], + 'phone_ext_b' => [ 'title' => ts('Phone Ext (Contact B)'), 'name' => 'phone_ext', - ), - ), + ], + ], 'grouping' => 'contact_b_fields', - ), - 'civicrm_relationship_type' => array( + ], + 'civicrm_relationship_type' => [ 'dao' => 'CRM_Contact_DAO_RelationshipType', - 'fields' => array( - 'label_a_b' => array( + 'fields' => [ + 'label_a_b' => [ 'title' => ts('Relationship A-B '), 'default' => TRUE, - ), - 'label_b_a' => array( + ], + 'label_b_a' => [ 'title' => ts('Relationship B-A '), 'default' => TRUE, - ), - ), - 'order_bys' => array( - 'label_a_b' => array( + ], + ], + 'order_bys' => [ + 'label_a_b' => [ 'title' => ts('Relationship A-B'), 'name' => 'label_a_b', - ), - 'label_b_A' => array( + ], + 'label_b_A' => [ 'title' => ts('Relationship B-A'), 'name' => 'label_b_a', - ), - ), + ], + ], 'grouping' => 'relation-fields', - ), - 'civicrm_relationship' => array( + ], + 'civicrm_relationship' => [ 'dao' => 'CRM_Contact_DAO_Relationship', - 'fields' => array( - 'start_date' => array( + 'fields' => [ + 'start_date' => [ 'title' => ts('Relationship Start Date'), - ), - 'end_date' => array( + ], + 'end_date' => [ 'title' => ts('Relationship End Date'), - ), - 'is_permission_a_b' => array( + ], + 'is_permission_a_b' => [ 'title' => ts('Permission A has to access B'), - ), - 'is_permission_b_a' => array( + ], + 'is_permission_b_a' => [ 'title' => ts('Permission B has to access A'), - ), - 'description' => array( + ], + 'description' => [ 'title' => ts('Description'), - ), - 'relationship_id' => array( + ], + 'relationship_id' => [ 'title' => ts('Rel ID'), 'name' => 'id', - ), - ), - 'filters' => array( - 'is_active' => array( + ], + ], + 'filters' => [ + 'is_active' => [ 'title' => ts('Relationship Status'), 'operatorType' => CRM_Report_Form::OP_SELECT, - 'options' => array( + 'options' => [ '' => ts('- Any -'), 1 => ts('Active'), 0 => ts('Inactive'), - ), + ], 'type' => CRM_Utils_Type::T_INT, - ), - 'is_valid' => array( + ], + 'is_valid' => [ 'title' => ts('Relationship Dates Validity'), 'operatorType' => CRM_Report_Form::OP_SELECT, - 'options' => array( + 'options' => [ NULL => ts('- Any -'), 1 => ts('Not expired'), 0 => ts('Expired'), - ), + ], 'type' => CRM_Utils_Type::T_INT, - ), - 'relationship_type_id' => array( + ], + 'relationship_type_id' => [ 'title' => ts('Relationship'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, NULL, NULL, NULL, TRUE), 'type' => CRM_Utils_Type::T_INT, - ), - 'start_date' => array( + ], + 'start_date' => [ 'title' => ts('Start Date'), 'type' => CRM_Utils_Type::T_DATE, - ), - 'end_date' => array( + ], + 'end_date' => [ 'title' => ts('End Date'), 'type' => CRM_Utils_Type::T_DATE, - ), - 'active_period_date' => array( + ], + 'active_period_date' => [ 'title' => ts('Active Period'), 'type' => CRM_Utils_Type::T_DATE, - ), - 'is_permission_a_b' => array( + ], + 'is_permission_a_b' => [ 'title' => ts('Does contact A have permission over contact B?'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contact_BAO_Relationship::buildOptions('is_permission_a_b'), 'type' => CRM_Utils_Type::T_INT, - ), - 'is_permission_b_a' => array( + ], + 'is_permission_b_a' => [ 'title' => ts('Does contact B have permission over contact A?'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contact_BAO_Relationship::buildOptions('is_permission_b_a'), 'type' => CRM_Utils_Type::T_INT, - ), - ), + ], + ], - 'order_bys' => array( - 'start_date' => array( + 'order_bys' => [ + 'start_date' => [ 'title' => ts('Start Date'), 'name' => 'start_date', - ), - ), + ], + ], 'grouping' => 'relation-fields', - ), - 'civicrm_address' => array( + ], + 'civicrm_address' => [ 'dao' => 'CRM_Core_DAO_Address', - 'filters' => array( - 'country_id' => array( + 'filters' => [ + 'country_id' => [ 'title' => ts('Country'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::country(), - ), - 'state_province_id' => array( + ], + 'state_province_id' => [ 'title' => ts('State/Province'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::stateProvince(), - ), - ), + ], + ], 'grouping' => 'contact-fields', - ), - ); + ], + ]; $this->_groupFilter = TRUE; $this->_tagFilter = TRUE; @@ -360,7 +360,7 @@ public function preProcess() { } public function select() { - $select = $this->_columnHeaders = array(); + $select = $this->_columnHeaders = []; foreach ($this->_columns as $tableName => $table) { if (array_key_exists('fields', $table)) { foreach ($table['fields'] as $fieldName => $field) { @@ -456,7 +456,7 @@ public function from() { } public function where() { - $whereClauses = $havingClauses = array(); + $whereClauses = $havingClauses = []; foreach ($this->_columns as $tableName => $table) { if (array_key_exists('filters', $table)) { foreach ($table['filters'] as $fieldName => $field) { @@ -483,7 +483,7 @@ public function where() { $fieldName == 'contact_type_b') ) { $cTypes = CRM_Utils_Array::value("{$fieldName}_value", $this->_params); - $contactTypes = $contactSubTypes = array(); + $contactTypes = $contactSubTypes = []; if (!empty($cTypes)) { foreach ($cTypes as $ctype) { $getTypes = CRM_Utils_System::explode('_', $ctype, 2); @@ -593,7 +593,7 @@ public function statistics(&$rows) { if ($value['title'] == 'Relationship') { $relTypes = CRM_Core_PseudoConstant::relationshipType(); $op = CRM_Utils_Array::value('relationship_type_id_op', $this->_params) == 'in' ? ts('Is one of') . ' ' : ts('Is not one of') . ' '; - $relationshipTypes = array(); + $relationshipTypes = []; foreach ($this->_params['relationship_type_id_value'] as $relationship) { $relationshipTypes[] = $relTypes[$relationship]['label_' . $this->relationType]; } @@ -610,17 +610,17 @@ public function statistics(&$rows) { } // For displaying relationship status. if (!$isStatusFilter && $relStatus) { - $statistics['filters'][] = array( + $statistics['filters'][] = [ 'title' => ts('Relationship Status'), 'value' => $relStatus, - ); + ]; } return $statistics; } public function groupBy() { $this->_groupBy = " "; - $groupBy = array(); + $groupBy = []; if ($this->relationType == 'a_b') { $groupBy[] = " {$this->_aliases['civicrm_contact']}.id"; } @@ -632,7 +632,7 @@ public function groupBy() { $groupBy[] = "{$this->_aliases['civicrm_relationship']}.id"; } else { - $groupBy = array("{$this->_aliases['civicrm_relationship']}.id"); + $groupBy = ["{$this->_aliases['civicrm_relationship']}.id"]; } $this->_groupBy = CRM_Contact_BAO_Query::getGroupByFromSelectColumns($this->_selectClauses, $groupBy); @@ -641,8 +641,8 @@ public function groupBy() { public function beginPostProcessCommon() { $originalRelationshipTypeIdValue = CRM_Utils_Array::value('relationship_type_id_value', $this->_params); if ($originalRelationshipTypeIdValue) { - $relationshipTypes = array(); - $direction = array(); + $relationshipTypes = []; + $direction = []; foreach ((array) $originalRelationshipTypeIdValue as $relationship_type) { $relType = explode('_', $relationship_type); $direction[] = $relType[1] . '_' . $relType[2]; @@ -658,10 +658,10 @@ public function beginPostProcessCommon() { public function postProcess() { $this->beginPostProcess(); - $this->buildACLClause(array( + $this->buildACLClause([ $this->_aliases['civicrm_contact'], $this->_aliases['civicrm_contact_b'], - )); + ]); $sql = $this->buildQuery(); $this->buildRows($sql, $rows); @@ -693,7 +693,7 @@ public function alterDisplay(&$rows) { if (array_key_exists('civicrm_contact_contact_sub_type_a', $row)) { if ($value = $row['civicrm_contact_contact_sub_type_a']) { $rowValues = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value); - $rowLabels = array(); + $rowLabels = []; foreach ($rowValues as $rowValue) { if ($rowValue) { $rowLabels[] = CRM_Core_Pseudoconstant::getLabel('CRM_Contact_BAO_Contact', 'contact_sub_type', $rowValue); @@ -709,7 +709,7 @@ public function alterDisplay(&$rows) { if (array_key_exists('civicrm_contact_b_contact_sub_type_b', $row)) { if ($value = $row['civicrm_contact_b_contact_sub_type_b']) { $rowValues = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value); - $rowLabels = array(); + $rowLabels = []; foreach ($rowValues as $rowValue) { if ($rowValue) { $rowLabels[] = CRM_Core_Pseudoconstant::getLabel('CRM_Contact_BAO_Contact', 'contact_sub_type', $rowValue); @@ -837,7 +837,7 @@ public function activeClause( $fieldName, $relative, $from, $to, $type = NULL, $fromTime = NULL, $toTime = NULL ) { - $clauses = array(); + $clauses = []; if (in_array($relative, array_keys($this->getOperationPair(CRM_Report_Form::OP_DATE)))) { return NULL; } diff --git a/CRM/Report/Form/Contribute/Bookkeeping.php b/CRM/Report/Form/Contribute/Bookkeeping.php index 053b8b3718aa..753844af9894 100644 --- a/CRM/Report/Form/Contribute/Bookkeeping.php +++ b/CRM/Report/Form/Contribute/Bookkeeping.php @@ -34,12 +34,12 @@ class CRM_Report_Form_Contribute_Bookkeeping extends CRM_Report_Form { protected $_summary = NULL; - protected $_customGroupExtends = array( + protected $_customGroupExtends = [ 'Contact', 'Individual', 'Contribution', 'Membership', - ); + ]; /** * This report has not been optimised for group filtering. @@ -59,362 +59,362 @@ class CRM_Report_Form_Contribute_Bookkeeping extends CRM_Report_Form { */ public function __construct() { $this->_autoIncludeIndexedFieldsAsOrderBys = 1; - $this->_columns = array( - 'civicrm_contact' => array( + $this->_columns = [ + 'civicrm_contact' => [ 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => array( - 'sort_name' => array( + 'fields' => [ + 'sort_name' => [ 'title' => ts('Contact Name'), 'required' => TRUE, 'no_repeat' => TRUE, - ), - 'first_name' => array( + ], + 'first_name' => [ 'title' => ts('First Name'), - ), - 'middle_name' => array( + ], + 'middle_name' => [ 'title' => ts('Middle Name'), - ), - 'last_name' => array( + ], + 'last_name' => [ 'title' => ts('Last Name'), - ), - 'id' => array( + ], + 'id' => [ 'no_display' => TRUE, 'required' => TRUE, - ), - 'gender_id' => array( + ], + 'gender_id' => [ 'title' => ts('Gender'), - ), - 'birth_date' => array( + ], + 'birth_date' => [ 'title' => ts('Birth Date'), - ), - 'age' => array( + ], + 'age' => [ 'title' => ts('Age'), 'dbAlias' => 'TIMESTAMPDIFF(YEAR, contact_civireport.birth_date, CURDATE())', - ), - 'contact_type' => array( + ], + 'contact_type' => [ 'title' => ts('Contact Type'), - ), - 'contact_sub_type' => array( + ], + 'contact_sub_type' => [ 'title' => ts('Contact Subtype'), - ), - ), + ], + ], 'grouping' => 'contact-fields', - 'order_bys' => array( - 'sort_name' => array( + 'order_bys' => [ + 'sort_name' => [ 'title' => ts('Last Name, First Name'), 'default' => '1', 'default_weight' => '0', 'default_order' => 'ASC', - ), - 'first_name' => array( + ], + 'first_name' => [ 'name' => 'first_name', 'title' => ts('First Name'), - ), - 'gender_id' => array( + ], + 'gender_id' => [ 'name' => 'gender_id', 'title' => ts('Gender'), - ), - 'birth_date' => array( + ], + 'birth_date' => [ 'name' => 'birth_date', 'title' => ts('Birth Date'), - ), - 'contact_type' => array( + ], + 'contact_type' => [ 'title' => ts('Contact Type'), - ), - 'contact_sub_type' => array( + ], + 'contact_sub_type' => [ 'title' => ts('Contact Subtype'), - ), - ), - 'filters' => array( - 'sort_name' => array( + ], + ], + 'filters' => [ + 'sort_name' => [ 'title' => ts('Contact Name'), 'operator' => 'like', - ), - 'id' => array( + ], + 'id' => [ 'title' => ts('Contact ID'), 'no_display' => TRUE, - ), - 'gender_id' => array( + ], + 'gender_id' => [ 'title' => ts('Gender'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id'), - ), - 'birth_date' => array( + ], + 'birth_date' => [ 'title' => ts('Birth Date'), 'operatorType' => CRM_Report_Form::OP_DATE, - ), - 'contact_type' => array( + ], + 'contact_type' => [ 'title' => ts('Contact Type'), - ), - 'contact_sub_type' => array( + ], + 'contact_sub_type' => [ 'title' => ts('Contact Subtype'), - ), - ), - ), - 'civicrm_membership' => array( + ], + ], + ], + 'civicrm_membership' => [ 'dao' => 'CRM_Member_DAO_Membership', - 'fields' => array( - 'id' => array( + 'fields' => [ + 'id' => [ 'title' => ts('Membership #'), 'no_display' => TRUE, 'required' => TRUE, - ), - ), - ), - 'civicrm_financial_account' => array( + ], + ], + ], + 'civicrm_financial_account' => [ 'dao' => 'CRM_Financial_DAO_FinancialAccount', - 'fields' => array( - 'debit_accounting_code' => array( + 'fields' => [ + 'debit_accounting_code' => [ 'title' => ts('Financial Account Code - Debit'), 'name' => 'accounting_code', 'alias' => 'financial_account_civireport_debit', 'default' => TRUE, - ), - 'debit_contact_id' => array( + ], + 'debit_contact_id' => [ 'title' => ts('Financial Account Owner - Debit'), 'name' => 'organization_name', 'alias' => 'debit_contact', - ), - 'credit_accounting_code' => array( + ], + 'credit_accounting_code' => [ 'title' => ts('Financial Account Code - Credit'), 'name' => 'accounting_code', 'alias' => 'financial_account_civireport_credit', 'default' => TRUE, - ), - 'credit_contact_id' => array( + ], + 'credit_contact_id' => [ 'title' => ts('Financial Account Owner - Credit'), 'name' => 'organization_name', 'alias' => 'credit_contact', - ), - 'debit_name' => array( + ], + 'debit_name' => [ 'title' => ts('Financial Account Name - Debit'), 'name' => 'name', 'alias' => 'financial_account_civireport_debit', 'default' => TRUE, - ), - 'credit_name' => array( + ], + 'credit_name' => [ 'title' => ts('Financial Account Name - Credit'), 'name' => 'name', 'alias' => 'financial_account_civireport_credit', 'default' => TRUE, - ), - ), - 'filters' => array( - 'debit_accounting_code' => array( + ], + ], + 'filters' => [ + 'debit_accounting_code' => [ 'title' => ts('Financial Account Code - Debit'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::financialAccount(NULL, NULL, 'accounting_code', 'accounting_code'), 'name' => 'accounting_code', 'alias' => 'financial_account_civireport_debit', - ), - 'debit_contact_id' => array( + ], + 'debit_contact_id' => [ 'title' => ts('Financial Account Owner - Debit'), 'operatorType' => CRM_Report_Form::OP_SELECT, 'type' => CRM_Utils_Type::T_INT, - 'options' => array('' => '- Select Organization -') + CRM_Financial_BAO_FinancialAccount::getOrganizationNames(FALSE), + 'options' => ['' => '- Select Organization -'] + CRM_Financial_BAO_FinancialAccount::getOrganizationNames(FALSE), 'name' => 'contact_id', 'alias' => 'financial_account_civireport_debit', - ), - 'credit_accounting_code' => array( + ], + 'credit_accounting_code' => [ 'title' => ts('Financial Account Code - Credit'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::financialAccount(NULL, NULL, 'accounting_code', 'accounting_code'), 'name' => 'accounting_code', 'alias' => 'financial_account_civireport_credit', - ), - 'credit_contact_id' => array( + ], + 'credit_contact_id' => [ 'title' => ts('Financial Account Owner - Credit'), 'operatorType' => CRM_Report_Form::OP_SELECT, 'type' => CRM_Utils_Type::T_INT, - 'options' => array('' => '- Select Organization -') + CRM_Financial_BAO_FinancialAccount::getOrganizationNames(FALSE), + 'options' => ['' => '- Select Organization -'] + CRM_Financial_BAO_FinancialAccount::getOrganizationNames(FALSE), 'name' => 'contact_id', 'alias' => 'financial_account_civireport_credit', - ), - 'debit_name' => array( + ], + 'debit_name' => [ 'title' => ts('Financial Account Name - Debit'), 'type' => CRM_Utils_Type::T_STRING, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::financialAccount(), 'name' => 'id', 'alias' => 'financial_account_civireport_debit', - ), - 'credit_name' => array( + ], + 'credit_name' => [ 'title' => ts('Financial Account Name - Credit'), 'type' => CRM_Utils_Type::T_STRING, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::financialAccount(), 'name' => 'id', 'alias' => 'financial_account_civireport_credit', - ), - ), - ), - 'civicrm_line_item' => array( + ], + ], + ], + 'civicrm_line_item' => [ 'dao' => 'CRM_Price_DAO_LineItem', - 'fields' => array( - 'financial_type_id' => array( + 'fields' => [ + 'financial_type_id' => [ 'title' => ts('Financial Type'), 'default' => TRUE, - ), - ), - 'filters' => array( - 'financial_type_id' => array( + ], + ], + 'filters' => [ + 'financial_type_id' => [ 'title' => ts('Financial Type'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes(), - ), - ), - 'order_bys' => array( - 'financial_type_id' => array('title' => ts('Financial Type')), - ), - ), - 'civicrm_batch' => array( + ], + ], + 'order_bys' => [ + 'financial_type_id' => ['title' => ts('Financial Type')], + ], + ], + 'civicrm_batch' => [ 'dao' => 'CRM_Batch_DAO_Batch', - 'fields' => array( - 'title' => array( + 'fields' => [ + 'title' => [ 'title' => ts('Batch Title'), 'alias' => 'batch', 'default' => FALSE, - ), - 'name' => array( + ], + 'name' => [ 'title' => ts('Batch Name'), 'alias' => 'batch', 'default' => TRUE, - ), - ), - ), - 'civicrm_contribution' => array( + ], + ], + ], + 'civicrm_contribution' => [ 'dao' => 'CRM_Contribute_DAO_Contribution', - 'fields' => array( - 'receive_date' => array( + 'fields' => [ + 'receive_date' => [ 'default' => TRUE, - ), - 'invoice_id' => array( + ], + 'invoice_id' => [ 'title' => ts('Invoice Reference'), 'default' => TRUE, - ), - 'invoice_number' => array( + ], + 'invoice_number' => [ 'title' => ts('Invoice Number'), - ), - 'contribution_status_id' => array( + ], + 'contribution_status_id' => [ 'title' => ts('Contribution Status'), 'default' => TRUE, - ), - 'contribution_source' => array( + ], + 'contribution_source' => [ 'title' => ts('Source'), 'name' => 'source', - ), - 'id' => array( + ], + 'id' => [ 'title' => ts('Contribution ID'), 'default' => TRUE, - ), - ), - 'filters' => array( - 'contribution_id' => array( + ], + ], + 'filters' => [ + 'contribution_id' => [ 'title' => ts('Contribution ID'), 'name' => 'id', 'operatorType' => CRM_Report_Form::OP_INT, 'type' => CRM_Utils_Type::T_INT, - ), - 'receive_date' => array('operatorType' => CRM_Report_Form::OP_DATE), - 'contribution_source' => array( + ], + 'receive_date' => ['operatorType' => CRM_Report_Form::OP_DATE], + 'contribution_source' => [ 'title' => ts('Source'), 'name' => 'source', 'type' => CRM_Utils_Type::T_STRING, - ), - 'contribution_status_id' => array( + ], + 'contribution_status_id' => [ 'title' => ts('Contribution Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), - 'default' => array(1), - ), - ), - 'order_bys' => array( - 'contribution_id' => array('title' => ts('Contribution #')), - 'contribution_status_id' => array('title' => ts('Contribution Status')), - ), + 'default' => [1], + ], + ], + 'order_bys' => [ + 'contribution_id' => ['title' => ts('Contribution #')], + 'contribution_status_id' => ['title' => ts('Contribution Status')], + ], 'grouping' => 'contri-fields', - ), - 'civicrm_financial_trxn' => array( + ], + 'civicrm_financial_trxn' => [ 'dao' => 'CRM_Financial_DAO_FinancialTrxn', - 'fields' => array( - 'check_number' => array( + 'fields' => [ + 'check_number' => [ 'title' => ts('Cheque #'), 'default' => TRUE, - ), - 'payment_instrument_id' => array( + ], + 'payment_instrument_id' => [ 'title' => ts('Payment Method'), 'default' => TRUE, - ), - 'currency' => array( + ], + 'currency' => [ 'required' => TRUE, 'no_display' => TRUE, - ), - 'trxn_date' => array( + ], + 'trxn_date' => [ 'title' => ts('Transaction Date'), 'default' => TRUE, 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME, - ), - 'trxn_id' => array( + ], + 'trxn_id' => [ 'title' => ts('Trans #'), 'default' => TRUE, - ), - 'card_type_id' => array( + ], + 'card_type_id' => [ 'title' => ts('Credit Card Type'), - ), - ), - 'filters' => array( - 'payment_instrument_id' => array( + ], + ], + 'filters' => [ + 'payment_instrument_id' => [ 'title' => ts('Payment Method'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::paymentInstrument(), - ), - 'currency' => array( + ], + 'currency' => [ 'title' => ts('Currency'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_OptionGroup::values('currencies_enabled'), 'default' => NULL, 'type' => CRM_Utils_Type::T_STRING, - ), - 'trxn_date' => array( + ], + 'trxn_date' => [ 'title' => ts('Transaction Date'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME, - ), - 'status_id' => array( + ], + 'status_id' => [ 'title' => ts('Financial Transaction Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), - 'default' => array(1), - ), - 'card_type_id' => array( + 'default' => [1], + ], + 'card_type_id' => [ 'title' => ts('Credit Card Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Financial_DAO_FinancialTrxn::buildOptions('card_type_id'), 'default' => NULL, 'type' => CRM_Utils_Type::T_STRING, - ), - ), - 'order_bys' => array( - 'payment_instrument_id' => array('title' => ts('Payment Method')), - ), - ), - 'civicrm_entity_financial_trxn' => array( + ], + ], + 'order_bys' => [ + 'payment_instrument_id' => ['title' => ts('Payment Method')], + ], + ], + 'civicrm_entity_financial_trxn' => [ 'dao' => 'CRM_Financial_DAO_EntityFinancialTrxn', - 'fields' => array( - 'amount' => array( + 'fields' => [ + 'amount' => [ 'title' => ts('Amount'), 'default' => TRUE, 'type' => CRM_Utils_Type::T_STRING, - ), - ), - 'filters' => array( - 'amount' => array('title' => ts('Amount')), - ), - ), - ); + ], + ], + 'filters' => [ + 'amount' => ['title' => ts('Amount')], + ], + ], + ]; $this->_groupFilter = TRUE; $this->_tagFilter = TRUE; @@ -426,9 +426,9 @@ public function preProcess() { } public function select() { - $select = array(); + $select = []; - $this->_columnHeaders = array(); + $this->_columnHeaders = []; foreach ($this->_columns as $tableName => $table) { if (array_key_exists('fields', $table)) { foreach ($table['fields'] as $fieldName => $field) { @@ -537,11 +537,11 @@ public function where() { if (array_key_exists('filters', $table)) { foreach ($table['filters'] as $fieldName => $field) { $clause = NULL; - if (in_array($fieldName, array( + if (in_array($fieldName, [ 'credit_accounting_code', 'credit_name', 'credit_contact_id', - ) + ] )) { $field['dbAlias'] = "CASE WHEN financial_trxn_civireport.from_financial_account_id IS NOT NULL @@ -588,10 +588,10 @@ public function postProcess() { } public function groupBy() { - $groupBy = array( + $groupBy = [ "{$this->_aliases['civicrm_entity_financial_trxn']}.id", "{$this->_aliases['civicrm_line_item']}.id", - ); + ]; $this->_groupBy = CRM_Contact_BAO_Query::getGroupByFromSelectColumns($this->_selectClauses, $groupBy); } @@ -607,12 +607,12 @@ public function statistics(&$rows) { ELSE {$this->_aliases['civicrm_entity_financial_trxn']}.amount END as amount"; - $this->_selectClauses = array( + $this->_selectClauses = [ "{$this->_aliases['civicrm_contribution']}.id", "{$this->_aliases['civicrm_entity_financial_trxn']}.id as trxnID", "{$this->_aliases['civicrm_contribution']}.currency", $financialSelect, - ); + ]; $select = "SELECT " . implode(', ', $this->_selectClauses); $this->groupBy(); @@ -624,23 +624,23 @@ public function statistics(&$rows) { FROM {$tempTableName} GROUP BY currency"; $dao = CRM_Core_DAO::executeQuery($sql); - $amount = $avg = array(); + $amount = $avg = []; while ($dao->fetch()) { $amount[] = CRM_Utils_Money::format($dao->amount, $dao->currency); $avg[] = CRM_Utils_Money::format(round(($dao->amount / $dao->count), 2), $dao->currency); } - $statistics['counts']['amount'] = array( + $statistics['counts']['amount'] = [ 'value' => implode(', ', $amount), 'title' => ts('Total Amount'), 'type' => CRM_Utils_Type::T_STRING, - ); - $statistics['counts']['avg'] = array( + ]; + $statistics['counts']['avg'] = [ 'value' => implode(', ', $avg), 'title' => ts('Average'), 'type' => CRM_Utils_Type::T_STRING, - ); + ]; return $statistics; } diff --git a/CRM/Report/Form/Contribute/DeferredRevenue.php b/CRM/Report/Form/Contribute/DeferredRevenue.php index 96846184b8d5..837a417c3aba 100644 --- a/CRM/Report/Form/Contribute/DeferredRevenue.php +++ b/CRM/Report/Form/Contribute/DeferredRevenue.php @@ -37,235 +37,235 @@ class CRM_Report_Form_Contribute_DeferredRevenue extends CRM_Report_Form { /** * Holds Deferred Financial Account */ - protected $_deferredFinancialAccount = array(); + protected $_deferredFinancialAccount = []; /** */ public function __construct() { $this->_exposeContactID = FALSE; $this->_deferredFinancialAccount = CRM_Financial_BAO_FinancialAccount::getAllDeferredFinancialAccount(); - $this->_columns = array( - 'civicrm_financial_trxn' => array( + $this->_columns = [ + 'civicrm_financial_trxn' => [ 'dao' => 'CRM_Financial_DAO_FinancialTrxn', - 'fields' => array( - 'status_id' => array( + 'fields' => [ + 'status_id' => [ 'title' => ts('Transaction'), - ), - 'trxn_date' => array( + ], + 'trxn_date' => [ 'title' => ts('Transaction Date'), 'type' => CRM_Utils_Type::T_DATE, 'required' => TRUE, - ), - 'total_amount' => array( + ], + 'total_amount' => [ 'title' => ts('Transaction Amount'), 'type' => CRM_Utils_Type::T_MONEY, 'required' => TRUE, 'dbAlias' => 'SUM(financial_trxn_1_civireport.total_amount )', - ), - ), - 'filters' => array( - 'trxn_date' => array( + ], + ], + 'filters' => [ + 'trxn_date' => [ 'title' => ts('Transaction Date'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE, - ), - ), - ), - 'civicrm_contribution' => array( + ], + ], + ], + 'civicrm_contribution' => [ 'dao' => 'CRM_Contribute_DAO_Contribution', - 'fields' => array( - 'id' => array( + 'fields' => [ + 'id' => [ 'title' => ts('Contribution ID'), - ), - 'contribution_id' => array( + ], + 'contribution_id' => [ 'title' => ts('Contribution ID'), 'required' => TRUE, 'no_display' => TRUE, 'dbAlias' => 'contribution_civireport.id', - ), - 'contact_id' => array( + ], + 'contact_id' => [ 'title' => ts('Contact ID'), - ), - 'source' => array( + ], + 'source' => [ 'title' => ts('Source'), - ), - 'receive_date' => array( + ], + 'receive_date' => [ 'title' => ts('Receive Date'), 'type' => CRM_Utils_Type::T_DATE, - ), - 'cancel_date' => array( + ], + 'cancel_date' => [ 'title' => ts('Cancel Date'), 'type' => CRM_Utils_Type::T_DATE, - ), - 'revenue_recognition_date' => array( + ], + 'revenue_recognition_date' => [ 'title' => ts('Revenue Recognition Date'), 'type' => CRM_Utils_Type::T_DATE, - ), - ), - 'filters' => array( - 'receive_date' => array( + ], + ], + 'filters' => [ + 'receive_date' => [ 'title' => ts('Receive Date'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE, - ), - 'cancel_date' => array( + ], + 'cancel_date' => [ 'title' => ts('Cancel Date'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE, - ), - 'revenue_recognition_date' => array( + ], + 'revenue_recognition_date' => [ 'title' => ts('Revenue Recognition Date'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE, - ), - 'revenue_recognition_date_toggle' => array( + ], + 'revenue_recognition_date_toggle' => [ 'title' => ts("Current month's revenue?"), 'type' => CRM_Utils_Type::T_BOOLEAN, 'default' => 0, 'pseudofield' => TRUE, - ), - ), - ), - 'civicrm_financial_account' => array( + ], + ], + ], + 'civicrm_financial_account' => [ 'dao' => 'CRM_Financial_DAO_FinancialAccount', - 'fields' => array( - 'name' => array( + 'fields' => [ + 'name' => [ 'title' => ts('Deferred Account'), 'required' => TRUE, 'no_display' => TRUE, - ), - 'id' => array( + ], + 'id' => [ 'title' => ts('Deferred Account ID'), 'required' => TRUE, 'no_display' => TRUE, - ), - 'accounting_code' => array( + ], + 'accounting_code' => [ 'title' => ts('Deferred Accounting Code'), 'required' => TRUE, 'no_display' => TRUE, - ), - ), - 'filters' => array( - 'id' => array( + ], + ], + 'filters' => [ + 'id' => [ 'title' => ts('Deferred Financial Account'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->_deferredFinancialAccount, 'type' => CRM_Utils_Type::T_INT, - ), - ), - ), - 'civicrm_financial_account_1' => array( + ], + ], + ], + 'civicrm_financial_account_1' => [ 'dao' => 'CRM_Financial_DAO_FinancialAccount', - 'fields' => array( - 'name' => array( + 'fields' => [ + 'name' => [ 'title' => ts('Revenue Account'), 'required' => TRUE, 'no_display' => TRUE, - ), - 'id' => array( + ], + 'id' => [ 'title' => ts('Revenue Account ID'), 'required' => TRUE, 'no_display' => TRUE, - ), - 'accounting_code' => array( + ], + 'accounting_code' => [ 'title' => ts('Revenue Accounting code'), 'no_display' => TRUE, 'required' => TRUE, - ), - ), - ), - 'civicrm_financial_item' => array( + ], + ], + ], + 'civicrm_financial_item' => [ 'dao' => 'CRM_Financial_DAO_FinancialItem', - 'fields' => array( - 'status_id' => array( + 'fields' => [ + 'status_id' => [ 'title' => ts('Status'), 'required' => TRUE, 'no_display' => TRUE, - ), - 'id' => array( + ], + 'id' => [ 'title' => ts('Financial Item ID'), 'required' => TRUE, 'no_display' => TRUE, - ), - 'description' => array( + ], + 'description' => [ 'title' => ts('Item'), - ), - ), - ), - 'civicrm_financial_trxn_1' => array( + ], + ], + ], + 'civicrm_financial_trxn_1' => [ 'dao' => 'CRM_Financial_DAO_FinancialTrxn', - 'fields' => array( - 'total_amount' => array( + 'fields' => [ + 'total_amount' => [ 'title' => ts('Deferred Transaction Amount'), 'type' => CRM_Utils_Type::T_MONEY, 'required' => TRUE, 'no_display' => TRUE, 'dbAlias' => 'GROUP_CONCAT(financial_trxn_1_civireport.total_amount)', - ), - 'trxn_date' => array( + ], + 'trxn_date' => [ 'title' => ts('Deferred Transaction Date'), 'required' => TRUE, 'no_display' => TRUE, 'dbAlias' => 'GROUP_CONCAT(financial_trxn_1_civireport.trxn_date)', 'type' => CRM_Utils_Type::T_DATE, - ), - ), - ), - 'civicrm_contact' => array( + ], + ], + ], + 'civicrm_contact' => [ 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => array( - 'display_name' => array( + 'fields' => [ + 'display_name' => [ 'title' => ts('Contact Name'), - ), - 'id' => array( + ], + 'id' => [ 'title' => ts('Contact ID'), 'required' => TRUE, 'no_display' => TRUE, - ), - ), - ), - 'civicrm_membership' => array( + ], + ], + ], + 'civicrm_membership' => [ 'dao' => 'CRM_Member_DAO_Membership', - 'fields' => array( - 'start_date' => array( + 'fields' => [ + 'start_date' => [ 'title' => ts('Start Date'), 'dbAlias' => 'IFNULL(membership_civireport.start_date, event_civireport.start_date)', 'type' => CRM_Utils_Type::T_DATE, - ), - 'end_date' => array( + ], + 'end_date' => [ 'title' => ts('End Date'), 'dbdbAlias' => 'IFNULL(membership_civireport.end_date, event_civireport.end_date)', 'type' => CRM_Utils_Type::T_DATE, - ), - ), - ), - 'civicrm_event' => array( + ], + ], + ], + 'civicrm_event' => [ 'dao' => 'CRM_Event_DAO_Event', - ), - 'civicrm_participant' => array( + ], + 'civicrm_participant' => [ 'dao' => 'CRM_Event_DAO_Participant', - ), - 'civicrm_batch' => array( + ], + 'civicrm_batch' => [ 'dao' => 'CRM_Batch_DAO_EntityBatch', 'grouping' => 'contri-fields', - 'fields' => array( - 'batch_id' => array( + 'fields' => [ + 'batch_id' => [ 'title' => ts('Batch Title'), 'dbAlias' => "GROUP_CONCAT(DISTINCT batch_civireport.batch_id ORDER BY batch_civireport.batch_id SEPARATOR ',')", - ), - ), - 'filters' => array( - 'batch_id' => array( + ], + ], + 'filters' => [ + 'batch_id' => [ 'title' => ts('Batch Title'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Batch_BAO_Batch::getBatches(), 'type' => CRM_Utils_Type::T_INT, - ), - ), - ), - ); + ], + ], + ], + ]; parent::__construct(); } @@ -386,10 +386,10 @@ public function groupBy() { $this->_groupBy = "GROUP BY {$this->_aliases['civicrm_financial_account']}.id, {$this->_aliases['civicrm_financial_account_1']}.id, {$this->_aliases['civicrm_financial_item']}.id"; $this->_select = CRM_Contact_BAO_Query::appendAnyValueToSelect( $this->_selectClauses, - array( + [ "{$this->_aliases['civicrm_financial_account_1']}.id", "{$this->_aliases['civicrm_financial_item']}.id", - ) + ] ); } @@ -398,7 +398,7 @@ public function groupBy() { */ public function modifyColumnHeaders() { // Re-order the columns in a custom order defined below. - $sortArray = array( + $sortArray = [ 'civicrm_batch_batch_id', 'civicrm_financial_trxn_status_id', 'civicrm_financial_trxn_trxn_date', @@ -410,7 +410,7 @@ public function modifyColumnHeaders() { 'civicrm_contribution_contact_id', 'civicrm_contact_display_name', 'civicrm_contribution_source', - ); + ]; // Only re-order selected columns. $sortArray = array_flip(array_intersect_key(array_flip($sortArray), $this->_columnHeaders)); @@ -419,17 +419,17 @@ public function modifyColumnHeaders() { // Add months to the columns. if ($this->_params['revenue_recognition_date_toggle_value']) { - $this->_columnHeaders[date('M, Y', strtotime(date('Y-m-d')))] = array( + $this->_columnHeaders[date('M, Y', strtotime(date('Y-m-d')))] = [ 'title' => date('M, Y', strtotime(date('Y-m-d'))), 'type' => CRM_Utils_Type::T_DATE, - ); + ]; } else { for ($i = 0; $i < 12; $i++) { - $this->_columnHeaders[date('M, Y', strtotime(date('Y-m-d') . "+{$i} month"))] = array( + $this->_columnHeaders[date('M, Y', strtotime(date('Y-m-d') . "+{$i} month"))] = [ 'title' => date('M, Y', strtotime(date('Y-m-d') . "+{$i} month")), 'type' => CRM_Utils_Type::T_DATE, - ); + ]; } } } @@ -450,11 +450,11 @@ public function buildRows($sql, &$rows) { $dateFormat = Civi::settings()->get('dateformatFinancialBatch'); if (!is_array($rows)) { - $rows = array(); + $rows = []; } while ($dao->fetch()) { - $row = array(); + $row = []; foreach ($this->_columnHeaders as $key => $value) { $arraykey = $dao->civicrm_financial_account_id . '_' . $dao->civicrm_financial_account_1_id; diff --git a/CRM/Report/Form/Contribute/Detail.php b/CRM/Report/Form/Contribute/Detail.php index accac0c1e195..82060fafdd8b 100644 --- a/CRM/Report/Form/Contribute/Detail.php +++ b/CRM/Report/Form/Contribute/Detail.php @@ -38,11 +38,11 @@ class CRM_Report_Form_Contribute_Detail extends CRM_Report_Form { protected $noDisplayContributionOrSoftColumn = FALSE; - protected $_customGroupExtends = array( + protected $_customGroupExtends = [ 'Contact', 'Individual', 'Contribution', - ); + ]; protected $groupConcatTested = TRUE; @@ -86,276 +86,276 @@ class CRM_Report_Form_Contribute_Detail extends CRM_Report_Form { */ public function __construct() { $this->_autoIncludeIndexedFieldsAsOrderBys = 1; - $this->_columns = array_merge($this->getColumns('Contact', array( - 'order_bys_defaults' => array('sort_name' => 'ASC '), - 'fields_defaults' => array('sort_name'), - 'fields_excluded' => array('id'), - 'fields_required' => array('id'), - 'filters_defaults' => array('is_deleted' => 0), + $this->_columns = array_merge($this->getColumns('Contact', [ + 'order_bys_defaults' => ['sort_name' => 'ASC '], + 'fields_defaults' => ['sort_name'], + 'fields_excluded' => ['id'], + 'fields_required' => ['id'], + 'filters_defaults' => ['is_deleted' => 0], 'no_field_disambiguation' => TRUE, - )), array( - 'civicrm_email' => array( + ]), [ + 'civicrm_email' => [ 'dao' => 'CRM_Core_DAO_Email', - 'fields' => array( - 'email' => array( + 'fields' => [ + 'email' => [ 'title' => ts('Donor Email'), 'default' => TRUE, - ), - ), + ], + ], 'grouping' => 'contact-fields', - ), - 'civicrm_line_item' => array( + ], + 'civicrm_line_item' => [ 'dao' => 'CRM_Price_DAO_LineItem', - ), - 'civicrm_phone' => array( + ], + 'civicrm_phone' => [ 'dao' => 'CRM_Core_DAO_Phone', - 'fields' => array( - 'phone' => array( + 'fields' => [ + 'phone' => [ 'title' => ts('Donor Phone'), 'default' => TRUE, 'no_repeat' => TRUE, - ), - ), + ], + ], 'grouping' => 'contact-fields', - ), - 'civicrm_contribution' => array( + ], + 'civicrm_contribution' => [ 'dao' => 'CRM_Contribute_DAO_Contribution', - 'fields' => array( - 'contribution_id' => array( + 'fields' => [ + 'contribution_id' => [ 'name' => 'id', 'no_display' => TRUE, 'required' => TRUE, - ), - 'list_contri_id' => array( + ], + 'list_contri_id' => [ 'name' => 'id', 'title' => ts('Contribution ID'), - ), - 'financial_type_id' => array( + ], + 'financial_type_id' => [ 'title' => ts('Financial Type'), 'default' => TRUE, - ), - 'contribution_status_id' => array( + ], + 'contribution_status_id' => [ 'title' => ts('Contribution Status'), - ), - 'contribution_page_id' => array( + ], + 'contribution_page_id' => [ 'title' => ts('Contribution Page'), - ), - 'source' => array( + ], + 'source' => [ 'title' => ts('Source'), - ), - 'payment_instrument_id' => array( + ], + 'payment_instrument_id' => [ 'title' => ts('Payment Type'), - ), - 'check_number' => array( + ], + 'check_number' => [ 'title' => ts('Check Number'), - ), - 'currency' => array( + ], + 'currency' => [ 'required' => TRUE, 'no_display' => TRUE, - ), + ], 'trxn_id' => NULL, - 'receive_date' => array('default' => TRUE), + 'receive_date' => ['default' => TRUE], 'receipt_date' => NULL, 'thankyou_date' => NULL, - 'total_amount' => array( + 'total_amount' => [ 'title' => ts('Amount'), 'required' => TRUE, - ), - 'non_deductible_amount' => array( + ], + 'non_deductible_amount' => [ 'title' => ts('Non-deductible Amount'), - ), + ], 'fee_amount' => NULL, 'net_amount' => NULL, - 'contribution_or_soft' => array( + 'contribution_or_soft' => [ 'title' => ts('Contribution OR Soft Credit?'), 'dbAlias' => "'Contribution'", - ), - 'soft_credits' => array( + ], + 'soft_credits' => [ 'title' => ts('Soft Credits'), 'dbAlias' => "NULL", - ), - 'soft_credit_for' => array( + ], + 'soft_credit_for' => [ 'title' => ts('Soft Credit For'), 'dbAlias' => "NULL", - ), - 'cancel_date' => array( + ], + 'cancel_date' => [ 'title' => ts('Cancelled / Refunded Date'), - ), - 'cancel_reason' => array( + ], + 'cancel_reason' => [ 'title' => ts('Cancellation / Refund Reason'), - ), - ), - 'filters' => array( - 'contribution_or_soft' => array( + ], + ], + 'filters' => [ + 'contribution_or_soft' => [ 'title' => ts('Contribution OR Soft Credit?'), 'clause' => "(1)", 'operatorType' => CRM_Report_Form::OP_SELECT, 'type' => CRM_Utils_Type::T_STRING, - 'options' => array( + 'options' => [ 'contributions_only' => ts('Contributions Only'), 'soft_credits_only' => ts('Soft Credits Only'), 'both' => ts('Both'), - ), - ), - 'receive_date' => array('operatorType' => CRM_Report_Form::OP_DATE), - 'thankyou_date' => array('operatorType' => CRM_Report_Form::OP_DATE), - 'contribution_source' => array( + ], + ], + 'receive_date' => ['operatorType' => CRM_Report_Form::OP_DATE], + 'thankyou_date' => ['operatorType' => CRM_Report_Form::OP_DATE], + 'contribution_source' => [ 'title' => ts('Source'), 'name' => 'source', 'type' => CRM_Utils_Type::T_STRING, - ), - 'currency' => array( + ], + 'currency' => [ 'title' => ts('Currency'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_OptionGroup::values('currencies_enabled'), 'default' => NULL, 'type' => CRM_Utils_Type::T_STRING, - ), - 'non_deductible_amount' => array( + ], + 'non_deductible_amount' => [ 'title' => ts('Non-deductible Amount'), - ), - 'financial_type_id' => array( + ], + 'financial_type_id' => [ 'title' => ts('Financial Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes(), 'type' => CRM_Utils_Type::T_INT, - ), - 'contribution_page_id' => array( + ], + 'contribution_page_id' => [ 'title' => ts('Contribution Page'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::contributionPage(), 'type' => CRM_Utils_Type::T_INT, - ), - 'payment_instrument_id' => array( + ], + 'payment_instrument_id' => [ 'title' => ts('Payment Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::paymentInstrument(), 'type' => CRM_Utils_Type::T_INT, - ), - 'contribution_status_id' => array( + ], + 'contribution_status_id' => [ 'title' => ts('Contribution Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), - 'default' => array(1), + 'default' => [1], 'type' => CRM_Utils_Type::T_INT, - ), - 'total_amount' => array('title' => ts('Contribution Amount')), - 'cancel_date' => array( + ], + 'total_amount' => ['title' => ts('Contribution Amount')], + 'cancel_date' => [ 'title' => ts('Cancelled / Refunded Date'), 'operatorType' => CRM_Report_Form::OP_DATE, - ), - 'cancel_reason' => array( + ], + 'cancel_reason' => [ 'title' => ts('Cancellation / Refund Reason'), - ), - ), - 'order_bys' => array( - 'financial_type_id' => array('title' => ts('Financial Type')), - 'contribution_status_id' => array('title' => ts('Contribution Status')), - 'payment_instrument_id' => array('title' => ts('Payment Method')), - 'receive_date' => array('title' => ts('Date Received')), - 'thankyou_date' => array('title' => ts('Thank-you Date')), - ), - 'group_bys' => array( - 'contribution_id' => array( + ], + ], + 'order_bys' => [ + 'financial_type_id' => ['title' => ts('Financial Type')], + 'contribution_status_id' => ['title' => ts('Contribution Status')], + 'payment_instrument_id' => ['title' => ts('Payment Method')], + 'receive_date' => ['title' => ts('Date Received')], + 'thankyou_date' => ['title' => ts('Thank-you Date')], + ], + 'group_bys' => [ + 'contribution_id' => [ 'name' => 'id', 'required' => TRUE, 'default' => TRUE, 'title' => ts('Contribution'), - ), - ), + ], + ], 'grouping' => 'contri-fields', - ), - 'civicrm_contribution_soft' => array( + ], + 'civicrm_contribution_soft' => [ 'dao' => 'CRM_Contribute_DAO_ContributionSoft', - 'fields' => array( - 'soft_credit_type_id' => array('title' => ts('Soft Credit Type')), + 'fields' => [ + 'soft_credit_type_id' => ['title' => ts('Soft Credit Type')], 'soft_credit_amount' => ['title' => ts('Soft Credit amount'), 'name' => 'amount', 'type' => CRM_Utils_Type::T_MONEY], - ), - 'filters' => array( - 'soft_credit_type_id' => array( + ], + 'filters' => [ + 'soft_credit_type_id' => [ 'title' => ts('Soft Credit Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_OptionGroup::values('soft_credit_type'), 'default' => NULL, 'type' => CRM_Utils_Type::T_STRING, - ), - ), - 'group_bys' => array( - 'soft_credit_id' => array( + ], + ], + 'group_bys' => [ + 'soft_credit_id' => [ 'name' => 'id', 'title' => ts('Soft Credit'), - ), - ), - ), - 'civicrm_financial_trxn' => array( + ], + ], + ], + 'civicrm_financial_trxn' => [ 'dao' => 'CRM_Financial_DAO_FinancialTrxn', - 'fields' => array( - 'card_type_id' => array( + 'fields' => [ + 'card_type_id' => [ 'title' => ts('Credit Card Type'), - ), - ), - 'filters' => array( - 'card_type_id' => array( + ], + ], + 'filters' => [ + 'card_type_id' => [ 'title' => ts('Credit Card Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Financial_DAO_FinancialTrxn::buildOptions('card_type_id'), 'default' => NULL, 'type' => CRM_Utils_Type::T_STRING, - ), - ), - ), - 'civicrm_batch' => array( + ], + ], + ], + 'civicrm_batch' => [ 'dao' => 'CRM_Batch_DAO_EntityBatch', 'grouping' => 'contri-fields', - 'fields' => array( - 'batch_id' => array( + 'fields' => [ + 'batch_id' => [ 'name' => 'batch_id', 'title' => ts('Batch Name'), - ), - ), - 'filters' => array( - 'bid' => array( + ], + ], + 'filters' => [ + 'bid' => [ 'title' => ts('Batch Name'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Batch_BAO_Batch::getBatches(), 'type' => CRM_Utils_Type::T_INT, 'dbAlias' => 'batch_civireport.batch_id', - ), - ), - ), - 'civicrm_contribution_ordinality' => array( + ], + ], + ], + 'civicrm_contribution_ordinality' => [ 'dao' => 'CRM_Contribute_DAO_Contribution', 'alias' => 'cordinality', - 'filters' => array( - 'ordinality' => array( + 'filters' => [ + 'ordinality' => [ 'title' => ts('Contribution Ordinality'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => array( + 'options' => [ 0 => 'First by Contributor', 1 => 'Second or Later by Contributor', - ), + ], 'type' => CRM_Utils_Type::T_INT, - ), - ), - ), - 'civicrm_note' => array( + ], + ], + ], + 'civicrm_note' => [ 'dao' => 'CRM_Core_DAO_Note', - 'fields' => array( - 'contribution_note' => array( + 'fields' => [ + 'contribution_note' => [ 'name' => 'note', 'title' => ts('Contribution Note'), - ), - ), - 'filters' => array( - 'note' => array( + ], + ], + 'filters' => [ + 'note' => [ 'name' => 'note', 'title' => ts('Contribution Note'), 'operator' => 'like', 'type' => CRM_Utils_Type::T_STRING, - ), - ), - ), - )) + $this->addAddressFields(FALSE); + ], + ], + ], + ]) + $this->addAddressFields(FALSE); // The tests test for this variation of the sort_name field. Don't argue with the tests :-). $this->_columns['civicrm_contact']['fields']['sort_name']['title'] = ts('Donor Name'); $this->_groupFilter = TRUE; @@ -408,7 +408,7 @@ public function from() { public function statistics(&$rows) { $statistics = parent::statistics($rows); - $totalAmount = $average = $fees = $net = array(); + $totalAmount = $average = $fees = $net = []; $count = 0; $select = " SELECT COUNT({$this->_aliases['civicrm_contribution']}.total_amount ) as count, @@ -431,37 +431,37 @@ public function statistics(&$rows) { $average[] = CRM_Utils_Money::format($dao->avg, $dao->currency); $count += $dao->count; } - $statistics['counts']['amount'] = array( + $statistics['counts']['amount'] = [ 'title' => ts('Total Amount (Contributions)'), 'value' => implode(', ', $totalAmount), 'type' => CRM_Utils_Type::T_STRING, - ); - $statistics['counts']['count'] = array( + ]; + $statistics['counts']['count'] = [ 'title' => ts('Total Contributions'), 'value' => $count, - ); - $statistics['counts']['fees'] = array( + ]; + $statistics['counts']['fees'] = [ 'title' => ts('Fees'), 'value' => implode(', ', $fees), 'type' => CRM_Utils_Type::T_STRING, - ); - $statistics['counts']['net'] = array( + ]; + $statistics['counts']['net'] = [ 'title' => ts('Net'), 'value' => implode(', ', $net), 'type' => CRM_Utils_Type::T_STRING, - ); - $statistics['counts']['avg'] = array( + ]; + $statistics['counts']['avg'] = [ 'title' => ts('Average'), 'value' => implode(', ', $average), 'type' => CRM_Utils_Type::T_STRING, - ); + ]; // Stats for soft credits if ($this->_softFrom && CRM_Utils_Array::value('contribution_or_soft_value', $this->_params) != 'contributions_only' ) { - $totalAmount = $average = array(); + $totalAmount = $average = []; $count = 0; $select = " SELECT COUNT(contribution_soft_civireport.amount ) as count, @@ -480,20 +480,20 @@ public function statistics(&$rows) { $average[] = CRM_Utils_Money::format($dao->avg, $dao->currency); $count += $dao->count; } - $statistics['counts']['softamount'] = array( + $statistics['counts']['softamount'] = [ 'title' => ts('Total Amount (Soft Credits)'), 'value' => implode(', ', $totalAmount), 'type' => CRM_Utils_Type::T_STRING, - ); - $statistics['counts']['softcount'] = array( + ]; + $statistics['counts']['softcount'] = [ 'title' => ts('Total Soft Credits'), 'value' => $count, - ); - $statistics['counts']['softavg'] = array( + ]; + $statistics['counts']['softavg'] = [ 'title' => ts('Average (Soft Credits)'), 'value' => implode(', ', $average), 'type' => CRM_Utils_Type::T_STRING, - ); + ]; } return $statistics; @@ -537,7 +537,7 @@ public function beginPostProcessCommon() { ) { unset($this->_params['fields']['soft_credit_type_id']); if (!empty($this->_params['soft_credit_type_id_value'])) { - $this->_params['soft_credit_type_id_value'] = array(); + $this->_params['soft_credit_type_id_value'] = []; CRM_Core_Session::setStatus(ts('Is it not possible to filter on soft contribution type when not including soft credits.')); } } @@ -828,7 +828,7 @@ public function sectionTotals() { // pull section aliases out of $this->_sections $sectionAliases = array_keys($this->_sections); - $ifnulls = array(); + $ifnulls = []; foreach (array_merge($sectionAliases, $this->_selectAliases) as $alias) { $ifnulls[] = "ifnull($alias, '') as $alias"; } @@ -853,7 +853,7 @@ public function sectionTotals() { "$addtotals, count(*) as ct from {$this->temporaryTables['civireport_contribution_detail_temp3']['name']} group by " . implode(", ", $sectionAliases); // initialize array of total counts - $sumcontribs = $totals = array(); + $sumcontribs = $totals = []; $dao = CRM_Core_DAO::executeQuery($query); $this->addToDeveloperTab($query); while ($dao->fetch()) { @@ -864,7 +864,7 @@ public function sectionTotals() { $row = $rows[0]; // add totals for all permutations of section values - $values = array(); + $values = []; $i = 1; $aliasCount = count($sectionAliases); foreach ($sectionAliases as $alias) { @@ -887,7 +887,7 @@ public function sectionTotals() { } } if ($showsumcontribs) { - $totalandsum = array(); + $totalandsum = []; // ts exception to avoid having ts("%1 %2: %3") $title = '%1 contributions / soft-credits: %2'; @@ -902,10 +902,10 @@ public function sectionTotals() { $title = '%1 soft-credits: %2'; } foreach ($totals as $key => $total) { - $totalandsum[$key] = ts($title, array( + $totalandsum[$key] = ts($title, [ 1 => $total, 2 => CRM_Utils_Money::format($sumcontribs[$key]), - )); + ]); } $this->assign('sectionTotals', $totalandsum); } diff --git a/CRM/Report/Form/Contribute/History.php b/CRM/Report/Form/Contribute/History.php index a0e407561236..89b0dfe4b9ac 100644 --- a/CRM/Report/Form/Contribute/History.php +++ b/CRM/Report/Form/Contribute/History.php @@ -33,18 +33,18 @@ class CRM_Report_Form_Contribute_History extends CRM_Report_Form { // Primary Contacts count limitCONSTROW_COUNT_LIMIT = 10; - protected $_relationshipColumns = array(); + protected $_relationshipColumns = []; - protected $_customGroupExtends = array( + protected $_customGroupExtends = [ 'Contact', 'Individual', 'Contribution', - ); + ]; - protected $_referenceYear = array( + protected $_referenceYear = [ 'this_year' => '', 'other_year' => '', - ); + ]; protected $_yearStatisticsFrom = ''; protected $_yearStatisticsTo = ''; @@ -56,7 +56,7 @@ public function __construct() { $yearsInPast = 4; $date = CRM_Core_SelectValues::date('custom', NULL, $yearsInPast, 0); $count = $date['maxYear']; - $optionYear = array('' => ts('- select -')); + $optionYear = ['' => ts('- select -')]; $this->_yearStatisticsFrom = $date['minYear']; $this->_yearStatisticsTo = $date['maxYear']; @@ -66,7 +66,7 @@ public function __construct() { $date['minYear']++; } - $relationTypeOp = array(); + $relationTypeOp = []; $relationshipTypes = CRM_Core_PseudoConstant::relationshipType(); foreach ($relationshipTypes as $rid => $rtype) { if ($rtype['label_a_b'] != $rtype['label_b_a']) { @@ -77,239 +77,239 @@ public function __construct() { } } - $this->_columns = array( - 'civicrm_contact' => array( + $this->_columns = [ + 'civicrm_contact' => [ 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => array( - 'sort_name' => array( + 'fields' => [ + 'sort_name' => [ 'title' => ts('Contact Name'), 'default' => TRUE, 'required' => TRUE, 'no_repeat' => TRUE, - ), - 'first_name' => array( + ], + 'first_name' => [ 'title' => ts('First Name'), - ), - 'middle_name' => array( + ], + 'middle_name' => [ 'title' => ts('Middle Name'), - ), - 'last_name' => array( + ], + 'last_name' => [ 'title' => ts('Last Name'), - ), - 'id' => array( + ], + 'id' => [ 'no_display' => TRUE, 'default' => TRUE, 'required' => TRUE, - ), - 'gender_id' => array( + ], + 'gender_id' => [ 'title' => ts('Gender'), - ), - 'birth_date' => array( + ], + 'birth_date' => [ 'title' => ts('Birth Date'), - ), - 'age' => array( + ], + 'age' => [ 'title' => ts('Age'), 'dbAlias' => 'TIMESTAMPDIFF(YEAR, contact_civireport.birth_date, CURDATE())', - ), - 'contact_type' => array( + ], + 'contact_type' => [ 'title' => ts('Contact Type'), - ), - 'contact_sub_type' => array( + ], + 'contact_sub_type' => [ 'title' => ts('Contact Subtype'), - ), - ), + ], + ], 'grouping' => 'contact-fields', - 'order_bys' => array( - 'sort_name' => array( + 'order_bys' => [ + 'sort_name' => [ 'title' => ts('Last Name, First Name'), 'default' => '1', 'default_weight' => '0', 'default_order' => 'ASC', - ), - 'first_name' => array( + ], + 'first_name' => [ 'name' => 'first_name', 'title' => ts('First Name'), - ), - 'gender_id' => array( + ], + 'gender_id' => [ 'name' => 'gender_id', 'title' => ts('Gender'), - ), - 'birth_date' => array( + ], + 'birth_date' => [ 'name' => 'birth_date', 'title' => ts('Birth Date'), - ), - 'contact_type' => array( + ], + 'contact_type' => [ 'title' => ts('Contact Type'), - ), - 'contact_sub_type' => array( + ], + 'contact_sub_type' => [ 'title' => ts('Contact Subtype'), - ), - ), - 'filters' => array( - 'sort_name' => array('title' => ts('Contact Name')), - 'id' => array( + ], + ], + 'filters' => [ + 'sort_name' => ['title' => ts('Contact Name')], + 'id' => [ 'title' => ts('Contact ID'), 'no_display' => TRUE, - ), - 'gender_id' => array( + ], + 'gender_id' => [ 'title' => ts('Gender'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id'), - ), - 'birth_date' => array( + ], + 'birth_date' => [ 'title' => ts('Birth Date'), 'operatorType' => CRM_Report_Form::OP_DATE, - ), - 'contact_type' => array( + ], + 'contact_type' => [ 'title' => ts('Contact Type'), - ), - 'contact_sub_type' => array( + ], + 'contact_sub_type' => [ 'title' => ts('Contact Subtype'), - ), - ), - ), - 'civicrm_email' => array( + ], + ], + ], + 'civicrm_email' => [ 'dao' => 'CRM_Core_DAO_Email', - 'fields' => array( - 'email' => array( + 'fields' => [ + 'email' => [ 'title' => ts('Email'), 'no_repeat' => TRUE, - ), - ), + ], + ], 'grouping' => 'contact-fields', - ), - 'civicrm_phone' => array( + ], + 'civicrm_phone' => [ 'dao' => 'CRM_Core_DAO_Phone', - 'fields' => array( - 'phone' => array( + 'fields' => [ + 'phone' => [ 'title' => ts('Phone'), 'no_repeat' => TRUE, - ), - ), + ], + ], 'grouping' => 'contact-fields', - ), - ) + $this->addAddressFields(FALSE, FALSE, FALSE, array()) + array( - 'civicrm_relationship' => array( + ], + ] + $this->addAddressFields(FALSE, FALSE, FALSE, []) + [ + 'civicrm_relationship' => [ 'dao' => 'CRM_Contact_DAO_Relationship', - 'fields' => array( - 'relationship_type_id' => array( + 'fields' => [ + 'relationship_type_id' => [ 'title' => ts('Relationship Type'), 'default' => TRUE, - ), - 'contact_id_a' => array('no_display' => TRUE), - 'contact_id_b' => array('no_display' => TRUE), - ), - 'filters' => array( - 'relationship_type_id' => array( + ], + 'contact_id_a' => ['no_display' => TRUE], + 'contact_id_b' => ['no_display' => TRUE], + ], + 'filters' => [ + 'relationship_type_id' => [ 'title' => ts('Relationship Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $relationTypeOp, 'type' => CRM_Utils_Type::T_STRING, - ), - ), - ), - ) + array( - 'civicrm_contribution' => array( + ], + ], + ], + ] + [ + 'civicrm_contribution' => [ 'dao' => 'CRM_Contribute_DAO_Contribution', - 'fields' => array( - 'total_amount' => array( + 'fields' => [ + 'total_amount' => [ 'title' => ts('Amount Statistics'), 'default' => TRUE, 'required' => TRUE, 'no_display' => TRUE, - 'statistics' => array('sum' => ts('Aggregate Amount')), - ), - 'receive_date' => array( + 'statistics' => ['sum' => ts('Aggregate Amount')], + ], + 'receive_date' => [ 'required' => TRUE, 'default' => TRUE, 'no_display' => TRUE, - ), - ), + ], + ], 'grouping' => 'contri-fields', - 'filters' => array( - 'this_year' => array( + 'filters' => [ + 'this_year' => [ 'title' => ts('This Year'), 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => $optionYear, 'default' => '', - ), - 'other_year' => array( + ], + 'other_year' => [ 'title' => ts('Other Years'), 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => $optionYear, 'default' => '', - ), - 'receive_date' => array('operatorType' => CRM_Report_Form::OP_DATE), - 'contribution_status_id' => array( + ], + 'receive_date' => ['operatorType' => CRM_Report_Form::OP_DATE], + 'contribution_status_id' => [ 'title' => ts('Contribution Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), - 'default' => array(1), - ), - 'financial_type_id' => array( + 'default' => [1], + ], + 'financial_type_id' => [ 'title' => ts('Financial Type'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::financialType(), - ), - 'total_amount' => array( + ], + 'total_amount' => [ 'title' => ts('Contribution Amount'), - ), - 'total_sum' => array( + ], + 'total_sum' => [ 'title' => ts('Aggregate Amount'), 'type' => CRM_Report_Form::OP_INT, 'dbAlias' => 'civicrm_contribution_total_amount_sum', 'having' => TRUE, - ), - ), - ), - ); - $this->_columns += array( - 'civicrm_financial_trxn' => array( + ], + ], + ], + ]; + $this->_columns += [ + 'civicrm_financial_trxn' => [ 'dao' => 'CRM_Financial_DAO_FinancialTrxn', - 'fields' => array( - 'card_type_id' => array( + 'fields' => [ + 'card_type_id' => [ 'title' => ts('Credit Card Type'), 'dbAlias' => 'GROUP_CONCAT(financial_trxn_civireport.card_type_id SEPARATOR ",")', - ), - ), - 'filters' => array( - 'card_type_id' => array( + ], + ], + 'filters' => [ + 'card_type_id' => [ 'title' => ts('Credit Card Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Financial_DAO_FinancialTrxn::buildOptions('card_type_id'), 'default' => NULL, 'type' => CRM_Utils_Type::T_STRING, - ), - ), - ), - ); + ], + ], + ], + ]; $this->_columns['civicrm_contribution']['fields']['civicrm_upto_' . - $this->_yearStatisticsFrom] = array( - 'title' => ts('Up To %1 Donation', array(1 => $this->_yearStatisticsFrom)), + $this->_yearStatisticsFrom] = [ + 'title' => ts('Up To %1 Donation', [1 => $this->_yearStatisticsFrom]), 'default' => TRUE, 'type' => CRM_Utils_Type::T_MONEY, 'is_statistics' => TRUE, - ); + ]; $yearConter = $this->_yearStatisticsFrom; $yearConter++; while ($yearConter <= $this->_yearStatisticsTo) { - $this->_columns['civicrm_contribution']['fields'][$yearConter] = array( - 'title' => ts('%1 Donation', array(1 => $yearConter)), + $this->_columns['civicrm_contribution']['fields'][$yearConter] = [ + 'title' => ts('%1 Donation', [1 => $yearConter]), 'default' => TRUE, 'type' => CRM_Utils_Type::T_MONEY, 'is_statistics' => TRUE, - ); + ]; $yearConter++; } - $this->_columns['civicrm_contribution']['fields']['aggregate_amount'] = array( + $this->_columns['civicrm_contribution']['fields']['aggregate_amount'] = [ 'title' => ts('Aggregate Amount'), 'type' => CRM_Utils_Type::T_MONEY, 'is_statistics' => TRUE, - ); + ]; $this->_groupFilter = TRUE; $this->_tagFilter = TRUE; @@ -321,9 +321,9 @@ public function preProcess() { } public function select() { - $select = array(); + $select = []; // @todo remove this & use parent (with maybe some override in this or better yet selectWhere fn) - $this->_columnHeaders = array(); + $this->_columnHeaders = []; foreach ($this->_columns as $tableName => $table) { if (array_key_exists('fields', $table)) { @@ -398,7 +398,7 @@ public function from() { } public function where() { - $whereClauses = $havingClauses = $relationshipWhere = array(); + $whereClauses = $havingClauses = $relationshipWhere = []; $this->_relationshipWhere = ''; $this->_statusClause = ''; @@ -474,10 +474,10 @@ public function where() { } public function groupBy() { - $groupBy = array( + $groupBy = [ "{$this->_aliases['civicrm_contribution']}.contact_id", "YEAR({$this->_aliases['civicrm_contribution']}.receive_date)", - ); + ]; $this->_groupBy = CRM_Contact_BAO_Query::getGroupByFromSelectColumns($this->_selectClauses, $groupBy); } @@ -514,16 +514,16 @@ public function statistics(&$rows) { $count++; } } - $statistics['counts']['rowCount'] = array( + $statistics['counts']['rowCount'] = [ 'title' => ts('Primary Contact(s) Listed'), 'value' => $count, - ); + ]; if ($this->_rowsFound && ($this->_rowsFound > $count)) { - $statistics['counts']['rowsFound'] = array( + $statistics['counts']['rowsFound'] = [ 'title' => ts('Total Primary Contact(s)'), 'value' => $this->_rowsFound, - ); + ]; } return $statistics; @@ -537,7 +537,7 @@ public function statistics(&$rows) { * @return array */ public static function formRule($fields, $files, $self) { - $errors = array(); + $errors = []; if (!empty($fields['this_year_value']) && !empty($fields['other_year_value']) && ($fields['this_year_value'] == $fields['other_year_value']) @@ -560,7 +560,7 @@ public function postProcess() { $this->groupBy(); $sql = NULL; - $rows = array(); + $rows = []; // build array of result based on column headers. This method also allows // modifying column headers before using it to build result set i.e $rows. @@ -590,7 +590,7 @@ public function fixReportParams() { * @param $rows */ public function buildRows($sql, &$rows) { - $contactIds = array(); + $contactIds = []; $addWhere = ''; @@ -615,7 +615,7 @@ public function buildRows($sql, &$rows) { $dao->free(); $this->setPager(); - $relationshipRows = array(); + $relationshipRows = []; if (empty($contactIds)) { return; } @@ -631,7 +631,7 @@ public function buildRows($sql, &$rows) { $relatedContributions = $this->buildContributionRows($relatedContactIds); - $summaryYears = array(); + $summaryYears = []; $summaryYears[] = "civicrm_upto_{$this->_yearStatisticsFrom}"; $yearConter = $this->_yearStatisticsFrom; $yearConter++; @@ -647,7 +647,7 @@ public function buildRows($sql, &$rows) { $rows[$cid] = $row; continue; } - $total = array(); + $total = []; $total['civicrm_contact_sort_name'] = ts('Total'); foreach ($summaryYears as $year) { $total[$year] = CRM_Utils_Array::value($year, $primaryRow, 0); @@ -674,7 +674,7 @@ public function buildRows($sql, &$rows) { } if ($relatedContact) { $rows["{$cid}_total"] = $total; - $rows["{$cid}_bank"] = array('civicrm_contact_sort_name' => ' '); + $rows["{$cid}_bank"] = ['civicrm_contact_sort_name' => ' ']; } } } @@ -685,7 +685,7 @@ public function buildRows($sql, &$rows) { * @return array */ public function buildContributionRows($contactIds) { - $rows = array(); + $rows = []; if (empty($contactIds)) { return $rows; } @@ -696,7 +696,7 @@ public function buildContributionRows($contactIds) { $dao = CRM_Core_DAO::executeQuery($sqlContribution); $contributionSum = 0; - $yearcal = array(); + $yearcal = []; while ($dao->fetch()) { if (!$dao->civicrm_contact_id) { continue; @@ -737,9 +737,9 @@ public function buildContributionRows($contactIds) { * @return array */ public function buildRelationshipRows($contactIds) { - $relationshipRows = $relatedContactIds = array(); + $relationshipRows = $relatedContactIds = []; if (empty($contactIds)) { - return array($relationshipRows, $relatedContactIds); + return [$relationshipRows, $relatedContactIds]; } $relContactAlias = 'contact_relationship'; @@ -754,7 +754,7 @@ public function buildRelationshipRows($contactIds) { $dao = CRM_Core_DAO::executeQuery($sqlRelationship); while ($dao->fetch()) { - $row = array(); + $row = []; foreach (array_keys($this->_relationshipColumns) as $rel_column) { $row[$rel_column] = $dao->$rel_column; } @@ -772,7 +772,7 @@ public function buildRelationshipRows($contactIds) { } } $dao->free(); - return array($relationshipRows, $relatedContactIds); + return [$relationshipRows, $relatedContactIds]; } /** @@ -784,10 +784,10 @@ public function buildRelationshipRows($contactIds) { */ public function getOperationPair($type = "string", $fieldName = NULL) { if ($fieldName == 'this_year' || $fieldName == 'other_year') { - return array( + return [ 'calendar' => ts('Is Calendar Year'), 'fiscal' => ts('Fiscal Year Starting'), - ); + ]; } return parent::getOperationPair($type, $fieldName); } diff --git a/CRM/Report/Form/Contribute/HouseholdSummary.php b/CRM/Report/Form/Contribute/HouseholdSummary.php index dff6c5231716..e84092113986 100644 --- a/CRM/Report/Form/Contribute/HouseholdSummary.php +++ b/CRM/Report/Form/Contribute/HouseholdSummary.php @@ -32,7 +32,7 @@ */ class CRM_Report_Form_Contribute_HouseholdSummary extends CRM_Report_Form { - public $_drilldownReport = array('contribute/detail' => 'Link to Detail Report'); + public $_drilldownReport = ['contribute/detail' => 'Link to Detail Report']; protected $_summary = NULL; @@ -42,165 +42,165 @@ class CRM_Report_Form_Contribute_HouseholdSummary extends CRM_Report_Form { public function __construct() { self::validRelationships(); - $this->_columns = array( - 'civicrm_contact_household' => array( + $this->_columns = [ + 'civicrm_contact_household' => [ 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => array( - 'household_name' => array( + 'fields' => [ + 'household_name' => [ 'title' => ts('Household Name'), 'required' => TRUE, - ), - 'id' => array( + ], + 'id' => [ 'no_display' => TRUE, 'required' => TRUE, - ), - 'contact_type' => array( + ], + 'contact_type' => [ 'title' => ts('Contact Type'), - ), - 'contact_sub_type' => array( + ], + 'contact_sub_type' => [ 'title' => ts('Contact Subtype'), - ), - ), - 'filters' => array( - 'household_name' => array( + ], + ], + 'filters' => [ + 'household_name' => [ 'title' => ts('Household Name'), - ), - 'is_deleted' => array( + ], + 'is_deleted' => [ 'default' => 0, 'type' => CRM_Utils_Type::T_BOOLEAN, - ), - ), + ], + ], 'grouping' => 'household-fields', - ), - 'civicrm_line_item' => array( + ], + 'civicrm_line_item' => [ 'dao' => 'CRM_Price_DAO_LineItem', - ), - 'civicrm_relationship' => array( + ], + 'civicrm_relationship' => [ 'dao' => 'CRM_Contact_DAO_Relationship', - 'fields' => array( - 'relationship_type_id' => array( + 'fields' => [ + 'relationship_type_id' => [ 'title' => ts('Relationship Type'), - ), - ), - 'filters' => array( - 'relationship_type_id' => array( + ], + ], + 'filters' => [ + 'relationship_type_id' => [ 'title' => ts('Relationship Type'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => $this->relationTypes, 'default' => key($this->relationTypes), - ), - ), + ], + ], 'grouping' => 'household-fields', - ), - 'civicrm_contact' => array( + ], + 'civicrm_contact' => [ 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => array( - 'sort_name' => array( + 'fields' => [ + 'sort_name' => [ 'title' => ts('Contact Name'), 'required' => TRUE, - ), - 'id' => array( + ], + 'id' => [ 'no_display' => TRUE, 'required' => TRUE, - ), - ), + ], + ], 'grouping' => 'contact-fields', - ), - 'civicrm_contribution' => array( + ], + 'civicrm_contribution' => [ 'dao' => 'CRM_Contribute_DAO_Contribution', - 'fields' => array( - 'total_amount' => array( + 'fields' => [ + 'total_amount' => [ 'title' => ts('Amount'), 'required' => TRUE, - ), - 'id' => array( + ], + 'id' => [ 'no_display' => TRUE, 'required' => TRUE, - ), - 'contribution_status_id' => array( + ], + 'contribution_status_id' => [ 'title' => ts('Contribution Status'), 'default' => TRUE, - ), - 'check_number' => array( + ], + 'check_number' => [ 'title' => ts('Check Number'), - ), - 'currency' => array( + ], + 'currency' => [ 'required' => TRUE, 'no_display' => TRUE, - ), - 'financial_type_id' => array( + ], + 'financial_type_id' => [ 'title' => ts('Financial Type'), - ), + ], 'trxn_id' => NULL, - 'receive_date' => array('default' => TRUE), + 'receive_date' => ['default' => TRUE], 'receipt_date' => NULL, - ), - 'filters' => array( - 'receive_date' => array('operatorType' => CRM_Report_Form::OP_DATE), - 'total_amount' => array('title' => ts('Amount Between')), - 'currency' => array( + ], + 'filters' => [ + 'receive_date' => ['operatorType' => CRM_Report_Form::OP_DATE], + 'total_amount' => ['title' => ts('Amount Between')], + 'currency' => [ 'title' => ts('Currency'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_OptionGroup::values('currencies_enabled'), 'default' => NULL, 'type' => CRM_Utils_Type::T_STRING, - ), - 'contribution_status_id' => array( + ], + 'contribution_status_id' => [ 'title' => ts('Contribution Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), - 'default' => array(1), - ), - 'financial_type_id' => array( + 'default' => [1], + ], + 'financial_type_id' => [ 'title' => ts('Financial Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::financialType(), - ), - ), + ], + ], 'grouping' => 'contri-fields', - ), - 'civicrm_financial_trxn' => array( + ], + 'civicrm_financial_trxn' => [ 'dao' => 'CRM_Financial_DAO_FinancialTrxn', - 'fields' => array( - 'card_type_id' => array( + 'fields' => [ + 'card_type_id' => [ 'title' => ts('Credit Card Type'), 'dbAlias' => 'GROUP_CONCAT(financial_trxn_civireport.card_type_id SEPARATOR ",")', - ), - ), - 'filters' => array( - 'card_type_id' => array( + ], + ], + 'filters' => [ + 'card_type_id' => [ 'title' => ts('Credit Card Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Financial_DAO_FinancialTrxn::buildOptions('card_type_id'), 'default' => NULL, 'type' => CRM_Utils_Type::T_STRING, - ), - ), - ), - 'civicrm_address' => array( + ], + ], + ], + 'civicrm_address' => [ 'dao' => 'CRM_Core_DAO_Address', - 'fields' => array( + 'fields' => [ 'street_address' => NULL, 'city' => NULL, 'postal_code' => NULL, - 'state_province_id' => array( + 'state_province_id' => [ 'title' => ts('State/Province'), - ), - 'country_id' => array( + ], + 'country_id' => [ 'title' => ts('Country'), - ), - ), + ], + ], 'grouping' => 'contact-fields', - ), - 'civicrm_email' => array( + ], + 'civicrm_email' => [ 'dao' => 'CRM_Core_DAO_Email', - 'fields' => array( + 'fields' => [ 'email' => NULL, - ), + ], 'grouping' => 'contact-fields', - ), - ); + ], + ]; // If we have a campaign, build out the relevant elements $this->addCampaignFields('civicrm_contribution'); @@ -211,7 +211,7 @@ public function __construct() { public function select() { // @todo remove this & use parent select. - $this->_columnHeaders = $select = array(); + $this->_columnHeaders = $select = []; foreach ($this->_columns as $tableName => $table) { if (array_key_exists('fields', $table)) { foreach ($table['fields'] as $fieldName => $field) { @@ -260,7 +260,7 @@ public function from() { } public function where() { - $clauses = array(); + $clauses = []; foreach ($this->_columns as $tableName => $table) { if (array_key_exists('filters', $table)) { foreach ($table['filters'] as $fieldName => $field) { @@ -308,12 +308,12 @@ public function where() { } public function groupBy() { - $groupBy = array( + $groupBy = [ "{$this->_aliases['civicrm_relationship']}.$this->householdContact", "{$this->_aliases['civicrm_relationship']}.$this->otherContact", "{$this->_aliases['civicrm_contribution']}.id", "{$this->_aliases['civicrm_relationship']}.relationship_type_id", - ); + ]; $this->_groupBy = CRM_Contact_BAO_Query::getGroupByFromSelectColumns($this->_selectClauses, $groupBy); } @@ -346,12 +346,12 @@ public function statistics(&$rows) { public function postProcess() { $this->beginPostProcess(); - $this->buildACLClause(array( + $this->buildACLClause([ $this->_aliases['civicrm_contact'], $this->_aliases['civicrm_contact_household'], - )); + ]); $sql = $this->buildQuery(TRUE); - $rows = array(); + $rows = []; $this->buildRows($sql, $rows); $this->formatDisplay($rows); @@ -377,16 +377,16 @@ public function beginPostProcessCommon() { } public function validRelationships() { - $this->relationTypes = $relationTypes = array(); + $this->relationTypes = $relationTypes = []; - $params = array('contact_type_b' => 'Household', 'version' => 3); + $params = ['contact_type_b' => 'Household', 'version' => 3]; $typesA = civicrm_api('relationship_type', 'get', $params); if (empty($typesA['is_error'])) { foreach ($typesA['values'] as $rel) { $relationTypes[$rel['id']][$rel['id'] . '_b_a'] = $rel['label_b_a']; } } - $params = array('contact_type_a' => 'Household', 'version' => 3); + $params = ['contact_type_a' => 'Household', 'version' => 3]; $typesB = civicrm_api('relationship_type', 'get', $params); if (empty($typesB['is_error'])) { foreach ($typesB['values'] as $rel) { diff --git a/CRM/Report/Form/Contribute/Lybunt.php b/CRM/Report/Form/Contribute/Lybunt.php index 8bc65e7b5935..3b1ed480be71 100644 --- a/CRM/Report/Form/Contribute/Lybunt.php +++ b/CRM/Report/Form/Contribute/Lybunt.php @@ -32,11 +32,11 @@ */ class CRM_Report_Form_Contribute_Lybunt extends CRM_Report_Form { - protected $_charts = array( + protected $_charts = [ '' => 'Tabular', 'barChart' => 'Bar Chart', 'pieChart' => 'Pie Chart', - ); + ]; /** * This is the report that links will lead to. @@ -46,16 +46,16 @@ class CRM_Report_Form_Contribute_Lybunt extends CRM_Report_Form { * * @var array */ - public $_drilldownReport = array('contribute/detail' => 'Link to Detail Report'); + public $_drilldownReport = ['contribute/detail' => 'Link to Detail Report']; protected $lifeTime_from = NULL; protected $lifeTime_where = NULL; - protected $_customGroupExtends = array( + protected $_customGroupExtends = [ 'Contact', 'Individual', 'Household', 'Organization', - ); + ]; /** * Table containing list of contact IDs. @@ -89,177 +89,177 @@ public function __construct() { $date['minYear']++; } - $this->_columns = array( - 'civicrm_contact' => array( + $this->_columns = [ + 'civicrm_contact' => [ 'dao' => 'CRM_Contact_DAO_Contact', 'grouping' => 'contact-field', 'fields' => $this->getBasicContactFields(), - 'order_bys' => array( - 'sort_name' => array( + 'order_bys' => [ + 'sort_name' => [ 'title' => ts('Last Name, First Name'), 'default' => '0', 'default_order' => 'ASC', - ), - 'first_name' => array( + ], + 'first_name' => [ 'name' => 'first_name', 'title' => ts('First Name'), - ), - 'gender_id' => array( + ], + 'gender_id' => [ 'name' => 'gender_id', 'title' => ts('Gender'), - ), - 'birth_date' => array( + ], + 'birth_date' => [ 'name' => 'birth_date', 'title' => ts('Birth Date'), - ), - 'contact_type' => array( + ], + 'contact_type' => [ 'title' => ts('Contact Type'), - ), - 'contact_sub_type' => array( + ], + 'contact_sub_type' => [ 'title' => ts('Contact Subtype'), - ), - ), - 'filters' => array( - 'sort_name' => array( + ], + ], + 'filters' => [ + 'sort_name' => [ 'title' => ts('Donor Name'), 'operator' => 'like', - ), - 'id' => array( + ], + 'id' => [ 'title' => ts('Contact ID'), 'no_display' => TRUE, - ), - 'gender_id' => array( + ], + 'gender_id' => [ 'title' => ts('Gender'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id'), - ), - 'birth_date' => array( + ], + 'birth_date' => [ 'title' => ts('Birth Date'), 'operatorType' => CRM_Report_Form::OP_DATE, - ), - 'contact_type' => array( + ], + 'contact_type' => [ 'title' => ts('Contact Type'), - ), - 'contact_sub_type' => array( + ], + 'contact_sub_type' => [ 'title' => ts('Contact Subtype'), - ), - 'is_deceased' => array(), - 'do_not_phone' => array(), - 'do_not_email' => array(), - 'do_not_sms' => array(), - 'do_not_mail' => array(), - 'is_opt_out' => array(), - ), - ), - 'civicrm_line_item' => array( + ], + 'is_deceased' => [], + 'do_not_phone' => [], + 'do_not_email' => [], + 'do_not_sms' => [], + 'do_not_mail' => [], + 'is_opt_out' => [], + ], + ], + 'civicrm_line_item' => [ 'dao' => 'CRM_Price_DAO_LineItem', - ), - 'civicrm_email' => array( + ], + 'civicrm_email' => [ 'dao' => 'CRM_Core_DAO_Email', 'grouping' => 'contact-field', - 'fields' => array( - 'email' => array( + 'fields' => [ + 'email' => [ 'title' => ts('Email'), 'default' => TRUE, - ), - 'on_hold' => array( + ], + 'on_hold' => [ 'title' => ts('Email on hold'), - ), - ), - ), - 'civicrm_phone' => array( + ], + ], + ], + 'civicrm_phone' => [ 'dao' => 'CRM_Core_DAO_Phone', 'grouping' => 'contact-field', - 'fields' => array( - 'phone' => array( + 'fields' => [ + 'phone' => [ 'title' => ts('Phone'), 'default' => TRUE, - ), - ), - ), - ); + ], + ], + ], + ]; $this->_columns += $this->addAddressFields(FALSE); - $this->_columns += array( - 'civicrm_contribution' => array( + $this->_columns += [ + 'civicrm_contribution' => [ 'dao' => 'CRM_Contribute_DAO_Contribution', - 'fields' => array( - 'contact_id' => array( + 'fields' => [ + 'contact_id' => [ 'title' => ts('contactId'), 'no_display' => TRUE, 'required' => TRUE, 'no_repeat' => TRUE, - ), - 'receive_date' => array( + ], + 'receive_date' => [ 'title' => ts('Year'), 'no_display' => TRUE, 'required' => TRUE, 'no_repeat' => TRUE, - ), - 'last_year_total_amount' => array( + ], + 'last_year_total_amount' => [ 'title' => ts('Last Year Total'), 'default' => TRUE, 'type' => CRM_Utils_Type::T_MONEY, 'required' => TRUE, - ), - 'civicrm_life_time_total' => array( + ], + 'civicrm_life_time_total' => [ 'title' => ts('Lifetime Total'), 'default' => TRUE, 'type' => CRM_Utils_Type::T_MONEY, - 'statistics' => array('sum' => ts('Lifetime total')), - ), - ), - 'filters' => array( - 'yid' => array( + 'statistics' => ['sum' => ts('Lifetime total')], + ], + ], + 'filters' => [ + 'yid' => [ 'name' => 'receive_date', 'title' => ts('This Year'), 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => $optionYear, 'default' => date('Y'), 'type' => CRM_Utils_Type::T_INT, - ), - 'financial_type_id' => array( + ], + 'financial_type_id' => [ 'title' => ts('Financial Type'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes(), - ), - 'contribution_status_id' => array( + ], + 'contribution_status_id' => [ 'title' => ts('Contribution Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), - 'default' => array('1'), - ), - ), - 'order_bys' => array( - 'last_year_total_amount' => array( + 'default' => ['1'], + ], + ], + 'order_bys' => [ + 'last_year_total_amount' => [ 'title' => ts('Total amount last year'), 'default' => '1', 'default_weight' => '0', 'default_order' => 'DESC', - ), - ), - ), - ); - $this->_columns += array( - 'civicrm_financial_trxn' => array( + ], + ], + ], + ]; + $this->_columns += [ + 'civicrm_financial_trxn' => [ 'dao' => 'CRM_Financial_DAO_FinancialTrxn', - 'fields' => array( - 'card_type_id' => array( + 'fields' => [ + 'card_type_id' => [ 'title' => ts('Credit Card Type'), 'dbAlias' => 'GROUP_CONCAT(financial_trxn_civireport.card_type_id SEPARATOR ",")', - ), - ), - 'filters' => array( - 'card_type_id' => array( + ], + ], + 'filters' => [ + 'card_type_id' => [ 'title' => ts('Credit Card Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Financial_DAO_FinancialTrxn::buildOptions('card_type_id'), 'default' => NULL, 'type' => CRM_Utils_Type::T_STRING, - ), - ), - ), - ); + ], + ], + ], + ]; // If we have a campaign, build out the relevant elements $this->addCampaignFields('civicrm_contribution'); @@ -502,19 +502,19 @@ public function statistics(&$rows) { $this->countStat($statistics, count($rows)); if (!empty($rows)) { if (!empty($this->rollupRow) && !empty($this->rollupRow['civicrm_contribution_last_year_total_amount'])) { - $statistics['counts']['civicrm_contribution_last_year_total_amount'] = array( + $statistics['counts']['civicrm_contribution_last_year_total_amount'] = [ 'value' => $this->rollupRow['civicrm_contribution_last_year_total_amount'], 'title' => $this->getLastYearColumnTitle(), 'type' => CRM_Utils_Type::T_MONEY, - ); + ]; } if (!empty($this->rollupRow) && !empty($this->rollupRow['civicrm_contribution_civicrm_life_time_total'])) { - $statistics['counts']['civicrm_contribution_civicrm_life_time_total'] = array( + $statistics['counts']['civicrm_contribution_civicrm_life_time_total'] = [ 'value' => $this->rollupRow['civicrm_contribution_civicrm_life_time_total'], 'title' => ts('Total LifeTime'), 'type' => CRM_Utils_Type::T_MONEY, - ); + ]; } else { $select = "SELECT SUM({$this->_aliases['civicrm_contribution']}.total_amount) as amount, @@ -523,16 +523,16 @@ public function statistics(&$rows) { $sql = "{$select} {$this->_from} {$this->_where}"; $dao = CRM_Core_DAO::executeQuery($sql); if ($dao->fetch()) { - $statistics['counts']['amount'] = array( + $statistics['counts']['amount'] = [ 'value' => $dao->amount, 'title' => ts('Total LifeTime'), 'type' => CRM_Utils_Type::T_MONEY, - ); - $statistics['counts']['last_year'] = array( + ]; + $statistics['counts']['last_year'] = [ 'value' => $dao->last_year, 'title' => $this->getLastYearColumnTitle(), 'type' => CRM_Utils_Type::T_MONEY, - ); + ]; } } } @@ -559,7 +559,7 @@ public function beginPostProcessCommon() { } // Reset where clauses to be regenerated in postProcess. - $this->_whereClauses = array(); + $this->_whereClauses = []; } /** @@ -628,9 +628,9 @@ public function buildQuery($applyLimit = TRUE) { */ protected function resetFormSqlAndWhereHavingClauses() { $this->sql = ''; - $this->_havingClauses = array(); - $this->_whereClauses = array(); - $this->sqlArray = array(); + $this->_havingClauses = []; + $this->_whereClauses = []; + $this->sqlArray = []; } /** @@ -638,9 +638,9 @@ protected function resetFormSqlAndWhereHavingClauses() { */ public function buildChart(&$rows) { - $graphRows = array(); + $graphRows = []; $count = 0; - $display = array(); + $display = []; $current_year = $this->_params['yid_value']; $previous_year = $current_year - 1; @@ -655,11 +655,11 @@ public function buildChart(&$rows) { $config = CRM_Core_Config::Singleton(); $graphRows['value'] = $display; - $chartInfo = array( + $chartInfo = [ 'legend' => ts('Lybunt Report'), 'xname' => ts('Year'), - 'yname' => ts('Amount (%1)', array(1 => $config->defaultCurrency)), - ); + 'yname' => ts('Amount (%1)', [1 => $config->defaultCurrency]), + ]; if ($this->_params['charts']) { // build chart. CRM_Utils_OpenFlashChart::reportChart($graphRows, $this->_params['charts'], $interval, $chartInfo); @@ -732,10 +732,10 @@ public function alterDisplay(&$rows) { */ public function getOperationPair($type = "string", $fieldName = NULL) { if ($fieldName == 'yid') { - return array( + return [ 'calendar' => ts('Is Calendar Year'), 'fiscal' => ts('Fiscal Year Starting'), - ); + ]; } return parent::getOperationPair($type, $fieldName); } diff --git a/CRM/Report/Form/Contribute/OrganizationSummary.php b/CRM/Report/Form/Contribute/OrganizationSummary.php index 28ad21076363..9e4926a9ad22 100644 --- a/CRM/Report/Form/Contribute/OrganizationSummary.php +++ b/CRM/Report/Form/Contribute/OrganizationSummary.php @@ -32,7 +32,7 @@ */ class CRM_Report_Form_Contribute_OrganizationSummary extends CRM_Report_Form { - public $_drilldownReport = array('contribute/detail' => 'Link to Detail Report'); + public $_drilldownReport = ['contribute/detail' => 'Link to Detail Report']; protected $_summary = NULL; @@ -54,156 +54,156 @@ class CRM_Report_Form_Contribute_OrganizationSummary extends CRM_Report_Form { public function __construct() { self::validRelationships(); - $this->_columns = array( - 'civicrm_contact_organization' => array( + $this->_columns = [ + 'civicrm_contact_organization' => [ 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => array( - 'organization_name' => array( + 'fields' => [ + 'organization_name' => [ 'title' => ts('Organization Name'), 'required' => TRUE, 'no_repeat' => TRUE, - ), - 'id' => array( + ], + 'id' => [ 'no_display' => TRUE, 'required' => TRUE, - ), - 'contact_type' => array( + ], + 'contact_type' => [ 'title' => ts('Contact Type'), - ), - 'contact_sub_type' => array( + ], + 'contact_sub_type' => [ 'title' => ts('Contact Subtype'), - ), - ), - 'filters' => array( - 'organization_name' => array( + ], + ], + 'filters' => [ + 'organization_name' => [ 'title' => ts('Organization Name'), - ), - 'is_deleted' => array( + ], + 'is_deleted' => [ 'default' => 0, 'type' => CRM_Utils_Type::T_BOOLEAN, - ), - ), + ], + ], 'grouping' => 'organization-fields', - ), - 'civicrm_line_item' => array( + ], + 'civicrm_line_item' => [ 'dao' => 'CRM_Price_DAO_LineItem', - ), - 'civicrm_relationship' => array( + ], + 'civicrm_relationship' => [ 'dao' => 'CRM_Contact_DAO_Relationship', - 'fields' => array( - 'relationship_type_id' => array( + 'fields' => [ + 'relationship_type_id' => [ 'title' => ts('Relationship Type'), - ), - ), - 'filters' => array( - 'relationship_type_id' => array( + ], + ], + 'filters' => [ + 'relationship_type_id' => [ 'title' => ts('Relationship Type'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => $this->relationTypes, 'default' => key($this->relationTypes), - ), - ), + ], + ], 'grouping' => 'organization-fields', - ), - 'civicrm_contact' => array( + ], + 'civicrm_contact' => [ 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => array( - 'sort_name' => array( + 'fields' => [ + 'sort_name' => [ 'title' => ts('Contact Name'), 'required' => TRUE, - ), - 'id' => array( + ], + 'id' => [ 'no_display' => TRUE, 'required' => TRUE, - ), - ), + ], + ], 'grouping' => 'contact-fields', - ), - 'civicrm_contribution' => array( + ], + 'civicrm_contribution' => [ 'dao' => 'CRM_Contribute_DAO_Contribution', - 'fields' => array( - 'total_amount' => array( + 'fields' => [ + 'total_amount' => [ 'title' => ts('Amount'), 'required' => TRUE, - ), - 'id' => array( + ], + 'id' => [ 'no_display' => TRUE, 'required' => TRUE, - ), - 'contribution_status_id' => array( + ], + 'contribution_status_id' => [ 'title' => ts('Contribution Status'), 'default' => TRUE, - ), - 'check_number' => array( + ], + 'check_number' => [ 'title' => ts('Check Number'), - ), - 'currency' => array( + ], + 'currency' => [ 'required' => TRUE, 'no_display' => TRUE, - ), + ], 'trxn_id' => NULL, - 'receive_date' => array('default' => TRUE), + 'receive_date' => ['default' => TRUE], 'receipt_date' => NULL, - ), - 'filters' => array( - 'receive_date' => array('operatorType' => CRM_Report_Form::OP_DATE), - 'total_amount' => array('title' => ts('Amount Between')), - 'currency' => array( + ], + 'filters' => [ + 'receive_date' => ['operatorType' => CRM_Report_Form::OP_DATE], + 'total_amount' => ['title' => ts('Amount Between')], + 'currency' => [ 'title' => ts('Currency'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_OptionGroup::values('currencies_enabled'), 'default' => NULL, 'type' => CRM_Utils_Type::T_STRING, - ), - 'contribution_status_id' => array( + ], + 'contribution_status_id' => [ 'title' => ts('Contribution Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), - 'default' => array(1), - ), - ), + 'default' => [1], + ], + ], 'grouping' => 'contri-fields', - ), - 'civicrm_address' => array( + ], + 'civicrm_address' => [ 'dao' => 'CRM_Core_DAO_Address', - 'fields' => array( + 'fields' => [ 'street_address' => NULL, 'city' => NULL, 'postal_code' => NULL, - 'state_province_id' => array( + 'state_province_id' => [ 'title' => ts('State/Province'), - ), - 'country_id' => array( + ], + 'country_id' => [ 'title' => ts('Country'), - ), - ), + ], + ], 'grouping' => 'contact-fields', - ), - 'civicrm_email' => array( + ], + 'civicrm_email' => [ 'dao' => 'CRM_Core_DAO_Email', - 'fields' => array('email' => NULL), + 'fields' => ['email' => NULL], 'grouping' => 'contact-fields', - ), - 'civicrm_financial_trxn' => array( + ], + 'civicrm_financial_trxn' => [ 'dao' => 'CRM_Financial_DAO_FinancialTrxn', - 'fields' => array( - 'card_type_id' => array( + 'fields' => [ + 'card_type_id' => [ 'title' => ts('Credit Card Type'), 'dbAlias' => 'GROUP_CONCAT(financial_trxn_civireport.card_type_id SEPARATOR ",")', - ), - ), - 'filters' => array( - 'card_type_id' => array( + ], + ], + 'filters' => [ + 'card_type_id' => [ 'title' => ts('Credit Card Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Financial_DAO_FinancialTrxn::buildOptions('card_type_id'), 'default' => NULL, 'type' => CRM_Utils_Type::T_STRING, - ), - ), - ), - ); + ], + ], + ], + ]; // If we have a campaign, build out the relevant elements $this->addCampaignFields('civicrm_contribution'); @@ -218,7 +218,7 @@ public function preProcess() { public function select() { // @todo remove this in favour of using parent function - $this->_columnHeaders = $select = array(); + $this->_columnHeaders = $select = []; foreach ($this->_columns as $tableName => $table) { if (array_key_exists('fields', $table)) { foreach ($table['fields'] as $fieldName => $field) { @@ -267,7 +267,7 @@ public function from() { } public function where() { - $clauses = array(); + $clauses = []; foreach ($this->_columns as $tableName => $table) { if (array_key_exists('filters', $table)) { foreach ($table['filters'] as $fieldName => $field) { @@ -316,12 +316,12 @@ public function where() { } public function groupBy() { - $groupBy = array( + $groupBy = [ "{$this->_aliases['civicrm_relationship']}.$this->orgContact", "{$this->_aliases['civicrm_relationship']}.$this->otherContact", "{$this->_aliases['civicrm_contribution']}.id", "{$this->_aliases['civicrm_relationship']}.relationship_type_id", - ); + ]; $this->_groupBy = CRM_Contact_BAO_Query::getGroupByFromSelectColumns($this->_selectClauses, $groupBy); } @@ -350,9 +350,9 @@ public function statistics(&$rows) { public function postProcess() { $this->beginPostProcess(); - $this->buildACLClause(array($this->_aliases['civicrm_contact'], $this->_aliases['civicrm_contact_organization'])); + $this->buildACLClause([$this->_aliases['civicrm_contact'], $this->_aliases['civicrm_contact_organization']]); $sql = $this->buildQuery(TRUE); - $rows = array(); + $rows = []; $this->buildRows($sql, $rows); $this->formatDisplay($rows); $this->doTemplateAssignment($rows); @@ -377,9 +377,9 @@ public function beginPostProcessCommon() { } public function validRelationships() { - $this->relationTypes = $relationTypes = array(); + $this->relationTypes = $relationTypes = []; - $params = array('contact_type_b' => 'Organization', 'version' => 3); + $params = ['contact_type_b' => 'Organization', 'version' => 3]; $typesA = civicrm_api('relationship_type', 'get', $params); if (empty($typesA['is_error'])) { @@ -388,7 +388,7 @@ public function validRelationships() { } } - $params = array('contact_type_a' => 'Organization', 'version' => 3); + $params = ['contact_type_a' => 'Organization', 'version' => 3]; $typesB = civicrm_api('relationship_type', 'get', $params); if (empty($typesB['is_error'])) { diff --git a/CRM/Report/Form/Contribute/PCP.php b/CRM/Report/Form/Contribute/PCP.php index 7ae29f131fe3..abd1972899dd 100644 --- a/CRM/Report/Form/Contribute/PCP.php +++ b/CRM/Report/Form/Contribute/PCP.php @@ -38,178 +38,178 @@ class CRM_Report_Form_Contribute_PCP extends CRM_Report_Form { * Class constructor. */ public function __construct() { - $this->_columns = array( - 'civicrm_contact' => array( + $this->_columns = [ + 'civicrm_contact' => [ 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => array( - 'sort_name' => array( + 'fields' => [ + 'sort_name' => [ 'title' => ts('Supporter'), 'required' => TRUE, 'default' => TRUE, - ), - 'id' => array( + ], + 'id' => [ 'required' => TRUE, 'no_display' => TRUE, - ), - 'contact_type' => array( + ], + 'contact_type' => [ 'title' => ts('Supporter Contact Type'), - ), - 'contact_sub_type' => array( + ], + 'contact_sub_type' => [ 'title' => ts('Supporter Contact Subtype'), - ), - ), - 'filters' => array( - 'sort_name' => array( + ], + ], + 'filters' => [ + 'sort_name' => [ 'title' => ts('Supporter Name'), 'type' => CRM_Utils_Type::T_STRING, 'operator' => 'like', - ), - 'id' => array( + ], + 'id' => [ 'title' => ts('Contact ID'), 'no_display' => TRUE, - ), - ), + ], + ], 'grouping' => 'pcp-fields', - ), - 'civicrm_contribution_page' => array( + ], + 'civicrm_contribution_page' => [ 'dao' => 'CRM_Contribute_DAO_ContributionPage', 'alias' => 'cp', - 'fields' => array( - 'page_title' => array( + 'fields' => [ + 'page_title' => [ 'title' => ts('Page Title'), 'name' => 'title', 'dbAlias' => 'coalesce(cp_civireport.title, e_civireport.title)', 'default' => TRUE, - ), - ), - 'filters' => array( - 'page_title' => array( + ], + ], + 'filters' => [ + 'page_title' => [ 'title' => ts('Contribution Page Title'), 'name' => 'title', 'type' => CRM_Utils_Type::T_STRING, - ), - ), + ], + ], 'grouping' => 'pcp-fields', - ), - 'civicrm_event' => array( + ], + 'civicrm_event' => [ 'alias' => 'e', - 'filters' => array( - 'event_title' => array( + 'filters' => [ + 'event_title' => [ 'title' => ts('Event Title'), 'name' => 'title', 'type' => CRM_Utils_Type::T_STRING, - ), - ), + ], + ], 'grouping' => 'pcp-fields', - ), - 'civicrm_pcp' => array( + ], + 'civicrm_pcp' => [ 'dao' => 'CRM_PCP_DAO_PCP', - 'fields' => array( - 'title' => array( + 'fields' => [ + 'title' => [ 'title' => ts('Personal Campaign Title'), 'default' => TRUE, - ), - 'page_type' => array( + ], + 'page_type' => [ 'title' => ts('Page Type'), 'default' => FALSE, - ), - 'goal_amount' => array( + ], + 'goal_amount' => [ 'title' => ts('Goal Amount'), 'type' => CRM_Utils_Type::T_MONEY, 'default' => TRUE, - ), - ), - 'filters' => array( - 'title' => array( + ], + ], + 'filters' => [ + 'title' => [ 'title' => ts('Personal Campaign Title'), 'type' => CRM_Utils_Type::T_STRING, - ), - ), - 'group_bys' => array( - 'pcp_id' => array( + ], + ], + 'group_bys' => [ + 'pcp_id' => [ 'name' => 'id', 'required' => TRUE, 'default' => TRUE, 'title' => ts('Personal Campaign Page'), - ), - ), + ], + ], 'grouping' => 'pcp-fields', - ), - 'civicrm_contribution_soft' => array( + ], + 'civicrm_contribution_soft' => [ 'dao' => 'CRM_Contribute_DAO_ContributionSoft', - 'fields' => array( - 'amount_1' => array( + 'fields' => [ + 'amount_1' => [ 'title' => ts('Committed Amount'), 'name' => 'amount', 'type' => CRM_Utils_Type::T_MONEY, 'default' => TRUE, - 'statistics' => array( + 'statistics' => [ 'sum' => ts('Committed Amount'), - ), - ), - 'amount_2' => array( + ], + ], + 'amount_2' => [ 'title' => ts('Amount Received'), 'name' => 'amount', 'type' => CRM_Utils_Type::T_MONEY, 'default' => TRUE, // nice trick with dbAlias 'dbAlias' => 'SUM(IF( contribution_civireport.contribution_status_id > 1, 0, contribution_soft_civireport.amount))', - ), - 'soft_id' => array( + ], + 'soft_id' => [ 'title' => ts('Number of Donors'), 'name' => 'id', 'default' => TRUE, - 'statistics' => array( + 'statistics' => [ 'count' => ts('Number of Donors'), - ), - ), - ), - 'filters' => array( - 'amount_2' => array( + ], + ], + ], + 'filters' => [ + 'amount_2' => [ 'title' => ts('Amount Received'), 'type' => CRM_Utils_Type::T_MONEY, 'dbAlias' => 'SUM(IF( contribution_civireport.contribution_status_id > 1, 0, contribution_soft_civireport.amount))', - ), - ), + ], + ], 'grouping' => 'pcp-fields', - ), - 'civicrm_contribution' => array( + ], + 'civicrm_contribution' => [ 'dao' => 'CRM_Contribute_DAO_Contribution', - 'fields' => array( - 'contribution_id' => array( + 'fields' => [ + 'contribution_id' => [ 'name' => 'id', 'no_display' => TRUE, 'required' => TRUE, - ), - 'receive_date' => array( + ], + 'receive_date' => [ 'title' => ts('Most Recent Contribution'), 'default' => TRUE, - 'statistics' => array( + 'statistics' => [ 'max' => ts('Most Recent Contribution'), - ), - ), - ), + ], + ], + ], 'grouping' => 'pcp-fields', - ), - 'civicrm_financial_trxn' => array( + ], + 'civicrm_financial_trxn' => [ 'dao' => 'CRM_Financial_DAO_FinancialTrxn', - 'fields' => array( - 'card_type_id' => array( + 'fields' => [ + 'card_type_id' => [ 'title' => ts('Credit Card Type'), 'dbAlias' => 'GROUP_CONCAT(financial_trxn_civireport.card_type_id SEPARATOR ",")', - ), - ), - 'filters' => array( - 'card_type_id' => array( + ], + ], + 'filters' => [ + 'card_type_id' => [ 'title' => ts('Credit Card Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Financial_DAO_FinancialTrxn::buildOptions('card_type_id'), 'default' => NULL, 'type' => CRM_Utils_Type::T_STRING, - ), - ), - ), - ); + ], + ], + ], + ]; parent::__construct(); $this->optimisedForOnlyFullGroupBy = FALSE; @@ -250,7 +250,7 @@ public function orderBy() { } public function where() { - $whereClauses = $havingClauses = array(); + $whereClauses = $havingClauses = []; foreach ($this->_columns as $tableName => $table) { if (array_key_exists('filters', $table)) { @@ -336,26 +336,26 @@ public function statistics(&$rows) { $dao->fetch(); $goal_total = $dao->goal_total; - $statistics['counts']['goal_total'] = array( + $statistics['counts']['goal_total'] = [ 'title' => ts('Goal Total'), 'value' => $goal_total, 'type' => CRM_Utils_Type::T_MONEY, - ); - $statistics['counts']['committed_total'] = array( + ]; + $statistics['counts']['committed_total'] = [ 'title' => ts('Total Committed'), 'value' => $committed_total, 'type' => CRM_Utils_Type::T_MONEY, - ); - $statistics['counts']['received_total'] = array( + ]; + $statistics['counts']['received_total'] = [ 'title' => ts('Total Received'), 'value' => $received_total, 'type' => CRM_Utils_Type::T_MONEY, - ); - $statistics['counts']['donors_total'] = array( + ]; + $statistics['counts']['donors_total'] = [ 'title' => ts('Total Donors'), 'value' => $donors_total, 'type' => CRM_Utils_Type::T_INT, - ); + ]; return $statistics; } @@ -370,7 +370,7 @@ public function statistics(&$rows) { */ public function alterDisplay(&$rows) { $entryFound = FALSE; - $checkList = array(); + $checkList = []; foreach ($rows as $rowNum => $row) { if (!empty($this->_noRepeats) && $this->_outputMode != 'csv') { // not repeat contact sort names if it matches with the one diff --git a/CRM/Report/Form/Contribute/Recur.php b/CRM/Report/Form/Contribute/Recur.php index 7d1f6309c56c..e3f733f059e6 100644 --- a/CRM/Report/Form/Contribute/Recur.php +++ b/CRM/Report/Form/Contribute/Recur.php @@ -51,213 +51,213 @@ class CRM_Report_Form_Contribute_Recur extends CRM_Report_Form { * Class constructor. */ public function __construct() { - $this->_columns = array( - 'civicrm_contact' => array( + $this->_columns = [ + 'civicrm_contact' => [ 'dao' => 'CRM_Contact_DAO_Contact', - 'order_bys' => array( - 'sort_name' => array( + 'order_bys' => [ + 'sort_name' => [ 'title' => ts("Last name, First name"), - ), - ), - 'fields' => array( - 'sort_name' => array( + ], + ], + 'fields' => [ + 'sort_name' => [ 'title' => ts('Contact Name'), 'no_repeat' => TRUE, 'default' => TRUE, - ), - 'id' => array( + ], + 'id' => [ 'no_display' => TRUE, 'required' => TRUE, - ), - ), - ), - 'civicrm_email' => array( + ], + ], + ], + 'civicrm_email' => [ 'dao' => 'CRM_Core_DAO_Email', - 'fields' => array( - 'email' => array( + 'fields' => [ + 'email' => [ 'title' => ts('Email'), 'no_repeat' => TRUE, - ), - ), + ], + ], 'grouping' => 'contact-fields', - ), - 'civicrm_phone' => array( + ], + 'civicrm_phone' => [ 'dao' => 'CRM_Core_DAO_Phone', - 'fields' => array( - 'phone' => array( + 'fields' => [ + 'phone' => [ 'title' => ts('Phone'), 'no_repeat' => TRUE, - ), - ), + ], + ], 'grouping' => 'contact-fields', - ), - 'civicrm_contribution' => array( + ], + 'civicrm_contribution' => [ 'dao' => 'CRM_Contribute_DAO_Contribution', - 'fields' => array( - 'id' => array( + 'fields' => [ + 'id' => [ 'no_display' => TRUE, 'required' => TRUE, - ), - 'total_amount' => array( + ], + 'total_amount' => [ 'title' => ts('Amount Contributed to Date'), - 'statistics' => array( + 'statistics' => [ 'sum' => ts("Total Amount Contributed"), - ), - ), - ), - ), - 'civicrm_financial_trxn' => array( + ], + ], + ], + ], + 'civicrm_financial_trxn' => [ 'dao' => 'CRM_Financial_DAO_FinancialTrxn', - 'fields' => array( - 'card_type_id' => array( + 'fields' => [ + 'card_type_id' => [ 'title' => ts('Credit Card Type'), 'dbAlias' => 'GROUP_CONCAT(financial_trxn_civireport.card_type_id SEPARATOR ",")', - ), - ), - 'filters' => array( - 'card_type_id' => array( + ], + ], + 'filters' => [ + 'card_type_id' => [ 'title' => ts('Credit Card Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Financial_DAO_FinancialTrxn::buildOptions('card_type_id'), 'default' => NULL, 'type' => CRM_Utils_Type::T_STRING, - ), - ), - ), - 'civicrm_contribution_recur' => array( + ], + ], + ], + 'civicrm_contribution_recur' => [ 'dao' => 'CRM_Contribute_DAO_ContributionRecur', - 'fields' => array( - 'id' => array( + 'fields' => [ + 'id' => [ 'no_display' => TRUE, 'required' => TRUE, - ), - 'currency' => array( + ], + 'currency' => [ 'title' => ts("Currency"), 'required' => TRUE, 'no_display' => TRUE, - ), - 'contribution_status_id' => array( + ], + 'contribution_status_id' => [ 'title' => ts('Contribution Status'), - ), - 'frequency_interval' => array( + ], + 'frequency_interval' => [ 'title' => ts('Frequency interval'), 'default' => TRUE, - ), - 'frequency_unit' => array( + ], + 'frequency_unit' => [ 'title' => ts('Frequency unit'), 'default' => TRUE, - ), - 'amount' => array( + ], + 'amount' => [ 'title' => ts('Installment Amount'), 'default' => TRUE, - ), - 'installments' => array( + ], + 'installments' => [ 'title' => ts('Installments'), 'default' => TRUE, - ), - 'start_date' => array( + ], + 'start_date' => [ 'title' => ts('Start Date'), - ), - 'create_date' => array( + ], + 'create_date' => [ 'title' => ts('Create Date'), - ), - 'modified_date' => array( + ], + 'modified_date' => [ 'title' => ts('Modified Date'), - ), - 'cancel_date' => array( + ], + 'cancel_date' => [ 'title' => ts('Cancel Date'), - ), - 'end_date' => array( + ], + 'end_date' => [ 'title' => ts('End Date'), - ), - 'next_sched_contribution_date' => array( + ], + 'next_sched_contribution_date' => [ 'title' => ts('Next Scheduled Contribution Date'), - ), - 'failure_count' => array( + ], + 'failure_count' => [ 'title' => ts('Failure Count'), - ), - 'failure_retry_date' => array( + ], + 'failure_retry_date' => [ 'title' => ts('Failure Retry Date'), - ), - 'payment_processor_id' => array( + ], + 'payment_processor_id' => [ 'title' => ts('Payment Processor'), - ), - ), - 'filters' => array( - 'contribution_status_id' => array( + ], + ], + 'filters' => [ + 'contribution_status_id' => [ 'title' => ts('Contribution Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), - 'default' => array(5), + 'default' => [5], 'type' => CRM_Utils_Type::T_INT, - ), - 'currency' => array( + ], + 'currency' => [ 'title' => ts('Currency'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_OptionGroup::values('currencies_enabled'), 'default' => NULL, 'type' => CRM_Utils_Type::T_STRING, - ), - 'financial_type_id' => array( + ], + 'financial_type_id' => [ 'title' => ts('Financial Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes(), 'type' => CRM_Utils_Type::T_INT, - ), - 'frequency_unit' => array( + ], + 'frequency_unit' => [ 'title' => ts('Frequency Unit'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_OptionGroup::values('recur_frequency_units'), 'type' => CRM_Utils_Type::T_STRING, - ), - 'frequency_interval' => array( + ], + 'frequency_interval' => [ 'title' => ts('Frequency Interval'), 'type' => CRM_Utils_Type::T_INT, - ), - 'amount' => array( + ], + 'amount' => [ 'title' => ts('Installment Amount'), 'type' => CRM_Utils_Type::T_MONEY, - ), - 'installments' => array( + ], + 'installments' => [ 'title' => ts('Installments'), 'type' => CRM_Utils_Type::T_INT, - ), - 'start_date' => array( + ], + 'start_date' => [ 'title' => ts('Start Date'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME, - ), - 'next_sched_contribution_date' => array( + ], + 'next_sched_contribution_date' => [ 'title' => ts('Next Scheduled Contribution Date'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME, - ), - 'end_date' => array( + ], + 'end_date' => [ 'title' => ts('End Date'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME, - ), - 'modified_date' => array( + ], + 'modified_date' => [ 'title' => ts('Last Contribution Processed'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME, - ), - 'calculated_end_date' => array( + ], + 'calculated_end_date' => [ 'title' => ts('Calculated end date (either end date or date all installments will be made)'), 'description' => "does this work?", 'operatorType' => CRM_Report_Form::OP_DATE, 'pseudofield' => TRUE, - ), - 'payment_processor_id' => array( + ], + 'payment_processor_id' => [ 'title' => ts('Payment Processor'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_BAO_ContributionRecur::buildOptions('payment_processor_id', 'get'), 'default' => NULL, 'type' => CRM_Utils_Type::T_INT, - ), - ), - ), - ); + ], + ], + ], + ]; $this->_currencyColumn = 'civicrm_contribution_recur_currency'; $this->_groupFilter = TRUE; parent::__construct(); @@ -302,7 +302,7 @@ public function where() { // Or, we calculate the end date based on the start date + // installments * intervals using the mysql date_add function, along // with the interval unit (e.g. DATE_ADD(start_date, INTERVAL 12 * 1 MONTH) - $date_suffixes = array('relative', 'from', 'to'); + $date_suffixes = ['relative', 'from', 'to']; foreach ($date_suffixes as $suffix) { $isBreak = FALSE; // Check to see if the user wants to search by calculated date. diff --git a/CRM/Report/Form/Contribute/RecurSummary.php b/CRM/Report/Form/Contribute/RecurSummary.php index 779473903085..af66c0dc6858 100644 --- a/CRM/Report/Form/Contribute/RecurSummary.php +++ b/CRM/Report/Form/Contribute/RecurSummary.php @@ -37,49 +37,49 @@ class CRM_Report_Form_Contribute_RecurSummary extends CRM_Report_Form { */ public function __construct() { - $this->_columns = array( - 'civicrm_contribution_recur' => array( + $this->_columns = [ + 'civicrm_contribution_recur' => [ 'dao' => 'CRM_Contribute_DAO_ContributionRecur', - 'fields' => array( - 'id' => array( + 'fields' => [ + 'id' => [ 'no_display' => TRUE, 'required' => TRUE, - ), - 'payment_instrument_id' => array( + ], + 'payment_instrument_id' => [ 'title' => ts('Payment Instrument'), 'default' => TRUE, 'required' => TRUE, - ), - 'start_date' => array( + ], + 'start_date' => [ 'title' => ts('Started'), 'default' => TRUE, 'required' => TRUE, - ), - 'cancel_date' => array( + ], + 'cancel_date' => [ 'title' => ts('Cancelled'), 'default' => TRUE, 'required' => TRUE, - ), - 'contribution_status_id' => array( + ], + 'contribution_status_id' => [ 'title' => ts('Active'), 'default' => TRUE, 'required' => TRUE, - ), - 'amount' => array( + ], + 'amount' => [ 'title' => ts('Total Amount'), 'default' => TRUE, 'required' => TRUE, - ), - ), - 'filters' => array( - 'start_date' => array( + ], + ], + 'filters' => [ + 'start_date' => [ 'title' => ts('Start Date'), 'operatorType' => CRM_Report_Form::OP_DATETIME, 'type' => CRM_Utils_Type::T_TIME, - ), - ), - ), - ); + ], + ], + ], + ]; $this->_currencyColumn = 'civicrm_contribution_recur_currency'; parent::__construct(); } @@ -95,8 +95,8 @@ public function setDefaultValues($freeze = TRUE) { public function select() { // @todo remove & only adjust parent with selectWhere fn (if needed) - $select = array(); - $this->_columnHeaders = array(); + $select = []; + $this->_columnHeaders = []; foreach ($this->_columns as $tableName => $table) { if (array_key_exists('group_bys', $table)) { foreach ($table['group_bys'] as $fieldName => $field) { @@ -139,8 +139,8 @@ public function select() { // just to make sure these values are transfered to rows. // since we need that for calculation purpose, // e.g making subtotals look nicer or graphs - $this->_columnHeaders["{$tableName}_{$fieldName}_interval"] = array('no_display' => TRUE); - $this->_columnHeaders["{$tableName}_{$fieldName}_subtotal"] = array('no_display' => TRUE); + $this->_columnHeaders["{$tableName}_{$fieldName}_interval"] = ['no_display' => TRUE]; + $this->_columnHeaders["{$tableName}_{$fieldName}_subtotal"] = ['no_display' => TRUE]; } } } @@ -210,7 +210,7 @@ public function from() { public function postProcess() { $this->beginPostProcess(); $sql = $this->buildQuery(TRUE); - $rows = array(); + $rows = []; $this->buildRows($sql, $rows); $this->formatDisplay($rows); @@ -325,13 +325,13 @@ public function alterDisplay(&$rows) { } // Add total line only if results are available if (count($rows) > 0) { - $lastRow = array( + $lastRow = [ 'civicrm_contribution_recur_payment_instrument_id' => '', 'civicrm_contribution_recur_start_date' => $started, 'civicrm_contribution_recur_cancel_date' => $cancelled, 'civicrm_contribution_recur_contribution_status_id' => $active, 'civicrm_contribution_recur_amount' => CRM_Utils_Money::format($total), - ); + ]; $rows[] = $lastRow; } } diff --git a/CRM/Report/Form/Contribute/SoftCredit.php b/CRM/Report/Form/Contribute/SoftCredit.php index 5296451542ab..31d50193cdae 100644 --- a/CRM/Report/Form/Contribute/SoftCredit.php +++ b/CRM/Report/Form/Contribute/SoftCredit.php @@ -38,19 +38,19 @@ class CRM_Report_Form_Contribute_SoftCredit extends CRM_Report_Form { protected $_emailFieldCredit = FALSE; protected $_phoneField = FALSE; protected $_phoneFieldCredit = FALSE; - protected $_charts = array( + protected $_charts = [ '' => 'Tabular', 'barChart' => 'Bar Chart', 'pieChart' => 'Pie Chart', - ); + ]; - protected $_customGroupExtends = array( + protected $_customGroupExtends = [ 'Contact', 'Individual', 'Contribution', - ); + ]; - public $_drilldownReport = array('contribute/detail' => 'Link to Detail Report'); + public $_drilldownReport = ['contribute/detail' => 'Link to Detail Report']; /** * This report has not been optimised for group filtering. @@ -70,249 +70,249 @@ class CRM_Report_Form_Contribute_SoftCredit extends CRM_Report_Form { public function __construct() { $this->optimisedForOnlyFullGroupBy = FALSE; - $this->_columns = array( - 'civicrm_contact' => array( + $this->_columns = [ + 'civicrm_contact' => [ 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => array( - 'display_name_creditor' => array( + 'fields' => [ + 'display_name_creditor' => [ 'title' => ts('Soft Credit Name'), 'name' => 'sort_name', 'alias' => 'contact_civireport', 'required' => TRUE, 'no_repeat' => TRUE, - ), - 'id_creditor' => array( + ], + 'id_creditor' => [ 'title' => ts('Soft Credit Id'), 'name' => 'id', 'alias' => 'contact_civireport', 'no_display' => TRUE, 'required' => TRUE, - ), - 'display_name_constituent' => array( + ], + 'display_name_constituent' => [ 'title' => ts('Contributor Name'), 'name' => 'sort_name', 'alias' => 'constituentname', 'required' => TRUE, - ), - 'id_constituent' => array( + ], + 'id_constituent' => [ 'title' => ts('Const Id'), 'name' => 'id', 'alias' => 'constituentname', 'no_display' => TRUE, 'required' => TRUE, - ), - 'first_name' => array( + ], + 'first_name' => [ 'title' => ts('First Name'), - ), - 'middle_name' => array( + ], + 'middle_name' => [ 'title' => ts('Middle Name'), - ), - 'last_name' => array( + ], + 'last_name' => [ 'title' => ts('Last Name'), - ), - 'gender_id' => array( + ], + 'gender_id' => [ 'title' => ts('Gender'), - ), - 'birth_date' => array( + ], + 'birth_date' => [ 'title' => ts('Birth Date'), - ), - 'age' => array( + ], + 'age' => [ 'title' => ts('Age'), 'dbAlias' => 'TIMESTAMPDIFF(YEAR, contact_civireport.birth_date, CURDATE())', - ), - 'contact_type' => array( + ], + 'contact_type' => [ 'title' => ts('Contact Type'), - ), - 'contact_sub_type' => array( + ], + 'contact_sub_type' => [ 'title' => ts('Contact Subtype'), - ), - ), + ], + ], 'grouping' => 'contact-fields', - 'order_bys' => array( - 'sort_name' => array( + 'order_bys' => [ + 'sort_name' => [ 'title' => ts('Last Name, First Name'), 'default' => '1', 'default_weight' => '0', 'default_order' => 'ASC', - ), - 'first_name' => array( + ], + 'first_name' => [ 'name' => 'first_name', 'title' => ts('First Name'), - ), - 'gender_id' => array( + ], + 'gender_id' => [ 'name' => 'gender_id', 'title' => ts('Gender'), - ), - 'birth_date' => array( + ], + 'birth_date' => [ 'name' => 'birth_date', 'title' => ts('Birth Date'), - ), - 'age_at_event' => array( + ], + 'age_at_event' => [ 'name' => 'age_at_event', 'title' => ts('Age at Event'), - ), - 'contact_type' => array( + ], + 'contact_type' => [ 'title' => ts('Contact Type'), - ), - 'contact_sub_type' => array( + ], + 'contact_sub_type' => [ 'title' => ts('Contact Subtype'), - ), - ), - 'filters' => array( - 'sort_name' => array( + ], + ], + 'filters' => [ + 'sort_name' => [ 'name' => 'sort_name', 'title' => ts('Soft Credit Name'), - ), - 'gender_id' => array( + ], + 'gender_id' => [ 'title' => ts('Gender'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id'), - ), - 'birth_date' => array( + ], + 'birth_date' => [ 'title' => ts('Birth Date'), 'operatorType' => CRM_Report_Form::OP_DATE, - ), - 'contact_type' => array( + ], + 'contact_type' => [ 'title' => ts('Contact Type'), - ), - 'contact_sub_type' => array( + ], + 'contact_sub_type' => [ 'title' => ts('Contact Subtype'), - ), - ), - ), - 'civicrm_email' => array( + ], + ], + ], + 'civicrm_email' => [ 'dao' => 'CRM_Core_DAO_Email', - 'fields' => array( - 'email_creditor' => array( + 'fields' => [ + 'email_creditor' => [ 'title' => ts('Soft Credit Email'), 'name' => 'email', 'alias' => 'emailcredit', 'default' => TRUE, 'no_repeat' => TRUE, - ), - 'email_constituent' => array( + ], + 'email_constituent' => [ 'title' => ts('Contributor\'s Email'), 'name' => 'email', 'alias' => 'emailconst', - ), - ), + ], + ], 'grouping' => 'contact-fields', - ), - 'civicrm_phone' => array( + ], + 'civicrm_phone' => [ 'dao' => 'CRM_Core_DAO_Phone', - 'fields' => array( - 'phone_creditor' => array( + 'fields' => [ + 'phone_creditor' => [ 'title' => ts('Soft Credit Phone'), 'name' => 'phone', 'alias' => 'pcredit', 'default' => TRUE, - ), - 'phone_constituent' => array( + ], + 'phone_constituent' => [ 'title' => ts('Contributor\'s Phone'), 'name' => 'phone', 'alias' => 'pconst', 'no_repeat' => TRUE, - ), - ), + ], + ], 'grouping' => 'contact-fields', - ), - 'civicrm_financial_type' => array( + ], + 'civicrm_financial_type' => [ 'dao' => 'CRM_Financial_DAO_FinancialType', - 'fields' => array('financial_type' => NULL), - 'filters' => array( - 'id' => array( + 'fields' => ['financial_type' => NULL], + 'filters' => [ + 'id' => [ 'name' => 'id', 'title' => ts('Financial Type'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes(), - ), - ), + ], + ], 'grouping' => 'softcredit-fields', - ), - 'civicrm_contribution' => array( + ], + 'civicrm_contribution' => [ 'dao' => 'CRM_Contribute_DAO_Contribution', - 'fields' => array( + 'fields' => [ 'contribution_source' => NULL, - 'currency' => array( + 'currency' => [ 'required' => TRUE, 'no_display' => TRUE, - ), - ), + ], + ], 'grouping' => 'softcredit-fields', - 'filters' => array( - 'receive_date' => array('operatorType' => CRM_Report_Form::OP_DATE), - 'currency' => array( + 'filters' => [ + 'receive_date' => ['operatorType' => CRM_Report_Form::OP_DATE], + 'currency' => [ 'title' => ts('Currency'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_OptionGroup::values('currencies_enabled'), 'default' => NULL, 'type' => CRM_Utils_Type::T_STRING, - ), - 'contribution_status_id' => array( + ], + 'contribution_status_id' => [ 'title' => ts('Contribution Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), - 'default' => array(1), - ), - ), - ), - 'civicrm_contribution_soft' => array( + 'default' => [1], + ], + ], + ], + 'civicrm_contribution_soft' => [ 'dao' => 'CRM_Contribute_DAO_ContributionSoft', - 'fields' => array( - 'contribution_id' => array( + 'fields' => [ + 'contribution_id' => [ 'title' => ts('Contribution ID'), 'no_display' => TRUE, 'default' => TRUE, - ), - 'amount' => array( + ], + 'amount' => [ 'title' => ts('Amount Statistics'), 'default' => TRUE, - 'statistics' => array( + 'statistics' => [ 'sum' => ts('Aggregate Amount'), 'count' => ts('Contributions'), 'avg' => ts('Average'), - ), - ), - 'id' => array( + ], + ], + 'id' => [ 'default' => TRUE, 'no_display' => TRUE, - ), - 'soft_credit_type_id' => array('title' => ts('Soft Credit Type')), - ), - 'filters' => array( - 'soft_credit_type_id' => array( + ], + 'soft_credit_type_id' => ['title' => ts('Soft Credit Type')], + ], + 'filters' => [ + 'soft_credit_type_id' => [ 'title' => ts('Soft Credit Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_OptionGroup::values('soft_credit_type'), 'default' => NULL, 'type' => CRM_Utils_Type::T_STRING, - ), - 'amount' => array( + ], + 'amount' => [ 'title' => ts('Soft Credit Amount'), - ), - ), + ], + ], 'grouping' => 'softcredit-fields', - ), - 'civicrm_financial_trxn' => array( + ], + 'civicrm_financial_trxn' => [ 'dao' => 'CRM_Financial_DAO_FinancialTrxn', - 'fields' => array( - 'card_type_id' => array( + 'fields' => [ + 'card_type_id' => [ 'title' => ts('Credit Card Type'), 'dbAlias' => 'GROUP_CONCAT(financial_trxn_civireport.card_type_id SEPARATOR ",")', - ), - ), - 'filters' => array( - 'card_type_id' => array( + ], + ], + 'filters' => [ + 'card_type_id' => [ 'title' => ts('Credit Card Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Financial_DAO_FinancialTrxn::buildOptions('card_type_id'), 'default' => NULL, 'type' => CRM_Utils_Type::T_STRING, - ), - ), - ), - ); + ], + ], + ], + ]; // If we have a campaign, build out the relevant elements $this->addCampaignFields('civicrm_contribution'); @@ -329,8 +329,8 @@ public function preProcess() { } public function select() { - $select = array(); - $this->_columnHeaders = array(); + $select = []; + $this->_columnHeaders = []; foreach ($this->_columns as $tableName => $table) { if (array_key_exists('fields', $table)) { foreach ($table['fields'] as $fieldName => $field) { @@ -405,7 +405,7 @@ public function select() { * @return array */ public static function formRule($fields, $files, $self) { - $errors = $grouping = array(); + $errors = $grouping = []; return $errors; } @@ -473,7 +473,7 @@ public function from() { public function groupBy() { $this->_rollup = 'WITH ROLLUP'; - $this->_select = CRM_Contact_BAO_Query::appendAnyValueToSelect($this->selectClause, array("{$this->_aliases['civicrm_contribution_soft']}.contact_id", "constituentname.id")); + $this->_select = CRM_Contact_BAO_Query::appendAnyValueToSelect($this->selectClause, ["{$this->_aliases['civicrm_contribution_soft']}.contact_id", "constituentname.id"]); $this->_groupBy = " GROUP BY {$this->_aliases['civicrm_contribution_soft']}.contact_id, constituentname.id {$this->_rollup}"; } @@ -504,27 +504,27 @@ public function statistics(&$rows) { $dao = CRM_Core_DAO::executeQuery($sql); $count = 0; - $totalAmount = $average = array(); + $totalAmount = $average = []; while ($dao->fetch()) { $totalAmount[] = CRM_Utils_Money::format($dao->amount, $dao->currency) . '(' . $dao->count . ')'; $average[] = CRM_Utils_Money::format($dao->avg, $dao->currency); $count += $dao->count; } - $statistics['counts']['amount'] = array( + $statistics['counts']['amount'] = [ 'title' => ts('Total Amount'), 'value' => implode(', ', $totalAmount), 'type' => CRM_Utils_Type::T_STRING, - ); - $statistics['counts']['count'] = array( + ]; + $statistics['counts']['count'] = [ 'title' => ts('Total Contributions'), 'value' => $count, - ); - $statistics['counts']['avg'] = array( + ]; + $statistics['counts']['avg'] = [ 'title' => ts('Average'), 'value' => implode(', ', $average), 'type' => CRM_Utils_Type::T_STRING, - ); + ]; return $statistics; } @@ -532,10 +532,10 @@ public function statistics(&$rows) { public function postProcess() { $this->beginPostProcess(); - $this->buildACLClause(array('constituentname', 'contact_civireport')); + $this->buildACLClause(['constituentname', 'contact_civireport']); $sql = $this->buildQuery(); - $rows = $graphRows = array(); + $rows = $graphRows = []; $this->buildRows($sql, $rows); $this->formatDisplay($rows); diff --git a/CRM/Report/Form/Contribute/Sybunt.php b/CRM/Report/Form/Contribute/Sybunt.php index e4b59f0d70c5..22c337eb8cec 100644 --- a/CRM/Report/Form/Contribute/Sybunt.php +++ b/CRM/Report/Form/Contribute/Sybunt.php @@ -32,19 +32,19 @@ */ class CRM_Report_Form_Contribute_Sybunt extends CRM_Report_Form { - protected $_charts = array( + protected $_charts = [ '' => 'Tabular', 'barChart' => 'Bar Chart', 'pieChart' => 'Pie Chart', - ); + ]; - protected $_customGroupExtends = array( + protected $_customGroupExtends = [ 'Contact', 'Individual', 'Contribution', - ); + ]; - public $_drilldownReport = array('contribute/detail' => 'Link to Detail Report'); + public $_drilldownReport = ['contribute/detail' => 'Link to Detail Report']; /** * This report has been optimised for group filtering. @@ -70,193 +70,193 @@ public function __construct() { $date['minYear']++; } - $this->_columns = array( - 'civicrm_contact' => array( + $this->_columns = [ + 'civicrm_contact' => [ 'dao' => 'CRM_Contact_DAO_Contact', 'grouping' => 'contact-field', - 'fields' => array( - 'sort_name' => array( + 'fields' => [ + 'sort_name' => [ 'title' => ts('Donor Name'), 'required' => TRUE, - ), - 'first_name' => array( + ], + 'first_name' => [ 'title' => ts('First Name'), - ), - 'middle_name' => array( + ], + 'middle_name' => [ 'title' => ts('Middle Name'), - ), - 'last_name' => array( + ], + 'last_name' => [ 'title' => ts('Last Name'), - ), - 'id' => array( + ], + 'id' => [ 'no_display' => TRUE, 'required' => TRUE, - ), - 'gender_id' => array( + ], + 'gender_id' => [ 'title' => ts('Gender'), - ), - 'birth_date' => array( + ], + 'birth_date' => [ 'title' => ts('Birth Date'), - ), - 'age' => array( + ], + 'age' => [ 'title' => ts('Age'), 'dbAlias' => 'TIMESTAMPDIFF(YEAR, contact_civireport.birth_date, CURDATE())', - ), - 'contact_type' => array( + ], + 'contact_type' => [ 'title' => ts('Contact Type'), - ), - 'contact_sub_type' => array( + ], + 'contact_sub_type' => [ 'title' => ts('Contact Subtype'), - ), - ), - 'order_bys' => array( - 'sort_name' => array( + ], + ], + 'order_bys' => [ + 'sort_name' => [ 'title' => ts('Last Name, First Name'), 'default' => '1', 'default_weight' => '0', 'default_order' => 'ASC', - ), - 'first_name' => array( + ], + 'first_name' => [ 'name' => 'first_name', 'title' => ts('First Name'), - ), - 'gender_id' => array( + ], + 'gender_id' => [ 'name' => 'gender_id', 'title' => ts('Gender'), - ), - 'birth_date' => array( + ], + 'birth_date' => [ 'name' => 'birth_date', 'title' => ts('Birth Date'), - ), - 'age_at_event' => array( + ], + 'age_at_event' => [ 'name' => 'age_at_event', 'title' => ts('Age at Event'), - ), - 'contact_type' => array( + ], + 'contact_type' => [ 'title' => ts('Contact Type'), - ), - 'contact_sub_type' => array( + ], + 'contact_sub_type' => [ 'title' => ts('Contact Subtype'), - ), - ), - 'filters' => array( - 'sort_name' => array( + ], + ], + 'filters' => [ + 'sort_name' => [ 'title' => ts('Donor Name'), 'operator' => 'like', - ), - 'id' => array( + ], + 'id' => [ 'title' => ts('Contact ID'), 'no_display' => TRUE, - ), - 'gender_id' => array( + ], + 'gender_id' => [ 'title' => ts('Gender'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id'), - ), - 'birth_date' => array( + ], + 'birth_date' => [ 'title' => ts('Birth Date'), 'operatorType' => CRM_Report_Form::OP_DATE, - ), - 'contact_type' => array( + ], + 'contact_type' => [ 'title' => ts('Contact Type'), - ), - 'contact_sub_type' => array( + ], + 'contact_sub_type' => [ 'title' => ts('Contact Subtype'), - ), - ), - ), - 'civicrm_line_item' => array( + ], + ], + ], + 'civicrm_line_item' => [ 'dao' => 'CRM_Price_DAO_LineItem', - ), - 'civicrm_email' => array( + ], + 'civicrm_email' => [ 'dao' => 'CRM_Core_DAO_Email', 'grouping' => 'contact-field', - 'fields' => array( - 'email' => array( + 'fields' => [ + 'email' => [ 'title' => ts('Email'), 'default' => TRUE, - ), - ), - ), - 'civicrm_phone' => array( + ], + ], + ], + 'civicrm_phone' => [ 'dao' => 'CRM_Core_DAO_Phone', 'grouping' => 'contact-field', - 'fields' => array( - 'phone' => array( + 'fields' => [ + 'phone' => [ 'title' => ts('Phone'), 'default' => TRUE, - ), - ), - ), - ); + ], + ], + ], + ]; $this->_columns += $this->addAddressFields(); - $this->_columns += array( - 'civicrm_contribution' => array( + $this->_columns += [ + 'civicrm_contribution' => [ 'dao' => 'CRM_Contribute_DAO_Contribution', - 'fields' => array( - 'contact_id' => array( + 'fields' => [ + 'contact_id' => [ 'title' => ts('contactId'), 'no_display' => TRUE, 'required' => TRUE, 'no_repeat' => TRUE, - ), - 'total_amount' => array( + ], + 'total_amount' => [ 'title' => ts('Total Amount'), 'no_display' => TRUE, 'required' => TRUE, 'no_repeat' => TRUE, - ), - 'receive_date' => array( + ], + 'receive_date' => [ 'title' => ts('Year'), 'no_display' => TRUE, 'required' => TRUE, 'no_repeat' => TRUE, - ), - ), - 'filters' => array( - 'yid' => array( + ], + ], + 'filters' => [ + 'yid' => [ 'name' => 'receive_date', 'title' => ts('This Year'), 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => $optionYear, 'default' => date('Y'), 'type' => CRM_Utils_Type::T_INT, - ), - 'financial_type_id' => array( + ], + 'financial_type_id' => [ 'title' => ts('Financial Type'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes(), - ), - 'contribution_status_id' => array( + ], + 'contribution_status_id' => [ 'title' => ts('Contribution Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), - 'default' => array('1'), - ), - ), - ), - ); - $this->_columns += array( - 'civicrm_financial_trxn' => array( + 'default' => ['1'], + ], + ], + ], + ]; + $this->_columns += [ + 'civicrm_financial_trxn' => [ 'dao' => 'CRM_Financial_DAO_FinancialTrxn', - 'fields' => array( - 'card_type_id' => array( + 'fields' => [ + 'card_type_id' => [ 'title' => ts('Credit Card Type'), 'dbAlias' => 'GROUP_CONCAT(financial_trxn_civireport.card_type_id SEPARATOR ",")', - ), - ), - 'filters' => array( - 'card_type_id' => array( + ], + ], + 'filters' => [ + 'card_type_id' => [ 'title' => ts('Credit Card Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'default' => NULL, 'options' => CRM_Financial_DAO_FinancialTrxn::buildOptions('card_type_id'), 'type' => CRM_Utils_Type::T_STRING, - ), - ), - ), - ); + ], + ], + ], + ]; // If we have a campaign, build out the relevant elements $this->addCampaignFields('civicrm_contribution'); @@ -271,8 +271,8 @@ public function preProcess() { } public function select() { - $select = array(); - $this->_columnHeaders = array(); + $select = []; + $this->_columnHeaders = []; $current_year = $this->_params['yid_value']; $previous_year = $current_year - 1; $previous_pyear = $current_year - 2; @@ -290,7 +290,7 @@ public function select() { $select[] = "SUM({$field['dbAlias']}) as {$tableName}_{$fieldName}"; $this->_columnHeaders["civicrm_upto_{$upTo_year}"]['type'] = $field['type']; - $this->_columnHeaders["civicrm_upto_{$upTo_year}"]['title'] = ts("Up To %1", array(1 => $upTo_year)); + $this->_columnHeaders["civicrm_upto_{$upTo_year}"]['title'] = ts("Up To %1", [1 => $upTo_year]); $this->_columnHeaders["year_{$previous_ppyear}"]['type'] = $field['type']; $this->_columnHeaders["year_{$previous_ppyear}"]['title'] = $previous_ppyear; @@ -343,7 +343,7 @@ public function from() { public function where() { $this->_statusClause = ""; - $clauses = array($this->_aliases['civicrm_contribution'] . '.is_test = 0'); + $clauses = [$this->_aliases['civicrm_contribution'] . '.is_test = 0']; foreach ($this->_columns as $tableName => $table) { if (array_key_exists('filters', $table)) { foreach ($table['filters'] as $fieldName => $field) { @@ -400,7 +400,7 @@ public function groupBy() { $this->assign('chartSupported', TRUE); $fiscalYearOffset = self::fiscalYearOffset("{$this->_aliases['civicrm_contribution']}.receive_date"); $this->_groupBy = "GROUP BY {$this->_aliases['civicrm_contribution']}.contact_id, {$fiscalYearOffset}"; - $this->_select = CRM_Contact_BAO_Query::appendAnyValueToSelect($this->_selectClauses, array("{$this->_aliases['civicrm_contribution']}.contact_id", $fiscalYearOffset)); + $this->_select = CRM_Contact_BAO_Query::appendAnyValueToSelect($this->_selectClauses, ["{$this->_aliases['civicrm_contribution']}.contact_id", $fiscalYearOffset]); $this->_groupBy .= " {$this->_rollup}"; } @@ -420,11 +420,11 @@ public function statistics(&$rows) { $sql = "{$select} {$this->_from} {$this->_where}"; $dao = CRM_Core_DAO::executeQuery($sql); if ($dao->fetch()) { - $statistics['counts']['amount'] = array( + $statistics['counts']['amount'] = [ 'value' => $dao->amount, 'title' => ts('Total LifeTime'), 'type' => CRM_Utils_Type::T_MONEY, - ); + ]; } } return $statistics; @@ -436,7 +436,7 @@ public function postProcess() { $this->buildACLClause($this->_aliases['civicrm_contact']); $this->buildQuery(); - $rows = $contactIds = array(); + $rows = $contactIds = []; if (empty($this->_params['charts'])) { $this->limit(); $getContacts = "SELECT SQL_CALC_FOUND_ROWS {$this->_aliases['civicrm_contact']}.id as cid {$this->_from} {$this->_where} GROUP BY {$this->_aliases['civicrm_contact']}.id {$this->_limit}"; @@ -467,15 +467,15 @@ public function postProcess() { $previous_ppyear = $current_year - 3; $upTo_year = $current_year - 4; - $rows = $row = array(); + $rows = $row = []; $dao = CRM_Core_DAO::executeQuery($sql); $contributionSum = 0; - $yearcal = array(); + $yearcal = []; while ($dao->fetch()) { if (!$dao->civicrm_contribution_contact_id) { continue; } - $row = array(); + $row = []; foreach ($this->_columnHeaders as $key => $value) { if (property_exists($dao, $key)) { $rows[$dao->civicrm_contribution_contact_id][$key] = $dao->$key; @@ -513,7 +513,7 @@ public function postProcess() { * @param $rows */ public function buildChart(&$rows) { - $graphRows = array(); + $graphRows = []; $count = 0; $current_year = $this->_params['yid_value']; $previous_year = $current_year - 1; @@ -539,11 +539,11 @@ public function buildChart(&$rows) { $graphRows['value'] = $display; $config = CRM_Core_Config::Singleton(); - $chartInfo = array( + $chartInfo = [ 'legend' => ts('Sybunt Report'), 'xname' => ts('Year'), - 'yname' => ts('Amount (%1)', array(1 => $config->defaultCurrency)), - ); + 'yname' => ts('Amount (%1)', [1 => $config->defaultCurrency]), + ]; if ($this->_params['charts']) { // build the chart. CRM_Utils_OpenFlashChart::reportChart($graphRows, $this->_params['charts'], $interval, $chartInfo); @@ -610,10 +610,10 @@ public function alterDisplay(&$rows) { */ public function getOperationPair($type = "string", $fieldName = NULL) { if ($fieldName == 'yid') { - return array( + return [ 'calendar' => ts('Is Calendar Year'), 'fiscal' => ts('Fiscal Year Starting'), - ); + ]; } return parent::getOperationPair($type, $fieldName); } diff --git a/CRM/Report/Form/Contribute/TopDonor.php b/CRM/Report/Form/Contribute/TopDonor.php index f489c0f187b9..9b613bef3cdb 100644 --- a/CRM/Report/Form/Contribute/TopDonor.php +++ b/CRM/Report/Form/Contribute/TopDonor.php @@ -33,11 +33,11 @@ class CRM_Report_Form_Contribute_TopDonor extends CRM_Report_Form { protected $_summary = NULL; - protected $_customGroupExtends = array( + protected $_customGroupExtends = [ 'Contact', 'Individual', 'Contribution', - ); + ]; /** * This report has not been optimised for group filtering. @@ -52,157 +52,157 @@ class CRM_Report_Form_Contribute_TopDonor extends CRM_Report_Form { */ protected $groupFilterNotOptimised = TRUE; - public $_drilldownReport = array('contribute/detail' => 'Link to Detail Report'); + public $_drilldownReport = ['contribute/detail' => 'Link to Detail Report']; - protected $_charts = array( + protected $_charts = [ '' => 'Tabular', 'barChart' => 'Bar Chart', 'pieChart' => 'Pie Chart', - ); + ]; /** */ public function __construct() { $this->_autoIncludeIndexedFieldsAsOrderBys = 1; - $this->_columns = array( - 'civicrm_contact' => array( + $this->_columns = [ + 'civicrm_contact' => [ 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => array( - 'display_name' => array( + 'fields' => [ + 'display_name' => [ 'title' => ts('Contact Name'), 'required' => TRUE, 'no_repeat' => TRUE, - ), - 'first_name' => array( + ], + 'first_name' => [ 'title' => ts('First Name'), - ), - 'middle_name' => array( + ], + 'middle_name' => [ 'title' => ts('Middle Name'), - ), - 'last_name' => array( + ], + 'last_name' => [ 'title' => ts('Last Name'), - ), - 'id' => array( + ], + 'id' => [ 'no_display' => TRUE, 'required' => TRUE, - ), - 'gender_id' => array( + ], + 'gender_id' => [ 'title' => ts('Gender'), - ), - 'birth_date' => array( + ], + 'birth_date' => [ 'title' => ts('Birth Date'), - ), - 'age' => array( + ], + 'age' => [ 'title' => ts('Age'), 'dbAlias' => 'TIMESTAMPDIFF(YEAR, contact_civireport.birth_date, CURDATE())', - ), - 'contact_type' => array( + ], + 'contact_type' => [ 'title' => ts('Contact Type'), - ), - 'contact_sub_type' => array( + ], + 'contact_sub_type' => [ 'title' => ts('Contact Subtype'), - ), - ), + ], + ], 'filters' => $this->getBasicContactFilters(), 'group_bys' => ['contact_contact_id' => ['name' => 'id', 'required' => 1, 'no_display' => 1]], - ), - 'civicrm_line_item' => array( + ], + 'civicrm_line_item' => [ 'dao' => 'CRM_Price_DAO_LineItem', - ), - ); + ], + ]; $this->_columns += $this->getAddressColumns(['group_by' => FALSE]); - $this->_columns += array( - 'civicrm_contribution' => array( + $this->_columns += [ + 'civicrm_contribution' => [ 'dao' => 'CRM_Contribute_DAO_Contribution', - 'fields' => array( - 'total_amount' => array( + 'fields' => [ + 'total_amount' => [ 'title' => ts('Amount Statistics'), 'required' => TRUE, - 'statistics' => array( + 'statistics' => [ 'sum' => ts('Aggregate Amount'), 'count' => ts('Donations'), 'avg' => ts('Average'), - ), - ), - 'currency' => array( + ], + ], + 'currency' => [ 'required' => TRUE, 'no_display' => TRUE, - ), - ), - 'filters' => array( - 'receive_date' => array( + ], + ], + 'filters' => [ + 'receive_date' => [ 'default' => 'this.year', 'operatorType' => CRM_Report_Form::OP_DATE, - ), - 'currency' => array( + ], + 'currency' => [ 'title' => ts('Currency'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_OptionGroup::values('currencies_enabled'), 'default' => NULL, 'type' => CRM_Utils_Type::T_STRING, - ), - 'total_range' => array( + ], + 'total_range' => [ 'title' => ts('Show no. of Top Donors'), 'type' => CRM_Utils_Type::T_INT, 'default_op' => 'eq', - ), - 'financial_type_id' => array( + ], + 'financial_type_id' => [ 'name' => 'financial_type_id', 'title' => ts('Financial Type'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes(), - ), - 'contribution_status_id' => array( + ], + 'contribution_status_id' => [ 'title' => ts('Contribution Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), - 'default' => array(1), - ), - ), + 'default' => [1], + ], + ], 'group_bys' => ['contribution_currency' => ['name' => 'currency', 'required' => 1, 'no_display' => 1]], - ), - 'civicrm_financial_trxn' => array( + ], + 'civicrm_financial_trxn' => [ 'dao' => 'CRM_Financial_DAO_FinancialTrxn', - 'fields' => array( - 'card_type_id' => array( + 'fields' => [ + 'card_type_id' => [ 'title' => ts('Credit Card Type'), 'dbAlias' => 'GROUP_CONCAT(financial_trxn_civireport.card_type_id SEPARATOR ",")', - ), - ), - 'filters' => array( - 'card_type_id' => array( + ], + ], + 'filters' => [ + 'card_type_id' => [ 'title' => ts('Credit Card Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Financial_DAO_FinancialTrxn::buildOptions('card_type_id'), 'default' => NULL, 'type' => CRM_Utils_Type::T_STRING, - ), - ), - ), - 'civicrm_email' => array( + ], + ], + ], + 'civicrm_email' => [ 'dao' => 'CRM_Core_DAO_Email', - 'fields' => array( - 'email' => array( + 'fields' => [ + 'email' => [ 'title' => ts('Email'), 'default' => TRUE, 'no_repeat' => TRUE, - ), - ), + ], + ], 'grouping' => 'email-fields', - ), - 'civicrm_phone' => array( + ], + 'civicrm_phone' => [ 'dao' => 'CRM_Core_DAO_Phone', - 'fields' => array( - 'phone' => array( + 'fields' => [ + 'phone' => [ 'title' => ts('Phone'), 'default' => TRUE, 'no_repeat' => TRUE, - ), - ), + ], + ], 'grouping' => 'phone-fields', - ), - ); + ], + ]; $this->_groupFilter = TRUE; $this->_tagFilter = TRUE; @@ -218,15 +218,15 @@ public function __construct() { * @return array */ public static function formRule($fields, $files, $self) { - $errors = array(); + $errors = []; $op = CRM_Utils_Array::value('total_range_op', $fields); $val = CRM_Utils_Array::value('total_range_value', $fields); - if (!in_array($op, array( + if (!in_array($op, [ 'eq', 'lte', - )) + ]) ) { $errors['total_range_op'] = ts("Please select 'Is equal to' OR 'Is Less than or equal to' operator"); } @@ -253,7 +253,7 @@ public function from() { } public function where() { - $clauses = array(); + $clauses = []; $this->_tempClause = $this->_outerCluase = $this->_groupLimit = ''; foreach ($this->_columns as $tableName => $table) { if (array_key_exists('filters', $table)) { @@ -328,11 +328,11 @@ public function buildRows($sql, &$rows) { public function add2group($groupID) { if (is_numeric($groupID)) { $this->_limit = $this->_groupLimit; - $rows = array(); + $rows = []; $this->_columnHeaders['civicrm_contact_id'] = 1; $this->buildRows('', $rows); - $contact_ids = array(); + $contact_ids = []; // Add resulting contacts to group foreach ($rows as $row) { $contact_ids[$row['civicrm_contact_id']] = $row['civicrm_contact_id']; diff --git a/CRM/Report/Form/Event/Income.php b/CRM/Report/Form/Event/Income.php index 41bcc465758c..bf62cd0f8649 100644 --- a/CRM/Report/Form/Event/Income.php +++ b/CRM/Report/Form/Event/Income.php @@ -45,19 +45,19 @@ class CRM_Report_Form_Event_Income extends CRM_Report_Form { */ public function __construct() { - $this->_columns = array( - 'civicrm_event' => array( + $this->_columns = [ + 'civicrm_event' => [ 'dao' => 'CRM_Event_DAO_Event', - 'filters' => array( - 'id' => array( + 'filters' => [ + 'id' => [ 'title' => ts('Event'), 'operatorType' => CRM_Report_Form::OP_ENTITYREF, 'type' => CRM_Utils_Type::T_INT, - 'attributes' => array('select' => array('minimumInputLength' => 0)), - ), - ), - ), - ); + 'attributes' => ['select' => ['minimumInputLength' => 0]], + ], + ], + ], + ]; parent::__construct(); } @@ -82,7 +82,7 @@ public function buildEventReport($eventIDs) { $participantRole = CRM_Event_PseudoConstant::participantRole(); $paymentInstruments = CRM_Contribute_PseudoConstant::paymentInstrument(); - $rows = $eventSummary = $roleRows = $statusRows = $instrumentRows = $count = array(); + $rows = $eventSummary = $roleRows = $statusRows = $instrumentRows = $count = []; $optionGroupDAO = new CRM_Core_DAO_OptionGroup(); $optionGroupDAO->name = 'event_type'; @@ -91,7 +91,7 @@ public function buildEventReport($eventIDs) { $optionGroupId = $optionGroupDAO->id; } //show the income of active participant status (Counted = filter = 1) - $activeParticipantStatusIDArray = $activeParticipantStatusLabelArray = array(); + $activeParticipantStatusIDArray = $activeParticipantStatusLabelArray = []; foreach ($participantStatus as $id => $label) { $activeParticipantStatusIDArray[] = $id; $activeParticipantStatusLabelArray[] = $label; @@ -99,7 +99,7 @@ public function buildEventReport($eventIDs) { $activeParticipantStatus = implode(',', $activeParticipantStatusIDArray); $activeparticipnatStutusLabel = implode(', ', $activeParticipantStatusLabelArray); $activeParticipantClause = " AND civicrm_participant.status_id IN ( $activeParticipantStatus ) "; - $select = array( + $select = [ "civicrm_event.id as event_id", "civicrm_event.title as event_title", "civicrm_event.max_participants as max_participants", @@ -107,7 +107,7 @@ public function buildEventReport($eventIDs) { "civicrm_event.end_date as end_date", "civicrm_option_value.label as event_type", "civicrm_participant.fee_currency as currency", - ); + ]; $groupBy = CRM_Contact_BAO_Query::getGroupByFromSelectColumns($select, 'civicrm_event.id'); $sql = " @@ -125,7 +125,7 @@ public function buildEventReport($eventIDs) { WHERE civicrm_event.id IN( {$eventID}) {$groupBy}"; $eventDAO = $this->executeReportQuery($sql); - $currency = array(); + $currency = []; while ($eventDAO->fetch()) { $eventSummary[$eventDAO->event_id][ts('Title')] = $eventDAO->event_title; $eventSummary[$eventDAO->event_id][ts('Max Participants')] = $eventDAO->max_participants; @@ -269,7 +269,7 @@ public function buildEventReport($eventIDs) { * @return array */ public function statistics(&$eventIDs) { - $statistics = array(); + $statistics = []; $count = count($eventIDs); $this->countStat($statistics, $count); if ($this->_setVariable) { @@ -300,14 +300,14 @@ public function limit($rowCount = self::ROW_COUNT_LIMIT) { * @param int $rowCount */ public function setPager($rowCount = self::ROW_COUNT_LIMIT) { - $params = array( + $params = [ 'total' => $this->_rowsFound, 'rowCount' => self::ROW_COUNT_LIMIT, 'status' => ts('Records %%StatusMessage%%'), 'buttonBottom' => 'PagerBottomButton', 'buttonTop' => 'PagerTopButton', 'pageID' => $this->get(CRM_Utils_Pager::PAGE_ID), - ); + ]; $pager = new CRM_Utils_Pager($params); $this->assign_by_ref('pager', $pager); @@ -324,7 +324,7 @@ public function postProcess() { $noSelection = FALSE; if (empty($this->_params['id_value'])) { - $this->_params['id_value'] = array(); + $this->_params['id_value'] = []; $this->_setVariable = FALSE; $events = CRM_Event_PseudoConstant::event(NULL, NULL, @@ -349,7 +349,7 @@ public function postProcess() { $this->limit(); $this->setPager(); - $showEvents = array(); + $showEvents = []; $count = 0; $numRows = $this->_limit; diff --git a/CRM/Report/Form/Event/IncomeCountSummary.php b/CRM/Report/Form/Event/IncomeCountSummary.php index d8dbeed4f4a7..25c5c533b2bb 100644 --- a/CRM/Report/Form/Event/IncomeCountSummary.php +++ b/CRM/Report/Form/Event/IncomeCountSummary.php @@ -34,124 +34,124 @@ class CRM_Report_Form_Event_IncomeCountSummary extends CRM_Report_Form { protected $_summary = NULL; - protected $_charts = array( + protected $_charts = [ '' => 'Tabular', 'barChart' => 'Bar Chart', 'pieChart' => 'Pie Chart', - ); + ]; protected $_add2groupSupported = FALSE; - protected $_customGroupExtends = array( + protected $_customGroupExtends = [ 'Event', - ); + ]; - public $_drilldownReport = array('event/participantlist' => 'Link to Detail Report'); + public $_drilldownReport = ['event/participantlist' => 'Link to Detail Report']; /** * Class constructor. */ public function __construct() { - $this->_columns = array( - 'civicrm_event' => array( + $this->_columns = [ + 'civicrm_event' => [ 'dao' => 'CRM_Event_DAO_Event', - 'fields' => array( - 'title' => array( + 'fields' => [ + 'title' => [ 'title' => ts('Event'), 'required' => TRUE, - ), - 'id' => array( + ], + 'id' => [ 'title' => ts('Event ID'), 'no_display' => TRUE, 'required' => TRUE, - ), - 'event_type_id' => array( + ], + 'event_type_id' => [ 'title' => ts('Event Type'), - ), - 'fee_label' => array( + ], + 'fee_label' => [ 'title' => ts('Fee Label'), - ), - 'event_start_date' => array( + ], + 'event_start_date' => [ 'title' => ts('Event Start Date'), - ), - 'event_end_date' => array( + ], + 'event_end_date' => [ 'title' => ts('Event End Date'), - ), - 'max_participants' => array( + ], + 'max_participants' => [ 'title' => ts('Capacity'), 'type' => CRM_Utils_Type::T_INT, - ), - ), - 'filters' => array( - 'id' => array( + ], + ], + 'filters' => [ + 'id' => [ 'title' => ts('Event'), 'operatorType' => CRM_Report_Form::OP_ENTITYREF, 'type' => CRM_Utils_Type::T_INT, - 'attributes' => array('select' => array('minimumInputLength' => 0)), - ), - 'event_type_id' => array( + 'attributes' => ['select' => ['minimumInputLength' => 0]], + ], + 'event_type_id' => [ 'name' => 'event_type_id', 'title' => ts('Event Type'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_OptionGroup::values('event_type'), - ), - 'event_start_date' => array( + ], + 'event_start_date' => [ 'title' => ts('Event Start Date'), 'operatorType' => CRM_Report_Form::OP_DATE, - ), - 'event_end_date' => array( + ], + 'event_end_date' => [ 'title' => ts('Event End Date'), 'operatorType' => CRM_Report_Form::OP_DATE, - ), - ), - ), - 'civicrm_line_item' => array( + ], + ], + ], + 'civicrm_line_item' => [ 'dao' => 'CRM_Price_DAO_LineItem', - 'fields' => array( - 'participant_count' => array( + 'fields' => [ + 'participant_count' => [ 'title' => ts('Participants'), 'default' => TRUE, - 'statistics' => array( + 'statistics' => [ 'count' => ts('Participants'), - ), - ), - 'line_total' => array( + ], + ], + 'line_total' => [ 'title' => ts('Income Statistics'), 'type' => CRM_Utils_Type::T_MONEY, 'default' => TRUE, - 'statistics' => array( + 'statistics' => [ 'sum' => ts('Income'), 'avg' => ts('Average'), - ), - ), - ), - ), - 'civicrm_participant' => array( + ], + ], + ], + ], + 'civicrm_participant' => [ 'dao' => 'CRM_Event_DAO_Participant', - 'filters' => array( - 'sid' => array( + 'filters' => [ + 'sid' => [ 'name' => 'status_id', 'title' => ts('Participant Status'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Event_PseudoConstant::participantStatus(NULL, NULL, "label"), - ), - 'rid' => array( + ], + 'rid' => [ 'name' => 'role_id', 'title' => ts('Participant Role'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Event_PseudoConstant::participantRole(), - ), - 'participant_register_date' => array( + ], + 'participant_register_date' => [ 'title' => ts('Registration Date'), 'operatorType' => CRM_Report_Form::OP_DATE, - ), - ), - ), - ); + ], + ], + ], + ]; parent::__construct(); } @@ -160,7 +160,7 @@ public function preProcess() { } public function select() { - $select = array(); + $select = []; foreach ($this->_columns as $tableName => $table) { if (array_key_exists('fields', $table)) { foreach ($table['fields'] as $fieldName => $field) { @@ -219,7 +219,7 @@ public function from() { } public function where() { - $clauses = array(); + $clauses = []; $this->_participantWhere = ""; foreach ($this->_columns as $tableName => $table) { if (array_key_exists('filters', $table)) { @@ -280,21 +280,21 @@ public function statistics(&$rows) { if ($dao->count && $dao->amount) { $avg = $dao->amount / $dao->count; } - $statistics['counts']['count'] = array( + $statistics['counts']['count'] = [ 'value' => $dao->count, 'title' => ts('Total Participants'), 'type' => CRM_Utils_Type::T_INT, - ); - $statistics['counts']['amount'] = array( + ]; + $statistics['counts']['amount'] = [ 'value' => $dao->amount, 'title' => ts('Total Income'), 'type' => CRM_Utils_Type::T_MONEY, - ); - $statistics['counts']['avg'] = array( + ]; + $statistics['counts']['avg'] = [ 'value' => $avg, 'title' => ts('Average'), 'type' => CRM_Utils_Type::T_MONEY, - ); + ]; } return $statistics; } @@ -317,11 +317,11 @@ public function postProcess() { //set pager before execution of query in function participantInfo() $this->setPager(); - $rows = $graphRows = array(); + $rows = $graphRows = []; $count = 0; while ($dao->fetch()) { - $row = array(); + $row = []; foreach ($this->_columnHeaders as $key => $value) { if (($key == 'civicrm_event_start_date') || ($key == 'civicrm_event_end_date') @@ -385,17 +385,17 @@ public function buildChart(&$rows) { } if ((!empty($rows)) && $countEvent != 1) { - $chartInfo = array( + $chartInfo = [ 'legend' => ts('Participants Summary'), 'xname' => ts('Event'), 'yname' => ts('Total Participants'), - ); + ]; if (!empty($graphRows)) { foreach ($graphRows[$this->_interval] as $key => $val) { $graph[$val] = $graphRows['value'][$key]; } $chartInfo['values'] = $graph; - $chartInfo['tip'] = ts('Participants : %1', array(1 => '#val#')); + $chartInfo['tip'] = ts('Participants : %1', [1 => '#val#']); $chartInfo['xLabelAngle'] = 20; // build the chart. diff --git a/CRM/Report/Form/Event/ParticipantListCount.php b/CRM/Report/Form/Event/ParticipantListCount.php index a03f9c9c3e50..7ff1c1fca6f9 100644 --- a/CRM/Report/Form/Event/ParticipantListCount.php +++ b/CRM/Report/Form/Event/ParticipantListCount.php @@ -35,10 +35,10 @@ class CRM_Report_Form_Event_ParticipantListCount extends CRM_Report_Form { protected $_summary = NULL; protected $_groupFilter = TRUE; protected $_tagFilter = TRUE; - protected $_customGroupExtends = array( + protected $_customGroupExtends = [ 'Participant', 'Event', - ); + ]; /** * This report has not been optimised for group filtering. * @@ -52,298 +52,298 @@ class CRM_Report_Form_Event_ParticipantListCount extends CRM_Report_Form { */ protected $groupFilterNotOptimised = TRUE; - public $_drilldownReport = array('event/income' => 'Link to Detail Report'); + public $_drilldownReport = ['event/income' => 'Link to Detail Report']; /** * Class constructor. */ public function __construct() { - $this->_columns = array( - 'civicrm_contact' => array( + $this->_columns = [ + 'civicrm_contact' => [ 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => array( - 'sort_name' => array( + 'fields' => [ + 'sort_name' => [ 'title' => ts('Name'), 'default' => TRUE, 'no_repeat' => TRUE, 'required' => TRUE, - ), - 'first_name' => array( + ], + 'first_name' => [ 'title' => ts('First Name'), - ), - 'middle_name' => array( + ], + 'middle_name' => [ 'title' => ts('Middle Name'), - ), - 'last_name' => array( + ], + 'last_name' => [ 'title' => ts('Last Name'), - ), - 'id' => array( + ], + 'id' => [ 'no_display' => TRUE, 'required' => TRUE, - ), - 'gender_id' => array( + ], + 'gender_id' => [ 'title' => ts('Gender'), - ), - 'birth_date' => array( + ], + 'birth_date' => [ 'title' => ts('Birth Date'), - ), - 'age' => array( + ], + 'age' => [ 'title' => ts('Age'), 'dbAlias' => 'TIMESTAMPDIFF(YEAR, contact_civireport.birth_date, CURDATE())', - ), - 'contact_type' => array( + ], + 'contact_type' => [ 'title' => ts('Contact Type'), - ), - 'contact_sub_type' => array( + ], + 'contact_sub_type' => [ 'title' => ts('Contact Subtype'), - ), - ), - 'filters' => array( - 'sort_name' => array( + ], + ], + 'filters' => [ + 'sort_name' => [ 'title' => ts('Participant Name'), 'operator' => 'like', - ), - 'id' => array( + ], + 'id' => [ 'title' => ts('Contact ID'), 'no_display' => TRUE, - ), - 'gender_id' => array( + ], + 'gender_id' => [ 'title' => ts('Gender'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id'), - ), - 'birth_date' => array( + ], + 'birth_date' => [ 'title' => ts('Birth Date'), 'operatorType' => CRM_Report_Form::OP_DATE, - ), - 'contact_type' => array( + ], + 'contact_type' => [ 'title' => ts('Contact Type'), - ), - 'contact_sub_type' => array( + ], + 'contact_sub_type' => [ 'title' => ts('Contact Subtype'), - ), - ), + ], + ], 'grouping' => 'contact-fields', - 'order_bys' => array( - 'sort_name' => array( + 'order_bys' => [ + 'sort_name' => [ 'title' => ts('Last Name, First Name'), 'default' => '1', 'default_weight' => '0', 'default_order' => 'ASC', - ), - 'first_name' => array( + ], + 'first_name' => [ 'name' => 'first_name', 'title' => ts('First Name'), - ), - 'gender_id' => array( + ], + 'gender_id' => [ 'name' => 'gender_id', 'title' => ts('Gender'), - ), - 'birth_date' => array( + ], + 'birth_date' => [ 'name' => 'birth_date', 'title' => ts('Birth Date'), - ), - 'contact_type' => array( + ], + 'contact_type' => [ 'title' => ts('Contact Type'), - ), - 'contact_sub_type' => array( + ], + 'contact_sub_type' => [ 'title' => ts('Contact Subtype'), - ), - ), - ), - 'civicrm_employer' => array( + ], + ], + ], + 'civicrm_employer' => [ 'dao' => 'CRM_Contact_DAO_Contact', 'grouping' => 'contact-fields', - 'fields' => array( - 'id' => array( + 'fields' => [ + 'id' => [ 'no_display' => TRUE, 'required' => TRUE, - ), - 'organization_name' => array( + ], + 'organization_name' => [ 'title' => ts('Employer'), 'default' => TRUE, 'no_repeat' => TRUE, - ), - ), - ), - 'civicrm_email' => array( + ], + ], + ], + 'civicrm_email' => [ 'dao' => 'CRM_Core_DAO_Email', - 'fields' => array( - 'email' => array( + 'fields' => [ + 'email' => [ 'title' => ts('Email'), 'no_repeat' => TRUE, - ), - ), + ], + ], 'grouping' => 'contact-fields', - 'filters' => array( - 'email' => array( + 'filters' => [ + 'email' => [ 'title' => ts('Participant E-mail'), 'operator' => 'like', - ), - ), - ), - 'civicrm_phone' => array( + ], + ], + ], + 'civicrm_phone' => [ 'dao' => 'CRM_Core_DAO_Phone', 'grouping' => 'contact-fields', - 'fields' => array( - 'phone' => array( + 'fields' => [ + 'phone' => [ 'title' => ts('Phone No'), 'default' => TRUE, - ), - ), - ), - 'civicrm_address' => array( + ], + ], + ], + 'civicrm_address' => [ 'dao' => 'CRM_Core_DAO_Address', - 'fields' => array( + 'fields' => [ 'street_address' => NULL, 'city' => NULL, 'postal_code' => NULL, - 'state_province_id' => array( + 'state_province_id' => [ 'title' => ts('State/Province'), - ), - 'country_id' => array( + ], + 'country_id' => [ 'title' => ts('Country'), - ), - ), + ], + ], 'grouping' => 'contact-fields', - ), - 'civicrm_participant' => array( + ], + 'civicrm_participant' => [ 'dao' => 'CRM_Event_DAO_Participant', - 'fields' => array( - 'participant_id' => array( + 'fields' => [ + 'participant_id' => [ 'title' => ts('Participant ID'), 'default' => TRUE, - ), - 'event_id' => array( + ], + 'event_id' => [ 'title' => ts('Event'), 'type' => CRM_Utils_Type::T_STRING, - ), - 'role_id' => array( + ], + 'role_id' => [ 'title' => ts('Role'), 'default' => TRUE, - ), - 'status_id' => array( + ], + 'status_id' => [ 'title' => ts('Status'), 'default' => TRUE, - ), - 'participant_register_date' => array( + ], + 'participant_register_date' => [ 'title' => ts('Registration Date'), - ), - ), + ], + ], 'grouping' => 'event-fields', - 'filters' => array( - 'event_id' => array( + 'filters' => [ + 'event_id' => [ 'name' => 'event_id', 'title' => ts('Event'), 'operatorType' => CRM_Report_Form::OP_ENTITYREF, 'type' => CRM_Utils_Type::T_INT, - 'attributes' => array( + 'attributes' => [ 'entity' => 'Event', - 'select' => array('minimumInputLength' => 0), - ), - ), - 'sid' => array( + 'select' => ['minimumInputLength' => 0], + ], + ], + 'sid' => [ 'name' => 'status_id', 'title' => ts('Participant Status'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Event_PseudoConstant::participantStatus(NULL, NULL, 'label'), - ), - 'rid' => array( + ], + 'rid' => [ 'name' => 'role_id', 'title' => ts('Participant Role'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT_SEPARATOR, 'type' => CRM_Utils_Type::T_INT, 'options' => CRM_Event_PseudoConstant::participantRole(), - ), - 'participant_register_date' => array( + ], + 'participant_register_date' => [ 'title' => ts('Registration Date'), 'operatorType' => CRM_Report_Form::OP_DATE, - ), - ), - 'group_bys' => array( - 'event_id' => array( + ], + ], + 'group_bys' => [ + 'event_id' => [ 'title' => ts('Event'), - ), - ), - ), - 'civicrm_event' => array( + ], + ], + ], + 'civicrm_event' => [ 'dao' => 'CRM_Event_DAO_Event', - 'fields' => array( - 'event_type_id' => array( + 'fields' => [ + 'event_type_id' => [ 'title' => ts('Event Type'), - ), - 'start_date' => array( + ], + 'start_date' => [ 'title' => ts('Event Start Date'), - ), - 'end_date' => array( + ], + 'end_date' => [ 'title' => ts('Event End Date'), - ), - ), + ], + ], 'grouping' => 'event-fields', - 'filters' => array( - 'eid' => array( + 'filters' => [ + 'eid' => [ 'name' => 'event_type_id', 'title' => ts('Event Type'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_OptionGroup::values('event_type'), - ), - 'event_start_date' => array( + ], + 'event_start_date' => [ 'name' => 'event_start_date', 'title' => ts('Event Start Date'), 'operatorType' => CRM_Report_Form::OP_DATE, - ), - 'event_end_date' => array( + ], + 'event_end_date' => [ 'name' => 'event_end_date', 'title' => ts('Event End Date'), 'operatorType' => CRM_Report_Form::OP_DATE, - ), - ), - 'group_bys' => array( - 'event_type_id' => array( + ], + ], + 'group_bys' => [ + 'event_type_id' => [ 'title' => ts('Event Type '), - ), - ), - ), - 'civicrm_line_item' => array( + ], + ], + ], + 'civicrm_line_item' => [ 'dao' => 'CRM_Price_DAO_LineItem', - 'fields' => array( - 'line_total' => array( + 'fields' => [ + 'line_total' => [ 'title' => ts('Income'), 'default' => TRUE, - 'statistics' => array( + 'statistics' => [ 'sum' => ts('Amount'), 'avg' => ts('Average'), - ), - ), - 'participant_count' => array( + ], + ], + 'participant_count' => [ 'title' => ts('Count'), 'default' => TRUE, - 'statistics' => array( + 'statistics' => [ 'sum' => ts('Count'), - ), - ), - ), - ), - ); - - $this->_options = array( - 'blank_column_begin' => array( + ], + ], + ], + ], + ]; + + $this->_options = [ + 'blank_column_begin' => [ 'title' => ts('Blank column at the Begining'), 'type' => 'checkbox', - ), - 'blank_column_end' => array( + ], + 'blank_column_end' => [ 'title' => ts('Blank column at the End'), 'type' => 'select', - 'options' => array( + 'options' => [ '' => '-select-', 1 => ts('One'), 2 => ts('Two'), 3 => ts('Three'), - ), - ), - ); + ], + ], + ]; parent::__construct(); } @@ -371,29 +371,29 @@ public function statistics(&$rows) { if ($dao->count && $dao->amount) { $avg = $dao->amount / $dao->count; } - $statistics['counts']['count'] = array( + $statistics['counts']['count'] = [ 'value' => $dao->count, 'title' => ts('Total Participants'), 'type' => CRM_Utils_Type::T_INT, - ); - $statistics['counts']['amount'] = array( + ]; + $statistics['counts']['amount'] = [ 'value' => $dao->amount, 'title' => ts('Total Income'), 'type' => CRM_Utils_Type::T_MONEY, - ); - $statistics['counts']['avg'] = array( + ]; + $statistics['counts']['avg'] = [ 'value' => $avg, 'title' => ts('Average'), 'type' => CRM_Utils_Type::T_MONEY, - ); + ]; } return $statistics; } public function select() { - $select = array(); - $this->_columnHeaders = array(); + $select = []; + $this->_columnHeaders = []; //add blank column at the Start if (array_key_exists('options', $this->_params) && @@ -448,7 +448,7 @@ public function select() { * @return array */ public static function formRule($fields, $files, $self) { - $errors = $grouping = array(); + $errors = $grouping = []; return $errors; } @@ -590,7 +590,7 @@ public function alterDisplay(&$rows) { if (array_key_exists('civicrm_participant_role_id', $row)) { if ($value = $row['civicrm_participant_role_id']) { $roles = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value); - $value = array(); + $value = []; foreach ($roles as $role) { $value[$role] = CRM_Event_PseudoConstant::participantRole($role, FALSE); } diff --git a/CRM/Report/Form/Event/Summary.php b/CRM/Report/Form/Event/Summary.php index 0d689cc848b2..ec4d864bb151 100644 --- a/CRM/Report/Form/Event/Summary.php +++ b/CRM/Report/Form/Event/Summary.php @@ -34,75 +34,75 @@ class CRM_Report_Form_Event_Summary extends CRM_Report_Form { protected $_summary = NULL; - protected $_charts = array( + protected $_charts = [ '' => 'Tabular', 'barChart' => 'Bar Chart', 'pieChart' => 'Pie Chart', - ); + ]; protected $_add2groupSupported = FALSE; - protected $_customGroupExtends = array( + protected $_customGroupExtends = [ 'Event', - ); - public $_drilldownReport = array('event/income' => 'Link to Detail Report'); + ]; + public $_drilldownReport = ['event/income' => 'Link to Detail Report']; /** * Class constructor. */ public function __construct() { - $this->_columns = array( - 'civicrm_event' => array( + $this->_columns = [ + 'civicrm_event' => [ 'dao' => 'CRM_Event_DAO_Event', - 'fields' => array( - 'id' => array( + 'fields' => [ + 'id' => [ 'no_display' => TRUE, 'required' => TRUE, - ), - 'title' => array( + ], + 'title' => [ 'title' => ts('Event Title'), 'required' => TRUE, - ), - 'event_type_id' => array( + ], + 'event_type_id' => [ 'title' => ts('Event Type'), 'required' => TRUE, - ), - 'fee_label' => array('title' => ts('Fee Label')), - 'event_start_date' => array( + ], + 'fee_label' => ['title' => ts('Fee Label')], + 'event_start_date' => [ 'title' => ts('Event Start Date'), - ), - 'event_end_date' => array('title' => ts('Event End Date')), - 'max_participants' => array( + ], + 'event_end_date' => ['title' => ts('Event End Date')], + 'max_participants' => [ 'title' => ts('Capacity'), 'type' => CRM_Utils_Type::T_INT, - ), - ), - 'filters' => array( - 'id' => array( + ], + ], + 'filters' => [ + 'id' => [ 'title' => ts('Event'), 'operatorType' => CRM_Report_Form::OP_ENTITYREF, 'type' => CRM_Utils_Type::T_INT, - 'attributes' => array('select' => array('minimumInputLength' => 0)), - ), - 'event_type_id' => array( + 'attributes' => ['select' => ['minimumInputLength' => 0]], + ], + 'event_type_id' => [ 'name' => 'event_type_id', 'title' => ts('Event Type'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_OptionGroup::values('event_type'), - ), - 'event_start_date' => array( + ], + 'event_start_date' => [ 'title' => ts('Event Start Date'), 'operatorType' => CRM_Report_Form::OP_DATE, - ), - 'event_end_date' => array( + ], + 'event_end_date' => [ 'title' => ts('Event End Date'), 'operatorType' => CRM_Report_Form::OP_DATE, - ), - ), - ), - ); + ], + ], + ], + ]; $this->_currencyColumn = 'civicrm_participant_fee_currency'; parent::__construct(); } @@ -112,7 +112,7 @@ public function preProcess() { } public function select() { - $select = array(); + $select = []; foreach ($this->_columns as $tableName => $table) { if (array_key_exists('fields', $table)) { foreach ($table['fields'] as $fieldName => $field) { @@ -134,7 +134,7 @@ public function from() { } public function where() { - $clauses = array(); + $clauses = []; $this->_participantWhere = ""; foreach ($this->_columns as $tableName => $table) { if (array_key_exists('filters', $table)) { @@ -206,7 +206,7 @@ public function participantInfo() { civicrm_participant.fee_currency"; $info = CRM_Core_DAO::executeQuery($sql); - $participant_data = $participant_info = $currency = array(); + $participant_data = $participant_info = $currency = []; while ($info->fetch()) { $participant_data[$info->event_id][$info->statusId]['participant'] = $info->participant; @@ -247,7 +247,7 @@ public function participantInfo() { * Build header for table. */ public function buildColumnHeaders() { - $this->_columnHeaders = array(); + $this->_columnHeaders = []; foreach ($this->_columns as $tableName => $table) { if (array_key_exists('fields', $table)) { foreach ($table['fields'] as $fieldName => $field) { @@ -271,18 +271,18 @@ public function buildColumnHeaders() { //make column header for participant status No-show/Cancelled/Pending $type2_header = implode('/', $statusType2); - $this->_columnHeaders['statusType1'] = array( + $this->_columnHeaders['statusType1'] = [ 'title' => $type1_header, 'type' => CRM_Utils_Type::T_INT, - ); - $this->_columnHeaders['statusType2'] = array( + ]; + $this->_columnHeaders['statusType2'] = [ 'title' => $type2_header, 'type' => CRM_Utils_Type::T_INT, - ); - $this->_columnHeaders['totalAmount'] = array( + ]; + $this->_columnHeaders['totalAmount'] = [ 'title' => ts('Total Income'), 'type' => CRM_Utils_Type::T_STRING, - ); + ]; } public function postProcess() { @@ -298,10 +298,10 @@ public function postProcess() { //set pager before exicution of query in function participantInfo() $this->setPager(); - $rows = $graphRows = array(); + $rows = $graphRows = []; $count = 0; while ($dao->fetch()) { - $row = array(); + $row = []; foreach ($this->_columnHeaders as $key => $value) { if (($key == 'civicrm_event_start_date') || ($key == 'civicrm_event_end_date') @@ -355,11 +355,11 @@ public function buildChart(&$rows) { if ((!empty($rows)) && $countEvent != 1) { $config = CRM_Core_Config::Singleton(); - $chartInfo = array( + $chartInfo = [ 'legend' => ts('Event Summary'), 'xname' => ts('Event'), - 'yname' => ts('Total Amount (%1)', array(1 => $config->defaultCurrency)), - ); + 'yname' => ts('Total Amount (%1)', [1 => $config->defaultCurrency]), + ]; if (!empty($graphRows)) { foreach ($graphRows[$this->_interval] as $key => $val) { $graph[$val] = $graphRows['value'][$key]; diff --git a/CRM/Report/Form/Extended.php b/CRM/Report/Form/Extended.php index b698ff7c468f..9e04ef659b41 100644 --- a/CRM/Report/Form/Extended.php +++ b/CRM/Report/Form/Extended.php @@ -39,7 +39,7 @@ class CRM_Report_Form_Extended extends CRM_Report_Form { protected $_summary = NULL; - protected $_customGroupExtends = array(); + protected $_customGroupExtends = []; protected $_baseTable = 'civicrm_contact'; /** @@ -88,7 +88,7 @@ public function from() { * @return array */ public function fromClauses() { - return array(); + return []; } public function groupBy() { @@ -149,7 +149,7 @@ public function alterDisplay(&$rows) { } $selectedFields = array_keys($firstRow); - $alterfunctions = $altermap = array(); + $alterfunctions = $altermap = []; foreach ($this->_columns as $tablename => $table) { if (array_key_exists('fields', $table)) { foreach ($table['fields'] as $field => $specs) { @@ -181,526 +181,526 @@ public function alterDisplay(&$rows) { * @return array */ public function getLineItemColumns() { - return array( - 'civicrm_line_item' => array( + return [ + 'civicrm_line_item' => [ 'dao' => 'CRM_Price_BAO_LineItem', - 'fields' => array( - 'qty' => array( + 'fields' => [ + 'qty' => [ 'title' => ts('Quantity'), 'type' => CRM_Utils_Type::T_INT, - 'statistics' => array('sum' => ts('Total Quantity Selected')), - ), - 'unit_price' => array( + 'statistics' => ['sum' => ts('Total Quantity Selected')], + ], + 'unit_price' => [ 'title' => ts('Unit Price'), - ), - 'line_total' => array( + ], + 'line_total' => [ 'title' => ts('Line Total'), 'type' => CRM_Utils_Type::T_MONEY, - 'statistics' => array('sum' => ts('Total of Line Items')), - ), - ), - 'participant_count' => array( + 'statistics' => ['sum' => ts('Total of Line Items')], + ], + ], + 'participant_count' => [ 'title' => ts('Participant Count'), - 'statistics' => array('sum' => ts('Total Participants')), - ), - 'filters' => array( - 'qty' => array( + 'statistics' => ['sum' => ts('Total Participants')], + ], + 'filters' => [ + 'qty' => [ 'title' => ts('Quantity'), 'type' => CRM_Utils_Type::T_INT, 'operator' => CRM_Report_Form::OP_INT, - ), - ), - 'group_bys' => array( - 'price_field_id' => array( + ], + ], + 'group_bys' => [ + 'price_field_id' => [ 'title' => ts('Price Field'), - ), - 'price_field_value_id' => array( + ], + 'price_field_value_id' => [ 'title' => ts('Price Field Option'), - ), - 'line_item_id' => array( + ], + 'line_item_id' => [ 'title' => ts('Individual Line Item'), 'name' => 'id', - ), - ), - ), - ); + ], + ], + ], + ]; } /** * @return array */ public function getPriceFieldValueColumns() { - return array( - 'civicrm_price_field_value' => array( + return [ + 'civicrm_price_field_value' => [ 'dao' => 'CRM_Price_BAO_PriceFieldValue', - 'fields' => array( - 'price_field_value_label' => array( + 'fields' => [ + 'price_field_value_label' => [ 'title' => ts('Price Field Value Label'), 'name' => 'label', - ), - ), - 'filters' => array( - 'price_field_value_label' => array( + ], + ], + 'filters' => [ + 'price_field_value_label' => [ 'title' => ts('Price Fields Value Label'), 'type' => CRM_Utils_Type::T_STRING, 'operator' => 'like', 'name' => 'label', - ), - ), - 'order_bys' => array( - 'label' => array( + ], + ], + 'order_bys' => [ + 'label' => [ 'title' => ts('Price Field Value Label'), - ), - ), + ], + ], 'group_bys' => //note that we have a requirement to group by label such that all 'Promo book' lines // are grouped together across price sets but there may be a separate need to group // by id so that entries in one price set are distinct from others. Not quite sure what // to call the distinction for end users benefit - array( - 'price_field_value_label' => array( + [ + 'price_field_value_label' => [ 'title' => ts('Price Field Value Label'), 'name' => 'label', - ), - ), - ), - ); + ], + ], + ], + ]; } /** * @return array */ public function getPriceFieldColumns() { - return array( - 'civicrm_price_field' => array( + return [ + 'civicrm_price_field' => [ 'dao' => 'CRM_Price_BAO_PriceField', - 'fields' => array( - 'price_field_label' => array( + 'fields' => [ + 'price_field_label' => [ 'title' => ts('Price Field Label'), 'name' => 'label', - ), - ), - 'filters' => array( - 'price_field_label' => array( + ], + ], + 'filters' => [ + 'price_field_label' => [ 'title' => ts('Price Field Label'), 'type' => CRM_Utils_Type::T_STRING, 'operator' => 'like', 'name' => 'label', - ), - ), - 'order_bys' => array( - 'price_field_label' => array( + ], + ], + 'order_bys' => [ + 'price_field_label' => [ 'title' => ts('Price Field Label'), 'name' => 'label', - ), - ), - 'group_bys' => array( - 'price_field_label' => array( + ], + ], + 'group_bys' => [ + 'price_field_label' => [ 'title' => ts('Price Field Label'), 'name' => 'label', - ), - ), - ), - ); + ], + ], + ], + ]; } /** * @return array */ public function getParticipantColumns() { - static $_events = array(); + static $_events = []; if (!isset($_events['all'])) { CRM_Core_PseudoConstant::populate($_events['all'], 'CRM_Event_DAO_Event', FALSE, 'title', 'is_active', "is_template IS NULL OR is_template = 0", 'end_date DESC'); } - return array( - 'civicrm_participant' => array( + return [ + 'civicrm_participant' => [ 'dao' => 'CRM_Event_DAO_Participant', - 'fields' => array( - 'participant_id' => array('title' => ts('Participant ID')), - 'participant_record' => array( + 'fields' => [ + 'participant_id' => ['title' => ts('Participant ID')], + 'participant_record' => [ 'name' => 'id', 'title' => ts('Participant ID'), - ), - 'event_id' => array( + ], + 'event_id' => [ 'title' => ts('Event ID'), 'type' => CRM_Utils_Type::T_STRING, 'alter_display' => 'alterEventID', - ), - 'status_id' => array( + ], + 'status_id' => [ 'title' => ts('Status'), 'alter_display' => 'alterParticipantStatus', - ), - 'role_id' => array( + ], + 'role_id' => [ 'title' => ts('Role'), 'alter_display' => 'alterParticipantRole', - ), + ], 'participant_fee_level' => NULL, 'participant_fee_amount' => NULL, - 'participant_register_date' => array('title' => ts('Registration Date')), - ), + 'participant_register_date' => ['title' => ts('Registration Date')], + ], 'grouping' => 'event-fields', - 'filters' => array( - 'event_id' => array( + 'filters' => [ + 'event_id' => [ 'name' => 'event_id', 'title' => ts('Event'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $_events['all'], - ), - 'sid' => array( + ], + 'sid' => [ 'name' => 'status_id', 'title' => ts('Participant Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Event_PseudoConstant::participantStatus(NULL, NULL, 'label'), - ), - 'rid' => array( + ], + 'rid' => [ 'name' => 'role_id', 'title' => ts('Participant Role'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Event_PseudoConstant::participantRole(), - ), - 'participant_register_date' => array( + ], + 'participant_register_date' => [ 'title' => ts('Registration Date'), 'operatorType' => CRM_Report_Form::OP_DATE, - ), - ), - 'order_bys' => array( - 'event_id' => array( + ], + ], + 'order_bys' => [ + 'event_id' => [ 'title' => ts('Event'), 'default_weight' => '1', 'default_order' => 'ASC', - ), - ), - 'group_bys' => array( - 'event_id' => array('title' => ts('Event')), - ), - ), - ); + ], + ], + 'group_bys' => [ + 'event_id' => ['title' => ts('Event')], + ], + ], + ]; } /** * @return array */ public function getMembershipColumns() { - return array( - 'civicrm_membership' => array( + return [ + 'civicrm_membership' => [ 'dao' => 'CRM_Member_DAO_Membership', 'grouping' => 'member-fields', - 'fields' => array( - 'membership_type_id' => array( + 'fields' => [ + 'membership_type_id' => [ 'title' => ts('Membership Type'), 'required' => TRUE, 'alter_display' => 'alterMembershipTypeID', - ), - 'status_id' => array( + ], + 'status_id' => [ 'title' => ts('Membership Status'), 'required' => TRUE, 'alter_display' => 'alterMembershipStatusID', - ), + ], 'join_date' => NULL, - 'start_date' => array( + 'start_date' => [ 'title' => ts('Current Cycle Start Date'), - ), - 'end_date' => array( + ], + 'end_date' => [ 'title' => ts('Current Membership Cycle End Date'), - ), - ), - 'group_bys' => array( - 'membership_type_id' => array( + ], + ], + 'group_bys' => [ + 'membership_type_id' => [ 'title' => ts('Membership Type'), - ), - ), - 'filters' => array( - 'join_date' => array( + ], + ], + 'filters' => [ + 'join_date' => [ 'type' => CRM_Utils_Type::T_DATE, 'operatorType' => CRM_Report_Form::OP_DATE, - ), - ), - ), - ); + ], + ], + ], + ]; } /** * @return array */ public function getMembershipTypeColumns() { - return array( - 'civicrm_membership_type' => array( + return [ + 'civicrm_membership_type' => [ 'dao' => 'CRM_Member_DAO_MembershipType', 'grouping' => 'member-fields', - 'filters' => array( - 'gid' => array( + 'filters' => [ + 'gid' => [ 'name' => 'id', 'title' => ts('Membership Types'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'type' => CRM_Utils_Type::T_INT + CRM_Utils_Type::T_ENUM, 'options' => CRM_Member_PseudoConstant::membershipType(), - ), - ), - ), - ); + ], + ], + ], + ]; } /** * @return array */ public function getEventColumns() { - return array( - 'civicrm_event' => array( + return [ + 'civicrm_event' => [ 'dao' => 'CRM_Event_DAO_Event', - 'fields' => array( - 'id' => array( + 'fields' => [ + 'id' => [ 'no_display' => TRUE, 'required' => TRUE, - ), - 'title' => array( + ], + 'title' => [ 'title' => ts('Event Title'), 'required' => TRUE, - ), - 'event_type_id' => array( + ], + 'event_type_id' => [ 'title' => ts('Event Type'), 'required' => TRUE, 'alter_display' => 'alterEventType', - ), - 'fee_label' => array('title' => ts('Fee Label')), - 'event_start_date' => array( + ], + 'fee_label' => ['title' => ts('Fee Label')], + 'event_start_date' => [ 'title' => ts('Event Start Date'), - ), - 'event_end_date' => array('title' => ts('Event End Date')), - 'max_participants' => array( + ], + 'event_end_date' => ['title' => ts('Event End Date')], + 'max_participants' => [ 'title' => ts('Capacity'), 'type' => CRM_Utils_Type::T_INT, - ), - ), + ], + ], 'grouping' => 'event-fields', - 'filters' => array( - 'event_type_id' => array( + 'filters' => [ + 'event_type_id' => [ 'name' => 'event_type_id', 'title' => ts('Event Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_OptionGroup::values('event_type'), - ), - 'event_title' => array( + ], + 'event_title' => [ 'name' => 'title', 'title' => ts('Event Title'), 'operatorType' => CRM_Report_Form::OP_STRING, - ), - ), - 'order_bys' => array( - 'event_type_id' => array( + ], + ], + 'order_bys' => [ + 'event_type_id' => [ 'title' => ts('Event Type'), 'default_weight' => '2', 'default_order' => 'ASC', - ), - ), - 'group_bys' => array( - 'event_type_id' => array( + ], + ], + 'group_bys' => [ + 'event_type_id' => [ 'title' => ts('Event Type'), - ), - ), - ), - ); + ], + ], + ], + ]; } /** * @return array */ public function getContributionColumns() { - return array( - 'civicrm_contribution' => array( + return [ + 'civicrm_contribution' => [ 'dao' => 'CRM_Contribute_DAO_Contribution', - 'fields' => array( - 'contribution_id' => array( + 'fields' => [ + 'contribution_id' => [ 'name' => 'id', - ), - 'financial_type_id' => array( + ], + 'financial_type_id' => [ 'title' => ts('Financial Type'), 'default' => TRUE, 'alter_display' => 'alterContributionType', - ), - 'payment_instrument_id' => array( + ], + 'payment_instrument_id' => [ 'title' => ts('Payment Method'), 'alter_display' => 'alterPaymentType', - ), - 'source' => array('title' => ts('Contribution Source')), + ], + 'source' => ['title' => ts('Contribution Source')], 'trxn_id' => NULL, - 'receive_date' => array('default' => TRUE), + 'receive_date' => ['default' => TRUE], 'receipt_date' => NULL, 'fee_amount' => NULL, 'net_amount' => NULL, - 'total_amount' => array( + 'total_amount' => [ 'title' => ts('Amount'), - 'statistics' => array('sum' => ts('Total Amount')), + 'statistics' => ['sum' => ts('Total Amount')], 'type' => CRM_Utils_Type::T_MONEY, - ), - ), - 'filters' => array( - 'receive_date' => array('operatorType' => CRM_Report_Form::OP_DATE), - 'financial_type_id' => array( + ], + ], + 'filters' => [ + 'receive_date' => ['operatorType' => CRM_Report_Form::OP_DATE], + 'financial_type_id' => [ 'title' => ts('Financial Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::financialType(), - ), - 'payment_instrument_id' => array( + ], + 'payment_instrument_id' => [ 'title' => ts('Payment Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::paymentInstrument(), - ), - 'contribution_status_id' => array( + ], + 'contribution_status_id' => [ 'title' => ts('Contribution Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), - ), - 'total_amount' => array('title' => ts('Contribution Amount')), - ), - 'order_bys' => array( - 'payment_instrument_id' => array( + ], + 'total_amount' => ['title' => ts('Contribution Amount')], + ], + 'order_bys' => [ + 'payment_instrument_id' => [ 'title' => ts('Payment Method'), - ), - 'financial_type_id' => array( + ], + 'financial_type_id' => [ 'title' => ts('Financial Type'), - ), - ), - 'group_bys' => array( - 'financial_type_id' => array('title' => ts('Financial Type')), - 'payment_instrument_id' => array('title' => ts('Payment Method')), - 'contribution_id' => array( + ], + ], + 'group_bys' => [ + 'financial_type_id' => ['title' => ts('Financial Type')], + 'payment_instrument_id' => ['title' => ts('Payment Method')], + 'contribution_id' => [ 'title' => ts('Individual Contribution'), 'name' => 'id', - ), - 'source' => array('title' => ts('Contribution Source')), - ), + ], + 'source' => ['title' => ts('Contribution Source')], + ], 'grouping' => 'contribution-fields', - ), - ); + ], + ]; } /** * @return array */ public function getContactColumns() { - return array( - 'civicrm_contact' => array( + return [ + 'civicrm_contact' => [ 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => array( - 'display_name' => array( + 'fields' => [ + 'display_name' => [ 'title' => ts('Contact Name'), - ), - 'id' => array( + ], + 'id' => [ 'title' => ts('Contact ID'), 'alter_display' => 'alterContactID', - ), - 'first_name' => array( + ], + 'first_name' => [ 'title' => ts('First Name'), - ), - 'last_name' => array( + ], + 'last_name' => [ 'title' => ts('Last Name'), - ), - 'nick_name' => array( + ], + 'nick_name' => [ 'title' => ts('Nickname'), 'alter_display' => 'alterNickname', - ), - ), - 'filters' => array( - 'id' => array( + ], + ], + 'filters' => [ + 'id' => [ 'title' => ts('Contact ID'), - ), - 'sort_name' => array( + ], + 'sort_name' => [ 'title' => ts('Contact Name'), - ), - ), + ], + ], 'grouping' => 'contact-fields', - 'order_bys' => array( - 'sort_name' => array( + 'order_bys' => [ + 'sort_name' => [ 'title' => ts('Last Name, First Name'), 'default' => '1', 'default_weight' => '0', 'default_order' => 'ASC', - ), - ), - ), - ); + ], + ], + ], + ]; } /** * @return array */ public function getCaseColumns() { - return array( - 'civicrm_case' => array( + return [ + 'civicrm_case' => [ 'dao' => 'CRM_Case_DAO_Case', - 'fields' => array( - 'id' => array( + 'fields' => [ + 'id' => [ 'title' => ts('Case ID'), 'required' => FALSE, - ), - 'subject' => array( + ], + 'subject' => [ 'title' => ts('Case Subject'), 'default' => TRUE, - ), - 'status_id' => array( + ], + 'status_id' => [ 'title' => ts('Status'), 'default' => TRUE, - ), - 'case_type_id' => array( + ], + 'case_type_id' => [ 'title' => ts('Case Type'), 'default' => TRUE, - ), - 'case_start_date' => array( + ], + 'case_start_date' => [ 'title' => ts('Case Start Date'), 'name' => 'start_date', 'default' => TRUE, - ), - 'case_end_date' => array( + ], + 'case_end_date' => [ 'title' => ts('Case End Date'), 'name' => 'end_date', 'default' => TRUE, - ), - 'case_duration' => array( + ], + 'case_duration' => [ 'name' => 'duration', 'title' => ts('Duration (Days)'), 'default' => FALSE, - ), - 'case_is_deleted' => array( + ], + 'case_is_deleted' => [ 'name' => 'is_deleted', 'title' => ts('Case Deleted?'), 'default' => FALSE, 'type' => CRM_Utils_Type::T_INT, - ), - ), - 'filters' => array( - 'case_start_date' => array( + ], + ], + 'filters' => [ + 'case_start_date' => [ 'title' => ts('Case Start Date'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE, 'name' => 'start_date', - ), - 'case_end_date' => array( + ], + 'case_end_date' => [ 'title' => ts('Case End Date'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE, 'name' => 'end_date', - ), - 'case_type_id' => array( + ], + 'case_type_id' => [ 'title' => ts('Case Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->case_types, - ), - 'case_status_id' => array( + ], + 'case_status_id' => [ 'title' => ts('Case Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->case_statuses, 'name' => 'status_id', - ), - 'case_is_deleted' => array( + ], + 'case_is_deleted' => [ 'title' => ts('Case Deleted?'), 'type' => CRM_Report_Form::OP_INT, 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => $this->deleted_labels, 'default' => 0, 'name' => 'is_deleted', - ), - ), - ), - ); + ], + ], + ], + ]; } /** @@ -718,204 +718,204 @@ public function getCaseColumns() { * @return array * address columns definition */ - public function getAddressColumns($options = array()) { - $defaultOptions = array( + public function getAddressColumns($options = []) { + $defaultOptions = [ 'prefix' => '', 'prefix_label' => '', 'group_by' => FALSE, 'order_by' => TRUE, 'filters' => TRUE, - 'defaults' => array( + 'defaults' => [ 'country_id' => TRUE, - ), - ); + ], + ]; $options = array_merge($defaultOptions, $options); - $addressFields = array( - $options['prefix'] . 'civicrm_address' => array( + $addressFields = [ + $options['prefix'] . 'civicrm_address' => [ 'dao' => 'CRM_Core_DAO_Address', 'name' => 'civicrm_address', 'alias' => $options['prefix'] . 'civicrm_address', - 'fields' => array( - $options['prefix'] . 'name' => array( + 'fields' => [ + $options['prefix'] . 'name' => [ 'title' => ts($options['prefix_label'] . 'Address Name'), 'default' => CRM_Utils_Array::value('name', $options['defaults'], FALSE), 'name' => 'name', - ), - $options['prefix'] . 'street_address' => array( + ], + $options['prefix'] . 'street_address' => [ 'title' => ts($options['prefix_label'] . 'Street Address'), 'default' => CRM_Utils_Array::value('street_address', $options['defaults'], FALSE), 'name' => 'street_address', - ), - $options['prefix'] . 'supplemental_address_1' => array( + ], + $options['prefix'] . 'supplemental_address_1' => [ 'title' => ts($options['prefix_label'] . 'Supplementary Address Field 1'), 'default' => CRM_Utils_Array::value('supplemental_address_1', $options['defaults'], FALSE), 'name' => 'supplemental_address_1', - ), - $options['prefix'] . 'supplemental_address_2' => array( + ], + $options['prefix'] . 'supplemental_address_2' => [ 'title' => ts($options['prefix_label'] . 'Supplementary Address Field 2'), 'default' => CRM_Utils_Array::value('supplemental_address_2', $options['defaults'], FALSE), 'name' => 'supplemental_address_2', - ), - $options['prefix'] . 'supplemental_address_3' => array( + ], + $options['prefix'] . 'supplemental_address_3' => [ 'title' => ts($options['prefix_label'] . 'Supplementary Address Field 3'), 'default' => CRM_Utils_Array::value('supplemental_address_3', $options['defaults'], FALSE), 'name' => 'supplemental_address_3', - ), - $options['prefix'] . 'street_number' => array( + ], + $options['prefix'] . 'street_number' => [ 'name' => 'street_number', 'title' => ts($options['prefix_label'] . 'Street Number'), 'type' => 1, 'default' => CRM_Utils_Array::value('street_number', $options['defaults'], FALSE), - ), - $options['prefix'] . 'street_name' => array( + ], + $options['prefix'] . 'street_name' => [ 'name' => 'street_name', 'title' => ts($options['prefix_label'] . 'Street Name'), 'type' => 1, 'default' => CRM_Utils_Array::value('street_name', $options['defaults'], FALSE), - ), - $options['prefix'] . 'street_unit' => array( + ], + $options['prefix'] . 'street_unit' => [ 'name' => 'street_unit', 'title' => ts($options['prefix_label'] . 'Street Unit'), 'type' => 1, 'default' => CRM_Utils_Array::value('street_unit', $options['defaults'], FALSE), - ), - $options['prefix'] . 'city' => array( + ], + $options['prefix'] . 'city' => [ 'title' => ts($options['prefix_label'] . 'City'), 'default' => CRM_Utils_Array::value('city', $options['defaults'], FALSE), 'name' => 'city', - ), - $options['prefix'] . 'postal_code' => array( + ], + $options['prefix'] . 'postal_code' => [ 'title' => ts($options['prefix_label'] . 'Postal Code'), 'default' => CRM_Utils_Array::value('postal_code', $options['defaults'], FALSE), 'name' => 'postal_code', - ), - $options['prefix'] . 'county_id' => array( + ], + $options['prefix'] . 'county_id' => [ 'title' => ts($options['prefix_label'] . 'County'), 'default' => CRM_Utils_Array::value('county_id', $options['defaults'], FALSE), 'alter_display' => 'alterCountyID', 'name' => 'county_id', - ), - $options['prefix'] . 'state_province_id' => array( + ], + $options['prefix'] . 'state_province_id' => [ 'title' => ts($options['prefix_label'] . 'State/Province'), 'default' => CRM_Utils_Array::value('state_province_id', $options['defaults'], FALSE), 'alter_display' => 'alterStateProvinceID', 'name' => 'state_province_id', - ), - $options['prefix'] . 'country_id' => array( + ], + $options['prefix'] . 'country_id' => [ 'title' => ts($options['prefix_label'] . 'Country'), 'default' => CRM_Utils_Array::value('country_id', $options['defaults'], FALSE), 'alter_display' => 'alterCountryID', 'name' => 'country_id', - ), - ), + ], + ], 'grouping' => 'location-fields', - ), - ); + ], + ]; if ($options['filters']) { - $addressFields[$options['prefix'] . 'civicrm_address']['filters'] = array( - $options['prefix'] . 'street_number' => array( + $addressFields[$options['prefix'] . 'civicrm_address']['filters'] = [ + $options['prefix'] . 'street_number' => [ 'title' => ts($options['prefix_label'] . 'Street Number'), 'type' => 1, 'name' => 'street_number', - ), - $options['prefix'] . 'street_name' => array( + ], + $options['prefix'] . 'street_name' => [ 'title' => ts($options['prefix_label'] . 'Street Name'), 'name' => $options['prefix'] . 'street_name', 'operator' => 'like', - ), - $options['prefix'] . 'postal_code' => array( + ], + $options['prefix'] . 'postal_code' => [ 'title' => ts($options['prefix_label'] . 'Postal Code'), 'type' => 1, 'name' => 'postal_code', - ), - $options['prefix'] . 'city' => array( + ], + $options['prefix'] . 'city' => [ 'title' => ts($options['prefix_label'] . 'City'), 'operator' => 'like', 'name' => 'city', - ), - $options['prefix'] . 'county_id' => array( + ], + $options['prefix'] . 'county_id' => [ 'name' => 'county_id', 'title' => ts($options['prefix_label'] . 'County'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::county(), - ), - $options['prefix'] . 'state_province_id' => array( + ], + $options['prefix'] . 'state_province_id' => [ 'name' => 'state_province_id', 'title' => ts($options['prefix_label'] . 'State/Province'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::stateProvince(), - ), - $options['prefix'] . 'country_id' => array( + ], + $options['prefix'] . 'country_id' => [ 'name' => 'country_id', 'title' => ts($options['prefix_label'] . 'Country'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::country(), - ), - ); + ], + ]; } if ($options['order_by']) { $addressFields[$options['prefix'] . - 'civicrm_address']['order_bys'] = array( - $options['prefix'] . 'street_name' => array( + 'civicrm_address']['order_bys'] = [ + $options['prefix'] . 'street_name' => [ 'title' => ts($options['prefix_label'] . 'Street Name'), 'name' => 'street_name', - ), - $options['prefix'] . 'street_number' => array( + ], + $options['prefix'] . 'street_number' => [ 'title' => ts($options['prefix_label'] . 'Odd / Even Street Number'), 'name' => 'street_number', - ), - $options['prefix'] . 'street_address' => array( + ], + $options['prefix'] . 'street_address' => [ 'title' => ts($options['prefix_label'] . 'Street Address'), 'name' => 'street_address', - ), - $options['prefix'] . 'city' => array( + ], + $options['prefix'] . 'city' => [ 'title' => ts($options['prefix_label'] . 'City'), 'name' => 'city', - ), - $options['prefix'] . 'postal_code' => array( + ], + $options['prefix'] . 'postal_code' => [ 'title' => ts($options['prefix_label'] . 'Post Code'), 'name' => 'postal_code', - ), - ); + ], + ]; } if ($options['group_by']) { - $addressFields['civicrm_address']['group_bys'] = array( - $options['prefix'] . 'street_address' => array( + $addressFields['civicrm_address']['group_bys'] = [ + $options['prefix'] . 'street_address' => [ 'title' => ts($options['prefix_label'] . 'Street Address'), 'name' => 'street_address', - ), - $options['prefix'] . 'city' => array( + ], + $options['prefix'] . 'city' => [ 'title' => ts($options['prefix_label'] . 'City'), 'name' => 'city', - ), - $options['prefix'] . 'postal_code' => array( + ], + $options['prefix'] . 'postal_code' => [ 'title' => ts($options['prefix_label'] . 'Post Code'), 'name' => 'postal_code', - ), - $options['prefix'] . 'state_province_id' => array( + ], + $options['prefix'] . 'state_province_id' => [ 'title' => ts($options['prefix_label'] . 'State/Province'), 'name' => 'state_province_id', - ), - $options['prefix'] . 'country_id' => array( + ], + $options['prefix'] . 'country_id' => [ 'title' => ts($options['prefix_label'] . 'Country'), 'name' => 'country_id', - ), - $options['prefix'] . 'county_id' => array( + ], + $options['prefix'] . 'county_id' => [ 'title' => ts($options['prefix_label'] . 'County'), 'name' => 'county_id', - ), - ); + ], + ]; } return $addressFields; } @@ -926,88 +926,88 @@ public function getAddressColumns($options = array()) { * @return array */ public function getAvailableJoins() { - return array( - 'priceFieldValue_from_lineItem' => array( + return [ + 'priceFieldValue_from_lineItem' => [ 'leftTable' => 'civicrm_line_item', 'rightTable' => 'civicrm_price_field_value', 'callback' => 'joinPriceFieldValueFromLineItem', - ), - 'priceField_from_lineItem' => array( + ], + 'priceField_from_lineItem' => [ 'leftTable' => 'civicrm_line_item', 'rightTable' => 'civicrm_price_field', 'callback' => 'joinPriceFieldFromLineItem', - ), - 'participant_from_lineItem' => array( + ], + 'participant_from_lineItem' => [ 'leftTable' => 'civicrm_line_item', 'rightTable' => 'civicrm_participant', 'callback' => 'joinParticipantFromLineItem', - ), - 'contribution_from_lineItem' => array( + ], + 'contribution_from_lineItem' => [ 'leftTable' => 'civicrm_line_item', 'rightTable' => 'civicrm_contribution', 'callback' => 'joinContributionFromLineItem', - ), - 'membership_from_lineItem' => array( + ], + 'membership_from_lineItem' => [ 'leftTable' => 'civicrm_line_item', 'rightTable' => 'civicrm_membership', 'callback' => 'joinMembershipFromLineItem', - ), - 'contribution_from_participant' => array( + ], + 'contribution_from_participant' => [ 'leftTable' => 'civicrm_participant', 'rightTable' => 'civicrm_contribution', 'callback' => 'joinContributionFromParticipant', - ), - 'contribution_from_membership' => array( + ], + 'contribution_from_membership' => [ 'leftTable' => 'civicrm_membership', 'rightTable' => 'civicrm_contribution', 'callback' => 'joinContributionFromMembership', - ), - 'membership_from_contribution' => array( + ], + 'membership_from_contribution' => [ 'leftTable' => 'civicrm_contribution', 'rightTable' => 'civicrm_membership', 'callback' => 'joinMembershipFromContribution', - ), - 'membershipType_from_membership' => array( + ], + 'membershipType_from_membership' => [ 'leftTable' => 'civicrm_membership', 'rightTable' => 'civicrm_membership_type', 'callback' => 'joinMembershipTypeFromMembership', - ), - 'lineItem_from_contribution' => array( + ], + 'lineItem_from_contribution' => [ 'leftTable' => 'civicrm_contribution', 'rightTable' => 'civicrm_line_item', 'callback' => 'joinLineItemFromContribution', - ), - 'lineItem_from_membership' => array( + ], + 'lineItem_from_membership' => [ 'leftTable' => 'civicrm_membership', 'rightTable' => 'civicrm_line_item', 'callback' => 'joinLineItemFromMembership', - ), - 'contact_from_participant' => array( + ], + 'contact_from_participant' => [ 'leftTable' => 'civicrm_participant', 'rightTable' => 'civicrm_contact', 'callback' => 'joinContactFromParticipant', - ), - 'contact_from_membership' => array( + ], + 'contact_from_membership' => [ 'leftTable' => 'civicrm_membership', 'rightTable' => 'civicrm_contact', 'callback' => 'joinContactFromMembership', - ), - 'contact_from_contribution' => array( + ], + 'contact_from_contribution' => [ 'leftTable' => 'civicrm_contribution', 'rightTable' => 'civicrm_contact', 'callback' => 'joinContactFromContribution', - ), - 'event_from_participant' => array( + ], + 'event_from_participant' => [ 'leftTable' => 'civicrm_participant', 'rightTable' => 'civicrm_event', 'callback' => 'joinEventFromParticipant', - ), - 'address_from_contact' => array( + ], + 'address_from_contact' => [ 'leftTable' => 'civicrm_contact', 'rightTable' => 'civicrm_address', 'callback' => 'joinAddressFromContact', - ), - ); + ], + ]; } /** @@ -1319,7 +1319,7 @@ public function alterCountryID($value, &$row, $selectedfield, $criteriaFieldName $url = CRM_Utils_System::url(CRM_Utils_System::currentPath(), "reset=1&force=1&{$criteriaFieldName}_op=in&{$criteriaFieldName}_value={$value}", $this->_absoluteUrl); $row[$selectedfield . '_link'] = $url; $row[$selectedfield . - '_hover'] = ts("%1 for this country.", array(1 => $value)); + '_hover'] = ts("%1 for this country.", [1 => $value]); $countries = CRM_Core_PseudoConstant::country($value, FALSE); if (!is_array($countries)) { return $countries; @@ -1338,7 +1338,7 @@ public function alterCountyID($value, &$row, $selectedfield, $criteriaFieldName) $url = CRM_Utils_System::url(CRM_Utils_System::currentPath(), "reset=1&force=1&{$criteriaFieldName}_op=in&{$criteriaFieldName}_value={$value}", $this->_absoluteUrl); $row[$selectedfield . '_link'] = $url; $row[$selectedfield . - '_hover'] = ts("%1 for this county.", array(1 => $value)); + '_hover'] = ts("%1 for this county.", [1 => $value]); $counties = CRM_Core_PseudoConstant::county($value, FALSE); if (!is_array($counties)) { return $counties; @@ -1357,7 +1357,7 @@ public function alterStateProvinceID($value, &$row, $selectedfield, $criteriaFie $url = CRM_Utils_System::url(CRM_Utils_System::currentPath(), "reset=1&force=1&{$criteriaFieldName}_op=in&{$criteriaFieldName}_value={$value}", $this->_absoluteUrl); $row[$selectedfield . '_link'] = $url; $row[$selectedfield . - '_hover'] = ts("%1 for this state.", array(1 => $value)); + '_hover'] = ts("%1 for this state.", [1 => $value]); $states = CRM_Core_PseudoConstant::stateProvince($value, FALSE); if (!is_array($states)) { @@ -1400,7 +1400,7 @@ public function alterParticipantRole($value) { return NULL; } $roles = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value); - $value = array(); + $value = []; foreach ($roles as $role) { $value[$role] = CRM_Event_PseudoConstant::participantRole($role, FALSE); } diff --git a/CRM/Report/Form/Grant/Detail.php b/CRM/Report/Form/Grant/Detail.php index 458bf557661b..a70b673e649d 100644 --- a/CRM/Report/Form/Grant/Detail.php +++ b/CRM/Report/Form/Grant/Detail.php @@ -32,180 +32,180 @@ */ class CRM_Report_Form_Grant_Detail extends CRM_Report_Form { - protected $_customGroupExtends = array( + protected $_customGroupExtends = [ 'Contact', 'Individual', 'Household', 'Organization', 'Grant', - ); + ]; /** * Class constructor. */ public function __construct() { - $contactCols = $this->getColumns('Contact', array( - 'order_bys_defaults' => array('sort_name' => 'ASC '), + $contactCols = $this->getColumns('Contact', [ + 'order_bys_defaults' => ['sort_name' => 'ASC '], 'fields_defaults' => ['sort_name'], 'fields_excluded' => ['id'], 'fields_required' => ['id'], - 'filters_defaults' => array('is_deleted' => 0), + 'filters_defaults' => ['is_deleted' => 0], 'no_field_disambiguation' => TRUE, - )); - $specificCols = array( - 'civicrm_email' => array( + ]); + $specificCols = [ + 'civicrm_email' => [ 'dao' => 'CRM_Core_DAO_Email', - 'fields' => array( - 'email' => array( + 'fields' => [ + 'email' => [ 'title' => ts('Email'), - ), - ), + ], + ], 'grouping' => 'contact-fields', - ), - 'civicrm_phone' => array( + ], + 'civicrm_phone' => [ 'dao' => 'CRM_Core_DAO_Phone', - 'fields' => array( - 'phone' => array( + 'fields' => [ + 'phone' => [ 'title' => ts('Phone'), - ), - ), + ], + ], 'grouping' => 'contact-fields', - ), - 'civicrm_grant' => array( + ], + 'civicrm_grant' => [ 'dao' => 'CRM_Grant_DAO_Grant', - 'fields' => array( - 'grant_type_id' => array( + 'fields' => [ + 'grant_type_id' => [ 'name' => 'grant_type_id', 'title' => ts('Grant Type'), - ), - 'status_id' => array( + ], + 'status_id' => [ 'name' => 'status_id', 'title' => ts('Grant Status'), - ), - 'amount_total' => array( + ], + 'amount_total' => [ 'name' => 'amount_total', 'title' => ts('Amount Requested'), 'type' => CRM_Utils_Type::T_MONEY, - ), - 'amount_granted' => array( + ], + 'amount_granted' => [ 'name' => 'amount_granted', 'title' => ts('Amount Granted'), - ), - 'application_received_date' => array( + ], + 'application_received_date' => [ 'name' => 'application_received_date', 'title' => ts('Application Received'), 'default' => TRUE, 'type' => CRM_Utils_Type::T_DATE, - ), - 'money_transfer_date' => array( + ], + 'money_transfer_date' => [ 'name' => 'money_transfer_date', 'title' => ts('Money Transfer Date'), 'type' => CRM_Utils_Type::T_DATE, - ), - 'grant_due_date' => array( + ], + 'grant_due_date' => [ 'name' => 'grant_due_date', 'title' => ts('Grant Report Due'), 'type' => CRM_Utils_Type::T_DATE, - ), - 'decision_date' => array( + ], + 'decision_date' => [ 'name' => 'decision_date', 'title' => ts('Grant Decision Date'), 'type' => CRM_Utils_Type::T_DATE, - ), - 'rationale' => array( + ], + 'rationale' => [ 'name' => 'rationale', 'title' => ts('Rationale'), - ), - 'grant_report_received' => array( + ], + 'grant_report_received' => [ 'name' => 'grant_report_received', 'title' => ts('Grant Report Received'), - ), - ), - 'filters' => array( - 'grant_type' => array( + ], + ], + 'filters' => [ + 'grant_type' => [ 'name' => 'grant_type_id', 'title' => ts('Grant Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'grant_type_id'), - ), - 'status_id' => array( + ], + 'status_id' => [ 'name' => 'status_id', 'title' => ts('Grant Status'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'status_id'), - ), - 'amount_granted' => array( + ], + 'amount_granted' => [ 'title' => ts('Amount Granted'), 'operatorType' => CRM_Report_Form::OP_INT, - ), - 'amount_total' => array( + ], + 'amount_total' => [ 'title' => ts('Amount Requested'), 'operatorType' => CRM_Report_Form::OP_INT, - ), - 'application_received_date' => array( + ], + 'application_received_date' => [ 'title' => ts('Application Received'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE, - ), - 'money_transfer_date' => array( + ], + 'money_transfer_date' => [ 'title' => ts('Money Transfer Date'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE, - ), - 'grant_due_date' => array( + ], + 'grant_due_date' => [ 'title' => ts('Grant Report Due'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE, - ), - 'decision_date' => array( + ], + 'decision_date' => [ 'title' => ts('Grant Decision Date'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE, - ), - ), - 'group_bys' => array( - 'grant_type_id' => array( + ], + ], + 'group_bys' => [ + 'grant_type_id' => [ 'title' => ts('Grant Type'), - ), - 'status_id' => array( + ], + 'status_id' => [ 'title' => ts('Grant Status'), - ), - 'application_received_date' => array( + ], + 'application_received_date' => [ 'title' => ts('Application Received Date'), - ), - 'money_transfer_date' => array( + ], + 'money_transfer_date' => [ 'title' => ts('Money Transfer Date'), - ), - 'decision_date' => array( + ], + 'decision_date' => [ 'title' => ts('Grant Decision Date'), - ), - ), - 'order_bys' => array( - 'grant_type_id' => array( + ], + ], + 'order_bys' => [ + 'grant_type_id' => [ 'title' => ts('Grant Type'), - ), - 'status_id' => array( + ], + 'status_id' => [ 'title' => ts('Grant Status'), - ), - 'amount_total' => array( + ], + 'amount_total' => [ 'title' => ts('Amount Requested'), - ), - 'amount_granted' => array( + ], + 'amount_granted' => [ 'title' => ts('Amount Granted'), - ), - 'application_received_date' => array( + ], + 'application_received_date' => [ 'title' => ts('Application Received Date'), - ), - 'money_transfer_date' => array( + ], + 'money_transfer_date' => [ 'title' => ts('Money Transfer Date'), - ), - 'decision_date' => array( + ], + 'decision_date' => [ 'title' => ts('Grant Decision Date'), - ), - ), - ), - ); + ], + ], + ], + ]; $this->_columns = array_merge($contactCols, $specificCols, $this->addAddressFields(FALSE)); diff --git a/CRM/Report/Form/Grant/Statistics.php b/CRM/Report/Form/Grant/Statistics.php index d579ebc4ec51..f4e76f98fd8b 100644 --- a/CRM/Report/Form/Grant/Statistics.php +++ b/CRM/Report/Form/Grant/Statistics.php @@ -32,7 +32,7 @@ */ class CRM_Report_Form_Grant_Statistics extends CRM_Report_Form { - protected $_customGroupExtends = array('Grant'); + protected $_customGroupExtends = ['Grant']; protected $_add2groupSupported = FALSE; @@ -40,173 +40,173 @@ class CRM_Report_Form_Grant_Statistics extends CRM_Report_Form { * Class constructor. */ public function __construct() { - $this->_columns = array( - 'civicrm_grant' => array( + $this->_columns = [ + 'civicrm_grant' => [ 'dao' => 'CRM_Grant_DAO_Grant', - 'fields' => array( - 'summary_statistics' => array( + 'fields' => [ + 'summary_statistics' => [ 'name' => 'id', 'title' => ts('Summary Statistics'), 'required' => TRUE, - ), - 'grant_type_id' => array( + ], + 'grant_type_id' => [ 'name' => 'grant_type_id', 'title' => ts('By Grant Type'), - ), - 'status_id' => array( + ], + 'status_id' => [ 'no_display' => TRUE, 'required' => TRUE, - ), - 'amount_total' => array( + ], + 'amount_total' => [ 'no_display' => TRUE, 'required' => TRUE, - ), - 'grant_report_received' => array( + ], + 'grant_report_received' => [ 'no_display' => TRUE, 'required' => TRUE, - ), - 'currency' => array( + ], + 'currency' => [ 'no_display' => TRUE, 'required' => TRUE, - ), - ), - 'filters' => array( - 'application_received_date' => array( + ], + ], + 'filters' => [ + 'application_received_date' => [ 'name' => 'application_received_date', 'title' => ts('Application Received'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE, - ), - 'decision_date' => array( + ], + 'decision_date' => [ 'name' => 'decision_date', 'title' => ts('Grant Decision'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE, - ), - 'money_transfer_date' => array( + ], + 'money_transfer_date' => [ 'name' => 'money_transfer_date', 'title' => ts('Money Transferred'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE, - ), - 'grant_due_date' => array( + ], + 'grant_due_date' => [ 'name' => 'grant_due_date', 'title' => ts('Grant Report Due'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE, - ), - 'grant_type' => array( + ], + 'grant_type' => [ 'name' => 'grant_type_id', 'title' => ts('Grant Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'grant_type_id'), - ), - 'status_id' => array( + ], + 'status_id' => [ 'name' => 'status_id', 'title' => ts('Grant Status'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'status_id'), - ), - 'amount_requested' => array( + ], + 'amount_requested' => [ 'name' => 'amount_requested', 'title' => ts('Amount Requested'), 'type' => CRM_Utils_Type::T_MONEY, - ), - 'amount_granted' => array( + ], + 'amount_granted' => [ 'name' => 'amount_granted', 'title' => ts('Amount Granted'), - ), - 'grant_report_received' => array( + ], + 'grant_report_received' => [ 'name' => 'grant_report_received', 'title' => ts('Report Received'), 'operatorType' => CRM_Report_Form::OP_SELECT, - 'options' => array( + 'options' => [ '' => ts('- select -'), 0 => ts('No'), 1 => ts('Yes'), - ), - ), - ), - ), - 'civicrm_contact' => array( + ], + ], + ], + ], + 'civicrm_contact' => [ 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => array( - 'id' => array( + 'fields' => [ + 'id' => [ 'required' => TRUE, 'no_display' => TRUE, - ), - 'gender_id' => array( + ], + 'gender_id' => [ 'name' => 'gender_id', 'title' => ts('By Gender'), - ), - 'contact_type' => array( + ], + 'contact_type' => [ 'name' => 'contact_type', 'title' => ts('By Contact Type'), - ), - ), - 'filters' => array( - 'gender_id' => array( + ], + ], + 'filters' => [ + 'gender_id' => [ 'name' => 'gender_id', 'title' => ts('Gender'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id'), - ), - 'contact_type' => array( + ], + 'contact_type' => [ 'name' => 'contact_type', 'title' => ts('Contact Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contact_BAO_ContactType::basicTypePairs(), - ), - ), + ], + ], 'grouping' => 'contact-fields', - ), - 'civicrm_worldregion' => array( + ], + 'civicrm_worldregion' => [ 'dao' => 'CRM_Core_DAO_Worldregion', - 'fields' => array( - 'id' => array( + 'fields' => [ + 'id' => [ 'no_display' => TRUE, - ), - 'name' => array( + ], + 'name' => [ 'name' => 'name', 'title' => ts('By World Region'), - ), - ), - 'filters' => array( - 'region_id' => array( + ], + ], + 'filters' => [ + 'region_id' => [ 'name' => 'id', 'title' => ts('World Region'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::worldRegion(), - ), - ), - ), - 'civicrm_address' => array( + ], + ], + ], + 'civicrm_address' => [ 'dao' => 'CRM_Core_DAO_Address', - 'fields' => array( - 'country_id' => array( + 'fields' => [ + 'country_id' => [ 'name' => 'country_id', 'title' => ts('By Country'), - ), - ), - 'filters' => array( - 'country_id' => array( + ], + ], + 'filters' => [ + 'country_id' => [ 'title' => ts('Country'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::country(), - ), - ), - ), - ); + ], + ], + ], + ]; parent::__construct(); } public function select() { - $select = array(); + $select = []; - $this->_columnHeaders = array(); + $this->_columnHeaders = []; foreach ($this->_columns as $tableName => $table) { if (array_key_exists('fields', $table)) { foreach ($table['fields'] as $fieldName => $field) { @@ -346,10 +346,10 @@ public function postProcess() { * Rows generated by SQL, with an array for each row. */ public function alterDisplay(&$rows) { - $totalStatistics = $grantStatistics = array(); + $totalStatistics = $grantStatistics = []; $totalStatistics = parent::statistics($rows); $awardedGrantsAmount = $grantsReceived = $totalAmount = $awardedGrants = $grantReportsReceived = 0; - $grantStatistics = array(); + $grantStatistics = []; $grantTypes = CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'grant_type_id'); $countries = CRM_Core_PseudoConstant::country(); @@ -443,7 +443,7 @@ public function alterDisplay(&$rows) { $customFieldTitle = CRM_Utils_Array::value('title', $this->_columnHeaders[$customField]); $customGroupTitle = explode('_custom', strstr($customField, 'civicrm_value_')); $customGroupTitle = $this->_columns[$customGroupTitle[0]]['group_title']; - $grantStatistics[$customGroupTitle]['title'] = ts('By %1', array(1 => $customGroupTitle)); + $grantStatistics[$customGroupTitle]['title'] = ts('By %1', [1 => $customGroupTitle]); $customData = ($customValue) ? FALSE : TRUE; self::getStatistics($grantStatistics[$customGroupTitle], $customFieldTitle, $values, @@ -453,22 +453,22 @@ public function alterDisplay(&$rows) { } } - $totalStatistics['total_statistics'] = array( - 'grants_received' => array( + $totalStatistics['total_statistics'] = [ + 'grants_received' => [ 'title' => ts('Grant Requests Received'), 'count' => $grantsReceived, 'amount' => $totalAmount, - ), - 'grants_awarded' => array( + ], + 'grants_awarded' => [ 'title' => ts('Grants Awarded'), 'count' => $awardedGrants, 'amount' => $amountGranted, - ), - 'grants_report_received' => array( + ], + 'grants_report_received' => [ 'title' => ts('Grant Reports Received'), 'count' => $grantReportsReceived, - ), - ); + ], + ]; $this->assign('totalStatistics', $totalStatistics); $this->assign('grantStatistics', $grantStatistics); @@ -476,27 +476,27 @@ public function alterDisplay(&$rows) { if ($this->_outputMode == 'csv' || $this->_outputMode == 'pdf' ) { - $row = array(); - $this->_columnHeaders = array( - 'civicrm_grant_total_grants' => array('title' => ts('Summary')), - 'civicrm_grant_count' => array('title' => ts('Count')), - 'civicrm_grant_amount' => array('title' => ts('Amount')), - ); + $row = []; + $this->_columnHeaders = [ + 'civicrm_grant_total_grants' => ['title' => ts('Summary')], + 'civicrm_grant_count' => ['title' => ts('Count')], + 'civicrm_grant_amount' => ['title' => ts('Amount')], + ]; foreach ($totalStatistics['total_statistics'] as $title => $value) { - $row[] = array( + $row[] = [ 'civicrm_grant_total_grants' => $value['title'], 'civicrm_grant_count' => $value['count'], 'civicrm_grant_amount' => $value['amount'], - ); + ]; } if (!empty($grantStatistics)) { foreach ($grantStatistics as $key => $value) { - $row[] = array( + $row[] = [ 'civicrm_grant_total_grants' => $value['title'], 'civicrm_grant_count' => ts('Number of Grants') . ' (%)', 'civicrm_grant_amount' => ts('Total Amount') . ' (%)', - ); + ]; foreach ($value['value'] as $field => $values) { foreach ($values['currency'] as $currency => $amount) { @@ -505,11 +505,11 @@ public function alterDisplay(&$rows) { } $totalAmt = implode(', ', $totalAmount); $count = (boolean) CRM_Utils_Array::value('count', $values, 0) ? $values['count'] . " ({$values['percentage']}%)" : ''; - $row[] = array( + $row[] = [ 'civicrm_grant_total_grants' => $field, 'civicrm_grant_count' => $count, 'civicrm_grant_amount' => $totalAmt, - ); + ]; } } } @@ -533,7 +533,7 @@ public static function getStatistics( return; } - $currencies = CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'currency', array('labelColumn' => 'symbol')); + $currencies = CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'currency', ['labelColumn' => 'symbol']); $currency = $currencies[$values['civicrm_grant_currency']]; if (!$customData) { diff --git a/CRM/Report/Form/Instance.php b/CRM/Report/Form/Instance.php index 7fa815d85841..ec2d76e2dc22 100644 --- a/CRM/Report/Form/Instance.php +++ b/CRM/Report/Form/Instance.php @@ -85,7 +85,7 @@ public static function buildForm(&$form) { $form->add('number', 'row_count', ts('Limit Dashboard Results'), - array('class' => 'four', 'min' => 1) + ['class' => 'four', 'min' => 1] ); $form->add('textarea', @@ -101,16 +101,16 @@ public static function buildForm(&$form) { ); $form->addElement('checkbox', 'is_navigation', ts('Include Report in Navigation Menu?'), NULL, - array('onclick' => "return showHideByValue('is_navigation','','navigation_menu','table-row','radio',false);") + ['onclick' => "return showHideByValue('is_navigation','','navigation_menu','table-row','radio',false);"] ); - $form->addElement('select', 'view_mode', ts('Configure link to...'), array( + $form->addElement('select', 'view_mode', ts('Configure link to...'), [ 'view' => ts('View Results'), 'criteria' => ts('Show Criteria'), - )); + ]); $form->addElement('checkbox', 'addToDashboard', ts('Available for Dashboard?')); - $form->add('number', 'cache_minutes', ts('Cache dashlet for'), array('class' => 'four', 'min' => 1)); + $form->add('number', 'cache_minutes', ts('Cache dashlet for'), ['class' => 'four', 'min' => 1]); $form->addElement('checkbox', 'add_to_my_reports', ts('Add to My Reports?'), NULL); $form->addElement('checkbox', 'is_reserved', ts('Reserved Report?')); @@ -125,7 +125,7 @@ public static function buildForm(&$form) { $form->addElement('select', 'permission', ts('Permission'), - array('0' => ts('Everyone (includes anonymous)')) + CRM_Core_Permission::basicPermissions() + ['0' => ts('Everyone (includes anonymous)')] + CRM_Core_Permission::basicPermissions() ); // prepare user_roles to save as names not as ids @@ -138,45 +138,45 @@ public static function buildForm(&$form) { 'grouprole', ts('ACL Group/Role'), $user_roles, - array( + [ 'size' => 5, 'style' => 'width:240px', 'class' => 'advmultiselect', - ) + ] ); - $grouprole->setButtonAttributes('add', array('value' => ts('Add >>'))); - $grouprole->setButtonAttributes('remove', array('value' => ts('<< Remove'))); + $grouprole->setButtonAttributes('add', ['value' => ts('Add >>')]); + $grouprole->setButtonAttributes('remove', ['value' => ts('<< Remove')]); } } // navigation field $parentMenu = CRM_Core_BAO_Navigation::getNavigationList(); - $form->add('select', 'parent_id', ts('Parent Menu'), array('' => ts('- select -')) + $parentMenu); + $form->add('select', 'parent_id', ts('Parent Menu'), ['' => ts('- select -')] + $parentMenu); // For now we only providing drilldown for one primary detail report only. In future this could be multiple reports foreach ($form->_drilldownReport as $reportUrl => $drillLabel) { $instanceList = CRM_Report_Utils_Report::getInstanceList($reportUrl); if (count($instanceList) > 1) { - $form->add('select', 'drilldown_id', $drillLabel, array('' => ts('- select -')) + $instanceList); + $form->add('select', 'drilldown_id', $drillLabel, ['' => ts('- select -')] + $instanceList); } break; } - $form->addButtons(array( - array( + $form->addButtons([ + [ 'type' => 'submit', 'name' => ts('Save Report'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); - $form->addFormRule(array('CRM_Report_Form_Instance', 'formRule'), $form); + $form->addFormRule(['CRM_Report_Form_Instance', 'formRule'], $form); } /** @@ -194,7 +194,7 @@ public static function formRule($fields, $errors, $self) { $saveButton = str_replace('_next', '_save', $nextButton); $clickedButton = $self->getVar('_instanceButtonName'); - $errors = array(); + $errors = []; if ($clickedButton == $nextButton || $clickedButton == $saveButton) { if (empty($fields['title'])) { $errors['title'] = ts('Title is a required field.'); @@ -218,7 +218,7 @@ public static function setDefaultValues(&$form, &$defaults) { } $instanceID = $form->getVar('_id'); - $navigationDefaults = array(); + $navigationDefaults = []; if (!isset($defaults['permission'])) { $defaults['permission'] = 'access CiviReport'; @@ -281,7 +281,7 @@ public static function setDefaultValues(&$form, &$defaults) { if (!empty($defaults['navigation_id'])) { // Get the default navigation parent id. - $params = array('id' => $defaults['navigation_id']); + $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); @@ -346,7 +346,7 @@ public static function postProcess(&$form, $redirect = TRUE) { $formValues = $params; // unset params from $formValues that doesn't match with DB columns of instance tables, and also not required in form-values for sure - $unsetFields = array( + $unsetFields = [ 'title', 'to_emails', 'cc_emails', @@ -359,7 +359,7 @@ public static function postProcess(&$form, $redirect = TRUE) { 'report_footer', 'grouprole', 'task', - ); + ]; foreach ($unsetFields as $field) { unset($formValues[$field]); } @@ -383,18 +383,18 @@ public static function postProcess(&$form, $redirect = TRUE) { if ($instanceID && !$isNew) { // updating existing instance - $statusMsg = ts('"%1" report has been updated.', array(1 => $instance->title)); + $statusMsg = ts('"%1" report has been updated.', [1 => $instance->title]); } elseif ($form->getVar('_id') && $isNew) { - $statusMsg = ts('Your report has been successfully copied as "%1". You are currently viewing the new copy.', array(1 => $instance->title)); + $statusMsg = ts('Your report has been successfully copied as "%1". You are currently viewing the new copy.', [1 => $instance->title]); } else { - $statusMsg = ts('"%1" report has been successfully created. You are currently viewing the new report instance.', array(1 => $instance->title)); + $statusMsg = ts('"%1" report has been successfully created. You are currently viewing the new report instance.', [1 => $instance->title]); } CRM_Core_Session::setStatus($statusMsg); if ($redirect) { - $urlParams = array('reset' => 1); + $urlParams = ['reset' => 1]; if ($view_mode == 'view') { $urlParams['force'] = 1; } diff --git a/CRM/Report/Form/Mailing/Bounce.php b/CRM/Report/Form/Mailing/Bounce.php index 37ab9284ee80..9cb491a484ae 100644 --- a/CRM/Report/Form/Mailing/Bounce.php +++ b/CRM/Report/Form/Mailing/Bounce.php @@ -38,18 +38,18 @@ class CRM_Report_Form_Mailing_Bounce extends CRM_Report_Form { protected $_phoneField = FALSE; - protected $_customGroupExtends = array( + protected $_customGroupExtends = [ 'Contact', 'Individual', 'Household', 'Organization', - ); + ]; - protected $_charts = array( + protected $_charts = [ '' => 'Tabular', 'barChart' => 'Bar Chart', 'pieChart' => 'Pie Chart', - ); + ]; /** * This report has not been optimised for group filtering. @@ -68,196 +68,196 @@ class CRM_Report_Form_Mailing_Bounce extends CRM_Report_Form { * Class constructor. */ public function __construct() { - $this->_columns = array(); + $this->_columns = []; - $this->_columns['civicrm_contact'] = array( + $this->_columns['civicrm_contact'] = [ 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => array( - 'id' => array( + 'fields' => [ + 'id' => [ 'title' => ts('Contact ID'), 'required' => TRUE, - ), - 'sort_name' => array( + ], + 'sort_name' => [ 'title' => ts('Contact Name'), 'required' => TRUE, - ), - ), - 'filters' => array( - 'sort_name' => array( + ], + ], + 'filters' => [ + 'sort_name' => [ 'title' => ts('Contact Name'), - ), - 'source' => array( + ], + 'source' => [ 'title' => ts('Contact Source'), 'type' => CRM_Utils_Type::T_STRING, - ), - 'id' => array( + ], + 'id' => [ 'title' => ts('Contact ID'), 'no_display' => TRUE, - ), - ), - 'order_bys' => array( - 'sort_name' => array( + ], + ], + 'order_bys' => [ + 'sort_name' => [ 'title' => ts('Contact Name'), 'default' => TRUE, 'default_order' => 'ASC', - ), - ), + ], + ], 'grouping' => 'contact-fields', - ); + ]; - $this->_columns['civicrm_mailing'] = array( + $this->_columns['civicrm_mailing'] = [ 'dao' => 'CRM_Mailing_DAO_Mailing', - 'fields' => array( - 'mailing_name' => array( + 'fields' => [ + 'mailing_name' => [ 'name' => 'name', 'title' => ts('Mailing Name'), 'default' => TRUE, - ), - 'mailing_name_alias' => array( + ], + 'mailing_name_alias' => [ 'name' => 'name', 'required' => TRUE, 'no_display' => TRUE, - ), - 'mailing_subject' => array( + ], + 'mailing_subject' => [ 'name' => 'subject', 'title' => ts('Mailing Subject'), 'default' => TRUE, - ), - ), - 'filters' => array( - 'mailing_id' => array( + ], + ], + 'filters' => [ + 'mailing_id' => [ 'name' => 'id', 'title' => ts('Mailing Name'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'type' => CRM_Utils_Type::T_INT, 'options' => CRM_Mailing_BAO_Mailing::getMailingsList(), 'operator' => 'like', - ), - 'mailing_subject' => array( + ], + 'mailing_subject' => [ 'name' => 'subject', 'title' => ts('Mailing Subject'), 'type' => CRM_Utils_Type::T_STRING, 'operator' => 'like', - ), - ), - 'order_bys' => array( - 'mailing_name' => array( + ], + ], + 'order_bys' => [ + 'mailing_name' => [ 'name' => 'name', 'title' => ts('Mailing Name'), - ), - 'mailing_subject' => array( + ], + 'mailing_subject' => [ 'name' => 'subject', 'title' => ts('Mailing Subject'), - ), - ), + ], + ], 'grouping' => 'mailing-fields', - ); + ]; - $this->_columns['civicrm_mailing_event_bounce'] = array( + $this->_columns['civicrm_mailing_event_bounce'] = [ 'dao' => 'CRM_Mailing_DAO_Mailing', - 'fields' => array( - 'bounce_reason' => array( + 'fields' => [ + 'bounce_reason' => [ 'title' => ts('Bounce Reason'), - ), - 'time_stamp' => array( + ], + 'time_stamp' => [ 'title' => ts('Bounce Date'), - ), - ), - 'filters' => array( - 'bounce_reason' => array( + ], + ], + 'filters' => [ + 'bounce_reason' => [ 'title' => ts('Bounce Reason'), 'type' => CRM_Utils_Type::T_STRING, - ), - 'time_stamp' => array( + ], + 'time_stamp' => [ 'title' => ts('Bounce Date'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME, - ), - ), - 'order_bys' => array( - 'bounce_reason' => array( + ], + ], + 'order_bys' => [ + 'bounce_reason' => [ 'title' => ts('Bounce Reason'), - ), - 'time_stamp' => array( + ], + 'time_stamp' => [ 'title' => ts('Bounce Date'), - ), - ), + ], + ], 'grouping' => 'mailing-fields', - ); + ]; - $this->_columns['civicrm_mailing_bounce_type'] = array( + $this->_columns['civicrm_mailing_bounce_type'] = [ 'dao' => 'CRM_Mailing_DAO_BounceType', - 'fields' => array( - 'bounce_name' => array( + 'fields' => [ + 'bounce_name' => [ 'name' => 'name', 'title' => ts('Bounce Type'), - ), - ), - 'filters' => array( - 'bounce_type_name' => array( + ], + ], + 'filters' => [ + 'bounce_type_name' => [ 'name' => 'name', 'title' => ts('Bounce Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'type' => CRM_Utils_Type::T_STRING, 'options' => self::bounce_type(), 'operator' => 'like', - ), - ), - 'order_bys' => array( - 'bounce_name' => array( + ], + ], + 'order_bys' => [ + 'bounce_name' => [ 'name' => 'name', 'title' => ts('Bounce Type'), - ), - ), + ], + ], 'grouping' => 'mailing-fields', - ); + ]; - $this->_columns['civicrm_email'] = array( + $this->_columns['civicrm_email'] = [ 'dao' => 'CRM_Core_DAO_Email', - 'fields' => array( - 'email' => array( + 'fields' => [ + 'email' => [ 'title' => ts('Email'), 'no_repeat' => TRUE, - ), - 'on_hold' => array( + ], + 'on_hold' => [ 'title' => ts('On hold'), - ), - 'hold_date' => array( + ], + 'hold_date' => [ 'title' => ts('Hold date'), - ), - 'reset_date' => array( + ], + 'reset_date' => [ 'title' => ts('Hold reset date'), - ), - ), - 'filters' => array( - 'email' => array( + ], + ], + 'filters' => [ + 'email' => [ 'title' => ts('Email'), - ), - 'on_hold' => array( + ], + 'on_hold' => [ 'title' => ts('On hold'), - ), - 'hold_date' => array( + ], + 'hold_date' => [ 'title' => ts('Hold date'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE, - ), - 'reset_date' => array( + ], + 'reset_date' => [ 'title' => ts('Hold reset date'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE, - ), - ), - 'order_bys' => array( - 'email' => array('title' => ts('Email'), 'default_order' => 'ASC'), - ), + ], + ], + 'order_bys' => [ + 'email' => ['title' => ts('Email'), 'default_order' => 'ASC'], + ], 'grouping' => 'contact-fields', - ); + ]; - $this->_columns['civicrm_phone'] = array( + $this->_columns['civicrm_phone'] = [ 'dao' => 'CRM_Core_DAO_Phone', - 'fields' => array('phone' => NULL), + 'fields' => ['phone' => NULL], 'grouping' => 'contact-fields', - ); + ]; $this->_groupFilter = TRUE; $this->_tagFilter = TRUE; @@ -270,8 +270,8 @@ public function preProcess() { } public function select() { - $select = array(); - $this->_columnHeaders = array(); + $select = []; + $this->_columnHeaders = []; foreach ($this->_columns as $tableName => $table) { if (array_key_exists('fields', $table)) { @@ -312,7 +312,7 @@ public function select() { * @return array */ public static function formRule($fields, $files, $self) { - $errors = $grouping = array(); + $errors = $grouping = []; return $errors; } @@ -342,7 +342,7 @@ public function from() { public function where() { - $clauses = array(); + $clauses = []; // Exclude SMS mailing type $clauses[] = "{$this->_aliases['civicrm_mailing']}.sms_provider_id IS NULL"; @@ -401,7 +401,7 @@ public function postProcess() { $sql = $this->buildQuery(TRUE); - $rows = $graphRows = array(); + $rows = $graphRows = []; $this->buildRows($sql, $rows); $this->formatDisplay($rows); @@ -417,13 +417,13 @@ public function buildChart(&$rows) { return; } - $chartInfo = array( + $chartInfo = [ 'legend' => ts('Mail Bounce Report'), 'xname' => ts('Mailing'), 'yname' => ts('Bounce'), 'xLabelAngle' => 20, - 'tip' => ts('Mail Bounce: %1', array(1 => '#val#')), - ); + 'tip' => ts('Mail Bounce: %1', [1 => '#val#']), + ]; foreach ($rows as $row) { $chartInfo['values'][$row['civicrm_mailing_mailing_name_alias']] = $row['civicrm_mailing_bounce_count']; } @@ -438,7 +438,7 @@ public function buildChart(&$rows) { */ public function bounce_type() { - $data = array(); + $data = []; $bounce_type = new CRM_Mailing_DAO_BounceType(); $query = "SELECT name FROM civicrm_mailing_bounce_type"; @@ -496,11 +496,11 @@ public function alterDisplay(&$rows) { } // Convert datetime values to custom date and time format - $dateFields = array( + $dateFields = [ 'civicrm_mailing_event_bounce_time_stamp', 'civicrm_email_hold_date', 'civicrm_email_reset_date', - ); + ]; foreach ($dateFields as $dateField) { if (array_key_exists($dateField, $row)) { diff --git a/CRM/Report/Form/Mailing/Clicks.php b/CRM/Report/Form/Mailing/Clicks.php index 054463b1fe44..b2239e02b2e5 100644 --- a/CRM/Report/Form/Mailing/Clicks.php +++ b/CRM/Report/Form/Mailing/Clicks.php @@ -40,18 +40,18 @@ class CRM_Report_Form_Mailing_Clicks extends CRM_Report_Form { protected $_phoneField = FALSE; - protected $_customGroupExtends = array( + protected $_customGroupExtends = [ 'Contact', 'Individual', 'Household', 'Organization', - ); + ]; - protected $_charts = array( + protected $_charts = [ '' => 'Tabular', 'barChart' => 'Bar Chart', 'pieChart' => 'Pie Chart', - ); + ]; /** * This report has not been optimised for group filtering. @@ -70,153 +70,153 @@ class CRM_Report_Form_Mailing_Clicks extends CRM_Report_Form { * Class constructor. */ public function __construct() { - $this->_columns = array(); + $this->_columns = []; - $this->_columns['civicrm_contact'] = array( + $this->_columns['civicrm_contact'] = [ 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => array( - 'id' => array( + 'fields' => [ + 'id' => [ 'title' => ts('Contact ID'), 'required' => TRUE, - ), - 'sort_name' => array( + ], + 'sort_name' => [ 'title' => ts('Contact Name'), 'required' => TRUE, - ), - ), - 'filters' => array( - 'sort_name' => array( + ], + ], + 'filters' => [ + 'sort_name' => [ 'title' => ts('Contact Name'), - ), - 'source' => array( + ], + 'source' => [ 'title' => ts('Contact Source'), 'type' => CRM_Utils_Type::T_STRING, - ), - 'id' => array( + ], + 'id' => [ 'title' => ts('Contact ID'), 'no_display' => TRUE, - ), - ), - 'order_bys' => array( - 'sort_name' => array( + ], + ], + 'order_bys' => [ + 'sort_name' => [ 'title' => ts('Contact Name'), 'default' => TRUE, 'default_order' => 'ASC', - ), - ), + ], + ], 'grouping' => 'contact-fields', - ); + ]; - $this->_columns['civicrm_mailing'] = array( + $this->_columns['civicrm_mailing'] = [ 'dao' => 'CRM_Mailing_DAO_Mailing', - 'fields' => array( - 'mailing_name' => array( + 'fields' => [ + 'mailing_name' => [ 'name' => 'name', 'title' => ts('Mailing Name'), 'default' => TRUE, - ), - 'mailing_name_alias' => array( + ], + 'mailing_name_alias' => [ 'name' => 'name', 'required' => TRUE, 'no_display' => TRUE, - ), - 'mailing_subject' => array( + ], + 'mailing_subject' => [ 'name' => 'subject', 'title' => ts('Mailing Subject'), 'default' => TRUE, - ), - ), - 'filters' => array( - 'mailing_id' => array( + ], + ], + 'filters' => [ + 'mailing_id' => [ 'name' => 'id', 'title' => ts('Mailing Name'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'type' => CRM_Utils_Type::T_INT, 'options' => CRM_Mailing_BAO_Mailing::getMailingsList(), 'operator' => 'like', - ), - 'mailing_subject' => array( + ], + 'mailing_subject' => [ 'name' => 'subject', 'title' => ts('Mailing Subject'), 'type' => CRM_Utils_Type::T_STRING, 'operator' => 'like', - ), - ), - 'order_bys' => array( - 'mailing_name' => array( + ], + ], + 'order_bys' => [ + 'mailing_name' => [ 'name' => 'name', 'title' => ts('Mailing Name'), - ), - 'mailing_subject' => array( + ], + 'mailing_subject' => [ 'name' => 'subject', 'title' => ts('Mailing Subject'), - ), - ), + ], + ], 'grouping' => 'mailing-fields', - ); + ]; - $this->_columns['civicrm_email'] = array( + $this->_columns['civicrm_email'] = [ 'dao' => 'CRM_Core_DAO_Email', - 'fields' => array( - 'email' => array( + 'fields' => [ + 'email' => [ 'title' => ts('Email'), 'no_repeat' => TRUE, - ), - ), + ], + ], 'grouping' => 'contact-fields', - ); + ]; - $this->_columns['civicrm_phone'] = array( + $this->_columns['civicrm_phone'] = [ 'dao' => 'CRM_Core_DAO_Phone', - 'fields' => array('phone' => NULL), + 'fields' => ['phone' => NULL], 'grouping' => 'contact-fields', - ); + ]; - $this->_columns['civicrm_mailing_trackable_url'] = array( + $this->_columns['civicrm_mailing_trackable_url'] = [ 'dao' => 'CRM_Mailing_DAO_TrackableURL', - 'fields' => array( - 'url' => array( + 'fields' => [ + 'url' => [ 'title' => ts('Click through URL'), - ), - ), + ], + ], // To do this filter should really be like mailing id filter a multi select, However // Not clear on how to make filter dependant on selected mailings at this stage so have set a // text filter which works for now - 'filters' => array( - 'url' => array( + 'filters' => [ + 'url' => [ 'title' => ts('URL'), 'type' => CRM_Utils_Type::T_STRING, 'operator' => 'like', - ), - ), - 'order_bys' => array( - 'url' => array('title' => ts('Click through URL')), - ), + ], + ], + 'order_bys' => [ + 'url' => ['title' => ts('Click through URL')], + ], 'grouping' => 'mailing-fields', - ); + ]; - $this->_columns['civicrm_mailing_event_trackable_url_open'] = array( + $this->_columns['civicrm_mailing_event_trackable_url_open'] = [ 'dao' => 'CRM_Mailing_Event_DAO_TrackableURLOpen', - 'fields' => array( - 'time_stamp' => array( + 'fields' => [ + 'time_stamp' => [ 'title' => ts('Click Date'), 'default' => TRUE, - ), - ), - 'filters' => array( - 'time_stamp' => array( + ], + ], + 'filters' => [ + 'time_stamp' => [ 'title' => ts('Click Date'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE, - ), - ), - 'order_bys' => array( - 'time_stamp' => array( + ], + ], + 'order_bys' => [ + 'time_stamp' => [ 'title' => ts('Click Date'), - ), - ), + ], + ], 'grouping' => 'mailing-fields', - ); + ]; $this->_groupFilter = TRUE; $this->_tagFilter = TRUE; @@ -229,8 +229,8 @@ public function preProcess() { } public function select() { - $select = array(); - $this->_columnHeaders = array(); + $select = []; + $this->_columnHeaders = []; foreach ($this->_columns as $tableName => $table) { if (array_key_exists('fields', $table)) { foreach ($table['fields'] as $fieldName => $field) { @@ -270,7 +270,7 @@ public function select() { * @return array */ public static function formRule($fields, $files, $self) { - $errors = $grouping = array(); + $errors = $grouping = []; return $errors; } @@ -321,7 +321,7 @@ public function postProcess() { $sql = $this->buildQuery(TRUE); - $rows = $graphRows = array(); + $rows = $graphRows = []; $this->buildRows($sql, $rows); $this->formatDisplay($rows); @@ -337,13 +337,13 @@ public function buildChart(&$rows) { return; } - $chartInfo = array( + $chartInfo = [ 'legend' => ts('Mail Click-Through Report'), 'xname' => ts('Mailing'), 'yname' => ts('Clicks'), 'xLabelAngle' => 20, - 'tip' => ts('Clicks: %1', array(1 => '#val#')), - ); + 'tip' => ts('Clicks: %1', [1 => '#val#']), + ]; foreach ($rows as $row) { $chartInfo['values'][$row['civicrm_mailing_mailing_name_alias']] = $row['civicrm_mailing_click_count']; } diff --git a/CRM/Report/Form/Mailing/Detail.php b/CRM/Report/Form/Mailing/Detail.php index b74e01f1f8b7..2b3afb486695 100644 --- a/CRM/Report/Form/Mailing/Detail.php +++ b/CRM/Report/Form/Mailing/Detail.php @@ -32,12 +32,12 @@ */ class CRM_Report_Form_Mailing_Detail extends CRM_Report_Form { - protected $_customGroupExtends = array( + protected $_customGroupExtends = [ 'Contact', 'Individual', 'Household', 'Organization', - ); + ]; protected $_exposeContactID = FALSE; @@ -58,221 +58,221 @@ class CRM_Report_Form_Mailing_Detail extends CRM_Report_Form { * Class constructor. */ public function __construct() { - $this->_columns = array(); + $this->_columns = []; - $this->_columns['civicrm_contact'] = array( + $this->_columns['civicrm_contact'] = [ 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => array( - 'id' => array( + 'fields' => [ + 'id' => [ 'name' => 'id', 'title' => ts('Contact ID'), 'required' => TRUE, 'no_display' => TRUE, - ), - 'sort_name' => array( + ], + 'sort_name' => [ 'title' => ts('Contact Name'), 'required' => TRUE, - ), - ), - 'filters' => array( - 'sort_name' => array( + ], + ], + 'filters' => [ + 'sort_name' => [ 'title' => ts('Contact Name'), - ), - 'id' => array( + ], + 'id' => [ 'title' => ts('Contact ID'), 'no_display' => TRUE, - ), - ), - 'order_bys' => array( - 'sort_name' => array( + ], + ], + 'order_bys' => [ + 'sort_name' => [ 'title' => ts('Contact Name'), 'default' => TRUE, 'default_order' => 'ASC', - ), - ), + ], + ], 'grouping' => 'contact-fields', - ); + ]; - $this->_columns['civicrm_mailing'] = array( + $this->_columns['civicrm_mailing'] = [ 'dao' => 'CRM_Mailing_DAO_Mailing', - 'fields' => array( - 'mailing_name' => array( + 'fields' => [ + 'mailing_name' => [ 'name' => 'name', 'title' => ts('Mailing Name'), 'default' => TRUE, - ), - 'mailing_subject' => array( + ], + 'mailing_subject' => [ 'name' => 'subject', 'title' => ts('Mailing Subject'), 'default' => TRUE, - ), - ), - 'filters' => array( - 'mailing_id' => array( + ], + ], + 'filters' => [ + 'mailing_id' => [ 'name' => 'id', 'title' => ts('Mailing Name'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'type' => CRM_Utils_Type::T_INT, 'options' => CRM_Mailing_BAO_Mailing::getMailingsList(), - ), - 'mailing_subject' => array( + ], + 'mailing_subject' => [ 'name' => 'subject', 'title' => ts('Mailing Subject'), 'type' => CRM_Utils_Type::T_STRING, 'operator' => 'like', - ), - ), - 'order_bys' => array( - 'mailing_name' => array( + ], + ], + 'order_bys' => [ + 'mailing_name' => [ 'name' => 'name', 'title' => ts('Mailing Name'), - ), - 'mailing_subject' => array( + ], + 'mailing_subject' => [ 'name' => 'subject', 'title' => ts('Mailing Subject'), - ), - ), + ], + ], 'grouping' => 'mailing-fields', - ); + ]; // adding dao just to have alias - $this->_columns['civicrm_mailing_event_bounce'] = array( + $this->_columns['civicrm_mailing_event_bounce'] = [ 'dao' => 'CRM_Mailing_Event_DAO_Bounce', - ); + ]; - $this->_columns['civicrm_mailing_event_delivered'] = array( + $this->_columns['civicrm_mailing_event_delivered'] = [ 'dao' => 'CRM_Mailing_Event_DAO_Delivered', - 'fields' => array( - 'delivery_id' => array( + 'fields' => [ + 'delivery_id' => [ 'name' => 'id', 'title' => ts('Delivery Status'), 'default' => TRUE, - ), - ), - 'filters' => array( - 'delivery_status' => array( + ], + ], + 'filters' => [ + 'delivery_status' => [ 'name' => 'delivery_status', 'title' => ts('Delivery Status'), 'operatorType' => CRM_Report_Form::OP_SELECT, 'type' => CRM_Utils_Type::T_STRING, - 'options' => array( + 'options' => [ '' => 'Any', 'successful' => 'Successful', 'bounced' => 'Bounced', - ), - ), - ), + ], + ], + ], 'grouping' => 'mailing-fields', - ); + ]; - $this->_columns['civicrm_mailing_event_unsubscribe'] = array( + $this->_columns['civicrm_mailing_event_unsubscribe'] = [ 'dao' => 'CRM_Mailing_Event_DAO_Unsubscribe', - 'fields' => array( - 'unsubscribe_id' => array( + 'fields' => [ + 'unsubscribe_id' => [ 'name' => 'id', 'title' => ts('Unsubscribe'), 'default' => TRUE, - ), - 'optout_id' => array( + ], + 'optout_id' => [ 'name' => 'id', 'title' => ts('Opt-out'), 'default' => TRUE, 'alias' => 'mailing_event_unsubscribe_civireport2', - ), - ), - 'filters' => array( - 'is_unsubscribed' => array( + ], + ], + 'filters' => [ + 'is_unsubscribed' => [ 'name' => 'id', 'title' => ts('Unsubscribed'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_SELECT, - 'options' => array( + 'options' => [ '' => ts('Any'), '0' => ts('No'), '1' => ts('Yes'), - ), + ], 'clause' => 'mailing_event_unsubscribe_civireport.id IS NULL', - ), - 'is_optout' => array( + ], + 'is_optout' => [ 'title' => ts('Opted-out'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_SELECT, - 'options' => array( + 'options' => [ '' => ts('Any'), '0' => ts('No'), '1' => ts('Yes'), - ), + ], 'clause' => 'mailing_event_unsubscribe_civireport2.id IS NULL', - ), - ), + ], + ], 'grouping' => 'mailing-fields', - ); + ]; - $this->_columns['civicrm_mailing_event_reply'] = array( + $this->_columns['civicrm_mailing_event_reply'] = [ 'dao' => 'CRM_Mailing_Event_DAO_Reply', - 'fields' => array( - 'reply_id' => array( + 'fields' => [ + 'reply_id' => [ 'name' => 'id', 'title' => ts('Reply'), - ), - ), - 'filters' => array( - 'is_replied' => array( + ], + ], + 'filters' => [ + 'is_replied' => [ 'name' => 'id', 'title' => ts('Replied'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_SELECT, - 'options' => array( + 'options' => [ '' => ts('Any'), '0' => ts('No'), '1' => ts('Yes'), - ), + ], 'clause' => 'mailing_event_reply_civireport.id IS NULL', - ), - ), + ], + ], 'grouping' => 'mailing-fields', - ); + ]; - $this->_columns['civicrm_mailing_event_forward'] = array( + $this->_columns['civicrm_mailing_event_forward'] = [ 'dao' => 'CRM_Mailing_Event_DAO_Forward', - 'fields' => array( - 'forward_id' => array( + 'fields' => [ + 'forward_id' => [ 'name' => 'id', 'title' => ts('Forwarded to Email'), - ), - ), - 'filters' => array( - 'is_forwarded' => array( + ], + ], + 'filters' => [ + 'is_forwarded' => [ 'name' => 'id', 'title' => ts('Forwarded'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_SELECT, - 'options' => array( + 'options' => [ '' => ts('Any'), '0' => ts('No'), '1' => ts('Yes'), - ), + ], 'clause' => 'mailing_event_forward_civireport.id IS NULL', - ), - ), + ], + ], 'grouping' => 'mailing-fields', - ); + ]; - $this->_columns['civicrm_email'] = array( + $this->_columns['civicrm_email'] = [ 'dao' => 'CRM_Core_DAO_Email', - 'fields' => array( - 'email' => array( + 'fields' => [ + 'email' => [ 'title' => ts('Email'), - ), - ), + ], + ], 'grouping' => 'contact-fields', - ); + ]; - $this->_columns['civicrm_phone'] = array( + $this->_columns['civicrm_phone'] = [ 'dao' => 'CRM_Core_DAO_Phone', - 'fields' => array('phone' => NULL), + 'fields' => ['phone' => NULL], 'grouping' => 'contact-fields', - ); + ]; $this->_groupFilter = TRUE; $this->_tagFilter = TRUE; @@ -281,19 +281,19 @@ public function __construct() { } public function select() { - $select = $columns = array(); + $select = $columns = []; foreach ($this->_columns as $tableName => $table) { if (array_key_exists('fields', $table)) { foreach ($table['fields'] as $fieldName => $field) { if (!empty($field['required']) || !empty($this->_params['fields'][$fieldName]) ) { - if (in_array($fieldName, array( + if (in_array($fieldName, [ 'unsubscribe_id', 'optout_id', 'forward_id', '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); @@ -456,7 +456,7 @@ public function where() { */ public function mailingList() { - $data = array(); + $data = []; $mailing = new CRM_Mailing_BAO_Mailing(); $query = "SELECT name FROM civicrm_mailing "; $mailing->query($query); diff --git a/CRM/Report/Form/Mailing/Opened.php b/CRM/Report/Form/Mailing/Opened.php index a466f03e5e5c..f040552ca479 100644 --- a/CRM/Report/Form/Mailing/Opened.php +++ b/CRM/Report/Form/Mailing/Opened.php @@ -38,18 +38,18 @@ class CRM_Report_Form_Mailing_Opened extends CRM_Report_Form { protected $_phoneField = FALSE; - protected $_customGroupExtends = array( + protected $_customGroupExtends = [ 'Contact', 'Individual', 'Household', 'Organization', - ); + ]; - protected $_charts = array( + protected $_charts = [ '' => 'Tabular', 'barChart' => 'Bar Chart', 'pieChart' => 'Pie Chart', - ); + ]; /** * This report has not been optimised for group filtering. @@ -69,143 +69,143 @@ class CRM_Report_Form_Mailing_Opened extends CRM_Report_Form { */ public function __construct() { $this->optimisedForOnlyFullGroupBy = FALSE; - $this->_columns = array(); + $this->_columns = []; - $this->_columns['civicrm_contact'] = array( + $this->_columns['civicrm_contact'] = [ 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => array( - 'id' => array( + 'fields' => [ + 'id' => [ 'title' => ts('Contact ID'), 'required' => TRUE, - ), - 'sort_name' => array( + ], + 'sort_name' => [ 'title' => ts('Contact Name'), 'required' => TRUE, - ), - ), - 'filters' => array( - 'sort_name' => array( + ], + ], + 'filters' => [ + 'sort_name' => [ 'title' => ts('Contact Name'), - ), - 'source' => array( + ], + 'source' => [ 'title' => ts('Contact Source'), 'type' => CRM_Utils_Type::T_STRING, - ), - 'id' => array( + ], + 'id' => [ 'title' => ts('Contact ID'), 'no_display' => TRUE, - ), - ), - 'order_bys' => array( - 'sort_name' => array( + ], + ], + 'order_bys' => [ + 'sort_name' => [ 'title' => ts('Contact Name'), 'default' => TRUE, 'default_order' => 'ASC', - ), - ), + ], + ], 'grouping' => 'contact-fields', - ); + ]; - $this->_columns['civicrm_mailing'] = array( + $this->_columns['civicrm_mailing'] = [ 'dao' => 'CRM_Mailing_DAO_Mailing', - 'fields' => array( - 'mailing_name' => array( + 'fields' => [ + 'mailing_name' => [ 'name' => 'name', 'title' => ts('Mailing Name'), 'default' => TRUE, - ), - 'mailing_name_alias' => array( + ], + 'mailing_name_alias' => [ 'name' => 'name', 'required' => TRUE, 'no_display' => TRUE, - ), - 'mailing_subject' => array( + ], + 'mailing_subject' => [ 'name' => 'subject', 'title' => ts('Mailing Subject'), 'default' => TRUE, - ), - ), - 'filters' => array( - 'mailing_id' => array( + ], + ], + 'filters' => [ + 'mailing_id' => [ 'name' => 'id', 'title' => ts('Mailing Name'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'type' => CRM_Utils_Type::T_INT, 'options' => CRM_Mailing_BAO_Mailing::getMailingsList(), 'operator' => 'like', - ), - 'mailing_subject' => array( + ], + 'mailing_subject' => [ 'name' => 'subject', 'title' => ts('Mailing Subject'), 'type' => CRM_Utils_Type::T_STRING, 'operator' => 'like', - ), - ), - 'order_bys' => array( - 'mailing_name' => array( + ], + ], + 'order_bys' => [ + 'mailing_name' => [ 'name' => 'name', 'title' => ts('Mailing Name'), - ), - 'mailing_subject' => array( + ], + 'mailing_subject' => [ 'name' => 'subject', 'title' => ts('Mailing Subject'), - ), - ), + ], + ], 'grouping' => 'mailing-fields', - ); + ]; - $this->_columns['civicrm_email'] = array( + $this->_columns['civicrm_email'] = [ 'dao' => 'CRM_Core_DAO_Email', - 'fields' => array( - 'email' => array( + 'fields' => [ + 'email' => [ 'title' => ts('Email'), 'no_repeat' => TRUE, - ), - ), - 'order_bys' => array( - 'email' => array('title' => ts('Email'), 'default_order' => 'ASC'), - ), + ], + ], + 'order_bys' => [ + 'email' => ['title' => ts('Email'), 'default_order' => 'ASC'], + ], 'grouping' => 'contact-fields', - ); + ]; - $this->_columns['civicrm_phone'] = array( + $this->_columns['civicrm_phone'] = [ 'dao' => 'CRM_Core_DAO_Phone', - 'fields' => array('phone' => NULL), + 'fields' => ['phone' => NULL], 'grouping' => 'contact-fields', - ); + ]; - $this->_columns['civicrm_mailing_event_opened'] = array( + $this->_columns['civicrm_mailing_event_opened'] = [ 'dao' => 'CRM_Mailing_Event_DAO_Opened', - 'fields' => array( - 'id' => array( + 'fields' => [ + 'id' => [ 'required' => TRUE, 'no_display' => TRUE, 'dbAlias' => CRM_Utils_SQL::supportsFullGroupBy() ? 'ANY_VALUE(mailing_event_opened_civireport.id)' : NULL, - ), - 'time_stamp' => array( + ], + 'time_stamp' => [ 'title' => ts('Open Date'), 'default' => TRUE, - ), - ), - 'filters' => array( - 'time_stamp' => array( + ], + ], + 'filters' => [ + 'time_stamp' => [ 'title' => ts('Open Date'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE, - ), - 'unique_opens' => array( + ], + 'unique_opens' => [ 'title' => ts('Unique Opens'), 'type' => CRM_Utils_Type::T_BOOLEAN, 'pseudofield' => TRUE, - ), - ), - 'order_bys' => array( - 'time_stamp' => array( + ], + ], + 'order_bys' => [ + 'time_stamp' => [ 'title' => ts('Open Date'), - ), - ), + ], + ], 'grouping' => 'mailing-fields', - ); + ]; $this->_groupFilter = TRUE; $this->_tagFilter = TRUE; @@ -218,8 +218,8 @@ public function preProcess() { } public function select() { - $select = array(); - $this->_columnHeaders = array(); + $select = []; + $this->_columnHeaders = []; foreach ($this->_columns as $tableName => $table) { if (array_key_exists('fields', $table)) { foreach ($table['fields'] as $fieldName => $field) { @@ -259,7 +259,7 @@ public function select() { * @return array */ public static function formRule($fields, $files, $self) { - $errors = $grouping = array(); + $errors = $grouping = []; return $errors; } @@ -289,11 +289,11 @@ public function where() { } public function groupBy() { - $groupBys = array(); + $groupBys = []; // Do not use group by clause if distinct = 0 mentioned in url params. flag is used in mailing report screen, default value is TRUE // this report is used to show total opened and unique opened if (CRM_Utils_Request::retrieve('distinct', 'Boolean', CRM_Core_DAO::$_nullObject, FALSE, TRUE)) { - $groupBys = empty($this->_params['charts']) ? array("civicrm_mailing_event_queue.email_id") : array("{$this->_aliases['civicrm_mailing']}.id"); + $groupBys = empty($this->_params['charts']) ? ["civicrm_mailing_event_queue.email_id"] : ["{$this->_aliases['civicrm_mailing']}.id"]; if (!empty($this->_params['unique_opens_value'])) { $groupBys[] = "civicrm_mailing_event_queue.id"; } @@ -312,7 +312,7 @@ public function postProcess() { $sql = $this->buildQuery(TRUE); - $rows = $graphRows = array(); + $rows = $graphRows = []; $this->buildRows($sql, $rows); $this->formatDisplay($rows); @@ -328,13 +328,13 @@ public function buildChart(&$rows) { return; } - $chartInfo = array( + $chartInfo = [ 'legend' => ts('Mail Opened Report'), 'xname' => ts('Mailing'), 'yname' => ts('Opened'), 'xLabelAngle' => 20, - 'tip' => ts('Mail Opened: %1', array(1 => '#val#')), - ); + 'tip' => ts('Mail Opened: %1', [1 => '#val#']), + ]; foreach ($rows as $row) { $chartInfo['values'][$row['civicrm_mailing_mailing_name_alias']] = $row['civicrm_mailing_opened_count']; } diff --git a/CRM/Report/Form/Mailing/Summary.php b/CRM/Report/Form/Mailing/Summary.php index b862ffcc72c6..ba6acbee02bc 100644 --- a/CRM/Report/Form/Mailing/Summary.php +++ b/CRM/Report/Form/Mailing/Summary.php @@ -34,267 +34,267 @@ class CRM_Report_Form_Mailing_Summary extends CRM_Report_Form { protected $_summary = NULL; - protected $_customGroupExtends = array(); + protected $_customGroupExtends = []; protected $_add2groupSupported = FALSE; - public $_drilldownReport = array('mailing/detail' => 'Link to Detail Report'); + public $_drilldownReport = ['mailing/detail' => 'Link to Detail Report']; - protected $_charts = array( + protected $_charts = [ '' => 'Tabular', 'bar_3dChart' => 'Bar Chart', - ); + ]; /** * Class constructor. */ public function __construct() { - $this->_columns = array(); + $this->_columns = []; - $this->_columns['civicrm_mailing'] = array( + $this->_columns['civicrm_mailing'] = [ 'dao' => 'CRM_Mailing_DAO_Mailing', - 'fields' => array( - 'id' => array( + 'fields' => [ + 'id' => [ 'name' => 'id', 'title' => ts('Mailing ID'), 'required' => TRUE, 'no_display' => TRUE, - ), - 'name' => array( + ], + 'name' => [ 'title' => ts('Mailing Name'), 'required' => TRUE, - ), - 'created_date' => array( + ], + 'created_date' => [ 'title' => ts('Date Created'), - ), - 'subject' => array( + ], + 'subject' => [ 'title' => ts('Subject'), - ), - ), - 'filters' => array( - 'is_completed' => array( + ], + ], + 'filters' => [ + 'is_completed' => [ 'title' => ts('Mailing Status'), 'operatorType' => CRM_Report_Form::OP_SELECT, 'type' => CRM_Utils_Type::T_INT, - 'options' => array( + 'options' => [ 0 => 'Incomplete', 1 => 'Complete', - ), + ], //'operator' => 'like', 'default' => 1, - ), - 'mailing_id' => array( + ], + 'mailing_id' => [ 'name' => 'id', 'title' => ts('Mailing Name'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'type' => CRM_Utils_Type::T_INT, 'options' => CRM_Mailing_BAO_Mailing::getMailingsList(), 'operator' => 'like', - ), - 'mailing_subject' => array( + ], + 'mailing_subject' => [ 'name' => 'subject', 'title' => ts('Mailing Subject'), 'type' => CRM_Utils_Type::T_STRING, 'operator' => 'like', - ), - ), - 'order_bys' => array( - 'mailing_name' => array( + ], + ], + 'order_bys' => [ + 'mailing_name' => [ 'name' => 'name', 'title' => ts('Mailing Name'), - ), - 'mailing_subject' => array( + ], + 'mailing_subject' => [ 'name' => 'subject', 'title' => ts('Mailing Subject'), - ), - ), - ); + ], + ], + ]; - $this->_columns['civicrm_mailing_job'] = array( + $this->_columns['civicrm_mailing_job'] = [ 'dao' => 'CRM_Mailing_DAO_MailingJob', - 'fields' => array( - 'start_date' => array( + 'fields' => [ + 'start_date' => [ 'title' => ts('Start Date'), 'dbAlias' => 'MIN(mailing_job_civireport.start_date)', - ), - 'end_date' => array( + ], + 'end_date' => [ 'title' => ts('End Date'), 'dbAlias' => 'MAX(mailing_job_civireport.end_date)', - ), - ), - 'filters' => array( - 'status' => array( + ], + ], + 'filters' => [ + 'status' => [ 'type' => CRM_Utils_Type::T_STRING, 'default' => 'Complete', 'no_display' => TRUE, - ), - 'is_test' => array( + ], + 'is_test' => [ 'type' => CRM_Utils_Type::T_INT, 'default' => 0, 'no_display' => TRUE, - ), - 'start_date' => array( + ], + 'start_date' => [ 'title' => ts('Start Date'), 'default' => 'this.year', 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE, - ), - 'end_date' => array( + ], + 'end_date' => [ 'title' => ts('End Date'), 'default' => 'this.year', 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE, - ), - ), - 'order_bys' => array( - 'start_date' => array( + ], + ], + 'order_bys' => [ + 'start_date' => [ 'title' => ts('Start Date'), 'dbAlias' => 'MIN(mailing_job_civireport.start_date)', - ), - 'end_date' => array( + ], + 'end_date' => [ 'title' => ts('End Date'), 'default_weight' => '1', 'default_order' => 'DESC', 'dbAlias' => 'MAX(mailing_job_civireport.end_date)', - ), - ), + ], + ], 'grouping' => 'mailing-fields', - ); + ]; - $this->_columns['civicrm_mailing_event_queue'] = array( + $this->_columns['civicrm_mailing_event_queue'] = [ 'dao' => 'CRM_Mailing_DAO_Mailing', - 'fields' => array( - 'queue_count' => array( + 'fields' => [ + 'queue_count' => [ 'name' => 'id', 'title' => ts('Intended Recipients'), - ), - ), - ); + ], + ], + ]; - $this->_columns['civicrm_mailing_event_delivered'] = array( + $this->_columns['civicrm_mailing_event_delivered'] = [ 'dao' => 'CRM_Mailing_DAO_Mailing', - 'fields' => array( - 'delivered_count' => array( + 'fields' => [ + 'delivered_count' => [ 'name' => 'event_queue_id', 'title' => ts('Delivered'), - ), - 'accepted_rate' => array( + ], + 'accepted_rate' => [ 'title' => ts('Accepted Rate'), - 'statistics' => array( + 'statistics' => [ 'calc' => 'PERCENTAGE', 'top' => 'civicrm_mailing_event_delivered.delivered_count', 'base' => 'civicrm_mailing_event_queue.queue_count', - ), - ), - ), - ); + ], + ], + ], + ]; - $this->_columns['civicrm_mailing_event_bounce'] = array( + $this->_columns['civicrm_mailing_event_bounce'] = [ 'dao' => 'CRM_Mailing_DAO_Mailing', - 'fields' => array( - 'bounce_count' => array( + 'fields' => [ + 'bounce_count' => [ 'name' => 'event_queue_id', 'title' => ts('Bounce'), - ), - 'bounce_rate' => array( + ], + 'bounce_rate' => [ 'title' => ts('Bounce Rate'), - 'statistics' => array( + 'statistics' => [ 'calc' => 'PERCENTAGE', 'top' => 'civicrm_mailing_event_bounce.bounce_count', 'base' => 'civicrm_mailing_event_queue.queue_count', - ), - ), - ), - ); + ], + ], + ], + ]; - $this->_columns['civicrm_mailing_event_opened'] = array( + $this->_columns['civicrm_mailing_event_opened'] = [ 'dao' => 'CRM_Mailing_DAO_Mailing', - 'fields' => array( - 'unique_open_count' => array( + 'fields' => [ + 'unique_open_count' => [ 'name' => 'id', 'alias' => 'mailing_event_opened_civireport', 'dbAlias' => 'mailing_event_opened_civireport.event_queue_id', 'title' => ts('Unique Opens'), - ), - 'unique_open_rate' => array( + ], + 'unique_open_rate' => [ 'title' => ts('Unique Open Rate'), - 'statistics' => array( + 'statistics' => [ 'calc' => 'PERCENTAGE', 'top' => 'civicrm_mailing_event_opened.unique_open_count', 'base' => 'civicrm_mailing_event_delivered.delivered_count', - ), - ), - 'open_count' => array( + ], + ], + 'open_count' => [ 'name' => 'event_queue_id', 'title' => ts('Total Opens'), - ), - 'open_rate' => array( + ], + 'open_rate' => [ 'title' => ts('Total Open Rate'), - 'statistics' => array( + 'statistics' => [ 'calc' => 'PERCENTAGE', 'top' => 'civicrm_mailing_event_opened.open_count', 'base' => 'civicrm_mailing_event_delivered.delivered_count', - ), - ), - ), - ); + ], + ], + ], + ]; - $this->_columns['civicrm_mailing_event_trackable_url_open'] = array( + $this->_columns['civicrm_mailing_event_trackable_url_open'] = [ 'dao' => 'CRM_Mailing_DAO_Mailing', - 'fields' => array( - 'click_count' => array( + 'fields' => [ + 'click_count' => [ 'name' => 'event_queue_id', 'title' => ts('Unique Clicks'), - ), - 'CTR' => array( + ], + 'CTR' => [ 'title' => ts('Click through Rate'), 'default' => 0, - 'statistics' => array( + 'statistics' => [ 'calc' => 'PERCENTAGE', 'top' => 'civicrm_mailing_event_trackable_url_open.click_count', 'base' => 'civicrm_mailing_event_delivered.delivered_count', - ), - ), - 'CTO' => array( + ], + ], + 'CTO' => [ 'title' => ts('Click to Open Rate'), 'default' => 0, - 'statistics' => array( + 'statistics' => [ 'calc' => 'PERCENTAGE', 'top' => 'civicrm_mailing_event_trackable_url_open.click_count', 'base' => 'civicrm_mailing_event_opened.open_count', - ), - ), - ), - ); + ], + ], + ], + ]; - $this->_columns['civicrm_mailing_event_unsubscribe'] = array( + $this->_columns['civicrm_mailing_event_unsubscribe'] = [ 'dao' => 'CRM_Mailing_DAO_Mailing', - 'fields' => array( - 'unsubscribe_count' => array( + 'fields' => [ + 'unsubscribe_count' => [ 'name' => 'id', 'title' => ts('Unsubscribe'), 'alias' => 'mailing_event_unsubscribe_civireport', 'dbAlias' => 'mailing_event_unsubscribe_civireport.event_queue_id', - ), - 'optout_count' => array( + ], + 'optout_count' => [ 'name' => 'id', 'title' => ts('Opt-outs'), 'alias' => 'mailing_event_optout_civireport', 'dbAlias' => 'mailing_event_optout_civireport.event_queue_id', - ), - ), - ); - $this->_columns['civicrm_mailing_group'] = array( + ], + ], + ]; + $this->_columns['civicrm_mailing_group'] = [ 'dao' => 'CRM_Mailing_DAO_MailingGroup', - 'filters' => array( - 'entity_id' => array( + 'filters' => [ + 'entity_id' => [ 'title' => ts('Groups Included in Mailing'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'type' => CRM_Utils_Type::T_INT, 'options' => CRM_Core_PseudoConstant::group(), - ), - ), - ); + ], + ], + ]; // If we have campaigns enabled, add those elements to both the fields, filters. $this->addCampaignFields('civicrm_mailing'); parent::__construct(); @@ -310,14 +310,14 @@ public function preProcess() { */ public function select() { - $count_tables = array( + $count_tables = [ 'civicrm_mailing_event_queue', 'civicrm_mailing_event_delivered', 'civicrm_mailing_event_opened', 'civicrm_mailing_event_bounce', 'civicrm_mailing_event_trackable_url_open', 'civicrm_mailing_event_unsubscribe', - ); + ]; // Define a list of columns that should be counted with the DISTINCT // keyword. For example, civicrm_mailing_event_opened.unique_open_count @@ -327,7 +327,7 @@ public function select() { // is the key in $this->_columns, and $fieldName is the key in that array's // ['fields'] array. // Reference: CRM-20660 - $distinctCountColumns = array( + $distinctCountColumns = [ 'civicrm_mailing_event_queue.queue_count', 'civicrm_mailing_event_delivered.delivered_count', 'civicrm_mailing_event_bounce.bounce_count', @@ -335,10 +335,10 @@ public function select() { 'civicrm_mailing_event_trackable_url_open.click_count', 'civicrm_mailing_event_unsubscribe.unsubscribe_count', 'civicrm_mailing_event_unsubscribe.optout_count', - ); + ]; - $select = array(); - $this->_columnHeaders = array(); + $select = []; + $this->_columnHeaders = []; foreach ($this->_columns as $tableName => $table) { if (array_key_exists('fields', $table)) { foreach ($table['fields'] as $fieldName => $field) { @@ -417,7 +417,7 @@ public function from() { } public function where() { - $clauses = array(); + $clauses = []; //to avoid the sms listings $clauses[] = "{$this->_aliases['civicrm_mailing']}.sms_provider_id IS NULL"; @@ -466,9 +466,9 @@ public function where() { } public function groupBy() { - $groupBy = array( + $groupBy = [ "{$this->_aliases['civicrm_mailing']}.id", - ); + ]; $this->_groupBy = CRM_Contact_BAO_Query::getGroupByFromSelectColumns($this->_selectClauses, $groupBy); } @@ -488,7 +488,7 @@ public function postProcess() { // print_r($sql); - $rows = $graphRows = array(); + $rows = $graphRows = []; $this->buildRows($sql, $rows); $this->formatDisplay($rows); @@ -500,24 +500,24 @@ public function postProcess() { * @return array */ public static function getChartCriteria() { - return array( - 'count' => array( + return [ + 'count' => [ 'civicrm_mailing_event_delivered_delivered_count' => ts('Delivered'), 'civicrm_mailing_event_bounce_bounce_count' => ts('Bounce'), 'civicrm_mailing_event_opened_open_count' => ts('Total Opens'), 'civicrm_mailing_event_opened_unique_open_count' => ts('Unique Opens'), 'civicrm_mailing_event_trackable_url_open_click_count' => ts('Unique Clicks'), 'civicrm_mailing_event_unsubscribe_unsubscribe_count' => ts('Unsubscribe'), - ), - 'rate' => array( + ], + 'rate' => [ 'civicrm_mailing_event_delivered_accepted_rate' => ts('Accepted Rate'), 'civicrm_mailing_event_bounce_bounce_rate' => ts('Bounce Rate'), 'civicrm_mailing_event_opened_open_rate' => ts('Total Open Rate'), 'civicrm_mailing_event_opened_unique_open_rate' => ts('Unique Open Rate'), 'civicrm_mailing_event_trackable_url_open_CTR' => ts('Click through Rate'), 'civicrm_mailing_event_trackable_url_open_CTO' => ts('Click to Open Rate'), - ), - ); + ], + ]; } /** @@ -528,7 +528,7 @@ public static function getChartCriteria() { * @return array */ public static function formRule($fields, $files, $self) { - $errors = array(); + $errors = []; if (empty($fields['charts'])) { return $errors; @@ -537,7 +537,7 @@ public static function formRule($fields, $files, $self) { $criteria = self::getChartCriteria(); $isError = TRUE; foreach ($fields['fields'] as $fld => $isActive) { - if (in_array($fld, array( + if (in_array($fld, [ 'delivered_count', 'bounce_count', 'open_count', @@ -550,16 +550,16 @@ public static function formRule($fields, $files, $self) { 'CTO', 'unique_open_rate', 'unique_open_count', - ))) { + ])) { $isError = FALSE; } } if ($isError) { - $errors['_qf_default'] = ts('For Chart view, please select at least one field from %1 OR %2.', array( + $errors['_qf_default'] = ts('For Chart view, please select at least one field from %1 OR %2.', [ 1 => implode(', ', $criteria['count']), 2 => implode(', ', $criteria['rate']), - )); + ]); } return $errors; @@ -575,17 +575,17 @@ public function buildChart(&$rows) { $criteria = self::getChartCriteria(); - $chartInfo = array( + $chartInfo = [ 'legend' => ts('Mail Summary'), 'xname' => ts('Mailing'), 'yname' => ts('Statistics'), 'xLabelAngle' => 20, - 'tip' => array(), - ); + 'tip' => [], + ]; $plotRate = $plotCount = TRUE; foreach ($rows as $row) { - $chartInfo['values'][$row['civicrm_mailing_name']] = array(); + $chartInfo['values'][$row['civicrm_mailing_name']] = []; if ($plotCount) { foreach ($criteria['count'] as $criteriaName => $label) { if (isset($row[$criteriaName])) { diff --git a/CRM/Report/Form/Member/ContributionDetail.php b/CRM/Report/Form/Member/ContributionDetail.php index 47ab00637f18..beabdbc122f6 100644 --- a/CRM/Report/Form/Member/ContributionDetail.php +++ b/CRM/Report/Form/Member/ContributionDetail.php @@ -34,11 +34,11 @@ class CRM_Report_Form_Member_ContributionDetail extends CRM_Report_Form { protected $_summary = NULL; - protected $_customGroupExtends = array( + protected $_customGroupExtends = [ 'Contribution', 'Membership', 'Contact', - ); + ]; /** * This report has not been optimised for group filtering. @@ -59,314 +59,314 @@ class CRM_Report_Form_Member_ContributionDetail extends CRM_Report_Form { * Class constructor. */ public function __construct() { - $this->_columns = array( - 'civicrm_contact' => array( + $this->_columns = [ + 'civicrm_contact' => [ 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => array( - 'sort_name' => array( + 'fields' => [ + 'sort_name' => [ 'title' => ts('Donor Name'), 'required' => TRUE, 'no_repeat' => TRUE, - ), - 'first_name' => array( + ], + 'first_name' => [ 'title' => ts('First Name'), 'no_repeat' => TRUE, - ), - 'last_name' => array( + ], + 'last_name' => [ 'title' => ts('Last Name'), 'no_repeat' => TRUE, - ), - 'nick_name' => array( + ], + 'nick_name' => [ 'title' => ts('Nickname'), 'no_repeat' => TRUE, - ), - 'contact_type' => array( + ], + 'contact_type' => [ 'title' => ts('Contact Type'), 'no_repeat' => TRUE, - ), - 'contact_sub_type' => array( + ], + 'contact_sub_type' => [ 'title' => ts('Contact Subtype'), 'no_repeat' => TRUE, - ), - 'do_not_email' => array( + ], + 'do_not_email' => [ 'title' => ts('Do Not Email'), 'no_repeat' => TRUE, - ), - 'is_opt_out' => array( + ], + 'is_opt_out' => [ 'title' => ts('No Bulk Email(Is Opt Out)'), 'no_repeat' => TRUE, - ), - 'id' => array( + ], + 'id' => [ 'no_display' => TRUE, 'required' => TRUE, 'csv_display' => TRUE, 'title' => ts('Contact ID'), - ), - ), - 'filters' => array( - 'sort_name' => array( + ], + ], + 'filters' => [ + 'sort_name' => [ 'title' => ts('Donor Name'), 'operator' => 'like', - ), - 'id' => array( + ], + 'id' => [ 'title' => ts('Contact ID'), 'no_display' => TRUE, - ), - ), + ], + ], 'grouping' => 'contact-fields', - ), - 'civicrm_email' => array( + ], + 'civicrm_email' => [ 'dao' => 'CRM_Core_DAO_Email', - 'fields' => array( - 'email' => array( + 'fields' => [ + 'email' => [ 'title' => ts('Donor Email'), 'default' => TRUE, 'no_repeat' => TRUE, - ), - ), + ], + ], 'grouping' => 'contact-fields', - ), - 'civicrm_phone' => array( + ], + 'civicrm_phone' => [ 'dao' => 'CRM_Core_DAO_Phone', - 'fields' => array( - 'phone' => array( + 'fields' => [ + 'phone' => [ 'title' => ts('Donor Phone'), 'default' => TRUE, 'no_repeat' => TRUE, - ), - ), + ], + ], 'grouping' => 'contact-fields', - ), - 'first_donation' => array( + ], + 'first_donation' => [ 'dao' => 'CRM_Contribute_DAO_Contribution', - 'fields' => array( - 'first_donation_date' => array( + 'fields' => [ + 'first_donation_date' => [ 'title' => ts('First Contribution Date'), 'base_field' => 'receive_date', 'no_repeat' => TRUE, - ), - 'first_donation_amount' => array( + ], + 'first_donation_amount' => [ 'title' => ts('First Contribution Amount'), 'base_field' => 'total_amount', 'no_repeat' => TRUE, - ), - ), - ), - 'civicrm_contribution' => array( + ], + ], + ], + 'civicrm_contribution' => [ 'dao' => 'CRM_Contribute_DAO_Contribution', - 'fields' => array( - 'contribution_id' => array( + 'fields' => [ + 'contribution_id' => [ 'name' => 'id', 'no_display' => TRUE, 'required' => TRUE, 'csv_display' => TRUE, 'title' => ts('Contribution ID'), - ), - 'financial_type_id' => array( + ], + 'financial_type_id' => [ 'title' => ts('Financial Type'), 'default' => TRUE, - ), - 'contribution_recur_id' => array( + ], + 'contribution_recur_id' => [ 'title' => ts('Recurring Contribution Id'), 'name' => 'contribution_recur_id', 'required' => TRUE, 'no_display' => TRUE, 'csv_display' => TRUE, - ), - 'contribution_status_id' => array( + ], + 'contribution_status_id' => [ 'title' => ts('Contribution Status'), - ), - 'payment_instrument_id' => array( + ], + 'payment_instrument_id' => [ 'title' => ts('Payment Type'), - ), - 'contribution_source' => array( + ], + 'contribution_source' => [ 'name' => 'source', 'title' => ts('Contribution Source'), - ), - 'currency' => array( + ], + 'currency' => [ 'required' => TRUE, 'no_display' => TRUE, - ), + ], 'trxn_id' => NULL, - 'receive_date' => array('default' => TRUE), + 'receive_date' => ['default' => TRUE], 'receipt_date' => NULL, 'fee_amount' => NULL, 'net_amount' => NULL, - 'total_amount' => array( + 'total_amount' => [ 'title' => ts('Amount'), 'required' => TRUE, - ), - ), - 'filters' => array( - 'receive_date' => array('operatorType' => CRM_Report_Form::OP_DATE), - 'financial_type_id' => array( + ], + ], + 'filters' => [ + 'receive_date' => ['operatorType' => CRM_Report_Form::OP_DATE], + 'financial_type_id' => [ 'title' => ts('Financial Type'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::financialType(), - ), - 'currency' => array( + ], + 'currency' => [ 'title' => ts('Currency'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_OptionGroup::values('currencies_enabled'), 'default' => NULL, 'type' => CRM_Utils_Type::T_STRING, - ), - 'payment_instrument_id' => array( + ], + 'payment_instrument_id' => [ 'title' => ts('Payment Type'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::paymentInstrument(), - ), - 'contribution_status_id' => array( + ], + 'contribution_status_id' => [ 'title' => ts('Contribution Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), - 'default' => array(1), - ), - 'total_amount' => array('title' => ts('Contribution Amount')), - ), + 'default' => [1], + ], + 'total_amount' => ['title' => ts('Contribution Amount')], + ], 'grouping' => 'contri-fields', - ), - 'civicrm_product' => array( + ], + 'civicrm_product' => [ 'dao' => 'CRM_Contribute_DAO_Product', - 'fields' => array( - 'product_name' => array( + 'fields' => [ + 'product_name' => [ 'name' => 'name', 'title' => ts('Premium'), - ), - ), - ), - 'civicrm_batch' => array( + ], + ], + ], + 'civicrm_batch' => [ 'dao' => 'CRM_Batch_DAO_EntityBatch', 'grouping' => 'contri-fields', - 'fields' => array( - 'batch_id' => array( + 'fields' => [ + 'batch_id' => [ 'name' => 'batch_id', 'title' => ts('Batch Name'), - ), - ), - 'filters' => array( - 'bid' => array( + ], + ], + 'filters' => [ + 'bid' => [ 'title' => ts('Batch Name'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Batch_BAO_Batch::getBatches(), 'type' => CRM_Utils_Type::T_INT, 'dbAlias' => 'batch_civireport.batch_id', - ), - ), - ), - 'civicrm_contribution_product' => array( + ], + ], + ], + 'civicrm_contribution_product' => [ 'dao' => 'CRM_Contribute_DAO_ContributionProduct', - 'fields' => array( - 'product_id' => array( + 'fields' => [ + 'product_id' => [ 'no_display' => TRUE, - ), - 'product_option' => array( + ], + 'product_option' => [ 'title' => ts('Premium Option'), - ), - 'fulfilled_date' => array( + ], + 'fulfilled_date' => [ 'title' => ts('Premium Fulfilled Date'), - ), - 'contribution_id' => array( + ], + 'contribution_id' => [ 'no_display' => TRUE, - ), - ), - ), - 'civicrm_contribution_ordinality' => array( + ], + ], + ], + 'civicrm_contribution_ordinality' => [ 'dao' => 'CRM_Contribute_DAO_Contribution', 'alias' => 'cordinality', - 'filters' => array( - 'ordinality' => array( + 'filters' => [ + 'ordinality' => [ 'title' => ts('Contribution Ordinality'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, - 'options' => array( + 'options' => [ 0 => 'First by Contributor', 1 => 'Second or Later by Contributor', - ), - ), - ), - ), - 'civicrm_membership' => array( + ], + ], + ], + ], + 'civicrm_membership' => [ 'dao' => 'CRM_Member_DAO_Membership', - 'fields' => array( - 'membership_type_id' => array( + 'fields' => [ + 'membership_type_id' => [ 'title' => ts('Membership Type'), 'required' => TRUE, 'no_repeat' => TRUE, - ), - 'membership_start_date' => array( + ], + 'membership_start_date' => [ 'title' => ts('Start Date'), 'default' => TRUE, - ), - 'membership_end_date' => array( + ], + 'membership_end_date' => [ 'title' => ts('End Date'), 'default' => TRUE, - ), - 'join_date' => array( + ], + 'join_date' => [ 'title' => ts('Join Date'), 'default' => TRUE, - ), - 'source' => array('title' => ts('Membership Source')), - ), - 'filters' => array( - 'join_date' => array('operatorType' => CRM_Report_Form::OP_DATE), - 'membership_start_date' => array('operatorType' => CRM_Report_Form::OP_DATE), - 'membership_end_date' => array('operatorType' => CRM_Report_Form::OP_DATE), - 'owner_membership_id' => array( + ], + 'source' => ['title' => ts('Membership Source')], + ], + 'filters' => [ + 'join_date' => ['operatorType' => CRM_Report_Form::OP_DATE], + 'membership_start_date' => ['operatorType' => CRM_Report_Form::OP_DATE], + 'membership_end_date' => ['operatorType' => CRM_Report_Form::OP_DATE], + 'owner_membership_id' => [ 'title' => ts('Membership Owner ID'), 'operatorType' => CRM_Report_Form::OP_INT, - ), - 'tid' => array( + ], + 'tid' => [ 'name' => 'membership_type_id', 'title' => ts('Membership Types'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Member_PseudoConstant::membershipType(), - ), - ), + ], + ], 'grouping' => 'member-fields', - ), - 'civicrm_membership_status' => array( + ], + 'civicrm_membership_status' => [ 'dao' => 'CRM_Member_DAO_MembershipStatus', 'alias' => 'mem_status', - 'fields' => array( - 'membership_status_name' => array( + 'fields' => [ + 'membership_status_name' => [ 'name' => 'name', 'title' => ts('Membership Status'), 'default' => TRUE, - ), - ), - 'filters' => array( - 'sid' => array( + ], + ], + 'filters' => [ + 'sid' => [ 'name' => 'id', 'title' => ts('Membership Status'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Member_PseudoConstant::membershipStatus(NULL, NULL, 'label'), - ), - ), + ], + ], 'grouping' => 'member-fields', - ), - 'civicrm_note' => array( + ], + 'civicrm_note' => [ 'dao' => 'CRM_Core_DAO_Note', - 'fields' => array( - 'contribution_note' => array( + 'fields' => [ + 'contribution_note' => [ 'name' => 'note', 'title' => ts('Contribution Note'), - ), - ), - 'filters' => array( - 'note' => array( + ], + ], + 'filters' => [ + 'note' => [ 'name' => 'note', 'title' => ts('Contribution Note'), 'operator' => 'like', 'type' => CRM_Utils_Type::T_STRING, - ), - ), - ), - ) + $this->addAddressFields(FALSE); + ], + ], + ], + ] + $this->addAddressFields(FALSE); $this->_groupFilter = TRUE; $this->_tagFilter = TRUE; @@ -383,9 +383,9 @@ public function preProcess() { } public function select() { - $select = array(); + $select = []; - $this->_columnHeaders = array(); + $this->_columnHeaders = []; foreach ($this->_columns as $tableName => $table) { if (array_key_exists('fields', $table)) { foreach ($table['fields'] as $fieldName => $field) { @@ -558,10 +558,10 @@ public function buildQuery($applyLimit = TRUE) { } public function groupBy() { - $groupBy = array( + $groupBy = [ "{$this->_aliases['civicrm_contact']}.id", "{$this->_aliases['civicrm_contribution']}.id", - ); + ]; $this->_groupBy = CRM_Contact_BAO_Query::getGroupByFromSelectColumns($this->_selectClauses, $groupBy); } @@ -590,24 +590,24 @@ public function statistics(&$rows) { GROUP BY cc.currency"; $dao = CRM_Core_DAO::executeQuery($sql); - $totalAmount = $average = array(); + $totalAmount = $average = []; while ($dao->fetch()) { $totalAmount[] = CRM_Utils_Money::format($dao->amount, $dao->currency) . "(" . $dao->count . ")"; $average[] = CRM_Utils_Money::format($dao->avg, $dao->currency); } - $statistics['counts']['amount'] = array( + $statistics['counts']['amount'] = [ 'title' => ts('Total Amount'), 'value' => implode(', ', $totalAmount), 'type' => CRM_Utils_Type::T_STRING, - ); + ]; - $statistics['counts']['avg'] = array( + $statistics['counts']['avg'] = [ 'title' => ts('Average'), 'value' => implode(', ', $average), 'type' => CRM_Utils_Type::T_STRING, - ); + ]; return $statistics; } @@ -623,7 +623,7 @@ public function postProcess() { */ public function alterDisplay(&$rows) { // custom code to alter rows - $checkList = array(); + $checkList = []; $entryFound = FALSE; $contributionTypes = CRM_Contribute_PseudoConstant::financialType(); diff --git a/CRM/Report/Form/Member/Detail.php b/CRM/Report/Form/Member/Detail.php index 94afd1f19763..4d816ee3db96 100644 --- a/CRM/Report/Form/Member/Detail.php +++ b/CRM/Report/Form/Member/Detail.php @@ -34,14 +34,14 @@ class CRM_Report_Form_Member_Detail extends CRM_Report_Form { protected $_summary = NULL; - protected $_customGroupExtends = array( + protected $_customGroupExtends = [ 'Membership', 'Contribution', 'Contact', 'Individual', 'Household', 'Organization', - ); + ]; protected $_customGroupGroupBy = FALSE; @@ -62,188 +62,188 @@ class CRM_Report_Form_Member_Detail extends CRM_Report_Form { * Class constructor. */ public function __construct() { - $this->_columns = array( - 'civicrm_contact' => array( + $this->_columns = [ + 'civicrm_contact' => [ 'dao' => 'CRM_Contact_DAO_Contact', 'fields' => $this->getBasicContactFields(), - 'filters' => array( - 'sort_name' => array( + 'filters' => [ + 'sort_name' => [ 'title' => ts('Contact Name'), 'operator' => 'like', - ), - 'is_deleted' => array( + ], + 'is_deleted' => [ 'title' => ts('Is Deleted'), 'default' => 0, 'type' => CRM_Utils_Type::T_BOOLEAN, - ), - 'id' => array('no_display' => TRUE), - ), - 'order_bys' => array( - 'sort_name' => array( + ], + 'id' => ['no_display' => TRUE], + ], + 'order_bys' => [ + 'sort_name' => [ 'title' => ts('Last Name, First Name'), 'default' => '1', 'default_weight' => '0', 'default_order' => 'ASC', - ), - ), + ], + ], 'grouping' => 'contact-fields', - ), - 'civicrm_membership' => array( + ], + 'civicrm_membership' => [ 'dao' => 'CRM_Member_DAO_Membership', - 'fields' => array( - 'membership_type_id' => array( + 'fields' => [ + 'membership_type_id' => [ 'title' => ts('Membership Type'), 'required' => TRUE, 'no_repeat' => TRUE, - ), - 'membership_start_date' => array( + ], + 'membership_start_date' => [ 'title' => ts('Start Date'), 'default' => TRUE, - ), - 'membership_end_date' => array( + ], + 'membership_end_date' => [ 'title' => ts('End Date'), 'default' => TRUE, - ), - 'owner_membership_id' => array( + ], + 'owner_membership_id' => [ 'title' => ts('Primary/Inherited?'), 'default' => TRUE, - ), - 'join_date' => array( + ], + 'join_date' => [ 'title' => ts('Join Date'), 'default' => TRUE, - ), - 'source' => array('title' => ts('Source')), - ), - 'filters' => array( - 'join_date' => array('operatorType' => CRM_Report_Form::OP_DATE), - 'membership_start_date' => array('operatorType' => CRM_Report_Form::OP_DATE), - 'membership_end_date' => array('operatorType' => CRM_Report_Form::OP_DATE), - 'owner_membership_id' => array( + ], + 'source' => ['title' => ts('Source')], + ], + 'filters' => [ + 'join_date' => ['operatorType' => CRM_Report_Form::OP_DATE], + 'membership_start_date' => ['operatorType' => CRM_Report_Form::OP_DATE], + 'membership_end_date' => ['operatorType' => CRM_Report_Form::OP_DATE], + 'owner_membership_id' => [ 'title' => ts('Membership Owner ID'), 'operatorType' => CRM_Report_Form::OP_INT, - ), - 'tid' => array( + ], + 'tid' => [ 'name' => 'membership_type_id', 'title' => ts('Membership Types'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Member_PseudoConstant::membershipType(), - ), - ), - 'order_bys' => array( - 'membership_type_id' => array( + ], + ], + 'order_bys' => [ + 'membership_type_id' => [ 'title' => ts('Membership Type'), 'default' => '0', 'default_weight' => '1', 'default_order' => 'ASC', - ), - ), + ], + ], 'grouping' => 'member-fields', - 'group_bys' => array( - 'id' => array( + 'group_bys' => [ + 'id' => [ 'title' => ts('Membership'), 'default' => TRUE, - ), - ), - ), - 'civicrm_membership_status' => array( + ], + ], + ], + 'civicrm_membership_status' => [ 'dao' => 'CRM_Member_DAO_MembershipStatus', 'alias' => 'mem_status', - 'fields' => array( - 'name' => array( + 'fields' => [ + 'name' => [ 'title' => ts('Status'), 'default' => TRUE, - ), - ), - 'filters' => array( - 'sid' => array( + ], + ], + 'filters' => [ + 'sid' => [ 'name' => 'id', 'title' => ts('Status'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Member_PseudoConstant::membershipStatus(NULL, NULL, 'label'), - ), - ), + ], + ], 'grouping' => 'member-fields', - ), - 'civicrm_email' => array( + ], + 'civicrm_email' => [ 'dao' => 'CRM_Core_DAO_Email', - 'fields' => array('email' => NULL), + 'fields' => ['email' => NULL], 'grouping' => 'contact-fields', - ), - 'civicrm_phone' => array( + ], + 'civicrm_phone' => [ 'dao' => 'CRM_Core_DAO_Phone', - 'fields' => array('phone' => NULL), + 'fields' => ['phone' => NULL], 'grouping' => 'contact-fields', - ), - 'civicrm_contribution' => array( + ], + 'civicrm_contribution' => [ 'dao' => 'CRM_Contribute_DAO_Contribution', - 'fields' => array( - 'contribution_id' => array( + 'fields' => [ + 'contribution_id' => [ 'name' => 'id', 'no_display' => TRUE, 'required' => TRUE, - ), - 'financial_type_id' => array('title' => ts('Financial Type')), - 'contribution_status_id' => array('title' => ts('Contribution Status')), - 'payment_instrument_id' => array('title' => ts('Payment Type')), - 'currency' => array( + ], + 'financial_type_id' => ['title' => ts('Financial Type')], + 'contribution_status_id' => ['title' => ts('Contribution Status')], + 'payment_instrument_id' => ['title' => ts('Payment Type')], + 'currency' => [ 'required' => TRUE, 'no_display' => TRUE, - ), + ], 'trxn_id' => NULL, 'receive_date' => NULL, 'receipt_date' => NULL, 'fee_amount' => NULL, 'net_amount' => NULL, - 'total_amount' => array( + 'total_amount' => [ 'title' => ts('Payment Amount (most recent)'), - 'statistics' => array('sum' => ts('Amount')), - ), - ), - 'filters' => array( - 'receive_date' => array('operatorType' => CRM_Report_Form::OP_DATE), - 'financial_type_id' => array( + 'statistics' => ['sum' => ts('Amount')], + ], + ], + 'filters' => [ + 'receive_date' => ['operatorType' => CRM_Report_Form::OP_DATE], + 'financial_type_id' => [ 'title' => ts('Financial Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::financialType(), 'type' => CRM_Utils_Type::T_INT, - ), - 'payment_instrument_id' => array( + ], + 'payment_instrument_id' => [ 'title' => ts('Payment Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::paymentInstrument(), 'type' => CRM_Utils_Type::T_INT, - ), - 'currency' => array( + ], + 'currency' => [ 'title' => ts('Currency'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_OptionGroup::values('currencies_enabled'), 'default' => NULL, 'type' => CRM_Utils_Type::T_STRING, - ), - 'contribution_status_id' => array( + ], + 'contribution_status_id' => [ 'title' => ts('Contribution Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), 'type' => CRM_Utils_Type::T_INT, - ), - 'total_amount' => array('title' => ts('Contribution Amount')), - ), - 'order_bys' => array( - 'receive_date' => array( + ], + 'total_amount' => ['title' => ts('Contribution Amount')], + ], + 'order_bys' => [ + 'receive_date' => [ 'title' => ts('Date Received'), 'default_weight' => '2', 'default_order' => 'DESC', - ), - ), + ], + ], 'grouping' => 'contri-fields', - ), - ) + $this->getAddressColumns(array( + ], + ] + $this->getAddressColumns([ // These options are only excluded because they were not previously present. 'order_by' => FALSE, 'group_by' => FALSE, - )); + ]); $this->_groupFilter = TRUE; $this->_tagFilter = TRUE; @@ -295,7 +295,7 @@ public function from() { */ public function alterDisplay(&$rows) { $entryFound = FALSE; - $checkList = array(); + $checkList = []; $contributionTypes = CRM_Contribute_PseudoConstant::financialType(); $contributionStatus = CRM_Contribute_PseudoConstant::contributionStatus(); @@ -307,7 +307,7 @@ public function alterDisplay(&$rows) { $repeatFound < $rowNum - 1 ) { unset($checkList); - $checkList = array(); + $checkList = []; } if (!empty($this->_noRepeats) && $this->_outputMode != 'csv') { // not repeat contact display names if it matches with the one diff --git a/CRM/Report/Form/Member/Lapse.php b/CRM/Report/Form/Member/Lapse.php index 4a7f744e7455..1313c3e744f9 100644 --- a/CRM/Report/Form/Member/Lapse.php +++ b/CRM/Report/Form/Member/Lapse.php @@ -35,11 +35,11 @@ class CRM_Report_Form_Member_Lapse extends CRM_Report_Form { protected $_summary = NULL; - protected $_charts = array('' => 'Tabular'); - protected $_customGroupExtends = array( + protected $_charts = ['' => 'Tabular']; + protected $_customGroupExtends = [ 'Membership', - ); - public $_drilldownReport = array('member/detail' => 'Link to Detail Report'); + ]; + public $_drilldownReport = ['member/detail' => 'Link to Detail Report']; /** * This report has not been optimised for group filtering. @@ -60,112 +60,112 @@ class CRM_Report_Form_Member_Lapse extends CRM_Report_Form { public function __construct() { // UI for selecting columns to appear in the report list // array containing the columns, group_bys and filters build and provided to Form - $this->_columns = array( - 'civicrm_contact' => array( + $this->_columns = [ + 'civicrm_contact' => [ 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => array( - 'sort_name' => array( + 'fields' => [ + 'sort_name' => [ 'title' => ts('Member Name'), 'no_repeat' => TRUE, 'required' => TRUE, - ), - 'id' => array( + ], + 'id' => [ 'no_display' => TRUE, 'required' => TRUE, - ), - 'first_name' => array( + ], + 'first_name' => [ 'title' => ts('First Name'), 'no_repeat' => TRUE, - ), - 'last_name' => array( + ], + 'last_name' => [ 'title' => ts('Last Name'), 'no_repeat' => TRUE, - ), - 'contact_type' => array( + ], + 'contact_type' => [ 'title' => ts('Contact Type'), - ), - 'contact_sub_type' => array( + ], + 'contact_sub_type' => [ 'title' => ts('Contact Subtype'), - ), - ), + ], + ], 'grouping' => 'contact-fields', - ), - 'civicrm_membership_type' => array( + ], + 'civicrm_membership_type' => [ 'dao' => 'CRM_Member_DAO_MembershipType', 'grouping' => 'member-fields', - 'filters' => array( - 'tid' => array( + 'filters' => [ + 'tid' => [ 'name' => 'id', 'title' => ts('Membership Types'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Member_PseudoConstant::membershipType(), - ), - ), - ), - 'civicrm_membership' => array( + ], + ], + ], + 'civicrm_membership' => [ 'dao' => 'CRM_Member_DAO_Membership', 'grouping' => 'member-fields', - 'fields' => array( - 'membership_type_id' => array( + 'fields' => [ + 'membership_type_id' => [ 'title' => ts('Membership Type'), 'required' => TRUE, 'type' => CRM_Utils_Type::T_STRING, - ), - 'membership_start_date' => array( + ], + 'membership_start_date' => [ 'title' => ts('Current Cycle Start Date'), - ), - 'membership_end_date' => array( + ], + 'membership_end_date' => [ 'title' => ts('Membership Lapse Date'), 'required' => TRUE, - ), - ), - 'filters' => array( - 'membership_end_date' => array( + ], + ], + 'filters' => [ + 'membership_end_date' => [ 'title' => ts('Lapsed Memberships'), 'operatorType' => CRM_Report_Form::OP_DATE, - ), - ), - ), - 'civicrm_membership_status' => array( + ], + ], + ], + 'civicrm_membership_status' => [ 'dao' => 'CRM_Member_DAO_MembershipStatus', 'alias' => 'mem_status', - 'fields' => array( - 'name' => array( + 'fields' => [ + 'name' => [ 'title' => ts('Current Status'), 'required' => TRUE, - ), - ), + ], + ], 'grouping' => 'member-fields', - ), - 'civicrm_address' => array( + ], + 'civicrm_address' => [ 'dao' => 'CRM_Core_DAO_Address', - 'fields' => array( + 'fields' => [ 'street_address' => NULL, 'city' => NULL, 'postal_code' => NULL, - 'state_province_id' => array( + 'state_province_id' => [ 'title' => ts('State/Province'), - ), - 'country_id' => array( + ], + 'country_id' => [ 'title' => ts('Country'), 'default' => TRUE, - ), - ), + ], + ], 'grouping' => 'contact-fields', - ), - 'civicrm_phone' => array( + ], + 'civicrm_phone' => [ 'dao' => 'CRM_Core_DAO_Phone', 'alias' => 'phone', - 'fields' => array('phone' => NULL), + 'fields' => ['phone' => NULL], 'grouping' => 'contact-fields', - ), - 'civicrm_email' => array( + ], + 'civicrm_email' => [ 'dao' => 'CRM_Core_DAO_Email', - 'fields' => array('email' => NULL), + 'fields' => ['email' => NULL], 'grouping' => 'contact-fields', - ), - ); + ], + ]; // If we have campaigns enabled, add those elements to both the fields, filters. $this->addCampaignFields('civicrm_membership'); @@ -180,8 +180,8 @@ public function preProcess() { } public function select() { - $select = array(); - $this->_columnHeaders = array(); + $select = []; + $this->_columnHeaders = []; foreach ($this->_columns as $tableName => $table) { if (array_key_exists('fields', $table)) { foreach ($table['fields'] as $fieldName => $field) { @@ -206,7 +206,7 @@ public function select() { * @return array */ public static function formRule($fields, $files, $self) { - $errors = $grouping = array(); + $errors = $grouping = []; //check for searching combination of dispaly columns and //grouping criteria @@ -232,7 +232,7 @@ public function from() { } public function where() { - $clauses = array(); + $clauses = []; foreach ($this->_columns as $tableName => $table) { if (array_key_exists('filters', $table)) { foreach ($table['filters'] as $fieldName => $field) { @@ -296,10 +296,10 @@ public function postProcess() { $sql = $this->buildQuery(TRUE); $dao = CRM_Core_DAO::executeQuery($sql); - $rows = $graphRows = array(); + $rows = $graphRows = []; $count = 0; while ($dao->fetch()) { - $row = array(); + $row = []; foreach ($this->_columnHeaders as $key => $value) { $row[$key] = $dao->$key; } @@ -325,7 +325,7 @@ public function postProcess() { */ public function alterDisplay(&$rows) { $entryFound = FALSE; - $checkList = array(); + $checkList = []; foreach ($rows as $rowNum => $row) { diff --git a/CRM/Report/Form/Member/Summary.php b/CRM/Report/Form/Member/Summary.php index cb61d3baa711..9ad2a41fb3cd 100644 --- a/CRM/Report/Form/Member/Summary.php +++ b/CRM/Report/Form/Member/Summary.php @@ -34,16 +34,16 @@ class CRM_Report_Form_Member_Summary extends CRM_Report_Form { protected $_summary = NULL; protected $_interval = NULL; - protected $_charts = array( + protected $_charts = [ '' => 'Tabular', 'barChart' => 'Bar Chart', 'pieChart' => 'Pie Chart', - ); + ]; protected $_add2groupSupported = FALSE; - protected $_customGroupExtends = array('Membership'); + protected $_customGroupExtends = ['Membership']; protected $_customGroupGroupBy = FALSE; - public $_drilldownReport = array('member/detail' => 'Link to Detail Report'); + public $_drilldownReport = ['member/detail' => 'Link to Detail Report']; /** * This report has not been optimised for group filtering. @@ -62,115 +62,115 @@ class CRM_Report_Form_Member_Summary extends CRM_Report_Form { * Class constructor. */ public function __construct() { - $this->_columns = array( - 'civicrm_membership' => array( + $this->_columns = [ + 'civicrm_membership' => [ 'dao' => 'CRM_Member_DAO_MembershipType', 'grouping' => 'member-fields', - 'fields' => array( - 'membership_type_id' => array( + 'fields' => [ + 'membership_type_id' => [ 'title' => ts('Membership Type'), 'required' => TRUE, - ), - ), - 'filters' => array( - 'join_date' => array( + ], + ], + 'filters' => [ + 'join_date' => [ 'title' => ts('Member Since'), 'type' => CRM_Utils_Type::T_DATE, 'operatorType' => CRM_Report_Form::OP_DATE, - ), - 'membership_start_date' => array( + ], + 'membership_start_date' => [ 'name' => 'start_date', 'title' => ts('Membership Start Date'), 'type' => CRM_Utils_Type::T_DATE, 'operatorType' => CRM_Report_Form::OP_DATE, - ), - 'membership_end_date' => array( + ], + 'membership_end_date' => [ 'name' => 'end_date', 'title' => ts('Membership End Date'), 'type' => CRM_Utils_Type::T_DATE, 'operatorType' => CRM_Report_Form::OP_DATE, - ), - 'owner_membership_id' => array( + ], + 'owner_membership_id' => [ 'title' => ts('Membership Owner ID'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_INT, - ), - 'membership_type_id' => array( + ], + 'membership_type_id' => [ 'title' => ts('Membership Type'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Member_PseudoConstant::membershipType(), - ), - 'status_id' => array( + ], + 'status_id' => [ 'title' => ts('Membership Status'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Member_PseudoConstant::membershipStatus(NULL, NULL, 'label'), - ), - ), - 'group_bys' => array( - 'join_date' => array( + ], + ], + 'group_bys' => [ + 'join_date' => [ 'title' => ts('Member Since'), 'default' => TRUE, 'frequency' => TRUE, 'chart' => TRUE, 'type' => 12, - ), - 'membership_type_id' => array( + ], + 'membership_type_id' => [ 'title' => ts('Membership Type'), 'default' => TRUE, 'chart' => TRUE, - ), - ), - ), - 'civicrm_contact' => array( + ], + ], + ], + 'civicrm_contact' => [ 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => array( - 'contact_id' => array( + 'fields' => [ + 'contact_id' => [ 'no_display' => TRUE, - ), - 'contact_type' => array( + ], + 'contact_type' => [ 'title' => ts('Contact Type'), - ), - 'contact_sub_type' => array( + ], + 'contact_sub_type' => [ 'title' => ts('Contact Subtype'), - ), - ), - ), - 'civicrm_contribution' => array( + ], + ], + ], + 'civicrm_contribution' => [ 'dao' => 'CRM_Contribute_DAO_Contribution', - 'fields' => array( - 'currency' => array( + 'fields' => [ + 'currency' => [ 'required' => TRUE, 'no_display' => TRUE, - ), - 'total_amount' => array( + ], + 'total_amount' => [ 'title' => ts('Amount Statistics'), 'default' => TRUE, - 'statistics' => array( + 'statistics' => [ 'sum' => ts('Total Payments Made'), 'count' => ts('Contribution Count'), 'avg' => ts('Average'), - ), - ), - ), - 'filters' => array( - 'currency' => array( + ], + ], + ], + 'filters' => [ + 'currency' => [ 'title' => ts('Currency'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_OptionGroup::values('currencies_enabled'), 'default' => NULL, 'type' => CRM_Utils_Type::T_STRING, - ), - 'contribution_status_id' => array( + ], + 'contribution_status_id' => [ 'title' => ts('Contribution Status'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::contributionStatus(), - ), - ), + ], + ], 'grouping' => 'member-fields', - ), - ); + ], + ]; $this->_tagFilter = TRUE; // If we have campaigns enabled, add those elements to both the fields, filters and group by @@ -182,15 +182,15 @@ public function __construct() { } public function select() { - $select = array(); + $select = []; $groupBys = FALSE; - $this->_columnHeaders = array(); + $this->_columnHeaders = []; $select[] = " COUNT( DISTINCT {$this->_aliases['civicrm_membership']}.id ) as civicrm_membership_member_count"; $select['joinDate'] = " {$this->_aliases['civicrm_membership']}.join_date as civicrm_membership_member_join_date"; - $this->_columnHeaders["civicrm_membership_member_join_date"] = array( + $this->_columnHeaders["civicrm_membership_member_join_date"] = [ 'title' => ts('Member Since'), 'type' => CRM_Utils_Type::T_DATE, - ); + ]; foreach ($this->_columns as $tableName => $table) { if (array_key_exists('group_bys', $table)) { foreach ($table['group_bys'] as $fieldName => $field) { @@ -235,8 +235,8 @@ public function select() { // just to make sure these values are transferred to rows. // since we need that for calculation purpose, // e.g making subtotals look nicer or graphs - $this->_columnHeaders["{$tableName}_{$fieldName}_interval"] = array('no_display' => TRUE); - $this->_columnHeaders["{$tableName}_{$fieldName}_subtotal"] = array('no_display' => TRUE); + $this->_columnHeaders["{$tableName}_{$fieldName}_interval"] = ['no_display' => TRUE]; + $this->_columnHeaders["{$tableName}_{$fieldName}_subtotal"] = ['no_display' => TRUE]; } $groupBys = TRUE; } @@ -298,10 +298,10 @@ public function select() { } } } - $this->_columnHeaders["civicrm_membership_member_count"] = array( + $this->_columnHeaders["civicrm_membership_member_count"] = [ 'title' => ts('Member Count'), 'type' => CRM_Utils_Type::T_INT, - ); + ]; } //If grouping is availabled then remove join date from field if ($groupBys) { @@ -350,7 +350,7 @@ public function groupBy() { $append = "YEAR({$field['dbAlias']})"; if (in_array(strtolower($this->_params['group_bys_freq'][$fieldName]), - array('year') + ['year'] )) { $append = ''; } @@ -397,7 +397,7 @@ public function statistics(&$rows) { $dao = CRM_Core_DAO::executeQuery($sql); - $totalAmount = $average = array(); + $totalAmount = $average = []; $count = $memberCount = 0; while ($dao->fetch()) { $totalAmount[] = CRM_Utils_Money::format($dao->amount, $dao->currency) . "(" . $dao->count . ")"; @@ -405,24 +405,24 @@ public function statistics(&$rows) { $count += $dao->count; $memberCount += $dao->memberCount; } - $statistics['counts']['amount'] = array( + $statistics['counts']['amount'] = [ 'title' => ts('Total Amount'), 'value' => implode(', ', $totalAmount), 'type' => CRM_Utils_Type::T_STRING, - ); - $statistics['counts']['count'] = array( + ]; + $statistics['counts']['count'] = [ 'title' => ts('Total Contributions'), 'value' => $count, - ); - $statistics['counts']['memberCount'] = array( + ]; + $statistics['counts']['memberCount'] = [ 'title' => ts('Total Members'), 'value' => $memberCount, - ); - $statistics['counts']['avg'] = array( + ]; + $statistics['counts']['avg'] = [ 'title' => ts('Average'), 'value' => implode(', ', $average), 'type' => CRM_Utils_Type::T_STRING, - ); + ]; if (!(int) $statistics['counts']['amount']['value']) { //if total amount is zero then hide Chart Options @@ -440,7 +440,7 @@ public function postProcess() { * @param $rows */ public function buildChart(&$rows) { - $graphRows = array(); + $graphRows = []; $count = 0; $membershipTypeValues = CRM_Member_PseudoConstant::membershipType(); $isMembershipType = CRM_Utils_Array::value('membership_type_id', $this->_params['group_bys']); @@ -500,11 +500,11 @@ public function buildChart(&$rows) { // build chart. if ($isMembershipType) { $graphRows['value'] = $display; - $chartInfo = array( + $chartInfo = [ 'legend' => ts('Membership Summary'), 'xname' => ts('Member Since / Member Type'), 'yname' => ts('Fees'), - ); + ]; CRM_Utils_OpenFlashChart::reportChart($graphRows, $this->_params['charts'], $interval, $chartInfo); } else { @@ -535,7 +535,7 @@ public function alterDisplay(&$rows) { $dateStart = CRM_Utils_Date::customFormat($row['civicrm_membership_join_date_start'], '%Y%m%d'); $endDate = new DateTime($dateStart); - $dateEnd = array(); + $dateEnd = []; list($dateEnd['Y'], $dateEnd['M'], $dateEnd['d']) = explode(':', $endDate->format('Y:m:d')); diff --git a/CRM/Report/Form/Membership/Summary.php b/CRM/Report/Form/Membership/Summary.php index 96f8cc4b6530..34c3a77e3b91 100644 --- a/CRM/Report/Form/Membership/Summary.php +++ b/CRM/Report/Form/Membership/Summary.php @@ -34,11 +34,11 @@ class CRM_Report_Form_Membership_Summary extends CRM_Report_Form { protected $_summary = NULL; - protected $_charts = array( + protected $_charts = [ '' => 'Tabular', 'barChart' => 'Bar Chart', 'pieChart' => 'Pie Chart', - ); + ]; /** * Constructor function. @@ -46,93 +46,93 @@ class CRM_Report_Form_Membership_Summary extends CRM_Report_Form { public function __construct() { // UI for selecting columns to appear in the report list // array containing the columns, group_bys and filters build and provided to Form - $this->_columns = array( - 'civicrm_contact' => array( + $this->_columns = [ + 'civicrm_contact' => [ 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => array( - 'sort_name' => array( + 'fields' => [ + 'sort_name' => [ 'title' => ts('Member Name'), 'no_repeat' => TRUE, 'required' => TRUE, - ), - 'id' => array( + ], + 'id' => [ 'no_display' => TRUE, 'required' => TRUE, - ), - ), - 'group_bys' => array( - 'id' => array('title' => ts('Contact ID')), - 'display_name' => array( + ], + ], + 'group_bys' => [ + 'id' => ['title' => ts('Contact ID')], + 'display_name' => [ 'title' => ts('Contact Name'), - ), - ), + ], + ], 'grouping' => 'contact-fields', - ), - 'civicrm_membership_type' => array( + ], + 'civicrm_membership_type' => [ 'dao' => 'CRM_Member_DAO_MembershipType', 'grouping' => 'member-fields', - 'filters' => array( - 'gid' => array( + 'filters' => [ + 'gid' => [ 'name' => 'id', 'title' => ts('Membership Types'), 'type' => CRM_Utils_Type::T_INT + CRM_Utils_Type::T_ENUM, 'options' => CRM_Member_PseudoConstant::membershipType(), - ), - ), - ), - 'civicrm_membership' => array( + ], + ], + ], + 'civicrm_membership' => [ 'dao' => 'CRM_Member_DAO_Membership', 'grouping' => 'member-fields', - 'fields' => array( - 'membership_type_id' => array( + 'fields' => [ + 'membership_type_id' => [ 'title' => ts('Membership Type'), 'required' => TRUE, - ), + ], 'join_date' => NULL, - 'start_date' => array( + 'start_date' => [ 'title' => ts('Current Cycle Start Date'), - ), - 'end_date' => array( + ], + 'end_date' => [ 'title' => ts('Current Cycle End Date'), - ), - ), - 'group_bys' => array( - 'membership_type_id' => array('title' => ts('Membership Type')), - ), - 'filters' => array( - 'join_date' => array('type' => CRM_Utils_Type::T_DATE), - ), - ), - 'civicrm_address' => array( + ], + ], + 'group_bys' => [ + 'membership_type_id' => ['title' => ts('Membership Type')], + ], + 'filters' => [ + 'join_date' => ['type' => CRM_Utils_Type::T_DATE], + ], + ], + 'civicrm_address' => [ 'dao' => 'CRM_Core_DAO_Address', - 'fields' => array( + 'fields' => [ 'street_address' => NULL, 'city' => NULL, 'postal_code' => NULL, - 'state_province_id' => array( + 'state_province_id' => [ 'title' => ts('State/Province'), - ), - 'country_id' => array( + ], + 'country_id' => [ 'title' => ts('Country'), 'default' => TRUE, - ), - ), + ], + ], 'grouping' => 'contact-fields', - ), - 'civicrm_email' => array( + ], + 'civicrm_email' => [ 'dao' => 'CRM_Core_DAO_Email', - 'fields' => array('email' => NULL), + 'fields' => ['email' => NULL], 'grouping' => 'contact-fields', - ), - 'civicrm_contribution' => array( + ], + 'civicrm_contribution' => [ 'dao' => 'CRM_Contribute_DAO_Contribution', - 'filters' => array( - 'total_amount' => array( + 'filters' => [ + 'total_amount' => [ 'title' => ts('Contribution Amount'), - ), - ), - ), - ); + ], + ], + ], + ]; parent::__construct(); } @@ -149,8 +149,8 @@ public function preProcess() { */ public function select() { // @todo remove this in favour of just using parent. - $select = array(); - $this->_columnHeaders = array(); + $select = []; + $this->_columnHeaders = []; foreach ($this->_columns as $tableName => $table) { if (array_key_exists('fields', $table)) { foreach ($table['fields'] as $fieldName => $field) { @@ -192,7 +192,7 @@ public function from() { * @todo this looks like it duplicates the parent & could go. */ public function where() { - $clauses = array(); + $clauses = []; foreach ($this->_columns as $tableName => $table) { if (array_key_exists('filters', $table)) { foreach ($table['filters'] as $fieldName => $field) { @@ -241,11 +241,11 @@ public function where() { * @return array */ public function statistics(&$rows) { - $statistics = array(); - $statistics[] = array( + $statistics = []; + $statistics[] = [ 'title' => ts('Row(s) Listed'), 'value' => count($rows), - ); + ]; return $statistics; } @@ -307,10 +307,10 @@ public function postProcess() { $sql = "{$this->_select} {$this->_from} {$this->_where} {$this->_groupBy}"; $dao = CRM_Core_DAO::executeQuery($sql); - $rows = $graphRows = array(); + $rows = $graphRows = []; $count = 0; while ($dao->fetch()) { - $row = array(); + $row = []; foreach ($this->_columnHeaders as $key => $value) { $row[$key] = $dao->$key; } @@ -333,11 +333,11 @@ public function postProcess() { $this->assign('statistics', $this->statistics($rows)); if (!empty($this->_params['charts'])) { - foreach (array( + foreach ([ 'receive_date', $this->_interval, 'value', - ) as $ignore) { + ] as $ignore) { unset($graphRows[$ignore][$count - 1]); } @@ -358,7 +358,7 @@ public function postProcess() { */ public function alterDisplay(&$rows) { $entryFound = FALSE; - $checkList = array(); + $checkList = []; foreach ($rows as $rowNum => $row) { diff --git a/CRM/Report/Form/Pledge/Detail.php b/CRM/Report/Form/Pledge/Detail.php index a9cba5fc4e67..b29c729bad9d 100644 --- a/CRM/Report/Form/Pledge/Detail.php +++ b/CRM/Report/Form/Pledge/Detail.php @@ -45,11 +45,11 @@ class CRM_Report_Form_Pledge_Detail extends CRM_Report_Form { protected $_summary = NULL; protected $_totalPaid = FALSE; - protected $_pledgeStatuses = array(); - protected $_customGroupExtends = array( + protected $_pledgeStatuses = []; + protected $_customGroupExtends = [ 'Pledge', 'Individual', - ); + ]; /** * This report has not been optimised for group filtering. @@ -72,123 +72,123 @@ public function __construct() { FALSE, FALSE, FALSE, NULL, 'label' ); - $this->_columns = array( - 'civicrm_contact' => array( + $this->_columns = [ + 'civicrm_contact' => [ 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => array( - 'sort_name' => array( + 'fields' => [ + 'sort_name' => [ 'title' => ts('Contact Name'), 'required' => TRUE, 'no_repeat' => TRUE, - ), - ), - 'filters' => array( - 'sort_name' => array('title' => ts('Contact Name')), - 'id' => array('no_display' => TRUE), - ), + ], + ], + 'filters' => [ + 'sort_name' => ['title' => ts('Contact Name')], + 'id' => ['no_display' => TRUE], + ], 'grouping' => 'contact-fields', - ), - 'civicrm_email' => array( + ], + 'civicrm_email' => [ 'dao' => 'CRM_Core_DAO_Email', - 'fields' => array( - 'email' => array('no_repeat' => TRUE), - ), + 'fields' => [ + 'email' => ['no_repeat' => TRUE], + ], 'grouping' => 'contact-fields', - ), - 'civicrm_pledge' => array( + ], + 'civicrm_pledge' => [ 'dao' => 'CRM_Pledge_DAO_Pledge', - 'fields' => array( - 'id' => array( + 'fields' => [ + 'id' => [ 'no_display' => TRUE, 'required' => TRUE, - ), - 'contact_id' => array( + ], + 'contact_id' => [ 'no_display' => TRUE, 'required' => TRUE, - ), - 'financial_type_id' => array( + ], + 'financial_type_id' => [ 'title' => ts('Financial Type'), - ), - 'amount' => array( + ], + 'amount' => [ 'title' => ts('Pledge Amount'), 'required' => TRUE, 'type' => CRM_Utils_Type::T_MONEY, - ), - 'currency' => array( + ], + 'currency' => [ 'required' => TRUE, 'no_display' => TRUE, - ), - 'frequency_unit' => array( + ], + 'frequency_unit' => [ 'title' => ts('Frequency Unit'), - ), - 'installments' => array( + ], + 'installments' => [ 'title' => ts('Installments'), - ), - 'pledge_create_date' => array( + ], + 'pledge_create_date' => [ 'title' => ts('Pledge Made Date'), - ), - 'start_date' => array( + ], + 'start_date' => [ 'title' => ts('Pledge Start Date'), 'type' => CRM_Utils_Type::T_DATE, - ), - 'end_date' => array( + ], + 'end_date' => [ 'title' => ts('Pledge End Date'), 'type' => CRM_Utils_Type::T_DATE, - ), - 'status_id' => array( + ], + 'status_id' => [ 'title' => ts('Pledge Status'), 'required' => TRUE, - ), - ), - 'filters' => array( - 'pledge_create_date' => array( + ], + ], + 'filters' => [ + 'pledge_create_date' => [ 'title' => ts('Pledge Made Date'), 'operatorType' => CRM_Report_Form::OP_DATE, - ), - 'pledge_amount' => array( + ], + 'pledge_amount' => [ 'title' => ts('Pledged Amount'), 'operatorType' => CRM_Report_Form::OP_INT, - ), - 'currency' => array( + ], + 'currency' => [ 'title' => ts('Currency'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_OptionGroup::values('currencies_enabled'), 'default' => NULL, 'type' => CRM_Utils_Type::T_STRING, - ), - 'sid' => array( + ], + 'sid' => [ 'name' => 'status_id', 'title' => ts('Pledge Status'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_OptionGroup::values('pledge_status'), - ), - 'financial_type_id' => array( + ], + 'financial_type_id' => [ 'title' => ts('Financial Type'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::financialType(), - ), + ], - ), - ), - 'civicrm_pledge_payment' => array( + ], + ], + 'civicrm_pledge_payment' => [ 'dao' => 'CRM_Pledge_DAO_PledgePayment', - 'fields' => array( - 'total_paid' => array( + 'fields' => [ + 'total_paid' => [ 'title' => ts('Total Amount Paid'), 'type' => CRM_Utils_Type::T_MONEY, - ), - 'balance_due' => array( + ], + 'balance_due' => [ 'title' => ts('Balance Due'), 'default' => TRUE, 'type' => CRM_Utils_Type::T_MONEY, - ), - ), - ), - ); + ], + ], + ], + ]; - $this->_columns += $this->getAddressColumns(array('group_by' => FALSE)) + $this->getPhoneColumns(); + $this->_columns += $this->getAddressColumns(['group_by' => FALSE]) + $this->getPhoneColumns(); // If we have a campaign, build out the relevant elements $this->addCampaignFields('civicrm_pledge', TRUE); @@ -220,10 +220,10 @@ public function select() { public function selectClause(&$tableName, $tableKey, &$fieldName, &$field) { if ($fieldName == 'total_paid') { $this->_totalPaid = TRUE; // add pledge_payment join - $this->_columnHeaders["{$tableName}_{$fieldName}"] = array( + $this->_columnHeaders["{$tableName}_{$fieldName}"] = [ 'title' => $field['title'], 'type' => $field['type'], - ); + ]; return "COALESCE(sum({$this->_aliases[$tableName]}.actual_amount), 0) as {$tableName}_{$fieldName}"; } if ($fieldName == 'balance_due') { @@ -231,10 +231,10 @@ public function selectClause(&$tableName, $tableKey, &$fieldName, &$field) { $completedStatus = array_search('Completed', $this->_pledgeStatuses); $this->_totalPaid = TRUE; // add pledge_payment join $this->_columnHeaders["{$tableName}_{$fieldName}"] = $field['title']; - $this->_columnHeaders["{$tableName}_{$fieldName}"] = array( + $this->_columnHeaders["{$tableName}_{$fieldName}"] = [ 'title' => $field['title'], 'type' => $field['type'], - ); + ]; return "IF({$this->_aliases['civicrm_pledge']}.status_id IN({$cancelledStatus}, $completedStatus), 0, COALESCE({$this->_aliases['civicrm_pledge']}.amount, 0) - COALESCE(sum({$this->_aliases[$tableName]}.actual_amount),0)) as {$tableName}_{$fieldName}"; } return FALSE; @@ -243,7 +243,7 @@ public function selectClause(&$tableName, $tableKey, &$fieldName, &$field) { public function groupBy() { parent::groupBy(); if (empty($this->_groupBy) && $this->_totalPaid) { - $groupBy = array("{$this->_aliases['civicrm_pledge']}.id", "{$this->_aliases['civicrm_pledge']}.currency"); + $groupBy = ["{$this->_aliases['civicrm_pledge']}.id", "{$this->_aliases['civicrm_pledge']}.currency"]; $this->_groupBy = CRM_Contact_BAO_Query::getGroupByFromSelectColumns($this->_selectClauses, $groupBy); } } @@ -282,7 +282,7 @@ public function statistics(&$rows) { $this->from(); $this->customDataFrom(); if (!$this->_having) { - $totalAmount = $average = array(); + $totalAmount = $average = []; $count = 0; $select = " SELECT COUNT({$this->_aliases['civicrm_pledge']}.amount ) as count, @@ -301,29 +301,29 @@ public function statistics(&$rows) { $average = CRM_Utils_Money::format($dao->avg, $dao->currency); $count = $dao->count; $totalCount .= $count; - $statistics['counts']['amount' . $index] = array( + $statistics['counts']['amount' . $index] = [ 'title' => ts('Total Pledged') . ' (' . $dao->currency . ')', 'value' => $totalAmount, 'type' => CRM_Utils_Type::T_STRING, - ); - $statistics['counts']['avg' . $index] = array( + ]; + $statistics['counts']['avg' . $index] = [ 'title' => ts('Average') . ' (' . $dao->currency . ')', 'value' => $average, 'type' => CRM_Utils_Type::T_STRING, - ); - $statistics['counts']['count' . $index] = array( + ]; + $statistics['counts']['count' . $index] = [ 'title' => ts('Total No Pledges') . ' (' . $dao->currency . ')', 'value' => $count, 'type' => CRM_Utils_Type::T_INT, - ); + ]; $index++; } if ($totalCount > $count) { - $statistics['counts']['count' . $index] = array( + $statistics['counts']['count' . $index] = [ 'title' => ts('Total No Pledges'), 'value' => $totalCount, 'type' => CRM_Utils_Type::T_INT, - ); + ]; } } // reset from clause @@ -339,7 +339,7 @@ public function orderBy() { } public function where() { - $clauses = array(); + $clauses = []; foreach ($this->_columns as $tableName => $table) { if (array_key_exists('filters', $table)) { foreach ($table['filters'] as $fieldName => $field) { @@ -397,7 +397,7 @@ public function postProcess() { // get the acl clauses built before we assemble the query $this->buildACLClause($this->_aliases['civicrm_contact']); $sql = $this->buildQuery(); - $rows = $payment = array(); + $rows = $payment = []; $dao = CRM_Core_DAO::executeQuery($sql); @@ -408,7 +408,7 @@ public function postProcess() { while ($dao->fetch()) { $pledgeID = $dao->civicrm_pledge_id; foreach ($this->_columnHeaders as $columnHeadersKey => $columnHeadersValue) { - $row = array(); + $row = []; if (property_exists($dao, $columnHeadersKey)) { $display[$pledgeID][$columnHeadersKey] = $dao->$columnHeadersKey; } @@ -417,14 +417,14 @@ public function postProcess() { } // Add Special headers - $this->_columnHeaders['scheduled_date'] = array( + $this->_columnHeaders['scheduled_date'] = [ 'type' => CRM_Utils_Type::T_DATE, 'title' => ts('Next Payment Due'), - ); - $this->_columnHeaders['scheduled_amount'] = array( + ]; + $this->_columnHeaders['scheduled_amount'] = [ 'type' => CRM_Utils_Type::T_MONEY, 'title' => ts('Next Payment Amount'), - ); + ]; $this->_columnHeaders['status_id'] = NULL; /* @@ -433,10 +433,10 @@ public function postProcess() { * (arguably the pledge amount should be moved to after these fields too) * */ - $tableHeaders = array( + $tableHeaders = [ 'civicrm_pledge_payment_total_paid', 'civicrm_pledge_payment_balance_due', - ); + ]; foreach ($tableHeaders as $header) { //per above, unset & reset them so they move to the end @@ -482,7 +482,7 @@ public function postProcess() { // Displaying entire data on the form if (!empty($display)) { foreach ($display as $key => $value) { - $row = array(); + $row = []; foreach ($this->_columnHeaders as $columnKey => $columnValue) { if (array_key_exists($columnKey, $value)) { $row[$columnKey] = !empty($value[$columnKey]) ? $value[$columnKey] : ''; @@ -512,7 +512,7 @@ public function postProcess() { */ public function alterDisplay(&$rows) { $entryFound = FALSE; - $checkList = array(); + $checkList = []; $display_flag = $prev_cid = $cid = 0; foreach ($rows as $rowNum => $row) { diff --git a/CRM/Report/Form/Pledge/Pbnp.php b/CRM/Report/Form/Pledge/Pbnp.php index 562b1435f3da..e796cac5fee4 100644 --- a/CRM/Report/Form/Pledge/Pbnp.php +++ b/CRM/Report/Form/Pledge/Pbnp.php @@ -31,147 +31,147 @@ * @copyright CiviCRM LLC (c) 2004-2019 */ class CRM_Report_Form_Pledge_Pbnp extends CRM_Report_Form { - protected $_charts = array( + protected $_charts = [ '' => 'Tabular', 'barChart' => 'Bar Chart', 'pieChart' => 'Pie Chart', - ); - public $_drilldownReport = array('pledge/summary' => 'Link to Detail Report'); + ]; + public $_drilldownReport = ['pledge/summary' => 'Link to Detail Report']; - protected $_customGroupExtends = array( + protected $_customGroupExtends = [ 'Pledge', - ); + ]; /** * Class constructor. */ public function __construct() { - $this->_columns = array( - 'civicrm_contact' => array( + $this->_columns = [ + 'civicrm_contact' => [ 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => array( - 'sort_name' => array( + 'fields' => [ + 'sort_name' => [ 'title' => ts('Constituent Name'), 'required' => TRUE, 'no_repeat' => TRUE, - ), - 'id' => array( + ], + 'id' => [ 'no_display' => TRUE, 'required' => TRUE, - ), - ), + ], + ], 'grouping' => 'contact-fields', - ), - 'civicrm_pledge' => array( + ], + 'civicrm_pledge' => [ 'dao' => 'CRM_Pledge_DAO_Pledge', - 'fields' => array( - 'pledge_create_date' => array( + 'fields' => [ + 'pledge_create_date' => [ 'title' => ts('Pledge Made'), 'required' => TRUE, - ), - 'financial_type_id' => array( + ], + 'financial_type_id' => [ 'title' => ts('Financial Type'), 'required' => TRUE, - ), - 'frequency_unit' => array( + ], + 'frequency_unit' => [ 'title' => ts('Frequency Unit'), - ), - 'installments' => array( + ], + 'installments' => [ 'title' => ts('Installments'), - ), - 'amount' => array( + ], + 'amount' => [ 'title' => ts('Amount'), 'required' => TRUE, 'type' => CRM_Utils_Type::T_MONEY, - ), - 'currency' => array( + ], + 'currency' => [ 'required' => TRUE, 'no_display' => TRUE, - ), - 'status_id' => array( + ], + 'status_id' => [ 'title' => ts('Status'), - ), - ), - 'filters' => array( - 'pledge_create_date' => array( + ], + ], + 'filters' => [ + 'pledge_create_date' => [ 'title' => ts('Pledge Made'), 'operatorType' => CRM_Report_Form::OP_DATE, - ), - 'pledge_amount' => array( + ], + 'pledge_amount' => [ 'title' => ts('Pledged Amount'), 'operatorType' => CRM_Report_Form::OP_INT, - ), - 'currency' => array( + ], + 'currency' => [ 'title' => ts('Currency'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_OptionGroup::values('currencies_enabled'), 'default' => NULL, 'type' => CRM_Utils_Type::T_STRING, - ), - 'financial_type_id' => array( + ], + 'financial_type_id' => [ 'title' => ts('Financial Type'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::financialType(), - ), - 'pledge_status_id' => array( + ], + 'pledge_status_id' => [ 'name' => 'status_id', 'title' => ts('Pledge Status'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_OptionGroup::values('pledge_status'), - ), - 'installments' => array( + ], + 'installments' => [ 'title' => ts('Installments'), 'type' => CRM_Utils_Type::T_INT, - ), - ), + ], + ], 'grouping' => 'pledge-fields', - ), - 'civicrm_pledge_payment' => array( + ], + 'civicrm_pledge_payment' => [ 'dao' => 'CRM_Pledge_DAO_PledgePayment', - 'fields' => array( - 'scheduled_date' => array( + 'fields' => [ + 'scheduled_date' => [ 'title' => ts('Next Payment Due'), 'type' => CRM_Utils_Type::T_DATE, 'required' => TRUE, - ), - 'scheduled_amount' => array( + ], + 'scheduled_amount' => [ 'type' => CRM_Utils_Type::T_MONEY, 'title' => ts('Next Payment Amount'), - ), - ), - 'filters' => array( - 'scheduled_date' => array( + ], + ], + 'filters' => [ + 'scheduled_date' => [ 'title' => ts('Next Payment Due'), 'operatorType' => CRM_Report_Form::OP_DATE, 'type' => CRM_Utils_Type::T_DATE, - ), - ), + ], + ], 'grouping' => 'pledge-fields', - ), - 'civicrm_address' => array( + ], + 'civicrm_address' => [ 'dao' => 'CRM_Core_DAO_Address', - 'fields' => array( + 'fields' => [ 'street_address' => NULL, 'city' => NULL, 'postal_code' => NULL, - 'state_province_id' => array( + 'state_province_id' => [ 'title' => ts('State/Province'), - ), - 'country_id' => array( + ], + 'country_id' => [ 'title' => ts('Country'), 'default' => TRUE, - ), - ), + ], + ], 'grouping' => 'contact-fields', - ), - 'civicrm_email' => array( + ], + 'civicrm_email' => [ 'dao' => 'CRM_Core_DAO_Email', - 'fields' => array('email' => NULL), + 'fields' => ['email' => NULL], 'grouping' => 'contact-fields', - ), - ); + ], + ]; // If we have a campaign, build out the relevant elements $this->addCampaignFields('civicrm_pledge'); @@ -188,8 +188,8 @@ public function preProcess() { } public function select() { - $select = array(); - $this->_columnHeaders = array(); + $select = []; + $this->_columnHeaders = []; foreach ($this->_columns as $tableName => $table) { if (array_key_exists('fields', $table)) { foreach ($table['fields'] as $fieldName => $field) { @@ -212,11 +212,11 @@ public function from() { $allStatus = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name'); $pendingStatus = array_search('Pending', $allStatus); - foreach (array( + foreach ([ 'Pending', 'In Progress', 'Overdue', - ) as $statusKey) { + ] as $statusKey) { if ($key = CRM_Utils_Array::key($statusKey, $allStatus)) { $unpaidStatus[] = $key; } @@ -243,11 +243,11 @@ public function from() { } public function groupBy() { - $groupBy = array( + $groupBy = [ "{$this->_aliases['civicrm_pledge']}.contact_id", "{$this->_aliases['civicrm_pledge']}.id", "{$this->_aliases['civicrm_pledge']}.currency", - ); + ]; $this->_groupBy = CRM_Contact_BAO_Query::getGroupByFromSelectColumns($this->_selectClauses, $groupBy); } @@ -271,7 +271,7 @@ public function postProcess() { */ public function alterDisplay(&$rows) { $entryFound = FALSE; - $checkList = array(); + $checkList = []; $display_flag = $prev_cid = $cid = 0; foreach ($rows as $rowNum => $row) { diff --git a/CRM/Report/Form/Pledge/Summary.php b/CRM/Report/Form/Pledge/Summary.php index 80495afa02ec..d8ca6b0bde27 100644 --- a/CRM/Report/Form/Pledge/Summary.php +++ b/CRM/Report/Form/Pledge/Summary.php @@ -36,7 +36,7 @@ class CRM_Report_Form_Pledge_Summary extends CRM_Report_Form { protected $_summary = NULL; protected $_totalPaid = FALSE; - protected $_customGroupExtends = array('Pledge', 'Individual'); + protected $_customGroupExtends = ['Pledge', 'Individual']; protected $_customGroupGroupBy = TRUE; /** @@ -56,141 +56,141 @@ class CRM_Report_Form_Pledge_Summary extends CRM_Report_Form { * Class constructor. */ public function __construct() { - $this->_columns = array( - 'civicrm_contact' => array( + $this->_columns = [ + 'civicrm_contact' => [ 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => array( - 'sort_name' => array( + 'fields' => [ + 'sort_name' => [ 'title' => ts('Contact Name'), 'no_repeat' => TRUE, - ), - 'postal_greeting_display' => array('title' => ts('Postal Greeting')), - 'id' => array( + ], + 'postal_greeting_display' => ['title' => ts('Postal Greeting')], + 'id' => [ 'no_display' => TRUE, 'required' => TRUE, - ), - ), + ], + ], 'grouping' => 'contact-fields', - 'group_bys' => array( - 'id' => array('title' => ts('Contact ID')), - 'sort_name' => array( + 'group_bys' => [ + 'id' => ['title' => ts('Contact ID')], + 'sort_name' => [ 'title' => ts('Contact Name'), - ), - ), - ), - 'civicrm_email' => array( + ], + ], + ], + 'civicrm_email' => [ 'dao' => 'CRM_Core_DAO_Email', - 'fields' => array( - 'email' => array( + 'fields' => [ + 'email' => [ 'no_repeat' => TRUE, 'title' => ts('email'), - ), - ), + ], + ], 'grouping' => 'contact-fields', - ), - 'civicrm_pledge' => array( + ], + 'civicrm_pledge' => [ 'dao' => 'CRM_Pledge_DAO_Pledge', - 'fields' => array( - 'id' => array( + 'fields' => [ + 'id' => [ 'no_display' => TRUE, 'required' => FALSE, - ), - 'financial_type_id' => array( + ], + 'financial_type_id' => [ 'title' => ts('Financial Type'), - ), - 'currency' => array( + ], + 'currency' => [ 'required' => TRUE, 'no_display' => TRUE, - ), - 'amount' => array( + ], + 'amount' => [ 'title' => ts('Pledge Amount'), 'required' => TRUE, 'type' => CRM_Utils_Type::T_MONEY, - 'statistics' => array( + 'statistics' => [ 'sum' => ts('Aggregate Amount Pledged'), 'count' => ts('Pledges'), 'avg' => ts('Average'), - ), - ), - 'frequency_unit' => array( + ], + ], + 'frequency_unit' => [ 'title' => ts('Frequency Unit'), - ), - 'installments' => array( + ], + 'installments' => [ 'title' => ts('Installments'), - ), - 'pledge_create_date' => array( + ], + 'pledge_create_date' => [ 'title' => ts('Pledge Made Date'), - ), - 'start_date' => array( + ], + 'start_date' => [ 'title' => ts('Pledge Start Date'), 'type' => CRM_Utils_Type::T_DATE, - ), - 'end_date' => array( + ], + 'end_date' => [ 'title' => ts('Pledge End Date'), 'type' => CRM_Utils_Type::T_DATE, - ), - 'status_id' => array( + ], + 'status_id' => [ 'title' => ts('Pledge Status'), - ), - ), - 'filters' => array( - 'pledge_create_date' => array( + ], + ], + 'filters' => [ + 'pledge_create_date' => [ 'title' => ts('Pledge Made Date'), 'operatorType' => CRM_Report_Form::OP_DATE, - ), - 'pledge_amount' => array( + ], + 'pledge_amount' => [ 'title' => ts('Pledged Amount'), 'operatorType' => CRM_Report_Form::OP_INT, - ), - 'currency' => array( + ], + 'currency' => [ 'title' => ts('Currency'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_OptionGroup::values('currencies_enabled'), 'default' => NULL, 'type' => CRM_Utils_Type::T_STRING, - ), - 'sid' => array( + ], + 'sid' => [ 'name' => 'status_id', 'title' => ts('Pledge Status'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_OptionGroup::values('pledge_status'), - ), - 'financial_type_id' => array( + ], + 'financial_type_id' => [ 'title' => ts('Financial Type'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Contribute_PseudoConstant::financialType(), - ), - ), - 'group_bys' => array( - 'pledge_create_date' => array( + ], + ], + 'group_bys' => [ + 'pledge_create_date' => [ 'frequency' => TRUE, 'default' => TRUE, 'chart' => TRUE, - ), - 'frequency_unit' => array( + ], + 'frequency_unit' => [ 'title' => ts('Frequency Unit'), - ), - 'status_id' => array( + ], + 'status_id' => [ 'title' => ts('Pledge Status'), - ), - 'financial_type_id' => array( + ], + 'financial_type_id' => [ 'title' => ts('Financial Type'), - ), - ), - ), - 'civicrm_pledge_payment' => array( + ], + ], + ], + 'civicrm_pledge_payment' => [ 'dao' => 'CRM_Pledge_DAO_PledgePayment', - 'fields' => array( - 'total_paid' => array( + 'fields' => [ + 'total_paid' => [ 'title' => ts('Total Amount Paid'), 'type' => CRM_Utils_Type::T_STRING, 'dbAlias' => 'sum(pledge_payment_civireport.actual_amount)', - ), - ), - ), - ) + $this->addAddressFields(); + ], + ], + ], + ] + $this->addAddressFields(); $this->_groupFilter = TRUE; $this->_tagFilter = TRUE; @@ -247,7 +247,7 @@ public function groupBy() { $append = "YEAR({$field['dbAlias']}),"; if (in_array(strtolower($this->_params['group_bys_freq'][$fieldName]), - array('year') + ['year'] )) { $append = ''; } @@ -299,27 +299,27 @@ public function statistics(&$rows) { $dao = CRM_Core_DAO::executeQuery($sql); if ($dao->fetch()) { - $statistics['count']['amount'] = array( + $statistics['count']['amount'] = [ 'value' => $dao->amount, 'title' => ts('Total Pledged'), 'type' => CRM_Utils_Type::T_MONEY, - ); - $statistics['count']['count '] = array( + ]; + $statistics['count']['count '] = [ 'value' => $dao->count, 'title' => ts('Total No Pledges'), - ); - $statistics['count']['avg '] = array( + ]; + $statistics['count']['avg '] = [ 'value' => $dao->avg, 'title' => ts('Average'), 'type' => CRM_Utils_Type::T_MONEY, - ); + ]; } } return $statistics; } public function where() { - $clauses = array(); + $clauses = []; foreach ($this->_columns as $tableName => $table) { if (array_key_exists('filters', $table)) { foreach ($table['filters'] as $fieldName => $field) { @@ -385,7 +385,7 @@ public function postProcess() { */ public function alterDisplay(&$rows) { $entryFound = FALSE; - $checkList = array(); + $checkList = []; $display_flag = $prev_cid = $cid = 0; foreach ($rows as $rowNum => $row) { diff --git a/CRM/Report/Form/Register.php b/CRM/Report/Form/Register.php index b926f290e292..c99ac77738c8 100644 --- a/CRM/Report/Form/Register.php +++ b/CRM/Report/Form/Register.php @@ -50,7 +50,7 @@ public function preProcess() { 'report_template', 'id', 'name' ); - $instanceInfo = array(); + $instanceInfo = []; } /** @@ -63,18 +63,18 @@ public function preProcess() { * reference to the array of default values */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; if ($this->_action & CRM_Core_Action::DELETE) { return $defaults; } if ($this->_id) { - $params = array('id' => $this->_id); - $defaults = array(); + $params = ['id' => $this->_id]; + $defaults = []; CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_OptionValue', $params, $defaults); } else { $defaults['weight'] = CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_OptionValue', - array('option_group_id' => $this->_opID) + ['option_group_id' => $this->_opID] ); } return $defaults; @@ -82,55 +82,55 @@ public function setDefaultValues() { public function buildQuickForm() { if ($this->_action & CRM_Core_Action::DELETE) { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => ts('Delete'), 'spacing' => '         ', 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); return; } - $this->add('text', 'label', ts('Title'), array('size' => 40), TRUE); - $this->add('text', 'value', ts('URL'), array('size' => 40), TRUE); - $this->add('text', 'name', ts('Class'), array('size' => 40), TRUE); - $element = $this->add('number', 'weight', ts('Order'), array('size' => 4), TRUE); + $this->add('text', 'label', ts('Title'), ['size' => 40], TRUE); + $this->add('text', 'value', ts('URL'), ['size' => 40], TRUE); + $this->add('text', 'name', ts('Class'), ['size' => 40], TRUE); + $element = $this->add('number', 'weight', ts('Order'), ['size' => 4], TRUE); // $element->freeze( ); - $this->add('text', 'description', ts('Description'), array('size' => 40), TRUE); + $this->add('text', 'description', ts('Description'), ['size' => 40], TRUE); $this->add('checkbox', 'is_active', ts('Enabled?')); $this->_components = CRM_Core_Component::getComponents(); //unset the report component unset($this->_components['CiviReport']); - $components = array(); + $components = []; foreach ($this->_components as $name => $object) { $components[$object->componentID] = $object->info['translatedName']; } - $this->add('select', 'component_id', ts('Component'), array('' => ts('Contact')) + $components); + $this->add('select', 'component_id', ts('Component'), ['' => ts('Contact')] + $components); - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'upload', 'name' => ts('Save'), 'spacing' => '         ', 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); - $this->addFormRule(array('CRM_Report_Form_Register', 'formRule'), $this); + $this->addFormRule(['CRM_Report_Form_Register', 'formRule'], $this); } /** @@ -141,7 +141,7 @@ public function buildQuickForm() { * @return array */ public static function formRule($fields, $files, $self) { - $errors = array(); + $errors = []; $dupeClass = FALSE; $reportUrl = new CRM_Core_DAO_OptionValue(); $reportUrl->option_group_id = $self->_opID; @@ -179,11 +179,11 @@ public function postProcess() { if ($this->_action & CRM_Core_Action::DELETE) { if (CRM_Core_BAO_OptionValue::del($this->_id)) { - CRM_Core_Session::setStatus(ts('Selected %1 Report has been deleted.', array(1 => $this->_GName)), ts('Record Deleted'), 'success'); + CRM_Core_Session::setStatus(ts('Selected %1 Report has been deleted.', [1 => $this->_GName]), ts('Record Deleted'), 'success'); CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin/report/options/report_template', "reset=1")); } else { - CRM_Core_Session::setStatus(ts('Selected %1 type has not been deleted.', array(1 => $this->_GName)), '', 'info'); + CRM_Core_Session::setStatus(ts('Selected %1 type has not been deleted.', [1 => $this->_GName]), '', 'info'); CRM_Utils_Weight::correctDuplicateWeights('CRM_Core_DAO_OptionValue', $fieldValues); } } @@ -192,10 +192,10 @@ public function postProcess() { $params = $this->controller->exportValues($this->_name); $optionValue = CRM_Core_OptionValue::addOptionValue($params, 'report_template', $this->_action, $this->_id); - CRM_Core_Session::setStatus(ts('The %1 \'%2\' has been saved.', array( + CRM_Core_Session::setStatus(ts('The %1 \'%2\' has been saved.', [ 1 => 'Report Template', 2 => $optionValue->label, - )), ts('Saved'), 'success'); + ]), ts('Saved'), 'success'); CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin/report/options/report_template', "reset=1")); } } diff --git a/CRM/Report/Form/Walklist/Walklist.php b/CRM/Report/Form/Walklist/Walklist.php index ec527934d46b..efa89aa2b053 100644 --- a/CRM/Report/Form/Walklist/Walklist.php +++ b/CRM/Report/Form/Walklist/Walklist.php @@ -34,59 +34,59 @@ class CRM_Report_Form_Walklist_Walklist extends CRM_Report_Form { protected $_summary = NULL; - public $_drilldownReport = array('contact/detail' => 'Link to Detail Report'); + public $_drilldownReport = ['contact/detail' => 'Link to Detail Report']; - protected $_customGroupExtends = array( + protected $_customGroupExtends = [ 'Contact', 'Individual', 'Household', 'Organization', - ); + ]; /** * Class constructor. */ public function __construct() { - $this->_columns = array( - 'civicrm_contact' => array( + $this->_columns = [ + 'civicrm_contact' => [ 'dao' => 'CRM_Contact_DAO_Contact', - 'fields' => array( - 'id' => array( + 'fields' => [ + 'id' => [ 'title' => ts('Contact ID'), 'no_display' => TRUE, 'required' => TRUE, - ), - 'sort_name' => array( + ], + 'sort_name' => [ 'title' => ts('Contact Name'), 'required' => TRUE, 'no_repeat' => TRUE, - ), - ), - 'filters' => array( - 'sort_name' => array( + ], + ], + 'filters' => [ + 'sort_name' => [ 'title' => ts('Contact Name'), 'operator' => 'like', - ), - ), + ], + ], 'grouping' => 'contact-fields', - 'order_bys' => array( - 'sort_name' => array( + 'order_bys' => [ + 'sort_name' => [ 'title' => ts('Contact Name'), 'required' => TRUE, - ), - ), - ), - 'civicrm_email' => array( + ], + ], + ], + 'civicrm_email' => [ 'dao' => 'CRM_Core_DAO_Email', - 'fields' => array('email' => array('default' => TRUE)), + 'fields' => ['email' => ['default' => TRUE]], 'grouping' => 'location-fields', - ), - 'civicrm_phone' => array( + ], + 'civicrm_phone' => [ 'dao' => 'CRM_Core_DAO_Phone', - 'fields' => array('phone' => NULL), + 'fields' => ['phone' => NULL], 'grouping' => 'location-fields', - ), - ) + $this->getAddressColumns(array('group_bys' => FALSE)); + ], + ] + $this->getAddressColumns(['group_bys' => FALSE]); parent::__construct(); } @@ -96,9 +96,9 @@ public function preProcess() { public function select() { // @todo remove this function & use parent. - $select = array(); + $select = []; - $this->_columnHeaders = array(); + $this->_columnHeaders = []; foreach ($this->_columns as $tableName => $table) { foreach ($table['fields'] as $fieldName => $field) { if (!empty($field['required']) || @@ -128,7 +128,7 @@ public function from() { } public function where() { - $clauses = array(); + $clauses = []; foreach ($this->_columns as $tableName => $table) { if (array_key_exists('filters', $table)) { foreach ($table['filters'] as $fieldName => $field) { diff --git a/CRM/Report/Info.php b/CRM/Report/Info.php index 8189997c255c..5cd505292fcd 100644 --- a/CRM/Report/Info.php +++ b/CRM/Report/Info.php @@ -51,13 +51,13 @@ class CRM_Report_Info extends CRM_Core_Component_Info { * collection of required component settings */ public function getInfo() { - return array( + return [ 'name' => 'CiviReport', 'translatedName' => ts('CiviReport'), 'title' => ts('CiviCRM Report Engine'), 'search' => 0, 'showActivitiesInCore' => 1, - ); + ]; } @@ -78,36 +78,36 @@ public function getInfo() { * collection of permissions, null if none */ public function getPermissions($getAllUnconditionally = FALSE, $descriptions = FALSE) { - $permissions = array( - 'access CiviReport' => array( + $permissions = [ + 'access CiviReport' => [ ts('access CiviReport'), ts('View reports'), - ), - 'access Report Criteria' => array( + ], + 'access Report Criteria' => [ ts('access Report Criteria'), ts('Change report search criteria'), - ), - 'save Report Criteria' => array( + ], + 'save Report Criteria' => [ ts('save Report Criteria'), ts('Save report search criteria'), - ), - 'administer private reports' => array( + ], + 'administer private reports' => [ ts('administer private reports'), ts('Edit all private reports'), - ), - 'administer reserved reports' => array( + ], + 'administer reserved reports' => [ ts('administer reserved reports'), ts('Edit all reports that have been marked as reserved'), - ), - 'administer Reports' => array( + ], + 'administer Reports' => [ ts('administer Reports'), ts('Manage report templates'), - ), - 'view report sql' => array( + ], + 'view report sql' => [ ts('view report sql'), ts('View sql used in CiviReports'), - ), - ); + ], + ]; if (!$descriptions) { foreach ($permissions as $name => $attr) { diff --git a/CRM/Report/Page/Instance.php b/CRM/Report/Page/Instance.php index 89c0adb7850d..c101c06b18d5 100644 --- a/CRM/Report/Page/Instance.php +++ b/CRM/Report/Page/Instance.php @@ -73,8 +73,8 @@ public function run() { } if (strstr($templateInfo['name'], '_Form') || !is_null($reportClass)) { - $instanceInfo = array(); - CRM_Report_BAO_ReportInstance::retrieve(array('id' => $instanceId), $instanceInfo); + $instanceInfo = []; + CRM_Report_BAO_ReportInstance::retrieve(['id' => $instanceId], $instanceInfo); if (!empty($instanceInfo['title'])) { CRM_Utils_System::setTitle($instanceInfo['title']); diff --git a/CRM/Report/Page/InstanceList.php b/CRM/Report/Page/InstanceList.php index 3e5147a501ad..e623e77a5d0c 100644 --- a/CRM/Report/Page/InstanceList.php +++ b/CRM/Report/Page/InstanceList.php @@ -38,7 +38,7 @@ class CRM_Report_Page_InstanceList extends CRM_Core_Page { static $_links = NULL; - static $_exceptions = array('logging/contact/detail'); + static $_exceptions = ['logging/contact/detail']; /** * Name of component if report list is filtered. @@ -85,11 +85,11 @@ class CRM_Report_Page_InstanceList extends CRM_Core_Page { public function info() { $report = ''; - $queryParams = array(); + $queryParams = []; if ($this->ovID) { $report .= " AND v.id = %1 "; - $queryParams[1] = array($this->ovID, 'Integer'); + $queryParams[1] = [$this->ovID, 'Integer']; } if ($this->compID) { @@ -99,7 +99,7 @@ public function info() { } else { $report .= " AND v.component_id = %2 "; - $queryParams[2] = array($this->compID, 'Integer'); + $queryParams[2] = [$this->compID, 'Integer']; $cmpName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Component', $this->compID, 'name', 'id' ); @@ -111,11 +111,11 @@ public function info() { } elseif ($this->grouping) { $report .= " AND v.grouping = %3 "; - $queryParams[3] = array($this->grouping, 'String'); + $queryParams[3] = [$this->grouping, 'String']; } elseif ($this->myReports) { $report .= " AND inst.owner_id = %4 "; - $queryParams[4] = array(CRM_Core_Session::getLoggedInContactID(), 'Integer'); + $queryParams[4] = [CRM_Core_Session::getLoggedInContactID(), 'Integer']; } $sql = " @@ -137,12 +137,12 @@ public function info() { WHERE v.is_active = 1 {$report} AND inst.domain_id = %9 ORDER BY v.weight ASC, inst.title ASC"; - $queryParams[9] = array(CRM_Core_Config::domainID(), 'Integer'); + $queryParams[9] = [CRM_Core_Config::domainID(), 'Integer']; $dao = CRM_Core_DAO::executeQuery($sql, $queryParams); $config = CRM_Core_Config::singleton(); - $rows = array(); + $rows = []; $url = 'civicrm/report/instance'; $my_reports_grouping = 'My'; while ($dao->fetch()) { @@ -171,7 +171,7 @@ public function info() { if (trim($dao->title)) { if ($this->ovID) { - $this->title = ts("Report(s) created from the template: %1", array(1 => $dao->label)); + $this->title = ts("Report(s) created from the template: %1", [1 => $dao->label]); } $report_grouping = $dao->compName; @@ -190,7 +190,7 @@ public function info() { if (isset($rows[$my_reports_grouping])) { $my_reports = $rows[$my_reports_grouping]; unset($rows[$my_reports_grouping]); - $rows = array($my_reports_grouping => $my_reports) + $rows; + $rows = [$my_reports_grouping => $my_reports] + $rows; } return $rows; } @@ -216,13 +216,13 @@ public function run() { $this->assign('title', $this->title); } else { - CRM_Utils_System::setTitle(ts('%1 Reports', array(1 => $this->_compName))); + CRM_Utils_System::setTitle(ts('%1 Reports', [1 => $this->_compName])); } } // assign link to template list for users with appropriate permissions if (CRM_Core_Permission::check('administer Reports')) { if ($this->compID) { - $newButton = ts('New %1 Report', array(1 => $this->_compName)); + $newButton = ts('New %1 Report', [1 => $this->_compName]); $templateUrl = CRM_Utils_System::url('civicrm/report/template/list', "reset=1&compid={$this->compID}"); } else { @@ -247,40 +247,40 @@ public function run() { */ protected function getActionLinks($instanceID, $className) { $urlCommon = 'civicrm/report/instance/' . $instanceID; - $actions = array( - 'copy' => array( + $actions = [ + 'copy' => [ 'url' => CRM_Utils_System::url($urlCommon, 'reset=1&output=copy'), 'label' => ts('Save a Copy'), - ), - 'pdf' => array( + ], + 'pdf' => [ 'url' => CRM_Utils_System::url($urlCommon, 'reset=1&force=1&output=pdf'), 'label' => ts('View as pdf'), - ), - 'print' => array( + ], + 'print' => [ 'url' => CRM_Utils_System::url($urlCommon, 'reset=1&force=1&output=print'), 'label' => ts('Print report'), - ), - ); + ], + ]; // Hackery, Hackera, Hacker ahahahahahaha a super nasty hack. // Almost all report classes support csv & loading each class to call the method seems too // expensive. We also have on our later list 'do they support charts' which is instance specific // e.g use of group by might affect it. So, lets just skip for the few that don't for now. - $csvBlackList = array( + $csvBlackList = [ 'CRM_Report_Form_Contact_Detail', 'CRM_Report_Form_Event_Income', - ); + ]; if (!in_array($className, $csvBlackList)) { - $actions['csv'] = array( + $actions['csv'] = [ 'url' => CRM_Utils_System::url($urlCommon, 'reset=1&force=1&output=csv'), 'label' => ts('Export to csv'), - ); + ]; } if (CRM_Core_Permission::check('administer Reports')) { - $actions['delete'] = array( + $actions['delete'] = [ 'url' => CRM_Utils_System::url($urlCommon, 'reset=1&action=delete'), 'label' => ts('Delete report'), 'confirm_message' => ts('Are you sure you want delete this report? This action cannot be undone.'), - ); + ]; } return $actions; diff --git a/CRM/Report/Page/Options.php b/CRM/Report/Page/Options.php index 466ba235e172..65374992f1eb 100644 --- a/CRM/Report/Page/Options.php +++ b/CRM/Report/Page/Options.php @@ -110,30 +110,30 @@ public function getBAOName() { */ public function &links() { if (!(self::$_links)) { - self::$_links = array( - CRM_Core_Action::UPDATE => array( + self::$_links = [ + CRM_Core_Action::UPDATE => [ 'name' => ts('Edit'), 'url' => 'civicrm/admin/report/register/' . self::$_gName, 'qs' => 'action=update&id=%%id%%&reset=1', - 'title' => ts('Edit %1', array(1 => self::$_gName)), - ), - CRM_Core_Action::DISABLE => array( + 'title' => ts('Edit %1', [1 => self::$_gName]), + ], + CRM_Core_Action::DISABLE => [ 'name' => ts('Disable'), 'ref' => 'crm-enable-disable', - 'title' => ts('Disable %1', array(1 => self::$_gName)), - ), - CRM_Core_Action::ENABLE => array( + 'title' => ts('Disable %1', [1 => self::$_gName]), + ], + CRM_Core_Action::ENABLE => [ 'name' => ts('Enable'), 'ref' => 'crm-enable-disable', - 'title' => ts('Enable %1', array(1 => self::$_gName)), - ), - CRM_Core_Action::DELETE => array( + 'title' => ts('Enable %1', [1 => self::$_gName]), + ], + CRM_Core_Action::DELETE => [ 'name' => ts('Delete'), 'url' => 'civicrm/admin/report/register/' . self::$_gName, 'qs' => 'action=delete&id=%%id%%&reset=1', - 'title' => ts('Delete %1 Type', array(1 => self::$_gName)), - ), - ); + 'title' => ts('Delete %1 Type', [1 => self::$_gName]), + ], + ]; } return self::$_links; @@ -151,7 +151,7 @@ public function run() { * Browse all options. */ public function browse() { - $groupParams = array('name' => self::$_gName); + $groupParams = ['name' => self::$_gName]; $optionValue = CRM_Core_OptionValue::getRows($groupParams, $this->links(), 'weight'); $gName = self::$_gName; $returnURL = CRM_Utils_System::url("civicrm/admin/report/options/$gName", diff --git a/CRM/Report/Page/Report.php b/CRM/Report/Page/Report.php index 8284532680ca..82c95ec674a6 100644 --- a/CRM/Report/Page/Report.php +++ b/CRM/Report/Page/Report.php @@ -61,7 +61,7 @@ public function run() { } if (strstr(CRM_Utils_Array::value('name', $templateInfo), '_Form') || !is_null($reportClass)) { - CRM_Utils_System::setTitle(ts('%1 - Template', array(1 => $templateInfo['label']))); + CRM_Utils_System::setTitle(ts('%1 - Template', [1 => $templateInfo['label']])); $this->assign('reportTitle', $templateInfo['label']); $session = CRM_Core_Session::singleton(); diff --git a/CRM/Report/Page/TemplateList.php b/CRM/Report/Page/TemplateList.php index 5180f3d44310..631b5b68b478 100644 --- a/CRM/Report/Page/TemplateList.php +++ b/CRM/Report/Page/TemplateList.php @@ -83,7 +83,7 @@ public static function &info($compID = NULL, $grouping = NULL) { $sql .= " ORDER BY v.weight "; $dao = CRM_Core_DAO::executeQuery($sql); - $rows = array(); + $rows = []; $config = CRM_Core_Config::singleton(); while ($dao->fetch()) { if ($dao->component_name != 'Contact' && $dao->component_name != $dao->grouping && diff --git a/CRM/Report/Utils/Get.php b/CRM/Report/Utils/Get.php index 30e302183e40..02d9b5730961 100644 --- a/CRM/Report/Utils/Get.php +++ b/CRM/Report/Utils/Get.php @@ -200,10 +200,10 @@ public static function intParam($fieldName, &$field, &$defaults) { */ public static function processChart(&$defaults) { $chartType = CRM_Utils_Array::value("charts", $_GET); - if (in_array($chartType, array( + if (in_array($chartType, [ 'barChart', 'pieChart', - ))) { + ])) { $defaults["charts"] = $chartType; } } @@ -298,7 +298,7 @@ public static function processFields(&$reportFields, &$defaults) { } if (CRM_Utils_Array::value("ufld", $_GET) == 1) { // unset all display columns - $defaults['fields'] = array(); + $defaults['fields'] = []; } if (!empty($urlFields)) { foreach ($reportFields as $tableName => $fields) { diff --git a/CRM/Report/Utils/Report.php b/CRM/Report/Utils/Report.php index 43a7fcf71d45..68f5f69dd9d6 100644 --- a/CRM/Report/Utils/Report.php +++ b/CRM/Report/Utils/Report.php @@ -71,7 +71,7 @@ public static function getValueIDFromUrl($instanceID = NULL) { if ($optionVal) { $templateInfo = CRM_Core_OptionGroup::getRowValues('report_template', "{$optionVal}", 'value'); - return array(CRM_Utils_Array::value('id', $templateInfo), $optionVal); + return [CRM_Utils_Array::value('id', $templateInfo), $optionVal]; } return FALSE; @@ -83,14 +83,14 @@ public static function getValueIDFromUrl($instanceID = NULL) { * @return mixed */ public static function getInstanceIDForValue($optionVal) { - static $valId = array(); + static $valId = []; if (!array_key_exists($optionVal, $valId)) { $sql = " SELECT MIN(id) FROM civicrm_report_instance WHERE report_id = %1"; - $params = array(1 => array($optionVal, 'String')); + $params = [1 => [$optionVal, 'String']]; $valId[$optionVal] = CRM_Core_DAO::singleValueQuery($sql, $params); } return $valId[$optionVal]; @@ -102,7 +102,7 @@ public static function getInstanceIDForValue($optionVal) { * @return mixed */ public static function getInstanceIDForPath($path = NULL) { - static $valId = array(); + static $valId = []; // if $path is null, try to get it from url $path = self::getInstancePath(); @@ -112,7 +112,7 @@ public static function getInstanceIDForPath($path = NULL) { SELECT MIN(id) FROM civicrm_report_instance WHERE TRIM(BOTH '/' FROM CONCAT(report_id, '/', name)) = %1"; - $params = array(1 => array($path, 'String')); + $params = [1 => [$path, 'String']]; $valId[$path] = CRM_Core_DAO::singleValueQuery($sql, $params); } return CRM_Utils_Array::value($path, $valId); @@ -127,7 +127,7 @@ public static function getInstanceIDForPath($path = NULL) { * * @return bool|string */ - public static function getNextUrl($urlValue, $query = 'reset=1', $absolute = FALSE, $instanceID = NULL, $drilldownReport = array()) { + public static function getNextUrl($urlValue, $query = 'reset=1', $absolute = FALSE, $instanceID = NULL, $drilldownReport = []) { if ($instanceID) { $drilldownInstanceID = FALSE; if (array_key_exists($urlValue, $drilldownReport)) { @@ -170,7 +170,7 @@ public static function getInstanceCount($optionVal) { FROM civicrm_report_instance inst WHERE inst.report_id = %1"; - $params = array(1 => array($optionVal, 'String')); + $params = [1 => [$optionVal, 'String']]; $count = CRM_Core_DAO::singleValueQuery($sql, $params); return $count; } @@ -183,7 +183,7 @@ public static function getInstanceCount($optionVal) { * * @return bool */ - public static function mailReport($fileContent, $instanceID = NULL, $outputMode = 'html', $attachments = array()) { + public static function mailReport($fileContent, $instanceID = NULL, $outputMode = 'html', $attachments = []) { if (!$instanceID) { return FALSE; } @@ -192,14 +192,14 @@ public static function mailReport($fileContent, $instanceID = NULL, $outputMode $domainEmailAddress ) = CRM_Core_BAO_Domain::getNameAndEmail(); - $params = array('id' => $instanceID); - $instanceInfo = array(); + $params = ['id' => $instanceID]; + $instanceInfo = []; CRM_Core_DAO::commonRetrieve('CRM_Report_DAO_ReportInstance', $params, $instanceInfo ); - $params = array(); + $params = []; $params['groupName'] = 'Report Email Sender'; $params['from'] = '"' . $domainEmailName . '" <' . $domainEmailAddress . '>'; //$domainEmailName; @@ -208,7 +208,7 @@ public static function mailReport($fileContent, $instanceID = NULL, $outputMode $params['cc'] = CRM_Utils_Array::value('email_cc', $instanceInfo); $params['subject'] = CRM_Utils_Array::value('email_subject', $instanceInfo); if (empty($instanceInfo['attachments'])) { - $instanceInfo['attachments'] = array(); + $instanceInfo['attachments'] = []; } $params['attachments'] = array_merge(CRM_Utils_Array::value('attachments', $instanceInfo), $attachments); $params['text'] = ''; @@ -259,7 +259,7 @@ public static function makeCsv(&$form, &$rows) { $headers ) . "\r\n"; - $displayRows = array(); + $displayRows = []; $value = NULL; foreach ($rows as $row) { foreach ($columnHeaders as $k => $v) { @@ -348,8 +348,8 @@ public static function isInstancePermissioned($instanceId) { return TRUE; } - $instanceValues = array(); - $params = array('id' => $instanceId); + $instanceValues = []; + $params = ['id' => $instanceId]; CRM_Core_DAO::commonRetrieve('CRM_Report_DAO_ReportInstance', $params, $instanceValues @@ -381,8 +381,8 @@ public static function isInstanceGroupRoleAllowed($instanceId) { return TRUE; } - $instanceValues = array(); - $params = array('id' => $instanceId); + $instanceValues = []; + $params = ['id' => $instanceId]; CRM_Core_DAO::commonRetrieve('CRM_Report_DAO_ReportInstance', $params, $instanceValues @@ -418,14 +418,14 @@ public static function processReport($params) { $_REQUEST['reset'] = CRM_Utils_Array::value('reset', $params, 1); $optionVal = self::getValueFromUrl($instanceId); - $messages = array("Report Mail Triggered..."); + $messages = ["Report Mail Triggered..."]; $templateInfo = CRM_Core_OptionGroup::getRowValues('report_template', $optionVal, 'value'); $obj = new CRM_Report_Page_Instance(); $is_error = 0; if (strstr(CRM_Utils_Array::value('name', $templateInfo), '_Form')) { - $instanceInfo = array(); - CRM_Report_BAO_ReportInstance::retrieve(array('id' => $instanceId), $instanceInfo); + $instanceInfo = []; + CRM_Report_BAO_ReportInstance::retrieve(['id' => $instanceId], $instanceInfo); if (!empty($instanceInfo['title'])) { $obj->assign('reportTitle', $instanceInfo['title']); @@ -435,17 +435,17 @@ public static function processReport($params) { } $wrapper = new CRM_Utils_Wrapper(); - $arguments = array( - 'urlToSession' => array( - array( + $arguments = [ + 'urlToSession' => [ + [ 'urlVar' => 'instanceId', 'type' => 'Positive', 'sessionVar' => 'instanceId', 'default' => 'null', - ), - ), + ], + ], 'ignoreKey' => TRUE, - ); + ]; $messages[] = $wrapper->run($templateInfo['name'], NULL, $arguments); } else { @@ -458,10 +458,10 @@ public static function processReport($params) { } } - $result = array( + $result = [ 'is_error' => $is_error, 'messages' => implode("\n", $messages), - ); + ]; return $result; } @@ -478,11 +478,11 @@ public static function processReport($params) { * @return string * URL query string */ - public static function getPreviewCriteriaQueryParams($defaults = array(), $params = array()) { + public static function getPreviewCriteriaQueryParams($defaults = [], $params = []) { static $query_string; if (!isset($query_string)) { if (!empty($params)) { - $url_params = $op_values = $string_values = $process_params = array(); + $url_params = $op_values = $string_values = $process_params = []; // We'll only use $params that are different from what's in $default. foreach ($params as $field_name => $field_value) { @@ -553,15 +553,15 @@ public static function getPreviewCriteriaQueryParams($defaults = array(), $param * @return mixed */ public static function getInstanceList($reportUrl) { - static $instanceDetails = array(); + static $instanceDetails = []; if (!array_key_exists($reportUrl, $instanceDetails)) { - $instanceDetails[$reportUrl] = array(); + $instanceDetails[$reportUrl] = []; $sql = " SELECT id, title FROM civicrm_report_instance WHERE report_id = %1"; - $params = array(1 => array($reportUrl, 'String')); + $params = [1 => [$reportUrl, 'String']]; $result = CRM_Core_DAO::executeQuery($sql, $params); while ($result->fetch()) { $instanceDetails[$reportUrl][$result->id] = $result->title . " (ID: {$result->id})"; diff --git a/CRM/SMS/BAO/Provider.php b/CRM/SMS/BAO/Provider.php index 20740a04e3dc..932d18002914 100644 --- a/CRM/SMS/BAO/Provider.php +++ b/CRM/SMS/BAO/Provider.php @@ -44,7 +44,7 @@ public function __construct() { */ public static function activeProviderCount() { $activeProviders = CRM_Core_DAO::singleValueQuery('SELECT count(id) FROM civicrm_sms_provider WHERE is_active = 1 AND (domain_id = %1 OR domain_id IS NULL)', - array(1 => array(CRM_Core_Config::domainID(), 'Positive'))); + [1 => [CRM_Core_Config::domainID(), 'Positive']]); return $activeProviders; } @@ -63,8 +63,8 @@ public static function activeProviderCount() { */ public static function getProviders($selectArr = NULL, $filter = NULL, $getActive = TRUE, $orderBy = 'id') { - $providers = array(); - $temp = array(); + $providers = []; + $temp = []; $dao = new CRM_SMS_DAO_Provider(); if ($filter && !array_key_exists('is_active', $filter) && $getActive) { $dao->is_active = 1; @@ -163,17 +163,17 @@ public static function del($providerID) { * @return mixed */ public static function getProviderInfo($providerID, $returnParam = NULL, $returnDefaultString = NULL) { - static $providerInfo = array(); + static $providerInfo = []; if (!array_key_exists($providerID, $providerInfo)) { - $providerInfo[$providerID] = array(); + $providerInfo[$providerID] = []; $dao = new CRM_SMS_DAO_Provider(); $dao->id = $providerID; if ($dao->find(TRUE)) { CRM_Core_DAO::storeValues($dao, $providerInfo[$providerID]); $inputLines = explode("\n", $providerInfo[$providerID]['api_params']); - $inputVals = array(); + $inputVals = []; foreach ($inputLines as $value) { if ($value) { list($key, $val) = explode("=", $value); diff --git a/CRM/SMS/Controller/Send.php b/CRM/SMS/Controller/Send.php index 44adddd5c1d1..9466a425ffdc 100644 --- a/CRM/SMS/Controller/Send.php +++ b/CRM/SMS/Controller/Send.php @@ -62,7 +62,7 @@ public function __construct($title = NULL, $action = CRM_Core_Action::NONE, $mod $this->addPages($this->_stateMachine, $action); // add all the actions - $uploadNames = array_merge(array('textFile'), + $uploadNames = array_merge(['textFile'], CRM_Core_BAO_File::uploadNames() ); diff --git a/CRM/SMS/Form/Group.php b/CRM/SMS/Form/Group.php index ce4e803d6062..f3d64d81afec 100644 --- a/CRM/SMS/Form/Group.php +++ b/CRM/SMS/Form/Group.php @@ -41,7 +41,7 @@ class CRM_SMS_Form_Group extends CRM_Contact_Form_Task { */ public function preProcess() { if (!CRM_SMS_BAO_Provider::activeProviderCount()) { - CRM_Core_Error::fatal(ts('The SMS Provider has not been configured or is not active.', array(1 => CRM_Utils_System::url('civicrm/admin/sms/provider', 'reset=1')))); + CRM_Core_Error::fatal(ts('The SMS Provider has not been configured or is not active.', [1 => CRM_Utils_System::url('civicrm/admin/sms/provider', 'reset=1')])); } $session = CRM_Core_Session::singleton(); @@ -60,7 +60,7 @@ public function setDefaultValues() { $mailingID = CRM_Utils_Request::retrieve('mid', 'Integer', $this, FALSE, NULL); $continue = CRM_Utils_Request::retrieve('continue', 'String', $this, FALSE, NULL); - $defaults = array(); + $defaults = []; if ($mailingID) { $mailing = new CRM_Mailing_DAO_Mailing(); @@ -70,7 +70,7 @@ public function setDefaultValues() { $defaults['name'] = $mailing->name; if (!$continue) { - $defaults['name'] = ts('Copy of %1', array(1 => $mailing->name)); + $defaults['name'] = ts('Copy of %1', [1 => $mailing->name]); } else { // CRM-7590, reuse same mailing ID if we are continuing @@ -79,7 +79,7 @@ public function setDefaultValues() { $dao = new CRM_Mailing_DAO_MailingGroup(); - $mailingGroups = array(); + $mailingGroups = []; $dao->mailing_id = $mailingID; $dao->find(); while ($dao->fetch()) { @@ -123,18 +123,18 @@ public function buildQuickForm() { // Get the sms mailing list. $mailings = CRM_Mailing_PseudoConstant::completed('sms'); if (!$mailings) { - $mailings = array(); + $mailings = []; } // run the groups through a hook so users can trim it if needed CRM_Utils_Hook::mailingGroups($this, $groups, $mailings); - $select2style = array( + $select2style = [ 'multiple' => TRUE, 'style' => 'width: 100%; max-width: 60em;', 'class' => 'crm-select2', 'placeholder' => ts('- select -'), - ); + ]; $this->add('select', 'includeGroups', ts('Include Group(s)'), @@ -163,20 +163,20 @@ public function buildQuickForm() { $select2style ); - $this->addFormRule(array('CRM_SMS_Form_Group', 'formRule')); + $this->addFormRule(['CRM_SMS_Form_Group', 'formRule']); - $buttons = array( - array( + $buttons = [ + [ 'type' => 'next', 'name' => ts('Next'), 'spacing' => '                 ', 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ); + ], + ]; $this->addButtons($buttons); @@ -187,14 +187,14 @@ public function buildQuickForm() { public function postProcess() { $values = $this->controller->exportValues($this->_name); - $groups = array(); + $groups = []; - foreach (array( + foreach ([ 'name', 'group_id', 'is_sms', 'sms_provider_id', - ) as $n) { + ] as $n) { if (!empty($values[$n])) { $params[$n] = $values[$n]; if ($n == 'sms_provider_id') { @@ -227,7 +227,7 @@ public function postProcess() { } } - $mailings = array(); + $mailings = []; if (is_array($inMailings)) { foreach ($inMailings as $key => $id) { if ($id) { @@ -246,7 +246,7 @@ public function postProcess() { $session = CRM_Core_Session::singleton(); $params['groups'] = $groups; $params['mailings'] = $mailings; - $ids = array(); + $ids = []; if ($this->get('mailing_id')) { // don't create a new mass sms if already exists @@ -256,10 +256,10 @@ public function postProcess() { $mailingTableName = CRM_Mailing_BAO_Mailing::getTableName(); // delete previous includes/excludes, if mailing already existed - foreach (array( + foreach ([ 'groups', 'mailings', - ) as $entity) { + ] as $entity) { $mg = new CRM_Mailing_DAO_MailingGroup(); $mg->mailing_id = $ids['mailing_id']; $mg->entity_table = ($entity == 'groups') ? $groupTableName : $mailingTableName; @@ -317,13 +317,13 @@ public function getTitle() { * list of errors to be posted back to the form */ public static function formRule($fields) { - $errors = array(); + $errors = []; if (isset($fields['includeGroups']) && is_array($fields['includeGroups']) && isset($fields['excludeGroups']) && is_array($fields['excludeGroups']) ) { - $checkGroups = array(); + $checkGroups = []; $checkGroups = array_intersect($fields['includeGroups'], $fields['excludeGroups']); if (!empty($checkGroups)) { $errors['excludeGroups'] = ts('Cannot have same groups in Include Group(s) and Exclude Group(s).'); @@ -335,7 +335,7 @@ public static function formRule($fields) { isset($fields['excludeMailings']) && is_array($fields['excludeMailings']) ) { - $checkMailings = array(); + $checkMailings = []; $checkMailings = array_intersect($fields['includeMailings'], $fields['excludeMailings']); if (!empty($checkMailings)) { $errors['excludeMailings'] = ts('Cannot have same sms in Include mailing(s) and Exclude mailing(s).'); diff --git a/CRM/SMS/Form/Provider.php b/CRM/SMS/Form/Provider.php index 88107b07378d..1ed76a1d0227 100644 --- a/CRM/SMS/Form/Provider.php +++ b/CRM/SMS/Form/Provider.php @@ -65,17 +65,17 @@ public function preProcess() { public function buildQuickForm() { parent::buildQuickForm(); - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => $this->_action & CRM_Core_Action::DELETE ? ts('Delete') : ts('Save'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - )); + ], + ]); if ($this->_action & CRM_Core_Action::DELETE) { return; @@ -86,16 +86,16 @@ public function buildQuickForm() { $providerNames = CRM_Core_OptionGroup::values('sms_provider_name', FALSE, FALSE, FALSE, NULL, 'label'); $apiTypes = CRM_Core_OptionGroup::values('sms_api_type', FALSE, FALSE, FALSE, NULL, 'label'); - $this->add('select', 'name', ts('Name'), array('' => '- select -') + $providerNames, TRUE); + $this->add('select', 'name', ts('Name'), ['' => '- select -'] + $providerNames, TRUE); $this->add('text', 'title', ts('Title'), $attributes['title'], TRUE ); - $this->addRule('title', ts('This Title already exists in Database.'), 'objectExists', array( + $this->addRule('title', ts('This Title already exists in Database.'), 'objectExists', [ 'CRM_SMS_DAO_Provider', $this->_id, - )); + ]); $this->add('text', 'username', ts('Username'), $attributes['username'], TRUE @@ -124,12 +124,12 @@ public function buildQuickForm() { * @return array */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; $name = CRM_Utils_Request::retrieve('key', 'String', $this, FALSE, NULL); if ($name) { $defaults['name'] = $name; - $provider = CRM_SMS_Provider::singleton(array('provider' => $name)); + $provider = CRM_SMS_Provider::singleton(['provider' => $name]); $defaults['api_url'] = $provider->_apiURL; } diff --git a/CRM/SMS/Form/Schedule.php b/CRM/SMS/Form/Schedule.php index f4ddf7d868f1..82c3e594ff90 100644 --- a/CRM/SMS/Form/Schedule.php +++ b/CRM/SMS/Form/Schedule.php @@ -48,7 +48,7 @@ public function preProcess() { * Set default values for the form. */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; $count = $this->get('count'); @@ -74,29 +74,29 @@ public function buildQuickform() { $this->add('datepicker', 'start_date', '', NULL, FALSE, ['minDate' => time()]); - $this->addFormRule(array('CRM_SMS_Form_Schedule', 'formRule'), $this); + $this->addFormRule(['CRM_SMS_Form_Schedule', 'formRule'], $this); - $buttons = array( - array( + $buttons = [ + [ 'type' => 'back', 'name' => ts('Previous'), - ), - array( + ], + [ 'type' => 'next', 'name' => ts('Submit Mass SMS'), 'spacing' => '                 ', 'isDefault' => TRUE, - 'js' => array('onclick' => "return submitOnce(this,'" . $this->_name . "','" . ts('Processing') . "');"), - ), - array( + 'js' => ['onclick' => "return submitOnce(this,'" . $this->_name . "','" . ts('Processing') . "');"], + ], + [ 'type' => 'cancel', 'name' => ts('Continue Later'), - ), - ); + ], + ]; $this->addButtons($buttons); - $preview = array(); + $preview = []; $preview['type'] = CRM_Core_DAO::getFieldValue('CRM_Mailing_DAO_Mailing', $this->_mailingID, 'body_html') ? 'html' : 'text'; $preview['viewURL'] = CRM_Utils_System::url('civicrm/mailing/view', "reset=1&id={$this->_mailingID}"); $this->assign_by_ref('preview', $preview); @@ -132,9 +132,9 @@ public static function formRule($params, $files, $self) { } if (strtotime($params['start_date']) < time()) { - return array( + return [ 'start_date' => ts('Start date cannot be earlier than the current time.'), - ); + ]; } return TRUE; @@ -144,7 +144,7 @@ public static function formRule($params, $files, $self) { * Process the posted form values. Create and schedule a Mass SMS. */ public function postProcess() { - $params = array(); + $params = []; $params['mailing_id'] = $ids['mailing_id'] = $this->_mailingID; diff --git a/CRM/SMS/Form/Upload.php b/CRM/SMS/Form/Upload.php index 7a0342a5e0cc..91ba35392f19 100644 --- a/CRM/SMS/Form/Upload.php +++ b/CRM/SMS/Form/Upload.php @@ -61,7 +61,7 @@ public function setDefaultValues() { $this->set('skipTextFile', FALSE); - $defaults = array(); + $defaults = []; if ($mailingID) { $dao = new CRM_Mailing_DAO_Mailing(); @@ -115,7 +115,7 @@ public function setDefaultValues() { public function buildQuickForm() { $session = CRM_Core_Session::singleton(); $config = CRM_Core_Config::singleton(); - $options = array(); + $options = []; $tempVar = FALSE; $this->assign('max_sms_length', CRM_SMS_Provider::MAX_SMS_CHAR); @@ -125,8 +125,8 @@ public function buildQuickForm() { "CRM_SMS_Controller_Send_{$this->controller->_key}" ); - $attributes = array('onclick' => "showHideUpload();"); - $options = array(ts('Upload Content'), ts('Compose On-screen')); + $attributes = ['onclick' => "showHideUpload();"]; + $options = [ts('Upload Content'), ts('Compose On-screen')]; $this->addRadio('upload_type', ts('I want to'), $options, $attributes, "  "); @@ -137,31 +137,31 @@ public function buildQuickForm() { $this->addRule('textFile', ts('File size should be less than 1 MByte'), 'maxfilesize', 1024 * 1024); $this->addRule('textFile', ts('File must be in UTF-8 encoding'), 'utf8File'); - $this->addFormRule(array('CRM_SMS_Form_Upload', 'formRule'), $this); + $this->addFormRule(['CRM_SMS_Form_Upload', 'formRule'], $this); - $buttons = array( - array( + $buttons = [ + [ 'type' => 'back', 'name' => ts('Previous'), - ), - array( + ], + [ 'type' => 'upload', 'name' => ts('Next'), 'spacing' => '                 ', 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ); + ], + ]; $this->addButtons($buttons); } public function postProcess() { - $params = $ids = array(); - $uploadParams = array('from_name'); + $params = $ids = []; + $uploadParams = ['from_name']; $formValues = $this->controller->exportValues($this->_name); @@ -198,16 +198,16 @@ public function postProcess() { $session = CRM_Core_Session::singleton(); $params['contact_id'] = $session->get('userID'); - $composeFields = array( + $composeFields = [ 'SMStemplate', 'SMSsaveTemplate', 'SMSupdateTemplate', 'SMSsaveTemplateName', - ); + ]; $msgTemplate = NULL; // Mail template is composed. if ($formValues['upload_type']) { - $composeParams = array(); + $composeParams = []; foreach ($composeFields as $key) { if (!empty($formValues[$key])) { $composeParams[$key] = $formValues[$key]; @@ -216,11 +216,11 @@ public function postProcess() { } if (!empty($composeParams['SMSupdateTemplate'])) { - $templateParams = array( + $templateParams = [ 'msg_text' => $text_message, 'is_active' => TRUE, 'is_sms' => TRUE, - ); + ]; $templateParams['id'] = $formValues['SMStemplate']; @@ -228,11 +228,11 @@ public function postProcess() { } if (!empty($composeParams['SMSsaveTemplate'])) { - $templateParams = array( + $templateParams = [ 'msg_text' => $text_message, 'is_active' => TRUE, 'is_sms' => TRUE, - ); + ]; $templateParams['msg_title'] = $composeParams['SMSsaveTemplateName']; @@ -270,7 +270,7 @@ public static function formRule($params, $files, $self) { if (!empty($_POST['_qf_Import_refresh'])) { return TRUE; } - $errors = array(); + $errors = []; $template = CRM_Core_Smarty::singleton(); $domain = CRM_Core_BAO_Domain::getDomain(); @@ -280,22 +280,22 @@ public static function formRule($params, $files, $self) { $mailing->find(TRUE); $session = CRM_Core_Session::singleton(); - $values = array( + $values = [ 'contact_id' => $session->get('userID'), 'version' => 3, - ); + ]; require_once 'api/api.php'; $contact = civicrm_api('contact', 'get', $values); // CRM-4524. $contact = reset($contact['values']); - $verp = array_flip(array('optOut', 'reply', 'unsubscribe', 'resubscribe', 'owner')); + $verp = array_flip(['optOut', 'reply', 'unsubscribe', 'resubscribe', 'owner']); foreach ($verp as $key => $value) { $verp[$key]++; } - $urls = array_flip(array('forward', 'optOutUrl', 'unsubscribeUrl', 'resubscribeUrl')); + $urls = array_flip(['forward', 'optOutUrl', 'unsubscribeUrl', 'resubscribeUrl']); foreach ($urls as $key => $value) { $urls[$key]++; } @@ -317,7 +317,7 @@ public static function formRule($params, $files, $self) { if (!empty($params['text_message'])) { $messageCheck = CRM_Utils_Array::value('text_message', $params); 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", array(1 => 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]); } } } @@ -339,7 +339,7 @@ public static function formRule($params, $files, $self) { $name = 'text message'; } - $dataErrors = array(); + $dataErrors = []; // Do a full token replacement on a dummy verp, the current // contact and domain, and the first organization. @@ -372,12 +372,12 @@ public static function formRule($params, $files, $self) { } } if (strlen($contentCheck) > CRM_SMS_Provider::MAX_SMS_CHAR) { - $dataErrors[] = '
  • ' . ts('The body of the SMS cannot exceed %1 characters.', array(1 => CRM_SMS_Provider::MAX_SMS_CHAR)) . '
  • '; + $dataErrors[] = '
  • ' . ts('The body of the SMS cannot exceed %1 characters.', [1 => CRM_SMS_Provider::MAX_SMS_CHAR]) . '
  • '; } if (!empty($dataErrors)) { - $errors['textFile'] = ts('The following errors were detected in %1:', array( + $errors['textFile'] = ts('The following errors were detected in %1:', [ 1 => $name, - )) . '
      ' . implode('', $dataErrors) . '
    '; + ]) . '
      ' . implode('', $dataErrors) . '
    '; } } diff --git a/CRM/SMS/StateMachine/Send.php b/CRM/SMS/StateMachine/Send.php index 11668b13856b..1d4646114fe1 100644 --- a/CRM/SMS/StateMachine/Send.php +++ b/CRM/SMS/StateMachine/Send.php @@ -47,11 +47,11 @@ class CRM_SMS_StateMachine_Send extends CRM_Core_StateMachine { public function __construct($controller, $action = CRM_Core_Action::NONE) { parent::__construct($controller, $action); - $this->_pages = array( + $this->_pages = [ 'CRM_SMS_Form_Group' => NULL, 'CRM_SMS_Form_Upload' => NULL, 'CRM_SMS_Form_Schedule' => NULL, - ); + ]; $this->addSequentialPages($this->_pages, $action); } diff --git a/CRM/Tag/Form/Edit.php b/CRM/Tag/Form/Edit.php index 3cff861b0785..b4feead66f3a 100644 --- a/CRM/Tag/Form/Edit.php +++ b/CRM/Tag/Form/Edit.php @@ -68,14 +68,14 @@ public function buildQuickForm() { CRM_Core_Error::statusBounce(ts("Unknown tag."), $bounceUrl); } if ($tag = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Tag', $id, 'name', 'parent_id')) { - CRM_Core_Error::statusBounce(ts("This tag cannot be deleted. You must delete all its child tags ('%1', etc) prior to deleting this tag.", array(1 => $tag)), $bounceUrl); + CRM_Core_Error::statusBounce(ts("This tag cannot be deleted. You must delete all its child tags ('%1', etc) prior to deleting this tag.", [1 => $tag]), $bounceUrl); } if (!CRM_Core_Permission::check('administer reserved tags') && CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Tag', $id, 'is_reserved')) { CRM_Core_Error::statusBounce(ts("You do not have sufficient permission to delete this reserved tag."), $bounceUrl); } } if (count($this->_id) > 1) { - $this->assign('delName', ts('%1 tags', array(1 => count($this->_id)))); + $this->assign('delName', ts('%1 tags', [1 => count($this->_id)])); } } else { @@ -107,7 +107,7 @@ public function buildQuickForm() { if (!$this->_isTagSet) { if (!$isTagSetChild) { $colorTags = CRM_Core_BAO_Tag::getColorTags(NULL, TRUE, $this->_id); - $this->add('select2', 'parent_id', ts('Parent Tag'), $colorTags, FALSE, array('placeholder' => ts('- select -'))); + $this->add('select2', 'parent_id', ts('Parent Tag'), $colorTags, FALSE, ['placeholder' => ts('- select -')]); } // Tagsets are not selectable by definition so only include the selectable field if NOT a tagset. @@ -127,10 +127,10 @@ public function buildQuickForm() { $this->add('text', 'name', ts('Name'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Tag', 'name'), TRUE ); - $this->addRule('name', ts('Name already exists in Database.'), 'objectExists', array( + $this->addRule('name', ts('Name already exists in Database.'), 'objectExists', [ 'CRM_Core_DAO_Tag', $this->_id, - )); + ]); $this->add('text', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Tag', 'description') @@ -139,7 +139,7 @@ public function buildQuickForm() { $isReserved = $this->add('checkbox', 'is_reserved', ts('Reserved?')); if (!$isTagSetChild) { - $this->addSelect('used_for', array('multiple' => TRUE, 'option_url' => NULL)); + $this->addSelect('used_for', ['multiple' => TRUE, 'option_url' => NULL]); } $this->assign('adminTagset', $adminTagset); @@ -162,7 +162,7 @@ public function setDefaultValues() { $defaults = parent::setDefaultValues(); $cloneFrom = CRM_Utils_Request::retrieve('clone_from', 'Integer'); if (empty($this->_id) && $cloneFrom) { - $params = array('id' => $cloneFrom); + $params = ['id' => $cloneFrom]; CRM_Core_BAO_Tag::retrieve($params, $this->_values); $this->_values['name'] .= ' (' . ts('copy') . ')'; if (!empty($this->_values['is_reserved']) && !CRM_Core_Permission::check('administer reserved tags')) { @@ -185,7 +185,7 @@ public function setDefaultValues() { public function postProcess() { if ($this->_action == CRM_Core_Action::DELETE) { $deleted = 0; - $tag = civicrm_api3('tag', 'getsingle', array('id' => $this->_id[0])); + $tag = civicrm_api3('tag', 'getsingle', ['id' => $this->_id[0]]); foreach ($this->_id as $id) { if (CRM_Core_BAO_Tag::del($id)) { $deleted++; @@ -193,14 +193,14 @@ public function postProcess() { } if (count($this->_id) == 1 && $deleted == 1) { if ($tag['is_tagset']) { - CRM_Core_Session::setStatus(ts("The tag set '%1' has been deleted.", array(1 => $tag['name'])), ts('Deleted'), 'success'); + CRM_Core_Session::setStatus(ts("The tag set '%1' has been deleted.", [1 => $tag['name']]), ts('Deleted'), 'success'); } else { - CRM_Core_Session::setStatus(ts("The tag '%1' has been deleted.", array(1 => $tag['name'])), ts('Deleted'), 'success'); + CRM_Core_Session::setStatus(ts("The tag '%1' has been deleted.", [1 => $tag['name']]), ts('Deleted'), 'success'); } } else { - CRM_Core_Session::setStatus(ts("Deleted %1 tags.", array(1 => $deleted)), ts('Deleted'), 'success'); + CRM_Core_Session::setStatus(ts("Deleted %1 tags.", [1 => $deleted]), ts('Deleted'), 'success'); } } else { @@ -233,7 +233,7 @@ public function postProcess() { $params['is_selectable'] = 0; } $tag = CRM_Core_BAO_Tag::add($params); - CRM_Core_Session::setStatus(ts("The tag '%1' has been saved.", array(1 => $tag->name)), ts('Saved'), 'success'); + CRM_Core_Session::setStatus(ts("The tag '%1' has been saved.", [1 => $tag->name]), ts('Saved'), 'success'); $this->ajaxResponse['tag'] = $tag->toArray(); } CRM_Core_Session::singleton()->pushUserContext(CRM_Utils_System::url('civicrm/tag')); diff --git a/CRM/Tag/Form/Merge.php b/CRM/Tag/Form/Merge.php index e8ce8b495705..a581bf141f65 100644 --- a/CRM/Tag/Form/Merge.php +++ b/CRM/Tag/Form/Merge.php @@ -45,7 +45,7 @@ public function preProcess() { if (count($this->_id) < 2) { CRM_Core_Error::statusBounce(ts("You must select at least 2 tags for merging."), $url); } - $tags = civicrm_api3('Tag', 'get', array('id' => array('IN' => $this->_id), 'options' => array('limit' => 0))); + $tags = civicrm_api3('Tag', 'get', ['id' => ['IN' => $this->_id], 'options' => ['limit' => 0]]); $this->_tags = $tags['values']; if (count($this->_id) != count($this->_tags)) { CRM_Core_Error::statusBounce(ts("Unknown tag."), $url); @@ -66,18 +66,18 @@ public function buildQuickForm() { $this->add('text', 'name', ts('Name of combined tag'), TRUE); $this->assign('tags', CRM_Utils_Array::collect('name', $this->_tags)); - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => ts('Merge'), 'spacing' => '         ', 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); } @@ -88,9 +88,9 @@ public function buildQuickForm() { */ public function setDefaultValues() { $primary = CRM_Utils_Array::first($this->_tags); - return array( + return [ 'name' => $primary['name'], - ); + ]; } /** @@ -106,7 +106,7 @@ public function postProcess() { } if ($params['name'] != $primary['name']) { - civicrm_api3('Tag', 'create', array('id' => $primary['id'], 'name' => $params['name'])); + civicrm_api3('Tag', 'create', ['id' => $primary['id'], 'name' => $params['name']]); } $key = array_search($params['name'], $deleted); @@ -115,8 +115,8 @@ public function postProcess() { } CRM_Core_Session::setStatus( - ts('All records previously tagged %1 are now tagged %2.', array(1 => implode(' ' . ts('or') . ' ', $deleted), 2 => $params['name'])), - ts('%1 Tags Merged', array(1 => count($this->_id))), + ts('All records previously tagged %1 are now tagged %2.', [1 => implode(' ' . ts('or') . ' ', $deleted), 2 => $params['name']]), + ts('%1 Tags Merged', [1 => count($this->_id)]), 'success' ); diff --git a/CRM/Tag/Form/Tag.php b/CRM/Tag/Form/Tag.php index 321bcd9aecfa..27e5048e21b4 100644 --- a/CRM/Tag/Form/Tag.php +++ b/CRM/Tag/Form/Tag.php @@ -81,15 +81,15 @@ public function buildQuickForm() { // need to append the array with the " checked " if contact is tagged with the tag foreach ($allTags as $tagID => $varValue) { if (in_array($tagID, $entityTag)) { - $tagAttribute = array( + $tagAttribute = [ 'checked' => 'checked', 'id' => "tag_{$tagID}", - ); + ]; } else { - $tagAttribute = array( + $tagAttribute = [ 'id' => "tag_{$tagID}", - ); + ]; } $tagChk[$tagID] = $this->createElement('checkbox', $tagID, '', '', $tagAttribute); diff --git a/CRM/Tag/Page/Tag.php b/CRM/Tag/Page/Tag.php index 6ed3c4181c86..11d899a511f9 100644 --- a/CRM/Tag/Page/Tag.php +++ b/CRM/Tag/Page/Tag.php @@ -43,23 +43,23 @@ public function run() { CRM_Core_Resources::singleton() ->addScriptFile('civicrm', 'bower_components/jstree/dist/jstree.min.js', 0, 'html-header') ->addStyleFile('civicrm', 'bower_components/jstree/dist/themes/default/style.min.css') - ->addPermissions(array('administer reserved tags', 'administer Tagsets')); + ->addPermissions(['administer reserved tags', 'administer Tagsets']); - $usedFor = $tagsets = array(); + $usedFor = $tagsets = []; - $result = civicrm_api3('OptionValue', 'get', array( - 'return' => array("value", "name"), + $result = civicrm_api3('OptionValue', 'get', [ + 'return' => ["value", "name"], 'option_group_id' => "tag_used_for", - )); + ]); foreach ($result['values'] as $value) { $usedFor[$value['value']] = $value['name']; } - $result = civicrm_api3('Tag', 'get', array( - 'return' => array("name", "used_for", "description", "created_id.display_name", "created_date", "is_reserved"), + $result = civicrm_api3('Tag', 'get', [ + 'return' => ["name", "used_for", "description", "created_id.display_name", "created_date", "is_reserved"], 'is_tagset' => 1, - 'options' => array('limit' => 0), - )); + 'options' => ['limit' => 0], + ]); foreach ($result['values'] as $id => $tagset) { $used = explode(',', CRM_Utils_Array::value('used_for', $tagset, '')); $tagset['used_for_label'] = array_values(array_intersect_key($usedFor, array_flip($used))); diff --git a/CRM/UF/Form/AbstractPreview.php b/CRM/UF/Form/AbstractPreview.php index a04b5b4c6297..2379f2fef6b2 100644 --- a/CRM/UF/Form/AbstractPreview.php +++ b/CRM/UF/Form/AbstractPreview.php @@ -80,7 +80,7 @@ public function setProfile($fields, $isSingleField = FALSE, $flag = FALSE) { * the default array reference */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; foreach ($this->_fields as $name => $field) { if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($field['name'])) { CRM_Core_BAO_CustomField::setProfileDefaults($customFieldID, $name, $defaults, NULL, CRM_Profile_Form::MODE_REGISTER); diff --git a/CRM/UF/Form/AdvanceSetting.php b/CRM/UF/Form/AdvanceSetting.php index f2945f63dad8..7caff1af5dea 100644 --- a/CRM/UF/Form/AdvanceSetting.php +++ b/CRM/UF/Form/AdvanceSetting.php @@ -48,7 +48,7 @@ public static function buildAdvanceSetting(&$form) { $form->addElement('checkbox', 'is_map', ts('Enable mapping for this profile?')); // should we allow updates on a exisitng contact - $options = array(); + $options = []; $options[] = $form->createElement('radio', NULL, NULL, ts('Issue warning and do not save'), 0); $options[] = $form->createElement('radio', NULL, NULL, ts('Update the matching contact'), 1); $options[] = $form->createElement('radio', NULL, NULL, ts('Allow duplicate contact to be created'), 2); @@ -61,7 +61,7 @@ public static function buildAdvanceSetting(&$form) { $form->addElement('text', 'cancel_URL', ts('Cancel Redirect URL'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_UFGroup', 'cancel_URL')); // add select for groups - $group = array('' => ts('- select -')) + $form->_group; + $group = ['' => ts('- select -')] + $form->_group; $form->_groupElement = &$form->addElement('select', 'group', ts('Limit listings to a specific Group?'), $group); //add notify field @@ -78,7 +78,7 @@ public static function buildAdvanceSetting(&$form) { // should we display a link to the website profile $config = CRM_Core_Config::singleton(); - $form->addElement('checkbox', 'is_uf_link', ts('Include %1 user account information links in search results?', array(1 => $config->userFramework))); + $form->addElement('checkbox', 'is_uf_link', ts('Include %1 user account information links in search results?', [1 => $config->userFramework])); // want to create cms user $session = CRM_Core_Session::singleton(); @@ -87,15 +87,15 @@ public static function buildAdvanceSetting(&$form) { $form->_cmsId = TRUE; } - $options = array(); + $options = []; $options[] = $form->createElement('radio', NULL, NULL, ts('No account create option'), 0); $options[] = $form->createElement('radio', NULL, NULL, ts('Give option, but not required'), 1); $options[] = $form->createElement('radio', NULL, NULL, ts('Account creation required'), 2); - $form->addGroup($options, 'is_cms_user', ts('%1 user account registration option?', array(1 => $config->userFramework))); + $form->addGroup($options, 'is_cms_user', ts('%1 user account registration option?', [1 => $config->userFramework])); // options for including Proximity Search in the profile search form - $proxOptions = array(); + $proxOptions = []; $proxOptions[] = $form->createElement('radio', NULL, NULL, ts('None'), 0); $proxOptions[] = $form->createElement('radio', NULL, NULL, ts('Optional'), 1); $proxOptions[] = $form->createElement('radio', NULL, NULL, ts('Required'), 2); diff --git a/CRM/UF/Form/Field.php b/CRM/UF/Form/Field.php index 5b0c433a781c..7617d6f804a6 100644 --- a/CRM/UF/Form/Field.php +++ b/CRM/UF/Form/Field.php @@ -105,12 +105,12 @@ public function preProcess() { $session = CRM_Core_Session::singleton(); $session->pushUserContext($url); - $breadCrumb = array( - array( + $breadCrumb = [ + [ 'title' => ts('CiviCRM Profile Fields'), 'url' => $url, - ), - ); + ], + ]; CRM_Utils_System::appendBreadCrumb($breadCrumb); } @@ -149,7 +149,7 @@ public function preProcess() { $this->_fields = array_merge($this->_fields, CRM_Contact_BAO_Query_Hook::singleton()->getFields()); - $this->_selectFields = array(); + $this->_selectFields = []; foreach ($this->_fields as $name => $field) { // lets skip note for now since we dont support it if ($name == 'note') { @@ -182,24 +182,24 @@ public function preProcess() { */ public function buildQuickForm() { if ($this->_action & CRM_Core_Action::DELETE) { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => ts('Delete Profile Field'), 'spacing' => '         ', 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - )); + ], + ]); return; } $addressCustomFields = array_keys(CRM_Core_BAO_CustomField::getFieldsForImport('Address')); if (isset($this->_id)) { - $params = array('id' => $this->_id); + $params = ['id' => $this->_id]; CRM_Core_BAO_UFField::retrieve($params, $defaults); // set it to null if so (avoids crappy E_NOTICE errors below @@ -214,12 +214,12 @@ public function buildQuickForm() { $defaults['location_type_id'] = 0; } - $defaults['field_name'] = array( + $defaults['field_name'] = [ $defaults['field_type'], ($defaults['field_type'] == "Formatting" ? "" : $defaults['field_name']), ($defaults['field_name'] == "url") ? $defaults['website_type_id'] : $defaults['location_type_id'], CRM_Utils_Array::value('phone_type_id', $defaults), - ); + ]; $this->_gid = $defaults['uf_group_id']; } else { @@ -230,7 +230,7 @@ public function buildQuickForm() { $this->assign('otherModules', $otherModules); if ($this->_action & CRM_Core_Action::ADD) { - $fieldValues = array('uf_group_id' => $this->_gid); + $fieldValues = ['uf_group_id' => $this->_gid]; $defaults['weight'] = CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_UFField', $fieldValues); } @@ -245,7 +245,7 @@ public function buildQuickForm() { $fields = CRM_Core_BAO_UFField::getAvailableFields($this->_gid, $defaults); - $noSearchable = $hasWebsiteTypes = array(); + $noSearchable = $hasWebsiteTypes = []; foreach ($fields as $key => $value) { foreach ($value as $key1 => $value1) { @@ -290,20 +290,20 @@ public function buildQuickForm() { if ($defaultLocationType) { $defaultLocation = $this->_location_types[$defaultLocationType->id]; unset($this->_location_types[$defaultLocationType->id]); - $this->_location_types = array( + $this->_location_types = [ $defaultLocationType->id => $defaultLocation, - ) + $this->_location_types; + ] + $this->_location_types; } - $this->_location_types = array('Primary') + $this->_location_types; + $this->_location_types = ['Primary'] + $this->_location_types; // since we need a hierarchical list to display contact types & subtypes, // this is what we going to display in first selector $contactTypes = CRM_Contact_BAO_ContactType::getSelectElements(FALSE, FALSE); unset($contactTypes['']); - $contactTypes = !empty($contactTypes) ? array('Contact' => 'Contacts') + $contactTypes : array(); - $sel1 = array('' => '- select -') + $contactTypes; + $contactTypes = !empty($contactTypes) ? ['Contact' => 'Contacts'] + $contactTypes : []; + $sel1 = ['' => '- select -'] + $contactTypes; if (!empty($fields['Activity'])) { $sel1['Activity'] = 'Activity'; @@ -365,7 +365,7 @@ public function buildQuickForm() { } } - $this->_defaults = array(); + $this->_defaults = []; $js = "\n"; $this->assign('initHideBoxes', $js); @@ -291,23 +297,22 @@ public function buildQuickForm() { $this->setDefaults($defaults); - $this->addButtons(array( - array( - 'type' => 'back', - 'name' => ts('Previous'), - ), - array( - 'type' => 'next', - 'name' => ts('Continue'), - 'spacing' => '          ', - 'isDefault' => TRUE, - ), - array( - 'type' => 'cancel', - 'name' => ts('Cancel'), - ), - ) - ); + $this->addButtons([ + [ + 'type' => 'back', + 'name' => ts('Previous'), + ], + [ + 'type' => 'next', + 'name' => ts('Continue'), + 'spacing' => '          ', + 'isDefault' => TRUE, + ], + [ + 'type' => 'cancel', + 'name' => ts('Cancel'), + ], + ]); } /** @@ -323,25 +328,25 @@ public function buildQuickForm() { * list of errors to be posted back to the form */ public static function formRule($fields, $files, $self) { - $errors = array(); + $errors = []; $fieldMessage = NULL; $contactORContributionId = $self->_onDuplicate == CRM_Import_Parser::DUPLICATE_UPDATE ? 'contribution_id' : 'contribution_contact_id'; if (!array_key_exists('savedMapping', $fields)) { - $importKeys = array(); + $importKeys = []; foreach ($fields['mapper'] as $mapperPart) { $importKeys[] = $mapperPart[0]; } $contactTypeId = $self->get('contactType'); - $contactTypes = array( + $contactTypes = [ CRM_Import_Parser::CONTACT_INDIVIDUAL => 'Individual', CRM_Import_Parser::CONTACT_HOUSEHOLD => 'Household', CRM_Import_Parser::CONTACT_ORGANIZATION => 'Organization', - ); - $params = array( + ]; + $params = [ 'used' => 'Unsupervised', 'contact_type' => isset($contactTypes[$contactTypeId]) ? $contactTypes[$contactTypeId] : '', - ); + ]; list($ruleFields, $threshold) = CRM_Dedupe_BAO_RuleGroup::dedupeRuleFieldsWeight($params); $weightSum = 0; foreach ($importKeys as $key => $val) { @@ -363,11 +368,11 @@ public static function formRule($fields, $files, $self) { } // FIXME: should use the schema titles, not redeclare them - $requiredFields = array( + $requiredFields = [ $contactORContributionId == 'contribution_id' ? 'contribution_id' : 'contribution_contact_id' => $contactORContributionId == 'contribution_id' ? ts('Contribution ID') : ts('Contact ID'), 'total_amount' => ts('Total Amount'), 'financial_type' => ts('Financial Type'), - ); + ]; foreach ($requiredFields as $field => $title) { if (!in_array($field, $importKeys)) { @@ -378,9 +383,9 @@ public static function formRule($fields, $files, $self) { if (!($weightSum >= $threshold || in_array('external_identifier', $importKeys)) && $self->_onDuplicate != CRM_Import_Parser::DUPLICATE_UPDATE ) { - $errors['_qf_default'] .= ts('Missing required contact matching fields.') . " $fieldMessage " . ts('(Sum of all weights should be greater than or equal to threshold: %1).', array( + $errors['_qf_default'] .= ts('Missing required contact matching fields.') . " $fieldMessage " . ts('(Sum of all weights should be greater than or equal to threshold: %1).', [ 1 => $threshold, - )) . '
    '; + ]) . '
    '; } elseif ($self->_onDuplicate == CRM_Import_Parser::DUPLICATE_UPDATE && !(in_array('invoice_id', $importKeys) || in_array('trxn_id', $importKeys) || @@ -391,9 +396,9 @@ public static function formRule($fields, $files, $self) { } } else { - $errors['_qf_default'] .= ts('Missing required field: %1', array( + $errors['_qf_default'] .= ts('Missing required field: %1', [ 1 => $title, - )) . '
    '; + ]) . '
    '; } } } @@ -403,7 +408,12 @@ public static function formRule($fields, $files, $self) { $atleastOne = FALSE; foreach ($self->_mapperFields as $key => $field) { if (in_array($key, $importKeys) && - !in_array($key, array('doNotImport', 'contribution_id', 'invoice_id', 'trxn_id')) + !in_array($key, [ + 'doNotImport', + 'contribution_id', + 'invoice_id', + 'trxn_id', + ]) ) { $atleastOne = TRUE; break; @@ -459,7 +469,7 @@ public function postProcess() { $seperator = $this->controller->exportValue('DataSource', 'fieldSeparator'); $skipColumnHeader = $this->controller->exportValue('DataSource', 'skipColumnHeader'); - $mapper = $mapperKeys = $mapperKeysMain = $mapperSoftCredit = $softCreditFields = $mapperPhoneType = $mapperSoftCreditType = array(); + $mapper = $mapperKeys = $mapperKeysMain = $mapperSoftCredit = $softCreditFields = $mapperPhoneType = $mapperSoftCreditType = []; $mapperKeys = $this->controller->exportValue($this->_name, 'mapper'); $softCreditTypes = CRM_Core_OptionGroup::values('soft_credit_type'); @@ -477,10 +487,10 @@ public function postProcess() { else { $softCreditFields[$i] = $mapperSoftCredit[$i]; } - $mapperSoftCreditType[$i] = array( + $mapperSoftCreditType[$i] = [ 'value' => isset($mapperKeys[$i][2]) ? $mapperKeys[$i][2] : '', 'label' => isset($softCreditTypes[$mapperKeys[$i][2]]) ? $softCreditTypes[$mapperKeys[$i][2]] : '', - ); + ]; } else { $mapperSoftCredit[$i] = $softCreditFields[$i] = $mapperSoftCreditType[$i] = NULL; @@ -500,7 +510,7 @@ public function postProcess() { $mappingFields->mapping_id = $params['mappingId']; $mappingFields->find(); - $mappingFieldsId = array(); + $mappingFieldsId = []; while ($mappingFields->fetch()) { if ($mappingFields->id) { $mappingFieldsId[$mappingFields->column_number] = $mappingFields->id; @@ -522,11 +532,11 @@ public function postProcess() { //Saving Mapping Details and Records if (!empty($params['saveMapping'])) { - $mappingParams = array( + $mappingParams = [ 'name' => $params['saveMappingName'], 'description' => $params['saveMappingDesc'], 'mapping_type_id' => CRM_Core_PseudoConstant::getKey('CRM_Core_BAO_Mapping', 'mapping_type_id', 'Import Contribution'), - ); + ]; $saveMapping = CRM_Core_BAO_Mapping::add($mappingParams); for ($i = 0; $i < $this->_columnCount; $i++) { From 7265b08312ac2639849a77f4beb2d48ddf281500 Mon Sep 17 00:00:00 2001 From: eileen Date: Fri, 5 Apr 2019 19:50:42 +1300 Subject: [PATCH 081/121] [NFC] Reformat tricksy file CRM_Mailing_BAO_Mailing --- CRM/Mailing/BAO/Mailing.php | 646 +++++++++++++++++------------------- 1 file changed, 305 insertions(+), 341 deletions(-) diff --git a/CRM/Mailing/BAO/Mailing.php b/CRM/Mailing/BAO/Mailing.php index ce320a9b2683..a6e37494c442 100644 --- a/CRM/Mailing/BAO/Mailing.php +++ b/CRM/Mailing/BAO/Mailing.php @@ -104,7 +104,7 @@ public static function getRecipientsCount($mailingID) { //rebuild the recipients self::getRecipients($mailingID); - return civicrm_api3('MailingRecipients', 'getcount', array('mailing_id' => $mailingID)); + return civicrm_api3('MailingRecipients', 'getcount', ['mailing_id' => $mailingID]); } /** @@ -125,14 +125,14 @@ public static function getRecipients($mailingID) { $isSMSmode = (!CRM_Utils_System::isNull($mailingObj->sms_provider_id)); $mailingGroup = new CRM_Mailing_DAO_MailingGroup(); - $recipientsGroup = $excludeSmartGroupIDs = $includeSmartGroupIDs = $priorMailingIDs = array(); + $recipientsGroup = $excludeSmartGroupIDs = $includeSmartGroupIDs = $priorMailingIDs = []; $dao = CRM_Utils_SQL_Select::from('civicrm_mailing_group') - ->select('GROUP_CONCAT(entity_id SEPARATOR ",") as group_ids, group_type, entity_table') - ->where('mailing_id = #mailing_id AND entity_table RLIKE "^civicrm_(group.*|mailing)$" ') - ->groupBy(array('group_type', 'entity_table')) - ->param('!groupTableName', CRM_Contact_BAO_Group::getTableName()) - ->param('#mailing_id', $mailingID) - ->execute(); + ->select('GROUP_CONCAT(entity_id SEPARATOR ",") as group_ids, group_type, entity_table') + ->where('mailing_id = #mailing_id AND entity_table RLIKE "^civicrm_(group.*|mailing)$" ') + ->groupBy(['group_type', 'entity_table']) + ->param('!groupTableName', CRM_Contact_BAO_Group::getTableName()) + ->param('#mailing_id', $mailingID) + ->execute(); while ($dao->fetch()) { if ($dao->entity_table == 'civicrm_mailing') { $priorMailingIDs[$dao->group_type] = explode(',', $dao->group_ids); @@ -145,7 +145,12 @@ public static function getRecipients($mailingID) { // there is no need to proceed further if no mailing group is selected to include recipients, // but before return clear the mailing recipients populated earlier since as per current params no group is selected if (empty($recipientsGroup['Include']) && empty($priorMailingIDs['Include'])) { - CRM_Core_DAO::executeQuery(" DELETE FROM civicrm_mailing_recipients WHERE mailing_id = %1 ", array(1 => array($mailingID, 'Integer'))); + CRM_Core_DAO::executeQuery(" DELETE FROM civicrm_mailing_recipients WHERE mailing_id = %1 ", [ + 1 => [ + $mailingID, + 'Integer', + ], + ]); return; } @@ -190,7 +195,7 @@ public static function getRecipients($mailingID) { ->select('DISTINCT contact_id') ->where('status = "Added" AND group_id IN (#groups)') ->param('#groups', $recipientsGroup['Exclude']) - ->insertInto($excludeTempTablename, array('contact_id')) + ->insertInto($excludeTempTablename, ['contact_id']) ->execute(); if (count($excludeSmartGroupIDs)) { @@ -198,7 +203,7 @@ public static function getRecipients($mailingID) { ->select('contact_id') ->where('group_id IN (#groups)') ->param('#groups', $excludeSmartGroupIDs) - ->insertIgnoreInto($excludeTempTablename, array('contact_id')) + ->insertIgnoreInto($excludeTempTablename, ['contact_id']) ->execute(); } } @@ -207,7 +212,7 @@ public static function getRecipients($mailingID) { ->select('DISTINCT contact_id') ->where('mailing_id IN (#mailings)') ->param('#mailings', $priorMailingIDs['Exclude']) - ->insertIgnoreInto($excludeTempTablename, array('contact_id')) + ->insertIgnoreInto($excludeTempTablename, ['contact_id']) ->execute(); } @@ -216,7 +221,7 @@ public static function getRecipients($mailingID) { ->select('DISTINCT contact_id') ->where('status = "Removed" AND group_id IN (#groups)') ->param('#groups', $recipientsGroup['Base']) - ->insertIgnoreInto($excludeTempTablename, array('contact_id')) + ->insertIgnoreInto($excludeTempTablename, ['contact_id']) ->execute(); } @@ -230,7 +235,7 @@ public static function getRecipients($mailingID) { ); if ($isSMSmode) { - $criteria = array( + $criteria = [ 'is_opt_out' => CRM_Utils_SQL_Select::fragment()->where("$contact.is_opt_out = 0"), 'is_deceased' => CRM_Utils_SQL_Select::fragment()->where("$contact.is_deceased <> 1"), 'do_not_sms' => CRM_Utils_SQL_Select::fragment()->where("$contact.do_not_sms = 0"), @@ -240,11 +245,11 @@ public static function getRecipients($mailingID) { 'mailing_id' => CRM_Utils_SQL_Select::fragment()->where("mg.mailing_id = #mailingID"), 'temp_contact_null' => CRM_Utils_SQL_Select::fragment()->where('temp.contact_id IS null'), 'order_by' => CRM_Utils_SQL_Select::fragment()->orderBy("$entityTable.is_primary"), - ); + ]; } else { // Criterias to filter recipients that need to be included - $criteria = array( + $criteria = [ 'do_not_email' => CRM_Utils_SQL_Select::fragment()->where("$contact.do_not_email = 0"), 'is_opt_out' => CRM_Utils_SQL_Select::fragment()->where("$contact.is_opt_out = 0"), 'is_deceased' => CRM_Utils_SQL_Select::fragment()->where("$contact.is_deceased <> 1"), @@ -255,7 +260,7 @@ public static function getRecipients($mailingID) { 'mailing_id' => CRM_Utils_SQL_Select::fragment()->where("mg.mailing_id = #mailingID"), 'temp_contact_null' => CRM_Utils_SQL_Select::fragment()->where('temp.contact_id IS NULL'), 'order_by' => CRM_Utils_SQL_Select::fragment()->orderBy($order_by), - ); + ]; } // Allow user to alter query responsible to fetch mailing recipients before build, @@ -273,8 +278,8 @@ public static function getRecipients($mailingID) { ->join('temp', " LEFT JOIN $excludeTempTablename temp ON $contact.id = temp.contact_id ") ->where('gc.group_id IN (#groups) AND gc.status = "Added"') ->merge($criteria) - ->groupBy(array("$contact.id", "$entityTable.id")) - ->replaceInto($includedTempTablename, array('contact_id', $entityColumn)) + ->groupBy(["$contact.id", "$entityTable.id"]) + ->replaceInto($includedTempTablename, ['contact_id', $entityColumn]) ->param('#groups', $recipientsGroup['Include']) ->param('#mailingID', $mailingID) ->execute(); @@ -288,7 +293,10 @@ public static function getRecipients($mailingID) { ->where('mailing_id IN (#mailings)') ->where('temp.contact_id IS NULL') ->param('#mailings', $priorMailingIDs['Include']) - ->insertIgnoreInto($includedTempTablename, array('contact_id', $entityColumn)) + ->insertIgnoreInto($includedTempTablename, [ + 'contact_id', + $entityColumn, + ]) ->execute(); } @@ -303,7 +311,7 @@ public static function getRecipients($mailingID) { ->where('gc.group_id IN (#groups)') ->where('gcr.status IS NULL OR gcr.status != "Removed"') ->merge($criteria) - ->replaceInto($includedTempTablename, array('contact_id', $entityColumn)) + ->replaceInto($includedTempTablename, ['contact_id', $entityColumn]) ->param('#groups', $includeSmartGroupIDs) ->param('#mailingID', $mailingID) ->execute(); @@ -311,10 +319,10 @@ public static function getRecipients($mailingID) { // Construct the filtered search queries. $dao = CRM_Utils_SQL_Select::from('civicrm_mailing_group') - ->select('search_id, search_args, entity_id') - ->where('search_id IS NOT NULL AND mailing_id = #mailingID') - ->param('#mailingID', $mailingID) - ->execute(); + ->select('search_id, search_args, entity_id') + ->where('search_id IS NOT NULL AND mailing_id = #mailingID') + ->param('#mailingID', $mailingID) + ->execute(); while ($dao->fetch()) { $customSQL = CRM_Contact_BAO_SearchCustom::civiMailSQL($dao->search_id, $dao->search_args, @@ -327,18 +335,30 @@ public static function getRecipients($mailingID) { list($aclFrom, $aclWhere) = CRM_Contact_BAO_Contact_Permission::cacheClause(); // clear all the mailing recipients before populating - CRM_Core_DAO::executeQuery(" DELETE FROM civicrm_mailing_recipients WHERE mailing_id = %1 ", array(1 => array($mailingID, 'Integer'))); - - $selectClause = array('#mailingID', 'i.contact_id', "i.$entityColumn"); + CRM_Core_DAO::executeQuery(" DELETE FROM civicrm_mailing_recipients WHERE mailing_id = %1 ", [ + 1 => [ + $mailingID, + 'Integer', + ], + ]); + + $selectClause = ['#mailingID', 'i.contact_id', "i.$entityColumn"]; // CRM-3975 - $orderBy = array("i.contact_id", "i.$entityColumn"); + $orderBy = ["i.contact_id", "i.$entityColumn"]; - $query = CRM_Utils_SQL_Select::from('civicrm_contact contact_a')->join('i', " INNER JOIN {$includedTempTablename} i ON contact_a.id = i.contact_id "); + $query = CRM_Utils_SQL_Select::from('civicrm_contact contact_a') + ->join('i', " INNER JOIN {$includedTempTablename} i ON contact_a.id = i.contact_id "); if (!$isSMSmode && $mailingObj->dedupe_email) { - $orderBy = array("MIN(i.contact_id)", "MIN(i.$entityColumn)"); - $query = $query->join('e', " INNER JOIN civicrm_email e ON e.id = i.email_id ")->groupBy("e.email"); + $orderBy = ["MIN(i.contact_id)", "MIN(i.$entityColumn)"]; + $query = $query->join('e', " INNER JOIN civicrm_email e ON e.id = i.email_id ") + ->groupBy("e.email"); if (CRM_Utils_SQL::supportsFullGroupBy()) { - $selectClause = array('#mailingID', 'ANY_VALUE(i.contact_id) contact_id', "ANY_VALUE(i.$entityColumn) $entityColumn", "e.email"); + $selectClause = [ + '#mailingID', + 'ANY_VALUE(i.contact_id) contact_id', + "ANY_VALUE(i.$entityColumn) $entityColumn", + "e.email", + ]; } } @@ -358,12 +378,12 @@ public static function getRecipients($mailingID) { $sql = $query->toSQL(); CRM_Utils_SQL_Select::from("( $sql ) AS i ") ->select($selectClause) - ->insertInto('civicrm_mailing_recipients', array('mailing_id', 'contact_id', $entityColumn)) + ->insertInto('civicrm_mailing_recipients', ['mailing_id', 'contact_id', $entityColumn]) ->param('#mailingID', $mailingID) ->execute(); } else { - $query->insertInto('civicrm_mailing_recipients', array('mailing_id', 'contact_id', $entityColumn)) + $query->insertInto('civicrm_mailing_recipients', ['mailing_id', 'contact_id', $entityColumn]) ->param('#mailingID', $mailingID) ->execute(); } @@ -401,14 +421,14 @@ public static function getLocationFilterAndOrderBy($email_selection_method, $loc $location_filter = "($email.location_type_id != $location_type_id)"; // If there is more than one email that doesn't match the location, // prefer the one marked is_bulkmail, followed by is_primary. - $orderBy = array("$email.is_bulkmail", "$email.is_primary"); + $orderBy = ["$email.is_bulkmail", "$email.is_primary"]; break; case 'location-only': $location_filter = "($email.location_type_id = $location_type_id)"; // If there is more than one email of the desired location, prefer // the one marked is_bulkmail, followed by is_primary. - $orderBy = array("$email.is_bulkmail", "$email.is_primary"); + $orderBy = ["$email.is_bulkmail", "$email.is_primary"]; break; case 'location-prefer': @@ -422,17 +442,21 @@ public static function getLocationFilterAndOrderBy($email_selection_method, $loc // types are left out, so they will be assigned the value 0. That // means, they will all be equally tied for first place, with our // location being last. - $orderBy = array("FIELD($email.location_type_id, $location_type_id)", "$email.is_bulkmail", "$email.is_primary"); + $orderBy = [ + "FIELD($email.location_type_id, $location_type_id)", + "$email.is_bulkmail", + "$email.is_primary", + ]; break; case 'automatic': // fall through to default default: $location_filter = "($email.is_bulkmail = 1 OR $email.is_primary = 1)"; - $orderBy = array("$email.is_bulkmail"); + $orderBy = ["$email.is_bulkmail"]; } - return array($location_filter, $orderBy); + return [$location_filter, $orderBy]; } /** @@ -460,7 +484,7 @@ private function _getMailingGroupIds($type = 'Include') { } $mailingGroup->query($query); - $groupIds = array(); + $groupIds = []; while ($mailingGroup->fetch()) { $groupIds[] = $mailingGroup->entity_id; } @@ -477,7 +501,7 @@ private function _getMailingGroupIds($type = 'Include') { */ private function getPatterns($onlyHrefs = FALSE) { - $patterns = array(); + $patterns = []; $protos = '(https?|ftp|mailto)'; $letters = '\w'; @@ -516,19 +540,19 @@ public function &getDataFunc($token) { static $_categories = NULL; static $_categoryString = NULL; if (!$_categories) { - $_categories = array( + $_categories = [ 'domain' => NULL, 'action' => NULL, 'mailing' => NULL, 'contact' => NULL, - ); + ]; CRM_Utils_Hook::tokens($_categories); $_categoryString = implode('|', array_keys($_categories)); } - $funcStruct = array('type' => NULL, 'token' => $token); - $matches = array(); + $funcStruct = ['type' => NULL, 'token' => $token]; + $matches = []; if ((preg_match('/^href/i', $token) || preg_match('/^http/i', $token))) { // it is a url so we need to check to see if there are any tokens embedded // if so then call this function again to get the token dataFunc @@ -536,7 +560,7 @@ public function &getDataFunc($token) { // will know what how to handle this token. if (preg_match_all('/(\{\w+\.\w+\})/', $token, $matches)) { $funcStruct['type'] = 'embedded_url'; - $funcStruct['embed_parts'] = $funcStruct['token'] = array(); + $funcStruct['embed_parts'] = $funcStruct['token'] = []; foreach ($matches[1] as $match) { $preg_token = '/' . preg_quote($match, '/') . '/'; $list = preg_split($preg_token, $token, 2); @@ -580,20 +604,20 @@ private function getPreparedTemplates() { $patterns['subject'] = $patterns['text'] = $this->getPatterns(); $templates = $this->getTemplates(); - $this->preparedTemplates = array(); + $this->preparedTemplates = []; - foreach (array( + foreach ([ 'html', 'text', 'subject', - ) as $key) { + ] as $key) { if (!isset($templates[$key])) { continue; } - $matches = array(); - $tokens = array(); - $split_template = array(); + $matches = []; + $tokens = []; + $split_template = []; $email = $templates[$key]; preg_match_all($patterns[$key], $email, $matches, PREG_PATTERN_ORDER); @@ -623,9 +647,9 @@ private function getPreparedTemplates() { public function getTemplates() { if (!$this->templates) { $this->getHeaderFooter(); - $this->templates = array(); + $this->templates = []; if ($this->body_text || !empty($this->header)) { - $template = array(); + $template = []; if (!empty($this->header->body_text)) { $template[] = $this->header->body_text; } @@ -653,7 +677,7 @@ public function getTemplates() { // To check for an html part strip tags if (trim(strip_tags($this->body_html, ''))) { - $template = array(); + $template = []; if ($this->header) { $template[] = $this->header->body_html; } @@ -675,7 +699,7 @@ public function getTemplates() { } if ($this->subject) { - $template = array(); + $template = []; $template[] = $this->subject; $this->templates['subject'] = implode("\n", $template); } @@ -703,7 +727,7 @@ public function getTemplates() { public function &getTokens() { if (!$this->tokens) { - $this->tokens = array('html' => array(), 'text' => array(), 'subject' => array()); + $this->tokens = ['html' => [], 'text' => [], 'subject' => []]; if ($this->body_html) { $this->_getTokens('html'); @@ -766,7 +790,7 @@ private function _getTokens($prop) { foreach ($newTokens as $type => $names) { if (!isset($this->tokens[$prop][$type])) { - $this->tokens[$prop][$type] = array(); + $this->tokens[$prop][$type] = []; } foreach ($names as $key => $name) { $this->tokens[$prop][$type][] = $name; @@ -784,14 +808,14 @@ private function _getTokens($prop) { */ public function getTestRecipients($testParams) { if (!empty($testParams['test_group']) && array_key_exists($testParams['test_group'], CRM_Core_PseudoConstant::group())) { - $contacts = civicrm_api('contact', 'get', array( + $contacts = civicrm_api('contact', 'get', [ 'version' => 3, 'group' => $testParams['test_group'], 'return' => 'id', - 'options' => array( + 'options' => [ 'limit' => 100000000000, - ), - ) + ], + ] ); foreach (array_keys($contacts['values']) as $groupContact) { @@ -812,11 +836,11 @@ public function getTestRecipients($testParams) { "; $dao = CRM_Core_DAO::executeQuery($query); if ($dao->fetch()) { - $params = array( + $params = [ 'job_id' => $testParams['job_id'], 'email_id' => $dao->email_id, 'contact_id' => $groupContact, - ); + ]; CRM_Mailing_Event_BAO_Queue::create($params); } } @@ -871,7 +895,7 @@ public static function addMessageIdHeader(&$headers, $prefix, $job_id, $event_qu $localpart = CRM_Core_BAO_MailSettings::defaultLocalpart(); $emailDomain = CRM_Core_BAO_MailSettings::defaultDomain(); $includeMessageId = CRM_Core_BAO_MailSettings::includeMessageId(); - $fields = array(); + $fields = []; $fields[] = 'Message-ID'; // CRM-17754 check if Resent-Message-id is set also if not add it in when re-laying reply email if ($prefix == 'r') { @@ -880,12 +904,12 @@ public static function addMessageIdHeader(&$headers, $prefix, $job_id, $event_qu foreach ($fields as $field) { if ($includeMessageId && (!array_key_exists($field, $headers))) { $headers[$field] = '<' . implode($config->verpSeparator, - array( + [ $localpart . $prefix, $job_id, $event_queue_id, $hash, - ) + ] ) . "@{$emailDomain}>"; } } @@ -916,7 +940,7 @@ public static function getVerpAndUrls($job_id, $event_queue_id, $hash, $email) { // use $bao's instance method to get verp and urls list($verp, $urls, $_) = $bao->getVerpAndUrlsAndHeaders($job_id, $event_queue_id, $hash, $email); - return array($verp, $urls); + return [$verp, $urls]; } /** @@ -947,14 +971,14 @@ public function getVerpAndUrlsAndHeaders($job_id, $event_queue_id, $hash, $email * resubscribe: contact opts back into all target lists for the mailing * optOut: contact unsubscribes from the domain */ - $verp = array(); - $verpTokens = array( + $verp = []; + $verpTokens = [ 'reply' => 'r', 'bounce' => 'b', 'unsubscribe' => 'u', 'resubscribe' => 'e', 'optOut' => 'o', - ); + ]; $localpart = CRM_Core_BAO_MailSettings::defaultLocalpart(); $emailDomain = CRM_Core_BAO_MailSettings::defaultDomain(); @@ -965,12 +989,12 @@ public function getVerpAndUrlsAndHeaders($job_id, $event_queue_id, $hash, $email foreach ($verpTokens as $key => $value) { $verp[$key] = implode($config->verpSeparator, - array( + [ $localpart . $value, $job_id, $event_queue_id, $hash, - ) + ] ) . "@$emailDomain"; } @@ -983,41 +1007,26 @@ public function getVerpAndUrlsAndHeaders($job_id, $event_queue_id, $hash, $email $verp['reply'] = "\"{$this->from_name}\" <{$this->from_email}>"; } - $urls = array( - 'forward' => CRM_Utils_System::url('civicrm/mailing/forward', - "reset=1&jid={$job_id}&qid={$event_queue_id}&h={$hash}", - TRUE, NULL, TRUE, TRUE - ), - 'unsubscribeUrl' => CRM_Utils_System::url('civicrm/mailing/unsubscribe', - "reset=1&jid={$job_id}&qid={$event_queue_id}&h={$hash}", - TRUE, NULL, TRUE, TRUE - ), - 'resubscribeUrl' => CRM_Utils_System::url('civicrm/mailing/resubscribe', - "reset=1&jid={$job_id}&qid={$event_queue_id}&h={$hash}", - TRUE, NULL, TRUE, TRUE - ), - 'optOutUrl' => CRM_Utils_System::url('civicrm/mailing/optout', - "reset=1&jid={$job_id}&qid={$event_queue_id}&h={$hash}", - TRUE, NULL, TRUE, TRUE - ), - 'subscribeUrl' => CRM_Utils_System::url('civicrm/mailing/subscribe', - 'reset=1', - TRUE, NULL, TRUE, TRUE - ), - ); + $urls = [ + 'forward' => CRM_Utils_System::url('civicrm/mailing/forward', "reset=1&jid={$job_id}&qid={$event_queue_id}&h={$hash}", TRUE, NULL, TRUE, TRUE), + 'unsubscribeUrl' => CRM_Utils_System::url('civicrm/mailing/unsubscribe', "reset=1&jid={$job_id}&qid={$event_queue_id}&h={$hash}", TRUE, NULL, TRUE, TRUE), + 'resubscribeUrl' => CRM_Utils_System::url('civicrm/mailing/resubscribe', "reset=1&jid={$job_id}&qid={$event_queue_id}&h={$hash}", TRUE, NULL, TRUE, TRUE), + 'optOutUrl' => CRM_Utils_System::url('civicrm/mailing/optout', "reset=1&jid={$job_id}&qid={$event_queue_id}&h={$hash}", TRUE, NULL, TRUE, TRUE), + 'subscribeUrl' => CRM_Utils_System::url('civicrm/mailing/subscribe', 'reset=1', TRUE, NULL, TRUE, TRUE), + ]; - $headers = array( + $headers = [ 'Reply-To' => $verp['reply'], 'Return-Path' => $verp['bounce'], 'From' => "\"{$this->from_name}\" <{$this->from_email}>", 'Subject' => $this->subject, 'List-Unsubscribe' => "", - ); + ]; self::addMessageIdHeader($headers, 'm', $job_id, $event_queue_id, $hash); if ($isForward) { $headers['Subject'] = "[Fwd:{$this->subject}]"; } - return array(&$verp, &$urls, &$headers); + return [&$verp, &$urls, &$headers]; } /** @@ -1086,11 +1095,11 @@ public function compose( } elseif ($contactId === 0) { //anonymous user - $contact = array(); + $contact = []; CRM_Utils_Hook::tokenValues($contact, $contactId, $job_id); } else { - $params = array(array('contact_id', '=', $contactId, 0, 0)); + $params = [['contact_id', '=', $contactId, 0, 0]]; list($contact) = CRM_Contact_BAO_Query::apiQuery($params); //CRM-4524 @@ -1098,7 +1107,7 @@ public function compose( if (!$contact || is_a($contact, 'CRM_Core_Error')) { CRM_Core_Error::debug_log_message(ts('CiviMail will not send email to a non-existent contact: %1', - array(1 => $contactId) + [1 => $contactId] )); // setting this because function is called by reference //@todo test not calling function by reference @@ -1111,11 +1120,11 @@ public function compose( } $pTemplates = $this->getPreparedTemplates(); - $pEmails = array(); + $pEmails = []; foreach ($pTemplates as $type => $pTemplate) { $html = ($type == 'html') ? TRUE : FALSE; - $pEmails[$type] = array(); + $pEmails[$type] = []; $pEmail = &$pEmails[$type]; $template = &$pTemplates[$type]['template']; $tokens = &$pTemplates[$type]['tokens']; @@ -1190,7 +1199,7 @@ public function compose( // CRM-9833 // something went wrong, lets log it and return null (by reference) CRM_Core_Error::debug_log_message(ts('CiviMail will not send an empty mail body, Skipping: %1', - array(1 => $email) + [1 => $email] )); $res = NULL; return $res; @@ -1220,13 +1229,13 @@ public function compose( //cycle through mailParams and set headers array foreach ($mailParams as $paramKey => $paramValue) { //exclude values not intended for the header - if (!in_array($paramKey, array( + if (!in_array($paramKey, [ 'text', 'html', 'attachments', 'toName', 'toEmail', - )) + ]) ) { $headers[$paramKey] = $paramValue; } @@ -1300,7 +1309,7 @@ public function compose( public static function tokenReplace(&$mailing) { $domain = CRM_Core_BAO_Domain::getDomain(); - foreach (array('text', 'html') as $type) { + foreach (['text', 'html'] as $type) { $tokens = $mailing->getTokens(); if (isset($mailing->templates[$type])) { $mailing->templates[$type] = CRM_Utils_Token::replaceSubscribeInviteTokens($mailing->templates[$type]); @@ -1339,7 +1348,7 @@ private function getTokenData(&$token_a, $html = FALSE, &$contact, &$verp, &$url $useSmarty = defined('CIVICRM_MAIL_SMARTY') && CIVICRM_MAIL_SMARTY ? TRUE : FALSE; if ($type == 'embedded_url') { - $embed_data = array(); + $embed_data = []; foreach ($token as $t) { $embed_data[] = $this->getTokenData($t, $html, $contact, $verp, $urls, $event_queue_id); } @@ -1413,7 +1422,7 @@ private function getTokenData(&$token_a, $html = FALSE, &$contact, &$verp, &$url */ public function &getGroupNames() { if (!isset($this->id)) { - return array(); + return []; } $mg = new CRM_Mailing_DAO_MailingGroup(); $mgtable = CRM_Mailing_DAO_MailingGroup::getTableName(); @@ -1426,7 +1435,7 @@ public function &getGroupNames() { AND $mgtable.group_type = 'Include' ORDER BY $group.name"); - $groups = array(); + $groups = []; while ($mg->fetch()) { $groups[] = $mg->name; } @@ -1445,7 +1454,7 @@ public function &getGroupNames() { * * @return CRM_Mailing_DAO_Mailing */ - public static function add(&$params, $ids = array()) { + public static function add(&$params, $ids = []) { $id = CRM_Utils_Array::value('id', $params, CRM_Utils_Array::value('mailing_id', $ids)); if (empty($params['id']) && !empty($ids)) { @@ -1522,7 +1531,7 @@ public static function add(&$params, $ids = array()) { * $mailing The new mailing object * @throws \Exception */ - public static function create(&$params, $ids = array()) { + public static function create(&$params, $ids = []) { if (empty($params['id']) && (array_filter($ids) !== [])) { $params['id'] = isset($ids['mailing_id']) ? $ids['mailing_id'] : $ids['id']; @@ -1537,11 +1546,11 @@ public static function create(&$params, $ids = array()) { $domain = civicrm_api( 'Domain', 'getsingle', - array( + [ 'version' => 3, 'current_domain' => 1, 'sequential' => 1, - ) + ] ); if (isset($domain['from_email'])) { $domain_email = $domain['from_email']; @@ -1555,7 +1564,7 @@ public static function create(&$params, $ids = array()) { $session =& CRM_Core_Session::singleton(); $params['created_id'] = $session->get('userID'); } - $defaults = array( + $defaults = [ // load the default config settings for each // eg reply_id, unsubscribe_id need to use // correct template IDs here @@ -1576,7 +1585,7 @@ public static function create(&$params, $ids = array()) { 'created_date' => date('YmdHis'), 'scheduled_date' => NULL, 'approval_date' => NULL, - ); + ]; // Get the default from email address, if not provided. if (empty($defaults['from_email'])) { @@ -1614,9 +1623,13 @@ public static function create(&$params, $ids = array()) { /* Create the mailing group record */ $mg = new CRM_Mailing_DAO_MailingGroup(); - $groupTypes = array('include' => 'Include', 'exclude' => 'Exclude', 'base' => 'Base'); - foreach (array('groups', 'mailings') as $entity) { - foreach (array('include', 'exclude', 'base') as $type) { + $groupTypes = [ + 'include' => 'Include', + 'exclude' => 'Exclude', + 'base' => 'Base', + ]; + foreach (['groups', 'mailings'] as $entity) { + foreach (['include', 'exclude', 'base'] as $type) { if (isset($params[$entity][$type])) { self::replaceGroups($mailing->id, $groupTypes[$type], $entity, $params[$entity][$type]); } @@ -1639,7 +1652,8 @@ public static function create(&$params, $ids = array()) { // If we're going to autosend, then check validity before saving. if (empty($params['is_completed']) && !empty($params['scheduled_date']) && $params['scheduled_date'] != 'null' && !empty($params['_evil_bao_validator_'])) { - $cb = Civi\Core\Resolver::singleton()->get($params['_evil_bao_validator_']); + $cb = Civi\Core\Resolver::singleton() + ->get($params['_evil_bao_validator_']); $errors = call_user_func($cb, $mailing); if (!empty($errors)) { $fields = implode(',', array_keys($errors)); @@ -1686,12 +1700,12 @@ public static function create(&$params, $ids = array()) { * List of error messages. */ public static function checkSendable($mailing) { - $errors = array(); - foreach (array('subject', 'name', 'from_name', 'from_email') as $field) { + $errors = []; + foreach (['subject', 'name', 'from_name', 'from_email'] as $field) { if (empty($mailing->{$field})) { - $errors[$field] = ts('Field "%1" is required.', array( + $errors[$field] = ts('Field "%1" is required.', [ 1 => $field, - )); + ]); } } if (empty($mailing->body_html) && empty($mailing->body_text)) { @@ -1701,7 +1715,7 @@ public static function checkSendable($mailing) { if (!Civi::settings()->get('disable_mandatory_tokens_check')) { $header = $mailing->header_id && $mailing->header_id != 'null' ? CRM_Mailing_BAO_MailingComponent::findById($mailing->header_id) : NULL; $footer = $mailing->footer_id && $mailing->footer_id != 'null' ? CRM_Mailing_BAO_MailingComponent::findById($mailing->footer_id) : NULL; - foreach (array('body_html', 'body_text') as $field) { + foreach (['body_html', 'body_text'] as $field) { if (empty($mailing->{$field})) { continue; } @@ -1710,7 +1724,7 @@ public static function checkSendable($mailing) { if ($err !== TRUE) { foreach ($err as $token => $desc) { $errors["{$field}:{$token}"] = ts('This message is missing a required token - {%1}: %2', - array(1 => $token, 2 => $desc) + [1 => $token, 2 => $desc] ); } } @@ -1732,16 +1746,16 @@ public static function checkSendable($mailing) { * @throws CiviCRM_API3_Exception */ public static function replaceGroups($mailingId, $type, $entity, $entityIds) { - $values = array(); + $values = []; foreach ($entityIds as $entityId) { - $values[] = array('entity_id' => $entityId); + $values[] = ['entity_id' => $entityId]; } - civicrm_api3('mailing_group', 'replace', array( + civicrm_api3('mailing_group', 'replace', [ 'mailing_id' => $mailingId, 'group_type' => $type, 'entity_table' => ($entity == 'groups') ? CRM_Contact_BAO_Group::getTableName() : CRM_Mailing_BAO_Mailing::getTableName(), 'values' => $values, - )); + ]); } /** @@ -1778,7 +1792,7 @@ public static function &report($id, $skipDetails = FALSE, $isSMS = FALSE) { $mailing = new CRM_Mailing_BAO_Mailing(); - $t = array( + $t = [ 'mailing' => self::getTableName(), 'mailing_group' => CRM_Mailing_DAO_MailingGroup::getTableName(), 'group' => CRM_Contact_BAO_Group::getTableName(), @@ -1794,9 +1808,9 @@ public static function &report($id, $skipDetails = FALSE, $isSMS = FALSE) { 'urlopen' => CRM_Mailing_Event_BAO_TrackableURLOpen::getTableName(), 'component' => CRM_Mailing_BAO_MailingComponent::getTableName(), 'spool' => CRM_Mailing_BAO_Spool::getTableName(), - ); + ]; - $report = array(); + $report = []; $additionalWhereClause = " AND "; if (!$isSMS) { $additionalWhereClause .= " {$t['mailing']}.sms_provider_id IS NULL "; @@ -1814,7 +1828,7 @@ public static function &report($id, $skipDetails = FALSE, $isSMS = FALSE) { $mailing->fetch(); - $report['mailing'] = array(); + $report['mailing'] = []; foreach (array_keys(self::fields()) as $field) { if ($field == 'mailing_modified_date') { $field = 'modified_date'; @@ -1836,16 +1850,16 @@ public static function &report($id, $skipDetails = FALSE, $isSMS = FALSE) { /* Get the component info */ - $query = array(); + $query = []; - $components = array( + $components = [ 'header' => ts('Header'), 'footer' => ts('Footer'), 'reply' => ts('Reply'), 'optout' => ts('Opt-Out'), 'resubscribe' => ts('Resubscribe'), 'unsubscribe' => ts('Unsubscribe'), - ); + ]; foreach (array_keys($components) as $type) { $query[] = "SELECT {$t['component']}.name as name, '$type' as type, @@ -1859,15 +1873,13 @@ public static function &report($id, $skipDetails = FALSE, $isSMS = FALSE) { $q = '(' . implode(') UNION (', $query) . ')'; $mailing->query($q); - $report['component'] = array(); + $report['component'] = []; while ($mailing->fetch()) { - $report['component'][] = array( + $report['component'][] = [ 'type' => $components[$mailing->type], 'name' => $mailing->name, - 'link' => CRM_Utils_System::url('civicrm/mailing/component', - "reset=1&action=update&id={$mailing->id}" - ), - ); + 'link' => CRM_Utils_System::url('civicrm/mailing/component', "reset=1&action=update&id={$mailing->id}"), + ]; } /* Get the recipient group info */ @@ -1893,9 +1905,9 @@ public static function &report($id, $skipDetails = FALSE, $isSMS = FALSE) { WHERE {$t['mailing_group']}.mailing_id = $mailing_id "); - $report['group'] = array('include' => array(), 'exclude' => array(), 'base' => array()); + $report['group'] = ['include' => [], 'exclude' => [], 'base' => []]; while ($mailing->fetch()) { - $row = array(); + $row = []; if (isset($mailing->group_id)) { $row['id'] = $mailing->group_id; $row['name'] = $mailing->group_title; @@ -1960,9 +1972,10 @@ public static function &report($id, $skipDetails = FALSE, $isSMS = FALSE) { AND {$t['job']}.is_test = 0 GROUP BY {$t['job']}.id"); - $report['jobs'] = array(); - $report['event_totals'] = array(); - $elements = array( + $report['jobs'] = []; + $report['event_totals'] = []; + $path = 'civicrm/mailing/report/event'; + $elements = [ 'queue', 'delivered', 'url', @@ -1974,7 +1987,7 @@ public static function &report($id, $skipDetails = FALSE, $isSMS = FALSE) { 'total_opened', 'bounce', 'spool', - ); + ]; // initialize various counters foreach ($elements as $field) { @@ -1982,7 +1995,7 @@ public static function &report($id, $skipDetails = FALSE, $isSMS = FALSE) { } while ($mailing->fetch()) { - $row = array(); + $row = []; foreach ($elements as $field) { if (isset($mailing->$field)) { $row[$field] = $mailing->$field; @@ -2026,46 +2039,19 @@ public static function &report($id, $skipDetails = FALSE, $isSMS = FALSE) { $row['clickthrough_rate'] = 0; } - $row['links'] = array( - 'clicks' => CRM_Utils_System::url( - 'civicrm/mailing/report/event', - "reset=1&event=click&mid=$mailing_id&jid={$mailing->id}" - ), - 'queue' => CRM_Utils_System::url( - 'civicrm/mailing/report/event', - "reset=1&event=queue&mid=$mailing_id&jid={$mailing->id}" - ), - 'delivered' => CRM_Utils_System::url( - 'civicrm/mailing/report/event', - "reset=1&event=delivered&mid=$mailing_id&jid={$mailing->id}" - ), - 'bounce' => CRM_Utils_System::url( - 'civicrm/mailing/report/event', - "reset=1&event=bounce&mid=$mailing_id&jid={$mailing->id}" - ), - 'unsubscribe' => CRM_Utils_System::url( - 'civicrm/mailing/report/event', - "reset=1&event=unsubscribe&mid=$mailing_id&jid={$mailing->id}" - ), - 'forward' => CRM_Utils_System::url( - 'civicrm/mailing/report/event', - "reset=1&event=forward&mid=$mailing_id&jid={$mailing->id}" - ), - 'reply' => CRM_Utils_System::url( - 'civicrm/mailing/report/event', - "reset=1&event=reply&mid=$mailing_id&jid={$mailing->id}" - ), - 'opened' => CRM_Utils_System::url( - 'civicrm/mailing/report/event', - "reset=1&event=opened&mid=$mailing_id&jid={$mailing->id}" - ), - ); + $arg = "reset=1&mid=$mailing_id&jid={$mailing->id}"; + $row['links'] = [ + 'clicks' => CRM_Utils_System::url($path, "$arg&event=click"), + 'queue' => CRM_Utils_System::url($path, "$arg&event=queue"), + 'delivered' => CRM_Utils_System::url($path, "$arg&event=delivered"), + 'bounce' => CRM_Utils_System::url($path, "$arg&event=bounce"), + 'unsubscribe' => CRM_Utils_System::url($path, "$arg&event=unsubscribe"), + 'forward' => CRM_Utils_System::url($path, "$arg&event=forward"), + 'reply' => CRM_Utils_System::url($path, "$arg&event=reply"), + 'opened' => CRM_Utils_System::url($path, "$arg&event=opened"), + ]; - foreach (array( - 'scheduled_date', - 'start_date', - 'end_date', - ) as $key) { + foreach (['scheduled_date', 'start_date', 'end_date'] as $key) { $row[$key] = CRM_Utils_Date::customFormat($row[$key]); } $report['jobs'][] = $row; @@ -2118,90 +2104,43 @@ public static function &report($id, $skipDetails = FALSE, $isSMS = FALSE) { GROUP BY {$t['url']}.id ORDER BY unique_clicks DESC"); - $report['click_through'] = array(); + $report['click_through'] = []; while ($mailing->fetch()) { - $report['click_through'][] = array( + $report['click_through'][] = [ 'url' => $mailing->url, - 'link' => CRM_Utils_System::url( - 'civicrm/mailing/report/event', - "reset=1&event=click&mid=$mailing_id&uid={$mailing->id}" - ), - 'link_unique' => CRM_Utils_System::url( - 'civicrm/mailing/report/event', - "reset=1&event=click&mid=$mailing_id&uid={$mailing->id}&distinct=1" - ), + 'link' => CRM_Utils_System::url($path, "reset=1&event=click&mid=$mailing_id&uid={$mailing->id}"), + 'link_unique' => CRM_Utils_System::url($path, "reset=1&event=click&mid=$mailing_id&uid={$mailing->id}&distinct=1"), 'clicks' => $mailing->clicks, 'unique' => $mailing->unique_clicks, 'rate' => CRM_Utils_Array::value('delivered', $report['event_totals']) ? (100.0 * $mailing->unique_clicks) / $report['event_totals']['delivered'] : 0, 'report' => CRM_Report_Utils_Report::getNextUrl('mailing/clicks', "reset=1&mailing_id_value={$mailing_id}&url_value={$mailing->url}", FALSE, TRUE), - ); - } - - $report['event_totals']['links'] = array( - 'clicks' => CRM_Utils_System::url( - 'civicrm/mailing/report/event', - "reset=1&event=click&mid=$mailing_id" - ), - 'clicks_unique' => CRM_Utils_System::url( - 'civicrm/mailing/report/event', - "reset=1&event=click&mid=$mailing_id&distinct=1" - ), - 'queue' => CRM_Utils_System::url( - 'civicrm/mailing/report/event', - "reset=1&event=queue&mid=$mailing_id" - ), - 'delivered' => CRM_Utils_System::url( - 'civicrm/mailing/report/event', - "reset=1&event=delivered&mid=$mailing_id" - ), - 'bounce' => CRM_Utils_System::url( - 'civicrm/mailing/report/event', - "reset=1&event=bounce&mid=$mailing_id" - ), - 'unsubscribe' => CRM_Utils_System::url( - 'civicrm/mailing/report/event', - "reset=1&event=unsubscribe&mid=$mailing_id" - ), - 'optout' => CRM_Utils_System::url( - 'civicrm/mailing/report/event', - "reset=1&event=optout&mid=$mailing_id" - ), - 'forward' => CRM_Utils_System::url( - 'civicrm/mailing/report/event', - "reset=1&event=forward&mid=$mailing_id" - ), - 'reply' => CRM_Utils_System::url( - 'civicrm/mailing/report/event', - "reset=1&event=reply&mid=$mailing_id" - ), - 'opened' => CRM_Utils_System::url( - 'civicrm/mailing/report/event', - "reset=1&event=opened&mid=$mailing_id" - ), - ); - - $actionLinks = array(CRM_Core_Action::VIEW => array('name' => ts('Report'))); - $actionLinks[CRM_Core_Action::ADVANCED] = array( + ]; + } + + $arg = "reset=1&mid=$mailing_id"; + $report['event_totals']['links'] = [ + 'clicks' => CRM_Utils_System::url($path, "$arg&event=click"), + 'clicks_unique' => CRM_Utils_System::url($path, "$arg&event=click&distinct=1"), + 'queue' => CRM_Utils_System::url($path, "$arg&event=queue"), + 'delivered' => CRM_Utils_System::url($path, "$arg&event=delivered"), + 'bounce' => CRM_Utils_System::url($path, "$arg&event=bounce"), + 'unsubscribe' => CRM_Utils_System::url($path, "$arg&event=unsubscribe"), + 'optout' => CRM_Utils_System::url($path, "$arg&event=optout"), + 'forward' => CRM_Utils_System::url($path, "$arg&event=forward"), + 'reply' => CRM_Utils_System::url($path, "$arg&event=reply"), + 'opened' => CRM_Utils_System::url($path, "$arg&event=opened"), + ]; + + $actionLinks = [CRM_Core_Action::VIEW => ['name' => ts('Report')]]; + $actionLinks[CRM_Core_Action::ADVANCED] = [ 'name' => ts('Advanced Search'), 'url' => 'civicrm/contact/search/advanced', - ); + ]; $action = array_sum(array_keys($actionLinks)); - $report['event_totals']['actionlinks'] = array(); - foreach (array( - 'clicks', - 'clicks_unique', - 'queue', - 'delivered', - 'bounce', - 'unsubscribe', - 'forward', - 'reply', - 'opened', - 'opened_unique', - 'optout', - ) as $key) { + $report['event_totals']['actionlinks'] = []; + foreach (['clicks', 'clicks_unique', 'queue', 'delivered', 'bounce', 'unsubscribe', 'forward', 'reply', 'opened', 'opened_unique', 'optout'] as $key) { $url = 'mailing/detail'; $reportFilter = "reset=1&mailing_id_value={$mailing_id}"; $searchFilter = "force=1&mailing_id=%%mid%%"; @@ -2256,7 +2195,7 @@ public static function &report($id, $skipDetails = FALSE, $isSMS = FALSE) { $report['event_totals']['actionlinks'][$key] = CRM_Core_Action::formLink( $actionLinks, $action, - array('mid' => $mailing_id), + ['mid' => $mailing_id], ts('more'), FALSE, 'mailing.report.action', @@ -2348,15 +2287,15 @@ public static function mailingACLIDs() { return TRUE; } - $mailingIDs = array(); + $mailingIDs = []; // get all the groups that this user can access // if they dont have universal access - $groupNames = civicrm_api3('Group', 'get', array( + $groupNames = civicrm_api3('Group', 'get', [ 'check_permissions' => TRUE, - 'return' => array('title', 'id'), - 'options' => array('limit' => 0), - )); + 'return' => ['title', 'id'], + 'options' => ['limit' => 0], + ]); foreach ($groupNames['values'] as $group) { $groups[$group['id']] = $group['title']; } @@ -2374,7 +2313,7 @@ public static function mailingACLIDs() { "; $dao = CRM_Core_DAO::executeQuery($query); - $mailingIDs = array(); + $mailingIDs = []; while ($dao->fetch()) { $mailingIDs[] = $dao->id; } @@ -2422,13 +2361,21 @@ public function &getRows($offset, $rowCount, $sort, $additionalClause = NULL, $a //get all campaigns. $allCampaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE); - $select = array( - "$mailing.id", "$mailing.name", "$job.status", - "$mailing.approval_status_id", "createdContact.sort_name as created_by", "scheduledContact.sort_name as scheduled_by", - "$mailing.created_id as created_id", "$mailing.scheduled_id as scheduled_id", "$mailing.is_archived as archived", - "$mailing.created_date as created_date", "campaign_id", "$mailing.sms_provider_id as sms_provider_id", + $select = [ + "$mailing.id", + "$mailing.name", + "$job.status", + "$mailing.approval_status_id", + "createdContact.sort_name as created_by", + "scheduledContact.sort_name as scheduled_by", + "$mailing.created_id as created_id", + "$mailing.scheduled_id as scheduled_id", + "$mailing.is_archived as archived", + "$mailing.created_date as created_date", + "campaign_id", + "$mailing.sms_provider_id as sms_provider_id", "$mailing.language", - ); + ]; // we only care about parent jobs, since that holds all the info on // the mailing @@ -2464,14 +2411,14 @@ public function &getRows($offset, $rowCount, $sort, $additionalClause = NULL, $a } if (!$additionalParams) { - $additionalParams = array(); + $additionalParams = []; } $dao = CRM_Core_DAO::executeQuery($query, $additionalParams); - $rows = array(); + $rows = []; while ($dao->fetch()) { - $rows[] = array( + $rows[] = [ 'id' => $dao->id, 'name' => $dao->name, 'status' => $dao->status ? $dao->status : 'Not scheduled', @@ -2490,7 +2437,7 @@ public function &getRows($offset, $rowCount, $sort, $additionalClause = NULL, $a 'campaign' => empty($dao->campaign_id) ? NULL : $allCampaigns[$dao->campaign_id], 'sms_provider_id' => $dao->sms_provider_id, 'language' => $dao->language, - ); + ]; } return $rows; } @@ -2562,7 +2509,7 @@ public static function delJob($id) { public function getReturnProperties() { $tokens = &$this->getTokens(); - $properties = array(); + $properties = []; if (isset($tokens['html']) && isset($tokens['html']['contact']) ) { @@ -2581,7 +2528,7 @@ public function getReturnProperties() { $properties = array_merge($properties, $tokens['subject']['contact']); } - $returnProperties = array(); + $returnProperties = []; $returnProperties['display_name'] = $returnProperties['contact_id'] = $returnProperties['preferred_mail_format'] = $returnProperties['hash'] = 1; foreach ($properties as $p) { @@ -2600,7 +2547,7 @@ public function getReturnProperties() { */ public static function commonCompose(&$form) { //get the tokens. - $tokens = array(); + $tokens = []; if (method_exists($form, 'listTokens')) { $tokens = array_merge($form->listTokens(), $tokens); @@ -2609,10 +2556,13 @@ public static function commonCompose(&$form) { //sorted in ascending order tokens by ignoring word case $form->assign('tokens', CRM_Utils_Token::formatTokensForDisplay($tokens)); - $templates = array(); + $templates = []; - $textFields = array('text_message' => ts('HTML Format'), 'sms_text_message' => ts('SMS Message')); - $modePrefixes = array('Mail' => NULL, 'SMS' => 'SMS'); + $textFields = [ + 'text_message' => ts('HTML Format'), + 'sms_text_message' => ts('SMS Message'), + ]; + $modePrefixes = ['Mail' => NULL, 'SMS' => 'SMS']; $className = CRM_Utils_System::getClassName($form); @@ -2621,11 +2571,11 @@ public static function commonCompose(&$form) { ) { $form->add('wysiwyg', 'html_message', strstr($className, 'PDF') ? ts('Document Body') : ts('HTML Format'), - array( + [ 'cols' => '80', 'rows' => '8', 'onkeyup' => "return verify(this)", - ) + ] ); if ($className != 'CRM_Admin_Form_ScheduleReminders') { @@ -2645,11 +2595,11 @@ public static function commonCompose(&$form) { $form->assign('max_sms_length', CRM_SMS_Provider::MAX_SMS_CHAR); } $form->add('textarea', $id, $label, - array( + [ 'cols' => '80', 'rows' => '8', 'onkeyup' => "return verify(this, '{$prefix}')", - ) + ] ); } @@ -2664,14 +2614,14 @@ public static function commonCompose(&$form) { $form->assign('templates', TRUE); $form->add('select', "{$prefix}template", ts('Use Template'), - array('' => ts('- select -')) + $templates[$prefix], FALSE, - array('onChange' => "selectValue( this.value, '{$prefix}');") + ['' => ts('- select -')] + $templates[$prefix], FALSE, + ['onChange' => "selectValue( this.value, '{$prefix}');"] ); } $form->add('checkbox', "{$prefix}updateTemplate", ts('Update Template'), NULL); $form->add('checkbox', "{$prefix}saveTemplate", ts('Save As New Template'), NULL, FALSE, - array('onclick' => "showSaveDetails(this, '{$prefix}');") + ['onclick' => "showSaveDetails(this, '{$prefix}');"] ); $form->add('text', "{$prefix}saveTemplateName", ts('Template Title')); } @@ -2679,7 +2629,7 @@ public static function commonCompose(&$form) { // I'm not sure this is ever called. $action = CRM_Utils_Request::retrieve('action', 'String', $form, FALSE); if ((CRM_Utils_System::getClassName($form) == 'CRM_Contact_Form_Task_PDF') && - $action == CRM_Core_Action::VIEW + $action == CRM_Core_Action::VIEW ) { $form->freeze('html_message'); } @@ -2702,7 +2652,7 @@ public function searchMailingIDs() { AND $group.group_type = 'Base'"; $searchDAO = CRM_Core_DAO::executeQuery($query); - $mailingIDs = array(); + $mailingIDs = []; while ($searchDAO->fetch()) { $mailingIDs[] = $searchDAO->mailing_id; } @@ -2777,7 +2727,7 @@ public static function getMailingContent(&$report, &$form, $isSMS = FALSE) { * @return mixed */ public static function overrideVerp($jobID) { - static $_cache = array(); + static $_cache = []; if (!isset($_cache[$jobID])) { $query = " @@ -2786,7 +2736,7 @@ public static function overrideVerp($jobID) { INNER JOIN civicrm_mailing_job ON civicrm_mailing.id = civicrm_mailing_job.mailing_id WHERE civicrm_mailing_job.id = %1 "; - $params = array(1 => array($jobID, 'Integer')); + $params = [1 => [$jobID, 'Integer']]; $_cache[$jobID] = CRM_Core_DAO::singleValueQuery($query, $params); } return $_cache[$jobID]; @@ -2802,10 +2752,10 @@ public static function processQueue($mode = NULL) { $config = CRM_Core_Config::singleton(); if ($mode == NULL && CRM_Core_BAO_MailSettings::defaultDomain() == "EXAMPLE.ORG") { - throw new CRM_Core_Exception(ts('The default mailbox has not been configured. You will find more info in the online system administrator guide', array( - 1 => CRM_Utils_System::url('civicrm/admin/mailSettings', 'reset=1'), - 2 => "https://docs.civicrm.org/sysadmin/en/latest/setup/civimail/", - ))); + throw new CRM_Core_Exception(ts('The default mailbox has not been configured. You will find more info in the online system administrator guide', [ + 1 => CRM_Utils_System::url('civicrm/admin/mailSettings', 'reset=1'), + 2 => "https://docs.civicrm.org/sysadmin/en/latest/setup/civimail/", + ])); } // check if we are enforcing number of parallel cron jobs @@ -2821,7 +2771,8 @@ public static function processQueue($mode = NULL) { // Check if we are using global locks foreach ($lockArray as $lockID) { - $cronLock = Civi::lockManager()->acquire("worker.mailing.send.{$lockID}"); + $cronLock = Civi::lockManager() + ->acquire("worker.mailing.send.{$lockID}"); if ($cronLock->isAcquired()) { $gotCronLock = TRUE; break; @@ -2868,7 +2819,7 @@ private static function addMultipleEmails($mailingID) { ( SELECT contact_id FROM civicrm_mailing_recipients mr WHERE mailing_id = %1 ) AND e.id NOT IN ( SELECT email_id FROM civicrm_mailing_recipients mr WHERE mailing_id = %1 ) "; - $params = array(1 => array($mailingID, 'Integer')); + $params = [1 => [$mailingID, 'Integer']]; $dao = CRM_Core_DAO::executeQuery($sql, $params); } @@ -2879,7 +2830,7 @@ private static function addMultipleEmails($mailingID) { * @return mixed */ public static function getMailingsList($isSMS = FALSE) { - static $list = array(); + static $list = []; $where = " WHERE "; if (!$isSMS) { $where .= " civicrm_mailing.sms_provider_id IS NULL "; @@ -2933,9 +2884,9 @@ public static function getContactMailingSelector(&$params) { } // format params and add links - $contactMailings = array(); + $contactMailings = []; foreach ($mailings as $mailingId => $values) { - $mailing = array(); + $mailing = []; $mailing['subject'] = $values['subject']; $mailing['creator_name'] = CRM_Utils_System::href( $values['creator_name'], @@ -2950,21 +2901,21 @@ public static function getContactMailingSelector(&$params) { "
    Clicks: " . CRM_Utils_Array::value($values['mailing_id'], $clickCounts, 0); - $actionLinks = array( - CRM_Core_Action::VIEW => array( + $actionLinks = [ + CRM_Core_Action::VIEW => [ 'name' => ts('View'), 'url' => 'civicrm/mailing/view', 'qs' => "reset=1&id=%%mkey%%", 'title' => ts('View Mailing'), 'class' => 'crm-popup', - ), - CRM_Core_Action::BROWSE => array( + ], + CRM_Core_Action::BROWSE => [ 'name' => ts('Mailing Report'), 'url' => 'civicrm/mailing/report', 'qs' => "mid=%%mid%%&reset=1&cid=%%cid%%&context=mailing", 'title' => ts('View Mailing Report'), - ), - ); + ], + ]; $mailingKey = $values['mailing_id']; if ($hash = CRM_Mailing_BAO_Mailing::getMailingHash($mailingKey)) { @@ -2974,11 +2925,11 @@ public static function getContactMailingSelector(&$params) { $mailing['links'] = CRM_Core_Action::formLink( $actionLinks, NULL, - array( + [ 'mid' => $values['mailing_id'], 'cid' => $params['contact_id'], 'mkey' => $mailingKey, - ), + ], ts('more'), FALSE, 'mailing.contact.action', @@ -2989,7 +2940,7 @@ public static function getContactMailingSelector(&$params) { array_push($contactMailings, $mailing); } - $contactMailingsDT = array(); + $contactMailingsDT = []; $contactMailingsDT['data'] = $contactMailings; $contactMailingsDT['recordsTotal'] = $params['total']; $contactMailingsDT['recordsFiltered'] = $params['total']; @@ -3039,27 +2990,37 @@ static public function getContactMailingsCount(&$params) { */ public static function getWorkflowFieldPerms() { $fieldNames = array_keys(CRM_Mailing_DAO_Mailing::fields()); - $fieldPerms = array(); + $fieldPerms = []; foreach ($fieldNames as $fieldName) { if ($fieldName == 'id') { - $fieldPerms[$fieldName] = array( - array('access CiviMail', 'schedule mailings', 'approve mailings', 'create mailings'), // OR - ); - } - elseif (in_array($fieldName, array('scheduled_date', 'scheduled_id'))) { - $fieldPerms[$fieldName] = array( - array('access CiviMail', 'schedule mailings'), // OR - ); - } - elseif (in_array($fieldName, array('approval_date', 'approver_id', 'approval_status_id', 'approval_note'))) { - $fieldPerms[$fieldName] = array( - array('access CiviMail', 'approve mailings'), // OR - ); + $fieldPerms[$fieldName] = [ + [ + 'access CiviMail', + 'schedule mailings', + 'approve mailings', + 'create mailings', + ], // OR + ]; + } + elseif (in_array($fieldName, ['scheduled_date', 'scheduled_id'])) { + $fieldPerms[$fieldName] = [ + ['access CiviMail', 'schedule mailings'], // OR + ]; + } + elseif (in_array($fieldName, [ + 'approval_date', + 'approver_id', + 'approval_status_id', + 'approval_note', + ])) { + $fieldPerms[$fieldName] = [ + ['access CiviMail', 'approve mailings'], // OR + ]; } else { - $fieldPerms[$fieldName] = array( - array('access CiviMail', 'create mailings'), // OR - ); + $fieldPerms[$fieldName] = [ + ['access CiviMail', 'create mailings'], // OR + ]; } } return $fieldPerms; @@ -3071,10 +3032,10 @@ public static function getWorkflowFieldPerms() { * @return array */ public static function mailingGroupEntityTables() { - return array( + return [ CRM_Contact_BAO_Group::getTableName() => 'Group', CRM_Mailing_BAO_Mailing::getTableName() => 'Mailing', - ); + ]; } /** @@ -3086,8 +3047,11 @@ public static function mailingGroupEntityTables() { * @return string */ public static function getPublicViewUrl($id, $absolute = TRUE) { - if ((civicrm_api3('Mailing', 'getvalue', array('id' => $id, 'return' => 'visibility'))) === 'Public Pages') { - return CRM_Utils_System::url('civicrm/mailing/view', array('id' => $id), $absolute, NULL, TRUE, TRUE); + if ((civicrm_api3('Mailing', 'getvalue', [ + 'id' => $id, + 'return' => 'visibility', + ])) === 'Public Pages') { + return CRM_Utils_System::url('civicrm/mailing/view', ['id' => $id], $absolute, NULL, TRUE, TRUE); } } @@ -3103,16 +3067,16 @@ public static function getPublicViewUrl($id, $absolute = TRUE) { */ public static function getTemplateTypes() { if (!isset(Civi::$statics[__CLASS__]['templateTypes'])) { - $types = array(); - $types[] = array( + $types = []; + $types[] = [ 'name' => 'traditional', 'editorUrl' => CRM_Mailing_Info::workflowEnabled() ? '~/crmMailing/EditMailingCtrl/workflow.html' : '~/crmMailing/EditMailingCtrl/2step.html', 'weight' => 0, - ); + ]; CRM_Utils_Hook::mailingTemplateTypes($types); - $defaults = array('weight' => 0); + $defaults = ['weight' => 0]; foreach (array_keys($types) as $typeName) { $types[$typeName] = array_merge($defaults, $types[$typeName]); } @@ -3136,7 +3100,7 @@ public static function getTemplateTypes() { * Array(string $name => string $label). */ public static function getTemplateTypeNames() { - $r = array(); + $r = []; foreach (self::getTemplateTypes() as $type) { $r[$type['name']] = $type['name']; } From 21f8fcf7c6c0988324b1c472a179814f98183d64 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Fri, 5 Apr 2019 13:04:21 -0700 Subject: [PATCH 082/121] (NFC) Civi/ - Update to pass new phpcs --- Civi/Core/DAO/Event/PostDelete.php | 1 + Civi/Core/DAO/Event/PostUpdate.php | 1 + Civi/Core/DAO/Event/PreDelete.php | 1 + 3 files changed, 3 insertions(+) diff --git a/Civi/Core/DAO/Event/PostDelete.php b/Civi/Core/DAO/Event/PostDelete.php index 2f5cfdeaac19..e90732da7a4b 100644 --- a/Civi/Core/DAO/Event/PostDelete.php +++ b/Civi/Core/DAO/Event/PostDelete.php @@ -51,4 +51,5 @@ public function __construct($object, $result) { $this->object = $object; $this->result = $result; } + } diff --git a/Civi/Core/DAO/Event/PostUpdate.php b/Civi/Core/DAO/Event/PostUpdate.php index 6cb18839bd34..362f026c5a65 100644 --- a/Civi/Core/DAO/Event/PostUpdate.php +++ b/Civi/Core/DAO/Event/PostUpdate.php @@ -44,4 +44,5 @@ class PostUpdate extends \Symfony\Component\EventDispatcher\Event { public function __construct($object) { $this->object = $object; } + } diff --git a/Civi/Core/DAO/Event/PreDelete.php b/Civi/Core/DAO/Event/PreDelete.php index 3bfe944ece51..7182c30e705e 100644 --- a/Civi/Core/DAO/Event/PreDelete.php +++ b/Civi/Core/DAO/Event/PreDelete.php @@ -44,4 +44,5 @@ class PreDelete extends \Symfony\Component\EventDispatcher\Event { public function __construct($object) { $this->object = $object; } + } From e122e55d89d351b1d22979ae15d6c76bb3bbecca Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Fri, 5 Apr 2019 13:11:11 -0700 Subject: [PATCH 083/121] (NFC) CRM/ - Update to pass new phpcs --- CRM/Contact/BAO/Contact.php | 12 ++++----- CRM/Contact/Page/View/Summary.php | 5 +--- .../Exception/CheckLineItemsException.php | 26 +++++++++---------- CRM/Core/I18n/SchemaStructure.php | 10 +++---- CRM/Dedupe/Merger.php | 3 ++- 5 files changed, 27 insertions(+), 29 deletions(-) diff --git a/CRM/Contact/BAO/Contact.php b/CRM/Contact/BAO/Contact.php index f620157027d5..4a8d50a5199c 100644 --- a/CRM/Contact/BAO/Contact.php +++ b/CRM/Contact/BAO/Contact.php @@ -2398,12 +2398,12 @@ public static function formatProfileContactParams( 'prefix_id', 'suffix_id', )) && - ($value == '' || !isset($value)) && - ($session->get('authSrc') & (CRM_Core_Permission::AUTH_SRC_CHECKSUM + CRM_Core_Permission::AUTH_SRC_LOGIN)) == 0 || - ($key == 'current_employer' && empty($params['current_employer']))) { - // CRM-10128: if auth source is not checksum / login && $value is blank, do not fill $data with empty value - // to avoid update with empty values - continue; + ($value == '' || !isset($value)) && + ($session->get('authSrc') & (CRM_Core_Permission::AUTH_SRC_CHECKSUM + CRM_Core_Permission::AUTH_SRC_LOGIN)) == 0 || + ($key == 'current_employer' && empty($params['current_employer']))) { + // CRM-10128: if auth source is not checksum / login && $value is blank, do not fill $data with empty value + // to avoid update with empty values + continue; } else { $data[$key] = $value; diff --git a/CRM/Contact/Page/View/Summary.php b/CRM/Contact/Page/View/Summary.php index 79f375ca81d2..f91a87480b61 100644 --- a/CRM/Contact/Page/View/Summary.php +++ b/CRM/Contact/Page/View/Summary.php @@ -411,10 +411,7 @@ public function getTabs() { } elseif ($accessCiviCRM && !empty($this->_viewOptions[$tab['id']])) { $allTabs[] = $tab + [ - 'url' => CRM_Utils_System::url( - "civicrm/contact/view/{$tab['id']}", - "reset=1&cid={$this->_contactId}" - ), + 'url' => CRM_Utils_System::url("civicrm/contact/view/{$tab['id']}", "reset=1&cid={$this->_contactId}"), 'count' => CRM_Contact_BAO_Contact::getCountComponent($tab['id'], $this->_contactId), ]; $weight = $tab['weight'] + 10; diff --git a/CRM/Contribute/Exception/CheckLineItemsException.php b/CRM/Contribute/Exception/CheckLineItemsException.php index d14a3aec98f9..c1c0d3a91427 100644 --- a/CRM/Contribute/Exception/CheckLineItemsException.php +++ b/CRM/Contribute/Exception/CheckLineItemsException.php @@ -1,13 +1,13 @@ - [ @@ -211,7 +211,7 @@ public static function &columns() { * Indices for translatable fields. */ public static function &indices() { - static $result = null; + static $result = NULL; if (!$result) { $result = [ 'civicrm_custom_group' => [ @@ -255,7 +255,7 @@ public static function &indices() { * Array of names of tables with fields that can be translated. */ static function &tables() { - static $result = null; + static $result = NULL; if (!$result) { $result = array_keys(self::columns()); } @@ -269,7 +269,7 @@ static function &tables() { * Array of the widgets for editing translatable fields. */ static function &widgets() { - static $result = null; + static $result = NULL; if (!$result) { $result = [ 'civicrm_location_type' => [ diff --git a/CRM/Dedupe/Merger.php b/CRM/Dedupe/Merger.php index ca2f28d0a5f8..3cab5581bbd1 100644 --- a/CRM/Dedupe/Merger.php +++ b/CRM/Dedupe/Merger.php @@ -472,7 +472,8 @@ public static function removeContactBelongings($otherID, $tables) { "return" => "id", ] ) - )); + ) + ); if (!empty($membershipIDs)) { civicrm_api3("Membership", "get", [ From e29f3512514e921eed4a34336c312ff8189e4e6c Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Fri, 5 Apr 2019 13:13:25 -0700 Subject: [PATCH 084/121] (NFC) api/v3 - Update to pass new phpcs --- api/v3/Domain.php | 2 +- api/v3/Event.php | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/api/v3/Domain.php b/api/v3/Domain.php index 94e5c52a9746..552121fbe13c 100644 --- a/api/v3/Domain.php +++ b/api/v3/Domain.php @@ -85,7 +85,7 @@ function civicrm_api3_domain_get($params) { 'phone', $values['location']['phone'][1] ), - ]; + ]; } if (!empty($values['location']['address'])) { diff --git a/api/v3/Event.php b/api/v3/Event.php index 5bbb7dc7a37b..dba0f7da4684 100644 --- a/api/v3/Event.php +++ b/api/v3/Event.php @@ -255,11 +255,7 @@ function _civicrm_api3_event_getlist_output($result, $request) { 'id' => $row[$request['id_field']], 'label' => $row[$request['label_field']], 'description' => [ - CRM_Core_Pseudoconstant::getLabel( - 'CRM_Event_BAO_Event', - 'event_type_id', - $row['event_type_id'] - ), + CRM_Core_Pseudoconstant::getLabel('CRM_Event_BAO_Event', 'event_type_id', $row['event_type_id']), ], ]; if (!empty($row['start_date'])) { From 420384a058a18b230102483b4cb9f2abfdc413db Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Fri, 5 Apr 2019 13:16:23 -0700 Subject: [PATCH 085/121] (NFC) tests/ - Update to pass new phpcs --- tests/phpunit/CRM/Export/BAO/ExportTest.php | 4 +- tests/phpunit/CRM/Price/Form/FieldTest.php | 170 ++++++++++---------- tests/phpunit/CiviTest/CiviUnitTestCase.php | 2 +- tests/phpunit/E2E/Extern/RestTest.php | 7 +- 4 files changed, 91 insertions(+), 92 deletions(-) diff --git a/tests/phpunit/CRM/Export/BAO/ExportTest.php b/tests/phpunit/CRM/Export/BAO/ExportTest.php index f1341e1f1841..00626abc0f83 100644 --- a/tests/phpunit/CRM/Export/BAO/ExportTest.php +++ b/tests/phpunit/CRM/Export/BAO/ExportTest.php @@ -1724,14 +1724,14 @@ public function textExportParticipantSpecifyFieldsNoPayment() { $selectedFields = $this->getAllSpecifiableParticipantReturnFields(); foreach ($selectedFields as $index => $field) { if (substr($field[1], 0, 22) === 'componentPaymentField_') { - unset ($selectedFields[$index]); + unset($selectedFields[$index]); } } $expected = $this->getAllSpecifiableParticipantReturnFields(); foreach ($expected as $index => $field) { if (substr($index, 0, 22) === 'componentPaymentField_') { - unset ($expected[$index]); + unset($expected[$index]); } } diff --git a/tests/phpunit/CRM/Price/Form/FieldTest.php b/tests/phpunit/CRM/Price/Form/FieldTest.php index d1c13513bc0e..08ede64999d0 100644 --- a/tests/phpunit/CRM/Price/Form/FieldTest.php +++ b/tests/phpunit/CRM/Price/Form/FieldTest.php @@ -1,85 +1,85 @@ -visibilityOptionsKeys = CRM_Price_BAO_PriceFieldValue::buildOptions('visibility_id', NULL, array( - 'labelColumn' => 'name', - 'flip' => TRUE, - )); - - $this->publicFieldParams = $this->initializeFieldParameters(array( - 'label' => 'Public Price Field', - 'name' => 'public_price', - 'visibility_id' => $this->visibilityOptionsKeys['public'], - )); - - $this->adminFieldParams = $this->initializeFieldParameters(array( - 'label' => 'Public Price Field', - 'name' => 'public_price', - 'visibility_id' => $this->visibilityOptionsKeys['admin'], - )); - } - - public function testPublicFieldWithOnlyAdminOptionsIsNotAllowed() { - $this->publicFieldParams['option_label'][1] = 'Admin Price'; - $this->publicFieldParams['option_amount'][1] = 10; - $this->publicFieldParams['option_visibility_id'][1] = $this->visibilityOptionsKeys['admin']; - - $form = new CRM_Price_Form_Field(); - $form->_action = CRM_Core_Action::ADD; - $files = array(); - - $validationResult = $form->formRule($this->publicFieldParams, $files, $form); - $this->assertType('array', $validationResult); - $this->assertTrue(array_key_exists('visibility_id', $validationResult)); - } - - public function testAdminFieldDoesNotAllowPublicOptions() { - $this->adminFieldParams['option_label'][1] = 'Admin Price'; - $this->adminFieldParams['option_amount'][1] = 10; - $this->adminFieldParams['option_visibility_id'][1] = $this->visibilityOptionsKeys['public']; - - $form = new CRM_Price_Form_Field(); - $form->_action = CRM_Core_Action::ADD; - $files = array(); - - $validationResult = $form->formRule($this->adminFieldParams, $files, $form); - $this->assertType('array', $validationResult); - $this->assertTrue(array_key_exists('visibility_id', $validationResult)); - } - - private function initializeFieldParameters($params) { - $defaultParams = array( - 'label' => 'Price Field', - 'name' => CRM_Utils_String::titleToVar('Price Field'), - 'html_type' => 'Select', - 'is_display_amounts' => 1, - 'weight' => 1, - 'options_per_line' => 1, - 'is_enter_qty' => 1, - 'financial_type_id' => $this->getFinancialTypeId('Event Fee'), - 'visibility_id' => $this->visibilityOptionsKeys['public'], - ); - - for ($index = 1; $index <= CRM_Price_Form_Field::NUM_OPTION; $index++) { - $defaultParams['option_label'][$index] = NULL; - $defaultParams['option_value'][$index] = NULL; - $defaultParams['option_name'][$index] = NULL; - $defaultParams['option_weight'][$index] = NULL; - $defaultParams['option_amount'][$index] = NULL; - $defaultParams['option_visibility_id'][$index] = NULL; - } - - return array_merge($defaultParams, $params); - } - -} +visibilityOptionsKeys = CRM_Price_BAO_PriceFieldValue::buildOptions('visibility_id', NULL, array( + 'labelColumn' => 'name', + 'flip' => TRUE, + )); + + $this->publicFieldParams = $this->initializeFieldParameters(array( + 'label' => 'Public Price Field', + 'name' => 'public_price', + 'visibility_id' => $this->visibilityOptionsKeys['public'], + )); + + $this->adminFieldParams = $this->initializeFieldParameters(array( + 'label' => 'Public Price Field', + 'name' => 'public_price', + 'visibility_id' => $this->visibilityOptionsKeys['admin'], + )); + } + + public function testPublicFieldWithOnlyAdminOptionsIsNotAllowed() { + $this->publicFieldParams['option_label'][1] = 'Admin Price'; + $this->publicFieldParams['option_amount'][1] = 10; + $this->publicFieldParams['option_visibility_id'][1] = $this->visibilityOptionsKeys['admin']; + + $form = new CRM_Price_Form_Field(); + $form->_action = CRM_Core_Action::ADD; + $files = array(); + + $validationResult = $form->formRule($this->publicFieldParams, $files, $form); + $this->assertType('array', $validationResult); + $this->assertTrue(array_key_exists('visibility_id', $validationResult)); + } + + public function testAdminFieldDoesNotAllowPublicOptions() { + $this->adminFieldParams['option_label'][1] = 'Admin Price'; + $this->adminFieldParams['option_amount'][1] = 10; + $this->adminFieldParams['option_visibility_id'][1] = $this->visibilityOptionsKeys['public']; + + $form = new CRM_Price_Form_Field(); + $form->_action = CRM_Core_Action::ADD; + $files = array(); + + $validationResult = $form->formRule($this->adminFieldParams, $files, $form); + $this->assertType('array', $validationResult); + $this->assertTrue(array_key_exists('visibility_id', $validationResult)); + } + + private function initializeFieldParameters($params) { + $defaultParams = array( + 'label' => 'Price Field', + 'name' => CRM_Utils_String::titleToVar('Price Field'), + 'html_type' => 'Select', + 'is_display_amounts' => 1, + 'weight' => 1, + 'options_per_line' => 1, + 'is_enter_qty' => 1, + 'financial_type_id' => $this->getFinancialTypeId('Event Fee'), + 'visibility_id' => $this->visibilityOptionsKeys['public'], + ); + + for ($index = 1; $index <= CRM_Price_Form_Field::NUM_OPTION; $index++) { + $defaultParams['option_label'][$index] = NULL; + $defaultParams['option_value'][$index] = NULL; + $defaultParams['option_name'][$index] = NULL; + $defaultParams['option_weight'][$index] = NULL; + $defaultParams['option_amount'][$index] = NULL; + $defaultParams['option_visibility_id'][$index] = NULL; + } + + return array_merge($defaultParams, $params); + } + +} diff --git a/tests/phpunit/CiviTest/CiviUnitTestCase.php b/tests/phpunit/CiviTest/CiviUnitTestCase.php index 08762b0ca6a9..c3f62042e4d9 100644 --- a/tests/phpunit/CiviTest/CiviUnitTestCase.php +++ b/tests/phpunit/CiviTest/CiviUnitTestCase.php @@ -164,7 +164,7 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase { * @param array $data * @param string $dataName */ - public function __construct($name = NULL, array$data = array(), $dataName = '') { + public function __construct($name = NULL, array $data = array(), $dataName = '') { parent::__construct($name, $data, $dataName); // we need full error reporting diff --git a/tests/phpunit/E2E/Extern/RestTest.php b/tests/phpunit/E2E/Extern/RestTest.php index 56e1b0e2d1d5..0d9d96315714 100644 --- a/tests/phpunit/E2E/Extern/RestTest.php +++ b/tests/phpunit/E2E/Extern/RestTest.php @@ -292,10 +292,9 @@ protected function updateAdminApiKey() { 'return' => 'id', )); - $this->old_api_keys[$adminContactId] = CRM_Core_DAO::singleValueQuery('SELECT api_key FROM civicrm_contact WHERE id = %1', - array( - 1 => array($adminContactId, 'Positive'), - )); + $this->old_api_keys[$adminContactId] = CRM_Core_DAO::singleValueQuery('SELECT api_key FROM civicrm_contact WHERE id = %1', [ + 1 => [$adminContactId, 'Positive'], + ]); //$this->old_admin_api_key = civicrm_api3('Contact', 'get', array( // 'id' => $adminContactId, From 7237222fb42b2b176597fffb40a940994149f50d Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Fri, 5 Apr 2019 13:24:53 -0700 Subject: [PATCH 086/121] (NFC) Update to pass new phpcs --- api/v3/Contribution.php | 4 +- api/v3/System.php | 6 +- .../CRM/Core/DAO/AllCoreTablesTest.php | 2 +- tests/phpunit/CRM/Price/Form/OptionTest.php | 184 +++++++++--------- 4 files changed, 96 insertions(+), 100 deletions(-) diff --git a/api/v3/Contribution.php b/api/v3/Contribution.php index 870ee7b17af8..717c6709befe 100644 --- a/api/v3/Contribution.php +++ b/api/v3/Contribution.php @@ -725,8 +725,8 @@ function _ipn_process_transaction(&$params, $contribution, $input, $ids, $firstC $input['card_type_id'] = CRM_Utils_Array::value('card_type_id', $params); $input['pan_truncation'] = CRM_Utils_Array::value('pan_truncation', $params); $transaction = new CRM_Core_Transaction(); - return CRM_Contribute_BAO_Contribution::completeOrder($input, $ids, $objects, $transaction, !empty - ($contribution->contribution_recur_id), $contribution); + return CRM_Contribute_BAO_Contribution::completeOrder($input, $ids, $objects, $transaction, + !empty($contribution->contribution_recur_id), $contribution); } /** diff --git a/api/v3/System.php b/api/v3/System.php index 258afb3445de..baf4fe197bc7 100644 --- a/api/v3/System.php +++ b/api/v3/System.php @@ -254,11 +254,7 @@ function civicrm_api3_system_get($params) { 'version' => CRM_Utils_System::version(), 'dev' => (bool) CRM_Utils_System::isDevelopment(), 'components' => array_keys(CRM_Core_Component::getEnabledComponents()), - 'extensions' => preg_grep( - '/^uninstalled$/', - CRM_Extension_System::singleton()->getManager()->getStatuses(), - PREG_GREP_INVERT - ), + 'extensions' => preg_grep('/^uninstalled$/', CRM_Extension_System::singleton()->getManager()->getStatuses(), PREG_GREP_INVERT), 'multidomain' => CRM_Core_DAO::singleValueQuery('SELECT count(*) FROM civicrm_domain') > 1, 'settings' => _civicrm_api3_system_get_redacted_settings(), 'exampleUrl' => CRM_Utils_System::url('civicrm/example', NULL, TRUE, NULL, FALSE), diff --git a/tests/phpunit/CRM/Core/DAO/AllCoreTablesTest.php b/tests/phpunit/CRM/Core/DAO/AllCoreTablesTest.php index 2ad560ec98e2..6029a0c91e7a 100644 --- a/tests/phpunit/CRM/Core/DAO/AllCoreTablesTest.php +++ b/tests/phpunit/CRM/Core/DAO/AllCoreTablesTest.php @@ -38,7 +38,7 @@ public function testHook() { /** * Implements hook_civicrm_entityTypes(). * - * @param array $entityTypes + * @see CRM_Utils_Hook::entityTypes() */ public function _hook_civicrm_entityTypes(&$entityTypes) { $entityTypes['CRM_Core_DAO_Email']['fields_callback'][] = function ($class, &$fields) { diff --git a/tests/phpunit/CRM/Price/Form/OptionTest.php b/tests/phpunit/CRM/Price/Form/OptionTest.php index 4d297b86c42e..faf6c0b720ac 100644 --- a/tests/phpunit/CRM/Price/Form/OptionTest.php +++ b/tests/phpunit/CRM/Price/Form/OptionTest.php @@ -1,92 +1,92 @@ -visibilityOptions = CRM_Price_BAO_PriceFieldValue::buildOptions('visibility_id', NULL, array( - 'labelColumn' => 'name', - )); - $this->visibilityOptionsKeys = CRM_Price_BAO_PriceFieldValue::buildOptions('visibility_id', NULL, array( - 'labelColumn' => 'name', - 'flip' => TRUE, - )); - } - - public function testChangingUniquePublicOptionOnPublicFieldIsNotAllowed() { - $this->setUpPriceSet(array( - 'html_type' => 'Select', - 'visibility_id' => $this->visibilityOptionsKeys['public'], - 'option_label' => array('1' => 'Price Field 1', '2' => 'Price Field 2'), - 'option_value' => array('1' => 100, '2' => 200), - 'option_name' => array('1' => 'Price Field 1', '2' => 'Price Field 2'), - 'option_weight' => array('1' => 1, '2' => 2), - 'option_amount' => array('1' => 100, '2' => 200), - 'option_visibility_id' => array(1 => $this->visibilityOptionsKeys['public'], 2 => $this->visibilityOptionsKeys['admin']), - )); - - $params = array( - 'fieldId' => $this->publicValue['price_field_id'], - 'optionId' => $this->publicValue['id'], - 'visibility_id' => $this->visibilityOptionsKeys['admin'], - ); - - $form = new CRM_Price_Form_Option(); - $form->_action = CRM_Core_Action::ADD; - $files = array(); - - $validationResult = $form->formRule($params, $files, $form); - $this->assertType('array', $validationResult); - $this->assertTrue(array_key_exists('visibility_id', $validationResult)); - } - - public function testAddingPublicOptionToAdminFieldIsNotAllowed() { - $this->setUpPriceSet(array( - 'html_type' => 'Select', - 'visibility_id' => $this->visibilityOptionsKeys['admin'], - 'option_label' => array('1' => 'Price Field 1', '2' => 'Price Field 2'), - 'option_value' => array('1' => 100, '2' => 200), - 'option_name' => array('1' => 'Price Field 1', '2' => 'Price Field 2'), - 'option_weight' => array('1' => 1, '2' => 2), - 'option_amount' => array('1' => 100, '2' => 200), - 'option_visibility_id' => array(1 => $this->visibilityOptionsKeys['admin'], 2 => $this->visibilityOptionsKeys['admin']), - )); - - $params = array( - 'fieldId' => $this->adminValue['price_field_id'], - 'optionId' => $this->adminValue['id'], - 'visibility_id' => $this->visibilityOptionsKeys['public'], - ); - - $form = new CRM_Price_Form_Option(); - $form->_action = CRM_Core_Action::ADD; - $files = array(); - - $validationResult = $form->formRule($params, $files, $form); - $this->assertType('array', $validationResult); - $this->assertTrue(array_key_exists('visibility_id', $validationResult)); - } - - private function setUpPriceSet($params) { - $priceSetCreateResult = $this->createPriceSet('contribution_page', NULL, $params); - - $this->priceFieldValues = $priceSetCreateResult['values']; - - foreach ($this->priceFieldValues as $currentField) { - if ($this->visibilityOptions[$currentField['visibility_id']] == 'public') { - $this->publicValue = $currentField; - } - else { - $this->adminValue = $currentField; - } - } - } - -} +visibilityOptions = CRM_Price_BAO_PriceFieldValue::buildOptions('visibility_id', NULL, array( + 'labelColumn' => 'name', + )); + $this->visibilityOptionsKeys = CRM_Price_BAO_PriceFieldValue::buildOptions('visibility_id', NULL, array( + 'labelColumn' => 'name', + 'flip' => TRUE, + )); + } + + public function testChangingUniquePublicOptionOnPublicFieldIsNotAllowed() { + $this->setUpPriceSet(array( + 'html_type' => 'Select', + 'visibility_id' => $this->visibilityOptionsKeys['public'], + 'option_label' => array('1' => 'Price Field 1', '2' => 'Price Field 2'), + 'option_value' => array('1' => 100, '2' => 200), + 'option_name' => array('1' => 'Price Field 1', '2' => 'Price Field 2'), + 'option_weight' => array('1' => 1, '2' => 2), + 'option_amount' => array('1' => 100, '2' => 200), + 'option_visibility_id' => array(1 => $this->visibilityOptionsKeys['public'], 2 => $this->visibilityOptionsKeys['admin']), + )); + + $params = array( + 'fieldId' => $this->publicValue['price_field_id'], + 'optionId' => $this->publicValue['id'], + 'visibility_id' => $this->visibilityOptionsKeys['admin'], + ); + + $form = new CRM_Price_Form_Option(); + $form->_action = CRM_Core_Action::ADD; + $files = array(); + + $validationResult = $form->formRule($params, $files, $form); + $this->assertType('array', $validationResult); + $this->assertTrue(array_key_exists('visibility_id', $validationResult)); + } + + public function testAddingPublicOptionToAdminFieldIsNotAllowed() { + $this->setUpPriceSet(array( + 'html_type' => 'Select', + 'visibility_id' => $this->visibilityOptionsKeys['admin'], + 'option_label' => array('1' => 'Price Field 1', '2' => 'Price Field 2'), + 'option_value' => array('1' => 100, '2' => 200), + 'option_name' => array('1' => 'Price Field 1', '2' => 'Price Field 2'), + 'option_weight' => array('1' => 1, '2' => 2), + 'option_amount' => array('1' => 100, '2' => 200), + 'option_visibility_id' => array(1 => $this->visibilityOptionsKeys['admin'], 2 => $this->visibilityOptionsKeys['admin']), + )); + + $params = array( + 'fieldId' => $this->adminValue['price_field_id'], + 'optionId' => $this->adminValue['id'], + 'visibility_id' => $this->visibilityOptionsKeys['public'], + ); + + $form = new CRM_Price_Form_Option(); + $form->_action = CRM_Core_Action::ADD; + $files = array(); + + $validationResult = $form->formRule($params, $files, $form); + $this->assertType('array', $validationResult); + $this->assertTrue(array_key_exists('visibility_id', $validationResult)); + } + + private function setUpPriceSet($params) { + $priceSetCreateResult = $this->createPriceSet('contribution_page', NULL, $params); + + $this->priceFieldValues = $priceSetCreateResult['values']; + + foreach ($this->priceFieldValues as $currentField) { + if ($this->visibilityOptions[$currentField['visibility_id']] == 'public') { + $this->publicValue = $currentField; + } + else { + $this->adminValue = $currentField; + } + } + } + +} From cf9ccf98dd6af3c4251df206fbf60b2a508b3c49 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Fri, 5 Apr 2019 13:46:10 -0700 Subject: [PATCH 087/121] (NFC) Various updates for future version of civicrm/coder --- CRM/Core/BAO/Address.php | 20 ++++---------------- CRM/Core/BAO/CMSUser.php | 2 +- CRM/Core/BAO/Cache.php | 6 ++++-- CRM/Core/BAO/Cache/Psr16.php | 20 +++++++++++++++----- CRM/Core/BAO/CustomGroup.php | 8 +++++--- CRM/Core/BAO/Dashboard.php | 12 +++++------- 6 files changed, 34 insertions(+), 34 deletions(-) diff --git a/CRM/Core/BAO/Address.php b/CRM/Core/BAO/Address.php index 8b5748501768..b5ec97d74863 100644 --- a/CRM/Core/BAO/Address.php +++ b/CRM/Core/BAO/Address.php @@ -360,12 +360,7 @@ public static function fixAddress(&$params) { ); if ($parseStreetAddress && !empty($params['street_address'])) { - foreach ([ - 'street_number', - 'street_name', - 'street_unit', - 'street_number_suffix', - ] as $fld) { + foreach (['street_number', 'street_name', 'street_unit', 'street_number_suffix'] as $fld) { unset($params[$fld]); } // main parse string. @@ -494,12 +489,7 @@ public static function &getValues($entityBlock, $microformat = FALSE, $fieldName while ($address->fetch()) { // deprecate reference. if ($count > 1) { - foreach ([ - 'state', - 'state_name', - 'country', - 'world_region', - ] as $fld) { + foreach (['state', 'state_name', 'country', 'world_region'] as $fld) { if (isset($address->$fld)) { unset($address->$fld); } @@ -733,10 +723,8 @@ public static function parseStreetAddress($streetAddress, $locale = NULL) { $streetAddress = trim($streetAddress); $matches = []; - if (in_array($locale, [ - 'en_CA', - 'fr_CA', - ]) && preg_match('/^([A-Za-z0-9]+)[ ]*\-[ ]*/', $streetAddress, $matches) + if (in_array($locale, ['en_CA', 'fr_CA']) + && preg_match('/^([A-Za-z0-9]+)[ ]*\-[ ]*/', $streetAddress, $matches) ) { $parseFields['street_unit'] = $matches[1]; // unset from rest of street address diff --git a/CRM/Core/BAO/CMSUser.php b/CRM/Core/BAO/CMSUser.php index 368bcd97dee9..36bb8bdb6f0c 100644 --- a/CRM/Core/BAO/CMSUser.php +++ b/CRM/Core/BAO/CMSUser.php @@ -213,7 +213,7 @@ public static function formRule($fields, $files, $form) { } // now check that the cms db does not have the user name and/or email - if ($isDrupal OR $isJoomla OR $isWordPress) { + if ($isDrupal or $isJoomla or $isWordPress) { $params = [ 'name' => $fields['cms_name'], 'mail' => $fields[$emailName], diff --git a/CRM/Core/BAO/Cache.php b/CRM/Core/BAO/Cache.php index ffdcfa7b31d2..3347f978d86e 100644 --- a/CRM/Core/BAO/Cache.php +++ b/CRM/Core/BAO/Cache.php @@ -45,7 +45,8 @@ class CRM_Core_BAO_Cache extends CRM_Core_DAO_Cache { * * @var int, number of second */ - const DEFAULT_SESSION_TTL = 172800; // Two days: 2*24*60*60 + // Two days: 2*24*60*60 + const DEFAULT_SESSION_TTL = 172800; /** * @var array ($cacheKey => $cacheValue) @@ -174,7 +175,8 @@ public static function setItem(&$data, $group, $path, $componentID = NULL) { $table = self::getTableName(); $where = self::whereCache($group, $path, $componentID); $dataExists = CRM_Core_DAO::singleValueQuery("SELECT COUNT(*) FROM $table WHERE {$where}"); - $now = date('Y-m-d H:i:s'); // FIXME - Use SQL NOW() or CRM_Utils_Time? + // FIXME - Use SQL NOW() or CRM_Utils_Time? + $now = date('Y-m-d H:i:s'); $dataSerialized = self::encode($data); // This table has a wonky index, so we cannot use REPLACE or diff --git a/CRM/Core/BAO/Cache/Psr16.php b/CRM/Core/BAO/Cache/Psr16.php index 986a4bcbf4b8..03463d473ee5 100644 --- a/CRM/Core/BAO/Cache/Psr16.php +++ b/CRM/Core/BAO/Cache/Psr16.php @@ -189,11 +189,21 @@ public static function getLegacyGroups() { 'custom data', // Universe - 'dashboard', // be.chiro.civi.atomfeeds - 'lineitem-editor', // biz.jmaconsulting.lineitemedit - 'HRCore_Info', // civihr/uk.co.compucorp.civicrm.hrcore - 'CiviCRM setting Spec', // nz.co.fuzion.entitysetting - 'descendant groups for an org', // org.civicrm.multisite + + // be.chiro.civi.atomfeeds + 'dashboard', + + // biz.jmaconsulting.lineitemedit + 'lineitem-editor', + + // civihr/uk.co.compucorp.civicrm.hrcore + 'HRCore_Info', + + // nz.co.fuzion.entitysetting + 'CiviCRM setting Spec', + + // org.civicrm.multisite + 'descendant groups for an org', ]; } diff --git a/CRM/Core/BAO/CustomGroup.php b/CRM/Core/BAO/CustomGroup.php index 8fa78cbf7ae4..01e65fc4cefd 100644 --- a/CRM/Core/BAO/CustomGroup.php +++ b/CRM/Core/BAO/CustomGroup.php @@ -303,7 +303,8 @@ public static function autoCreateByActivityType($activityTypeId) { if (self::hasCustomGroup('Activity', NULL, $activityTypeId)) { return TRUE; } - $activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE, FALSE); // everything + // everything + $activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE, FALSE); $params = [ 'version' => 3, 'extends' => 'Activity', @@ -484,7 +485,7 @@ public static function getTree( foreach ($subTypes as $key => $subType) { $subTypeClauses[] = self::whereListHas("civicrm_custom_group.extends_entity_column_value", self::validateSubTypeByEntity($entityType, $subType)); } - $subTypeClause = '(' . implode(' OR ', $subTypeClauses) . ')'; + $subTypeClause = '(' . implode(' OR ', $subTypeClauses) . ')'; if (!$onlySubType) { $subTypeClause = '(' . $subTypeClause . ' OR civicrm_custom_group.extends_entity_column_value IS NULL )'; } @@ -716,7 +717,8 @@ protected static function validateSubTypeByEntity($entityType, $subType) { * SQL condition. */ static private function whereListHas($column, $value, $delimiter = CRM_Core_DAO::VALUE_SEPARATOR) { - $bareValue = trim($value, $delimiter); // ? + // ? + $bareValue = trim($value, $delimiter); $escapedValue = CRM_Utils_Type::escape("%{$delimiter}{$bareValue}{$delimiter}%", 'String', FALSE); return "($column LIKE \"$escapedValue\")"; } diff --git a/CRM/Core/BAO/Dashboard.php b/CRM/Core/BAO/Dashboard.php index 1bfd6812d212..091348624bb4 100644 --- a/CRM/Core/BAO/Dashboard.php +++ b/CRM/Core/BAO/Dashboard.php @@ -181,9 +181,9 @@ public static function getContactDashletsForJS() { public static function initializeDashlets() { $dashlets = []; $getDashlets = civicrm_api3("Dashboard", "get", [ - 'domain_id' => CRM_Core_Config::domainID(), - 'option.limit' => 0, - ]); + 'domain_id' => CRM_Core_Config::domainID(), + 'option.limit' => 0, + ]); $contactID = CRM_Core_Session::getLoggedInContactID(); $allDashlets = CRM_Utils_Array::index(['name'], $getDashlets['values']); $defaultDashlets = []; @@ -271,10 +271,8 @@ public static function checkPermission($permission, $operator) { } // hack to handle case permissions - if (!$componentName && in_array($key, [ - 'access my cases and activities', - 'access all cases and activities', - ]) + if (!$componentName + && in_array($key, ['access my cases and activities', 'access all cases and activities']) ) { $componentName = 'CiviCase'; } From 0d48f1cc2cefd21e794aa0c2750f328eebff80ba Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Fri, 5 Apr 2019 14:04:17 -0700 Subject: [PATCH 088/121] (NFC) Apply upcoming civicrm/coder policies (batch 1) Method: * Checkout latest merged branch of civicrm/coder (`8.x-2.x-civi`) * Run this command to autoclean a batch of 100 files `PG=1 SIZE=100 ; find Civi/ CRM/ api/ bin/ extern/ tests/ -name '*.php' | grep -v /examples/ | grep -v /DAO/ | sort | head -n $(( $PG * $SIZE )) | tail -n $SIZE | xargs phpcbf-civi` * Go through the diff. For anything that looks wonky, open in an editor and find a better solution Note: The automated checker makes good points about awkward indentation, but the automated cleanup often makes it worse. So that's why I have to open it up. --- CRM/ACL/Form/ACL.php | 30 +++++++++++------------ CRM/ACL/Form/ACLBasic.php | 6 ++--- CRM/ACL/Page/ACL.php | 24 +++++++++---------- CRM/Activity/ActionMapping.php | 1 - CRM/Activity/BAO/Activity.php | 8 +++---- CRM/Activity/Form/Activity.php | 6 +---- CRM/Activity/Form/ActivityView.php | 2 +- CRM/Activity/Form/Task/FileOnCase.php | 3 ++- CRM/Activity/Import/Form/MapField.php | 2 +- CRM/Activity/Import/Parser.php | 18 +++++--------- CRM/Activity/Tokens.php | 3 ++- CRM/Admin/Form.php | 34 +++++++++++++-------------- CRM/Admin/Form/CMSUser.php | 21 ++++++++--------- CRM/Admin/Form/Extensions.php | 21 ++++++++--------- CRM/Admin/Form/Generic.php | 21 ++++++++--------- CRM/Admin/Form/Job.php | 6 ++--- CRM/Admin/Form/Mapping.php | 6 ++--- CRM/Admin/Form/MessageTemplates.php | 15 ++++++------ CRM/Admin/Form/Options.php | 33 ++++++++++---------------- CRM/Admin/Form/PaymentProcessor.php | 10 ++++---- CRM/Admin/Form/PdfFormats.php | 6 ++--- CRM/Admin/Form/Persistent.php | 21 ++++++++--------- CRM/Admin/Form/Preferences.php | 21 ++++++++--------- CRM/Admin/Form/RelationshipType.php | 4 ++-- CRM/Admin/Form/Setting.php | 24 +++++++++---------- CRM/Admin/Form/Setting/UF.php | 3 ++- CRM/Admin/Form/WordReplacements.php | 21 ++++++++--------- CRM/Admin/Page/AJAX.php | 4 ++-- 28 files changed, 174 insertions(+), 200 deletions(-) diff --git a/CRM/ACL/Form/ACL.php b/CRM/ACL/Form/ACL.php index 76e54265621a..b119f7503aed 100644 --- a/CRM/ACL/Form/ACL.php +++ b/CRM/ACL/Form/ACL.php @@ -141,30 +141,30 @@ public function buildQuickForm() { $label = ts('Role'); $role = [ - '-1' => ts('- select role -'), - '0' => ts('Everyone'), - ] + CRM_Core_OptionGroup::values('acl_role'); + '-1' => ts('- select role -'), + '0' => ts('Everyone'), + ] + CRM_Core_OptionGroup::values('acl_role'); $this->add('select', 'entity_id', $label, $role, TRUE); $group = [ - '-1' => ts('- select -'), - '0' => ts('All Groups'), - ] + CRM_Core_PseudoConstant::group(); + '-1' => ts('- select -'), + '0' => ts('All Groups'), + ] + CRM_Core_PseudoConstant::group(); $customGroup = [ - '-1' => ts('- select -'), - '0' => ts('All Custom Groups'), - ] + CRM_Core_PseudoConstant::get('CRM_Core_DAO_CustomField', 'custom_group_id'); + '-1' => ts('- select -'), + '0' => ts('All Custom Groups'), + ] + CRM_Core_PseudoConstant::get('CRM_Core_DAO_CustomField', 'custom_group_id'); $ufGroup = [ - '-1' => ts('- select -'), - '0' => ts('All Profiles'), - ] + CRM_Core_PseudoConstant::get('CRM_Core_DAO_UFField', 'uf_group_id'); + '-1' => ts('- select -'), + '0' => ts('All Profiles'), + ] + CRM_Core_PseudoConstant::get('CRM_Core_DAO_UFField', 'uf_group_id'); $event = [ - '-1' => ts('- select -'), - '0' => ts('All Events'), - ] + CRM_Event_PseudoConstant::event(NULL, FALSE, "( is_template IS NULL OR is_template != 1 )"); + '-1' => ts('- select -'), + '0' => ts('All Events'), + ] + CRM_Event_PseudoConstant::event(NULL, FALSE, "( is_template IS NULL OR is_template != 1 )"); $this->add('select', 'group_id', ts('Group'), $group); $this->add('select', 'custom_group_id', ts('Custom Data'), $customGroup); diff --git a/CRM/ACL/Form/ACLBasic.php b/CRM/ACL/Form/ACLBasic.php index af902384fdfd..263b49592765 100644 --- a/CRM/ACL/Form/ACLBasic.php +++ b/CRM/ACL/Form/ACLBasic.php @@ -80,9 +80,9 @@ public function buildQuickForm() { $label = ts('Role'); $role = [ - '-1' => ts('- select role -'), - '0' => ts('Everyone'), - ] + CRM_Core_OptionGroup::values('acl_role'); + '-1' => ts('- select role -'), + '0' => ts('Everyone'), + ] + CRM_Core_OptionGroup::values('acl_role'); $entityID = &$this->add('select', 'entity_id', $label, $role, TRUE); if ($this->_id) { diff --git a/CRM/ACL/Page/ACL.php b/CRM/ACL/Page/ACL.php index f056c675ce7c..4413ce82b2b2 100644 --- a/CRM/ACL/Page/ACL.php +++ b/CRM/ACL/Page/ACL.php @@ -123,22 +123,22 @@ public function browse() { $roles = CRM_Core_OptionGroup::values('acl_role'); $group = [ - '-1' => ts('- select -'), - '0' => ts('All Groups'), - ] + CRM_Core_PseudoConstant::group(); + '-1' => ts('- select -'), + '0' => ts('All Groups'), + ] + CRM_Core_PseudoConstant::group(); $customGroup = [ - '-1' => ts('- select -'), - '0' => ts('All Custom Groups'), - ] + CRM_Core_PseudoConstant::get('CRM_Core_DAO_CustomField', 'custom_group_id'); + '-1' => ts('- select -'), + '0' => ts('All Custom Groups'), + ] + CRM_Core_PseudoConstant::get('CRM_Core_DAO_CustomField', 'custom_group_id'); $ufGroup = [ - '-1' => ts('- select -'), - '0' => ts('All Profiles'), - ] + CRM_Core_PseudoConstant::get('CRM_Core_DAO_UFField', 'uf_group_id'); + '-1' => ts('- select -'), + '0' => ts('All Profiles'), + ] + CRM_Core_PseudoConstant::get('CRM_Core_DAO_UFField', 'uf_group_id'); $event = [ - '-1' => ts('- select -'), - '0' => ts('All Events'), - ] + CRM_Event_PseudoConstant::event(); + '-1' => ts('- select -'), + '0' => ts('All Events'), + ] + CRM_Event_PseudoConstant::event(); while ($dao->fetch()) { $acl[$dao->id] = []; diff --git a/CRM/Activity/ActionMapping.php b/CRM/Activity/ActionMapping.php index 9f5dccb1f63a..5251972ea9ab 100644 --- a/CRM/Activity/ActionMapping.php +++ b/CRM/Activity/ActionMapping.php @@ -30,7 +30,6 @@ * @copyright CiviCRM LLC (c) 2004-2019 */ -use Civi\ActionSchedule\RecipientBuilder; /** * Class CRM_Activity_ActionMapping diff --git a/CRM/Activity/BAO/Activity.php b/CRM/Activity/BAO/Activity.php index dc66751ca4fa..e454ef229e5f 100644 --- a/CRM/Activity/BAO/Activity.php +++ b/CRM/Activity/BAO/Activity.php @@ -1207,7 +1207,7 @@ public static function sendSMS( } if (!isset($contactDetails) && !isset($contactIds)) { - Throw new CRM_Core_Exception('You must specify either $contactDetails or $contactIds'); + throw new CRM_Core_Exception('You must specify either $contactDetails or $contactIds'); } // Populate $contactDetails and $contactIds if only one is set if (is_array($contactIds) && !empty($contactIds) && empty($contactDetails)) { @@ -2403,9 +2403,9 @@ protected static function getActivityParamsForDashboardFunctions($params) { $enabledComponents = self::activityComponents(); // @todo - should we move this to activity get api. foreach ([ - 'case_id' => 'CiviCase', - 'campaign_id' => 'CiviCampaign', - ] as $attr => $component) { + 'case_id' => 'CiviCase', + 'campaign_id' => 'CiviCampaign', + ] as $attr => $component) { if (!in_array($component, $enabledComponents)) { $activityParams[$attr] = ['IS NULL' => 1]; } diff --git a/CRM/Activity/Form/Activity.php b/CRM/Activity/Form/Activity.php index b3e65e0c8732..7fffdb7cd588 100644 --- a/CRM/Activity/Form/Activity.php +++ b/CRM/Activity/Form/Activity.php @@ -260,11 +260,7 @@ public function preProcess() { if (CRM_Contact_Form_Search::isSearchContext($this->_context)) { $this->_context = 'search'; } - elseif (!in_array($this->_context, [ - 'dashlet', - 'case', - 'dashletFullscreen', - ]) + elseif (!in_array($this->_context, ['dashlet', 'case', 'dashletFullscreen']) && $this->_currentlyViewedContactId ) { $this->_context = 'activity'; diff --git a/CRM/Activity/Form/ActivityView.php b/CRM/Activity/Form/ActivityView.php index 4a2ef88b3078..d0e884397168 100644 --- a/CRM/Activity/Form/ActivityView.php +++ b/CRM/Activity/Form/ActivityView.php @@ -130,7 +130,7 @@ public function buildQuickForm() { 'spacing' => '         ', 'isDefault' => TRUE, ], - ] + ] ); } diff --git a/CRM/Activity/Form/Task/FileOnCase.php b/CRM/Activity/Form/Task/FileOnCase.php index 90225b18a61b..893012b15c8b 100644 --- a/CRM/Activity/Form/Task/FileOnCase.php +++ b/CRM/Activity/Form/Task/FileOnCase.php @@ -109,7 +109,8 @@ public function postProcess() { } } else { - CRM_Core_Session::setStatus(ts('Not permitted to file activity %1 %2.', [ + CRM_Core_Session::setStatus( + ts('Not permitted to file activity %1 %2.', [ 1 => empty($defaults['subject']) ? '' : $defaults['subject'], 2 => $defaults['activity_date_time'], ]), diff --git a/CRM/Activity/Import/Form/MapField.php b/CRM/Activity/Import/Form/MapField.php index 9cbb7d7e27ca..f2f59dc04f72 100644 --- a/CRM/Activity/Import/Form/MapField.php +++ b/CRM/Activity/Import/Form/MapField.php @@ -251,7 +251,7 @@ public function buildQuickForm() { 'type' => 'cancel', 'name' => ts('Cancel'), ], - ] + ] ); } diff --git a/CRM/Activity/Import/Parser.php b/CRM/Activity/Import/Parser.php index 664e4a0deb78..aca16398574a 100644 --- a/CRM/Activity/Import/Parser.php +++ b/CRM/Activity/Import/Parser.php @@ -240,30 +240,24 @@ public function run( } if ($this->_invalidRowCount) { // removed view url for invlaid contacts - $headers = array_merge([ - ts('Line Number'), - ts('Reason'), - ], + $headers = array_merge( + [ts('Line Number'), ts('Reason')], $customHeaders ); $this->_errorFileName = self::errorFileName(self::ERROR); self::exportCSV($this->_errorFileName, $headers, $this->_errors); } if ($this->_conflictCount) { - $headers = array_merge([ - ts('Line Number'), - ts('Reason'), - ], + $headers = array_merge( + [ts('Line Number'), ts('Reason')], $customHeaders ); $this->_conflictFileName = self::errorFileName(self::CONFLICT); self::exportCSV($this->_conflictFileName, $headers, $this->_conflicts); } if ($this->_duplicateCount) { - $headers = array_merge([ - ts('Line Number'), - ts('View Activity History URL'), - ], + $headers = array_merge( + [ts('Line Number'), ts('View Activity History URL')], $customHeaders ); diff --git a/CRM/Activity/Tokens.php b/CRM/Activity/Tokens.php index 4bd22e2dd95a..ebb83d02f125 100644 --- a/CRM/Activity/Tokens.php +++ b/CRM/Activity/Tokens.php @@ -78,7 +78,8 @@ public function alterActionScheduleQuery(\Civi\ActionSchedule\Event\MailingQuery // Q: Could we simplify & move the extra AND clauses into `where(...)`? $e->query->param('casEntityJoinExpr', 'e.id = reminder.entity_id AND e.is_current_revision = 1 AND e.is_deleted = 0'); - $e->query->select('e.*'); // FIXME: seems too broad. + // FIXME: seems too broad. + $e->query->select('e.*'); $e->query->select('ov.label as activity_type, e.id as activity_id'); $e->query->join("og", "!casMailingJoinType civicrm_option_group og ON og.name = 'activity_type'"); diff --git a/CRM/Admin/Form.php b/CRM/Admin/Form.php index eae83336915e..e4edfb0a7c60 100644 --- a/CRM/Admin/Form.php +++ b/CRM/Admin/Form.php @@ -128,27 +128,25 @@ public function setDefaultValues() { public function buildQuickForm() { if ($this->_action & CRM_Core_Action::VIEW || $this->_action & CRM_Core_Action::PREVIEW) { $this->addButtons([ - [ - 'type' => 'cancel', - 'name' => ts('Done'), - 'isDefault' => TRUE, - ], - ] - ); + [ + 'type' => 'cancel', + 'name' => ts('Done'), + 'isDefault' => TRUE, + ], + ]); } else { $this->addButtons([ - [ - 'type' => 'next', - 'name' => $this->_action & CRM_Core_Action::DELETE ? ts('Delete') : ts('Save'), - 'isDefault' => TRUE, - ], - [ - 'type' => 'cancel', - 'name' => ts('Cancel'), - ], - ] - ); + [ + 'type' => 'next', + 'name' => $this->_action & CRM_Core_Action::DELETE ? ts('Delete') : ts('Save'), + 'isDefault' => TRUE, + ], + [ + 'type' => 'cancel', + 'name' => ts('Cancel'), + ], + ]); } } diff --git a/CRM/Admin/Form/CMSUser.php b/CRM/Admin/Form/CMSUser.php index 37ce38eb8dec..44305056b654 100644 --- a/CRM/Admin/Form/CMSUser.php +++ b/CRM/Admin/Form/CMSUser.php @@ -42,17 +42,16 @@ class CRM_Admin_Form_CMSUser extends CRM_Core_Form { public function buildQuickForm() { $this->addButtons([ - [ - 'type' => 'next', - 'name' => ts('OK'), - 'isDefault' => TRUE, - ], - [ - 'type' => 'cancel', - 'name' => ts('Cancel'), - ], - ] - ); + [ + 'type' => 'next', + 'name' => ts('OK'), + 'isDefault' => TRUE, + ], + [ + 'type' => 'cancel', + 'name' => ts('Cancel'), + ], + ]); } /** diff --git a/CRM/Admin/Form/Extensions.php b/CRM/Admin/Form/Extensions.php index 35927326e994..852ebb082083 100644 --- a/CRM/Admin/Form/Extensions.php +++ b/CRM/Admin/Form/Extensions.php @@ -137,17 +137,16 @@ public function buildQuickForm() { $this->assign('title', $title); $this->addButtons([ - [ - 'type' => 'next', - 'name' => $buttonName, - 'isDefault' => TRUE, - ], - [ - 'type' => 'cancel', - 'name' => ts('Cancel'), - ], - ] - ); + [ + 'type' => 'next', + 'name' => $buttonName, + 'isDefault' => TRUE, + ], + [ + 'type' => 'cancel', + 'name' => ts('Cancel'), + ], + ]); } /** diff --git a/CRM/Admin/Form/Generic.php b/CRM/Admin/Form/Generic.php index 9919469cba9e..04b29ecd9793 100644 --- a/CRM/Admin/Form/Generic.php +++ b/CRM/Admin/Form/Generic.php @@ -84,17 +84,16 @@ public function buildQuickForm() { // @todo - do we still like this redirect? CRM_Core_Session::singleton()->pushUserContext(CRM_Utils_System::url('civicrm/admin', 'reset=1')); $this->addButtons([ - [ - 'type' => 'next', - 'name' => ts('Save'), - 'isDefault' => TRUE, - ], - [ - 'type' => 'cancel', - 'name' => ts('Cancel'), - ], - ] - ); + [ + 'type' => 'next', + 'name' => ts('Save'), + 'isDefault' => TRUE, + ], + [ + 'type' => 'cancel', + 'name' => ts('Cancel'), + ], + ]); } /** diff --git a/CRM/Admin/Form/Job.php b/CRM/Admin/Form/Job.php index 624e03a70efb..42f4a3c3861d 100644 --- a/CRM/Admin/Form/Job.php +++ b/CRM/Admin/Form/Job.php @@ -78,9 +78,9 @@ public function buildQuickForm($check = FALSE) { ); $this->addRule('name', ts('Name already exists in Database.'), 'objectExists', [ - 'CRM_Core_DAO_Job', - $this->_id, - ]); + 'CRM_Core_DAO_Job', + $this->_id, + ]); $this->add('text', 'description', ts('Description'), $attributes['description'] diff --git a/CRM/Admin/Form/Mapping.php b/CRM/Admin/Form/Mapping.php index 8dc369ae95bf..2dac50e76328 100644 --- a/CRM/Admin/Form/Mapping.php +++ b/CRM/Admin/Form/Mapping.php @@ -61,9 +61,9 @@ public function buildQuickForm() { CRM_Core_DAO::getAttribute('CRM_Core_DAO_Mapping', 'name'), TRUE ); $this->addRule('name', ts('Name already exists in Database.'), 'objectExists', [ - 'CRM_Core_DAO_Mapping', - $this->_id, - ]); + 'CRM_Core_DAO_Mapping', + $this->_id, + ]); $this->addElement('text', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Mapping', 'description') diff --git a/CRM/Admin/Form/MessageTemplates.php b/CRM/Admin/Form/MessageTemplates.php index b3dab487318b..8ff7528fdab3 100644 --- a/CRM/Admin/Form/MessageTemplates.php +++ b/CRM/Admin/Form/MessageTemplates.php @@ -95,14 +95,13 @@ public function buildQuickForm() { $cancelURL = CRM_Utils_System::url('civicrm/admin/messageTemplates', 'selectedChild=workflow&reset=1'); $cancelURL = str_replace('&', '&', $cancelURL); $this->addButtons([ - [ - 'type' => 'cancel', - 'name' => ts('Done'), - 'js' => ['onclick' => "location.href='{$cancelURL}'; return false;"], - 'isDefault' => TRUE, - ], - ] - ); + [ + 'type' => 'cancel', + 'name' => ts('Done'), + 'js' => ['onclick' => "location.href='{$cancelURL}'; return false;"], + 'isDefault' => TRUE, + ], + ]); } else { $this->_workflow_id = CRM_Utils_Array::value('workflow_id', $this->_values); diff --git a/CRM/Admin/Form/Options.php b/CRM/Admin/Form/Options.php index b380feacf5ad..3e8dd6a65aa6 100644 --- a/CRM/Admin/Form/Options.php +++ b/CRM/Admin/Form/Options.php @@ -96,9 +96,9 @@ public function preProcess() { if ($isInUse) { $scriptURL = "" . ts('Learn more about a script that can automatically update contact addressee and greeting options.') . ""; CRM_Core_Session::setStatus(ts('The selected %1 option has not been deleted because it is currently in use. Please update these contacts to use a different format before deleting this option. %2', [ - 1 => $this->_gLabel, - 2 => $scriptURL, - ]), ts('Sorry'), 'error'); + 1 => $this->_gLabel, + 2 => $scriptURL, + ]), ts('Sorry'), 'error'); $redirect = CRM_Utils_System::url($url, $params); CRM_Utils_System::redirect($redirect); } @@ -193,11 +193,8 @@ public function buildQuickForm() { $this->add('color', 'color', ts('Color')); } - if (!in_array($this->_gName, [ - 'email_greeting', - 'postal_greeting', - 'addressee', - ]) && !$isReserved + if (!in_array($this->_gName, ['email_greeting', 'postal_greeting', 'addressee']) + && !$isReserved ) { $this->addRule('label', ts('This Label already exists in the database for this option group. Please select a different Label.'), @@ -323,11 +320,8 @@ public function buildQuickForm() { } // get contact type for which user want to create a new greeting/addressee type, CRM-4575 - if (in_array($this->_gName, [ - 'email_greeting', - 'postal_greeting', - 'addressee', - ]) && !$isReserved + if (in_array($this->_gName, ['email_greeting', 'postal_greeting', 'addressee']) + && !$isReserved ) { $values = [ 1 => ts('Individual'), @@ -372,11 +366,8 @@ public static function formRule($fields, $files, $self) { $errors['grouping'] = ts('Status class is a required field'); } - if (in_array($self->_gName, [ - 'email_greeting', - 'postal_greeting', - 'addressee', - ]) && empty($self->_defaultValues['is_reserved']) + if (in_array($self->_gName, ['email_greeting', 'postal_greeting', 'addressee']) + && empty($self->_defaultValues['is_reserved']) ) { $label = $fields['label']; $condition = " AND v.label = '{$label}' "; @@ -487,9 +478,9 @@ public function postProcess() { $optionValue = CRM_Core_OptionValue::addOptionValue($params, $this->_gName, $this->_action, $this->_id); CRM_Core_Session::setStatus(ts('The %1 \'%2\' has been saved.', [ - 1 => $this->_gLabel, - 2 => $optionValue->label, - ]), ts('Saved'), 'success'); + 1 => $this->_gLabel, + 2 => $optionValue->label, + ]), ts('Saved'), 'success'); $this->ajaxResponse['optionValue'] = $optionValue->toArray(); } diff --git a/CRM/Admin/Form/PaymentProcessor.php b/CRM/Admin/Form/PaymentProcessor.php index 84fdf07e7ded..aef46cc304f5 100644 --- a/CRM/Admin/Form/PaymentProcessor.php +++ b/CRM/Admin/Form/PaymentProcessor.php @@ -183,11 +183,11 @@ public function buildQuickForm($check = FALSE) { ); $this->addRule('name', ts('Name already exists in Database.'), 'objectExists', [ - 'CRM_Financial_DAO_PaymentProcessor', - $this->_id, - 'name', - CRM_Core_Config::domainID(), - ]); + 'CRM_Financial_DAO_PaymentProcessor', + $this->_id, + 'name', + CRM_Core_Config::domainID(), + ]); $this->add('text', 'description', ts('Description'), $attributes['description'] diff --git a/CRM/Admin/Form/PdfFormats.php b/CRM/Admin/Form/PdfFormats.php index c075b044bb8e..94e29cbf03f7 100644 --- a/CRM/Admin/Form/PdfFormats.php +++ b/CRM/Admin/Form/PdfFormats.php @@ -80,9 +80,9 @@ public function buildQuickForm() { $this->add('number', 'weight', ts('Order'), CRM_Core_DAO::getAttribute('CRM_Core_BAO_PdfFormat', 'weight'), TRUE); $this->addRule('name', ts('Name already exists in Database.'), 'objectExists', [ - 'CRM_Core_BAO_PdfFormat', - $this->_id, - ]); + 'CRM_Core_BAO_PdfFormat', + $this->_id, + ]); $this->addRule('margin_left', ts('Margin must be numeric'), 'numeric'); $this->addRule('margin_right', ts('Margin must be numeric'), 'numeric'); $this->addRule('margin_top', ts('Margin must be numeric'), 'numeric'); diff --git a/CRM/Admin/Form/Persistent.php b/CRM/Admin/Form/Persistent.php index 3c44d8473770..e62d3313bc0b 100644 --- a/CRM/Admin/Form/Persistent.php +++ b/CRM/Admin/Form/Persistent.php @@ -73,17 +73,16 @@ public function buildQuickForm() { $this->add('text', 'name', ts('Name:'), NULL, TRUE); $this->add('textarea', 'data', ts('Data:'), ['rows' => 4, 'cols' => 50], TRUE); $this->addButtons([ - [ - 'type' => 'submit', - 'name' => ts('Save'), - 'isDefault' => TRUE, - ], - [ - 'type' => 'cancel', - 'name' => ts('Cancel'), - ], - ] - ); + [ + 'type' => 'submit', + 'name' => ts('Save'), + 'isDefault' => TRUE, + ], + [ + 'type' => 'cancel', + 'name' => ts('Cancel'), + ], + ]); } public function postProcess() { diff --git a/CRM/Admin/Form/Preferences.php b/CRM/Admin/Form/Preferences.php index 6a6e8e2e7ab3..55578d404a53 100644 --- a/CRM/Admin/Form/Preferences.php +++ b/CRM/Admin/Form/Preferences.php @@ -228,17 +228,16 @@ public function buildQuickForm() { } $this->addButtons([ - [ - 'type' => 'next', - 'name' => ts('Save'), - 'isDefault' => TRUE, - ], - [ - 'type' => 'cancel', - 'name' => ts('Cancel'), - ], - ] - ); + [ + 'type' => 'next', + 'name' => ts('Save'), + 'isDefault' => TRUE, + ], + [ + 'type' => 'cancel', + 'name' => ts('Cancel'), + ], + ]); if ($this->_action == CRM_Core_Action::VIEW) { $this->freeze(); diff --git a/CRM/Admin/Form/RelationshipType.php b/CRM/Admin/Form/RelationshipType.php index 8383ed28de56..1b537f90634a 100644 --- a/CRM/Admin/Form/RelationshipType.php +++ b/CRM/Admin/Form/RelationshipType.php @@ -69,11 +69,11 @@ protected function setEntityFields() { ], 'label_b_a' => [ 'name' => 'label_b_a', - 'description' => ts("Label for the relationship from Contact B to Contact A. EXAMPLE: Contact B is 'Child of' Contact A. You may leave this blank for relationships where the name is the same in both directions (e.g. Spouse).") + 'description' => ts("Label for the relationship from Contact B to Contact A. EXAMPLE: Contact B is 'Child of' Contact A. You may leave this blank for relationships where the name is the same in both directions (e.g. Spouse)."), ], 'description' => [ 'name' => 'description', - 'description' => '' + 'description' => '', ], 'contact_types_a' => ['name' => 'contact_types_a', 'not-auto-addable' => TRUE], 'contact_types_b' => ['name' => 'contact_types_b', 'not-auto-addable' => TRUE], diff --git a/CRM/Admin/Form/Setting.php b/CRM/Admin/Form/Setting.php index 6f60a4c9333f..e0be4241a38e 100644 --- a/CRM/Admin/Form/Setting.php +++ b/CRM/Admin/Form/Setting.php @@ -74,17 +74,16 @@ public function setDefaultValues() { public function buildQuickForm() { CRM_Core_Session::singleton()->pushUserContext(CRM_Utils_System::url('civicrm/admin', 'reset=1')); $this->addButtons([ - [ - 'type' => 'next', - 'name' => ts('Save'), - 'isDefault' => TRUE, - ], - [ - 'type' => 'cancel', - 'name' => ts('Cancel'), - ], - ] - ); + [ + 'type' => 'next', + 'name' => ts('Save'), + 'isDefault' => TRUE, + ], + [ + 'type' => 'cancel', + 'name' => ts('Cancel'), + ], + ]); $this->addFieldsDefinedInSettingsMetadata(); @@ -143,7 +142,8 @@ public function commonProcess(&$params) { } CRM_Core_Config::clearDBCache(); - Civi::cache('session')->clear(); // This doesn't make a lot of sense to me, but it maintains pre-existing behavior. + // This doesn't make a lot of sense to me, but it maintains pre-existing behavior. + Civi::cache('session')->clear(); CRM_Utils_System::flushCache(); CRM_Core_Resources::singleton()->resetCacheCode(); diff --git a/CRM/Admin/Form/Setting/UF.php b/CRM/Admin/Form/Setting/UF.php index 7fa620428db3..efb8e9a44fbb 100644 --- a/CRM/Admin/Form/Setting/UF.php +++ b/CRM/Admin/Form/Setting/UF.php @@ -85,7 +85,8 @@ function_exists('module_exists') && if ($config->userFramework === 'Backdrop') { $tablePrefixes = '$database_prefix = array('; } - $tablePrefixes .= "\n 'default' => '$drupal_prefix',"; // add default prefix: the drupal database prefix + // add default prefix: the drupal database prefix + $tablePrefixes .= "\n 'default' => '$drupal_prefix',"; $prefix = ""; if ($config->dsn != $config->userFrameworkDSN) { $prefix = "`{$dsnArray['database']}`."; diff --git a/CRM/Admin/Form/WordReplacements.php b/CRM/Admin/Form/WordReplacements.php index df67f04a2403..7213107cf547 100644 --- a/CRM/Admin/Form/WordReplacements.php +++ b/CRM/Admin/Form/WordReplacements.php @@ -139,17 +139,16 @@ public function buildQuickForm() { $this->assign('stringOverrideInstances', empty($stringOverrideInstances) ? FALSE : $stringOverrideInstances); $this->addButtons([ - [ - 'type' => 'next', - 'name' => ts('Save'), - 'isDefault' => TRUE, - ], - [ - 'type' => 'cancel', - 'name' => ts('Cancel'), - ], - ] - ); + [ + 'type' => 'next', + 'name' => ts('Save'), + 'isDefault' => TRUE, + ], + [ + 'type' => 'cancel', + 'name' => ts('Cancel'), + ], + ]); $this->addFormRule(['CRM_Admin_Form_WordReplacements', 'formRule'], $this); } diff --git a/CRM/Admin/Page/AJAX.php b/CRM/Admin/Page/AJAX.php index 02a9485e3bdc..f6dc2edee1fa 100644 --- a/CRM/Admin/Page/AJAX.php +++ b/CRM/Admin/Page/AJAX.php @@ -162,8 +162,8 @@ public static function getStatusMsg() { $ret['illegal'] = TRUE; $table = $template->fetch('CRM/Price/Page/table.tpl'); $ret['content'] = ts('Unable to disable the \'%1\' price set - it is currently in use by one or more active events, contribution pages or contributions.', [ - 1 => $priceSet, - ]) . "
    $table"; + 1 => $priceSet, + ]) . "
    $table"; } else { $ret['content'] = ts('Are you sure you want to disable \'%1\' Price Set?', [1 => $priceSet]); From 5d4fcf5450aed1c1b8b3fef49efdb56a75dec7c9 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Fri, 5 Apr 2019 14:27:21 -0700 Subject: [PATCH 089/121] (NFC) Apply upcoming civicrm/coder policies (batch 2) Method: * Checkout latest merged branch of civicrm/coder (`8.x-2.x-civi`) * Run this command to autoclean a batch of 100 files `PG=2 SIZE=100 ; find Civi/ CRM/ api/ bin/ extern/ tests/ -name '*.php' | grep -v /examples/ | grep -v /DAO/ | sort | head -n $(( $PG * $SIZE )) | tail -n $SIZE | xargs phpcbf-civi` * Go through the diff. For anything that looks wonky, open in an editor and find a better solution. Note: The automated checker makes good points about awkward indentation, but the automated cleanup often makes it worse. So that's why I have to open it up. --- CRM/Admin/Page/CKEditorConfig.php | 10 +++-- CRM/Admin/Page/Extensions.php | 3 +- CRM/Admin/Page/ExtensionsUpgrade.php | 3 +- CRM/Admin/Page/MessageTemplates.php | 3 +- CRM/Admin/Page/PaymentProcessor.php | 6 +-- CRM/Badge/Form/Layout.php | 29 +++++++------ CRM/Batch/Form/Entry.php | 30 +++++++------- CRM/Campaign/BAO/Campaign.php | 3 +- CRM/Campaign/BAO/Query.php | 5 +-- CRM/Campaign/BAO/Survey.php | 9 ++-- CRM/Campaign/Form/Campaign.php | 21 +++++----- CRM/Campaign/Form/Petition/Signature.php | 13 +++--- CRM/Campaign/Form/Search.php | 6 +-- CRM/Campaign/Form/Search/Campaign.php | 3 +- CRM/Campaign/Form/Survey/Delete.php | 21 +++++----- CRM/Campaign/Form/Survey/Questions.php | 3 +- CRM/Campaign/Form/Survey/Results.php | 3 +- CRM/Campaign/Form/Task.php | 21 +++++----- CRM/Campaign/Form/Task/Interview.php | 22 +++++----- CRM/Campaign/Form/Task/Print.php | 23 +++++------ CRM/Campaign/Form/Task/Release.php | 12 +++--- CRM/Campaign/Form/Task/Result.php | 13 +++--- CRM/Campaign/Page/AJAX.php | 44 ++++++++++---------- CRM/Campaign/Page/Vote.php | 3 +- CRM/Case/BAO/Case.php | 3 +- CRM/Case/BAO/CaseType.php | 3 +- CRM/Case/Form/Activity/ChangeCaseStatus.php | 7 ++-- CRM/Case/Form/Activity/OpenCase.php | 44 ++++++++++---------- CRM/Case/Form/Case.php | 46 ++++++++++----------- CRM/Case/Form/CaseView.php | 21 +++++----- CRM/Case/Form/CustomData.php | 21 +++++----- 31 files changed, 219 insertions(+), 235 deletions(-) diff --git a/CRM/Admin/Page/CKEditorConfig.php b/CRM/Admin/Page/CKEditorConfig.php index ac157b423e4a..03f7ec34b046 100644 --- a/CRM/Admin/Page/CKEditorConfig.php +++ b/CRM/Admin/Page/CKEditorConfig.php @@ -106,10 +106,12 @@ public function run() { $this->assign('configUrl', $configUrl); $this->assign('revertConfirm', htmlspecialchars(ts('Are you sure you want to revert all changes?', ['escape' => 'js']))); - CRM_Utils_System::appendBreadCrumb([[ - 'url' => CRM_Utils_System::url('civicrm/admin/setting/preferences/display', 'reset=1'), - 'title' => ts('Display Preferences'), - ]]); + CRM_Utils_System::appendBreadCrumb([ + [ + 'url' => CRM_Utils_System::url('civicrm/admin/setting/preferences/display', 'reset=1'), + 'title' => ts('Display Preferences'), + ], + ]); return parent::run(); } diff --git a/CRM/Admin/Page/Extensions.php b/CRM/Admin/Page/Extensions.php index 9250536e5d9e..d242c9090be4 100644 --- a/CRM/Admin/Page/Extensions.php +++ b/CRM/Admin/Page/Extensions.php @@ -160,7 +160,8 @@ public function formatLocalExtensionRows() { $mapper = CRM_Extension_System::singleton()->getMapper(); $manager = CRM_Extension_System::singleton()->getManager(); - $localExtensionRows = []; // array($pseudo_id => extended_CRM_Extension_Info) + // array($pseudo_id => extended_CRM_Extension_Info) + $localExtensionRows = []; $keys = array_keys($manager->getStatuses()); sort($keys); foreach ($keys as $key) { diff --git a/CRM/Admin/Page/ExtensionsUpgrade.php b/CRM/Admin/Page/ExtensionsUpgrade.php index fceb66ebb365..3a183826fc25 100644 --- a/CRM/Admin/Page/ExtensionsUpgrade.php +++ b/CRM/Admin/Page/ExtensionsUpgrade.php @@ -24,7 +24,8 @@ public function run() { ]); CRM_Core_Error::debug_log_message('CRM_Admin_Page_ExtensionsUpgrade: Start upgrades'); - $runner->runAllViaWeb(); // does not return + // does not return + $runner->runAllViaWeb(); } /** diff --git a/CRM/Admin/Page/MessageTemplates.php b/CRM/Admin/Page/MessageTemplates.php index ab21c4da1786..86efc76239c2 100644 --- a/CRM/Admin/Page/MessageTemplates.php +++ b/CRM/Admin/Page/MessageTemplates.php @@ -161,7 +161,8 @@ public function action(&$object, $action, &$values, &$links, $permission, $force } // rebuild the action links HTML, as we need to handle %%orig_id%% for revertible templates - $values['action'] = CRM_Core_Action::formLink($links, $action, [ + $values['action'] = CRM_Core_Action::formLink($links, $action, + [ 'id' => $object->id, 'orig_id' => CRM_Utils_Array::value($object->id, $this->_revertible), ], diff --git a/CRM/Admin/Page/PaymentProcessor.php b/CRM/Admin/Page/PaymentProcessor.php index b79a3d4eedce..4a5142e88a15 100644 --- a/CRM/Admin/Page/PaymentProcessor.php +++ b/CRM/Admin/Page/PaymentProcessor.php @@ -101,9 +101,9 @@ public function run() { CRM_Utils_System::setTitle(ts('Settings - Payment Processor')); //CRM-15546 $paymentProcessorTypes = CRM_Core_PseudoConstant::get('CRM_Financial_DAO_PaymentProcessor', 'payment_processor_type_id', array( - 'labelColumn' => 'name', - 'flip' => 1, - )); + 'labelColumn' => 'name', + 'flip' => 1, + )); $this->assign('defaultPaymentProcessorType', $paymentProcessorTypes['PayPal']); $breadCrumb = array( array( diff --git a/CRM/Badge/Form/Layout.php b/CRM/Badge/Form/Layout.php index a34b5ebcc465..af93d47ee057 100644 --- a/CRM/Badge/Form/Layout.php +++ b/CRM/Badge/Form/Layout.php @@ -131,21 +131,20 @@ public function buildQuickForm() { $this->addRule('width_participant_image', ts('Enter valid height'), 'positiveInteger'); $this->addButtons([ - [ - 'type' => 'next', - 'name' => ts('Save'), - 'isDefault' => TRUE, - ], - [ - 'type' => 'refresh', - 'name' => ts('Save and Preview'), - ], - [ - 'type' => 'cancel', - 'name' => ts('Cancel'), - ], - ] - ); + [ + 'type' => 'next', + 'name' => ts('Save'), + 'isDefault' => TRUE, + ], + [ + 'type' => 'refresh', + 'name' => ts('Save and Preview'), + ], + [ + 'type' => 'cancel', + 'name' => ts('Cancel'), + ], + ]); } /** diff --git a/CRM/Batch/Form/Entry.php b/CRM/Batch/Form/Entry.php index ab4475da8196..ec698a8d1d0e 100644 --- a/CRM/Batch/Form/Entry.php +++ b/CRM/Batch/Form/Entry.php @@ -177,17 +177,16 @@ public function buildQuickForm() { ); $this->addButtons([ - [ - 'type' => 'upload', - 'name' => ts('Validate & Process the Batch'), - 'isDefault' => TRUE, - ], - [ - 'type' => 'cancel', - 'name' => ts('Save & Continue Later'), - ], - ] - ); + [ + 'type' => 'upload', + 'name' => ts('Validate & Process the Batch'), + 'isDefault' => TRUE, + ], + [ + 'type' => 'cancel', + 'name' => ts('Save & Continue Later'), + ], + ]); $this->assign('rowCount', $this->_batchInfo['item_count'] + 1); @@ -204,9 +203,9 @@ public function buildQuickForm() { for ($rowNumber = 1; $rowNumber <= $this->_batchInfo['item_count']; $rowNumber++) { $this->addEntityRef("primary_contact_id[{$rowNumber}]", '', [ - 'create' => TRUE, - 'placeholder' => ts('- select -'), - ]); + 'create' => TRUE, + 'placeholder' => ts('- select -'), + ]); // special field specific to membership batch udpate if ($this->_batchInfo['type_id'] == 2) { @@ -254,7 +253,8 @@ public function buildQuickForm() { // Notes: $this->_elementIndex gives an approximate count of the variables being sent // An offset value is set to deal with additional vars that are likely passed. // There may be a more accurate way to do this... - $offset = 50; // set an offset to account for other vars we are not counting + // set an offset to account for other vars we are not counting + $offset = 50; if ((count($this->_elementIndex) + $offset) > ini_get("max_input_vars")) { CRM_Core_Error::fatal(ts('Batch size is too large. Increase value of php.ini setting "max_input_vars" (current val = ' . ini_get("max_input_vars") . ')')); } diff --git a/CRM/Campaign/BAO/Campaign.php b/CRM/Campaign/BAO/Campaign.php index 23c75b5c7948..0d5ebe8cb5ba 100644 --- a/CRM/Campaign/BAO/Campaign.php +++ b/CRM/Campaign/BAO/Campaign.php @@ -716,7 +716,8 @@ public static function getEntityRefCreateLinks() { 'url' => CRM_Utils_System::url('civicrm/campaign/add', "reset=1", NULL, NULL, FALSE, FALSE, TRUE), 'type' => 'Campaign', - ]]; + ], + ]; } return FALSE; } diff --git a/CRM/Campaign/BAO/Query.php b/CRM/Campaign/BAO/Query.php index 4f2f0e09a7d9..86391e8348c3 100644 --- a/CRM/Campaign/BAO/Query.php +++ b/CRM/Campaign/BAO/Query.php @@ -398,10 +398,7 @@ public static function buildSearchForm(&$form) { $dao = CRM_Core_DAO::executeQuery($query, [1 => ['Voter_Info', 'String']]); $customSearchFields = []; while ($dao->fetch()) { - foreach ([ - 'ward', - 'precinct', - ] as $name) { + foreach (['ward', 'precinct'] as $name) { if (stripos($name, $dao->label) !== FALSE) { $fieldId = $dao->id; $fieldName = 'custom_' . $dao->id; diff --git a/CRM/Campaign/BAO/Survey.php b/CRM/Campaign/BAO/Survey.php index 7ec3ca0e4ad2..63c9244890b5 100644 --- a/CRM/Campaign/BAO/Survey.php +++ b/CRM/Campaign/BAO/Survey.php @@ -439,11 +439,8 @@ public static function voterDetails($voterIds, $returnProperties = []) { $autocompleteContactSearch = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_autocomplete_options' ); - $returnProperties = array_fill_keys(array_merge([ - 'contact_type', - 'contact_sub_type', - 'sort_name', - ], + $returnProperties = array_fill_keys(array_merge( + ['contact_type', 'contact_sub_type', 'sort_name'], array_keys($autocompleteContactSearch) ), 1); } @@ -913,7 +910,7 @@ public static function getSurveyProfileId($surveyId) { * * @return mixed */ - public Static function getReportID($surveyId) { + public static function getReportID($surveyId) { static $reportIds = []; if (!array_key_exists($surveyId, $reportIds)) { diff --git a/CRM/Campaign/Form/Campaign.php b/CRM/Campaign/Form/Campaign.php index 91536ec81d73..06a3c6130bda 100644 --- a/CRM/Campaign/Form/Campaign.php +++ b/CRM/Campaign/Form/Campaign.php @@ -168,17 +168,16 @@ public function buildQuickForm() { if ($this->_action & CRM_Core_Action::DELETE) { $this->addButtons([ - [ - 'type' => 'next', - 'name' => ts('Delete'), - 'isDefault' => TRUE, - ], - [ - 'type' => 'cancel', - 'name' => ts('Cancel'), - ], - ] - ); + [ + 'type' => 'next', + 'name' => ts('Delete'), + 'isDefault' => TRUE, + ], + [ + 'type' => 'cancel', + 'name' => ts('Cancel'), + ], + ]); return; } diff --git a/CRM/Campaign/Form/Petition/Signature.php b/CRM/Campaign/Form/Petition/Signature.php index c973bfdc559d..f39166cebff2 100644 --- a/CRM/Campaign/Form/Petition/Signature.php +++ b/CRM/Campaign/Form/Petition/Signature.php @@ -297,13 +297,12 @@ public function buildQuickForm() { } // add buttons $this->addButtons([ - [ - 'type' => 'upload', - 'name' => ts('Sign the Petition'), - 'isDefault' => TRUE, - ], - ] - ); + [ + 'type' => 'upload', + 'name' => ts('Sign the Petition'), + 'isDefault' => TRUE, + ], + ]); } /** diff --git a/CRM/Campaign/Form/Search.php b/CRM/Campaign/Form/Search.php index 02c54b871d94..43b0c707babd 100644 --- a/CRM/Campaign/Form/Search.php +++ b/CRM/Campaign/Form/Search.php @@ -339,11 +339,7 @@ public function formatParams() { //apply filter of survey contact type for search. $contactType = CRM_Campaign_BAO_Survey::getSurveyContactType(CRM_Utils_Array::value('campaign_survey_id', $this->_formValues)); - if ($contactType && in_array($this->_operation, array( - 'reserve', - 'interview', - )) - ) { + if ($contactType && in_array($this->_operation, ['reserve', 'interview'])) { $this->_formValues['contact_type'][$contactType] = 1; } diff --git a/CRM/Campaign/Form/Search/Campaign.php b/CRM/Campaign/Form/Search/Campaign.php index 331cadd60520..6fc5d63ab848 100644 --- a/CRM/Campaign/Form/Search/Campaign.php +++ b/CRM/Campaign/Form/Search/Campaign.php @@ -110,8 +110,7 @@ public function buildQuickForm() { '' => ts('- select -'), '0' => ts('Yes'), '1' => ts('No'), - ] - ); + ]); //build the array of all search params. $this->_searchParams = []; diff --git a/CRM/Campaign/Form/Survey/Delete.php b/CRM/Campaign/Form/Survey/Delete.php index 8d32335eb8cb..2f473c9632fa 100644 --- a/CRM/Campaign/Form/Survey/Delete.php +++ b/CRM/Campaign/Form/Survey/Delete.php @@ -72,17 +72,16 @@ public function preProcess() { */ public function buildQuickForm() { $this->addButtons([ - [ - 'type' => 'next', - 'name' => ts('Delete'), - 'isDefault' => TRUE, - ], - [ - 'type' => 'cancel', - 'name' => ts('Cancel'), - ], - ] - ); + [ + 'type' => 'next', + 'name' => ts('Delete'), + 'isDefault' => TRUE, + ], + [ + 'type' => 'cancel', + 'name' => ts('Cancel'), + ], + ]); } /** diff --git a/CRM/Campaign/Form/Survey/Questions.php b/CRM/Campaign/Form/Survey/Questions.php index b0cfd2ddba73..c7154ceb37b4 100644 --- a/CRM/Campaign/Form/Survey/Questions.php +++ b/CRM/Campaign/Form/Survey/Questions.php @@ -66,7 +66,8 @@ public function setDefaultValues() { public function buildQuickForm() { $subTypeId = CRM_Core_DAO::getFieldValue('CRM_Campaign_DAO_Survey', $this->_surveyId, 'activity_type_id'); if (!CRM_Core_BAO_CustomGroup::autoCreateByActivityType($subTypeId)) { - $activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE, FALSE); // everything + // everything + $activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE, FALSE); // FIXME: Displays weird "/\ Array" message; doesn't work with tabs CRM_Core_Session::setStatus( ts( diff --git a/CRM/Campaign/Form/Survey/Results.php b/CRM/Campaign/Form/Survey/Results.php index 5c2946ac8e97..20475c05aac0 100644 --- a/CRM/Campaign/Form/Survey/Results.php +++ b/CRM/Campaign/Form/Survey/Results.php @@ -413,7 +413,8 @@ public function postProcess() { 'name' => "survey_{$survey->id}", 'title' => $params['report_title'] ? $params['report_title'] : $this->_values['title'], 'status_id_op' => 'eq', - 'status_id_value' => $activityStatus['Scheduled'], // reserved status + // reserved status + 'status_id_value' => $activityStatus['Scheduled'], 'survey_id_value' => [$survey->id], 'description' => ts('Detailed report for canvassing, phone-banking, walk lists or other surveys.'), ]; diff --git a/CRM/Campaign/Form/Task.php b/CRM/Campaign/Form/Task.php index 86b7a269b930..f6575049df61 100644 --- a/CRM/Campaign/Form/Task.php +++ b/CRM/Campaign/Form/Task.php @@ -109,17 +109,16 @@ public function setContactIDs() { */ public function addDefaultButtons($title, $nextType = 'next', $backType = 'back', $submitOnce = FALSE) { $this->addButtons([ - [ - 'type' => $nextType, - 'name' => $title, - 'isDefault' => TRUE, - ], - [ - 'type' => $backType, - 'name' => ts('Cancel'), - ], - ] - ); + [ + 'type' => $nextType, + 'name' => $title, + 'isDefault' => TRUE, + ], + [ + 'type' => $backType, + 'name' => ts('Cancel'), + ], + ]); } } diff --git a/CRM/Campaign/Form/Task/Interview.php b/CRM/Campaign/Form/Task/Interview.php index 30bc84499d95..1bffb99f9a1d 100644 --- a/CRM/Campaign/Form/Task/Interview.php +++ b/CRM/Campaign/Form/Task/Interview.php @@ -75,10 +75,10 @@ public function preProcess() { if ($this->_reserveToInterview || $this->_votingTab) { //user came from voting tab / reserve form. foreach ([ - 'surveyId', - 'contactIds', - 'interviewerId', - ] as $fld) { + 'surveyId', + 'contactIds', + 'interviewerId', + ] as $fld) { $this->{"_$fld"} = $this->get($fld); } //get the target voter ids. @@ -292,9 +292,9 @@ public function buildQuickForm() { for ($i = 1; $i < count($options); $i++) { $this->addElement('select', "order_bys[{$i}][column]", ts('Order by Column'), $options); $this->addElement('select', "order_bys[{$i}][order]", ts('Order by Order'), [ - 'ASC' => ts('Ascending'), - 'DESC' => ts('Descending'), - ]); + 'ASC' => ts('Ascending'), + 'DESC' => ts('Descending'), + ]); } //pickup the uf fields. @@ -443,10 +443,10 @@ public function postProcess() { elseif ($buttonName == '_qf_Interview_next_interviewToRelease') { //get ready to jump to release form. foreach ([ - 'surveyId', - 'contactIds', - 'interviewerId', - ] as $fld) { + 'surveyId', + 'contactIds', + 'interviewerId', + ] as $fld) { $this->controller->set($fld, $this->{"_$fld"}); } $this->controller->set('interviewToRelease', TRUE); diff --git a/CRM/Campaign/Form/Task/Print.php b/CRM/Campaign/Form/Task/Print.php index e6fea042b596..bfc08a11000f 100644 --- a/CRM/Campaign/Form/Task/Print.php +++ b/CRM/Campaign/Form/Task/Print.php @@ -82,18 +82,17 @@ public function buildQuickForm() { // just need to add a javacript to popup the window for printing // $this->addButtons([ - [ - 'type' => 'next', - 'name' => ts('Print Respondents'), - 'js' => ['onclick' => 'window.print()'], - 'isDefault' => TRUE, - ], - [ - 'type' => 'back', - 'name' => ts('Done'), - ], - ] - ); + [ + 'type' => 'next', + 'name' => ts('Print Respondents'), + 'js' => ['onclick' => 'window.print()'], + 'isDefault' => TRUE, + ], + [ + 'type' => 'back', + 'name' => ts('Done'), + ], + ]); } /** diff --git a/CRM/Campaign/Form/Task/Release.php b/CRM/Campaign/Form/Task/Release.php index c45a8d536951..75d994d1557c 100644 --- a/CRM/Campaign/Form/Task/Release.php +++ b/CRM/Campaign/Form/Task/Release.php @@ -67,10 +67,10 @@ public function preProcess() { if ($this->_interviewToRelease) { //user came from interview form. foreach ([ - 'surveyId', - 'contactIds', - 'interviewerId', - ] as $fld) { + 'surveyId', + 'contactIds', + 'interviewerId', + ] as $fld) { $this->{"_$fld"} = $this->get($fld); } @@ -101,9 +101,7 @@ public function preProcess() { $activityStatus = CRM_Core_PseudoConstant::activityStatus('name'); $statusIds = []; - foreach ([ - 'Scheduled', - ] as $name) { + foreach (['Scheduled'] as $name) { if ($statusId = array_search($name, $activityStatus)) { $statusIds[] = $statusId; } diff --git a/CRM/Campaign/Form/Task/Result.php b/CRM/Campaign/Form/Task/Result.php index 88185e585973..25f81fb7fdbd 100644 --- a/CRM/Campaign/Form/Task/Result.php +++ b/CRM/Campaign/Form/Task/Result.php @@ -47,13 +47,12 @@ public function preProcess() { */ public function buildQuickForm() { $this->addButtons([ - [ - 'type' => 'done', - 'name' => ts('Done'), - 'isDefault' => TRUE, - ], - ] - ); + [ + 'type' => 'done', + 'name' => ts('Done'), + 'isDefault' => TRUE, + ], + ]); } } diff --git a/CRM/Campaign/Page/AJAX.php b/CRM/Campaign/Page/AJAX.php index a784ef99af20..ecec01993619 100644 --- a/CRM/Campaign/Page/AJAX.php +++ b/CRM/Campaign/Page/AJAX.php @@ -158,9 +158,9 @@ public function voterList() { //format multi-select group and contact types. foreach ([ - 'group', - 'contact_type', - ] as $param) { + 'group', + 'contact_type', + ] as $param) { $paramValue = CRM_Utils_Array::value($param, $params); if ($paramValue) { unset($params[$param]); @@ -173,10 +173,10 @@ public function voterList() { $voterClauseParams = []; foreach ([ - 'campaign_survey_id', - 'survey_interviewer_id', - 'campaign_search_voter_for', - ] as $fld) { + 'campaign_survey_id', + 'survey_interviewer_id', + 'campaign_search_voter_for', + ] as $fld) { $voterClauseParams[$fld] = CRM_Utils_Array::value($fld, $params); } @@ -602,11 +602,11 @@ public static function campaignList() { } } foreach ([ - 'sort', - 'offset', - 'rowCount', - 'sortOrder', - ] as $sortParam) { + 'sort', + 'offset', + 'rowCount', + 'sortOrder', + ] as $sortParam) { $params[$sortParam] = $$sortParam; } @@ -707,11 +707,11 @@ public function surveyList() { } } foreach ([ - 'sort', - 'offset', - 'rowCount', - 'sortOrder', - ] as $sortParam) { + 'sort', + 'offset', + 'rowCount', + 'sortOrder', + ] as $sortParam) { $params[$sortParam] = $$sortParam; } @@ -807,11 +807,11 @@ public function petitionList() { } } foreach ([ - 'sort', - 'offset', - 'rowCount', - 'sortOrder', - ] as $sortParam) { + 'sort', + 'offset', + 'rowCount', + 'sortOrder', + ] as $sortParam) { $params[$sortParam] = $$sortParam; } diff --git a/CRM/Campaign/Page/Vote.php b/CRM/Campaign/Page/Vote.php index 4bb67d1cc477..ad131746ff45 100644 --- a/CRM/Campaign/Page/Vote.php +++ b/CRM/Campaign/Page/Vote.php @@ -119,8 +119,7 @@ public function buildTabs() { 'administer CiviCampaign', "{$name} campaign contacts", ], - ]) - ) { + ])) { continue; } diff --git a/CRM/Case/BAO/Case.php b/CRM/Case/BAO/Case.php index 09e2cb6fe09c..db2d1ca90c96 100644 --- a/CRM/Case/BAO/Case.php +++ b/CRM/Case/BAO/Case.php @@ -76,7 +76,8 @@ public static function add(&$params) { $caseDAO = new CRM_Case_DAO_Case(); $caseDAO->copyValues($params); $result = $caseDAO->save(); - $caseDAO->find(TRUE); // Get other case values (required by XML processor), this adds to $result array + // Get other case values (required by XML processor), this adds to $result array + $caseDAO->find(TRUE); return $result; } diff --git a/CRM/Case/BAO/CaseType.php b/CRM/Case/BAO/CaseType.php index b89f35abf30e..d7985761140c 100644 --- a/CRM/Case/BAO/CaseType.php +++ b/CRM/Case/BAO/CaseType.php @@ -160,7 +160,8 @@ public static function convertDefinitionToXML($name, $definition) { } break; - case 'sequence': // passthrough + // passthrough + case 'sequence': case 'timeline': if ($setVal) { $xmlFile .= "<{$index}>true\n"; diff --git a/CRM/Case/Form/Activity/ChangeCaseStatus.php b/CRM/Case/Form/Activity/ChangeCaseStatus.php index a5503aac1e6b..d0059b0cf23d 100644 --- a/CRM/Case/Form/Activity/ChangeCaseStatus.php +++ b/CRM/Case/Form/Activity/ChangeCaseStatus.php @@ -208,10 +208,9 @@ public static function endPostProcess(&$form, &$params, $activity) { foreach ($form->_oldCaseStatus as $statuskey => $statusval) { if ($activity->subject == 'null') { $activity->subject = ts('Case status changed from %1 to %2', [ - 1 => CRM_Utils_Array::value($statusval, $form->_caseStatus), - 2 => CRM_Utils_Array::value($params['case_status_id'], $form->_caseStatus), - ] - ); + 1 => CRM_Utils_Array::value($statusval, $form->_caseStatus), + 2 => CRM_Utils_Array::value($params['case_status_id'], $form->_caseStatus), + ]); $activity->save(); } } diff --git a/CRM/Case/Form/Activity/OpenCase.php b/CRM/Case/Form/Activity/OpenCase.php index 1903cc87d410..37f794492e22 100644 --- a/CRM/Case/Form/Activity/OpenCase.php +++ b/CRM/Case/Form/Activity/OpenCase.php @@ -107,7 +107,8 @@ public static function setDefaultValues(&$form) { else { $caseStatus = CRM_Core_OptionGroup::values('case_status', FALSE, FALSE, FALSE, 'AND is_default = 1'); if (count($caseStatus) == 1) { - $caseStatus = key($caseStatus); //$defaults['status_id'] = key($caseStatus); + //$defaults['status_id'] = key($caseStatus); + $caseStatus = key($caseStatus); } } $defaults['status_id'] = $caseStatus; @@ -153,9 +154,9 @@ public static function buildQuickForm(&$form) { } if ($form->_context == 'standalone') { $form->addEntityRef('client_id', ts('Client'), [ - 'create' => TRUE, - 'multiple' => $form->_allowMultiClient, - ], TRUE); + 'create' => TRUE, + 'multiple' => $form->_allowMultiClient, + ], TRUE); } $element = $form->addField('case_type_id', [ @@ -193,24 +194,23 @@ public static function buildQuickForm(&$form) { $form->add('wysiwyg', 'activity_details', ts('Details'), ['rows' => 4, 'cols' => 60], FALSE); $form->addButtons([ - [ - 'type' => 'upload', - 'name' => ts('Save'), - 'isDefault' => TRUE, - 'submitOnce' => TRUE, - ], - [ - 'type' => 'upload', - 'name' => ts('Save and New'), - 'subName' => 'new', - 'submitOnce' => TRUE, - ], - [ - 'type' => 'cancel', - 'name' => ts('Cancel'), - ], - ] - ); + [ + 'type' => 'upload', + 'name' => ts('Save'), + 'isDefault' => TRUE, + 'submitOnce' => TRUE, + ], + [ + 'type' => 'upload', + 'name' => ts('Save and New'), + 'subName' => 'new', + 'submitOnce' => TRUE, + ], + [ + 'type' => 'cancel', + 'name' => ts('Cancel'), + ], + ]); } /** diff --git a/CRM/Case/Form/Case.php b/CRM/Case/Form/Case.php index 87885469db23..f988aba14562 100644 --- a/CRM/Case/Form/Case.php +++ b/CRM/Case/Form/Case.php @@ -239,18 +239,17 @@ public function buildQuickForm() { $title = ts('Restore'); } $this->addButtons([ - [ - 'type' => 'next', - 'name' => $title, - 'spacing' => '         ', - 'isDefault' => TRUE, - ], - [ - 'type' => 'cancel', - 'name' => ts('Cancel'), - ], - ] - ); + [ + 'type' => 'next', + 'name' => $title, + 'spacing' => '         ', + 'isDefault' => TRUE, + ], + [ + 'type' => 'cancel', + 'name' => ts('Cancel'), + ], + ]); return; } @@ -283,18 +282,17 @@ public function buildQuickForm() { CRM_Core_Form_Tag::buildQuickForm($this, $parentNames, 'civicrm_case', NULL, FALSE, TRUE); $this->addButtons([ - [ - 'type' => 'next', - 'name' => ts('Save'), - 'spacing' => '         ', - 'isDefault' => TRUE, - ], - [ - 'type' => 'cancel', - 'name' => ts('Cancel'), - ], - ] - ); + [ + 'type' => 'next', + 'name' => ts('Save'), + 'spacing' => '         ', + 'isDefault' => TRUE, + ], + [ + 'type' => 'cancel', + 'name' => ts('Cancel'), + ], + ]); $className = "CRM_Case_Form_Activity_{$this->_activityTypeFile}"; $className::buildQuickForm($this); diff --git a/CRM/Case/Form/CaseView.php b/CRM/Case/Form/CaseView.php index dd479144b48b..fdf587ca58df 100644 --- a/CRM/Case/Form/CaseView.php +++ b/CRM/Case/Form/CaseView.php @@ -148,9 +148,9 @@ public function preProcess() { $this->assign('hasRelatedCases', (bool) $relatedCases); if ($relatedCases) { $this->assign('relatedCaseLabel', ts('%1 Related Case', [ - 'count' => count($relatedCases), - 'plural' => '%1 Related Cases', - ])); + 'count' => count($relatedCases), + 'plural' => '%1 Related Cases', + ])); $this->assign('relatedCaseUrl', CRM_Utils_System::url('civicrm/contact/view/case', [ 'id' => $this->_caseID, 'cid' => $this->_contactID, @@ -398,14 +398,13 @@ public function buildQuickForm() { CRM_Core_Form_Tag::buildQuickForm($this, $parentNames, 'civicrm_case', $this->_caseID, FALSE, TRUE); $this->addButtons([ - [ - 'type' => 'cancel', - 'name' => ts('Done'), - 'spacing' => '         ', - 'isDefault' => TRUE, - ], - ] - ); + [ + 'type' => 'cancel', + 'name' => ts('Done'), + 'spacing' => '         ', + 'isDefault' => TRUE, + ], + ]); } /** diff --git a/CRM/Case/Form/CustomData.php b/CRM/Case/Form/CustomData.php index 0ff5a3dde932..46f375414973 100644 --- a/CRM/Case/Form/CustomData.php +++ b/CRM/Case/Form/CustomData.php @@ -99,17 +99,16 @@ public function buildQuickForm() { // make this form an upload since we dont know if the custom data injected dynamically // is of type file etc $this->addButtons([ - [ - 'type' => 'upload', - 'name' => ts('Save'), - 'isDefault' => TRUE, - ], - [ - 'type' => 'cancel', - 'name' => ts('Cancel'), - ], - ] - ); + [ + 'type' => 'upload', + 'name' => ts('Save'), + 'isDefault' => TRUE, + ], + [ + 'type' => 'cancel', + 'name' => ts('Cancel'), + ], + ]); } /** From 34f3bbd96c35d9758ab4f702b6020e203a2febbe Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Sat, 6 Apr 2019 16:12:54 +1100 Subject: [PATCH 090/121] (NFC) Upgrade Civi Folder to the new coder version --- Civi/API/Event/PrepareEvent.php | 1 + Civi/API/Event/ResolveEvent.php | 1 + .../API/Exception/NotImplementedException.php | 1 + Civi/API/Exception/UnauthorizedException.php | 1 + Civi/API/ExternalBatch.php | 4 ++-- Civi/API/Kernel.php | 24 +++++++++---------- Civi/API/Provider/MagicFunctionProvider.php | 7 ++++-- Civi/API/Provider/ProviderInterface.php | 4 +--- Civi/API/Provider/ReflectionProvider.php | 4 +++- Civi/API/Provider/StaticProvider.php | 6 ++--- Civi/API/SelectQuery.php | 1 + Civi/API/Subscriber/APIv3SchemaAdapter.php | 1 + Civi/API/Subscriber/ChainSubscriber.php | 1 + .../API/Subscriber/DynamicFKAuthorization.php | 3 ++- Civi/API/Subscriber/I18nSubscriber.php | 1 + Civi/API/Subscriber/PermissionCheck.php | 1 + Civi/API/Subscriber/TransactionSubscriber.php | 1 + Civi/API/Subscriber/WhitelistSubscriber.php | 7 +++--- Civi/API/Subscriber/XDebugSubscriber.php | 1 + Civi/API/WhitelistRule.php | 2 +- .../Event/MailingQueryEvent.php | 5 ++-- .../Event/MappingRegisterEvent.php | 2 +- Civi/ActionSchedule/Mapping.php | 4 ++-- Civi/Angular/Manager.php | 1 + Civi/CCase/CaseChangeListener.php | 1 + Civi/CCase/Event/CaseChangeEvent.php | 1 + Civi/CCase/Events.php | 2 +- Civi/CiUtil/Arrays.php | 1 + Civi/CiUtil/Command/AntagonistCommand.php | 1 + Civi/CiUtil/Command/CompareCommand.php | 7 ++++-- Civi/CiUtil/Command/LsCommand.php | 1 + Civi/CiUtil/ComparisonPrinter.php | 4 ++-- Civi/CiUtil/CsvPrinter.php | 6 ++--- Civi/CiUtil/JenkinsParser.php | 1 + Civi/CiUtil/PHPUnitParser.php | 1 + Civi/CiUtil/PHPUnitScanner.php | 1 + Civi/Core/AssetBuilder.php | 9 +++---- Civi/Core/Container.php | 22 +++++------------ Civi/Core/LocalizationInitializer.php | 1 - Civi/Core/Resolver.php | 3 ++- Civi/Core/SettingsManager.php | 14 ++++++++--- Civi/Core/SqlTrigger/StaticTriggers.php | 1 - Civi/Core/SqlTrigger/TimestampTriggers.php | 2 -- Civi/Core/SqlTriggers.php | 4 ++-- Civi/Install/Requirements.php | 8 +++++-- Civi/Test.php | 3 +-- Civi/Test/Api3TestTrait.php | 3 ++- Civi/Test/CiviEnvBuilder/CallbackStep.php | 1 + Civi/Test/CiviEnvBuilder/ExtensionsStep.php | 1 + Civi/Test/CiviEnvBuilder/SqlFileStep.php | 1 - Civi/Test/CiviEnvBuilder/SqlStep.php | 2 +- Civi/Test/CiviEnvBuilder/StepInterface.php | 1 + Civi/Test/CiviTestListener.php | 3 ++- Civi/Token/AbstractTokenSubscriber.php | 8 +++---- Civi/Token/TokenCompatSubscriber.php | 7 +++--- Civi/Token/TokenProcessor.php | 15 +++++++----- Civi/Token/TokenRow.php | 8 +++---- 57 files changed, 130 insertions(+), 98 deletions(-) diff --git a/Civi/API/Event/PrepareEvent.php b/Civi/API/Event/PrepareEvent.php index 7d8d7738d206..cc06e179ec1f 100644 --- a/Civi/API/Event/PrepareEvent.php +++ b/Civi/API/Event/PrepareEvent.php @@ -32,6 +32,7 @@ * @package Civi\API\Event */ class PrepareEvent extends Event { + /** * @param array $apiRequest * The full description of the API request. diff --git a/Civi/API/Event/ResolveEvent.php b/Civi/API/Event/ResolveEvent.php index b41da5b22b7a..396418649173 100644 --- a/Civi/API/Event/ResolveEvent.php +++ b/Civi/API/Event/ResolveEvent.php @@ -32,6 +32,7 @@ * @package Civi\API\Event */ class ResolveEvent extends Event { + /** * @param array $apiRequest * The full description of the API request. diff --git a/Civi/API/Exception/NotImplementedException.php b/Civi/API/Exception/NotImplementedException.php index 0c263d4f8b47..b8f253f13ebd 100644 --- a/Civi/API/Exception/NotImplementedException.php +++ b/Civi/API/Exception/NotImplementedException.php @@ -8,6 +8,7 @@ * @package Civi\API\Exception */ class NotImplementedException extends \API_Exception { + /** * @param string $message * The human friendly error message. diff --git a/Civi/API/Exception/UnauthorizedException.php b/Civi/API/Exception/UnauthorizedException.php index e35cf3faa308..4e3bdbf7379e 100644 --- a/Civi/API/Exception/UnauthorizedException.php +++ b/Civi/API/Exception/UnauthorizedException.php @@ -8,6 +8,7 @@ * @package Civi\API\Exception */ class UnauthorizedException extends \API_Exception { + /** * @param string $message * The human friendly error message. diff --git a/Civi/API/ExternalBatch.php b/Civi/API/ExternalBatch.php index d2f039a85468..f9ea3ae69cf2 100644 --- a/Civi/API/ExternalBatch.php +++ b/Civi/API/ExternalBatch.php @@ -119,7 +119,7 @@ public function wait() { while (!empty($this->processes)) { usleep(self::POLL_INTERVAL); foreach (array_keys($this->processes) as $idx) { - /** @var Process $process */ + /** @var \Symfony\Component\Process\Process $process */ $process = $this->processes[$idx]; if (!$process->isRunning()) { $parsed = json_decode($process->getOutput(), TRUE); @@ -179,7 +179,7 @@ public function isSupported() { /** * @param array $apiCall * Array with keys: entity, action, params. - * @return Process + * @return \Symfony\Component\Process\Process * @throws \CRM_Core_Exception */ public function createProcess($apiCall) { diff --git a/Civi/API/Kernel.php b/Civi/API/Kernel.php index 96167a8e8e47..cc0cc3805f2c 100644 --- a/Civi/API/Kernel.php +++ b/Civi/API/Kernel.php @@ -31,7 +31,6 @@ use Civi\API\Event\ExceptionEvent; use Civi\API\Event\ResolveEvent; use Civi\API\Event\RespondEvent; -use Civi\API\Provider\ProviderInterface; /** * @package Civi @@ -217,7 +216,7 @@ protected function validate($apiRequest) { * Array(0 => ProviderInterface, 1 => array $apiRequest). */ public function resolve($apiRequest) { - /** @var ResolveEvent $resolveEvent */ + /** @var \Civi\API\Event\ResolveEvent $resolveEvent */ $resolveEvent = $this->dispatcher->dispatch(Events::RESOLVE, new ResolveEvent($apiRequest, $this)); $apiRequest = $resolveEvent->getApiRequest(); if (!$resolveEvent->getApiProvider()) { @@ -229,14 +228,14 @@ public function resolve($apiRequest) { /** * Determine if the API request is allowed (under current policy) * - * @param ProviderInterface $apiProvider + * @param \Civi\API\Provider\ProviderInterface $apiProvider * The API provider responsible for executing the request. * @param array $apiRequest * The full description of the API request. * @throws Exception\UnauthorizedException */ public function authorize($apiProvider, $apiRequest) { - /** @var AuthorizeEvent $event */ + /** @var \Civi\API\Event\AuthorizeEvent $event */ $event = $this->dispatcher->dispatch(Events::AUTHORIZE, new AuthorizeEvent($apiProvider, $apiRequest, $this)); if (!$event->isAuthorized()) { throw new \Civi\API\Exception\UnauthorizedException("Authorization failed"); @@ -246,7 +245,7 @@ public function authorize($apiProvider, $apiRequest) { /** * Allow third-party code to manipulate the API request before execution. * - * @param ProviderInterface $apiProvider + * @param \Civi\API\Provider\ProviderInterface $apiProvider * The API provider responsible for executing the request. * @param array $apiRequest * The full description of the API request. @@ -254,7 +253,7 @@ public function authorize($apiProvider, $apiRequest) { * The revised API request. */ public function prepare($apiProvider, $apiRequest) { - /** @var PrepareEvent $event */ + /** @var \Civi\API\Event\PrepareEvent $event */ $event = $this->dispatcher->dispatch(Events::PREPARE, new PrepareEvent($apiProvider, $apiRequest, $this)); return $event->getApiRequest(); } @@ -262,7 +261,7 @@ public function prepare($apiProvider, $apiRequest) { /** * Allow third-party code to manipulate the API response after execution. * - * @param ProviderInterface $apiProvider + * @param \Civi\API\Provider\ProviderInterface $apiProvider * The API provider responsible for executing the request. * @param array $apiRequest * The full description of the API request. @@ -272,7 +271,7 @@ public function prepare($apiProvider, $apiRequest) { * The revised $result. */ public function respond($apiProvider, $apiRequest, $result) { - /** @var RespondEvent $event */ + /** @var \Civi\API\Event\RespondEvent $event */ $event = $this->dispatcher->dispatch(Events::RESPOND, new RespondEvent($apiProvider, $apiRequest, $result, $this)); return $event->getResponse(); } @@ -287,7 +286,7 @@ public function getEntityNames($version) { // Question: Would it better to eliminate $this->apiProviders and just use $this->dispatcher? $entityNames = []; foreach ($this->getApiProviders() as $provider) { - /** @var ProviderInterface $provider */ + /** @var \Civi\API\Provider\ProviderInterface $provider */ $entityNames = array_merge($entityNames, $provider->getEntityNames($version)); } $entityNames = array_unique($entityNames); @@ -307,7 +306,7 @@ public function getActionNames($version, $entity) { // Question: Would it better to eliminate $this->apiProviders and just use $this->dispatcher? $actionNames = []; foreach ($this->getApiProviders() as $provider) { - /** @var ProviderInterface $provider */ + /** @var \Civi\API\Provider\ProviderInterface $provider */ $actionNames = array_merge($actionNames, $provider->getActionNames($version, $entity)); } $actionNames = array_unique($actionNames); @@ -345,7 +344,8 @@ public function formatApiException($e, $apiRequest) { $data['action'] = \CRM_Utils_Array::value('action', $apiRequest); if (\CRM_Utils_Array::value('debug', \CRM_Utils_Array::value('params', $apiRequest)) - && empty($data['trace']) // prevent recursion + // prevent recursion + && empty($data['trace']) ) { $data['trace'] = $e->getTraceAsString(); } @@ -459,7 +459,7 @@ public function setApiProviders($apiProviders) { } /** - * @param ProviderInterface $apiProvider + * @param \Civi\API\Provider\ProviderInterface $apiProvider * The API provider responsible for executing the request. * @return Kernel */ diff --git a/Civi/API/Provider/MagicFunctionProvider.php b/Civi/API/Provider/MagicFunctionProvider.php index 27324e452e4a..346b47035987 100644 --- a/Civi/API/Provider/MagicFunctionProvider.php +++ b/Civi/API/Provider/MagicFunctionProvider.php @@ -35,6 +35,7 @@ * conventions. */ class MagicFunctionProvider implements EventSubscriberInterface, ProviderInterface { + /** * @return array */ @@ -285,7 +286,8 @@ protected function loadEntity($entity, $version) { } // Check for standalone action files; to match _civicrm_api_resolve(), only load the first one - $loaded_files = []; // array($relativeFilePath => TRUE) + // array($relativeFilePath => TRUE) + $loaded_files = []; $include_dirs = array_unique(explode(PATH_SEPARATOR, get_include_path())); foreach ($include_dirs as $include_dir) { foreach ([$camelName, 'Generic'] as $name) { @@ -299,7 +301,8 @@ protected function loadEntity($entity, $version) { foreach ($iterator as $fileinfo) { $file = $fileinfo->getFilename(); if (array_key_exists($file, $loaded_files)) { - continue; // action provided by an earlier item on include_path + // action provided by an earlier item on include_path + continue; } $parts = explode(".", $file); diff --git a/Civi/API/Provider/ProviderInterface.php b/Civi/API/Provider/ProviderInterface.php index c002eeec0127..4fbc8b7e316a 100644 --- a/Civi/API/Provider/ProviderInterface.php +++ b/Civi/API/Provider/ProviderInterface.php @@ -27,13 +27,11 @@ namespace Civi\API\Provider; -use Civi\API\Events; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; - /** * An API "provider" provides a means to execute API requests. */ interface ProviderInterface { + /** * @param array $apiRequest * The full description of the API request. diff --git a/Civi/API/Provider/ReflectionProvider.php b/Civi/API/Provider/ReflectionProvider.php index 48a680d29fbb..e3c74e51833f 100644 --- a/Civi/API/Provider/ReflectionProvider.php +++ b/Civi/API/Provider/ReflectionProvider.php @@ -34,6 +34,7 @@ * This class defines operations for inspecting the API's metadata. */ class ReflectionProvider implements EventSubscriberInterface, ProviderInterface { + /** * @return array */ @@ -68,7 +69,8 @@ public function __construct($apiKernel) { $this->apiKernel = $apiKernel; $this->actions = [ 'Entity' => ['get', 'getactions'], - '*' => ['getactions'], // 'getfields' + // 'getfields' + '*' => ['getactions'], ]; } diff --git a/Civi/API/Provider/StaticProvider.php b/Civi/API/Provider/StaticProvider.php index f4e2701e0530..0a10aee85a95 100644 --- a/Civi/API/Provider/StaticProvider.php +++ b/Civi/API/Provider/StaticProvider.php @@ -102,7 +102,7 @@ public function setRecords($records) { * @param array $apiRequest * The full description of the API request. * @return array - * Formatted API result + * Formatted API result * @throws \API_Exception */ public function doCreate($apiRequest) { @@ -131,7 +131,7 @@ public function doCreate($apiRequest) { * @param array $apiRequest * The full description of the API request. * @return array - * Formatted API result + * Formatted API result * @throws \API_Exception */ public function doGet($apiRequest) { @@ -142,7 +142,7 @@ public function doGet($apiRequest) { * @param array $apiRequest * The full description of the API request. * @return array - * Formatted API result + * Formatted API result * @throws \API_Exception */ public function doDelete($apiRequest) { diff --git a/Civi/API/SelectQuery.php b/Civi/API/SelectQuery.php index 9a03d7eb39be..f7b61cd8910b 100644 --- a/Civi/API/SelectQuery.php +++ b/Civi/API/SelectQuery.php @@ -25,6 +25,7 @@ +--------------------------------------------------------------------+ */ namespace Civi\API; + use Civi\API\Exception\UnauthorizedException; /** diff --git a/Civi/API/Subscriber/APIv3SchemaAdapter.php b/Civi/API/Subscriber/APIv3SchemaAdapter.php index af77d3b7ea5e..e6428711eb4d 100644 --- a/Civi/API/Subscriber/APIv3SchemaAdapter.php +++ b/Civi/API/Subscriber/APIv3SchemaAdapter.php @@ -35,6 +35,7 @@ * and validates that the fields are provided correctly. */ class APIv3SchemaAdapter implements EventSubscriberInterface { + /** * @return array */ diff --git a/Civi/API/Subscriber/ChainSubscriber.php b/Civi/API/Subscriber/ChainSubscriber.php index 5fb27c1ed69e..84b55753a0e9 100644 --- a/Civi/API/Subscriber/ChainSubscriber.php +++ b/Civi/API/Subscriber/ChainSubscriber.php @@ -50,6 +50,7 @@ * eg Amy's contact_id). */ class ChainSubscriber implements EventSubscriberInterface { + /** * @return array */ diff --git a/Civi/API/Subscriber/DynamicFKAuthorization.php b/Civi/API/Subscriber/DynamicFKAuthorization.php index 03ba52d0b42b..647172ceddfb 100644 --- a/Civi/API/Subscriber/DynamicFKAuthorization.php +++ b/Civi/API/Subscriber/DynamicFKAuthorization.php @@ -227,7 +227,8 @@ public function authorizeDelegate($action, $entityTable, $entityId, $apiRequest) $exception = NULL; $self = $this; \CRM_Core_Transaction::create(TRUE)->run(function($tx) use ($entity, $action, $entityId, &$exception, $self) { - $tx->rollback(); // Just to be safe. + // Just to be safe. + $tx->rollback(); $params = [ 'version' => 3, diff --git a/Civi/API/Subscriber/I18nSubscriber.php b/Civi/API/Subscriber/I18nSubscriber.php index 632064f3cfa4..c430928202ba 100644 --- a/Civi/API/Subscriber/I18nSubscriber.php +++ b/Civi/API/Subscriber/I18nSubscriber.php @@ -35,6 +35,7 @@ * @package Civi\API\Subscriber */ class I18nSubscriber implements EventSubscriberInterface { + /** * @return array */ diff --git a/Civi/API/Subscriber/PermissionCheck.php b/Civi/API/Subscriber/PermissionCheck.php index 0a8248ef57bd..c4fe5c748139 100644 --- a/Civi/API/Subscriber/PermissionCheck.php +++ b/Civi/API/Subscriber/PermissionCheck.php @@ -36,6 +36,7 @@ * Civi\API\Annotation\Permission. */ class PermissionCheck implements EventSubscriberInterface { + /** * @return array */ diff --git a/Civi/API/Subscriber/TransactionSubscriber.php b/Civi/API/Subscriber/TransactionSubscriber.php index 8b110ab70c40..4f7b0c64d870 100644 --- a/Civi/API/Subscriber/TransactionSubscriber.php +++ b/Civi/API/Subscriber/TransactionSubscriber.php @@ -44,6 +44,7 @@ * @package Civi\API\Subscriber */ class TransactionSubscriber implements EventSubscriberInterface { + /** * @return array */ diff --git a/Civi/API/Subscriber/WhitelistSubscriber.php b/Civi/API/Subscriber/WhitelistSubscriber.php index 3c69c04af140..fbb272d3959d 100644 --- a/Civi/API/Subscriber/WhitelistSubscriber.php +++ b/Civi/API/Subscriber/WhitelistSubscriber.php @@ -29,7 +29,6 @@ use Civi\API\Events; use Civi\API\Event\AuthorizeEvent; use Civi\API\Event\RespondEvent; -use Civi\API\WhitelistRule; use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** @@ -75,7 +74,7 @@ public static function getSubscribedEvents() { public function __construct($rules) { $this->rules = []; foreach ($rules as $rule) { - /** @var WhitelistRule $rule */ + /** @var \Civi\API\WhitelistRule $rule */ if ($rule->isValid()) { $this->rules[] = $rule; } @@ -89,7 +88,7 @@ public function __construct($rules) { * Determine which, if any, whitelist rules apply this request. * Reject unauthorized requests. * - * @param AuthorizeEvent $event + * @param \Civi\API\Event\AuthorizeEvent $event * @throws \CRM_Core_Exception */ public function onApiAuthorize(AuthorizeEvent $event) { @@ -108,7 +107,7 @@ public function onApiAuthorize(AuthorizeEvent $event) { /** * Apply any filtering rules based on the chosen whitelist rule. - * @param RespondEvent $event + * @param \Civi\API\Event\RespondEvent $event */ public function onApiRespond(RespondEvent $event) { $apiRequest = $event->getApiRequest(); diff --git a/Civi/API/Subscriber/XDebugSubscriber.php b/Civi/API/Subscriber/XDebugSubscriber.php index 294ed9fd23aa..0648cf50b73b 100644 --- a/Civi/API/Subscriber/XDebugSubscriber.php +++ b/Civi/API/Subscriber/XDebugSubscriber.php @@ -35,6 +35,7 @@ * @package Civi\API\Subscriber */ class XDebugSubscriber implements EventSubscriberInterface { + /** * @return array */ diff --git a/Civi/API/WhitelistRule.php b/Civi/API/WhitelistRule.php index 50d5b3e232bc..0cc9ef01292e 100644 --- a/Civi/API/WhitelistRule.php +++ b/Civi/API/WhitelistRule.php @@ -48,7 +48,7 @@ */ class WhitelistRule { - static $IGNORE_FIELDS = [ + public static $IGNORE_FIELDS = [ 'check_permissions', 'debug', 'offset', diff --git a/Civi/ActionSchedule/Event/MailingQueryEvent.php b/Civi/ActionSchedule/Event/MailingQueryEvent.php index 472c1c3bcdd4..e8b136e84dc4 100644 --- a/Civi/ActionSchedule/Event/MailingQueryEvent.php +++ b/Civi/ActionSchedule/Event/MailingQueryEvent.php @@ -1,7 +1,6 @@ res = $res; diff --git a/Civi/CCase/CaseChangeListener.php b/Civi/CCase/CaseChangeListener.php index 65f115b6e99c..b473a090e03d 100644 --- a/Civi/CCase/CaseChangeListener.php +++ b/Civi/CCase/CaseChangeListener.php @@ -32,6 +32,7 @@ * @package Civi\CCase */ interface CaseChangeListener { + /** * @param \Civi\CCase\Event\CaseChangeEvent $event * diff --git a/Civi/CCase/Event/CaseChangeEvent.php b/Civi/CCase/Event/CaseChangeEvent.php index e091ac4ba7b3..a873b519f937 100644 --- a/Civi/CCase/Event/CaseChangeEvent.php +++ b/Civi/CCase/Event/CaseChangeEvent.php @@ -26,6 +26,7 @@ */ namespace Civi\CCase\Event; + use Civi\Core\Event\GenericHookEvent; /** diff --git a/Civi/CCase/Events.php b/Civi/CCase/Events.php index 278590dfa932..a3890248f274 100644 --- a/Civi/CCase/Events.php +++ b/Civi/CCase/Events.php @@ -37,7 +37,7 @@ class Events { * * We do not want to fire case-change events recursively. */ - static $isActive = []; + public static $isActive = []; /** * Following a change to an activity or case, fire the case-change event. diff --git a/Civi/CiUtil/Arrays.php b/Civi/CiUtil/Arrays.php index 48b6c226d412..e3933ee126a2 100644 --- a/Civi/CiUtil/Arrays.php +++ b/Civi/CiUtil/Arrays.php @@ -7,6 +7,7 @@ * @package Civi\CiUtil */ class Arrays { + /** * @param $arr * @param $col diff --git a/Civi/CiUtil/Command/AntagonistCommand.php b/Civi/CiUtil/Command/AntagonistCommand.php index 4f7e47911663..d8d9761ffe1a 100644 --- a/Civi/CiUtil/Command/AntagonistCommand.php +++ b/Civi/CiUtil/Command/AntagonistCommand.php @@ -7,6 +7,7 @@ * @package Civi\CiUtil\Command */ class AntagonistCommand { + /** * @param $argv */ diff --git a/Civi/CiUtil/Command/CompareCommand.php b/Civi/CiUtil/Command/CompareCommand.php index 84b7064239de..beae7ac77976 100644 --- a/Civi/CiUtil/Command/CompareCommand.php +++ b/Civi/CiUtil/Command/CompareCommand.php @@ -7,6 +7,7 @@ * @package Civi\CiUtil\Command */ class CompareCommand { + /** * @param $argv */ @@ -19,7 +20,8 @@ public static function main($argv) { $parser = ['\Civi\CiUtil\PHPUnitParser', 'parseJsonResults']; $printerType = 'txt'; - $suites = []; // array('file' => string, 'results' => array) + // array('file' => string, 'results' => array) + $suites = []; for ($i = 1; $i < count($argv); $i++) { switch ($argv[$i]) { case '--phpunit-json': @@ -50,7 +52,8 @@ public static function main($argv) { } } - $tests = []; // array(string $name) + // array(string $name) + $tests = []; foreach ($suites as $suite) { $tests = array_unique(array_merge( $tests, diff --git a/Civi/CiUtil/Command/LsCommand.php b/Civi/CiUtil/Command/LsCommand.php index 88f0d84947e3..f0db547cf54c 100644 --- a/Civi/CiUtil/Command/LsCommand.php +++ b/Civi/CiUtil/Command/LsCommand.php @@ -7,6 +7,7 @@ * @package Civi\CiUtil\Command */ class LsCommand { + /** * @param $argv */ diff --git a/Civi/CiUtil/ComparisonPrinter.php b/Civi/CiUtil/ComparisonPrinter.php index a58a83eb6704..27acd8908c6c 100644 --- a/Civi/CiUtil/ComparisonPrinter.php +++ b/Civi/CiUtil/ComparisonPrinter.php @@ -7,8 +7,8 @@ * @package Civi\CiUtil */ class ComparisonPrinter { - var $headers; - var $hasHeader = FALSE; + public $headers; + public $hasHeader = FALSE; /** * @param $headers diff --git a/Civi/CiUtil/CsvPrinter.php b/Civi/CiUtil/CsvPrinter.php index 4c4ec185a3ef..55c7dbba4393 100644 --- a/Civi/CiUtil/CsvPrinter.php +++ b/Civi/CiUtil/CsvPrinter.php @@ -7,9 +7,9 @@ * @package Civi\CiUtil */ class CsvPrinter { - var $file; - var $headers; - var $hasHeader = FALSE; + public $file; + public $headers; + public $hasHeader = FALSE; /** * @param $file diff --git a/Civi/CiUtil/JenkinsParser.php b/Civi/CiUtil/JenkinsParser.php index 616219ced24e..4a1429876869 100644 --- a/Civi/CiUtil/JenkinsParser.php +++ b/Civi/CiUtil/JenkinsParser.php @@ -5,6 +5,7 @@ * Parse Jenkins result files */ class JenkinsParser { + /** * @param string $content * Xml data. diff --git a/Civi/CiUtil/PHPUnitParser.php b/Civi/CiUtil/PHPUnitParser.php index e956388adf1c..9ff2b7d572c2 100644 --- a/Civi/CiUtil/PHPUnitParser.php +++ b/Civi/CiUtil/PHPUnitParser.php @@ -5,6 +5,7 @@ * Parse phpunit result files */ class PHPUnitParser { + /** * @param string $content * Phpunit streaming JSON. diff --git a/Civi/CiUtil/PHPUnitScanner.php b/Civi/CiUtil/PHPUnitScanner.php index 8264e9e2660b..a1028f52f5c8 100644 --- a/Civi/CiUtil/PHPUnitScanner.php +++ b/Civi/CiUtil/PHPUnitScanner.php @@ -7,6 +7,7 @@ * Search for PHPUnit test cases */ class PHPUnitScanner { + /** * @param $path * @return array class names diff --git a/Civi/Core/AssetBuilder.php b/Civi/Core/AssetBuilder.php index 595a53ce4054..b60f41e20bcc 100644 --- a/Civi/Core/AssetBuilder.php +++ b/Civi/Core/AssetBuilder.php @@ -84,6 +84,9 @@ public static function getCacheModes() { ]; } + /** + * @var mixed + */ protected $cacheEnabled; /** @@ -238,8 +241,7 @@ public function clear() { protected function getCachePath($fileName = NULL) { // imageUploadDir has the correct functional properties but a wonky name. $suffix = ($fileName === NULL) ? '' : (DIRECTORY_SEPARATOR . $fileName); - return - \CRM_Utils_File::addTrailingSlash(\CRM_Core_Config::singleton()->imageUploadDir) + return \CRM_Utils_File::addTrailingSlash(\CRM_Core_Config::singleton()->imageUploadDir) . 'dyn' . $suffix; } @@ -255,8 +257,7 @@ protected function getCachePath($fileName = NULL) { protected function getCacheUrl($fileName = NULL) { // imageUploadURL has the correct functional properties but a wonky name. $suffix = ($fileName === NULL) ? '' : ('/' . $fileName); - return - \CRM_Utils_File::addTrailingSlash(\CRM_Core_Config::singleton()->imageUploadURL, '/') + return \CRM_Utils_File::addTrailingSlash(\CRM_Core_Config::singleton()->imageUploadURL, '/') . 'dyn' . $suffix; } diff --git a/Civi/Core/Container.php b/Civi/Core/Container.php index 2763d763d7ce..4e01f4a9dbd8 100644 --- a/Civi/Core/Container.php +++ b/Civi/Core/Container.php @@ -1,23 +1,13 @@ SettingsBag $bag). */ - protected $bagsByDomain = [], $bagsByContact = []; + protected $bagsByDomain = []; + + + /** + * @var array + * Array (int $id => SettingsBag $bag). + */ + protected $bagsByContact = []; /** * @var array|NULL @@ -310,7 +317,8 @@ public function flush() { $this->mandatory = NULL; $this->cache->flush(); - \Civi::cache('settings')->flush(); // SettingsMetadata; not guaranteed to use same cache. + // SettingsMetadata; not guaranteed to use same cache. + \Civi::cache('settings')->flush(); foreach ($this->bagsByDomain as $bag) { /** @var SettingsBag $bag */ diff --git a/Civi/Core/SqlTrigger/StaticTriggers.php b/Civi/Core/SqlTrigger/StaticTriggers.php index e97213967f70..c0f6f981b773 100644 --- a/Civi/Core/SqlTrigger/StaticTriggers.php +++ b/Civi/Core/SqlTrigger/StaticTriggers.php @@ -56,7 +56,6 @@ public function __construct($triggers) { $this->triggers = $triggers; } - /** * Add our list of triggers to the global list. * diff --git a/Civi/Core/SqlTrigger/TimestampTriggers.php b/Civi/Core/SqlTrigger/TimestampTriggers.php index 235ce70b604c..c2249cf07d45 100644 --- a/Civi/Core/SqlTrigger/TimestampTriggers.php +++ b/Civi/Core/SqlTrigger/TimestampTriggers.php @@ -28,8 +28,6 @@ namespace Civi\Core\SqlTrigger; -use Civi\Core\Event\GenericHookEvent; - /** * Build a set of SQL triggers for tracking timestamps on an entity. * diff --git a/Civi/Core/SqlTriggers.php b/Civi/Core/SqlTriggers.php index 172e7d0e79e0..ce54d1844899 100644 --- a/Civi/Core/SqlTriggers.php +++ b/Civi/Core/SqlTriggers.php @@ -207,8 +207,8 @@ public function enqueueQuery($triggerSQL, $params = []) { if (!file_exists($this->getFile())) { // Ugh. Need to let user know somehow. This is the first change. \CRM_Core_Session::setStatus(ts('The mysql commands you need to run are stored in %1', [ - 1 => $this->getFile(), - ]), + 1 => $this->getFile(), + ]), '', 'alert', ['expires' => 0] diff --git a/Civi/Install/Requirements.php b/Civi/Install/Requirements.php index e4423e8f51e2..7d8fd3821c4e 100644 --- a/Civi/Install/Requirements.php +++ b/Civi/Install/Requirements.php @@ -23,6 +23,9 @@ class Requirements { */ const REQUIREMENT_ERROR = 2; + /** + * @var array + */ protected $system_checks = [ 'checkMemory', 'checkServerVariables', @@ -106,7 +109,7 @@ public function checkDatabase(array $db_config) { /** * Generates a mysql connection * - * @param $db_confic array + * @param $db_config array * @return object mysqli connection */ protected function connect($db_config) { @@ -488,7 +491,8 @@ public function checkMysqlThreadStack($db_config) { return $results; } - $r = mysqli_query($conn, "SHOW VARIABLES LIKE 'thread_stack'"); // bytes => kb + // bytes => kb + $r = mysqli_query($conn, "SHOW VARIABLES LIKE 'thread_stack'"); if (!$r) { $results['severity'] = $this::REQUIREMENT_ERROR; $results['details'] = 'Could not query thread_stack value'; diff --git a/Civi/Test.php b/Civi/Test.php index 8e44fcd5094f..51d929054dab 100644 --- a/Civi/Test.php +++ b/Civi/Test.php @@ -45,7 +45,7 @@ public static function dsn($part = NULL) { /** * Get a connection to the test database. * - * @return PDO + * @return \PDO */ public static function pdo() { if (!isset(self::$singletons['pdo'])) { @@ -127,7 +127,6 @@ public static function schema() { return self::$singletons['schema']; } - /** * @return \Civi\Test\Data */ diff --git a/Civi/Test/Api3TestTrait.php b/Civi/Test/Api3TestTrait.php index 4b85837021c3..5386e93969dc 100644 --- a/Civi/Test/Api3TestTrait.php +++ b/Civi/Test/Api3TestTrait.php @@ -16,6 +16,7 @@ trait Api3TestTrait { /** * Api version - easier to override than just a define + * @var int */ protected $_apiversion = 3; @@ -206,7 +207,7 @@ public function callAPISuccessGetSingle($entity, $params, $checkAgainst = NULL) throw new \Exception( 'Invalid getsingle result' . print_r($result, TRUE) . "\n entity: $entity . \n params \n " . print_r($params, TRUE) - . "\n entities retrieved with blank params \n" . print_r($unfilteredResult, TRUE) + . "\n entities retrieved with blank params \n" . print_r($unfilteredResult, TRUE) ); } if ($checkAgainst) { diff --git a/Civi/Test/CiviEnvBuilder/CallbackStep.php b/Civi/Test/CiviEnvBuilder/CallbackStep.php index 6d0c9f055c3a..8e6110bee38e 100644 --- a/Civi/Test/CiviEnvBuilder/CallbackStep.php +++ b/Civi/Test/CiviEnvBuilder/CallbackStep.php @@ -1,5 +1,6 @@ file = $file; } - public function getSig() { return implode(' ', [ $this->file, diff --git a/Civi/Test/CiviEnvBuilder/SqlStep.php b/Civi/Test/CiviEnvBuilder/SqlStep.php index 7a2736b019c8..e892883e03ce 100644 --- a/Civi/Test/CiviEnvBuilder/SqlStep.php +++ b/Civi/Test/CiviEnvBuilder/SqlStep.php @@ -1,5 +1,6 @@ sql = $sql; } - public function getSig() { return md5($this->sql); } diff --git a/Civi/Test/CiviEnvBuilder/StepInterface.php b/Civi/Test/CiviEnvBuilder/StepInterface.php index 3d6dc95cc1e3..8ed2c2ce77df 100644 --- a/Civi/Test/CiviEnvBuilder/StepInterface.php +++ b/Civi/Test/CiviEnvBuilder/StepInterface.php @@ -2,6 +2,7 @@ namespace Civi\Test\CiviEnvBuilder; interface StepInterface { + public function getSig(); public function isValid(); diff --git a/Civi/Test/CiviTestListener.php b/Civi/Test/CiviTestListener.php index 8eca8cbf756a..255eb8628f71 100644 --- a/Civi/Test/CiviTestListener.php +++ b/Civi/Test/CiviTestListener.php @@ -98,7 +98,8 @@ protected function bootHeadless($test) { \CRM_Utils_System::flushCache(); \Civi::reset(); \CRM_Core_Session::singleton()->set('userID', NULL); - $config = \CRM_Core_Config::singleton(TRUE, TRUE); // ugh, performance + // ugh, performance + $config = \CRM_Core_Config::singleton(TRUE, TRUE); if (property_exists($config->userPermissionClass, 'permissions')) { $config->userPermissionClass->permissions = NULL; diff --git a/Civi/Token/AbstractTokenSubscriber.php b/Civi/Token/AbstractTokenSubscriber.php index 38d2875ce3f5..012d306930ae 100644 --- a/Civi/Token/AbstractTokenSubscriber.php +++ b/Civi/Token/AbstractTokenSubscriber.php @@ -110,7 +110,7 @@ public function checkActive(\Civi\Token\TokenProcessor $processor) { /** * Register the declared tokens. * - * @param TokenRegisterEvent $e + * @param \Civi\Token\Event\TokenRegisterEvent $e * The registration event. Add new tokens using register(). */ public function registerTokens(TokenRegisterEvent $e) { @@ -133,7 +133,7 @@ public function registerTokens(TokenRegisterEvent $e) { * This is method is not always appropriate, but if you're specifically * focused on scheduled reminders, it can be convenient. * - * @param MailingQueryEvent $e + * @param \Civi\ActionSchedule\Event\MailingQueryEvent $e * The pending query which may be modified. See discussion on * MailingQueryEvent::$query. */ @@ -143,7 +143,7 @@ public function alterActionScheduleQuery(MailingQueryEvent $e) { /** * Populate the token data. * - * @param TokenValueEvent $e + * @param \Civi\Token\Event\TokenValueEvent $e * The event, which includes a list of rows and tokens. */ public function evaluateTokens(TokenValueEvent $e) { @@ -204,6 +204,6 @@ public function prefetch(TokenValueEvent $e) { * Any data that was returned by the prefetch(). * @return mixed */ - public abstract function evaluateToken(TokenRow $row, $entity, $field, $prefetch = NULL); + abstract public function evaluateToken(TokenRow $row, $entity, $field, $prefetch = NULL); } diff --git a/Civi/Token/TokenCompatSubscriber.php b/Civi/Token/TokenCompatSubscriber.php index 2e8721e67696..672080d29ba4 100644 --- a/Civi/Token/TokenCompatSubscriber.php +++ b/Civi/Token/TokenCompatSubscriber.php @@ -33,7 +33,7 @@ public static function getSubscribedEvents() { /** * Load token data. * - * @param TokenValueEvent $e + * @param \Civi\Token\Event\TokenValueEvent $e * @throws TokenException */ public function onEvaluate(TokenValueEvent $e) { @@ -59,7 +59,8 @@ public function onEvaluate(TokenValueEvent $e) { ['contact_id', '=', $contactId, 0, 0], ]; list($contact, $_) = \CRM_Contact_BAO_Query::apiQuery($params); - $contact = reset($contact); //CRM-4524 + //CRM-4524 + $contact = reset($contact); if (!$contact || is_a($contact, 'CRM_Core_Error')) { // FIXME: Need to differentiate errors which kill the batch vs the individual row. throw new TokenException("Failed to generate token data. Invalid contact ID: " . $row->context['contactId']); @@ -109,7 +110,7 @@ public function onEvaluate(TokenValueEvent $e) { /** * Apply the various CRM_Utils_Token helpers. * - * @param TokenRenderEvent $e + * @param \Civi\Token\Event\TokenRenderEvent $e */ public function onRender(TokenRenderEvent $e) { $isHtml = ($e->message['format'] == 'text/html'); diff --git a/Civi/Token/TokenProcessor.php b/Civi/Token/TokenProcessor.php index c98977343546..1364ed714faa 100644 --- a/Civi/Token/TokenProcessor.php +++ b/Civi/Token/TokenProcessor.php @@ -4,7 +4,6 @@ use Civi\Token\Event\TokenRegisterEvent; use Civi\Token\Event\TokenRenderEvent; use Civi\Token\Event\TokenValueEvent; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Traversable; class TokenProcessor { @@ -33,7 +32,7 @@ class TokenProcessor { public $context; /** - * @var EventDispatcherInterface + * @var \Symfony\Component\EventDispatcher\EventDispatcherInterface */ protected $dispatcher; @@ -82,7 +81,7 @@ class TokenProcessor { protected $next = 0; /** - * @param EventDispatcherInterface $dispatcher + * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $dispatcher * @param array $context */ public function __construct($dispatcher, $context) { @@ -188,6 +187,7 @@ public function getRows() { * * @param string $field * Ex: 'contactId'. + * @param $subfield * @return array * Ex: [12, 34, 56]. */ @@ -278,7 +278,9 @@ public function render($name, $row) { $row->fill($message['format']); $useSmarty = !empty($row->context['smarty']); - // FIXME preg_callback. + /** + *@FIXME preg_callback. + */ $tokens = $this->rowValues[$row->tokenRow][$message['format']]; $flatTokens = []; \CRM_Utils_Array::flatten($tokens, $flatTokens, '', '.'); @@ -304,10 +306,11 @@ class TokenRowIterator extends \IteratorIterator { /** * @param TokenProcessor $tokenProcessor - * @param Traversable $iterator + * @param \Traversable $iterator */ public function __construct(TokenProcessor $tokenProcessor, Traversable $iterator) { - parent::__construct($iterator); // TODO: Change the autogenerated stub + // TODO: Change the autogenerated stub + parent::__construct($iterator); $this->tokenProcessor = $tokenProcessor; } diff --git a/Civi/Token/TokenRow.php b/Civi/Token/TokenRow.php index a57a37b5d0fa..5287219a9401 100644 --- a/Civi/Token/TokenRow.php +++ b/Civi/Token/TokenRow.php @@ -65,7 +65,8 @@ class TokenRow { public function __construct(TokenProcessor $tokenProcessor, $key) { $this->tokenProcessor = $tokenProcessor; $this->tokenRow = $key; - $this->format('text/plain'); // Set a default. + // Set a default. + $this->format('text/plain'); $this->context = new TokenRowContext($tokenProcessor, $key); } @@ -138,7 +139,7 @@ public function customToken($entity, $customFieldID, $entityID) { $customFieldName = "custom_" . $customFieldID; $record = civicrm_api3($entity, "getSingle", [ 'return' => $customFieldName, - 'id' => $entityID, + 'id' => $entityID, ]); $fieldValue = \CRM_Utils_Array::value($customFieldName, $record, ''); @@ -305,8 +306,7 @@ public function __construct($tokenProcessor, $tokenRow) { * @return bool */ public function offsetExists($offset) { - return - isset($this->tokenProcessor->rowContexts[$this->tokenRow][$offset]) + return isset($this->tokenProcessor->rowContexts[$this->tokenRow][$offset]) || isset($this->tokenProcessor->context[$offset]); } From 08eba299a28ec5be0a5c74479115f271e7f64546 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Sat, 6 Apr 2019 07:55:14 -0400 Subject: [PATCH 091/121] Encourage developers to use .then instead of .done jQuery promises have both methods which (if only passing one argument) are interchangeable. But native js promises do not have a .done method, so let's start getting our code more future-proof. --- templates/CRM/Admin/Page/APIExplorer.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/templates/CRM/Admin/Page/APIExplorer.js b/templates/CRM/Admin/Page/APIExplorer.js index 7d85e83586ad..7b8e83d49964 100644 --- a/templates/CRM/Admin/Page/APIExplorer.js +++ b/templates/CRM/Admin/Page/APIExplorer.js @@ -221,7 +221,7 @@ if (entity) { $selector.prop('disabled', true); getActions(entity) - .done(function(actions) { + .then(function(actions) { $selector.prop('disabled', false); CRM.utils.setOptions($('.api-chain-action', $row), _.transform(actions.values, function(ret, item) {ret.push({value: item, key: item});})); }); @@ -247,7 +247,7 @@ apiCalls.getactions = [entity, 'getactions']; } CRM.api3(apiCalls) - .done(function(data) { + .then(function(data) { data.getfields.values = _.indexBy(data.getfields.values, 'name'); getFieldsCache[entity+action] = data.getfields; getActionsCache[entity] = getActionsCache[entity] || data.getactions; @@ -298,7 +298,7 @@ renderJoinSelector(); return; } - getMetadata(entity, action).done(function(data) { + getMetadata(entity, action).then(function(data) { if ($(changedElement).is('#api-entity')) { actions = getActionsCache[entity]; populateActions(); @@ -736,7 +736,7 @@ q.json += "\n}"; } q.php += ");"; - q.json += ").done(function(result) {\n // do something\n});"; + q.json += ").then(function(result) {\n // do something with result\n}, function(error) {\n // oops\n});"; q.smarty += "}\n{foreach from=$result.values item=" + entity.toLowerCase() + "}\n {$" + entity.toLowerCase() + ".some_field}\n{/foreach}"; if (!_.includes(action, 'get')) { q.smarty = '{* Smarty API only works with get actions *}'; @@ -784,7 +784,7 @@ }, type: _.includes(action, 'get') ? 'GET' : 'POST', dataType: 'text' - }).done(function(text) { + }).then(function(text) { // There may be debug information appended to the end of the json string var footerPos = text.indexOf("\n}<"); if (footerPos) { @@ -805,7 +805,7 @@ function getExamples() { CRM.utils.setOptions($('#example-action').prop('disabled', true).addClass('loading'), []); $.getJSON(CRM.url('civicrm/ajax/apiexample', {entity: $(this).val()})) - .done(function(result) { + .then(function(result) { CRM.utils.setOptions($('#example-action').prop('disabled', false).removeClass('loading'), result); }); } @@ -820,7 +820,7 @@ if (entity && action) { $('#example-result').block(); $.get(CRM.url('civicrm/ajax/apiexample', {file: entity + '/' + action})) - .done(function(result) { + .then(function(result) { $('#example-result').unblock().text(result); prettyPrint('#example-result'); }); @@ -835,7 +835,7 @@ function getDocEntity() { CRM.utils.setOptions($('#doc-action').prop('disabled', true).addClass('loading'), []); $.getJSON(CRM.url('civicrm/ajax/apidoc', {entity: $(this).val()})) - .done(function(result) { + .then(function(result) { entityDoc = result.doc; CRM.utils.setOptions($('#doc-action').prop('disabled', false).removeClass('loading'), result.actions); $('#doc-result').html(result.doc); @@ -853,7 +853,7 @@ if (entity && action) { $('#doc-result').block(); $.get(CRM.url('civicrm/ajax/apidoc', {entity: entity, action: action})) - .done(function(result) { + .then(function(result) { $('#doc-result').unblock().html(result.doc); if (result.code) { $('#doc-result').append(docCodeTpl(result)); @@ -928,7 +928,7 @@ if ($(this).is(':checked')) { joins[name] = ent; $('input.api-param-name, #api-return-value').addClass('loading'); - getMetadata(ent, 'get').done(function() { + getMetadata(ent, 'get').then(function() { renderJoinSelector(); populateFields(fields, entity, action, ''); $('input.api-param-name, #api-return-value').removeClass('loading'); From 7c31ae578d5ddd411112a2f747255c022d7baa06 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Sat, 6 Apr 2019 15:50:26 +1100 Subject: [PATCH 092/121] (NFC) Bring up API folder to style of future coder checker --- api/v3/AclRole.php | 1 - api/v3/ActionSchedule.php | 1 - api/v3/Activity.php | 8 +++----- api/v3/Attachment.php | 3 ++- api/v3/Case.php | 11 ++++------- api/v3/CaseType.php | 6 ++++-- api/v3/Contact.php | 13 +++++-------- api/v3/Contribution.php | 2 +- api/v3/CustomField.php | 5 ++--- api/v3/CustomValue.php | 1 - api/v3/Cxn.php | 2 +- api/v3/CxnApp.php | 4 ++-- api/v3/Dashboard.php | 12 +++++------- api/v3/Domain.php | 13 +++---------- api/v3/EntityTag.php | 2 +- api/v3/Event.php | 1 - api/v3/Exception.php | 2 ++ api/v3/Extension.php | 12 ++++++++---- api/v3/Generic.php | 3 ++- api/v3/Generic/Setvalue.php | 3 +-- api/v3/GroupOrganization.php | 1 - api/v3/Job.php | 3 ++- api/v3/LocBlock.php | 2 +- api/v3/Logging.php | 4 ++-- api/v3/Mailing.php | 27 ++++++++++++++------------- api/v3/MailingAB.php | 18 +++++++++--------- api/v3/MailingComponent.php | 1 - api/v3/MailingContact.php | 3 ++- api/v3/MailingRecipients.php | 1 - api/v3/Membership.php | 1 - api/v3/Order.php | 2 +- api/v3/Participant.php | 1 - api/v3/Payment.php | 11 ++++++----- api/v3/PaymentProcessor.php | 1 - api/v3/Pcp.php | 1 + api/v3/Profile.php | 10 +++++----- api/v3/Relationship.php | 2 +- api/v3/ReportTemplate.php | 5 +++-- api/v3/SavedSearch.php | 9 ++++++--- api/v3/Setting.php | 11 ++++++++--- api/v3/Survey.php | 1 - api/v3/System.php | 6 ++++-- api/v3/WordReplacement.php | 1 - api/v3/utils.php | 20 ++++++++++---------- 44 files changed, 121 insertions(+), 126 deletions(-) diff --git a/api/v3/AclRole.php b/api/v3/AclRole.php index 5522845e21fa..0be3488d1dcf 100644 --- a/api/v3/AclRole.php +++ b/api/v3/AclRole.php @@ -43,7 +43,6 @@ function civicrm_api3_acl_role_create($params) { return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'EntityRole'); } - /** * AclRole create metadata. * diff --git a/api/v3/ActionSchedule.php b/api/v3/ActionSchedule.php index d7f6e263f6a8..6ad016423163 100644 --- a/api/v3/ActionSchedule.php +++ b/api/v3/ActionSchedule.php @@ -43,7 +43,6 @@ function civicrm_api3_action_schedule_get($params) { return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'ActionSchedule'); } - /** * Create a new ActionSchedule. * diff --git a/api/v3/Activity.php b/api/v3/Activity.php index 5fa7492538e7..ff9ac1258c5b 100644 --- a/api/v3/Activity.php +++ b/api/v3/Activity.php @@ -31,7 +31,6 @@ * @package CiviCRM_APIv3 */ - /** * Creates or updates an Activity. * @@ -291,7 +290,7 @@ function _civicrm_api3_activity_get_spec(&$params) { * @param array $params * Array per getfields documentation. * - * @return array API result array + * @return array * API result array * * @throws \API_Exception @@ -592,7 +591,7 @@ function _civicrm_api3_activity_fill_activity_contact_names(&$activities, $param $typeMap = [ $assigneeType => 'assignee', $sourceType => 'source', - $targetType => 'target' + $targetType => 'target', ]; $activityContactTypes = [$sourceType]; @@ -609,7 +608,7 @@ function _civicrm_api3_activity_fill_activity_contact_names(&$activities, $param 'activity_id', 'record_type_id', 'contact_id.display_name', - 'contact_id' + 'contact_id', ], 'check_permissions' => !empty($params['check_permissions']), ]; @@ -631,7 +630,6 @@ function _civicrm_api3_activity_fill_activity_contact_names(&$activities, $param } } - /** * Delete a specified Activity. * diff --git a/api/v3/Attachment.php b/api/v3/Attachment.php index ea4c42e4dad7..3d5f39a3b04f 100644 --- a/api/v3/Attachment.php +++ b/api/v3/Attachment.php @@ -481,7 +481,8 @@ function _civicrm_api3_attachment_getfields() { // Would be hard to securely handle changes. $spec['entity_table']['title'] = CRM_Utils_Array::value('title', $spec['entity_table'], 'Entity Table') . ' (write-once)'; $spec['entity_id'] = $entityFileFields['entity_id']; - $spec['entity_id']['title'] = CRM_Utils_Array::value('title', $spec['entity_id'], 'Entity ID') . ' (write-once)'; // would be hard to securely handle changes + // would be hard to securely handle changes + $spec['entity_id']['title'] = CRM_Utils_Array::value('title', $spec['entity_id'], 'Entity ID') . ' (write-once)'; $spec['url'] = [ 'title' => 'URL (read-only)', 'description' => 'URL for downloading the file (not searchable, expire-able)', diff --git a/api/v3/Case.php b/api/v3/Case.php index 312c8ba64218..8603714c7834 100644 --- a/api/v3/Case.php +++ b/api/v3/Case.php @@ -32,7 +32,6 @@ * @package CiviCRM_APIv3 */ - /** * Open a new case, add client and manager roles, and standard timeline. * @@ -67,11 +66,10 @@ function civicrm_api3_case_create($params) { if (empty($params['id'])) { // Creating a new case, so make sure we have the necessary parameters civicrm_api3_verify_mandatory($params, NULL, [ - 'contact_id', - 'subject', - ['case_type', 'case_type_id'], - ] - ); + 'contact_id', + 'subject', + ['case_type', 'case_type_id'], + ]); } else { // Update an existing case @@ -744,7 +742,6 @@ function _civicrm_api3_case_format_params(&$params) { } } - /** * It actually works a lot better to use the CaseContact api instead of the Case api * for entityRef fields so we can perform the necessary joins, diff --git a/api/v3/CaseType.php b/api/v3/CaseType.php index 155caba2a58a..79dd471037f7 100644 --- a/api/v3/CaseType.php +++ b/api/v3/CaseType.php @@ -52,8 +52,10 @@ function civicrm_api3_case_type_create($params) { } // This is an existing case-type. if (!empty($params['id']) && isset($params['definition']) - && !CRM_Case_BAO_CaseType::isForked($params['id']) // which is not yet forked - && !CRM_Case_BAO_CaseType::isForkable($params['id']) // for which new forks are prohibited + // which is not yet forked + && !CRM_Case_BAO_CaseType::isForked($params['id']) + // for which new forks are prohibited + && !CRM_Case_BAO_CaseType::isForkable($params['id']) ) { unset($params['definition']); } diff --git a/api/v3/Contact.php b/api/v3/Contact.php index 54ce858580f7..c493cad4c89d 100644 --- a/api/v3/Contact.php +++ b/api/v3/Contact.php @@ -524,7 +524,6 @@ function civicrm_api3_contact_delete($params) { } } - /** * Check parameters passed in. * @@ -549,12 +548,11 @@ function _civicrm_api3_contact_check_params(&$params) { case 'individual': civicrm_api3_verify_one_mandatory($params, NULL, [ - 'first_name', - 'last_name', - 'email', - 'display_name', - ] - ); + 'first_name', + 'last_name', + 'email', + 'display_name', + ]); break; } @@ -1454,7 +1452,6 @@ function civicrm_api3_contact_proximity($params) { return civicrm_api3_create_success($contacts, $params, 'Contact', 'get_by_location', $dao); } - /** * Get parameters for getlist function. * diff --git a/api/v3/Contribution.php b/api/v3/Contribution.php index 717c6709befe..8366a44528ca 100644 --- a/api/v3/Contribution.php +++ b/api/v3/Contribution.php @@ -672,7 +672,7 @@ function civicrm_api3_contribution_repeattransaction(&$params) { return _ipn_process_transaction($params, $contribution, $input, $ids, $original_contribution); } - catch(Exception $e) { + catch (Exception $e) { throw new API_Exception('failed to load related objects' . $e->getMessage() . "\n" . $e->getTraceAsString()); } } diff --git a/api/v3/CustomField.php b/api/v3/CustomField.php index 0ac81d5e9451..322f37104cb8 100644 --- a/api/v3/CustomField.php +++ b/api/v3/CustomField.php @@ -242,9 +242,8 @@ function _civicrm_api3_custom_field_validate_field($fieldName, $value, $fieldDet break; } - if (in_array($htmlType, [ - 'Select', 'Multi-Select', 'CheckBox', 'Radio']) && - !isset($errors[$fieldName]) + if (in_array($htmlType, ['Select', 'Multi-Select', 'CheckBox', 'Radio']) + && !isset($errors[$fieldName]) ) { $options = CRM_Core_OptionGroup::valuesByID($fieldDetails['option_group_id']); if (!is_array($value)) { diff --git a/api/v3/CustomValue.php b/api/v3/CustomValue.php index 7ada45ac29c7..48c3f93b8583 100644 --- a/api/v3/CustomValue.php +++ b/api/v3/CustomValue.php @@ -31,7 +31,6 @@ * @package CiviCRM_APIv3 */ - /** * Sets custom values for an entity. * diff --git a/api/v3/Cxn.php b/api/v3/Cxn.php index 6f12beb094c9..66ed809b8be5 100644 --- a/api/v3/Cxn.php +++ b/api/v3/Cxn.php @@ -317,7 +317,7 @@ function civicrm_api3_cxn_create($params) { return civicrm_api3_create_success($result, $params, 'Cxn', 'create'); } - catch(Exception $ex){ + catch (Exception $ex) { throw $ex; } } diff --git a/api/v3/CxnApp.php b/api/v3/CxnApp.php index 9e289c8d8af2..0045d3b08f2a 100644 --- a/api/v3/CxnApp.php +++ b/api/v3/CxnApp.php @@ -25,8 +25,8 @@ +--------------------------------------------------------------------+ */ -use \Civi\Cxn\Rpc\Message\AppMetasMessage; -use \Civi\Cxn\Rpc\Message\GarbledMessage; +use Civi\Cxn\Rpc\Message\AppMetasMessage; +use Civi\Cxn\Rpc\Message\GarbledMessage; /** * The CxnApp API provides a pseudo-entity for exploring the list diff --git a/api/v3/Dashboard.php b/api/v3/Dashboard.php index 1cd9bd98f44a..b343429cb792 100644 --- a/api/v3/Dashboard.php +++ b/api/v3/Dashboard.php @@ -31,7 +31,6 @@ * @package CiviCRM_APIv3 */ - /** * Creates or updates an Dashlet. * @@ -42,12 +41,11 @@ */ function civicrm_api3_dashboard_create($params) { civicrm_api3_verify_one_mandatory($params, NULL, [ - 'name', - 'label', - 'url', - 'fullscreen_url', - ] - ); + 'name', + 'label', + 'url', + 'fullscreen_url', + ]); return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'Dashboard'); } diff --git a/api/v3/Domain.php b/api/v3/Domain.php index 552121fbe13c..971bf86b3b3f 100644 --- a/api/v3/Domain.php +++ b/api/v3/Domain.php @@ -76,16 +76,9 @@ function civicrm_api3_domain_get($params) { if (!empty($values['location']['phone'])) { $domain['domain_phone'] = [ 'phone_type' => CRM_Core_PseudoConstant::getLabel('CRM_Core_BAO_Phone', 'phone_type_id', - CRM_Utils_Array::value( - 'phone_type_id', - $values['location']['phone'][1] - ) - ), - 'phone' => CRM_Utils_Array::value( - 'phone', - $values['location']['phone'][1] - ), - ]; + CRM_Utils_Array::value('phone_type_id', $values['location']['phone'][1])), + 'phone' => CRM_Utils_Array::value('phone', $values['location']['phone'][1]), + ]; } if (!empty($values['location']['address'])) { diff --git a/api/v3/EntityTag.php b/api/v3/EntityTag.php index 6ed334f78124..48ccea152cd5 100644 --- a/api/v3/EntityTag.php +++ b/api/v3/EntityTag.php @@ -190,7 +190,7 @@ function civicrm_api3_entity_tag_replace($params) { return civicrm_api3_create_success($result, $params, 'EntityTag', 'replace'); } - catch(Exception $e) { + catch (Exception $e) { $transaction->rollback(); return civicrm_api3_create_error($e->getMessage()); } diff --git a/api/v3/Event.php b/api/v3/Event.php index dba0f7da4684..5f58ebc6755a 100644 --- a/api/v3/Event.php +++ b/api/v3/Event.php @@ -217,7 +217,6 @@ function _civicrm_api3_event_getisfull(&$event, $event_id) { $event[$event_id]['is_full'] = $event[$event_id]['available_places'] == 0 ? 1 : 0; } - /** * Get event list parameters. * diff --git a/api/v3/Exception.php b/api/v3/Exception.php index 8ed2ada6aca6..4275c44a34da 100644 --- a/api/v3/Exception.php +++ b/api/v3/Exception.php @@ -24,6 +24,7 @@ | see the CiviCRM license FAQ at http://civicrm.org/licensing | +--------------------------------------------------------------------+ */ + /** * Get a Dedupe Exception. * @@ -36,6 +37,7 @@ function civicrm_api3_exception_get($params) { return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params); } + /** * Create or update an dedupe exception. * diff --git a/api/v3/Extension.php b/api/v3/Extension.php index f079acaee7aa..a08275180192 100644 --- a/api/v3/Extension.php +++ b/api/v3/Extension.php @@ -301,13 +301,15 @@ function civicrm_api3_extension_refresh($params) { if ($params['local']) { $system->getManager()->refresh(); - $system->getManager()->getStatuses(); // force immediate scan + // force immediate scan + $system->getManager()->getStatuses(); } if ($params['remote']) { if ($system->getBrowser()->isEnabled() && empty($system->getBrowser()->checkRequirements)) { $system->getBrowser()->refresh(); - $system->getBrowser()->getExtensions(); // force immediate download + // force immediate download + $system->getBrowser()->getExtensions(); } } @@ -358,7 +360,8 @@ function civicrm_api3_extension_get($params) { continue; } $info = CRM_Extension_System::createExtendedInfo($obj); - $info['id'] = $id++; // backward compatibility with indexing scheme + // backward compatibility with indexing scheme + $info['id'] = $id++; if (!empty($keys)) { if (in_array($key, $keys)) { $result[] = $info; @@ -392,7 +395,8 @@ function civicrm_api3_extension_getremote($params) { $id = 0; foreach ($extensions as $key => $obj) { $info = []; - $info['id'] = $id++; // backward compatibility with indexing scheme + // backward compatibility with indexing scheme + $info['id'] = $id++; $info = array_merge($info, (array) $obj); $result[] = $info; } diff --git a/api/v3/Generic.php b/api/v3/Generic.php index bbc58bfbd19c..c88419ccb40b 100644 --- a/api/v3/Generic.php +++ b/api/v3/Generic.php @@ -130,7 +130,8 @@ function civicrm_api3_generic_getfields($apiRequest, $unique = TRUE) { 'api.required' => 1, 'api.aliases' => [$lowercase_entity . '_id'], 'type' => CRM_Utils_Type::T_INT, - ]]; + ], + ]; break; // Note: adding setvalue case here instead of in a generic spec function because diff --git a/api/v3/Generic/Setvalue.php b/api/v3/Generic/Setvalue.php index b04b1242e376..3c6f4b1017ad 100644 --- a/api/v3/Generic/Setvalue.php +++ b/api/v3/Generic/Setvalue.php @@ -57,8 +57,7 @@ function civicrm_api3_generic_setValue($apiRequest) { $fields = civicrm_api($entity, 'getFields', [ 'version' => 3, 'action' => 'create', - "sequential"] - ); + ]); // getfields error, shouldn't happen. if ($fields['is_error']) { return $fields; diff --git a/api/v3/GroupOrganization.php b/api/v3/GroupOrganization.php index 858df4bd97ef..481e344337b9 100644 --- a/api/v3/GroupOrganization.php +++ b/api/v3/GroupOrganization.php @@ -31,7 +31,6 @@ * @package CiviCRM_APIv3 */ - /** * Get group organization record/s. * diff --git a/api/v3/Job.php b/api/v3/Job.php index 0c28926fe300..86cfa253d27f 100644 --- a/api/v3/Job.php +++ b/api/v3/Job.php @@ -228,6 +228,7 @@ function civicrm_api3_job_send_reminder($params) { return civicrm_api3_create_error($result['messages']); } } + /** * Adjust metadata for "send_reminder" action. * @@ -244,6 +245,7 @@ function _civicrm_api3_job_send_reminder(&$params) { 'title' => 'Action Schedule ID', ]; } + /** * Execute a specific report instance and send the output via email. * @@ -464,7 +466,6 @@ function civicrm_api3_job_process_participant($params) { } } - /** * This api checks and updates the status of all membership records for a given domain. * diff --git a/api/v3/LocBlock.php b/api/v3/LocBlock.php index 5f9b1ce9e48d..0e7ef7c6429d 100644 --- a/api/v3/LocBlock.php +++ b/api/v3/LocBlock.php @@ -86,7 +86,7 @@ function civicrm_api3_loc_block_create($params) { _civicrm_api3_object_to_array($dao, $values[$dao->id]); return civicrm_api3_create_success($values, $params, 'LocBlock', 'create', $dao); } - throw New API_Exception('Unable to create LocBlock. Please check your params.'); + throw new API_Exception('Unable to create LocBlock. Please check your params.'); } /** diff --git a/api/v3/Logging.php b/api/v3/Logging.php index 22ebe9bd3927..7b1353ad8200 100644 --- a/api/v3/Logging.php +++ b/api/v3/Logging.php @@ -37,7 +37,7 @@ * @param array $params * * @return array - * API Success Array + * API Success Array * @throws \API_Exception * @throws \Civi\API\Exception\UnauthorizedException */ @@ -88,7 +88,7 @@ function _civicrm_api3_logging_revert_spec(&$params) { * @param array $params * * @return array - * API Success Array + * API Success Array * @throws \API_Exception * @throws \Civi\API\Exception\UnauthorizedException */ diff --git a/api/v3/Mailing.php b/api/v3/Mailing.php index 38ebc4161edf..86139b2d2fee 100644 --- a/api/v3/Mailing.php +++ b/api/v3/Mailing.php @@ -38,7 +38,7 @@ * @param array $params * * @return array - * API Success Array + * API Success Array * @throws \API_Exception * @throws \Civi\API\Exception\UnauthorizedException */ @@ -440,7 +440,8 @@ function _civicrm_api3_mailing_event_reply_spec(&$params) { $params['hash']['api.required'] = 1; $params['hash']['title'] = 'Hash'; $params['replyTo']['api.required'] = 0; - $params['replyTo']['title'] = 'Reply To';//doesn't really explain adequately + //doesn't really explain adequately + $params['replyTo']['title'] = 'Reply To'; } /** @@ -635,17 +636,17 @@ function civicrm_api3_mailing_send_test($params) { $testEmailParams['emails'] = array_key_exists('test_email', $testEmailParams) ? explode(',', strtolower($testEmailParams['test_email'])) : NULL; if (!empty($params['test_email'])) { $query = CRM_Utils_SQL_Select::from('civicrm_email e') - ->select(['e.id', 'e.contact_id', 'e.email']) - ->join('c', 'INNER JOIN civicrm_contact c ON e.contact_id = c.id') - ->where('e.email IN (@emails)', ['@emails' => $testEmailParams['emails']]) - ->where('e.on_hold = 0') - ->where('c.is_opt_out = 0') - ->where('c.do_not_email = 0') - ->where('c.is_deceased = 0') - ->where('c.is_deleted = 0') - ->groupBy('e.id') - ->orderBy(['e.is_bulkmail DESC', 'e.is_primary DESC']) - ->toSQL(); + ->select(['e.id', 'e.contact_id', 'e.email']) + ->join('c', 'INNER JOIN civicrm_contact c ON e.contact_id = c.id') + ->where('e.email IN (@emails)', ['@emails' => $testEmailParams['emails']]) + ->where('e.on_hold = 0') + ->where('c.is_opt_out = 0') + ->where('c.do_not_email = 0') + ->where('c.is_deceased = 0') + ->where('c.is_deleted = 0') + ->groupBy('e.id') + ->orderBy(['e.is_bulkmail DESC', 'e.is_primary DESC']) + ->toSQL(); $dao = CRM_Core_DAO::executeQuery($query); $emailDetail = []; // fetch contact_id and email id for all existing emails diff --git a/api/v3/MailingAB.php b/api/v3/MailingAB.php index 2ef7637d373e..077b8bf2d44a 100644 --- a/api/v3/MailingAB.php +++ b/api/v3/MailingAB.php @@ -135,13 +135,13 @@ function civicrm_api3_mailing_a_b_submit($params) { throw new API_Exception("Cannot transition to state 'Testing'"); } civicrm_api3('Mailing', 'submit', $submitParams + [ - 'id' => $dao->mailing_id_a, - '_skip_evil_bao_auto_recipients_' => 0, - ]); + 'id' => $dao->mailing_id_a, + '_skip_evil_bao_auto_recipients_' => 0, + ]); civicrm_api3('Mailing', 'submit', $submitParams + [ - 'id' => $dao->mailing_id_b, - '_skip_evil_bao_auto_recipients_' => 1, - ]); + 'id' => $dao->mailing_id_b, + '_skip_evil_bao_auto_recipients_' => 1, + ]); CRM_Mailing_BAO_MailingAB::distributeRecipients($dao); break; @@ -150,9 +150,9 @@ function civicrm_api3_mailing_a_b_submit($params) { throw new API_Exception("Cannot transition to state 'Final'"); } civicrm_api3('Mailing', 'submit', $submitParams + [ - 'id' => $dao->mailing_id_c, - '_skip_evil_bao_auto_recipients_' => 1, - ]); + 'id' => $dao->mailing_id_c, + '_skip_evil_bao_auto_recipients_' => 1, + ]); break; default: diff --git a/api/v3/MailingComponent.php b/api/v3/MailingComponent.php index 47d59c8d530a..886dc2321cc2 100644 --- a/api/v3/MailingComponent.php +++ b/api/v3/MailingComponent.php @@ -44,7 +44,6 @@ function civicrm_api3_mailing_component_create($params) { return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'MailingComponent'); } - /** * Adjust Metadata for Create action. * diff --git a/api/v3/MailingContact.php b/api/v3/MailingContact.php index b4eedb52b143..e4d693a258a2 100644 --- a/api/v3/MailingContact.php +++ b/api/v3/MailingContact.php @@ -83,7 +83,8 @@ function _civicrm_api3_mailing_contact_get_spec(&$params) { $params['type'] = [ 'api.default' => 'Delivered', - 'title' => 'Type', // doesn't really explain the field - but not sure I understand it to explain it better + // doesn't really explain the field - but not sure I understand it to explain it better + 'title' => 'Type', 'type' => CRM_Utils_Type::T_STRING, 'options' => [ 'Delivered' => 'Delivered', diff --git a/api/v3/MailingRecipients.php b/api/v3/MailingRecipients.php index 27be1c7cf16a..ce2a8547e00d 100644 --- a/api/v3/MailingRecipients.php +++ b/api/v3/MailingRecipients.php @@ -31,7 +31,6 @@ * @package CiviCRM_APIv3 */ - /** * Returns array of MailingRecipients. * diff --git a/api/v3/Membership.php b/api/v3/Membership.php index 7d9b86ac49e0..af6ba7a0fcd3 100644 --- a/api/v3/Membership.php +++ b/api/v3/Membership.php @@ -280,7 +280,6 @@ function _civicrm_api3_membership_get_customv2behaviour(&$params, $membershipTyp return $membershipValues; } - /** * Non-standard behaviour inherited from v2. * diff --git a/api/v3/Order.php b/api/v3/Order.php index fff662a96a61..e895e0fc1146 100644 --- a/api/v3/Order.php +++ b/api/v3/Order.php @@ -189,7 +189,7 @@ function civicrm_api3_order_cancel($params) { */ function _civicrm_api3_order_cancel_spec(&$params) { $params['contribution_id'] = [ - 'api.required' => 1 , + 'api.required' => 1, 'title' => 'Contribution ID', 'type' => CRM_Utils_Type::T_INT, ]; diff --git a/api/v3/Participant.php b/api/v3/Participant.php index d9b75b3be004..368525482511 100644 --- a/api/v3/Participant.php +++ b/api/v3/Participant.php @@ -128,7 +128,6 @@ function _civicrm_api3_participant_createlineitem(&$params, $participant) { } } - /** * Adjust Metadata for Create action. * diff --git a/api/v3/Payment.php b/api/v3/Payment.php index 25e4ae17e9b6..69367bf6f087 100644 --- a/api/v3/Payment.php +++ b/api/v3/Payment.php @@ -150,12 +150,12 @@ function civicrm_api3_payment_create(&$params) { function _civicrm_api3_payment_create_spec(&$params) { $params = [ 'contribution_id' => [ - 'api.required' => 1 , + 'api.required' => 1, 'title' => 'Contribution ID', 'type' => CRM_Utils_Type::T_INT, ], 'total_amount' => [ - 'api.required' => 1 , + 'api.required' => 1, 'title' => 'Total Payment Amount', 'type' => CRM_Utils_Type::T_FLOAT, ], @@ -209,7 +209,7 @@ function _civicrm_api3_payment_get_spec(&$params) { function _civicrm_api3_payment_delete_spec(&$params) { $params = [ 'id' => [ - 'api.required' => 1 , + 'api.required' => 1, 'title' => 'Payment ID', 'type' => CRM_Utils_Type::T_INT, 'api.aliases' => ['payment_id'], @@ -228,7 +228,7 @@ function _civicrm_api3_payment_delete_spec(&$params) { function _civicrm_api3_payment_cancel_spec(&$params) { $params = [ 'id' => [ - 'api.required' => 1 , + 'api.required' => 1, 'title' => 'Payment ID', 'type' => CRM_Utils_Type::T_INT, 'api.aliases' => ['payment_id'], @@ -263,7 +263,8 @@ function civicrm_api3_payment_sendconfirmation($params) { 'subject' => $result[1], 'message_txt' => $result[2], 'message_html' => $result[3], - ]]); + ], + ]); } /** diff --git a/api/v3/PaymentProcessor.php b/api/v3/PaymentProcessor.php index 658b51aae3fc..51e401c75e96 100644 --- a/api/v3/PaymentProcessor.php +++ b/api/v3/PaymentProcessor.php @@ -93,7 +93,6 @@ function civicrm_api3_payment_processor_get($params) { return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params); } - /** * Set default getlist parameters. * diff --git a/api/v3/Pcp.php b/api/v3/Pcp.php index 3380fe242cf5..71c61e7711f7 100644 --- a/api/v3/Pcp.php +++ b/api/v3/Pcp.php @@ -32,6 +32,7 @@ * * @package CiviCRM_APIv3 */ + /** * Create or update a survey. * diff --git a/api/v3/Profile.php b/api/v3/Profile.php index 6c25483f369b..1d6cfe80b95a 100644 --- a/api/v3/Profile.php +++ b/api/v3/Profile.php @@ -446,7 +446,7 @@ function _civicrm_api3_profile_getbillingpseudoprofile(&$params) { 'api.email.get.1' => ['location_type_id' => 'Billing'], 'api.email.get.2' => ['is_billing' => TRUE], 'return' => 'api.email.get, api.address.get, api.address.getoptions, country, state_province, email, first_name, last_name, middle_name, ' . implode($addressFields, ','), - ] + ] ); $values = [ @@ -611,10 +611,10 @@ function _civicrm_api3_buildprofile_submitfields($profileID, $optionsBehaviour = } /** * putting this on hold -this would cause the api to set the default - but could have unexpected behaviour - if (isset($result['values'][$realName]['default_value'])) { - //this would be the case for a custom field with a configured default - $profileFields[$profileID][$entityfield]['api.default'] = $result['values'][$realName]['default_value']; - } + * if (isset($result['values'][$realName]['default_value'])) { + * //this would be the case for a custom field with a configured default + * $profileFields[$profileID][$entityfield]['api.default'] = $result['values'][$realName]['default_value']; + * } */ } } diff --git a/api/v3/Relationship.php b/api/v3/Relationship.php index 0a7254cc9adc..d08889cd896b 100644 --- a/api/v3/Relationship.php +++ b/api/v3/Relationship.php @@ -216,6 +216,6 @@ function _civicrm_api3_relationship_getoptions_spec(&$params) { 'title' => ts('Is Form?'), 'description' => $relationshipTypePrefix . ts('Formats the options for use' . ' in a form if true. The format is <id>_a_b => <label>'), - 'type' => CRM_Utils_Type::T_BOOLEAN + 'type' => CRM_Utils_Type::T_BOOLEAN, ]; } diff --git a/api/v3/ReportTemplate.php b/api/v3/ReportTemplate.php index 87d54afdce2e..5fd747431899 100644 --- a/api/v3/ReportTemplate.php +++ b/api/v3/ReportTemplate.php @@ -135,7 +135,7 @@ function _civicrm_api3_report_template_getrows($params) { 'option_group_name' => 'report_template', 'return' => 'name', 'value' => $params['report_id'], - ] + ] ); $reportInstance = new $class(); @@ -154,7 +154,7 @@ function _civicrm_api3_report_template_getrows($params) { $reportInstance->beginPostProcessCommon(); $sql = $reportInstance->buildQuery(); $reportInstance->addToDeveloperTab($sql); - $rows = $metadata = $requiredMetadata = []; + $rows = $metadata = $requiredMetadata = []; $reportInstance->buildRows($sql, $rows); $reportInstance->formatDisplay($rows); @@ -191,6 +191,7 @@ function civicrm_api3_report_template_getstatistics($params) { $reportInstance->cleanUpTemporaryTables(); return civicrm_api3_create_success($stats, $params, 'ReportTemplate', 'getstatistics', CRM_Core_DAO::$_nullObject, $metadata); } + /** * Adjust metadata for template getrows action. * diff --git a/api/v3/SavedSearch.php b/api/v3/SavedSearch.php index 4c6b7a2fd4ad..c515e890e247 100644 --- a/api/v3/SavedSearch.php +++ b/api/v3/SavedSearch.php @@ -38,7 +38,8 @@ * @param array $params * Associative array of property name-value pairs to insert in new saved search. * @example SavedSearch/Create.php Std create example. - * @return array api result array + * @return array + * api result array * {@getfields saved_search_create} * @access public */ @@ -72,7 +73,8 @@ function civicrm_api3_saved_search_create($params) { * Associative array of property name-value pairs. $params['id'] should be * the ID of the saved search to be deleted. * @example SavedSearch/Delete.php Std delete example. - * @return array api result array + * @return array + * api result array * {@getfields saved_search_delete} * @access public */ @@ -86,7 +88,8 @@ function civicrm_api3_saved_search_delete($params) { * @param array $params * An associative array of name-value pairs. * @example SavedSearch/Get.php Std get example. - * @return array api result array + * @return array + * api result array * {@getfields saved_search_get} * @access public */ diff --git a/api/v3/Setting.php b/api/v3/Setting.php index 21a38ed52d6d..e7d2338c254f 100644 --- a/api/v3/Setting.php +++ b/api/v3/Setting.php @@ -44,12 +44,14 @@ function civicrm_api3_setting_getfields($params) { 'name' => [ 'title' => 'name of setting field', 'api.required' => 1, - 'type' => CRM_Utils_Type::T_STRING], + 'type' => CRM_Utils_Type::T_STRING, + ], 'group' => [ 'api.required' => 0, 'title' => 'Setting Group', 'description' => 'Settings Group. This is required if the setting is not stored in config', - 'type' => CRM_Utils_Type::T_STRING], + 'type' => CRM_Utils_Type::T_STRING, + ], ]; return civicrm_api3_create_success($result, $params, 'Setting', 'getfields'); } @@ -121,6 +123,7 @@ function civicrm_api3_setting_getdefaults(&$params) { } return civicrm_api3_create_success($defaults, $params, 'Setting', 'getfields'); } + /** * Metadata for Setting create function. * @@ -320,6 +323,7 @@ function civicrm_api3_setting_get($params) { $result = CRM_Core_BAO_Setting::getItems($params, $domains, CRM_Utils_Array::value('return', $params, [])); return civicrm_api3_create_success($result, $params, 'Setting', 'get'); } + /** * Metadata for setting create function. * @@ -337,6 +341,7 @@ function _civicrm_api3_setting_get_spec(&$params) { 'description' => 'if you know the group defining it will make the api more efficient', ]; } + /** * Returns value for specific parameter. * @@ -417,7 +422,7 @@ function _civicrm_api3_setting_getDomainArray(&$params) { } if ($params['domain_id'] == 'current_domain') { - $params['domain_id'] = CRM_Core_Config::domainID(); + $params['domain_id'] = CRM_Core_Config::domainID(); } if ($params['domain_id'] == 'all') { diff --git a/api/v3/Survey.php b/api/v3/Survey.php index dbea9f1ec3b3..3b4605a27d25 100644 --- a/api/v3/Survey.php +++ b/api/v3/Survey.php @@ -35,7 +35,6 @@ * @package CiviCRM_APIv3 */ - /** * Create or update a survey. * diff --git a/api/v3/System.php b/api/v3/System.php index baf4fe197bc7..b15a471bbdc8 100644 --- a/api/v3/System.php +++ b/api/v3/System.php @@ -230,8 +230,10 @@ function civicrm_api3_system_get($params) { $config = CRM_Core_Config::singleton(); $returnValues = [ [ - 'version' => CRM_Utils_System::version(), // deprecated in favor of civi.version - 'uf' => CIVICRM_UF, // deprecated in favor of cms.type + // deprecated in favor of civi.version + 'version' => CRM_Utils_System::version(), + // deprecated in favor of cms.type + 'uf' => CIVICRM_UF, 'php' => [ 'version' => phpversion(), 'time' => time(), diff --git a/api/v3/WordReplacement.php b/api/v3/WordReplacement.php index 25bdbfd321da..b5bc93a19b4f 100644 --- a/api/v3/WordReplacement.php +++ b/api/v3/WordReplacement.php @@ -46,7 +46,6 @@ function civicrm_api3_word_replacement_get($params) { return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params); } - /** * Create a new Word Replacement. * diff --git a/api/v3/utils.php b/api/v3/utils.php index de3253668a41..bac0826f5cd3 100644 --- a/api/v3/utils.php +++ b/api/v3/utils.php @@ -213,7 +213,7 @@ function civicrm_api3_create_success($values = 1, $params = [], $entity = NULL, 'option_sort', 'options', 'prettyprint', - ]); + ]); if ($undefined) { $result['undefined_fields'] = array_merge($undefined); } @@ -432,6 +432,7 @@ function _civicrm_api3_filter_fields_for_bao($entity, &$params, &$values) { $fields = $fields['values']; _civicrm_api3_store_values($fields, $params, $values); } + /** * Store values. * @@ -1767,9 +1768,9 @@ function _civicrm_api3_validate_unique_key(&$params, &$fieldName) { return; } $existing = civicrm_api($params['entity'], 'get', [ - 'version' => $params['version'], - $fieldName => $fieldValue, - ]); + 'version' => $params['version'], + $fieldName => $fieldValue, + ]); // an entry already exists for this unique field if ($existing['count'] == 1) { // question - could this ever be a security issue? @@ -1836,9 +1837,9 @@ function _civicrm_api3_generic_replace($entity, $params) { ); foreach ($staleIDs as $staleID) { $delete = civicrm_api($entity, 'delete', [ - 'version' => $params['version'], - 'id' => $staleID, - ]); + 'version' => $params['version'], + 'id' => $staleID, + ]); if (civicrm_error($delete)) { $transaction->rollback(); return $delete; @@ -1847,11 +1848,11 @@ function _civicrm_api3_generic_replace($entity, $params) { return civicrm_api3_create_success($creates, $params); } - catch(PEAR_Exception $e) { + catch (PEAR_Exception $e) { $transaction->rollback(); return civicrm_api3_create_error($e->getMessage()); } - catch(Exception $e) { + catch (Exception $e) { $transaction->rollback(); return civicrm_api3_create_error($e->getMessage()); } @@ -1984,7 +1985,6 @@ function _civicrm_api_get_custom_fields($entity, &$params) { return $ret; } - /** * Fill params array with alternate (alias) values where a field has an alias and that is filled & the main field isn't. * From 52929a9c5199863e149e4f685a671d971ff8e375 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Sun, 7 Apr 2019 08:30:20 +1000 Subject: [PATCH 093/121] Fix location of comment to match future coder version --- ang/crmResource.ang.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ang/crmResource.ang.php b/ang/crmResource.ang.php index eaa504f30cce..577f48e1efd3 100644 --- a/ang/crmResource.ang.php +++ b/ang/crmResource.ang.php @@ -6,5 +6,6 @@ return [ 'ext' => 'civicrm', // 'js' => array('js/angular-crmResource/byModule.js'), // One HTTP request per module. - 'js' => ['js/angular-crmResource/all.js'], // One HTTP request for all modules. + // One HTTP request for all modules. + 'js' => ['js/angular-crmResource/all.js'], ]; From 39b959db2c4b46180f1a87b15862baa4806a732f Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Sun, 7 Apr 2019 08:14:21 +1000 Subject: [PATCH 094/121] Update Unit test styling to cover the future coder version --- .../main.php | 2 +- .../main.php | 1 + .../main.php | 4 +- tests/phpunit/CRM/ACL/ListTest.php | 60 ++-- .../CRM/Activity/BAO/ActivityTargetTest.php | 1 - .../phpunit/CRM/Activity/BAO/ActivityTest.php | 13 +- .../phpunit/CRM/Activity/Form/SearchTest.php | 2 +- tests/phpunit/CRM/Batch/BAO/BatchTest.php | 2 +- tests/phpunit/CRM/Bridge/OG/DrupalTest.php | 1 + .../phpunit/CRM/Case/BAO/CaseTypeForkTest.php | 2 +- tests/phpunit/CRM/Case/BAO/CaseTypeTest.php | 20 +- tests/phpunit/CRM/Case/BAO/QueryTest.php | 6 +- .../CRM/Case/XMLProcessor/ProcessTest.php | 16 +- .../CRM/Contact/BAO/ActivitySearchTest.php | 1 - tests/phpunit/CRM/Contact/BAO/ContactTest.php | 3 +- .../CRM/Contact/BAO/GroupContactCacheTest.php | 1 - .../CRM/Contact/BAO/GroupContactTest.php | 1 - tests/phpunit/CRM/Contact/BAO/GroupTest.php | 3 +- .../CRM/Contact/BAO/IndividualTest.php | 6 +- tests/phpunit/CRM/Contact/BAO/QueryTest.php | 37 +- .../CRM/Contact/BAO/RelationshipTest.php | 6 +- .../Form/Search/Custom/FullTextTest.php | 47 ++- .../Contact/Form/Search/SearchContactTest.php | 2 +- .../CRM/Contact/Import/Parser/ContactTest.php | 7 +- tests/phpunit/CRM/Contact/SelectorTest.php | 93 +++-- .../CRM/Contribute/BAO/ContributionTest.php | 17 +- .../phpunit/CRM/Contribute/BAO/QueryTest.php | 1 + .../CRM/Contribute/Form/ContributionTest.php | 146 +++----- .../CRM/Contribute/Form/Task/InvoiceTest.php | 4 +- .../Form/Task/PDFLetterCommonTest.php | 3 - .../CRM/Contribute/Form/Task/StatusTest.php | 4 +- .../phpunit/CRM/Contribute/Form/TaskTest.php | 4 +- .../Import/Parser/ContributionTest.php | 2 + .../CRM/Core/BAO/ActionScheduleTest.php | 59 +-- tests/phpunit/CRM/Core/BAO/AddressTest.php | 1 + tests/phpunit/CRM/Core/BAO/CacheTest.php | 24 +- .../CRM/Core/BAO/ConfigSettingTest.php | 1 + .../phpunit/CRM/Core/BAO/CustomValueTest.php | 1 + tests/phpunit/CRM/Core/BAO/EmailTest.php | 1 + .../CRM/Core/BAO/FinancialTrxnTest.php | 4 +- tests/phpunit/CRM/Core/BAO/IMTest.php | 1 + tests/phpunit/CRM/Core/BAO/LocationTest.php | 15 +- tests/phpunit/CRM/Core/BAO/NavigationTest.php | 2 +- tests/phpunit/CRM/Core/BAO/OpenIDTest.php | 1 + .../phpunit/CRM/Core/BAO/OptionValueTest.php | 1 - .../CRM/Core/BAO/RecurringEntityTest.php | 3 +- tests/phpunit/CRM/Core/BAO/SettingTest.php | 4 +- tests/phpunit/CRM/Core/BAO/UFFieldTest.php | 24 +- .../CRM/Core/CodeGen/FreshnessTest.php | 27 +- .../CRM/Core/CommunityMessagesTest.php | 21 +- tests/phpunit/CRM/Core/Config/MailerTest.php | 12 +- .../CRM/Core/DAO/AllCoreTablesTest.php | 1 + tests/phpunit/CRM/Core/DAOConformanceTest.php | 3 +- tests/phpunit/CRM/Core/DAOTest.php | 6 +- tests/phpunit/CRM/Core/I18n/LocaleTest.php | 2 +- tests/phpunit/CRM/Core/I18n/SchemaTest.php | 2 +- tests/phpunit/CRM/Core/InnoDBIndexerTest.php | 7 +- .../phpunit/CRM/Core/ManagedEntitiesTest.php | 14 +- tests/phpunit/CRM/Core/MenuTest.php | 17 +- tests/phpunit/CRM/Core/OptionGroupTest.php | 2 - tests/phpunit/CRM/Core/Page/AJAXTest.php | 1 + tests/phpunit/CRM/Core/Page/RedirectTest.php | 1 + .../CRM/Core/Payment/AuthorizeNetIPNTest.php | 20 +- .../CRM/Core/Payment/AuthorizeNetTest.php | 2 +- .../phpunit/CRM/Core/Payment/BaseIPNTest.php | 13 +- .../CRM/Core/Payment/PayPalIPNTest.php | 24 +- .../CRM/Core/Payment/PayPalProIPNTest.php | 49 ++- tests/phpunit/CRM/Core/PseudoConstantTest.php | 30 +- tests/phpunit/CRM/Core/RegionTest.php | 1 + tests/phpunit/CRM/Core/ResourcesTest.php | 30 +- .../CRM/Core/Smarty/plugins/CrmMoneyTest.php | 3 +- .../CRM/Core/Smarty/plugins/CrmScopeTest.php | 1 + tests/phpunit/CRM/Core/TransactionTest.php | 84 +++-- tests/phpunit/CRM/Dedupe/MergerTest.php | 20 +- .../CRM/Event/BAO/AdditionalPaymentTest.php | 6 +- .../CRM/Event/BAO/ChangeFeeSelectionTest.php | 15 +- tests/phpunit/CRM/Event/BAO/QueryTest.php | 6 +- .../CRM/Event/Form/ParticipantTest.php | 7 +- .../Form/Registration/RegistrationTest.php | 1 - tests/phpunit/CRM/Export/BAO/ExportTest.php | 187 +++++----- tests/phpunit/CRM/Extension/BrowserTest.php | 1 + .../CRM/Extension/Container/BasicTest.php | 1 + .../Extension/Container/CollectionTest.php | 18 +- .../CRM/Extension/Container/StaticTest.php | 1 + tests/phpunit/CRM/Extension/InfoTest.php | 1 + .../CRM/Extension/Manager/ModuleTest.php | 15 +- .../CRM/Extension/Manager/ReportTest.php | 1 + .../CRM/Extension/Manager/SearchTest.php | 1 + tests/phpunit/CRM/Extension/ManagerTest.php | 25 +- tests/phpunit/CRM/Extension/MapperTest.php | 21 +- .../CRM/Financial/BAO/FinancialItemTest.php | 14 +- .../Financial/BAO/PaymentProcessorTest.php | 1 + .../Financial/Page/AjaxBatchSummaryTest.php | 1 + tests/phpunit/CRM/Group/Page/AjaxTest.php | 18 +- tests/phpunit/CRM/Logging/LoggingTest.php | 1 - tests/phpunit/CRM/Mailing/BAO/MailingTest.php | 7 +- .../CRM/Mailing/BaseMailingSystemTest.php | 27 +- tests/phpunit/CRM/Mailing/TokensTest.php | 1 + .../phpunit/CRM/Member/BAO/MembershipTest.php | 9 +- .../CRM/Member/Form/MembershipRenewalTest.php | 21 +- .../CRM/Member/Form/MembershipTest.php | 70 ++-- .../CRM/Member/StatusOverrideTypesTest.php | 2 +- .../CRM/Pledge/BAO/PledgePaymentTest.php | 21 +- tests/phpunit/CRM/Pledge/Form/SearchTest.php | 41 ++- tests/phpunit/CRM/Queue/RunnerTest.php | 17 +- .../CRM/Report/Form/ContactSummaryTest.php | 8 +- tests/phpunit/CRM/SMS/ProviderTest.php | 1 - .../phpunit/CRM/UF/Page/ProfileEditorTest.php | 1 + .../CRM/Upgrade/Incremental/BaseTest.php | 14 +- .../phpunit/CRM/Utils/API/MatchOptionTest.php | 14 +- .../CRM/Utils/API/ReloadOptionTest.php | 3 +- tests/phpunit/CRM/Utils/AddressTest.php | 9 +- tests/phpunit/CRM/Utils/ArrayTest.php | 18 +- .../phpunit/CRM/Utils/Cache/SqlGroupTest.php | 16 +- tests/phpunit/CRM/Utils/DateTest.php | 6 +- tests/phpunit/CRM/Utils/FileTest.php | 1 + tests/phpunit/CRM/Utils/HTMLTest.php | 49 ++- tests/phpunit/CRM/Utils/HookTest.php | 6 +- tests/phpunit/CRM/Utils/HtmlToTextTest.php | 3 +- tests/phpunit/CRM/Utils/ICalendarTest.php | 6 +- tests/phpunit/CRM/Utils/JSTest.php | 34 +- .../CRM/Utils/Mail/EmailProcessorTest.php | 7 +- .../phpunit/CRM/Utils/QueryFormatterTest.php | 11 +- tests/phpunit/CRM/Utils/RuleTest.php | 4 +- tests/phpunit/CRM/Utils/SQL/InsertTest.php | 1 + tests/phpunit/CRM/Utils/SQL/SelectTest.php | 1 + tests/phpunit/CRM/Utils/SignerTest.php | 12 +- tests/phpunit/CRM/Utils/StringTest.php | 3 +- tests/phpunit/CRM/Utils/SystemTest.php | 16 +- tests/phpunit/CRM/Utils/TimeTest.php | 4 +- .../phpunit/CRMTraits/ACL/PermissionTrait.php | 9 + tests/phpunit/CRMTraits/PCP/PCPTestTrait.php | 1 + .../phpunit/CRMTraits/Page/PageTestTrait.php | 2 +- tests/phpunit/Civi/API/KernelTest.php | 10 +- .../Subscriber/DynamicFKAuthorizationTest.php | 12 +- .../ActionSchedule/AbstractMappingTest.php | 5 +- tests/phpunit/Civi/Angular/ManagerTest.php | 2 +- .../Civi/CCase/SequenceListenerTest.php | 14 +- tests/phpunit/Civi/Core/ResolverTest.php | 5 +- .../Civi/Test/ExampleTransactionalTest.php | 2 +- .../phpunit/Civi/Token/TokenProcessorTest.php | 7 +- tests/phpunit/CiviTest/CiviCaseTestCase.php | 7 +- tests/phpunit/CiviTest/CiviReportTestCase.php | 1 + tests/phpunit/CiviTest/CiviTestSuite.php | 9 +- tests/phpunit/CiviTest/CiviUnitTestCase.php | 147 ++++---- tests/phpunit/E2E/Cache/TieredTest.php | 9 +- tests/phpunit/E2E/Cache/TwoInstancesTest.php | 7 +- tests/phpunit/E2E/Core/AssetBuilderTest.php | 1 - tests/phpunit/E2E/Core/PrevNextTest.php | 10 +- tests/phpunit/E2E/Extern/RestTest.php | 54 ++- tests/phpunit/E2E/Extern/SoapTest.php | 21 +- tests/phpunit/EnvTests.php | 1 + tests/phpunit/HelloTest.php | 7 +- tests/phpunit/api/v3/ACLPermissionTest.php | 16 +- tests/phpunit/api/v3/APIWrapperTest.php | 1 + tests/phpunit/api/v3/ActivityContactTest.php | 1 - tests/phpunit/api/v3/ActivityTest.php | 18 +- tests/phpunit/api/v3/AddressTest.php | 12 +- tests/phpunit/api/v3/AttachmentTest.php | 38 +- tests/phpunit/api/v3/CaseTest.php | 24 +- tests/phpunit/api/v3/CaseTypeTest.php | 4 +- tests/phpunit/api/v3/ContactTest.php | 83 ++--- tests/phpunit/api/v3/ContactTypeTest.php | 3 - tests/phpunit/api/v3/ContributionPageTest.php | 100 +++--- tests/phpunit/api/v3/ContributionSoftTest.php | 7 +- tests/phpunit/api/v3/ContributionTest.php | 336 ++++++++---------- tests/phpunit/api/v3/CountryTest.php | 1 - tests/phpunit/api/v3/CustomApiTest.php | 10 +- tests/phpunit/api/v3/CustomFieldTest.php | 15 +- .../api/v3/CustomValueContactTypeTest.php | 21 +- tests/phpunit/api/v3/DashboardContactTest.php | 11 +- tests/phpunit/api/v3/DomainTest.php | 48 +-- tests/phpunit/api/v3/EmailTest.php | 6 +- tests/phpunit/api/v3/EntityTagACLTest.php | 4 +- tests/phpunit/api/v3/EventTest.php | 30 +- tests/phpunit/api/v3/FinancialTypeACLTest.php | 3 - tests/phpunit/api/v3/GroupTest.php | 32 +- .../phpunit/api/v3/JobProcessMailingTest.php | 143 +++++--- tests/phpunit/api/v3/JobTest.php | 47 ++- .../phpunit/api/v3/JobTestCustomDataTest.php | 1 + tests/phpunit/api/v3/LoggingTest.php | 55 +-- tests/phpunit/api/v3/MailingABTest.php | 3 +- tests/phpunit/api/v3/MailingContactTest.php | 6 +- tests/phpunit/api/v3/MailingTest.php | 318 ++++++++++------- .../phpunit/api/v3/MembershipPaymentTest.php | 1 - tests/phpunit/api/v3/MembershipStatusTest.php | 2 - tests/phpunit/api/v3/MembershipTest.php | 19 +- tests/phpunit/api/v3/MessageTemplateTest.php | 5 +- tests/phpunit/api/v3/MultilingualTest.php | 9 +- tests/phpunit/api/v3/OptionGroupTest.php | 12 +- tests/phpunit/api/v3/OptionValueTest.php | 1 - tests/phpunit/api/v3/OrderTest.php | 9 +- .../phpunit/api/v3/ParticipantPaymentTest.php | 26 +- tests/phpunit/api/v3/ParticipantTest.php | 28 +- .../api/v3/PaymentProcessorTypeTest.php | 3 +- tests/phpunit/api/v3/PaymentTest.php | 6 +- tests/phpunit/api/v3/PcpTest.php | 3 +- tests/phpunit/api/v3/PhoneTest.php | 1 - tests/phpunit/api/v3/PledgePaymentTest.php | 4 - tests/phpunit/api/v3/PledgeTest.php | 5 - tests/phpunit/api/v3/ProfileTest.php | 146 ++++---- tests/phpunit/api/v3/RelationshipTest.php | 18 +- tests/phpunit/api/v3/ReportTemplateTest.php | 18 +- tests/phpunit/api/v3/SettingTest.php | 31 +- tests/phpunit/api/v3/StatusPreferenceTest.php | 1 - tests/phpunit/api/v3/SurveyRespondantTest.php | 1 - tests/phpunit/api/v3/SurveyTest.php | 7 +- .../phpunit/api/v3/SyntaxConformanceTest.php | 93 +++-- tests/phpunit/api/v3/SystemCheckTest.php | 1 - tests/phpunit/api/v3/TagTest.php | 3 + .../api/v3/TaxContributionPageTest.php | 3 +- tests/phpunit/api/v3/UFFieldTest.php | 5 +- tests/phpunit/api/v3/UFGroupTest.php | 5 +- tests/phpunit/api/v3/UFJoinTest.php | 6 +- tests/phpunit/api/v3/UFMatchTest.php | 6 +- tests/phpunit/api/v3/UtilsTest.php | 12 +- tests/phpunit/api/v3/ValidateTest.php | 1 + .../api/v3/custom_api/MailingProviderData.php | 13 +- tests/qunit/crm-translate/test.php | 17 +- 219 files changed, 2237 insertions(+), 1883 deletions(-) diff --git a/tests/extensions/test.extension.manager.paymenttest/main.php b/tests/extensions/test.extension.manager.paymenttest/main.php index dac3dc64e3d6..e6affe4bc9e2 100644 --- a/tests/extensions/test.extension.manager.paymenttest/main.php +++ b/tests/extensions/test.extension.manager.paymenttest/main.php @@ -5,7 +5,7 @@ */ class test_extension_manager_paymenttest extends CRM_Core_Payment { - static $counts = array(); + public static $counts = array(); public function install() { self::$counts['install'] = isset(self::$counts['install']) ? self::$counts['install'] : 0; diff --git a/tests/extensions/test.extension.manager.reporttest/main.php b/tests/extensions/test.extension.manager.reporttest/main.php index 66e29af22cab..96d1b7657b81 100644 --- a/tests/extensions/test.extension.manager.reporttest/main.php +++ b/tests/extensions/test.extension.manager.reporttest/main.php @@ -4,6 +4,7 @@ * Class test_extension_manager_reporttest */ class test_extension_manager_reporttest extends CRM_Core_Report { + /** * Class constructor. */ diff --git a/tests/extensions/test.extension.manager.searchtest/main.php b/tests/extensions/test.extension.manager.searchtest/main.php index 7ae801e52baf..f1bcdcd6a15a 100644 --- a/tests/extensions/test.extension.manager.searchtest/main.php +++ b/tests/extensions/test.extension.manager.searchtest/main.php @@ -6,6 +6,7 @@ * Class test_extension_manager_searchtest */ class test_extension_manager_searchtest extends CRM_Contact_Form_Search_Custom_Base implements CRM_Contact_Form_Search_Interface { + /** * @param $formValues */ @@ -48,7 +49,8 @@ public function buildForm(&$form) { /** * Get a list of summary data points. * - * @return mixed; NULL or array with keys: + * @return mixed + * - NULL or array with keys: * - summary: string * - total: numeric */ diff --git a/tests/phpunit/CRM/ACL/ListTest.php b/tests/phpunit/CRM/ACL/ListTest.php index c7157d72b5c5..c9b78c76efd1 100644 --- a/tests/phpunit/CRM/ACL/ListTest.php +++ b/tests/phpunit/CRM/ACL/ListTest.php @@ -28,7 +28,8 @@ public function testViewAllPermission() { $contacts = $this->createScenarioPlain(); // test WITH all permissions - CRM_Core_Config::singleton()->userPermissionClass->permissions = NULL; // NULL means 'all permissions' in UnitTests environment + // NULL means 'all permissions' in UnitTests environment + CRM_Core_Config::singleton()->userPermissionClass->permissions = NULL; $result = CRM_Contact_BAO_Contact_Permission::allowList($contacts); sort($result); $this->assertEquals($result, $contacts, "Contacts should be viewable when 'view all contacts'"); @@ -52,7 +53,6 @@ public function testViewAllPermission() { $this->assertEmpty($result, "Contacts should NOT be viewable when 'view all contacts' is not set"); } - /** * general test for the 'view all contacts' permission */ @@ -73,7 +73,6 @@ public function testEditAllPermission() { $this->assertEmpty($result, "Contacts should NOT be viewable when 'edit all contacts' is not set"); } - /** * Test access related to the 'access deleted contact' permission */ @@ -95,7 +94,6 @@ public function testViewEditDeleted() { $this->assertEquals(count($result), count($contacts) - 1, "Only deleted contacts should be excluded"); } - /** * Test access based on relations * @@ -177,7 +175,6 @@ public function testPermissionByRelation() { } } - /** * Test access based on ACL */ @@ -202,7 +199,6 @@ public function testPermissionByACL() { $this->assertContains($contacts[4], $result, "User[0] should NOT have an ACL permission on contact[4]."); } - /** * Test access with a mix of ACL and relationship */ @@ -285,10 +281,9 @@ public function testPermissionCompare() { } } - - /**************************************************** - * Scenario Builders * - ***************************************************/ + /* + * Scenario Builders + */ /** * create plain test scenario, no relationships/ACLs @@ -322,66 +317,79 @@ protected function createScenarioRelations() { // create some relationships $this->callAPISuccess('Relationship', 'create', array( - 'relationship_type_id' => 1, // CHILD OF + // CHILD OF + 'relationship_type_id' => 1, 'contact_id_a' => $contacts[1], 'contact_id_b' => $contacts[0], 'is_permission_b_a' => 1, 'is_active' => 1, - )); + )); $this->callAPISuccess('Relationship', 'create', array( - 'relationship_type_id' => 1, // CHILD OF + // CHILD OF + 'relationship_type_id' => 1, 'contact_id_a' => $contacts[2], 'contact_id_b' => $contacts[1], 'is_permission_b_a' => 1, 'is_active' => 1, - )); + )); $this->callAPISuccess('Relationship', 'create', array( - 'relationship_type_id' => 1, // CHILD OF + // CHILD OF + 'relationship_type_id' => 1, 'contact_id_a' => $contacts[4], 'contact_id_b' => $contacts[2], 'is_permission_b_a' => 1, 'is_active' => 1, - )); + )); $this->callAPISuccess('Relationship', 'create', array( - 'relationship_type_id' => 4, // SIBLING OF + // SIBLING OF + 'relationship_type_id' => 4, 'contact_id_a' => $contacts[5], 'contact_id_b' => $contacts[0], - 'is_permission_b_a' => 2, // View + // View + 'is_permission_b_a' => 2, 'is_active' => 1, )); $this->callAPISuccess('Relationship', 'create', array( - 'relationship_type_id' => 1, // CHILD OF + // CHILD OF + 'relationship_type_id' => 1, 'contact_id_a' => $contacts[6], 'contact_id_b' => $contacts[5], - 'is_permission_b_a' => 1, // Edit + // Edit + 'is_permission_b_a' => 1, 'is_active' => 1, )); $this->callAPISuccess('Relationship', 'create', array( - 'relationship_type_id' => 1, // CHILD OF + // CHILD OF + 'relationship_type_id' => 1, 'contact_id_a' => $contacts[7], 'contact_id_b' => $contacts[5], - 'is_permission_b_a' => 2, // View + // View + 'is_permission_b_a' => 2, 'is_active' => 1, )); $this->callAPISuccess('Relationship', 'create', array( - 'relationship_type_id' => 4, // SIBLING OF + // SIBLING OF + 'relationship_type_id' => 4, 'contact_id_a' => $contacts[0], 'contact_id_b' => $contacts[8], - 'is_permission_a_b' => 1, // edit (as a_b) + // edit (as a_b) + 'is_permission_a_b' => 1, 'is_active' => 1, )); $this->callAPISuccess('Relationship', 'create', array( - 'relationship_type_id' => 1, // CHILD OF + // CHILD OF + 'relationship_type_id' => 1, 'contact_id_a' => $contacts[9], 'contact_id_b' => $contacts[8], - 'is_permission_b_a' => 2, // view + // view + 'is_permission_b_a' => 2, 'is_active' => 1, )); diff --git a/tests/phpunit/CRM/Activity/BAO/ActivityTargetTest.php b/tests/phpunit/CRM/Activity/BAO/ActivityTargetTest.php index 39e9df34f740..09330c5fbdb8 100644 --- a/tests/phpunit/CRM/Activity/BAO/ActivityTargetTest.php +++ b/tests/phpunit/CRM/Activity/BAO/ActivityTargetTest.php @@ -55,7 +55,6 @@ public function testRetrieveTargetIdsByActivityIdZeroID() { $this->assertSame($target, array(), 'No targets returned'); } - public function testRetrieveTargetIdsByActivityIdOneID() { $activity = $this->activityCreate(); diff --git a/tests/phpunit/CRM/Activity/BAO/ActivityTest.php b/tests/phpunit/CRM/Activity/BAO/ActivityTest.php index 51b3dcd4def0..1f49256bb887 100644 --- a/tests/phpunit/CRM/Activity/BAO/ActivityTest.php +++ b/tests/phpunit/CRM/Activity/BAO/ActivityTest.php @@ -5,6 +5,7 @@ * @group headless */ class CRM_Activity_BAO_ActivityTest extends CiviUnitTestCase { + public function setUp() { parent::setUp(); $this->prepareForACLs(); @@ -343,7 +344,8 @@ public function testGetActivitiesCountforNonAdminDashboard() { 'caseId' => NULL, 'context' => 'home', 'activity_type_id' => NULL, - 'activity_status_id' => CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'status_id', 'Scheduled'), // for dashlet the Scheduled status is set by default + // for dashlet the Scheduled status is set by default + 'activity_status_id' => CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'status_id', 'Scheduled'), 'offset' => 0, 'rowCount' => 0, 'sort' => NULL, @@ -513,7 +515,8 @@ public function testGetActivitiesforNonAdminDashboard() { 'caseId' => NULL, 'context' => 'home', 'activity_type_id' => NULL, - 'activity_status_id' => CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'status_id', 'Scheduled'), // for dashlet the Scheduled status is set by default + // for dashlet the Scheduled status is set by default + 'activity_status_id' => CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'status_id', 'Scheduled'), 'offset' => 0, 'rowCount' => 0, 'sort' => NULL, @@ -958,7 +961,7 @@ public function getActivityDateData() { 'count' => 2, 'earliest' => strtotime('first day of january last year'), 'latest' => strtotime('first day of january this year'), - ] + ], ], ]; } @@ -1040,7 +1043,8 @@ protected function setUpForActivityDashboardTests() { 'caseId' => NULL, 'context' => 'home', 'activity_type_id' => NULL, - 'activity_status_id' => CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'status_id', 'Scheduled'), // for dashlet the Scheduled status is set by default + // for dashlet the Scheduled status is set by default + 'activity_status_id' => CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'status_id', 'Scheduled'), 'offset' => 0, 'rowCount' => 0, 'sort' => NULL, @@ -1239,7 +1243,6 @@ public function testSendSMSMobileInToProviderParamWithDoNotSMS() { $this->assertEquals(0, $success, "Expected success to be 0"); } - /** * @param int $phoneType (0=no phone, phone_type option group (1=fixed, 2=mobile) * @param bool $passPhoneTypeInContactDetails diff --git a/tests/phpunit/CRM/Activity/Form/SearchTest.php b/tests/phpunit/CRM/Activity/Form/SearchTest.php index 9061313f1f5a..e5ec443e98e4 100644 --- a/tests/phpunit/CRM/Activity/Form/SearchTest.php +++ b/tests/phpunit/CRM/Activity/Form/SearchTest.php @@ -116,7 +116,7 @@ public function getSearchCriteria() { ], [ 'search_criteria' => [ - ['activity_status_id', '=', ['IN' => ['1', '2']], 0, 0] + ['activity_status_id', '=', ['IN' => ['1', '2']], 0, 0], ], 'expected_qill' => [['Activity Status In Scheduled, Completed']], ], diff --git a/tests/phpunit/CRM/Batch/BAO/BatchTest.php b/tests/phpunit/CRM/Batch/BAO/BatchTest.php index 7a9631ac9348..1e7b4664e917 100644 --- a/tests/phpunit/CRM/Batch/BAO/BatchTest.php +++ b/tests/phpunit/CRM/Batch/BAO/BatchTest.php @@ -66,7 +66,7 @@ public function testGetBatchFinancialItems() { ]); $this->contributionCreate([ 'contact_id' => $contactId, - 'total_amount' => 1, + 'total_amount' => 1, 'payment_instrument_id' => 'Credit Card', 'financial_type_id' => 'Member Dues', 'contribution_status_id' => 'Completed', diff --git a/tests/phpunit/CRM/Bridge/OG/DrupalTest.php b/tests/phpunit/CRM/Bridge/OG/DrupalTest.php index 566f8820dbd1..fdbda500498a 100644 --- a/tests/phpunit/CRM/Bridge/OG/DrupalTest.php +++ b/tests/phpunit/CRM/Bridge/OG/DrupalTest.php @@ -41,6 +41,7 @@ * @group headless */ class CRM_Bridge_OG_DrupalTest extends CiviUnitTestCase { + /** * Test that one (ane only one) role (option value) is deleted by the updateCiviACLRole function */ diff --git a/tests/phpunit/CRM/Case/BAO/CaseTypeForkTest.php b/tests/phpunit/CRM/Case/BAO/CaseTypeForkTest.php index 21f0c46eb639..caa23c93d3b4 100644 --- a/tests/phpunit/CRM/Case/BAO/CaseTypeForkTest.php +++ b/tests/phpunit/CRM/Case/BAO/CaseTypeForkTest.php @@ -6,6 +6,7 @@ * @group headless */ class CRM_Case_BAO_CaseTypeForkTest extends CiviCaseTestCase { + public function setUp() { parent::setUp(); CRM_Core_ManagedEntities::singleton(TRUE)->reconcile(); @@ -41,7 +42,6 @@ public function testManagerContact() { $this->assertEquals($relTypeID, $xmlProcessor->getCaseManagerRoleId('ForkableCaseType')); } - /** * Edit the definition of ForkableCaseType. */ diff --git a/tests/phpunit/CRM/Case/BAO/CaseTypeTest.php b/tests/phpunit/CRM/Case/BAO/CaseTypeTest.php index d0f8bed73dc6..b83fac0cca96 100644 --- a/tests/phpunit/CRM/Case/BAO/CaseTypeTest.php +++ b/tests/phpunit/CRM/Case/BAO/CaseTypeTest.php @@ -117,13 +117,13 @@ public function definitionProvider() { $cases = array(); foreach (array( - 'empty-defn', - 'empty-lists', - 'one-item-in-each', - 'two-items-in-each', - 'forkable-0', - 'forkable-1', - ) as $key) { + 'empty-defn', + 'empty-lists', + 'one-item-in-each', + 'two-items-in-each', + 'forkable-0', + 'forkable-1', + ) as $key) { $cases[] = array($key, $fixtures[$key]['json'], $fixtures[$key]['xml']); } return $cases; @@ -187,8 +187,10 @@ public function testRoundtrip_JsonToXmlToJson($fixtureName, $inputJson, $ignore) */ public function normalizeXml($xml) { return trim( - preg_replace(":\n*<:", "\n<", // tags on new lines - preg_replace("/\n[\n ]+/", "\n", // no leading whitespace + // tags on new lines + preg_replace(":\n*<:", "\n<", + // no leading whitespace + preg_replace("/\n[\n ]+/", "\n", $xml ) ) diff --git a/tests/phpunit/CRM/Case/BAO/QueryTest.php b/tests/phpunit/CRM/Case/BAO/QueryTest.php index 9bef8b6b0252..3543366524ff 100644 --- a/tests/phpunit/CRM/Case/BAO/QueryTest.php +++ b/tests/phpunit/CRM/Case/BAO/QueryTest.php @@ -59,9 +59,9 @@ public function testWhereClauseSingle() { $queryObj = new CRM_Contact_BAO_Query($params, NULL, NULL, FALSE, FALSE, CRM_Contact_BAO_Query::MODE_CASE); $this->assertEquals(array( - 0 => 'Activity Type = Contribution', - 1 => 'Activity Type = Scheduled', - 2 => 'Activity Medium = In Person', + 0 => 'Activity Type = Contribution', + 1 => 'Activity Type = Scheduled', + 2 => 'Activity Medium = In Person', ), $queryObj->_qill[1] ); diff --git a/tests/phpunit/CRM/Case/XMLProcessor/ProcessTest.php b/tests/phpunit/CRM/Case/XMLProcessor/ProcessTest.php index 2d30c0bc82f2..53dcd83690ac 100644 --- a/tests/phpunit/CRM/Case/XMLProcessor/ProcessTest.php +++ b/tests/phpunit/CRM/Case/XMLProcessor/ProcessTest.php @@ -37,18 +37,18 @@ protected function setUpContacts() { */ protected function setupDefaultAssigneeOptions() { $options = [ - 'NONE', 'BY_RELATIONSHIP', 'SPECIFIC_CONTACT', 'USER_CREATING_THE_CASE' + 'NONE', 'BY_RELATIONSHIP', 'SPECIFIC_CONTACT', 'USER_CREATING_THE_CASE', ]; CRM_Core_BAO_OptionGroup::ensureOptionGroupExists([ - 'name' => 'activity_default_assignee' + 'name' => 'activity_default_assignee', ]); foreach ($options as $option) { $optionValue = CRM_Core_BAO_OptionValue::ensureOptionValueExists([ 'option_group_id' => 'activity_default_assignee', 'name' => $option, - 'label' => $option + 'label' => $option, ]); $this->defaultAssigneeOptionsValues[$option] = $optionValue['value']; @@ -65,19 +65,19 @@ protected function setupRelationships() { 'name_a_b' => 'Pupil of', 'name_b_a' => 'Instructor', 'contact_id_a' => $this->contacts['ana'], - 'contact_id_b' => $this->contacts['beto'] + 'contact_id_b' => $this->contacts['beto'], ], 'ana_is_spouse_of_carlos' => [ 'type_id' => NULL, 'name_a_b' => 'Spouse of', 'name_b_a' => 'Spouse of', 'contact_id_a' => $this->contacts['ana'], - 'contact_id_b' => $this->contacts['carlos'] + 'contact_id_b' => $this->contacts['carlos'], ], 'unassigned_employee' => [ 'type_id' => NULL, 'name_a_b' => 'Employee of', - 'name_b_a' => 'Employer' + 'name_b_a' => 'Employer', ], ]; @@ -88,7 +88,7 @@ protected function setupRelationships() { 'name_a_b' => $relationship['name_a_b'], 'label_a_b' => $relationship['name_a_b'], 'name_b_a' => $relationship['name_b_a'], - 'label_b_a' => $relationship['name_b_a'] + 'label_b_a' => $relationship['name_b_a'], ]); if (isset($relationship['contact_id_a'])) { @@ -231,7 +231,7 @@ protected function assertActivityAssignedToContactExists($assigneeContactId) { $expectedContact = $assigneeContactId === NULL ? [] : [$assigneeContactId]; $result = $this->callAPISuccess('Activity', 'get', [ 'target_contact_id' => $this->activityParams['clientID'], - 'return' => ['assignee_contact_id'] + 'return' => ['assignee_contact_id'], ]); $activity = CRM_Utils_Array::first($result['values']); diff --git a/tests/phpunit/CRM/Contact/BAO/ActivitySearchTest.php b/tests/phpunit/CRM/Contact/BAO/ActivitySearchTest.php index cfad097932c8..69a094ac6d58 100644 --- a/tests/phpunit/CRM/Contact/BAO/ActivitySearchTest.php +++ b/tests/phpunit/CRM/Contact/BAO/ActivitySearchTest.php @@ -43,7 +43,6 @@ class CRM_Contact_BAO_ActivitySearchTest extends CiviUnitTestCase { protected $_params; protected $test_activity_type_value; - /** * Test setup for every test. * diff --git a/tests/phpunit/CRM/Contact/BAO/ContactTest.php b/tests/phpunit/CRM/Contact/BAO/ContactTest.php index 81998d865d31..cc168dfeac4b 100644 --- a/tests/phpunit/CRM/Contact/BAO/ContactTest.php +++ b/tests/phpunit/CRM/Contact/BAO/ContactTest.php @@ -1550,7 +1550,8 @@ public function _testTimestamps($callbacks) { $prevTimestamps = $origTimestamps; foreach ($callbacks as $callbackName => $callback) { - sleep(1); // advance clock by 1 second to ensure timestamps change + // advance clock by 1 second to ensure timestamps change + sleep(1); $callback($contactId); $newTimestamps = CRM_Contact_BAO_Contact::getTimestamps($contactId); diff --git a/tests/phpunit/CRM/Contact/BAO/GroupContactCacheTest.php b/tests/phpunit/CRM/Contact/BAO/GroupContactCacheTest.php index faf560bd736c..b8af15bcba9c 100644 --- a/tests/phpunit/CRM/Contact/BAO/GroupContactCacheTest.php +++ b/tests/phpunit/CRM/Contact/BAO/GroupContactCacheTest.php @@ -486,7 +486,6 @@ public function testSmartGroupSearchBuilder() { $this->callAPISuccess('group', 'delete', ['id' => $group2->id]); } - public function testMultipleGroupWhereClause() { $returnProperties = array( 'contact_type' => 1, diff --git a/tests/phpunit/CRM/Contact/BAO/GroupContactTest.php b/tests/phpunit/CRM/Contact/BAO/GroupContactTest.php index 0a1957923729..718a6232497d 100644 --- a/tests/phpunit/CRM/Contact/BAO/GroupContactTest.php +++ b/tests/phpunit/CRM/Contact/BAO/GroupContactTest.php @@ -192,7 +192,6 @@ public function testContactSearchByParentGroup() { $this->callAPISuccess('Contact', 'delete', array('id' => $childSmartGroupContact)); } - /** * CRM-19698: Test case for combine contact search in regular and smart group */ diff --git a/tests/phpunit/CRM/Contact/BAO/GroupTest.php b/tests/phpunit/CRM/Contact/BAO/GroupTest.php index 481e9bca1a4f..b37d5ddb366c 100644 --- a/tests/phpunit/CRM/Contact/BAO/GroupTest.php +++ b/tests/phpunit/CRM/Contact/BAO/GroupTest.php @@ -94,7 +94,8 @@ public function testGroupHirearchy() { 'name' => uniqid(), 'title' => 'Parent Group B', 'description' => 'Parent Group Two', - 'is_active' => 0, // disable + // disable + 'is_active' => 0, )); $group2 = CRM_Contact_BAO_Group::create($params); diff --git a/tests/phpunit/CRM/Contact/BAO/IndividualTest.php b/tests/phpunit/CRM/Contact/BAO/IndividualTest.php index 71938a96fc73..9d70a7e2ae99 100644 --- a/tests/phpunit/CRM/Contact/BAO/IndividualTest.php +++ b/tests/phpunit/CRM/Contact/BAO/IndividualTest.php @@ -58,8 +58,10 @@ public function testFormatDisplayNamePrefixesById() { 'contact_type' => 'Individual', 'first_name' => 'Ben', 'last_name' => 'Lee', - 'prefix_id' => 4, // this is the doctor - 'suffix_id' => 2, // and the doctor is a senior + // this is the doctor + 'prefix_id' => 4, + // and the doctor is a senior + 'suffix_id' => 2, ); $contact = new CRM_Contact_DAO_Contact(); diff --git a/tests/phpunit/CRM/Contact/BAO/QueryTest.php b/tests/phpunit/CRM/Contact/BAO/QueryTest.php index abbe151527e6..95ea92894a18 100644 --- a/tests/phpunit/CRM/Contact/BAO/QueryTest.php +++ b/tests/phpunit/CRM/Contact/BAO/QueryTest.php @@ -78,10 +78,10 @@ public function testSearchProfileHomeCityCRM14263() { $contactID = $this->individualCreate(); CRM_Core_Config::singleton()->defaultSearchProfileID = 1; $this->callAPISuccess('address', 'create', array( - 'contact_id' => $contactID, - 'city' => 'Cool City', - 'location_type_id' => 1, - )); + 'contact_id' => $contactID, + 'city' => 'Cool City', + 'location_type_id' => 1, + )); $params = array( 0 => array( 0 => 'city-1', @@ -117,10 +117,10 @@ public function testSearchProfileHomeCityNoResultsCRM14263() { $contactID = $this->individualCreate(); CRM_Core_Config::singleton()->defaultSearchProfileID = 1; $this->callAPISuccess('address', 'create', array( - 'contact_id' => $contactID, - 'city' => 'Cool City', - 'location_type_id' => 1, - )); + 'contact_id' => $contactID, + 'city' => 'Cool City', + 'location_type_id' => 1, + )); $params = array( 0 => array( 0 => 'city-1', @@ -242,7 +242,6 @@ public function testSearchOtherLocationUpperLower() { $resultDAO->fetch(); } - /** * CRM-14263 search builder failure with search profile & address in criteria. * @@ -252,16 +251,18 @@ public function testSearchOtherLocationUpperLower() { * @dataProvider getSearchProfileData * * @param array $params + * @param string $selectClause + * @param string $whereClause */ public function testSearchProfilePrimaryCityCRM14263($params, $selectClause, $whereClause) { $contactID = $this->individualCreate(); CRM_Core_Config::singleton()->defaultSearchProfileID = 1; $this->callAPISuccess('address', 'create', array( - 'contact_id' => $contactID, - 'city' => 'Cool CITY', - 'street_address' => 'Long STREET', - 'location_type_id' => 1, - )); + 'contact_id' => $contactID, + 'city' => 'Cool CITY', + 'street_address' => 'Long STREET', + 'location_type_id' => 1, + )); $returnProperties = array( 'contact_type' => 1, 'contact_sub_type' => 1, @@ -770,7 +771,7 @@ public function testGetSummaryQueryWithFinancialACLDisabled() { 'avg' => '$ 233.33', 'amount' => '$ 1,400.00', 'count' => 6, - ], + ], 'cancel' => [ 'count' => 2, 'amount' => '$ 100.00', @@ -822,13 +823,15 @@ public function testGetSummaryQueryWithFinancialACLEnabled() { */ public function testConvertFormValuesCRM21816() { $fv = array( - "member_end_date_relative" => "starting_2.month", // next 60 days + // next 60 days + "member_end_date_relative" => "starting_2.month", "member_end_date_low" => "20180101000000", "member_end_date_high" => "20180331235959", "membership_is_current_member" => "1", "member_is_primary" => "1", ); - $fv_orig = $fv; // $fv is modified by convertFormValues() + // $fv is modified by convertFormValues() + $fv_orig = $fv; $params = CRM_Contact_BAO_Query::convertFormValues($fv); // restructure for easier testing diff --git a/tests/phpunit/CRM/Contact/BAO/RelationshipTest.php b/tests/phpunit/CRM/Contact/BAO/RelationshipTest.php index 7a58b6d9a63a..4ad1e3412364 100644 --- a/tests/phpunit/CRM/Contact/BAO/RelationshipTest.php +++ b/tests/phpunit/CRM/Contact/BAO/RelationshipTest.php @@ -51,7 +51,7 @@ protected function tearDown() { $this->quickCleanup([ 'civicrm_relationship_type', 'civicrm_relationship', - 'civicrm_contact' + 'civicrm_contact', ]); parent::tearDown(); @@ -120,7 +120,7 @@ public function testContactIdAndRelationshipIdWillBeUsedInFilter() { $options = CRM_Contact_BAO_Relationship::buildRelationshipTypeOptions([ 'relationship_id' => (string) $relationship['id'], - 'contact_id' => $individual['id'] + 'contact_id' => $individual['id'], ]); // for this relationship only individual=>organization is possible @@ -132,7 +132,7 @@ public function testContactIdAndRelationshipIdWillBeUsedInFilter() { $this->assertNotContains($personToPersonReverseType, $options); $options = CRM_Contact_BAO_Relationship::buildRelationshipTypeOptions([ - 'contact_id' => $individual['id'] + 'contact_id' => $individual['id'], ]); // for this result we only know that "A" must be an individual diff --git a/tests/phpunit/CRM/Contact/Form/Search/Custom/FullTextTest.php b/tests/phpunit/CRM/Contact/Form/Search/Custom/FullTextTest.php index 7d84df4864c5..4bff5fb7f96a 100644 --- a/tests/phpunit/CRM/Contact/Form/Search/Custom/FullTextTest.php +++ b/tests/phpunit/CRM/Contact/Form/Search/Custom/FullTextTest.php @@ -1,30 +1,29 @@ groupCreate([ 'group_type' => [ $groupTypes['Access Control'] => 1, - ] + ], ]); // Add random 5 contacts to a group. $this->groupContactCreate($groupId, 5); diff --git a/tests/phpunit/CRM/Contact/Import/Parser/ContactTest.php b/tests/phpunit/CRM/Contact/Import/Parser/ContactTest.php index e1312ea1d8e0..f6a4598d3205 100644 --- a/tests/phpunit/CRM/Contact/Import/Parser/ContactTest.php +++ b/tests/phpunit/CRM/Contact/Import/Parser/ContactTest.php @@ -89,9 +89,9 @@ public function testImportParserWtihEmployeeOfRelationship() { $this->assertEquals(CRM_Import_Parser::VALID, $parser->import(CRM_Import_Parser::DUPLICATE_UPDATE, $values), 'Return code from parser import was not as expected'); $this->callAPISuccess("Contact", "get", array( - "first_name" => "Alok", - "last_name" => "Patel", - "organization_name" => "Agileware", + "first_name" => "Alok", + "last_name" => "Patel", + "organization_name" => "Agileware", )); } @@ -272,7 +272,6 @@ public function testImportDeceased() { $this->callAPISuccess('Contact', 'delete', array('id' => $contact['id'])); } - /** * Test that the import parser adds the address to the primary location. * diff --git a/tests/phpunit/CRM/Contact/SelectorTest.php b/tests/phpunit/CRM/Contact/SelectorTest.php index 1eb5337323e3..917396028bda 100644 --- a/tests/phpunit/CRM/Contact/SelectorTest.php +++ b/tests/phpunit/CRM/Contact/SelectorTest.php @@ -40,6 +40,7 @@ class CRM_Contact_SelectorTest extends CiviUnitTestCase { public function tearDown() { } + /** * Test the query from the selector class is consistent with the dataset expectation. * @@ -147,11 +148,11 @@ public function testPrevNextCache() { // build cache key and use to it to fetch prev-next cache record $cacheKey = 'civicrm search ' . $key; $contacts = CRM_Utils_SQL_Select::from('civicrm_prevnext_cache') - ->select(['entity_id1', 'cacheKey']) - ->where("cacheKey = @key") - ->param('key', $cacheKey) - ->execute() - ->fetchAll(); + ->select(['entity_id1', 'cacheKey']) + ->where("cacheKey = @key") + ->param('key', $cacheKey) + ->execute() + ->fetchAll(); $this->assertEquals(1, count($contacts)); // check the prevNext record matches $expectedEntry = [ @@ -293,13 +294,15 @@ public function querySets() { * Test the contact ID query does not fail on country search. */ public function testContactIDQuery() { - $params = [[ - 0 => 'country-1', - 1 => '=', - 2 => '1228', - 3 => 1, - 4 => 0, - ]]; + $params = [ + [ + 0 => 'country-1', + 1 => '=', + 2 => '1228', + 3 => 1, + 4 => 0, + ], + ]; $searchOBJ = new CRM_Contact_Selector(NULL); $searchOBJ->contactIDQuery($params, '1_u'); @@ -325,13 +328,15 @@ public function testSelectorQueryOnNonASCIIlocationType() { $selector = new CRM_Contact_Selector( 'CRM_Contact_Selector', ['email' => ['IS NOT NULL' => 1]], - [[ - 0 => 'email-' . $locationType->id, - 1 => 'IS NOT NULL', - 2 => NULL, - 3 => 1, - 4 => 0, - ]], + [ + [ + 0 => 'email-' . $locationType->id, + 1 => 'IS NOT NULL', + 2 => NULL, + 3 => 1, + 4 => 0, + ], + ], [ 'contact_type' => 1, 'contact_sub_type' => 1, @@ -380,23 +385,30 @@ public function testWhereClauseByOperator() { 'IN' => ['IN' => ['Adam']], ]; $filtersByWhereClause = [ - 'IS NOT NULL' => '( contact_a.first_name IS NOT NULL )', // doesn't matter - '=' => "( contact_a.first_name = 'Adam' )", // case sensitive check - 'LIKE' => "( contact_a.first_name LIKE '%Ad%' )", // case insensitive check - 'RLIKE' => "( contact_a.first_name RLIKE BINARY '^A[a-z]{3}$' )", // case sensitive check - 'IN' => '( contact_a.first_name IN ("Adam") )', // case sensitive check + // doesn't matter + 'IS NOT NULL' => '( contact_a.first_name IS NOT NULL )', + // case sensitive check + '=' => "( contact_a.first_name = 'Adam' )", + // case insensitive check + 'LIKE' => "( contact_a.first_name LIKE '%Ad%' )", + // case sensitive check + 'RLIKE' => "( contact_a.first_name RLIKE BINARY '^A[a-z]{3}$' )", + // case sensitive check + 'IN' => '( contact_a.first_name IN ("Adam") )', ]; foreach ($filters as $op => $filter) { $selector = new CRM_Contact_Selector( 'CRM_Contact_Selector', ['first_name' => [$op => $filter]], - [[ - 0 => 'first_name', - 1 => $op, - 2 => $filter, - 3 => 1, - 4 => 0, - ]], + [ + [ + 0 => 'first_name', + 1 => $op, + 2 => $filter, + 3 => 1, + 4 => 0, + ], + ], [], CRM_Core_Action::NONE, NULL, @@ -419,13 +431,15 @@ public function testWhereClauseByOperator() { */ public function testSelectorQueryOrderByCustomField() { //Search for any params. - $params = [[ - 0 => 'country-1', - 1 => '=', - 2 => '1228', - 3 => 1, - 4 => 0, - ]]; + $params = [ + [ + 0 => 'country-1', + 1 => '=', + 2 => '1228', + 3 => 1, + 4 => 0, + ], + ]; //Create a test custom group and field. $customGroup = $this->callAPISuccess('CustomGroup', 'create', array( @@ -505,7 +519,8 @@ public function testCustomDateField() { 2 => 1, 3 => 1, 4 => 0, - ]], + ], + ], [], CRM_Core_Action::NONE, NULL, diff --git a/tests/phpunit/CRM/Contribute/BAO/ContributionTest.php b/tests/phpunit/CRM/Contribute/BAO/ContributionTest.php index 16a9d0eb4781..44505f9f462c 100644 --- a/tests/phpunit/CRM/Contribute/BAO/ContributionTest.php +++ b/tests/phpunit/CRM/Contribute/BAO/ContributionTest.php @@ -331,7 +331,8 @@ public function testAnnualQueryWithFinancialACLsEnabled() { public function testAnnualWithMultipleLineItems() { $contactID = $this->createLoggedInUserWithFinancialACL(); $this->createContributionWithTwoLineItemsAgainstPriceSet([ - 'contact_id' => $contactID] + 'contact_id' => $contactID, + ] ); $this->enableFinancialACLs(); $sql = CRM_Contribute_BAO_Contribution::getAnnualQuery([$contactID]); @@ -1382,14 +1383,12 @@ public function createContributionWithTax($params = array()) { $form = new CRM_Contribute_Form_Contribution(); $form->testSubmit(array( - 'total_amount' => $params['total_amount'], - 'financial_type_id' => $financialType['id'], - 'contact_id' => $contactId, - 'contribution_status_id' => 1, - 'price_set_id' => 0, - ), - CRM_Core_Action::ADD - ); + 'total_amount' => $params['total_amount'], + 'financial_type_id' => $financialType['id'], + 'contact_id' => $contactId, + 'contribution_status_id' => 1, + 'price_set_id' => 0, + ), CRM_Core_Action::ADD); $contribution = $this->callAPISuccessGetSingle('Contribution', array( 'contact_id' => $contactId, diff --git a/tests/phpunit/CRM/Contribute/BAO/QueryTest.php b/tests/phpunit/CRM/Contribute/BAO/QueryTest.php index b3e27b9bca63..8942d740cfca 100644 --- a/tests/phpunit/CRM/Contribute/BAO/QueryTest.php +++ b/tests/phpunit/CRM/Contribute/BAO/QueryTest.php @@ -5,6 +5,7 @@ * @group headless */ class CRM_Contribute_BAO_QueryTest extends CiviUnitTestCase { + public function tearDown() { $this->quickCleanUpFinancialEntities(); } diff --git a/tests/phpunit/CRM/Contribute/Form/ContributionTest.php b/tests/phpunit/CRM/Contribute/Form/ContributionTest.php index 8904cf1ccfe5..81e35403654a 100644 --- a/tests/phpunit/CRM/Contribute/Form/ContributionTest.php +++ b/tests/phpunit/CRM/Contribute/Form/ContributionTest.php @@ -34,9 +34,6 @@ */ class CRM_Contribute_Form_ContributionTest extends CiviUnitTestCase { - /** - * Assume empty database with just civicrm_data. - */ protected $_individualId; protected $_contribution; protected $_financialTypeId = 1; @@ -158,8 +155,7 @@ public function testSubmit($thousandSeparator) { 'contact_id' => $this->_individualId, 'payment_instrument_id' => array_search('Check', $this->paymentInstruments), 'contribution_status_id' => 1, - ), - CRM_Core_Action::ADD); + ), CRM_Core_Action::ADD); $contribution = $this->callAPISuccessGetSingle('Contribution', array('contact_id' => $this->_individualId)); $this->assertEmpty($contribution['amount_level']); $this->assertEquals(1234, $contribution['total_amount']); @@ -181,8 +177,7 @@ public function testSubmitCreditCard() { $this->callAPISuccessGetCount('Contribution', array( 'contact_id' => $this->_individualId, 'contribution_status_id' => 'Completed', - ), - 1); + ), 1); } /** @@ -240,7 +235,7 @@ public function testSubmitCreditCardPayPal() { 'payment_instrument_id' => $this->callAPISuccessGetValue('PaymentProcessor', array( 'return' => 'payment_instrument_id', 'id' => $paymentProcessorID, - )), + )), )); $this->assertEquals(1, $contribution["count"], "Contribution count should be one."); @@ -314,7 +309,6 @@ public function testSubmitCreditCardWithEmailReceipt() { $mut->stop(); } - /** * Test the submit function on the contribution page. */ @@ -369,7 +363,7 @@ public function testSubmitCreditCardNoReceipt() { 'payment_instrument_id' => $this->callAPISuccessGetValue('PaymentProcessor', array( 'return' => 'payment_instrument_id', 'id' => $this->paymentProcessorID, - )), + )), ), 1); $contact = $this->callAPISuccessGetSingle('Contact', array('id' => $this->_individualId)); $this->assertTrue(empty($contact['source'])); @@ -501,9 +495,7 @@ public function testSubmitCreditCardInvalid() { 'payment_processor_id' => $this->paymentProcessorID, 'credit_card_exp_date' => array('M' => 5, 'Y' => 2012), 'credit_card_number' => '411111111111111', - ), CRM_Core_Action::ADD, - 'live' - ); + ), CRM_Core_Action::ADD, 'live'); } catch (\Civi\Payment\Exception\PaymentProcessorException $e) { $this->callAPISuccessGetCount('Contribution', array( @@ -540,9 +532,7 @@ public function testSubmitCreditCardWithBillingAddress() { 'credit_card_exp_date' => array('M' => 5, 'Y' => 2025), 'credit_card_number' => '411111111111111', 'billing_city-5' => 'Vancouver', - ), CRM_Core_Action::ADD, - 'live' - ); + ), CRM_Core_Action::ADD, 'live'); $contribution = $this->callAPISuccessGetSingle('Contribution', array('return' => 'address_id')); $this->assertNotEmpty($contribution['address_id']); // CRM-18490 : There is a unwanted test leakage due to below getsingle Api as it only fails in Jenkin @@ -573,9 +563,7 @@ public function testSubmitCreditCardWithRecur() { 'credit_card_exp_date' => array('M' => 5, 'Y' => 2025), 'credit_card_number' => '411111111111111', 'billing_city-5' => 'Vancouver', - ), CRM_Core_Action::ADD, - 'live' - ); + ), CRM_Core_Action::ADD, 'live'); $contribution = $this->callAPISuccessGetSingle('Contribution', array('return' => 'receive_date')); $this->assertEquals($contribution['receive_date'], $receiveDate); } @@ -593,9 +581,7 @@ public function testSubmitCreditCardWithNoBillingAddress() { 'payment_processor_id' => $this->paymentProcessorID, 'credit_card_exp_date' => array('M' => 5, 'Y' => 2025), 'credit_card_number' => '411111111111111', - ), CRM_Core_Action::ADD, - 'live' - ); + ), CRM_Core_Action::ADD, 'live'); $contribution = $this->callAPISuccessGetSingle('Contribution', array('return' => 'address_id')); $this->assertEmpty($contribution['address_id']); $this->callAPISuccessGetCount('Address', array( @@ -620,8 +606,8 @@ public function testSubmitEmailReceipt() { ), CRM_Core_Action::ADD); $this->callAPISuccessGetCount('Contribution', array('contact_id' => $this->_individualId), 1); $mut->checkMailLog(array( - '

    Please print this receipt for your records.

    ', - ) + '

    Please print this receipt for your records.

    ', + ) ); $mut->stop(); } @@ -646,10 +632,9 @@ public function testSubmitEmailReceiptUserEmailFromAddress() { ), CRM_Core_Action::ADD); $this->callAPISuccessGetCount('Contribution', array('contact_id' => $this->_individualId), 1); $mut->checkMailLog(array( - '

    Please print this receipt for your records.

    ', - '', - ) - ); + '

    Please print this receipt for your records.

    ', + '', + )); $mut->stop(); } @@ -714,14 +699,13 @@ public function testEmailReceiptOnPayLater() { $form->testSubmit($params, CRM_Core_Action::ADD); $mut->checkMailLog(array( - 'Financial Type: Donation + 'Financial Type: Donation --------------------------------------------------------- Item Qty Each Total ---------------------------------------------------------- Price Field - Price Field 1 1 $ 100.00 $ 100.00 ', - ) - ); + )); $mut->stop(); } @@ -809,8 +793,7 @@ public function testPremiumUpdateCreditCard() { 'payment_processor_id' => $this->paymentProcessorID, 'credit_card_exp_date' => array('M' => 5, 'Y' => 2026), 'credit_card_number' => '411111111111111', - ), CRM_Core_Action::ADD, - 'live'); + ), CRM_Core_Action::ADD, 'live'); $contributionProduct = $this->callAPISuccess('contribution_product', 'getsingle', array()); $this->assertEquals('clumsy smurf', $contributionProduct['product_option']); $mut->checkMailLog(array( @@ -833,8 +816,7 @@ public function testSubmitWithNote() { 'payment_instrument_id' => array_search('Check', $this->paymentInstruments), 'contribution_status_id' => 1, 'note' => 'Super cool and interesting stuff', - ), - CRM_Core_Action::ADD); + ), CRM_Core_Action::ADD); $this->callAPISuccessGetCount('Contribution', array('contact_id' => $this->_individualId), 1); $note = $this->callAPISuccessGetSingle('note', array('entity_table' => 'civicrm_contribution')); $this->assertEquals($note['note'], 'Super cool and interesting stuff'); @@ -897,14 +879,13 @@ public function testSubmitUpdate($thousandSeparator) { $form = new CRM_Contribute_Form_Contribution(); $form->testSubmit(array( - 'total_amount' => $this->formatMoneyInput(6100.10), - 'financial_type_id' => 1, - 'contact_id' => $this->_individualId, - 'payment_instrument_id' => array_search('Check', $this->paymentInstruments), - 'contribution_status_id' => 1, - 'price_set_id' => 0, - ), - CRM_Core_Action::ADD); + 'total_amount' => $this->formatMoneyInput(6100.10), + 'financial_type_id' => 1, + 'contact_id' => $this->_individualId, + 'payment_instrument_id' => array_search('Check', $this->paymentInstruments), + 'contribution_status_id' => 1, + 'price_set_id' => 0, + ), CRM_Core_Action::ADD); $contribution = $this->callAPISuccessGetSingle('Contribution', array('contact_id' => $this->_individualId)); $form->testSubmit(array( 'total_amount' => $this->formatMoneyInput(5200.20), @@ -915,8 +896,7 @@ public function testSubmitUpdate($thousandSeparator) { 'contribution_status_id' => 1, 'price_set_id' => 0, 'id' => $contribution['id'], - ), - CRM_Core_Action::UPDATE); + ), CRM_Core_Action::UPDATE); $contribution = $this->callAPISuccessGetSingle('Contribution', array('contact_id' => $this->_individualId)); $this->assertEquals(5200.20, $contribution['total_amount'], 2); @@ -941,15 +921,14 @@ public function testSubmitUpdateChangePaymentInstrument($thousandSeparator) { $form = new CRM_Contribute_Form_Contribution(); $form->testSubmit(array( - 'total_amount' => 1200.55, - 'financial_type_id' => 1, - 'contact_id' => $this->_individualId, - 'payment_instrument_id' => array_search('Check', $this->paymentInstruments), - 'check_number' => '123AX', - 'contribution_status_id' => 1, - 'price_set_id' => 0, - ), - CRM_Core_Action::ADD); + 'total_amount' => 1200.55, + 'financial_type_id' => 1, + 'contact_id' => $this->_individualId, + 'payment_instrument_id' => array_search('Check', $this->paymentInstruments), + 'check_number' => '123AX', + 'contribution_status_id' => 1, + 'price_set_id' => 0, + ), CRM_Core_Action::ADD); $contribution = $this->callAPISuccessGetSingle('Contribution', array('contact_id' => $this->_individualId)); $form->testSubmit(array( 'total_amount' => 1200.55, @@ -962,8 +941,7 @@ public function testSubmitUpdateChangePaymentInstrument($thousandSeparator) { 'contribution_status_id' => 1, 'price_set_id' => 0, 'id' => $contribution['id'], - ), - CRM_Core_Action::UPDATE); + ), CRM_Core_Action::UPDATE); $contribution = $this->callAPISuccessGetSingle('Contribution', array('contact_id' => $this->_individualId)); $this->assertEquals(1200.55, $contribution['total_amount']); @@ -1061,13 +1039,13 @@ public function testSubmitSaleTax($thousandSeparator) { $form = new CRM_Contribute_Form_Contribution(); $form->testSubmit(array( - 'total_amount' => $this->formatMoneyInput(1000.00), - 'financial_type_id' => $this->_financialTypeId, - 'contact_id' => $this->_individualId, - 'payment_instrument_id' => array_search('Check', $this->paymentInstruments), - 'contribution_status_id' => 1, - 'price_set_id' => 0, - ), + 'total_amount' => $this->formatMoneyInput(1000.00), + 'financial_type_id' => $this->_financialTypeId, + 'contact_id' => $this->_individualId, + 'payment_instrument_id' => array_search('Check', $this->paymentInstruments), + 'contribution_status_id' => 1, + 'price_set_id' => 0, + ), CRM_Core_Action::ADD ); $contribution = $this->callAPISuccessGetSingle('Contribution', @@ -1086,14 +1064,12 @@ public function testSubmitSaleTax($thousandSeparator) { // CRM-20423: Upon simple submit of 'Edit Contribution' form ensure that total amount is same $form->testSubmit(array( - 'id' => $contribution['id'], - 'financial_type_id' => 3, - 'contact_id' => $this->_individualId, - 'payment_instrument_id' => array_search('Check', $this->paymentInstruments), - 'contribution_status_id' => 1, - ), - CRM_Core_Action::UPDATE - ); + 'id' => $contribution['id'], + 'financial_type_id' => 3, + 'contact_id' => $this->_individualId, + 'payment_instrument_id' => array_search('Check', $this->paymentInstruments), + 'contribution_status_id' => 1, + ), CRM_Core_Action::UPDATE); $contribution = $this->callAPISuccessGetSingle('Contribution', array('contact_id' => $this->_individualId)); // Check if total amount is unchanged @@ -1109,15 +1085,13 @@ public function testSubmitWithOutSaleTax() { $form = new CRM_Contribute_Form_Contribution(); $form->testSubmit(array( - 'total_amount' => 100, - 'financial_type_id' => 3, - 'contact_id' => $this->_individualId, - 'payment_instrument_id' => array_search('Check', $this->paymentInstruments), - 'contribution_status_id' => 1, - 'price_set_id' => 0, - ), - CRM_Core_Action::ADD - ); + 'total_amount' => 100, + 'financial_type_id' => 3, + 'contact_id' => $this->_individualId, + 'payment_instrument_id' => array_search('Check', $this->paymentInstruments), + 'contribution_status_id' => 1, + 'price_set_id' => 0, + ), CRM_Core_Action::ADD); $contribution = $this->callAPISuccessGetSingle('Contribution', array( 'contact_id' => $this->_individualId, @@ -1170,9 +1144,7 @@ public function testReSubmitSaleTax($thousandSeparator) { 'contribution_status_id' => 1, 'is_email_receipt' => 1, 'from_email_address' => 'demo@example.com', - ), - CRM_Core_Action::UPDATE - ); + ), CRM_Core_Action::UPDATE); $contribution = $this->callAPISuccessGetSingle('Contribution', array( 'contribution_id' => 1, @@ -1231,9 +1203,7 @@ public function testReSubmitSaleTaxAlteredAmount($thousandSeparator) { 'contribution_status_id' => 1, 'is_email_receipt' => 1, 'from_email_address' => 'demo@example.com', - ), - CRM_Core_Action::UPDATE - ); + ), CRM_Core_Action::UPDATE); $contribution = $this->callAPISuccessGetSingle('Contribution', array( 'contribution_id' => 1, @@ -1285,9 +1255,7 @@ protected function doInitialSubmit() { 'payment_instrument_id' => array_search('Check', $this->paymentInstruments), 'contribution_status_id' => 1, 'price_set_id' => 0, - ), - CRM_Core_Action::ADD - ); + ), CRM_Core_Action::ADD); $contribution = $this->callAPISuccessGetSingle('Contribution', array( 'contribution_id' => 1, diff --git a/tests/phpunit/CRM/Contribute/Form/Task/InvoiceTest.php b/tests/phpunit/CRM/Contribute/Form/Task/InvoiceTest.php index 761102391203..2f87e3b1350d 100644 --- a/tests/phpunit/CRM/Contribute/Form/Task/InvoiceTest.php +++ b/tests/phpunit/CRM/Contribute/Form/Task/InvoiceTest.php @@ -33,9 +33,7 @@ * @group headless */ class CRM_Contribute_Form_Task_InvoiceTest extends CiviUnitTestCase { - /** - * Assume empty database with just civicrm_data. - */ + protected $_individualId; /** diff --git a/tests/phpunit/CRM/Contribute/Form/Task/PDFLetterCommonTest.php b/tests/phpunit/CRM/Contribute/Form/Task/PDFLetterCommonTest.php index e7efed51b921..b7eada9d98a0 100644 --- a/tests/phpunit/CRM/Contribute/Form/Task/PDFLetterCommonTest.php +++ b/tests/phpunit/CRM/Contribute/Form/Task/PDFLetterCommonTest.php @@ -34,9 +34,6 @@ */ class CRM_Contribute_Form_Task_PDFLetterCommonTest extends CiviUnitTestCase { - /** - * Assume empty database with just civicrm_data. - */ protected $_individualId; protected $_docTypes = NULL; diff --git a/tests/phpunit/CRM/Contribute/Form/Task/StatusTest.php b/tests/phpunit/CRM/Contribute/Form/Task/StatusTest.php index 5afdb1b595b8..498efed17d63 100644 --- a/tests/phpunit/CRM/Contribute/Form/Task/StatusTest.php +++ b/tests/phpunit/CRM/Contribute/Form/Task/StatusTest.php @@ -29,9 +29,7 @@ * Class CRM_Contribute_Form_Task_StatusTest */ class CRM_Contribute_Form_Task_StatusTest extends CiviUnitTestCase { - /** - * Assume empty database with just civicrm_data. - */ + protected $_individualId; /** diff --git a/tests/phpunit/CRM/Contribute/Form/TaskTest.php b/tests/phpunit/CRM/Contribute/Form/TaskTest.php index ffecaada62cd..5cd4cdec9c6e 100644 --- a/tests/phpunit/CRM/Contribute/Form/TaskTest.php +++ b/tests/phpunit/CRM/Contribute/Form/TaskTest.php @@ -29,9 +29,7 @@ * Class CRM_Contribute_Form_Tasktest */ class CRM_Contribute_Form_TaskTest extends CiviUnitTestCase { - /** - * Assume empty database with just civicrm_data. - */ + protected $_individualId; /** diff --git a/tests/phpunit/CRM/Contribute/Import/Parser/ContributionTest.php b/tests/phpunit/CRM/Contribute/Import/Parser/ContributionTest.php index 740178e609a9..ed21e72e2e6f 100644 --- a/tests/phpunit/CRM/Contribute/Import/Parser/ContributionTest.php +++ b/tests/phpunit/CRM/Contribute/Import/Parser/ContributionTest.php @@ -11,12 +11,14 @@ */ class CRM_Contribute_Import_Parser_ContributionTest extends CiviUnitTestCase { protected $_tablesToTruncate = array(); + /** * Setup function. */ public function setUp() { parent::setUp(); } + /** * Test import parser will add contribution and soft contribution each for different contact. * diff --git a/tests/phpunit/CRM/Core/BAO/ActionScheduleTest.php b/tests/phpunit/CRM/Core/BAO/ActionScheduleTest.php index fead50b0ddd8..e552004e2685 100644 --- a/tests/phpunit/CRM/Core/BAO/ActionScheduleTest.php +++ b/tests/phpunit/CRM/Core/BAO/ActionScheduleTest.php @@ -79,8 +79,10 @@ public function setUp() { 'start_date' => '20120315', 'end_date' => '20120615', ), - 'role_id' => '1', // Attendee. - 'status_id' => '8', // No-show. + // Attendee. + 'role_id' => '1', + // No-show. + 'status_id' => '8', ); $this->fixtures['phonecall'] = array( @@ -528,12 +530,15 @@ public function setUp() { 'end_date' => '', 'end_frequency_interval' => '', 'end_frequency_unit' => '', - 'entity_status' => '', // participant status id - 'entity_value' => '', // event type id + // participant status id + 'entity_status' => '', + // event type id + 'entity_value' => '', 'group_id' => '', 'is_active' => 1, 'is_repeat' => '0', - 'mapping_id' => 2, // event type + // event type + 'mapping_id' => 2, 'msg_template_id' => '', 'recipient' => '', 'recipient_listing' => '', @@ -557,12 +562,15 @@ public function setUp() { 'end_date' => 'event_end_date', 'end_frequency_interval' => '3', 'end_frequency_unit' => 'month', - 'entity_status' => '', // participant status id - 'entity_value' => '', // event type id + // participant status id + 'entity_status' => '', + // event type id + 'entity_value' => '', 'group_id' => '', 'is_active' => 1, 'is_repeat' => '1', - 'mapping_id' => 2, // event type + // event type + 'mapping_id' => 2, 'msg_template_id' => '', 'recipient' => '', 'recipient_listing' => '', @@ -709,11 +717,16 @@ public function mailerExamples() { // Some tokens - short as subject has 128char limit in DB. $someTokensTmpl = implode(';;', array( - '{contact.display_name}', // basic contact token - '{contact.gender}', // funny legacy contact token - '{contact.gender_id}', // funny legacy contact token - '{domain.name}', // domain token - '{activity.activity_type}', // action-scheduler token + // basic contact token + '{contact.display_name}', + // funny legacy contact token + '{contact.gender}', + // funny legacy contact token + '{contact.gender_id}', + // domain token + '{domain.name}', + // action-scheduler token + '{activity.activity_type}', )); // Further tokens can be tested in the body text/html. $manyTokensTmpl = implode(';;', array( @@ -1051,7 +1064,6 @@ public function testMembershipDateMatch() { )); } - /** * CRM-21675: Support parent and smart group in 'Limit to' field */ @@ -1307,7 +1319,6 @@ public function testMembershipEndDateMatch() { )); } - /** * Test membership end date email. * @@ -1573,9 +1584,12 @@ public function testMembershipOnMultipleReminder() { $result = $this->callAPISuccess('contact', 'create', array_merge($this->fixtures['contact'], array('contact_id' => $membership->contact_id))); $this->assertAPISuccess($result); - $actionScheduleBefore = $this->fixtures['sched_membership_end_2week']; // Send email 2 weeks before end_date - $actionScheduleOn = $this->fixtures['sched_on_membership_end_date']; // Send email on end_date/expiry date - $actionScheduleAfter = $this->fixtures['sched_after_1day_membership_end_date']; // Send email 1 day after end_date/grace period + // Send email 2 weeks before end_date + $actionScheduleBefore = $this->fixtures['sched_membership_end_2week']; + // Send email on end_date/expiry date + $actionScheduleOn = $this->fixtures['sched_on_membership_end_date']; + // Send email 1 day after end_date/grace period + $actionScheduleAfter = $this->fixtures['sched_after_1day_membership_end_date']; $actionScheduleBefore['entity_value'] = $actionScheduleOn['entity_value'] = $actionScheduleAfter['entity_value'] = $membership->membership_type_id; foreach (array('actionScheduleBefore', 'actionScheduleOn', 'actionScheduleAfter') as $value) { $$value = CRM_Core_BAO_ActionSchedule::add($$value); @@ -1622,17 +1636,20 @@ public function testMembershipOnMultipleReminder() { $this->assertApproxEquals( strtotime('2012-06-01 01:00:00'), strtotime(CRM_Core_DAO::getFieldValue('CRM_Core_DAO_ActionLog', $actionScheduleBefore->id, 'action_date_time', 'action_schedule_id', TRUE)), - 3 // Variation in test execution time. + // Variation in test execution time. + 3 ); $this->assertApproxEquals( strtotime('2012-06-15 00:00:00'), strtotime(CRM_Core_DAO::getFieldValue('CRM_Core_DAO_ActionLog', $actionScheduleOn->id, 'action_date_time', 'action_schedule_id', TRUE)), - 3 // Variation in test execution time. + // Variation in test execution time. + 3 ); $this->assertApproxEquals( strtotime('2012-06-16 01:00:00'), strtotime(CRM_Core_DAO::getFieldValue('CRM_Core_DAO_ActionLog', $actionScheduleAfter->id, 'action_date_time', 'action_schedule_id', TRUE)), - 3 // Variation in test execution time. + // Variation in test execution time. + 3 ); //extend MED to 2 weeks after the current MED (that may signifies as membership renewal activity) diff --git a/tests/phpunit/CRM/Core/BAO/AddressTest.php b/tests/phpunit/CRM/Core/BAO/AddressTest.php index 53c5c40eb582..44130a7786f7 100644 --- a/tests/phpunit/CRM/Core/BAO/AddressTest.php +++ b/tests/phpunit/CRM/Core/BAO/AddressTest.php @@ -30,6 +30,7 @@ * @group headless */ class CRM_Core_BAO_AddressTest extends CiviUnitTestCase { + public function setUp() { parent::setUp(); diff --git a/tests/phpunit/CRM/Core/BAO/CacheTest.php b/tests/phpunit/CRM/Core/BAO/CacheTest.php index ac154eb20557..99abb9e6493f 100644 --- a/tests/phpunit/CRM/Core/BAO/CacheTest.php +++ b/tests/phpunit/CRM/Core/BAO/CacheTest.php @@ -84,14 +84,22 @@ public function testSetGetItem($originalValue) { public function getCleanKeyExamples() { $es = []; - $es[] = ['hello_world and/other.planets', 'hello_world-20and-2fother.planets']; // allowed chars - $es[] = ['hello/world+-#@{}', 'hello-2fworld-2b-2d-23-40-7b-7d']; // escaped chars - $es[] = ["LF-\nTAB-\tCR-\remojiskull💀", 'LF-2d-aTAB-2d-9CR-2d-demojiskull-f0-9f-92-80']; // short with emoji - $es[] = ["LF-\nTAB-\tCR-\remojibomb💣emojiskull💀", '-5d9324e052f6e10240dce5029c5e8525']; // long with emoji - $es[] = ['123456789 123456789 123456789 123456789 123456789 123', '123456789-20123456789-20123456789-20123456789-20123456789-20123']; // spaces are escaped - $es[] = ['123456789_123456789_123456789_123456789_123456789_123456789_123', '123456789_123456789_123456789_123456789_123456789_123456789_123']; // long but allowed - $es[] = ['123456789_123456789_123456789_123456789_123456789_123456789_1234', '-e02b981aff954fdcc9a81c25f5ec9681']; // too long, md5 fallback - $es[] = ['123456789-/23456789-+23456789--23456789_123456789_123456789', '-43b6dec1026187ae6f6a8fe4d56ab22e']; // too long, md5 fallback + // allowed chars + $es[] = ['hello_world and/other.planets', 'hello_world-20and-2fother.planets']; + // escaped chars + $es[] = ['hello/world+-#@{}', 'hello-2fworld-2b-2d-23-40-7b-7d']; + // short with emoji + $es[] = ["LF-\nTAB-\tCR-\remojiskull💀", 'LF-2d-aTAB-2d-9CR-2d-demojiskull-f0-9f-92-80']; + // long with emoji + $es[] = ["LF-\nTAB-\tCR-\remojibomb💣emojiskull💀", '-5d9324e052f6e10240dce5029c5e8525']; + // spaces are escaped + $es[] = ['123456789 123456789 123456789 123456789 123456789 123', '123456789-20123456789-20123456789-20123456789-20123456789-20123']; + // long but allowed + $es[] = ['123456789_123456789_123456789_123456789_123456789_123456789_123', '123456789_123456789_123456789_123456789_123456789_123456789_123']; + // too long, md5 fallback + $es[] = ['123456789_123456789_123456789_123456789_123456789_123456789_1234', '-e02b981aff954fdcc9a81c25f5ec9681']; + // too long, md5 fallback + $es[] = ['123456789-/23456789-+23456789--23456789_123456789_123456789', '-43b6dec1026187ae6f6a8fe4d56ab22e']; return $es; } diff --git a/tests/phpunit/CRM/Core/BAO/ConfigSettingTest.php b/tests/phpunit/CRM/Core/BAO/ConfigSettingTest.php index 4930469b53a0..38ad72fd97a5 100644 --- a/tests/phpunit/CRM/Core/BAO/ConfigSettingTest.php +++ b/tests/phpunit/CRM/Core/BAO/ConfigSettingTest.php @@ -30,6 +30,7 @@ * @group headless */ class CRM_Core_BAO_ConfigSettingTest extends CiviUnitTestCase { + public function testToggleComponent() { $origNames = array(); foreach (CRM_Core_Component::getEnabledComponents() as $c) { diff --git a/tests/phpunit/CRM/Core/BAO/CustomValueTest.php b/tests/phpunit/CRM/Core/BAO/CustomValueTest.php index 39a751f3487f..16fcde5311e4 100644 --- a/tests/phpunit/CRM/Core/BAO/CustomValueTest.php +++ b/tests/phpunit/CRM/Core/BAO/CustomValueTest.php @@ -36,6 +36,7 @@ * @group headless */ class CRM_Core_BAO_CustomValueTest extends CiviUnitTestCase { + public function testTypeCheckWithValidInput() { $values = array( diff --git a/tests/phpunit/CRM/Core/BAO/EmailTest.php b/tests/phpunit/CRM/Core/BAO/EmailTest.php index a97290d2fa91..530a4030a734 100644 --- a/tests/phpunit/CRM/Core/BAO/EmailTest.php +++ b/tests/phpunit/CRM/Core/BAO/EmailTest.php @@ -5,6 +5,7 @@ * @group headless */ class CRM_Core_BAO_EmailTest extends CiviUnitTestCase { + public function setUp() { parent::setUp(); diff --git a/tests/phpunit/CRM/Core/BAO/FinancialTrxnTest.php b/tests/phpunit/CRM/Core/BAO/FinancialTrxnTest.php index 94de1d4d10ef..388dcea22b53 100644 --- a/tests/phpunit/CRM/Core/BAO/FinancialTrxnTest.php +++ b/tests/phpunit/CRM/Core/BAO/FinancialTrxnTest.php @@ -30,6 +30,7 @@ * @group headless */ class CRM_Core_BAO_FinancialTrxnTest extends CiviUnitTestCase { + public function setUp() { parent::setUp(); } @@ -120,7 +121,8 @@ public function testGetExPartialPaymentTrxn() { $paid = CRM_Core_BAO_FinancialTrxn::getTotalPayments($params['contribution_id']); $total = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $params['contribution_id'], 'total_amount'); $cmp = bccomp($total, $paid, 5); - if ($cmp == 0 || $cmp == -1) {// If paid amount is greater or equal to total amount + // If paid amount is greater or equal to total amount + if ($cmp == 0 || $cmp == -1) { civicrm_api3('Contribution', 'completetransaction', array('id' => $contribution['id'])); } diff --git a/tests/phpunit/CRM/Core/BAO/IMTest.php b/tests/phpunit/CRM/Core/BAO/IMTest.php index c1420a9e9f7b..c5700282ae1f 100644 --- a/tests/phpunit/CRM/Core/BAO/IMTest.php +++ b/tests/phpunit/CRM/Core/BAO/IMTest.php @@ -5,6 +5,7 @@ * @group headless */ class CRM_Core_BAO_IMTest extends CiviUnitTestCase { + public function setUp() { parent::setUp(); } diff --git a/tests/phpunit/CRM/Core/BAO/LocationTest.php b/tests/phpunit/CRM/Core/BAO/LocationTest.php index b7745fc5fa1c..548b3f71e100 100644 --- a/tests/phpunit/CRM/Core/BAO/LocationTest.php +++ b/tests/phpunit/CRM/Core/BAO/LocationTest.php @@ -38,17 +38,18 @@ * @group headless */ class CRM_Core_BAO_LocationTest extends CiviUnitTestCase { + public function setUp() { parent::setUp(); $this->quickCleanup(array( - 'civicrm_contact', - 'civicrm_address', - 'civicrm_loc_block', - 'civicrm_email', - 'civicrm_phone', - 'civicrm_im', - )); + 'civicrm_contact', + 'civicrm_address', + 'civicrm_loc_block', + 'civicrm_email', + 'civicrm_phone', + 'civicrm_im', + )); } /** diff --git a/tests/phpunit/CRM/Core/BAO/NavigationTest.php b/tests/phpunit/CRM/Core/BAO/NavigationTest.php index fab453d83e67..a85114172631 100644 --- a/tests/phpunit/CRM/Core/BAO/NavigationTest.php +++ b/tests/phpunit/CRM/Core/BAO/NavigationTest.php @@ -290,7 +290,7 @@ public function testFixNavigationMenu_inferIDs_deep() { public function testCheckPermissions() { $menuItem = [ 'permission' => 'access CiviCRM, access CiviContribute', - 'operator' => 'AND' + 'operator' => 'AND', ]; CRM_Core_BAO_ConfigSetting::enableComponent('CiviContribute'); CRM_Core_Config::singleton()->userPermissionClass->permissions = ['access CiviCRM', 'access CiviContribute']; diff --git a/tests/phpunit/CRM/Core/BAO/OpenIDTest.php b/tests/phpunit/CRM/Core/BAO/OpenIDTest.php index ffa02b7af137..313fbe0ac49a 100644 --- a/tests/phpunit/CRM/Core/BAO/OpenIDTest.php +++ b/tests/phpunit/CRM/Core/BAO/OpenIDTest.php @@ -5,6 +5,7 @@ * @group headless */ class CRM_Core_BAO_OpenIDTest extends CiviUnitTestCase { + public function tearDown() { // If we truncate only contact, then stale domain and openid records will be left. // If we truncate none of these tables, then contactDelete() will incrementally diff --git a/tests/phpunit/CRM/Core/BAO/OptionValueTest.php b/tests/phpunit/CRM/Core/BAO/OptionValueTest.php index a4598d1962e1..778812833cb6 100644 --- a/tests/phpunit/CRM/Core/BAO/OptionValueTest.php +++ b/tests/phpunit/CRM/Core/BAO/OptionValueTest.php @@ -64,7 +64,6 @@ public function testEnsureOptionValueExistsNewValue() { $this->fail('Should not have gotten this far'); } - /** * Ensure only one option value copes with disabled. * diff --git a/tests/phpunit/CRM/Core/BAO/RecurringEntityTest.php b/tests/phpunit/CRM/Core/BAO/RecurringEntityTest.php index 7ee88cefb4d2..199d46873e18 100644 --- a/tests/phpunit/CRM/Core/BAO/RecurringEntityTest.php +++ b/tests/phpunit/CRM/Core/BAO/RecurringEntityTest.php @@ -187,7 +187,8 @@ public function testEventGeneration() { //Create tell a friend for event $daoTellAFriend = new CRM_Friend_DAO_Friend(); $daoTellAFriend->entity_table = 'civicrm_event'; - $daoTellAFriend->entity_id = $daoEvent->id; // join with event + // join with event + $daoTellAFriend->entity_id = $daoEvent->id; $daoTellAFriend->title = 'Testing tell a friend'; $daoTellAFriend->is_active = 1; $daoTellAFriend->save(); diff --git a/tests/phpunit/CRM/Core/BAO/SettingTest.php b/tests/phpunit/CRM/Core/BAO/SettingTest.php index 53527d9a4cf4..b9bf5507d0ab 100644 --- a/tests/phpunit/CRM/Core/BAO/SettingTest.php +++ b/tests/phpunit/CRM/Core/BAO/SettingTest.php @@ -30,6 +30,7 @@ * @group headless */ class CRM_Core_BAO_SettingTest extends CiviUnitTestCase { + public function setUp() { parent::setUp(); global $civicrm_setting; @@ -143,7 +144,8 @@ public function testOnChange() { 'is_contact' => 0, 'description' => NULL, 'help_text' => NULL, - 'on_change' => array(// list of callbacks + // list of callbacks + 'on_change' => array( array(__CLASS__, '_testOnChange_onChangeExample'), ), ), diff --git a/tests/phpunit/CRM/Core/BAO/UFFieldTest.php b/tests/phpunit/CRM/Core/BAO/UFFieldTest.php index c745657fb6d2..24b6d2597b7e 100644 --- a/tests/phpunit/CRM/Core/BAO/UFFieldTest.php +++ b/tests/phpunit/CRM/Core/BAO/UFFieldTest.php @@ -45,25 +45,31 @@ public function testGetAvailable_byGid() { $fields = CRM_Core_BAO_UFField::getAvailableFields($ufGroupId); // Make sure that each entity has 1+ present field and 1+ missing (already-used) field - $this->assertFalse(isset($fields['Contact']['do_not_sms'])); // already used + // already used + $this->assertFalse(isset($fields['Contact']['do_not_sms'])); $this->assertEquals('city', $fields['Contact']['city']['name']); - $this->assertFalse(isset($fields['Individual']['first_name'])); // already used + // already used + $this->assertFalse(isset($fields['Individual']['first_name'])); $this->assertEquals('birth_date', $fields['Individual']['birth_date']['name']); $this->assertEquals('organization_name', $fields['Organization']['organization_name']['name']); $this->assertEquals('legal_name', $fields['Organization']['legal_name']['name']); - $this->assertFalse(isset($fields['Contribution']['amount_level'])); // already used + // already used + $this->assertFalse(isset($fields['Contribution']['amount_level'])); $this->assertEquals('cancel_reason', $fields['Contribution']['cancel_reason']['name']); - $this->assertFalse(isset($fields['Participant']['participant_note'])); // already used + // already used + $this->assertFalse(isset($fields['Participant']['participant_note'])); $this->assertEquals('participant_role', $fields['Participant']['participant_role']['name']); - $this->assertFalse(isset($fields['Membership']['join_date'])); // already used + // already used + $this->assertFalse(isset($fields['Membership']['join_date'])); $this->assertEquals('end_date', $fields['Membership']['membership_end_date']['name']); - $this->assertFalse(isset($fields['Activity']['activity_date_time'])); // already used + // already used + $this->assertFalse(isset($fields['Activity']['activity_date_time'])); $this->assertEquals('subject', $fields['Activity']['activity_subject']['name']); // Make sure that some of the blacklisted fields don't appear @@ -93,10 +99,12 @@ public function testGetAvailable_byGidDefaults() { $defaults = array('field_name' => array('Individual', 'first_name')); $fields = CRM_Core_BAO_UFField::getAvailableFields($ufGroupId, $defaults); - $this->assertFalse(isset($fields['Contact']['do_not_sms'])); // already used + // already used + $this->assertFalse(isset($fields['Contact']['do_not_sms'])); $this->assertEquals('city', $fields['Contact']['city']['name']); - $this->assertEquals('first_name', $fields['Individual']['first_name']['name']); // used by me + // used by me + $this->assertEquals('first_name', $fields['Individual']['first_name']['name']); $this->assertEquals('birth_date', $fields['Individual']['birth_date']['name']); } diff --git a/tests/phpunit/CRM/Core/CodeGen/FreshnessTest.php b/tests/phpunit/CRM/Core/CodeGen/FreshnessTest.php index bde3451d1e6f..d58bbddbf625 100644 --- a/tests/phpunit/CRM/Core/CodeGen/FreshnessTest.php +++ b/tests/phpunit/CRM/Core/CodeGen/FreshnessTest.php @@ -56,15 +56,24 @@ protected function createCodeGen() { $path = rtrim($GLOBALS['civicrm_root'], '/'); $genCode = new CRM_Core_CodeGen_Main( - $path . '/CRM/Core/DAO/', // $CoreDAOCodePath - $path . '/sql/', // $sqlCodePath - $path . '/', // $phpCodePath - $path . '/templates/', // $tplCodePath - NULL, // IGNORE, - CIVICRM_UF, // cms - NULL, // db version - $path . '/xml/schema/Schema.xml', // schema file - NULL // path to digest file + // $CoreDAOCodePath + $path . '/CRM/Core/DAO/', + // $sqlCodePath + $path . '/sql/', + // $phpCodePath + $path . '/', + // $tplCodePath + $path . '/templates/', + // IGNORE, + NULL, + // cms + CIVICRM_UF, + // db version + NULL, + // schema file + $path . '/xml/schema/Schema.xml', + // path to digest file + NULL ); return $genCode; } diff --git a/tests/phpunit/CRM/Core/CommunityMessagesTest.php b/tests/phpunit/CRM/Core/CommunityMessagesTest.php index 5073ec548e58..427a252f20b3 100644 --- a/tests/phpunit/CRM/Core/CommunityMessagesTest.php +++ b/tests/phpunit/CRM/Core/CommunityMessagesTest.php @@ -64,8 +64,10 @@ public static function initWebResponses() { 'invalid-ttl-document' => array( CRM_Utils_HttpClient::STATUS_OK, json_encode(array( - 'ttl' => 'z', // not an integer! - 'retry' => 'z', // not an integer! + // not an integer! + 'ttl' => 'z', + // not an integer! + 'retry' => 'z', 'messages' => array( array( 'markup' => '

    Invalid document

    ', @@ -206,7 +208,8 @@ public function testGetDocument_NewOK_CacheOK_UpdateOK() { $this->assertApproxEquals(strtotime('2013-03-01 10:10:00'), $doc2['expires'], self::APPROX_TIME_EQUALITY); // third try, $doc1 expired, update it - CRM_Utils_Time::setTime('2013-03-01 12:00:02'); // more than 2 hours later (DEFAULT_RETRY) + // more than 2 hours later (DEFAULT_RETRY) + CRM_Utils_Time::setTime('2013-03-01 12:00:02'); $communityMessages = new CRM_Core_CommunityMessages( $this->cache, $this->expectOneHttpRequest(self::$webResponses['second-valid-response']) @@ -248,7 +251,8 @@ public function testGetDocument_NewFailure_CacheOK_UpdateOK($badWebResponse) { $this->assertEquals($doc1['expires'], $doc2['expires']); // third try, $doc1 expired, try again, get a good response - CRM_Utils_Time::setTime('2013-03-01 12:00:02'); // more than 2 hours later (DEFAULT_RETRY) + // more than 2 hours later (DEFAULT_RETRY) + CRM_Utils_Time::setTime('2013-03-01 12:00:02'); $communityMessages = new CRM_Core_CommunityMessages( $this->cache, $this->expectOneHttpRequest(self::$webResponses['first-valid-response']) @@ -283,7 +287,8 @@ public function testGetDocument_NewOK_UpdateFailure_CacheOK_UpdateOK($badWebResp $this->assertApproxEquals(strtotime('2013-03-01 10:10:00'), $doc1['expires'], self::APPROX_TIME_EQUALITY); // second try, $doc1 has expired; bad response; keep old data - CRM_Utils_Time::setTime('2013-03-01 12:00:02'); // more than 2 hours later (DEFAULT_RETRY) + // more than 2 hours later (DEFAULT_RETRY) + CRM_Utils_Time::setTime('2013-03-01 12:00:02'); $communityMessages = new CRM_Core_CommunityMessages( $this->cache, $this->expectOneHttpRequest($badWebResponse) @@ -327,7 +332,8 @@ public function testPick_rand() { // randomly pick many times $trials = 80; - $freq = array(); // array($message => $count) + // array($message => $count) + $freq = array(); for ($i = 0; $i < $trials; $i++) { $message = $communityMessages->pick(); $freq[$message['markup']] = CRM_Utils_Array::value($message['markup'], $freq, 0) + 1; @@ -354,7 +360,8 @@ public function testPick_componentFilter() { // randomly pick many times $trials = 10; - $freq = array(); // array($message => $count) + // array($message => $count) + $freq = array(); for ($i = 0; $i < $trials; $i++) { $message = $communityMessages->pick(); $freq[$message['markup']] = CRM_Utils_Array::value($message['markup'], $freq, 0) + 1; diff --git a/tests/phpunit/CRM/Core/Config/MailerTest.php b/tests/phpunit/CRM/Core/Config/MailerTest.php index 64f94339cf3e..4db3883b8ba0 100644 --- a/tests/phpunit/CRM/Core/Config/MailerTest.php +++ b/tests/phpunit/CRM/Core/Config/MailerTest.php @@ -42,7 +42,7 @@ class CRM_Core_Config_MailerTest extends CiviUnitTestCase { /** * @var array (string=>int) Keep count of the #times different functions are called */ - var $calls; + public $calls; public function setUp() { $this->calls = array( @@ -55,11 +55,11 @@ public function setUp() { public function testHookAlterMailer() { $test = $this; $mockMailer = new CRM_Utils_FakeObject(array( - 'send' => function ($recipients, $headers, $body) use ($test) { - $test->calls['send']++; - $test->assertEquals(array('to@example.org'), $recipients); - $test->assertEquals('Subject Example', $headers['Subject']); - }, + 'send' => function ($recipients, $headers, $body) use ($test) { + $test->calls['send']++; + $test->assertEquals(array('to@example.org'), $recipients); + $test->assertEquals('Subject Example', $headers['Subject']); + }, )); CRM_Utils_Hook::singleton()->setHook('civicrm_alterMailer', diff --git a/tests/phpunit/CRM/Core/DAO/AllCoreTablesTest.php b/tests/phpunit/CRM/Core/DAO/AllCoreTablesTest.php index 6029a0c91e7a..9931ac026542 100644 --- a/tests/phpunit/CRM/Core/DAO/AllCoreTablesTest.php +++ b/tests/phpunit/CRM/Core/DAO/AllCoreTablesTest.php @@ -5,6 +5,7 @@ * @group headless */ class CRM_Core_DAO_AllCoreTablesTest extends CiviUnitTestCase { + public function testGetTableForClass() { $this->assertEquals('civicrm_email', CRM_Core_DAO_AllCoreTables::getTableForClass('CRM_Core_DAO_Email')); $this->assertEquals('civicrm_email', CRM_Core_DAO_AllCoreTables::getTableForClass('CRM_Core_BAO_Email')); diff --git a/tests/phpunit/CRM/Core/DAOConformanceTest.php b/tests/phpunit/CRM/Core/DAOConformanceTest.php index ea6ba085fbde..7c306862768f 100644 --- a/tests/phpunit/CRM/Core/DAOConformanceTest.php +++ b/tests/phpunit/CRM/Core/DAOConformanceTest.php @@ -25,7 +25,8 @@ public function testFieldsHaveTitles($class) { * Get all DAO classes. */ public function getAllDAO() { - $this->setUp(); // Ugh. Need full bootstrap to enumerate classes. + // Ugh. Need full bootstrap to enumerate classes. + $this->setUp(); $classList = CRM_Core_DAO_AllCoreTables::getClasses(); $return = array(); foreach ($classList as $class) { diff --git a/tests/phpunit/CRM/Core/DAOTest.php b/tests/phpunit/CRM/Core/DAOTest.php index 2d362709f799..397e54ec12b5 100644 --- a/tests/phpunit/CRM/Core/DAOTest.php +++ b/tests/phpunit/CRM/Core/DAOTest.php @@ -300,14 +300,16 @@ public function testMyISAMCheck() { $tempName = CRM_Core_DAO::createTempTableName('civicrm', FALSE); $this->assertEquals(0, CRM_Core_DAO::isDBMyISAM()); CRM_Core_DAO::executeQuery("CREATE TABLE $tempName (`id` int(10) unsigned NOT NULL) ENGINE = MyISAM"); - $this->assertEquals(0, CRM_Core_DAO::isDBMyISAM()); // Ignore temp tables + // Ignore temp tables + $this->assertEquals(0, CRM_Core_DAO::isDBMyISAM()); CRM_Core_DAO::executeQuery("DROP TABLE $tempName"); // A temp table should not raise flag (randomized naming). $tempName = CRM_Core_DAO::createTempTableName('civicrm', TRUE); $this->assertEquals(0, CRM_Core_DAO::isDBMyISAM()); CRM_Core_DAO::executeQuery("CREATE TABLE $tempName (`id` int(10) unsigned NOT NULL) ENGINE = MyISAM"); - $this->assertEquals(0, CRM_Core_DAO::isDBMyISAM()); // Ignore temp tables + // Ignore temp tables + $this->assertEquals(0, CRM_Core_DAO::isDBMyISAM()); CRM_Core_DAO::executeQuery("DROP TABLE $tempName"); } diff --git a/tests/phpunit/CRM/Core/I18n/LocaleTest.php b/tests/phpunit/CRM/Core/I18n/LocaleTest.php index 4d4bfbef9759..16690fbec47a 100644 --- a/tests/phpunit/CRM/Core/I18n/LocaleTest.php +++ b/tests/phpunit/CRM/Core/I18n/LocaleTest.php @@ -91,7 +91,7 @@ public function testUiLanguages() { $this->assertTreeEquals([ 'en_US' => 'English (United States)', 'fr_CA' => 'French (Canada)', - ], $result); + ], $result); CRM_Core_I18n::singleton()->setLocale('en_US'); CRM_Core_I18n_Schema::makeSinglelingual('en_US'); diff --git a/tests/phpunit/CRM/Core/I18n/SchemaTest.php b/tests/phpunit/CRM/Core/I18n/SchemaTest.php index ed5a78ce88a7..ec0574eb4a65 100644 --- a/tests/phpunit/CRM/Core/I18n/SchemaTest.php +++ b/tests/phpunit/CRM/Core/I18n/SchemaTest.php @@ -90,7 +90,7 @@ public function testI18nSchemaRewrite($table, $expectedRewrite) { // Test Currently skipped for civicrm_option_group and civicrm_event due to issues with the regex. // Agreed as not a blocker for CRM-20427 as an issue previously. if (!$skip_tests) { - $query6 = "SELECT " . '"' . "Fixed the the {$table} ticket" . '"'; + $query6 = "SELECT " . '"' . "Fixed the the {$table} ticket" . '"'; $new_query6 = CRM_Core_I18n_Schema::rewriteQuery($query6); $this->assertEquals($query6, $new_query6); } diff --git a/tests/phpunit/CRM/Core/InnoDBIndexerTest.php b/tests/phpunit/CRM/Core/InnoDBIndexerTest.php index e594e2d3ef67..60470e2ffd93 100644 --- a/tests/phpunit/CRM/Core/InnoDBIndexerTest.php +++ b/tests/phpunit/CRM/Core/InnoDBIndexerTest.php @@ -5,6 +5,7 @@ * @group headless */ class CRM_Core_InnoDBIndexerTest extends CiviUnitTestCase { + public function tearDown() { // May or may not cleanup well if there's a bug in the indexer. // This is better than nothing -- and better than duplicating the @@ -28,8 +29,10 @@ public function testHasDeclaredIndex() { $this->assertTrue($idx->hasDeclaredIndex('civicrm_contact', array('first_name', 'last_name'))); $this->assertTrue($idx->hasDeclaredIndex('civicrm_contact', array('last_name', 'first_name'))); - $this->assertTrue($idx->hasDeclaredIndex('civicrm_contact', array('first_name'))); // not sure if this is right behavior - $this->assertTrue($idx->hasDeclaredIndex('civicrm_contact', array('last_name'))); // not sure if this is right behavior + // not sure if this is right behavior + $this->assertTrue($idx->hasDeclaredIndex('civicrm_contact', array('first_name'))); + // not sure if this is right behavior + $this->assertTrue($idx->hasDeclaredIndex('civicrm_contact', array('last_name'))); $this->assertTrue($idx->hasDeclaredIndex('civicrm_contact', array('foo'))); $this->assertFalse($idx->hasDeclaredIndex('civicrm_contact', array('whiz'))); diff --git a/tests/phpunit/CRM/Core/ManagedEntitiesTest.php b/tests/phpunit/CRM/Core/ManagedEntitiesTest.php index da9da77bca7f..7e95163fa555 100644 --- a/tests/phpunit/CRM/Core/ManagedEntitiesTest.php +++ b/tests/phpunit/CRM/Core/ManagedEntitiesTest.php @@ -16,7 +16,7 @@ class CRM_Core_ManagedEntitiesTest extends CiviUnitTestCase { protected $adhocProvider; /** - * @var array(string $shortName => CRM_Core_Module $module) + * @var array(string */ protected $modules; @@ -173,7 +173,8 @@ public function testModifyDeclaration_UpdateNever() { // create first managed entity ('foo') $decls[] = array_merge($this->fixtures['com.example.one-foo'], array( - 'update' => 'never', // Policy is to never update after initial creation + // Policy is to never update after initial creation + 'update' => 'never', )); $me = new CRM_Core_ManagedEntities($this->modules, $decls); $me->reconcile(); @@ -281,7 +282,8 @@ public function testInvalidDeclarationModule() { // create first managed entity ('foo') $decls = array(); $decls[] = array( - 'module' => 'com.example.unknown', // erroneous + // erroneous + 'module' => 'com.example.unknown', 'name' => 'foo', 'entity' => 'CustomSearch', 'params' => array( @@ -308,7 +310,8 @@ public function testMissingName() { $decls = array(); $decls[] = array( 'module' => 'com.example.unknown', - 'name' => NULL, // erroneous + // erroneous + 'name' => NULL, 'entity' => 'CustomSearch', 'params' => array( 'version' => 3, @@ -335,7 +338,8 @@ public function testMissingEntity() { $decls[] = array( 'module' => 'com.example.unknown', 'name' => 'foo', - 'entity' => NULL, // erroneous + // erroneous + 'entity' => NULL, 'params' => array( 'version' => 3, 'class_name' => 'CRM_Example_One_Foo', diff --git a/tests/phpunit/CRM/Core/MenuTest.php b/tests/phpunit/CRM/Core/MenuTest.php index 1b6a7d311ae6..fcb4c7ec6c60 100644 --- a/tests/phpunit/CRM/Core/MenuTest.php +++ b/tests/phpunit/CRM/Core/MenuTest.php @@ -57,10 +57,14 @@ public function testReadXML_IDS() { $this->assertEquals(array(), $menu['civicrm/foo/bar']['ids_arguments']['html']); $idsConfig = CRM_Core_IDS::createRouteConfig($menu['civicrm/foo/bar']); - $this->assertTrue(in_array('alpha', $idsConfig['General']['json'])); // XML - $this->assertTrue(in_array('beta', $idsConfig['General']['json'])); // XML - $this->assertTrue(in_array('gamma', $idsConfig['General']['exceptions'])); // XML - $this->assertTrue(in_array('thankyou_text', $idsConfig['General']['exceptions'])); // Inherited + // XML + $this->assertTrue(in_array('alpha', $idsConfig['General']['json'])); + // XML + $this->assertTrue(in_array('beta', $idsConfig['General']['json'])); + // XML + $this->assertTrue(in_array('gamma', $idsConfig['General']['exceptions'])); + // Inherited + $this->assertTrue(in_array('thankyou_text', $idsConfig['General']['exceptions'])); } /** @@ -73,7 +77,7 @@ public function testModuleData() { $this->assertFalse(isset($item['ids_arguments']['exceptions'])); $this->assertFalse(isset($item['whimsy'])); - CRM_Utils_Hook::singleton()->setHook('civicrm_alterMenu', function(&$items){ + CRM_Utils_Hook::singleton()->setHook('civicrm_alterMenu', function(&$items) { $items['civicrm/case']['ids_arguments']['exceptions'][] = 'foobar'; $items['civicrm/case']['whimsy'] = 'godliness'; }); @@ -88,7 +92,8 @@ public function testModuleData() { * @return array */ public function pathArguments() { - $cases = array(); // array(0 => string $input, 1 => array $expectedOutput) + // array(0 => string $input, 1 => array $expectedOutput) + $cases = array(); //$cases[] = array(NULL, array()); //$cases[] = array('', array()); //$cases[] = array('freestanding', array('freestanding' => NULL)); diff --git a/tests/phpunit/CRM/Core/OptionGroupTest.php b/tests/phpunit/CRM/Core/OptionGroupTest.php index d5309f0bf988..340756d0dbb2 100644 --- a/tests/phpunit/CRM/Core/OptionGroupTest.php +++ b/tests/phpunit/CRM/Core/OptionGroupTest.php @@ -91,7 +91,6 @@ public function testsOptionGroupDataType($optionGroup, $expectedDataType) { } } - public function emailAddressTests() { $tests[] = array('"Name"', '"Name" '); $tests[] = array('"Name" ', '"Name" '); @@ -99,7 +98,6 @@ public function emailAddressTests() { return $tests; } - /** * @dataProvider emailAddressTests */ diff --git a/tests/phpunit/CRM/Core/Page/AJAXTest.php b/tests/phpunit/CRM/Core/Page/AJAXTest.php index 607906977688..4ba11db870b1 100644 --- a/tests/phpunit/CRM/Core/Page/AJAXTest.php +++ b/tests/phpunit/CRM/Core/Page/AJAXTest.php @@ -5,6 +5,7 @@ * @group headless */ class CRM_Core_Page_AJAXTest extends CiviUnitTestCase { + public function testCheckAuthz() { $cases = array(); diff --git a/tests/phpunit/CRM/Core/Page/RedirectTest.php b/tests/phpunit/CRM/Core/Page/RedirectTest.php index 686665df9261..85514f6dd052 100644 --- a/tests/phpunit/CRM/Core/Page/RedirectTest.php +++ b/tests/phpunit/CRM/Core/Page/RedirectTest.php @@ -10,6 +10,7 @@ class CRM_Core_Page_RedirectTest extends CiviUnitTestCase { * * @return array */ + /** * @return array */ diff --git a/tests/phpunit/CRM/Core/Payment/AuthorizeNetIPNTest.php b/tests/phpunit/CRM/Core/Payment/AuthorizeNetIPNTest.php index 300f6324ff83..0c302a5b4133 100644 --- a/tests/phpunit/CRM/Core/Payment/AuthorizeNetIPNTest.php +++ b/tests/phpunit/CRM/Core/Payment/AuthorizeNetIPNTest.php @@ -33,6 +33,7 @@ public function setUp() { public function tearDown() { $this->quickCleanUpFinancialEntities(); } + /** * Ensure recurring contributions from Contribution Pages * with receipt turned off don't send a receipt. @@ -131,9 +132,9 @@ public function testIPNPaymentRecurSuccess() { $IPN = new CRM_Core_Payment_AuthorizeNetIPN($this->getRecurSubsequentTransaction()); $IPN->main(); $contribution = $this->callAPISuccess('contribution', 'get', array( - 'contribution_recur_id' => $this->_contributionRecurID, - 'sequential' => 1, - )); + 'contribution_recur_id' => $this->_contributionRecurID, + 'sequential' => 1, + )); $this->assertEquals(2, $contribution['count']); $this->assertEquals('second_one', $contribution['values'][1]['trxn_id']); $this->assertEquals(date('Y-m-d'), date('Y-m-d', strtotime($contribution['values'][1]['receive_date']))); @@ -184,7 +185,6 @@ public function testIPNPaymentRecurSuccessSuppliedReceiveDate() { $this->assertEquals('2010-07-01', date('Y-m-d', strtotime($contribution['values'][1]['receive_date']))); } - /** * Test IPN response updates contribution_recur & contribution for first & second contribution */ @@ -202,9 +202,9 @@ public function testIPNPaymentMembershipRecurSuccess() { $IPN = new CRM_Core_Payment_AuthorizeNetIPN($this->getRecurSubsequentTransaction()); $IPN->main(); $contribution = $this->callAPISuccess('contribution', 'get', array( - 'contribution_recur_id' => $this->_contributionRecurID, - 'sequential' => 1, - )); + 'contribution_recur_id' => $this->_contributionRecurID, + 'sequential' => 1, + )); $this->assertEquals(2, $contribution['count']); // Ensure both contributions are coded as credit card contributions. $this->assertEquals(1, $contribution['values'][0]['payment_instrument_id']); @@ -212,9 +212,9 @@ public function testIPNPaymentMembershipRecurSuccess() { $this->assertEquals('second_one', $contribution['values'][1]['trxn_id']); $this->callAPISuccessGetSingle('membership_payment', array('contribution_id' => $contribution['values'][1]['id'])); $this->callAPISuccessGetSingle('line_item', array( - 'contribution_id' => $contribution['values'][1]['id'], - 'entity_table' => 'civicrm_membership', - )); + 'contribution_id' => $contribution['values'][1]['id'], + 'entity_table' => 'civicrm_membership', + )); } /** diff --git a/tests/phpunit/CRM/Core/Payment/AuthorizeNetTest.php b/tests/phpunit/CRM/Core/Payment/AuthorizeNetTest.php index 080a8d720d64..4a1e48c9087a 100644 --- a/tests/phpunit/CRM/Core/Payment/AuthorizeNetTest.php +++ b/tests/phpunit/CRM/Core/Payment/AuthorizeNetTest.php @@ -53,7 +53,7 @@ public function tearDown() { * Test works but not both due to some form of caching going on in the SmartySingleton */ public function testCreateSingleNowDated() { - $firstName = 'John_' . substr(sha1(rand()), 0, 7) . uniqid(); + $firstName = 'John_' . substr(sha1(rand()), 0, 7) . uniqid(); $lastName = 'Smith_' . substr(sha1(rand()), 0, 7) . uniqid(); $nameParams = array('first_name' => $firstName, 'last_name' => $lastName); $contactId = $this->individualCreate($nameParams); diff --git a/tests/phpunit/CRM/Core/Payment/BaseIPNTest.php b/tests/phpunit/CRM/Core/Payment/BaseIPNTest.php index 20598d4712ec..a1e60737065e 100644 --- a/tests/phpunit/CRM/Core/Payment/BaseIPNTest.php +++ b/tests/phpunit/CRM/Core/Payment/BaseIPNTest.php @@ -140,8 +140,8 @@ public function testLoadMembershipObjectsNoLeakage() { $this->ids['contact'] = $this->_contactId = $this->individualCreate(array( 'first_name' => 'Donald', 'last_name' => 'Duck', - 'email' => 'the-don@duckville.com, - ')); + 'email' => 'the-don@duckville.com', + )); $contribution = $this->callAPISuccess('contribution', 'create', array_merge($this->_contributionParams, array('invoice_id' => 'abc'))); $this->_contributionId = $contribution['id']; $this->_setUpMembershipObjects(); @@ -273,11 +273,10 @@ public function testsendMailParticipantObjectsCheckLog() { $this->IPN->loadObjects($this->input, $this->ids, $this->objects, FALSE, $this->_processorId); $this->IPN->sendMail($this->input, $this->ids, $this->objects, $values, FALSE, FALSE); $mut->checkMailLog(array( - 'Thank you for your participation', - 'Annual CiviCRM meet', - 'Mr. Anthony Anderson II', - ) - ); + 'Thank you for your participation', + 'Annual CiviCRM meet', + 'Mr. Anthony Anderson II', + )); $mut->stop(); } diff --git a/tests/phpunit/CRM/Core/Payment/PayPalIPNTest.php b/tests/phpunit/CRM/Core/Payment/PayPalIPNTest.php index 3f1b49dda6ba..126bc6cb6f2c 100644 --- a/tests/phpunit/CRM/Core/Payment/PayPalIPNTest.php +++ b/tests/phpunit/CRM/Core/Payment/PayPalIPNTest.php @@ -135,9 +135,9 @@ public function testIPNPaymentRecurSuccess() { $paypalIPN = new CRM_Core_Payment_PayPalIPN($this->getPaypalRecurSubsequentTransaction()); $paypalIPN->main(); $contributions = $this->callAPISuccess('contribution', 'get', array( - 'contribution_recur_id' => $this->_contributionRecurID, - 'sequential' => 1, - )); + 'contribution_recur_id' => $this->_contributionRecurID, + 'sequential' => 1, + )); $this->assertEquals(2, $contributions['count']); $contribution2 = $contributions['values'][1]; $this->assertEquals('secondone', $contribution2['trxn_id']); @@ -177,19 +177,19 @@ public function testIPNPaymentMembershipRecurSuccess() { $renewedMembershipEndDate = $this->membershipRenewalDate($durationUnit, $membershipEndDate); $this->assertEquals($renewedMembershipEndDate, $this->callAPISuccessGetValue('membership', array('return' => 'end_date'))); $contribution = $this->callAPISuccess('contribution', 'get', array( - 'contribution_recur_id' => $this->_contributionRecurID, - 'sequential' => 1, - )); + 'contribution_recur_id' => $this->_contributionRecurID, + 'sequential' => 1, + )); $this->assertEquals(2, $contribution['count']); $this->assertEquals('secondone', $contribution['values'][1]['trxn_id']); $this->callAPISuccessGetCount('line_item', array( - 'entity_id' => $this->ids['membership'], - 'entity_table' => 'civicrm_membership', - ), 2); + 'entity_id' => $this->ids['membership'], + 'entity_table' => 'civicrm_membership', + ), 2); $this->callAPISuccessGetSingle('line_item', array( - 'contribution_id' => $contribution['values'][1]['id'], - 'entity_table' => 'civicrm_membership', - )); + 'contribution_id' => $contribution['values'][1]['id'], + 'entity_table' => 'civicrm_membership', + )); $this->callAPISuccessGetSingle('membership_payment', array('contribution_id' => $contribution['values'][1]['id'])); } diff --git a/tests/phpunit/CRM/Core/Payment/PayPalProIPNTest.php b/tests/phpunit/CRM/Core/Payment/PayPalProIPNTest.php index 949d3aa35c89..f1cb8d2919ce 100644 --- a/tests/phpunit/CRM/Core/Payment/PayPalProIPNTest.php +++ b/tests/phpunit/CRM/Core/Payment/PayPalProIPNTest.php @@ -52,12 +52,11 @@ public function setUp() { $this->_paymentProcessorID = $this->paymentProcessorCreate(array('is_test' => 0)); $this->_contactID = $this->individualCreate(); $contributionPage = $this->callAPISuccess('contribution_page', 'create', array( - 'title' => "Test Contribution Page", - 'financial_type_id' => $this->_financialTypeID, - 'currency' => 'USD', - 'payment_processor' => $this->_paymentProcessorID, - ) - ); + 'title' => "Test Contribution Page", + 'financial_type_id' => $this->_financialTypeID, + 'currency' => 'USD', + 'payment_processor' => $this->_paymentProcessorID, + )); $this->_contributionPageID = $contributionPage['id']; } @@ -90,9 +89,9 @@ public function testIPNPaymentRecurSuccess() { $paypalIPN = new CRM_Core_Payment_PayPalProIPN($this->getPaypalProRecurSubsequentTransaction()); $paypalIPN->main(); $contribution = $this->callAPISuccess('contribution', 'get', array( - 'contribution_recur_id' => $this->_contributionRecurID, - 'sequential' => 1, - )); + 'contribution_recur_id' => $this->_contributionRecurID, + 'sequential' => 1, + )); $this->assertEquals(2, $contribution['count']); $this->assertEquals('secondone', $contribution['values'][1]['trxn_id']); $this->assertEquals('Debit Card', $contribution['values'][1]['payment_instrument']); @@ -121,19 +120,19 @@ public function testIPNPaymentMembershipRecurSuccess() { $renewedMembershipEndDate = $this->membershipRenewalDate($durationUnit, $membershipEndDate); $this->assertEquals($renewedMembershipEndDate, $this->callAPISuccessGetValue('membership', array('return' => 'end_date'))); $contribution = $this->callAPISuccess('contribution', 'get', array( - 'contribution_recur_id' => $this->_contributionRecurID, - 'sequential' => 1, - )); + 'contribution_recur_id' => $this->_contributionRecurID, + 'sequential' => 1, + )); $this->assertEquals(2, $contribution['count']); $this->assertEquals('secondone', $contribution['values'][1]['trxn_id']); $this->callAPISuccessGetCount('line_item', array( - 'entity_id' => $this->ids['membership'], - 'entity_table' => 'civicrm_membership', - ), 2); + 'entity_id' => $this->ids['membership'], + 'entity_table' => 'civicrm_membership', + ), 2); $this->callAPISuccessGetSingle('line_item', array( - 'contribution_id' => $contribution['values'][1]['id'], - 'entity_table' => 'civicrm_membership', - )); + 'contribution_id' => $contribution['values'][1]['id'], + 'entity_table' => 'civicrm_membership', + )); $this->callAPISuccessGetSingle('membership_payment', array('contribution_id' => $contribution['values'][1]['id'])); } @@ -161,9 +160,9 @@ public function testIPNPaymentCRM13743() { $paypalIPN = new CRM_Core_Payment_PayPalProIPN($this->getPaypalProRecurSubsequentTransaction()); $paypalIPN->main(); $contribution = $this->callAPISuccess('contribution', 'get', array( - 'contribution_recur_id' => $this->_contributionRecurID, - 'sequential' => 1, - )); + 'contribution_recur_id' => $this->_contributionRecurID, + 'sequential' => 1, + )); $this->assertEquals(1, $contribution['count']); $this->assertEquals('secondone', $contribution['values'][0]['trxn_id']); $this->assertEquals(strtotime('03:59:05 Jul 14, 2013 PDT'), strtotime($contribution['values'][0]['receive_date'])); @@ -397,10 +396,10 @@ public function getPaypalExpressRecurSubscriptionConfirmation() { 'residence_country' => 'GB', 'initial_payment_amount' => '0.00', 'rp_invoice_id' => 'i=' . $this->_invoiceID - . '&m=&c=' . $this->_contributionID - . '&r=' . $this->_contributionRecurID - . '&b=' . $this->_contactID - . '&p=' . $this->_contributionPageID, + . '&m=&c=' . $this->_contributionID + . '&r=' . $this->_contributionRecurID + . '&b=' . $this->_contactID + . '&p=' . $this->_contributionPageID, 'currency_code' => 'GBP', 'time_created' => '12:39:01 May 09, 2018 PDT', 'verify_sign' => 'AUg223oCjn4HgJXKkrICawXQ3fyUA2gAd1.f1IPJ4r.9sln-nWcB-EJG', diff --git a/tests/phpunit/CRM/Core/PseudoConstantTest.php b/tests/phpunit/CRM/Core/PseudoConstantTest.php index e924e6240dfc..100f317ecb1e 100644 --- a/tests/phpunit/CRM/Core/PseudoConstantTest.php +++ b/tests/phpunit/CRM/Core/PseudoConstantTest.php @@ -1078,16 +1078,16 @@ public function testContactTypes() { $this->assertEquals($byName, $result); // But we can also fetch by ID $result = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'contact_type', array( - 'keyColumn' => 'id', - 'labelColumn' => 'name', - )); + 'keyColumn' => 'id', + 'labelColumn' => 'name', + )); $this->assertEquals($byId, $result); // Make sure flip param works $result = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'contact_type', array( - 'keyColumn' => 'id', - 'labelColumn' => 'name', - 'flip' => TRUE, - )); + 'keyColumn' => 'id', + 'labelColumn' => 'name', + 'flip' => TRUE, + )); $this->assertEquals(array_flip($byId), $result); } @@ -1099,14 +1099,14 @@ public function testGetTaxRates() { 'is_active' => 1, )); $financialAccount = $this->callAPISuccess('financial_account', 'create', array( - 'name' => 'Test Tax financial account ', - 'contact_id' => $contact, - 'financial_account_type_id' => 2, - 'is_tax' => 1, - 'tax_rate' => 5.00, - 'is_reserved' => 0, - 'is_active' => 1, - 'is_default' => 0, + 'name' => 'Test Tax financial account ', + 'contact_id' => $contact, + 'financial_account_type_id' => 2, + 'is_tax' => 1, + 'tax_rate' => 5.00, + 'is_reserved' => 0, + 'is_active' => 1, + 'is_default' => 0, )); $financialTypeId = $financialType['id']; $financialAccountId = $financialAccount['id']; diff --git a/tests/phpunit/CRM/Core/RegionTest.php b/tests/phpunit/CRM/Core/RegionTest.php index 3f4956eba134..b4ed3894edef 100644 --- a/tests/phpunit/CRM/Core/RegionTest.php +++ b/tests/phpunit/CRM/Core/RegionTest.php @@ -5,6 +5,7 @@ * @group headless */ class CRM_Core_RegionTest extends CiviUnitTestCase { + public function setUp() { parent::setUp(); require_once 'CRM/Core/Smarty.php'; diff --git a/tests/phpunit/CRM/Core/ResourcesTest.php b/tests/phpunit/CRM/Core/ResourcesTest.php index 8feda0079623..c9b76195eea2 100644 --- a/tests/phpunit/CRM/Core/ResourcesTest.php +++ b/tests/phpunit/CRM/Core/ResourcesTest.php @@ -77,12 +77,14 @@ public function tearDown() { public function testAddScriptFile() { $this->res ->addScriptFile('com.example.ext', 'foo%20bar.js', 0, 'testAddScriptFile') - ->addScriptFile('com.example.ext', 'foo%20bar.js', 0, 'testAddScriptFile')// extra + // extra + ->addScriptFile('com.example.ext', 'foo%20bar.js', 0, 'testAddScriptFile') ->addScriptFile('civicrm', 'foo%20bar.js', 0, 'testAddScriptFile'); $smarty = CRM_Core_Smarty::singleton(); $actual = $smarty->fetch('string:{crmRegion name=testAddScriptFile}{/crmRegion}'); - $expected = "" // stable ordering: alphabetical by (snippet.weight,snippet.name) + // stable ordering: alphabetical by (snippet.weight,snippet.name) + $expected = "" . "\n" . "\n"; $this->assertEquals($expected, $actual); @@ -108,12 +110,14 @@ public function testAddScriptFile() { public function testAddScriptURL() { $this->res ->addScriptUrl('/whiz/foo%20bar.js', 0, 'testAddScriptURL') - ->addScriptUrl('/whiz/foo%20bar.js', 0, 'testAddScriptURL')// extra + // extra + ->addScriptUrl('/whiz/foo%20bar.js', 0, 'testAddScriptURL') ->addScriptUrl('/whizbang/foo%20bar.js', 0, 'testAddScriptURL'); $smarty = CRM_Core_Smarty::singleton(); $actual = $smarty->fetch('string:{crmRegion name=testAddScriptURL}{/crmRegion}'); - $expected = "" // stable ordering: alphabetical by (snippet.weight,snippet.name) + // stable ordering: alphabetical by (snippet.weight,snippet.name) + $expected = "" . "\n" . "\n"; $this->assertEquals($expected, $actual); @@ -218,7 +222,8 @@ public function testCrmJS() { $this->assertEquals('', $actual); $actual = $smarty->fetch('string:{crmRegion name=testCrmJS}{/crmRegion}'); - $expected = "" // stable ordering: alphabetical by (snippet.weight,snippet.name) + // stable ordering: alphabetical by (snippet.weight,snippet.name) + $expected = "" . "\n" . "\n"; $this->assertEquals($expected, $actual); @@ -227,12 +232,14 @@ public function testCrmJS() { public function testAddStyleFile() { $this->res ->addStyleFile('com.example.ext', 'foo%20bar.css', 0, 'testAddStyleFile') - ->addStyleFile('com.example.ext', 'foo%20bar.css', 0, 'testAddStyleFile')// extra + // extra + ->addStyleFile('com.example.ext', 'foo%20bar.css', 0, 'testAddStyleFile') ->addStyleFile('civicrm', 'foo%20bar.css', 0, 'testAddStyleFile'); $smarty = CRM_Core_Smarty::singleton(); $actual = $smarty->fetch('string:{crmRegion name=testAddStyleFile}{/crmRegion}'); - $expected = "" // stable ordering: alphabetical by (snippet.weight,snippet.name) + // stable ordering: alphabetical by (snippet.weight,snippet.name) + $expected = "" . "\n" . "\n"; $this->assertEquals($expected, $actual); @@ -241,12 +248,14 @@ public function testAddStyleFile() { public function testAddStyleURL() { $this->res ->addStyleUrl('/whiz/foo%20bar.css', 0, 'testAddStyleURL') - ->addStyleUrl('/whiz/foo%20bar.css', 0, 'testAddStyleURL')// extra + // extra + ->addStyleUrl('/whiz/foo%20bar.css', 0, 'testAddStyleURL') ->addStyleUrl('/whizbang/foo%20bar.css', 0, 'testAddStyleURL'); $smarty = CRM_Core_Smarty::singleton(); $actual = $smarty->fetch('string:{crmRegion name=testAddStyleURL}{/crmRegion}'); - $expected = "" // stable ordering: alphabetical by (snippet.weight,snippet.name) + // stable ordering: alphabetical by (snippet.weight,snippet.name) + $expected = "" . "\n" . "\n"; $this->assertEquals($expected, $actual); @@ -275,7 +284,8 @@ public function testCrmCSS() { $this->assertEquals('', $actual); $actual = $smarty->fetch('string:{crmRegion name=testCrmCSS}{/crmRegion}'); - $expected = "" // stable ordering: alphabetical by (snippet.weight,snippet.name) + // stable ordering: alphabetical by (snippet.weight,snippet.name) + $expected = "" . "\n" . "\n"; $this->assertEquals($expected, $actual); diff --git a/tests/phpunit/CRM/Core/Smarty/plugins/CrmMoneyTest.php b/tests/phpunit/CRM/Core/Smarty/plugins/CrmMoneyTest.php index 1a2f62f7fa62..e2e2e6a40a92 100644 --- a/tests/phpunit/CRM/Core/Smarty/plugins/CrmMoneyTest.php +++ b/tests/phpunit/CRM/Core/Smarty/plugins/CrmMoneyTest.php @@ -5,6 +5,7 @@ * @group headless */ class CRM_Core_Smarty_plugins_CrmMoneyTest extends CiviUnitTestCase { + public function setUp() { parent::setUp(); require_once 'CRM/Core/Smarty.php'; @@ -23,7 +24,7 @@ public function moneyCases() { $cases[] = ['€ 1,234.00', '{assign var="amount" value="1234.00"}{$amount|crmMoney:EUR}']; $cases[] = [ '$ ', - '{assign var="amount" value=\'\'}{$amount|crmMoney:USD}' + '{assign var="amount" value=\'\'}{$amount|crmMoney:USD}', ]; return $cases; } diff --git a/tests/phpunit/CRM/Core/Smarty/plugins/CrmScopeTest.php b/tests/phpunit/CRM/Core/Smarty/plugins/CrmScopeTest.php index 79ddcbcff4d1..54ac3a2e8de9 100644 --- a/tests/phpunit/CRM/Core/Smarty/plugins/CrmScopeTest.php +++ b/tests/phpunit/CRM/Core/Smarty/plugins/CrmScopeTest.php @@ -5,6 +5,7 @@ * @group headless */ class CRM_Core_Smarty_plugins_CrmScopeTest extends CiviUnitTestCase { + public function setUp() { parent::setUp(); require_once 'CRM/Core/Smarty.php'; diff --git a/tests/phpunit/CRM/Core/TransactionTest.php b/tests/phpunit/CRM/Core/TransactionTest.php index 43d109a081d0..5836f791bb5f 100644 --- a/tests/phpunit/CRM/Core/TransactionTest.php +++ b/tests/phpunit/CRM/Core/TransactionTest.php @@ -84,8 +84,10 @@ public function testBatchRollback($createStyle, $commitStyle) { $this->runBatch( 'reuse-tx', array( - array('reuse-tx', $createStyle, $commitStyle), // cid 0 - array('reuse-tx', $createStyle, $commitStyle), // cid 1 + // cid 0 + array('reuse-tx', $createStyle, $commitStyle), + // cid 1 + array('reuse-tx', $createStyle, $commitStyle), ), array(0 => TRUE, 1 => TRUE), 'rollback' @@ -110,9 +112,12 @@ public function testMixedBatchCommit_nesting($createStyle, $commitStyle) { $this->runBatch( 'reuse-tx', array( - array('nest-tx', $createStyle, $commitStyle), // cid 0 - array('nest-tx', $createStyle, 'rollback'), // cid 1 - array('nest-tx', $createStyle, $commitStyle), // cid 2 + // cid 0 + array('nest-tx', $createStyle, $commitStyle), + // cid 1 + array('nest-tx', $createStyle, 'rollback'), + // cid 2 + array('nest-tx', $createStyle, $commitStyle), ), array(0 => TRUE, 1 => FALSE, 2 => TRUE), $commitStyle @@ -137,9 +142,12 @@ public function testMixedBatchCommit_reuse($createStyle, $commitStyle) { $this->runBatch( 'reuse-tx', array( - array('reuse-tx', $createStyle, $commitStyle), // cid 0 - array('reuse-tx', $createStyle, 'rollback'), // cid 1 - array('reuse-tx', $createStyle, $commitStyle), // cid 2 + // cid 0 + array('reuse-tx', $createStyle, $commitStyle), + // cid 1 + array('reuse-tx', $createStyle, 'rollback'), + // cid 2 + array('reuse-tx', $createStyle, $commitStyle), ), array(0 => TRUE, 1 => TRUE, 2 => TRUE), $commitStyle @@ -164,9 +172,12 @@ public function testMixedBatchRollback_nesting($createStyle, $commitStyle) { $this->runBatch( 'reuse-tx', array( - array('nest-tx', $createStyle, $commitStyle), // cid 0 - array('nest-tx', $createStyle, 'rollback'), // cid 1 - array('nest-tx', $createStyle, $commitStyle), // cid 2 + // cid 0 + array('nest-tx', $createStyle, $commitStyle), + // cid 1 + array('nest-tx', $createStyle, 'rollback'), + // cid 2 + array('nest-tx', $createStyle, $commitStyle), ), array(0 => TRUE, 1 => FALSE, 2 => TRUE), 'rollback' @@ -208,21 +219,21 @@ public function testCallback_commit() { $tx = new CRM_Core_Transaction(); CRM_Core_Transaction::addCallback(CRM_Core_Transaction::PHASE_PRE_COMMIT, array($this, '_preCommit'), array( - 'qwe', - 'rty', - )); + 'qwe', + 'rty', + )); CRM_Core_Transaction::addCallback(CRM_Core_Transaction::PHASE_POST_COMMIT, array($this, '_postCommit'), array( - 'uio', - 'p[]', - )); + 'uio', + 'p[]', + )); CRM_Core_Transaction::addCallback(CRM_Core_Transaction::PHASE_PRE_ROLLBACK, array( - $this, - '_preRollback', - ), array('asd', 'fgh')); + $this, + '_preRollback', + ), array('asd', 'fgh')); CRM_Core_Transaction::addCallback(CRM_Core_Transaction::PHASE_POST_ROLLBACK, array( - $this, - '_postRollback', - ), array('jkl', ';')); + $this, + '_postRollback', + ), array('jkl', ';')); CRM_Core_DAO::executeQuery('UPDATE civicrm_contact SET id = 100 WHERE id = 100'); @@ -236,21 +247,21 @@ public function testCallback_rollback() { $tx = new CRM_Core_Transaction(); CRM_Core_Transaction::addCallback(CRM_Core_Transaction::PHASE_PRE_COMMIT, array($this, '_preCommit'), array( - 'ewq', - 'ytr', - )); + 'ewq', + 'ytr', + )); CRM_Core_Transaction::addCallback(CRM_Core_Transaction::PHASE_POST_COMMIT, array($this, '_postCommit'), array( - 'oiu', - '][p', - )); + 'oiu', + '][p', + )); CRM_Core_Transaction::addCallback(CRM_Core_Transaction::PHASE_PRE_ROLLBACK, array( - $this, - '_preRollback', - ), array('dsa', 'hgf')); + $this, + '_preRollback', + ), array('dsa', 'hgf')); CRM_Core_Transaction::addCallback(CRM_Core_Transaction::PHASE_POST_ROLLBACK, array( - $this, - '_postRollback', - ), array('lkj', ';')); + $this, + '_postRollback', + ), array('lkj', ';')); CRM_Core_DAO::executeQuery('UPDATE civicrm_contact SET id = 100 WHERE id = 100'); $tx->rollback(); @@ -287,7 +298,8 @@ public function testRun_ok($createStyle, $commitStyle) { public function testRun_exception($createStyle, $commitStyle) { $tx = new CRM_Core_Transaction(); $test = $this; - $e = NULL; // Exception + // Exception + $e = NULL; try { CRM_Core_Transaction::create(TRUE)->run(function ($tx) use (&$test, $createStyle, $commitStyle) { $test->createContactWithTransaction('nest-tx', $createStyle, $commitStyle); diff --git a/tests/phpunit/CRM/Dedupe/MergerTest.php b/tests/phpunit/CRM/Dedupe/MergerTest.php index e98380a807f3..96f440873f98 100644 --- a/tests/phpunit/CRM/Dedupe/MergerTest.php +++ b/tests/phpunit/CRM/Dedupe/MergerTest.php @@ -153,7 +153,8 @@ public function testBatchMergeSelectedDuplicates() { $this->assertEquals(count($foundDupes), 3, 'Check Individual-Supervised dupe rule for dupesInGroup().'); // Run dedupe finder as the browser would - $_SERVER['REQUEST_METHOD'] = 'GET'; //avoid invalid key error + //avoid invalid key error + $_SERVER['REQUEST_METHOD'] = 'GET'; $object = new CRM_Contact_Page_DedupeFind(); $object->set('gid', $this->_groupId); $object->set('rgid', $dao->id); @@ -216,7 +217,8 @@ public function testBatchMergeAllDuplicates() { $this->assertEquals(count($foundDupes), 3, 'Check Individual-Supervised dupe rule for dupesInGroup().'); // Run dedupe finder as the browser would - $_SERVER['REQUEST_METHOD'] = 'GET'; //avoid invalid key error + //avoid invalid key error + $_SERVER['REQUEST_METHOD'] = 'GET'; $object = new CRM_Contact_Page_DedupeFind(); $object->set('gid', $this->_groupId); $object->set('rgid', $dao->id); @@ -510,7 +512,7 @@ public function testMergeMembership() { //Merge and move the mem to the main contact. $this->mergeContacts($originalContactID, $duplicateContactID, [ 'move_rel_table_memberships' => 1, - 'operation' => ['move_rel_table_memberships' => ['add' => 1]] + 'operation' => ['move_rel_table_memberships' => ['add' => 1]], ]); //Check if membership is correctly transferred to original contact. @@ -535,8 +537,10 @@ public function testCustomDataOverwrite() { $this->setupMatchData(); $originalContactID = $this->contacts[0]['id']; - $duplicateContactID1 = $this->contacts[1]['id']; // used as duplicate contact in 1st use-case - $duplicateContactID2 = $this->contacts[2]['id']; // used as duplicate contact in 2nd use-case + // used as duplicate contact in 1st use-case + $duplicateContactID1 = $this->contacts[1]['id']; + // used as duplicate contact in 2nd use-case + $duplicateContactID2 = $this->contacts[2]['id']; // update the text custom field for original contact with value 'abc' $this->callAPISuccess('Contact', 'create', array( @@ -561,7 +565,7 @@ public function testCustomDataOverwrite() { /*** USE-CASE 1: DO NOT OVERWRITE CUSTOM FIELD VALUE **/ $this->mergeContacts($originalContactID, $duplicateContactID1, array( - "move_{$customFieldName}" => NULL, + "move_{$customFieldName}" => NULL, )); $this->assertCustomFieldValue($originalContactID, 'abc', $customFieldName); @@ -818,7 +822,6 @@ public function setupMatchData() { } } - /** * Get the list of tables that refer to the CID. * @@ -958,7 +961,8 @@ public function getStaticCIDRefs() { ), 'civicrm_participant' => array( 0 => 'contact_id', - 1 => 'transferred_to_contact_id', //CRM-16761 + //CRM-16761 + 1 => 'transferred_to_contact_id', ), 'civicrm_payment_token' => array( 0 => 'contact_id', diff --git a/tests/phpunit/CRM/Event/BAO/AdditionalPaymentTest.php b/tests/phpunit/CRM/Event/BAO/AdditionalPaymentTest.php index 8c05c65f9ba6..aa4cd9e4313a 100644 --- a/tests/phpunit/CRM/Event/BAO/AdditionalPaymentTest.php +++ b/tests/phpunit/CRM/Event/BAO/AdditionalPaymentTest.php @@ -103,9 +103,9 @@ protected function addParticipantWithPayment($feeTotal, $actualPaidAmt, $partici // add participant payment entry $this->callAPISuccess('participant_payment', 'create', array( - 'participant_id' => $participant['id'], - 'contribution_id' => $contributionId, - )); + 'participant_id' => $participant['id'], + 'contribution_id' => $contributionId, + )); // -- processing priceSet using the BAO $lineItem = array(); diff --git a/tests/phpunit/CRM/Event/BAO/ChangeFeeSelectionTest.php b/tests/phpunit/CRM/Event/BAO/ChangeFeeSelectionTest.php index d3002c716ec9..a2fc34fbbcef 100644 --- a/tests/phpunit/CRM/Event/BAO/ChangeFeeSelectionTest.php +++ b/tests/phpunit/CRM/Event/BAO/ChangeFeeSelectionTest.php @@ -79,8 +79,8 @@ public function tearDown() { protected function priceSetCreate($type = 'Radio') { $feeTotal = 55; $minAmt = 0; - $paramsSet['title'] = 'Two Options' . substr(sha1(rand()), 0, 4); - $paramsSet['name'] = CRM_Utils_String::titleToVar('Two Options') . substr(sha1(rand()), 0, 4); + $paramsSet['title'] = 'Two Options' . substr(sha1(rand()), 0, 4); + $paramsSet['name'] = CRM_Utils_String::titleToVar('Two Options') . substr(sha1(rand()), 0, 4); $paramsSet['is_active'] = FALSE; $paramsSet['extends'] = 1; @@ -129,7 +129,7 @@ protected function priceSetCreate($type = 'Radio') { $field = CRM_Price_BAO_PriceField::create($paramsField); $values = $this->callAPISuccess('PriceFieldValue', 'get', [ 'price_field_id' => $field->id, - 'return' => ['id', 'label'] + 'return' => ['id', 'label'], ]); foreach ($values['values'] as $value) { switch ($value['label']) { @@ -410,19 +410,22 @@ public function testCRM21513() { $unpaidStatus = CRM_Core_PseudoConstant::getKey('CRM_Financial_DAO_FinancialItem', 'status_id', 'Unpaid'); $expectedResults = array( array( - 'amount' => 10.00, // when qty 1 is used + // when qty 1 is used + 'amount' => 10.00, 'status_id' => $unpaidStatus, 'entity_table' => 'civicrm_line_item', 'entity_id' => 1, ), array( - 'amount' => 20.00, // when qty 3 is used, add the surplus amount i.e. $30 - $10 = $20 + // when qty 3 is used, add the surplus amount i.e. $30 - $10 = $20 + 'amount' => 20.00, 'status_id' => $unpaidStatus, 'entity_table' => 'civicrm_line_item', 'entity_id' => 1, ), array( - 'amount' => -10.00, // when qty 2 is used, add the surplus amount i.e. $20 - $30 = -$10 + // when qty 2 is used, add the surplus amount i.e. $20 - $30 = -$10 + 'amount' => -10.00, 'status_id' => $unpaidStatus, 'entity_table' => 'civicrm_line_item', 'entity_id' => 1, diff --git a/tests/phpunit/CRM/Event/BAO/QueryTest.php b/tests/phpunit/CRM/Event/BAO/QueryTest.php index d95a7fbb0ed6..efa9bb555445 100644 --- a/tests/phpunit/CRM/Event/BAO/QueryTest.php +++ b/tests/phpunit/CRM/Event/BAO/QueryTest.php @@ -15,13 +15,13 @@ public function testParticipantNote() { 'api.participant.create' => [ 'event_id' => $event['id'], 'note' => 'some_note', - ] + ], ]); $this->individualCreate([ 'api.participant.create' => [ 'event_id' => $event['id'], 'note' => 'some_other_note', - ] + ], ]); $params = [ [ @@ -30,7 +30,7 @@ public function testParticipantNote() { 2 => 'some_note', 3 => 1, 4 => 0, - ] + ], ]; $query = new CRM_Contact_BAO_Query($params, NULL, NULL, FALSE, FALSE, CRM_Contact_BAO_Query::MODE_CONTACTS); diff --git a/tests/phpunit/CRM/Event/Form/ParticipantTest.php b/tests/phpunit/CRM/Event/Form/ParticipantTest.php index 4ed8844c0f5c..77f0982f03e4 100644 --- a/tests/phpunit/CRM/Event/Form/ParticipantTest.php +++ b/tests/phpunit/CRM/Event/Form/ParticipantTest.php @@ -207,10 +207,9 @@ public function testParticipantOfflineReceipt($thousandSeparator) { $this->testSubmitWithPayment($thousandSeparator); //Check if type is correctly populated in mails. $mail = $mut->checkMailLog([ - '

    Test event type - 1

    ', - $this->formatMoneyInput(1550.55), - ] - ); + '

    Test event type - 1

    ', + $this->formatMoneyInput(1550.55), + ]); } /** diff --git a/tests/phpunit/CRM/Event/Form/Registration/RegistrationTest.php b/tests/phpunit/CRM/Event/Form/Registration/RegistrationTest.php index 757119cbefca..260d2d422e2a 100644 --- a/tests/phpunit/CRM/Event/Form/Registration/RegistrationTest.php +++ b/tests/phpunit/CRM/Event/Form/Registration/RegistrationTest.php @@ -35,7 +35,6 @@ public function setUp() { parent::setUp(); } - /** * CRM-19626 - Test minimum value configured for priceset. */ diff --git a/tests/phpunit/CRM/Export/BAO/ExportTest.php b/tests/phpunit/CRM/Export/BAO/ExportTest.php index 00626abc0f83..156cc1d29518 100644 --- a/tests/phpunit/CRM/Export/BAO/ExportTest.php +++ b/tests/phpunit/CRM/Export/BAO/ExportTest.php @@ -654,7 +654,7 @@ public function testExportIMData() { $relationships = [ $this->contactIDs[1] => ['label' => 'Spouse of'], $this->contactIDs[2] => ['label' => 'Household Member of'], - $this->contactIDs[3] => ['label' => 'Employee of'] + $this->contactIDs[3] => ['label' => 'Employee of'], ]; foreach ($relationships as $contactID => $relationshipType) { @@ -662,7 +662,7 @@ public function testExportIMData() { $result = $this->callAPISuccess('Relationship', 'create', [ 'contact_id_a' => $this->contactIDs[0], 'relationship_type_id' => $relationshipTypeID, - 'contact_id_b' => $contactID + 'contact_id_b' => $contactID, ]); $relationships[$contactID]['id'] = $result['id']; $relationships[$contactID]['relationship_type_id'] = $relationshipTypeID; @@ -817,7 +817,6 @@ public function testExportIMData() { } - /** * Test phone data export. * @@ -845,7 +844,7 @@ public function testExportPhoneData() { } $relationships = [ - $this->contactIDs[1] => ['label' => 'Spouse of'] + $this->contactIDs[1] => ['label' => 'Spouse of'], ]; foreach ($relationships as $contactID => $relationshipType) { @@ -853,7 +852,7 @@ public function testExportPhoneData() { $result = $this->callAPISuccess('Relationship', 'create', [ 'contact_id_a' => $this->contactIDs[0], 'relationship_type_id' => $relationshipTypeID, - 'contact_id_b' => $contactID + 'contact_id_b' => $contactID, ]); $relationships[$contactID]['id'] = $result['id']; $relationships[$contactID]['relationship_type_id'] = $relationshipTypeID; @@ -943,7 +942,7 @@ public function testExportAddressData() { $relationships = [ $this->contactIDs[1] => ['label' => 'Spouse of'], $this->contactIDs[2] => ['label' => 'Household Member of'], - $this->contactIDs[3] => ['label' => 'Employee of'] + $this->contactIDs[3] => ['label' => 'Employee of'], ]; foreach ($relationships as $contactID => $relationshipType) { @@ -951,7 +950,7 @@ public function testExportAddressData() { $result = $this->callAPISuccess('Relationship', 'create', [ 'contact_id_a' => $this->contactIDs[0], 'relationship_type_id' => $relationshipTypeID, - 'contact_id_b' => $contactID + 'contact_id_b' => $contactID, ]); $relationships[$contactID]['id'] = $result['id']; $relationships[$contactID]['relationship_type_id'] = $relationshipTypeID; @@ -1148,6 +1147,7 @@ public function getReasonsNotToMail() { [[], ['street_address' => '']], ]; } + /** * @return array */ @@ -1158,8 +1158,8 @@ protected function setUpHousehold() { 'api.Address.create' => [ 'city' => 'Portland', 'state_province_id' => 'Maine', - 'location_type_id' => 'Home' - ] + 'location_type_id' => 'Home', + ], ]); $relationshipTypes = $this->callAPISuccess('RelationshipType', 'get', [])['values']; @@ -1738,6 +1738,7 @@ public function textExportParticipantSpecifyFieldsNoPayment() { list($tableName, $sqlColumns) = $this->doExport($selectedFields, $this->contactIDs[1], CRM_Export_Form_Select::EVENT_EXPORT); $this->assertEquals($expected, $sqlColumns); } + /** * Get all return fields (@todo - still being built up. * @@ -2035,90 +2036,90 @@ public function getSqlColumnsOutput() { */ protected function getBasicHeaderDefinition($isContactExport) { $headers = [ - 0 => 'Contact ID', - 1 => 'Contact Type', - 2 => 'Contact Subtype', - 3 => 'Do Not Email', - 4 => 'Do Not Phone', - 5 => 'Do Not Mail', - 6 => 'Do Not Sms', - 7 => 'Do Not Trade', - 8 => 'No Bulk Emails (User Opt Out)', - 9 => 'Legal Identifier', - 10 => 'External Identifier', - 11 => 'Sort Name', - 12 => 'Display Name', - 13 => 'Nickname', - 14 => 'Legal Name', - 15 => 'Image Url', - 16 => 'Preferred Communication Method', - 17 => 'Preferred Language', - 18 => 'Preferred Mail Format', - 19 => 'Contact Hash', - 20 => 'Contact Source', - 21 => 'First Name', - 22 => 'Middle Name', - 23 => 'Last Name', - 24 => 'Individual Prefix', - 25 => 'Individual Suffix', - 26 => 'Formal Title', - 27 => 'Communication Style', - 28 => 'Email Greeting ID', - 29 => 'Postal Greeting ID', - 30 => 'Addressee ID', - 31 => 'Job Title', - 32 => 'Gender', - 33 => 'Birth Date', - 34 => 'Deceased', - 35 => 'Deceased Date', - 36 => 'Household Name', - 37 => 'Organization Name', - 38 => 'Sic Code', - 39 => 'Unique ID (OpenID)', - 40 => 'Current Employer ID', - 41 => 'Contact is in Trash', - 42 => 'Created Date', - 43 => 'Modified Date', - 44 => 'Addressee', - 45 => 'Email Greeting', - 46 => 'Postal Greeting', - 47 => 'Current Employer', - 48 => 'Location Type', - 49 => 'Street Address', - 50 => 'Street Number', - 51 => 'Street Number Suffix', - 52 => 'Street Name', - 53 => 'Street Unit', - 54 => 'Supplemental Address 1', - 55 => 'Supplemental Address 2', - 56 => 'Supplemental Address 3', - 57 => 'City', - 58 => 'Postal Code Suffix', - 59 => 'Postal Code', - 60 => 'Latitude', - 61 => 'Longitude', - 62 => 'Address Name', - 63 => 'Master Address Belongs To', - 64 => 'County', - 65 => 'State', - 66 => 'Country', - 67 => 'Phone', - 68 => 'Phone Extension', - 69 => 'Phone Type', - 70 => 'Email', - 71 => 'On Hold', - 72 => 'Use for Bulk Mail', - 73 => 'Signature Text', - 74 => 'Signature Html', - 75 => 'IM Provider', - 76 => 'IM Screen Name', - 77 => 'OpenID', - 78 => 'World Region', - 79 => 'Website', - 80 => 'Group(s)', - 81 => 'Tag(s)', - 82 => 'Note(s)', - ]; + 0 => 'Contact ID', + 1 => 'Contact Type', + 2 => 'Contact Subtype', + 3 => 'Do Not Email', + 4 => 'Do Not Phone', + 5 => 'Do Not Mail', + 6 => 'Do Not Sms', + 7 => 'Do Not Trade', + 8 => 'No Bulk Emails (User Opt Out)', + 9 => 'Legal Identifier', + 10 => 'External Identifier', + 11 => 'Sort Name', + 12 => 'Display Name', + 13 => 'Nickname', + 14 => 'Legal Name', + 15 => 'Image Url', + 16 => 'Preferred Communication Method', + 17 => 'Preferred Language', + 18 => 'Preferred Mail Format', + 19 => 'Contact Hash', + 20 => 'Contact Source', + 21 => 'First Name', + 22 => 'Middle Name', + 23 => 'Last Name', + 24 => 'Individual Prefix', + 25 => 'Individual Suffix', + 26 => 'Formal Title', + 27 => 'Communication Style', + 28 => 'Email Greeting ID', + 29 => 'Postal Greeting ID', + 30 => 'Addressee ID', + 31 => 'Job Title', + 32 => 'Gender', + 33 => 'Birth Date', + 34 => 'Deceased', + 35 => 'Deceased Date', + 36 => 'Household Name', + 37 => 'Organization Name', + 38 => 'Sic Code', + 39 => 'Unique ID (OpenID)', + 40 => 'Current Employer ID', + 41 => 'Contact is in Trash', + 42 => 'Created Date', + 43 => 'Modified Date', + 44 => 'Addressee', + 45 => 'Email Greeting', + 46 => 'Postal Greeting', + 47 => 'Current Employer', + 48 => 'Location Type', + 49 => 'Street Address', + 50 => 'Street Number', + 51 => 'Street Number Suffix', + 52 => 'Street Name', + 53 => 'Street Unit', + 54 => 'Supplemental Address 1', + 55 => 'Supplemental Address 2', + 56 => 'Supplemental Address 3', + 57 => 'City', + 58 => 'Postal Code Suffix', + 59 => 'Postal Code', + 60 => 'Latitude', + 61 => 'Longitude', + 62 => 'Address Name', + 63 => 'Master Address Belongs To', + 64 => 'County', + 65 => 'State', + 66 => 'Country', + 67 => 'Phone', + 68 => 'Phone Extension', + 69 => 'Phone Type', + 70 => 'Email', + 71 => 'On Hold', + 72 => 'Use for Bulk Mail', + 73 => 'Signature Text', + 74 => 'Signature Html', + 75 => 'IM Provider', + 76 => 'IM Screen Name', + 77 => 'OpenID', + 78 => 'World Region', + 79 => 'Website', + 80 => 'Group(s)', + 81 => 'Tag(s)', + 82 => 'Note(s)', + ]; if (!$isContactExport) { unset($headers[80]); unset($headers[81]); diff --git a/tests/phpunit/CRM/Extension/BrowserTest.php b/tests/phpunit/CRM/Extension/BrowserTest.php index 065b94ce13a6..722bfdf803fa 100644 --- a/tests/phpunit/CRM/Extension/BrowserTest.php +++ b/tests/phpunit/CRM/Extension/BrowserTest.php @@ -5,6 +5,7 @@ * @group headless */ class CRM_Extension_BrowserTest extends CiviUnitTestCase { + public function setUp() { parent::setUp(); } diff --git a/tests/phpunit/CRM/Extension/Container/BasicTest.php b/tests/phpunit/CRM/Extension/Container/BasicTest.php index b3aea51c473a..7bd9ba822c66 100644 --- a/tests/phpunit/CRM/Extension/Container/BasicTest.php +++ b/tests/phpunit/CRM/Extension/Container/BasicTest.php @@ -5,6 +5,7 @@ * @group headless */ class CRM_Extension_Container_BasicTest extends CiviUnitTestCase { + public function setUp() { parent::setUp(); } diff --git a/tests/phpunit/CRM/Extension/Container/CollectionTest.php b/tests/phpunit/CRM/Extension/Container/CollectionTest.php index a258453a5ed8..d79a0a097484 100644 --- a/tests/phpunit/CRM/Extension/Container/CollectionTest.php +++ b/tests/phpunit/CRM/Extension/Container/CollectionTest.php @@ -47,12 +47,12 @@ public function testGetKeysEmpty() { public function testGetKeys() { $c = $this->_createContainer(); $this->assertEquals(array( - 'test.conflict', - 'test.whiz', - 'test.whizbang', - 'test.foo', - 'test.foo.bar', - ), $c->getKeys()); + 'test.conflict', + 'test.whiz', + 'test.whizbang', + 'test.foo', + 'test.foo.bar', + ), $c->getKeys()); } public function testGetPath() { @@ -97,8 +97,10 @@ public function testCaching() { $this->assertTrue(is_array($cache->get('ext-collection'))); $cacheData = $cache->get('ext-collection'); - $this->assertEquals('a', $cacheData['test.foo']); // 'test.foo' was defined in the 'a' container - $this->assertEquals('b', $cacheData['test.whiz']); // 'test.whiz' was defined in the 'b' container + // 'test.foo' was defined in the 'a' container + $this->assertEquals('a', $cacheData['test.foo']); + // 'test.whiz' was defined in the 'b' container + $this->assertEquals('b', $cacheData['test.whiz']); } /** diff --git a/tests/phpunit/CRM/Extension/Container/StaticTest.php b/tests/phpunit/CRM/Extension/Container/StaticTest.php index 46edf4d1f9f4..c5e460d93ad6 100644 --- a/tests/phpunit/CRM/Extension/Container/StaticTest.php +++ b/tests/phpunit/CRM/Extension/Container/StaticTest.php @@ -5,6 +5,7 @@ * @group headless */ class CRM_Extension_Container_StaticTest extends CiviUnitTestCase { + public function setUp() { parent::setUp(); } diff --git a/tests/phpunit/CRM/Extension/InfoTest.php b/tests/phpunit/CRM/Extension/InfoTest.php index 879cb76288c7..492a34b88c9b 100644 --- a/tests/phpunit/CRM/Extension/InfoTest.php +++ b/tests/phpunit/CRM/Extension/InfoTest.php @@ -5,6 +5,7 @@ * @group headless */ class CRM_Extension_InfoTest extends CiviUnitTestCase { + public function setUp() { parent::setUp(); $this->file = NULL; diff --git a/tests/phpunit/CRM/Extension/Manager/ModuleTest.php b/tests/phpunit/CRM/Extension/Manager/ModuleTest.php index 282e912a5d7f..a193171490c7 100644 --- a/tests/phpunit/CRM/Extension/Manager/ModuleTest.php +++ b/tests/phpunit/CRM/Extension/Manager/ModuleTest.php @@ -140,7 +140,8 @@ public function testInstall_DirtyRemove_Disable_Uninstall() { $this->assertHookCounts('test_extension_manager_module_auto1', array( 'install' => 1, 'enable' => 1, - 'disable' => 0, // normally called -- but not for missing modules! + // normally called -- but not for missing modules! + 'disable' => 0, 'uninstall' => 0, )); $this->assertModuleActiveByName(FALSE, 'test_extension_manager_module_auto1'); @@ -150,8 +151,10 @@ public function testInstall_DirtyRemove_Disable_Uninstall() { $this->assertHookCounts('test_extension_manager_module_auto1', array( 'install' => 1, 'enable' => 1, - 'disable' => 0, // normally called -- but not for missing modules! - 'uninstall' => 0, // normally called -- but not for missing modules! + // normally called -- but not for missing modules! + 'disable' => 0, + // normally called -- but not for missing modules! + 'uninstall' => 0, )); $this->assertEquals('unknown', $manager->getStatus('test.extension.manager.module.auto1')); $this->assertModuleActiveByName(FALSE, 'test_extension_manager_module_auto1'); @@ -193,7 +196,8 @@ public function testInstall_DirtyRemove_Disable_Restore() { $this->assertHookCounts('test_extension_manager_module_auto2', array( 'install' => 1, 'enable' => 1, - 'disable' => 0, // normally called -- but not for missing modules! + // normally called -- but not for missing modules! + 'disable' => 0, 'uninstall' => 0, )); $this->assertModuleActiveByName(FALSE, 'test_extension_manager_module_auto2'); @@ -233,7 +237,8 @@ public function assertHookCounts($module, $counts) { * @param $prefix */ public function assertModuleActiveByName($expectedIsActive, $prefix) { - $activeModules = CRM_Core_PseudoConstant::getModuleExtensions(TRUE); // FIXME + // FIXME + $activeModules = CRM_Core_PseudoConstant::getModuleExtensions(TRUE); foreach ($activeModules as $activeModule) { if ($activeModule['prefix'] == $prefix) { $this->assertEquals($expectedIsActive, TRUE); diff --git a/tests/phpunit/CRM/Extension/Manager/ReportTest.php b/tests/phpunit/CRM/Extension/Manager/ReportTest.php index 99aea38dc2e5..3d44db92bfc6 100644 --- a/tests/phpunit/CRM/Extension/Manager/ReportTest.php +++ b/tests/phpunit/CRM/Extension/Manager/ReportTest.php @@ -5,6 +5,7 @@ * @group headless */ class CRM_Extension_Manager_ReportTest extends CiviUnitTestCase { + public function setUp() { parent::setUp(); //if (class_exists('test_extension_manager_reporttest')) { diff --git a/tests/phpunit/CRM/Extension/Manager/SearchTest.php b/tests/phpunit/CRM/Extension/Manager/SearchTest.php index 4771997cf0d8..d6b28e52eb01 100644 --- a/tests/phpunit/CRM/Extension/Manager/SearchTest.php +++ b/tests/phpunit/CRM/Extension/Manager/SearchTest.php @@ -5,6 +5,7 @@ * @group headless */ class CRM_Extension_Manager_SearchTest extends CiviUnitTestCase { + public function setUp() { parent::setUp(); //if (class_exists('test_extension_manager_searchtest')) { diff --git a/tests/phpunit/CRM/Extension/ManagerTest.php b/tests/phpunit/CRM/Extension/ManagerTest.php index 53afb936c2d9..3cf5b894c155 100644 --- a/tests/phpunit/CRM/Extension/ManagerTest.php +++ b/tests/phpunit/CRM/Extension/ManagerTest.php @@ -93,7 +93,8 @@ public function testInstall_Disable_Uninstall() { ->method('onPostDisable'); $manager->disable(array('test.foo.bar')); $this->assertEquals('disabled', $manager->getStatus('test.foo.bar')); - $this->assertEquals('installed', $manager->getStatus('test.whiz.bang')); // no side-effect + // no side-effect + $this->assertEquals('installed', $manager->getStatus('test.whiz.bang')); $testingTypeManager ->expects($this->once()) @@ -103,7 +104,8 @@ public function testInstall_Disable_Uninstall() { ->method('onPostUninstall'); $manager->uninstall(array('test.foo.bar')); $this->assertEquals('uninstalled', $manager->getStatus('test.foo.bar')); - $this->assertEquals('installed', $manager->getStatus('test.whiz.bang')); // no side-effect + // no side-effect + $this->assertEquals('installed', $manager->getStatus('test.whiz.bang')); } /** @@ -222,7 +224,6 @@ public function test_InstallAuto_DisableUpstream() { $this->assertEquals('uninstalled', $manager->getStatus('test.whiz.bang')); } - /** * Install an extension and then harshly remove the underlying source. * Subseuently disable and uninstall. @@ -341,7 +342,8 @@ public function testInstall_Disable_Install() { $testingTypeManager ->expects($this->once()) ->method('onPostEnable'); - $manager->install(array('test.foo.bar')); // install() instead of enable() + // install() instead of enable() + $manager->install(array('test.foo.bar')); $this->assertEquals('installed', $manager->getStatus('test.foo.bar')); } @@ -368,7 +370,8 @@ public function testEnableBare() { $testingTypeManager ->expects($this->never()) ->method('onPostEnable'); - $manager->enable(array('test.foo.bar')); // enable not install + // enable not install + $manager->enable(array('test.foo.bar')); $this->assertEquals('installed', $manager->getStatus('test.foo.bar')); } @@ -400,10 +403,12 @@ public function testReplace_Unknown() { $this->download = $this->_createDownload('test.newextension', 'newextension'); $testingTypeManager - ->expects($this->never())// no data to replace + // no data to replace + ->expects($this->never()) ->method('onPreReplace'); $testingTypeManager - ->expects($this->never())// no data to replace + // no data to replace + ->expects($this->never()) ->method('onPostReplace'); $manager->replace($this->download); $this->assertEquals('uninstalled', $manager->getStatus('test.newextension')); @@ -428,10 +433,12 @@ public function testReplace_Uninstalled() { $this->download = $this->_createDownload('test.whiz.bang', 'newextension'); $testingTypeManager - ->expects($this->never())// no data to replace + // no data to replace + ->expects($this->never()) ->method('onPreReplace'); $testingTypeManager - ->expects($this->never())// no data to replace + // no data to replace + ->expects($this->never()) ->method('onPostReplace'); $manager->replace($this->download); $this->assertEquals('uninstalled', $manager->getStatus('test.whiz.bang')); diff --git a/tests/phpunit/CRM/Extension/MapperTest.php b/tests/phpunit/CRM/Extension/MapperTest.php index 748d6ab16e90..828852ee7547 100644 --- a/tests/phpunit/CRM/Extension/MapperTest.php +++ b/tests/phpunit/CRM/Extension/MapperTest.php @@ -9,17 +9,32 @@ class CRM_Extension_MapperTest extends CiviUnitTestCase { /** * @var string */ - protected $basedir, $basedir2; + protected $basedir; + + /** + * @var string + */ + protected $basedir2; + + /** + * @var CRM_Extension_Container_Interface + */ + protected $container; /** * @var CRM_Extension_Container_Interface */ - protected $container, $containerWithSlash; + protected $containerWithSlash; + + /** + * @var CRM_Extension_Mapper + */ + protected $mapper; /** * @var CRM_Extension_Mapper */ - protected $mapper, $mapperWithSlash; + protected $mapperWithSlash; public function setUp() { parent::setUp(); diff --git a/tests/phpunit/CRM/Financial/BAO/FinancialItemTest.php b/tests/phpunit/CRM/Financial/BAO/FinancialItemTest.php index 2fb343e29038..6217d95b1636 100644 --- a/tests/phpunit/CRM/Financial/BAO/FinancialItemTest.php +++ b/tests/phpunit/CRM/Financial/BAO/FinancialItemTest.php @@ -318,14 +318,12 @@ public function testGetPreviousFinancialItemHavingTax($thousandSeparator) { $this->relationForFinancialTypeWithFinancialAccount(1); $form = new CRM_Contribute_Form_Contribution(); $form->testSubmit(array( - 'total_amount' => 100, - 'financial_type_id' => 1, - 'contact_id' => $contactId, - 'contribution_status_id' => 1, - 'price_set_id' => 0, - ), - CRM_Core_Action::ADD - ); + 'total_amount' => 100, + 'financial_type_id' => 1, + 'contact_id' => $contactId, + 'contribution_status_id' => 1, + 'price_set_id' => 0, + ), CRM_Core_Action::ADD); $contribution = $this->callAPISuccessGetSingle('Contribution', array( 'contact_id' => $contactId, diff --git a/tests/phpunit/CRM/Financial/BAO/PaymentProcessorTest.php b/tests/phpunit/CRM/Financial/BAO/PaymentProcessorTest.php index 1a12e8a8d030..729bd1cd63ad 100644 --- a/tests/phpunit/CRM/Financial/BAO/PaymentProcessorTest.php +++ b/tests/phpunit/CRM/Financial/BAO/PaymentProcessorTest.php @@ -30,6 +30,7 @@ * @group headless */ class CRM_Financial_BAO_PaymentProcessorTest extends CiviUnitTestCase { + public function setUp() { parent::setUp(); } diff --git a/tests/phpunit/CRM/Financial/Page/AjaxBatchSummaryTest.php b/tests/phpunit/CRM/Financial/Page/AjaxBatchSummaryTest.php index c4ed28412f9d..9ae40bcb891d 100644 --- a/tests/phpunit/CRM/Financial/Page/AjaxBatchSummaryTest.php +++ b/tests/phpunit/CRM/Financial/Page/AjaxBatchSummaryTest.php @@ -30,6 +30,7 @@ * @group headless */ class CRM_Financial_Page_AjaxBatchSummaryTest extends CiviUnitTestCase { + /** * Test the makeBatchSummary function. * diff --git a/tests/phpunit/CRM/Group/Page/AjaxTest.php b/tests/phpunit/CRM/Group/Page/AjaxTest.php index b6eb77718be8..fd69fd866e51 100644 --- a/tests/phpunit/CRM/Group/Page/AjaxTest.php +++ b/tests/phpunit/CRM/Group/Page/AjaxTest.php @@ -38,15 +38,15 @@ public function setUp() { $this->hookClass = CRM_Utils_Hook::singleton(); $this->createLoggedInUser(); $this->_permissionedDisabledGroup = $this->groupCreate(array( - 'title' => 'pick-me-disabled', - 'is_active' => 0, - 'name' => 'pick-me-disabled', - )); + 'title' => 'pick-me-disabled', + 'is_active' => 0, + 'name' => 'pick-me-disabled', + )); $this->_permissionedGroup = $this->groupCreate(array( - 'title' => 'pick-me-active', - 'is_active' => 1, - 'name' => 'pick-me-active', - )); + 'title' => 'pick-me-active', + 'is_active' => 1, + 'name' => 'pick-me-active', + )); $this->groupCreate(array('title' => 'not-me-disabled', 'is_active' => 0, 'name' => 'not-me-disabled')); $this->groupCreate(array('title' => 'not-me-active', 'is_active' => 1, 'name' => 'not-me-active')); } @@ -242,7 +242,6 @@ public function testGroupListViewAllContactsAll() { $this->assertEquals('pick-me-disabled', $groups['data'][3]['title']); } - /** * Retrieve groups as 'view all contacts' */ @@ -443,7 +442,6 @@ public function testGroupListAclGroupHookDisabledNotFound() { $this->assertEquals(0, $groups['recordsTotal'], 'Total needs to be set correctly'); } - /** * ACL Group hook. */ diff --git a/tests/phpunit/CRM/Logging/LoggingTest.php b/tests/phpunit/CRM/Logging/LoggingTest.php index f10464447430..880cddb22ff5 100644 --- a/tests/phpunit/CRM/Logging/LoggingTest.php +++ b/tests/phpunit/CRM/Logging/LoggingTest.php @@ -30,7 +30,6 @@ public function testMultilingualLogging() { $logging->disableLogging(); } - /** * Test creating logging schema when database is in multilingual mode. * Also test altering a multilingual table. diff --git a/tests/phpunit/CRM/Mailing/BAO/MailingTest.php b/tests/phpunit/CRM/Mailing/BAO/MailingTest.php index cff6d4fc3aef..326f43408556 100644 --- a/tests/phpunit/CRM/Mailing/BAO/MailingTest.php +++ b/tests/phpunit/CRM/Mailing/BAO/MailingTest.php @@ -265,7 +265,6 @@ public function hook_civicrm_aclGroup($type, $contactID, $tableName, &$allGroups } } - /** * @todo Missing tests: * - Ensure opt out emails are not mailed @@ -610,9 +609,9 @@ public function alterMailingRecipients(&$mailingObject, &$criteria, $context) { // modify the filter to include only deceased recipient(s) that is Tagged $criteria['is_deceased'] = CRM_Utils_SQL_Select::fragment()->where("civicrm_contact.is_deceased = 1"); $criteria['tagged_contact'] = CRM_Utils_SQL_Select::fragment() - ->join('civicrm_entity_tag', "INNER JOIN civicrm_entity_tag et ON et.entity_id = civicrm_contact.id AND et.entity_table = 'civicrm_contact'") - ->join('civicrm_tag', "INNER JOIN civicrm_tag t ON t.id = et.tag_id") - ->where("t.name = 'Tagged'"); + ->join('civicrm_entity_tag', "INNER JOIN civicrm_entity_tag et ON et.entity_id = civicrm_contact.id AND et.entity_table = 'civicrm_contact'") + ->join('civicrm_tag', "INNER JOIN civicrm_tag t ON t.id = et.tag_id") + ->where("t.name = 'Tagged'"); } else { $mailingRecipients = $this->callAPISuccess('MailingRecipients', 'get', array( diff --git a/tests/phpunit/CRM/Mailing/BaseMailingSystemTest.php b/tests/phpunit/CRM/Mailing/BaseMailingSystemTest.php index 3c658fc4e3e4..5b1238a72e38 100644 --- a/tests/phpunit/CRM/Mailing/BaseMailingSystemTest.php +++ b/tests/phpunit/CRM/Mailing/BaseMailingSystemTest.php @@ -76,7 +76,8 @@ public function setUp() { public function tearDown() { $this->_mut->stop(); CRM_Utils_Hook::singleton()->reset(); - CRM_Mailing_BAO_MailingJob::$mailsProcessed = 0; // DGW + // DGW + CRM_Mailing_BAO_MailingJob::$mailsProcessed = 0; parent::tearDown(); } @@ -125,9 +126,11 @@ public function testText() { $this->assertEquals('plain', $message->body->subType); $this->assertRegExp( ";" . - "Sample Header for TEXT formatted content.\n" . // Default header + // Default header + "Sample Header for TEXT formatted content.\n" . "BEWARE children need regular infusions of toys. Santa knows your .*\\. There is no http.*civicrm/mailing/optout.*\\.\n" . - "to unsubscribe: http.*civicrm/mailing/optout" . // Default footer + // Default footer + "to unsubscribe: http.*civicrm/mailing/optout" . ";", $message->body->text ); @@ -156,10 +159,13 @@ public function testHtmlWithOpenTracking() { $this->assertEquals('html', $htmlPart->subType); $this->assertRegExp( ";" . - "Sample Header for HTML formatted content.\n" . // Default header + // Default header + "Sample Header for HTML formatted content.\n" . // FIXME: CiviMail puts double " after hyperlink! - "

    You can go to Google or opt out.

    \n" . // body_html - "Sample Footer for HTML formatted content" . // Default footer + // body_html + "

    You can go to Google or opt out.

    \n" . + // Default footer + "Sample Footer for HTML formatted content" . ".*\n" . "assertEquals('plain', $textPart->subType); $this->assertRegExp( ";" . - "Sample Header for TEXT formatted content.\n" . // Default header - "You can go to Google \\[1\\] or opt out \\[2\\]\\.\n" . // body_html, filtered + // Default header + "Sample Header for TEXT formatted content.\n" . + // body_html, filtered + "You can go to Google \\[1\\] or opt out \\[2\\]\\.\n" . "\n" . "Links:\n" . "------\n" . "\\[1\\] http://example.net/first\\?cs=[0-9a-f_]+\n" . "\\[2\\] http.*civicrm/mailing/optout.*\n" . "\n" . - "to unsubscribe: http.*civicrm/mailing/optout" . // Default footer + // Default footer + "to unsubscribe: http.*civicrm/mailing/optout" . ";", $textPart->text ); diff --git a/tests/phpunit/CRM/Mailing/TokensTest.php b/tests/phpunit/CRM/Mailing/TokensTest.php index 2cbd3124be74..721f87f7c087 100644 --- a/tests/phpunit/CRM/Mailing/TokensTest.php +++ b/tests/phpunit/CRM/Mailing/TokensTest.php @@ -4,6 +4,7 @@ * @group headless */ class CRM_Mailing_TokensTest extends \CiviUnitTestCase { + protected function setUp() { $this->useTransaction(); parent::setUp(); diff --git a/tests/phpunit/CRM/Member/BAO/MembershipTest.php b/tests/phpunit/CRM/Member/BAO/MembershipTest.php index 9e33b02206ff..edea7ade40ed 100644 --- a/tests/phpunit/CRM/Member/BAO/MembershipTest.php +++ b/tests/phpunit/CRM/Member/BAO/MembershipTest.php @@ -71,11 +71,13 @@ public function tearDown() { /** * Create membership type using given organization id. * @param $organizationId + * @param bool $withRelationship * @return array|int */ private function createMembershipType($organizationId, $withRelationship = FALSE) { $membershipType = $this->callAPISuccess('MembershipType', 'create', array( - 'domain_id' => 1, //Default domain ID + //Default domain ID + 'domain_id' => 1, 'member_of_contact_id' => $organizationId, 'financial_type_id' => "Member Dues", 'duration_unit' => "year", @@ -111,7 +113,8 @@ public function testDeleteRelatedMembershipsOnParentTypeChanged() { // Create relationship between organization and individual contact $this->callAPISuccess('Relationship', 'create', array( - 'relationship_type_id' => 5, // Employer of relationship + // Employer of relationship + 'relationship_type_id' => 5, 'contact_id_a' => $contactId, 'contact_id_b' => $organizationId, 'is_active' => 1, @@ -396,7 +399,6 @@ public function testGetContactMembership() { $this->contactDelete($contactId); } - /** * Get the contribution. * page id from the membership record @@ -489,7 +491,6 @@ public function testGetMembershipCount() { $this->contactDelete($contactId); } - /** * Checkup sort name function. */ diff --git a/tests/phpunit/CRM/Member/Form/MembershipRenewalTest.php b/tests/phpunit/CRM/Member/Form/MembershipRenewalTest.php index 6165e70928cd..b4c118daba50 100644 --- a/tests/phpunit/CRM/Member/Form/MembershipRenewalTest.php +++ b/tests/phpunit/CRM/Member/Form/MembershipRenewalTest.php @@ -33,9 +33,6 @@ */ class CRM_Member_Form_MembershipRenewalTest extends CiviUnitTestCase { - /** - * Assume empty database with just civicrm_data. - */ protected $_individualId; protected $_contribution; protected $_financialTypeId = 1; @@ -170,7 +167,8 @@ public function testSubmit() { 'cvv2' => '123', 'credit_card_exp_date' => array( 'M' => '9', - 'Y' => '2024', // TODO: Future proof + // TODO: Future proof + 'Y' => '2024', ), 'credit_card_type' => 'Visa', 'billing_first_name' => 'Test', @@ -204,7 +202,7 @@ public function testSubmit() { 'id' => $this->_paymentProcessorID, 'return' => 'payment_instrument_id', )), - ), 'online'); + ), 'online'); } /** @@ -247,7 +245,8 @@ public function testSubmitRecur() { 'cvv2' => '123', 'credit_card_exp_date' => array( 'M' => '9', - 'Y' => '2019', // TODO: Future proof + // TODO: Future proof + 'Y' => '2019', ), 'credit_card_type' => 'Visa', 'billing_first_name' => 'Test', @@ -296,7 +295,7 @@ public function testSubmitRecur() { $this->callAPISuccessGetSingle('address', array( 'contact_id' => $this->_individualId, 'street_address' => '10 Test St', - 'postal_code' => 90210, + 'postal_code' => 90210, )); } @@ -400,7 +399,7 @@ public function testSubmitRecurCompleteInstantWithMail($thousandSeparator) { $contributionRecur = $this->callAPISuccessGetSingle('ContributionRecur', array('contact_id' => $this->_individualId)); $this->assertEquals(1, $contributionRecur['is_email_receipt']); $this->mut->checkMailLog([ - '$ ' . $this->formatMoneyInput(7800.90) + '$ ' . $this->formatMoneyInput(7800.90), ]); $this->mut->stop(); $this->setCurrencySeparators(','); @@ -611,7 +610,8 @@ protected function getBaseSubmitParams() { 'num_terms' => '1', 'source' => '', 'total_amount' => $this->formatMoneyInput('7800.90'), - 'financial_type_id' => '2', //Member dues, see data.xml + //Member dues, see data.xml + 'financial_type_id' => '2', 'soft_credit_type_id' => 11, 'soft_credit_contact_id' => '', 'from_email_address' => '"Demonstrators Anonymous" ', @@ -621,7 +621,8 @@ protected function getBaseSubmitParams() { 'cvv2' => '123', 'credit_card_exp_date' => array( 'M' => '9', - 'Y' => '2019', // TODO: Future proof + // TODO: Future proof + 'Y' => '2019', ), 'credit_card_type' => 'Visa', 'billing_first_name' => 'Test', diff --git a/tests/phpunit/CRM/Member/Form/MembershipTest.php b/tests/phpunit/CRM/Member/Form/MembershipTest.php index c6b52dedfdba..0ac9a2803e0b 100644 --- a/tests/phpunit/CRM/Member/Form/MembershipTest.php +++ b/tests/phpunit/CRM/Member/Form/MembershipTest.php @@ -41,9 +41,6 @@ */ class CRM_Member_Form_MembershipTest extends CiviUnitTestCase { - /** - * Assume empty database with just civicrm_data. - */ protected $_individualId; protected $_contribution; protected $_financialTypeId = 1; @@ -472,7 +469,8 @@ public function testSubmit($thousandSeparator) { 'num_terms' => '1', 'source' => '', 'total_amount' => $this->formatMoneyInput(1234.56), - 'financial_type_id' => '2', //Member dues, see data.xml + //Member dues, see data.xml + 'financial_type_id' => '2', 'soft_credit_type_id' => '', 'soft_credit_contact_id' => '', 'from_email_address' => '"Demonstrators Anonymous" ', @@ -481,7 +479,8 @@ public function testSubmit($thousandSeparator) { 'cvv2' => '123', 'credit_card_exp_date' => array( 'M' => '9', - 'Y' => '2024', // TODO: Future proof + // TODO: Future proof + 'Y' => '2024', ), 'credit_card_type' => 'Visa', 'billing_first_name' => 'Test', @@ -570,7 +569,8 @@ public function testContributionUpdateOnMembershipTypeChange() { 'receive_date' => date('Y-m-d', time()) . ' 20:36:00', 'payment_instrument_id' => array_search('Check', $this->paymentInstruments), 'contribution_status_id' => CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed'), - 'financial_type_id' => '2', //Member dues, see data.xml + //Member dues, see data.xml + 'financial_type_id' => '2', 'payment_processor_id' => $this->_paymentProcessorID, ); $form->_contactID = $this->_individualId; @@ -618,7 +618,8 @@ public function testContributionUpdateOnMembershipTypeChange() { 'total_amount' => 25, 'receive_date' => date('Y-m-d', time()) . ' 20:36:00', 'payment_instrument_id' => array_search('Check', $this->paymentInstruments), - 'financial_type_id' => '2', //Member dues, see data.xml + //Member dues, see data.xml + 'financial_type_id' => '2', 'payment_processor_id' => $this->_paymentProcessorID, ); $form->_contactID = $this->_individualId; @@ -668,7 +669,8 @@ public function testSubmitPartialPayment($thousandSeparator) { 'total_amount' => $this->formatMoneyInput($partiallyPaidAmount), 'payment_instrument_id' => array_search('Check', $this->paymentInstruments), 'contribution_status_id' => CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Partially paid'), - 'financial_type_id' => '2', //Member dues, see data.xml + //Member dues, see data.xml + 'financial_type_id' => '2', 'payment_processor_id' => $this->_paymentProcessorID, ); $form->_contactID = $this->_individualId; @@ -959,26 +961,25 @@ public function testSubmitRecurCompleteInstant() { 'contribution_id' => $contribution['id'], ), 1); $mut->checkMailLog(array( - '=========================================================== + '=========================================================== Billing Name and Address =========================================================== Test 10 Test St Test, AR 90210 US', - '=========================================================== + '=========================================================== Membership Information =========================================================== Membership Type: AnnualFixed Membership Start Date: ', - '=========================================================== + '=========================================================== Credit Card Information =========================================================== Visa ************1111 Expires: ', - ) - ); + )); $mut->stop(); } @@ -1124,7 +1125,8 @@ protected function getBaseSubmitParams() { 'num_terms' => '1', 'source' => '', 'total_amount' => '77.00', - 'financial_type_id' => '2', //Member dues, see data.xml + //Member dues, see data.xml + 'financial_type_id' => '2', 'soft_credit_type_id' => 11, 'soft_credit_contact_id' => '', 'from_email_address' => '"Demonstrators Anonymous" ', @@ -1134,7 +1136,8 @@ protected function getBaseSubmitParams() { 'cvv2' => '123', 'credit_card_exp_date' => array( 'M' => '9', - 'Y' => '2019', // TODO: Future proof + // TODO: Future proof + 'Y' => '2019', ), 'credit_card_type' => 'Visa', 'billing_first_name' => 'Test', @@ -1177,26 +1180,24 @@ protected function createTwoMembershipsViaPriceSetInBackEnd($contactId) { $priceFieldID = $priceField['id']; // create two price options, each represent a membership type of amount 20 and 10 respectively $priceFieldValue = $this->callAPISuccess('price_field_value', 'create', array( - 'price_set_id' => $priceSetID, - 'price_field_id' => $priceField['id'], - 'label' => 'Long Haired Goat', - 'amount' => 20, - 'financial_type_id' => 'Donation', - 'membership_type_id' => 15, - 'membership_num_terms' => 1, - ) - ); + 'price_set_id' => $priceSetID, + 'price_field_id' => $priceField['id'], + 'label' => 'Long Haired Goat', + 'amount' => 20, + 'financial_type_id' => 'Donation', + 'membership_type_id' => 15, + 'membership_num_terms' => 1, + )); $pfvIDs = array($priceFieldValue['id'] => 1); $priceFieldValue = $this->callAPISuccess('price_field_value', 'create', array( - 'price_set_id' => $priceSetID, - 'price_field_id' => $priceField['id'], - 'label' => 'Shoe-eating Goat', - 'amount' => 10, - 'financial_type_id' => 'Donation', - 'membership_type_id' => 35, - 'membership_num_terms' => 2, - ) - ); + 'price_set_id' => $priceSetID, + 'price_field_id' => $priceField['id'], + 'label' => 'Shoe-eating Goat', + 'amount' => 10, + 'financial_type_id' => 'Donation', + 'membership_type_id' => 35, + 'membership_num_terms' => 2, + )); $pfvIDs[$priceFieldValue['id']] = 1; // register for both of these memberships via backoffice membership form submission @@ -1320,7 +1321,8 @@ public function testLineItemAmountOnSalesTax() { 'receive_date' => date('Y-m-d', time()) . ' 20:36:00', 'payment_instrument_id' => array_search('Check', $this->paymentInstruments), 'contribution_status_id' => CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed'), - 'financial_type_id' => 2, //Member dues, see data.xml + //Member dues, see data.xml + 'financial_type_id' => 2, 'payment_processor_id' => $this->_paymentProcessorID, ); $form->_contactID = $this->_individualId; diff --git a/tests/phpunit/CRM/Member/StatusOverrideTypesTest.php b/tests/phpunit/CRM/Member/StatusOverrideTypesTest.php index a4fd72731898..6f3f9e7818f6 100644 --- a/tests/phpunit/CRM/Member/StatusOverrideTypesTest.php +++ b/tests/phpunit/CRM/Member/StatusOverrideTypesTest.php @@ -30,6 +30,7 @@ * @group headless */ class CRM_Member_StatusOverrideTypesTest extends CiviUnitTestCase { + public function setUp() { parent::setUp(); } @@ -46,7 +47,6 @@ public function testIsOverriddenReturnTrueForPermanentStatusOverrideType() { $this->assertTrue($isOverridden); } - public function testIsOverriddenReturnTrueForUntilDateStatusOverrideType() { $statusOverrideTypes = new CRM_Member_StatusOverrideTypes(); $isOverridden = $statusOverrideTypes::isOverridden(CRM_Member_StatusOverrideTypes::UNTIL_DATE); diff --git a/tests/phpunit/CRM/Pledge/BAO/PledgePaymentTest.php b/tests/phpunit/CRM/Pledge/BAO/PledgePaymentTest.php index aff2727f00d8..c02ed2497791 100644 --- a/tests/phpunit/CRM/Pledge/BAO/PledgePaymentTest.php +++ b/tests/phpunit/CRM/Pledge/BAO/PledgePaymentTest.php @@ -395,11 +395,14 @@ public function testCreatePledgePaymentForMultipleInstallments() { CRM_Core_Action::ADD, $pledgePayments['values'][0]['id'], $contributionID, - NULL, // adjustTotalAmount + // adjustTotalAmount + NULL, 404.70, 134.90, - 1, // contribution_status_id - NULL // original_contribution_status_id + // contribution_status_id + 1, + // original_contribution_status_id + NULL ); // Fetch the pledge payments again to see if the amounts and statuses @@ -450,7 +453,8 @@ public function testCreatePledgePaymentForMultipleInstallments2() { 'amount' => 100.00, 'pledge_status_id' => 2, 'pledge_financial_type_id' => 1, - 'original_installment_amount' => (100 / 12), // the API does not allow this + // the API does not allow this + 'original_installment_amount' => (100 / 12), 'frequency_interval' => 1, 'frequency_unit' => 'month', 'frequency_day' => 1, @@ -491,11 +495,14 @@ public function testCreatePledgePaymentForMultipleInstallments2() { CRM_Core_Action::ADD, $pledgePayments['values'][0]['id'], $contributionID, - NULL, // adjustTotalAmount + // adjustTotalAmount + NULL, 100.00, 100.00, - 1, // contribution_status_id - NULL // original_contribution_status_id + // contribution_status_id + 1, + // original_contribution_status_id + NULL ); // Fetch the pledge payments again to see if the amounts and statuses diff --git a/tests/phpunit/CRM/Pledge/Form/SearchTest.php b/tests/phpunit/CRM/Pledge/Form/SearchTest.php index 4209849b09cf..bff24470a6f0 100644 --- a/tests/phpunit/CRM/Pledge/Form/SearchTest.php +++ b/tests/phpunit/CRM/Pledge/Form/SearchTest.php @@ -5,11 +5,13 @@ * @group headless */ class CRM_Pledge_Form_SearchTest extends CiviUnitTestCase { + public function setUp() { parent::setUp(); $this->individualID = $this->individualCreate(); $this->pledgeCreate(array('contact_id' => $this->individualID)); } + public function tearDown() { parent::tearDown(); $tablesToTruncate = array( @@ -19,6 +21,7 @@ public function tearDown() { ); $this->quickCleanup($tablesToTruncate); } + /** * Test submitted the search form. */ @@ -32,25 +35,25 @@ public function testSearch() { $date = date('Y-m-d') . ' 00:00:00'; $rows = $form->controller->get('rows'); $this->assertEquals(array( - 'contact_id' => '3', - 'sort_name' => 'Anderson, Anthony', - 'display_name' => 'Mr. Anthony Anderson II', - 'pledge_id' => '1', - 'pledge_amount' => '100.00', - 'pledge_create_date' => $date, - 'pledge_next_pay_date' => $date, - 'pledge_next_pay_amount' => '20.00', - 'pledge_status_id' => '2', - 'pledge_status' => 'Pending', - 'pledge_is_test' => '0', - 'pledge_financial_type' => 'Donation', - 'pledge_currency' => 'USD', - 'campaign' => NULL, - 'campaign_id' => NULL, - 'pledge_status_name' => 'Pending', - 'checkbox' => 'mark_x_1', - 'action' => 'ViewEditmore', - 'contact_type' => '
    ', + 'contact_id' => '3', + 'sort_name' => 'Anderson, Anthony', + 'display_name' => 'Mr. Anthony Anderson II', + 'pledge_id' => '1', + 'pledge_amount' => '100.00', + 'pledge_create_date' => $date, + 'pledge_next_pay_date' => $date, + 'pledge_next_pay_amount' => '20.00', + 'pledge_status_id' => '2', + 'pledge_status' => 'Pending', + 'pledge_is_test' => '0', + 'pledge_financial_type' => 'Donation', + 'pledge_currency' => 'USD', + 'campaign' => NULL, + 'campaign_id' => NULL, + 'pledge_status_name' => 'Pending', + 'checkbox' => 'mark_x_1', + 'action' => 'ViewEditmore', + 'contact_type' => '
    ', ), $rows[0]); } diff --git a/tests/phpunit/CRM/Queue/RunnerTest.php b/tests/phpunit/CRM/Queue/RunnerTest.php index d88fe13a67cf..1216ce41f949 100644 --- a/tests/phpunit/CRM/Queue/RunnerTest.php +++ b/tests/phpunit/CRM/Queue/RunnerTest.php @@ -228,10 +228,11 @@ public function testRunAll_Abort_False() { $this->assertEquals(2, $this->queue->numberOfItems()); } - /* **** Queue tasks **** */ - - - static $_recordedValues; + /** + * Queue tasks + * @var array + */ + protected static $_recordedValues; /** * @param $taskCtx @@ -239,7 +240,7 @@ public function testRunAll_Abort_False() { * * @return bool */ - static public function _recordValue($taskCtx, $value) { + public static function _recordValue($taskCtx, $value) { self::$_recordedValues[] = $value; return TRUE; } @@ -249,7 +250,7 @@ static public function _recordValue($taskCtx, $value) { * * @return bool */ - static public function _returnFalse($taskCtx) { + public static function _returnFalse($taskCtx) { return FALSE; } @@ -259,7 +260,7 @@ static public function _returnFalse($taskCtx) { * * @throws Exception */ - static public function _throwException($taskCtx, $value) { + public static function _throwException($taskCtx, $value) { throw new Exception("Manufactured error: $value"); } @@ -270,7 +271,7 @@ static public function _throwException($taskCtx, $value) { * * @return bool */ - static public function _enqueueNumbers($taskCtx, $low, $high) { + public static function _enqueueNumbers($taskCtx, $low, $high) { for ($i = $low; $i <= $high; $i++) { $taskCtx->queue->createItem(new CRM_Queue_Task( array('CRM_Queue_RunnerTest', '_recordValue'), diff --git a/tests/phpunit/CRM/Report/Form/ContactSummaryTest.php b/tests/phpunit/CRM/Report/Form/ContactSummaryTest.php index 6765e43731c4..4a4077707efe 100644 --- a/tests/phpunit/CRM/Report/Form/ContactSummaryTest.php +++ b/tests/phpunit/CRM/Report/Form/ContactSummaryTest.php @@ -63,28 +63,28 @@ public function testOddEvenStreetNumber() { 'location_type_id' => 1, 'is_primary' => 1, 'street_number' => 3, - ] + ], ]), 'odd_street_number_2' => $this->individualCreate([ 'api.Address.create' => [ 'location_type_id' => 1, 'is_primary' => 1, 'street_number' => 5, - ] + ], ]), 'even_street_number_1' => $this->individualCreate([ 'api.Address.create' => [ 'location_type_id' => 1, 'is_primary' => 1, 'street_number' => 2, - ] + ], ]), 'even_street_number_2' => $this->individualCreate([ 'api.Address.create' => [ 'location_type_id' => 1, 'is_primary' => 1, 'street_number' => 4, - ] + ], ]), 'no_street_number' => $this->individualCreate(), ]; diff --git a/tests/phpunit/CRM/SMS/ProviderTest.php b/tests/phpunit/CRM/SMS/ProviderTest.php index f402cbd28eba..bf03ef8ec2ed 100644 --- a/tests/phpunit/CRM/SMS/ProviderTest.php +++ b/tests/phpunit/CRM/SMS/ProviderTest.php @@ -96,7 +96,6 @@ public function testProcessInboundSetToContactIDUsingHook() { $this->assertEquals($contact['id'], $activity['source_contact_id']); } - public function smsHookTest(&$message) { $testSourceContact = $this->individualCreate(array('phone' => array(1 => array('phone' => '+61487654321')))); $message->toContactID = $testSourceContact; diff --git a/tests/phpunit/CRM/UF/Page/ProfileEditorTest.php b/tests/phpunit/CRM/UF/Page/ProfileEditorTest.php index 58d416f82044..94e4321cb190 100644 --- a/tests/phpunit/CRM/UF/Page/ProfileEditorTest.php +++ b/tests/phpunit/CRM/UF/Page/ProfileEditorTest.php @@ -5,6 +5,7 @@ * @group headless */ class CRM_UF_Page_ProfileEditorTest extends CiviUnitTestCase { + public function setUp() { parent::setUp(); } diff --git a/tests/phpunit/CRM/Upgrade/Incremental/BaseTest.php b/tests/phpunit/CRM/Upgrade/Incremental/BaseTest.php index 3827a8c2c7a7..74dbaca6ab43 100644 --- a/tests/phpunit/CRM/Upgrade/Incremental/BaseTest.php +++ b/tests/phpunit/CRM/Upgrade/Incremental/BaseTest.php @@ -89,10 +89,10 @@ public function testMessageTemplateGetUpgradeMessages() { */ public function testSmartGroupDatePickerConversion() { $this->callAPISuccess('SavedSearch', 'create', [ - 'form_values' => [ + 'form_values' => [ ['grant_application_received_date_high', '=', '01/20/2019'], ['grant_due_date_low', '=', '01/22/2019'], - ] + ], ]); $smartGroupConversionObject = new CRM_Upgrade_Incremental_SmartGroups(); $smartGroupConversionObject->updateGroups([ @@ -100,8 +100,8 @@ public function testSmartGroupDatePickerConversion() { 'grant_application_received_date', 'grant_decision_date', 'grant_money_transfer_date', - 'grant_due_date' - ] + 'grant_due_date', + ], ]); $savedSearch = $this->callAPISuccessGetSingle('SavedSearch', []); $this->assertEquals('grant_application_received_date_high', $savedSearch['form_values'][0][0]); @@ -124,7 +124,7 @@ public function testOnHoldConversion() { $this->callAPISuccess('SavedSearch', 'create', [ 'form_values' => [ ['on_hold', '=', '1'], - ] + ], ]); $smartGroupConversionObject = new CRM_Upgrade_Incremental_SmartGroups('5.11.alpha1'); $smartGroupConversionObject->convertEqualsStringToInArray('on_hold'); @@ -141,7 +141,7 @@ public function testRenameField() { $this->callAPISuccess('SavedSearch', 'create', [ 'form_values' => [ ['activity_date_low', '=', '01/22/2019'], - ] + ], ]); $smartGroupConversionObject = new CRM_Upgrade_Incremental_SmartGroups(); $smartGroupConversionObject->renameField('activity_date_low', 'activity_date_time_low'); @@ -157,7 +157,7 @@ public function testRenameFields() { 'form_values' => [ ['activity_date_low', '=', '01/22/2019'], ['activity_date_relative', '=', 0], - ] + ], ]); $smartGroupConversionObject = new CRM_Upgrade_Incremental_SmartGroups(); $smartGroupConversionObject->renameFields([ diff --git a/tests/phpunit/CRM/Utils/API/MatchOptionTest.php b/tests/phpunit/CRM/Utils/API/MatchOptionTest.php index 2dcd6fbd3306..4ba2d584bffa 100644 --- a/tests/phpunit/CRM/Utils/API/MatchOptionTest.php +++ b/tests/phpunit/CRM/Utils/API/MatchOptionTest.php @@ -9,7 +9,7 @@ class CRM_Utils_API_MatchOptionTest extends CiviUnitTestCase { /** * @var array */ - var $noise; + public $noise; public function setUp() { parent::setUp(); @@ -108,7 +108,8 @@ public function testCreateMatch_one($apiOptionName) { 'external_identifier' => '1', )); - $this->individualCreate(array('email' => 'ignore2@example.com')); // more noise! + // more noise! + $this->individualCreate(array('email' => 'ignore2@example.com')); // update the record by matching first/last name $result2 = $this->callAPISuccess('contact', 'create', array( @@ -156,7 +157,8 @@ public function testCreateMatch_many($apiOptionName) { 'external_identifier' => '2', )); - $this->individualCreate(array('email' => 'ignore2@example.com')); // more noise! + // more noise! + $this->individualCreate(array('email' => 'ignore2@example.com')); // Try to update - but fail due to ambiguity $result3 = $this->callAPIFailure('contact', 'create', array( @@ -239,7 +241,8 @@ public function testReplaceMatch_Email() { $this->assertEquals($createEmailValues[0]['id'], $updateEmailValues[0]['id']); $this->assertEquals($createEmailValues[0]['id'], $getValues[0]['id']); $this->assertEquals('j1-b@example.com', $getValues[0]['email']); - $this->assertEquals('The Dude abides.', $getValues[0]['signature_text']); // preserved from original creation; proves that we updated existing record + // preserved from original creation; proves that we updated existing record + $this->assertEquals('The Dude abides.', $getValues[0]['signature_text']); // The second email (j2@example.com) is deleted because contact_id+location_type_id doesn't appear in new list. // The third email (j3@example.com) is inserted (new ID#) because it doesn't match an existing contact_id+location_type_id. @@ -324,7 +327,8 @@ public function testReplaceMatch_Address() { $this->assertEquals($createAddressValues[0]['id'], $updateAddressValues[0]['id']); $this->assertEquals($createAddressValues[0]['id'], $getValues[0]['id']); $this->assertEquals('j1-b Example Ave', $getValues[0]['street_address']); - $this->assertEquals('The Dude abides.', $getValues[0]['supplemental_address_1']); // preserved from original creation; proves that we updated existing record + // preserved from original creation; proves that we updated existing record + $this->assertEquals('The Dude abides.', $getValues[0]['supplemental_address_1']); // The second street_address (j2 Example Ave) is deleted because contact_id+location_type_id doesn't appear in new list. // The third street_address (j3 Example Ave) is inserted (new ID#) because it doesn't match an existing contact_id+location_type_id. diff --git a/tests/phpunit/CRM/Utils/API/ReloadOptionTest.php b/tests/phpunit/CRM/Utils/API/ReloadOptionTest.php index bb492f4f3e47..3fcb389df691 100644 --- a/tests/phpunit/CRM/Utils/API/ReloadOptionTest.php +++ b/tests/phpunit/CRM/Utils/API/ReloadOptionTest.php @@ -28,7 +28,8 @@ public function testNoReload() { 'nick_name' => 'Firstie', )); $this->assertEquals('First', $result['values'][$result['id']]['first_name']); - $this->assertEquals('Firstie', $result['values'][$result['id']]['nick_name']); // munged by hook, but we haven't realized it + // munged by hook, but we haven't realized it + $this->assertEquals('Firstie', $result['values'][$result['id']]['nick_name']); } /** diff --git a/tests/phpunit/CRM/Utils/AddressTest.php b/tests/phpunit/CRM/Utils/AddressTest.php index 6fa80cabafd2..1f66726caedc 100644 --- a/tests/phpunit/CRM/Utils/AddressTest.php +++ b/tests/phpunit/CRM/Utils/AddressTest.php @@ -42,7 +42,8 @@ public function testStateProvinceFormattedBillingAddress() { 'billing_street_address-99' => '123 Happy Place', 'billing_city-99' => 'Miami', 'billing_postal_code-99' => 33101, - 'state_province-99' => '1000', // 1000 => Alabama (AL) + // 1000 => Alabama (AL) + 'state_province-99' => '1000', 'country-99' => 'United States', ); @@ -59,14 +60,16 @@ public function testStateProvinceFormattedBillingAddress() { // test using alternate names for state/province field unset($params['state_province-99']); - $params['billing_state_province-99'] = '1000'; // alternate name 1 + // alternate name 1 + $params['billing_state_province-99'] = '1000'; $addFormat = '{contact.state_province_name}'; Civi::settings()->set('address_format', $addFormat); $formatted_address = CRM_Utils_Address::getFormattedBillingAddressFieldsFromParameters($params, '99'); $this->assertTrue((bool) $formatted_address == 'Alabama'); unset($params['state_province-99']); - $params['billing_state_province_id-99'] = '1000'; // alternate name 2 + // alternate name 2 + $params['billing_state_province_id-99'] = '1000'; $addFormat = '{contact.state_province_name}'; Civi::settings()->set('address_format', $addFormat); $formatted_address = CRM_Utils_Address::getFormattedBillingAddressFieldsFromParameters($params, '99'); diff --git a/tests/phpunit/CRM/Utils/ArrayTest.php b/tests/phpunit/CRM/Utils/ArrayTest.php index 212b523ceb49..c4d56cbe51ef 100644 --- a/tests/phpunit/CRM/Utils/ArrayTest.php +++ b/tests/phpunit/CRM/Utils/ArrayTest.php @@ -279,7 +279,7 @@ public function getRecursiveValueExamples() { [NULL, ['wrong' => NULL, 'right' => ['foo' => 1, 'bar' => 2]]], [1, 'wrong'], 'nada', 'nada', ], [ - [NULL, ['wrong' => NULL, 'right' => ['foo' => 1, 'bar' => 2]]], [1, 'right'], NULL, ['foo' => 1, 'bar' => 2] + [NULL, ['wrong' => NULL, 'right' => ['foo' => 1, 'bar' => 2]]], [1, 'right'], NULL, ['foo' => 1, 'bar' => 2], ], [ [NULL, ['wrong' => NULL, 'right' => ['foo' => 1, 'bar' => 2]]], [1, 'right', 'foo'], NULL, 1, @@ -290,6 +290,7 @@ public function getRecursiveValueExamples() { /** * @param $array * @param $path + * @param $default * @param $expected * @dataProvider getRecursiveValueExamples */ @@ -318,6 +319,7 @@ public function getBuildValueExamples() { /** * Test the build recursive function. * + * @param $source * @param $path * @param $expected * @@ -339,13 +341,13 @@ public function testFlatten() { '2' => 'boz', ], 'my_complex' => [ - 'dog' => 'woof', - 'asdf' => [ - 'my_zero' => 0, - 'my_int' => 1, - 'my_null' => NULL, - 'my_empty' => '', - ], + 'dog' => 'woof', + 'asdf' => [ + 'my_zero' => 0, + 'my_int' => 1, + 'my_null' => NULL, + 'my_empty' => '', + ], ], 'my_simple' => 999, ]; diff --git a/tests/phpunit/CRM/Utils/Cache/SqlGroupTest.php b/tests/phpunit/CRM/Utils/Cache/SqlGroupTest.php index 77f31a26b4ae..130eaa533498 100644 --- a/tests/phpunit/CRM/Utils/Cache/SqlGroupTest.php +++ b/tests/phpunit/CRM/Utils/Cache/SqlGroupTest.php @@ -5,6 +5,7 @@ * @group headless */ class CRM_Utils_Cache_SqlGroupTest extends CiviUnitTestCase { + public function setUp() { parent::setUp(); } @@ -76,17 +77,22 @@ public function testPrefetch() { 'group' => 'testPrefetch', 'prefetch' => TRUE, )); - $this->assertEquals($fooValue, $b->getFromFrontCache('foo')); // should work b/c value was prefetched - $this->assertEquals($fooValue, $b->get('foo')); // should work b/c value was prefetched + // should work b/c value was prefetched + $this->assertEquals($fooValue, $b->getFromFrontCache('foo')); + // should work b/c value was prefetched + $this->assertEquals($fooValue, $b->get('foo')); // 3. see what happens when prefetch is FALSE $c = new CRM_Utils_Cache_SqlGroup(array( 'group' => 'testPrefetch', 'prefetch' => FALSE, )); - $this->assertEquals(NULL, $c->getFromFrontCache('foo')); // should be NULL b/c value was NOT prefetched - $this->assertEquals($fooValue, $c->get('foo')); // should work b/c value is fetched on demand - $this->assertEquals($fooValue, $c->getFromFrontCache('foo')); // should work b/c value was fetched on demand + // should be NULL b/c value was NOT prefetched + $this->assertEquals(NULL, $c->getFromFrontCache('foo')); + // should work b/c value is fetched on demand + $this->assertEquals($fooValue, $c->get('foo')); + // should work b/c value was fetched on demand + $this->assertEquals($fooValue, $c->getFromFrontCache('foo')); } } diff --git a/tests/phpunit/CRM/Utils/DateTest.php b/tests/phpunit/CRM/Utils/DateTest.php index dbe2d3b64438..c7828ea1662c 100644 --- a/tests/phpunit/CRM/Utils/DateTest.php +++ b/tests/phpunit/CRM/Utils/DateTest.php @@ -101,7 +101,7 @@ public function testRelativeToAbsoluteFiscalYear() { $date = CRM_Utils_Date::relativeToAbsolute($relativeString, 'fiscal_year'); $this->assertEquals([ 'from' => $fiscalYearStartYear . '0701', - 'to' => ($fiscalYearStartYear + 1) . '0630' + 'to' => ($fiscalYearStartYear + 1) . '0630', ], $date, 'relative term is ' . $relativeString); $fiscalYearStartYear--; @@ -182,7 +182,7 @@ public function testRelativeToAbsoluteYearRange() { $offset = (substr($relativeString, -1, 1)) - 1; $this->assertEquals([ 'from' => $lastYear - $offset . '0101', - 'to' => $lastYear . '1231', + 'to' => $lastYear . '1231', ], $date, 'relative term is ' . $relativeString); } } @@ -205,7 +205,7 @@ public function testRelativeToAbsoluteFiscalYearRange() { $offset = (substr($relativeString, -1, 1)); $this->assertEquals([ 'from' => $lastFiscalYearEnd - $offset . '0701', - 'to' => $lastFiscalYearEnd . '0630', + 'to' => $lastFiscalYearEnd . '0630', ], $date, 'relative term is ' . $relativeString); } } diff --git a/tests/phpunit/CRM/Utils/FileTest.php b/tests/phpunit/CRM/Utils/FileTest.php index 8a6a4eb67416..f52784ae4fb2 100644 --- a/tests/phpunit/CRM/Utils/FileTest.php +++ b/tests/phpunit/CRM/Utils/FileTest.php @@ -23,6 +23,7 @@ public function testIsChildPath() { )); } } + public function testStripComment() { $strings = array( "\nab\n-- cd\nef" => "\nab\nef", diff --git a/tests/phpunit/CRM/Utils/HTMLTest.php b/tests/phpunit/CRM/Utils/HTMLTest.php index 0d2831983a7e..f0baa01662a1 100644 --- a/tests/phpunit/CRM/Utils/HTMLTest.php +++ b/tests/phpunit/CRM/Utils/HTMLTest.php @@ -30,6 +30,7 @@ * @group headless */ class CRM_Utils_HTMLTest extends CiviUnitTestCase { + /** * @return array */ @@ -39,67 +40,83 @@ public function translateExamples() { '', array(), ); - $cases[] = array(// missing ts + // missing ts + $cases[] = array( '
    Hello world
    ', array(), ); - $cases[] = array(// text, no arg + // text, no arg + $cases[] = array( '
    {{ts("Hello world")}}
    ', array('Hello world'), ); - $cases[] = array(// text, no arg, alternate text + // text, no arg, alternate text + $cases[] = array( '
    {{ts("Good morning, Dave")}}
    ', array('Good morning, Dave'), ); - $cases[] = array(// text, with arg + // text, with arg + $cases[] = array( '
    {{ts("Hello world", {1: "whiz"})}}
    ', array('Hello world'), ); - $cases[] = array(// text, not really ts(), no arg + // text, not really ts(), no arg + $cases[] = array( '
    {{clients("Hello world")}}
    ', array(), ); - $cases[] = array(// text, not really ts(), with arg + // text, not really ts(), with arg + $cases[] = array( '
    {{clients("Hello world", {1: "whiz"})}}
    ', array(), ); - $cases[] = array(// two strings, duplicate + // two strings, duplicate + $cases[] = array( '
    {{ts("Hello world")}}

    {{ts("Hello world")}}

    ', array('Hello world'), ); - $cases[] = array(// two strings, addition + // two strings, addition + $cases[] = array( '
    {{ts("Hello world") + "-" + ts("How do you do?")}}

    ', array('Hello world', 'How do you do?'), ); - $cases[] = array(// two strings, separate calls + // two strings, separate calls + $cases[] = array( '
    {{ts("Hello world")}}

    {{ts("How do you do?")}}

    ', array('Hello world', 'How do you do?'), ); - $cases[] = array(// single quoted + // single quoted + $cases[] = array( '
    {{ts(\'Hello world\')}}
    ', array('Hello world'), ); - $cases[] = array(// unclear string + // unclear string + $cases[] = array( '
    {{ts(message)}}
    ', array(), ); - $cases[] = array(// ts() within a string + // ts() within a string + $cases[] = array( '
    {{ts("Does the ts(\'example\') notation work?")}}
    ', array('Does the ts(\'example\') notation work?'), ); - $cases[] = array(// attribute, no arg + // attribute, no arg + $cases[] = array( '
    ', array('Hello world'), ); - $cases[] = array(// attribute, with arg + // attribute, with arg + $cases[] = array( '
    ', array('Hello world'), ); - $cases[] = array(// attribute, two strings, with arg + // attribute, two strings, with arg + $cases[] = array( '
    ', array('Hello world', 'How do you do, %1?'), ); - $cases[] = array(// trick question! Not used on Smarty templates. + // trick question! Not used on Smarty templates. + $cases[] = array( '
    {ts}Hello world{/ts}
    ', array(), ); diff --git a/tests/phpunit/CRM/Utils/HookTest.php b/tests/phpunit/CRM/Utils/HookTest.php index 358ac5edeb1e..a1e0e6329ae8 100644 --- a/tests/phpunit/CRM/Utils/HookTest.php +++ b/tests/phpunit/CRM/Utils/HookTest.php @@ -6,11 +6,11 @@ */ class CRM_Utils_HookTest extends CiviUnitTestCase { - static $activeTest = NULL; + protected static $activeTest = NULL; - var $fakeModules; + public $fakeModules; - var $log; + public $log; public function setUp() { parent::setUp(); diff --git a/tests/phpunit/CRM/Utils/HtmlToTextTest.php b/tests/phpunit/CRM/Utils/HtmlToTextTest.php index 982580d609aa..928bc7147db6 100644 --- a/tests/phpunit/CRM/Utils/HtmlToTextTest.php +++ b/tests/phpunit/CRM/Utils/HtmlToTextTest.php @@ -14,7 +14,8 @@ public function setUp() { * @return array */ public function htmlToTextExamples() { - $cases = array(); // array(0 => string $html, 1 => string $text) + // array(0 => string $html, 1 => string $text) + $cases = array(); $cases[] = array( '

    ', diff --git a/tests/phpunit/CRM/Utils/ICalendarTest.php b/tests/phpunit/CRM/Utils/ICalendarTest.php index fad955750da6..1ed549e67b6e 100644 --- a/tests/phpunit/CRM/Utils/ICalendarTest.php +++ b/tests/phpunit/CRM/Utils/ICalendarTest.php @@ -37,10 +37,12 @@ class CRM_Utils_ICalendarTest extends CiviUnitTestCase { public function escapeExamples() { $cases = array(); $cases[] = array("Hello - this is, a test!"); + this is, a test!", + ); $cases[] = array("Hello!! - this is, a \"test\"!"); + this is, a \"test\"!", + ); return $cases; } diff --git a/tests/phpunit/CRM/Utils/JSTest.php b/tests/phpunit/CRM/Utils/JSTest.php index 8a35e9419f19..612f8be0945d 100644 --- a/tests/phpunit/CRM/Utils/JSTest.php +++ b/tests/phpunit/CRM/Utils/JSTest.php @@ -30,6 +30,7 @@ * @group headless */ class CRM_Utils_JSTest extends CiviUnitTestCase { + /** * @return array */ @@ -39,27 +40,33 @@ public function translateExamples() { '', array(), ); - $cases[] = array(// missing ts + // missing ts + $cases[] = array( 'alert("Hello world")', array(), ); - $cases[] = array(// basic function call + // basic function call + $cases[] = array( 'alert(ts("Hello world"));', array('Hello world'), ); - $cases[] = array(// with arg + // with arg + $cases[] = array( 'alert(ts("Hello world", {1: "whiz"}));', array('Hello world'), ); - $cases[] = array(// not really ts() + // not really ts() + $cases[] = array( 'alert(clients("Hello world"));', array(), ); - $cases[] = array(// not really ts() + // not really ts() + $cases[] = array( 'alert(clients("Hello world", {1: "whiz"}));', array(), ); - $cases[] = array(// with arg + // with arg + $cases[] = array( "\n" . "public function whits() {\n" . " for (a in b) {\n" . @@ -70,15 +77,18 @@ public function translateExamples() { "}\n", array('Hello'), ); - $cases[] = array(// duplicate + // duplicate + $cases[] = array( 'alert(ts("Hello world") + "-" + ts("Hello world"));', array('Hello world'), ); - $cases[] = array(// two strings, addition + // two strings, addition + $cases[] = array( 'alert(ts("Hello world") + "-" + ts("How do you do?"));', array('Hello world', 'How do you do?'), ); - $cases[] = array(// two strings, separate calls + // two strings, separate calls + $cases[] = array( 'alert(ts("Hello world");\nalert(ts("How do you do?"));', array('Hello world', 'How do you do?'), ); @@ -86,11 +96,13 @@ public function translateExamples() { 'alert(ts(\'Single quoted\'));', array('Single quoted'), ); - $cases[] = array(// unclear string + // unclear string + $cases[] = array( 'alert(ts(message));', array(), ); - $cases[] = array(// ts() within a string + // ts() within a string + $cases[] = array( 'alert(ts("Does the ts(\'example\') notation work?"));', array('Does the ts(\'example\') notation work?'), ); diff --git a/tests/phpunit/CRM/Utils/Mail/EmailProcessorTest.php b/tests/phpunit/CRM/Utils/Mail/EmailProcessorTest.php index 9b1d189fffa7..8abebc844a12 100644 --- a/tests/phpunit/CRM/Utils/Mail/EmailProcessorTest.php +++ b/tests/phpunit/CRM/Utils/Mail/EmailProcessorTest.php @@ -4,7 +4,6 @@ * Class CRM_Utils_Mail_EmailProcessorTest * @group headless */ - class CRM_Utils_Mail_EmailProcessorTest extends CiviUnitTestCase { /** @@ -61,7 +60,7 @@ public function testBounceProcessingInvalidCharacter() { $this->setUpMailing(); $mail = 'test_invalid_character.eml'; - copy(__DIR__ . '/data/bounces/' . $mail, __DIR__ . '/data/mail/' . $mail); + copy(__DIR__ . '/data/bounces/' . $mail, __DIR__ . '/data/mail/' . $mail); $this->callAPISuccess('job', 'fetch_bounces', array()); $this->assertFalse(file_exists(__DIR__ . '/data/mail/' . $mail)); $this->checkMailingBounces(1); @@ -74,7 +73,7 @@ public function testBounceProcessingUTF8mb4() { $this->setUpMailing(); $mail = 'test_utf8mb4_character.txt'; - copy(__DIR__ . '/data/bounces/' . $mail, __DIR__ . '/data/mail/' . $mail); + copy(__DIR__ . '/data/bounces/' . $mail, __DIR__ . '/data/mail/' . $mail); $this->callAPISuccess('job', 'fetch_bounces', array()); $this->assertFalse(file_exists(__DIR__ . '/data/mail/' . $mail)); $this->checkMailingBounces(1); @@ -89,7 +88,7 @@ public function testProcessingMultipartRelatedEmail() { $this->setUpMailing(); $mail = 'test_sample_message.eml'; - copy(__DIR__ . '/data/bounces/' . $mail, __DIR__ . '/data/mail/' . $mail); + copy(__DIR__ . '/data/bounces/' . $mail, __DIR__ . '/data/mail/' . $mail); $this->callAPISuccess('job', 'fetch_bounces', array()); $this->assertFalse(file_exists(__DIR__ . '/data/mail/' . $mail)); $this->checkMailingBounces(1); diff --git a/tests/phpunit/CRM/Utils/QueryFormatterTest.php b/tests/phpunit/CRM/Utils/QueryFormatterTest.php index 04ff5dc283f9..68072e3cabd0 100644 --- a/tests/phpunit/CRM/Utils/QueryFormatterTest.php +++ b/tests/phpunit/CRM/Utils/QueryFormatterTest.php @@ -109,11 +109,11 @@ public function dataProvider() { // If user supplies wildcards, then ignore mode. foreach (array( - 'simple', - 'wildphrase', - 'wildwords', - 'wildwords-suffix', - ) as $mode) { + 'simple', + 'wildphrase', + 'wildwords', + 'wildwords-suffix', + ) as $mode) { $cases[] = array('first% second', 'like', $mode, 'first% second', array(3, 7)); $cases[] = array('first% second', 'fts', $mode, 'first* second', array(3, 7)); $cases[] = array('first% second', 'ftsbool', $mode, '+first* +second', array(3, 7)); @@ -134,6 +134,7 @@ public function dataProvider() { * @param string $language * @param string $mode * @param string $expectedText + * @param array|NULL $expectedRowIds * * @dataProvider dataProvider */ diff --git a/tests/phpunit/CRM/Utils/RuleTest.php b/tests/phpunit/CRM/Utils/RuleTest.php index edf81083b202..188089faaa1e 100644 --- a/tests/phpunit/CRM/Utils/RuleTest.php +++ b/tests/phpunit/CRM/Utils/RuleTest.php @@ -146,7 +146,7 @@ public function alphanumericData() { '-', '_foo', 'one-two', - 'f00' + 'f00', ]; $expectFalse = [ ' ', @@ -157,7 +157,7 @@ public function alphanumericData() { "", '(foo)', 'foo;', - '[foo]' + '[foo]', ]; $data = []; foreach ($expectTrue as $value) { diff --git a/tests/phpunit/CRM/Utils/SQL/InsertTest.php b/tests/phpunit/CRM/Utils/SQL/InsertTest.php index 5a502243f63f..ba997cca805c 100644 --- a/tests/phpunit/CRM/Utils/SQL/InsertTest.php +++ b/tests/phpunit/CRM/Utils/SQL/InsertTest.php @@ -5,6 +5,7 @@ * @group headless */ class CRM_Utils_SQL_InsertTest extends CiviUnitTestCase { + public function testRow_twice() { $insert = CRM_Utils_SQL_Insert::into('foo') ->row(array('first' => '1', 'second' => '2')) diff --git a/tests/phpunit/CRM/Utils/SQL/SelectTest.php b/tests/phpunit/CRM/Utils/SQL/SelectTest.php index ba4d8d29dd24..5cecf42c6e76 100644 --- a/tests/phpunit/CRM/Utils/SQL/SelectTest.php +++ b/tests/phpunit/CRM/Utils/SQL/SelectTest.php @@ -5,6 +5,7 @@ * @group headless */ class CRM_Utils_SQL_SelectTest extends CiviUnitTestCase { + public function testGetDefault() { $select = CRM_Utils_SQL_Select::from('foo bar'); $this->assertLike('SELECT * FROM foo bar', $select->toSQL()); diff --git a/tests/phpunit/CRM/Utils/SignerTest.php b/tests/phpunit/CRM/Utils/SignerTest.php index 109f5aaaedbc..51de42931924 100644 --- a/tests/phpunit/CRM/Utils/SignerTest.php +++ b/tests/phpunit/CRM/Utils/SignerTest.php @@ -131,11 +131,13 @@ public function testSignValidate() { ); $cases[] = array( 'signParams' => array( - 'a' => 1, // int + // int + 'a' => 1, 'b' => 'bee', ), 'validateParams' => array( - 'a' => '1', // string + // string + 'a' => '1', 'b' => 'bee', ), 'isValid' => TRUE, @@ -144,9 +146,11 @@ public function testSignValidate() { foreach ($cases as $caseId => $case) { $signer = new CRM_Utils_Signer('secret', array('a', 'b', 'c')); $signature = $signer->sign($case['signParams']); - $this->assertTrue(!empty($signature) && is_string($signature)); // arbitrary + // arbitrary + $this->assertTrue(!empty($signature) && is_string($signature)); - $validator = new CRM_Utils_Signer('secret', array('a', 'b', 'c')); // same as $signer but physically separate + // same as $signer but physically separate + $validator = new CRM_Utils_Signer('secret', array('a', 'b', 'c')); $isValid = $validator->validate($signature, $case['validateParams']); if ($isValid !== $case['isValid']) { diff --git a/tests/phpunit/CRM/Utils/StringTest.php b/tests/phpunit/CRM/Utils/StringTest.php index 472655b06be7..4bc1bd3adee2 100644 --- a/tests/phpunit/CRM/Utils/StringTest.php +++ b/tests/phpunit/CRM/Utils/StringTest.php @@ -131,7 +131,8 @@ public function testParsePrefix($input, $defaultPrefix, $expected) { * @return array */ public function booleanDataProvider() { - $cases = array(); // array(0 => $input, 1 => $expectedOutput) + // array(0 => $input, 1 => $expectedOutput) + $cases = array(); $cases[] = array(TRUE, TRUE); $cases[] = array(FALSE, FALSE); $cases[] = array(1, TRUE); diff --git a/tests/phpunit/CRM/Utils/SystemTest.php b/tests/phpunit/CRM/Utils/SystemTest.php index 633abc64ebc6..66bab81091e2 100644 --- a/tests/phpunit/CRM/Utils/SystemTest.php +++ b/tests/phpunit/CRM/Utils/SystemTest.php @@ -1,6 +1,5 @@ $parsedUrl, - 'original' => $url + 'original' => $url, ]); } catch (CRM_Core_Exception $e) { @@ -65,7 +64,7 @@ public function testRedirectHook($url, $parsedUrl) { * * We do some checks here. * - * @param UriInterface $urlQuery + * @param \Psr\Http\Message\UriInterface $urlQuery * @param array $context * * @throws \CRM_Core_Exception @@ -90,7 +89,8 @@ public function getURLs() { 'scheme' => 'https', 'host' => 'example.com', 'query' => 'ab=cd', - ]], + ], + ], ['http://myuser:mypass@foo.bar:123/whiz?a=b&c=d', [ 'scheme' => 'http', 'host' => 'foo.bar', @@ -99,10 +99,12 @@ public function getURLs() { 'pass' => 'mypass', 'path' => '/whiz', 'query' => 'a=b&c=d', - ]], + ], + ], ['/foo/bar', [ - 'path' => '/foo/bar' - ]], + 'path' => '/foo/bar', + ], + ], ]; } diff --git a/tests/phpunit/CRM/Utils/TimeTest.php b/tests/phpunit/CRM/Utils/TimeTest.php index 2f919def919a..55c647d1bd54 100644 --- a/tests/phpunit/CRM/Utils/TimeTest.php +++ b/tests/phpunit/CRM/Utils/TimeTest.php @@ -5,13 +5,15 @@ * @group headless */ class CRM_Utils_TimeTest extends CiviUnitTestCase { + /** * Equal cases. * * @return array */ public function equalCases() { - $cases = array(); // array(0 => $timeA, 1 => $timeB, 2 => $threshold, 3 => $expectedResult) + // array(0 => $timeA, 1 => $timeB, 2 => $threshold, 3 => $expectedResult) + $cases = array(); $cases[] = array('2012-04-01 12:00:00', '2012-04-01 12:00:00', 0, 1); $cases[] = array('2012-04-01 12:00:00', '2012-04-01 12:00:01', 0, 0); $cases[] = array('2012-04-01 12:00:00', '2012-04-01 12:00:50', 60, 1); diff --git a/tests/phpunit/CRMTraits/ACL/PermissionTrait.php b/tests/phpunit/CRMTraits/ACL/PermissionTrait.php index 23826363524e..01a1afd146fa 100644 --- a/tests/phpunit/CRMTraits/ACL/PermissionTrait.php +++ b/tests/phpunit/CRMTraits/ACL/PermissionTrait.php @@ -32,7 +32,16 @@ */ trait CRMTraits_ACL_PermissionTrait { + /** + * ContactID of allowed Contact + * @var int + */ protected $allowedContactId = 0; + + /** + * Array of allowed contactIds + * @var array + */ protected $allowedContacts = []; /** diff --git a/tests/phpunit/CRMTraits/PCP/PCPTestTrait.php b/tests/phpunit/CRMTraits/PCP/PCPTestTrait.php index 522a553d415a..17454df59192 100644 --- a/tests/phpunit/CRMTraits/PCP/PCPTestTrait.php +++ b/tests/phpunit/CRMTraits/PCP/PCPTestTrait.php @@ -31,6 +31,7 @@ * Traits for testing PCP pages. */ trait CRMTraits_PCP_PCPTestTrait { + /** * Build and return pcpBlock params. * diff --git a/tests/phpunit/CRMTraits/Page/PageTestTrait.php b/tests/phpunit/CRMTraits/Page/PageTestTrait.php index 8b2a2f5db322..bf8cc69c1773 100644 --- a/tests/phpunit/CRMTraits/Page/PageTestTrait.php +++ b/tests/phpunit/CRMTraits/Page/PageTestTrait.php @@ -122,7 +122,7 @@ protected function assertSmartyVariableArrayIncludes($variableName, $index, $exp protected function listenForPageContent() { $this->hookClass->setHook('civicrm_alterContent', [ $this, - 'checkPageContent' + 'checkPageContent', ]); } diff --git a/tests/phpunit/Civi/API/KernelTest.php b/tests/phpunit/Civi/API/KernelTest.php index 00168d5a30d3..995c26dc1740 100644 --- a/tests/phpunit/Civi/API/KernelTest.php +++ b/tests/phpunit/Civi/API/KernelTest.php @@ -1,7 +1,7 @@ array('name' => string $eventName, 'type' => string $className)) */ - var $actualEventSequence; + public $actualEventSequence; /** - * @var EventDispatcher + * @var \Symfony\Component\EventDispatcher\EventDispatcher */ - var $dispatcher; + public $dispatcher; /** * @var Kernel */ - var $kernel; + public $kernel; protected function setUp() { parent::setUp(); diff --git a/tests/phpunit/Civi/API/Subscriber/DynamicFKAuthorizationTest.php b/tests/phpunit/Civi/API/Subscriber/DynamicFKAuthorizationTest.php index 3e0a32f47044..0576ddeb53da 100644 --- a/tests/phpunit/Civi/API/Subscriber/DynamicFKAuthorizationTest.php +++ b/tests/phpunit/Civi/API/Subscriber/DynamicFKAuthorizationTest.php @@ -1,8 +1,8 @@ cronSchedule = array( 'start' => '2015-01-20 00:00:00', 'end' => '2015-03-01 00:00:00', - 'interval' => 24 * 60 * 60, // seconds + // seconds + 'interval' => 24 * 60 * 60, ); $this->schedule = new \CRM_Core_DAO_ActionSchedule(); diff --git a/tests/phpunit/Civi/Angular/ManagerTest.php b/tests/phpunit/Civi/Angular/ManagerTest.php index abe88a40ee61..2635469a93af 100644 --- a/tests/phpunit/Civi/Angular/ManagerTest.php +++ b/tests/phpunit/Civi/Angular/ManagerTest.php @@ -214,7 +214,7 @@ public function testResolveDeps() { public function hook_civicrm_alterAngular($angular) { $angular->add(ChangeSet::create('cat-stevens') ->requires('crmMailing', 'crmCatStevens') - ->alterHtml('~/crmMailing/EditMailingCtrl/2step.html', function(\phpQueryObject $doc){ + ->alterHtml('~/crmMailing/EditMailingCtrl/2step.html', function(\phpQueryObject $doc) { $doc->find('[ng-form="crmMailingSubform"]')->attr('cat-stevens', 'ts(\'wild world\')'); }) ); diff --git a/tests/phpunit/Civi/CCase/SequenceListenerTest.php b/tests/phpunit/Civi/CCase/SequenceListenerTest.php index 01307a59b2ab..72ac7fd51168 100644 --- a/tests/phpunit/Civi/CCase/SequenceListenerTest.php +++ b/tests/phpunit/Civi/CCase/SequenceListenerTest.php @@ -84,11 +84,11 @@ public function testSequence() { //Add an Activity before the case is closed \CRM_Utils_Time::setTime('2013-11-30 04:00:00'); $this->callApiSuccess('Activity', 'create', array( - 'activity_name' => 'Follow up', - 'activity_type_id' => $actTypes['Follow up'], - 'status_id' => $actStatuses['Scheduled'], - 'case_id' => $case['id'], - 'activity_date_time' => \CRM_Utils_Time::getTime(), + 'activity_name' => 'Follow up', + 'activity_type_id' => $actTypes['Follow up'], + 'status_id' => $actStatuses['Scheduled'], + 'case_id' => $case['id'], + 'activity_date_time' => \CRM_Utils_Time::getTime(), )); $analyzer->flush(); $this->assertApproxTime('2013-11-30 01:00:00', self::ag($analyzer->getSingleActivity('Medical evaluation'), 'activity_date_time')); @@ -120,8 +120,8 @@ public function testSequence() { // Complete the additional Activity; Case closed \CRM_Utils_Time::setTime('2013-11-30 04:00:00'); $this->callApiSuccess('Activity', 'create', array( - 'id' => self::ag($analyzer->getSingleActivity('Follow up'), 'id'), - 'status_id' => $actStatuses['Completed'], + 'id' => self::ag($analyzer->getSingleActivity('Follow up'), 'id'), + 'status_id' => $actStatuses['Completed'], )); $analyzer->flush(); $this->assertApproxTime('2013-11-30 01:00:00', self::ag($analyzer->getSingleActivity('Medical evaluation'), 'activity_date_time')); diff --git a/tests/phpunit/Civi/Core/ResolverTest.php b/tests/phpunit/Civi/Core/ResolverTest.php index 4c0466a2b530..0f5f3c551ad1 100644 --- a/tests/phpunit/Civi/Core/ResolverTest.php +++ b/tests/phpunit/Civi/Core/ResolverTest.php @@ -17,7 +17,8 @@ class ResolverTest extends \CiviUnitTestCase { * Test setup. */ protected function setUp() { - parent::setUp(); // TODO: Change the autogenerated stub + // TODO: Change the autogenerated stub + parent::setUp(); $this->resolver = new Resolver(); } @@ -169,6 +170,7 @@ public function ping($arg1) { } namespace { + /** * @param string $arg1 * Dummy value to pass through. @@ -186,4 +188,5 @@ function civi_core_callback_dummy($arg1) { function civicrm_api3_resolvertest_ping($params) { return civicrm_api3_create_success("api dummy received " . $params['first']); } + } diff --git a/tests/phpunit/Civi/Test/ExampleTransactionalTest.php b/tests/phpunit/Civi/Test/ExampleTransactionalTest.php index 7c54db29d10e..bf502300311b 100644 --- a/tests/phpunit/Civi/Test/ExampleTransactionalTest.php +++ b/tests/phpunit/Civi/Test/ExampleTransactionalTest.php @@ -15,7 +15,7 @@ class ExampleTransactionalTest extends \PHPUnit_Framework_TestCase implements He * @var array * Array(int $id). */ - static $contactIds = array(); + protected static $contactIds = array(); public function setUpHeadless() { return \Civi\Test::headless()->apply(); diff --git a/tests/phpunit/Civi/Token/TokenProcessorTest.php b/tests/phpunit/Civi/Token/TokenProcessorTest.php index 38d02d44c153..808e490693ce 100644 --- a/tests/phpunit/Civi/Token/TokenProcessorTest.php +++ b/tests/phpunit/Civi/Token/TokenProcessorTest.php @@ -8,7 +8,7 @@ class TokenProcessorTest extends \CiviUnitTestCase { /** - * @var EventDispatcher + * @var \Symfony\Component\EventDispatcher\EventDispatcher */ protected $dispatcher; @@ -154,7 +154,7 @@ public function testFull() { ); $expectText = array( - 0 => 'Good morning, What. #0123 is a good number. Trickster {contact.display_name}. Bye!' , + 0 => 'Good morning, What. #0123 is a good number. Trickster {contact.display_name}. Bye!', 1 => 'Good morning, Who. #0004 is a good number. Trickster {contact.display_name}. Bye!', 2 => 'Good morning, Darth Vader. #0010 is a good number. Trickster {contact.display_name}. Bye!', ); @@ -168,7 +168,8 @@ public function testFull() { $rowCount++; } $this->assertEquals(3, $rowCount); - $this->assertEquals(0, $this->counts['onListTokens']); // This may change in the future. + // This may change in the future. + $this->assertEquals(0, $this->counts['onListTokens']); $this->assertEquals(1, $this->counts['onEvalTokens']); } diff --git a/tests/phpunit/CiviTest/CiviCaseTestCase.php b/tests/phpunit/CiviTest/CiviCaseTestCase.php index f47395e52661..299f5411652b 100644 --- a/tests/phpunit/CiviTest/CiviCaseTestCase.php +++ b/tests/phpunit/CiviTest/CiviCaseTestCase.php @@ -51,10 +51,9 @@ public function setUp() { // & was really hard to troubleshoot as involved truncating option_value table to mitigate this & not leaving DB in a // state where tests could run afterwards without re-loading. $this->caseStatusGroup = $this->callAPISuccess('option_group', 'get', array( - 'name' => 'case_status', - 'format.only_id' => 1, - ) - ); + 'name' => 'case_status', + 'format.only_id' => 1, + )); $optionValues = array( 'Medical evaluation' => 'Medical evaluation', 'Mental health evaluation' => "Mental health evaluation", diff --git a/tests/phpunit/CiviTest/CiviReportTestCase.php b/tests/phpunit/CiviTest/CiviReportTestCase.php index 641a5f36d74e..84fed16315ba 100644 --- a/tests/phpunit/CiviTest/CiviReportTestCase.php +++ b/tests/phpunit/CiviTest/CiviReportTestCase.php @@ -29,6 +29,7 @@ * Class CiviReportTestCase */ class CiviReportTestCase extends CiviUnitTestCase { + public function setUp() { parent::setUp(); $this->_sethtmlGlobals(); diff --git a/tests/phpunit/CiviTest/CiviTestSuite.php b/tests/phpunit/CiviTest/CiviTestSuite.php index 4dd175274b44..43e6150fce6c 100644 --- a/tests/phpunit/CiviTest/CiviTestSuite.php +++ b/tests/phpunit/CiviTest/CiviTestSuite.php @@ -119,7 +119,8 @@ protected function addAllTests( } // Pass 1: Check all *Tests.php files - $addTests = array(); // array(callable) + // array(callable) + $addTests = array(); //echo "start Pass 1 on {$dirInfo->getRealPath()}\n"; $dir = new DirectoryIterator($dirInfo->getRealPath()); foreach ($dir as $fileInfo) { @@ -155,7 +156,8 @@ protected function addAllTests( } // Pass 2: Scan all subdirectories - $addAllTests = array(); // array(array(0 => $suite, 1 => $file, 2 => SplFileinfo)) + // array(array(0 => $suite, 1 => $file, 2 => SplFileinfo)) + $addAllTests = array(); $dir = new DirectoryIterator($dirInfo->getRealPath()); //echo "start Pass 2 on {$dirInfo->getRealPath()}\n"; foreach ($dir as $fileInfo) { @@ -176,7 +178,8 @@ protected function addAllTests( // Pass 3: Check all *Test.php files in this directory //echo "start Pass 3 on {$dirInfo->getRealPath()}\n"; - $addTestSuites = array(); // array(className) + // array(className) + $addTestSuites = array(); $dir = new DirectoryIterator($dirInfo->getRealPath()); foreach ($dir as $fileInfo) { if ($fileInfo->isReadable() && $fileInfo->isFile() diff --git a/tests/phpunit/CiviTest/CiviUnitTestCase.php b/tests/phpunit/CiviTest/CiviUnitTestCase.php index c3f62042e4d9..39ab293589a2 100644 --- a/tests/phpunit/CiviTest/CiviUnitTestCase.php +++ b/tests/phpunit/CiviTest/CiviUnitTestCase.php @@ -78,6 +78,7 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase { /** * Track tables we have modified during a test. + * @var array */ protected $_tablesToTruncate = array(); @@ -292,7 +293,8 @@ protected function setUp() { $session = CRM_Core_Session::singleton(); $session->set('userID', NULL); - $this->errorScope = CRM_Core_TemporaryErrorScope::useException(); // REVERT + // REVERT + $this->errorScope = CRM_Core_TemporaryErrorScope::useException(); // Use a temporary file for STDIN $GLOBALS['stdin'] = tmpfile(); if ($GLOBALS['stdin'] === FALSE) { @@ -320,7 +322,8 @@ protected function setUp() { // initialize the object once db is loaded \Civi::reset(); - $config = CRM_Core_Config::singleton(TRUE, TRUE); // ugh, performance + // ugh, performance + $config = CRM_Core_Config::singleton(TRUE, TRUE); // when running unit tests, use mockup user framework $this->hookClass = CRM_Utils_Hook::singleton(); @@ -815,6 +818,7 @@ public function householdCreate($params = array(), $seq = 0) { * enum contact type: Individual, Organization * @param int $seq * sequence number for the values of this type + * @param bool $random * * @return array * properties of sample contact (ie. $params for API call) @@ -1029,15 +1033,13 @@ public function membershipRenewalDate($durationUnit, $membershipEndDate) { */ public function relationshipTypeCreate($params = array()) { $params = array_merge(array( - 'name_a_b' => 'Relation 1 for relationship type create', - 'name_b_a' => 'Relation 2 for relationship type create', - 'contact_type_a' => 'Individual', - 'contact_type_b' => 'Organization', - 'is_reserved' => 1, - 'is_active' => 1, - ), - $params - ); + 'name_a_b' => 'Relation 1 for relationship type create', + 'name_b_a' => 'Relation 2 for relationship type create', + 'contact_type_a' => 'Individual', + 'contact_type_b' => 'Organization', + 'is_reserved' => 1, + 'is_active' => 1, + ), $params); $result = $this->callAPISuccess('relationship_type', 'create', $params); CRM_Core_PseudoConstant::flush('relationshipType'); @@ -1174,7 +1176,7 @@ public function processorCreate($params = array()) { * @param array $processorParams * * @return \CRM_Core_Payment_Dummy - * Instance of Dummy Payment Processor + * Instance of Dummy Payment Processor */ public function dummyProcessorCreate($processorParams = array()) { $paymentProcessorID = $this->processorCreate($processorParams); @@ -1628,6 +1630,7 @@ protected function cleanUpAfterACLs() { $config = CRM_Core_Config::singleton(); unset($config->userPermissionClass->permissions); } + /** * Create a smart group. * @@ -1657,7 +1660,7 @@ public function smartGroupCreate($smartGroupParams = array(), $groupParams = arr * @param int $totalCount * @param bool $random * @return int - * groupId of created group + * groupId of created group */ public function groupContactCreate($groupID, $totalCount = 10, $random = FALSE) { $params = array('group_id' => $groupID); @@ -1997,7 +2000,6 @@ public function entityCustomGroupWithSingleStringMultiSelectFieldCreate($functio return array('custom_group_id' => $customGroup['id'], 'custom_field_id' => $customField['id'], 'custom_field_option_group_id' => $custom_field_api_result['values'][0]['option_group_id'], 'custom_field_group_options' => $options); } - /** * Delete custom group. * @@ -2238,6 +2240,7 @@ public function restoreDefaultPriceSetConfig() { CRM_Core_DAO::executeQuery("INSERT INTO `civicrm_price_field` (`id`, `price_set_id`, `name`, `label`, `html_type`, `is_enter_qty`, `help_pre`, `help_post`, `weight`, `is_display_amounts`, `options_per_line`, `is_active`, `is_required`, `active_on`, `expire_on`, `javascript`, `visibility_id`) VALUES (1, 1, 'contribution_amount', 'Contribution Amount', 'Text', 0, NULL, NULL, 1, 1, 1, 1, 1, NULL, NULL, NULL, 1)"); CRM_Core_DAO::executeQuery("INSERT INTO `civicrm_price_field_value` (`id`, `price_field_id`, `name`, `label`, `description`, `amount`, `count`, `max_value`, `weight`, `membership_type_id`, `membership_num_terms`, `is_default`, `is_active`, `financial_type_id`, `non_deductible_amount`) VALUES (1, 1, 'contribution_amount', 'Contribution Amount', NULL, '1', NULL, NULL, 1, NULL, NULL, 0, 1, 1, 0.00)"); } + /* * Function does a 'Get' on the entity & compares the fields in the Params with those returned * Default behaviour is to also delete the entity @@ -2252,6 +2255,7 @@ public function restoreDefaultPriceSetConfig() { * @param string $errorText * Text to print on error. */ + /** * @param array $params * @param int $id @@ -2776,26 +2780,25 @@ public function offsetDefaultPriceSet() { */ public function paymentProcessorCreate($params = array()) { $params = array_merge(array( - 'name' => 'demo', - 'domain_id' => CRM_Core_Config::domainID(), - 'payment_processor_type_id' => 'PayPal', - 'is_active' => 1, - 'is_default' => 0, - 'is_test' => 1, - 'user_name' => 'sunil._1183377782_biz_api1.webaccess.co.in', - 'password' => '1183377788', - 'signature' => 'APixCoQ-Zsaj-u3IH7mD5Do-7HUqA9loGnLSzsZga9Zr-aNmaJa3WGPH', - 'url_site' => 'https://www.sandbox.paypal.com/', - 'url_api' => 'https://api-3t.sandbox.paypal.com/', - 'url_button' => 'https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif', - 'class_name' => 'Payment_PayPalImpl', - 'billing_mode' => 3, - 'financial_type_id' => 1, - 'financial_account_id' => 12, - // Credit card = 1 so can pass 'by accident'. - 'payment_instrument_id' => 'Debit Card', - ), - $params); + 'name' => 'demo', + 'domain_id' => CRM_Core_Config::domainID(), + 'payment_processor_type_id' => 'PayPal', + 'is_active' => 1, + 'is_default' => 0, + 'is_test' => 1, + 'user_name' => 'sunil._1183377782_biz_api1.webaccess.co.in', + 'password' => '1183377788', + 'signature' => 'APixCoQ-Zsaj-u3IH7mD5Do-7HUqA9loGnLSzsZga9Zr-aNmaJa3WGPH', + 'url_site' => 'https://www.sandbox.paypal.com/', + 'url_api' => 'https://api-3t.sandbox.paypal.com/', + 'url_button' => 'https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif', + 'class_name' => 'Payment_PayPalImpl', + 'billing_mode' => 3, + 'financial_type_id' => 1, + 'financial_account_id' => 12, + // Credit card = 1 so can pass 'by accident'. + 'payment_instrument_id' => 'Debit Card', + ), $params); if (!is_numeric($params['payment_processor_type_id'])) { // really the api should handle this through getoptions but it's not exactly api call so lets just sort it //here @@ -2816,18 +2819,16 @@ public function paymentProcessorCreate($params = array()) { */ public function setupRecurringPaymentProcessorTransaction($recurParams = [], $contributionParams = []) { $contributionParams = array_merge([ - 'total_amount' => '200', - 'invoice_id' => $this->_invoiceID, - 'financial_type_id' => 'Donation', - 'contribution_status_id' => 'Pending', - 'contact_id' => $this->_contactID, - 'contribution_page_id' => $this->_contributionPageID, - 'payment_processor_id' => $this->_paymentProcessorID, - 'is_test' => 0, - 'skipCleanMoney' => TRUE, - ], - $contributionParams - ); + 'total_amount' => '200', + 'invoice_id' => $this->_invoiceID, + 'financial_type_id' => 'Donation', + 'contribution_status_id' => 'Pending', + 'contact_id' => $this->_contactID, + 'contribution_page_id' => $this->_contributionPageID, + 'payment_processor_id' => $this->_paymentProcessorID, + 'is_test' => 0, + 'skipCleanMoney' => TRUE, + ], $contributionParams); $contributionRecur = $this->callAPISuccess('contribution_recur', 'create', array_merge(array( 'contact_id' => $this->_contactID, 'amount' => 1000, @@ -3127,6 +3128,7 @@ protected function createParticipantWithContribution() { * * @param string $component * @param int $componentId + * @param array $priceFieldOptions * * @return array */ @@ -3393,9 +3395,7 @@ protected function createPaymentInstrument($params = array(), $financialAccountN 'label' => 'Payment Instrument -' . substr(sha1(rand()), 0, 7), 'option_group_id' => 'payment_instrument', 'is_active' => 1, - ), - $params - ); + ), $params); $newPaymentInstrument = $this->callAPISuccess('OptionValue', 'create', $params)['id']; $relationTypeID = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Asset Account is' ")); @@ -3522,36 +3522,33 @@ public function createPriceSetWithPage($entity = NULL, $params = array()) { 'html_type' => 'Radio', )); $priceFieldValue = $this->callAPISuccess('price_field_value', 'create', array( - 'price_set_id' => $priceSetID, - 'price_field_id' => $priceField['id'], - 'label' => 'Long Haired Goat', - 'amount' => 20, - 'financial_type_id' => 'Donation', - 'membership_type_id' => $membershipTypeID, - 'membership_num_terms' => 1, - ) - ); + 'price_set_id' => $priceSetID, + 'price_field_id' => $priceField['id'], + 'label' => 'Long Haired Goat', + 'amount' => 20, + 'financial_type_id' => 'Donation', + 'membership_type_id' => $membershipTypeID, + 'membership_num_terms' => 1, + )); $this->_ids['price_field_value'] = array($priceFieldValue['id']); $priceFieldValue = $this->callAPISuccess('price_field_value', 'create', array( - 'price_set_id' => $priceSetID, - 'price_field_id' => $priceField['id'], - 'label' => 'Shoe-eating Goat', - 'amount' => 10, - 'financial_type_id' => 'Donation', - 'membership_type_id' => $membershipTypeID, - 'membership_num_terms' => 2, - ) - ); + 'price_set_id' => $priceSetID, + 'price_field_id' => $priceField['id'], + 'label' => 'Shoe-eating Goat', + 'amount' => 10, + 'financial_type_id' => 'Donation', + 'membership_type_id' => $membershipTypeID, + 'membership_num_terms' => 2, + )); $this->_ids['price_field_value'][] = $priceFieldValue['id']; $priceFieldValue = $this->callAPISuccess('price_field_value', 'create', array( - 'price_set_id' => $priceSetID, - 'price_field_id' => $priceField['id'], - 'label' => 'Shoe-eating Goat', - 'amount' => 10, - 'financial_type_id' => 'Donation', - ) - ); + 'price_set_id' => $priceSetID, + 'price_field_id' => $priceField['id'], + 'label' => 'Shoe-eating Goat', + 'amount' => 10, + 'financial_type_id' => 'Donation', + )); $this->_ids['price_field_value']['cont'] = $priceFieldValue['id']; $this->_ids['price_set'] = $priceSetID; @@ -3613,7 +3610,6 @@ public function onPost($op, $objectName, $objectId, &$objectRef) { } } - /** * Instantiate form object. * @@ -3662,7 +3658,6 @@ protected function formatMoneyInput($amount) { return CRM_Utils_Money::format($amount, NULL, '%a'); } - /** * Get the contribution object. * diff --git a/tests/phpunit/E2E/Cache/TieredTest.php b/tests/phpunit/E2E/Cache/TieredTest.php index ac31a41639fa..a2c11fea6098 100644 --- a/tests/phpunit/E2E/Cache/TieredTest.php +++ b/tests/phpunit/E2E/Cache/TieredTest.php @@ -35,7 +35,12 @@ class E2E_Cache_TieredTest extends E2E_Cache_CacheTestCase { /** * @var CRM_Utils_Cache_ArrayCache */ - protected $a, $b; + protected $a; + + /** + * @var CRM_Utils_Cache_ArrayCache + */ + protected $b; protected function tearDown() { if (function_exists('timecop_return')) { @@ -53,7 +58,7 @@ public function createSimpleCache($maxTimeouts = [86400]) { $this->b = CRM_Utils_Cache::create([ 'name' => 'e2e tiered test b', 'type' => ['ArrayCache'], - ]) + ]), ], $maxTimeouts); } diff --git a/tests/phpunit/E2E/Cache/TwoInstancesTest.php b/tests/phpunit/E2E/Cache/TwoInstancesTest.php index 579a8397398f..93e712e327fc 100644 --- a/tests/phpunit/E2E/Cache/TwoInstancesTest.php +++ b/tests/phpunit/E2E/Cache/TwoInstancesTest.php @@ -34,7 +34,12 @@ class E2E_Cache_TwoInstancesTest extends CiviEndToEndTestCase { /** * @var Psr\SimpleCache\CacheInterface; */ - protected $a, $b; + protected $a; + + /** + * @var Psr\SimpleCache\CacheInterface; + */ + protected $b; protected function setUp() { parent::setUp(); diff --git a/tests/phpunit/E2E/Core/AssetBuilderTest.php b/tests/phpunit/E2E/Core/AssetBuilderTest.php index 5d5766d9acd7..19df9a3c1cd2 100644 --- a/tests/phpunit/E2E/Core/AssetBuilderTest.php +++ b/tests/phpunit/E2E/Core/AssetBuilderTest.php @@ -5,7 +5,6 @@ use Civi\Core\AssetBuilder; use Civi\Core\Event\GenericHookEvent; - /** * Class AssetBuilderTest * @package E2E\Core diff --git a/tests/phpunit/E2E/Core/PrevNextTest.php b/tests/phpunit/E2E/Core/PrevNextTest.php index ed1fdebae63b..97e020865e8f 100644 --- a/tests/phpunit/E2E/Core/PrevNextTest.php +++ b/tests/phpunit/E2E/Core/PrevNextTest.php @@ -15,7 +15,12 @@ class PrevNextTest extends \CiviEndToEndTestCase { /** * @var string */ - protected $cacheKey, $cacheKeyB; + protected $cacheKey; + + /** + * @var string + */ + protected $cacheKeyB; /** * @var \CRM_Core_PrevNextCache_Interface @@ -313,12 +318,13 @@ public function testDeleteAll() { $this->assertSelections([], 'getall', $this->cacheKeyB); } - /** * Assert that the current cacheKey has a list of selected contact IDs. * * @param array $ids * Contact IDs that should be selected. + * @param string $action + * @param string|NULL $cacheKey */ protected function assertSelections($ids, $action = 'get', $cacheKey = NULL) { if ($cacheKey === NULL) { diff --git a/tests/phpunit/E2E/Extern/RestTest.php b/tests/phpunit/E2E/Extern/RestTest.php index 0d9d96315714..a288acc5689e 100644 --- a/tests/phpunit/E2E/Extern/RestTest.php +++ b/tests/phpunit/E2E/Extern/RestTest.php @@ -96,104 +96,122 @@ public function apiTestCases() { // entity,action: omit apiKey, valid entity+action $cases[] = array( - array(// query + // query + array( "entity" => "Contact", "action" => "get", "key" => $GLOBALS['_CV']['CIVI_SITE_KEY'], "json" => "1", ), - 1, // is_error + // is_error + 1, ); // entity,action: valid apiKey, valid entity+action $cases[] = array( - array(// query + // query + array( "entity" => "Contact", "action" => "get", "key" => $GLOBALS['_CV']['CIVI_SITE_KEY'], "json" => "1", "api_key" => self::getApiKey(), ), - 0, // is_error + // is_error + 0, ); // entity,action: bad apiKey, valid entity+action $cases[] = array( - array(// query + // query + array( "entity" => "Contact", "action" => "get", "key" => $GLOBALS['_CV']['CIVI_SITE_KEY'], "json" => "1", "api_key" => 'garbage_' . self::getApiKey(), ), - 1, // is_error + // is_error + 1, ); // entity,action: valid apiKey, invalid entity+action $cases[] = array( - array(// query + // query + array( "entity" => "Contactses", "action" => "get", "key" => $GLOBALS['_CV']['CIVI_SITE_KEY'], "json" => "1", "api_key" => self::getApiKey(), ), - 1, // is_error + // is_error + 1, ); // q=civicrm/entity/action: omit apiKey, valid entity+action $cases[] = array( - array(// query + // query + array( "q" => "civicrm/contact/get", "key" => $GLOBALS['_CV']['CIVI_SITE_KEY'], "json" => "1", ), - 1, // is_error + // is_error + 1, ); // q=civicrm/entity/action: valid apiKey, valid entity+action $cases[] = array( - array(// query + // query + array( "q" => "civicrm/contact/get", "key" => $GLOBALS['_CV']['CIVI_SITE_KEY'], "json" => "1", "api_key" => self::getApiKey(), ), - 0, // is_error + // is_error + 0, ); // q=civicrm/entity/action: invalid apiKey, valid entity+action $cases[] = array( - array(// query + // query + array( "q" => "civicrm/contact/get", "key" => $GLOBALS['_CV']['CIVI_SITE_KEY'], "json" => "1", "api_key" => 'garbage_' . self::getApiKey(), ), - 1, // is_error + // is_error + 1, ); // q=civicrm/entity/action: valid apiKey, invalid entity+action $cases[] = array( - array(// query + // query + array( "q" => "civicrm/contactses/get", "key" => $GLOBALS['_CV']['CIVI_SITE_KEY'], "json" => "1", "api_key" => self::getApiKey(), ), - 1, // is_error + // is_error + 1, ); // q=civicrm/entity/action: valid apiKey, invalid entity+action // XXX Actually Ping is valid, no? $cases[] = array( - array(// query + // query + array( "q" => "civicrm/ping", "key" => $GLOBALS['_CV']['CIVI_SITE_KEY'], "json" => "1", "api_key" => self::getApiKey(), ), - 0, // is_error + // is_error + 0, ); return $cases; diff --git a/tests/phpunit/E2E/Extern/SoapTest.php b/tests/phpunit/E2E/Extern/SoapTest.php index 8f556c0364a1..7f618da5a702 100644 --- a/tests/phpunit/E2E/Extern/SoapTest.php +++ b/tests/phpunit/E2E/Extern/SoapTest.php @@ -33,7 +33,17 @@ class E2E_Extern_SoapTest extends CiviEndToEndTestCase { /** * @var string */ - var $url, $adminUser, $adminPass; + public $url; + + /** + * @var string + */ + public $adminUser; + + /** + * @var string + */ + public $adminPass; public function setUp() { CRM_Core_Config::singleton(1, 1); @@ -91,11 +101,10 @@ public function testGetContact() { */ protected function createClient() { return new SoapClient(NULL, array( - 'location' => $this->url, - 'uri' => 'urn:civicrm', - 'trace' => 1, - ) - ); + 'location' => $this->url, + 'uri' => 'urn:civicrm', + 'trace' => 1, + )); } } diff --git a/tests/phpunit/EnvTests.php b/tests/phpunit/EnvTests.php index 9bfa80f8dbf3..18ef4d3a0e08 100644 --- a/tests/phpunit/EnvTests.php +++ b/tests/phpunit/EnvTests.php @@ -11,6 +11,7 @@ * (eg "MyFirstTest::testFoo"). */ class EnvTests extends \PHPUnit_Framework_TestSuite { + /** * @return \EnvTests */ diff --git a/tests/phpunit/HelloTest.php b/tests/phpunit/HelloTest.php index af4b139744e2..74e3ad5bcb26 100644 --- a/tests/phpunit/HelloTest.php +++ b/tests/phpunit/HelloTest.php @@ -43,8 +43,11 @@ * Class HelloTest */ class HelloTest extends PHPUnit_Framework_TestCase { - // contains the object handle of the string class - var $abc; + /** + * contains the object handle of the string class + * @var string + */ + public $abc; /** * @param string|null $name diff --git a/tests/phpunit/api/v3/ACLPermissionTest.php b/tests/phpunit/api/v3/ACLPermissionTest.php index 1e4e4a5cc2b3..f72b0a8818ff 100644 --- a/tests/phpunit/api/v3/ACLPermissionTest.php +++ b/tests/phpunit/api/v3/ACLPermissionTest.php @@ -510,7 +510,8 @@ public static function entities() { return [ ['contribution'], ['participant'], - ];// @todo array('pledge' => 'pledge') + // @todo array('pledge' => 'pledge') + ]; } /** @@ -684,10 +685,10 @@ public function testGetActivityByAclCannotViewAllContacts() { ], ]); foreach ([ - 'source_contact', - 'target_contact', - 'assignee_contact', - ] as $roleName) { + 'source_contact', + 'target_contact', + 'assignee_contact', + ] as $roleName) { $roleKey = $roleName . '_id'; if ($role !== $roleKey) { $this->assertTrue(empty($result[$roleKey]), "Only contact in $role is permissioned to be returned, not $roleKey"); @@ -829,9 +830,8 @@ protected function getActivityContacts($activity) { $contacts = []; $activityContacts = $this->callAPISuccess('ActivityContact', 'get', [ - 'activity_id' => $activity['id'], - ] - ); + 'activity_id' => $activity['id'], + ]); $activityRecordTypes = $this->callAPISuccess('ActivityContact', 'getoptions', ['field' => 'record_type_id']); foreach ($activityContacts['values'] as $activityContact) { diff --git a/tests/phpunit/api/v3/APIWrapperTest.php b/tests/phpunit/api/v3/APIWrapperTest.php index d256a294ec09..56c688b9153a 100644 --- a/tests/phpunit/api/v3/APIWrapperTest.php +++ b/tests/phpunit/api/v3/APIWrapperTest.php @@ -89,6 +89,7 @@ public function testWrapperHook() { * Class api_v3_APIWrapperTest_Impl */ class api_v3_APIWrapperTest_Impl implements API_Wrapper { + /** * @inheritDoc */ diff --git a/tests/phpunit/api/v3/ActivityContactTest.php b/tests/phpunit/api/v3/ActivityContactTest.php index bbe878d15d55..737f4c0e5dfc 100644 --- a/tests/phpunit/api/v3/ActivityContactTest.php +++ b/tests/phpunit/api/v3/ActivityContactTest.php @@ -39,7 +39,6 @@ class api_v3_ActivityContactTest extends CiviUnitTestCase { protected $_activityID; protected $_params; - public function setUp() { $this->_apiversion = 3; parent::setUp(); diff --git a/tests/phpunit/api/v3/ActivityTest.php b/tests/phpunit/api/v3/ActivityTest.php index 8345c0bdcc7d..6e1b3f602e5b 100644 --- a/tests/phpunit/api/v3/ActivityTest.php +++ b/tests/phpunit/api/v3/ActivityTest.php @@ -268,7 +268,6 @@ public function testActivityCreateWithInvalidPriority() { $this->assertEquals('priority_id', $result['error_field']); } - /** * Test create succeeds with valid string for priority. */ @@ -560,7 +559,6 @@ public function testActivityCreateSupportActivityStatus() { "'Invalid' is not a valid option for field status_id"); } - /** * Test civicrm_activity_create() with using a text status_id. */ @@ -655,7 +653,6 @@ public function testGetFilter() { $this->callAPISuccess('Activity', 'Delete', array('id' => $result['id'])); } - /** * Test civicrm_activity_get() with filter target_contact_id */ @@ -768,7 +765,6 @@ public function testJoinOnTags() { $this->assertEquals($tagDescription, $activityget['tag_id'][$tag['id']]['tag_id.description']); } - /** * Test that activity.get api works to filter on and return files. */ @@ -1391,15 +1387,13 @@ public function testGetWithOr() { */ public function testGetOverdue() { $overdueAct = $this->callAPISuccess('Activity', 'create', array( - 'activity_date_time' => 'now - 1 week', - 'status_id' => 'Scheduled', - ) + $this->_params - ); + 'activity_date_time' => 'now - 1 week', + 'status_id' => 'Scheduled', + ) + $this->_params); $completedAct = $this->callAPISuccess('Activity', 'create', array( - 'activity_date_time' => 'now - 1 week', - 'status_id' => 'Completed', - ) + $this->_params - ); + 'activity_date_time' => 'now - 1 week', + 'status_id' => 'Completed', + ) + $this->_params); $ids = array($overdueAct['id'], $completedAct['id']); // Test sorting diff --git a/tests/phpunit/api/v3/AddressTest.php b/tests/phpunit/api/v3/AddressTest.php index 0307114cccf1..bbbc21cf9a7d 100644 --- a/tests/phpunit/api/v3/AddressTest.php +++ b/tests/phpunit/api/v3/AddressTest.php @@ -416,7 +416,8 @@ public function testGetWithJoin() { public function testCreateAddressStateProvinceIDCorrectForCountry() { $params = $this->_params; $params['sequential'] = 1; - $params['country_id'] = '1228'; // United States country id + // United States country id + $params['country_id'] = '1228'; $params['state_province_id'] = 'Maryland'; $params['city'] = 'Baltimore'; $params['street_address'] = '600 N Charles St.'; @@ -430,7 +431,8 @@ public function testCreateAddressStateProvinceIDCorrectForCountry() { // Now try it in Liberia $params = $this->_params; $params['sequential'] = 1; - $params['country_id'] = '1122'; // Liberia country id + // Liberia country id + $params['country_id'] = '1122'; $params['state_province_id'] = 'Maryland'; $address2 = $this->callAPISuccess('address', 'create', $params); $this->assertEquals('3497', $address2['values'][0]['state_province_id']); @@ -466,8 +468,10 @@ public function testCreateAddressSymbolicCountryAndState($inputCountry, $inputSt 'location_type_id' => 1, 'street_address' => '123 Some St', 'city' => 'Hereville', - 'country_id' => $inputCountry, //'US', - 'state_province_id' => $inputState, // 'California', + //'US', + 'country_id' => $inputCountry, + // 'California', + 'state_province_id' => $inputState, 'postal_code' => '94100', ]); $created = CRM_Utils_Array::first($r['values']); diff --git a/tests/phpunit/api/v3/AttachmentTest.php b/tests/phpunit/api/v3/AttachmentTest.php index 9e313db638d0..9bb5c29dc7e4 100644 --- a/tests/phpunit/api/v3/AttachmentTest.php +++ b/tests/phpunit/api/v3/AttachmentTest.php @@ -45,7 +45,6 @@ public static function getFilePrefix() { return self::$filePrefix; } - protected function setUp() { parent::setUp(); $this->useTransaction(TRUE); @@ -64,7 +63,8 @@ protected function tearDown() { * @return array */ public function okCreateProvider() { - $cases = array(); // array($entityClass, $createParams, $expectedContent) + // array($entityClass, $createParams, $expectedContent) + $cases = array(); $cases[] = array( 'CRM_Activity_DAO_Activity', @@ -108,7 +108,8 @@ public function okCreateProvider() { * @return array */ public function badCreateProvider() { - $cases = array(); // array($entityClass, $createParams, $expectedError) + // array($entityClass, $createParams, $expectedError) + $cases = array(); $cases[] = array( 'CRM_Activity_DAO_Activity', @@ -172,7 +173,8 @@ public function badCreateProvider() { * @return array */ public function badUpdateProvider() { - $cases = array(); // array($entityClass, $createParams, $updateParams, $expectedError) + // array($entityClass, $createParams, $updateParams, $expectedError) + $cases = array(); $readOnlyFields = array( 'name' => 'newname.txt', @@ -204,7 +206,8 @@ public function badUpdateProvider() { * @return array */ public function okGetProvider() { - $cases = array(); // array($getParams, $expectedNames) + // array($getParams, $expectedNames) + $cases = array(); // Each search runs in a DB which contains these attachments: // Activity #123: example_123.txt (text/plain) and example_123.csv (text/csv) @@ -256,7 +259,8 @@ public function okGetProvider() { * @return array */ public function badGetProvider() { - $cases = array(); // array($getParams, $expectedNames) + // array($getParams, $expectedNames) + $cases = array(); // Each search runs in a DB which contains these attachments: // Activity #123: example_123.txt (text/plain) and example_123.csv (text/csv) @@ -309,9 +313,9 @@ public function testCreate($testEntityClass, $createParams, $expectedContent) { $this->assertTrue(is_numeric($entity->id)); $createResult = $this->callAPISuccess('Attachment', 'create', $createParams + array( - 'entity_table' => $entity_table, - 'entity_id' => $entity->id, - )); + 'entity_table' => $entity_table, + 'entity_id' => $entity->id, + )); $fileId = $createResult['id']; $this->assertTrue(is_numeric($fileId)); $this->assertEquals($entity_table, $createResult['values'][$fileId]['entity_table']); @@ -355,9 +359,9 @@ public function testCreateFailure($testEntityClass, $createParams, $expectedErro $this->assertTrue(is_numeric($entity->id)); $createResult = $this->callAPIFailure('Attachment', 'create', $createParams + array( - 'entity_table' => $entity_table, - 'entity_id' => $entity->id, - )); + 'entity_table' => $entity_table, + 'entity_id' => $entity->id, + )); $this->assertRegExp($expectedError, $createResult['error_message']); } @@ -374,15 +378,15 @@ public function testCreateWithBadUpdate($testEntityClass, $createParams, $update $this->assertTrue(is_numeric($entity->id)); $createResult = $this->callAPISuccess('Attachment', 'create', $createParams + array( - 'entity_table' => $entity_table, - 'entity_id' => $entity->id, - )); + 'entity_table' => $entity_table, + 'entity_id' => $entity->id, + )); $fileId = $createResult['id']; $this->assertTrue(is_numeric($fileId)); $updateResult = $this->callAPIFailure('Attachment', 'create', $updateParams + array( - 'id' => $fileId, - )); + 'id' => $fileId, + )); $this->assertRegExp($expectedError, $updateResult['error_message']); } diff --git a/tests/phpunit/api/v3/CaseTest.php b/tests/phpunit/api/v3/CaseTest.php index 873f37e82910..5e53e3967c56 100644 --- a/tests/phpunit/api/v3/CaseTest.php +++ b/tests/phpunit/api/v3/CaseTest.php @@ -380,9 +380,9 @@ public function testCaseGetByActivity() { // Fetch case based on an activity id $result = $this->callAPISuccess('case', 'get', array( - 'activity_id' => $activity, - 'return' => 'activities', - )); + 'activity_id' => $activity, + 'return' => 'activities', + )); $this->assertEquals(FALSE, empty($result['values'][$id])); $this->assertEquals($result['values'][$id], $case); } @@ -400,9 +400,9 @@ public function testCaseGetByContact() { // Fetch case based on client contact id $result = $this->callAPISuccess('case', 'get', array( - 'client_id' => $this->_params['contact_id'], - 'return' => array('activities', 'contacts'), - )); + 'client_id' => $this->_params['contact_id'], + 'return' => array('activities', 'contacts'), + )); $this->assertAPIArrayComparison($result['values'][$id], $case); } @@ -419,9 +419,9 @@ public function testCaseGetBySubject() { // Fetch case based on client contact id $result = $this->callAPISuccess('case', 'get', array( - 'subject' => $this->_params['subject'], - 'return' => array('subject'), - )); + 'subject' => $this->_params['subject'], + 'return' => array('subject'), + )); $this->assertAPIArrayComparison($result['values'][$id], $case); } @@ -433,9 +433,9 @@ public function testCaseGetByWrongSubject() { // Append 'wrong' to subject so that it is no longer the same. $result = $this->callAPISuccess('case', 'get', array( - 'subject' => $this->_params['subject'] . 'wrong', - 'return' => array('activities', 'contacts'), - )); + 'subject' => $this->_params['subject'] . 'wrong', + 'return' => array('activities', 'contacts'), + )); $this->assertEquals(0, $result['count']); } diff --git a/tests/phpunit/api/v3/CaseTypeTest.php b/tests/phpunit/api/v3/CaseTypeTest.php index 7546c73ac788..9a64c1ce91e8 100644 --- a/tests/phpunit/api/v3/CaseTypeTest.php +++ b/tests/phpunit/api/v3/CaseTypeTest.php @@ -127,7 +127,8 @@ public function testCaseTypeCreate_invalidName() { // Create Case Type $params = array( 'title' => 'Application', - 'name' => 'Appl ication', // spaces are not allowed + // spaces are not allowed + 'name' => 'Appl ication', 'is_active' => 1, 'weight' => 4, ); @@ -135,7 +136,6 @@ public function testCaseTypeCreate_invalidName() { $this->callAPIFailure('CaseType', 'create', $params); } - /** * Test update (create with id) function with valid parameters. */ diff --git a/tests/phpunit/api/v3/ContactTest.php b/tests/phpunit/api/v3/ContactTest.php index a42772938229..818068d0363a 100644 --- a/tests/phpunit/api/v3/ContactTest.php +++ b/tests/phpunit/api/v3/ContactTest.php @@ -611,8 +611,8 @@ public function testCreatePreferredLanguageUnset() { $this->callAPISuccess('Contact', 'create', array( 'first_name' => 'Snoop', 'last_name' => 'Dog', - 'contact_type' => 'Individual') - ); + 'contact_type' => 'Individual', + )); $result = $this->callAPISuccessGetSingle('Contact', array('last_name' => 'Dog')); $this->assertEquals('en_US', $result['preferred_language']); } @@ -637,11 +637,10 @@ public function testCreatePreferredLanguageSet() { public function testCreatePreferredLanguageNull() { $this->callAPISuccess('Setting', 'create', array('contact_default_language' => 'null')); $this->callAPISuccess('Contact', 'create', array( - 'first_name' => 'Snoop', - 'last_name' => 'Dog', - 'contact_type' => 'Individual', - ) - ); + 'first_name' => 'Snoop', + 'last_name' => 'Dog', + 'contact_type' => 'Individual', + )); $result = $this->callAPISuccessGetSingle('Contact', array('last_name' => 'Dog')); $this->assertEquals(NULL, $result['preferred_language']); } @@ -731,7 +730,6 @@ public function testCreateContactCustomFldDateTime() { $this->callAPISuccess('Contact', 'create', $params); } - /** * Test creating a current employer through API. */ @@ -743,21 +741,18 @@ public function testContactCreateCurrentEmployer() { )); $this->assertEquals(0, $count); $employerResult = $this->callAPISuccess('contact', 'create', array_merge($this->_params, array( - 'current_employer' => 'new employer org', - ) - )); + 'current_employer' => 'new employer org', + ))); // do it again as an update to check it doesn't cause an error $employerResult = $this->callAPISuccess('contact', 'create', array_merge($this->_params, array( - 'current_employer' => 'new employer org', - 'id' => $employerResult['id'], - ) - )); + 'current_employer' => 'new employer org', + 'id' => $employerResult['id'], + ))); $expectedCount = 1; $this->callAPISuccess('contact', 'getcount', array( - 'organization_name' => 'new employer org', - 'contact_type' => 'Organization', - ), - $expectedCount); + 'organization_name' => 'new employer org', + 'contact_type' => 'Organization', + ), $expectedCount); $result = $this->callAPISuccess('contact', 'getsingle', array( 'id' => $employerResult['id'], @@ -775,8 +770,8 @@ public function testContactCreateCurrentEmployer() { public function testContactCreateDuplicateCurrentEmployerEnables() { // Set up - create employer relationship. $employerResult = $this->callAPISuccess('contact', 'create', array_merge($this->_params, array( - 'current_employer' => 'new employer org', - ) + 'current_employer' => 'new employer org', + ) )); $relationship = $this->callAPISuccess('relationship', 'get', array( 'contact_id_a' => $employerResult['id'], @@ -791,9 +786,9 @@ public function testContactCreateDuplicateCurrentEmployerEnables() { // Re-set the current employer - thus enabling the relationship. $this->callAPISuccess('contact', 'create', array_merge($this->_params, array( - 'current_employer' => 'new employer org', - 'id' => $employerResult['id'], - ) + 'current_employer' => 'new employer org', + 'id' => $employerResult['id'], + ) )); //check is_active is now 1 $relationship = $this->callAPISuccess('relationship', 'getsingle', array( @@ -993,7 +988,8 @@ public function testSortLimitChainedRelationshipGetCRM15983() { 'options' => array( 'limit' => '1', 'sort' => 'start_date DESC', - )), + ), + ), ); $get_result = $this->callAPISuccess('contact', 'getsingle', $get_params); @@ -1047,7 +1043,7 @@ public function testGetByAddresseeID() { 'skip_greeting_processing' => 1, 'addressee_id' => 'null', 'email_greeting_id' => 'null', - 'postal_greeting_id' => 'null' + 'postal_greeting_id' => 'null', ]); $individual2ID = $this->individualCreate(); @@ -1350,10 +1346,10 @@ public function testDirectionChainingRelationshipsCRM16084() { // Clean up first. $this->callAPISuccess('contact', 'delete', array( 'id' => $create_result_1['id'], - )); + )); $this->callAPISuccess('contact', 'delete', array( 'id' => $create_result_2['id'], - )); + )); $this->callAPISuccess('contact', 'delete', array( 'id' => $create_result_2['id'], )); @@ -1569,9 +1565,8 @@ public function testMergeOrganizations() { $organizationID1 = $this->organizationCreate(array(), 0); $organizationID2 = $this->organizationCreate(array(), 1); $contact = $this->callAPISuccess('contact', 'create', array_merge($this->_params, array( - 'employer_id' => $organizationID1, - ) - )); + 'employer_id' => $organizationID1, + ))); $contact = $contact["values"][$contact["id"]]; $membershipType = $this->createEmployerOfMembership(); @@ -1941,7 +1936,6 @@ public function testPseudoFields() { ), $result['preferred_communication_method']); } - /** * Test birth date parameters. * @@ -3807,7 +3801,8 @@ public function testCreateCommunicationStyleUnset() { $this->callAPISuccess('Contact', 'create', array( 'first_name' => 'John', 'last_name' => 'Doe', - 'contact_type' => 'Individual') + 'contact_type' => 'Individual', + ) ); $result = $this->callAPISuccessGetSingle('Contact', array('last_name' => 'Doe')); $this->assertEquals(1, $result['communication_style_id']); @@ -3934,37 +3929,43 @@ public function testSmartGroupsForRelatedContacts() { 'contact_id_a' => $c1, 'contact_id_b' => $c2, 'is_active' => 1, - 'relationship_type_id' => $rtype1['id'], // Child of + // Child of + 'relationship_type_id' => $rtype1['id'], )); $this->callAPISuccess('relationship', 'create', array( 'contact_id_a' => $c1, 'contact_id_b' => $h1, 'is_active' => 1, - 'relationship_type_id' => $rtype2['id'], // Household Member of + // Household Member of + 'relationship_type_id' => $rtype2['id'], )); $this->callAPISuccess('relationship', 'create', array( 'contact_id_a' => $c2, 'contact_id_b' => $h1, 'is_active' => 1, - 'relationship_type_id' => $rtype2['id'], // Household Member of + // Household Member of + 'relationship_type_id' => $rtype2['id'], )); $ssParams = array( 'formValues' => array( - 'display_relationship_type' => $rtype1['id'] . '_a_b', // Child of + // Child of + 'display_relationship_type' => $rtype1['id'] . '_a_b', 'sort_name' => 'Adams', ), ); $g1ID = $this->smartGroupCreate($ssParams, array('name' => uniqid(), 'title' => uniqid())); $ssParams = array( 'formValues' => array( - 'display_relationship_type' => $rtype2['id'] . '_a_b', // Household Member of + // Household Member of + 'display_relationship_type' => $rtype2['id'] . '_a_b', ), ); $g2ID = $this->smartGroupCreate($ssParams, array('name' => uniqid(), 'title' => uniqid())); $ssParams = array( 'formValues' => array( - 'display_relationship_type' => $rtype2['id'] . '_b_a', // Household Member is + // Household Member is + 'display_relationship_type' => $rtype2['id'] . '_b_a', ), ); // the reverse of g2 which adds another layer for overlap at related contact filter @@ -4023,7 +4024,7 @@ public function testContactGetWithTag() { $tags = []; foreach (['Tag A', 'Tag B'] as $name) { $tags[] = $this->callApiSuccess('Tag', 'create', [ - 'name' => $name + 'name' => $name, ]); } @@ -4066,7 +4067,7 @@ public function testContactGetWithTag() { } $this->callAPISuccess('Contact', 'delete', [ 'id' => $contact['id'], - 'skip_undelete' => TRUE + 'skip_undelete' => TRUE, ]); } diff --git a/tests/phpunit/api/v3/ContactTypeTest.php b/tests/phpunit/api/v3/ContactTypeTest.php index 0219a3e410c4..61fc14926ea9 100644 --- a/tests/phpunit/api/v3/ContactTypeTest.php +++ b/tests/phpunit/api/v3/ContactTypeTest.php @@ -110,7 +110,6 @@ public function testContactCreate() { $this->callAPISuccess('contact', 'delete', $params); } - /** * Test add with invalid data. */ @@ -134,7 +133,6 @@ public function testContactAddInvalidData() { $contact = $this->callAPIFailure('contact', 'create', $contactParams); } - /** * Test update with no subtype to valid subtype. * success expected @@ -200,7 +198,6 @@ public function testContactUpdateNoSubtypeValid() { $this->callAPISuccess('contact', 'delete', $params); } - /** * Test update with no subtype to invalid subtype. */ diff --git a/tests/phpunit/api/v3/ContributionPageTest.php b/tests/phpunit/api/v3/ContributionPageTest.php index e773ba39f0ce..2c663e924fc5 100644 --- a/tests/phpunit/api/v3/ContributionPageTest.php +++ b/tests/phpunit/api/v3/ContributionPageTest.php @@ -112,7 +112,8 @@ public function testGetContributionPageByAmount() { $createResult = $this->callAPISuccess($this->_entity, 'create', $this->params); $this->id = $createResult['id']; $getParams = array( - 'amount' => '' . $this->testAmount, // 3456 + // 3456 + 'amount' => '' . $this->testAmount, 'currency' => 'NZD', 'financial_type_id' => 1, ); @@ -133,7 +134,6 @@ public function testGetFieldsContributionPage() { $this->assertEquals(12, $result['values']['start_date']['type']); } - /** * Test form submission with basic price set. */ @@ -438,13 +438,11 @@ public function testSubmitMembershipBlockNotSeparatePaymentZeroDollarsWithEmail( $this->assertCount(1, $msgs); $mut->checkMailLog(array( - 'Membership Type: General', - 'Gruffier', - ), - array( - 'Amount', - ) - ); + 'Membership Type: General', + 'Gruffier', + ), array( + 'Amount', + )); $mut->stop(); $mut->clearMessages(); } @@ -504,7 +502,6 @@ public function testSubmitMembershipBlockIsSeparatePayment() { $this->assertEquals($membership['contact_id'], $contributions['values'][$membershipPayment['contribution_id']]['contact_id']); } - /** * Test submit with a membership block in place. */ @@ -1277,23 +1274,21 @@ public function testSubmitMembershipPriceSetPaymentPaymentProcessorRecurDelayed( $membership = $this->callAPISuccessGetSingle('membership', array('id' => $membershipPayment['membership_id'])); //renew it with processor setting completed - should extend membership $submitParams = array_merge($submitParams, array( - 'contact_id' => $contribution['contact_id'], - 'is_recur' => 1, - 'frequency_interval' => 1, - 'frequency_unit' => $this->params['recur_frequency_unit'], - ) - ); + 'contact_id' => $contribution['contact_id'], + 'is_recur' => 1, + 'frequency_interval' => 1, + 'frequency_unit' => $this->params['recur_frequency_unit'], + )); $dummyPP->setDoDirectPaymentResult(array('payment_status_id' => 2)); $this->callAPISuccess('contribution_page', 'submit', $submitParams); $newContribution = $this->callAPISuccess('contribution', 'getsingle', array( - 'id' => array( - 'NOT IN' => array($contribution['id']), - ), - 'contribution_page_id' => $this->_ids['contribution_page'], - 'contribution_status_id' => 2, - ) - ); + 'id' => array( + 'NOT IN' => array($contribution['id']), + ), + 'contribution_page_id' => $this->_ids['contribution_page'], + 'contribution_status_id' => 2, + )); $line = $this->callAPISuccess('line_item', 'getsingle', array('contribution_id' => $newContribution['id'])); $this->assertEquals('civicrm_membership', $line['entity_table']); $this->assertEquals($membership['id'], $line['entity_id']); @@ -1339,7 +1334,6 @@ public function testSubmitMembershipIsSeparatePaymentNotRecur() { $this->assertEmpty($recur['count']); } - /** * Set up membership contribution page. * @param bool $isSeparatePayment @@ -1502,34 +1496,31 @@ public function setUpContributionPage($isRecur = FALSE) { } if (empty($this->_ids['price_field_value'])) { $this->callAPISuccess('price_field_value', 'create', array( - 'price_set_id' => $priceSetID, - 'price_field_id' => $priceField['id'], - 'label' => 'Long Haired Goat', - 'financial_type_id' => 'Donation', - 'amount' => 20, - 'non_deductible_amount' => 15, - ) - ); + 'price_set_id' => $priceSetID, + 'price_field_id' => $priceField['id'], + 'label' => 'Long Haired Goat', + 'financial_type_id' => 'Donation', + 'amount' => 20, + 'non_deductible_amount' => 15, + )); $priceFieldValue = $this->callAPISuccess('price_field_value', 'create', array( - 'price_set_id' => $priceSetID, - 'price_field_id' => $priceField['id'], - 'label' => 'Shoe-eating Goat', - 'financial_type_id' => 'Donation', - 'amount' => 10, - 'non_deductible_amount' => 5, - ) - ); + 'price_set_id' => $priceSetID, + 'price_field_id' => $priceField['id'], + 'label' => 'Shoe-eating Goat', + 'financial_type_id' => 'Donation', + 'amount' => 10, + 'non_deductible_amount' => 5, + )); $this->_ids['price_field_value'] = array($priceFieldValue['id']); $this->_ids['price_field_value']['cheapskate'] = $this->callAPISuccess('price_field_value', 'create', array( - 'price_set_id' => $priceSetID, - 'price_field_id' => $priceField['id'], - 'label' => 'Stingy Goat', - 'financial_type_id' => 'Donation', - 'amount' => 0, - 'non_deductible_amount' => 0, - ) - )['id']; + 'price_set_id' => $priceSetID, + 'price_field_id' => $priceField['id'], + 'label' => 'Stingy Goat', + 'financial_type_id' => 'Donation', + 'amount' => 0, + 'non_deductible_amount' => 0, + ))['id']; } $this->_ids['contribution_page'] = $contributionPageResult['id']; } @@ -1544,7 +1535,8 @@ public function setUpMultiIntervalMembershipContributionPage() { $this->_ids['contribution_page'] = $contributionPage['id']; $this->_ids['membership_type'] = $this->membershipTypeCreate(array( - 'auto_renew' => 2, // force auto-renew + // force auto-renew + 'auto_renew' => 2, 'duration_unit' => 'month', )); @@ -1696,7 +1688,8 @@ public function testSubmitPledgePaymentPaymentProcessorRecurFuturePayment() { // Check if contribution created. $contribution = $this->callAPISuccess('contribution', 'getsingle', array( 'contribution_page_id' => $this->_ids['contribution_page'], - 'contribution_status_id' => 'Completed', // Will be pending when actual payment processor is used (dummy processor does not support future payments). + // Will be pending when actual payment processor is used (dummy processor does not support future payments). + 'contribution_status_id' => 'Completed', )); $this->assertEquals('create_first_success', $contribution['trxn_id']); @@ -1714,13 +1707,15 @@ public function testSubmitPledgePaymentPaymentProcessorRecurFuturePayment() { $this->assertEquals($pledgePayment['count'], 3); $this->assertEquals(date('Ymd', strtotime($pledgePayment['values'][1]['scheduled_date'])), date('Ymd', strtotime("+1 month"))); $this->assertEquals($pledgePayment['values'][1]['scheduled_amount'], 100.00); - $this->assertEquals($pledgePayment['values'][1]['status_id'], 1); // Will be pending when actual payment processor is used (dummy processor does not support future payments). + // Will be pending when actual payment processor is used (dummy processor does not support future payments). + $this->assertEquals($pledgePayment['values'][1]['status_id'], 1); // Check contribution recur record. $recur = $this->callAPISuccess('contribution_recur', 'getsingle', array('id' => $contribution['contribution_recur_id'])); $this->assertEquals(date('Ymd', strtotime($recur['start_date'])), date('Ymd', strtotime("+1 month"))); $this->assertEquals($recur['amount'], 100.00); - $this->assertEquals($recur['contribution_status_id'], 5); // In progress status. + // In progress status. + $this->assertEquals($recur['contribution_status_id'], 5); } /** @@ -1912,7 +1907,6 @@ public function testSubmitContributionPageWithPriceSetQuantity($thousandSeparato $this->assertEquals($lineItem_TaxAmount, round(180 * 16.95 * 0.10, 2), 'Wrong Sales Tax Amount is calculated and stored.'); } - /** * Test validating a contribution page submit. */ diff --git a/tests/phpunit/api/v3/ContributionSoftTest.php b/tests/phpunit/api/v3/ContributionSoftTest.php index d335202902ee..fe23a9717271 100644 --- a/tests/phpunit/api/v3/ContributionSoftTest.php +++ b/tests/phpunit/api/v3/ContributionSoftTest.php @@ -61,7 +61,6 @@ class api_v3_ContributionSoftTest extends CiviUnitTestCase { public $debug = 0; protected $_params; - public function setUp() { parent::setUp(); $this->useTransaction(TRUE); @@ -148,9 +147,8 @@ public function testGetContributionSoft() { //test get by contact id works $result = $this->callAPISuccess('contribution_soft', 'get', array( - 'contact_id' => $this->_softIndividual2Id, - ) - ); + 'contact_id' => $this->_softIndividual2Id, + )); $this->assertEquals(1, $result['count']); $this->callAPISuccess('contribution_soft', 'Delete', array( @@ -168,7 +166,6 @@ public function testGetContributionSoft() { )); } - /** * civicrm_contribution_soft. */ diff --git a/tests/phpunit/api/v3/ContributionTest.php b/tests/phpunit/api/v3/ContributionTest.php index 9b99b42f9fd6..70d339f05223 100644 --- a/tests/phpunit/api/v3/ContributionTest.php +++ b/tests/phpunit/api/v3/ContributionTest.php @@ -34,9 +34,6 @@ */ class api_v3_ContributionTest extends CiviUnitTestCase { - /** - * Assume empty database with just civicrm_data. - */ protected $_individualId; protected $_contribution; protected $_financialTypeId = 1; @@ -979,7 +976,6 @@ public function testCreateContributionWithFee() { $this->_checkFinancialRecords($contribution, 'feeAmount'); } - /** * Function tests that additional financial records are created when online contribution is created. */ @@ -1188,10 +1184,9 @@ public function testCreateUpdateContributionPayLater() { $contribution = $this->callAPISuccess('contribution', 'create', $contribParams); $newParams = array_merge($contribParams, array( - 'id' => $contribution['id'], - 'contribution_status_id' => 1, - ) - ); + 'id' => $contribution['id'], + 'contribution_status_id' => 1, + )); $contribution = $this->callAPISuccess('contribution', 'create', $newParams); $contribution = $contribution['values'][$contribution['id']]; $this->assertEquals($contribution['contribution_status_id'], '1'); @@ -1215,10 +1210,9 @@ public function testCreateUpdateContributionPaymentInstrument() { $contribution = $this->callAPISuccess('contribution', 'create', $contribParams); $newParams = array_merge($contribParams, array( - 'id' => $contribution['id'], - 'payment_instrument_id' => $instrumentId, - ) - ); + 'id' => $contribution['id'], + 'payment_instrument_id' => $instrumentId, + )); $contribution = $this->callAPISuccess('contribution', 'create', $newParams); $this->assertAPISuccess($contribution); $this->checkFinancialTrxnPaymentInstrumentChange($contribution['id'], 4, $instrumentId); @@ -1243,10 +1237,9 @@ public function testCreateUpdateNegativeContributionPaymentInstrument() { $contribution = $this->callAPISuccess('contribution', 'create', $contribParams); $newParams = array_merge($contribParams, array( - 'id' => $contribution['id'], - 'payment_instrument_id' => $instrumentId, - ) - ); + 'id' => $contribution['id'], + 'payment_instrument_id' => $instrumentId, + )); $contribution = $this->callAPISuccess('contribution', 'create', $newParams); $this->assertAPISuccess($contribution); $this->checkFinancialTrxnPaymentInstrumentChange($contribution['id'], 4, $instrumentId, -100); @@ -1270,12 +1263,11 @@ public function testCreateUpdateContributionRefund() { ); $contribution = $this->callAPISuccess('contribution', 'create', $contributionParams); $newParams = array_merge($contributionParams, array( - 'id' => $contribution['id'], - 'contribution_status_id' => 'Refunded', - 'cancel_date' => '2015-01-01 09:00', - 'refund_trxn_id' => 'the refund', - ) - ); + 'id' => $contribution['id'], + 'contribution_status_id' => 'Refunded', + 'cancel_date' => '2015-01-01 09:00', + 'refund_trxn_id' => 'the refund', + )); $contribution = $this->callAPISuccess('contribution', 'create', $newParams); $this->_checkFinancialTrxn($contribution, 'refund'); @@ -1406,12 +1398,11 @@ public function testCreateUpdateContributionRefundTrxnIDPassedIn() { ); $contribution = $this->callAPISuccess('contribution', 'create', $contributionParams); $newParams = array_merge($contributionParams, array( - 'id' => $contribution['id'], - 'contribution_status_id' => 'Refunded', - 'cancel_date' => '2015-01-01 09:00', - 'trxn_id' => 'the refund', - ) - ); + 'id' => $contribution['id'], + 'contribution_status_id' => 'Refunded', + 'cancel_date' => '2015-01-01 09:00', + 'trxn_id' => 'the refund', + )); $contribution = $this->callAPISuccess('contribution', 'create', $newParams); $this->_checkFinancialTrxn($contribution, 'refund'); @@ -1441,13 +1432,12 @@ public function testCreateUpdateContributionRefundRefundAndTrxnIDPassedIn() { ); $contribution = $this->callAPISuccess('contribution', 'create', $contributionParams); $newParams = array_merge($contributionParams, array( - 'id' => $contribution['id'], - 'contribution_status_id' => 'Refunded', - 'cancel_date' => '2015-01-01 09:00', - 'trxn_id' => 'cont id', - 'refund_trxn_id' => 'the refund', - ) - ); + 'id' => $contribution['id'], + 'contribution_status_id' => 'Refunded', + 'cancel_date' => '2015-01-01 09:00', + 'trxn_id' => 'cont id', + 'refund_trxn_id' => 'the refund', + )); $contribution = $this->callAPISuccess('contribution', 'create', $newParams); $this->_checkFinancialTrxn($contribution, 'refund'); @@ -1477,13 +1467,12 @@ public function testCreateUpdateContributionRefundRefundNullTrxnIDPassedIn() { ); $contribution = $this->callAPISuccess('contribution', 'create', $contributionParams); $newParams = array_merge($contributionParams, array( - 'id' => $contribution['id'], - 'contribution_status_id' => 'Refunded', - 'cancel_date' => '2015-01-01 09:00', - 'trxn_id' => 'cont id', - 'refund_trxn_id' => '', - ) - ); + 'id' => $contribution['id'], + 'contribution_status_id' => 'Refunded', + 'cancel_date' => '2015-01-01 09:00', + 'trxn_id' => 'cont id', + 'refund_trxn_id' => '', + )); $contribution = $this->callAPISuccess('contribution', 'create', $newParams); $this->_checkFinancialTrxn($contribution, 'refund', NULL, array('trxn_id' => NULL)); @@ -1508,10 +1497,9 @@ public function testCreateUpdateContributionInValidStatusChange() { ); $contribution = $this->callAPISuccess('contribution', 'create', $contribParams); $newParams = array_merge($contribParams, array( - 'id' => $contribution['id'], - 'contribution_status_id' => 2, - ) - ); + 'id' => $contribution['id'], + 'contribution_status_id' => 2, + )); $this->callAPIFailure('contribution', 'create', $newParams, ts('Cannot change contribution status from Completed to Pending.')); } @@ -1532,11 +1520,10 @@ public function testCreateUpdateContributionCancelPending() { ); $contribution = $this->callAPISuccess('contribution', 'create', $contribParams); $newParams = array_merge($contribParams, array( - 'id' => $contribution['id'], - 'contribution_status_id' => 3, - 'cancel_date' => '2012-02-02 09:00', - ) - ); + 'id' => $contribution['id'], + 'contribution_status_id' => 3, + 'cancel_date' => '2012-02-02 09:00', + )); //Check if trxn_date is same as cancel_date. $checkTrxnDate = array( 'trxn_date' => '2012-02-02 09:00:00', @@ -1561,10 +1548,9 @@ public function testCreateUpdateContributionChangeFinancialType() { ); $contribution = $this->callAPISuccess('contribution', 'create', $contribParams); $newParams = array_merge($contribParams, array( - 'id' => $contribution['id'], - 'financial_type_id' => 3, - ) - ); + 'id' => $contribution['id'], + 'financial_type_id' => 3, + )); $contribution = $this->callAPISuccess('contribution', 'create', $newParams); $this->_checkFinancialTrxn($contribution, 'changeFinancial'); $this->_checkFinancialItem($contribution['id'], 'changeFinancial'); @@ -1632,7 +1618,6 @@ public function testCreateUpdateContribution() { $new_params = array( 'contribution_id' => $contribution['id'], - ); $contribution = $this->callAPISuccessGetSingle('contribution', $new_params); @@ -1652,7 +1637,6 @@ public function testCreateUpdateContribution() { $params = array( 'contribution_id' => $contributionID, - ); $result = $this->callAPISuccess('contribution', 'delete', $params); $this->assertAPISuccess($result); @@ -1706,7 +1690,7 @@ public function testUpdateContributionNetAmountVariants() { $this->callAPISuccess('Contribution', 'create', [ 'id' => $contributionID, - 'payment_instrument' => 'Cash' + 'payment_instrument' => 'Cash', ]); $contribution = $this->callAPISuccessGetSingle('Contribution', [ 'id' => $contributionID, @@ -1734,7 +1718,6 @@ public function testDeleteParamsNotArrayContribution() { public function testDeleteWrongParamContribution() { $params = array( 'contribution_source' => 'SSF', - ); $this->callAPIFailure('contribution', 'delete', $params); } @@ -1770,7 +1753,6 @@ public function testSearchEmptyParams() { 'invoice_id' => 78910, 'source' => 'SSF', 'contribution_status_id' => 1, - ); $contribution = $this->callAPISuccess('contribution', 'create', $p); @@ -1804,7 +1786,6 @@ public function testSearch() { 'financial_type_id' => $this->_financialTypeId, 'non_deductible_amount' => 10.00, 'contribution_status_id' => 1, - ); $contribution1 = $this->callAPISuccess('contribution', 'create', $p1); @@ -1819,13 +1800,11 @@ public function testSearch() { 'fee_amount' => 50.00, 'net_amount' => 60.00, 'contribution_status_id' => 2, - ); $contribution2 = $this->callAPISuccess('contribution', 'create', $p2); $params = array( 'contribution_id' => $contribution2['id'], - ); $result = $this->callAPISuccess('contribution', 'get', $params); $res = $result['values'][$contribution2['id']]; @@ -2007,7 +1986,7 @@ public function testBillingAddress() { $params = array_merge($this->_params, array( 'contribution_status_id' => 2, 'address_id' => $address['id'], - ) + ) ); $contribution = $this->callAPISuccess('contribution', 'create', $params); $this->callAPISuccess('contribution', 'completetransaction', array( @@ -2075,14 +2054,14 @@ public function testCheckTaxAmount($thousandSeparator) { 'is_active' => 1, )); $financialAccount = $this->callAPISuccess('financial_account', 'create', array( - 'name' => 'Test Tax financial account ', - 'contact_id' => $contact, - 'financial_account_type_id' => 2, - 'is_tax' => 1, - 'tax_rate' => 5.00, - 'is_reserved' => 0, - 'is_active' => 1, - 'is_default' => 0, + 'name' => 'Test Tax financial account ', + 'contact_id' => $contact, + 'financial_account_type_id' => 2, + 'is_tax' => 1, + 'tax_rate' => 5.00, + 'is_reserved' => 0, + 'is_active' => 1, + 'is_default' => 0, )); $financialTypeId = $financialType['id']; $financialAccountId = $financialAccount['id']; @@ -2098,9 +2077,9 @@ public function testCheckTaxAmount($thousandSeparator) { $contribution = $this->callAPISuccess('contribution', 'create', $params); $contribution1 = $this->callAPISuccess('contribution', 'get', array('id' => $contribution['id'], 'return' => 'tax_amount', 'sequential' => 1)); $this->callAPISuccess('contribution', 'completetransaction', array( - 'id' => $contribution['id'], - 'trxn_id' => '777788888', - 'fee_amount' => '6.00', + 'id' => $contribution['id'], + 'trxn_id' => '777788888', + 'fee_amount' => '6.00', )); $contribution2 = $this->callAPISuccess('contribution', 'get', array('id' => $contribution['id'], 'return' => array('tax_amount', 'fee_amount', 'net_amount'), 'sequential' => 1)); $this->assertEquals($contribution1['values'][0]['tax_amount'], $contribution2['values'][0]['tax_amount']); @@ -2309,15 +2288,15 @@ public function testRepeatTransactionMembershipRenewCompletedContribution() { )); $this->callAPISuccess('membership', 'create', array( - 'id' => $membership['id'], - 'end_date' => 'yesterday', - 'status_id' => 'Expired', + 'id' => $membership['id'], + 'end_date' => 'yesterday', + 'status_id' => 'Expired', )); $contribution = $this->callAPISuccess('contribution', 'repeattransaction', array( - 'contribution_recur_id' => $originalContribution['values'][1]['contribution_recur_id'], - 'contribution_status_id' => 'Completed', - 'trxn_id' => 'bobsled', + 'contribution_recur_id' => $originalContribution['values'][1]['contribution_recur_id'], + 'contribution_status_id' => 'Completed', + 'trxn_id' => 'bobsled', )); $membershipStatusId = $this->callAPISuccess('membership', 'getvalue', array( @@ -2710,7 +2689,6 @@ public function testRepeatTransactionUpdatedFinancialTypeAndNotEquals() { $this->assertEquals($expectedLineItem, $lineItem2['values'][0]); } - /** * Test completing a transaction does not 'mess' with net amount (CRM-15960). */ @@ -2797,6 +2775,7 @@ public function testCompleteTransactionForRecurring() { $this->mut->stop(); $this->revertTemplateToReservedTemplate(); } + /** * CRM-19710 - Test to ensure that completetransaction respects the input for is_email_receipt setting. * @@ -3036,8 +3015,8 @@ public function testCompleteTransactionWithParticipantRecord() { $this->_individualId = $this->createLoggedInUser(); $contributionID = $this->createPendingParticipantContribution(); $this->callAPISuccess('contribution', 'completetransaction', array( - 'id' => $contributionID, - ) + 'id' => $contributionID, + ) ); $participantStatus = $this->callAPISuccessGetValue('participant', array( 'id' => $this->_ids['participant'], @@ -3069,7 +3048,8 @@ public function testCompleteTransactionMembershipPriceSet() { $this->createPriceSetWithPage('membership'); $stateOfGrace = $this->callAPISuccess('MembershipStatus', 'getvalue', array( 'name' => 'Grace', - 'return' => 'id') + 'return' => 'id', + ) ); $this->setUpPendingContribution($this->_ids['price_field_value'][0]); $membership = $this->callAPISuccess('membership', 'getsingle', array('id' => $this->_ids['membership'])); @@ -3249,6 +3229,7 @@ public function cleanUpAfterPriceSets() { * Set up a pending transaction with a specific price field id. * * @param int $priceFieldValueID + * @param array $contriParams */ public function setUpPendingContribution($priceFieldValueID, $contriParams = array()) { $contactID = $this->individualCreate(); @@ -3298,18 +3279,16 @@ public function testSendMail() { $mut = new CiviMailUtils($this, TRUE); $contribution = $this->callAPISuccess('contribution', 'create', $this->_params); $this->callAPISuccess('contribution', 'sendconfirmation', array( - 'id' => $contribution['id'], - 'receipt_from_email' => 'api@civicrm.org', - ) - ); + 'id' => $contribution['id'], + 'receipt_from_email' => 'api@civicrm.org', + )); $mut->checkMailLog(array( - '$ 100.00', - 'Contribution Information', - 'Please print this confirmation for your records', - ), array( - 'Event', - ) - ); + '$ 100.00', + 'Contribution Information', + 'Please print this confirmation for your records', + ), array( + 'Event', + )); $this->checkCreditCardDetails($mut, $contribution['id']); $mut->stop(); @@ -3360,10 +3339,9 @@ public function testSendconfirmationPayLater() { // Create email try { civicrm_api3('contribution', 'sendconfirmation', array( - 'id' => $contribution['id'], - 'receipt_from_email' => 'api@civicrm.org', - ) - ); + 'id' => $contribution['id'], + 'receipt_from_email' => 'api@civicrm.org', + )); } catch (Exception $e) { // Need to figure out how to stop this some other day @@ -3377,16 +3355,14 @@ public function testSendconfirmationPayLater() { // Retrieve mail & check it has the pay_later_receipt info $mut->getMostRecentEmail('raw'); $mut->checkMailLog(array( - (string) $contribParams['total_amount'], - $pageParams['pay_later_receipt'], - ), array( - 'Event', - ) - ); + (string) $contribParams['total_amount'], + $pageParams['pay_later_receipt'], + ), array( + 'Event', + )); $mut->stop(); } - /** * Check credit card details in sent mail via API * @@ -3397,19 +3373,20 @@ public function testSendconfirmationPayLater() { public function checkCreditCardDetails($mut, $contributionID) { $contribution = $this->callAPISuccess('contribution', 'create', $this->_params); $this->callAPISuccess('contribution', 'sendconfirmation', array( - 'id' => $contributionID, - 'receipt_from_email' => 'api@civicrm.org', - 'payment_processor_id' => $this->paymentProcessorID, - ) - ); + 'id' => $contributionID, + 'receipt_from_email' => 'api@civicrm.org', + 'payment_processor_id' => $this->paymentProcessorID, + )); $mut->checkMailLog(array( - 'Credit Card Information', // credit card header - 'Billing Name and Address', // billing header - 'anthony_anderson@civicrm.org', // billing name - ), array( - 'Event', - ) - ); + // credit card header + 'Credit Card Information', + // billing header + 'Billing Name and Address', + // billing name + 'anthony_anderson@civicrm.org', + ), array( + 'Event', + )); } /** @@ -3439,17 +3416,15 @@ public function testSendMailEvent() { 'contribution_id' => $contribution['id'], )); $this->callAPISuccess('contribution', 'sendconfirmation', array( - 'id' => $contribution['id'], - 'receipt_from_email' => 'api@civicrm.org', - ) - ); + 'id' => $contribution['id'], + 'receipt_from_email' => 'api@civicrm.org', + )); $mut->checkMailLog(array( - 'Annual CiviCRM meet', - 'Event', - 'To: "Mr. Anthony Anderson II" ', - ), array() - ); + 'Annual CiviCRM meet', + 'Event', + 'To: "Mr. Anthony Anderson II" ', + ), array()); $mut->stop(); } @@ -3466,7 +3441,6 @@ public function contributionGetnCheck($params, $id, $delete = TRUE) { $contribution = $this->callAPISuccess('Contribution', 'Get', array( 'id' => $id, - )); if ($delete) { @@ -3493,9 +3467,8 @@ public function createPendingPledgeContribution() { $this->_ids['pledge'] = $pledgeID; $contribution = $this->callAPISuccess('contribution', 'create', array_merge($this->_params, array( 'contribution_status_id' => 'Pending', - 'total_amount' => 500, - )) - ); + 'total_amount' => 500, + ))); $paymentID = $this->callAPISuccessGetValue('PledgePayment', array( 'options' => array('limit' => 1), 'return' => 'id', @@ -3644,6 +3617,7 @@ public function _checkFinancialItem($contId, $context) { * @param int $contributionID * @param int $originalInstrumentID * @param int $newInstrumentID + * @param int $amount */ public function checkFinancialTrxnPaymentInstrumentChange($contributionID, $originalInstrumentID, $newInstrumentID, $amount = 100) { @@ -3853,17 +3827,17 @@ protected function setUpRecurringContribution($generalParams = array(), $recurPa */ protected function setUpAutoRenewMembership($generalParams = array(), $recurParams = array()) { $newContact = $this->callAPISuccess('Contact', 'create', array( - 'contact_type' => 'Individual', - 'sort_name' => 'McTesterson, Testy', - 'display_name' => 'Testy McTesterson', - 'preferred_language' => 'en_US', - 'preferred_mail_format' => 'Both', - 'first_name' => 'Testy', - 'last_name' => 'McTesterson', - 'contact_is_deleted' => '0', - 'email_id' => '4', - 'email' => 'tmctesterson@example.com', - 'on_hold' => '0', + 'contact_type' => 'Individual', + 'sort_name' => 'McTesterson, Testy', + 'display_name' => 'Testy McTesterson', + 'preferred_language' => 'en_US', + 'preferred_mail_format' => 'Both', + 'first_name' => 'Testy', + 'last_name' => 'McTesterson', + 'contact_is_deleted' => '0', + 'email_id' => '4', + 'email' => 'tmctesterson@example.com', + 'on_hold' => '0', )); $membershipType = $this->callAPISuccess('MembershipType', 'create', array( 'domain_id' => "Default Domain Name", @@ -3915,11 +3889,13 @@ protected function setUpAutoRenewMembership($generalParams = array(), $recurPara return array($originalContribution, $membership); } + /** * Set up a repeat transaction. * * @param array $recurParams - * + * @param mixed $flag + * @param array $contributionParams * @return array */ protected function setUpRepeatTransaction($recurParams = array(), $flag, $contributionParams = array()) { @@ -4067,13 +4043,12 @@ public function testSendMailWithAPISetFromDetails() { 'receipt_from_name' => 'CiviCRM LLC', )); $mut->checkMailLog(array( - 'From: CiviCRM LLC ', - 'Contribution Information', - 'Please print this confirmation for your records', - ), array( - 'Event', - ) - ); + 'From: CiviCRM LLC ', + 'Contribution Information', + 'Please print this confirmation for your records', + ), array( + 'Event', + )); $mut->stop(); } @@ -4089,13 +4064,12 @@ public function testSendMailWithNoFromSetFallToDomain() { )); $domain = $this->callAPISuccess('domain', 'getsingle', array('id' => 1)); $mut->checkMailLog(array( - 'From: ' . $domain['from_name'] . ' <' . $domain['from_email'] . '>', - 'Contribution Information', - 'Please print this confirmation for your records', - ), array( - 'Event', - ) - ); + 'From: ' . $domain['from_name'] . ' <' . $domain['from_email'] . '>', + 'Contribution Information', + 'Please print this confirmation for your records', + ), array( + 'Event', + )); $mut->stop(); } @@ -4113,12 +4087,12 @@ public function testSendMailWithRepeatTransactionAPIFalltoDomain() { )); $domain = $this->callAPISuccess('domain', 'getsingle', array('id' => 1)); $mut->checkMailLog(array( - 'From: ' . $domain['from_name'] . ' <' . $domain['from_email'] . '>', - 'Contribution Information', - 'Please print this confirmation for your records', - ), array( - 'Event', - ) + 'From: ' . $domain['from_name'] . ' <' . $domain['from_email'] . '>', + 'Contribution Information', + 'Please print this confirmation for your records', + ), array( + 'Event', + ) ); $mut->stop(); } @@ -4145,22 +4119,22 @@ public function testSendMailWithRepeatTransactionAPIFalltoContributionPage() { $this->_params, array( 'contribution_recur_id' => $contributionRecur['id'], - 'contribution_page_id' => $contributionPage['id'])) + 'contribution_page_id' => $contributionPage['id'], + )) ); $this->callAPISuccess('contribution', 'repeattransaction', array( 'contribution_status_id' => 'Completed', 'trxn_id' => uniqid(), 'original_contribution_id' => $originalContribution, - ) + ) ); $mut->checkMailLog(array( - 'From: CiviCRM LLC ', - 'Contribution Information', - 'Please print this confirmation for your records', - ), array( - 'Event', - ) - ); + 'From: CiviCRM LLC ', + 'Contribution Information', + 'Please print this confirmation for your records', + ), array( + 'Event', + )); $mut->stop(); } @@ -4179,16 +4153,14 @@ public function testSendMailWithRepeatTransactionAPIFalltoSystemFromNoDefaultFro 'contribution_status_id' => 'Completed', 'trxn_id' => uniqid(), 'original_contribution_id' => $originalContribution, - ) - ); + )); $mut->checkMailLog(array( - 'From: ' . $domain['name'] . ' <' . $domain['domain_email'] . '>', - 'Contribution Information', - 'Please print this confirmation for your records', - ), array( - 'Event', - ) - ); + 'From: ' . $domain['name'] . ' <' . $domain['domain_email'] . '>', + 'Contribution Information', + 'Please print this confirmation for your records', + ), array( + 'Event', + )); $mut->stop(); } diff --git a/tests/phpunit/api/v3/CountryTest.php b/tests/phpunit/api/v3/CountryTest.php index 1722d740ca76..3e02d38d5048 100644 --- a/tests/phpunit/api/v3/CountryTest.php +++ b/tests/phpunit/api/v3/CountryTest.php @@ -36,7 +36,6 @@ class api_v3_CountryTest extends CiviUnitTestCase { protected $_apiversion; protected $_params; - public function setUp() { $this->_apiversion = 3; parent::setUp(); diff --git a/tests/phpunit/api/v3/CustomApiTest.php b/tests/phpunit/api/v3/CustomApiTest.php index acd34eac672c..a6cd684936b0 100644 --- a/tests/phpunit/api/v3/CustomApiTest.php +++ b/tests/phpunit/api/v3/CustomApiTest.php @@ -63,12 +63,10 @@ public function testCustomApi() { $this->assertEquals('xyzabx2017-01-01 00:00:00', $result['id']); $this->assertEquals('xyzabx2017-01-01 00:00:00', $result['id']); $this->assertEquals(array( - 'contact_identifier' => 'xyz', - 'mailing_identifier' => 'abx', - 'mailing_identifier.name' => 'CiviMail', - ), - reset($result['values']) - ); + 'contact_identifier' => 'xyz', + 'mailing_identifier' => 'abx', + 'mailing_identifier.name' => 'CiviMail', + ), reset($result['values'])); } /** diff --git a/tests/phpunit/api/v3/CustomFieldTest.php b/tests/phpunit/api/v3/CustomFieldTest.php index 9aedd3a473a0..df8a9886420b 100644 --- a/tests/phpunit/api/v3/CustomFieldTest.php +++ b/tests/phpunit/api/v3/CustomFieldTest.php @@ -144,9 +144,11 @@ public function testCustomFieldCreateAllAvailableFormInputs() { $n++; } } + /* * Can't figure out the point of this? */ + /** * @param array $params */ @@ -466,16 +468,16 @@ public function testGetfields_CrossEntityPollution() { // Add some fields $contactGroup = $this->customGroupCreate(array('extends' => 'Contact', 'title' => 'test_group_c')); $contactField = $this->customFieldCreate(array( - 'custom_group_id' => $contactGroup['id'], - 'label' => 'For Contacts', - )); + 'custom_group_id' => $contactGroup['id'], + 'label' => 'For Contacts', + )); $indivGroup = $this->customGroupCreate(array('extends' => 'Individual', 'title' => 'test_group_i')); $indivField = $this->customFieldCreate(array('custom_group_id' => $indivGroup['id'], 'label' => 'For Individuals')); $activityGroup = $this->customGroupCreate(array('extends' => 'Activity', 'title' => 'test_group_a')); $activityField = $this->customFieldCreate(array( - 'custom_group_id' => $activityGroup['id'], - 'label' => 'For Activities', - )); + 'custom_group_id' => $activityGroup['id'], + 'label' => 'For Activities', + )); // Check getfields $this->assertEquals( @@ -568,7 +570,6 @@ public function testCustomFieldCreateWithOptionGroupName() { $result = $this->callAPISuccess('CustomField', 'create', $params); } - /** * @param $getFieldsResult * diff --git a/tests/phpunit/api/v3/CustomValueContactTypeTest.php b/tests/phpunit/api/v3/CustomValueContactTypeTest.php index 2c9a18e4014e..a163eef78875 100644 --- a/tests/phpunit/api/v3/CustomValueContactTypeTest.php +++ b/tests/phpunit/api/v3/CustomValueContactTypeTest.php @@ -118,14 +118,14 @@ public function testGetFields() { $result = $this->callAPISuccess('Contact', 'getfields', array()); $this->assertArrayHasKey("custom_{$this->IndividualField['id']}", $result['values'], 'If This fails there is probably a caching issue - failure in line' . __LINE__ . print_r(array_keys($result['values']), TRUE)); $result = $this->callAPISuccess('Contact', 'getfields', array( - 'action' => 'create', - 'contact_type' => 'Individual', - ), 'in line' . __LINE__); + 'action' => 'create', + 'contact_type' => 'Individual', + ), 'in line' . __LINE__); $this->assertArrayHasKey("custom_{$this->IndividualField['id']}", $result['values']); $result = $this->callAPISuccess('Contact', 'getfields', array( - 'action' => 'create', - 'contact_type' => 'Organization', - )); + 'action' => 'create', + 'contact_type' => 'Organization', + )); $this->assertArrayNotHasKey("custom_{$this->IndividualField['id']}", $result['values'], 'in line' . __LINE__ . print_r(array_keys($result['values']), TRUE)); $result = $this->callAPISuccess('Relationship', 'getfields', array('action' => 'create'), 'in line' . __LINE__); $this->assertArrayNotHasKey("custom_{$this->IndividualField['id']}", $result['values']); @@ -140,7 +140,8 @@ public function testAddIndividualCustomDataToOrganization() { 'id' => $this->organization, 'contact_type' => 'Organization', "custom_{$this->IndividualField['id']}" => 'Test String', - 'debug' => 1, // so that undefined_fields is returned + // so that undefined_fields is returned + 'debug' => 1, ); $contact = $this->callAPISuccess('contact', 'create', $params); @@ -187,7 +188,8 @@ public function testAddIndividualStudentCustomDataToOrganizationSponsor() { 'contact_id' => $this->organizationSponsor, 'contact_type' => 'Organization', "custom_{$this->IndiStudentField['id']}" => 'Test String', - 'debug' => 1, // so that undefined_fields is returned + // so that undefined_fields is returned + 'debug' => 1, ); $contact = $this->callAPISuccess('contact', 'create', $params); @@ -225,7 +227,8 @@ public function testAddIndividualStudentCustomDataToIndividualParent() { 'contact_id' => $this->individualParent, 'contact_type' => 'Individual', "custom_{$this->IndiStudentField['id']}" => 'Test String', - 'debug' => 1, // so that undefined_fields is returned + // so that undefined_fields is returned + 'debug' => 1, ); $contact = $this->callAPISuccess('contact', 'create', $params); $this->assertTrue(is_array($contact['undefined_fields']), __LINE__); diff --git a/tests/phpunit/api/v3/DashboardContactTest.php b/tests/phpunit/api/v3/DashboardContactTest.php index 6f95516ff22f..1d639a81e4b3 100644 --- a/tests/phpunit/api/v3/DashboardContactTest.php +++ b/tests/phpunit/api/v3/DashboardContactTest.php @@ -54,12 +54,11 @@ public function testDashboardContactCreate() { ); $dashresult = $this->callAPISuccess('dashboard', 'create', $dashParams); $contact = $this->callAPISuccess('contact', 'create', array( - 'first_name' => 'abc1', - 'contact_type' => 'Individual', - 'last_name' => 'xyz1', - 'email' => 'abc@abc.com', - ) - ); + 'first_name' => 'abc1', + 'contact_type' => 'Individual', + 'last_name' => 'xyz1', + 'email' => 'abc@abc.com', + )); $oldCount = CRM_Core_DAO::singleValueQuery("select count(*) from civicrm_dashboard_contact where contact_id = {$contact['id']} AND is_active = 1 AND dashboard_id = {$dashresult['id']}"); $params = array( 'version' => 3, diff --git a/tests/phpunit/api/v3/DomainTest.php b/tests/phpunit/api/v3/DomainTest.php index 78541ddd30fd..6291f4a76930 100644 --- a/tests/phpunit/api/v3/DomainTest.php +++ b/tests/phpunit/api/v3/DomainTest.php @@ -34,9 +34,11 @@ */ class api_v3_DomainTest extends CiviUnitTestCase { - /* This test case doesn't require DB reset - apart from - where cleanDB() is called. */ - + /** + * This test case doesn't require DB reset - apart from + * where cleanDB() is called. + * @var bool + */ public $DBResetRequired = FALSE; protected $_apiversion = 3; @@ -56,29 +58,27 @@ protected function setUp() { $params['entity_table'] = CRM_Core_BAO_Domain::getTableName(); $defaultLocationType = CRM_Core_BAO_LocationType::getDefault(); $domContact = $this->callAPISuccess('contact', 'create', array( - 'contact_type' => 'Organization', - 'organization_name' => 'new org', - 'api.phone.create' => array( - 'location_type_id' => $defaultLocationType->id, - 'phone_type_id' => 1, - 'phone' => '456-456', - ), - 'api.address.create' => array( - 'location_type_id' => $defaultLocationType->id, - 'street_address' => '45 Penny Lane', - ), - 'api.email.create' => array( - 'location_type_id' => $defaultLocationType->id, - 'email' => 'my@email.com', - ), - ) - ); + 'contact_type' => 'Organization', + 'organization_name' => 'new org', + 'api.phone.create' => array( + 'location_type_id' => $defaultLocationType->id, + 'phone_type_id' => 1, + 'phone' => '456-456', + ), + 'api.address.create' => array( + 'location_type_id' => $defaultLocationType->id, + 'street_address' => '45 Penny Lane', + ), + 'api.email.create' => array( + 'location_type_id' => $defaultLocationType->id, + 'email' => 'my@email.com', + ), + )); $this->callAPISuccess('domain', 'create', array( - 'id' => 1, - 'contact_id' => $domContact['id'], - ) - ); + 'id' => 1, + 'contact_id' => $domContact['id'], + )); $this->params = array( 'name' => 'A-team domain', 'description' => 'domain of chaos', diff --git a/tests/phpunit/api/v3/EmailTest.php b/tests/phpunit/api/v3/EmailTest.php index 5cb68bc1e149..489319f9d52a 100644 --- a/tests/phpunit/api/v3/EmailTest.php +++ b/tests/phpunit/api/v3/EmailTest.php @@ -87,9 +87,9 @@ public function testCreateEmailPrimaryHandlingChangeToPrimary() { //now we check & make sure it has been set to primary $expected = 1; $check = $this->callAPISuccess('email', 'getcount', array( - 'is_primary' => 1, - 'id' => $email1['id'], - ), + 'is_primary' => 1, + 'id' => $email1['id'], + ), $expected ); } diff --git a/tests/phpunit/api/v3/EntityTagACLTest.php b/tests/phpunit/api/v3/EntityTagACLTest.php index aa16888bf309..1102a3ef8e0c 100644 --- a/tests/phpunit/api/v3/EntityTagACLTest.php +++ b/tests/phpunit/api/v3/EntityTagACLTest.php @@ -81,8 +81,7 @@ public function setUp() { 'used_for' => $key, 'name' => $entity, 'description' => $entity, - ) - ); + )); } CRM_Core_Config::singleton()->userPermissionClass->permissions = array('access CiviCRM'); } @@ -108,6 +107,7 @@ protected function getTableForTag($entity) { $options = $this->getTagOptions(); return array_search($entity, $options); } + /** * Get entities which can be tagged in data provider format. */ diff --git a/tests/phpunit/api/v3/EventTest.php b/tests/phpunit/api/v3/EventTest.php index 4c4157789bdd..0bf26f3a82c7 100644 --- a/tests/phpunit/api/v3/EventTest.php +++ b/tests/phpunit/api/v3/EventTest.php @@ -192,6 +192,7 @@ public function testGetEventByIdSort() { $this->assertEquals(1, $result['id'], ' in line ' . __LINE__); } + /* * Getting the id back of an event. * Does not work yet, bug in API @@ -207,7 +208,6 @@ public function testGetIdOfEventByEventTitle() { } */ - /** * Test 'is.Current' option. Existing event is 'old' so only current should be returned */ @@ -274,11 +274,11 @@ public function testGetSingleReturnIsFull() { $this->assertEquals(0, $currentEvent['is_full'], ' is full is set in line ' . __LINE__); $this->assertEquals(1, $currentEvent['available_places'], 'available places is set in line ' . __LINE__); $participant = $this->callAPISuccess('Participant', 'create', array( - 'participant_status' => 1, - 'role_id' => 1, - 'contact_id' => $contactID, - 'event_id' => $this->_eventIds[0], - )); + 'participant_status' => 1, + 'role_id' => 1, + 'contact_id' => $contactID, + 'event_id' => $this->_eventIds[0], + )); $currentEvent = $this->callAPIAndDocument('Event', 'getsingle', $getEventParams, __FUNCTION__, __FILE__, $description, $subfile); $this->assertEquals(1, $currentEvent['is_full'], ' is full is set in line ' . __LINE__); $this->assertEquals(0, $currentEvent['available_places'], 'available places is set in line ' . __LINE__); @@ -356,7 +356,7 @@ public function testChainingGetNonExistingLocBlock() { 'id' => $result['id'], // this chaining request should not break things: 'api.LocBlock.get' => array('id' => '$value.loc_block_id'), - )); + )); $this->assertEquals($result['id'], $check['id']); $this->callAPISuccess($this->_entity, 'Delete', array('id' => $result['id'])); @@ -378,9 +378,9 @@ public function testCreateWithCustom() { $result = $this->callAPIAndDocument($this->_entity, 'create', $params, __FUNCTION__, __FILE__); $check = $this->callAPISuccess($this->_entity, 'get', array( - 'return.custom_' . $ids['custom_field_id'] => 1, - 'id' => $result['id'], - )); + 'return.custom_' . $ids['custom_field_id'] => 1, + 'id' => $result['id'], + )); $this->assertEquals("custom string", $check['values'][$check['id']]['custom_' . $ids['custom_field_id']], ' in line ' . __LINE__); $this->customFieldDelete($ids['custom_field_id']); @@ -400,8 +400,8 @@ public function testSearchCustomField() { // Search for events having CRM-16036 as the value for this custom // field. This should not return anything. $check = $this->callAPISuccess($this->_entity, 'get', array( - 'custom_' . $ids['custom_field_id'] => 'CRM-16036', - )); + 'custom_' . $ids['custom_field_id'] => 'CRM-16036', + )); $this->assertEquals(0, $check['count']); @@ -421,8 +421,8 @@ public function testSearchCustomFieldIsNull() { // Search for events having NULL as the value for this custom // field. This should return all events created in setUp. $check = $this->callAPISuccess($this->_entity, 'get', array( - 'custom_' . $ids['custom_field_id'] => array('IS NULL' => 1), - )); + 'custom_' . $ids['custom_field_id'] => array('IS NULL' => 1), + )); $this->assertGreaterThan(0, $check['count']); @@ -565,7 +565,6 @@ public function testEventSearchCustomFieldWithChainedCall() { )); } - /** * Test that an event with a price set can be created. */ @@ -649,7 +648,6 @@ public function testUpdateEvent() { $this->callAPISuccess($this->_entity, 'Delete', array('id' => $result['id'])); } - public function testDeleteEmptyParams() { $result = $this->callAPIFailure('Event', 'Delete', array()); } diff --git a/tests/phpunit/api/v3/FinancialTypeACLTest.php b/tests/phpunit/api/v3/FinancialTypeACLTest.php index b275df4e0665..ccccba6bc29f 100644 --- a/tests/phpunit/api/v3/FinancialTypeACLTest.php +++ b/tests/phpunit/api/v3/FinancialTypeACLTest.php @@ -35,9 +35,6 @@ class api_v3_FinancialTypeACLTest extends CiviUnitTestCase { use CRMTraits_Financial_FinancialACLTrait; - /** - * Assume empty database with just civicrm_data. - */ protected $_individualId; protected $_contribution; protected $_financialTypeId = 1; diff --git a/tests/phpunit/api/v3/GroupTest.php b/tests/phpunit/api/v3/GroupTest.php index 7b115881879e..07af06f50110 100644 --- a/tests/phpunit/api/v3/GroupTest.php +++ b/tests/phpunit/api/v3/GroupTest.php @@ -74,7 +74,6 @@ public function testGroupCreateNoTitle() { $this->callAPIFailure('group', 'create', $params, 'Mandatory key(s) missing from params array: title'); } - public function testGetGroupWithEmptyParams() { $group = $this->callAPISuccess('group', 'get', array()); @@ -173,11 +172,10 @@ public function testGroupCreateWithTypeAndParent() { //Pass group_type param in checkbox format. $params = array_merge($params, array( - 'name' => 'Test Checkbox Format', - 'title' => 'Test Checkbox Format', - 'group_type' => array(2 => 1), - ) - ); + 'name' => 'Test Checkbox Format', + 'title' => 'Test Checkbox Format', + 'group_type' => array(2 => 1), + )); $result = $this->callAPISuccess('Group', 'create', $params); $group = $result['values'][$result['id']]; $this->assertEquals($group['name'], "Test Checkbox Format"); @@ -185,13 +183,12 @@ public function testGroupCreateWithTypeAndParent() { //assert single value for group_type and parent $params = array_merge($params, array( - 'name' => 'Test Group 2', - 'title' => 'Test Group 2', - 'group_type' => 2, - 'parents' => $result['id'], - 'sequential' => 1, - ) - ); + 'name' => 'Test Group 2', + 'title' => 'Test Group 2', + 'group_type' => 2, + 'parents' => $result['id'], + 'sequential' => 1, + )); $group2 = $this->callAPISuccess('Group', 'create', $params)['values'][0]; $this->assertEquals($group2['group_type'], array($params['group_type'])); @@ -199,11 +196,10 @@ public function testGroupCreateWithTypeAndParent() { // Test array format for parents. $params = array_merge($params, array( - 'name' => 'Test Group 3', - 'title' => 'Test Group 3', - 'parents' => [$result['id'], $group2['id']], - ) - ); + 'name' => 'Test Group 3', + 'title' => 'Test Group 3', + 'parents' => [$result['id'], $group2['id']], + )); $group3 = $this->callAPISuccess('Group', 'create', $params)['values'][0]; $parents = $this->callAPISuccess('Group', 'getvalue', ['return' => 'parents', 'id' => $group3['id']]); diff --git a/tests/phpunit/api/v3/JobProcessMailingTest.php b/tests/phpunit/api/v3/JobProcessMailingTest.php index 7bf7396b77b5..c96a3f1e5f3d 100644 --- a/tests/phpunit/api/v3/JobProcessMailingTest.php +++ b/tests/phpunit/api/v3/JobProcessMailingTest.php @@ -60,7 +60,8 @@ class api_v3_JobProcessMailingTest extends CiviUnitTestCase { public function setUp() { $this->cleanupMailingTest(); parent::setUp(); - CRM_Mailing_BAO_MailingJob::$mailsProcessed = 0; // DGW + // DGW + CRM_Mailing_BAO_MailingJob::$mailsProcessed = 0; $this->_groupID = $this->groupCreate(); $this->_email = 'test@test.test'; $this->_params = array( @@ -72,15 +73,24 @@ public function setUp() { 'scheduled_date' => 'now', ); $this->defaultSettings = array( - 'mailings' => 1, // int, #mailings to send - 'recipients' => 20, // int, #contacts to receive mailing - 'workers' => 1, // int, #concurrent cron jobs - 'iterations' => 1, // int, #times to spawn all the workers - 'lockHold' => 0, // int, #extra seconds each cron job should hold lock - 'mailerBatchLimit' => 0, // int, max# recipients to send in a given cron run - 'mailerJobsMax' => 0, // int, max# concurrent jobs - 'mailerJobSize' => 0, // int, max# recipients in each job - 'mailThrottleTime' => 0, // int, microseconds separating messages + // int, #mailings to send + 'mailings' => 1, + // int, #contacts to receive mailing + 'recipients' => 20, + // int, #concurrent cron jobs + 'workers' => 1, + // int, #times to spawn all the workers + 'iterations' => 1, + // int, #extra seconds each cron job should hold lock + 'lockHold' => 0, + // int, max# recipients to send in a given cron run + 'mailerBatchLimit' => 0, + // int, max# concurrent jobs + 'mailerJobsMax' => 0, + // int, max# recipients in each job + 'mailerJobSize' => 0, + // int, microseconds separating messages + 'mailThrottleTime' => 0, ); $this->_mut = new CiviMailUtils($this, TRUE); $this->callAPISuccess('mail_settings', 'get', array('api.mail_settings.create' => array('domain' => 'chaos.org'))); @@ -92,7 +102,8 @@ public function tearDown() { //$this->_mut->clearMessages(); $this->_mut->stop(); CRM_Utils_Hook::singleton()->reset(); - CRM_Mailing_BAO_MailingJob::$mailsProcessed = 0; // DGW + // DGW + CRM_Mailing_BAO_MailingJob::$mailsProcessed = 0; //$this->cleanupMailingTest(); parent::tearDown(); } @@ -211,15 +222,18 @@ public function concurrencyExamples() { 'mailerJobsMax' => 1, ), array( - 0 => 2, // 2 jobs which produce 0 messages - 4 => 1, // 1 job which produces 4 messages + // 2 jobs which produce 0 messages + 0 => 2, + // 1 job which produces 4 messages + 4 => 1, ), 4, ); // Launch 3 workers, but mailerJobsMax limits us to 2 workers. $es[1] = array( - array(// Settings. + // Settings. + array( 'recipients' => 20, 'workers' => 3, // FIXME: lockHold is unrealistic/unrepresentative. In reality, this situation fails because @@ -230,90 +244,121 @@ public function concurrencyExamples() { 'mailerBatchLimit' => 5, 'mailerJobsMax' => 2, ), - array(// Tallies. - 0 => 1, // 1 job which produce 0 messages - 5 => 2, // 2 jobs which produce 5 messages + // Tallies. + array( + // 1 job which produce 0 messages + 0 => 1, + // 2 jobs which produce 5 messages + 5 => 2, ), - 10, // Total sent. + // Total sent. + 10, ); // Launch 3 workers and saturate them (mailerJobsMax=3) $es[2] = array( - array(// Settings. + // Settings. + array( 'recipients' => 20, 'workers' => 3, 'mailerBatchLimit' => 6, 'mailerJobsMax' => 3, ), - array(// Tallies. - 6 => 3, // 3 jobs which produce 6 messages + // Tallies. + array( + // 3 jobs which produce 6 messages + 6 => 3, ), - 18, // Total sent. + // Total sent. + 18, ); // Launch 4 workers and saturate them (mailerJobsMax=0) $es[3] = array( - array(// Settings. + // Settings. + array( 'recipients' => 20, 'workers' => 4, 'mailerBatchLimit' => 6, 'mailerJobsMax' => 0, ), - array(// Tallies. - 6 => 3, // 3 jobs which produce 6 messages - 2 => 1, // 1 job which produces 2 messages + // Tallies. + array( + // 3 jobs which produce 6 messages + 6 => 3, + // 1 job which produces 2 messages + 2 => 1, ), - 20, // Total sent. + // Total sent. + 20, ); // Launch 1 worker, 3 times in a row. Deliver everything. $es[4] = array( - array(// Settings. + // Settings. + array( 'recipients' => 10, 'workers' => 1, 'iterations' => 3, 'mailerBatchLimit' => 7, ), - array(// Tallies. - 7 => 1, // 1 job which produces 7 messages - 3 => 1, // 1 job which produces 3 messages - 0 => 1, // 1 job which produces 0 messages + // Tallies. + array( + // 1 job which produces 7 messages + 7 => 1, + // 1 job which produces 3 messages + 3 => 1, + // 1 job which produces 0 messages + 0 => 1, ), - 10, // Total sent. + // Total sent. + 10, ); // Launch 2 worker, 3 times in a row. Deliver everything. $es[5] = array( - array(// Settings. + // Settings. + array( 'recipients' => 10, 'workers' => 2, 'iterations' => 3, 'mailerBatchLimit' => 3, ), - array(// Tallies. - 3 => 3, // 3 jobs which produce 3 messages - 1 => 1, // 1 job which produces 1 messages - 0 => 2, // 2 jobs which produce 0 messages + // Tallies. + array( + // 3 jobs which produce 3 messages + 3 => 3, + // 1 job which produces 1 messages + 1 => 1, + // 2 jobs which produce 0 messages + 0 => 2, ), - 10, // Total sent. + // Total sent. + 10, ); // For two mailings, launch 1 worker, 5 times in a row. Deliver everything. $es[6] = array( - array(// Settings. + // Settings. + array( 'mailings' => 2, 'recipients' => 10, 'workers' => 1, 'iterations' => 5, 'mailerBatchLimit' => 6, ), - array(// Tallies. + // Tallies. + array( // x6 => x4+x2 => x6 => x2 => x0 - 6 => 3, // 3 jobs which produce 6 messages - 2 => 1, // 1 job which produces 2 messages - 0 => 1, // 1 job which produces 0 messages + // 3 jobs which produce 6 messages + 6 => 3, + // 1 job which produces 2 messages + 2 => 1, + // 1 job which produces 0 messages + 0 => 1, ), - 20, // Total sent. + // Total sent. + 20, ); return $es; @@ -370,10 +415,10 @@ public function testConcurrency($settings, $expectedTallies, $expectedTotal) { $actualTallies = $this->tallyApiResults($allApiResults); $this->assertEquals($expectedTallies, $actualTallies, 'API tallies should match.' . print_r(array( - 'expectedTallies' => $expectedTallies, - 'actualTallies' => $actualTallies, - 'apiResults' => $allApiResults, - ), TRUE)); + 'expectedTallies' => $expectedTallies, + 'actualTallies' => $actualTallies, + 'apiResults' => $allApiResults, + ), TRUE)); $this->_mut->assertRecipients($this->getRecipients(1, $expectedTotal / $settings['mailings'], 'nul.example.com', $settings['mailings'])); $this->assertEquals(0, $apiCalls->getRunningCount()); } diff --git a/tests/phpunit/api/v3/JobTest.php b/tests/phpunit/api/v3/JobTest.php index de6d2885e17f..a9308ef6395b 100644 --- a/tests/phpunit/api/v3/JobTest.php +++ b/tests/phpunit/api/v3/JobTest.php @@ -49,7 +49,7 @@ class api_v3_JobTest extends CiviUnitTestCase { * * Must be created outside the transaction due to it breaking the transaction. * - * @var + * @var int */ public $membershipTypeID; @@ -264,12 +264,11 @@ public function testCallSendReminderLimitTo() { } if ($i > 1) { $this->callAPISuccess('membership', 'create', array( - 'contact_id' => $contactID, - 'membership_type_id' => $membershipTypeID, - 'join_date' => 'now', - 'start_date' => '+ 1 day', - ) - ); + 'contact_id' => $contactID, + 'membership_type_id' => $membershipTypeID, + 'join_date' => 'now', + 'start_date' => '+ 1 day', + )); } } $this->callAPISuccess('action_schedule', 'create', array( @@ -697,10 +696,12 @@ public function getMergeLocationData() { $data = $this->getMergeLocations($address1, $address2, 'Address'); $data = array_merge($data, $this->getMergeLocations(array('phone' => '12345', 'phone_type_id' => 1), array('phone' => '678910', 'phone_type_id' => 1), 'Phone')); $data = array_merge($data, $this->getMergeLocations(array('phone' => '12345'), array('phone' => '678910'), 'Phone')); - $data = array_merge($data, $this->getMergeLocations(array('email' => 'mini@me.com'), array('email' => 'mini@me.org'), 'Email', array(array( - 'email' => 'anthony_anderson@civicrm.org', - 'location_type_id' => 'Home', - )))); + $data = array_merge($data, $this->getMergeLocations(array('email' => 'mini@me.com'), array('email' => 'mini@me.org'), 'Email', array( + array( + 'email' => 'anthony_anderson@civicrm.org', + 'location_type_id' => 'Home', + ), + ))); return $data; } @@ -780,6 +781,7 @@ public function getOnHoldSets() { * * @param string $contactType * @param string $used + * @param string $name * @param bool $isReserved * @param int $threshold */ @@ -1381,7 +1383,7 @@ public function hookPreRelationship($op, $objectName, $id, &$params) { * @param array $locationParams1 * @param array $locationParams2 * @param string $entity - * + * @param array $additionalExpected * @return array */ public function getMergeLocations($locationParams1, $locationParams2, $entity, $additionalExpected = array()) { @@ -1819,7 +1821,8 @@ public function testProcessMembershipUpdateStatus() { // Default params, which we'll expand on below. $params = [ 'membership_type_id' => $membershipTypeId, - 'skipStatusCal' => 1, // Don't calculate status. + // Don't calculate status. + 'skipStatusCal' => 1, 'source' => 'Test', 'sequential' => 1, ]; @@ -1835,7 +1838,8 @@ public function testProcessMembershipUpdateStatus() { $params['join_date'] = date('Y-m-d'); $params['start_date'] = date('Y-m-d'); $params['end_date'] = date('Y-m-d', strtotime('now + 1 year')); - $params['status_id'] = 'Current'; // Intentionally incorrect status. + // Intentionally incorrect status. + $params['status_id'] = 'Current'; $resultNew = $this->callAPISuccess('Membership', 'create', $params); $this->assertEquals(array_search('Current', $memStatus), $resultNew['values'][0]['status_id']); @@ -1844,7 +1848,8 @@ public function testProcessMembershipUpdateStatus() { $params['join_date'] = date('Y-m-d', strtotime('now - 6 month')); $params['start_date'] = date('Y-m-d', strtotime('now - 6 month')); $params['end_date'] = date('Y-m-d', strtotime('now + 6 month')); - $params['status_id'] = 'New'; // Intentionally incorrect status. + // Intentionally incorrect status. + $params['status_id'] = 'New'; $resultCurrent = $this->callAPISuccess('Membership', 'create', $params); $this->assertEquals(array_search('New', $memStatus), $resultCurrent['values'][0]['status_id']); @@ -1853,7 +1858,8 @@ public function testProcessMembershipUpdateStatus() { $params['join_date'] = date('Y-m-d', strtotime('now - 53 week')); $params['start_date'] = date('Y-m-d', strtotime('now - 53 week')); $params['end_date'] = date('Y-m-d', strtotime('now - 1 week')); - $params['status_id'] = 'Current'; // Intentionally incorrect status. + // Intentionally incorrect status. + $params['status_id'] = 'Current'; $resultGrace = $this->callAPISuccess('Membership', 'create', $params); $this->assertEquals(array_search('Current', $memStatus), $resultGrace['values'][0]['status_id']); @@ -1862,7 +1868,8 @@ public function testProcessMembershipUpdateStatus() { $params['join_date'] = date('Y-m-d', strtotime('now - 16 month')); $params['start_date'] = date('Y-m-d', strtotime('now - 16 month')); $params['end_date'] = date('Y-m-d', strtotime('now - 4 month')); - $params['status_id'] = 'Grace'; // Intentionally incorrect status. + // Intentionally incorrect status. + $params['status_id'] = 'Grace'; $resultExpired = $this->callAPISuccess('Membership', 'create', $params); $this->assertEquals(array_search('Grace', $memStatus), $resultExpired['values'][0]['status_id']); @@ -1940,8 +1947,10 @@ public function testProcessMembershipUpdateStatus() { 'join_date' => date('Y-m-d', strtotime('now - 16 month')), 'start_date' => date('Y-m-d', strtotime('now - 16 month')), 'end_date' => date('Y-m-d', strtotime('now - 4 month')), - 'status_id' => 'Grace', // Intentionally incorrect status. - 'skipStatusCal' => 1, // Don't calculate status. + // Intentionally incorrect status. + 'status_id' => 'Grace', + // Don't calculate status. + 'skipStatusCal' => 1, ]; $organizationMembershipID = $this->contactMembershipCreate($params); diff --git a/tests/phpunit/api/v3/JobTestCustomDataTest.php b/tests/phpunit/api/v3/JobTestCustomDataTest.php index 0389b7879134..d7c5e9dedc32 100644 --- a/tests/phpunit/api/v3/JobTestCustomDataTest.php +++ b/tests/phpunit/api/v3/JobTestCustomDataTest.php @@ -218,6 +218,7 @@ public function getCheckboxData() { ); return $data; } + /** * Test the batch merge does not bork on custom date fields. * diff --git a/tests/phpunit/api/v3/LoggingTest.php b/tests/phpunit/api/v3/LoggingTest.php index 23ff335dab78..17d0fc9415a3 100644 --- a/tests/phpunit/api/v3/LoggingTest.php +++ b/tests/phpunit/api/v3/LoggingTest.php @@ -218,7 +218,8 @@ public function innodbLogTableSpecNewIndex(&$logTableSpec) { 'index_id' => 'id', 'index_log_conn_id' => 'log_conn_id', 'index_log_date' => 'log_date', - 'index_log_user_id' => 'log_user_id', // new index + // new index + 'index_log_user_id' => 'log_user_id', ), ); } @@ -304,7 +305,8 @@ public function testRevert() { $this->callAPISuccess('Contact', 'create', array( 'id' => $contactId, 'first_name' => 'Dopey', - 'api.email.create' => array('email' => 'dopey@mail.com')) + 'api.email.create' => array('email' => 'dopey@mail.com'), + ) ); $email = $this->callAPISuccessGetSingle('email', array('email' => 'dopey@mail.com')); $this->callAPIAndDocument('Logging', 'revert', array('log_conn_id' => 'woot', 'log_date' => $timeStamp), __FILE__, 'Revert'); @@ -323,10 +325,10 @@ public function testRevertNoDate() { sleep(1); CRM_Core_DAO::executeQuery("SET @uniqueID = 'Wot woot'"); $this->callAPISuccess('Contact', 'create', array( - 'id' => $contactId, - 'first_name' => 'Dopey', - 'api.email.create' => array('email' => 'dopey@mail.com')) - ); + 'id' => $contactId, + 'first_name' => 'Dopey', + 'api.email.create' => array('email' => 'dopey@mail.com'), + )); $email = $this->callAPISuccessGetSingle('email', array('email' => 'dopey@mail.com')); $this->callAPISuccess('Logging', 'revert', array('log_conn_id' => 'Wot woot')); $this->assertEquals('Anthony', $this->callAPISuccessGetValue('contact', array('id' => $contactId, 'return' => 'first_name'))); @@ -356,13 +358,12 @@ public function testRevertRestrictedTables() { sleep(1); CRM_Core_DAO::executeQuery("SET @uniqueID = 'bitty bot bot'"); $this->callAPISuccess('Contact', 'create', array( - 'id' => $contactId, - 'first_name' => 'Dopey', - 'address' => array(array('street_address' => '25 Dorky way', 'location_type_id' => 1)), - 'email' => array('email' => array('email' => 'dopey@mail.com', 'location_type_id' => 1)), - 'api.contribution.create' => array('financial_type_id' => 'Donation', 'receive_date' => 'now', 'total_amount' => 10), - ) - ); + 'id' => $contactId, + 'first_name' => 'Dopey', + 'address' => array(array('street_address' => '25 Dorky way', 'location_type_id' => 1)), + 'email' => array('email' => array('email' => 'dopey@mail.com', 'location_type_id' => 1)), + 'api.contribution.create' => array('financial_type_id' => 'Donation', 'receive_date' => 'now', 'total_amount' => 10), + )); $contact = $this->callAPISuccessGetSingle('contact', array('id' => $contactId, 'return' => array('first_name', 'email', 'modified_date', 'street_address'))); $this->assertEquals('Dopey', $contact['first_name']); $this->assertEquals('dopey@mail.com', $contact['email']); @@ -393,10 +394,10 @@ public function testRevertNoDateNotUnique() { $this->callAPISuccess('Setting', 'create', array('logging' => TRUE)); CRM_Core_DAO::executeQuery("SET @uniqueID = 'Wopity woot'"); $this->callAPISuccess('Contact', 'create', array( - 'id' => $contactId, - 'first_name' => 'Dopey', - 'api.email.create' => array('email' => 'dopey@mail.com')) - ); + 'id' => $contactId, + 'first_name' => 'Dopey', + 'api.email.create' => array('email' => 'dopey@mail.com'), + )); $this->callAPISuccess('Setting', 'create', array('logging_all_tables_uniquid' => FALSE)); $this->callAPISuccess('Setting', 'create', array('logging_uniqueid_date' => date('Y-m-d H:i:s', strtotime('+ 1 hour')))); $this->callAPIFailure( @@ -418,11 +419,11 @@ public function testGet() { sleep(1); $timeStamp = date('Y-m-d H:i:s'); $this->callAPISuccess('Contact', 'create', array( - 'id' => $contactId, - 'first_name' => 'Dopey', - 'last_name' => 'Dwarf', - 'api.email.create' => array('email' => 'dopey@mail.com')) - ); + 'id' => $contactId, + 'first_name' => 'Dopey', + 'last_name' => 'Dwarf', + 'api.email.create' => array('email' => 'dopey@mail.com'), + )); $this->callAPISuccessGetSingle('email', array('email' => 'dopey@mail.com')); $diffs = $this->callAPISuccess('Logging', 'get', array('log_conn_id' => 'wooty woot', 'log_date' => $timeStamp), __FUNCTION__, __FILE__); $this->assertLoggingIncludes($diffs['values'], array('to' => 'Dwarf, Dopey')); @@ -441,11 +442,11 @@ public function testGetNoDate() { // 1 second delay sleep(1); $this->callAPISuccess('Contact', 'create', array( - 'id' => $contactId, - 'first_name' => 'Dopey', - 'last_name' => 'Dwarf', - 'api.email.create' => array('email' => 'dopey@mail.com')) - ); + 'id' => $contactId, + 'first_name' => 'Dopey', + 'last_name' => 'Dwarf', + 'api.email.create' => array('email' => 'dopey@mail.com'), + )); $this->callAPISuccessGetSingle('email', array('email' => 'dopey@mail.com')); $diffs = $this->callAPIAndDocument('Logging', 'get', array('log_conn_id' => 'wooty wop wop'), __FUNCTION__, __FILE__); $this->assertLoggingIncludes($diffs['values'], array('to' => 'Dwarf, Dopey')); diff --git a/tests/phpunit/api/v3/MailingABTest.php b/tests/phpunit/api/v3/MailingABTest.php index 823b0d5dbfed..61f089c35002 100644 --- a/tests/phpunit/api/v3/MailingABTest.php +++ b/tests/phpunit/api/v3/MailingABTest.php @@ -98,7 +98,8 @@ public function testMailerDeleteSuccess() { * @return array */ public function groupPctProvider() { - $cases = array(); // array(int $totalSize, int $groupPct, int $expectedCountA, $expectedCountB, $expectedCountC) + // array(int $totalSize, int $groupPct, int $expectedCountA, $expectedCountB, $expectedCountC) + $cases = array(); $cases[] = array(400, 7, 28, 28, 344); $cases[] = array(100, 10, 10, 10, 80); $cases[] = array(50, 20, 10, 10, 30); diff --git a/tests/phpunit/api/v3/MailingContactTest.php b/tests/phpunit/api/v3/MailingContactTest.php index fdab46596196..a9e00c9ea33f 100644 --- a/tests/phpunit/api/v3/MailingContactTest.php +++ b/tests/phpunit/api/v3/MailingContactTest.php @@ -74,9 +74,8 @@ public function testMailingNullParams() { public function testMailingContactGetFields() { $result = $this->callAPISuccess('MailingContact', 'getfields', array( - 'action' => 'get', - ) - ); + 'action' => 'get', + )); $this->assertEquals('Delivered', $result['values']['type']['api.default']); } @@ -165,7 +164,6 @@ public function testMailingContactDelivered() { $this->assertEquals($result['values'][1]['creator_name'], "xyz1, abc1"); } - /** * Test that the API returns only the "Bounced" mailings when instructed to do so. */ diff --git a/tests/phpunit/api/v3/MailingTest.php b/tests/phpunit/api/v3/MailingTest.php index f208df94b023..d543a2919ca0 100644 --- a/tests/phpunit/api/v3/MailingTest.php +++ b/tests/phpunit/api/v3/MailingTest.php @@ -47,7 +47,8 @@ class api_v3_MailingTest extends CiviUnitTestCase { public function setUp() { parent::setUp(); $this->useTransaction(); - CRM_Mailing_BAO_MailingJob::$mailsProcessed = 0; // DGW + // DGW + CRM_Mailing_BAO_MailingJob::$mailsProcessed = 0; $this->_contactID = $this->individualCreate(); $this->_groupID = $this->groupCreate(); $this->_email = 'test@test.test'; @@ -70,7 +71,8 @@ public function setUp() { } public function tearDown() { - CRM_Mailing_BAO_MailingJob::$mailsProcessed = 0; // DGW + // DGW + CRM_Mailing_BAO_MailingJob::$mailsProcessed = 0; parent::tearDown(); } @@ -81,7 +83,8 @@ public function testMailerCreateSuccess() { $result = $this->callAPIAndDocument('mailing', 'create', $this->_params + array('scheduled_date' => 'now'), __FUNCTION__, __FILE__); $jobs = $this->callAPISuccess('mailing_job', 'get', array('mailing_id' => $result['id'])); $this->assertEquals(1, $jobs['count']); - unset($this->_params['created_id']); // return isn't working on this in getAndCheck so lets not check it for now + // return isn't working on this in getAndCheck so lets not check it for now + unset($this->_params['created_id']); $this->getAndCheck($this->_params, $result['id'], 'mailing'); } @@ -91,7 +94,7 @@ public function testMailerCreateSuccess() { public function testSkipAutoSchedule() { $this->callAPISuccess('Mailing', 'create', array_merge($this->_params, [ '_skip_evil_bao_auto_schedule_' => TRUE, - 'scheduled_date' => 'now' + 'scheduled_date' => 'now', ])); $this->callAPISuccessGetCount('Mailing', [], 1); $this->callAPISuccessGetCount('MailingJob', [], 0); @@ -107,7 +110,8 @@ public function testMailerCreateCompleted() { $jobs = $this->callAPISuccess('mailing_job', 'get', array('mailing_id' => $result['id'])); $this->assertEquals(1, $jobs['count']); $this->assertEquals('Complete', $jobs['values'][$jobs['id']]['status']); - unset($this->_params['created_id']); // return isn't working on this in getAndCheck so lets not check it for now + // return isn't working on this in getAndCheck so lets not check it for now + unset($this->_params['created_id']); $this->getAndCheck($this->_params, $result['id'], 'mailing'); } @@ -175,22 +179,22 @@ public function testMagicGroups_create_update() { $groupIDs['a'] = $this->groupCreate(array('name' => 'Example include group', 'title' => 'Example include group')); $groupIDs['b'] = $this->groupCreate(array('name' => 'Example exclude group', 'title' => 'Example exclude group')); $contactIDs['a'] = $this->individualCreate(array( - 'email' => 'include.me@example.org', - 'first_name' => 'Includer', - 'last_name' => 'Person', - )); + 'email' => 'include.me@example.org', + 'first_name' => 'Includer', + 'last_name' => 'Person', + )); $contactIDs['b'] = $this->individualCreate(array( - 'email' => 'exclude.me@example.org', - 'last_name' => 'Excluder', - )); + 'email' => 'exclude.me@example.org', + 'last_name' => 'Excluder', + )); $this->callAPISuccess('GroupContact', 'create', array( - 'group_id' => $groupIDs['a'], - 'contact_id' => $contactIDs['a'], - )); + 'group_id' => $groupIDs['a'], + 'contact_id' => $contactIDs['a'], + )); $this->callAPISuccess('GroupContact', 'create', array( - 'group_id' => $groupIDs['b'], - 'contact_id' => $contactIDs['b'], - )); + 'group_id' => $groupIDs['b'], + 'contact_id' => $contactIDs['b'], + )); // END SAMPLE DATA // ** Pass 1: Create @@ -257,10 +261,14 @@ public function testMailerPreview() { 'recipient' => CRM_Core_DAO::singleValueQuery('SELECT MAX(id) FROM civicrm_mailing_recipients'), ); $result = $this->callAPISuccess('mailing', 'create', $params); - $this->assertDBQuery($maxIDs['mailing'], 'SELECT MAX(id) FROM civicrm_mailing'); // 'Preview should not create any mailing records' - $this->assertDBQuery($maxIDs['job'], 'SELECT MAX(id) FROM civicrm_mailing_job'); // 'Preview should not create any mailing_job record' - $this->assertDBQuery($maxIDs['group'], 'SELECT MAX(id) FROM civicrm_mailing_group'); // 'Preview should not create any mailing_group records' - $this->assertDBQuery($maxIDs['recipient'], 'SELECT MAX(id) FROM civicrm_mailing_recipients'); // 'Preview should not create any mailing_recipient records' + // 'Preview should not create any mailing records' + $this->assertDBQuery($maxIDs['mailing'], 'SELECT MAX(id) FROM civicrm_mailing'); + // 'Preview should not create any mailing_job record' + $this->assertDBQuery($maxIDs['job'], 'SELECT MAX(id) FROM civicrm_mailing_job'); + // 'Preview should not create any mailing_group records' + $this->assertDBQuery($maxIDs['group'], 'SELECT MAX(id) FROM civicrm_mailing_group'); + // 'Preview should not create any mailing_recipient records' + $this->assertDBQuery($maxIDs['recipient'], 'SELECT MAX(id) FROM civicrm_mailing_recipients'); $previewResult = $result['values'][$result['id']]['api.Mailing.preview']; $this->assertEquals("Hello $displayName", $previewResult['values']['subject']); @@ -273,26 +281,26 @@ public function testMailerPreviewRecipients() { $groupIDs['inc'] = $this->groupCreate(array('name' => 'Example include group', 'title' => 'Example include group')); $groupIDs['exc'] = $this->groupCreate(array('name' => 'Example exclude group', 'title' => 'Example exclude group')); $contactIDs['include_me'] = $this->individualCreate(array( - 'email' => 'include.me@example.org', - 'first_name' => 'Includer', - 'last_name' => 'Person', - )); + 'email' => 'include.me@example.org', + 'first_name' => 'Includer', + 'last_name' => 'Person', + )); $contactIDs['exclude_me'] = $this->individualCreate(array( - 'email' => 'exclude.me@example.org', - 'last_name' => 'Excluder', - )); + 'email' => 'exclude.me@example.org', + 'last_name' => 'Excluder', + )); $this->callAPISuccess('GroupContact', 'create', array( - 'group_id' => $groupIDs['inc'], - 'contact_id' => $contactIDs['include_me'], - )); + 'group_id' => $groupIDs['inc'], + 'contact_id' => $contactIDs['include_me'], + )); $this->callAPISuccess('GroupContact', 'create', array( - 'group_id' => $groupIDs['inc'], - 'contact_id' => $contactIDs['exclude_me'], - )); + 'group_id' => $groupIDs['inc'], + 'contact_id' => $contactIDs['exclude_me'], + )); $this->callAPISuccess('GroupContact', 'create', array( - 'group_id' => $groupIDs['exc'], - 'contact_id' => $contactIDs['exclude_me'], - )); + 'group_id' => $groupIDs['exc'], + 'contact_id' => $contactIDs['exclude_me'], + )); $params = $this->_params; $params['groups']['include'] = array($groupIDs['inc']); @@ -316,8 +324,10 @@ public function testMailerPreviewRecipients() { 'group' => CRM_Core_DAO::singleValueQuery('SELECT MAX(id) FROM civicrm_mailing_group'), ); $create = $this->callAPIAndDocument('Mailing', 'create', $params, __FUNCTION__, __FILE__); - $this->assertDBQuery($maxIDs['mailing'], 'SELECT MAX(id) FROM civicrm_mailing'); // 'Preview should not create any mailing records' - $this->assertDBQuery($maxIDs['group'], 'SELECT MAX(id) FROM civicrm_mailing_group'); // 'Preview should not create any mailing_group records' + // 'Preview should not create any mailing records' + $this->assertDBQuery($maxIDs['mailing'], 'SELECT MAX(id) FROM civicrm_mailing'); + // 'Preview should not create any mailing_group records' + $this->assertDBQuery($maxIDs['group'], 'SELECT MAX(id) FROM civicrm_mailing_group'); $preview = $create['values'][$create['id']]['api.MailingRecipients.get']; $previewIds = array_values(CRM_Utils_Array::collect('contact_id', $preview['values'])); @@ -335,21 +345,21 @@ public function testMailerPreviewRecipientsDeduplicateAndOnholdEmails() { // BEGIN SAMPLE DATA $groupIDs['grp'] = $this->groupCreate(array('name' => 'Example group', 'title' => 'Example group')); $contactIDs['include_me'] = $this->individualCreate(array( - 'email' => 'include.me@example.org', - 'first_name' => 'Includer', - 'last_name' => 'Person', - )); + 'email' => 'include.me@example.org', + 'first_name' => 'Includer', + 'last_name' => 'Person', + )); $contactIDs['include_me_duplicate'] = $this->individualCreate(array( - 'email' => 'include.me@example.org', - 'first_name' => 'IncluderDuplicate', - 'last_name' => 'Person', - )); + 'email' => 'include.me@example.org', + 'first_name' => 'IncluderDuplicate', + 'last_name' => 'Person', + )); $contactIDs['include_me_onhold'] = $this->individualCreate(array( - 'email' => 'onholdinclude.me@example.org', - 'first_name' => 'Onhold', - 'last_name' => 'Person', - )); + 'email' => 'onholdinclude.me@example.org', + 'first_name' => 'Onhold', + 'last_name' => 'Person', + )); $emailId = $this->callAPISuccessGetValue('Email', array( 'return' => 'id', 'contact_id' => $contactIDs['include_me_onhold'], @@ -360,17 +370,17 @@ public function testMailerPreviewRecipientsDeduplicateAndOnholdEmails() { )); $this->callAPISuccess('GroupContact', 'create', array( - 'group_id' => $groupIDs['grp'], - 'contact_id' => $contactIDs['include_me'], - )); + 'group_id' => $groupIDs['grp'], + 'contact_id' => $contactIDs['include_me'], + )); $this->callAPISuccess('GroupContact', 'create', array( - 'group_id' => $groupIDs['grp'], - 'contact_id' => $contactIDs['include_me_duplicate'], - )); + 'group_id' => $groupIDs['grp'], + 'contact_id' => $contactIDs['include_me_duplicate'], + )); $this->callAPISuccess('GroupContact', 'create', array( - 'group_id' => $groupIDs['grp'], - 'contact_id' => $contactIDs['include_me_onhold'], - )); + 'group_id' => $groupIDs['grp'], + 'contact_id' => $contactIDs['include_me_onhold'], + )); $params = $this->_params; $params['groups']['include'] = array($groupIDs['grp']); @@ -402,10 +412,10 @@ public function testMailerPreviewRecipientsDeduplicateAndOnholdEmails() { */ public function testMailerSendTest_email() { $contactIDs['alice'] = $this->individualCreate(array( - 'email' => 'alice@example.org', - 'first_name' => 'Alice', - 'last_name' => 'Person', - )); + 'email' => 'alice@example.org', + 'first_name' => 'Alice', + 'last_name' => 'Person', + )); $mail = $this->callAPISuccess('mailing', 'create', $this->_params); @@ -414,7 +424,8 @@ public function testMailerSendTest_email() { // Per https://lab.civicrm.org/dev/mail/issues/32 test non-lowercase email $params['id'] = $mail['id']; $deliveredInfo = $this->callAPISuccess($this->_entity, 'send_test', $params); - $this->assertEquals(1, $deliveredInfo['count']); // verify mail has been sent to user by count + // verify mail has been sent to user by count + $this->assertEquals(1, $deliveredInfo['count']); $deliveredContacts = array_values(CRM_Utils_Array::collect('contact_id', $deliveredInfo['values'])); $this->assertEquals(array($contactIDs['alice']), $deliveredContacts); @@ -430,32 +441,32 @@ public function testMailerSendTest_group() { // BEGIN SAMPLE DATA $groupIDs['inc'] = $this->groupCreate(array('name' => 'Example include group', 'title' => 'Example include group')); $contactIDs['alice'] = $this->individualCreate(array( - 'email' => 'alice@example.org', - 'first_name' => 'Alice', - 'last_name' => 'Person', - )); + 'email' => 'alice@example.org', + 'first_name' => 'Alice', + 'last_name' => 'Person', + )); $contactIDs['bob'] = $this->individualCreate(array( - 'email' => 'bob@example.org', - 'first_name' => 'Bob', - 'last_name' => 'Person', - )); + 'email' => 'bob@example.org', + 'first_name' => 'Bob', + 'last_name' => 'Person', + )); $contactIDs['carol'] = $this->individualCreate(array( - 'email' => 'carol@example.org', - 'first_name' => 'Carol', - 'last_name' => 'Person', - )); + 'email' => 'carol@example.org', + 'first_name' => 'Carol', + 'last_name' => 'Person', + )); $this->callAPISuccess('GroupContact', 'create', array( - 'group_id' => $groupIDs['inc'], - 'contact_id' => $contactIDs['alice'], - )); + 'group_id' => $groupIDs['inc'], + 'contact_id' => $contactIDs['alice'], + )); $this->callAPISuccess('GroupContact', 'create', array( - 'group_id' => $groupIDs['inc'], - 'contact_id' => $contactIDs['bob'], - )); + 'group_id' => $groupIDs['inc'], + 'contact_id' => $contactIDs['bob'], + )); $this->callAPISuccess('GroupContact', 'create', array( - 'group_id' => $groupIDs['inc'], - 'contact_id' => $contactIDs['carol'], - )); + 'group_id' => $groupIDs['inc'], + 'contact_id' => $contactIDs['carol'], + )); // END SAMPLE DATA $mail = $this->callAPISuccess('mailing', 'create', $this->_params); @@ -464,7 +475,8 @@ public function testMailerSendTest_group() { 'test_email' => NULL, 'test_group' => $groupIDs['inc'], )); - $this->assertEquals(3, $deliveredInfo['count'], "in line " . __LINE__); // verify mail has been sent to user by count + // verify mail has been sent to user by count + $this->assertEquals(3, $deliveredInfo['count'], "in line " . __LINE__); $deliveredContacts = array_values(CRM_Utils_Array::collect('contact_id', $deliveredInfo['values'])); $this->assertEquals(array($contactIDs['alice'], $contactIDs['bob'], $contactIDs['carol']), $deliveredContacts); @@ -477,76 +489,117 @@ public function testMailerSendTest_group() { * @return array */ public function submitProvider() { - $cases = array(); // $useLogin, $params, $expectedFailure, $expectedJobCount + // $useLogin, $params, $expectedFailure, $expectedJobCount + $cases = array(); $cases[] = array( - TRUE, //useLogin - array(), // createParams + //useLogin + TRUE, + // createParams + array(), array('scheduled_date' => '2014-12-13 10:00:00', 'approval_date' => '2014-12-13 00:00:00'), - FALSE, // expectedFailure - 1, // expectedJobCount + // expectedFailure + FALSE, + // expectedJobCount + 1, ); $cases[] = array( - FALSE, //useLogin - array(), // createParams + //useLogin + FALSE, + // createParams + array(), array('scheduled_date' => '2014-12-13 10:00:00', 'approval_date' => '2014-12-13 00:00:00'), - "/Failed to determine current user/", // expectedFailure - 0, // expectedJobCount + // expectedFailure + "/Failed to determine current user/", + // expectedJobCount + 0, ); $cases[] = array( - TRUE, //useLogin - array(), // createParams + //useLogin + TRUE, + // createParams + array(), array('scheduled_date' => '2014-12-13 10:00:00'), - FALSE, // expectedFailure - 1, // expectedJobCount + // expectedFailure + FALSE, + // expectedJobCount + 1, ); $cases[] = array( - TRUE, //useLogin - array(), // createParams + //useLogin + TRUE, + // createParams + array(), array(), - "/Missing parameter scheduled_date and.or approval_date/", // expectedFailure - 0, // expectedJobCount + // expectedFailure + "/Missing parameter scheduled_date and.or approval_date/", + // expectedJobCount + 0, ); $cases[] = array( - TRUE, //useLogin - array('name' => ''), // createParams + //useLogin + TRUE, + // createParams + array('name' => ''), array('scheduled_date' => '2014-12-13 10:00:00', 'approval_date' => '2014-12-13 00:00:00'), - "/Mailing cannot be sent. There are missing or invalid fields \\(name\\)./", // expectedFailure - 0, // expectedJobCount + // expectedFailure + "/Mailing cannot be sent. There are missing or invalid fields \\(name\\)./", + // expectedJobCount + 0, ); $cases[] = array( - TRUE, //useLogin - array('body_html' => '', 'body_text' => ''), // createParams + //useLogin + TRUE, + // createParams + array('body_html' => '', 'body_text' => ''), array('scheduled_date' => '2014-12-13 10:00:00', 'approval_date' => '2014-12-13 00:00:00'), - "/Mailing cannot be sent. There are missing or invalid fields \\(body\\)./", // expectedFailure - 0, // expectedJobCount + // expectedFailure + "/Mailing cannot be sent. There are missing or invalid fields \\(body\\)./", + // expectedJobCount + 0, ); $cases[] = array( - TRUE, //useLogin - array('body_html' => 'Oops, did I leave my tokens at home?'), // createParams + //useLogin + TRUE, + // createParams + array('body_html' => 'Oops, did I leave my tokens at home?'), array('scheduled_date' => '2014-12-13 10:00:00', 'approval_date' => '2014-12-13 00:00:00'), - "/Mailing cannot be sent. There are missing or invalid fields \\(.*body_html.*optOut.*\\)./", // expectedFailure - 0, // expectedJobCount + // expectedFailure + "/Mailing cannot be sent. There are missing or invalid fields \\(.*body_html.*optOut.*\\)./", + // expectedJobCount + 0, ); $cases[] = array( - TRUE, //useLogin - array('body_text' => 'Oops, did I leave my tokens at home?'), // createParams + //useLogin + TRUE, + // createParams + array('body_text' => 'Oops, did I leave my tokens at home?'), array('scheduled_date' => '2014-12-13 10:00:00', 'approval_date' => '2014-12-13 00:00:00'), - "/Mailing cannot be sent. There are missing or invalid fields \\(.*body_text.*optOut.*\\)./", // expectedFailure - 0, // expectedJobCount + // expectedFailure + "/Mailing cannot be sent. There are missing or invalid fields \\(.*body_text.*optOut.*\\)./", + // expectedJobCount + 0, ); $cases[] = array( - TRUE, //useLogin - array('body_text' => 'Look ma, magic tokens in the text!', 'footer_id' => '%FOOTER%'), // createParams + //useLogin + TRUE, + // createParams + array('body_text' => 'Look ma, magic tokens in the text!', 'footer_id' => '%FOOTER%'), array('scheduled_date' => '2014-12-13 10:00:00', 'approval_date' => '2014-12-13 00:00:00'), - FALSE, // expectedFailure - 1, // expectedJobCount + // expectedFailure + FALSE, + // expectedJobCount + 1, ); $cases[] = array( - TRUE, //useLogin - array('body_html' => '

    Look ma, magic tokens in the markup!

    ', 'footer_id' => '%FOOTER%'), // createParams + //useLogin + TRUE, + // createParams + array('body_html' => '

    Look ma, magic tokens in the markup!

    ', 'footer_id' => '%FOOTER%'), array('scheduled_date' => '2014-12-13 10:00:00', 'approval_date' => '2014-12-13 00:00:00'), - FALSE, // expectedFailure - 1, // expectedJobCount + // expectedFailure + FALSE, + // expectedJobCount + 1, ); return $cases; } @@ -645,7 +698,8 @@ public function testUnsubscribeGroupList() { */ public function testMailerStats() { $result = $this->groupContactCreate($this->_groupID, 100); - $this->assertEquals(100, $result['added']); //verify if 100 contacts are added for group + //verify if 100 contacts are added for group + $this->assertEquals(100, $result['added']); //Create and send test mail first and change the mail job to live, //because stats api only works on live mail @@ -683,7 +737,8 @@ public function testMailerStats() { $result = $this->callAPISuccess('mailing', 'stats', array('mailing_id' => $mail['id'])); $expectedResult = array( - 'Delivered' => 80, //since among 100 mails 20 has been bounced + //since among 100 mails 20 has been bounced + 'Delivered' => 80, 'Bounces' => 20, 'Opened' => 20, 'Unique Clicks' => 0, @@ -831,7 +886,6 @@ public function testMailerReplyWrongParams() { ); } - //----------- civicrm_mailing_event_forward methods ---------- /** diff --git a/tests/phpunit/api/v3/MembershipPaymentTest.php b/tests/phpunit/api/v3/MembershipPaymentTest.php index 26f5e83b46e7..59bea92ed944 100644 --- a/tests/phpunit/api/v3/MembershipPaymentTest.php +++ b/tests/phpunit/api/v3/MembershipPaymentTest.php @@ -105,7 +105,6 @@ public function testCreate() { } - ///////////////// civicrm_membershipPayment_get methods /** diff --git a/tests/phpunit/api/v3/MembershipStatusTest.php b/tests/phpunit/api/v3/MembershipStatusTest.php index 001a7adc94db..7fd9f6714d73 100644 --- a/tests/phpunit/api/v3/MembershipStatusTest.php +++ b/tests/phpunit/api/v3/MembershipStatusTest.php @@ -56,7 +56,6 @@ public function tearDown() { ///////////////// civicrm_membership_status_get methods - /** * Test civicrm_membership_status_get with empty params. */ @@ -130,7 +129,6 @@ public function testUpdate() { $this->membershipStatusDelete($result['id']); } - ///////////////// civicrm_membership_status_delete methods /** diff --git a/tests/phpunit/api/v3/MembershipTest.php b/tests/phpunit/api/v3/MembershipTest.php index 36f3a84c8bd1..1cfd52ad0294 100644 --- a/tests/phpunit/api/v3/MembershipTest.php +++ b/tests/phpunit/api/v3/MembershipTest.php @@ -90,11 +90,11 @@ public function setUp() { */ public function tearDown() { $this->quickCleanup(array( - 'civicrm_membership', - 'civicrm_membership_payment', - 'civicrm_membership_log', - 'civicrm_uf_match', - ), + 'civicrm_membership', + 'civicrm_membership_payment', + 'civicrm_membership_log', + 'civicrm_uf_match', + ), TRUE ); $this->membershipStatusDelete($this->_membershipStatusID); @@ -137,8 +137,10 @@ public function testMembershipDeleteWithInvalidMembershipId() { * Test membership deletion and with the preserve contribution param. */ public function testMembershipDeletePreserveContribution() { - $membershipID = $this->contactMembershipCreate($this->_params); //DELETE - $this->assertDBRowExist('CRM_Member_DAO_Membership', $membershipID); //DELETE + //DELETE + $membershipID = $this->contactMembershipCreate($this->_params); + //DELETE + $this->assertDBRowExist('CRM_Member_DAO_Membership', $membershipID); $ContributionCreate = $this->callAPISuccess('Contribution', 'create', array( 'sequential' => 1, 'financial_type_id' => "Member Dues", @@ -388,7 +390,6 @@ public function testGet() { $this->assertEquals($result['is_override'], 1); } - /** * Test civicrm_membership_get with proper params. * Memberships expected. @@ -705,6 +706,7 @@ public function testMembershipGetWithReturn() { $this->assertEquals(array('id', 'end_date'), array_keys($membership)); } } + ///////////////// civicrm_membership_create methods /** @@ -1538,7 +1540,6 @@ public function testEmptyEndDateRolling() { $this->assertEquals('2010-01-20', $result['end_date']); } - /** * Test that if dates are set they not over-ridden if id is passed in */ diff --git a/tests/phpunit/api/v3/MessageTemplateTest.php b/tests/phpunit/api/v3/MessageTemplateTest.php index 1c44852b1c0a..bb45d3018717 100644 --- a/tests/phpunit/api/v3/MessageTemplateTest.php +++ b/tests/phpunit/api/v3/MessageTemplateTest.php @@ -32,13 +32,10 @@ * @group headless */ class api_v3_MessageTemplateTest extends CiviUnitTestCase { - /** - * Assume empty database with just civicrm_data. - */ + protected $entity = 'MessageTemplate'; protected $params; - public function setUp() { $this->_apiversion = 3; parent::setUp(); diff --git a/tests/phpunit/api/v3/MultilingualTest.php b/tests/phpunit/api/v3/MultilingualTest.php index 3ef14e07853c..05343641ea04 100644 --- a/tests/phpunit/api/v3/MultilingualTest.php +++ b/tests/phpunit/api/v3/MultilingualTest.php @@ -121,9 +121,12 @@ public function testAllEntities() { 'Location', 'Pcp', 'Survey', - 'UFField', // throw error for help_post column - 'UFGroup', //throw error for title - 'User', // need loggedIn user id + // throw error for help_post column + 'UFField', + //throw error for title + 'UFGroup', + // need loggedIn user id + 'User', ); // fetch all entities $entities = $this->callAPISuccess('Entity', 'get', array()); diff --git a/tests/phpunit/api/v3/OptionGroupTest.php b/tests/phpunit/api/v3/OptionGroupTest.php index 448782c1fcfe..a503e7d4be15 100644 --- a/tests/phpunit/api/v3/OptionGroupTest.php +++ b/tests/phpunit/api/v3/OptionGroupTest.php @@ -124,15 +124,16 @@ public function testGetOptionCreateFailOnDuplicate() { */ public function testGetOptionCreateFailRollback() { $countFirst = $this->callAPISuccess('OptionGroup', 'getcount', array( - 'options' => array('limit' => 5000), - ) + 'options' => array('limit' => 5000), + ) ); $params = array( 'sequential' => 1, 'name' => 'civicrm_rolback_test', 'is_reserved' => 1, 'is_active' => 1, - 'is_transactional' => 'nest', // executing within useTransactional() test case + // executing within useTransactional() test case + 'is_transactional' => 'nest', 'api.OptionValue.create' => array( 'label' => 'invalid entry', 'value' => 35, @@ -143,9 +144,8 @@ public function testGetOptionCreateFailRollback() { ); $result = $this->callAPIFailure('OptionGroup', 'create', $params); $countAfter = $this->callAPISuccess('OptionGroup', 'getcount', array( - 'options' => array('limit' => 5000), - ) - ); + 'options' => array('limit' => 5000), + )); $this->assertEquals($countFirst, $countAfter, 'Count of option groups should not have changed due to rollback triggered by option value In line ' . __LINE__ ); diff --git a/tests/phpunit/api/v3/OptionValueTest.php b/tests/phpunit/api/v3/OptionValueTest.php index 154cb18222fa..f2f37204609a 100644 --- a/tests/phpunit/api/v3/OptionValueTest.php +++ b/tests/phpunit/api/v3/OptionValueTest.php @@ -329,7 +329,6 @@ public function testCRM11876CreateOptionPseudoConstantUpdated() { $this->assertFalse(in_array($newOption, $fields['values'])); } - /** * Update option value with 'id' parameter and the value to update * and not passing option group id diff --git a/tests/phpunit/api/v3/OrderTest.php b/tests/phpunit/api/v3/OrderTest.php index 7f18041fdddc..f1302a844f66 100644 --- a/tests/phpunit/api/v3/OrderTest.php +++ b/tests/phpunit/api/v3/OrderTest.php @@ -34,9 +34,6 @@ */ class api_v3_OrderTest extends CiviUnitTestCase { - /** - * Assume empty database with just civicrm_data. - */ protected $_individualId; protected $_financialTypeId = 1; protected $_apiversion; @@ -557,7 +554,7 @@ public function testCreateOrderIfTotalAmountDoesNotMatchLineItemsAmountsIfNoTaxS 'financial_type_id' => 1, 'entity_table' => 'civicrm_contribution', ], - ] + ], ], ], ]; @@ -592,7 +589,7 @@ public function testCreateOrderIfTotalAmountDoesNotMatchLineItemsAmountsIfTaxSup 'entity_table' => 'civicrm_contribution', 'tax_amount' => 15, ], - ] + ], ], ], ]; @@ -623,7 +620,7 @@ public function testCreateOrderIfTotalAmountDoesMatchLineItemsAmountsAndTaxSuppl 'entity_table' => 'civicrm_contribution', 'tax_amount' => 15, ], - ] + ], ], ], ]; diff --git a/tests/phpunit/api/v3/ParticipantPaymentTest.php b/tests/phpunit/api/v3/ParticipantPaymentTest.php index f9492f96de7b..df0f3f7585c9 100644 --- a/tests/phpunit/api/v3/ParticipantPaymentTest.php +++ b/tests/phpunit/api/v3/ParticipantPaymentTest.php @@ -56,24 +56,24 @@ public function setUp() { $this->_financialTypeId = 1; $this->_participantID = $this->participantCreate(array( - 'contactID' => $this->_contactID, - 'eventID' => $this->_eventID, - )); + 'contactID' => $this->_contactID, + 'eventID' => $this->_eventID, + )); $this->_contactID2 = $this->individualCreate(); $this->_participantID2 = $this->participantCreate(array( - 'contactID' => $this->_contactID2, - 'eventID' => $this->_eventID, - )); + 'contactID' => $this->_contactID2, + 'eventID' => $this->_eventID, + )); $this->_participantID3 = $this->participantCreate(array( - 'contactID' => $this->_contactID2, - 'eventID' => $this->_eventID, - )); + 'contactID' => $this->_contactID2, + 'eventID' => $this->_eventID, + )); $this->_contactID3 = $this->individualCreate(); $this->_participantID4 = $this->participantCreate(array( - 'contactID' => $this->_contactID3, - 'eventID' => $this->_eventID, - )); + 'contactID' => $this->_contactID3, + 'eventID' => $this->_eventID, + )); } /** @@ -144,7 +144,6 @@ public function testPaymentInfoForEvent() { $this->assertEquals('100.00', $paymentInfo['total']); } - ///////////////// civicrm_participant_payment_create methods /** @@ -285,7 +284,6 @@ public function testPaymentPayLaterOnline() { $this->callAPISuccess('participant_payment', 'delete', $params); } - /** * Test civicrm_participant_payment_delete with wrong params type. */ diff --git a/tests/phpunit/api/v3/ParticipantTest.php b/tests/phpunit/api/v3/ParticipantTest.php index 60ed6ab6952a..2c438ea59759 100644 --- a/tests/phpunit/api/v3/ParticipantTest.php +++ b/tests/phpunit/api/v3/ParticipantTest.php @@ -60,19 +60,19 @@ public function setUp() { $this->_individualId = $this->individualCreate(); $this->_participantID = $this->participantCreate(array( - 'contact_id' => $this->_contactID, - 'event_id' => $this->_eventID, - )); + 'contact_id' => $this->_contactID, + 'event_id' => $this->_eventID, + )); $this->_contactID2 = $this->individualCreate(); $this->_participantID2 = $this->participantCreate(array( - 'contact_id' => $this->_contactID2, - 'event_id' => $this->_eventID, - 'registered_by_id' => $this->_participantID, - )); + 'contact_id' => $this->_contactID2, + 'event_id' => $this->_eventID, + 'registered_by_id' => $this->_participantID, + )); $this->_participantID3 = $this->participantCreate(array( - 'contact_id' => $this->_contactID2, - 'event_id' => $this->_eventID, - )); + 'contact_id' => $this->_contactID2, + 'event_id' => $this->_eventID, + )); $this->_params = array( 'contact_id' => $this->_contactID, 'event_id' => $this->_eventID, @@ -226,7 +226,6 @@ public function testGetParticipantWithPermission() { $this->assertEquals($result['is_error'], 0); } - /** * Check with params id. */ @@ -248,9 +247,9 @@ public function testGetNestedEventGet() { //create a second event & add participant to it. $event = $this->eventCreate(NULL); $this->callAPISuccess('participant', 'create', array( - 'event_id' => $event['id'], - 'contact_id' => $this->_contactID, - )); + 'event_id' => $event['id'], + 'contact_id' => $this->_contactID, + )); $description = "Demonstrates use of nested get to fetch event data with participant records."; $subfile = "NestedEventGet"; @@ -632,6 +631,7 @@ public function testUpdateCreateParticipantFeeLevelNoSeparator() { ); $this->getAndCheck($update, $participant['id'], 'participant'); } + ///////////////// civicrm_participant_update methods /** diff --git a/tests/phpunit/api/v3/PaymentProcessorTypeTest.php b/tests/phpunit/api/v3/PaymentProcessorTypeTest.php index 02a148893436..1c111296f5af 100644 --- a/tests/phpunit/api/v3/PaymentProcessorTypeTest.php +++ b/tests/phpunit/api/v3/PaymentProcessorTypeTest.php @@ -174,7 +174,8 @@ public function testPaymentProcessorTypeUpdate() { $params = array( 'id' => $this->_ppTypeID, - 'name' => 'API_Test_PP', // keep the same + // keep the same + 'name' => 'API_Test_PP', 'title' => 'API Test Payment Processor 2', 'class_name' => 'CRM_Core_Payment_APITest 2', 'billing_mode' => 2, diff --git a/tests/phpunit/api/v3/PaymentTest.php b/tests/phpunit/api/v3/PaymentTest.php index 0c49ce88f486..129495aa7855 100644 --- a/tests/phpunit/api/v3/PaymentTest.php +++ b/tests/phpunit/api/v3/PaymentTest.php @@ -34,9 +34,6 @@ */ class api_v3_PaymentTest extends CiviUnitTestCase { - /** - * Assume empty database with just civicrm_data. - */ protected $_individualId; protected $_financialTypeId = 1; protected $_apiversion; @@ -135,7 +132,8 @@ public function testPaymentEmailReceipt() { 'Dear Anthony,', 'Total Fees: $ 300.00', 'This Payment Amount: $ 50.00', - 'Balance Owed: $ 100.00', //150 was paid in the 1st payment. + //150 was paid in the 1st payment. + 'Balance Owed: $ 100.00', 'Event Information and Location', 'Paid By: Check', 'Check Number: 345', diff --git a/tests/phpunit/api/v3/PcpTest.php b/tests/phpunit/api/v3/PcpTest.php index eeb50621bd05..21ac18ac3c1a 100644 --- a/tests/phpunit/api/v3/PcpTest.php +++ b/tests/phpunit/api/v3/PcpTest.php @@ -55,7 +55,8 @@ public function setUp() { 'title' => "Pcp title", 'contact_id' => 1, 'page_id' => 1, - 'pcp_block_id' => 1); + 'pcp_block_id' => 1, + ); parent::setUp(); } diff --git a/tests/phpunit/api/v3/PhoneTest.php b/tests/phpunit/api/v3/PhoneTest.php index 5d32a51482fe..f8aff7aad372 100644 --- a/tests/phpunit/api/v3/PhoneTest.php +++ b/tests/phpunit/api/v3/PhoneTest.php @@ -38,7 +38,6 @@ class api_v3_PhoneTest extends CiviUnitTestCase { protected $_locationType; protected $_params; - public function setUp() { $this->_apiversion = 3; parent::setUp(); diff --git a/tests/phpunit/api/v3/PledgePaymentTest.php b/tests/phpunit/api/v3/PledgePaymentTest.php index 4f2a3e88c1cb..fbf0f7b2cec9 100644 --- a/tests/phpunit/api/v3/PledgePaymentTest.php +++ b/tests/phpunit/api/v3/PledgePaymentTest.php @@ -33,9 +33,6 @@ */ class api_v3_PledgePaymentTest extends CiviUnitTestCase { - /** - * Assume empty database with just civicrm_data. - */ protected $_individualId; protected $_pledgeID; protected $_apiversion = 3; @@ -169,7 +166,6 @@ public function testPledgeStatus() { $this->assertEquals(array_search('Completed', $paymentStatusTypes), $checkPaymentStatus['status_id']); } - /** * Test that passing in a single variable works:: status_id */ diff --git a/tests/phpunit/api/v3/PledgeTest.php b/tests/phpunit/api/v3/PledgeTest.php index b0adbd69ede1..507987b67bf5 100644 --- a/tests/phpunit/api/v3/PledgeTest.php +++ b/tests/phpunit/api/v3/PledgeTest.php @@ -33,9 +33,6 @@ */ class api_v3_PledgeTest extends CiviUnitTestCase { - /** - * Assume empty database with just civicrm_data. - */ protected $_individualId; protected $_pledge; protected $_apiversion; @@ -322,7 +319,6 @@ public function testCreatePledgeMontlySchedule() { $apiResult = $this->callAPISuccess('pledge', 'create', $params); } - /** * Test creation of pledge with only one payment. * @@ -505,7 +501,6 @@ public function testDeleteEmptyParamsPledge() { $this->callAPIFailure('pledge', 'delete', array(), 'Mandatory key(s) missing from params array: id'); } - /** * Failure test for invalid pledge id. */ diff --git a/tests/phpunit/api/v3/ProfileTest.php b/tests/phpunit/api/v3/ProfileTest.php index ce7af69fdf7d..6e2e88f7820b 100644 --- a/tests/phpunit/api/v3/ProfileTest.php +++ b/tests/phpunit/api/v3/ProfileTest.php @@ -161,17 +161,17 @@ public function testProfileGetMultipleHasBillingLocation() { $individual = $this->_createIndividualContact(); $contactId = key($individual); $this->callAPISuccess('address', 'create', array( - 'contact_id' => $contactId, - 'street_address' => '25 Big Street', - 'city' => 'big city', - 'location_type_id' => 5, - )); + 'contact_id' => $contactId, + 'street_address' => '25 Big Street', + 'city' => 'big city', + 'location_type_id' => 5, + )); $this->callAPISuccess('email', 'create', array( - 'contact_id' => $contactId, - 'email' => 'big@once.com', - 'location_type_id' => 2, - 'is_billing' => 1, - )); + 'contact_id' => $contactId, + 'email' => 'big@once.com', + 'location_type_id' => 2, + 'is_billing' => 1, + )); $params = array( 'profile_id' => array($this->_profileID, 1, 'Billing'), @@ -289,9 +289,9 @@ public function testGetFields() { $this->_createIndividualProfile(); $this->_addCustomFieldToProfile($this->_profileID); $result = $this->callAPIAndDocument('profile', 'getfields', array( - 'action' => 'submit', - 'profile_id' => $this->_profileID, - ), __FUNCTION__, __FILE__, + 'action' => 'submit', + 'profile_id' => $this->_profileID, + ), __FUNCTION__, __FILE__, 'demonstrates retrieving profile fields passing in an id'); $this->assertArrayKeyExists('first_name', $result['values']); $this->assertEquals('2', $result['values']['first_name']['type']); @@ -306,11 +306,10 @@ public function testGetFields() { */ public function testGetFieldsParticipantProfile() { $result = $this->callAPISuccess('profile', 'getfields', array( - 'action' => 'submit', - 'profile_id' => 'participant_status', - 'get_options' => 'all', - ) - ); + 'action' => 'submit', + 'profile_id' => 'participant_status', + 'get_options' => 'all', + )); $this->assertTrue(array_key_exists('participant_status_id', $result['values'])); $this->assertEquals('Attended', $result['values']['participant_status_id']['options'][2]); $this->assertEquals(array('participant_status'), $result['values']['participant_status_id']['api.aliases']); @@ -322,18 +321,17 @@ public function testGetFieldsParticipantProfile() { */ public function testGetFieldsMembershipBatchProfile() { $result = $this->callAPISuccess('profile', 'getfields', array( - 'action' => 'submit', - 'profile_id' => 'membership_batch_entry', - 'get_options' => 'all', - ) - ); + 'action' => 'submit', + 'profile_id' => 'membership_batch_entry', + 'get_options' => 'all', + )); $this->assertTrue(array_key_exists('total_amount', $result['values'])); $this->assertTrue(array_key_exists('financial_type_id', $result['values'])); $this->assertEquals(array( - 'contribution_type_id', - 'contribution_type', - 'financial_type', - ), $result['values']['financial_type_id']['api.aliases']); + 'contribution_type_id', + 'contribution_type', + 'financial_type', + ), $result['values']['financial_type_id']['api.aliases']); $this->assertTrue(!array_key_exists('financial_type', $result['values'])); $this->assertEquals(12, $result['values']['receive_date']['type']); } @@ -347,11 +345,10 @@ public function testGetFieldsAllProfiles() { $profileIDs = array_keys($result['values']); foreach ($profileIDs as $profileID) { $this->callAPISuccess('profile', 'getfields', array( - 'action' => 'submit', - 'profile_id' => $profileID, - 'get_options' => 'all', - ) - ); + 'action' => 'submit', + 'profile_id' => $profileID, + 'get_options' => 'all', + )); } } @@ -451,14 +448,14 @@ public function testProfileSubmitCheckCaching() { $membershipTypes = $this->callAPISuccess('membership_type', 'get', array()); $profileFields = $this->callAPISuccess('profile', 'getfields', array( - 'get_options' => 'all', - 'action' => 'submit', - 'profile_id' => 'membership_batch_entry', - )); + 'get_options' => 'all', + 'action' => 'submit', + 'profile_id' => 'membership_batch_entry', + )); $getoptions = $this->callAPISuccess('membership', 'getoptions', array( - 'field' => 'membership_type', - 'context' => 'validate', - )); + 'field' => 'membership_type', + 'context' => 'validate', + )); $this->assertEquals(array_keys($membershipTypes['values']), array_keys($getoptions['values'])); $this->assertEquals(array_keys($membershipTypes['values']), array_keys($profileFields['values']['membership_type_id']['options'])); @@ -469,9 +466,9 @@ public function testProfileSubmitCheckCaching() { */ public function testMembershipGetFieldsOrder() { $result = $this->callAPISuccess('profile', 'getfields', array( - 'action' => 'submit', - 'profile_id' => 'membership_batch_entry', - )); + 'action' => 'submit', + 'profile_id' => 'membership_batch_entry', + )); $weight = 1; foreach ($result['values'] as $fieldName => $field) { if ($fieldName == 'profile_id') { @@ -691,10 +688,10 @@ public function testProfileApply() { } foreach (array( - 'email', - 'phone', - 'address', - ) as $fieldType) { + 'email', + 'phone', + 'address', + ) as $fieldType) { $typeValues = array_pop($result['values'][$fieldType]); foreach ($expected[$fieldType] as $field => $value) { $this->assertEquals($value, CRM_Utils_Array::value($field, $typeValues), "In line " . __LINE__ . " error message: " . "missing/mismatching value for {$field} ({$fieldType})" @@ -810,31 +807,30 @@ public function testSubmitGreetingFields() { */ public function _createIndividualContact($params = array()) { $contactParams = array_merge(array( - 'first_name' => 'abc1', - 'last_name' => 'xyz1', - 'email' => 'abc1.xyz1@yahoo.com', - 'api.address.create' => array( - 'location_type_id' => 1, - 'is_primary' => 1, - 'street_address' => '5 Saint Helier St', - 'county' => 'Marin', - 'country' => 'UNITED STATES', - 'state_province' => 'Michigan', - 'supplemental_address_1' => 'Hallmark Ct', - 'supplemental_address_2' => 'Jersey Village', - 'supplemental_address_3' => 'My Town', - 'postal_code' => '90210', - 'city' => 'Gotham City', - 'is_billing' => 0, - ), - 'api.phone.create' => array( - 'location_type_id' => '1', - 'phone' => '021 512 755', - 'phone_type_id' => '1', - 'is_primary' => '1', - ), - ), $params - ); + 'first_name' => 'abc1', + 'last_name' => 'xyz1', + 'email' => 'abc1.xyz1@yahoo.com', + 'api.address.create' => array( + 'location_type_id' => 1, + 'is_primary' => 1, + 'street_address' => '5 Saint Helier St', + 'county' => 'Marin', + 'country' => 'UNITED STATES', + 'state_province' => 'Michigan', + 'supplemental_address_1' => 'Hallmark Ct', + 'supplemental_address_2' => 'Jersey Village', + 'supplemental_address_3' => 'My Town', + 'postal_code' => '90210', + 'city' => 'Gotham City', + 'is_billing' => 0, + ), + 'api.phone.create' => array( + 'location_type_id' => '1', + 'phone' => '021 512 755', + 'phone_type_id' => '1', + 'is_primary' => '1', + ), + ), $params); $this->_contactID = $this->individualCreate($contactParams); $this->_createIndividualProfile(); @@ -1005,10 +1001,10 @@ public function _createIndividualProfile() { public function _addCustomFieldToProfile($profileID) { $ids = $this->entityCustomGroupWithSingleFieldCreate(__FUNCTION__, ''); $this->uFFieldCreate(array( - 'uf_group_id' => $profileID, - 'field_name' => 'custom_' . $ids['custom_field_id'], - 'contact_type' => 'Contact', - )); + 'uf_group_id' => $profileID, + 'field_name' => 'custom_' . $ids['custom_field_id'], + 'contact_type' => 'Contact', + )); } } diff --git a/tests/phpunit/api/v3/RelationshipTest.php b/tests/phpunit/api/v3/RelationshipTest.php index 2ee40f064bc7..469624da2724 100644 --- a/tests/phpunit/api/v3/RelationshipTest.php +++ b/tests/phpunit/api/v3/RelationshipTest.php @@ -300,7 +300,6 @@ public function testRelationshipCreateUpdateDoesNotMangle() { } - /** * Check relationship creation. */ @@ -1123,9 +1122,8 @@ public function testGetRelationshipByTypeDAO() { $this->_ids['relationship'] = $this->callAPISuccess($this->_entity, 'create', array('format.only_id' => TRUE) + $this->_params); $this->callAPISuccess($this->_entity, 'getcount', array( - 'contact_id_a' => $this->_cId_a, - ), - 1); + 'contact_id_a' => $this->_cId_a, + ), 1); $result = $this->callAPISuccess($this->_entity, 'get', array( 'contact_id_a' => $this->_cId_a, 'relationship_type_id' => $this->_relTypeID, @@ -1148,8 +1146,10 @@ public function testGetRelationshipByTypeDAO() { public function testGetRelationshipByTypeArrayDAO() { $this->callAPISuccess($this->_entity, 'create', $this->_params); $org3 = $this->organizationCreate(); - $relType2 = 5; // lets just assume built in ones aren't being messed with! - $relType3 = 6; // lets just assume built in ones aren't being messed with! + // lets just assume built in ones aren't being messed with! + $relType2 = 5; + // lets just assume built in ones aren't being messed with! + $relType3 = 6; // Relationship 2. $this->callAPISuccess($this->_entity, 'create', @@ -1232,8 +1232,10 @@ public function testGetRelationshipByMembershipTypeDAO() { $this->callAPISuccess($this->_entity, 'create', $this->_params); $org3 = $this->organizationCreate(); - $relType2 = 5; // lets just assume built in ones aren't being messed with! - $relType3 = 6; // lets just assume built in ones aren't being messed with! + // lets just assume built in ones aren't being messed with! + $relType2 = 5; + // lets just assume built in ones aren't being messed with! + $relType3 = 6; $relType1 = 1; $memberType = $this->membershipTypeCreate(array( 'relationship_type_id' => CRM_Core_DAO::VALUE_SEPARATOR . $relType1 . CRM_Core_DAO::VALUE_SEPARATOR . $relType3 . CRM_Core_DAO::VALUE_SEPARATOR, diff --git a/tests/phpunit/api/v3/ReportTemplateTest.php b/tests/phpunit/api/v3/ReportTemplateTest.php index c9e212e0a8a5..b2eb935a1878 100644 --- a/tests/phpunit/api/v3/ReportTemplateTest.php +++ b/tests/phpunit/api/v3/ReportTemplateTest.php @@ -559,8 +559,8 @@ public function testCaseDetailsCaseTypeHeader() { $this->callAPISuccess('report_template', 'getrows', [ 'report_id' => 'case/detail', 'fields' => ['subject' => 1, 'client_sort_name' => 1], - 'order_bys' => [ - 1 => [ + 'order_bys' => [ + 1 => [ 'column' => 'case_type_title', 'order' => 'ASC', 'section' => '1', @@ -844,11 +844,11 @@ public function setUpIntersectingGroups() { )); foreach (array( - $addedToBothIndividualID, - $removedFromBothIndividualID, - $addedToSmartGroupRemovedFromOtherIndividualID, - $removedFromSmartGroupAddedToOtherIndividualID, - ) as $contactID) { + $addedToBothIndividualID, + $removedFromBothIndividualID, + $addedToSmartGroupRemovedFromOtherIndividualID, + $removedFromSmartGroupAddedToOtherIndividualID, + ) as $contactID) { $this->contributionCreate(array( 'contact_id' => $contactID, 'invoice_id' => '', @@ -1083,7 +1083,7 @@ public function testContributionDetailTotalHeader() { 'financial_type_id' => '1', 'receive_date' => '1', 'total_amount' => '1', - ], + ], 'order_bys' => [['column' => 'sort_name', 'order' => 'ASC', 'section' => '1']], 'options' => array('metadata' => array('sql')), )); @@ -1219,7 +1219,7 @@ public function testPcpReportTotals() { 'fields' => [ 'amount_1' => '1', 'soft_id' => '1', - ], + ], )); $values = $rows['values'][0]; $this->assertEquals(100.00, $values['civicrm_contribution_soft_amount_1_sum'], "Total commited should be $100"); diff --git a/tests/phpunit/api/v3/SettingTest.php b/tests/phpunit/api/v3/SettingTest.php index 3536f25955c1..aa75cf711572 100644 --- a/tests/phpunit/api/v3/SettingTest.php +++ b/tests/phpunit/api/v3/SettingTest.php @@ -158,7 +158,8 @@ public function testOnChange() { 'is_contact' => 0, 'description' => NULL, 'help_text' => NULL, - 'on_change' => array(// list of callbacks + // list of callbacks + 'on_change' => array( array(__CLASS__, '_testOnChange_onChangeExample'), ), ), @@ -365,10 +366,9 @@ public function testGetExtensionSetting() { */ public function testGetConfigSetting() { $settings = $this->callAPISuccess('setting', 'get', array( - 'name' => 'defaultCurrency', - 'sequential' => 1, - ) - ); + 'name' => 'defaultCurrency', + 'sequential' => 1, + )); $this->assertEquals('USD', $settings['values'][0]['defaultCurrency']); } @@ -377,20 +377,17 @@ public function testGetConfigSetting() { */ public function testGetSetConfigSettingMultipleDomains() { $settings = $this->callAPISuccess('setting', 'create', array( - 'defaultCurrency' => 'USD', - 'domain_id' => $this->_currentDomain, - ) - ); + 'defaultCurrency' => 'USD', + 'domain_id' => $this->_currentDomain, + )); $settings = $this->callAPISuccess('setting', 'create', array( - 'defaultCurrency' => 'CAD', - 'domain_id' => $this->_domainID2, - ) - ); + 'defaultCurrency' => 'CAD', + 'domain_id' => $this->_domainID2, + )); $settings = $this->callAPISuccess('setting', 'get', array( - 'return' => 'defaultCurrency', - 'domain_id' => 'all', - ) - ); + 'return' => 'defaultCurrency', + 'domain_id' => 'all', + )); $this->assertEquals('USD', $settings['values'][$this->_currentDomain]['defaultCurrency']); $this->assertEquals('CAD', $settings['values'][$this->_domainID2]['defaultCurrency'], "second domain (id {$this->_domainID2} ) should be set to CAD. First dom was {$this->_currentDomain} & was USD"); diff --git a/tests/phpunit/api/v3/StatusPreferenceTest.php b/tests/phpunit/api/v3/StatusPreferenceTest.php index 31104eb6883e..994f12f23018 100644 --- a/tests/phpunit/api/v3/StatusPreferenceTest.php +++ b/tests/phpunit/api/v3/StatusPreferenceTest.php @@ -37,7 +37,6 @@ class api_v3_StatusPreferenceTest extends CiviUnitTestCase { protected $_locationType; protected $_params; - public function setUp() { $this->_apiversion = 3; parent::setUp(); diff --git a/tests/phpunit/api/v3/SurveyRespondantTest.php b/tests/phpunit/api/v3/SurveyRespondantTest.php index 04a0a2c08cd8..60bf07e4c7a5 100644 --- a/tests/phpunit/api/v3/SurveyRespondantTest.php +++ b/tests/phpunit/api/v3/SurveyRespondantTest.php @@ -33,7 +33,6 @@ class api_v3_SurveyRespondantTest extends CiviUnitTestCase { protected $_apiversion = 3; protected $params; - public function setUp() { parent::setUp(); $this->useTransaction(TRUE); diff --git a/tests/phpunit/api/v3/SurveyTest.php b/tests/phpunit/api/v3/SurveyTest.php index 213de30d0dbf..9ba73694772b 100644 --- a/tests/phpunit/api/v3/SurveyTest.php +++ b/tests/phpunit/api/v3/SurveyTest.php @@ -49,12 +49,11 @@ class api_v3_SurveyTest extends CiviUnitTestCase { protected $entity = 'survey'; public $DBResetRequired = FALSE; - public function setUp() { $phoneBankActivityTypeID = $this->callAPISuccessGetValue('Option_value', array( - 'label' => 'PhoneBank', - 'return' => 'value', - ), 'integer'); + 'label' => 'PhoneBank', + 'return' => 'value', + ), 'integer'); $this->useTransaction(); $this->enableCiviCampaign(); $this->params = array( diff --git a/tests/phpunit/api/v3/SyntaxConformanceTest.php b/tests/phpunit/api/v3/SyntaxConformanceTest.php index e16d1e7e7d8f..76d31f00158a 100644 --- a/tests/phpunit/api/v3/SyntaxConformanceTest.php +++ b/tests/phpunit/api/v3/SyntaxConformanceTest.php @@ -47,6 +47,7 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { /** * This test case doesn't require DB reset. + * @var bool */ public $DBResetRequired = FALSE; @@ -54,8 +55,9 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase { /** * Map custom group entities to civicrm components. + * @var array */ - static $componentMap = array( + protected static $componentMap = array( 'Contribution' => 'CiviContribute', 'Membership' => 'CiviMember', 'Participant' => 'CiviEvent', @@ -81,7 +83,8 @@ public function setUp() { parent::setUp(); $this->enableCiviCampaign(); $this->toBeImplemented['get'] = array( - 'CxnApp', // CxnApp.get exists but relies on remote data outside our control; QA w/UtilsTest::testBasicArrayGet + // CxnApp.get exists but relies on remote data outside our control; QA w/UtilsTest::testBasicArrayGet + 'CxnApp', 'Profile', 'CustomValue', 'Constant', @@ -107,7 +110,8 @@ public function setUp() { 'User', 'Payment', 'Order', - 'SavedSearch', //work fine in local + //work fine in local + 'SavedSearch', 'Logging', ); $this->toBeImplemented['delete'] = array( @@ -567,12 +571,18 @@ public static function toBeSkipped_getlimit() { */ public static function toBeSkipped_getSqlOperators() { $entitiesWithout = array( - 'Case', //case api has non-std mandatory fields one of (case_id, contact_id, activity_id, contact_id) - 'Contact', // on the todo list! - 'EntityTag', // non-standard api - has inappropriate mandatory fields & doesn't implement limit - 'Extension', // can't handle creating 25 - 'Note', // note has a default get that isn't implemented in createTestObject -meaning you don't 'get' them - 'Setting', //a bit of a pseudoapi - keys by domain + //case api has non-std mandatory fields one of (case_id, contact_id, activity_id, contact_id) + 'Case', + // on the todo list! + 'Contact', + // non-standard api - has inappropriate mandatory fields & doesn't implement limit + 'EntityTag', + // can't handle creating 25 + 'Extension', + // note has a default get that isn't implemented in createTestObject -meaning you don't 'get' them + 'Note', + //a bit of a pseudoapi - keys by domain + 'Setting', ); return $entitiesWithout; } @@ -599,15 +609,18 @@ public function getKnownUnworkablesUpdateSingle($entity, $key) { ), 'Address' => array( 'cant_update' => array( - 'state_province_id', //issues with country id - need to ensure same country + //issues with country id - need to ensure same country + 'state_province_id', 'world_region', - 'master_id', //creates relationship + //creates relationship + 'master_id', ), 'cant_return' => ['street_parsing', 'skip_geocode', 'fix_address'], ), 'Batch' => array( 'cant_update' => array( - 'entity_table', // believe this field is defined in error + // believe this field is defined in error + 'entity_table', ), 'cant_return' => array( 'entity_table', @@ -660,9 +673,11 @@ public function getKnownUnworkablesUpdateSingle($entity, $key) { 'installments', 'original_installment_amount', 'next_pay_date', - 'amount', // can't be changed through API, + // can't be changed through API, + 'amount', ), - 'break_return' => array(// if these are passed in they are retrieved from the wrong table + // if these are passed in they are retrieved from the wrong table + 'break_return' => array( 'honor_contact_id', 'cancel_date', 'contribution_page_id', @@ -670,8 +685,10 @@ public function getKnownUnworkablesUpdateSingle($entity, $key) { 'financial_type_id', 'currency', ), - 'cant_return' => array(// can't be retrieved from api - 'honor_type_id', //due to uniquename missing + // can't be retrieved from api + 'cant_return' => array( + //due to uniquename missing + 'honor_type_id', 'end_date', 'modified_date', 'acknowledge_date', @@ -697,7 +714,8 @@ public function getKnownUnworkablesUpdateSingle($entity, $key) { ), 'PriceFieldValue' => array( 'cant_update' => array( - 'weight', //won't update as there is no 1 in the same price set + //won't update as there is no 1 in the same price set + 'weight', ), ), 'ReportInstance' => array( @@ -842,7 +860,8 @@ public function testCustomDataGet($entityName) { $this->markTestIncomplete('Note can not be processed here because of a vagary in the note api, it adds entity_table=contact to the get params when id is not present - which makes sense almost always but kills this test'); } $this->quickCleanup(array('civicrm_uf_match')); - $this->createLoggedInUser();// so subsidiary activities are created + // so subsidiary activities are created + $this->createLoggedInUser(); $entitiesWithNamingIssues = [ 'SmsProvider' => 'Provider', @@ -946,7 +965,6 @@ public function testGetList($Entity) { $this->callAPISuccess($Entity, 'getlist', ['label_field' => 'id']); } - /** * Test getlist works when entity is lowercase * @dataProvider entities_get @@ -1016,7 +1034,8 @@ public function testByID_get($entityName) { * @param string $entityName */ public function testLimit($entityName) { - $cases = array(); // each case is array(0 => $inputtedApiOptions, 1 => $expectedResultCount) + // each case is array(0 => $inputtedApiOptions, 1 => $expectedResultCount) + $cases = array(); $cases[] = array( array('options' => array('limit' => NULL)), 30, @@ -1218,7 +1237,7 @@ public function testNonExistantID_get($Entity) { /** * @dataProvider toBeSkipped_create - entities that don't need a create action + * entities that don't need a create action * @param $Entity */ public function testNotImplemented_create($Entity) { @@ -1272,7 +1291,8 @@ public function testValidSortSingleArrayById_get($Entity) { 'id desc' => '_id desc', 'id DESC' => '_id DESC', 'id ASC' => '_id ASC', - 'id asc' => '_id asc'); + 'id asc' => '_id asc', + ); foreach ($tests as $test => $expected) { if (in_array($Entity, $invalidEntitys)) { $this->markTestSkipped('It seems OK for ' . $Entity . ' to skip here as it silently ignores passed in params'); @@ -1406,10 +1426,9 @@ public function testCreateSingleValueAlter($entityName) { } // typecast with array to satisfy changes made in CRM-13160 if ($entityName == 'MembershipType' && in_array($fieldName, array( - 'relationship_type_id', - 'relationship_direction', - )) - ) { + 'relationship_type_id', + 'relationship_direction', + ))) { $entity[$fieldName] = (array) $entity[$fieldName]; } } @@ -1459,10 +1478,10 @@ public function testCreateSingleValueAlter($entityName) { //eg. pdf_format id doesn't ship with any if (isset($specs['pseudoconstant']['optionGroupName'])) { $optionValue = $this->callAPISuccess('option_value', 'create', array( - 'option_group_id' => $specs['pseudoconstant']['optionGroupName'], - 'label' => 'new option value', - 'sequential' => 1, - )); + 'option_group_id' => $specs['pseudoconstant']['optionGroupName'], + 'label' => 'new option value', + 'sequential' => 1, + )); $optionValue = $optionValue['values']; $keyColumn = CRM_Utils_Array::value('keyColumn', $specs['pseudoconstant'], 'value'); $options[$optionValue[0][$keyColumn]] = 'new option value'; @@ -1518,12 +1537,12 @@ public function testCreateSingleValueAlter($entityName) { } $this->assertAPIArrayComparison($entity, $checkEntity, array(), "checking if $fieldName was correctly updated\n" . print_r(array( - 'update-params' => $updateParams, - 'update-result' => $update, - 'getsingle-params' => $checkParams, - 'getsingle-result' => $checkEntity, - 'expected entity' => $entity, - ), TRUE)); + 'update-params' => $updateParams, + 'update-result' => $update, + 'getsingle-params' => $checkParams, + 'getsingle-result' => $checkEntity, + 'expected entity' => $entity, + ), TRUE)); if ($resetFKTo) { //reset the foreign key fields because otherwise our cleanup routine fails & some other unexpected stuff can kick in $entity = array_merge($entity, $resetFKTo); @@ -1548,7 +1567,7 @@ public function testCreateSingleValueAlter($entityName) { /** * @dataProvider toBeSkipped_delete - entities that don't need a delete action + * entities that don't need a delete action * @param $Entity */ public function testNotImplemented_delete($Entity) { diff --git a/tests/phpunit/api/v3/SystemCheckTest.php b/tests/phpunit/api/v3/SystemCheckTest.php index b17cf6d48574..ebd1a3f9fb8a 100644 --- a/tests/phpunit/api/v3/SystemCheckTest.php +++ b/tests/phpunit/api/v3/SystemCheckTest.php @@ -41,7 +41,6 @@ class api_v3_SystemCheckTest extends CiviUnitTestCase { protected $_locationType; protected $_params; - public function setUp() { $this->_apiversion = 3; parent::setUp(); diff --git a/tests/phpunit/api/v3/TagTest.php b/tests/phpunit/api/v3/TagTest.php index 27aeb873c910..c85d7427199f 100644 --- a/tests/phpunit/api/v3/TagTest.php +++ b/tests/phpunit/api/v3/TagTest.php @@ -35,6 +35,7 @@ class api_v3_TagTest extends CiviUnitTestCase { protected $_apiversion = 3; /** + * @var array * @ids array of values to be cleaned up in the tear down */ protected $ids = array(); @@ -54,6 +55,7 @@ public function setUp() { } ///////////////// civicrm_tag_get methods + /** * Test civicrm_tag_get with wrong params. */ @@ -149,6 +151,7 @@ public function testCreateEntitySpecificTag() { $params['used_for'] = 'civicrm_activity'; $this->getAndCheck($params, $result['id'], 'tag', 1, __FUNCTION__ . ' tag updated in line ' . __LINE__); } + ///////////////// civicrm_tag_delete methods /** diff --git a/tests/phpunit/api/v3/TaxContributionPageTest.php b/tests/phpunit/api/v3/TaxContributionPageTest.php index 8c3e704ff188..7ceef97bd627 100644 --- a/tests/phpunit/api/v3/TaxContributionPageTest.php +++ b/tests/phpunit/api/v3/TaxContributionPageTest.php @@ -383,7 +383,8 @@ public function testCreateUpdateContributionChangeTotal() { $this->assertEquals('120.00', $trxnAmount); $newParams = array( 'id' => $contribution['id'], - 'financial_type_id' => 1, // without tax rate i.e Donation + // without tax rate i.e Donation + 'financial_type_id' => 1, 'total_amount' => '300', ); $contribution = $this->callAPISuccess('contribution', 'create', $newParams); diff --git a/tests/phpunit/api/v3/UFFieldTest.php b/tests/phpunit/api/v3/UFFieldTest.php index 8e39fa141151..945bc52725b8 100644 --- a/tests/phpunit/api/v3/UFFieldTest.php +++ b/tests/phpunit/api/v3/UFFieldTest.php @@ -33,7 +33,10 @@ * @group headless */ class api_v3_UFFieldTest extends CiviUnitTestCase { - // ids from the uf_group_test.xml fixture + /** + * ids from the uf_group_test.xml fixture + * @var int + */ protected $_ufGroupId = 11; protected $_ufFieldId; protected $_contactId = 69; diff --git a/tests/phpunit/api/v3/UFGroupTest.php b/tests/phpunit/api/v3/UFGroupTest.php index 8d1ad601f9c6..fd335b02fae2 100644 --- a/tests/phpunit/api/v3/UFGroupTest.php +++ b/tests/phpunit/api/v3/UFGroupTest.php @@ -33,7 +33,10 @@ * @group headless */ class api_v3_UFGroupTest extends CiviUnitTestCase { - // ids from the uf_group_test.xml fixture + /** + * ids from the uf_group_test.xml fixture + * @var int + */ protected $_ufGroupId; protected $_ufFieldId; protected $_contactId; diff --git a/tests/phpunit/api/v3/UFJoinTest.php b/tests/phpunit/api/v3/UFJoinTest.php index ca35606be90b..381c5e281e1f 100644 --- a/tests/phpunit/api/v3/UFJoinTest.php +++ b/tests/phpunit/api/v3/UFJoinTest.php @@ -33,7 +33,10 @@ * @group headless */ class api_v3_UFJoinTest extends CiviUnitTestCase { - // ids from the uf_group_test.xml fixture + /** + * ids from the uf_group_test.xml fixture + * @var int + */ protected $_ufGroupId = 11; protected $_ufFieldId; protected $_contactId = 69; @@ -97,7 +100,6 @@ public function testFindUFGroupId() { } } - public function testUFJoinEditWrongParamsType() { $params = 'a string'; $result = $this->callAPIFailure('uf_join', 'create', $params); diff --git a/tests/phpunit/api/v3/UFMatchTest.php b/tests/phpunit/api/v3/UFMatchTest.php index 65b937f58ab8..b7c4ee776abc 100644 --- a/tests/phpunit/api/v3/UFMatchTest.php +++ b/tests/phpunit/api/v3/UFMatchTest.php @@ -33,14 +33,16 @@ * @group headless */ class api_v3_UFMatchTest extends CiviUnitTestCase { - // ids from the uf_group_test.xml fixture + /** + * ids from the uf_group_test.xml fixture + * @var int + */ protected $_ufGroupId = 11; protected $_ufFieldId; protected $_contactId; protected $_apiversion; protected $_params = array(); - protected function setUp() { parent::setUp(); $this->_apiversion = 3; diff --git a/tests/phpunit/api/v3/UtilsTest.php b/tests/phpunit/api/v3/UtilsTest.php index 6e13cdde81a4..9de6307fb08a 100644 --- a/tests/phpunit/api/v3/UtilsTest.php +++ b/tests/phpunit/api/v3/UtilsTest.php @@ -324,14 +324,18 @@ public function basicArrayCases() { $cases[] = array( $records, - array('version' => 3), // params - array('a', 'b', 'c', 'd', 'e'), // expected results + // params + array('version' => 3), + // expected results + array('a', 'b', 'c', 'd', 'e'), ); $cases[] = array( $records, - array('version' => 3, 'fruit' => 'apple'), // params - array('a', 'c', 'd', 'e'), // expected results + // params + array('version' => 3, 'fruit' => 'apple'), + // expected results + array('a', 'c', 'd', 'e'), ); $cases[] = array( diff --git a/tests/phpunit/api/v3/ValidateTest.php b/tests/phpunit/api/v3/ValidateTest.php index fc0ed1e80664..0a25ac6c4067 100644 --- a/tests/phpunit/api/v3/ValidateTest.php +++ b/tests/phpunit/api/v3/ValidateTest.php @@ -32,6 +32,7 @@ * @group headless */ class api_v3_ValidateTest extends CiviUnitTestCase { + /** * This method is called before a test is executed. */ diff --git a/tests/phpunit/api/v3/custom_api/MailingProviderData.php b/tests/phpunit/api/v3/custom_api/MailingProviderData.php index 26c2838d45c6..f01bf6ec9809 100644 --- a/tests/phpunit/api/v3/custom_api/MailingProviderData.php +++ b/tests/phpunit/api/v3/custom_api/MailingProviderData.php @@ -43,13 +43,13 @@ class CRM_Omnimail_DAO_MailingProviderData extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_mailing_provider_data'; + protected static $_tableName = 'civicrm_mailing_provider_data'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var boolean */ - static $_log = FALSE; + protected static $_log = FALSE; /** * External reference for the contact * @@ -100,6 +100,7 @@ public function __construct() { $this->__table = 'civicrm_mailing_provider_data'; parent::__construct(); } + /** * Returns all the column names of this table * @@ -165,7 +166,7 @@ public static function &fields() { 'entity' => 'MailingProviderData', 'bao' => 'CRM_Omnimail_DAO_MailingProviderData', 'localizable' => 0, - ) , + ), 'contact_id' => array( 'name' => 'contact_id', 'type' => CRM_Utils_Type::T_INT, @@ -189,6 +190,7 @@ public static function &fields() { } return Civi::$statics[__CLASS__]['fields']; } + /** * Return a mapping from field-name to the corresponding key (as used in fields()). * @@ -201,6 +203,7 @@ public static function &fieldKeys() { } return Civi::$statics[__CLASS__]['fieldKeys']; } + /** * Returns the names of this table * @@ -209,6 +212,7 @@ public static function &fieldKeys() { public static function getTableName() { return self::$_tableName; } + /** * Returns if this table needs to be logged * @@ -217,6 +221,7 @@ public static function getTableName() { public function getLog() { return self::$_log; } + /** * Returns the list of fields that can be imported * @@ -228,6 +233,7 @@ public static function &import($prefix = FALSE) { $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'mailing_provider_data', $prefix, array()); return $r; } + /** * Returns the list of fields that can be exported * @@ -239,6 +245,7 @@ public static function &export($prefix = FALSE) { $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'mailing_provider_data', $prefix, array()); return $r; } + /** * Returns the list of indices */ diff --git a/tests/qunit/crm-translate/test.php b/tests/qunit/crm-translate/test.php index ddf4723b90be..8090b119e2ff 100644 --- a/tests/qunit/crm-translate/test.php +++ b/tests/qunit/crm-translate/test.php @@ -1,14 +1,13 @@ addSetting(array( - 'strings' => array( - 'One, two, three' => 'Un, deux, trois', - 'I know' => 'Je sais', - ), - 'strings::org.example.foo' => array( - 'I know' => 'Je connais', - ), - ) -); + 'strings' => array( + 'One, two, three' => 'Un, deux, trois', + 'I know' => 'Je sais', + ), + 'strings::org.example.foo' => array( + 'I know' => 'Je connais', + ), +)); // CRM_Core_Resources::singleton()->addScriptFile(...); // CRM_Core_Resources::singleton()->addStyleFile(...); // CRM_Core_Resources::singleton()->addSetting(...); From 3655bea4bfdca18d0a888052aada39bf0d2218da Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Sun, 7 Apr 2019 11:31:17 +1000 Subject: [PATCH 095/121] (NFC) Update CRM/SMS/ CRM/UF/ CRM/Upgrade/ CRM/Tag/ to be up to speed with the new coder standard --- CRM/SMS/BAO/Provider.php | 2 +- CRM/SMS/Message.php | 47 ++++++++++---------- CRM/SMS/Page/Provider.php | 2 +- CRM/SMS/Provider.php | 6 ++- CRM/Tag/Form/Edit.php | 6 +-- CRM/Tag/Form/Merge.php | 3 +- CRM/UF/Form/AbstractPreview.php | 1 + CRM/UF/Form/Field.php | 8 ++-- CRM/UF/Page/ProfileEditor.php | 1 + CRM/Upgrade/Form.php | 5 +++ CRM/Upgrade/Headless.php | 6 ++- CRM/Upgrade/Incremental/General.php | 26 +++++------ CRM/Upgrade/Incremental/MessageTemplates.php | 12 ++--- CRM/Upgrade/Incremental/php/FiveEleven.php | 4 +- CRM/Upgrade/Incremental/php/FiveTwelve.php | 4 +- CRM/Upgrade/Incremental/php/FourFive.php | 8 ++-- CRM/Upgrade/Incremental/php/FourFour.php | 14 +++--- CRM/Upgrade/Incremental/php/FourSeven.php | 4 ++ CRM/Upgrade/Incremental/php/FourSix.php | 3 +- CRM/Upgrade/Incremental/php/FourThree.php | 3 +- CRM/Upgrade/Page/Cleanup.php | 1 + CRM/Upgrade/Page/Upgrade.php | 3 +- 22 files changed, 93 insertions(+), 76 deletions(-) diff --git a/CRM/SMS/BAO/Provider.php b/CRM/SMS/BAO/Provider.php index 932d18002914..45973eed249e 100644 --- a/CRM/SMS/BAO/Provider.php +++ b/CRM/SMS/BAO/Provider.php @@ -148,7 +148,7 @@ public static function del($providerID) { $dao = new CRM_SMS_DAO_Provider(); $dao->id = $providerID; - $dao->whereAdd = "(domain_id = " . CRM_Core_Config::domainID() . "OR domain_id IS NULL)"; + $dao->whereAdd = "(domain_id = " . CRM_Core_Config::domainID() . "OR domain_id IS NULL)"; if (!$dao->find(TRUE)) { return NULL; } diff --git a/CRM/SMS/Message.php b/CRM/SMS/Message.php index 8b0787f602ff..c6b1557ca1d4 100644 --- a/CRM/SMS/Message.php +++ b/CRM/SMS/Message.php @@ -1,31 +1,30 @@ formatPhone($this->stripPhone($message->from), $like, "like"); $message->fromContactID = CRM_Core_DAO::singleValueQuery("SELECT contact_id FROM civicrm_phone JOIN civicrm_contact ON civicrm_contact.id = civicrm_phone.contact_id WHERE !civicrm_contact.is_deleted AND phone LIKE %1", array( - 1 => array($formatFrom, 'String'))); + 1 => array($formatFrom, 'String'), + )); } if (!$message->fromContactID) { @@ -254,7 +255,8 @@ public function processInbound($from, $body, $to = NULL, $trackID = NULL) { // find recipient if $toContactID not set by hook if ($message->to) { $message->toContactID = CRM_Core_DAO::singleValueQuery("SELECT contact_id FROM civicrm_phone JOIN civicrm_contact ON civicrm_contact.id = civicrm_phone.contact_id WHERE !civicrm_contact.is_deleted AND phone LIKE %1", array( - 1 => array('%' . $message->to, 'String'))); + 1 => array('%' . $message->to, 'String'), + )); } else { $message->toContactID = $message->fromContactID; diff --git a/CRM/Tag/Form/Edit.php b/CRM/Tag/Form/Edit.php index b4feead66f3a..14b4adb6e124 100644 --- a/CRM/Tag/Form/Edit.php +++ b/CRM/Tag/Form/Edit.php @@ -128,9 +128,9 @@ public function buildQuickForm() { CRM_Core_DAO::getAttribute('CRM_Core_DAO_Tag', 'name'), TRUE ); $this->addRule('name', ts('Name already exists in Database.'), 'objectExists', [ - 'CRM_Core_DAO_Tag', - $this->_id, - ]); + 'CRM_Core_DAO_Tag', + $this->_id, + ]); $this->add('text', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_Tag', 'description') diff --git a/CRM/Tag/Form/Merge.php b/CRM/Tag/Form/Merge.php index a581bf141f65..67ef526fb430 100644 --- a/CRM/Tag/Form/Merge.php +++ b/CRM/Tag/Form/Merge.php @@ -77,8 +77,7 @@ public function buildQuickForm() { 'type' => 'cancel', 'name' => ts('Cancel'), ], - ] - ); + ]); } /** diff --git a/CRM/UF/Form/AbstractPreview.php b/CRM/UF/Form/AbstractPreview.php index 2379f2fef6b2..d0b0889b0392 100644 --- a/CRM/UF/Form/AbstractPreview.php +++ b/CRM/UF/Form/AbstractPreview.php @@ -111,6 +111,7 @@ public function buildQuickForm() { * * @return string */ + /** * @return string */ diff --git a/CRM/UF/Form/Field.php b/CRM/UF/Form/Field.php index 7617d6f804a6..9086dfc0b17f 100644 --- a/CRM/UF/Form/Field.php +++ b/CRM/UF/Form/Field.php @@ -688,7 +688,7 @@ public static function formRuleCustomDataExtentColumnValue($customField, $gid, $ $fieldTypeValues = CRM_Core_BAO_UFGroup::groupTypeValues($gid, $fieldType); if (empty($fieldTypeValues[$fieldType])) { - return; + return $errors; } $disallowedTypes = array_diff($extendsColumnValues, $fieldTypeValues[$fieldType]); @@ -1007,9 +1007,9 @@ protected function setMessageIfCountryNotAboveState($fieldName, $locationTypeID, $message = ts('For best results, the Country field should precede the State-Province field in your Profile form. You can use the up and down arrows on field listing page for this profile to change the order of these fields or manually edit weight for Country/State-Province Field.'); if (in_array($fieldName, [ - 'country', - 'state_province', - ]) && count(CRM_Core_Config::singleton()->countryLimit) > 1 + 'country', + 'state_province', + ]) && count(CRM_Core_Config::singleton()->countryLimit) > 1 ) { // get state or country field weight if exists $ufFieldDAO = new CRM_Core_DAO_UFField(); diff --git a/CRM/UF/Page/ProfileEditor.php b/CRM/UF/Page/ProfileEditor.php index d0724c3eb60f..9d4e38a7b1bc 100644 --- a/CRM/UF/Page/ProfileEditor.php +++ b/CRM/UF/Page/ProfileEditor.php @@ -7,6 +7,7 @@ * widgets */ class CRM_UF_Page_ProfileEditor extends CRM_Core_Page { + /** * Run page. * diff --git a/CRM/Upgrade/Form.php b/CRM/Upgrade/Form.php index 7bb04d65f402..483125451f1d 100644 --- a/CRM/Upgrade/Form.php +++ b/CRM/Upgrade/Form.php @@ -52,6 +52,9 @@ class CRM_Upgrade_Form extends CRM_Core_Form { */ const MINIMUM_PHP_VERSION = '5.6'; + /** + * @var \CRM_Core_Config + */ protected $_config; /** @@ -208,6 +211,7 @@ public function buildQuickForm() { * * @return string */ + /** * @return string */ @@ -234,6 +238,7 @@ public function getButtonTitle() { * * @return string */ + /** * @return string */ diff --git a/CRM/Upgrade/Headless.php b/CRM/Upgrade/Headless.php index 122dac41f5da..397481a5726d 100644 --- a/CRM/Upgrade/Headless.php +++ b/CRM/Upgrade/Headless.php @@ -36,7 +36,8 @@ class CRM_Upgrade_Headless { * @param bool $enablePrint * * @throws Exception - * @return array, with keys: + * @return array + * - with keys: * - message: string, HTML-ish blob */ public function run($enablePrint = TRUE) { @@ -71,7 +72,8 @@ public function run($enablePrint = TRUE) { if ($enablePrint) { print ($errorMessage); } - throw $queueResult['exception']; // FIXME test + // FIXME test + throw $queueResult['exception']; } CRM_Upgrade_Form::doFinish(); diff --git a/CRM/Upgrade/Incremental/General.php b/CRM/Upgrade/Incremental/General.php index 7653db11db04..6bad3517082a 100644 --- a/CRM/Upgrade/Incremental/General.php +++ b/CRM/Upgrade/Incremental/General.php @@ -68,9 +68,9 @@ public static function setPreUpgradeMessage(&$preUpgradeMessage, $currentVer, $l if (version_compare(phpversion(), self::MIN_RECOMMENDED_PHP_VER) < 0) { $preUpgradeMessage .= '

    '; $preUpgradeMessage .= ts('You may proceed with the upgrade and CiviCRM %1 will continue working normally, but future releases will require PHP %2 or above. We recommend PHP version %3.', [ - 1 => $latestVer, - 2 => self::MIN_RECOMMENDED_PHP_VER, - 3 => self::RECOMMENDED_PHP_VER, + 1 => $latestVer, + 2 => self::MIN_RECOMMENDED_PHP_VER, + 3 => self::RECOMMENDED_PHP_VER, ]); $preUpgradeMessage .= '

    '; } @@ -84,13 +84,13 @@ public static function setPreUpgradeMessage(&$preUpgradeMessage, $currentVer, $l if (file_exists($ofcFile)) { if (@unlink($ofcFile)) { $preUpgradeMessage .= '
    ' . ts('This system included an outdated, insecure script (%1). The file was automatically deleted.', [ - 1 => $ofcFile, - ]); + 1 => $ofcFile, + ]); } else { $preUpgradeMessage .= '
    ' . ts('This system includes an outdated, insecure script (%1). Please delete it.', [ - 1 => $ofcFile, - ]); + 1 => $ofcFile, + ]); } } @@ -136,9 +136,9 @@ public static function updateMessageTemplate(&$message, $version) { }, array_keys($messages), $messages); $message .= '
    ' . ts("The default copies of the message templates listed below will be updated to handle new features or correct a problem. Your installation has customized versions of these message templates, and you will need to apply the updates manually after running this upgrade. Click here for detailed instructions. %2", [ - 1 => 'http://wiki.civicrm.org/confluence/display/CRMDOC/Message+Templates#MessageTemplates-UpgradesandCustomizedSystemWorkflowTemplates', - 2 => '
      ' . implode('', $messagesHtml) . '
    ', - ]); + 1 => 'http://wiki.civicrm.org/confluence/display/CRMDOC/Message+Templates#MessageTemplates-UpgradesandCustomizedSystemWorkflowTemplates', + 2 => '
      ' . implode('', $messagesHtml) . '
    ', + ]); $messageObj->updateTemplates(); } @@ -213,9 +213,9 @@ public static function checkMessageTemplate(&$message, $latestVer, $currentVer) $html = "
      " . $html . "
        "; $message .= '
        ' . ts("The default copies of the message templates listed below will be updated to handle new features or correct a problem. Your installation has customized versions of these message templates, and you will need to apply the updates manually after running this upgrade. Click here for detailed instructions. %2", [ - 1 => 'http://wiki.civicrm.org/confluence/display/CRMDOC/Message+Templates#MessageTemplates-UpgradesandCustomizedSystemWorkflowTemplates', - 2 => $html, - ]); + 1 => 'http://wiki.civicrm.org/confluence/display/CRMDOC/Message+Templates#MessageTemplates-UpgradesandCustomizedSystemWorkflowTemplates', + 2 => $html, + ]); } } diff --git a/CRM/Upgrade/Incremental/MessageTemplates.php b/CRM/Upgrade/Incremental/MessageTemplates.php index ba754a3bb771..163b8fd0883b 100644 --- a/CRM/Upgrade/Incremental/MessageTemplates.php +++ b/CRM/Upgrade/Incremental/MessageTemplates.php @@ -80,7 +80,7 @@ protected function getTemplateUpdates() { ['name' => 'event_online_receipt', 'type' => 'text'], ['name' => 'event_online_receipt', 'type' => 'html'], ['name' => 'event_online_receipt', 'type' => 'subject'], - ] + ], ], [ 'version' => '5.7.alpha1', @@ -88,7 +88,7 @@ protected function getTemplateUpdates() { 'label' => ts('Contributions - Invoice'), 'templates' => [ ['name' => 'contribution_invoice_receipt', 'type' => 'html'], - ] + ], ], [ 'version' => '5.10.alpha1', @@ -101,7 +101,7 @@ protected function getTemplateUpdates() { ['name' => 'contribution_recurring_notify', 'type' => 'html'], ['name' => 'membership_online_receipt', 'type' => 'text'], ['name' => 'membership_online_receipt', 'type' => 'html'], - ] + ], ], [ 'version' => '5.12.alpha1', @@ -110,7 +110,7 @@ protected function getTemplateUpdates() { 'templates' => [ ['name' => 'payment_or_refund_notification', 'type' => 'text'], ['name' => 'payment_or_refund_notification', 'type' => 'html'], - ] + ], ], ]; } @@ -185,8 +185,8 @@ public function updateTemplates() { CRM_Core_DAO::executeQuery(" UPDATE civicrm_msg_template SET msg_{$template['type']} = %1 WHERE id IN (" . implode(',', $templatesToUpdate) . ")", [ - 1 => [$content, 'String'] - ] + 1 => [$content, 'String'], + ] ); } } diff --git a/CRM/Upgrade/Incremental/php/FiveEleven.php b/CRM/Upgrade/Incremental/php/FiveEleven.php index 6a3712120301..3b7548c869c4 100644 --- a/CRM/Upgrade/Incremental/php/FiveEleven.php +++ b/CRM/Upgrade/Incremental/php/FiveEleven.php @@ -79,8 +79,8 @@ public function upgrade_5_11_alpha1($rev) { 'grant_application_received_date', 'grant_decision_date', 'grant_money_transfer_date', - 'grant_due_date' - ] + 'grant_due_date', + ], ]); if (Civi::settings()->get('civimail_multiple_bulk_emails')) { $this->addTask('Update any on hold groups to reflect field change', 'updateOnHold', $rev); diff --git a/CRM/Upgrade/Incremental/php/FiveTwelve.php b/CRM/Upgrade/Incremental/php/FiveTwelve.php index 8202582bb4cb..4b24d588936a 100644 --- a/CRM/Upgrade/Incremental/php/FiveTwelve.php +++ b/CRM/Upgrade/Incremental/php/FiveTwelve.php @@ -85,8 +85,8 @@ public function upgrade_5_12_alpha1($rev) { $this->addTask('Update smart groups where jcalendar fields have been converted to datepicker', 'updateSmartGroups', [ 'datepickerConversion' => [ 'age_asof_date', - 'activity_date_time' - ] + 'activity_date_time', + ], ]); } diff --git a/CRM/Upgrade/Incremental/php/FourFive.php b/CRM/Upgrade/Incremental/php/FourFive.php index 88b4c214cd30..f5b9aada4155 100644 --- a/CRM/Upgrade/Incremental/php/FourFive.php +++ b/CRM/Upgrade/Incremental/php/FourFive.php @@ -111,9 +111,9 @@ public function upgrade_4_5_beta9($rev) { for ($startId = $minId; $startId <= $maxId; $startId += self::BATCH_SIZE) { $endId = $startId + self::BATCH_SIZE - 1; $title = ts("Upgrade DB to 4.5.beta9: Fix line items for {$label} (%1 => %2)", [ - 1 => $startId, - 2 => $endId, - ]); + 1 => $startId, + 2 => $endId, + ]); $this->addTask($title, 'task_4_5_0_fixLineItem', $startId, $endId, $label); } } @@ -131,7 +131,7 @@ public function upgrade_4_5_beta9($rev) { * the first/lowest entity ID to convert. * @param int $endId * the last/highest entity ID to convert. - * @param + * @param string $entityTable * * @return bool */ diff --git a/CRM/Upgrade/Incremental/php/FourFour.php b/CRM/Upgrade/Incremental/php/FourFour.php index b9ea206a2703..cb36122a406f 100644 --- a/CRM/Upgrade/Incremental/php/FourFour.php +++ b/CRM/Upgrade/Incremental/php/FourFour.php @@ -53,8 +53,8 @@ public function setPreUpgradeMessage(&$preUpgradeMessage, $rev, $currentVer = NU } if ($oversizedEntries > 0) { $preUpgradeMessage .= '
        ' . ts("WARNING: There are %1 word-replacement entries which will not be valid in v4.4+ (eg with over 255 characters). They will be dropped during upgrade. For details, consult the CiviCRM log.", [ - 1 => $oversizedEntries, - ]); + 1 => $oversizedEntries, + ]); } } } @@ -86,9 +86,9 @@ public function setPostUpgradeMessage(&$postUpgradeMessage, $rev) { $dao = CRM_Core_DAO::executeQuery($query); if ($dao->N) { $postUpgradeMessage .= '

        ' . ts('Your database contains %1 financial transaction records with no payment instrument (Paid By is empty). If you use the Accounting Batches feature this may result in unbalanced transactions. If you do not use this feature, you can ignore the condition (although you will be required to select a Paid By value for new transactions). You can review steps to correct transactions with missing payment instruments on the wiki.', [ - 1 => $dao->N, - 2 => 'http://wiki.civicrm.org/confluence/display/CRMDOC/Fixing+Transactions+Missing+a+Payment+Instrument+-+4.4.3+Upgrades', - ]) . ''; + 1 => $dao->N, + 2 => 'http://wiki.civicrm.org/confluence/display/CRMDOC/Fixing+Transactions+Missing+a+Payment+Instrument+-+4.4.3+Upgrades', + ]) . ''; } } if ($rev == '4.4.6') { @@ -359,7 +359,8 @@ public function upgrade_4_4_6($rev) { */ public function upgrade_4_4_7($rev, $originalVer, $latestVer) { // For WordPress/Joomla(?), cleanup broken image_URL from 4.4.6 upgrades - https://issues.civicrm.org/jira/browse/CRM-14971 - $exBackendUrl = CRM_Utils_System::url('civicrm/contact/imagefile', 'photo=XXX', TRUE); // URL formula from 4.4.6 upgrade + // URL formula from 4.4.6 upgrade + $exBackendUrl = CRM_Utils_System::url('civicrm/contact/imagefile', 'photo=XXX', TRUE); $exFrontendUrl = CRM_Utils_System::url('civicrm/contact/imagefile', 'photo=XXX', TRUE, NULL, TRUE, TRUE); if ($originalVer == '4.4.6' && $exBackendUrl != $exFrontendUrl) { $minId = CRM_Core_DAO::singleValueQuery('SELECT coalesce(min(id),0) FROM civicrm_contact WHERE image_URL IS NOT NULL'); @@ -770,7 +771,6 @@ public static function rebuildWordReplacementTable() { CRM_Core_BAO_WordReplacement::rebuild(); } - /** * CRM-13998 missing alter statements for civicrm_report_instance */ diff --git a/CRM/Upgrade/Incremental/php/FourSeven.php b/CRM/Upgrade/Incremental/php/FourSeven.php index 933d22d5f469..cf880abb4a8a 100644 --- a/CRM/Upgrade/Incremental/php/FourSeven.php +++ b/CRM/Upgrade/Incremental/php/FourSeven.php @@ -311,6 +311,7 @@ public function upgrade_4_7_12($rev) { $this->addTask(ts('Upgrade DB to %1: SQL', [1 => $rev]), 'runSql', $rev); $this->addTask('Add Data Type column to civicrm_option_group', 'addDataTypeColumnToOptionGroupTable'); } + /** * Upgrade function. * @@ -646,6 +647,9 @@ public static function convertBackendToSettings($domainId, $config_backend) { * Update Invoice number for all completed contribution. * * @param \CRM_Queue_TaskContext $ctx + * @param int $startID + * @param int $endID + * @param string $invoicePrefix * * @return bool */ diff --git a/CRM/Upgrade/Incremental/php/FourSix.php b/CRM/Upgrade/Incremental/php/FourSix.php index ff46607fc608..528c3aba1154 100644 --- a/CRM/Upgrade/Incremental/php/FourSix.php +++ b/CRM/Upgrade/Incremental/php/FourSix.php @@ -90,8 +90,9 @@ public static function updateReferenceDate(CRM_Queue_TaskContext $ctx) { // construct basic where clauses $where = [ + //choose reminder older then 9 months 'reminder.action_date_time >= DATE_SUB(reminder.action_date_time, INTERVAL 9 MONTH)', - ]; //choose reminder older then 9 months + ]; $dao = CRM_Core_DAO::executeQuery($query); while ($dao->fetch()) { diff --git a/CRM/Upgrade/Incremental/php/FourThree.php b/CRM/Upgrade/Incremental/php/FourThree.php index c46589262555..fe264d957725 100644 --- a/CRM/Upgrade/Incremental/php/FourThree.php +++ b/CRM/Upgrade/Incremental/php/FourThree.php @@ -63,7 +63,8 @@ public function setPreUpgradeMessage(&$preUpgradeMessage, $rev, $currentVer = NU // CRM-11823 - Make sure the D6 HTML HEAD technique will work on // upgrade pages ... except when we're in Drush. if (!function_exists('drush_main')) { - theme('item_list', []); // force-load theme registry + // force-load theme registry + theme('item_list', []); $theme_registry = theme_get_registry(); if (!isset($theme_registry['page']['preprocess functions']) || FALSE === array_search('civicrm_preprocess_page_inject', $theme_registry['page']['preprocess functions'])) { CRM_Core_Error::fatal('Please reset the Drupal cache (Administer => Site Configuration => Performance => Clear cached data))'); diff --git a/CRM/Upgrade/Page/Cleanup.php b/CRM/Upgrade/Page/Cleanup.php index 8e12931be973..ee8e5ca496ee 100644 --- a/CRM/Upgrade/Page/Cleanup.php +++ b/CRM/Upgrade/Page/Cleanup.php @@ -29,6 +29,7 @@ * Class CRM_Upgrade_Page_Cleanup */ class CRM_Upgrade_Page_Cleanup extends CRM_Core_Page { + public function cleanup425() { $rows = CRM_Upgrade_Incremental_php_FourTwo::deleteInvalidPairs(); $template = CRM_Core_Smarty::singleton(); diff --git a/CRM/Upgrade/Page/Upgrade.php b/CRM/Upgrade/Page/Upgrade.php index 131214eca3a6..1f60609e5f19 100644 --- a/CRM/Upgrade/Page/Upgrade.php +++ b/CRM/Upgrade/Page/Upgrade.php @@ -182,7 +182,8 @@ public function runFinish() { CRM_Upgrade_Form::doFinish(); } else { - $postUpgradeMessage = ''; // Session was destroyed! Can't recover messages. + // Session was destroyed! Can't recover messages. + $postUpgradeMessage = ''; } // do a version check - after doFinish() sets the final version From fa45b5b94d6640f4e7430272f6029c91bb3f50b6 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Sun, 7 Apr 2019 11:54:08 +1000 Subject: [PATCH 096/121] (NFC) Set _log and _table_name variables to be public --- CRM/ACL/DAO/ACL.php | 6 +++--- CRM/ACL/DAO/Cache.php | 4 ++-- CRM/ACL/DAO/EntityRole.php | 4 ++-- CRM/Activity/DAO/Activity.php | 6 +++--- CRM/Activity/DAO/ActivityContact.php | 6 +++--- CRM/Batch/DAO/Batch.php | 6 +++--- CRM/Batch/DAO/EntityBatch.php | 6 +++--- CRM/Campaign/DAO/Campaign.php | 6 +++--- CRM/Campaign/DAO/CampaignGroup.php | 6 +++--- CRM/Campaign/DAO/Survey.php | 6 +++--- CRM/Case/DAO/Case.php | 6 +++--- CRM/Case/DAO/CaseActivity.php | 6 +++--- CRM/Case/DAO/CaseContact.php | 6 +++--- CRM/Case/DAO/CaseType.php | 4 ++-- CRM/Contact/DAO/ACLContactCache.php | 6 +++--- CRM/Contact/DAO/Contact.php | 6 +++--- CRM/Contact/DAO/ContactType.php | 6 +++--- CRM/Contact/DAO/DashboardContact.php | 6 +++--- CRM/Contact/DAO/Group.php | 6 +++--- CRM/Contact/DAO/GroupContact.php | 6 +++--- CRM/Contact/DAO/GroupContactCache.php | 6 +++--- CRM/Contact/DAO/GroupNesting.php | 6 +++--- CRM/Contact/DAO/GroupOrganization.php | 6 +++--- CRM/Contact/DAO/Relationship.php | 6 +++--- CRM/Contact/DAO/RelationshipType.php | 4 ++-- CRM/Contact/DAO/SavedSearch.php | 6 +++--- CRM/Contact/DAO/SubscriptionHistory.php | 6 +++--- CRM/Contribute/DAO/Contribution.php | 6 +++--- CRM/Contribute/DAO/ContributionPage.php | 6 +++--- CRM/Contribute/DAO/ContributionProduct.php | 6 +++--- CRM/Contribute/DAO/ContributionRecur.php | 6 +++--- CRM/Contribute/DAO/ContributionSoft.php | 6 +++--- CRM/Contribute/DAO/Premium.php | 6 +++--- CRM/Contribute/DAO/PremiumsProduct.php | 6 +++--- CRM/Contribute/DAO/Product.php | 6 +++--- CRM/Contribute/DAO/Widget.php | 6 +++--- CRM/Core/DAO/ActionLog.php | 6 +++--- CRM/Core/DAO/ActionMapping.php | 4 ++-- CRM/Core/DAO/ActionSchedule.php | 6 +++--- CRM/Core/DAO/Address.php | 6 +++--- CRM/Core/DAO/AddressFormat.php | 4 ++-- CRM/Core/DAO/Cache.php | 6 +++--- CRM/Core/DAO/Component.php | 4 ++-- CRM/Core/DAO/Country.php | 6 +++--- CRM/Core/DAO/County.php | 6 +++--- CRM/Core/DAO/CustomField.php | 6 +++--- CRM/Core/DAO/CustomGroup.php | 6 +++--- CRM/Core/DAO/Dashboard.php | 6 +++--- CRM/Core/DAO/Discount.php | 6 +++--- CRM/Core/DAO/Domain.php | 6 +++--- CRM/Core/DAO/Email.php | 6 +++--- CRM/Core/DAO/EntityFile.php | 6 +++--- CRM/Core/DAO/EntityTag.php | 6 +++--- CRM/Core/DAO/Extension.php | 4 ++-- CRM/Core/DAO/File.php | 6 +++--- CRM/Core/DAO/IM.php | 6 +++--- CRM/Core/DAO/Job.php | 6 +++--- CRM/Core/DAO/JobLog.php | 6 +++--- CRM/Core/DAO/LocBlock.php | 6 +++--- CRM/Core/DAO/LocationType.php | 4 ++-- CRM/Core/DAO/Log.php | 6 +++--- CRM/Core/DAO/MailSettings.php | 6 +++--- CRM/Core/DAO/Managed.php | 4 ++-- CRM/Core/DAO/Mapping.php | 4 ++-- CRM/Core/DAO/MappingField.php | 6 +++--- CRM/Core/DAO/Menu.php | 6 +++--- CRM/Core/DAO/MessageTemplate.php | 4 ++-- CRM/Core/DAO/Navigation.php | 6 +++--- CRM/Core/DAO/Note.php | 6 +++--- CRM/Core/DAO/OpenID.php | 6 +++--- CRM/Core/DAO/OptionGroup.php | 4 ++-- CRM/Core/DAO/OptionValue.php | 6 +++--- CRM/Core/DAO/Persistent.php | 4 ++-- CRM/Core/DAO/Phone.php | 6 +++--- CRM/Core/DAO/PreferencesDate.php | 4 ++-- CRM/Core/DAO/PrevNextCache.php | 4 ++-- CRM/Core/DAO/PrintLabel.php | 6 +++--- CRM/Core/DAO/RecurringEntity.php | 4 ++-- CRM/Core/DAO/Setting.php | 6 +++--- CRM/Core/DAO/StateProvince.php | 6 +++--- CRM/Core/DAO/StatusPreference.php | 6 +++--- CRM/Core/DAO/SystemLog.php | 4 ++-- CRM/Core/DAO/Tag.php | 6 +++--- CRM/Core/DAO/Timezone.php | 6 +++--- CRM/Core/DAO/UFField.php | 6 +++--- CRM/Core/DAO/UFGroup.php | 6 +++--- CRM/Core/DAO/UFJoin.php | 6 +++--- CRM/Core/DAO/UFMatch.php | 6 +++--- CRM/Core/DAO/Website.php | 6 +++--- CRM/Core/DAO/WordReplacement.php | 6 +++--- CRM/Core/DAO/Worldregion.php | 4 ++-- CRM/Core/I18n/SchemaStructure.php | 10 +++++----- CRM/Cxn/DAO/Cxn.php | 4 ++-- CRM/Dedupe/DAO/Exception.php | 6 +++--- CRM/Dedupe/DAO/Rule.php | 6 +++--- CRM/Dedupe/DAO/RuleGroup.php | 4 ++-- CRM/Event/Cart/DAO/Cart.php | 4 ++-- CRM/Event/Cart/DAO/EventInCart.php | 4 ++-- CRM/Event/DAO/Event.php | 6 +++--- CRM/Event/DAO/Participant.php | 6 +++--- CRM/Event/DAO/ParticipantPayment.php | 6 +++--- CRM/Event/DAO/ParticipantStatusType.php | 4 ++-- CRM/Financial/DAO/Currency.php | 4 ++-- CRM/Financial/DAO/EntityFinancialAccount.php | 6 +++--- CRM/Financial/DAO/EntityFinancialTrxn.php | 6 +++--- CRM/Financial/DAO/FinancialAccount.php | 6 +++--- CRM/Financial/DAO/FinancialItem.php | 6 +++--- CRM/Financial/DAO/FinancialTrxn.php | 6 +++--- CRM/Financial/DAO/FinancialType.php | 4 ++-- CRM/Financial/DAO/PaymentProcessor.php | 6 +++--- CRM/Financial/DAO/PaymentProcessorType.php | 4 ++-- CRM/Financial/DAO/PaymentToken.php | 6 +++--- CRM/Friend/DAO/Friend.php | 6 +++--- CRM/Grant/DAO/Grant.php | 6 +++--- CRM/Mailing/DAO/BouncePattern.php | 6 +++--- CRM/Mailing/DAO/BounceType.php | 4 ++-- CRM/Mailing/DAO/Mailing.php | 6 +++--- CRM/Mailing/DAO/MailingAB.php | 6 +++--- CRM/Mailing/DAO/MailingComponent.php | 4 ++-- CRM/Mailing/DAO/MailingGroup.php | 6 +++--- CRM/Mailing/DAO/MailingJob.php | 6 +++--- CRM/Mailing/DAO/Recipients.php | 6 +++--- CRM/Mailing/DAO/Spool.php | 6 +++--- CRM/Mailing/DAO/TrackableURL.php | 6 +++--- CRM/Mailing/Event/DAO/Bounce.php | 4 ++-- CRM/Mailing/Event/DAO/Confirm.php | 4 ++-- CRM/Mailing/Event/DAO/Delivered.php | 4 ++-- CRM/Mailing/Event/DAO/Forward.php | 4 ++-- CRM/Mailing/Event/DAO/Opened.php | 4 ++-- CRM/Mailing/Event/DAO/Queue.php | 4 ++-- CRM/Mailing/Event/DAO/Reply.php | 4 ++-- CRM/Mailing/Event/DAO/Subscribe.php | 4 ++-- CRM/Mailing/Event/DAO/TrackableURLOpen.php | 4 ++-- CRM/Mailing/Event/DAO/Unsubscribe.php | 4 ++-- CRM/Member/DAO/Membership.php | 6 +++--- CRM/Member/DAO/MembershipBlock.php | 6 +++--- CRM/Member/DAO/MembershipLog.php | 6 +++--- CRM/Member/DAO/MembershipPayment.php | 6 +++--- CRM/Member/DAO/MembershipStatus.php | 4 ++-- CRM/Member/DAO/MembershipType.php | 6 +++--- CRM/PCP/DAO/PCP.php | 6 +++--- CRM/PCP/DAO/PCPBlock.php | 6 +++--- CRM/Pledge/DAO/Pledge.php | 6 +++--- CRM/Pledge/DAO/PledgeBlock.php | 6 +++--- CRM/Pledge/DAO/PledgePayment.php | 6 +++--- CRM/Price/DAO/LineItem.php | 6 +++--- CRM/Price/DAO/PriceField.php | 6 +++--- CRM/Price/DAO/PriceFieldValue.php | 6 +++--- CRM/Price/DAO/PriceSet.php | 6 +++--- CRM/Price/DAO/PriceSetEntity.php | 6 +++--- CRM/Queue/DAO/QueueItem.php | 4 ++-- CRM/Report/DAO/ReportInstance.php | 6 +++--- CRM/SMS/DAO/Provider.php | 6 +++--- xml/templates/dao.tpl | 4 ++-- 154 files changed, 422 insertions(+), 422 deletions(-) diff --git a/CRM/ACL/DAO/ACL.php b/CRM/ACL/DAO/ACL.php index a1d1b72bd399..51791fb5f5af 100644 --- a/CRM/ACL/DAO/ACL.php +++ b/CRM/ACL/DAO/ACL.php @@ -19,14 +19,14 @@ class CRM_ACL_DAO_ACL extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_acl'; + public static $_tableName = 'civicrm_acl'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * Unique table ID @@ -217,7 +217,7 @@ public static function &fields() { ], 'pseudoconstant' => [ 'callback' => 'CRM_ACL_BAO_ACL::operation', - ], + ] ], 'object_table' => [ 'name' => 'object_table', diff --git a/CRM/ACL/DAO/Cache.php b/CRM/ACL/DAO/Cache.php index 208dce728f8b..cd74fd01bba4 100644 --- a/CRM/ACL/DAO/Cache.php +++ b/CRM/ACL/DAO/Cache.php @@ -19,14 +19,14 @@ class CRM_ACL_DAO_Cache extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_acl_cache'; + public static $_tableName = 'civicrm_acl_cache'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * Unique table ID diff --git a/CRM/ACL/DAO/EntityRole.php b/CRM/ACL/DAO/EntityRole.php index a4dda46a3960..bb0fda29f27a 100644 --- a/CRM/ACL/DAO/EntityRole.php +++ b/CRM/ACL/DAO/EntityRole.php @@ -19,14 +19,14 @@ class CRM_ACL_DAO_EntityRole extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_acl_entity_role'; + public static $_tableName = 'civicrm_acl_entity_role'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * Unique table ID diff --git a/CRM/Activity/DAO/Activity.php b/CRM/Activity/DAO/Activity.php index 10a2bd9c8023..b6434b2bf68b 100644 --- a/CRM/Activity/DAO/Activity.php +++ b/CRM/Activity/DAO/Activity.php @@ -19,14 +19,14 @@ class CRM_Activity_DAO_Activity extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_activity'; + public static $_tableName = 'civicrm_activity'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * Unique Other Activity ID @@ -223,7 +223,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'phone_id', 'civicrm_phone', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'parent_id', 'civicrm_activity', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'relationship_id', 'civicrm_relationship', 'id'); diff --git a/CRM/Activity/DAO/ActivityContact.php b/CRM/Activity/DAO/ActivityContact.php index 41637f1f6b00..eab2e15f2aa4 100644 --- a/CRM/Activity/DAO/ActivityContact.php +++ b/CRM/Activity/DAO/ActivityContact.php @@ -19,14 +19,14 @@ class CRM_Activity_DAO_ActivityContact extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_activity_contact'; + public static $_tableName = 'civicrm_activity_contact'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * Activity contact id @@ -72,7 +72,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'activity_id', 'civicrm_activity', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); diff --git a/CRM/Batch/DAO/Batch.php b/CRM/Batch/DAO/Batch.php index 6e52b333b439..a066888d143f 100644 --- a/CRM/Batch/DAO/Batch.php +++ b/CRM/Batch/DAO/Batch.php @@ -19,14 +19,14 @@ class CRM_Batch_DAO_Batch extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_batch'; + public static $_tableName = 'civicrm_batch'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * Unique Address ID @@ -161,7 +161,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'created_id', 'civicrm_contact', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'modified_id', 'civicrm_contact', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'saved_search_id', 'civicrm_saved_search', 'id'); diff --git a/CRM/Batch/DAO/EntityBatch.php b/CRM/Batch/DAO/EntityBatch.php index a0430c1b1323..7526bf3d9130 100644 --- a/CRM/Batch/DAO/EntityBatch.php +++ b/CRM/Batch/DAO/EntityBatch.php @@ -19,14 +19,14 @@ class CRM_Batch_DAO_EntityBatch extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_entity_batch'; + public static $_tableName = 'civicrm_entity_batch'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * primary key @@ -72,7 +72,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'batch_id', 'civicrm_batch', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName(), 'entity_id', NULL, 'id', 'entity_table'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); diff --git a/CRM/Campaign/DAO/Campaign.php b/CRM/Campaign/DAO/Campaign.php index ed802d0e1cea..361539410738 100644 --- a/CRM/Campaign/DAO/Campaign.php +++ b/CRM/Campaign/DAO/Campaign.php @@ -19,14 +19,14 @@ class CRM_Campaign_DAO_Campaign extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_campaign'; + public static $_tableName = 'civicrm_campaign'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * Unique Campaign ID. @@ -163,7 +163,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'parent_id', 'civicrm_campaign', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'created_id', 'civicrm_contact', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'last_modified_id', 'civicrm_contact', 'id'); diff --git a/CRM/Campaign/DAO/CampaignGroup.php b/CRM/Campaign/DAO/CampaignGroup.php index 7262b441ac86..39807c1ac6ea 100644 --- a/CRM/Campaign/DAO/CampaignGroup.php +++ b/CRM/Campaign/DAO/CampaignGroup.php @@ -19,14 +19,14 @@ class CRM_Campaign_DAO_CampaignGroup extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_campaign_group'; + public static $_tableName = 'civicrm_campaign_group'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * Campaign Group id. @@ -79,7 +79,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'campaign_id', 'civicrm_campaign', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName(), 'entity_id', NULL, 'id', 'entity_table'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); diff --git a/CRM/Campaign/DAO/Survey.php b/CRM/Campaign/DAO/Survey.php index 07abfbf0f225..17cc7fcc90b9 100644 --- a/CRM/Campaign/DAO/Survey.php +++ b/CRM/Campaign/DAO/Survey.php @@ -19,14 +19,14 @@ class CRM_Campaign_DAO_Survey extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_survey'; + public static $_tableName = 'civicrm_survey'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * Survey id. @@ -184,7 +184,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'campaign_id', 'civicrm_campaign', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'created_id', 'civicrm_contact', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'last_modified_id', 'civicrm_contact', 'id'); diff --git a/CRM/Case/DAO/Case.php b/CRM/Case/DAO/Case.php index cbc8b16fb4f0..2405fa06e4b3 100644 --- a/CRM/Case/DAO/Case.php +++ b/CRM/Case/DAO/Case.php @@ -19,14 +19,14 @@ class CRM_Case_DAO_Case extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_case'; + public static $_tableName = 'civicrm_case'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * Unique Case ID @@ -112,7 +112,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'case_type_id', 'civicrm_case_type', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); } diff --git a/CRM/Case/DAO/CaseActivity.php b/CRM/Case/DAO/CaseActivity.php index c18b9c3f296e..f941d5cdd266 100644 --- a/CRM/Case/DAO/CaseActivity.php +++ b/CRM/Case/DAO/CaseActivity.php @@ -19,14 +19,14 @@ class CRM_Case_DAO_CaseActivity extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_case_activity'; + public static $_tableName = 'civicrm_case_activity'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * Unique case-activity association id @@ -65,7 +65,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'case_id', 'civicrm_case', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'activity_id', 'civicrm_activity', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); diff --git a/CRM/Case/DAO/CaseContact.php b/CRM/Case/DAO/CaseContact.php index f9ed6c241ffa..641b5e5ae506 100644 --- a/CRM/Case/DAO/CaseContact.php +++ b/CRM/Case/DAO/CaseContact.php @@ -19,14 +19,14 @@ class CRM_Case_DAO_CaseContact extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_case_contact'; + public static $_tableName = 'civicrm_case_contact'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * Unique case-contact association id @@ -65,7 +65,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'case_id', 'civicrm_case', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); diff --git a/CRM/Case/DAO/CaseType.php b/CRM/Case/DAO/CaseType.php index d68a89e8310e..f187f9d650a0 100644 --- a/CRM/Case/DAO/CaseType.php +++ b/CRM/Case/DAO/CaseType.php @@ -19,14 +19,14 @@ class CRM_Case_DAO_CaseType extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_case_type'; + public static $_tableName = 'civicrm_case_type'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * Autoincremented type id diff --git a/CRM/Contact/DAO/ACLContactCache.php b/CRM/Contact/DAO/ACLContactCache.php index 1deee6674ac7..b1c08f0f3fd0 100644 --- a/CRM/Contact/DAO/ACLContactCache.php +++ b/CRM/Contact/DAO/ACLContactCache.php @@ -19,14 +19,14 @@ class CRM_Contact_DAO_ACLContactCache extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_acl_contact_cache'; + public static $_tableName = 'civicrm_acl_contact_cache'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * primary key @@ -72,7 +72,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); } diff --git a/CRM/Contact/DAO/Contact.php b/CRM/Contact/DAO/Contact.php index fdf2f7256426..c5833d27b865 100644 --- a/CRM/Contact/DAO/Contact.php +++ b/CRM/Contact/DAO/Contact.php @@ -19,14 +19,14 @@ class CRM_Contact_DAO_Contact extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_contact'; + public static $_tableName = 'civicrm_contact'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * Unique Contact ID @@ -394,7 +394,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'primary_contact_id', 'civicrm_contact', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'employer_id', 'civicrm_contact', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); diff --git a/CRM/Contact/DAO/ContactType.php b/CRM/Contact/DAO/ContactType.php index 0ee5120228e9..db032d503fe6 100644 --- a/CRM/Contact/DAO/ContactType.php +++ b/CRM/Contact/DAO/ContactType.php @@ -19,14 +19,14 @@ class CRM_Contact_DAO_ContactType extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_contact_type'; + public static $_tableName = 'civicrm_contact_type'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * Contact Type ID @@ -100,7 +100,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'parent_id', 'civicrm_contact_type', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); } diff --git a/CRM/Contact/DAO/DashboardContact.php b/CRM/Contact/DAO/DashboardContact.php index 28d22111ecbb..8b354a2bb3d8 100644 --- a/CRM/Contact/DAO/DashboardContact.php +++ b/CRM/Contact/DAO/DashboardContact.php @@ -19,14 +19,14 @@ class CRM_Contact_DAO_DashboardContact extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_dashboard_contact'; + public static $_tableName = 'civicrm_dashboard_contact'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * @var int unsigned @@ -84,7 +84,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'dashboard_id', 'civicrm_dashboard', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); diff --git a/CRM/Contact/DAO/Group.php b/CRM/Contact/DAO/Group.php index 395779023d42..1213b90fc6e9 100644 --- a/CRM/Contact/DAO/Group.php +++ b/CRM/Contact/DAO/Group.php @@ -19,14 +19,14 @@ class CRM_Contact_DAO_Group extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_group'; + public static $_tableName = 'civicrm_group'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * Group ID @@ -182,7 +182,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'saved_search_id', 'civicrm_saved_search', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'created_id', 'civicrm_contact', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'modified_id', 'civicrm_contact', 'id'); diff --git a/CRM/Contact/DAO/GroupContact.php b/CRM/Contact/DAO/GroupContact.php index 7b619666f748..8a259670c63a 100644 --- a/CRM/Contact/DAO/GroupContact.php +++ b/CRM/Contact/DAO/GroupContact.php @@ -19,14 +19,14 @@ class CRM_Contact_DAO_GroupContact extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_group_contact'; + public static $_tableName = 'civicrm_group_contact'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * primary key @@ -86,7 +86,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'group_id', 'civicrm_group', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'location_id', 'civicrm_loc_block', 'id'); diff --git a/CRM/Contact/DAO/GroupContactCache.php b/CRM/Contact/DAO/GroupContactCache.php index a6d183b05286..7e97bd7b867d 100644 --- a/CRM/Contact/DAO/GroupContactCache.php +++ b/CRM/Contact/DAO/GroupContactCache.php @@ -19,14 +19,14 @@ class CRM_Contact_DAO_GroupContactCache extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_group_contact_cache'; + public static $_tableName = 'civicrm_group_contact_cache'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * primary key @@ -65,7 +65,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'group_id', 'civicrm_group', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); diff --git a/CRM/Contact/DAO/GroupNesting.php b/CRM/Contact/DAO/GroupNesting.php index 11ac4f2dcb31..d7a59df69366 100644 --- a/CRM/Contact/DAO/GroupNesting.php +++ b/CRM/Contact/DAO/GroupNesting.php @@ -19,14 +19,14 @@ class CRM_Contact_DAO_GroupNesting extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_group_nesting'; + public static $_tableName = 'civicrm_group_nesting'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * Relationship ID @@ -65,7 +65,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'child_group_id', 'civicrm_group', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'parent_group_id', 'civicrm_group', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); diff --git a/CRM/Contact/DAO/GroupOrganization.php b/CRM/Contact/DAO/GroupOrganization.php index 6238bcc8cd74..fd90ae2bfba3 100644 --- a/CRM/Contact/DAO/GroupOrganization.php +++ b/CRM/Contact/DAO/GroupOrganization.php @@ -19,14 +19,14 @@ class CRM_Contact_DAO_GroupOrganization extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_group_organization'; + public static $_tableName = 'civicrm_group_organization'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * Relationship ID @@ -65,7 +65,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'group_id', 'civicrm_group', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'organization_id', 'civicrm_contact', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); diff --git a/CRM/Contact/DAO/Relationship.php b/CRM/Contact/DAO/Relationship.php index 4c805e863d4a..c40f42183154 100644 --- a/CRM/Contact/DAO/Relationship.php +++ b/CRM/Contact/DAO/Relationship.php @@ -19,14 +19,14 @@ class CRM_Contact_DAO_Relationship extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_relationship'; + public static $_tableName = 'civicrm_relationship'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * Relationship ID @@ -121,7 +121,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id_a', 'civicrm_contact', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id_b', 'civicrm_contact', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'relationship_type_id', 'civicrm_relationship_type', 'id'); diff --git a/CRM/Contact/DAO/RelationshipType.php b/CRM/Contact/DAO/RelationshipType.php index c545a4674a1b..11bb3d1ba0eb 100644 --- a/CRM/Contact/DAO/RelationshipType.php +++ b/CRM/Contact/DAO/RelationshipType.php @@ -19,14 +19,14 @@ class CRM_Contact_DAO_RelationshipType extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_relationship_type'; + public static $_tableName = 'civicrm_relationship_type'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * Primary key diff --git a/CRM/Contact/DAO/SavedSearch.php b/CRM/Contact/DAO/SavedSearch.php index 5324ce2ef738..e1c75e9bac0e 100644 --- a/CRM/Contact/DAO/SavedSearch.php +++ b/CRM/Contact/DAO/SavedSearch.php @@ -19,14 +19,14 @@ class CRM_Contact_DAO_SavedSearch extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_saved_search'; + public static $_tableName = 'civicrm_saved_search'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * Saved Search ID @@ -93,7 +93,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'mapping_id', 'civicrm_mapping', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); } diff --git a/CRM/Contact/DAO/SubscriptionHistory.php b/CRM/Contact/DAO/SubscriptionHistory.php index 0fe5a9e49034..90f7ea3d8f81 100644 --- a/CRM/Contact/DAO/SubscriptionHistory.php +++ b/CRM/Contact/DAO/SubscriptionHistory.php @@ -19,14 +19,14 @@ class CRM_Contact_DAO_SubscriptionHistory extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_subscription_history'; + public static $_tableName = 'civicrm_subscription_history'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * Internal Id @@ -93,7 +93,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'group_id', 'civicrm_group', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); diff --git a/CRM/Contribute/DAO/Contribution.php b/CRM/Contribute/DAO/Contribution.php index c97c3d23d177..a3640ef1a4d9 100644 --- a/CRM/Contribute/DAO/Contribution.php +++ b/CRM/Contribute/DAO/Contribution.php @@ -19,14 +19,14 @@ class CRM_Contribute_DAO_Contribution extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_contribution'; + public static $_tableName = 'civicrm_contribution'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * Contribution ID @@ -242,7 +242,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'financial_type_id', 'civicrm_financial_type', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contribution_page_id', 'civicrm_contribution_page', 'id'); diff --git a/CRM/Contribute/DAO/ContributionPage.php b/CRM/Contribute/DAO/ContributionPage.php index aa9e93532c74..116c52df9da6 100644 --- a/CRM/Contribute/DAO/ContributionPage.php +++ b/CRM/Contribute/DAO/ContributionPage.php @@ -19,14 +19,14 @@ class CRM_Contribute_DAO_ContributionPage extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_contribution_page'; + public static $_tableName = 'civicrm_contribution_page'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * Contribution Id @@ -359,7 +359,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'financial_type_id', 'civicrm_financial_type', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'created_id', 'civicrm_contact', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'campaign_id', 'civicrm_campaign', 'id'); diff --git a/CRM/Contribute/DAO/ContributionProduct.php b/CRM/Contribute/DAO/ContributionProduct.php index a8e344185c10..58dd6257ce82 100644 --- a/CRM/Contribute/DAO/ContributionProduct.php +++ b/CRM/Contribute/DAO/ContributionProduct.php @@ -19,14 +19,14 @@ class CRM_Contribute_DAO_ContributionProduct extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_contribution_product'; + public static $_tableName = 'civicrm_contribution_product'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * @var int unsigned @@ -104,7 +104,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contribution_id', 'civicrm_contribution', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'financial_type_id', 'civicrm_financial_type', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); diff --git a/CRM/Contribute/DAO/ContributionRecur.php b/CRM/Contribute/DAO/ContributionRecur.php index e4642341d8cf..ba78c33c9c6e 100644 --- a/CRM/Contribute/DAO/ContributionRecur.php +++ b/CRM/Contribute/DAO/ContributionRecur.php @@ -19,14 +19,14 @@ class CRM_Contribute_DAO_ContributionRecur extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_contribution_recur'; + public static $_tableName = 'civicrm_contribution_recur'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * Contribution Recur ID @@ -243,7 +243,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'payment_token_id', 'civicrm_payment_token', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'payment_processor_id', 'civicrm_payment_processor', 'id'); diff --git a/CRM/Contribute/DAO/ContributionSoft.php b/CRM/Contribute/DAO/ContributionSoft.php index 0e165a224f27..ae009420f0b6 100644 --- a/CRM/Contribute/DAO/ContributionSoft.php +++ b/CRM/Contribute/DAO/ContributionSoft.php @@ -19,14 +19,14 @@ class CRM_Contribute_DAO_ContributionSoft extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_contribution_soft'; + public static $_tableName = 'civicrm_contribution_soft'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * Soft Contribution ID @@ -108,7 +108,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contribution_id', 'civicrm_contribution', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'pcp_id', 'civicrm_pcp', 'id'); diff --git a/CRM/Contribute/DAO/Premium.php b/CRM/Contribute/DAO/Premium.php index e5f5e213bf10..643bf1dbafdb 100644 --- a/CRM/Contribute/DAO/Premium.php +++ b/CRM/Contribute/DAO/Premium.php @@ -19,14 +19,14 @@ class CRM_Contribute_DAO_Premium extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_premiums'; + public static $_tableName = 'civicrm_premiums'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * @var int unsigned @@ -115,7 +115,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName(), 'entity_id', NULL, 'id', 'entity_table'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); } diff --git a/CRM/Contribute/DAO/PremiumsProduct.php b/CRM/Contribute/DAO/PremiumsProduct.php index ac79dab653d6..7f319b0669d1 100644 --- a/CRM/Contribute/DAO/PremiumsProduct.php +++ b/CRM/Contribute/DAO/PremiumsProduct.php @@ -19,14 +19,14 @@ class CRM_Contribute_DAO_PremiumsProduct extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_premiums_product'; + public static $_tableName = 'civicrm_premiums_product'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * Contribution ID @@ -77,7 +77,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'premiums_id', 'civicrm_premiums', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'product_id', 'civicrm_product', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'financial_type_id', 'civicrm_financial_type', 'id'); diff --git a/CRM/Contribute/DAO/Product.php b/CRM/Contribute/DAO/Product.php index aeeba277a48f..d4e1e75ef531 100644 --- a/CRM/Contribute/DAO/Product.php +++ b/CRM/Contribute/DAO/Product.php @@ -19,14 +19,14 @@ class CRM_Contribute_DAO_Product extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_product'; + public static $_tableName = 'civicrm_product'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * @var int unsigned @@ -174,7 +174,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'financial_type_id', 'civicrm_financial_type', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); } diff --git a/CRM/Contribute/DAO/Widget.php b/CRM/Contribute/DAO/Widget.php index 1dc507e5aa09..fb7eb5e58eda 100644 --- a/CRM/Contribute/DAO/Widget.php +++ b/CRM/Contribute/DAO/Widget.php @@ -19,14 +19,14 @@ class CRM_Contribute_DAO_Widget extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_contribution_widget'; + public static $_tableName = 'civicrm_contribution_widget'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * Contribution Id @@ -145,7 +145,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contribution_page_id', 'civicrm_contribution_page', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); } diff --git a/CRM/Core/DAO/ActionLog.php b/CRM/Core/DAO/ActionLog.php index 2ee540bf3c6a..cdccd9babb9e 100644 --- a/CRM/Core/DAO/ActionLog.php +++ b/CRM/Core/DAO/ActionLog.php @@ -19,14 +19,14 @@ class CRM_Core_DAO_ActionLog extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_action_log'; + public static $_tableName = 'civicrm_action_log'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * @var int unsigned @@ -112,7 +112,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'action_schedule_id', 'civicrm_action_schedule', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName(), 'entity_id', NULL, 'id', 'entity_table'); diff --git a/CRM/Core/DAO/ActionMapping.php b/CRM/Core/DAO/ActionMapping.php index 7170a4bd07d3..cafb30f2aa90 100644 --- a/CRM/Core/DAO/ActionMapping.php +++ b/CRM/Core/DAO/ActionMapping.php @@ -19,14 +19,14 @@ class CRM_Core_DAO_ActionMapping extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_action_mapping'; + public static $_tableName = 'civicrm_action_mapping'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * @var int unsigned diff --git a/CRM/Core/DAO/ActionSchedule.php b/CRM/Core/DAO/ActionSchedule.php index 8101c1d02305..7e5afe04e930 100644 --- a/CRM/Core/DAO/ActionSchedule.php +++ b/CRM/Core/DAO/ActionSchedule.php @@ -19,14 +19,14 @@ class CRM_Core_DAO_ActionSchedule extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_action_schedule'; + public static $_tableName = 'civicrm_action_schedule'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * @var int unsigned @@ -304,7 +304,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'group_id', 'civicrm_group', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'msg_template_id', 'civicrm_msg_template', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'sms_template_id', 'civicrm_msg_template', 'id'); diff --git a/CRM/Core/DAO/Address.php b/CRM/Core/DAO/Address.php index d435e848232a..05402a732e31 100644 --- a/CRM/Core/DAO/Address.php +++ b/CRM/Core/DAO/Address.php @@ -19,14 +19,14 @@ class CRM_Core_DAO_Address extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_address'; + public static $_tableName = 'civicrm_address'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * Unique Address ID @@ -247,7 +247,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'county_id', 'civicrm_county', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'state_province_id', 'civicrm_state_province', 'id'); diff --git a/CRM/Core/DAO/AddressFormat.php b/CRM/Core/DAO/AddressFormat.php index e1cb8f7061f6..d9286653a493 100644 --- a/CRM/Core/DAO/AddressFormat.php +++ b/CRM/Core/DAO/AddressFormat.php @@ -19,14 +19,14 @@ class CRM_Core_DAO_AddressFormat extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_address_format'; + public static $_tableName = 'civicrm_address_format'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * Address Format Id diff --git a/CRM/Core/DAO/Cache.php b/CRM/Core/DAO/Cache.php index 9ab23364a11f..d378cc8dd93f 100644 --- a/CRM/Core/DAO/Cache.php +++ b/CRM/Core/DAO/Cache.php @@ -19,14 +19,14 @@ class CRM_Core_DAO_Cache extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_cache'; + public static $_tableName = 'civicrm_cache'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * @var int unsigned @@ -91,7 +91,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'component_id', 'civicrm_component', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); } diff --git a/CRM/Core/DAO/Component.php b/CRM/Core/DAO/Component.php index 61d59a73d0fc..6303b7b1002a 100644 --- a/CRM/Core/DAO/Component.php +++ b/CRM/Core/DAO/Component.php @@ -19,14 +19,14 @@ class CRM_Core_DAO_Component extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_component'; + public static $_tableName = 'civicrm_component'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * Component ID diff --git a/CRM/Core/DAO/Country.php b/CRM/Core/DAO/Country.php index 56e719371fdd..376f3738f82c 100644 --- a/CRM/Core/DAO/Country.php +++ b/CRM/Core/DAO/Country.php @@ -19,14 +19,14 @@ class CRM_Core_DAO_Country extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_country'; + public static $_tableName = 'civicrm_country'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * Country Id @@ -107,7 +107,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'address_format_id', 'civicrm_address_format', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'region_id', 'civicrm_worldregion', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); diff --git a/CRM/Core/DAO/County.php b/CRM/Core/DAO/County.php index f9e75d702a2c..6858becf82db 100644 --- a/CRM/Core/DAO/County.php +++ b/CRM/Core/DAO/County.php @@ -19,14 +19,14 @@ class CRM_Core_DAO_County extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_county'; + public static $_tableName = 'civicrm_county'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * County ID @@ -72,7 +72,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'state_province_id', 'civicrm_state_province', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); } diff --git a/CRM/Core/DAO/CustomField.php b/CRM/Core/DAO/CustomField.php index 5b837c8121c3..8d06e9a74c91 100644 --- a/CRM/Core/DAO/CustomField.php +++ b/CRM/Core/DAO/CustomField.php @@ -19,14 +19,14 @@ class CRM_Core_DAO_CustomField extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_custom_field'; + public static $_tableName = 'civicrm_custom_field'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * Unique Custom Field ID @@ -254,7 +254,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'custom_group_id', 'civicrm_custom_group', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'option_group_id', 'civicrm_option_group', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); diff --git a/CRM/Core/DAO/CustomGroup.php b/CRM/Core/DAO/CustomGroup.php index ad282441f976..dbb98871caa6 100644 --- a/CRM/Core/DAO/CustomGroup.php +++ b/CRM/Core/DAO/CustomGroup.php @@ -19,14 +19,14 @@ class CRM_Core_DAO_CustomGroup extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_custom_group'; + public static $_tableName = 'civicrm_custom_group'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * Unique Custom Group ID @@ -191,7 +191,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'created_id', 'civicrm_contact', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); } diff --git a/CRM/Core/DAO/Dashboard.php b/CRM/Core/DAO/Dashboard.php index ea20cb1b5220..b9fe1d241c77 100644 --- a/CRM/Core/DAO/Dashboard.php +++ b/CRM/Core/DAO/Dashboard.php @@ -19,14 +19,14 @@ class CRM_Core_DAO_Dashboard extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_dashboard'; + public static $_tableName = 'civicrm_dashboard'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * @var int unsigned @@ -119,7 +119,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'domain_id', 'civicrm_domain', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); } diff --git a/CRM/Core/DAO/Discount.php b/CRM/Core/DAO/Discount.php index 7c396bc05698..eff4329fbbbd 100644 --- a/CRM/Core/DAO/Discount.php +++ b/CRM/Core/DAO/Discount.php @@ -19,14 +19,14 @@ class CRM_Core_DAO_Discount extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_discount'; + public static $_tableName = 'civicrm_discount'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * primary key @@ -86,7 +86,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'price_set_id', 'civicrm_price_set', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName(), 'entity_id', NULL, 'id', 'entity_table'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); diff --git a/CRM/Core/DAO/Domain.php b/CRM/Core/DAO/Domain.php index 89fe6d18c55d..b3abdbb2d505 100644 --- a/CRM/Core/DAO/Domain.php +++ b/CRM/Core/DAO/Domain.php @@ -19,14 +19,14 @@ class CRM_Core_DAO_Domain extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_domain'; + public static $_tableName = 'civicrm_domain'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * Domain ID @@ -100,7 +100,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); } diff --git a/CRM/Core/DAO/Email.php b/CRM/Core/DAO/Email.php index 5f472e124d7f..cd169bef4ac7 100644 --- a/CRM/Core/DAO/Email.php +++ b/CRM/Core/DAO/Email.php @@ -19,14 +19,14 @@ class CRM_Core_DAO_Email extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_email'; + public static $_tableName = 'civicrm_email'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * Unique Email ID @@ -128,7 +128,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); } diff --git a/CRM/Core/DAO/EntityFile.php b/CRM/Core/DAO/EntityFile.php index 6003d7bfa848..388f6b02dc96 100644 --- a/CRM/Core/DAO/EntityFile.php +++ b/CRM/Core/DAO/EntityFile.php @@ -19,14 +19,14 @@ class CRM_Core_DAO_EntityFile extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_entity_file'; + public static $_tableName = 'civicrm_entity_file'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * primary key @@ -72,7 +72,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'file_id', 'civicrm_file', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName(), 'entity_id', NULL, 'id', 'entity_table'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); diff --git a/CRM/Core/DAO/EntityTag.php b/CRM/Core/DAO/EntityTag.php index 63ed15c7c8f2..47bd481d6a04 100644 --- a/CRM/Core/DAO/EntityTag.php +++ b/CRM/Core/DAO/EntityTag.php @@ -19,14 +19,14 @@ class CRM_Core_DAO_EntityTag extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_entity_tag'; + public static $_tableName = 'civicrm_entity_tag'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * primary key @@ -72,7 +72,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'tag_id', 'civicrm_tag', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName(), 'entity_id', NULL, 'id', 'entity_table'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); diff --git a/CRM/Core/DAO/Extension.php b/CRM/Core/DAO/Extension.php index 722548b0f29a..be80ddb69711 100644 --- a/CRM/Core/DAO/Extension.php +++ b/CRM/Core/DAO/Extension.php @@ -19,14 +19,14 @@ class CRM_Core_DAO_Extension extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_extension'; + public static $_tableName = 'civicrm_extension'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * Local Extension ID diff --git a/CRM/Core/DAO/File.php b/CRM/Core/DAO/File.php index a2230c7d6ba9..41911d9b89ed 100644 --- a/CRM/Core/DAO/File.php +++ b/CRM/Core/DAO/File.php @@ -19,14 +19,14 @@ class CRM_Core_DAO_File extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_file'; + public static $_tableName = 'civicrm_file'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * Unique ID @@ -100,7 +100,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'created_id', 'civicrm_contact', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); } diff --git a/CRM/Core/DAO/IM.php b/CRM/Core/DAO/IM.php index c1183ba4c0b6..eed59c390865 100644 --- a/CRM/Core/DAO/IM.php +++ b/CRM/Core/DAO/IM.php @@ -19,14 +19,14 @@ class CRM_Core_DAO_IM extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_im'; + public static $_tableName = 'civicrm_im'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * Unique IM ID @@ -93,7 +93,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); } diff --git a/CRM/Core/DAO/Job.php b/CRM/Core/DAO/Job.php index 1ffdaf29f653..7c6ff616efe1 100644 --- a/CRM/Core/DAO/Job.php +++ b/CRM/Core/DAO/Job.php @@ -19,14 +19,14 @@ class CRM_Core_DAO_Job extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_job'; + public static $_tableName = 'civicrm_job'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * Job Id @@ -121,7 +121,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'domain_id', 'civicrm_domain', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); } diff --git a/CRM/Core/DAO/JobLog.php b/CRM/Core/DAO/JobLog.php index a7316388941d..aaa71773e7ea 100644 --- a/CRM/Core/DAO/JobLog.php +++ b/CRM/Core/DAO/JobLog.php @@ -19,14 +19,14 @@ class CRM_Core_DAO_JobLog extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_job_log'; + public static $_tableName = 'civicrm_job_log'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * Job log entry Id @@ -100,7 +100,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'domain_id', 'civicrm_domain', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); } diff --git a/CRM/Core/DAO/LocBlock.php b/CRM/Core/DAO/LocBlock.php index 6209648646eb..8862e752b54a 100644 --- a/CRM/Core/DAO/LocBlock.php +++ b/CRM/Core/DAO/LocBlock.php @@ -19,14 +19,14 @@ class CRM_Core_DAO_LocBlock extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_loc_block'; + public static $_tableName = 'civicrm_loc_block'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * Unique ID @@ -91,7 +91,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'address_id', 'civicrm_address', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'email_id', 'civicrm_email', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'phone_id', 'civicrm_phone', 'id'); diff --git a/CRM/Core/DAO/LocationType.php b/CRM/Core/DAO/LocationType.php index ea8fdadaff2f..ebbe98c330f2 100644 --- a/CRM/Core/DAO/LocationType.php +++ b/CRM/Core/DAO/LocationType.php @@ -19,14 +19,14 @@ class CRM_Core_DAO_LocationType extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_location_type'; + public static $_tableName = 'civicrm_location_type'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * Location Type ID diff --git a/CRM/Core/DAO/Log.php b/CRM/Core/DAO/Log.php index f6f132b2f899..61b9ab668c58 100644 --- a/CRM/Core/DAO/Log.php +++ b/CRM/Core/DAO/Log.php @@ -19,14 +19,14 @@ class CRM_Core_DAO_Log extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_log'; + public static $_tableName = 'civicrm_log'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * Log ID @@ -86,7 +86,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'modified_id', 'civicrm_contact', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName(), 'entity_id', NULL, 'id', 'entity_table'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); diff --git a/CRM/Core/DAO/MailSettings.php b/CRM/Core/DAO/MailSettings.php index 3c28b4d19ca9..5ffd0c27fefa 100644 --- a/CRM/Core/DAO/MailSettings.php +++ b/CRM/Core/DAO/MailSettings.php @@ -19,14 +19,14 @@ class CRM_Core_DAO_MailSettings extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_mail_settings'; + public static $_tableName = 'civicrm_mail_settings'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * primary key @@ -149,7 +149,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'domain_id', 'civicrm_domain', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); } diff --git a/CRM/Core/DAO/Managed.php b/CRM/Core/DAO/Managed.php index 7726ec418e38..4ba363ef562b 100644 --- a/CRM/Core/DAO/Managed.php +++ b/CRM/Core/DAO/Managed.php @@ -19,14 +19,14 @@ class CRM_Core_DAO_Managed extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_managed'; + public static $_tableName = 'civicrm_managed'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * Surrogate Key diff --git a/CRM/Core/DAO/Mapping.php b/CRM/Core/DAO/Mapping.php index f9d9b4448aaf..e2e3a90a0cd3 100644 --- a/CRM/Core/DAO/Mapping.php +++ b/CRM/Core/DAO/Mapping.php @@ -19,14 +19,14 @@ class CRM_Core_DAO_Mapping extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_mapping'; + public static $_tableName = 'civicrm_mapping'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * Mapping ID diff --git a/CRM/Core/DAO/MappingField.php b/CRM/Core/DAO/MappingField.php index 370021559d55..c7b228c75a1e 100644 --- a/CRM/Core/DAO/MappingField.php +++ b/CRM/Core/DAO/MappingField.php @@ -19,14 +19,14 @@ class CRM_Core_DAO_MappingField extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_mapping_field'; + public static $_tableName = 'civicrm_mapping_field'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * Mapping Field ID @@ -141,7 +141,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'mapping_id', 'civicrm_mapping', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'location_type_id', 'civicrm_location_type', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'relationship_type_id', 'civicrm_relationship_type', 'id'); diff --git a/CRM/Core/DAO/Menu.php b/CRM/Core/DAO/Menu.php index 8963ed75969e..10b3f14316cb 100644 --- a/CRM/Core/DAO/Menu.php +++ b/CRM/Core/DAO/Menu.php @@ -19,14 +19,14 @@ class CRM_Core_DAO_Menu extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_menu'; + public static $_tableName = 'civicrm_menu'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * @var int unsigned @@ -194,7 +194,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'domain_id', 'civicrm_domain', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'component_id', 'civicrm_component', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); diff --git a/CRM/Core/DAO/MessageTemplate.php b/CRM/Core/DAO/MessageTemplate.php index 53fa3bdad487..3fee5bb1f1f2 100644 --- a/CRM/Core/DAO/MessageTemplate.php +++ b/CRM/Core/DAO/MessageTemplate.php @@ -19,14 +19,14 @@ class CRM_Core_DAO_MessageTemplate extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_msg_template'; + public static $_tableName = 'civicrm_msg_template'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * Message Template ID diff --git a/CRM/Core/DAO/Navigation.php b/CRM/Core/DAO/Navigation.php index 9b11520e2028..60f0c807ddb0 100644 --- a/CRM/Core/DAO/Navigation.php +++ b/CRM/Core/DAO/Navigation.php @@ -19,14 +19,14 @@ class CRM_Core_DAO_Navigation extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_navigation'; + public static $_tableName = 'civicrm_navigation'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * @var int unsigned @@ -126,7 +126,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'domain_id', 'civicrm_domain', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'parent_id', 'civicrm_navigation', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); diff --git a/CRM/Core/DAO/Note.php b/CRM/Core/DAO/Note.php index 8287d98ba066..95b17c3bf8f0 100644 --- a/CRM/Core/DAO/Note.php +++ b/CRM/Core/DAO/Note.php @@ -19,14 +19,14 @@ class CRM_Core_DAO_Note extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_note'; + public static $_tableName = 'civicrm_note'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * Note ID @@ -100,7 +100,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName(), 'entity_id', NULL, 'id', 'entity_table'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); diff --git a/CRM/Core/DAO/OpenID.php b/CRM/Core/DAO/OpenID.php index e891899d581e..f70c0eca3df3 100644 --- a/CRM/Core/DAO/OpenID.php +++ b/CRM/Core/DAO/OpenID.php @@ -19,14 +19,14 @@ class CRM_Core_DAO_OpenID extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_openid'; + public static $_tableName = 'civicrm_openid'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * Unique OpenID ID @@ -86,7 +86,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); } diff --git a/CRM/Core/DAO/OptionGroup.php b/CRM/Core/DAO/OptionGroup.php index d127044f620f..c65b63b9aade 100644 --- a/CRM/Core/DAO/OptionGroup.php +++ b/CRM/Core/DAO/OptionGroup.php @@ -19,14 +19,14 @@ class CRM_Core_DAO_OptionGroup extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_option_group'; + public static $_tableName = 'civicrm_option_group'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * Option Group ID diff --git a/CRM/Core/DAO/OptionValue.php b/CRM/Core/DAO/OptionValue.php index 51972ced2090..e896d993552e 100644 --- a/CRM/Core/DAO/OptionValue.php +++ b/CRM/Core/DAO/OptionValue.php @@ -19,14 +19,14 @@ class CRM_Core_DAO_OptionValue extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_option_value'; + public static $_tableName = 'civicrm_option_value'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * Option ID @@ -168,7 +168,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'option_group_id', 'civicrm_option_group', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'component_id', 'civicrm_component', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'domain_id', 'civicrm_domain', 'id'); diff --git a/CRM/Core/DAO/Persistent.php b/CRM/Core/DAO/Persistent.php index 1ec90bd7fc32..c83bdf6505a9 100644 --- a/CRM/Core/DAO/Persistent.php +++ b/CRM/Core/DAO/Persistent.php @@ -19,14 +19,14 @@ class CRM_Core_DAO_Persistent extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_persistent'; + public static $_tableName = 'civicrm_persistent'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * Persistent Record Id diff --git a/CRM/Core/DAO/Phone.php b/CRM/Core/DAO/Phone.php index a3307d4275ed..002ea1b93c65 100644 --- a/CRM/Core/DAO/Phone.php +++ b/CRM/Core/DAO/Phone.php @@ -19,14 +19,14 @@ class CRM_Core_DAO_Phone extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_phone'; + public static $_tableName = 'civicrm_phone'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * Unique Phone ID @@ -114,7 +114,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); } diff --git a/CRM/Core/DAO/PreferencesDate.php b/CRM/Core/DAO/PreferencesDate.php index 4b0e745aa64e..02d3dd355402 100644 --- a/CRM/Core/DAO/PreferencesDate.php +++ b/CRM/Core/DAO/PreferencesDate.php @@ -19,14 +19,14 @@ class CRM_Core_DAO_PreferencesDate extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_preferences_date'; + public static $_tableName = 'civicrm_preferences_date'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * @var int unsigned diff --git a/CRM/Core/DAO/PrevNextCache.php b/CRM/Core/DAO/PrevNextCache.php index 59bedfc09ca9..3d878125a88f 100644 --- a/CRM/Core/DAO/PrevNextCache.php +++ b/CRM/Core/DAO/PrevNextCache.php @@ -19,14 +19,14 @@ class CRM_Core_DAO_PrevNextCache extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_prevnext_cache'; + public static $_tableName = 'civicrm_prevnext_cache'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * @var int unsigned diff --git a/CRM/Core/DAO/PrintLabel.php b/CRM/Core/DAO/PrintLabel.php index 43587a346a3c..5d9e84f6c996 100644 --- a/CRM/Core/DAO/PrintLabel.php +++ b/CRM/Core/DAO/PrintLabel.php @@ -19,14 +19,14 @@ class CRM_Core_DAO_PrintLabel extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_print_label'; + public static $_tableName = 'civicrm_print_label'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * @var int unsigned @@ -119,7 +119,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'created_id', 'civicrm_contact', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); } diff --git a/CRM/Core/DAO/RecurringEntity.php b/CRM/Core/DAO/RecurringEntity.php index 20e4ce6bffa7..0c08cbe3659a 100644 --- a/CRM/Core/DAO/RecurringEntity.php +++ b/CRM/Core/DAO/RecurringEntity.php @@ -19,14 +19,14 @@ class CRM_Core_DAO_RecurringEntity extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_recurring_entity'; + public static $_tableName = 'civicrm_recurring_entity'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * @var int unsigned diff --git a/CRM/Core/DAO/Setting.php b/CRM/Core/DAO/Setting.php index c61455962c31..7ce962cc08d2 100644 --- a/CRM/Core/DAO/Setting.php +++ b/CRM/Core/DAO/Setting.php @@ -19,14 +19,14 @@ class CRM_Core_DAO_Setting extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_setting'; + public static $_tableName = 'civicrm_setting'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * @var int unsigned @@ -105,7 +105,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'domain_id', 'civicrm_domain', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'component_id', 'civicrm_component', 'id'); diff --git a/CRM/Core/DAO/StateProvince.php b/CRM/Core/DAO/StateProvince.php index 793519c10269..345f8eb4c0ca 100644 --- a/CRM/Core/DAO/StateProvince.php +++ b/CRM/Core/DAO/StateProvince.php @@ -19,14 +19,14 @@ class CRM_Core_DAO_StateProvince extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_state_province'; + public static $_tableName = 'civicrm_state_province'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * State/Province ID @@ -72,7 +72,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'country_id', 'civicrm_country', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); } diff --git a/CRM/Core/DAO/StatusPreference.php b/CRM/Core/DAO/StatusPreference.php index 9219d3db94fc..69bdf13503ba 100644 --- a/CRM/Core/DAO/StatusPreference.php +++ b/CRM/Core/DAO/StatusPreference.php @@ -19,14 +19,14 @@ class CRM_Core_DAO_StatusPreference extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_status_pref'; + public static $_tableName = 'civicrm_status_pref'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * Unique Status Preference ID @@ -93,7 +93,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'domain_id', 'civicrm_domain', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); } diff --git a/CRM/Core/DAO/SystemLog.php b/CRM/Core/DAO/SystemLog.php index dddf24d1d8be..2090dd18dda7 100644 --- a/CRM/Core/DAO/SystemLog.php +++ b/CRM/Core/DAO/SystemLog.php @@ -19,14 +19,14 @@ class CRM_Core_DAO_SystemLog extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_system_log'; + public static $_tableName = 'civicrm_system_log'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * Primary key ID diff --git a/CRM/Core/DAO/Tag.php b/CRM/Core/DAO/Tag.php index b296d405ed86..bb716b17461d 100644 --- a/CRM/Core/DAO/Tag.php +++ b/CRM/Core/DAO/Tag.php @@ -19,14 +19,14 @@ class CRM_Core_DAO_Tag extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_tag'; + public static $_tableName = 'civicrm_tag'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * Tag ID @@ -115,7 +115,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'parent_id', 'civicrm_tag', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'created_id', 'civicrm_contact', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); diff --git a/CRM/Core/DAO/Timezone.php b/CRM/Core/DAO/Timezone.php index ef0ee771e6ff..3b75fab08927 100644 --- a/CRM/Core/DAO/Timezone.php +++ b/CRM/Core/DAO/Timezone.php @@ -19,14 +19,14 @@ class CRM_Core_DAO_Timezone extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_timezone'; + public static $_tableName = 'civicrm_timezone'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * Timezone Id @@ -84,7 +84,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'country_id', 'civicrm_country', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); } diff --git a/CRM/Core/DAO/UFField.php b/CRM/Core/DAO/UFField.php index 8093a57b470b..9befc7fab51b 100644 --- a/CRM/Core/DAO/UFField.php +++ b/CRM/Core/DAO/UFField.php @@ -19,14 +19,14 @@ class CRM_Core_DAO_UFField extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_uf_field'; + public static $_tableName = 'civicrm_uf_field'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * Unique table ID @@ -177,7 +177,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'uf_group_id', 'civicrm_uf_group', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'location_type_id', 'civicrm_location_type', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); diff --git a/CRM/Core/DAO/UFGroup.php b/CRM/Core/DAO/UFGroup.php index 27bfa1f2a3fb..c3d7c543358b 100644 --- a/CRM/Core/DAO/UFGroup.php +++ b/CRM/Core/DAO/UFGroup.php @@ -19,14 +19,14 @@ class CRM_Core_DAO_UFGroup extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_uf_group'; + public static $_tableName = 'civicrm_uf_group'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * Unique table ID @@ -231,7 +231,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'limit_listings_group_id', 'civicrm_group', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'add_to_group_id', 'civicrm_group', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'created_id', 'civicrm_contact', 'id'); diff --git a/CRM/Core/DAO/UFJoin.php b/CRM/Core/DAO/UFJoin.php index 909508c766d5..eaa94f4a9a07 100644 --- a/CRM/Core/DAO/UFJoin.php +++ b/CRM/Core/DAO/UFJoin.php @@ -19,14 +19,14 @@ class CRM_Core_DAO_UFJoin extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_uf_join'; + public static $_tableName = 'civicrm_uf_join'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * Unique table ID @@ -100,7 +100,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'uf_group_id', 'civicrm_uf_group', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName(), 'entity_id', NULL, 'id', 'entity_table'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); diff --git a/CRM/Core/DAO/UFMatch.php b/CRM/Core/DAO/UFMatch.php index 76f9c7ee7eed..6b54207610e9 100644 --- a/CRM/Core/DAO/UFMatch.php +++ b/CRM/Core/DAO/UFMatch.php @@ -19,14 +19,14 @@ class CRM_Core_DAO_UFMatch extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_uf_match'; + public static $_tableName = 'civicrm_uf_match'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * System generated ID. @@ -86,7 +86,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'domain_id', 'civicrm_domain', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); diff --git a/CRM/Core/DAO/Website.php b/CRM/Core/DAO/Website.php index beb502964f91..350f6d26ed84 100644 --- a/CRM/Core/DAO/Website.php +++ b/CRM/Core/DAO/Website.php @@ -19,14 +19,14 @@ class CRM_Core_DAO_Website extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_website'; + public static $_tableName = 'civicrm_website'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * Unique Website ID @@ -72,7 +72,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); } diff --git a/CRM/Core/DAO/WordReplacement.php b/CRM/Core/DAO/WordReplacement.php index e07d75920cc4..3084dae9bf42 100644 --- a/CRM/Core/DAO/WordReplacement.php +++ b/CRM/Core/DAO/WordReplacement.php @@ -19,14 +19,14 @@ class CRM_Core_DAO_WordReplacement extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_word_replacement'; + public static $_tableName = 'civicrm_word_replacement'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * Word replacement ID @@ -84,7 +84,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'domain_id', 'civicrm_domain', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); } diff --git a/CRM/Core/DAO/Worldregion.php b/CRM/Core/DAO/Worldregion.php index b09eeff53c5d..8e297e7e2a22 100644 --- a/CRM/Core/DAO/Worldregion.php +++ b/CRM/Core/DAO/Worldregion.php @@ -19,14 +19,14 @@ class CRM_Core_DAO_Worldregion extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_worldregion'; + public static $_tableName = 'civicrm_worldregion'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * Country Id diff --git a/CRM/Core/I18n/SchemaStructure.php b/CRM/Core/I18n/SchemaStructure.php index 1abf4abb7d9b..bec6ec355eb7 100644 --- a/CRM/Core/I18n/SchemaStructure.php +++ b/CRM/Core/I18n/SchemaStructure.php @@ -23,7 +23,7 @@ | GNU Affero General Public License or the licensing of CiviCRM, | | see the CiviCRM license FAQ at http://civicrm.org/licensing | +--------------------------------------------------------------------+ - */ +*/ /** * @@ -42,7 +42,7 @@ class CRM_Core_I18n_SchemaStructure { * A table-indexed array of translatable columns. */ public static function &columns() { - static $result = NULL; + static $result = null; if (!$result) { $result = [ 'civicrm_location_type' => [ @@ -211,7 +211,7 @@ public static function &columns() { * Indices for translatable fields. */ public static function &indices() { - static $result = NULL; + static $result = null; if (!$result) { $result = [ 'civicrm_custom_group' => [ @@ -255,7 +255,7 @@ public static function &indices() { * Array of names of tables with fields that can be translated. */ static function &tables() { - static $result = NULL; + static $result = null; if (!$result) { $result = array_keys(self::columns()); } @@ -269,7 +269,7 @@ static function &tables() { * Array of the widgets for editing translatable fields. */ static function &widgets() { - static $result = NULL; + static $result = null; if (!$result) { $result = [ 'civicrm_location_type' => [ diff --git a/CRM/Cxn/DAO/Cxn.php b/CRM/Cxn/DAO/Cxn.php index f4a87e67d423..96b240eead22 100644 --- a/CRM/Cxn/DAO/Cxn.php +++ b/CRM/Cxn/DAO/Cxn.php @@ -19,14 +19,14 @@ class CRM_Cxn_DAO_Cxn extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_cxn'; + public static $_tableName = 'civicrm_cxn'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * Connection ID diff --git a/CRM/Dedupe/DAO/Exception.php b/CRM/Dedupe/DAO/Exception.php index 3e824fa3e6a9..3692a9d0acae 100644 --- a/CRM/Dedupe/DAO/Exception.php +++ b/CRM/Dedupe/DAO/Exception.php @@ -19,14 +19,14 @@ class CRM_Dedupe_DAO_Exception extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_dedupe_exception'; + public static $_tableName = 'civicrm_dedupe_exception'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * Unique dedupe exception id @@ -65,7 +65,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id1', 'civicrm_contact', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id2', 'civicrm_contact', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); diff --git a/CRM/Dedupe/DAO/Rule.php b/CRM/Dedupe/DAO/Rule.php index ce99b810fcd8..b9e916d952ac 100644 --- a/CRM/Dedupe/DAO/Rule.php +++ b/CRM/Dedupe/DAO/Rule.php @@ -19,14 +19,14 @@ class CRM_Dedupe_DAO_Rule extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_dedupe_rule'; + public static $_tableName = 'civicrm_dedupe_rule'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * Unique dedupe rule id @@ -86,7 +86,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'dedupe_rule_group_id', 'civicrm_dedupe_rule_group', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); } diff --git a/CRM/Dedupe/DAO/RuleGroup.php b/CRM/Dedupe/DAO/RuleGroup.php index 420d82b3691b..d4b0fe9ba505 100644 --- a/CRM/Dedupe/DAO/RuleGroup.php +++ b/CRM/Dedupe/DAO/RuleGroup.php @@ -19,14 +19,14 @@ class CRM_Dedupe_DAO_RuleGroup extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_dedupe_rule_group'; + public static $_tableName = 'civicrm_dedupe_rule_group'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * Unique dedupe rule group id diff --git a/CRM/Event/Cart/DAO/Cart.php b/CRM/Event/Cart/DAO/Cart.php index bcb5af7bdfc3..e953400f05e8 100644 --- a/CRM/Event/Cart/DAO/Cart.php +++ b/CRM/Event/Cart/DAO/Cart.php @@ -19,14 +19,14 @@ class CRM_Event_Cart_DAO_Cart extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_event_carts'; + public static $_tableName = 'civicrm_event_carts'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * Cart Id diff --git a/CRM/Event/Cart/DAO/EventInCart.php b/CRM/Event/Cart/DAO/EventInCart.php index f83c4681b7ef..f0c31b4d3189 100644 --- a/CRM/Event/Cart/DAO/EventInCart.php +++ b/CRM/Event/Cart/DAO/EventInCart.php @@ -19,14 +19,14 @@ class CRM_Event_Cart_DAO_EventInCart extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_events_in_carts'; + public static $_tableName = 'civicrm_events_in_carts'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * Event In Cart Id diff --git a/CRM/Event/DAO/Event.php b/CRM/Event/DAO/Event.php index de49e964e232..3febfd099d38 100644 --- a/CRM/Event/DAO/Event.php +++ b/CRM/Event/DAO/Event.php @@ -19,14 +19,14 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_event'; + public static $_tableName = 'civicrm_event'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * Event @@ -525,7 +525,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'loc_block_id', 'civicrm_loc_block', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'created_id', 'civicrm_contact', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'campaign_id', 'civicrm_campaign', 'id'); diff --git a/CRM/Event/DAO/Participant.php b/CRM/Event/DAO/Participant.php index f688facea2cb..93be1828dbd8 100644 --- a/CRM/Event/DAO/Participant.php +++ b/CRM/Event/DAO/Participant.php @@ -19,14 +19,14 @@ class CRM_Event_DAO_Participant extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_participant'; + public static $_tableName = 'civicrm_participant'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * Participant Id @@ -174,7 +174,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'event_id', 'civicrm_event', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'status_id', 'civicrm_participant_status_type', 'id'); diff --git a/CRM/Event/DAO/ParticipantPayment.php b/CRM/Event/DAO/ParticipantPayment.php index 1e9402aa5412..91838cbf532e 100644 --- a/CRM/Event/DAO/ParticipantPayment.php +++ b/CRM/Event/DAO/ParticipantPayment.php @@ -19,14 +19,14 @@ class CRM_Event_DAO_ParticipantPayment extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_participant_payment'; + public static $_tableName = 'civicrm_participant_payment'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * Participant Payment Id @@ -65,7 +65,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'participant_id', 'civicrm_participant', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contribution_id', 'civicrm_contribution', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); diff --git a/CRM/Event/DAO/ParticipantStatusType.php b/CRM/Event/DAO/ParticipantStatusType.php index fac10276a38a..00c8d1def9bd 100644 --- a/CRM/Event/DAO/ParticipantStatusType.php +++ b/CRM/Event/DAO/ParticipantStatusType.php @@ -19,14 +19,14 @@ class CRM_Event_DAO_ParticipantStatusType extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_participant_status_type'; + public static $_tableName = 'civicrm_participant_status_type'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * unique participant status type id diff --git a/CRM/Financial/DAO/Currency.php b/CRM/Financial/DAO/Currency.php index 84de4610e474..672e3ed366e5 100644 --- a/CRM/Financial/DAO/Currency.php +++ b/CRM/Financial/DAO/Currency.php @@ -19,14 +19,14 @@ class CRM_Financial_DAO_Currency extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_currency'; + public static $_tableName = 'civicrm_currency'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * Currency Id diff --git a/CRM/Financial/DAO/EntityFinancialAccount.php b/CRM/Financial/DAO/EntityFinancialAccount.php index 96e385eeab58..687db0a729a6 100644 --- a/CRM/Financial/DAO/EntityFinancialAccount.php +++ b/CRM/Financial/DAO/EntityFinancialAccount.php @@ -19,14 +19,14 @@ class CRM_Financial_DAO_EntityFinancialAccount extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_entity_financial_account'; + public static $_tableName = 'civicrm_entity_financial_account'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * ID @@ -79,7 +79,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'financial_account_id', 'civicrm_financial_account', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName(), 'entity_id', NULL, 'id', 'entity_table'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); diff --git a/CRM/Financial/DAO/EntityFinancialTrxn.php b/CRM/Financial/DAO/EntityFinancialTrxn.php index 710879740ecb..dd5940494d7c 100644 --- a/CRM/Financial/DAO/EntityFinancialTrxn.php +++ b/CRM/Financial/DAO/EntityFinancialTrxn.php @@ -19,14 +19,14 @@ class CRM_Financial_DAO_EntityFinancialTrxn extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_entity_financial_trxn'; + public static $_tableName = 'civicrm_entity_financial_trxn'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * ID @@ -75,7 +75,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'financial_trxn_id', 'civicrm_financial_trxn', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName(), 'entity_id', NULL, 'id', 'entity_table'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); diff --git a/CRM/Financial/DAO/FinancialAccount.php b/CRM/Financial/DAO/FinancialAccount.php index e3ecc12530b2..c6aaa0097196 100644 --- a/CRM/Financial/DAO/FinancialAccount.php +++ b/CRM/Financial/DAO/FinancialAccount.php @@ -19,14 +19,14 @@ class CRM_Financial_DAO_FinancialAccount extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_financial_account'; + public static $_tableName = 'civicrm_financial_account'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * ID @@ -149,7 +149,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'parent_id', 'civicrm_financial_account', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); diff --git a/CRM/Financial/DAO/FinancialItem.php b/CRM/Financial/DAO/FinancialItem.php index 30284d4d2229..d25859144de4 100644 --- a/CRM/Financial/DAO/FinancialItem.php +++ b/CRM/Financial/DAO/FinancialItem.php @@ -19,14 +19,14 @@ class CRM_Financial_DAO_FinancialItem extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_financial_item'; + public static $_tableName = 'civicrm_financial_item'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * @var int unsigned @@ -119,7 +119,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'financial_account_id', 'civicrm_financial_account', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName(), 'entity_id', NULL, 'id', 'entity_table'); diff --git a/CRM/Financial/DAO/FinancialTrxn.php b/CRM/Financial/DAO/FinancialTrxn.php index 57e96aedf19f..f89106a691d2 100644 --- a/CRM/Financial/DAO/FinancialTrxn.php +++ b/CRM/Financial/DAO/FinancialTrxn.php @@ -19,14 +19,14 @@ class CRM_Financial_DAO_FinancialTrxn extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_financial_trxn'; + public static $_tableName = 'civicrm_financial_trxn'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * @var int unsigned @@ -161,7 +161,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'from_financial_account_id', 'civicrm_financial_account', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'to_financial_account_id', 'civicrm_financial_account', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'payment_processor_id', 'civicrm_payment_processor', 'id'); diff --git a/CRM/Financial/DAO/FinancialType.php b/CRM/Financial/DAO/FinancialType.php index 516fe493e833..611c7b6506bd 100644 --- a/CRM/Financial/DAO/FinancialType.php +++ b/CRM/Financial/DAO/FinancialType.php @@ -19,14 +19,14 @@ class CRM_Financial_DAO_FinancialType extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_financial_type'; + public static $_tableName = 'civicrm_financial_type'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * ID of original financial_type so you can search this table by the financial_type.id and then select the relevant version based on the timestamp diff --git a/CRM/Financial/DAO/PaymentProcessor.php b/CRM/Financial/DAO/PaymentProcessor.php index 311fe33b96d6..2c8bcffc3421 100644 --- a/CRM/Financial/DAO/PaymentProcessor.php +++ b/CRM/Financial/DAO/PaymentProcessor.php @@ -19,14 +19,14 @@ class CRM_Financial_DAO_PaymentProcessor extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_payment_processor'; + public static $_tableName = 'civicrm_payment_processor'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * Payment Processor ID @@ -185,7 +185,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'domain_id', 'civicrm_domain', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'payment_processor_type_id', 'civicrm_payment_processor_type', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); diff --git a/CRM/Financial/DAO/PaymentProcessorType.php b/CRM/Financial/DAO/PaymentProcessorType.php index 8fc4a6279a9c..e5de98746e41 100644 --- a/CRM/Financial/DAO/PaymentProcessorType.php +++ b/CRM/Financial/DAO/PaymentProcessorType.php @@ -19,14 +19,14 @@ class CRM_Financial_DAO_PaymentProcessorType extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_payment_processor_type'; + public static $_tableName = 'civicrm_payment_processor_type'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * Payment Processor Type ID diff --git a/CRM/Financial/DAO/PaymentToken.php b/CRM/Financial/DAO/PaymentToken.php index f016332899ce..923f2fb4fb2e 100644 --- a/CRM/Financial/DAO/PaymentToken.php +++ b/CRM/Financial/DAO/PaymentToken.php @@ -19,14 +19,14 @@ class CRM_Financial_DAO_PaymentToken extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_payment_token'; + public static $_tableName = 'civicrm_payment_token'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * Payment Token ID @@ -133,7 +133,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'payment_processor_id', 'civicrm_payment_processor', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'created_id', 'civicrm_contact', 'id'); diff --git a/CRM/Friend/DAO/Friend.php b/CRM/Friend/DAO/Friend.php index 421f6c64812a..568c648d3344 100644 --- a/CRM/Friend/DAO/Friend.php +++ b/CRM/Friend/DAO/Friend.php @@ -19,14 +19,14 @@ class CRM_Friend_DAO_Friend extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_tell_friend'; + public static $_tableName = 'civicrm_tell_friend'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * Friend ID @@ -110,7 +110,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName(), 'entity_id', NULL, 'id', 'entity_table'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); } diff --git a/CRM/Grant/DAO/Grant.php b/CRM/Grant/DAO/Grant.php index 03b5e1814cf2..f3b0a3f41490 100644 --- a/CRM/Grant/DAO/Grant.php +++ b/CRM/Grant/DAO/Grant.php @@ -19,14 +19,14 @@ class CRM_Grant_DAO_Grant extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_grant'; + public static $_tableName = 'civicrm_grant'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * Unique Grant id @@ -149,7 +149,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'financial_type_id', 'civicrm_financial_type', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); diff --git a/CRM/Mailing/DAO/BouncePattern.php b/CRM/Mailing/DAO/BouncePattern.php index abc1f763ee41..447451c0dc90 100644 --- a/CRM/Mailing/DAO/BouncePattern.php +++ b/CRM/Mailing/DAO/BouncePattern.php @@ -19,14 +19,14 @@ class CRM_Mailing_DAO_BouncePattern extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_mailing_bounce_pattern'; + public static $_tableName = 'civicrm_mailing_bounce_pattern'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * @var int unsigned @@ -63,7 +63,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'bounce_type_id', 'civicrm_mailing_bounce_type', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); } diff --git a/CRM/Mailing/DAO/BounceType.php b/CRM/Mailing/DAO/BounceType.php index 6b2ce2e986ac..134ed3302e2b 100644 --- a/CRM/Mailing/DAO/BounceType.php +++ b/CRM/Mailing/DAO/BounceType.php @@ -19,14 +19,14 @@ class CRM_Mailing_DAO_BounceType extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_mailing_bounce_type'; + public static $_tableName = 'civicrm_mailing_bounce_type'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * @var int unsigned diff --git a/CRM/Mailing/DAO/Mailing.php b/CRM/Mailing/DAO/Mailing.php index 3a36d6e9e790..e57dc5ced88d 100644 --- a/CRM/Mailing/DAO/Mailing.php +++ b/CRM/Mailing/DAO/Mailing.php @@ -19,14 +19,14 @@ class CRM_Mailing_DAO_Mailing extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_mailing'; + public static $_tableName = 'civicrm_mailing'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * @var int unsigned @@ -339,7 +339,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'domain_id', 'civicrm_domain', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'header_id', 'civicrm_mailing_component', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'footer_id', 'civicrm_mailing_component', 'id'); diff --git a/CRM/Mailing/DAO/MailingAB.php b/CRM/Mailing/DAO/MailingAB.php index 21a51e3752c9..9d4ac8bff0e0 100644 --- a/CRM/Mailing/DAO/MailingAB.php +++ b/CRM/Mailing/DAO/MailingAB.php @@ -19,14 +19,14 @@ class CRM_Mailing_DAO_MailingAB extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_mailing_abtest'; + public static $_tableName = 'civicrm_mailing_abtest'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * @var int unsigned @@ -134,7 +134,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'created_id', 'civicrm_contact', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); } diff --git a/CRM/Mailing/DAO/MailingComponent.php b/CRM/Mailing/DAO/MailingComponent.php index 37689283d088..6f2ba81e3139 100644 --- a/CRM/Mailing/DAO/MailingComponent.php +++ b/CRM/Mailing/DAO/MailingComponent.php @@ -19,14 +19,14 @@ class CRM_Mailing_DAO_MailingComponent extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_mailing_component'; + public static $_tableName = 'civicrm_mailing_component'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * @var int unsigned diff --git a/CRM/Mailing/DAO/MailingGroup.php b/CRM/Mailing/DAO/MailingGroup.php index f1f454382a3b..46f6a4033371 100644 --- a/CRM/Mailing/DAO/MailingGroup.php +++ b/CRM/Mailing/DAO/MailingGroup.php @@ -19,14 +19,14 @@ class CRM_Mailing_DAO_MailingGroup extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_mailing_group'; + public static $_tableName = 'civicrm_mailing_group'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * @var int unsigned @@ -91,7 +91,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'mailing_id', 'civicrm_mailing', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName(), 'entity_id', NULL, 'id', 'entity_table'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); diff --git a/CRM/Mailing/DAO/MailingJob.php b/CRM/Mailing/DAO/MailingJob.php index 6065831c5b2e..a88d4abcf64e 100644 --- a/CRM/Mailing/DAO/MailingJob.php +++ b/CRM/Mailing/DAO/MailingJob.php @@ -19,14 +19,14 @@ class CRM_Mailing_DAO_MailingJob extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_mailing_job'; + public static $_tableName = 'civicrm_mailing_job'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * @var int unsigned @@ -119,7 +119,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'mailing_id', 'civicrm_mailing', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'parent_id', 'civicrm_mailing_job', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); diff --git a/CRM/Mailing/DAO/Recipients.php b/CRM/Mailing/DAO/Recipients.php index 9817eea9b10b..3b10af904ae9 100644 --- a/CRM/Mailing/DAO/Recipients.php +++ b/CRM/Mailing/DAO/Recipients.php @@ -19,14 +19,14 @@ class CRM_Mailing_DAO_Recipients extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_mailing_recipients'; + public static $_tableName = 'civicrm_mailing_recipients'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * @var int unsigned @@ -77,7 +77,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'mailing_id', 'civicrm_mailing', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'email_id', 'civicrm_email', 'id'); diff --git a/CRM/Mailing/DAO/Spool.php b/CRM/Mailing/DAO/Spool.php index 693134c2a134..bdc28b428d04 100644 --- a/CRM/Mailing/DAO/Spool.php +++ b/CRM/Mailing/DAO/Spool.php @@ -19,14 +19,14 @@ class CRM_Mailing_DAO_Spool extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_mailing_spool'; + public static $_tableName = 'civicrm_mailing_spool'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * @var int unsigned @@ -91,7 +91,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'job_id', 'civicrm_mailing_job', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); } diff --git a/CRM/Mailing/DAO/TrackableURL.php b/CRM/Mailing/DAO/TrackableURL.php index c7d7acb3aced..840f42c6b3d3 100644 --- a/CRM/Mailing/DAO/TrackableURL.php +++ b/CRM/Mailing/DAO/TrackableURL.php @@ -19,14 +19,14 @@ class CRM_Mailing_DAO_TrackableURL extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_mailing_trackable_url'; + public static $_tableName = 'civicrm_mailing_trackable_url'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * @var int unsigned @@ -63,7 +63,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'mailing_id', 'civicrm_mailing', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); } diff --git a/CRM/Mailing/Event/DAO/Bounce.php b/CRM/Mailing/Event/DAO/Bounce.php index 17a049bcea46..ba53bf7c06c2 100644 --- a/CRM/Mailing/Event/DAO/Bounce.php +++ b/CRM/Mailing/Event/DAO/Bounce.php @@ -19,14 +19,14 @@ class CRM_Mailing_Event_DAO_Bounce extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_mailing_event_bounce'; + public static $_tableName = 'civicrm_mailing_event_bounce'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * @var int unsigned diff --git a/CRM/Mailing/Event/DAO/Confirm.php b/CRM/Mailing/Event/DAO/Confirm.php index e7caf8a74a74..b66ca4a6fb76 100644 --- a/CRM/Mailing/Event/DAO/Confirm.php +++ b/CRM/Mailing/Event/DAO/Confirm.php @@ -19,14 +19,14 @@ class CRM_Mailing_Event_DAO_Confirm extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_mailing_event_confirm'; + public static $_tableName = 'civicrm_mailing_event_confirm'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * @var int unsigned diff --git a/CRM/Mailing/Event/DAO/Delivered.php b/CRM/Mailing/Event/DAO/Delivered.php index 618287bfb7fc..ddde617bab6c 100644 --- a/CRM/Mailing/Event/DAO/Delivered.php +++ b/CRM/Mailing/Event/DAO/Delivered.php @@ -19,14 +19,14 @@ class CRM_Mailing_Event_DAO_Delivered extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_mailing_event_delivered'; + public static $_tableName = 'civicrm_mailing_event_delivered'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * @var int unsigned diff --git a/CRM/Mailing/Event/DAO/Forward.php b/CRM/Mailing/Event/DAO/Forward.php index a560f33c489c..c9d1588dd4fe 100644 --- a/CRM/Mailing/Event/DAO/Forward.php +++ b/CRM/Mailing/Event/DAO/Forward.php @@ -19,14 +19,14 @@ class CRM_Mailing_Event_DAO_Forward extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_mailing_event_forward'; + public static $_tableName = 'civicrm_mailing_event_forward'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * @var int unsigned diff --git a/CRM/Mailing/Event/DAO/Opened.php b/CRM/Mailing/Event/DAO/Opened.php index 18b46160418a..e3337cba2836 100644 --- a/CRM/Mailing/Event/DAO/Opened.php +++ b/CRM/Mailing/Event/DAO/Opened.php @@ -19,14 +19,14 @@ class CRM_Mailing_Event_DAO_Opened extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_mailing_event_opened'; + public static $_tableName = 'civicrm_mailing_event_opened'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * @var int unsigned diff --git a/CRM/Mailing/Event/DAO/Queue.php b/CRM/Mailing/Event/DAO/Queue.php index 7ff2bb353446..b1e344750002 100644 --- a/CRM/Mailing/Event/DAO/Queue.php +++ b/CRM/Mailing/Event/DAO/Queue.php @@ -19,14 +19,14 @@ class CRM_Mailing_Event_DAO_Queue extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_mailing_event_queue'; + public static $_tableName = 'civicrm_mailing_event_queue'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * @var int unsigned diff --git a/CRM/Mailing/Event/DAO/Reply.php b/CRM/Mailing/Event/DAO/Reply.php index 72d8686557ff..d7f71831b59d 100644 --- a/CRM/Mailing/Event/DAO/Reply.php +++ b/CRM/Mailing/Event/DAO/Reply.php @@ -19,14 +19,14 @@ class CRM_Mailing_Event_DAO_Reply extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_mailing_event_reply'; + public static $_tableName = 'civicrm_mailing_event_reply'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * @var int unsigned diff --git a/CRM/Mailing/Event/DAO/Subscribe.php b/CRM/Mailing/Event/DAO/Subscribe.php index fbd28c5d3b2b..888c2ecc199a 100644 --- a/CRM/Mailing/Event/DAO/Subscribe.php +++ b/CRM/Mailing/Event/DAO/Subscribe.php @@ -19,14 +19,14 @@ class CRM_Mailing_Event_DAO_Subscribe extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_mailing_event_subscribe'; + public static $_tableName = 'civicrm_mailing_event_subscribe'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * @var int unsigned diff --git a/CRM/Mailing/Event/DAO/TrackableURLOpen.php b/CRM/Mailing/Event/DAO/TrackableURLOpen.php index 2febab694cad..60e2eafef2c1 100644 --- a/CRM/Mailing/Event/DAO/TrackableURLOpen.php +++ b/CRM/Mailing/Event/DAO/TrackableURLOpen.php @@ -19,14 +19,14 @@ class CRM_Mailing_Event_DAO_TrackableURLOpen extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_mailing_event_trackable_url_open'; + public static $_tableName = 'civicrm_mailing_event_trackable_url_open'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * @var int unsigned diff --git a/CRM/Mailing/Event/DAO/Unsubscribe.php b/CRM/Mailing/Event/DAO/Unsubscribe.php index d8397181a6db..8459b8a50bd2 100644 --- a/CRM/Mailing/Event/DAO/Unsubscribe.php +++ b/CRM/Mailing/Event/DAO/Unsubscribe.php @@ -19,14 +19,14 @@ class CRM_Mailing_Event_DAO_Unsubscribe extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_mailing_event_unsubscribe'; + public static $_tableName = 'civicrm_mailing_event_unsubscribe'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * @var int unsigned diff --git a/CRM/Member/DAO/Membership.php b/CRM/Member/DAO/Membership.php index a7f757dcb7c6..5dbba6f274d7 100644 --- a/CRM/Member/DAO/Membership.php +++ b/CRM/Member/DAO/Membership.php @@ -19,14 +19,14 @@ class CRM_Member_DAO_Membership extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_membership'; + public static $_tableName = 'civicrm_membership'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * Membership Id @@ -150,7 +150,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'membership_type_id', 'civicrm_membership_type', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'status_id', 'civicrm_membership_status', 'id'); diff --git a/CRM/Member/DAO/MembershipBlock.php b/CRM/Member/DAO/MembershipBlock.php index 63d08cc0bd64..0b533176c33d 100644 --- a/CRM/Member/DAO/MembershipBlock.php +++ b/CRM/Member/DAO/MembershipBlock.php @@ -19,14 +19,14 @@ class CRM_Member_DAO_MembershipBlock extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_membership_block'; + public static $_tableName = 'civicrm_membership_block'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * Membership Id @@ -135,7 +135,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'entity_id', 'civicrm_contribution_page', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'membership_type_default', 'civicrm_membership_type', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); diff --git a/CRM/Member/DAO/MembershipLog.php b/CRM/Member/DAO/MembershipLog.php index c72b09b48929..306cd2064772 100644 --- a/CRM/Member/DAO/MembershipLog.php +++ b/CRM/Member/DAO/MembershipLog.php @@ -19,14 +19,14 @@ class CRM_Member_DAO_MembershipLog extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_membership_log'; + public static $_tableName = 'civicrm_membership_log'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * @var int unsigned @@ -105,7 +105,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'membership_id', 'civicrm_membership', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'status_id', 'civicrm_membership_status', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'modified_id', 'civicrm_contact', 'id'); diff --git a/CRM/Member/DAO/MembershipPayment.php b/CRM/Member/DAO/MembershipPayment.php index 9cebf440f006..e1b4c7abe95a 100644 --- a/CRM/Member/DAO/MembershipPayment.php +++ b/CRM/Member/DAO/MembershipPayment.php @@ -19,14 +19,14 @@ class CRM_Member_DAO_MembershipPayment extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_membership_payment'; + public static $_tableName = 'civicrm_membership_payment'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * @var int unsigned @@ -63,7 +63,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'membership_id', 'civicrm_membership', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contribution_id', 'civicrm_contribution', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); diff --git a/CRM/Member/DAO/MembershipStatus.php b/CRM/Member/DAO/MembershipStatus.php index 1bff2fe8073a..03d9b33b3081 100644 --- a/CRM/Member/DAO/MembershipStatus.php +++ b/CRM/Member/DAO/MembershipStatus.php @@ -19,14 +19,14 @@ class CRM_Member_DAO_MembershipStatus extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_membership_status'; + public static $_tableName = 'civicrm_membership_status'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * Membership Id diff --git a/CRM/Member/DAO/MembershipType.php b/CRM/Member/DAO/MembershipType.php index be6469019e38..e2f99222f0df 100644 --- a/CRM/Member/DAO/MembershipType.php +++ b/CRM/Member/DAO/MembershipType.php @@ -19,14 +19,14 @@ class CRM_Member_DAO_MembershipType extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_membership_type'; + public static $_tableName = 'civicrm_membership_type'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * Membership Id @@ -185,7 +185,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'domain_id', 'civicrm_domain', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'member_of_contact_id', 'civicrm_contact', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'financial_type_id', 'civicrm_financial_type', 'id'); diff --git a/CRM/PCP/DAO/PCP.php b/CRM/PCP/DAO/PCP.php index bde10b502e9e..20238b03d517 100644 --- a/CRM/PCP/DAO/PCP.php +++ b/CRM/PCP/DAO/PCP.php @@ -19,14 +19,14 @@ class CRM_PCP_DAO_PCP extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_pcp'; + public static $_tableName = 'civicrm_pcp'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * Personal Campaign Page ID @@ -142,7 +142,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); } diff --git a/CRM/PCP/DAO/PCPBlock.php b/CRM/PCP/DAO/PCPBlock.php index b6c8064c9d22..89b76af0be2c 100644 --- a/CRM/PCP/DAO/PCPBlock.php +++ b/CRM/PCP/DAO/PCPBlock.php @@ -19,14 +19,14 @@ class CRM_PCP_DAO_PCPBlock extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_pcp_block'; + public static $_tableName = 'civicrm_pcp_block'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * PCP block Id @@ -133,7 +133,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'supporter_profile_id', 'civicrm_uf_group', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName(), 'entity_id', NULL, 'id', 'entity_table'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName(), 'target_entity_id', NULL, 'id', 'target_entity_type'); diff --git a/CRM/Pledge/DAO/Pledge.php b/CRM/Pledge/DAO/Pledge.php index e98195db72a5..de2f29891683 100644 --- a/CRM/Pledge/DAO/Pledge.php +++ b/CRM/Pledge/DAO/Pledge.php @@ -19,14 +19,14 @@ class CRM_Pledge_DAO_Pledge extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_pledge'; + public static $_tableName = 'civicrm_pledge'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * Pledge ID @@ -203,7 +203,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'financial_type_id', 'civicrm_financial_type', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contribution_page_id', 'civicrm_contribution_page', 'id'); diff --git a/CRM/Pledge/DAO/PledgeBlock.php b/CRM/Pledge/DAO/PledgeBlock.php index 24f2f924d6e2..381f297a2c12 100644 --- a/CRM/Pledge/DAO/PledgeBlock.php +++ b/CRM/Pledge/DAO/PledgeBlock.php @@ -19,14 +19,14 @@ class CRM_Pledge_DAO_PledgeBlock extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_pledge_block'; + public static $_tableName = 'civicrm_pledge_block'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * Pledge ID @@ -121,7 +121,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName(), 'entity_id', NULL, 'id', 'entity_table'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); } diff --git a/CRM/Pledge/DAO/PledgePayment.php b/CRM/Pledge/DAO/PledgePayment.php index bffa34aba104..d43a0f779135 100644 --- a/CRM/Pledge/DAO/PledgePayment.php +++ b/CRM/Pledge/DAO/PledgePayment.php @@ -19,14 +19,14 @@ class CRM_Pledge_DAO_PledgePayment extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_pledge_payment'; + public static $_tableName = 'civicrm_pledge_payment'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * @var int unsigned @@ -110,7 +110,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'pledge_id', 'civicrm_pledge', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contribution_id', 'civicrm_contribution', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); diff --git a/CRM/Price/DAO/LineItem.php b/CRM/Price/DAO/LineItem.php index 08ee2d4eb06f..40dbb3f9996c 100644 --- a/CRM/Price/DAO/LineItem.php +++ b/CRM/Price/DAO/LineItem.php @@ -19,14 +19,14 @@ class CRM_Price_DAO_LineItem extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_line_item'; + public static $_tableName = 'civicrm_line_item'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * Line Item @@ -142,7 +142,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contribution_id', 'civicrm_contribution', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'price_field_id', 'civicrm_price_field', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'price_field_value_id', 'civicrm_price_field_value', 'id'); diff --git a/CRM/Price/DAO/PriceField.php b/CRM/Price/DAO/PriceField.php index 899a4b1c31e3..6211831f0b28 100644 --- a/CRM/Price/DAO/PriceField.php +++ b/CRM/Price/DAO/PriceField.php @@ -19,14 +19,14 @@ class CRM_Price_DAO_PriceField extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_price_field'; + public static $_tableName = 'civicrm_price_field'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * Price Field @@ -161,7 +161,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'price_set_id', 'civicrm_price_set', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); } diff --git a/CRM/Price/DAO/PriceFieldValue.php b/CRM/Price/DAO/PriceFieldValue.php index d6ba96ec79f2..c449711499b9 100644 --- a/CRM/Price/DAO/PriceFieldValue.php +++ b/CRM/Price/DAO/PriceFieldValue.php @@ -19,14 +19,14 @@ class CRM_Price_DAO_PriceFieldValue extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_price_field_value'; + public static $_tableName = 'civicrm_price_field_value'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * Price Field Value @@ -170,7 +170,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'price_field_id', 'civicrm_price_field', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'membership_type_id', 'civicrm_membership_type', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'financial_type_id', 'civicrm_financial_type', 'id'); diff --git a/CRM/Price/DAO/PriceSet.php b/CRM/Price/DAO/PriceSet.php index 1c3136568c52..ed8c4d685b86 100644 --- a/CRM/Price/DAO/PriceSet.php +++ b/CRM/Price/DAO/PriceSet.php @@ -19,14 +19,14 @@ class CRM_Price_DAO_PriceSet extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_price_set'; + public static $_tableName = 'civicrm_price_set'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * Price Set @@ -135,7 +135,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'domain_id', 'civicrm_domain', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'financial_type_id', 'civicrm_financial_type', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); diff --git a/CRM/Price/DAO/PriceSetEntity.php b/CRM/Price/DAO/PriceSetEntity.php index 17f1a3c32eab..0bef5929d79b 100644 --- a/CRM/Price/DAO/PriceSetEntity.php +++ b/CRM/Price/DAO/PriceSetEntity.php @@ -19,14 +19,14 @@ class CRM_Price_DAO_PriceSetEntity extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_price_set_entity'; + public static $_tableName = 'civicrm_price_set_entity'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = TRUE; + public static $_log = TRUE; /** * Price Set Entity @@ -72,7 +72,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'price_set_id', 'civicrm_price_set', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName(), 'entity_id', NULL, 'id', 'entity_table'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); diff --git a/CRM/Queue/DAO/QueueItem.php b/CRM/Queue/DAO/QueueItem.php index 7160abc27377..9c54006cbd88 100644 --- a/CRM/Queue/DAO/QueueItem.php +++ b/CRM/Queue/DAO/QueueItem.php @@ -19,14 +19,14 @@ class CRM_Queue_DAO_QueueItem extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_queue_item'; + public static $_tableName = 'civicrm_queue_item'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * @var int unsigned diff --git a/CRM/Report/DAO/ReportInstance.php b/CRM/Report/DAO/ReportInstance.php index 48a6a02296af..bd2d42c3ef4d 100644 --- a/CRM/Report/DAO/ReportInstance.php +++ b/CRM/Report/DAO/ReportInstance.php @@ -19,14 +19,14 @@ class CRM_Report_DAO_ReportInstance extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_report_instance'; + public static $_tableName = 'civicrm_report_instance'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * Report Instance ID @@ -189,7 +189,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'domain_id', 'civicrm_domain', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'created_id', 'civicrm_contact', 'id'); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'owner_id', 'civicrm_contact', 'id'); diff --git a/CRM/SMS/DAO/Provider.php b/CRM/SMS/DAO/Provider.php index 7ed8179e3d8b..969c212421af 100644 --- a/CRM/SMS/DAO/Provider.php +++ b/CRM/SMS/DAO/Provider.php @@ -19,14 +19,14 @@ class CRM_SMS_DAO_Provider extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_sms_provider'; + public static $_tableName = 'civicrm_sms_provider'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * SMS Provider ID @@ -111,7 +111,7 @@ public function __construct() { */ public static function getReferenceColumns() { if (!isset(Civi::$statics[__CLASS__]['links'])) { - Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__); + Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__); Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'domain_id', 'civicrm_domain', 'id'); CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']); } diff --git a/xml/templates/dao.tpl b/xml/templates/dao.tpl index 49955881549c..8e0f26f42d10 100644 --- a/xml/templates/dao.tpl +++ b/xml/templates/dao.tpl @@ -18,14 +18,14 @@ class {$table.className} extends CRM_Core_DAO {ldelim} * * @var string */ - static $_tableName = '{$table.name}'; + public static $_tableName = '{$table.name}'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = {$table.log|strtoupper}; + public static $_log = {$table.log|strtoupper}; {foreach from=$table.fields item=field} /** From 39b9dbb318c6dca32d7b61cc94ce2430cb66deb9 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Sat, 6 Apr 2019 16:07:30 -0700 Subject: [PATCH 097/121] (NFC) tests/ - Cleanup phpcbf oddities --- .../main.php | 4 +- tests/phpunit/CRM/Case/BAO/CaseTypeTest.php | 4 +- tests/phpunit/CRM/Case/BAO/QueryTest.php | 13 +++--- tests/phpunit/CRM/Contact/SelectorTest.php | 15 +++---- .../CRM/Contribute/Form/ContributionTest.php | 3 +- tests/phpunit/CRM/Utils/HookTest.php | 2 +- tests/phpunit/CRM/Utils/SystemTest.php | 40 +++++++++++-------- tests/phpunit/api/v3/ContributionTest.php | 3 +- .../phpunit/api/v3/JobProcessMailingTest.php | 4 +- 9 files changed, 47 insertions(+), 41 deletions(-) diff --git a/tests/extensions/test.extension.manager.searchtest/main.php b/tests/extensions/test.extension.manager.searchtest/main.php index f1bcdcd6a15a..0611cae2d083 100644 --- a/tests/extensions/test.extension.manager.searchtest/main.php +++ b/tests/extensions/test.extension.manager.searchtest/main.php @@ -51,8 +51,8 @@ public function buildForm(&$form) { * * @return mixed * - NULL or array with keys: - * - summary: string - * - total: numeric + * - summary: string + * - total: numeric */ public function summary() { return NULL; diff --git a/tests/phpunit/CRM/Case/BAO/CaseTypeTest.php b/tests/phpunit/CRM/Case/BAO/CaseTypeTest.php index b83fac0cca96..413c4acb3c3f 100644 --- a/tests/phpunit/CRM/Case/BAO/CaseTypeTest.php +++ b/tests/phpunit/CRM/Case/BAO/CaseTypeTest.php @@ -187,9 +187,9 @@ public function testRoundtrip_JsonToXmlToJson($fixtureName, $inputJson, $ignore) */ public function normalizeXml($xml) { return trim( - // tags on new lines + // tags on new lines preg_replace(":\n*<:", "\n<", - // no leading whitespace + // no leading whitespace preg_replace("/\n[\n ]+/", "\n", $xml ) diff --git a/tests/phpunit/CRM/Case/BAO/QueryTest.php b/tests/phpunit/CRM/Case/BAO/QueryTest.php index 3543366524ff..713cf7c92ae4 100644 --- a/tests/phpunit/CRM/Case/BAO/QueryTest.php +++ b/tests/phpunit/CRM/Case/BAO/QueryTest.php @@ -58,12 +58,13 @@ public function testWhereClauseSingle() { ); $queryObj = new CRM_Contact_BAO_Query($params, NULL, NULL, FALSE, FALSE, CRM_Contact_BAO_Query::MODE_CASE); - $this->assertEquals(array( - 0 => 'Activity Type = Contribution', - 1 => 'Activity Type = Scheduled', - 2 => 'Activity Medium = In Person', - ), - $queryObj->_qill[1] + $this->assertEquals( + array( + 0 => 'Activity Type = Contribution', + 1 => 'Activity Type = Scheduled', + 2 => 'Activity Medium = In Person', + ), + $queryObj->_qill[1] ); } diff --git a/tests/phpunit/CRM/Contact/SelectorTest.php b/tests/phpunit/CRM/Contact/SelectorTest.php index 917396028bda..e7d0a58cdcda 100644 --- a/tests/phpunit/CRM/Contact/SelectorTest.php +++ b/tests/phpunit/CRM/Contact/SelectorTest.php @@ -513,13 +513,14 @@ public function testCustomDateField() { $selector = new CRM_Contact_Selector( 'CRM_Contact_Selector', ['custom_' . $createdField['id'] => ['IS NOT EMPTY' => 1]], - [[ - 0 => 'custom_' . $createdField['id'], - 1 => 'IS NOT NULL', - 2 => 1, - 3 => 1, - 4 => 0, - ], + [ + [ + 0 => 'custom_' . $createdField['id'], + 1 => 'IS NOT NULL', + 2 => 1, + 3 => 1, + 4 => 0, + ], ], [], CRM_Core_Action::NONE, diff --git a/tests/phpunit/CRM/Contribute/Form/ContributionTest.php b/tests/phpunit/CRM/Contribute/Form/ContributionTest.php index 81e35403654a..629b9d92292a 100644 --- a/tests/phpunit/CRM/Contribute/Form/ContributionTest.php +++ b/tests/phpunit/CRM/Contribute/Form/ContributionTest.php @@ -607,8 +607,7 @@ public function testSubmitEmailReceipt() { $this->callAPISuccessGetCount('Contribution', array('contact_id' => $this->_individualId), 1); $mut->checkMailLog(array( '

        Please print this receipt for your records.

        ', - ) - ); + )); $mut->stop(); } diff --git a/tests/phpunit/CRM/Utils/HookTest.php b/tests/phpunit/CRM/Utils/HookTest.php index a1e0e6329ae8..e3167f200270 100644 --- a/tests/phpunit/CRM/Utils/HookTest.php +++ b/tests/phpunit/CRM/Utils/HookTest.php @@ -6,7 +6,7 @@ */ class CRM_Utils_HookTest extends CiviUnitTestCase { - protected static $activeTest = NULL; + public static $activeTest = NULL; public $fakeModules; diff --git a/tests/phpunit/CRM/Utils/SystemTest.php b/tests/phpunit/CRM/Utils/SystemTest.php index 66bab81091e2..457e73632991 100644 --- a/tests/phpunit/CRM/Utils/SystemTest.php +++ b/tests/phpunit/CRM/Utils/SystemTest.php @@ -85,25 +85,31 @@ public function hook_civicrm_alterRedirect($urlQuery, $context) { */ public function getURLs() { return [ - ['https://example.com?ab=cd', [ - 'scheme' => 'https', - 'host' => 'example.com', - 'query' => 'ab=cd', + [ + 'https://example.com?ab=cd', + [ + 'scheme' => 'https', + 'host' => 'example.com', + 'query' => 'ab=cd', + ], ], + [ + 'http://myuser:mypass@foo.bar:123/whiz?a=b&c=d', + [ + 'scheme' => 'http', + 'host' => 'foo.bar', + 'port' => 123, + 'user' => 'myuser', + 'pass' => 'mypass', + 'path' => '/whiz', + 'query' => 'a=b&c=d', + ], ], - ['http://myuser:mypass@foo.bar:123/whiz?a=b&c=d', [ - 'scheme' => 'http', - 'host' => 'foo.bar', - 'port' => 123, - 'user' => 'myuser', - 'pass' => 'mypass', - 'path' => '/whiz', - 'query' => 'a=b&c=d', - ], - ], - ['/foo/bar', [ - 'path' => '/foo/bar', - ], + [ + '/foo/bar', + [ + 'path' => '/foo/bar', + ], ], ]; } diff --git a/tests/phpunit/api/v3/ContributionTest.php b/tests/phpunit/api/v3/ContributionTest.php index 70d339f05223..27a776fc5274 100644 --- a/tests/phpunit/api/v3/ContributionTest.php +++ b/tests/phpunit/api/v3/ContributionTest.php @@ -3049,8 +3049,7 @@ public function testCompleteTransactionMembershipPriceSet() { $stateOfGrace = $this->callAPISuccess('MembershipStatus', 'getvalue', array( 'name' => 'Grace', 'return' => 'id', - ) - ); + )); $this->setUpPendingContribution($this->_ids['price_field_value'][0]); $membership = $this->callAPISuccess('membership', 'getsingle', array('id' => $this->_ids['membership'])); $logs = $this->callAPISuccess('MembershipLog', 'get', array( diff --git a/tests/phpunit/api/v3/JobProcessMailingTest.php b/tests/phpunit/api/v3/JobProcessMailingTest.php index c96a3f1e5f3d..1f4e1bfdbf56 100644 --- a/tests/phpunit/api/v3/JobProcessMailingTest.php +++ b/tests/phpunit/api/v3/JobProcessMailingTest.php @@ -222,9 +222,9 @@ public function concurrencyExamples() { 'mailerJobsMax' => 1, ), array( - // 2 jobs which produce 0 messages + // 2 jobs which produce 0 messages 0 => 2, - // 1 job which produces 4 messages + // 1 job which produces 4 messages 4 => 1, ), 4, From 6714d8d227f25c94a3435acf445ef902c36b880c Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Sun, 7 Apr 2019 11:22:19 +1000 Subject: [PATCH 098/121] (NFC) Bring CRM/Utils folder up to future coder standards --- CRM/Utils/API/AbstractFieldCoder.php | 4 +- CRM/Utils/API/HTMLInputCoder.php | 27 +++-- CRM/Utils/API/MatchOption.php | 3 +- CRM/Utils/Address/BatchUpdate.php | 24 ++--- CRM/Utils/Array.php | 3 +- CRM/Utils/Cache.php | 3 +- CRM/Utils/Cache/APCcache.php | 12 ++- CRM/Utils/Cache/ArrayCache.php | 4 +- CRM/Utils/Cache/ArrayDecorator.php | 3 +- CRM/Utils/Cache/FastArrayDecorator.php | 3 +- CRM/Utils/Cache/Memcache.php | 7 +- CRM/Utils/Cache/Memcached.php | 9 +- CRM/Utils/Cache/NaiveMultipleTrait.php | 1 + CRM/Utils/Cache/NoCache.php | 6 +- CRM/Utils/Cache/Redis.php | 9 +- CRM/Utils/Cache/SerializeCache.php | 10 +- CRM/Utils/Cache/SqlGroup.php | 5 +- CRM/Utils/Cache/Tiered.php | 3 +- CRM/Utils/Check/Component.php | 4 +- CRM/Utils/Check/Component/Env.php | 13 ++- CRM/Utils/Check/Component/PriceFields.php | 3 +- CRM/Utils/Check/Component/Security.php | 2 - CRM/Utils/Date.php | 11 +-- CRM/Utils/DeprecatedUtils.php | 13 ++- CRM/Utils/FakeObject.php | 1 + CRM/Utils/File.php | 3 +- CRM/Utils/GlobalStack.php | 2 +- CRM/Utils/Hook.php | 23 +++-- CRM/Utils/Hook/Joomla.php | 1 + CRM/Utils/Hook/Soap.php | 1 + CRM/Utils/Hook/UnitTests.php | 2 +- CRM/Utils/Hook/WordPress.php | 1 - CRM/Utils/JS.php | 1 + CRM/Utils/Mail.php | 8 +- CRM/Utils/Migrate/Export.php | 16 +-- CRM/Utils/Migrate/ExportJSON.php | 6 +- CRM/Utils/Migrate/Import.php | 1 + CRM/Utils/Money.php | 8 +- CRM/Utils/Network.php | 1 + CRM/Utils/Number.php | 10 +- CRM/Utils/OpenFlashChart.php | 16 +-- CRM/Utils/PDF/Document.php | 5 +- CRM/Utils/PDF/Label.php | 115 +++++++++++++++++----- CRM/Utils/PDF/Utils.php | 4 +- CRM/Utils/Pager.php | 12 +-- CRM/Utils/PseudoConstant.php | 1 + CRM/Utils/QueryFormatter.php | 7 +- CRM/Utils/REST.php | 16 ++- CRM/Utils/ReCAPTCHA.php | 1 - CRM/Utils/Request.php | 4 +- CRM/Utils/SQL/BaseParamQuery.php | 11 ++- CRM/Utils/SQL/Insert.php | 4 +- CRM/Utils/SQL/Select.php | 1 - CRM/Utils/SQL/TempTable.php | 10 +- CRM/Utils/Signer.php | 6 +- CRM/Utils/SoapServer.php | 4 +- CRM/Utils/String.php | 1 - CRM/Utils/System.php | 11 +-- CRM/Utils/System/Base.php | 23 +++-- CRM/Utils/System/DrupalBase.php | 12 +-- CRM/Utils/System/Joomla.php | 5 +- CRM/Utils/System/Soap.php | 5 +- CRM/Utils/System/UnitTests.php | 1 + CRM/Utils/System/WordPress.php | 6 +- CRM/Utils/SystemLogger.php | 1 + CRM/Utils/Token.php | 41 ++++---- CRM/Utils/Url.php | 4 +- CRM/Utils/Verp.php | 16 +-- CRM/Utils/Weight.php | 3 +- CRM/Utils/Wrapper.php | 1 + CRM/Utils/XML.php | 12 ++- CRM/Utils/Zip.php | 9 +- 72 files changed, 397 insertions(+), 238 deletions(-) diff --git a/CRM/Utils/API/AbstractFieldCoder.php b/CRM/Utils/API/AbstractFieldCoder.php index e14e23ff4dd7..6dfefd8fca66 100644 --- a/CRM/Utils/API/AbstractFieldCoder.php +++ b/CRM/Utils/API/AbstractFieldCoder.php @@ -92,7 +92,7 @@ public function isSkippedField($fldName) { * * @param array|string $values the field value from the API */ - public abstract function encodeInput(&$values); + abstract public function encodeInput(&$values); /** * Decode output. @@ -101,7 +101,7 @@ public abstract function encodeInput(&$values); * * @return mixed */ - public abstract function decodeOutput(&$values); + abstract public function decodeOutput(&$values); /** * @inheritDoc diff --git a/CRM/Utils/API/HTMLInputCoder.php b/CRM/Utils/API/HTMLInputCoder.php index 91df1ac52222..bc9a2b51810b 100644 --- a/CRM/Utils/API/HTMLInputCoder.php +++ b/CRM/Utils/API/HTMLInputCoder.php @@ -97,19 +97,28 @@ public function getSkipFields() { 'honor_block_text', 'pay_later_text', 'pay_later_receipt', - 'label', // This is needed for FROM Email Address configuration. dgg - 'url', // This is needed for navigation items urls + // This is needed for FROM Email Address configuration. dgg + 'label', + // This is needed for navigation items urls + 'url', 'details', - 'msg_text', // message templates’ text versions - 'text_message', // (send an) email to contact’s and CiviMail’s text version - 'data', // data i/p of persistent table - 'sqlQuery', // CRM-6673 + // message templates’ text versions + 'msg_text', + // (send an) email to contact’s and CiviMail’s text version + 'text_message', + // data i/p of persistent table + 'data', + // CRM-6673 + 'sqlQuery', 'pcp_title', 'pcp_intro_text', - 'new', // The 'new' text in word replacements - 'replyto_email', // e.g. '"Full Name" ' + // The 'new' text in word replacements + 'new', + // e.g. '"Full Name" ' + 'replyto_email', 'operator', - 'content', // CRM-20468 + // CRM-20468 + 'content', ]; $custom = CRM_Core_DAO::executeQuery('SELECT id FROM civicrm_custom_field WHERE html_type = "RichTextEditor"'); while ($custom->fetch()) { diff --git a/CRM/Utils/API/MatchOption.php b/CRM/Utils/API/MatchOption.php index 408dd3b8f493..0f0cdc8170af 100644 --- a/CRM/Utils/API/MatchOption.php +++ b/CRM/Utils/API/MatchOption.php @@ -153,7 +153,8 @@ public function match($entity, $createParams, $keys, $isMandatory) { if ($isMandatory) { throw new API_Exception("Failed to match existing record"); } - return $createParams; // OK, don't care + // OK, don't care + return $createParams; } elseif ($getResult['count'] == 1) { $item = array_shift($getResult['values']); diff --git a/CRM/Utils/Address/BatchUpdate.php b/CRM/Utils/Address/BatchUpdate.php index 688c8e423725..9b16c0d2f4c2 100644 --- a/CRM/Utils/Address/BatchUpdate.php +++ b/CRM/Utils/Address/BatchUpdate.php @@ -39,14 +39,14 @@ */ class CRM_Utils_Address_BatchUpdate { - var $start = NULL; - var $end = NULL; - var $geocoding = 1; - var $parse = 1; - var $throttle = 0; + public $start = NULL; + public $end = NULL; + public $geocoding = 1; + public $parse = 1; + public $throttle = 0; - var $returnMessages = []; - var $returnError = 0; + public $returnMessages = []; + public $returnError = 0; /** * Class constructor. @@ -260,16 +260,16 @@ public function processContacts($processGeocode, $parseStreetAddress) { $this->returnMessages[] = ts("Addresses Evaluated: %1", [ 1 => $totalAddresses, - ]) . "\n"; + ]) . "\n"; if ($processGeocode) { $this->returnMessages[] = ts("Addresses Geocoded: %1", [ - 1 => $totalGeocoded, - ]) . "\n"; + 1 => $totalGeocoded, + ]) . "\n"; } if ($parseStreetAddress) { $this->returnMessages[] = ts("Street Addresses Parsed: %1", [ - 1 => $totalAddressParsed, - ]) . "\n"; + 1 => $totalAddressParsed, + ]) . "\n"; if ($unparseableContactAddress) { $this->returnMessages[] = "
        \n" . ts("Following is the list of contacts whose address is not parsed:") . "
        \n"; foreach ($unparseableContactAddress as $contactLink) { diff --git a/CRM/Utils/Array.php b/CRM/Utils/Array.php index b95b9c4be305..4cda076ea3fc 100644 --- a/CRM/Utils/Array.php +++ b/CRM/Utils/Array.php @@ -1063,7 +1063,8 @@ public static function formatArrayKeys(&$array) { (count($keys) == 1 && (current($keys) > 1 || is_string(current($keys)) || - (current($keys) == 1 && $array[1] == 1) // handle (0 => 4), (1 => 1) + // handle (0 => 4), (1 => 1) + (current($keys) == 1 && $array[1] == 1) ) ) ) { diff --git a/CRM/Utils/Cache.php b/CRM/Utils/Cache.php index ee4ac03f3625..23975cae4d2a 100644 --- a/CRM/Utils/Cache.php +++ b/CRM/Utils/Cache.php @@ -251,7 +251,8 @@ public static function assertValidKey($key) { * Ex: 'ArrayCache', 'Memcache', 'Redis'. */ public static function getCacheDriver() { - $className = 'ArrayCache'; // default to ArrayCache for now + // default to ArrayCache for now + $className = 'ArrayCache'; // Maintain backward compatibility for now. // Setting CIVICRM_USE_MEMCACHE or CIVICRM_USE_ARRAYCACHE will diff --git a/CRM/Utils/Cache/APCcache.php b/CRM/Utils/Cache/APCcache.php index e18c06121f99..187da7edb801 100644 --- a/CRM/Utils/Cache/APCcache.php +++ b/CRM/Utils/Cache/APCcache.php @@ -32,8 +32,10 @@ */ class CRM_Utils_Cache_APCcache implements CRM_Utils_Cache_Interface { - use CRM_Utils_Cache_NaiveMultipleTrait; // TODO Consider native implementation. - use CRM_Utils_Cache_NaiveHasTrait; // TODO Native implementation + // TODO Consider native implementation. + use CRM_Utils_Cache_NaiveMultipleTrait; + // TODO Native implementation + use CRM_Utils_Cache_NaiveHasTrait; const DEFAULT_TIMEOUT = 3600; const DEFAULT_PREFIX = ''; @@ -123,8 +125,10 @@ public function delete($key) { public function flush() { $allinfo = apc_cache_info('user'); $keys = $allinfo['cache_list']; - $prefix = $this->_prefix; // Our keys follows this pattern: ([A-Za-z0-9_]+)?CRM_[A-Za-z0-9_]+ - $lp = strlen($prefix); // Get prefix length + // Our keys follows this pattern: ([A-Za-z0-9_]+)?CRM_[A-Za-z0-9_]+ + $prefix = $this->_prefix; + // Get prefix length + $lp = strlen($prefix); foreach ($keys as $key) { $name = $key['info']; diff --git a/CRM/Utils/Cache/ArrayCache.php b/CRM/Utils/Cache/ArrayCache.php index 47475326f361..92badc0cda9b 100644 --- a/CRM/Utils/Cache/ArrayCache.php +++ b/CRM/Utils/Cache/ArrayCache.php @@ -37,12 +37,14 @@ class CRM_Utils_Cache_Arraycache implements CRM_Utils_Cache_Interface { use CRM_Utils_Cache_NaiveMultipleTrait; - use CRM_Utils_Cache_NaiveHasTrait; // TODO Native implementation + // TODO Native implementation + use CRM_Utils_Cache_NaiveHasTrait; const DEFAULT_TIMEOUT = 3600; /** * The cache storage container, an in memory array by default + * @var array */ protected $_cache; diff --git a/CRM/Utils/Cache/ArrayDecorator.php b/CRM/Utils/Cache/ArrayDecorator.php index c9007070c3cf..86ac79728a52 100644 --- a/CRM/Utils/Cache/ArrayDecorator.php +++ b/CRM/Utils/Cache/ArrayDecorator.php @@ -41,7 +41,8 @@ */ class CRM_Utils_Cache_ArrayDecorator implements CRM_Utils_Cache_Interface { - use CRM_Utils_Cache_NaiveMultipleTrait; // TODO Consider native implementation. + // TODO Consider native implementation. + use CRM_Utils_Cache_NaiveMultipleTrait; /** * @var int diff --git a/CRM/Utils/Cache/FastArrayDecorator.php b/CRM/Utils/Cache/FastArrayDecorator.php index 82ef578d7257..d0eb1d2a9e00 100644 --- a/CRM/Utils/Cache/FastArrayDecorator.php +++ b/CRM/Utils/Cache/FastArrayDecorator.php @@ -54,7 +54,8 @@ */ class CRM_Utils_Cache_FastArrayDecorator implements CRM_Utils_Cache_Interface { - use CRM_Utils_Cache_NaiveMultipleTrait; // TODO Consider native implementation. + // TODO Consider native implementation. + use CRM_Utils_Cache_NaiveMultipleTrait; /** * @var int diff --git a/CRM/Utils/Cache/Memcache.php b/CRM/Utils/Cache/Memcache.php index 3e8057c49d8a..511663792e57 100644 --- a/CRM/Utils/Cache/Memcache.php +++ b/CRM/Utils/Cache/Memcache.php @@ -32,7 +32,8 @@ */ class CRM_Utils_Cache_Memcache implements CRM_Utils_Cache_Interface { - use CRM_Utils_Cache_NaiveMultipleTrait; // TODO Consider native implementation. + // TODO Consider native implementation. + use CRM_Utils_Cache_NaiveMultipleTrait; const DEFAULT_HOST = 'localhost'; const DEFAULT_PORT = 11211; @@ -163,7 +164,6 @@ public function has($key) { return ($result !== FALSE); } - /** * @param $key * @@ -194,7 +194,8 @@ protected function getTruePrefix() { $value = $this->_cache->get($key); if ($value === FALSE) { $value = uniqid(); - $this->_cache->set($key, $value, FALSE, 0); // Indefinite. + // Indefinite. + $this->_cache->set($key, $value, FALSE, 0); } $this->_truePrefix = [ 'value' => $value, diff --git a/CRM/Utils/Cache/Memcached.php b/CRM/Utils/Cache/Memcached.php index eeed41cc14cd..fd3aee39c236 100644 --- a/CRM/Utils/Cache/Memcached.php +++ b/CRM/Utils/Cache/Memcached.php @@ -32,7 +32,8 @@ */ class CRM_Utils_Cache_Memcached implements CRM_Utils_Cache_Interface { - use CRM_Utils_Cache_NaiveMultipleTrait; // TODO Consider native implementation. + // TODO Consider native implementation. + use CRM_Utils_Cache_NaiveMultipleTrait; const DEFAULT_HOST = 'localhost'; const DEFAULT_PORT = 11211; @@ -227,7 +228,8 @@ public function cleanKey($key) { $maxLen = self::MAX_KEY_LEN - strlen($truePrefix); $key = preg_replace('/\s+|\W+/', '_', $key); if (strlen($key) > $maxLen) { - $md5Key = md5($key); // this should be 32 characters in length + // this should be 32 characters in length + $md5Key = md5($key); $subKeyLen = $maxLen - 1 - strlen($md5Key); $key = substr($key, 0, $subKeyLen) . "_" . $md5Key; } @@ -256,7 +258,8 @@ protected function getTruePrefix() { $value = $this->_cache->get($key); if ($this->_cache->getResultCode() === Memcached::RES_NOTFOUND) { $value = uniqid(); - $this->_cache->add($key, $value, 0); // Indefinite. + // Indefinite. + $this->_cache->add($key, $value, 0); } $this->_truePrefix = [ 'value' => $value, diff --git a/CRM/Utils/Cache/NaiveMultipleTrait.php b/CRM/Utils/Cache/NaiveMultipleTrait.php index 16916f2a71ef..14914d964b9c 100644 --- a/CRM/Utils/Cache/NaiveMultipleTrait.php +++ b/CRM/Utils/Cache/NaiveMultipleTrait.php @@ -109,6 +109,7 @@ public function deleteMultiple($keys) { } /** + * @param $func * @param $keys * @throws \CRM_Utils_Cache_InvalidArgumentException */ diff --git a/CRM/Utils/Cache/NoCache.php b/CRM/Utils/Cache/NoCache.php index 9d39503782c7..42921bd7c8b0 100644 --- a/CRM/Utils/Cache/NoCache.php +++ b/CRM/Utils/Cache/NoCache.php @@ -32,8 +32,10 @@ */ class CRM_Utils_Cache_NoCache implements CRM_Utils_Cache_Interface { - use CRM_Utils_Cache_NaiveMultipleTrait; // TODO Consider native implementation. - use CRM_Utils_Cache_NaiveHasTrait; // TODO Native implementation + // TODO Consider native implementation. + use CRM_Utils_Cache_NaiveMultipleTrait; + // TODO Native implementation + use CRM_Utils_Cache_NaiveHasTrait; /** * We only need one instance of this object. So we use the singleton diff --git a/CRM/Utils/Cache/Redis.php b/CRM/Utils/Cache/Redis.php index 1b64e42881b4..f7c8435f791e 100644 --- a/CRM/Utils/Cache/Redis.php +++ b/CRM/Utils/Cache/Redis.php @@ -34,8 +34,10 @@ */ class CRM_Utils_Cache_Redis implements CRM_Utils_Cache_Interface { - use CRM_Utils_Cache_NaiveMultipleTrait; // TODO Consider native implementation. - use CRM_Utils_Cache_NaiveHasTrait; // TODO Native implementation + // TODO Consider native implementation. + use CRM_Utils_Cache_NaiveMultipleTrait; + // TODO Native implementation + use CRM_Utils_Cache_NaiveHasTrait; const DEFAULT_HOST = 'localhost'; const DEFAULT_PORT = 6379; @@ -76,7 +78,8 @@ class CRM_Utils_Cache_Redis implements CRM_Utils_Cache_Interface { public static function connect($config) { $host = isset($config['host']) ? $config['host'] : self::DEFAULT_HOST; $port = isset($config['port']) ? $config['port'] : self::DEFAULT_PORT; - $pass = CRM_Utils_Constant::value('CIVICRM_DB_CACHE_PASSWORD'); // Ugh. + // Ugh. + $pass = CRM_Utils_Constant::value('CIVICRM_DB_CACHE_PASSWORD'); $id = implode(':', ['connect', $host, $port /* $pass is constant */]); if (!isset(Civi::$statics[__CLASS__][$id])) { // Ideally, we'd track the connection in the service-container, but the diff --git a/CRM/Utils/Cache/SerializeCache.php b/CRM/Utils/Cache/SerializeCache.php index 3b1cf9517e6c..f17b4591076e 100644 --- a/CRM/Utils/Cache/SerializeCache.php +++ b/CRM/Utils/Cache/SerializeCache.php @@ -37,10 +37,12 @@ class CRM_Utils_Cache_SerializeCache implements CRM_Utils_Cache_Interface { use CRM_Utils_Cache_NaiveMultipleTrait; - use CRM_Utils_Cache_NaiveHasTrait; // TODO Native implementation + // TODO Native implementation + use CRM_Utils_Cache_NaiveHasTrait; /** * The cache storage container, an array by default, stored in a file under templates + * @var array */ private $_cache; @@ -101,7 +103,8 @@ public function set($key, $value, $ttl = NULL) { throw new \RuntimeException("FIXME: " . __CLASS__ . "::set() should support non-NULL TTL"); } if (file_exists($this->fileName($key))) { - return FALSE; // WTF, write-once cache?! + // WTF, write-once cache?! + return FALSE; } $this->_cache[$key] = $value; $bytes = file_put_contents($this->fileName($key), "version, '<')) { $updates[] = ts('%1 (%2) version %3 is installed. Upgrade to version %5.', [ - 1 => CRM_Utils_Array::value('label', $row), - 2 => $key, - 3 => $row['version'], - 4 => 'href="' . CRM_Utils_System::url('civicrm/admin/extensions', "action=update&id=$key&key=$key") . '"', - 5 => $remotes[$key]->version, - ]); + 1 => CRM_Utils_Array::value('label', $row), + 2 => $key, + 3 => $row['version'], + 4 => 'href="' . CRM_Utils_System::url('civicrm/admin/extensions', "action=update&id=$key&key=$key") . '"', + 5 => $remotes[$key]->version, + ]); } else { if (empty($row['label'])) { @@ -692,7 +692,6 @@ public function checkExtensions() { return $messages; } - /** * Checks if there are pending extension upgrades. * diff --git a/CRM/Utils/Check/Component/PriceFields.php b/CRM/Utils/Check/Component/PriceFields.php index 47e325cfe034..4261c95a8d19 100644 --- a/CRM/Utils/Check/Component/PriceFields.php +++ b/CRM/Utils/Check/Component/PriceFields.php @@ -53,7 +53,8 @@ public function checkPriceFields() { $url = CRM_Utils_System::url('civicrm/admin/price/field', [ 'reset' => 1, 'action' => 'browse', - 'sid' => $dao->ps_id]); + 'sid' => $dao->ps_id, + ]); $html .= "$dao->ps_title$dao->psf_labelView Price Set Fields"; } if ($count > 0) { diff --git a/CRM/Utils/Check/Component/Security.php b/CRM/Utils/Check/Component/Security.php index 984bf5fc3a0e..c0291e50d98d 100644 --- a/CRM/Utils/Check/Component/Security.php +++ b/CRM/Utils/Check/Component/Security.php @@ -202,7 +202,6 @@ public function checkDirectoriesAreNotBrowseable() { return $messages; } - /** * Check that some files are not present. * @@ -276,7 +275,6 @@ public function checkRemoteProfile() { return $messages; } - /** * Check that the sysadmin has not modified the Cxn * security setup. diff --git a/CRM/Utils/Date.php b/CRM/Utils/Date.php index 913c930a4559..24b2f7388072 100644 --- a/CRM/Utils/Date.php +++ b/CRM/Utils/Date.php @@ -763,7 +763,6 @@ public static function convertCacheTtl($ttl, $default) { } } - /** * @param null $timeStamp * @@ -901,7 +900,7 @@ public static function getFromTo($relative, $from, $to, $fromTime = NULL, $toTim * @return int * array $results contains years or months */ - static public function calculateAge($birthDate) { + public static function calculateAge($birthDate) { $results = []; $formatedBirthDate = CRM_Utils_Date::customFormat($birthDate, '%Y-%m-%d'); @@ -1858,9 +1857,9 @@ public static function relativeToAbsolute($relativeTerm, $unit) { } foreach ([ - 'from', - 'to', - ] as $item) { + 'from', + 'to', + ] as $item) { if (!empty($$item)) { $dateRange[$item] = self::format($$item); } @@ -1961,7 +1960,6 @@ public static function addDateMetadataToField($fieldMetaData, $field) { return $field; } - /** * Get the fields required for the 'extra' parameter when adding a datepicker. * @@ -2170,7 +2168,6 @@ public static function getCalendarDayOfMonth() { return $month; } - /** * Convert a relative date format to an api field. * diff --git a/CRM/Utils/DeprecatedUtils.php b/CRM/Utils/DeprecatedUtils.php index e05a690cd83e..9d2d7ca4e088 100644 --- a/CRM/Utils/DeprecatedUtils.php +++ b/CRM/Utils/DeprecatedUtils.php @@ -780,12 +780,12 @@ function _civicrm_api3_deprecated_add_formatted_param(&$values, &$params) { } foreach ([ - 'Phone', - 'Email', - 'IM', - 'OpenID', - 'Phone_Ext', - ] as $block) { + 'Phone', + 'Email', + 'IM', + 'OpenID', + 'Phone_Ext', + ] as $block) { $name = strtolower($block); if (!array_key_exists($name, $values)) { continue; @@ -1063,7 +1063,6 @@ function _civicrm_api3_deprecated_validate_formatted_contact(&$params) { return civicrm_api3_create_success(TRUE); } - /** * @deprecated - this is part of the import parser not the API & needs to be moved on out * diff --git a/CRM/Utils/FakeObject.php b/CRM/Utils/FakeObject.php index d119548e3cf0..83823708f809 100644 --- a/CRM/Utils/FakeObject.php +++ b/CRM/Utils/FakeObject.php @@ -43,6 +43,7 @@ * @endcode */ class CRM_Utils_FakeObject { + /** * @param $array */ diff --git a/CRM/Utils/File.php b/CRM/Utils/File.php index d9040ffc0f63..b51905f71496 100644 --- a/CRM/Utils/File.php +++ b/CRM/Utils/File.php @@ -797,7 +797,8 @@ public static function isChildPath($parent, $child, $checkRealPath = TRUE) { } } if (empty($childParts)) { - return FALSE; // same directory + // same directory + return FALSE; } else { return TRUE; diff --git a/CRM/Utils/GlobalStack.php b/CRM/Utils/GlobalStack.php index 50bf3c268a1b..0884e3b134c4 100644 --- a/CRM/Utils/GlobalStack.php +++ b/CRM/Utils/GlobalStack.php @@ -62,7 +62,7 @@ class CRM_Utils_GlobalStack { * * @return CRM_Utils_GlobalStack */ - static public function singleton() { + public static function singleton() { if (self::$_singleton === NULL) { self::$_singleton = new CRM_Utils_GlobalStack(); } diff --git a/CRM/Utils/Hook.php b/CRM/Utils/Hook.php index c4c8cd0ae98b..8282a89c7ca2 100644 --- a/CRM/Utils/Hook.php +++ b/CRM/Utils/Hook.php @@ -44,10 +44,15 @@ abstract class CRM_Utils_Hook { const SUMMARY_BELOW = 1; // place hook content above const SUMMARY_ABOVE = 2; - // create your own summaries + /** + *create your own summaries + */ const SUMMARY_REPLACE = 3; - static $_nullObject = NULL; + /** + * @var ojbect + */ + public static $_nullObject = NULL; /** * We only need one instance of this object. So we use the singleton @@ -123,7 +128,7 @@ public function __construct() { * * @return mixed */ - public abstract function invokeViaUF( + abstract public function invokeViaUF( $numParams, &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6, $fnSuffix @@ -1596,6 +1601,7 @@ public static function triggerInfo(&$info, $tableName = NULL) { 'civicrm_triggerInfo' ); } + /** * This hook allows changes to the spec of which tables to log. * @@ -1862,7 +1868,7 @@ public static function permission_check($permission, &$granted, $contactId) { } /** - * @param CRM_Core_Exception Exception $exception + * @param CRM_Core_ExceptionObject $exception * @param mixed $request * Reserved for future use. */ @@ -1981,7 +1987,6 @@ public static function alterBadge($labelName, &$label, &$format, &$participant) ->invoke(['labelName', 'label', 'format', 'participant'], $labelName, $label, $format, $participant, self::$_nullObject, self::$_nullObject, 'civicrm_alterBadge'); } - /** * This hook is called before encoding data in barcode. * @@ -2290,7 +2295,7 @@ public static function container(\Symfony\Component\DependencyInjection\Containe } /** - * @param array $fileSearches + * @param array $fileSearches CRM_Core_FileSearchInterface * @return mixed */ public static function fileSearches(&$fileSearches) { @@ -2426,8 +2431,8 @@ public static function geocoderFormat($geoProvider, &$values, $xml) { /** * This hook is called before an inbound SMS is processed. * - * @param CRM_SMS_Message Object $message - * An SMS message recieved + * @param \CRM_SMS_MessageObject $message + * An SMS message received * @return mixed */ public static function inboundSMS(&$message) { @@ -2438,7 +2443,7 @@ public static function inboundSMS(&$message) { * This hook is called to modify api params of EntityRef form field * * @param array $params - * + * @param string $formName * @return mixed */ public static function alterEntityRefParams(&$params, $formName) { diff --git a/CRM/Utils/Hook/Joomla.php b/CRM/Utils/Hook/Joomla.php index d0448e948b4c..eb2f7b0c774e 100644 --- a/CRM/Utils/Hook/Joomla.php +++ b/CRM/Utils/Hook/Joomla.php @@ -53,6 +53,7 @@ class CRM_Utils_Hook_Joomla extends CRM_Utils_Hook { * * @return mixed */ + /** * @param int $numParams * @param mixed $arg1 diff --git a/CRM/Utils/Hook/Soap.php b/CRM/Utils/Hook/Soap.php index fe6274e6175b..99e3522d759c 100644 --- a/CRM/Utils/Hook/Soap.php +++ b/CRM/Utils/Hook/Soap.php @@ -53,6 +53,7 @@ class CRM_Utils_Hook_Soap extends CRM_Utils_Hook { * * @return mixed */ + /** * @param int $numParams * @param mixed $arg1 diff --git a/CRM/Utils/Hook/UnitTests.php b/CRM/Utils/Hook/UnitTests.php index 39f35eac1a1e..f5fa1400a913 100644 --- a/CRM/Utils/Hook/UnitTests.php +++ b/CRM/Utils/Hook/UnitTests.php @@ -35,7 +35,7 @@ class CRM_Utils_Hook_UnitTests extends CRM_Utils_Hook { protected $mockObject; /** - * @var array $adhocHooks to call + * @var array */ protected $adhocHooks; protected $civiModules = NULL; diff --git a/CRM/Utils/Hook/WordPress.php b/CRM/Utils/Hook/WordPress.php index 2b7bc5bd7c63..ba032151bafa 100644 --- a/CRM/Utils/Hook/WordPress.php +++ b/CRM/Utils/Hook/WordPress.php @@ -160,7 +160,6 @@ public function invokeViaUF( } - /** * Build the list of plugins ("modules" in CiviCRM terminology) to be processed for hooks. * diff --git a/CRM/Utils/JS.php b/CRM/Utils/JS.php index f6d6710e9798..95340e36a38b 100644 --- a/CRM/Utils/JS.php +++ b/CRM/Utils/JS.php @@ -32,6 +32,7 @@ * @copyright CiviCRM LLC (c) 2004-2019 */ class CRM_Utils_JS { + /** * Parse a javascript file for translatable strings. * diff --git a/CRM/Utils/Mail.php b/CRM/Utils/Mail.php index 539b7605237d..ca7526bf37a3 100644 --- a/CRM/Utils/Mail.php +++ b/CRM/Utils/Mail.php @@ -319,8 +319,8 @@ public static function send(&$params) { */ public static function errorMessage($mailer, $result) { $message = '

        ' . ts('An error occurred when CiviCRM attempted to send an email (via %1). If you received this error after submitting on online contribution or event registration - the transaction was completed, but we were unable to send the email receipt.', [ - 1 => 'SMTP', - ]) . '

        ' . '

        ' . ts('The mail library returned the following error message:') . '
        ' . $result->getMessage() . '

        ' . '

        ' . ts('This is probably related to a problem in your Outbound Email Settings (Administer CiviCRM » System Settings » Outbound Email), OR the FROM email address specifically configured for your contribution page or event. Possible causes are:') . '

        '; + 1 => 'SMTP', + ]) . '

        ' . '

        ' . ts('The mail library returned the following error message:') . '
        ' . $result->getMessage() . '

        ' . '

        ' . ts('This is probably related to a problem in your Outbound Email Settings (Administer CiviCRM » System Settings » Outbound Email), OR the FROM email address specifically configured for your contribution page or event. Possible causes are:') . '

        '; if (is_a($mailer, 'Mail_smtp')) { $message .= '
          ' . '
        • ' . ts('Your SMTP Username or Password are incorrect.') . '
        • ' . '
        • ' . ts('Your SMTP Server (machine) name is incorrect.') . '
        • ' . '
        • ' . ts('You need to use a Port other than the default port 25 in your environment.') . '
        • ' . '
        • ' . ts('Your SMTP server is just not responding right now (it is down for some reason).') . '
        • '; @@ -330,8 +330,8 @@ public static function errorMessage($mailer, $result) { } $message .= '
        • ' . ts('The FROM Email Address configured for this feature may not be a valid sender based on your email service provider rules.') . '
        • ' . '
        ' . '

        ' . ts('Check this page for more information.', [ - 1 => CRM_Utils_System::docURL2('user/advanced-configuration/email-system-configuration', TRUE), - ]) . '

        '; + 1 => CRM_Utils_System::docURL2('user/advanced-configuration/email-system-configuration', TRUE), + ]) . '

        '; return $message; } diff --git a/CRM/Utils/Migrate/Export.php b/CRM/Utils/Migrate/Export.php index c6b372fc15d6..7497fb962a49 100644 --- a/CRM/Utils/Migrate/Export.php +++ b/CRM/Utils/Migrate/Export.php @@ -475,14 +475,14 @@ public function exportDAO($objectName, $object, $mappedFields) { // hack for extends_entity_column_value if ($name == 'extends_entity_column_value') { if (in_array($object->extends, [ - 'Event', - 'Activity', - 'Relationship', - 'Individual', - 'Organization', - 'Household', - 'Case', - ])) { + 'Event', + 'Activity', + 'Relationship', + 'Individual', + 'Organization', + 'Household', + 'Case', + ])) { if ($object->extends == 'Event') { $key = 'event_type'; } diff --git a/CRM/Utils/Migrate/ExportJSON.php b/CRM/Utils/Migrate/ExportJSON.php index b9adff788742..ffaa63065b77 100644 --- a/CRM/Utils/Migrate/ExportJSON.php +++ b/CRM/Utils/Migrate/ExportJSON.php @@ -434,9 +434,9 @@ public function relationship(&$contactIDs, &$additionalContacts) { $this->appendValue($dao->id, 'civicrm_relationship', $relationship); $this->addAdditionalContacts([ - $dao->contact_id_a, - $dao->contact_id_b, - ], + $dao->contact_id_a, + $dao->contact_id_b, + ], $additionalContacts ); } diff --git a/CRM/Utils/Migrate/Import.php b/CRM/Utils/Migrate/Import.php index 0a25d24bc7ab..340e10d51a6d 100644 --- a/CRM/Utils/Migrate/Import.php +++ b/CRM/Utils/Migrate/Import.php @@ -31,6 +31,7 @@ * @copyright CiviCRM LLC (c) 2004-2019 */ class CRM_Utils_Migrate_Import { + /** * Class constructor. */ diff --git a/CRM/Utils/Money.php b/CRM/Utils/Money.php index 77606d7061a4..ce15b9995bfa 100644 --- a/CRM/Utils/Money.php +++ b/CRM/Utils/Money.php @@ -35,7 +35,7 @@ * Money utilties */ class CRM_Utils_Money { - static $_currencySymbols = NULL; + public static $_currencySymbols = NULL; /** * Format a monetary string. @@ -87,9 +87,9 @@ public static function format($amount, $currency = NULL, $format = NULL, $onlyNu if (!self::$_currencySymbols) { self::$_currencySymbols = CRM_Core_PseudoConstant::get('CRM_Contribute_DAO_Contribution', 'currency', [ - 'keyColumn' => 'name', - 'labelColumn' => 'symbol', - ]); + 'keyColumn' => 'name', + 'labelColumn' => 'symbol', + ]); } if (!$currency) { diff --git a/CRM/Utils/Network.php b/CRM/Utils/Network.php index 0564590867a6..0a256816b047 100644 --- a/CRM/Utils/Network.php +++ b/CRM/Utils/Network.php @@ -34,6 +34,7 @@ * Simple static helpers for network operations */ class CRM_Utils_Network { + /** * Try connecting to a TCP service; if it fails, retry. Repeat until serverStartupTimeOut elapses. * diff --git a/CRM/Utils/Number.php b/CRM/Utils/Number.php index 619c8118d34e..02e31ad96a57 100644 --- a/CRM/Utils/Number.php +++ b/CRM/Utils/Number.php @@ -34,6 +34,7 @@ * Class CRM_Utils_Number */ class CRM_Utils_Number { + /** * Create a random number with a given precision. * @@ -64,13 +65,16 @@ public static function createRandomDecimal($precision) { public static function createTruncatedDecimal($keyValue, $precision) { list ($sigFigs, $decFigs) = $precision; $sign = ($keyValue < 0) ? '-1' : 1; - $val = str_replace('.', '', abs($keyValue)); // ex: -123.456 ==> 123456 - $val = substr($val, 0, $sigFigs); // ex: 123456 => 1234 + // ex: -123.456 ==> 123456 + $val = str_replace('.', '', abs($keyValue)); + // ex: 123456 => 1234 + $val = substr($val, 0, $sigFigs); // Move any extra digits after decimal $extraFigs = strlen($val) - ($sigFigs - $decFigs); if ($extraFigs > 0) { - return $sign * $val / pow(10, $extraFigs); // ex: 1234 => 1.234 + // ex: 1234 => 1.234 + return $sign * $val / pow(10, $extraFigs); } else { return $sign * $val; diff --git a/CRM/Utils/OpenFlashChart.php b/CRM/Utils/OpenFlashChart.php index 9f0b8f2db42e..26e34292ebfc 100644 --- a/CRM/Utils/OpenFlashChart.php +++ b/CRM/Utils/OpenFlashChart.php @@ -470,10 +470,10 @@ public static function chart($rows, $chart, $interval) { // carry some chart params if pass. foreach ([ - 'xSize', - 'ySize', - 'divName', - ] as $f) { + 'xSize', + 'ySize', + 'divName', + ] as $f) { if (!empty($rows[$f])) { $chartData[$f] = $rows[$f]; } @@ -510,10 +510,10 @@ public static function reportChart($rows, $chart, $interval, &$chartInfo) { // carry some chart params if pass. foreach ([ - 'xSize', - 'ySize', - 'divName', - ] as $f) { + 'xSize', + 'ySize', + 'divName', + ] as $f) { if (!empty($rows[$f])) { $chartData[$f] = $rows[$f]; } diff --git a/CRM/Utils/PDF/Document.php b/CRM/Utils/PDF/Document.php index 2fa43b4a4388..25490c9bb004 100644 --- a/CRM/Utils/PDF/Document.php +++ b/CRM/Utils/PDF/Document.php @@ -124,7 +124,8 @@ public static function printDoc($phpWord, $ext, $fileName) { $phpWord = \PhpOffice\PhpWord\IOFactory::load($fileName, $formats[$ext]); } - \PhpOffice\PhpWord\Settings::setOutputEscapingEnabled(TRUE); //CRM-20015 + //CRM-20015 + \PhpOffice\PhpWord\Settings::setOutputEscapingEnabled(TRUE); $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $formats[$ext]); CRM_Utils_System::setHttpHeader('Content-Type', "application/$ext"); @@ -147,7 +148,7 @@ public static function toTwip($value, $metric) { * @param string $type File type * * @return array - * Return extracted content of document in HTML and document type + * Return extracted content of document in HTML and document type */ public static function docReader($path, $type) { $type = array_search($type, CRM_Core_SelectValues::documentApplicationType()); diff --git a/CRM/Utils/PDF/Label.php b/CRM/Utils/PDF/Label.php index df5f935fb97f..1dc7caad170c 100644 --- a/CRM/Utils/PDF/Label.php +++ b/CRM/Utils/PDF/Label.php @@ -40,51 +40,120 @@ class CRM_Utils_PDF_Label extends TCPDF { // make these properties public due to // CRM-5880 - // Default label format values + /** + * Default label format values + * @var array + */ public $defaults; - // Current label format values + /** + * Current label format values + * @var array + */ public $format; - // Name of format + /** + * Name of format + * @var string + */ public $formatName; - // Left margin of labels + /** + * Left margin of labels + * @var float + */ public $marginLeft; - // Top margin of labels + /** + * Top margin of labels + * @var float + */ public $marginTop; - // Horizontal space between 2 labels + /** + * Horizontal space between 2 labels + * @var float + */ public $xSpace; - // Vertical space between 2 labels + /** + * Vertical space between 2 labels + * @var float + */ public $ySpace; - // Number of labels horizontally + /** + * Number of labels horizontally + * @var float + */ public $xNumber; - // Number of labels vertically + /** + * Number of labels vertically + * @var float + */ public $yNumber; - // Width of label + /** + * Width of label + * @var float + */ public $width; - // Height of label + /** + * Height of label + * @var float + */ public $height; - // Line Height of label - used in event code + /** + * Line Height of label - used in event code + * @var float + */ public $lineHeight = 0; - // Space between text and left edge of label + /** + * Space between text and left edge of label + * @var float + */ public $paddingLeft; - // Space between text and top edge of label + /** + * Space between text and top edge of label + * @var float + */ public $paddingTop; - // Character size (in points) + /** + * Character size (in points) + * @var float + */ public $charSize; - // Metric used for all PDF doc measurements + /** + * Metric used for all PDF doc measurements + * @var string + */ public $metricDoc; - // Name of the font + /** + * Name of the font + * @var string + */ public $fontName; - // 'B' bold, 'I' italic, 'BI' bold+italic + /** + * 'B' bold, 'I' italic, 'BI' bold+italic + * @var string + */ public $fontStyle; - // Paper size name + /** + * Paper size name + * @var string + */ public $paperSize; - // Paper orientation + /** + * Paper orientation + * @var string + */ public $orientation; - // Paper dimensions array (w, h) + /** + * Paper dimensions array (w, h) + * @var array + */ public $paper_dimensions; - // Counter for positioning labels + /** + * Counter for positioning labels + * @var float + */ public $countX = 0; - // Counter for positioning labels + /** + * Counter for positioning labels + * @var float + */ public $countY = 0; /** diff --git a/CRM/Utils/PDF/Utils.php b/CRM/Utils/PDF/Utils.php index 72c0d6c5bffe..7694dc24c748 100644 --- a/CRM/Utils/PDF/Utils.php +++ b/CRM/Utils/PDF/Utils.php @@ -28,6 +28,7 @@ use Dompdf\Dompdf; use Dompdf\Options; + /** * * @package CRM @@ -141,7 +142,8 @@ public static function _html2pdf_tcpdf($paper_size, $orientation, $margins, $htm // This function also uses the FPDI library documented at: http://www.setasign.com/products/fpdi/about/ // Syntax borrowed from https://github.com/jake-mw/CDNTaxReceipts/blob/master/cdntaxreceipts.functions.inc require_once 'tcpdf/tcpdf.php'; - require_once 'FPDI/fpdi.php'; // This library is only in the 'packages' area as of version 4.5 + // This library is only in the 'packages' area as of version 4.5 + require_once 'FPDI/fpdi.php'; $paper_size_arr = [$paper_size[2], $paper_size[3]]; diff --git a/CRM/Utils/Pager.php b/CRM/Utils/Pager.php index 74f8afee2da9..390764d766ac 100644 --- a/CRM/Utils/Pager.php +++ b/CRM/Utils/Pager.php @@ -112,13 +112,13 @@ public function __construct($params) { * page variable, but a different form element for one at the bottom. */ $this->_response['titleTop'] = ts('Page %1 of %2', [ - 1 => '', - 2 => $this->_response['numPages'], - ]); + 1 => '', + 2 => $this->_response['numPages'], + ]); $this->_response['titleBottom'] = ts('Page %1 of %2', [ - 1 => '', - 2 => $this->_response['numPages'], - ]); + 1 => '', + 2 => $this->_response['numPages'], + ]); } /** diff --git a/CRM/Utils/PseudoConstant.php b/CRM/Utils/PseudoConstant.php index 4ccbdba0dedf..7a3cf0d54768 100644 --- a/CRM/Utils/PseudoConstant.php +++ b/CRM/Utils/PseudoConstant.php @@ -36,6 +36,7 @@ class CRM_Utils_PseudoConstant { /** * CiviCRM pseudoconstant classes for wrapper functions. + * @var array */ private static $constantClasses = [ 'CRM_Core_PseudoConstant', diff --git a/CRM/Utils/QueryFormatter.php b/CRM/Utils/QueryFormatter.php index 863226ea15ad..9c4b49ee59be 100644 --- a/CRM/Utils/QueryFormatter.php +++ b/CRM/Utils/QueryFormatter.php @@ -88,6 +88,9 @@ class CRM_Utils_QueryFormatter { */ const MODE_WILDWORDS_SUFFIX = 'wildwords-suffix'; + /** + * @var \CRM_Utils_QueryFormatter|NULL + */ static protected $singleton; /** @@ -407,8 +410,8 @@ protected function mapWords($text, $template, $quotes = FALSE) { } /** - * @param $text - * @bool $quotes + * @param string $text + * @param bool $quotes * @return array */ protected function parseWords($text, $quotes) { diff --git a/CRM/Utils/REST.php b/CRM/Utils/REST.php index 52e7e5296484..b1df33aee17c 100644 --- a/CRM/Utils/REST.php +++ b/CRM/Utils/REST.php @@ -35,11 +35,13 @@ class CRM_Utils_REST { /** * Number of seconds we should let a REST process idle + * @var int */ - static $rest_timeout = 0; + public static $rest_timeout = 0; /** * Cache the actual UF Class + * @var string */ public $ufClass; @@ -399,8 +401,10 @@ public static function loadTemplate() { CRM_Utils_System::setHttpHeader("Status", "404 Not Found"); die("Can't find the requested template file templates/$tpl"); } - if (array_key_exists('id', $_GET)) {// special treatmenent, because it's often used - $smarty->assign('id', (int) $_GET['id']);// an id is always positive + // special treatmenent, because it's often used + if (array_key_exists('id', $_GET)) { + // an id is always positive + $smarty->assign('id', (int) $_GET['id']); } $pos = strpos(implode(array_keys($_GET)), '<'); @@ -480,7 +484,8 @@ public static function ajaxJson() { $params['check_permissions'] = TRUE; $params['version'] = 3; - $_GET['json'] = $requestParams['json'] = 1; // $requestParams is local-only; this line seems pointless unless there's a side-effect influencing other functions + // $requestParams is local-only; this line seems pointless unless there's a side-effect influencing other functions + $_GET['json'] = $requestParams['json'] = 1; if (!$params['sequential']) { $params['sequential'] = 1; } @@ -597,7 +602,8 @@ public function loadCMSBootstrap() { if (!empty($q)) { if (count($args) == 2 && $args[1] == 'ping') { CRM_Utils_System::loadBootStrap([], FALSE, FALSE); - return NULL; // this is pretty wonky but maybe there's some reason I can't see + // this is pretty wonky but maybe there's some reason I can't see + return NULL; } if (count($args) != 3) { return self::error('ERROR: Malformed REST path'); diff --git a/CRM/Utils/ReCAPTCHA.php b/CRM/Utils/ReCAPTCHA.php index d1afe457a1c7..31980430149b 100644 --- a/CRM/Utils/ReCAPTCHA.php +++ b/CRM/Utils/ReCAPTCHA.php @@ -62,7 +62,6 @@ public static function &singleton() { return self::$_singleton; } - /** * Check if reCaptcha settings is avilable to add on form. */ diff --git a/CRM/Utils/Request.php b/CRM/Utils/Request.php index a435d65a7cf8..2f55cea32c37 100644 --- a/CRM/Utils/Request.php +++ b/CRM/Utils/Request.php @@ -146,7 +146,7 @@ public static function retrieve($name, $type, &$store = NULL, $abort = FALSE, $d * @param array $method - '$_GET', '$_POST' or '$_REQUEST'. * * @return mixed - * The value of the variable + * The value of the variable */ protected static function getValue($name, $method) { if (isset($method[$name])) { @@ -235,7 +235,7 @@ public static function retrieveValue($name, $type, $defaultValue = NULL, $isRequ * @param array $attributes * The form attributes array. * - * @return string $value + * @return string * The desired value. */ public static function retrieveComponent($attributes) { diff --git a/CRM/Utils/SQL/BaseParamQuery.php b/CRM/Utils/SQL/BaseParamQuery.php index c2a61422b3d9..f48d05556c6d 100644 --- a/CRM/Utils/SQL/BaseParamQuery.php +++ b/CRM/Utils/SQL/BaseParamQuery.php @@ -36,11 +36,20 @@ class CRM_Utils_SQL_BaseParamQuery implements ArrayAccess { */ const INTERPOLATE_AUTO = 'auto'; + /** + * @var mixed + */ protected $mode = NULL; + /** + * @var array + */ protected $params = []; - // Public to work-around PHP 5.3 limit. + /** + * Public to work-around PHP 5.3 limit. + * @var bool + */ public $strict = NULL; /** diff --git a/CRM/Utils/SQL/Insert.php b/CRM/Utils/SQL/Insert.php index c06bd601c1bf..816c89f605d0 100644 --- a/CRM/Utils/SQL/Insert.php +++ b/CRM/Utils/SQL/Insert.php @@ -36,6 +36,7 @@ class CRM_Utils_SQL_Insert { /** * Array list of column names + * @var array */ private $columns; @@ -62,7 +63,8 @@ public static function dao(CRM_Core_DAO $dao) { $row = []; foreach ((array) $dao as $key => $value) { if ($value === 'null') { - $value = NULL; // Blerg!!! + // Blerg!!! + $value = NULL; } // Skip '_foobar' and '{\u00}*_options' and 'N'. if (preg_match('/[a-zA-Z]/', $key{0}) && $key !== 'N') { diff --git a/CRM/Utils/SQL/Select.php b/CRM/Utils/SQL/Select.php index 87190c69d200..bdb892ed4d9e 100644 --- a/CRM/Utils/SQL/Select.php +++ b/CRM/Utils/SQL/Select.php @@ -389,7 +389,6 @@ public function replaceInto($table, $fields = []) { return $this->insertInto($table, $fields); } - /** * @param array $fields * The fields to fill in the other table (in order). diff --git a/CRM/Utils/SQL/TempTable.php b/CRM/Utils/SQL/TempTable.php index 1cf5d81f7879..5433b17c416b 100644 --- a/CRM/Utils/SQL/TempTable.php +++ b/CRM/Utils/SQL/TempTable.php @@ -70,7 +70,8 @@ class CRM_Utils_SQL_TempTable { const UTF8 = 'DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci'; const CATEGORY_LENGTH = 12; const CATEGORY_REGEXP = ';^[a-zA-Z0-9]+$;'; - const ID_LENGTH = 37; // MAX{64} - CATEGORY_LENGTH{12} - CONST_LENGHTH{15} = 37 + // MAX{64} - CATEGORY_LENGTH{12} - CONST_LENGHTH{15} = 37 + const ID_LENGTH = 37; const ID_REGEXP = ';^[a-zA-Z0-9_]+$;'; const INNODB = 'ENGINE=InnoDB'; const MEMORY = 'ENGINE=MEMORY'; @@ -78,7 +79,12 @@ class CRM_Utils_SQL_TempTable { /** * @var bool */ - protected $durable, $utf8; + protected $durable; + + /** + * @var bool + */ + protected $utf8; protected $category; diff --git a/CRM/Utils/Signer.php b/CRM/Utils/Signer.php index 6e906392aaf6..6323b8931d7d 100644 --- a/CRM/Utils/Signer.php +++ b/CRM/Utils/Signer.php @@ -64,10 +64,12 @@ class CRM_Utils_Signer { * Array, fields which should be part of the signature. */ public function __construct($secret, $paramNames) { - sort($paramNames); // ensure consistent serialization of payloads + // ensure consistent serialization of payloads + sort($paramNames); $this->secret = $secret; $this->paramNames = $paramNames; - $this->signDelim = "_"; // chosen to be valid in URLs but not in salt or md5 + // chosen to be valid in URLs but not in salt or md5 + $this->signDelim = "_"; $this->defaultSalt = CRM_Utils_String::createRandom(self::SALT_LEN, CRM_Utils_String::ALPHANUMERIC); } diff --git a/CRM/Utils/SoapServer.php b/CRM/Utils/SoapServer.php index 104436ceee43..395cd549ebd9 100644 --- a/CRM/Utils/SoapServer.php +++ b/CRM/Utils/SoapServer.php @@ -35,11 +35,13 @@ class CRM_Utils_SoapServer { /** * Number of seconds we should let a soap process idle + * @var int */ - static $soap_timeout = 0; + public static $soap_timeout = 0; /** * Cache the actual UF Class + * @var string */ public $ufClass; diff --git a/CRM/Utils/String.php b/CRM/Utils/String.php index d01dd52a000c..c740e72a1f38 100644 --- a/CRM/Utils/String.php +++ b/CRM/Utils/String.php @@ -625,7 +625,6 @@ public static function stripPathChars( return str_replace($search, $replace, $string); } - /** * Use HTMLPurifier to clean up a text string and remove any potential * xss attacks. This is primarily used in public facing pages which diff --git a/CRM/Utils/System.php b/CRM/Utils/System.php index 64c035bde618..1ac8d03d0be2 100644 --- a/CRM/Utils/System.php +++ b/CRM/Utils/System.php @@ -54,13 +54,13 @@ */ class CRM_Utils_System { - static $_callbacks = NULL; + public static $_callbacks = NULL; /** * @var string * Page title */ - static $title = ''; + public static $title = ''; /** * Access methods in the appropriate CMS class @@ -103,8 +103,7 @@ public static function makeURL($urlVar, $includeReset = FALSE, $includeForce = T } } - return - self::url( + return self::url( $path, CRM_Utils_System::getLinksUrl($urlVar, $includeReset, $includeForce), $absolute @@ -688,7 +687,6 @@ public static function setUFMessage($message) { return $config->userSystem->setMessage($message); } - /** * Determine whether a value is null-ish. * @@ -1168,8 +1166,7 @@ public static function getRequestHeaders() { * this function, please go and change the code in the install script as well. */ public static function isSSL() { - return - (isset($_SERVER['HTTPS']) && + return (isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off') ? TRUE : FALSE; } diff --git a/CRM/Utils/System/Base.php b/CRM/Utils/System/Base.php index 3f99ae6af942..bf6830d8e49f 100644 --- a/CRM/Utils/System/Base.php +++ b/CRM/Utils/System/Base.php @@ -11,44 +11,44 @@ abstract class CRM_Utils_System_Base { * The correct method is to have functions on the UF classes for all UF specific * functions and leave the codebase oblivious to the type of CMS * - * @deprecated * @var bool + * @deprecated * TRUE, if the CMS is Drupal. */ - var $is_drupal = FALSE; + public $is_drupal = FALSE; /** * Deprecated property to check if this is a joomla install. The correct method is to have functions on the UF classes for all UF specific * functions and leave the codebase oblivious to the type of CMS * - * @deprecated * @var bool + * @deprecated * TRUE, if the CMS is Joomla!. */ - var $is_joomla = FALSE; + public $is_joomla = FALSE; /** * deprecated property to check if this is a wordpress install. The correct method is to have functions on the UF classes for all UF specific * functions and leave the codebase oblivious to the type of CMS * - * @deprecated * @var bool + * @deprecated * TRUE, if the CMS is WordPress. */ - var $is_wordpress = FALSE; + public $is_wordpress = FALSE; /** * Does this CMS / UF support a CMS specific logging mechanism? - * @todo - we should think about offering up logging mechanisms in a way that is also extensible by extensions * @var bool + * @todo - we should think about offering up logging mechanisms in a way that is also extensible by extensions */ - var $supports_UF_Logging = FALSE; + public $supports_UF_Logging = FALSE; /** * @var bool * TRUE, if the CMS allows CMS forms to be extended by hooks. */ - var $supports_form_extensions = FALSE; + public $supports_form_extensions = FALSE; public function initialize() { if (\CRM_Utils_System::isSSL()) { @@ -56,7 +56,7 @@ public function initialize() { } } - public abstract function loadBootStrap($params = [], $loadUser = TRUE, $throwError = TRUE, $realPath = NULL); + abstract public function loadBootStrap($params = [], $loadUser = TRUE, $throwError = TRUE, $realPath = NULL); /** * Append an additional breadcrumb tag to the existing breadcrumb. @@ -424,7 +424,7 @@ public function isPasswordUserGenerated() { * @return string * loginURL for the current CMS */ - public abstract function getLoginURL($destination = ''); + abstract public function getLoginURL($destination = ''); /** * Get the login destination string. @@ -710,7 +710,6 @@ public function setMySQLTimeZone() { } } - /** * Get timezone from CMS. * diff --git a/CRM/Utils/System/DrupalBase.php b/CRM/Utils/System/DrupalBase.php index e9061b5698ad..75d04ca71252 100644 --- a/CRM/Utils/System/DrupalBase.php +++ b/CRM/Utils/System/DrupalBase.php @@ -40,10 +40,10 @@ abstract class CRM_Utils_System_DrupalBase extends CRM_Utils_System_Base { /** * Does this CMS / UF support a CMS specific logging mechanism? - * @todo - we should think about offering up logging mechanisms in a way that is also extensible by extensions * @var bool + * @todo - we should think about offering up logging mechanisms in a way that is also extensible by extensions */ - var $supports_UF_Logging = TRUE; + public $supports_UF_Logging = TRUE; /** */ @@ -266,10 +266,10 @@ public function permissionDenied() { public function getUserRecordUrl($contactID) { $uid = CRM_Core_BAO_UFMatch::getUFId($contactID); if (CRM_Core_Session::singleton() - ->get('userID') == $contactID || CRM_Core_Permission::checkAnyPerm([ - 'cms:administer users', - 'cms:view user account', - ]) + ->get('userID') == $contactID || CRM_Core_Permission::checkAnyPerm([ + 'cms:administer users', + 'cms:view user account', + ]) ) { return $this->url('user/' . $uid); }; diff --git a/CRM/Utils/System/Joomla.php b/CRM/Utils/System/Joomla.php index 827493037b78..f98c794adfeb 100644 --- a/CRM/Utils/System/Joomla.php +++ b/CRM/Utils/System/Joomla.php @@ -35,6 +35,7 @@ * Joomla specific stuff goes here. */ class CRM_Utils_System_Joomla extends CRM_Utils_System_Base { + /** * Class constructor. */ @@ -317,8 +318,8 @@ public function setEmail(&$user) { global $database; $query = $db->getQuery(TRUE); $query->select($db->quoteName('email')) - ->from($db->quoteName('#__users')) - ->where($db->quoteName('id') . ' = ' . $user->id); + ->from($db->quoteName('#__users')) + ->where($db->quoteName('id') . ' = ' . $user->id); $database->setQuery($query); $user->email = $database->loadResult(); } diff --git a/CRM/Utils/System/Soap.php b/CRM/Utils/System/Soap.php index 468584843462..2edca70da7be 100644 --- a/CRM/Utils/System/Soap.php +++ b/CRM/Utils/System/Soap.php @@ -38,9 +38,10 @@ class CRM_Utils_System_Soap extends CRM_Utils_System_Base { /** * UF container variables. + * @var string */ - static $uf = NULL; - static $ufClass = NULL; + public static $uf = NULL; + public static $ufClass = NULL; /** * Given a permission string, check for access requirements diff --git a/CRM/Utils/System/UnitTests.php b/CRM/Utils/System/UnitTests.php index b1344e67231b..4882bbdb760e 100644 --- a/CRM/Utils/System/UnitTests.php +++ b/CRM/Utils/System/UnitTests.php @@ -37,6 +37,7 @@ * Helper authentication class for unit tests */ class CRM_Utils_System_UnitTests extends CRM_Utils_System_Base { + /** */ public function __construct() { diff --git a/CRM/Utils/System/WordPress.php b/CRM/Utils/System/WordPress.php index 544909985505..a188cff50138 100644 --- a/CRM/Utils/System/WordPress.php +++ b/CRM/Utils/System/WordPress.php @@ -37,6 +37,7 @@ * WordPress specific stuff goes here */ class CRM_Utils_System_WordPress extends CRM_Utils_System_Base { + /** */ public function __construct() { @@ -460,6 +461,9 @@ public function setUFLocale($civicrm_language) { * Optional credentials * - name: string, cms username * - pass: string, cms password + * @param bool $loadUser + * @param bool $throwError + * @param mixed $realPath * * @return bool */ @@ -788,7 +792,7 @@ public function getTimeZoneString() { public function getUserRecordUrl($contactID) { $uid = CRM_Core_BAO_UFMatch::getUFId($contactID); if (CRM_Core_Session::singleton() - ->get('userID') == $contactID || CRM_Core_Permission::checkAnyPerm(['cms:administer users']) + ->get('userID') == $contactID || CRM_Core_Permission::checkAnyPerm(['cms:administer users']) ) { return CRM_Core_Config::singleton()->userFrameworkBaseURL . "wp-admin/user-edit.php?user_id=" . $uid; } diff --git a/CRM/Utils/SystemLogger.php b/CRM/Utils/SystemLogger.php index aed051884683..641058894140 100644 --- a/CRM/Utils/SystemLogger.php +++ b/CRM/Utils/SystemLogger.php @@ -31,6 +31,7 @@ * @copyright CiviCRM LLC (c) 2004-2019 */ class CRM_Utils_SystemLogger extends Psr\Log\AbstractLogger implements \Psr\Log\LoggerInterface { + /** * Logs with an arbitrary level. * diff --git a/CRM/Utils/Token.php b/CRM/Utils/Token.php index 89d67e0c5b9a..d9014d7760ae 100644 --- a/CRM/Utils/Token.php +++ b/CRM/Utils/Token.php @@ -35,9 +35,9 @@ * Class to abstract token replacement. */ class CRM_Utils_Token { - static $_requiredTokens = NULL; + public static $_requiredTokens = NULL; - static $_tokens = [ + public static $_tokens = [ 'action' => [ 'forward', 'optOut', @@ -88,7 +88,6 @@ class CRM_Utils_Token { 'welcome' => ['group'], ]; - /** * @deprecated * This is used by CiviMail but will be made redundant by FlexMailer. @@ -116,7 +115,7 @@ public static function getRequiredTokens() { * The message. * * @return bool|array - * true if all required tokens are found, + * true if all required tokens are found, * else an array of the missing tokens */ public static function requiredTokens(&$str) { @@ -178,7 +177,7 @@ public static function token_match($type, $var, &$str) { * The token variable. * @param string $value * The value to substitute for the token. - * @param string (reference) $str The string to replace in + * @param string $str (reference) The string to replace in * * @param bool $escapeSmarty * @@ -1260,10 +1259,10 @@ public static function getTokenDetails( // special case for greeting replacement foreach ([ - 'email_greeting', - 'postal_greeting', - 'addressee', - ] as $val) { + 'email_greeting', + 'postal_greeting', + 'addressee', + ] as $val) { if (!empty($contactDetails[$contactID][$val])) { $contactDetails[$contactID][$val] = $contactDetails[$contactID]["{$val}_display"]; } @@ -1300,8 +1299,8 @@ public static function getTokenDetails( * contactDetails with hooks swapped out */ public static function getAnonymousTokenDetails($contactIDs = [ - 0, - ], + 0, + ], $returnProperties = NULL, $skipOnHold = TRUE, $skipDeceased = TRUE, @@ -1432,6 +1431,7 @@ public static function replaceGreetingTokens(&$tokenString, $contactDetails = NU * * @param string $tokenString * @param array $contactDetails + * @param array $greetingTokens */ private static function removeNullContactTokens(&$tokenString, $contactDetails, &$greetingTokens) { $greetingTokensOriginal = $greetingTokens; @@ -1477,10 +1477,10 @@ public static function flattenTokens(&$tokens) { $flattenTokens = []; foreach ([ - 'html', - 'text', - 'subject', - ] as $prop) { + 'html', + 'text', + 'subject', + ] as $prop) { if (!isset($tokens[$prop])) { continue; } @@ -1676,7 +1676,8 @@ public static function getApiTokenReplacement($entity, $token, $entityArray) { public static function replaceContributionTokens($str, &$contribution, $html = FALSE, $knownTokens = NULL, $escapeSmarty = FALSE) { $key = 'contribution'; if (!$knownTokens || !CRM_Utils_Array::value($key, $knownTokens)) { - return $str; //early return + //early return + return $str; } self::_buildContributionTokens(); @@ -1759,9 +1760,9 @@ public static function getMembershipTokenReplacement($entity, $token, $membershi case 'fee': try { $value = civicrm_api3('membership_type', 'getvalue', [ - 'id' => $membership['membership_type_id'], - 'return' => 'minimum_fee', - ]); + 'id' => $membership['membership_type_id'], + 'return' => 'minimum_fee', + ]); $value = CRM_Utils_Money::format($value, NULL, NULL, TRUE); } catch (CiviCRM_API3_Exception $e) { @@ -1847,7 +1848,7 @@ public static function legacyContactTokens() { * @param string $entity * @param bool $usedForTokenWidget * - * @return array $customTokens + * @return array * return custom field tokens in array('custom_N' => 'label') format */ public static function getCustomFieldTokens($entity, $usedForTokenWidget = FALSE) { diff --git a/CRM/Utils/Url.php b/CRM/Utils/Url.php index 314df438d662..4396263aacef 100644 --- a/CRM/Utils/Url.php +++ b/CRM/Utils/Url.php @@ -35,7 +35,7 @@ class CRM_Utils_Url { * * @param string $url * - * @return UriInterface + * @return \GuzzleHttp\Psr7\UriInterface */ public static function parseUrl($url) { return new Uri($url); @@ -44,7 +44,7 @@ public static function parseUrl($url) { /** * Unparse url back to a string. * - * @param UriInterface $parsed + * @param \GuzzleHttp\Psr7\UriInterface $parsed * * @return string */ diff --git a/CRM/Utils/Verp.php b/CRM/Utils/Verp.php index 87600a04ef63..a9d5140c3cdd 100644 --- a/CRM/Utils/Verp.php +++ b/CRM/Utils/Verp.php @@ -33,9 +33,11 @@ * @copyright CiviCRM LLC (c) 2004-2019 */ class CRM_Utils_Verp { - /* Mapping of reserved characters to hex codes */ - - static $encodeMap = [ + /** + * Mapping of reserved characters to hex codes + * @var array + */ + public static $encodeMap = [ '+' => '2B', '@' => '40', ':' => '3A', @@ -46,9 +48,11 @@ class CRM_Utils_Verp { ']' => '5D', ]; - /* Mapping of hex codes to reserved characters */ - - static $decodeMap = [ + /** + * Mapping of hex codes to reserved characters + * @var array + */ + public static $decodeMap = [ '40' => '@', '3A' => ':', '25' => '%', diff --git a/CRM/Utils/Weight.php b/CRM/Utils/Weight.php index 5fcc2a8162d8..3e4add68b7cf 100644 --- a/CRM/Utils/Weight.php +++ b/CRM/Utils/Weight.php @@ -35,8 +35,9 @@ class CRM_Utils_Weight { * To reduce the size of this patch, we only sign the exploitable fields * which make up "$baseURL" in addOrder() (eg 'filter' or 'dao'). * Less-exploitable fields (eg 'dir') are left unsigned. + * 'id','src','dst','dir' */ - static $SIGNABLE_FIELDS = ['reset', 'dao', 'idName', 'url', 'filter']; // 'id','src','dst','dir' + public static $SIGNABLE_FIELDS = ['reset', 'dao', 'idName', 'url', 'filter']; /** * Correct duplicate weight entries by putting them (duplicate weights) in sequence. diff --git a/CRM/Utils/Wrapper.php b/CRM/Utils/Wrapper.php index 7d17e1028aa8..df9b8a8f32f8 100644 --- a/CRM/Utils/Wrapper.php +++ b/CRM/Utils/Wrapper.php @@ -41,6 +41,7 @@ class CRM_Utils_Wrapper { * Simple Controller. * * The controller which will handle the display and processing of this page. + * @var \CRM_Core_Controller_Simple object */ protected $_controller; diff --git a/CRM/Utils/XML.php b/CRM/Utils/XML.php index 7eaa32040e29..daaf0a677259 100644 --- a/CRM/Utils/XML.php +++ b/CRM/Utils/XML.php @@ -40,8 +40,10 @@ class CRM_Utils_XML { * (0 => SimpleXMLElement|FALSE, 1 => errorMessage|FALSE) */ public static function parseFile($file) { - $xml = FALSE; // SimpleXMLElement - $error = FALSE; // string + // SimpleXMLElement + $xml = FALSE; + // string + $error = FALSE; if (!file_exists($file)) { $error = 'File ' . $file . ' does not exist.'; @@ -72,8 +74,10 @@ public static function parseFile($file) { * (0 => SimpleXMLElement|FALSE, 1 => errorMessage|FALSE) */ public static function parseString($string) { - $xml = FALSE; // SimpleXMLElement - $error = FALSE; // string + // SimpleXMLElement + $xml = FALSE; + // string + $error = FALSE; $oldLibXMLErrors = libxml_use_internal_errors(); libxml_use_internal_errors(TRUE); diff --git a/CRM/Utils/Zip.php b/CRM/Utils/Zip.php index b0cb93835ac0..2ef4c7915d00 100644 --- a/CRM/Utils/Zip.php +++ b/CRM/Utils/Zip.php @@ -44,7 +44,7 @@ class CRM_Utils_Zip { * @return mixed * FALSE if #root level items !=1; otherwise, the name of base dir */ - static public function findBaseDirName(ZipArchive $zip) { + public static function findBaseDirName(ZipArchive $zip) { $cnt = $zip->numFiles; $base = FALSE; @@ -77,7 +77,7 @@ static public function findBaseDirName(ZipArchive $zip) { * @return array(string) * no trailing / */ - static public function findBaseDirs(ZipArchive $zip) { + public static function findBaseDirs(ZipArchive $zip) { $cnt = $zip->numFiles; $basedirs = []; @@ -101,7 +101,7 @@ static public function findBaseDirs(ZipArchive $zip) { * @return string|bool * Return string or FALSE */ - static public function guessBasedir(ZipArchive $zip, $expected) { + public static function guessBasedir(ZipArchive $zip, $expected) { $candidate = FALSE; $basedirs = CRM_Utils_Zip::findBaseDirs($zip); if (in_array($expected, $basedirs)) { @@ -118,7 +118,6 @@ static public function guessBasedir(ZipArchive $zip, $expected) { } } - /** * An inefficient helper for creating a ZIP file from data in memory. * This is only intended for building temp files for unit-testing. @@ -131,7 +130,7 @@ static public function guessBasedir(ZipArchive $zip, $expected) { * Array, keys are file names and values are file contents. * @return bool */ - static public function createTestZip($zipName, $dirs, $files) { + public static function createTestZip($zipName, $dirs, $files) { $zip = new ZipArchive(); $res = $zip->open($zipName, ZipArchive::CREATE); if ($res === TRUE) { From c86d4e7c0607f85961b5b94a98a47cf3bf3ae44f Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Sun, 7 Apr 2019 13:44:57 +1000 Subject: [PATCH 099/121] (NFC) Update coding style in PCP, Pledge, Profile, Queue, Report folders --- CRM/PCP/BAO/PCP.php | 3 +- CRM/PCP/Form/Event.php | 7 ++--- CRM/PCP/Form/PCP.php | 6 ++-- CRM/PCP/Form/PCPAccount.php | 3 +- CRM/PCP/Page/PCP.php | 2 +- CRM/Pledge/BAO/Pledge.php | 11 +++---- CRM/Pledge/BAO/Query.php | 1 + CRM/Pledge/Form/Payment.php | 3 +- CRM/Pledge/Form/Pledge.php | 31 ++++++++++--------- CRM/Pledge/Form/PledgeView.php | 3 +- CRM/Pledge/Form/Search.php | 1 + CRM/Pledge/Form/Task.php | 3 +- CRM/Pledge/Form/Task/Print.php | 3 +- CRM/Pledge/Form/Task/Result.php | 3 +- CRM/Pledge/Form/Task/SearchTaskHookSample.php | 3 +- CRM/Pledge/Info.php | 2 +- CRM/Pledge/Selector/Search.php | 6 ++-- CRM/Pledge/Task.php | 2 +- CRM/Profile/Form.php | 4 ++- CRM/Profile/Page/Dynamic.php | 5 ++- CRM/Profile/Page/Listings.php | 1 + .../Page/MultipleRecordFieldsListing.php | 2 +- CRM/Profile/Selector/Listings.php | 5 +-- CRM/Queue/ErrorPolicy.php | 16 +++++----- CRM/Queue/Queue.php | 20 ++++++------ CRM/Queue/Runner.php | 5 ++- CRM/Report/DAO/ReportInstance.php | 4 +-- CRM/Report/Form.php | 30 ++++++++++-------- CRM/Report/Form/Campaign/SurveyDetails.php | 17 +++++----- CRM/Report/Form/Case/Detail.php | 3 +- CRM/Report/Form/Contact/LoggingDetail.php | 1 + CRM/Report/Form/Contact/LoggingSummary.php | 1 + CRM/Report/Form/Contribute/Bookkeeping.php | 9 +++--- .../Form/Contribute/DeferredRevenue.php | 1 + CRM/Report/Form/Contribute/History.php | 7 ++++- CRM/Report/Form/Contribute/Lybunt.php | 6 ++-- CRM/Report/Form/Contribute/Recur.php | 1 - CRM/Report/Form/Contribute/RecurSummary.php | 1 + CRM/Report/Form/Contribute/Repeat.php | 2 +- CRM/Report/Form/Contribute/Summary.php | 11 ++++--- CRM/Report/Form/Event/ParticipantListing.php | 3 +- CRM/Report/Form/Extended.php | 4 +-- CRM/Report/Form/Instance.php | 3 +- CRM/Report/Form/Mailing/Summary.php | 6 ++-- CRM/Report/Form/Membership/Summary.php | 8 ++--- CRM/Report/Form/Pledge/Detail.php | 6 ++-- CRM/Report/Form/Pledge/Pbnp.php | 8 ++--- CRM/Report/Form/Register.php | 12 +++---- CRM/Report/Info.php | 7 +++-- CRM/Report/Page/Instance.php | 1 + CRM/Report/Page/InstanceList.php | 6 ++-- CRM/Report/Page/Options.php | 8 ++--- 52 files changed, 169 insertions(+), 148 deletions(-) diff --git a/CRM/PCP/BAO/PCP.php b/CRM/PCP/BAO/PCP.php index f5674c558bff..367fa10429a3 100644 --- a/CRM/PCP/BAO/PCP.php +++ b/CRM/PCP/BAO/PCP.php @@ -37,7 +37,7 @@ class CRM_PCP_BAO_PCP extends CRM_PCP_DAO_PCP { * * @var array */ - static $_pcpLinks = NULL; + public static $_pcpLinks = NULL; /** * Class constructor. @@ -407,7 +407,6 @@ public static function buildPCPForm($form) { $form->add('text', 'notify_email', ts('Notify Email'), CRM_Core_DAO::getAttribute('CRM_PCP_DAO_PCPBlock', 'notify_email')); } - /** * Add PCP form elements to a form. * diff --git a/CRM/PCP/Form/Event.php b/CRM/PCP/Form/Event.php index 0be13e2b77cd..da7802382bd5 100644 --- a/CRM/PCP/Form/Event.php +++ b/CRM/PCP/Form/Event.php @@ -46,7 +46,6 @@ class CRM_PCP_Form_Event extends CRM_Event_Form_ManageEvent { */ public $_component = 'event'; - public function preProcess() { parent::preProcess(); $this->assign('selectedChild', 'pcp'); @@ -120,9 +119,9 @@ public function buildQuickForm() { if (!empty($pcpBlock->id) && CRM_PCP_BAO_PCP::getPcpBlockInUse($pcpBlock->id)) { foreach ([ - 'target_entity_type', - 'target_entity_id', - ] as $element_name) { + 'target_entity_type', + 'target_entity_id', + ] as $element_name) { $element = $this->getElement($element_name); $element->freeze(); } diff --git a/CRM/PCP/Form/PCP.php b/CRM/PCP/Form/PCP.php index cf0550415267..ff39071278fb 100644 --- a/CRM/PCP/Form/PCP.php +++ b/CRM/PCP/Form/PCP.php @@ -145,8 +145,7 @@ public function buildQuickForm() { 'type' => 'cancel', 'name' => ts('Cancel'), ], - ] - ); + ]); } else { @@ -170,8 +169,7 @@ public function buildQuickForm() { 'spacing' => '         ', 'isDefault' => TRUE, ], - ] - ); + ]); parent::buildQuickForm(); } } diff --git a/CRM/PCP/Form/PCPAccount.php b/CRM/PCP/Form/PCPAccount.php index 84c9b316a1ae..ccac09cf5496 100644 --- a/CRM/PCP/Form/PCPAccount.php +++ b/CRM/PCP/Form/PCPAccount.php @@ -40,6 +40,7 @@ class CRM_PCP_Form_PCPAccount extends CRM_Core_Form { /** * Variable defined for Contribution Page Id. + * @var int */ public $_pageId = NULL; public $_id = NULL; @@ -265,7 +266,7 @@ public function postProcess() { } } - $this->_contactID = CRM_Contact_BAO_Contact::getFirstDuplicateContact($params, 'Individual', 'Unsupervised', [], FALSE); + $this->_contactID = CRM_Contact_BAO_Contact::getFirstDuplicateContact($params, 'Individual', 'Unsupervised', [], FALSE); $contactID = CRM_Contact_BAO_Contact::createProfileContact($params, $this->_fields, $this->_contactID); $this->set('contactID', $contactID); diff --git a/CRM/PCP/Page/PCP.php b/CRM/PCP/Page/PCP.php index 32f828d4f14b..58768df2e0ad 100644 --- a/CRM/PCP/Page/PCP.php +++ b/CRM/PCP/Page/PCP.php @@ -43,7 +43,7 @@ class CRM_PCP_Page_PCP extends CRM_Core_Page_Basic { * * @var array */ - static $_links = NULL; + public static $_links = NULL; /** * Get BAO Name. diff --git a/CRM/Pledge/BAO/Pledge.php b/CRM/Pledge/BAO/Pledge.php index f934eb63bbea..62b4dfa74043 100644 --- a/CRM/Pledge/BAO/Pledge.php +++ b/CRM/Pledge/BAO/Pledge.php @@ -37,7 +37,7 @@ class CRM_Pledge_BAO_Pledge extends CRM_Pledge_DAO_Pledge { * * @var array */ - static $_exportableFields = NULL; + public static $_exportableFields = NULL; /** * Class constructor. @@ -798,10 +798,10 @@ public static function getContactPledges($contactID) { // get pending and in progress status foreach (array( - 'Pending', - 'In Progress', - 'Overdue', - ) as $name) { + 'Pending', + 'In Progress', + 'Overdue', + ) as $name) { if ($statusId = array_search($name, $pledgeStatuses)) { $status[] = $statusId; } @@ -1174,7 +1174,6 @@ protected static function getNonTransactionalStatus() { return array_flip(array_intersect($paymentStatus, array('Overdue', 'Pending'))); } - /** * Create array for recur record for pledge. * @return array diff --git a/CRM/Pledge/BAO/Query.php b/CRM/Pledge/BAO/Query.php index 960d67c29d6a..902872d1c1b3 100644 --- a/CRM/Pledge/BAO/Query.php +++ b/CRM/Pledge/BAO/Query.php @@ -31,6 +31,7 @@ * @copyright CiviCRM LLC (c) 2004-2019 */ class CRM_Pledge_BAO_Query extends CRM_Core_BAO_Query { + /** * Get pledge fields. * diff --git a/CRM/Pledge/Form/Payment.php b/CRM/Pledge/Form/Payment.php index d56b4907bfac..ea24635c075b 100644 --- a/CRM/Pledge/Form/Payment.php +++ b/CRM/Pledge/Form/Payment.php @@ -127,8 +127,7 @@ public function buildQuickForm() { 'type' => 'cancel', 'name' => ts('Cancel'), ], - ] - ); + ]); } /** diff --git a/CRM/Pledge/Form/Pledge.php b/CRM/Pledge/Form/Pledge.php index 7f4710d9a2a6..e7478f8b1310 100644 --- a/CRM/Pledge/Form/Pledge.php +++ b/CRM/Pledge/Form/Pledge.php @@ -53,16 +53,19 @@ class CRM_Pledge_Form_Pledge extends CRM_Core_Form { /** * The Pledge values if an existing pledge. + * @var array */ public $_values; /** * The Pledge frequency Units. + * @var array */ public $_freqUnits; /** * Is current pledge pending. + * @var bool */ public $_isPending = FALSE; @@ -119,7 +122,6 @@ public function preProcess() { $this->_fromEmails = CRM_Core_BAO_Email::getFromEmail(); } - /** * Set default values for the form. * The default values are retrieved from the database. @@ -205,16 +207,15 @@ public function buildQuickForm() { 'type' => 'cancel', 'name' => ts('Cancel'), ], - ] - ); + ]); return; } if ($this->_context == 'standalone') { $this->addEntityRef('contact_id', ts('Contact'), [ - 'create' => TRUE, - 'api' => ['extra' => ['email']], - ], TRUE); + 'create' => TRUE, + 'api' => ['extra' => ['email']], + ], TRUE); } $showAdditionalInfo = FALSE; @@ -293,10 +294,11 @@ public function buildQuickForm() { $this->addRule('frequency_day', ts('Please enter a valid payment due day.'), 'positiveInteger'); $this->add('text', 'eachPaymentAmount', ts('each'), [ - 'size' => 10, - 'style' => "background-color:#EBECE4", - 0 => 'READONLY', // WTF, preserved because its inexplicable - ]); + 'size' => 10, + 'style' => "background-color:#EBECE4", + // WTF, preserved because its inexplicable + 0 => 'READONLY', + ]); // add various dates $createDate = $this->add('datepicker', 'create_date', ts('Pledge Made'), [], TRUE, ['time' => FALSE]); @@ -381,8 +383,7 @@ public function buildQuickForm() { 'type' => 'cancel', 'name' => ts('Cancel'), ], - ] - ); + ]); $this->addFormRule(['CRM_Pledge_Form_Pledge', 'formRule'], $this); @@ -565,9 +566,9 @@ public function postProcess() { ); if (count($processors) > 0) { $statusMsg .= ' ' . ts("If a payment is due now, you can record a check, EFT, or cash payment for this pledge OR submit a credit card payment.", [ - 1 => $contribURL, - 2 => $creditURL, - ]); + 1 => $contribURL, + 2 => $creditURL, + ]); } else { $statusMsg .= ' ' . ts("If a payment is due now, you can record a check, EFT, or cash payment for this pledge.", [1 => $contribURL]); diff --git a/CRM/Pledge/Form/PledgeView.php b/CRM/Pledge/Form/PledgeView.php index 3120a7488d99..0509c6bd407b 100644 --- a/CRM/Pledge/Form/PledgeView.php +++ b/CRM/Pledge/Form/PledgeView.php @@ -136,8 +136,7 @@ public function buildQuickForm() { 'spacing' => '         ', 'isDefault' => TRUE, ], - ] - ); + ]); } } diff --git a/CRM/Pledge/Form/Search.php b/CRM/Pledge/Form/Search.php index 3f9bb872efe4..e4a0354e0147 100644 --- a/CRM/Pledge/Form/Search.php +++ b/CRM/Pledge/Form/Search.php @@ -59,6 +59,7 @@ class CRM_Pledge_Form_Search extends CRM_Core_Form_Search { /** * Prefix for the controller. + * @var string */ protected $_prefix = "pledge_"; diff --git a/CRM/Pledge/Form/Task.php b/CRM/Pledge/Form/Task.php index c6716dff0d9a..ede0eb0caaf8 100644 --- a/CRM/Pledge/Form/Task.php +++ b/CRM/Pledge/Form/Task.php @@ -140,8 +140,7 @@ public function addDefaultButtons($title, $nextType = 'next', $backType = 'back' 'type' => $backType, 'name' => ts('Cancel'), ], - ] - ); + ]); } } diff --git a/CRM/Pledge/Form/Task/Print.php b/CRM/Pledge/Form/Task/Print.php index 3b5cb4357fab..5af5df8d0b6a 100644 --- a/CRM/Pledge/Form/Task/Print.php +++ b/CRM/Pledge/Form/Task/Print.php @@ -80,8 +80,7 @@ public function buildQuickForm() { 'type' => 'back', 'name' => ts('Done'), ], - ] - ); + ]); } /** diff --git a/CRM/Pledge/Form/Task/Result.php b/CRM/Pledge/Form/Task/Result.php index 4a4994bfa00a..385a151fa001 100644 --- a/CRM/Pledge/Form/Task/Result.php +++ b/CRM/Pledge/Form/Task/Result.php @@ -52,8 +52,7 @@ public function buildQuickForm() { 'name' => ts('Done'), 'isDefault' => TRUE, ], - ] - ); + ]); } } diff --git a/CRM/Pledge/Form/Task/SearchTaskHookSample.php b/CRM/Pledge/Form/Task/SearchTaskHookSample.php index 255a0e4b3a3a..0c8576ece9ea 100644 --- a/CRM/Pledge/Form/Task/SearchTaskHookSample.php +++ b/CRM/Pledge/Form/Task/SearchTaskHookSample.php @@ -75,8 +75,7 @@ public function buildQuickForm() { 'name' => ts('Done'), 'isDefault' => TRUE, ], - ] - ); + ]); } } diff --git a/CRM/Pledge/Info.php b/CRM/Pledge/Info.php index d920df827e47..3bbac1648b0d 100644 --- a/CRM/Pledge/Info.php +++ b/CRM/Pledge/Info.php @@ -36,6 +36,7 @@ class CRM_Pledge_Info extends CRM_Core_Component_Info { /** + * @var string * @inheritDoc */ protected $keyword = 'pledge'; @@ -58,7 +59,6 @@ public function getInfo() { ]; } - /** * @inheritDoc * Provides permissions that are used by component. diff --git a/CRM/Pledge/Selector/Search.php b/CRM/Pledge/Selector/Search.php index 5c87aae324a1..94551d9544ae 100644 --- a/CRM/Pledge/Selector/Search.php +++ b/CRM/Pledge/Selector/Search.php @@ -43,21 +43,21 @@ class CRM_Pledge_Selector_Search extends CRM_Core_Selector_Base { * * @var array */ - static $_links = NULL; + public static $_links = NULL; /** * We use desc to remind us what that column is, name is used in the tpl * * @var array */ - static $_columnHeaders; + public static $_columnHeaders; /** * Properties of contact we're interested in displaying * * @var array */ - static $_properties = [ + public static $_properties = [ 'contact_id', 'sort_name', 'display_name', diff --git a/CRM/Pledge/Task.php b/CRM/Pledge/Task.php index 7becb5a000cc..39309019b676 100644 --- a/CRM/Pledge/Task.php +++ b/CRM/Pledge/Task.php @@ -36,7 +36,7 @@ */ class CRM_Pledge_Task extends CRM_Core_Task { - static $objectType = 'pledge'; + public static $objectType = 'pledge'; /** * These tasks are the core set of tasks that the user can perform diff --git a/CRM/Profile/Form.php b/CRM/Profile/Form.php index 647e86ae9c99..4c110de5d402 100644 --- a/CRM/Profile/Form.php +++ b/CRM/Profile/Form.php @@ -79,7 +79,7 @@ class CRM_Profile_Form extends CRM_Core_Form { /** * Name of button for saving matching contacts. - * @var + * @var string */ protected $_duplicateButtonName; /** @@ -113,6 +113,7 @@ class CRM_Profile_Form extends CRM_Core_Form { /** * Dedupe using a specific rule (CRM-6131). * Not currently exposed in profile settings, but can be set in a buildForm hook. + * @var int */ public $_ruleGroupID = NULL; @@ -137,6 +138,7 @@ class CRM_Profile_Form extends CRM_Core_Form { /** * Store profile ids if multiple profile ids are passed using comma separated. * Currently lets implement this functionality only for dialog mode. + * @var array */ protected $_profileIds = []; diff --git a/CRM/Profile/Page/Dynamic.php b/CRM/Profile/Page/Dynamic.php index a373d151470a..8f9d42e64cfb 100644 --- a/CRM/Profile/Page/Dynamic.php +++ b/CRM/Profile/Page/Dynamic.php @@ -72,6 +72,7 @@ class CRM_Profile_Page_Dynamic extends CRM_Core_Page { /** * Store profile ids if multiple profile ids are passed using comma separated. * Currently lets implement this functionality only for dialog mode + * @var array */ protected $_profileIds = []; @@ -93,8 +94,10 @@ class CRM_Profile_Page_Dynamic extends CRM_Core_Page { protected $_recordId = NULL; - /* + /** + * * fetch multirecord as well as non-multirecord fields + * @var int */ protected $_allFields = NULL; diff --git a/CRM/Profile/Page/Listings.php b/CRM/Profile/Page/Listings.php index d5e3c4a116d2..0fdc3a2d1e19 100644 --- a/CRM/Profile/Page/Listings.php +++ b/CRM/Profile/Page/Listings.php @@ -84,6 +84,7 @@ class CRM_Profile_Page_Listings extends CRM_Core_Page { /** * Store profile ids if multiple profile ids are passed using comma separated. * Currently lets implement this functionality only for dialog mode + * @var array */ protected $_profileIds = []; diff --git a/CRM/Profile/Page/MultipleRecordFieldsListing.php b/CRM/Profile/Page/MultipleRecordFieldsListing.php index 6d50d65b20a7..66bc8ed9eb3e 100644 --- a/CRM/Profile/Page/MultipleRecordFieldsListing.php +++ b/CRM/Profile/Page/MultipleRecordFieldsListing.php @@ -38,7 +38,7 @@ class CRM_Profile_Page_MultipleRecordFieldsListing extends CRM_Core_Page_Basic { * * @var array */ - static $_links = NULL; + public static $_links = NULL; protected $_fields = NULL; diff --git a/CRM/Profile/Selector/Listings.php b/CRM/Profile/Selector/Listings.php index 4d5a2034de4b..ac36108f2a2b 100644 --- a/CRM/Profile/Selector/Listings.php +++ b/CRM/Profile/Selector/Listings.php @@ -44,14 +44,14 @@ class CRM_Profile_Selector_Listings extends CRM_Core_Selector_Base implements CR * * @var array */ - static $_links = NULL; + public static $_links = NULL; /** * We use desc to remind us what that column is, name is used in the tpl * * @var array */ - static $_columnHeaders; + public static $_columnHeaders; /** * The sql params we use to get the list of contacts. @@ -119,6 +119,7 @@ class CRM_Profile_Selector_Listings extends CRM_Core_Selector_Base implements CR /** * Store profile ids if multiple profile ids are passed using comma separated. * Currently lets implement this functionality only for dialog mode + * @var array */ protected $_profileIds = []; diff --git a/CRM/Queue/ErrorPolicy.php b/CRM/Queue/ErrorPolicy.php index f87c5df7738a..600b45d25a62 100644 --- a/CRM/Queue/ErrorPolicy.php +++ b/CRM/Queue/ErrorPolicy.php @@ -63,10 +63,10 @@ public function activate() { $this->active = TRUE; $this->backup = []; foreach ([ - 'display_errors', - 'html_errors', - 'xmlrpc_errors', - ] as $key) { + 'display_errors', + 'html_errors', + 'xmlrpc_errors', + ] as $key) { $this->backup[$key] = ini_get($key); ini_set($key, 0); } @@ -82,10 +82,10 @@ public function deactivate() { $this->errorScope = NULL; restore_error_handler(); foreach ([ - 'display_errors', - 'html_errors', - 'xmlrpc_errors', - ] as $key) { + 'display_errors', + 'html_errors', + 'xmlrpc_errors', + ] as $key) { ini_set($key, $this->backup[$key]); } $this->active = FALSE; diff --git a/CRM/Queue/Queue.php b/CRM/Queue/Queue.php index d8c7df0848bd..6057668ddc89 100644 --- a/CRM/Queue/Queue.php +++ b/CRM/Queue/Queue.php @@ -71,24 +71,24 @@ public function getName() { /** * Perform any registation or resource-allocation for a new queue */ - public abstract function createQueue(); + abstract public function createQueue(); /** * Perform any loading or pre-fetch for an existing queue. */ - public abstract function loadQueue(); + abstract public function loadQueue(); /** * Release any resources claimed by the queue (memory, DB rows, etc) */ - public abstract function deleteQueue(); + abstract public function deleteQueue(); /** * Check if the queue exists. * * @return bool */ - public abstract function existsQueue(); + abstract public function existsQueue(); /** * Add a new item to the queue. @@ -99,14 +99,14 @@ public abstract function existsQueue(); * Queue-dependent options; for example, if this is a * priority-queue, then $options might specify the item's priority. */ - public abstract function createItem($data, $options = []); + abstract public function createItem($data, $options = []); /** * Determine number of items remaining in the queue. * * @return int */ - public abstract function numberOfItems(); + abstract public function numberOfItems(); /** * Get the next item. @@ -117,7 +117,7 @@ public abstract function numberOfItems(); * @return object * with key 'data' that matches the inputted data */ - public abstract function claimItem($lease_time = 3600); + abstract public function claimItem($lease_time = 3600); /** * Get the next item, even if there's an active lease @@ -128,7 +128,7 @@ public abstract function claimItem($lease_time = 3600); * @return object * with key 'data' that matches the inputted data */ - public abstract function stealItem($lease_time = 3600); + abstract public function stealItem($lease_time = 3600); /** * Remove an item from the queue. @@ -136,7 +136,7 @@ public abstract function stealItem($lease_time = 3600); * @param object $item * The item returned by claimItem. */ - public abstract function deleteItem($item); + abstract public function deleteItem($item); /** * Return an item that could not be processed. @@ -144,6 +144,6 @@ public abstract function deleteItem($item); * @param object $item * The item returned by claimItem. */ - public abstract function releaseItem($item); + abstract public function releaseItem($item); } diff --git a/CRM/Queue/Runner.php b/CRM/Queue/Runner.php index 837a77f8d882..fa2817e7130a 100644 --- a/CRM/Queue/Runner.php +++ b/CRM/Queue/Runner.php @@ -59,7 +59,10 @@ class CRM_Queue_Runner { public $onEnd; public $onEndUrl; public $pathPrefix; - // queue-runner id; used for persistence + /** + * queue-runner id; used for persistence + * @var int + */ public $qrid; /** diff --git a/CRM/Report/DAO/ReportInstance.php b/CRM/Report/DAO/ReportInstance.php index 48a6a02296af..c07fa67bca0e 100644 --- a/CRM/Report/DAO/ReportInstance.php +++ b/CRM/Report/DAO/ReportInstance.php @@ -19,14 +19,14 @@ class CRM_Report_DAO_ReportInstance extends CRM_Core_DAO { * * @var string */ - static $_tableName = 'civicrm_report_instance'; + public static $_tableName = 'civicrm_report_instance'; /** * Should CiviCRM log any modifications to this table in the civicrm_log table. * * @var bool */ - static $_log = FALSE; + public static $_log = FALSE; /** * Report Instance ID diff --git a/CRM/Report/Form.php b/CRM/Report/Form.php index 389e7769db2a..a136d9ef6c8b 100644 --- a/CRM/Report/Form.php +++ b/CRM/Report/Form.php @@ -93,6 +93,7 @@ class CRM_Report_Form extends CRM_Core_Form { /** * By default most reports hide contact id. * Setting this to true makes it available + * @var bool */ protected $_exposeContactID = TRUE; @@ -137,11 +138,13 @@ class CRM_Report_Form extends CRM_Core_Form { /** * Build tags filter + * @var bool */ protected $_tagFilter = FALSE; /** * specify entity table for tags filter + * @var string */ protected $_tagFilterTable = 'civicrm_contact'; @@ -322,6 +325,7 @@ class CRM_Report_Form extends CRM_Core_Form { /** * Variables to hold the acl inner join and where clause + * @var string|NULL */ protected $_aclFrom = NULL; protected $_aclWhere = NULL; @@ -354,7 +358,7 @@ class CRM_Report_Form extends CRM_Core_Form { * * (it's unclear if this could be merged with outputMode at this stage) * - * @var + * @var string|NULL */ protected $_format; @@ -390,6 +394,7 @@ class CRM_Report_Form extends CRM_Core_Form { /** * Variable to hold the currency alias + * @var string|NULL */ protected $_currencyColumn = NULL; @@ -448,6 +453,7 @@ class CRM_Report_Form extends CRM_Core_Form { * When a grand total row has calculated the status we pop it off to here. * * This allows us to access it from the stats function and avoid recalculating. + * @var array */ protected $rollupRow = []; @@ -501,6 +507,7 @@ class CRM_Report_Form extends CRM_Core_Form { * @var bool */ public $optimisedForOnlyFullGroupBy = TRUE; + /** * Class constructor. */ @@ -1611,8 +1618,7 @@ public function buildInstanceAndButtons() { 'name' => $showResultsLabel, 'isDefault' => TRUE, ], - ] - ); + ]); } /** @@ -3510,7 +3516,6 @@ public function compileContent() { CRM_Utils_Array::value('report_footer', $this->_formValues); } - /** * Post process function. */ @@ -3703,7 +3708,6 @@ public function whereGroupClause($field, $value, $op) { return "1"; } - /** * Create a table of the contact ids included by the group filter. * @@ -4137,13 +4141,13 @@ protected function isFieldFiltered($prop) { if (!empty($prop['filters']) && $this->_customGroupFilters) { foreach ($prop['filters'] as $fieldAlias => $val) { foreach ([ - 'value', - 'min', - 'max', - 'relative', - 'from', - 'to', - ] as $attach) { + 'value', + 'min', + 'max', + 'relative', + 'from', + 'to', + ] as $attach) { if (isset($this->_params[$fieldAlias . '_' . $attach]) && (!empty($this->_params[$fieldAlias . '_' . $attach]) || ($attach != 'relative' && @@ -4295,7 +4299,7 @@ public function selectedTables() { /** * Add campaign fields. - * + * @param string $entityTable * @param bool $groupBy * Add GroupBy? Not appropriate for detail report. * @param bool $orderBy diff --git a/CRM/Report/Form/Campaign/SurveyDetails.php b/CRM/Report/Form/Campaign/SurveyDetails.php index d84c14fd3305..e8b7f84b47d2 100644 --- a/CRM/Report/Form/Campaign/SurveyDetails.php +++ b/CRM/Report/Form/Campaign/SurveyDetails.php @@ -54,11 +54,15 @@ class CRM_Report_Form_Campaign_SurveyDetails extends CRM_Report_Form { private static $_surveyRespondentStatus; // Survey Question titles are overridden when in print or pdf mode to - // say Q1, Q2 instead of the full title - to save space. + /** + * say Q1, Q2 instead of the full title - to save space. + * @var array + */ private $_columnTitleOverrides = array(); /** */ + /** */ public function __construct() { @@ -704,12 +708,11 @@ private function _addSurveyResponseColumns() { 'alias' => "phone_civireport_{$fName}", 'fields' => array( $fName => array_merge($value, array( - 'is_required' => '1', - 'alias' => "phone_civireport_{$fName}", - 'dbAlias' => "phone_civireport_{$fName}.phone", - 'no_display' => TRUE, - ) - ), + 'is_required' => '1', + 'alias' => "phone_civireport_{$fName}", + 'dbAlias' => "phone_civireport_{$fName}.phone", + 'no_display' => TRUE, + )), ), ); $this->_aliases["civicrm_phone_{$fName}"] = $this->_columns["civicrm_{$fName}"]['alias']; diff --git a/CRM/Report/Form/Case/Detail.php b/CRM/Report/Form/Case/Detail.php index 0a38995fcba8..0c5bcffea387 100644 --- a/CRM/Report/Form/Case/Detail.php +++ b/CRM/Report/Form/Case/Detail.php @@ -150,7 +150,8 @@ public function __construct() { 'case_type_title' => [ 'title' => 'Case Type', 'name' => 'title', - ]] + ], + ], ], 'civicrm_contact' => [ 'dao' => 'CRM_Contact_DAO_Contact', diff --git a/CRM/Report/Form/Contact/LoggingDetail.php b/CRM/Report/Form/Contact/LoggingDetail.php index d65cb97d490f..aa0acc3256eb 100644 --- a/CRM/Report/Form/Contact/LoggingDetail.php +++ b/CRM/Report/Form/Contact/LoggingDetail.php @@ -33,6 +33,7 @@ * */ class CRM_Report_Form_Contact_LoggingDetail extends CRM_Logging_ReportDetail { + /** */ public function __construct() { diff --git a/CRM/Report/Form/Contact/LoggingSummary.php b/CRM/Report/Form/Contact/LoggingSummary.php index 61d255fdc9cd..97ebefc94bc5 100644 --- a/CRM/Report/Form/Contact/LoggingSummary.php +++ b/CRM/Report/Form/Contact/LoggingSummary.php @@ -33,6 +33,7 @@ class CRM_Report_Form_Contact_LoggingSummary extends CRM_Logging_ReportSummary { public $optimisedForOnlyFullGroupBy = FALSE; + /** * Class constructor. */ diff --git a/CRM/Report/Form/Contribute/Bookkeeping.php b/CRM/Report/Form/Contribute/Bookkeeping.php index 753844af9894..adceb9a0cbde 100644 --- a/CRM/Report/Form/Contribute/Bookkeeping.php +++ b/CRM/Report/Form/Contribute/Bookkeeping.php @@ -538,11 +538,10 @@ public function where() { foreach ($table['filters'] as $fieldName => $field) { $clause = NULL; if (in_array($fieldName, [ - 'credit_accounting_code', - 'credit_name', - 'credit_contact_id', - ] - )) { + 'credit_accounting_code', + 'credit_name', + 'credit_contact_id', + ])) { $field['dbAlias'] = "CASE WHEN financial_trxn_civireport.from_financial_account_id IS NOT NULL THEN financial_account_civireport_credit_1.{$field['name']} diff --git a/CRM/Report/Form/Contribute/DeferredRevenue.php b/CRM/Report/Form/Contribute/DeferredRevenue.php index 837a417c3aba..321c5378e3bc 100644 --- a/CRM/Report/Form/Contribute/DeferredRevenue.php +++ b/CRM/Report/Form/Contribute/DeferredRevenue.php @@ -36,6 +36,7 @@ class CRM_Report_Form_Contribute_DeferredRevenue extends CRM_Report_Form { /** * Holds Deferred Financial Account + * @var array */ protected $_deferredFinancialAccount = []; diff --git a/CRM/Report/Form/Contribute/History.php b/CRM/Report/Form/Contribute/History.php index 89b0dfe4b9ac..584bd347da73 100644 --- a/CRM/Report/Form/Contribute/History.php +++ b/CRM/Report/Form/Contribute/History.php @@ -31,8 +31,13 @@ * @copyright CiviCRM LLC (c) 2004-2019 */ class CRM_Report_Form_Contribute_History extends CRM_Report_Form { - // Primary Contacts count limitCONSTROW_COUNT_LIMIT = 10; + /** + * Primary Contacts count limitCONSTROW_COUNT_LIMIT = 10; + */ + /** + * @var array + */ protected $_relationshipColumns = []; protected $_customGroupExtends = [ diff --git a/CRM/Report/Form/Contribute/Lybunt.php b/CRM/Report/Form/Contribute/Lybunt.php index 3b1ed480be71..f3972d42f538 100644 --- a/CRM/Report/Form/Contribute/Lybunt.php +++ b/CRM/Report/Form/Contribute/Lybunt.php @@ -284,7 +284,7 @@ public function selectClause(&$tableName, $tableKey, &$fieldName, &$field) { $this->_columnHeaders["{$tableName}_{$fieldName}"] = $field; $this->_columnHeaders["{$tableName}_{$fieldName}"]['title'] = $this->getLastYearColumnTitle(); $this->_statFields[$this->getLastYearColumnTitle()] = "{$tableName}_{$fieldName}"; - return "SUM(IF(" . $this->whereClauseLastYear('contribution_civireport.receive_date') . ", contribution_civireport.total_amount, 0)) as {$tableName}_{$fieldName}"; + return "SUM(IF(" . $this->whereClauseLastYear('contribution_civireport.receive_date') . ", contribution_civireport.total_amount, 0)) as {$tableName}_{$fieldName}"; } if ($fieldName == 'civicrm_life_time_total') { $this->_columnHeaders["{$tableName}_{$fieldName}"] = $field; @@ -420,7 +420,6 @@ public function whereClauseThisYear($fieldName, $current_year = NULL) { return "$fieldName BETWEEN '" . $this->getFirstDateOfCurrentRange() . "' AND '" . $this->getLastDateOfCurrentRange() . "'"; } - /** * Get the year value for the current year. * @@ -482,7 +481,6 @@ public function getLastDateOfPriorRange() { return date('YmdHis', strtotime('+ 1 year - 1 second', strtotime($this->getFirstDateOfPriorRange()))); } - public function groupBy() { $this->_groupBy = "GROUP BY {$this->_aliases['civicrm_contribution']}.contact_id "; $this->_select = CRM_Contact_BAO_Query::appendAnyValueToSelect($this->_selectClauses, "{$this->_aliases['civicrm_contribution']}.contact_id"); @@ -518,7 +516,7 @@ public function statistics(&$rows) { } else { $select = "SELECT SUM({$this->_aliases['civicrm_contribution']}.total_amount) as amount, - SUM(IF( " . $this->whereClauseLastYear('contribution_civireport.receive_date') . ", contribution_civireport.total_amount, 0)) as last_year + SUM(IF( " . $this->whereClauseLastYear('contribution_civireport.receive_date') . ", contribution_civireport.total_amount, 0)) as last_year "; $sql = "{$select} {$this->_from} {$this->_where}"; $dao = CRM_Core_DAO::executeQuery($sql); diff --git a/CRM/Report/Form/Contribute/Recur.php b/CRM/Report/Form/Contribute/Recur.php index e3f733f059e6..240ad47e72cc 100644 --- a/CRM/Report/Form/Contribute/Recur.php +++ b/CRM/Report/Form/Contribute/Recur.php @@ -362,7 +362,6 @@ public function where() { } } - /** * Alter display of rows. * diff --git a/CRM/Report/Form/Contribute/RecurSummary.php b/CRM/Report/Form/Contribute/RecurSummary.php index af66c0dc6858..94188df82846 100644 --- a/CRM/Report/Form/Contribute/RecurSummary.php +++ b/CRM/Report/Form/Contribute/RecurSummary.php @@ -33,6 +33,7 @@ * */ class CRM_Report_Form_Contribute_RecurSummary extends CRM_Report_Form { + /** */ public function __construct() { diff --git a/CRM/Report/Form/Contribute/Repeat.php b/CRM/Report/Form/Contribute/Repeat.php index 142c7eb403f8..177c6a7a0c7e 100644 --- a/CRM/Report/Form/Contribute/Repeat.php +++ b/CRM/Report/Form/Contribute/Repeat.php @@ -78,7 +78,7 @@ class CRM_Report_Form_Contribute_Repeat extends CRM_Report_Form { /** * The column in the contribution table that joins to the temp tables. * - * @var + * @var string */ protected $contributionJoinTableColumn; diff --git a/CRM/Report/Form/Contribute/Summary.php b/CRM/Report/Form/Contribute/Summary.php index 6e4b238d6f56..05d72b807f19 100644 --- a/CRM/Report/Form/Contribute/Summary.php +++ b/CRM/Report/Form/Contribute/Summary.php @@ -442,10 +442,10 @@ public static function formRule($fields, $files, $self) { if (empty($fields['fields']['total_amount'])) { foreach (array( - 'total_count_value', - 'total_sum_value', - 'total_avg_value', - ) as $val) { + 'total_count_value', + 'total_sum_value', + 'total_avg_value', + ) as $val) { if (!empty($fields[$val])) { $errors[$val] = ts("Please select the Amount Statistics"); } @@ -745,7 +745,8 @@ public function buildRows($sql, &$rows) { $contriFields = array( 'civicrm_contribution_total_amount_sum', 'civicrm_contribution_total_amount_avg', - 'civicrm_contribution_total_amount_count'); + 'civicrm_contribution_total_amount_count', + ); $contriRows = array(); while ($contriDAO->fetch()) { $contriRow = array(); diff --git a/CRM/Report/Form/Event/ParticipantListing.php b/CRM/Report/Form/Event/ParticipantListing.php index 5524f1bb5057..018be0cf2dfb 100644 --- a/CRM/Report/Form/Event/ParticipantListing.php +++ b/CRM/Report/Form/Event/ParticipantListing.php @@ -66,7 +66,8 @@ public function __construct() { 'required' => TRUE, 'no_repeat' => TRUE, 'dbAlias' => 'contact_civireport.sort_name', - )), + ), + ), $this->getBasicContactFields(), array( 'age_at_event' => array( diff --git a/CRM/Report/Form/Extended.php b/CRM/Report/Form/Extended.php index 9e04ef659b41..873665e8cd87 100644 --- a/CRM/Report/Form/Extended.php +++ b/CRM/Report/Form/Extended.php @@ -63,7 +63,6 @@ public function select() { parent::select(); } - /** * From clause build where baseTable & fromClauses are defined */ @@ -252,7 +251,8 @@ public function getPriceFieldValueColumns() { 'title' => ts('Price Field Value Label'), ], ], - 'group_bys' => //note that we have a requirement to group by label such that all 'Promo book' lines + //note that we have a requirement to group by label such that all 'Promo book' lines + 'group_bys' => // are grouped together across price sets but there may be a separate need to group // by id so that entries in one price set are distinct from others. Not quite sure what // to call the distinction for end users benefit diff --git a/CRM/Report/Form/Instance.php b/CRM/Report/Form/Instance.php index ec2d76e2dc22..792948c03660 100644 --- a/CRM/Report/Form/Instance.php +++ b/CRM/Report/Form/Instance.php @@ -173,8 +173,7 @@ public static function buildForm(&$form) { 'type' => 'cancel', 'name' => ts('Cancel'), ], - ] - ); + ]); $form->addFormRule(['CRM_Report_Form_Instance', 'formRule'], $form); } diff --git a/CRM/Report/Form/Mailing/Summary.php b/CRM/Report/Form/Mailing/Summary.php index ba6acbee02bc..549eaf7cda53 100644 --- a/CRM/Report/Form/Mailing/Summary.php +++ b/CRM/Report/Form/Mailing/Summary.php @@ -557,9 +557,9 @@ public static function formRule($fields, $files, $self) { if ($isError) { $errors['_qf_default'] = ts('For Chart view, please select at least one field from %1 OR %2.', [ - 1 => implode(', ', $criteria['count']), - 2 => implode(', ', $criteria['rate']), - ]); + 1 => implode(', ', $criteria['count']), + 2 => implode(', ', $criteria['rate']), + ]); } return $errors; diff --git a/CRM/Report/Form/Membership/Summary.php b/CRM/Report/Form/Membership/Summary.php index 34c3a77e3b91..1a25d456039c 100644 --- a/CRM/Report/Form/Membership/Summary.php +++ b/CRM/Report/Form/Membership/Summary.php @@ -334,10 +334,10 @@ public function postProcess() { if (!empty($this->_params['charts'])) { foreach ([ - 'receive_date', - $this->_interval, - 'value', - ] as $ignore) { + 'receive_date', + $this->_interval, + 'value', + ] as $ignore) { unset($graphRows[$ignore][$count - 1]); } diff --git a/CRM/Report/Form/Pledge/Detail.php b/CRM/Report/Form/Pledge/Detail.php index b29c729bad9d..2774198c13f7 100644 --- a/CRM/Report/Form/Pledge/Detail.php +++ b/CRM/Report/Form/Pledge/Detail.php @@ -219,7 +219,8 @@ public function select() { */ public function selectClause(&$tableName, $tableKey, &$fieldName, &$field) { if ($fieldName == 'total_paid') { - $this->_totalPaid = TRUE; // add pledge_payment join + // add pledge_payment join + $this->_totalPaid = TRUE; $this->_columnHeaders["{$tableName}_{$fieldName}"] = [ 'title' => $field['title'], 'type' => $field['type'], @@ -229,7 +230,8 @@ public function selectClause(&$tableName, $tableKey, &$fieldName, &$field) { if ($fieldName == 'balance_due') { $cancelledStatus = array_search('Cancelled', $this->_pledgeStatuses); $completedStatus = array_search('Completed', $this->_pledgeStatuses); - $this->_totalPaid = TRUE; // add pledge_payment join + // add pledge_payment join + $this->_totalPaid = TRUE; $this->_columnHeaders["{$tableName}_{$fieldName}"] = $field['title']; $this->_columnHeaders["{$tableName}_{$fieldName}"] = [ 'title' => $field['title'], diff --git a/CRM/Report/Form/Pledge/Pbnp.php b/CRM/Report/Form/Pledge/Pbnp.php index e796cac5fee4..17369bf19abf 100644 --- a/CRM/Report/Form/Pledge/Pbnp.php +++ b/CRM/Report/Form/Pledge/Pbnp.php @@ -213,10 +213,10 @@ public function from() { $allStatus = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name'); $pendingStatus = array_search('Pending', $allStatus); foreach ([ - 'Pending', - 'In Progress', - 'Overdue', - ] as $statusKey) { + 'Pending', + 'In Progress', + 'Overdue', + ] as $statusKey) { if ($key = CRM_Utils_Array::key($statusKey, $allStatus)) { $unpaidStatus[] = $key; } diff --git a/CRM/Report/Form/Register.php b/CRM/Report/Form/Register.php index c99ac77738c8..469b9844357f 100644 --- a/CRM/Report/Form/Register.php +++ b/CRM/Report/Form/Register.php @@ -93,8 +93,7 @@ public function buildQuickForm() { 'type' => 'cancel', 'name' => ts('Cancel'), ], - ] - ); + ]); return; } @@ -128,8 +127,7 @@ public function buildQuickForm() { 'type' => 'cancel', 'name' => ts('Cancel'), ], - ] - ); + ]); $this->addFormRule(['CRM_Report_Form_Register', 'formRule'], $this); } @@ -193,9 +191,9 @@ public function postProcess() { $optionValue = CRM_Core_OptionValue::addOptionValue($params, 'report_template', $this->_action, $this->_id); CRM_Core_Session::setStatus(ts('The %1 \'%2\' has been saved.', [ - 1 => 'Report Template', - 2 => $optionValue->label, - ]), ts('Saved'), 'success'); + 1 => 'Report Template', + 2 => $optionValue->label, + ]), ts('Saved'), 'success'); CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin/report/options/report_template', "reset=1")); } } diff --git a/CRM/Report/Info.php b/CRM/Report/Info.php index 5cd505292fcd..7ba155628f71 100644 --- a/CRM/Report/Info.php +++ b/CRM/Report/Info.php @@ -37,6 +37,7 @@ class CRM_Report_Info extends CRM_Core_Component_Info { /** + * @var string * @inheritDoc */ protected $keyword = 'report'; @@ -60,7 +61,6 @@ public function getInfo() { ]; } - /** * @inheritDoc * Provides permissions that are used by component. @@ -118,7 +118,6 @@ public function getPermissions($getAllUnconditionally = FALSE, $descriptions = F return $permissions; } - /** * @inheritDoc * Provides information about user dashboard element @@ -139,6 +138,7 @@ public function getUserDashboardElement() { * @return mixed * component's User Dashboard applet object */ + /** * @return mixed */ @@ -156,6 +156,7 @@ public function getUserDashboardObject() { * collection of required dashboard settings, * null if no element offered */ + /** * @return array|null */ @@ -181,6 +182,7 @@ public function getIcon() { * collection of required pane settings, * null if no element offered */ + /** * @return array|null */ @@ -199,6 +201,7 @@ public function registerAdvancedSearchPane() { * @return array|null * collection of activity types */ + /** * @return array|null */ diff --git a/CRM/Report/Page/Instance.php b/CRM/Report/Page/Instance.php index c101c06b18d5..9d9c78130212 100644 --- a/CRM/Report/Page/Instance.php +++ b/CRM/Report/Page/Instance.php @@ -35,6 +35,7 @@ * Page for invoking report instances */ class CRM_Report_Page_Instance extends CRM_Core_Page { + /** * Run this page (figure out the action needed and perform it). */ diff --git a/CRM/Report/Page/InstanceList.php b/CRM/Report/Page/InstanceList.php index e623e77a5d0c..8e8b17cbdd75 100644 --- a/CRM/Report/Page/InstanceList.php +++ b/CRM/Report/Page/InstanceList.php @@ -36,9 +36,9 @@ */ class CRM_Report_Page_InstanceList extends CRM_Core_Page { - static $_links = NULL; + public static $_links = NULL; - static $_exceptions = ['logging/contact/detail']; + public static $_exceptions = ['logging/contact/detail']; /** * Name of component if report list is filtered. @@ -208,7 +208,7 @@ public function run() { $rows = $this->info(); $this->assign('list', $rows); - if ($this->ovID OR $this->compID) { + if ($this->ovID or $this->compID) { // link to view all reports $reportUrl = CRM_Utils_System::url('civicrm/report/list', "reset=1"); $this->assign('reportUrl', $reportUrl); diff --git a/CRM/Report/Page/Options.php b/CRM/Report/Page/Options.php index 65374992f1eb..c4e5a1378a81 100644 --- a/CRM/Report/Page/Options.php +++ b/CRM/Report/Page/Options.php @@ -43,28 +43,28 @@ class CRM_Report_Page_Options extends CRM_Core_Page_Basic { * * @var array */ - static $_links = NULL; + public static $_links = NULL; /** * The option group name. * * @var array */ - static $_gName = NULL; + public static $_gName = NULL; /** * The option group name in display format (capitalized, without underscores...etc) * * @var array */ - static $_GName = NULL; + public static $_GName = NULL; /** * The option group id. * * @var array */ - static $_gId = NULL; + public static $_gId = NULL; /** * Obtains the group name from url and sets the title. From 62d3ee279943eae74d2f4d5797f8bb3b3fcbfa5a Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Mon, 8 Apr 2019 07:24:06 +1000 Subject: [PATCH 100/121] (NFC) Update CRM/Activity CRM/Admin and CRM/Batch folders to be the future coder standard --- CRM/Activity/BAO/Activity.php | 6 +++--- CRM/Activity/BAO/ActivityContact.php | 6 +++--- CRM/Activity/BAO/Query.php | 1 + CRM/Activity/Form/Activity.php | 7 +++++-- CRM/Activity/Form/ActivityFilter.php | 1 + CRM/Activity/Form/ActivityLinks.php | 1 + CRM/Activity/Form/Search.php | 1 + CRM/Activity/Form/Task/Batch.php | 2 ++ CRM/Activity/Form/Task/FileOnCase.php | 2 ++ CRM/Activity/Form/Task/PickOption.php | 3 +++ CRM/Activity/Form/Task/PickProfile.php | 2 ++ CRM/Activity/Import/Field.php | 1 + CRM/Activity/Import/Form/MapField.php | 1 - CRM/Activity/Import/Parser.php | 5 +++++ CRM/Activity/Import/Parser/Activity.php | 2 +- CRM/Activity/Page/AJAX.php | 2 +- CRM/Activity/Selector/Activity.php | 2 +- CRM/Activity/Selector/Search.php | 6 +++--- CRM/Activity/Task.php | 2 +- CRM/Activity/Tokens.php | 3 +-- CRM/Admin/Form/LabelFormats.php | 2 ++ CRM/Admin/Form/MessageTemplates.php | 10 ++++++++-- CRM/Admin/Form/Navigation.php | 1 + CRM/Admin/Form/PaymentProcessor.php | 5 +++-- CRM/Admin/Form/PdfFormats.php | 1 + CRM/Admin/Form/ScheduleReminders.php | 1 + CRM/Admin/Form/Setting/Localization.php | 2 -- CRM/Admin/Form/SettingTrait.php | 2 ++ CRM/Admin/Page/AJAX.php | 10 +++++----- CRM/Admin/Page/APIExplorer.php | 1 - CRM/Admin/Page/Access.php | 1 + CRM/Admin/Page/Admin.php | 1 + CRM/Admin/Page/CKEditorConfig.php | 1 + CRM/Admin/Page/ConfigTaskList.php | 1 + CRM/Admin/Page/ContactType.php | 2 +- CRM/Admin/Page/EventTemplate.php | 2 +- CRM/Admin/Page/Extensions.php | 2 +- CRM/Admin/Page/Job.php | 2 +- CRM/Admin/Page/JobLog.php | 2 +- CRM/Admin/Page/LabelFormats.php | 2 +- CRM/Admin/Page/LocationType.php | 2 +- CRM/Admin/Page/MailSettings.php | 2 +- CRM/Admin/Page/Mapping.php | 2 +- CRM/Admin/Page/MessageTemplates.php | 12 +++++++++--- CRM/Admin/Page/Navigation.php | 2 +- CRM/Admin/Page/Options.php | 10 +++++----- CRM/Admin/Page/PaymentProcessor.php | 2 +- CRM/Admin/Page/PaymentProcessorType.php | 2 +- CRM/Admin/Page/PdfFormats.php | 2 +- CRM/Admin/Page/PreferencesDate.php | 2 +- CRM/Admin/Page/RelationshipType.php | 2 +- CRM/Admin/Page/ScheduleReminders.php | 2 +- CRM/Admin/Page/Setting.php | 1 + CRM/Batch/BAO/Batch.php | 7 ++++--- CRM/Batch/Form/Entry.php | 7 +++++++ CRM/Batch/Form/Search.php | 1 + CRM/Batch/Page/Batch.php | 2 +- 57 files changed, 109 insertions(+), 58 deletions(-) diff --git a/CRM/Activity/BAO/Activity.php b/CRM/Activity/BAO/Activity.php index e454ef229e5f..af4961d5ab5e 100644 --- a/CRM/Activity/BAO/Activity.php +++ b/CRM/Activity/BAO/Activity.php @@ -49,14 +49,14 @@ class CRM_Activity_BAO_Activity extends CRM_Activity_DAO_Activity { * * @var array */ - static $_exportableFields = NULL; + public static $_exportableFields = NULL; /** * Static field for all the activity information that we can potentially import. * * @var array */ - static $_importableFields = NULL; + public static $_importableFields = NULL; /** * Check if there is absolute minimum of data to add the object. @@ -901,7 +901,7 @@ public function addSelectWhereClause() { * that this concept might be extended later. In practice most places that * call this then re-add CiviCase in some way so it's all a bit... odd. * - * @return array Array of component id and name. + * @return array * Array of component id and name. */ public static function activityComponents($excludeComponentHandledActivities = TRUE) { diff --git a/CRM/Activity/BAO/ActivityContact.php b/CRM/Activity/BAO/ActivityContact.php index f12a86b20520..7039fba2f164 100644 --- a/CRM/Activity/BAO/ActivityContact.php +++ b/CRM/Activity/BAO/ActivityContact.php @@ -147,9 +147,9 @@ public static function retrieveContactIdsByActivityId($activityID, $recordTypeID * @see DB_DataObject::getLink() * * @return array|null - * array = if there are links defined for this table. - * empty array - if there is a links.ini file, but no links on this table - * null - if no links.ini exists for this database (hence try auto_links). + * array if there are links defined for this table. + * empty array - if there is a links.ini file, but no links on this table + * null - if no links.ini exists for this database (hence try auto_links). */ public function links() { $link = ['activity_id' => 'civicrm_activity:id']; diff --git a/CRM/Activity/BAO/Query.php b/CRM/Activity/BAO/Query.php index 8851d2fe351d..8f7cd076b8f5 100644 --- a/CRM/Activity/BAO/Query.php +++ b/CRM/Activity/BAO/Query.php @@ -673,6 +673,7 @@ public static function selectorReturnProperties() { * Where/qill clause for notes * * @param array $values + * @param object $query */ public static function whereClauseSingleActivityText(&$values, &$query) { list($name, $op, $value, $grouping, $wildcard) = $values; diff --git a/CRM/Activity/Form/Activity.php b/CRM/Activity/Form/Activity.php index 7fffdb7cd588..680188871e0c 100644 --- a/CRM/Activity/Form/Activity.php +++ b/CRM/Activity/Form/Activity.php @@ -119,7 +119,8 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task { protected $unsavedWarn = TRUE; - /* + /** + * * Is it possible to create separate activities with this form? * * When TRUE, the form will ask whether the user wants to create separate @@ -133,7 +134,9 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task { * behavior (e.g. in CRM_Case_Form_Activity) * * @var boolean + * */ + protected $supportsActivitySeparation = TRUE; /** @@ -826,7 +829,7 @@ public function buildQuickForm() { $doNotNotifyAssigneeFor = (array) Civi::settings() ->get('do_not_notify_assignees_for'); if (($this->_activityTypeId && in_array($this->_activityTypeId, $doNotNotifyAssigneeFor)) || !Civi::settings() - ->get('activity_assignee_notification')) { + ->get('activity_assignee_notification')) { $this->assign('activityAssigneeNotification', FALSE); } else { diff --git a/CRM/Activity/Form/ActivityFilter.php b/CRM/Activity/Form/ActivityFilter.php index 228a4c21f0ec..472c5b542c60 100644 --- a/CRM/Activity/Form/ActivityFilter.php +++ b/CRM/Activity/Form/ActivityFilter.php @@ -35,6 +35,7 @@ * This class generates form components for Activity Filter. */ class CRM_Activity_Form_ActivityFilter extends CRM_Core_Form { + public function buildQuickForm() { // add activity search filter $activityOptions = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE); diff --git a/CRM/Activity/Form/ActivityLinks.php b/CRM/Activity/Form/ActivityLinks.php index 1bbdd423f3bb..36a27d14b39c 100644 --- a/CRM/Activity/Form/ActivityLinks.php +++ b/CRM/Activity/Form/ActivityLinks.php @@ -35,6 +35,7 @@ * This class generates form components for Activity Links. */ class CRM_Activity_Form_ActivityLinks extends CRM_Core_Form { + public function buildQuickForm() { self::commonBuildQuickForm($this); } diff --git a/CRM/Activity/Form/Search.php b/CRM/Activity/Form/Search.php index a44b314c6c84..4aa16252d5d6 100644 --- a/CRM/Activity/Form/Search.php +++ b/CRM/Activity/Form/Search.php @@ -59,6 +59,7 @@ class CRM_Activity_Form_Search extends CRM_Core_Form_Search { /** * Prefix for the controller. + * @var string */ protected $_prefix = "activity_"; diff --git a/CRM/Activity/Form/Task/Batch.php b/CRM/Activity/Form/Task/Batch.php index b8cd458e100f..9bdb768b8b50 100644 --- a/CRM/Activity/Form/Task/Batch.php +++ b/CRM/Activity/Form/Task/Batch.php @@ -45,11 +45,13 @@ class CRM_Activity_Form_Task_Batch extends CRM_Activity_Form_Task { /** * Maximum profile fields that will be displayed. + * @var int */ protected $_maxFields = 9; /** * Variable to store redirect path. + * @var string */ protected $_userContext; diff --git a/CRM/Activity/Form/Task/FileOnCase.php b/CRM/Activity/Form/Task/FileOnCase.php index 893012b15c8b..dd4d2ebb3ad9 100644 --- a/CRM/Activity/Form/Task/FileOnCase.php +++ b/CRM/Activity/Form/Task/FileOnCase.php @@ -45,11 +45,13 @@ class CRM_Activity_Form_Task_FileOnCase extends CRM_Activity_Form_Task { /** * Variable to store redirect path. + * @var string */ protected $_userContext; /** * Variable to store contact Ids. + * @var array */ public $_contacts; diff --git a/CRM/Activity/Form/Task/PickOption.php b/CRM/Activity/Form/Task/PickOption.php index df4e59f5a42b..bef28a6b3b4a 100644 --- a/CRM/Activity/Form/Task/PickOption.php +++ b/CRM/Activity/Form/Task/PickOption.php @@ -45,16 +45,19 @@ class CRM_Activity_Form_Task_PickOption extends CRM_Activity_Form_Task { /** * Maximum Activities that should be allowed to update. + * @var int */ protected $_maxActivities = 100; /** * Variable to store redirect path. + * @var int */ protected $_userContext; /** * Variable to store contact Ids. + * @var array */ public $_contacts; diff --git a/CRM/Activity/Form/Task/PickProfile.php b/CRM/Activity/Form/Task/PickProfile.php index 10f258837c5a..1221a21c4abd 100644 --- a/CRM/Activity/Form/Task/PickProfile.php +++ b/CRM/Activity/Form/Task/PickProfile.php @@ -45,11 +45,13 @@ class CRM_Activity_Form_Task_PickProfile extends CRM_Activity_Form_Task { /** * Maximum Activities that should be allowed to update. + * @var int */ protected $_maxActivities = 100; /** * Variable to store redirect path. + * @var string */ protected $_userContext; diff --git a/CRM/Activity/Import/Field.php b/CRM/Activity/Import/Field.php index b36bdd7dc41c..b19a6002de94 100644 --- a/CRM/Activity/Import/Field.php +++ b/CRM/Activity/Import/Field.php @@ -40,6 +40,7 @@ class CRM_Activity_Import_Field { /** * Title of the field to be used in display + * @var string */ public $_title; diff --git a/CRM/Activity/Import/Form/MapField.php b/CRM/Activity/Import/Form/MapField.php index f2f59dc04f72..2b2e78053b6f 100644 --- a/CRM/Activity/Import/Form/MapField.php +++ b/CRM/Activity/Import/Form/MapField.php @@ -36,7 +36,6 @@ */ class CRM_Activity_Import_Form_MapField extends CRM_Import_Form_MapField { - /** * Set variables up before form is built. */ diff --git a/CRM/Activity/Import/Parser.php b/CRM/Activity/Import/Parser.php index aca16398574a..fc4aca0c20dc 100644 --- a/CRM/Activity/Import/Parser.php +++ b/CRM/Activity/Import/Parser.php @@ -36,16 +36,19 @@ abstract class CRM_Activity_Import_Parser extends CRM_Import_Parser { /** * Imported file size. + * @var int */ protected $_fileSize; /** * Separator being used. + * @var string */ protected $_seperator; /** * Total number of lines in file. + * @var int */ protected $_lineCount; @@ -63,6 +66,8 @@ abstract class CRM_Activity_Import_Parser extends CRM_Import_Parser { * @param bool $skipColumnHeader * @param int $mode * @param int $onDuplicate + * @param int $statusID + * @param int $totalRowCount * * @return mixed * @throws Exception diff --git a/CRM/Activity/Import/Parser/Activity.php b/CRM/Activity/Import/Parser/Activity.php index fbb3c6149737..de829240c3d7 100644 --- a/CRM/Activity/Import/Parser/Activity.php +++ b/CRM/Activity/Import/Parser/Activity.php @@ -47,7 +47,7 @@ class CRM_Activity_Import_Parser_Activity extends CRM_Activity_Import_Parser { /** * Array of successfully imported activity id's * - * @array + * @var array */ protected $_newActivity; diff --git a/CRM/Activity/Page/AJAX.php b/CRM/Activity/Page/AJAX.php index f96c4c0938d9..1da789c2734a 100644 --- a/CRM/Activity/Page/AJAX.php +++ b/CRM/Activity/Page/AJAX.php @@ -36,6 +36,7 @@ * This class contains all the function that are called using AJAX (jQuery) */ class CRM_Activity_Page_AJAX { + public static function getCaseActivity() { // Should those params be passed through the validateParams method? $caseID = CRM_Utils_Type::validate($_GET['caseID'], 'Integer'); @@ -143,7 +144,6 @@ public static function getCaseClientRelationships() { CRM_Utils_JSON::output($clientRelationshipsDT); } - public static function getCaseRoles() { $caseID = CRM_Utils_Type::escape($_GET['caseID'], 'Integer'); $contactID = CRM_Utils_Type::escape($_GET['cid'], 'Integer'); diff --git a/CRM/Activity/Selector/Activity.php b/CRM/Activity/Selector/Activity.php index befd1effda5b..e03072dbdd17 100644 --- a/CRM/Activity/Selector/Activity.php +++ b/CRM/Activity/Selector/Activity.php @@ -41,7 +41,7 @@ class CRM_Activity_Selector_Activity extends CRM_Core_Selector_Base implements C * * @var array */ - static $_columnHeaders; + public static $_columnHeaders; /** * ContactId - contact id of contact whose activies are displayed diff --git a/CRM/Activity/Selector/Search.php b/CRM/Activity/Selector/Search.php index f690f1bc534e..8a21dde81faa 100644 --- a/CRM/Activity/Selector/Search.php +++ b/CRM/Activity/Selector/Search.php @@ -43,21 +43,21 @@ class CRM_Activity_Selector_Search extends CRM_Core_Selector_Base implements CRM * * @var array */ - static $_links = NULL; + public static $_links = NULL; /** * We use desc to remind us what that column is, name is used in the tpl * * @var array */ - static $_columnHeaders; + public static $_columnHeaders; /** * Properties of contact we're interested in displaying * @var array */ - static $_properties = [ + public static $_properties = [ 'contact_id', 'contact_type', 'contact_sub_type', diff --git a/CRM/Activity/Task.php b/CRM/Activity/Task.php index bcd4cc804e70..00bfcbffd952 100644 --- a/CRM/Activity/Task.php +++ b/CRM/Activity/Task.php @@ -35,7 +35,7 @@ */ class CRM_Activity_Task extends CRM_Core_Task { - static $objectType = 'activity'; + public static $objectType = 'activity'; /** * These tasks are the core set of tasks that the user can perform diff --git a/CRM/Activity/Tokens.php b/CRM/Activity/Tokens.php index ebb83d02f125..3271b965922f 100644 --- a/CRM/Activity/Tokens.php +++ b/CRM/Activity/Tokens.php @@ -60,8 +60,7 @@ public function __construct() { */ public function checkActive(\Civi\Token\TokenProcessor $processor) { // Extracted from scheduled-reminders code. See the class description. - return - !empty($processor->context['actionMapping']) + return !empty($processor->context['actionMapping']) && $processor->context['actionMapping']->getEntity() === 'civicrm_activity'; } diff --git a/CRM/Admin/Form/LabelFormats.php b/CRM/Admin/Form/LabelFormats.php index 0a829c688999..6e3ad025df0c 100644 --- a/CRM/Admin/Form/LabelFormats.php +++ b/CRM/Admin/Form/LabelFormats.php @@ -39,11 +39,13 @@ class CRM_Admin_Form_LabelFormats extends CRM_Admin_Form { /** * Label Format ID. + * @var int */ protected $_id = NULL; /** * Group name, label format or name badge + * @var string */ protected $_group = NULL; diff --git a/CRM/Admin/Form/MessageTemplates.php b/CRM/Admin/Form/MessageTemplates.php index 8ff7528fdab3..06f0259ec921 100644 --- a/CRM/Admin/Form/MessageTemplates.php +++ b/CRM/Admin/Form/MessageTemplates.php @@ -36,10 +36,16 @@ * used by membership, contributions, event registrations, etc. */ class CRM_Admin_Form_MessageTemplates extends CRM_Admin_Form { - // which (and whether) mailing workflow this template belongs to + /** + * which (and whether) mailing workflow this template belongs to + * @var int + */ protected $_workflow_id = NULL; - // Is document file is already loaded as default value? + /** + * Is document file is already loaded as default value? + * @var bool + */ protected $_is_document = FALSE; public function preProcess() { diff --git a/CRM/Admin/Form/Navigation.php b/CRM/Admin/Form/Navigation.php index 370d0cdff772..cf885742b55e 100644 --- a/CRM/Admin/Form/Navigation.php +++ b/CRM/Admin/Form/Navigation.php @@ -38,6 +38,7 @@ class CRM_Admin_Form_Navigation extends CRM_Admin_Form { /** * The parent id of the navigation menu. + * @var int */ protected $_currentParentID = NULL; diff --git a/CRM/Admin/Form/PaymentProcessor.php b/CRM/Admin/Form/PaymentProcessor.php index aef46cc304f5..d8b32939550b 100644 --- a/CRM/Admin/Form/PaymentProcessor.php +++ b/CRM/Admin/Form/PaymentProcessor.php @@ -44,7 +44,8 @@ class CRM_Admin_Form_PaymentProcessor extends CRM_Admin_Form { protected $_paymentProcessorDAO; /** - * @var int $_paymentProcessorType Payment processor Type ID + * @var int + * Payment processor Type ID */ protected $_paymentProcessorType; @@ -448,7 +449,7 @@ public function updatePaymentProcessor(&$values, $domainID, $test) { else { $creditCards = "NULL"; } - $params = array_merge([ + $params = array_merge([ 'id' => $test ? $this->_testID : $this->_id, 'domain_id' => $domainID, 'is_test' => $test, diff --git a/CRM/Admin/Form/PdfFormats.php b/CRM/Admin/Form/PdfFormats.php index 94e29cbf03f7..ea8e7c40c91c 100644 --- a/CRM/Admin/Form/PdfFormats.php +++ b/CRM/Admin/Form/PdfFormats.php @@ -39,6 +39,7 @@ class CRM_Admin_Form_PdfFormats extends CRM_Admin_Form { /** * PDF Page Format ID. + * @var int */ protected $_id = NULL; diff --git a/CRM/Admin/Form/ScheduleReminders.php b/CRM/Admin/Form/ScheduleReminders.php index c7c89716fdcc..38e425bfd5f0 100644 --- a/CRM/Admin/Form/ScheduleReminders.php +++ b/CRM/Admin/Form/ScheduleReminders.php @@ -38,6 +38,7 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form { /** * Scheduled Reminder ID. + * @var int */ protected $_id = NULL; diff --git a/CRM/Admin/Form/Setting/Localization.php b/CRM/Admin/Form/Setting/Localization.php index 44829d550439..2940f4136fa6 100644 --- a/CRM/Admin/Form/Setting/Localization.php +++ b/CRM/Admin/Form/Setting/Localization.php @@ -255,7 +255,6 @@ public function postProcess() { } } - /** * Replace available currencies by the ones provided * @@ -286,7 +285,6 @@ public static function updateEnabledCurrencies($currencies, $default) { } - /** * @return array */ diff --git a/CRM/Admin/Form/SettingTrait.php b/CRM/Admin/Form/SettingTrait.php index b1b1cd31a482..6a056a95f88b 100644 --- a/CRM/Admin/Form/SettingTrait.php +++ b/CRM/Admin/Form/SettingTrait.php @@ -119,6 +119,7 @@ protected function getSettingMetadata($setting) { * e.g get 'serialize' key, if exists, for a field. * * @param $setting + * @param $item * @return mixed */ protected function getSettingMetadataItem($setting, $item) { @@ -294,6 +295,7 @@ protected function getQuickFormType($spec) { ]; return $mapping[$htmlType]; } + /** * Get the defaults for all fields defined in the metadata. * diff --git a/CRM/Admin/Page/AJAX.php b/CRM/Admin/Page/AJAX.php index f6dc2edee1fa..f782de942853 100644 --- a/CRM/Admin/Page/AJAX.php +++ b/CRM/Admin/Page/AJAX.php @@ -300,7 +300,7 @@ public static function getStatusMsg() { * * This appears to be only used by scheduled reminders. */ - static public function mappingList() { + public static function mappingList() { if (empty($_GET['mappingID'])) { CRM_Utils_JSON::output(['status' => 'error', 'error_msg' => 'required params missing.']); } @@ -383,10 +383,10 @@ public static function getTagTree() { } $dao = CRM_Utils_SQL_Select::from('civicrm_tag') - ->where($whereClauses) - ->groupBy('id') - ->orderBy($orderColumn) - ->execute(); + ->where($whereClauses) + ->groupBy('id') + ->orderBy($orderColumn) + ->execute(); while ($dao->fetch()) { if (!empty($substring)) { diff --git a/CRM/Admin/Page/APIExplorer.php b/CRM/Admin/Page/APIExplorer.php index 8414ec8ab325..a1ade427f6a9 100644 --- a/CRM/Admin/Page/APIExplorer.php +++ b/CRM/Admin/Page/APIExplorer.php @@ -59,7 +59,6 @@ private static function uniquePaths() { return $paths; } - /** * Run page. * diff --git a/CRM/Admin/Page/Access.php b/CRM/Admin/Page/Access.php index 54b2db56f72b..9d016ae5a19f 100644 --- a/CRM/Admin/Page/Access.php +++ b/CRM/Admin/Page/Access.php @@ -37,6 +37,7 @@ * For initial version, this page only contains static links - so this class is empty for now. */ class CRM_Admin_Page_Access extends CRM_Core_Page { + /** * @return string */ diff --git a/CRM/Admin/Page/Admin.php b/CRM/Admin/Page/Admin.php index eab28f37aad1..f195b5d693e0 100644 --- a/CRM/Admin/Page/Admin.php +++ b/CRM/Admin/Page/Admin.php @@ -35,6 +35,7 @@ * Page for displaying Administer CiviCRM Control Panel. */ class CRM_Admin_Page_Admin extends CRM_Core_Page { + /** * Run page. * diff --git a/CRM/Admin/Page/CKEditorConfig.php b/CRM/Admin/Page/CKEditorConfig.php index 03f7ec34b046..22f65399139c 100644 --- a/CRM/Admin/Page/CKEditorConfig.php +++ b/CRM/Admin/Page/CKEditorConfig.php @@ -245,6 +245,7 @@ public static function getConfigFile($preset = 'default') { } /** + * @param string $preset * @param string $contents */ public static function saveConfigFile($preset, $contents) { diff --git a/CRM/Admin/Page/ConfigTaskList.php b/CRM/Admin/Page/ConfigTaskList.php index 416a58d62d83..7d43f650e485 100644 --- a/CRM/Admin/Page/ConfigTaskList.php +++ b/CRM/Admin/Page/ConfigTaskList.php @@ -35,6 +35,7 @@ * Page for displaying list of site configuration tasks with links to each setting form. */ class CRM_Admin_Page_ConfigTaskList extends CRM_Core_Page { + /** * Run page. * diff --git a/CRM/Admin/Page/ContactType.php b/CRM/Admin/Page/ContactType.php index 1cfc16a5add9..b7d4dc2af287 100644 --- a/CRM/Admin/Page/ContactType.php +++ b/CRM/Admin/Page/ContactType.php @@ -43,7 +43,7 @@ class CRM_Admin_Page_ContactType extends CRM_Core_Page_Basic { * * @var array */ - static $_links = NULL; + public static $_links = NULL; /** * Get BAO Name. diff --git a/CRM/Admin/Page/EventTemplate.php b/CRM/Admin/Page/EventTemplate.php index 6c6ca7804fec..049b4d65667c 100644 --- a/CRM/Admin/Page/EventTemplate.php +++ b/CRM/Admin/Page/EventTemplate.php @@ -41,7 +41,7 @@ class CRM_Admin_Page_EventTemplate extends CRM_Core_Page_Basic { * * @var array */ - static $_links = NULL; + public static $_links = NULL; /** * Get BAO Name. diff --git a/CRM/Admin/Page/Extensions.php b/CRM/Admin/Page/Extensions.php index d242c9090be4..e190d36f636e 100644 --- a/CRM/Admin/Page/Extensions.php +++ b/CRM/Admin/Page/Extensions.php @@ -42,7 +42,7 @@ class CRM_Admin_Page_Extensions extends CRM_Core_Page_Basic { * * @var array */ - static $_links = NULL; + public static $_links = NULL; /** * Obtains the group name from url and sets the title. diff --git a/CRM/Admin/Page/Job.php b/CRM/Admin/Page/Job.php index 059fa9f58494..9fdc42cc44be 100644 --- a/CRM/Admin/Page/Job.php +++ b/CRM/Admin/Page/Job.php @@ -41,7 +41,7 @@ class CRM_Admin_Page_Job extends CRM_Core_Page_Basic { * * @var array */ - static $_links = NULL; + public static $_links = NULL; /** * Get BAO Name. diff --git a/CRM/Admin/Page/JobLog.php b/CRM/Admin/Page/JobLog.php index e5faee151dfc..b71ba3ab4d41 100644 --- a/CRM/Admin/Page/JobLog.php +++ b/CRM/Admin/Page/JobLog.php @@ -41,7 +41,7 @@ class CRM_Admin_Page_JobLog extends CRM_Core_Page_Basic { * * @var array */ - static $_links = NULL; + public static $_links = NULL; /** * Get BAO Name. diff --git a/CRM/Admin/Page/LabelFormats.php b/CRM/Admin/Page/LabelFormats.php index c90b5eba3d17..96b720a3d304 100644 --- a/CRM/Admin/Page/LabelFormats.php +++ b/CRM/Admin/Page/LabelFormats.php @@ -44,7 +44,7 @@ class CRM_Admin_Page_LabelFormats extends CRM_Core_Page_Basic { * * @var array */ - static $_links = NULL; + public static $_links = NULL; /** * Get BAO Name. diff --git a/CRM/Admin/Page/LocationType.php b/CRM/Admin/Page/LocationType.php index 16b2b25df69f..f22c00800a7b 100644 --- a/CRM/Admin/Page/LocationType.php +++ b/CRM/Admin/Page/LocationType.php @@ -43,7 +43,7 @@ class CRM_Admin_Page_LocationType extends CRM_Core_Page_Basic { * * @var array */ - static $_links = NULL; + public static $_links = NULL; /** * Get BAO Name. diff --git a/CRM/Admin/Page/MailSettings.php b/CRM/Admin/Page/MailSettings.php index 94b984a5e907..5a95c855e04d 100644 --- a/CRM/Admin/Page/MailSettings.php +++ b/CRM/Admin/Page/MailSettings.php @@ -43,7 +43,7 @@ class CRM_Admin_Page_MailSettings extends CRM_Core_Page_Basic { * * @var array */ - static $_links = NULL; + public static $_links = NULL; /** * Get BAO Name. diff --git a/CRM/Admin/Page/Mapping.php b/CRM/Admin/Page/Mapping.php index 33744306f0b5..0da215d2cc2c 100644 --- a/CRM/Admin/Page/Mapping.php +++ b/CRM/Admin/Page/Mapping.php @@ -43,7 +43,7 @@ class CRM_Admin_Page_Mapping extends CRM_Core_Page_Basic { * * @var array */ - static $_links = NULL; + public static $_links = NULL; /** * Get BAO. diff --git a/CRM/Admin/Page/MessageTemplates.php b/CRM/Admin/Page/MessageTemplates.php index 86efc76239c2..b81a56a0a02e 100644 --- a/CRM/Admin/Page/MessageTemplates.php +++ b/CRM/Admin/Page/MessageTemplates.php @@ -41,12 +41,18 @@ class CRM_Admin_Page_MessageTemplates extends CRM_Core_Page_Basic { * * @var array */ - static $_links = NULL; + public static $_links = NULL; - // ids of templates which diverted from the default ones and can be reverted + /** + * ids of templates which diverted from the default ones and can be reverted + * @var array + */ protected $_revertible = []; - // set to the id that we’re reverting at the given moment (if we are) + /** + * set to the id that we’re reverting at the given moment (if we are) + * @var int + */ protected $_revertedId; /** diff --git a/CRM/Admin/Page/Navigation.php b/CRM/Admin/Page/Navigation.php index eadce454feab..30234dacfca8 100644 --- a/CRM/Admin/Page/Navigation.php +++ b/CRM/Admin/Page/Navigation.php @@ -41,7 +41,7 @@ class CRM_Admin_Page_Navigation extends CRM_Core_Page_Basic { * * @var array */ - static $_links = NULL; + public static $_links = NULL; /** * Get BAO Name. diff --git a/CRM/Admin/Page/Options.php b/CRM/Admin/Page/Options.php index cf11d88def12..7ba567c047e8 100644 --- a/CRM/Admin/Page/Options.php +++ b/CRM/Admin/Page/Options.php @@ -43,35 +43,35 @@ class CRM_Admin_Page_Options extends CRM_Core_Page_Basic { * * @var array */ - static $_links = NULL; + public static $_links = NULL; /** * The option group name. * * @var array */ - static $_gName = NULL; + public static $_gName = NULL; /** * The option group name in display format (capitalized, without underscores...etc) * * @var array */ - static $_gLabel = NULL; + public static $_gLabel = NULL; /** * The option group id. * * @var array */ - static $_gId = NULL; + public static $_gId = NULL; /** * A boolean determining if you can add options to this group in the GUI. * * @var boolean */ - static $_isLocked = FALSE; + public static $_isLocked = FALSE; /** * Obtains the group name from url string or id from $_GET['gid']. diff --git a/CRM/Admin/Page/PaymentProcessor.php b/CRM/Admin/Page/PaymentProcessor.php index 4a5142e88a15..3ed9836bd18b 100644 --- a/CRM/Admin/Page/PaymentProcessor.php +++ b/CRM/Admin/Page/PaymentProcessor.php @@ -41,7 +41,7 @@ class CRM_Admin_Page_PaymentProcessor extends CRM_Core_Page_Basic { * * @var array */ - static $_links = NULL; + public static $_links = NULL; /** * Get BAO Name. diff --git a/CRM/Admin/Page/PaymentProcessorType.php b/CRM/Admin/Page/PaymentProcessorType.php index 212c60e42d41..ab366bd54f89 100644 --- a/CRM/Admin/Page/PaymentProcessorType.php +++ b/CRM/Admin/Page/PaymentProcessorType.php @@ -41,7 +41,7 @@ class CRM_Admin_Page_PaymentProcessorType extends CRM_Core_Page_Basic { * * @var array */ - static $_links = NULL; + public static $_links = NULL; /** * Get BAO Name. diff --git a/CRM/Admin/Page/PdfFormats.php b/CRM/Admin/Page/PdfFormats.php index ba7b0a2e48b0..24abb2921207 100644 --- a/CRM/Admin/Page/PdfFormats.php +++ b/CRM/Admin/Page/PdfFormats.php @@ -44,7 +44,7 @@ class CRM_Admin_Page_PdfFormats extends CRM_Core_Page_Basic { * * @var array */ - static $_links = NULL; + public static $_links = NULL; /** * Get BAO Name. diff --git a/CRM/Admin/Page/PreferencesDate.php b/CRM/Admin/Page/PreferencesDate.php index f1a65a769859..053d7efb28c0 100644 --- a/CRM/Admin/Page/PreferencesDate.php +++ b/CRM/Admin/Page/PreferencesDate.php @@ -41,7 +41,7 @@ class CRM_Admin_Page_PreferencesDate extends CRM_Core_Page_Basic { * * @var array */ - static $_links = NULL; + public static $_links = NULL; public $useLivePageJS = TRUE; diff --git a/CRM/Admin/Page/RelationshipType.php b/CRM/Admin/Page/RelationshipType.php index a93f8a70dab2..8657da762576 100644 --- a/CRM/Admin/Page/RelationshipType.php +++ b/CRM/Admin/Page/RelationshipType.php @@ -43,7 +43,7 @@ class CRM_Admin_Page_RelationshipType extends CRM_Core_Page_Basic { * * @var array */ - static $_links = NULL; + public static $_links = NULL; /** * Get BAO Name. diff --git a/CRM/Admin/Page/ScheduleReminders.php b/CRM/Admin/Page/ScheduleReminders.php index a4edd639585b..c87d5c654ec8 100644 --- a/CRM/Admin/Page/ScheduleReminders.php +++ b/CRM/Admin/Page/ScheduleReminders.php @@ -43,7 +43,7 @@ class CRM_Admin_Page_ScheduleReminders extends CRM_Core_Page_Basic { * * @var array */ - static $_links = NULL; + public static $_links = NULL; /** * Get BAO Name. diff --git a/CRM/Admin/Page/Setting.php b/CRM/Admin/Page/Setting.php index 35ba64de4b0e..0f747b58c155 100644 --- a/CRM/Admin/Page/Setting.php +++ b/CRM/Admin/Page/Setting.php @@ -35,6 +35,7 @@ * Page for displaying list of categories for Settings. */ class CRM_Admin_Page_Setting extends CRM_Core_Page { + /** * Run page. * diff --git a/CRM/Batch/BAO/Batch.php b/CRM/Batch/BAO/Batch.php index fb8dd25c32f3..aa87f7076f52 100644 --- a/CRM/Batch/BAO/Batch.php +++ b/CRM/Batch/BAO/Batch.php @@ -38,14 +38,16 @@ class CRM_Batch_BAO_Batch extends CRM_Batch_DAO_Batch { /** * Cache for the current batch object. + * @var object */ - static $_batch = NULL; + public static $_batch = NULL; /** * Not sure this is the best way to do this. Depends on how exportFinancialBatch() below gets called. * Maybe a parameter to that function is better. + * @var string */ - static $_exportFormat = NULL; + public static $_exportFormat = NULL; /** * Create a new batch. @@ -539,7 +541,6 @@ public static function getBatches() { return $batches; } - /** * Calculate sum of all entries in a batch. * Used to validate and update item_count and total when closing an accounting batch diff --git a/CRM/Batch/Form/Entry.php b/CRM/Batch/Form/Entry.php index ec698a8d1d0e..4d0671fa8e34 100644 --- a/CRM/Batch/Form/Entry.php +++ b/CRM/Batch/Form/Entry.php @@ -38,21 +38,25 @@ class CRM_Batch_Form_Entry extends CRM_Core_Form { /** * Maximum profile fields that will be displayed. + * @var int */ protected $_rowCount = 1; /** * Batch id. + * @var int */ protected $_batchId; /** * Batch information. + * @var array */ protected $_batchInfo = []; /** * Store the profile id associated with the batch type. + * @var int */ protected $_profileId; @@ -64,11 +68,13 @@ class CRM_Batch_Form_Entry extends CRM_Core_Form { /** * When not to reset sort_name. + * @var bool */ protected $_preserveDefault = TRUE; /** * Contact fields. + * @var array */ protected $_contactFields = []; @@ -88,6 +94,7 @@ class CRM_Batch_Form_Entry extends CRM_Core_Form { * These should get a standardised format in the beginPostProcess function. * * These fields are common to many forms. Some may override this. + * @var array */ protected $submittableMoneyFields = ['total_amount', 'net_amount', 'non_deductible_amount', 'fee_amount']; diff --git a/CRM/Batch/Form/Search.php b/CRM/Batch/Form/Search.php index daab61e9f82b..61b86a5f862b 100644 --- a/CRM/Batch/Form/Search.php +++ b/CRM/Batch/Form/Search.php @@ -31,6 +31,7 @@ * @copyright CiviCRM LLC (c) 2004-2019 */ class CRM_Batch_Form_Search extends CRM_Core_Form { + /** * Set default values. * diff --git a/CRM/Batch/Page/Batch.php b/CRM/Batch/Page/Batch.php index 5c9e06869525..6267d5d90dff 100644 --- a/CRM/Batch/Page/Batch.php +++ b/CRM/Batch/Page/Batch.php @@ -41,7 +41,7 @@ class CRM_Batch_Page_Batch extends CRM_Core_Page_Basic { * * @var array */ - static $_links = NULL; + public static $_links = NULL; /** * Get BAO Name. From 32e1f6ccb3ec721ea7fb8ba350d733dfd3a8d2ad Mon Sep 17 00:00:00 2001 From: eileen Date: Mon, 8 Apr 2019 09:33:02 +1200 Subject: [PATCH 101/121] Fix guzzle noisiness There is no reason to echo the failure here --- CRM/Utils/Check/Component.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CRM/Utils/Check/Component.php b/CRM/Utils/Check/Component.php index a3818e8ea3a4..9b2a02938cf7 100644 --- a/CRM/Utils/Check/Component.php +++ b/CRM/Utils/Check/Component.php @@ -62,9 +62,9 @@ public function checkAll() { * Check if file exists on given URL. * * @param string $url - * @param int $timeout + * @param float $timeout + * * @return bool - * @throws \GuzzleHttp\Exception\GuzzleException */ public function fileExists($url, $timeout = 0.50) { $fileExists = FALSE; @@ -76,7 +76,8 @@ public function fileExists($url, $timeout = 0.50) { $fileExists = ($guzzleResponse->getStatusCode() == 200); } catch (Exception $e) { - echo $e->getMessage(); + // At this stage we are not checking for variants of not being able to receive it. + // However, we might later enhance this to distinguish forbidden from a 500 error. } return $fileExists; } From 971e129ba60ff4699184047a1df9aa5daf678098 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Mon, 8 Apr 2019 07:45:09 +1000 Subject: [PATCH 102/121] (NFC) Update CRM/Member CRM/Note CRM/Logging CRM/Import and CRM/Price folders to be a future coder standard --- CRM/Import/DataSource/CSV.php | 6 +++--- CRM/Import/Form/DataSource.php | 3 +-- CRM/Import/Form/Preview.php | 4 ++-- CRM/Import/Form/Summary.php | 3 +-- CRM/Import/Parser.php | 11 +++++++++++ CRM/Logging/ReportDetail.php | 6 ++++-- CRM/Logging/Reverter.php | 2 +- CRM/Member/ActionMapping.php | 1 - CRM/Member/BAO/Membership.php | 13 ++++++++----- CRM/Member/BAO/MembershipBlock.php | 1 + CRM/Member/BAO/MembershipPayment.php | 1 - CRM/Member/BAO/MembershipStatus.php | 3 ++- CRM/Member/BAO/MembershipType.php | 6 +++--- CRM/Member/BAO/Query.php | 3 ++- CRM/Member/Form.php | 2 +- CRM/Member/Form/Membership.php | 15 ++++++++++----- CRM/Member/Form/MembershipBlock.php | 1 + CRM/Member/Form/MembershipRenewal.php | 5 +++++ CRM/Member/Form/MembershipStatus.php | 2 +- CRM/Member/Form/MembershipView.php | 2 +- CRM/Member/Form/Search.php | 1 + CRM/Member/Form/Task/Batch.php | 2 ++ CRM/Member/Form/Task/PickProfile.php | 2 ++ CRM/Member/Import/Field.php | 5 ++++- CRM/Member/Import/Form/MapField.php | 3 +-- CRM/Member/Import/Parser.php | 8 +++++++- CRM/Member/Import/Parser/Membership.php | 2 +- CRM/Member/Info.php | 7 ++++++- CRM/Member/Page/MembershipStatus.php | 2 +- CRM/Member/Page/MembershipType.php | 2 +- CRM/Member/Page/Tab.php | 4 ++-- CRM/Member/PseudoConstant.php | 2 +- CRM/Member/Selector/Search.php | 6 +++--- CRM/Member/Task.php | 12 ++++++++---- CRM/Member/Tokens.php | 3 +-- CRM/Note/Form/Note.php | 5 ++--- CRM/Price/BAO/LineItem.php | 7 ++++--- CRM/Price/BAO/PriceField.php | 3 ++- CRM/Price/BAO/PriceSet.php | 3 +-- CRM/Price/Form/Field.php | 1 + CRM/Price/Page/Option.php | 12 ++++++------ 41 files changed, 115 insertions(+), 67 deletions(-) diff --git a/CRM/Import/DataSource/CSV.php b/CRM/Import/DataSource/CSV.php index d51acd596219..69108e32629a 100644 --- a/CRM/Import/DataSource/CSV.php +++ b/CRM/Import/DataSource/CSV.php @@ -75,9 +75,9 @@ public function buildQuickForm(&$form) { $form->add('File', 'uploadFile', ts('Import Data File'), 'size=30 maxlength=255', TRUE); $form->setMaxFileSize($uploadFileSize); $form->addRule('uploadFile', ts('File size should be less than %1 MBytes (%2 bytes)', [ - 1 => $uploadSize, - 2 => $uploadFileSize, - ]), 'maxfilesize', $uploadFileSize); + 1 => $uploadSize, + 2 => $uploadFileSize, + ]), 'maxfilesize', $uploadFileSize); $form->addRule('uploadFile', ts('Input file must be in CSV format'), 'utf8File'); $form->addRule('uploadFile', ts('A valid file must be uploaded.'), 'uploadedfile'); diff --git a/CRM/Import/Form/DataSource.php b/CRM/Import/Form/DataSource.php index bbce16843453..ae577f0c519c 100644 --- a/CRM/Import/Form/DataSource.php +++ b/CRM/Import/Form/DataSource.php @@ -103,8 +103,7 @@ public function buildQuickForm() { 'type' => 'cancel', 'name' => ts('Cancel'), ], - ] - ); + ]); } /** diff --git a/CRM/Import/Form/Preview.php b/CRM/Import/Form/Preview.php index 4e9dcf71ce41..88810af0ba99 100644 --- a/CRM/Import/Form/Preview.php +++ b/CRM/Import/Form/Preview.php @@ -38,6 +38,7 @@ * those classes can be removed entirely and this class will not need to be abstract */ abstract class CRM_Import_Form_Preview extends CRM_Core_Form { + /** * Return a descriptive name for the page, used in wizard header. * @@ -66,8 +67,7 @@ public function buildQuickForm() { 'type' => 'cancel', 'name' => ts('Cancel'), ], - ] - ); + ]); } /** diff --git a/CRM/Import/Form/Summary.php b/CRM/Import/Form/Summary.php index 84f8d035936a..f24de6ebb9cf 100644 --- a/CRM/Import/Form/Summary.php +++ b/CRM/Import/Form/Summary.php @@ -49,8 +49,7 @@ public function buildQuickForm() { 'name' => ts('Done'), 'isDefault' => TRUE, ), - ) - ); + )); } /** diff --git a/CRM/Import/Parser.php b/CRM/Import/Parser.php index 70628323096c..cf01fdd05482 100644 --- a/CRM/Import/Parser.php +++ b/CRM/Import/Parser.php @@ -59,16 +59,19 @@ abstract class CRM_Import_Parser { /** * Total number of non empty lines + * @var int */ protected $_totalCount; /** * Running total number of valid lines + * @var int */ protected $_validCount; /** * Running total number of invalid rows + * @var int */ protected $_invalidRowCount; @@ -81,41 +84,49 @@ abstract class CRM_Import_Parser { /** * Array of error lines, bounded by MAX_ERROR + * @var array */ protected $_errors; /** * Total number of conflict lines + * @var int */ protected $_conflictCount; /** * Array of conflict lines + * @var array */ protected $_conflicts; /** * Total number of duplicate (from database) lines + * @var int */ protected $_duplicateCount; /** * Array of duplicate lines + * @var array */ protected $_duplicates; /** * Running total number of warnings + * @var int */ protected $_warningCount; /** * Maximum number of warnings to store + * @var int */ protected $_maxWarningCount = self::MAX_WARNINGS; /** * Array of warning lines, bounded by MAX_WARNING + * @var array */ protected $_warnings; diff --git a/CRM/Logging/ReportDetail.php b/CRM/Logging/ReportDetail.php index 3200b4482b68..7d89f4c96d54 100644 --- a/CRM/Logging/ReportDetail.php +++ b/CRM/Logging/ReportDetail.php @@ -52,7 +52,10 @@ class CRM_Logging_ReportDetail extends CRM_Report_Form { protected $altered_by; protected $altered_by_id; - // detail/summary report ids + /** + * detail/summary report ids + * @var int + */ protected $detail; protected $summary; @@ -281,7 +284,6 @@ protected function calculateContactDiffs() { $this->diffs = $this->getAllContactChangesForConnection(); } - /** * Get an array of changes made in the mysql connection. * diff --git a/CRM/Logging/Reverter.php b/CRM/Logging/Reverter.php index 7a1085f24621..844dcddca79f 100644 --- a/CRM/Logging/Reverter.php +++ b/CRM/Logging/Reverter.php @@ -128,7 +128,7 @@ public function revert() { // DAO-based tables case (($tableDAO = CRM_Core_DAO_AllCoreTables::getClassForTable($table)) != FALSE): - $dao = new $tableDAO (); + $dao = new $tableDAO(); foreach ($row as $id => $changes) { $dao->id = $id; foreach ($changes as $field => $value) { diff --git a/CRM/Member/ActionMapping.php b/CRM/Member/ActionMapping.php index 3546c48f9086..ee9c1b817076 100644 --- a/CRM/Member/ActionMapping.php +++ b/CRM/Member/ActionMapping.php @@ -25,7 +25,6 @@ +--------------------------------------------------------------------+ */ -use Civi\ActionSchedule\RecipientBuilder; /** * Class CRM_Member_ActionMapping diff --git a/CRM/Member/BAO/Membership.php b/CRM/Member/BAO/Membership.php index 8ad4e754496c..b359fdd15d0b 100644 --- a/CRM/Member/BAO/Membership.php +++ b/CRM/Member/BAO/Membership.php @@ -37,11 +37,11 @@ class CRM_Member_BAO_Membership extends CRM_Member_DAO_Membership { * * @var array */ - static $_importableFields = NULL; + public static $_importableFields = NULL; - static $_renewalActType = NULL; + public static $_renewalActType = NULL; - static $_signupActType = NULL; + public static $_signupActType = NULL; /** * Class constructor. @@ -601,6 +601,7 @@ public static function getStatusANDTypeValues($membershipId) { * * @param int $membershipId * Membership id that needs to be deleted. + * @param bool $preserveContrib * * @return int * Id of deleted Membership on success, false otherwise. @@ -616,6 +617,7 @@ public static function del($membershipId, $preserveContrib = FALSE) { * * @param int $membershipId * Membership id that needs to be deleted. + * @param bool $preserveContrib * * @return int * Id of deleted Membership on success, false otherwise. @@ -1114,7 +1116,7 @@ public static function statusAvailabilty() { * @param CRM_Member_DAO_Membership $membership * @param \CRM_Contribute_BAO_Contribution|\CRM_Contribute_DAO_Contribution $contribution */ - static public function updateRecurMembership(CRM_Member_DAO_Membership $membership, CRM_Contribute_BAO_Contribution $contribution) { + public static function updateRecurMembership(CRM_Member_DAO_Membership $membership, CRM_Contribute_BAO_Contribution $contribution) { if (empty($contribution->contribution_recur_id)) { return; @@ -1517,6 +1519,7 @@ public static function createRelatedMemberships(&$params, &$dao, $reset = FALSE) * Delete the record that are associated with this Membership Payment. * * @param int $membershipId + * @param bool $preserveContrib * * @return object * $membershipPayment deleted membership payment object @@ -2192,7 +2195,7 @@ public function processPriceSet($membershipId, $lineItem) { * * @param int $membershipId * Membership id. - * @all bool + * @param bool $all * if more than one payment associated with membership id need to be returned. * * @return int|int[] diff --git a/CRM/Member/BAO/MembershipBlock.php b/CRM/Member/BAO/MembershipBlock.php index 79891bed9944..8b785a42ec4d 100644 --- a/CRM/Member/BAO/MembershipBlock.php +++ b/CRM/Member/BAO/MembershipBlock.php @@ -33,6 +33,7 @@ * */ class CRM_Member_BAO_MembershipBlock extends CRM_Member_DAO_MembershipBlock { + /** * Class constructor. */ diff --git a/CRM/Member/BAO/MembershipPayment.php b/CRM/Member/BAO/MembershipPayment.php index bacf50d2f770..7a509ec3e26d 100644 --- a/CRM/Member/BAO/MembershipPayment.php +++ b/CRM/Member/BAO/MembershipPayment.php @@ -34,7 +34,6 @@ */ class CRM_Member_BAO_MembershipPayment extends CRM_Member_DAO_MembershipPayment { - /** * Class constructor. */ diff --git a/CRM/Member/BAO/MembershipStatus.php b/CRM/Member/BAO/MembershipStatus.php index 8b4b5329014b..c3508a7e1776 100644 --- a/CRM/Member/BAO/MembershipStatus.php +++ b/CRM/Member/BAO/MembershipStatus.php @@ -36,8 +36,9 @@ class CRM_Member_BAO_MembershipStatus extends CRM_Member_DAO_MembershipStatus { /** * Static holder for the default LT. + * @var int */ - static $_defaultMembershipStatus = NULL; + public static $_defaultMembershipStatus = NULL; /** * Class constructor. diff --git a/CRM/Member/BAO/MembershipType.php b/CRM/Member/BAO/MembershipType.php index 521fa621cd91..745294615101 100644 --- a/CRM/Member/BAO/MembershipType.php +++ b/CRM/Member/BAO/MembershipType.php @@ -36,10 +36,11 @@ class CRM_Member_BAO_MembershipType extends CRM_Member_DAO_MembershipType { /** * Static holder for the default Membership Type. + * @var int */ - static $_defaultMembershipType = NULL; + public static $_defaultMembershipType = NULL; - static $_membershipTypeInfo = []; + public static $_membershipTypeInfo = []; /** * Class constructor. @@ -716,7 +717,6 @@ public static function getMembershipTypeInfo() { return self::$_membershipTypeInfo; } - /** * @param array $params * @param int $previousID diff --git a/CRM/Member/BAO/Query.php b/CRM/Member/BAO/Query.php index 19a526d7f86e..3294569e6c52 100644 --- a/CRM/Member/BAO/Query.php +++ b/CRM/Member/BAO/Query.php @@ -233,7 +233,8 @@ public static function whereClauseSingle(&$values, &$query) { $value = ['IN' => explode(',', $value)]; } case 'membership_id': - case 'member_id': // CRM-18523 Updated to membership_id but kept member_id case for backwards compatibility + // CRM-18523 Updated to membership_id but kept member_id case for backwards compatibility + case 'member_id': case 'member_campaign_id': if (strpos($name, 'status') !== FALSE) { diff --git a/CRM/Member/Form.php b/CRM/Member/Form.php index 724aeed5528e..3bd495fefefd 100644 --- a/CRM/Member/Form.php +++ b/CRM/Member/Form.php @@ -47,7 +47,7 @@ class CRM_Member_Form extends CRM_Contribute_Form_AbstractEditPayment { /** * Membership Type ID - * @var + * @var int */ protected $_memType; diff --git a/CRM/Member/Form/Membership.php b/CRM/Member/Form/Membership.php index bbf97b31cd59..ec39152a4418 100644 --- a/CRM/Member/Form/Membership.php +++ b/CRM/Member/Form/Membership.php @@ -57,6 +57,7 @@ class CRM_Member_Form_Membership extends CRM_Member_Form { /** * email of the person paying for the membership (used for receipts) + * @var string */ protected $_memberEmail = NULL; @@ -76,6 +77,7 @@ class CRM_Member_Form_Membership extends CRM_Member_Form { /** * email of the person paying for the membership (used for receipts) + * @var string */ protected $_contributorEmail = NULL; @@ -128,7 +130,7 @@ protected function setEntityFields() { */ public function setDeleteMessage() { $this->deleteMessage = '' - . ts("WARNING: Deleting this membership will also delete any related payment (contribution) records." . ts("This action cannot be undone.") + . ts("WARNING: Deleting this membership will also delete any related payment (contribution) records." . ts("This action cannot be undone.") . '

        ' . ts("Consider modifying the membership status instead if you want to maintain an audit trail and avoid losing payment data. You can set the status to Cancelled by editing the membership and clicking the Status Override checkbox.") . '

        ' @@ -142,7 +144,6 @@ public function setDeleteMessage() { */ public function addCustomDataToForm() {} - /** * Overriding this entity trait function as not yet tested. * @@ -1730,9 +1731,12 @@ public function submit() { */ protected function updateContributionOnMembershipTypeChange($inputParams, $membership) { if (Civi::settings()->get('update_contribution_on_membership_type_change') && - ($this->_action & CRM_Core_Action::UPDATE) && // on update - $this->_id && // if ID is present - !in_array($this->_memType, $this->_memTypeSelected) // if selected membership doesn't match with earlier membership + // on update + ($this->_action & CRM_Core_Action::UPDATE) && + // if ID is present + $this->_id && + // if selected membership doesn't match with earlier membership + !in_array($this->_memType, $this->_memTypeSelected) ) { if (CRM_Utils_Array::value('is_recur', $inputParams)) { CRM_Core_Session::setStatus(ts('Associated recurring contribution cannot be updated on membership type change.', ts('Error'), 'error')); @@ -1797,6 +1801,7 @@ public static function addPriceFieldByMembershipType(&$formValues, $priceFields, } } } + /** * Set context in session. */ diff --git a/CRM/Member/Form/MembershipBlock.php b/CRM/Member/Form/MembershipBlock.php index bf0f4554b686..83df3d77a151 100644 --- a/CRM/Member/Form/MembershipBlock.php +++ b/CRM/Member/Form/MembershipBlock.php @@ -38,6 +38,7 @@ class CRM_Member_Form_MembershipBlock extends CRM_Contribute_Form_ContributionPa /** * Store membership price set id + * @var int */ protected $_memPriceSetId = NULL; diff --git a/CRM/Member/Form/MembershipRenewal.php b/CRM/Member/Form/MembershipRenewal.php index e3857d1a5d15..096e45e65254 100644 --- a/CRM/Member/Form/MembershipRenewal.php +++ b/CRM/Member/Form/MembershipRenewal.php @@ -45,6 +45,7 @@ class CRM_Member_Form_MembershipRenewal extends CRM_Member_Form { /** * email of the person paying for the membership (used for receipts) + * @var string */ protected $_memberEmail = NULL; @@ -65,6 +66,7 @@ class CRM_Member_Form_MembershipRenewal extends CRM_Member_Form { /** * email of the person paying for the membership (used for receipts) + * @var string */ protected $_contributorEmail = NULL; @@ -85,6 +87,7 @@ class CRM_Member_Form_MembershipRenewal extends CRM_Member_Form { /** * context would be set to standalone if the contact is use is being selected from * the form rather than in the URL + * @var string */ public $_context; @@ -402,6 +405,8 @@ public function buildQuickForm() { * * @param array $params * (ref.) an assoc array of name/value pairs. + * @param $files + * @param $self * * @return bool|array * mixed true or array of errors diff --git a/CRM/Member/Form/MembershipStatus.php b/CRM/Member/Form/MembershipStatus.php index 030ff03cd992..5f644507e375 100644 --- a/CRM/Member/Form/MembershipStatus.php +++ b/CRM/Member/Form/MembershipStatus.php @@ -91,7 +91,7 @@ protected function setEntityFields() { * We do this from the constructor in order to do a translation. */ public function setDeleteMessage() { - $this->deleteMessage = ts('You will not be able to delete this membership status if there are existing memberships with this status. You will need to check all your membership status rules afterwards to ensure that a valid status will always be available.') . " " . ts('Do you want to continue?'); + $this->deleteMessage = ts('You will not be able to delete this membership status if there are existing memberships with this status. You will need to check all your membership status rules afterwards to ensure that a valid status will always be available.') . " " . ts('Do you want to continue?'); } public function preProcess() { diff --git a/CRM/Member/Form/MembershipView.php b/CRM/Member/Form/MembershipView.php index 3d60d9a9b652..05520fb1d342 100644 --- a/CRM/Member/Form/MembershipView.php +++ b/CRM/Member/Form/MembershipView.php @@ -43,7 +43,7 @@ class CRM_Member_Form_MembershipView extends CRM_Core_Form { * * @var array */ - static $_links = NULL; + public static $_links = NULL; /** * The id of the membership being viewed. diff --git a/CRM/Member/Form/Search.php b/CRM/Member/Form/Search.php index 46a4acad2f43..8eba67bfa9c7 100644 --- a/CRM/Member/Form/Search.php +++ b/CRM/Member/Form/Search.php @@ -61,6 +61,7 @@ class CRM_Member_Form_Search extends CRM_Core_Form_Search { /** * Prefix for the controller. + * @var string */ protected $_prefix = "member_"; diff --git a/CRM/Member/Form/Task/Batch.php b/CRM/Member/Form/Task/Batch.php index 232595017bbc..99d6af35a4e6 100644 --- a/CRM/Member/Form/Task/Batch.php +++ b/CRM/Member/Form/Task/Batch.php @@ -45,11 +45,13 @@ class CRM_Member_Form_Task_Batch extends CRM_Member_Form_Task { /** * Maximum profile fields that will be displayed. + * @var int */ protected $_maxFields = 9; /** * Variable to store redirect path. + * @var string */ protected $_userContext; diff --git a/CRM/Member/Form/Task/PickProfile.php b/CRM/Member/Form/Task/PickProfile.php index 6648dadadbea..68b6ba1b53c7 100644 --- a/CRM/Member/Form/Task/PickProfile.php +++ b/CRM/Member/Form/Task/PickProfile.php @@ -47,11 +47,13 @@ class CRM_Member_Form_Task_PickProfile extends CRM_Member_Form_Task { /** * Maximum members that should be allowed to update + * @var int */ protected $_maxMembers = 100; /** * Variable to store redirect path + * @var string */ protected $_userContext; diff --git a/CRM/Member/Import/Field.php b/CRM/Member/Import/Field.php index fe6448043083..93bb374bc825 100644 --- a/CRM/Member/Import/Field.php +++ b/CRM/Member/Import/Field.php @@ -34,17 +34,20 @@ */ class CRM_Member_Import_Field { - /**#@+ + /** + * #@+ * @var string */ /** * Name of the field + * @var string */ public $_name; /** * Title of the field to be used in display + * @var string */ public $_title; diff --git a/CRM/Member/Import/Form/MapField.php b/CRM/Member/Import/Form/MapField.php index f02fa045dc80..fa849f6449fd 100644 --- a/CRM/Member/Import/Form/MapField.php +++ b/CRM/Member/Import/Form/MapField.php @@ -44,8 +44,7 @@ class CRM_Member_Import_Form_MapField extends CRM_Import_Form_MapField { * * @var int */ - static $_contactType = NULL; - + public static $_contactType = NULL; /** * Set variables up before form is built. diff --git a/CRM/Member/Import/Parser.php b/CRM/Member/Import/Parser.php index d8e631cc97a3..cf7367687609 100644 --- a/CRM/Member/Import/Parser.php +++ b/CRM/Member/Import/Parser.php @@ -36,22 +36,26 @@ abstract class CRM_Member_Import_Parser extends CRM_Import_Parser { protected $_fileName; - /**#@+ + /** + * #@+ * @var integer */ /** * Imported file size + * @var int */ protected $_fileSize; /** * Seperator being used + * @var string */ protected $_seperator; /** * Total number of lines in file + * @var int */ protected $_lineCount; @@ -70,6 +74,8 @@ abstract class CRM_Member_Import_Parser extends CRM_Import_Parser { * @param int $mode * @param int $contactType * @param int $onDuplicate + * @param int $statusID + * @param int $totalRowCount * * @return mixed * @throws Exception diff --git a/CRM/Member/Import/Parser/Membership.php b/CRM/Member/Import/Parser/Membership.php index 974c4294debd..66147109a9b3 100644 --- a/CRM/Member/Import/Parser/Membership.php +++ b/CRM/Member/Import/Parser/Membership.php @@ -51,7 +51,7 @@ class CRM_Member_Import_Parser_Membership extends CRM_Member_Import_Parser { /** * Array of successfully imported membership id's * - * @array + * @var array */ protected $_newMemberships; diff --git a/CRM/Member/Info.php b/CRM/Member/Info.php index c0f177ca2c02..059c72072607 100644 --- a/CRM/Member/Info.php +++ b/CRM/Member/Info.php @@ -38,6 +38,7 @@ class CRM_Member_Info extends CRM_Core_Component_Info { /** + * @var string * @inheritDoc */ protected $keyword = 'member'; @@ -51,6 +52,7 @@ class CRM_Member_Info extends CRM_Core_Component_Info { * @return array * collection of required component settings */ + /** * @return array */ @@ -64,7 +66,6 @@ public function getInfo() { ]; } - /** * @inheritDoc * Provides permissions that are used by component. @@ -115,6 +116,7 @@ public function getPermissions($getAllUnconditionally = FALSE, $descriptions = F * collection of required dashboard settings, * null if no element offered */ + /** * @return array|null */ @@ -139,6 +141,7 @@ public function getUserDashboardElement() { * collection of required dashboard settings, * null if no element offered */ + /** * @return array|null */ @@ -167,6 +170,7 @@ public function getIcon() { * collection of required pane settings, * null if no element offered */ + /** * @return array|null */ @@ -187,6 +191,7 @@ public function registerAdvancedSearchPane() { * @return array|null * collection of activity types */ + /** * @return array|null */ diff --git a/CRM/Member/Page/MembershipStatus.php b/CRM/Member/Page/MembershipStatus.php index 9cf874424068..c4e4b605d0c3 100644 --- a/CRM/Member/Page/MembershipStatus.php +++ b/CRM/Member/Page/MembershipStatus.php @@ -45,7 +45,7 @@ class CRM_Member_Page_MembershipStatus extends CRM_Core_Page_Basic { * * @var array */ - static $_links = NULL; + public static $_links = NULL; /** * Get BAO Name. diff --git a/CRM/Member/Page/MembershipType.php b/CRM/Member/Page/MembershipType.php index 96c16a60a8ee..e7807d67dad4 100644 --- a/CRM/Member/Page/MembershipType.php +++ b/CRM/Member/Page/MembershipType.php @@ -43,7 +43,7 @@ class CRM_Member_Page_MembershipType extends CRM_Core_Page { * * @var array */ - static $_links = NULL; + public static $_links = NULL; public $useLivePageJS = TRUE; diff --git a/CRM/Member/Page/Tab.php b/CRM/Member/Page/Tab.php index f51fdc13254a..9d6f944e1158 100644 --- a/CRM/Member/Page/Tab.php +++ b/CRM/Member/Page/Tab.php @@ -39,8 +39,8 @@ class CRM_Member_Page_Tab extends CRM_Core_Page { * * @var array */ - static $_links = NULL; - static $_membershipTypesLinks = NULL; + public static $_links = NULL; + public static $_membershipTypesLinks = NULL; public $_permission = NULL; public $_contactId = NULL; diff --git a/CRM/Member/PseudoConstant.php b/CRM/Member/PseudoConstant.php index af904929f7cf..417de01f0f77 100644 --- a/CRM/Member/PseudoConstant.php +++ b/CRM/Member/PseudoConstant.php @@ -92,7 +92,7 @@ public static function membershipType($id = NULL, $force = TRUE) { * @param bool $allStatus * * @return array - * array reference of all membership statuses if any + * array reference of all membership statuses if any */ public static function &membershipStatus($id = NULL, $cond = NULL, $column = 'name', $force = FALSE, $allStatus = FALSE) { if (self::$membershipStatus === NULL) { diff --git a/CRM/Member/Selector/Search.php b/CRM/Member/Selector/Search.php index 7775ecde8c56..850046d86574 100644 --- a/CRM/Member/Selector/Search.php +++ b/CRM/Member/Selector/Search.php @@ -43,20 +43,20 @@ class CRM_Member_Selector_Search extends CRM_Core_Selector_Base implements CRM_C * * @var array */ - static $_links = NULL; + public static $_links = NULL; /** * We use desc to remind us what that column is, name is used in the tpl * * @var array */ - static $_columnHeaders; + public static $_columnHeaders; /** * Properties of contact we're interested in displaying * @var array */ - static $_properties = [ + public static $_properties = [ 'contact_id', 'membership_id', 'contact_type', diff --git a/CRM/Member/Task.php b/CRM/Member/Task.php index 0827a267800e..3d17b53fdf82 100644 --- a/CRM/Member/Task.php +++ b/CRM/Member/Task.php @@ -40,11 +40,15 @@ * */ class CRM_Member_Task extends CRM_Core_Task { - const - // Member tasks - LABEL_MEMBERS = 201; + /** + * Member tasks + */ + const LABEL_MEMBERS = 201; - static $objectType = 'membership'; + /** + * @var string + */ + public static $objectType = 'membership'; /** * These tasks are the core set of tasks that the user can perform diff --git a/CRM/Member/Tokens.php b/CRM/Member/Tokens.php index 3e2dc921f80a..44100317acad 100644 --- a/CRM/Member/Tokens.php +++ b/CRM/Member/Tokens.php @@ -63,8 +63,7 @@ public function __construct() { */ public function checkActive(\Civi\Token\TokenProcessor $processor) { // Extracted from scheduled-reminders code. See the class description. - return - !empty($processor->context['actionMapping']) + return !empty($processor->context['actionMapping']) && $processor->context['actionMapping']->getEntity() === 'civicrm_membership'; } diff --git a/CRM/Note/Form/Note.php b/CRM/Note/Form/Note.php index 2b7478d64d57..9e1cfeebde32 100644 --- a/CRM/Note/Form/Note.php +++ b/CRM/Note/Form/Note.php @@ -143,8 +143,7 @@ public function buildQuickForm() { 'type' => 'cancel', 'name' => ts('Cancel'), ], - ] - ); + ]); return; } @@ -166,7 +165,7 @@ public function buildQuickForm() { 'type' => 'cancel', 'name' => ts('Cancel'), ], - ] + ] ); } diff --git a/CRM/Price/BAO/LineItem.php b/CRM/Price/BAO/LineItem.php index 55af3bcca800..4524376162f0 100644 --- a/CRM/Price/BAO/LineItem.php +++ b/CRM/Price/BAO/LineItem.php @@ -799,7 +799,7 @@ public static function changeFeeSelections( * @param array $lineItemsToUpdate * * @return array - * List of formatted reverse Financial Items to be recorded + * List of formatted reverse Financial Items to be recorded */ protected function getAdjustedFinancialItemsToRecord($entityID, $entityTable, $contributionID, $priceFieldValueIDsToCancel, $lineItemsToUpdate) { $previousLineItems = CRM_Price_BAO_LineItem::getLineItems($entityID, str_replace('civicrm_', '', $entityTable)); @@ -872,7 +872,7 @@ protected function checkFinancialItemTotalAmountByLineItemID($lineItemID) { * @param array $feeBlock * * @return array - * List of submitted line items + * List of submitted line items */ protected function getSubmittedLineItems($inputParams, $feeBlock) { $submittedLineItems = []; @@ -896,7 +896,7 @@ protected function getSubmittedLineItems($inputParams, $feeBlock) { * @param string $entity * * @return array - * Array of line items to alter with the following keys + * Array of line items to alter with the following keys * - line_items_to_add. If the line items required are new radio options that * have not previously been set then we should add line items for them * - line_items_to_update. If we have already been an active option and a change has @@ -980,6 +980,7 @@ protected function isCancelled($lineItem) { return TRUE; } } + /** * Add line Items as result of fee change. * diff --git a/CRM/Price/BAO/PriceField.php b/CRM/Price/BAO/PriceField.php index f6bb64992194..0085d6ec89d1 100644 --- a/CRM/Price/BAO/PriceField.php +++ b/CRM/Price/BAO/PriceField.php @@ -842,7 +842,8 @@ public static function priceSetValidation($priceSetId, $fields, &$error, $allowN $error['_qf_default'] = ts('%1 amount can not be less than zero. Please select the options accordingly.', [1 => $componentName]); } elseif ($totalAmount > 0 && - $totalPaymentAmountEnteredOnForm >= $totalAmount && // if total amount is equal to all selected amount in hand + // if total amount is equal to all selected amount in hand + $totalPaymentAmountEnteredOnForm >= $totalAmount && (CRM_Utils_Array::value('contribution_status_id', $fields) == CRM_Core_PseudoConstant::getKey('CRM_Contribute_DAO_Contribution', 'contribution_status_id', 'Partially paid')) ) { $error['total_amount'] = ts('You have specified the status Partially Paid but have entered an amount that equals or exceeds the amount due. Please adjust the status of the payment or the amount'); diff --git a/CRM/Price/BAO/PriceSet.php b/CRM/Price/BAO/PriceSet.php index cd2908f7b633..ff2e0c3b7712 100644 --- a/CRM/Price/BAO/PriceSet.php +++ b/CRM/Price/BAO/PriceSet.php @@ -42,7 +42,7 @@ class CRM_Price_BAO_PriceSet extends CRM_Price_DAO_PriceSet { * * @var array */ - static $_defaultPriceSet = NULL; + public static $_defaultPriceSet = NULL; /** * Class constructor. @@ -559,7 +559,6 @@ public static function getOnlyPriceFieldValueID(array $priceSet) { return (int) implode('_', array_keys($priceSet['fields'][$priceFieldID]['options'])); } - /** * Initiate price set such that various non-BAO things are set on the form. * diff --git a/CRM/Price/Form/Field.php b/CRM/Price/Form/Field.php index 3888e781e896..dc237c1fa735 100644 --- a/CRM/Price/Form/Field.php +++ b/CRM/Price/Form/Field.php @@ -64,6 +64,7 @@ class CRM_Price_Form_Field extends CRM_Core_Form { /** * Variable is set if price set is used for membership. + * @var bool */ protected $_useForMember; diff --git a/CRM/Price/Page/Option.php b/CRM/Price/Page/Option.php index a8ec96fb8d3e..bdf06ffc3631 100644 --- a/CRM/Price/Page/Option.php +++ b/CRM/Price/Page/Option.php @@ -122,14 +122,14 @@ public static function &actionLinks() { */ public function browse() { $priceOptions = civicrm_api3('PriceFieldValue', 'get', [ - 'price_field_id' => $this->_fid, + 'price_field_id' => $this->_fid, // Explicitly do not check permissions so we are not // restricted by financial type, so we can change them. - 'check_permissions' => FALSE, - 'options' => [ - 'limit' => 0, - 'sort' => ['weight', 'label'], - ], + 'check_permissions' => FALSE, + 'options' => [ + 'limit' => 0, + 'sort' => ['weight', 'label'], + ], ]); $customOption = $priceOptions['values']; From 24fbfa897ef4fb6421f535a28db87630597d8a40 Mon Sep 17 00:00:00 2001 From: DemeritCowboy Date: Sun, 7 Apr 2019 22:31:36 -0400 Subject: [PATCH 103/121] fix formRule signature --- CRM/Case/Form/Search.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CRM/Case/Form/Search.php b/CRM/Case/Form/Search.php index 313b74aa8ead..894e0059e34a 100644 --- a/CRM/Case/Form/Search.php +++ b/CRM/Case/Form/Search.php @@ -301,7 +301,7 @@ public function addRules() { * * @return array|bool */ - public static function formRule($fields) { + public static function formRule($fields, $files, $form) { $errors = []; if (!empty($errors)) { From 9cfc631e6750cc743981f36152e894c03aa59f68 Mon Sep 17 00:00:00 2001 From: eileen Date: Mon, 8 Apr 2019 14:32:51 +1200 Subject: [PATCH 104/121] Add unit test for api ContributionRecur.cancel, add support for cancel_reason --- CRM/Contribute/BAO/ContributionRecur.php | 12 +++++++++--- CRM/Contribute/Form/CancelSubscription.php | 2 +- api/v3/ContributionRecur.php | 19 +++++++++++++++++-- .../Contribute/BAO/ContributionRecurTest.php | 2 +- .../phpunit/api/v3/ContributionRecurTest.php | 12 ++++++++++++ 5 files changed, 40 insertions(+), 7 deletions(-) diff --git a/CRM/Contribute/BAO/ContributionRecur.php b/CRM/Contribute/BAO/ContributionRecur.php index 27f41cfcb2da..559496f02f0f 100644 --- a/CRM/Contribute/BAO/ContributionRecur.php +++ b/CRM/Contribute/BAO/ContributionRecur.php @@ -258,14 +258,19 @@ public static function deleteRecurContribution($recurId) { /** * Cancel Recurring contribution. * - * @param int $recurId - * Recur contribution id. + * @param array $params + * Recur contribution params * * @param array $activityParams * * @return bool */ - public static function cancelRecurContribution($recurId, $activityParams = []) { + public static function cancelRecurContribution($params, $activityParams = []) { + if (is_int($params)) { + CRM_Core_Error::deprecatedFunctionWarning('You are using a BAO function whose signature has changed. Please use the ContributionRecur.cancel api'); + $params = ['id' => $params]; + } + $recurId = $params['id']; if (!$recurId) { return FALSE; } @@ -282,6 +287,7 @@ public static function cancelRecurContribution($recurId, $activityParams = []) { $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_date = date('YmdHis'); $recur->save(); diff --git a/CRM/Contribute/Form/CancelSubscription.php b/CRM/Contribute/Form/CancelSubscription.php index ce98fbb513d7..dfd921041bd0 100644 --- a/CRM/Contribute/Form/CancelSubscription.php +++ b/CRM/Contribute/Form/CancelSubscription.php @@ -213,7 +213,7 @@ public function postProcess() { 'details' => $message, ]; $cancelStatus = CRM_Contribute_BAO_ContributionRecur::cancelRecurContribution( - $this->_subscriptionDetails->recur_id, + ['id' => $this->_subscriptionDetails->recur_id], $activityParams ); diff --git a/api/v3/ContributionRecur.php b/api/v3/ContributionRecur.php index 2ccb9555962f..ae29b75fda33 100644 --- a/api/v3/ContributionRecur.php +++ b/api/v3/ContributionRecur.php @@ -84,8 +84,23 @@ function civicrm_api3_contribution_recur_get($params) { * returns true is successfully cancelled */ function civicrm_api3_contribution_recur_cancel($params) { - civicrm_api3_verify_one_mandatory($params, NULL, ['id']); - return CRM_Contribute_BAO_ContributionRecur::cancelRecurContribution($params['id']) ? civicrm_api3_create_success() : civicrm_api3_create_error(ts('Error while cancelling recurring contribution')); + return CRM_Contribute_BAO_ContributionRecur::cancelRecurContribution($params) ? civicrm_api3_create_success() : civicrm_api3_create_error(ts('Error while cancelling recurring contribution')); +} + +/** + * Adjust Metadata for Cancel action. + * + * The metadata is used for setting defaults, documentation & validation. + * + * @param array $params + * Array of parameters determined by getfields. + */ +function _civicrm_api3_contribution_recur_cancel_spec(&$params) { + $params['id'] = [ + 'title' => ts('Contribution Recur ID'), + 'api.required' => TRUE, + 'type' => CRM_Utils_Type::T_INT, + ]; } /** diff --git a/tests/phpunit/CRM/Contribute/BAO/ContributionRecurTest.php b/tests/phpunit/CRM/Contribute/BAO/ContributionRecurTest.php index 2a755ba5fe34..5d82d4c0b839 100644 --- a/tests/phpunit/CRM/Contribute/BAO/ContributionRecurTest.php +++ b/tests/phpunit/CRM/Contribute/BAO/ContributionRecurTest.php @@ -90,7 +90,7 @@ public function testFindSave() { */ public function testCancelRecur() { $contributionRecur = $this->callAPISuccess('contribution_recur', 'create', $this->_params); - CRM_Contribute_BAO_ContributionRecur::cancelRecurContribution($contributionRecur['id']); + CRM_Contribute_BAO_ContributionRecur::cancelRecurContribution(['id' => $contributionRecur['id']]); } /** diff --git a/tests/phpunit/api/v3/ContributionRecurTest.php b/tests/phpunit/api/v3/ContributionRecurTest.php index b4a382a5c9f6..93e15db7bcb8 100644 --- a/tests/phpunit/api/v3/ContributionRecurTest.php +++ b/tests/phpunit/api/v3/ContributionRecurTest.php @@ -100,4 +100,16 @@ public function testGetFieldsContributionRecur() { $this->assertEquals(12, $result['values']['start_date']['type']); } + /** + * Test that we can cancel a contribution and add a cancel_reason via the api. + */ + public function testContributionRecurCancel() { + $result = $this->callAPISuccess($this->_entity, 'create', $this->params); + $this->callAPISuccess('ContributionRecur', 'cancel', ['id' => $result['id'], 'cancel_reason' => 'just cos']); + $cancelled = $this->callAPISuccess('ContributionRecur', 'getsingle', ['id' => $result['id']]); + $this->assertEquals('just cos', $cancelled['cancel_reason']); + $this->assertEquals(CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_ContributionRecur', 'contribution_status_id', 'Cancelled'), $cancelled['contribution_status_id']); + $this->assertEquals(date('Y-m-d'), date('Y-m-d', strtotime($cancelled['cancel_date']))); + } + } From 1889d803c21e702dcf73d13072e3effa4b633358 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Sun, 7 Apr 2019 11:13:47 -0400 Subject: [PATCH 105/121] Use asset-builder to render menubar css --- CRM/Core/Resources.php | 37 ++++++++++++++++++++++++++++++++----- css/crm-menubar.css | 4 ++-- 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/CRM/Core/Resources.php b/CRM/Core/Resources.php index 49110577174c..4c3fcd6ec1a0 100644 --- a/CRM/Core/Resources.php +++ b/CRM/Core/Resources.php @@ -24,6 +24,7 @@ | see the CiviCRM license FAQ at http://civicrm.org/licensing | +--------------------------------------------------------------------+ */ +use Civi\Core\Event\GenericHookEvent; /** * This class facilitates the loading of resources @@ -581,6 +582,7 @@ public function resetCacheCode() { * @return CRM_Core_Resources */ public function addCoreResources($region = 'html-header') { + Civi::dispatcher()->addListener('hook_civicrm_buildAsset', [$this, 'renderMenubarStylesheet']); if (!isset($this->addedCoreResources[$region]) && !self::isAjaxMode()) { $this->addedCoreResources[$region] = TRUE; $config = CRM_Core_Config::singleton(); @@ -760,14 +762,10 @@ public function coreResourceList($region) { $position = Civi::settings()->get('menubar_position') ?: 'over-cms-menu'; } if ($position !== 'none') { - $cms = strtolower($config->userFramework); - $cms = $cms === 'drupal' ? 'drupal7' : $cms; $items[] = 'bower_components/smartmenus/dist/jquery.smartmenus.min.js'; $items[] = 'bower_components/smartmenus/dist/addons/keyboard/jquery.smartmenus.keyboard.min.js'; $items[] = 'js/crm.menubar.js'; - $items[] = 'bower_components/smartmenus/dist/css/sm-core-css.css'; - $items[] = 'css/crm-menubar.css'; - $items[] = "css/menubar-$cms.css"; + $items[] = Civi::service('asset_builder')->getUrl('crm-menubar.css'); $items[] = [ 'menubar' => [ 'position' => $position, @@ -825,6 +823,35 @@ public static function isAjaxMode() { return (strpos($url, 'civicrm/ajax') === 0) || (strpos($url, 'civicrm/angular') === 0); } + /** + * @param GenericHookEvent $e + * @see \CRM_Utils_Hook::buildAsset() + */ + public static function renderMenubarStylesheet(GenericHookEvent $e) { + if ($e->asset !== 'crm-menubar.css') { + return; + } + $e->mimeType = 'text/css'; + $e->content = ''; + $config = CRM_Core_Config::singleton(); + $cms = strtolower($config->userFramework); + $cms = $cms === 'drupal' ? 'drupal7' : $cms; + $items = [ + 'bower_components/smartmenus/dist/css/sm-core-css.css', + 'css/crm-menubar.css', + "css/menubar-$cms.css", + ]; + foreach ($items as $item) { + $e->content .= file_get_contents(self::singleton()->getPath('civicrm', $item)); + } + $vars = [ + 'resourceBase' => rtrim($config->resourceBase, '/'), + ]; + foreach ($vars as $var => $val) { + $e->content = str_replace('$' . $var, $val, $e->content); + } + } + /** * Provide a list of available entityRef filters. * diff --git a/css/crm-menubar.css b/css/crm-menubar.css index 06800779a664..25aa00ca5cbf 100644 --- a/css/crm-menubar.css +++ b/css/crm-menubar.css @@ -163,7 +163,7 @@ ul.crm-quickSearch-results.ui-state-disabled { } #civicrm-menu-nav .crm-logo-sm { - background: url(../i/logo_sm.png) no-repeat; + background: url($resourceBase/i/logo_sm.png) no-repeat; display: inline-block; width: 16px; height: 16px; @@ -316,7 +316,7 @@ body.crm-menubar-over-cms-menu #crm-menubar-toggle-position a i { left: 5px; width: 18px; height: 18px; - background: url(../i/logo_lg.png) no-repeat; + background: url($resourceBase/i/logo_lg.png) no-repeat; background-size: 18px; top: 6px; } From 11b9f280dfce28fd693cb1fa05c6f420c586f185 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Mon, 8 Apr 2019 13:18:41 -0400 Subject: [PATCH 106/121] Navigation admin - fix icon picker & use select2 --- CRM/Admin/Form/Navigation.php | 10 +++++++--- CRM/Core/Form.php | 2 +- templates/CRM/Admin/Form/Navigation.tpl | 7 +------ 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/CRM/Admin/Form/Navigation.php b/CRM/Admin/Form/Navigation.php index cf885742b55e..1d7ae860cb18 100644 --- a/CRM/Admin/Form/Navigation.php +++ b/CRM/Admin/Form/Navigation.php @@ -73,10 +73,10 @@ public function buildQuickForm() { $permissions = []; foreach (CRM_Core_Permission::basicPermissions(TRUE, TRUE) as $id => $vals) { - $permissions[] = ['id' => $id, 'label' => $vals[0], 'description' => (array) CRM_Utils_Array::value(1, $vals)]; + $permissions[] = ['id' => $id, 'text' => $vals[0], 'description' => (array) CRM_Utils_Array::value(1, $vals)]; } - $this->add('text', 'permission', ts('Permission'), - ['placeholder' => ts('Unrestricted'), 'class' => 'huge', 'data-select-params' => json_encode(['data' => ['results' => $permissions, 'text' => 'label']])] + $this->add('select2', 'permission', ts('Permission'), $permissions, FALSE, + ['placeholder' => ts('Unrestricted'), 'class' => 'huge', 'multiple' => TRUE] ); $operators = ['AND' => ts('AND'), 'OR' => ts('OR')]; @@ -123,6 +123,10 @@ public function setDefaultValues() { // its ok if there is no element called is_active $defaults['is_active'] = ($this->_id) ? $this->_defaults['is_active'] : 1; + if (!empty($defaults['icon'])) { + $defaults['icon'] = trim(str_replace('crm-i', '', $defaults['icon'])); + } + return $defaults; } diff --git a/CRM/Core/Form.php b/CRM/Core/Form.php index e6ecef99e47d..df614d75e978 100644 --- a/CRM/Core/Form.php +++ b/CRM/Core/Form.php @@ -389,7 +389,7 @@ public function &add( if ($inputType == 'select2') { $type = 'text'; $options = $attributes; - $attributes = $attributes = ($extra ? $extra : []) + ['class' => '']; + $attributes = ($extra ? $extra : []) + ['class' => '']; $attributes['class'] = ltrim($attributes['class'] . " crm-select2 crm-form-select2"); $attributes['data-select-params'] = json_encode(['data' => $options, 'multiple' => !empty($attributes['multiple'])]); unset($attributes['multiple']); diff --git a/templates/CRM/Admin/Form/Navigation.tpl b/templates/CRM/Admin/Form/Navigation.tpl index 7ba9bc12ee96..41a6e6011529 100644 --- a/templates/CRM/Admin/Form/Navigation.tpl +++ b/templates/CRM/Admin/Form/Navigation.tpl @@ -66,12 +66,7 @@ .on('change', function() { $('span.permission_operator_wrapper').toggle(CRM._.includes($(this).val(), ',')); }) - .change() - .crmSelect2({ - formatResult: CRM.utils.formatSelect2Result, - formatSelection: function(row) {return row.label}, - multiple: true - }); + .change(); }); {/literal} From 5e69f428e99be6f2a625ef5be60251d9bf658d29 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Mon, 8 Apr 2019 14:39:13 -0400 Subject: [PATCH 107/121] Navigation admin - live refresh and links to related settings --- templates/CRM/Admin/Page/Navigation.hlp | 2 +- templates/CRM/Admin/Page/Navigation.tpl | 39 ++++++++++++++----------- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/templates/CRM/Admin/Page/Navigation.hlp b/templates/CRM/Admin/Page/Navigation.hlp index b2e6ddd951b2..038ac93e0cb7 100644 --- a/templates/CRM/Admin/Page/Navigation.hlp +++ b/templates/CRM/Admin/Page/Navigation.hlp @@ -40,5 +40,5 @@

      • {ts}Change the permissions for a menu item. Right-click and select 'Edit'.{/ts}
      • {ts}Re-order menu items (including moving them from one branch of the menu 'tree' to another. Simply use your mouse to 'drag and drop' the menu item to the new location.{/ts}
      -

      {ts}Changes you make to the menu are saved immediately. However, you will need reload this page to see your changes in the menu bar above.{/ts}

      +

      {ts}Changes you make to the menu are saved immediately.{/ts}

      {/htxt} diff --git a/templates/CRM/Admin/Page/Navigation.tpl b/templates/CRM/Admin/Page/Navigation.tpl index 9165e8a9d9d8..5c826b8488d9 100644 --- a/templates/CRM/Admin/Page/Navigation.tpl +++ b/templates/CRM/Admin/Page/Navigation.tpl @@ -27,19 +27,19 @@ {include file="CRM/Admin/Form/Navigation.tpl"} {else}
      - {ts}Customize the CiviCRM navigation menu bar for your users here.{/ts} {help id="id-navigation"} + {capture assign="displayPrefUrl"}href="{crmURL p='civicrm/admin/setting/preferences/display' q='reset=1'}"{/capture} + {capture assign="searchPrefUrl"}href="{crmURL p='civicrm/admin/setting/search' q='reset=1'}"{/capture} +

      {ts}Customize the CiviCRM navigation menu bar for your users here.{/ts} {help id="id-navigation"}

      +

      {ts 1=$displayPrefUrl}The menu color and position can be adjusted on the Display Preferences screen.{/ts}

      +

      {ts 1=$searchPrefUrl}Quicksearch options can be edited on the Search Preferences screen.{/ts}

      - {crmButton p="civicrm/admin/menu" q="action=add&reset=1" id="newMenuItem" icon="crm-i fa-plus-circle" style="margin-left: 6px;"}{ts}Add Menu Item{/ts}{/crmButton}     -

      + {crmButton p="civicrm/admin/menu" q="action=add&reset=1" id="newMenuItem" icon="crm-i fa-plus-circle" style="margin-left: 6px;"}{ts}Add Menu Item{/ts}{/crmButton}
      -
      +
      @@ -63,7 +63,7 @@ return: ['label', 'parent_id', 'icon'], name: {'!=': 'Home'}, sequential: 1 - }).done(function(data) { + }).then(function(data) { var items = []; $.each(data.values, function(key, value) { items.push({ @@ -108,9 +108,8 @@ } CRM.confirm({message: deleteMsg}) .on('crmConfirm:yes', function() { - CRM.api3('Navigation', 'delete', {id: nodeID}, true); + CRM.api3('Navigation', 'delete', {id: nodeID}, true).then(refreshMenubar); $("#navigation-tree").jstree(true).delete_node(menu.reference.closest('li')); - $("#reset-menu").show(); }); } } @@ -123,8 +122,7 @@ var refID = data.parent === '#' ? '' : data.parent; var ps = data.position; var postURL = {/literal}"{crmURL p='civicrm/ajax/menutree' h=0 q='key='}{crmKey name='civicrm/ajax/menutree'}"{literal}; - CRM.status({}, $.get( postURL + '&type=move&id=' + nodeID + '&ref_id=' + refID + '&ps='+ps)); - $("#reset-menu").show(); + CRM.status({}, $.get( postURL + '&type=move&id=' + nodeID + '&ref_id=' + refID + '&ps='+ps).then(refreshMenubar)); }); function editForm(menu) { @@ -138,7 +136,7 @@ } CRM.loadForm(CRM.url('civicrm/admin/menu', args)).on('crmFormSuccess', function() { $("#navigation-tree").jstree(true).refresh(); - $("#reset-menu").show(); + refreshMenubar(); }); } @@ -146,7 +144,7 @@ .on('click', CRM.popup) .on('crmPopupFormSuccess', function() { $("#navigation-tree").jstree(true).refresh(); - $("#reset-menu").show(); + refreshMenubar(); }); $('a.nav-reset').on('click', function(e) { @@ -158,13 +156,20 @@ .on('crmConfirm:yes', function() { $('#crm-container').block(); CRM.api3('Navigation', 'reset', {'for': 'report'}, true) - .done(function() { + .then(function() { $('#crm-container').unblock(); $("#navigation-tree").jstree(true).refresh(); - $("#reset-menu").show(); - }) + refreshMenubar(); + }); }); }); + + // Force-refresh the menubar by resetting the cache code + function refreshMenubar() { + CRM.menubar.destroy(); + CRM.menubar.cacheCode = Math.random(); + CRM.menubar.initialize(); + } }); {/literal} From 8a52ae342ef766d2f35e8527484fc5d3c2ba708d Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Sun, 7 Apr 2019 21:05:14 -0400 Subject: [PATCH 108/121] Configurable menubar color --- CRM/Admin/Form/Preferences/Display.php | 3 ++ CRM/Admin/Form/SettingTrait.php | 4 ++ CRM/Core/Resources.php | 9 ++++ CRM/Utils/Color.php | 52 ++++++++++++++++--- CRM/Utils/Rule.php | 10 ++++ CRM/Utils/Type.php | 7 +++ css/crm-menubar.css | 30 +++++------ settings/Core.setting.php | 17 +++++- .../CRM/Admin/Form/Preferences/Display.tpl | 6 +++ tests/phpunit/CRM/Utils/RuleTest.php | 30 +++++++++++ 10 files changed, 144 insertions(+), 24 deletions(-) diff --git a/CRM/Admin/Form/Preferences/Display.php b/CRM/Admin/Form/Preferences/Display.php index 7cf91d240baa..5f84883e956b 100644 --- a/CRM/Admin/Form/Preferences/Display.php +++ b/CRM/Admin/Form/Preferences/Display.php @@ -52,6 +52,7 @@ class CRM_Admin_Form_Preferences_Display extends CRM_Admin_Form_Preferences { 'display_name_format' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'sort_name_format' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'menubar_position' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, + 'menubar_color' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, ]; /** @@ -105,6 +106,8 @@ public function postProcess() { $this->postProcessCommon(); + \Civi::service('asset_builder')->clear(); + // If "Configure CKEditor" button was clicked if (!empty($this->_params['ckeditor_config'])) { // Suppress the "Saved" status message and redirect to the CKEditor Config page diff --git a/CRM/Admin/Form/SettingTrait.php b/CRM/Admin/Form/SettingTrait.php index 6a056a95f88b..f22470803fe6 100644 --- a/CRM/Admin/Form/SettingTrait.php +++ b/CRM/Admin/Form/SettingTrait.php @@ -238,6 +238,9 @@ protected function addFieldsDefinedInSettingsMetadata() { elseif ($add === 'addYesNo' && ($props['type'] === 'Boolean')) { $this->addRadio($setting, ts($props['title']), [1 => 'Yes', 0 => 'No'], NULL, '  '); } + elseif ($add === 'add') { + $this->add($props['html_type'], $setting, ts($props['title']), $options); + } else { $this->$add($setting, ts($props['title']), $options); } @@ -293,6 +296,7 @@ protected function getQuickFormType($spec) { 'entity_reference' => 'EntityRef', 'advmultiselect' => 'Element', ]; + $mapping += array_fill_keys(CRM_Core_Form::$html5Types, ''); return $mapping[$htmlType]; } diff --git a/CRM/Core/Resources.php b/CRM/Core/Resources.php index 4c3fcd6ec1a0..98b3ba8ae5bd 100644 --- a/CRM/Core/Resources.php +++ b/CRM/Core/Resources.php @@ -844,9 +844,18 @@ public static function renderMenubarStylesheet(GenericHookEvent $e) { foreach ($items as $item) { $e->content .= file_get_contents(self::singleton()->getPath('civicrm', $item)); } + $color = Civi::settings()->get('menubar_color'); + if (!CRM_Utils_Rule::color($color)) { + $color = Civi::settings()->getDefault('menubar_color'); + } $vars = [ 'resourceBase' => rtrim($config->resourceBase, '/'), + 'menubarColor' => $color, + 'semiTransparentMenuColor' => 'rgba(' . implode(', ', CRM_Utils_Color::getRgb($color)) . ', .85)', + 'highlightColor' => CRM_Utils_Color::getHighlight($color), + 'textColor' => CRM_Utils_Color::getContrast($color, '#333', '#ddd'), ]; + $vars['highlightTextColor'] = CRM_Utils_Color::getContrast($vars['highlightColor'], '#333', '#ddd'); foreach ($vars as $var => $val) { $e->content = str_replace('$' . $var, $val, $e->content); } diff --git a/CRM/Utils/Color.php b/CRM/Utils/Color.php index 80bac7f8f898..2cceca9ff334 100644 --- a/CRM/Utils/Color.php +++ b/CRM/Utils/Color.php @@ -42,15 +42,55 @@ class CRM_Utils_Color { * Based on YIQ value. * * @param string $hexcolor + * @param string $black + * @param string $white * @return string */ - public static function getContrast($hexcolor) { - $hexcolor = trim($hexcolor, ' #'); - $r = hexdec(substr($hexcolor, 0, 2)); - $g = hexdec(substr($hexcolor, 2, 2)); - $b = hexdec(substr($hexcolor, 4, 2)); + public static function getContrast($hexcolor, $black = 'black', $white = 'white') { + list($r, $g, $b) = self::getRgb($hexcolor); $yiq = (($r * 299) + ($g * 587) + ($b * 114)) / 1000; - return ($yiq >= 128) ? 'black' : 'white'; + return ($yiq >= 128) ? $black : $white; + } + + /** + * Convert hex color to decimal + * + * @param string $hexcolor + * @return array + * [red, green, blue] + */ + public static function getRgb($hexcolor) { + $hexcolor = trim($hexcolor, ' #'); + if (strlen($hexcolor) === 3) { + $hexcolor = $hexcolor[0] . $hexcolor[0] . $hexcolor[1] . $hexcolor[1] . $hexcolor[2] . $hexcolor[2]; + } + return [ + hexdec(substr($hexcolor, 0, 2)), + hexdec(substr($hexcolor, 2, 2)), + hexdec(substr($hexcolor, 4, 2)), + ]; + } + + /** + * Calculate a highlight color from a base color + * + * @param $hexcolor + * @return string + */ + public static function getHighlight($hexcolor) { + $rgb = CRM_Utils_Color::getRgb($hexcolor); + $avg = array_sum($rgb) / 3; + foreach ($rgb as &$v) { + if ($avg > 242) { + // For very bright values, lower the brightness + $v -= 50; + } + else { + // Bump up brightness on a nonlinear curve - darker colors get more of a boost + $v = min(255, intval((-.0035 * ($v - 242) ** 2) + 260)); + } + } + return '#' . implode(array_map('dechex', $rgb)); } } diff --git a/CRM/Utils/Rule.php b/CRM/Utils/Rule.php index 33a3d52bc093..50d72d38352e 100644 --- a/CRM/Utils/Rule.php +++ b/CRM/Utils/Rule.php @@ -540,6 +540,16 @@ public static function numberOfDigit($value, $noOfDigit) { return preg_match('/^\d{' . $noOfDigit . '}$/', $value) ? TRUE : FALSE; } + /** + * Strict validation of 6-digit hex color notation per html5 + * + * @param $value + * @return bool + */ + public static function color($value) { + return (bool) preg_match('/^#([\da-fA-F]{6})$/', $value); + } + /** * Strip thousand separator from a money string. * diff --git a/CRM/Utils/Type.php b/CRM/Utils/Type.php index 5baf25099023..e2786712a420 100644 --- a/CRM/Utils/Type.php +++ b/CRM/Utils/Type.php @@ -434,6 +434,7 @@ public static function validate($data, $type, $abort = TRUE, $name = 'One of par 'ExtensionKey', 'Json', 'Alphanumeric', + 'Color', ]; if (!in_array($type, $possibleTypes)) { if ($isThrowException) { @@ -554,6 +555,12 @@ public static function validate($data, $type, $abort = TRUE, $name = 'One of par return $data; } break; + + case 'Color': + if (CRM_Utils_Rule::color($data)) { + return $data; + } + break; } if ($abort) { diff --git a/css/crm-menubar.css b/css/crm-menubar.css index 25aa00ca5cbf..aa53639ccc1e 100644 --- a/css/crm-menubar.css +++ b/css/crm-menubar.css @@ -6,8 +6,8 @@ font-size: 13px; } #civicrm-menu { - background-color: #f2f2f2; - width: 100%; + background-color: $menubarColor; + width: 100%; z-index: 500; height: auto; margin: 0; @@ -22,7 +22,6 @@ #civicrm-menu li a { padding: 12px 8px; text-decoration: none; - color: #333; box-shadow: none; border: none; } @@ -42,12 +41,12 @@ #civicrm-menu li a:hover, #civicrm-menu li a.highlighted { text-decoration: none; - background-color: #fff; + background-color: $highlightColor; + color: $highlightTextColor; } #civicrm-menu li li .sub-arrow:before { content: "\f0da"; font-family: 'FontAwesome'; - color: #666; float: right; margin-right: -25px; } @@ -88,7 +87,7 @@ cursor: pointer; color: transparent; -webkit-tap-highlight-color: rgba(0,0,0,0); - background-color: #333; + background-color: #1b1b1b; } /* responsive icon */ @@ -174,10 +173,10 @@ ul.crm-quickSearch-results.ui-state-disabled { float: right; } #civicrm-menu #crm-menubar-toggle-position a i { - color: #888; margin: 0; - border-top: 2px solid #888; + border-top: 2px solid $textColor; font-size: 11px; + opacity: .8; } body.crm-menubar-over-cms-menu #crm-menubar-toggle-position a i { transform: rotate(180deg); @@ -215,10 +214,14 @@ body.crm-menubar-over-cms-menu #crm-menubar-toggle-position a i { } #civicrm-menu ul { - background-color: #fff; box-shadow: 0px 0px 2px 0 rgba(0,0,0,0.3); } + #civicrm-menu li a { + background-color: $semiTransparentMenuColor; + color: $textColor; + } + #civicrm-menu > li > a { height: 40px; } @@ -227,13 +230,6 @@ body.crm-menubar-over-cms-menu #crm-menubar-toggle-position a i { z-index: 200000; } - #civicrm-menu ul li a:focus, - #civicrm-menu ul li a:hover, - #civicrm-menu ul li a.highlighted { - background-color: #f2f2f2; - color: #222; - } - body.crm-menubar-over-cms-menu #civicrm-menu, body.crm-menubar-below-cms-menu #civicrm-menu { position: fixed; @@ -256,7 +252,7 @@ body.crm-menubar-over-cms-menu #crm-menubar-toggle-position a i { } #civicrm-menu { z-index: 100000; - background-color: #333; + background-color: #1b1b1b; } #civicrm-menu ul { background-color: #444; diff --git a/settings/Core.setting.php b/settings/Core.setting.php index 8d4cdc09686f..e90952c6a20f 100644 --- a/settings/Core.setting.php +++ b/settings/Core.setting.php @@ -1024,7 +1024,7 @@ 'type' => 'String', 'html_type' => 'select', 'default' => 'over-cms-menu', - 'add' => '5.9', + 'add' => '5.12', 'title' => ts('Menubar position'), 'is_domain' => 1, 'is_contact' => 0, @@ -1037,4 +1037,19 @@ 'none' => ts('None - disable menu'), ), ), + 'menubar_color' => array( + 'group_name' => 'CiviCRM Preferences', + 'group' => 'core', + 'name' => 'menubar_color', + 'type' => 'String', + 'html_type' => 'color', + 'default' => '#1b1b1b', + 'add' => '5.13', + 'title' => ts('Menubar color'), + 'is_domain' => 1, + 'is_contact' => 0, + 'description' => ts('Color of the CiviCRM main menu.'), + 'help_text' => NULL, + 'validate_callback' => 'CRM_Utils_Rule::color', + ), ); diff --git a/templates/CRM/Admin/Form/Preferences/Display.tpl b/templates/CRM/Admin/Form/Preferences/Display.tpl index 02f0f38f7e08..1c2a61ea4503 100644 --- a/templates/CRM/Admin/Form/Preferences/Display.tpl +++ b/templates/CRM/Admin/Form/Preferences/Display.tpl @@ -216,6 +216,12 @@
      {ts}Default position for the CiviCRM menubar.{/ts}
      + + {$form.menubar_color.label} + + {$form.menubar_color.html} + +
      {include file="CRM/common/formButtons.tpl" location="bottom"}
      diff --git a/tests/phpunit/CRM/Utils/RuleTest.php b/tests/phpunit/CRM/Utils/RuleTest.php index 188089faaa1e..0189c9c13f23 100644 --- a/tests/phpunit/CRM/Utils/RuleTest.php +++ b/tests/phpunit/CRM/Utils/RuleTest.php @@ -112,6 +112,36 @@ public function moneyDataProvider() { ); } + /** + * @dataProvider colorDataProvider + * @param $inputData + * @param $expectedResult + */ + public function testColor($inputData, $expectedResult) { + $this->assertEquals($expectedResult, CRM_Utils_Rule::color($inputData)); + } + + /** + * @return array + */ + public function colorDataProvider() { + return [ + ['#000000', TRUE], + ['#ffffff', TRUE], + ['#123456', TRUE], + ['#00aaff', TRUE], + // Some of these are valid css colors but we reject anything that doesn't conform to the html5 spec for + ['#ffffff00', FALSE], + ['#fff', FALSE], + ['##000000', FALSE], + ['ffffff', FALSE], + ['red', FALSE], + ['#orange', FALSE], + ['', FALSE], + ['rgb(255, 255, 255)', FALSE], + ]; + } + /** * @return array */ From 76ee148d5f45ef9e7ad5521173cf44f7f5e2c2d1 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Tue, 9 Apr 2019 07:56:01 +1000 Subject: [PATCH 109/121] Fix 4.7.31 Upgrade in multilingual mode --- CRM/Core/I18n/SchemaStructure_4_7_31.php | 712 ++++++++++++++++++++++ CRM/Upgrade/Incremental/Base.php | 8 +- CRM/Upgrade/Incremental/php/FourSeven.php | 6 +- 3 files changed, 719 insertions(+), 7 deletions(-) create mode 100644 CRM/Core/I18n/SchemaStructure_4_7_31.php diff --git a/CRM/Core/I18n/SchemaStructure_4_7_31.php b/CRM/Core/I18n/SchemaStructure_4_7_31.php new file mode 100644 index 000000000000..7e81bf7a4ea3 --- /dev/null +++ b/CRM/Core/I18n/SchemaStructure_4_7_31.php @@ -0,0 +1,712 @@ + [ + 'display_name' => "varchar(64)", + ], + 'civicrm_option_group' => [ + 'title' => "varchar(255)", + 'description' => "varchar(255)", + ], + 'civicrm_relationship_type' => [ + 'label_a_b' => "varchar(64)", + 'label_b_a' => "varchar(64)", + 'description' => "varchar(255)", + ], + 'civicrm_contact_type' => [ + 'label' => "varchar(64)", + 'description' => "text", + ], + 'civicrm_batch' => [ + 'title' => "varchar(255)", + 'description' => "text", + ], + 'civicrm_premiums' => [ + 'premiums_intro_title' => "varchar(255)", + 'premiums_intro_text' => "text", + 'premiums_nothankyou_label' => "varchar(255)", + ], + 'civicrm_membership_status' => [ + 'label' => "varchar(128)", + ], + 'civicrm_survey' => [ + 'title' => "varchar(255)", + 'instructions' => "text", + 'thankyou_title' => "varchar(255)", + 'thankyou_text' => "text", + ], + 'civicrm_participant_status_type' => [ + 'label' => "varchar(255)", + ], + 'civicrm_case_type' => [ + 'title' => "varchar(64)", + 'description' => "varchar(255)", + ], + 'civicrm_tell_friend' => [ + 'title' => "varchar(255)", + 'intro' => "text", + 'suggested_message' => "text", + 'thankyou_title' => "varchar(255)", + 'thankyou_text' => "text", + ], + 'civicrm_custom_group' => [ + 'title' => "varchar(64)", + 'help_pre' => "text", + 'help_post' => "text", + ], + 'civicrm_custom_field' => [ + 'label' => "varchar(255)", + 'help_pre' => "text", + 'help_post' => "text", + ], + 'civicrm_option_value' => [ + 'label' => "varchar(512)", + 'description' => "text", + ], + 'civicrm_group' => [ + 'title' => "varchar(64)", + ], + 'civicrm_contribution_page' => [ + 'title' => "varchar(255)", + 'intro_text' => "text", + 'pay_later_text' => "text", + 'pay_later_receipt' => "text", + 'initial_amount_label' => "varchar(255)", + 'initial_amount_help_text' => "text", + 'thankyou_title' => "varchar(255)", + 'thankyou_text' => "text", + 'thankyou_footer' => "text", + 'receipt_from_name' => "varchar(255)", + 'receipt_text' => "text", + 'footer_text' => "text", + ], + 'civicrm_product' => [ + 'name' => "varchar(255)", + 'description' => "text", + 'options' => "text", + ], + 'civicrm_membership_type' => [ + 'name' => "varchar(128)", + 'description' => "varchar(255)", + ], + 'civicrm_membership_block' => [ + 'new_title' => "varchar(255)", + 'new_text' => "text", + 'renewal_title' => "varchar(255)", + 'renewal_text' => "text", + ], + 'civicrm_price_set' => [ + 'title' => "varchar(255)", + 'help_pre' => "text", + 'help_post' => "text", + ], + 'civicrm_dashboard' => [ + 'label' => "varchar(255)", + ], + 'civicrm_uf_group' => [ + 'title' => "varchar(64)", + 'frontend_title' => "varchar(64)", + 'help_pre' => "text", + 'help_post' => "text", + 'cancel_button_text' => "varchar(64)", + 'submit_button_text' => "varchar(64)", + ], + 'civicrm_uf_field' => [ + 'help_post' => "text", + 'help_pre' => "text", + 'label' => "varchar(255)", + ], + 'civicrm_price_field' => [ + 'label' => "varchar(255)", + 'help_pre' => "text", + 'help_post' => "text", + ], + 'civicrm_price_field_value' => [ + 'label' => "varchar(255)", + 'description' => "text", + 'help_pre' => "text", + 'help_post' => "text", + ], + 'civicrm_pcp_block' => [ + 'link_text' => "varchar(255)", + ], + 'civicrm_event' => [ + 'title' => "varchar(255)", + 'summary' => "text", + 'description' => "text", + 'registration_link_text' => "varchar(255)", + 'event_full_text' => "text", + 'fee_label' => "varchar(255)", + 'intro_text' => "text", + 'footer_text' => "text", + 'confirm_title' => "varchar(255)", + 'confirm_text' => "text", + 'confirm_footer_text' => "text", + 'confirm_email_text' => "text", + 'confirm_from_name' => "varchar(255)", + 'thankyou_title' => "varchar(255)", + 'thankyou_text' => "text", + 'thankyou_footer_text' => "text", + 'pay_later_text' => "text", + 'pay_later_receipt' => "text", + 'initial_amount_label' => "varchar(255)", + 'initial_amount_help_text' => "text", + 'waitlist_text' => "text", + 'approval_req_text' => "text", + 'template_title' => "varchar(255)", + ], + ]; + } + return $result; + } + + /** + * Get a table indexed array of the indices for translatable fields. + * + * @return array + * Indices for translatable fields. + */ + public static function &indices() { + static $result = NULL; + if (!$result) { + $result = [ + 'civicrm_custom_group' => [ + 'UI_title_extends' => [ + 'name' => 'UI_title_extends', + 'field' => [ + 'title', + 'extends', + ], + 'unique' => 1, + ], + ], + 'civicrm_custom_field' => [ + 'UI_label_custom_group_id' => [ + 'name' => 'UI_label_custom_group_id', + 'field' => [ + 'label', + 'custom_group_id', + ], + 'unique' => 1, + ], + ], + 'civicrm_group' => [ + 'UI_title' => [ + 'name' => 'UI_title', + 'field' => [ + 'title', + ], + 'unique' => 1, + ], + ], + ]; + } + return $result; + } + + /** + * Get tables with translatable fields. + * + * @return array + * Array of names of tables with fields that can be translated. + */ + public static function &tables() { + static $result = NULL; + if (!$result) { + $result = array_keys(self::columns()); + } + return $result; + } + + /** + * Get a list of widgets for editing translatable fields. + * + * @return array + * Array of the widgets for editing translatable fields. + */ + public static function &widgets() { + static $result = NULL; + if (!$result) { + $result = [ + 'civicrm_location_type' => [ + 'display_name' => [ + 'type' => "Text", + ], + ], + 'civicrm_option_group' => [ + 'title' => [ + 'type' => "Text", + ], + 'description' => [ + 'type' => "Text", + ], + ], + 'civicrm_relationship_type' => [ + 'label_a_b' => [ + 'type' => "Text", + ], + 'label_b_a' => [ + 'type' => "Text", + ], + 'description' => [ + 'type' => "Text", + ], + ], + 'civicrm_contact_type' => [ + 'label' => [ + 'type' => "Text", + ], + 'description' => [ + 'type' => "TextArea", + 'rows' => "2", + 'cols' => "60", + ], + ], + 'civicrm_batch' => [ + 'title' => [ + 'type' => "Text", + ], + 'description' => [ + 'type' => "TextArea", + 'rows' => "4", + 'cols' => "80", + ], + ], + 'civicrm_premiums' => [ + 'premiums_intro_title' => [ + 'type' => "Text", + ], + 'premiums_intro_text' => [ + 'type' => "Text", + ], + 'premiums_nothankyou_label' => [ + 'type' => "Text", + ], + ], + 'civicrm_membership_status' => [ + 'label' => [ + 'type' => "Text", + ], + ], + 'civicrm_survey' => [ + 'title' => [ + 'type' => "Text", + 'required' => "true", + ], + 'instructions' => [ + 'type' => "TextArea", + 'rows' => "20", + 'cols' => "80", + ], + 'thankyou_title' => [ + 'type' => "Text", + ], + 'thankyou_text' => [ + 'type' => "TextArea", + 'rows' => "8", + 'cols' => "60", + ], + ], + 'civicrm_participant_status_type' => [ + 'label' => [ + 'type' => "Text", + ], + ], + 'civicrm_case_type' => [ + 'title' => [ + 'type' => "Text", + 'required' => "true", + ], + 'description' => [ + 'type' => "Text", + ], + ], + 'civicrm_tell_friend' => [ + 'title' => [ + 'type' => "Text", + ], + 'intro' => [ + 'type' => "Text", + ], + 'suggested_message' => [ + 'type' => "Text", + ], + 'thankyou_title' => [ + 'type' => "Text", + ], + 'thankyou_text' => [ + 'type' => "Text", + ], + ], + 'civicrm_custom_group' => [ + 'title' => [ + 'type' => "Text", + 'required' => "true", + ], + 'help_pre' => [ + 'type' => "TextArea", + 'rows' => "4", + 'cols' => "80", + ], + 'help_post' => [ + 'type' => "TextArea", + 'rows' => "4", + 'cols' => "80", + ], + ], + 'civicrm_custom_field' => [ + 'label' => [ + 'type' => "Text", + 'required' => "true", + ], + 'help_pre' => [ + 'type' => "Text", + ], + 'help_post' => [ + 'type' => "Text", + ], + ], + 'civicrm_option_value' => [ + 'label' => [ + 'type' => "Text", + 'required' => "true", + ], + 'description' => [ + 'type' => "TextArea", + 'rows' => "8", + 'cols' => "60", + ], + ], + 'civicrm_group' => [ + 'title' => [ + 'type' => "Text", + ], + ], + 'civicrm_contribution_page' => [ + 'title' => [ + 'type' => "Text", + ], + 'intro_text' => [ + 'type' => "RichTextEditor", + 'rows' => "6", + 'cols' => "50", + ], + 'pay_later_text' => [ + 'type' => "Text", + ], + 'pay_later_receipt' => [ + 'type' => "Text", + ], + 'initial_amount_label' => [ + 'type' => "Text", + ], + 'initial_amount_help_text' => [ + 'type' => "Text", + ], + 'thankyou_title' => [ + 'type' => "Text", + ], + 'thankyou_text' => [ + 'type' => "RichTextEditor", + 'rows' => "8", + 'cols' => "60", + ], + 'thankyou_footer' => [ + 'type' => "RichTextEditor", + 'rows' => "8", + 'cols' => "60", + ], + 'receipt_from_name' => [ + 'type' => "Text", + ], + 'receipt_text' => [ + 'type' => "TextArea", + 'rows' => "6", + 'cols' => "50", + ], + 'footer_text' => [ + 'type' => "RichTextEditor", + 'rows' => "6", + 'cols' => "50", + ], + ], + 'civicrm_product' => [ + 'name' => [ + 'type' => "Text", + 'required' => "true", + ], + 'description' => [ + 'type' => "Text", + ], + 'options' => [ + 'type' => "Text", + ], + ], + 'civicrm_membership_type' => [ + 'name' => [ + 'type' => "Text", + ], + 'description' => [ + 'type' => "TextArea", + 'rows' => "6", + 'cols' => "50", + ], + ], + 'civicrm_membership_block' => [ + 'new_title' => [ + 'type' => "Text", + ], + 'new_text' => [ + 'type' => "Text", + ], + 'renewal_title' => [ + 'type' => "Text", + ], + 'renewal_text' => [ + 'type' => "Text", + ], + ], + 'civicrm_price_set' => [ + 'title' => [ + 'type' => "Text", + 'required' => "true", + ], + 'help_pre' => [ + 'type' => "TextArea", + 'rows' => "4", + 'cols' => "80", + ], + 'help_post' => [ + 'type' => "TextArea", + 'rows' => "4", + 'cols' => "80", + ], + ], + 'civicrm_dashboard' => [ + 'label' => [ + 'type' => "Text", + ], + ], + 'civicrm_uf_group' => [ + 'title' => [ + 'type' => "Text", + 'required' => "true", + ], + 'frontend_title' => [ + 'type' => "Text", + ], + 'help_pre' => [ + 'type' => "TextArea", + 'rows' => "4", + 'cols' => "80", + ], + 'help_post' => [ + 'type' => "TextArea", + 'rows' => "4", + 'cols' => "80", + ], + 'cancel_button_text' => [ + 'type' => "Text", + ], + 'submit_button_text' => [ + 'type' => "Text", + ], + ], + 'civicrm_uf_field' => [ + 'help_post' => [ + 'type' => "Text", + ], + 'help_pre' => [ + 'type' => "Text", + ], + 'label' => [ + 'type' => "Text", + 'required' => "true", + ], + ], + 'civicrm_price_field' => [ + 'label' => [ + 'type' => "Text", + 'required' => "true", + ], + 'help_pre' => [ + 'type' => "TextArea", + 'rows' => "4", + 'cols' => "80", + ], + 'help_post' => [ + 'type' => "TextArea", + 'rows' => "4", + 'cols' => "80", + ], + ], + 'civicrm_price_field_value' => [ + 'label' => [ + 'type' => "Text", + ], + 'description' => [ + 'type' => "TextArea", + 'rows' => "2", + 'cols' => "60", + ], + 'help_pre' => [ + 'type' => "TextArea", + 'rows' => "2", + 'cols' => "60", + ], + 'help_post' => [ + 'type' => "TextArea", + 'rows' => "2", + 'cols' => "60", + ], + ], + 'civicrm_pcp_block' => [ + 'link_text' => [ + 'type' => "Text", + ], + ], + 'civicrm_event' => [ + 'title' => [ + 'type' => "Text", + ], + 'summary' => [ + 'type' => "TextArea", + 'rows' => "4", + 'cols' => "60", + ], + 'description' => [ + 'type' => "TextArea", + 'rows' => "8", + 'cols' => "60", + ], + 'registration_link_text' => [ + 'type' => "Text", + ], + 'event_full_text' => [ + 'type' => "TextArea", + 'rows' => "4", + 'cols' => "60", + ], + 'fee_label' => [ + 'type' => "Text", + ], + 'intro_text' => [ + 'type' => "TextArea", + 'rows' => "6", + 'cols' => "50", + ], + 'footer_text' => [ + 'type' => "TextArea", + 'rows' => "6", + 'cols' => "50", + ], + 'confirm_title' => [ + 'type' => "Text", + ], + 'confirm_text' => [ + 'type' => "TextArea", + 'rows' => "6", + 'cols' => "50", + ], + 'confirm_footer_text' => [ + 'type' => "TextArea", + 'rows' => "6", + 'cols' => "50", + ], + 'confirm_email_text' => [ + 'type' => "TextArea", + 'rows' => "4", + 'cols' => "50", + ], + 'confirm_from_name' => [ + 'type' => "Text", + ], + 'thankyou_title' => [ + 'type' => "Text", + ], + 'thankyou_text' => [ + 'type' => "TextArea", + 'rows' => "6", + 'cols' => "50", + ], + 'thankyou_footer_text' => [ + 'type' => "TextArea", + 'rows' => "6", + 'cols' => "50", + ], + 'pay_later_text' => [ + 'type' => "Text", + ], + 'pay_later_receipt' => [ + 'type' => "Text", + ], + 'initial_amount_label' => [ + 'type' => "Text", + ], + 'initial_amount_help_text' => [ + 'type' => "Text", + ], + 'waitlist_text' => [ + 'type' => "TextArea", + 'rows' => "4", + 'cols' => "60", + ], + 'approval_req_text' => [ + 'type' => "TextArea", + 'rows' => "4", + 'cols' => "60", + ], + 'template_title' => [ + 'type' => "Text", + ], + ], + ]; + } + return $result; + } + +} diff --git a/CRM/Upgrade/Incremental/Base.php b/CRM/Upgrade/Incremental/Base.php index 3855749ec68d..a044dacf06c8 100644 --- a/CRM/Upgrade/Incremental/Base.php +++ b/CRM/Upgrade/Incremental/Base.php @@ -151,7 +151,7 @@ public static function checkFKExists($table_name, $constraint_name) { * @param bool $localizable is this a field that should be localized * @return bool */ - public static function addColumn($ctx, $table, $column, $properties, $localizable = FALSE) { + public static function addColumn($ctx, $table, $column, $properties, $localizable = FALSE, $version = NULL) { $domain = new CRM_Core_DAO_Domain(); $domain->find(TRUE); $queries = []; @@ -178,7 +178,7 @@ public static function addColumn($ctx, $table, $column, $properties, $localizabl } if ($domain->locales) { $locales = explode(CRM_Core_DAO::VALUE_SEPARATOR, $domain->locales); - CRM_Core_I18n_Schema::rebuildMultilingualSchema($locales, NULL, TRUE); + CRM_Core_I18n_Schema::rebuildMultilingualSchema($locales, $version, TRUE); } return TRUE; } @@ -259,12 +259,12 @@ public static function dropIndex($ctx, $table, $indexName) { * @param CRM_Queue_TaskContext $ctx * @return bool */ - public static function rebuildMultilingalSchema($ctx) { + public static function rebuildMultilingalSchema($ctx, $version = NULL) { $domain = new CRM_Core_DAO_Domain(); $domain->find(TRUE); if ($domain->locales) { $locales = explode(CRM_Core_DAO::VALUE_SEPARATOR, $domain->locales); - CRM_Core_I18n_Schema::rebuildMultilingualSchema($locales); + CRM_Core_I18n_Schema::rebuildMultilingualSchema($locales, $version); } return TRUE; } diff --git a/CRM/Upgrade/Incremental/php/FourSeven.php b/CRM/Upgrade/Incremental/php/FourSeven.php index cf880abb4a8a..075153d23984 100644 --- a/CRM/Upgrade/Incremental/php/FourSeven.php +++ b/CRM/Upgrade/Incremental/php/FourSeven.php @@ -492,10 +492,10 @@ public function upgrade_4_7_28($rev) { * @param string $rev */ public function upgrade_4_7_31($rev) { - $this->addTask(ts('Upgrade DB to %1: SQL', [1 => $rev]), 'runSql', $rev); $this->addTask('CRM-21225: Add display title field to civicrm_uf_group', 'addColumn', 'civicrm_uf_group', 'frontend_title', - "VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL COMMENT 'Profile Form Public title'", TRUE); - $this->addTask('Rebuild Multilingual Schema', 'rebuildMultilingalSchema'); + "VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL COMMENT 'Profile Form Public title'", TRUE, '4.7.31'); + $this->addTask(ts('Upgrade DB to %1: SQL', [1 => $rev]), 'runSql', $rev); + $this->addTask('Rebuild Multilingual Schema', 'rebuildMultilingalSchema', '4.7.31'); } /** From 3d3449ce266ead91b43ece3b337d8c8a38bbad75 Mon Sep 17 00:00:00 2001 From: eileen Date: Mon, 8 Apr 2019 15:25:46 +1200 Subject: [PATCH 110/121] Add unit testing for activity creation when cancelling a recurring, related cleanup --- CRM/Contribute/BAO/ContributionRecur.php | 23 +++++++++---------- CRM/Contribute/Form/CancelSubscription.php | 9 +------- .../phpunit/api/v3/ContributionRecurTest.php | 8 ++++++- 3 files changed, 19 insertions(+), 21 deletions(-) diff --git a/CRM/Contribute/BAO/ContributionRecur.php b/CRM/Contribute/BAO/ContributionRecur.php index 559496f02f0f..649b361b49d6 100644 --- a/CRM/Contribute/BAO/ContributionRecur.php +++ b/CRM/Contribute/BAO/ContributionRecur.php @@ -261,11 +261,9 @@ public static function deleteRecurContribution($recurId) { * @param array $params * Recur contribution params * - * @param array $activityParams - * * @return bool */ - public static function cancelRecurContribution($params, $activityParams = []) { + public static function cancelRecurContribution($params) { if (is_int($params)) { CRM_Core_Error::deprecatedFunctionWarning('You are using a BAO function whose signature has changed. Please use the ContributionRecur.cancel api'); $params = ['id' => $params]; @@ -274,6 +272,10 @@ public static function cancelRecurContribution($params, $activityParams = []) { if (!$recurId) { return FALSE; } + $activityParams = [ + 'subject' => !empty($params['membership_id']) ? ts('Auto-renewal membership cancelled') : ts('Recurring contribution cancelled'), + 'details' => CRM_Utils_Array::value('processor_message', $params), + ]; $contributionStatus = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name'); $canceledId = array_search('Cancelled', $contributionStatus); @@ -303,8 +305,7 @@ public static function cancelRecurContribution($params, $activityParams = []) {
      ' . ts('Automatic renewal of %1 membership cancelled.', [1 => $membershipType]); } else { - $details .= ' -
      ' . ts('The recurring contribution of %1, every %2 %3 has been cancelled.', [ + $details .= '
      ' . ts('The recurring contribution of %1, every %2 %3 has been cancelled.', [ 1 => $dao->amount, 2 => $dao->frequency_interval, 3 => $dao->frequency_unit, @@ -313,20 +314,18 @@ public static function cancelRecurContribution($params, $activityParams = []) { $activityParams = [ 'source_contact_id' => $dao->contact_id, 'source_record_id' => $dao->recur_id, - 'activity_type_id' => CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Cancel Recurring Contribution'), + 'activity_type_id' => 'Cancel Recurring Contribution', 'subject' => CRM_Utils_Array::value('subject', $activityParams, ts('Recurring contribution cancelled')), 'details' => $details, - 'activity_date_time' => date('YmdHis'), - 'status_id' => CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_status_id', 'Completed'), + 'status_id' => 'Completed', ]; - $session = CRM_Core_Session::singleton(); - $cid = $session->get('userID'); + + $cid = CRM_Core_Session::singleton()->get('userID'); if ($cid) { $activityParams['target_contact_id'][] = $activityParams['source_contact_id']; $activityParams['source_contact_id'] = $cid; } - // @todo use the api & do less wrangling above - CRM_Activity_BAO_Activity::create($activityParams); + civicrm_api3('Activity', 'create', $activityParams); } $transaction->commit(); diff --git a/CRM/Contribute/Form/CancelSubscription.php b/CRM/Contribute/Form/CancelSubscription.php index dfd921041bd0..22896289093f 100644 --- a/CRM/Contribute/Form/CancelSubscription.php +++ b/CRM/Contribute/Form/CancelSubscription.php @@ -207,15 +207,8 @@ public function postProcess() { CRM_Core_Error::displaySessionError($cancelSubscription); } elseif ($cancelSubscription) { - $activityParams - = [ - 'subject' => $this->_mid ? ts('Auto-renewal membership cancelled') : ts('Recurring contribution cancelled'), - 'details' => $message, - ]; $cancelStatus = CRM_Contribute_BAO_ContributionRecur::cancelRecurContribution( - ['id' => $this->_subscriptionDetails->recur_id], - $activityParams - ); + ['id' => $this->_subscriptionDetails->recur_id, 'membership_id' => $this->_mid, 'processor_message' => $message]); if ($cancelStatus) { $tplParams = []; diff --git a/tests/phpunit/api/v3/ContributionRecurTest.php b/tests/phpunit/api/v3/ContributionRecurTest.php index 93e15db7bcb8..7903e0f40de3 100644 --- a/tests/phpunit/api/v3/ContributionRecurTest.php +++ b/tests/phpunit/api/v3/ContributionRecurTest.php @@ -105,11 +105,17 @@ public function testGetFieldsContributionRecur() { */ public function testContributionRecurCancel() { $result = $this->callAPISuccess($this->_entity, 'create', $this->params); - $this->callAPISuccess('ContributionRecur', 'cancel', ['id' => $result['id'], 'cancel_reason' => 'just cos']); + $this->callAPISuccess('ContributionRecur', 'cancel', ['id' => $result['id'], 'cancel_reason' => 'just cos', 'processor_message' => 'big fail']); $cancelled = $this->callAPISuccess('ContributionRecur', 'getsingle', ['id' => $result['id']]); $this->assertEquals('just cos', $cancelled['cancel_reason']); $this->assertEquals(CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_ContributionRecur', 'contribution_status_id', 'Cancelled'), $cancelled['contribution_status_id']); $this->assertEquals(date('Y-m-d'), date('Y-m-d', strtotime($cancelled['cancel_date']))); + $activity = $this->callAPISuccessGetSingle('Activity', ['activity_type_id' => 'Cancel Recurring Contribution', 'record_type_id' => $result['id']]); + $this->assertEquals('Recurring contribution cancelled', $activity['subject']); + $this->assertEquals('big fail
      The recurring contribution of 500.00, every 1 day has been cancelled.', $activity['details']); + $this->assertEquals(date('Y-m-d'), date('Y-m-d', strtotime($activity['activity_date_time']))); + $this->assertEquals($this->params['contact_id'], $activity['source_contact_id']); + $this->assertEquals(CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'status_id', 'Completed'), $activity['status_id']); } } From 08a3a5199c0f3437b15279a08c946147b686cbff Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Mon, 8 Apr 2019 16:20:36 -0700 Subject: [PATCH 111/121] Pass menubar preference as a param. Simplify cache mechanics. (#8) Ex: If an admin uses an API call (CLI/REST) to change the menubar color, then they don't need to follow-up with a cache-clear. The new setting just goes live. Ex: If a customization (via `civicrm.settings.php` or via extension) decides on the color scheme programmatically (e.g. per-domain or per-role or per-user-preference), then they don't need to clear cache. Multiple color schemes can coexist. --- CRM/Admin/Form/Preferences/Display.php | 2 -- CRM/Core/Resources.php | 6 ++++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CRM/Admin/Form/Preferences/Display.php b/CRM/Admin/Form/Preferences/Display.php index 5f84883e956b..9ba36825cdf9 100644 --- a/CRM/Admin/Form/Preferences/Display.php +++ b/CRM/Admin/Form/Preferences/Display.php @@ -106,8 +106,6 @@ public function postProcess() { $this->postProcessCommon(); - \Civi::service('asset_builder')->clear(); - // If "Configure CKEditor" button was clicked if (!empty($this->_params['ckeditor_config'])) { // Suppress the "Saved" status message and redirect to the CKEditor Config page diff --git a/CRM/Core/Resources.php b/CRM/Core/Resources.php index 98b3ba8ae5bd..55d8461d8fd4 100644 --- a/CRM/Core/Resources.php +++ b/CRM/Core/Resources.php @@ -765,7 +765,9 @@ public function coreResourceList($region) { $items[] = 'bower_components/smartmenus/dist/jquery.smartmenus.min.js'; $items[] = 'bower_components/smartmenus/dist/addons/keyboard/jquery.smartmenus.keyboard.min.js'; $items[] = 'js/crm.menubar.js'; - $items[] = Civi::service('asset_builder')->getUrl('crm-menubar.css'); + $items[] = Civi::service('asset_builder')->getUrl('crm-menubar.css', [ + 'color' => Civi::settings()->get('menubar_color'), + ]); $items[] = [ 'menubar' => [ 'position' => $position, @@ -844,7 +846,7 @@ public static function renderMenubarStylesheet(GenericHookEvent $e) { foreach ($items as $item) { $e->content .= file_get_contents(self::singleton()->getPath('civicrm', $item)); } - $color = Civi::settings()->get('menubar_color'); + $color = $e->params['color']; if (!CRM_Utils_Rule::color($color)) { $color = Civi::settings()->getDefault('menubar_color'); } From f15d3f218eb73db309bb182aa8580cd03c0480e4 Mon Sep 17 00:00:00 2001 From: eileen Date: Tue, 9 Apr 2019 12:51:57 +1200 Subject: [PATCH 112/121] Include lower level data when throwing an exception on payment processor.pay --- api/v3/PaymentProcessor.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/api/v3/PaymentProcessor.php b/api/v3/PaymentProcessor.php index 51e401c75e96..0c8b7c131662 100644 --- a/api/v3/PaymentProcessor.php +++ b/api/v3/PaymentProcessor.php @@ -122,12 +122,23 @@ function _civicrm_api3_payment_processor_getlist_defaults(&$request) { * * @return array * API result array. - * @throws CiviCRM_API3_Exception + * + * @throws \API_Exception */ function civicrm_api3_payment_processor_pay($params) { $processor = Civi\Payment\System::singleton()->getById($params['payment_processor_id']); $processor->setPaymentProcessor(civicrm_api3('PaymentProcessor', 'getsingle', ['id' => $params['payment_processor_id']])); - $result = $processor->doPayment($params); + try { + $result = $processor->doPayment($params); + } + catch (\Civi\Payment\Exception\PaymentProcessorException $e) { + $code = $e->getErrorCode(); + $errorData = $e->getErrorData(); + if (empty($code)) { + $code = 'EXTERNAL_FAILURE'; + } + throw new API_Exception('Payment failed', $code, $errorData, $e); + } return civicrm_api3_create_success(array($result), $params); } From f22fb451346b41578cda9bb606a713881317ef59 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Mon, 8 Apr 2019 16:13:48 -0700 Subject: [PATCH 113/121] (REF) CRM_Core_Resources - Move hook declaration from addCoreResources() to Container.php tldr: It's easier to declare `hook_civicrm_buildAsset` listeners at a high-level. Asset building can use two modes -- production mode writes a static file to disk when it's being reference. Debug mode just generates a URL for a web-service (which in turn dynamically renders the content in a separate page-view). If the only mode were production mode, then the code would be on pretty solid ground. We could even simplify things a lot by changing the AssetBuilder contract to replace the hooks with callbacks, as in: ```php Civi::service('asset_builder')->getUrl('crm-menu.css', function() { return '...the css code...'; }); ``` Why have a hook? Because hooks are generally context-free and always-available. If we use debug-mode (or if we add a feature to warm-up the caches during deployment), then we'll want to fire that hook from a different context (e.g. web-service or CLI), and the hook-listener needs to be available in those other contexts. It would be nice if we could declare hooks generally without needing to edit the `Container.php` mega-file (e.g. maybe some kind of annotation). But, for the moment, I think this is the best spot that we have in `civicrm-core` for ensuring that hook listeners are fully/consistently registered. --- CRM/Core/Resources.php | 1 - Civi/Core/Container.php | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/CRM/Core/Resources.php b/CRM/Core/Resources.php index 55d8461d8fd4..c65d0330eb77 100644 --- a/CRM/Core/Resources.php +++ b/CRM/Core/Resources.php @@ -582,7 +582,6 @@ public function resetCacheCode() { * @return CRM_Core_Resources */ public function addCoreResources($region = 'html-header') { - Civi::dispatcher()->addListener('hook_civicrm_buildAsset', [$this, 'renderMenubarStylesheet']); if (!isset($this->addedCoreResources[$region]) && !self::isAjaxMode()) { $this->addedCoreResources[$region] = TRUE; $config = CRM_Core_Config::singleton(); diff --git a/Civi/Core/Container.php b/Civi/Core/Container.php index 4e01f4a9dbd8..201111773ad0 100644 --- a/Civi/Core/Container.php +++ b/Civi/Core/Container.php @@ -320,6 +320,7 @@ public function createEventDispatcher($container) { $dispatcher->addListener('hook_civicrm_buildAsset', ['\Civi\Angular\Page\Modules', 'buildAngularModules']); $dispatcher->addListener('hook_civicrm_buildAsset', ['\CRM_Utils_VisualBundle', 'buildAssetJs']); $dispatcher->addListener('hook_civicrm_buildAsset', ['\CRM_Utils_VisualBundle', 'buildAssetCss']); + $dispatcher->addListener('hook_civicrm_buildAsset', ['\CRM_Core_Resources', 'renderMenubarStylesheet']); $dispatcher->addListener('civi.dao.postInsert', ['\CRM_Core_BAO_RecurringEntity', 'triggerInsert']); $dispatcher->addListener('civi.dao.postUpdate', ['\CRM_Core_BAO_RecurringEntity', 'triggerUpdate']); $dispatcher->addListener('civi.dao.postDelete', ['\CRM_Core_BAO_RecurringEntity', 'triggerDelete']); From dfc29fbb70d562b26ba938bf149cbaf9ab03d6cd Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Mon, 8 Apr 2019 21:08:59 -0400 Subject: [PATCH 114/121] colorTest --- tests/phpunit/CRM/Utils/ColorTest.php | 36 +++++++++++++++++++-------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/tests/phpunit/CRM/Utils/ColorTest.php b/tests/phpunit/CRM/Utils/ColorTest.php index 77b894f2a98b..94cb87527c5f 100644 --- a/tests/phpunit/CRM/Utils/ColorTest.php +++ b/tests/phpunit/CRM/Utils/ColorTest.php @@ -14,16 +14,32 @@ public function testGetContrast($background, $text) { } public function contrastExamples() { - return array( - array('ef4444', 'white'), - array('FAA31B', 'black'), - array('FFF000', 'black'), - array(' 82c341', 'black'), - array('#009F75', 'white'), - array('#88C6eD', 'black'), - array('# 394ba0', 'white'), - array(' #D54799', 'white'), - ); + return [ + ['ef4444', 'white'], + ['FAA31B', 'black'], + ['FFF000', 'black'], + [' 82c341', 'black'], + ['#009F75', 'white'], + ['#88C6eD', 'black'], + ['# 394ba0', 'white'], + [' #D54799', 'white'], + ]; + } + + /** + * @dataProvider rgbExamples + */ + public function testGetRgb($hex, $rgb) { + $this->assertEquals($rgb, CRM_Utils_Color::getRgb($hex)); + } + + public function rgbExamples() { + return [ + ['#fff', [255, 255, 255]], + ['#000000', [0, 0, 0]], + ['#111', [17, 17, 17]], + [' fffc99 ', [255, 252, 153]], + ]; } } From 4c257e173ba1ed08f29abeba0c21636cf5a26f22 Mon Sep 17 00:00:00 2001 From: eileen Date: Mon, 8 Apr 2019 10:16:10 +1200 Subject: [PATCH 115/121] Update new payment_processor.title field to be localisable Re-order upgrade to fix upgrade process and ensure there is the runSql step --- CRM/Core/I18n/SchemaStructure.php | 8 + CRM/Core/I18n/SchemaStructure_5_13_alpha1.php | 722 ++++++++++++++++++ CRM/Financial/DAO/PaymentProcessor.php | 6 +- CRM/Upgrade/Incremental/php/FiveThirteen.php | 7 +- CRM/Upgrade/Incremental/php/FourThree.php | 2 +- xml/schema/Financial/PaymentProcessor.xml | 1 + 6 files changed, 739 insertions(+), 7 deletions(-) create mode 100644 CRM/Core/I18n/SchemaStructure_5_13_alpha1.php diff --git a/CRM/Core/I18n/SchemaStructure.php b/CRM/Core/I18n/SchemaStructure.php index bec6ec355eb7..5bc0a76f0173 100644 --- a/CRM/Core/I18n/SchemaStructure.php +++ b/CRM/Core/I18n/SchemaStructure.php @@ -129,6 +129,9 @@ public static function &columns() { 'description' => "text", 'options' => "text", ], + 'civicrm_payment_processor' => [ + 'title' => "varchar(127)", + ], 'civicrm_membership_type' => [ 'name' => "varchar(128)", 'description' => "varchar(255)", @@ -486,6 +489,11 @@ static function &widgets() { 'type' => "Text", ], ], + 'civicrm_payment_processor' => [ + 'title' => [ + 'type' => "Text", + ], + ], 'civicrm_membership_type' => [ 'name' => [ 'type' => "Text", diff --git a/CRM/Core/I18n/SchemaStructure_5_13_alpha1.php b/CRM/Core/I18n/SchemaStructure_5_13_alpha1.php new file mode 100644 index 000000000000..2daed955688b --- /dev/null +++ b/CRM/Core/I18n/SchemaStructure_5_13_alpha1.php @@ -0,0 +1,722 @@ + [ + 'display_name' => "varchar(64)", + ], + 'civicrm_option_group' => [ + 'title' => "varchar(255)", + 'description' => "varchar(255)", + ], + 'civicrm_relationship_type' => [ + 'label_a_b' => "varchar(64)", + 'label_b_a' => "varchar(64)", + 'description' => "varchar(255)", + ], + 'civicrm_contact_type' => [ + 'label' => "varchar(64)", + 'description' => "text", + ], + 'civicrm_batch' => [ + 'title' => "varchar(255)", + 'description' => "text", + ], + 'civicrm_premiums' => [ + 'premiums_intro_title' => "varchar(255)", + 'premiums_intro_text' => "text", + 'premiums_nothankyou_label' => "varchar(255)", + ], + 'civicrm_membership_status' => [ + 'label' => "varchar(128)", + ], + 'civicrm_survey' => [ + 'title' => "varchar(255)", + 'instructions' => "text", + 'thankyou_title' => "varchar(255)", + 'thankyou_text' => "text", + ], + 'civicrm_participant_status_type' => [ + 'label' => "varchar(255)", + ], + 'civicrm_case_type' => [ + 'title' => "varchar(64)", + 'description' => "varchar(255)", + ], + 'civicrm_tell_friend' => [ + 'title' => "varchar(255)", + 'intro' => "text", + 'suggested_message' => "text", + 'thankyou_title' => "varchar(255)", + 'thankyou_text' => "text", + ], + 'civicrm_custom_group' => [ + 'title' => "varchar(64)", + 'help_pre' => "text", + 'help_post' => "text", + ], + 'civicrm_custom_field' => [ + 'label' => "varchar(255)", + 'help_pre' => "text", + 'help_post' => "text", + ], + 'civicrm_option_value' => [ + 'label' => "varchar(512)", + 'description' => "text", + ], + 'civicrm_group' => [ + 'title' => "varchar(64)", + ], + 'civicrm_contribution_page' => [ + 'title' => "varchar(255)", + 'intro_text' => "text", + 'pay_later_text' => "text", + 'pay_later_receipt' => "text", + 'initial_amount_label' => "varchar(255)", + 'initial_amount_help_text' => "text", + 'thankyou_title' => "varchar(255)", + 'thankyou_text' => "text", + 'thankyou_footer' => "text", + 'receipt_from_name' => "varchar(255)", + 'receipt_text' => "text", + 'footer_text' => "text", + ], + 'civicrm_product' => [ + 'name' => "varchar(255)", + 'description' => "text", + 'options' => "text", + ], + 'civicrm_payment_processor' => [ + 'title' => "varchar(127)", + ], + 'civicrm_membership_type' => [ + 'name' => "varchar(128)", + 'description' => "varchar(255)", + ], + 'civicrm_membership_block' => [ + 'new_title' => "varchar(255)", + 'new_text' => "text", + 'renewal_title' => "varchar(255)", + 'renewal_text' => "text", + ], + 'civicrm_price_set' => [ + 'title' => "varchar(255)", + 'help_pre' => "text", + 'help_post' => "text", + ], + 'civicrm_dashboard' => [ + 'label' => "varchar(255)", + ], + 'civicrm_uf_group' => [ + 'title' => "varchar(64)", + 'frontend_title' => "varchar(64)", + 'help_pre' => "text", + 'help_post' => "text", + 'cancel_button_text' => "varchar(64)", + 'submit_button_text' => "varchar(64)", + ], + 'civicrm_uf_field' => [ + 'help_post' => "text", + 'help_pre' => "text", + 'label' => "varchar(255)", + ], + 'civicrm_price_field' => [ + 'label' => "varchar(255)", + 'help_pre' => "text", + 'help_post' => "text", + ], + 'civicrm_price_field_value' => [ + 'label' => "varchar(255)", + 'description' => "text", + 'help_pre' => "text", + 'help_post' => "text", + ], + 'civicrm_pcp_block' => [ + 'link_text' => "varchar(255)", + ], + 'civicrm_event' => [ + 'title' => "varchar(255)", + 'summary' => "text", + 'description' => "text", + 'registration_link_text' => "varchar(255)", + 'event_full_text' => "text", + 'fee_label' => "varchar(255)", + 'intro_text' => "text", + 'footer_text' => "text", + 'confirm_title' => "varchar(255)", + 'confirm_text' => "text", + 'confirm_footer_text' => "text", + 'confirm_email_text' => "text", + 'confirm_from_name' => "varchar(255)", + 'thankyou_title' => "varchar(255)", + 'thankyou_text' => "text", + 'thankyou_footer_text' => "text", + 'pay_later_text' => "text", + 'pay_later_receipt' => "text", + 'initial_amount_label' => "varchar(255)", + 'initial_amount_help_text' => "text", + 'waitlist_text' => "text", + 'approval_req_text' => "text", + 'template_title' => "varchar(255)", + ], + ]; + } + return $result; + } + + /** + * Get a table indexed array of the indices for translatable fields. + * + * @return array + * Indices for translatable fields. + */ + public static function &indices() { + static $result = NULL; + if (!$result) { + $result = [ + 'civicrm_custom_group' => [ + 'UI_title_extends' => [ + 'name' => 'UI_title_extends', + 'field' => [ + 'title', + 'extends', + ], + 'unique' => 1, + ], + ], + 'civicrm_custom_field' => [ + 'UI_label_custom_group_id' => [ + 'name' => 'UI_label_custom_group_id', + 'field' => [ + 'label', + 'custom_group_id', + ], + 'unique' => 1, + ], + ], + 'civicrm_group' => [ + 'UI_title' => [ + 'name' => 'UI_title', + 'field' => [ + 'title', + ], + 'unique' => 1, + ], + ], + ]; + } + return $result; + } + + /** + * Get tables with translatable fields. + * + * @return array + * Array of names of tables with fields that can be translated. + */ + public static function &tables() { + static $result = NULL; + if (!$result) { + $result = array_keys(self::columns()); + } + return $result; + } + + /** + * Get a list of widgets for editing translatable fields. + * + * @return array + * Array of the widgets for editing translatable fields. + */ + public static function &widgets() { + static $result = NULL; + if (!$result) { + $result = [ + 'civicrm_location_type' => [ + 'display_name' => [ + 'type' => "Text", + ], + ], + 'civicrm_option_group' => [ + 'title' => [ + 'type' => "Text", + ], + 'description' => [ + 'type' => "Text", + ], + ], + 'civicrm_relationship_type' => [ + 'label_a_b' => [ + 'type' => "Text", + ], + 'label_b_a' => [ + 'type' => "Text", + ], + 'description' => [ + 'type' => "Text", + ], + ], + 'civicrm_contact_type' => [ + 'label' => [ + 'type' => "Text", + ], + 'description' => [ + 'type' => "TextArea", + 'rows' => "2", + 'cols' => "60", + ], + ], + 'civicrm_batch' => [ + 'title' => [ + 'type' => "Text", + ], + 'description' => [ + 'type' => "TextArea", + 'rows' => "4", + 'cols' => "80", + ], + ], + 'civicrm_premiums' => [ + 'premiums_intro_title' => [ + 'type' => "Text", + ], + 'premiums_intro_text' => [ + 'type' => "Text", + ], + 'premiums_nothankyou_label' => [ + 'type' => "Text", + ], + ], + 'civicrm_membership_status' => [ + 'label' => [ + 'type' => "Text", + ], + ], + 'civicrm_survey' => [ + 'title' => [ + 'type' => "Text", + 'required' => "true", + ], + 'instructions' => [ + 'type' => "TextArea", + 'rows' => "20", + 'cols' => "80", + ], + 'thankyou_title' => [ + 'type' => "Text", + ], + 'thankyou_text' => [ + 'type' => "TextArea", + 'rows' => "8", + 'cols' => "60", + ], + ], + 'civicrm_participant_status_type' => [ + 'label' => [ + 'type' => "Text", + ], + ], + 'civicrm_case_type' => [ + 'title' => [ + 'type' => "Text", + 'required' => "true", + ], + 'description' => [ + 'type' => "Text", + ], + ], + 'civicrm_tell_friend' => [ + 'title' => [ + 'type' => "Text", + ], + 'intro' => [ + 'type' => "Text", + ], + 'suggested_message' => [ + 'type' => "Text", + ], + 'thankyou_title' => [ + 'type' => "Text", + ], + 'thankyou_text' => [ + 'type' => "Text", + ], + ], + 'civicrm_custom_group' => [ + 'title' => [ + 'type' => "Text", + 'required' => "true", + ], + 'help_pre' => [ + 'type' => "TextArea", + 'rows' => "4", + 'cols' => "80", + ], + 'help_post' => [ + 'type' => "TextArea", + 'rows' => "4", + 'cols' => "80", + ], + ], + 'civicrm_custom_field' => [ + 'label' => [ + 'type' => "Text", + 'required' => "true", + ], + 'help_pre' => [ + 'type' => "Text", + ], + 'help_post' => [ + 'type' => "Text", + ], + ], + 'civicrm_option_value' => [ + 'label' => [ + 'type' => "Text", + 'required' => "true", + ], + 'description' => [ + 'type' => "TextArea", + 'rows' => "8", + 'cols' => "60", + ], + ], + 'civicrm_group' => [ + 'title' => [ + 'type' => "Text", + ], + ], + 'civicrm_contribution_page' => [ + 'title' => [ + 'type' => "Text", + ], + 'intro_text' => [ + 'type' => "RichTextEditor", + 'rows' => "6", + 'cols' => "50", + ], + 'pay_later_text' => [ + 'type' => "Text", + ], + 'pay_later_receipt' => [ + 'type' => "Text", + ], + 'initial_amount_label' => [ + 'type' => "Text", + ], + 'initial_amount_help_text' => [ + 'type' => "Text", + ], + 'thankyou_title' => [ + 'type' => "Text", + ], + 'thankyou_text' => [ + 'type' => "RichTextEditor", + 'rows' => "8", + 'cols' => "60", + ], + 'thankyou_footer' => [ + 'type' => "RichTextEditor", + 'rows' => "8", + 'cols' => "60", + ], + 'receipt_from_name' => [ + 'type' => "Text", + ], + 'receipt_text' => [ + 'type' => "TextArea", + 'rows' => "6", + 'cols' => "50", + ], + 'footer_text' => [ + 'type' => "RichTextEditor", + 'rows' => "6", + 'cols' => "50", + ], + ], + 'civicrm_product' => [ + 'name' => [ + 'type' => "Text", + 'required' => "true", + ], + 'description' => [ + 'type' => "Text", + ], + 'options' => [ + 'type' => "Text", + ], + ], + 'civicrm_payment_processor' => [ + 'title' => [ + 'type' => "Text", + ], + ], + 'civicrm_membership_type' => [ + 'name' => [ + 'type' => "Text", + 'label' => "Name", + ], + 'description' => [ + 'type' => "TextArea", + 'rows' => "6", + 'cols' => "50", + 'label' => "Description", + ], + ], + 'civicrm_membership_block' => [ + 'new_title' => [ + 'type' => "Text", + ], + 'new_text' => [ + 'type' => "Text", + ], + 'renewal_title' => [ + 'type' => "Text", + ], + 'renewal_text' => [ + 'type' => "Text", + ], + ], + 'civicrm_price_set' => [ + 'title' => [ + 'type' => "Text", + 'required' => "true", + ], + 'help_pre' => [ + 'type' => "TextArea", + 'rows' => "4", + 'cols' => "80", + ], + 'help_post' => [ + 'type' => "TextArea", + 'rows' => "4", + 'cols' => "80", + ], + ], + 'civicrm_dashboard' => [ + 'label' => [ + 'type' => "Text", + ], + ], + 'civicrm_uf_group' => [ + 'title' => [ + 'type' => "Text", + 'required' => "true", + ], + 'frontend_title' => [ + 'type' => "Text", + ], + 'help_pre' => [ + 'type' => "TextArea", + 'rows' => "4", + 'cols' => "80", + ], + 'help_post' => [ + 'type' => "TextArea", + 'rows' => "4", + 'cols' => "80", + ], + 'cancel_button_text' => [ + 'type' => "Text", + ], + 'submit_button_text' => [ + 'type' => "Text", + ], + ], + 'civicrm_uf_field' => [ + 'help_post' => [ + 'type' => "Text", + ], + 'help_pre' => [ + 'type' => "Text", + ], + 'label' => [ + 'type' => "Text", + 'required' => "true", + ], + ], + 'civicrm_price_field' => [ + 'label' => [ + 'type' => "Text", + 'required' => "true", + ], + 'help_pre' => [ + 'type' => "TextArea", + 'rows' => "4", + 'cols' => "80", + ], + 'help_post' => [ + 'type' => "TextArea", + 'rows' => "4", + 'cols' => "80", + ], + ], + 'civicrm_price_field_value' => [ + 'label' => [ + 'type' => "Text", + ], + 'description' => [ + 'type' => "TextArea", + 'rows' => "2", + 'cols' => "60", + ], + 'help_pre' => [ + 'type' => "TextArea", + 'rows' => "2", + 'cols' => "60", + ], + 'help_post' => [ + 'type' => "TextArea", + 'rows' => "2", + 'cols' => "60", + ], + ], + 'civicrm_pcp_block' => [ + 'link_text' => [ + 'type' => "Text", + ], + ], + 'civicrm_event' => [ + 'title' => [ + 'type' => "Text", + ], + 'summary' => [ + 'type' => "TextArea", + 'rows' => "4", + 'cols' => "60", + ], + 'description' => [ + 'type' => "TextArea", + 'rows' => "8", + 'cols' => "60", + ], + 'registration_link_text' => [ + 'type' => "Text", + ], + 'event_full_text' => [ + 'type' => "TextArea", + 'rows' => "4", + 'cols' => "60", + ], + 'fee_label' => [ + 'type' => "Text", + ], + 'intro_text' => [ + 'type' => "TextArea", + 'rows' => "6", + 'cols' => "50", + ], + 'footer_text' => [ + 'type' => "TextArea", + 'rows' => "6", + 'cols' => "50", + ], + 'confirm_title' => [ + 'type' => "Text", + ], + 'confirm_text' => [ + 'type' => "TextArea", + 'rows' => "6", + 'cols' => "50", + ], + 'confirm_footer_text' => [ + 'type' => "TextArea", + 'rows' => "6", + 'cols' => "50", + ], + 'confirm_email_text' => [ + 'type' => "TextArea", + 'rows' => "4", + 'cols' => "50", + ], + 'confirm_from_name' => [ + 'type' => "Text", + ], + 'thankyou_title' => [ + 'type' => "Text", + ], + 'thankyou_text' => [ + 'type' => "TextArea", + 'rows' => "6", + 'cols' => "50", + ], + 'thankyou_footer_text' => [ + 'type' => "TextArea", + 'rows' => "6", + 'cols' => "50", + ], + 'pay_later_text' => [ + 'type' => "Text", + ], + 'pay_later_receipt' => [ + 'type' => "Text", + ], + 'initial_amount_label' => [ + 'type' => "Text", + ], + 'initial_amount_help_text' => [ + 'type' => "Text", + ], + 'waitlist_text' => [ + 'type' => "TextArea", + 'rows' => "4", + 'cols' => "60", + ], + 'approval_req_text' => [ + 'type' => "TextArea", + 'rows' => "4", + 'cols' => "60", + ], + 'template_title' => [ + 'type' => "Text", + ], + ], + ]; + } + return $result; + } + +} diff --git a/CRM/Financial/DAO/PaymentProcessor.php b/CRM/Financial/DAO/PaymentProcessor.php index 2c8bcffc3421..eccbc23fc1cc 100644 --- a/CRM/Financial/DAO/PaymentProcessor.php +++ b/CRM/Financial/DAO/PaymentProcessor.php @@ -6,7 +6,7 @@ * * Generated from xml/schema/CRM/Financial/PaymentProcessor.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:42c6dc8a71daeb67aaa687156121ebf4) + * (GenCodeChecksum:83f0467b531d70e84945e9c55a8824b6) */ /** @@ -254,7 +254,7 @@ public static function &fields() { 'table_name' => 'civicrm_payment_processor', 'entity' => 'PaymentProcessor', 'bao' => 'CRM_Financial_BAO_PaymentProcessor', - 'localizable' => 0, + 'localizable' => 1, 'html' => [ 'type' => 'Text', ], @@ -523,7 +523,7 @@ public static function &fieldKeys() { * @return string */ public static function getTableName() { - return self::$_tableName; + return CRM_Core_DAO::getLocaleTableName(self::$_tableName); } /** diff --git a/CRM/Upgrade/Incremental/php/FiveThirteen.php b/CRM/Upgrade/Incremental/php/FiveThirteen.php index 5bfafc9e970c..22078f373243 100644 --- a/CRM/Upgrade/Incremental/php/FiveThirteen.php +++ b/CRM/Upgrade/Incremental/php/FiveThirteen.php @@ -74,12 +74,13 @@ public function setPostUpgradeMessage(&$postUpgradeMessage, $rev) { * @param string $rev */ public function upgrade_5_13_alpha1($rev) { + $this->addTask('Add title to civicrm_payment_processor', 'addColumn', + 'civicrm_payment_processor', 'title', "text COMMENT 'Payment Processor Descriptive Name.'", TRUE, '5.13.alpha1' + ); $this->addTask('Add cancel reason column to civicrm_contribution_recur', 'addColumn', 'civicrm_contribution_recur', 'cancel_reason', "text COMMENT 'Free text field for a reason for cancelling'", FALSE ); - $this->addTask('Add title to civicrm_payment_processor', 'addColumn', - 'civicrm_payment_processor', 'title', "text COMMENT 'Payment Processor Descriptive Name.'", FALSE - ); + $this->addTask(ts('Upgrade DB to %1: SQL', [1 => $rev]), 'runSql', $rev); } } diff --git a/CRM/Upgrade/Incremental/php/FourThree.php b/CRM/Upgrade/Incremental/php/FourThree.php index fe264d957725..a444e4962baf 100644 --- a/CRM/Upgrade/Incremental/php/FourThree.php +++ b/CRM/Upgrade/Incremental/php/FourThree.php @@ -92,7 +92,7 @@ public function setPreUpgradeMessage(&$preUpgradeMessage, $rev, $currentVer = NU if ($value != 'contact_id') { $query .= " AND contri_recur.{$value} IS NOT NULL "; } - $dao = CRM_Core_DAO::executeQuery($query); + $dao = CRM_Core_DAO::executeQuery($query, [], TRUE, NULL, FALSE, FALSE); if ($dao->N) { $invalidDataMessage = 'Oops, it looks like you have orphaned recurring contribution records in your database. Before this upgrade can complete they will need to be fixed or deleted. You can review steps to correct this situation on the documentation wiki.'; CRM_Core_Error::fatal($invalidDataMessage); diff --git a/xml/schema/Financial/PaymentProcessor.xml b/xml/schema/Financial/PaymentProcessor.xml index ceeba6b0ad71..76d1ef13bed1 100644 --- a/xml/schema/Financial/PaymentProcessor.xml +++ b/xml/schema/Financial/PaymentProcessor.xml @@ -52,6 +52,7 @@ Payment Processor Title varchar 127 + true Text From dfe1f88a1ed326018844dba87e91ba699a879929 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Mon, 8 Apr 2019 20:29:07 -0400 Subject: [PATCH 116/121] Short array syntax - auto convert settings dir --- settings/Address.setting.php | 20 +- settings/Campaign.setting.php | 12 +- settings/Case.setting.php | 44 ++-- settings/Contribute.setting.php | 48 ++-- settings/Core.setting.php | 382 +++++++++++++++--------------- settings/Developer.setting.php | 44 ++-- settings/Directory.setting.php | 28 +-- settings/Event.setting.php | 12 +- settings/Extension.setting.php | 12 +- settings/Localization.setting.php | 246 +++++++++---------- settings/Mailing.setting.php | 114 ++++----- settings/Map.setting.php | 44 ++-- settings/Member.setting.php | 12 +- settings/Multisite.setting.php | 22 +- settings/Search.setting.php | 92 +++---- settings/Url.setting.php | 20 +- 16 files changed, 576 insertions(+), 576 deletions(-) diff --git a/settings/Address.setting.php b/settings/Address.setting.php index ab578db90898..86766815efff 100644 --- a/settings/Address.setting.php +++ b/settings/Address.setting.php @@ -34,8 +34,8 @@ /** * Settings metadata file */ -return array( - 'address_standardization_provider' => array( +return [ + 'address_standardization_provider' => [ 'group_name' => 'Address Preferences', 'group' => 'address', 'name' => 'address_standardization_provider', @@ -49,8 +49,8 @@ 'is_contact' => 0, 'description' => NULL, 'help_text' => 'CiviCRM includes an optional plugin for interfacing with the United States Postal Services (USPS) Address Standardization web service. You must register to use the USPS service at https://www.usps.com/business/web-tools-apis/address-information.htm. If you are approved, they will provide you with a User ID and the URL for the service. Plugins for other address standardization services may be available from 3rd party developers. If installed, they will be included in the drop-down below. ', - ), - 'address_standardization_userid' => array( + ], + 'address_standardization_userid' => [ 'group_name' => 'Address Preferences', 'group' => 'address', 'name' => 'address_standardization_userid', @@ -63,8 +63,8 @@ 'is_contact' => 0, 'description' => NULL, 'help_text' => NULL, - ), - 'address_standardization_url' => array( + ], + 'address_standardization_url' => [ 'group_name' => 'Address Preferences', 'group' => 'address', 'name' => 'address_standardization_url', @@ -78,8 +78,8 @@ 'description' => NULL, 'help_text' => 'Web Service URL', 'validate_callback' => 'CRM_Utils_Rule::url', - ), - 'hideCountryMailingLabels' => array( + ], + 'hideCountryMailingLabels' => [ 'group_name' => 'Address Preferences', 'group' => 'address', 'name' => 'hideCountryMailingLabels', @@ -92,5 +92,5 @@ 'is_contact' => 0, 'description' => 'Do not display the country field in mailing labels when the country is the same as that of the domain', 'help_text' => NULL, - ), -); + ], +]; diff --git a/settings/Campaign.setting.php b/settings/Campaign.setting.php index ef9673b7913b..a17b25007c25 100644 --- a/settings/Campaign.setting.php +++ b/settings/Campaign.setting.php @@ -35,8 +35,8 @@ * Settings metadata file */ -return array( - 'tag_unconfirmed' => array( +return [ + 'tag_unconfirmed' => [ 'group_name' => 'Campaign Preferences', 'group' => 'campaign', 'name' => 'tag_unconfirmed', @@ -49,8 +49,8 @@ 'is_contact' => 0, 'description' => ts('If set, new contacts that are created when signing a petition are assigned a tag of this name.'), 'help_text' => '', - ), - 'petition_contacts' => array( + ], + 'petition_contacts' => [ 'group_name' => 'Campaign Preferences', 'group' => 'campaign', 'name' => 'petition_contacts', @@ -63,6 +63,6 @@ 'is_contact' => 0, 'description' => ts('All contacts that have signed a CiviCampaign petition will be added to this group. The group will be created if it does not exist (it is required for email verification).'), 'help_text' => '', - ), + ], -); +]; diff --git a/settings/Case.setting.php b/settings/Case.setting.php index 7702a7947d75..f85cd0af3b6f 100644 --- a/settings/Case.setting.php +++ b/settings/Case.setting.php @@ -36,71 +36,71 @@ /** * Settings metadata file */ -return array( - 'civicaseRedactActivityEmail' => array( +return [ + 'civicaseRedactActivityEmail' => [ 'group_name' => 'CiviCRM Preferences', 'group' => 'core', 'name' => 'civicaseRedactActivityEmail', 'type' => 'String', 'quick_form_type' => 'Select', 'html_type' => 'Select', - 'html_attributes' => array( + 'html_attributes' => [ //'class' => 'crm-select2', - ), + ], 'default' => 'default', 'add' => '4.7', 'title' => 'Redact Activity Email', 'is_domain' => 1, 'is_contact' => 0, - 'pseudoconstant' => array( + 'pseudoconstant' => [ 'callback' => 'CRM_Case_Info::getRedactOptions', - ), + ], 'description' => 'Should activity emails be redacted? (Set "Default" to load setting from the legacy "Settings.xml" file.)', 'help_text' => '', - ), - 'civicaseAllowMultipleClients' => array( + ], + 'civicaseAllowMultipleClients' => [ 'group_name' => 'CiviCRM Preferences', 'group' => 'core', 'name' => 'civicaseAllowMultipleClients', 'type' => 'String', 'quick_form_type' => 'Select', 'html_type' => 'Select', - 'html_attributes' => array( + 'html_attributes' => [ //'class' => 'crm-select2', - ), + ], 'default' => 'default', 'add' => '4.7', 'title' => 'Allow Multiple Case Clients', 'is_domain' => 1, 'is_contact' => 0, - 'pseudoconstant' => array( + 'pseudoconstant' => [ 'callback' => 'CRM_Case_Info::getMultiClientOptions', - ), + ], 'description' => 'How many clients may be associated with a given case? (Set "Default" to load setting from the legacy "Settings.xml" file.)', 'help_text' => '', - ), - 'civicaseNaturalActivityTypeSort' => array( + ], + 'civicaseNaturalActivityTypeSort' => [ 'group_name' => 'CiviCRM Preferences', 'group' => 'core', 'name' => 'civicaseNaturalActivityTypeSort', 'type' => 'String', 'quick_form_type' => 'Select', 'html_type' => 'Select', - 'html_attributes' => array( + 'html_attributes' => [ //'class' => 'crm-select2', - ), + ], 'default' => 'default', 'add' => '4.7', 'title' => 'Activity Type Sorting', 'is_domain' => 1, 'is_contact' => 0, - 'pseudoconstant' => array( + 'pseudoconstant' => [ 'callback' => 'CRM_Case_Info::getSortOptions', - ), + ], 'description' => 'How to sort activity-types on the "Manage Case" screen? (Set "Default" to load setting from the legacy "Settings.xml" file.)', 'help_text' => '', - ), - 'civicaseActivityRevisions' => array( + ], + 'civicaseActivityRevisions' => [ 'group_name' => 'CiviCRM Preferences', 'group' => 'core', 'name' => 'civicaseActivityRevisions', @@ -114,5 +114,5 @@ 'is_contact' => 0, 'description' => 'Enable tracking of activity revisions embedded within the "civicrm_activity" table. Alternatively, see "Administer => System Settings => Misc => Logging".', 'help_text' => '', - ), -); + ], +]; diff --git a/settings/Contribute.setting.php b/settings/Contribute.setting.php index 7b675e036ff6..d40dd4d0c416 100644 --- a/settings/Contribute.setting.php +++ b/settings/Contribute.setting.php @@ -33,8 +33,8 @@ * Settings metadata file */ -return array( - 'cvv_backoffice_required' => array( +return [ + 'cvv_backoffice_required' => [ 'group_name' => 'Contribute Preferences', 'group' => 'contribute', 'name' => 'cvv_backoffice_required', @@ -48,15 +48,15 @@ 'is_contact' => 0, 'description' => 'Is the CVV code required for back office credit card transactions', 'help_text' => 'If set it back-office credit card transactions will required a cvv code. Leave as required unless you have a very strong reason to change', - ), - 'contribution_invoice_settings' => array( + ], + 'contribution_invoice_settings' => [ // @todo our standard is to have a setting per item not to hide settings in an array with // no useful metadata. Undo this setting. 'group_name' => 'Contribute Preferences', 'group' => 'contribute', 'name' => 'contribution_invoice_settings', 'type' => 'Array', - 'default' => array( + 'default' => [ 'invoice_prefix' => 'INV_', 'credit_notes_prefix' => 'CN_', 'due_date' => '10', @@ -64,15 +64,15 @@ 'notes' => '', 'tax_term' => 'Sales Tax', 'tax_display_settings' => 'Inclusive', - ), + ], 'add' => '4.7', 'title' => 'Contribution Invoice Settings', 'is_domain' => 1, 'is_contact' => 0, 'description' => NULL, 'help_text' => NULL, - ), - 'invoicing' => array( + ], + 'invoicing' => [ 'group_name' => 'Contribute Preferences', 'group' => 'contribute', 'name' => 'invoicing', @@ -84,11 +84,11 @@ 'title' => 'Enable Tax and Invoicing', 'is_domain' => 1, 'is_contact' => 0, - 'on_change' => array( + 'on_change' => [ 'CRM_Invoicing_Utils::onToggle', - ), - ), - 'acl_financial_type' => array( + ], + ], + 'acl_financial_type' => [ 'group_name' => 'Contribute Preferences', 'group' => 'contribute', 'name' => 'acl_financial_type', @@ -103,8 +103,8 @@ 'description' => NULL, 'help_text' => NULL, 'help' => ['id' => 'acl_financial_type'], - ), - 'deferred_revenue_enabled' => array( + ], + 'deferred_revenue_enabled' => [ 'group_name' => 'Contribute Preferences', 'group' => 'contribute', 'name' => 'deferred_revenue_enabled', @@ -118,18 +118,18 @@ 'is_contact' => 0, 'description' => NULL, 'help_text' => NULL, - ), - 'default_invoice_page' => array( + ], + 'default_invoice_page' => [ 'group_name' => 'Contribute Preferences', 'group' => 'contribute', 'name' => 'default_invoice_page', 'type' => 'Integer', 'quick_form_type' => 'Select', 'default' => NULL, - 'pseudoconstant' => array( + 'pseudoconstant' => [ // @todo - handle table style pseudoconstants for settings & avoid deprecated function. 'callback' => 'CRM_Contribute_PseudoConstant::contributionPage', - ), + ], 'html_type' => 'select', 'add' => '4.7', 'title' => 'Default invoice payment page', @@ -137,8 +137,8 @@ 'is_contact' => 0, 'description' => NULL, 'help_text' => NULL, - ), - 'always_post_to_accounts_receivable' => array( + ], + 'always_post_to_accounts_receivable' => [ 'group_name' => 'Contribute Preferences', 'group' => 'contribute', 'name' => 'always_post_to_accounts_receivable', @@ -152,8 +152,8 @@ 'is_contact' => 0, 'description' => NULL, 'help_text' => NULL, - ), - 'update_contribution_on_membership_type_change' => array( + ], + 'update_contribution_on_membership_type_change' => [ 'group_name' => 'Contribute Preferences', 'group' => 'contribute', 'name' => 'update_contribution_on_membership_type_change', @@ -167,5 +167,5 @@ 'is_contact' => 0, 'description' => 'Enabling this setting will update related contribution of membership(s) except if the membership is paid for with a recurring contribution.', 'help_text' => NULL, - ), -); + ], +]; diff --git a/settings/Core.setting.php b/settings/Core.setting.php index e90952c6a20f..27af8a8f5b4f 100644 --- a/settings/Core.setting.php +++ b/settings/Core.setting.php @@ -34,17 +34,17 @@ /** * Settings metadata file */ -return array( - 'contact_view_options' => array( +return [ + 'contact_view_options' => [ 'group_name' => 'CiviCRM Preferences', 'group' => 'core', 'name' => 'contact_view_options', 'type' => 'String', 'quick_form_type' => 'CheckBoxes', 'html_type' => 'checkboxes', - 'pseudoconstant' => array( + 'pseudoconstant' => [ 'optionGroupName' => 'contact_view_options', - ), + ], 'default' => '123456789101113', 'add' => '4.1', 'title' => ts('Viewing Contacts'), @@ -53,16 +53,16 @@ 'description' => ts("Select the tabs that should be displayed when viewing a contact record. EXAMPLE: If your organization does not keep track of 'Relationships', then un-check this option to simplify the screen display. Tabs for Contributions, Pledges, Memberships, Events, Grants and Cases are also hidden if the corresponding component is not enabled. Go to Administer > System Settings > Enable Components to modify the components which are available for your site."), 'help_text' => NULL, 'serialize' => CRM_Core_DAO::SERIALIZE_SEPARATOR_BOOKEND, - ), - 'contact_edit_options' => array( + ], + 'contact_edit_options' => [ 'group_name' => 'CiviCRM Preferences', 'group' => 'core', 'name' => 'contact_edit_options', 'type' => 'String', 'html_type' => 'checkboxes', - 'pseudoconstant' => array( + 'pseudoconstant' => [ 'optionGroupName' => 'contact_edit_options', - ), + ], 'default' => '123456789111214151617', 'add' => '4.1', 'title' => ts('Editing Contacts'), @@ -71,16 +71,16 @@ 'description' => ts('Select the sections that should be included when adding or editing a contact record. EXAMPLE: If your organization does not record Gender and Birth Date for individuals, then simplify the form by un-checking this option. Drag interface allows you to change the order of the panes displayed on contact add/edit screen.'), 'help_text' => NULL, 'serialize' => CRM_Core_DAO::SERIALIZE_SEPARATOR_BOOKEND, - ), - 'advanced_search_options' => array( + ], + 'advanced_search_options' => [ 'group_name' => 'CiviCRM Preferences', 'group' => 'core', 'name' => 'advanced_search_options', 'type' => 'String', 'html_type' => 'checkboxes', - 'pseudoconstant' => array( + 'pseudoconstant' => [ 'optionGroupName' => 'advanced_search_options', - ), + ], 'default' => '123456789101112131516171819', 'add' => '4.1', 'title' => ts('Contact Search'), @@ -88,16 +88,16 @@ 'is_contact' => 0, 'description' => ts('Select the sections that should be included in the Basic and Advanced Search forms. EXAMPLE: If you don\'t track Relationships - then you do not need this section included in the advanced search form. Simplify the form by un-checking this option.'), 'serialize' => CRM_Core_DAO::SERIALIZE_SEPARATOR_BOOKEND, - ), - 'user_dashboard_options' => array( + ], + 'user_dashboard_options' => [ 'group_name' => 'CiviCRM Preferences', 'group' => 'core', 'name' => 'user_dashboard_options', 'type' => 'String', 'html_type' => 'checkboxes', - 'pseudoconstant' => array( + 'pseudoconstant' => [ 'optionGroupName' => 'user_dashboard_options', - ), + ], 'default' => '1234578', 'add' => '4.1', 'title' => ts('Contact Dashboard'), @@ -106,16 +106,16 @@ 'description' => ts('Select the sections that should be included in the Contact Dashboard. EXAMPLE: If you don\'t want constituents to view their own contribution history, un-check that option.'), 'help_text' => NULL, 'serialize' => CRM_Core_DAO::SERIALIZE_SEPARATOR_BOOKEND, - ), - 'address_options' => array( + ], + 'address_options' => [ 'group_name' => 'CiviCRM Preferences', 'group' => 'core', 'name' => 'address_options', 'type' => 'String', 'html_type' => 'checkboxes', - 'pseudoconstant' => array( + 'pseudoconstant' => [ 'optionGroupName' => 'address_options', - ), + ], 'default' => '123456891011', 'add' => '4.1', 'title' => ts('Address Fields'), @@ -124,8 +124,8 @@ 'description' => NULL, 'help_text' => NULL, 'serialize' => CRM_Core_DAO::SERIALIZE_SEPARATOR_BOOKEND, - ), - 'address_format' => array( + ], + 'address_format' => [ 'group_name' => 'CiviCRM Preferences', 'group' => 'core', 'name' => 'address_format', @@ -138,8 +138,8 @@ 'is_contact' => 0, 'description' => NULL, 'help_text' => NULL, - ), - 'mailing_format' => array( + ], + 'mailing_format' => [ 'group_name' => 'CiviCRM Preferences', 'group' => 'core', 'name' => 'mailing_format', @@ -152,8 +152,8 @@ 'is_contact' => 0, 'description' => NULL, 'help_text' => NULL, - ), - 'display_name_format' => array( + ], + 'display_name_format' => [ 'group_name' => 'CiviCRM Preferences', 'group' => 'core', 'name' => 'display_name_format', @@ -165,8 +165,8 @@ 'is_domain' => 1, 'is_contact' => 0, 'description' => ts('Display name format for individual contact display names.'), - ), - 'sort_name_format' => array( + ], + 'sort_name_format' => [ 'group_name' => 'CiviCRM Preferences', 'group' => 'core', 'name' => 'sort_name_format', @@ -178,8 +178,8 @@ 'is_domain' => 1, 'is_contact' => 0, 'description' => ts('Sort name format for individual contact display names.'), - ), - 'remote_profile_submissions' => array( + ], + 'remote_profile_submissions' => [ 'group_name' => 'CiviCRM Preferences', 'group' => 'core', 'name' => 'remote_profile_submissions', @@ -193,8 +193,8 @@ 'is_contact' => 0, 'description' => ts('If enabled, CiviCRM will permit submissions from external sites to profiles. This is disabled by default to limit abuse.'), 'help_text' => NULL, - ), - 'allow_alert_autodismissal' => array( + ], + 'allow_alert_autodismissal' => [ 'group_name' => 'CiviCRM Preferences', 'group' => 'core', 'name' => 'allow_alert_autodismissal', @@ -208,8 +208,8 @@ 'is_contact' => 0, 'description' => ts('If disabled, CiviCRM will not automatically dismiss any alerts after 10 seconds.'), 'help_text' => NULL, - ), - 'editor_id' => array( + ], + 'editor_id' => [ 'group_name' => 'CiviCRM Preferences', 'group' => 'core', 'name' => 'editor_id', @@ -218,16 +218,16 @@ 'default' => 'CKEditor', 'add' => '4.1', 'title' => ts('Wysiwig Editor'), - 'pseudoconstant' => array( + 'pseudoconstant' => [ 'optionGroupName' => 'wysiwyg_editor', 'keyColumn' => 'name', - ), + ], 'is_domain' => 1, 'is_contact' => 0, 'description' => NULL, 'help_text' => NULL, - ), - 'contact_ajax_check_similar' => array( + ], + 'contact_ajax_check_similar' => [ 'group_name' => 'CiviCRM Preferences', 'group' => 'core', 'name' => 'contact_ajax_check_similar', @@ -241,8 +241,8 @@ 'description' => NULL, 'help_text' => NULL, 'options' => ['1' => ts('While Typing'), '0' => ts('When Saving'), '2' => ts('Never')], - ), - 'ajaxPopupsEnabled' => array( + ], + 'ajaxPopupsEnabled' => [ 'group_name' => 'CiviCRM Preferences', 'group' => 'core', 'name' => 'ajaxPopupsEnabled', @@ -255,8 +255,8 @@ 'is_contact' => 0, 'description' => NULL, 'help_text' => NULL, - ), - 'activity_assignee_notification' => array( + ], + 'activity_assignee_notification' => [ 'group_name' => 'CiviCRM Preferences', 'group' => 'core', 'name' => 'activity_assignee_notification', @@ -269,8 +269,8 @@ 'is_contact' => 0, 'description' => NULL, 'help_text' => NULL, - ), - 'activity_assignee_notification_ics' => array( + ], + 'activity_assignee_notification_ics' => [ 'group_name' => 'CiviCRM Preferences', 'group' => 'core', 'name' => 'activity_assignee_notification_ics', @@ -283,17 +283,17 @@ 'is_contact' => 0, 'description' => NULL, 'help_text' => NULL, - ), - 'contact_autocomplete_options' => array( + ], + 'contact_autocomplete_options' => [ 'group_name' => 'CiviCRM Preferences', 'group' => 'core', 'name' => 'contact_autocomplete_options', 'type' => 'String', 'quick_form_type' => 'CheckBoxes', 'html_type' => 'checkboxes', - 'pseudoconstant' => array( + 'pseudoconstant' => [ 'callback' => 'CRM_Admin_Form_Setting_Search::getContactAutocompleteOptions', - ), + ], 'default' => '12', 'add' => '4.1', 'title' => ts('Autocomplete Contact Search'), @@ -302,17 +302,17 @@ 'description' => ts("Selected fields will be displayed in back-office autocomplete dropdown search results (Quick Search, etc.). Contact Name is always included."), 'help_text' => NULL, 'serialize' => CRM_Core_DAO::SERIALIZE_SEPARATOR_BOOKEND, - ), - 'contact_reference_options' => array( + ], + 'contact_reference_options' => [ 'group_name' => 'CiviCRM Preferences', 'group' => 'core', 'name' => 'contact_reference_options', 'type' => 'String', 'quick_form_type' => 'CheckBoxes', 'html_type' => 'checkboxes', - 'pseudoconstant' => array( + 'pseudoconstant' => [ 'callback' => 'CRM_Admin_Form_Setting_Search::getContactReferenceOptions', - ), + ], 'default' => '12', 'add' => '4.1', 'title' => ts('Contact Reference Options'), @@ -321,8 +321,8 @@ 'description' => ts("Selected fields will be displayed in autocomplete dropdown search results for 'Contact Reference' custom fields. Contact Name is always included. NOTE: You must assign 'access contact reference fields' permission to the anonymous role if you want to use custom contact reference fields in profiles on public pages. For most situations, you should use the 'Limit List to Group' setting when configuring a contact reference field which will be used in public forms to prevent exposing your entire contact list."), 'help_text' => NULL, 'serialize' => CRM_Core_DAO::SERIALIZE_SEPARATOR_BOOKEND, - ), - 'contact_smart_group_display' => array( + ], + 'contact_smart_group_display' => [ 'group_name' => 'CiviCRM Preferences', 'group' => 'core', 'name' => 'contact_smart_group_display', @@ -335,11 +335,11 @@ 'is_contact' => 0, 'description' => ts('Controls display of the smart groups that a contact is part of in each contact\'s "Groups" tab. "Show on Demand" provides the best performance, and is recommended for most sites.'), 'help_text' => NULL, - 'pseudoconstant' => array( + 'pseudoconstant' => [ 'optionGroupName' => 'contact_smart_group_display', - ), - ), - 'smart_group_cache_refresh_mode' => array( + ], + ], + 'smart_group_cache_refresh_mode' => [ 'group_name' => 'CiviCRM Preferences', 'group' => 'core', 'name' => 'smart_group_cache_refresh_mode', @@ -350,13 +350,13 @@ 'title' => ts('Smart Group Refresh Mode'), 'is_domain' => 1, 'is_contact' => 0, - 'pseudoconstant' => array( + 'pseudoconstant' => [ 'callback' => 'CRM_Contact_BAO_GroupContactCache::getModes', - ), + ], 'description' => ts('Should the smart groups be by cron jobs or user actions'), 'help_text' => ts('In "Opportunistic Flush" mode, caches are flushed in response to user actions; this mode is broadly compatible but may add latency during form-submissions. In "Cron Flush" mode, you should schedule a cron job to flush caches; this can improve latency on form-submissions but requires more setup.'), - ), - 'installed' => array( + ], + 'installed' => [ 'bootstrap_comment' => 'This is a boot setting which may be loaded during bootstrap. Defaults are loaded via SettingsBag::getSystemDefaults().', 'group_name' => 'CiviCRM Preferences', 'group' => 'core', @@ -370,8 +370,8 @@ 'is_contact' => 0, 'description' => ts('A flag indicating whether this system has run a post-installation routine'), 'help_text' => NULL, - ), - 'max_attachments' => array( + ], + 'max_attachments' => [ 'group_name' => 'CiviCRM Preferences', 'group' => 'core', 'name' => 'max_attachments', @@ -379,10 +379,10 @@ 'type' => 'Integer', 'quick_form_type' => 'Element', 'html_type' => 'text', - 'html_attributes' => array( + 'html_attributes' => [ 'size' => 2, 'maxlength' => 8, - ), + ], 'default' => 3, 'add' => '4.3', 'title' => ts('Maximum Attachments'), @@ -390,18 +390,18 @@ 'is_contact' => 0, 'description' => ts('Maximum number of files (documents, images, etc.) which can be attached to emails or activities.'), 'help_text' => NULL, - ), - 'maxFileSize' => array( + ], + 'maxFileSize' => [ 'group_name' => 'CiviCRM Preferences', 'group' => 'core', 'name' => 'maxFileSize', 'type' => 'Integer', 'quick_form_type' => 'Element', 'html_type' => 'text', - 'html_attributes' => array( + 'html_attributes' => [ 'size' => 2, 'maxlength' => 8, - ), + ], 'default' => 3, 'add' => '4.3', 'title' => ts('Maximum File Size (in MB)'), @@ -409,8 +409,8 @@ 'is_contact' => 0, 'description' => ts('Maximum Size of file (documents, images, etc.) which can be attached to emails or activities.
      Note: php.ini should support this file size.'), 'help_text' => NULL, - ), - 'contact_undelete' => array( + ], + 'contact_undelete' => [ 'group_name' => 'CiviCRM Preferences', 'group' => 'core', 'name' => 'contact_undelete', @@ -423,8 +423,8 @@ 'is_contact' => 0, 'description' => ts('If enabled, deleted contacts will be moved to trash (instead of being destroyed). Users with the proper permission are able to search for the deleted contacts and restore them (or delete permanently).'), 'help_text' => NULL, - ), - 'allowPermDeleteFinancial' => array( + ], + 'allowPermDeleteFinancial' => [ 'group_name' => 'CiviCRM Preferences', 'group' => 'core', 'name' => 'allowPermDeleteFinancial', @@ -437,8 +437,8 @@ 'is_contact' => 0, 'description' => ts('Allow Permanent Delete for contacts who are linked to live financial transactions'), 'help_text' => NULL, - ), - 'securityAlert' => array( + ], + 'securityAlert' => [ 'group_name' => 'CiviCRM Preferences', 'group' => 'core', 'name' => 'securityAlert', @@ -451,8 +451,8 @@ 'is_contact' => 0, 'description' => ts("If enabled, CiviCRM will display pop-up notifications (no more than once per day) for security and misconfiguration issues identified in the system check."), 'help_text' => NULL, - ), - 'doNotAttachPDFReceipt' => array( + ], + 'doNotAttachPDFReceipt' => [ 'group_name' => 'CiviCRM Preferences', 'group' => 'core', 'name' => 'doNotAttachPDFReceipt', @@ -465,17 +465,17 @@ 'is_contact' => 0, 'description' => ts("If enabled, CiviCRM sends PDF receipt as an attachment during event signup or online contribution."), 'help_text' => NULL, - ), - 'recordGeneratedLetters' => array( + ], + 'recordGeneratedLetters' => [ 'group_name' => 'CiviCRM Preferences', 'group' => 'core', 'name' => 'recordGeneratedLetters', 'type' => 'String', 'quick_form_type' => 'Select', 'html_type' => 'Select', - 'html_attributes' => array( + 'html_attributes' => [ 'class' => 'crm-select2', - ), + ], 'default' => 'multiple', 'add' => '4.7', 'title' => ts('Record generated letters'), @@ -483,20 +483,20 @@ 'is_contact' => 0, 'description' => ts('When generating a letter (PDF/Word) via mail-merge, how should the letter be recorded?'), 'help_text' => NULL, - 'pseudoconstant' => array( + 'pseudoconstant' => [ 'callback' => 'CRM_Contact_Form_Task_PDFLetterCommon::getLoggingOptions', - ), - ), - 'wkhtmltopdfPath' => array( + ], + ], + 'wkhtmltopdfPath' => [ 'group_name' => 'CiviCRM Preferences', 'group' => 'core', 'name' => 'wkhtmltopdfPath', 'type' => 'String', 'quick_form_type' => 'Element', - 'html_attributes' => array( + 'html_attributes' => [ 'size' => 64, 'maxlength' => 256, - ), + ], 'html_type' => 'text', 'default' => NULL, 'add' => '4.3', @@ -505,17 +505,17 @@ 'is_contact' => 0, 'description' => NULL, 'help_text' => NULL, - ), - 'recaptchaOptions' => array( + ], + 'recaptchaOptions' => [ 'group_name' => 'CiviCRM Preferences', 'group' => 'core', 'name' => 'recaptchaOptions', 'type' => 'String', 'quick_form_type' => 'Element', - 'html_attributes' => array( + 'html_attributes' => [ 'size' => 64, 'maxlength' => 64, - ), + ], 'html_type' => 'text', 'default' => NULL, 'add' => '4.3', @@ -524,17 +524,17 @@ 'is_contact' => 0, 'description' => ts('You can specify the reCAPTCHA theme options as comma separated data.(eg: theme:\'blackglass\', lang : \'fr\' ). Check the available options at Customizing the Look and Feel of reCAPTCHA.'), 'help_text' => NULL, - ), - 'recaptchaPublicKey' => array( + ], + 'recaptchaPublicKey' => [ 'group_name' => 'CiviCRM Preferences', 'group' => 'core', 'name' => 'recaptchaPublicKey', 'type' => 'String', 'quick_form_type' => 'Element', - 'html_attributes' => array( + 'html_attributes' => [ 'size' => 64, 'maxlength' => 64, - ), + ], 'html_type' => 'text', 'default' => NULL, 'add' => '4.3', @@ -543,8 +543,8 @@ 'is_contact' => 0, 'description' => NULL, 'help_text' => NULL, - ), - 'forceRecaptcha' => array( + ], + 'forceRecaptcha' => [ 'add' => '4.7', 'help_text' => NULL, 'is_domain' => 1, @@ -558,17 +558,17 @@ 'default' => '0', 'title' => ts('Force reCAPTCHA on Contribution pages'), 'description' => ts('If enabled, reCAPTCHA will show on all contribution pages.'), - ), - 'recaptchaPrivateKey' => array( + ], + 'recaptchaPrivateKey' => [ 'group_name' => 'CiviCRM Preferences', 'group' => 'core', 'name' => 'recaptchaPrivateKey', 'type' => 'String', 'quick_form_type' => 'Element', - 'html_attributes' => array( + 'html_attributes' => [ 'size' => 64, 'maxlength' => 64, - ), + ], 'html_type' => 'text', 'default' => NULL, 'add' => '4.3', @@ -577,17 +577,17 @@ 'is_contact' => 0, 'description' => NULL, 'help_text' => NULL, - ), - 'checksum_timeout' => array( + ], + 'checksum_timeout' => [ 'group_name' => 'CiviCRM Preferences', 'group' => 'core', 'name' => 'checksum_timeout', 'type' => 'Integer', 'quick_form_type' => 'Element', - 'html_attributes' => array( + 'html_attributes' => [ 'size' => 2, 'maxlength' => 8, - ), + ], 'html_type' => 'text', 'default' => 7, 'add' => '4.3', @@ -596,17 +596,17 @@ 'is_contact' => 0, 'description' => NULL, 'help_text' => NULL, - ), - 'blogUrl' => array( + ], + 'blogUrl' => [ 'group_name' => 'CiviCRM Preferences', 'group' => 'core', 'name' => 'blogUrl', 'type' => 'String', 'quick_form_type' => 'Element', - 'html_attributes' => array( + 'html_attributes' => [ 'size' => 64, 'maxlength' => 128, - ), + ], 'html_type' => 'text', 'default' => '*default*', 'add' => '4.3', @@ -615,17 +615,17 @@ 'is_contact' => 0, 'description' => ts('Blog feed URL used by the blog dashlet'), 'help_text' => ts('Use "*default*" for the system default or override with a custom URL'), - ), - 'communityMessagesUrl' => array( + ], + 'communityMessagesUrl' => [ 'group_name' => 'CiviCRM Preferences', 'group' => 'core', 'name' => 'communityMessagesUrl', 'type' => 'String', 'quick_form_type' => 'Element', - 'html_attributes' => array( + 'html_attributes' => [ 'size' => 64, 'maxlength' => 128, - ), + ], 'html_type' => 'text', 'default' => '*default*', 'add' => '4.3', @@ -634,17 +634,17 @@ 'is_contact' => 0, 'description' => ts('Service providing CiviCRM community messages'), 'help_text' => ts('Use "*default*" for the system default or override with a custom URL'), - ), - 'gettingStartedUrl' => array( + ], + 'gettingStartedUrl' => [ 'group_name' => 'CiviCRM Preferences', 'group' => 'core', 'name' => 'gettingStartedUrl', 'type' => 'String', 'quick_form_type' => 'Element', - 'html_attributes' => array( + 'html_attributes' => [ 'size' => 64, 'maxlength' => 128, - ), + ], 'html_type' => 'text', 'default' => '*default*', 'add' => '4.3', @@ -653,8 +653,8 @@ 'is_contact' => 0, 'description' => ts('Service providing the Getting Started data'), 'help_text' => ts('Use "*default*" for the system default or override with a custom URL'), - ), - 'resCacheCode' => array( + ], + 'resCacheCode' => [ 'group_name' => 'CiviCRM Preferences', 'group' => 'core', 'name' => 'resCacheCode', @@ -668,8 +668,8 @@ 'is_contact' => 0, 'description' => ts('Code appended to resource URLs (JS/CSS) to coerce HTTP caching'), 'help_text' => NULL, - ), - 'verifySSL' => array( + ], + 'verifySSL' => [ 'group_name' => 'CiviCRM Preferences', 'group' => 'core', 'name' => 'verifySSL', @@ -682,8 +682,8 @@ 'is_contact' => 0, 'description' => ts('If disabled, outbound web-service requests will allow unverified, insecure HTTPS connections'), 'help_text' => ts('Unless you are absolutely unable to configure your server to check the SSL certificate of the remote server you should leave this set to Yes'), - ), - 'enableSSL' => array( + ], + 'enableSSL' => [ 'group_name' => 'CiviCRM Preferences', 'group' => 'core', 'name' => 'enableSSL', @@ -696,8 +696,8 @@ 'is_contact' => 0, 'description' => ts('If enabled, inbound HTTP requests for sensitive pages will be redirected to HTTPS.'), 'help_text' => ts('If enabled, inbound HTTP requests for sensitive pages will be redirected to HTTPS.'), - ), - 'wpBasePage' => array( + ], + 'wpBasePage' => [ 'group_name' => 'CiviCRM Preferences', 'group' => 'core', 'name' => 'wpBasePage', @@ -711,8 +711,8 @@ 'is_contact' => 0, 'description' => ts('If set, CiviCRM will use this setting as the base url.'), 'help_text' => ts('By default, CiviCRM will generate front-facing pages using the home page at http://wp/ as its base. If you want to use a different template for CiviCRM pages, set the path here.'), - ), - 'secondDegRelPermissions' => array( + ], + 'secondDegRelPermissions' => [ 'group_name' => 'CiviCRM Preferences', 'group' => 'core', 'name' => 'secondDegRelPermissions', @@ -725,8 +725,8 @@ 'is_contact' => 0, 'description' => ts("If enabled, contacts with the permission to edit a related contact will inherit that contact's permission to edit other related contacts"), 'help_text' => NULL, - ), - 'enable_components' => array( + ], + 'enable_components' => [ 'bootstrap_comment' => 'This is a boot setting which may be loaded during bootstrap. Defaults are loaded via SettingsBag::getSystemDefaults().', 'group_name' => 'CiviCRM Preferences', 'group' => 'core', @@ -734,11 +734,11 @@ 'type' => 'Array', 'quick_form_type' => 'Element', 'html_type' => 'advmultiselect', - 'html_attributes' => array( + 'html_attributes' => [ 'size' => 5, 'style' => 'width:150px', 'class' => 'advmultiselect', - ), + ], 'default' => NULL, 'add' => '4.4', 'title' => ts('Enable Components'), @@ -746,13 +746,13 @@ 'is_contact' => 0, 'description' => NULL, 'help_text' => NULL, - 'on_change' => array( + 'on_change' => [ 'CRM_Case_Info::onToggleComponents', 'CRM_Core_Component::flushEnabledComponents', 'call://resources/resetCacheCode', - ), - ), - 'disable_core_css' => array( + ], + ], + 'disable_core_css' => [ 'group_name' => 'CiviCRM Preferences', 'group' => 'core', 'name' => 'disable_core_css', @@ -765,8 +765,8 @@ 'is_contact' => 0, 'description' => ts('Prevent the stylesheet "civicrm.css" from being loaded.'), 'help_text' => NULL, - ), - 'empoweredBy' => array( + ], + 'empoweredBy' => [ 'group_name' => 'CiviCRM Preferences', 'group' => 'core', 'name' => 'empoweredBy', @@ -779,8 +779,8 @@ 'is_contact' => 0, 'description' => ts('When enabled, "empowered by CiviCRM" is displayed at the bottom of public forms.'), 'help_text' => NULL, - ), - 'logging_no_trigger_permission' => array( + ], + 'logging_no_trigger_permission' => [ 'add' => '4.7', 'is_domain' => 1, 'is_contact' => 0, @@ -794,8 +794,8 @@ 'default' => 0, 'title' => ts('(EXPERIMENTAL) MySQL user does not have trigger permissions'), 'description' => ts('Set this when you intend to manage trigger creation outside of CiviCRM'), - ), - 'logging' => array( + ], + 'logging' => [ 'add' => '4.7', 'help_text' => NULL, 'is_domain' => 1, @@ -810,11 +810,11 @@ 'title' => ts('Logging'), 'description' => ts('If enabled, all actions will be logged with a complete record of changes.'), 'validate_callback' => 'CRM_Logging_Schema::checkLoggingSupport', - 'on_change' => array( + 'on_change' => [ 'CRM_Logging_Schema::onToggle', - ), - ), - 'logging_uniqueid_date' => array( + ], + ], + 'logging_uniqueid_date' => [ 'add' => '4.7', 'help_text' => ts('This is the date when CRM-18193 was implemented'), 'is_domain' => 1, @@ -828,8 +828,8 @@ 'default' => NULL, 'title' => ts('Logging Unique ID not recorded before'), 'description' => ts('This is the date when CRM-18193 was implemented'), - ), - 'logging_all_tables_uniquid' => array( + ], + 'logging_all_tables_uniquid' => [ 'add' => '4.7', 'help_text' => ts('This indicates there are no tables holdng pre-uniqid log_conn_id values (CRM-18193)'), 'is_domain' => 1, @@ -843,8 +843,8 @@ 'default' => 0, 'title' => ts('All tables use Unique Connection ID'), 'description' => ts('Do some tables pre-date CRM-18193?'), - ), - 'userFrameworkUsersTableName' => array( + ], + 'userFrameworkUsersTableName' => [ 'add' => '4.7', 'help_text' => NULL, 'is_domain' => 1, @@ -855,15 +855,15 @@ 'type' => 'String', 'quick_form_type' => 'Element', 'html_type' => 'text', - 'html_attributes' => array( + 'html_attributes' => [ 'size' => '32', 'maxlength' => '64', - ), + ], 'default' => 'users', 'title' => ts('CMS Users Table Name'), 'description' => '', - ), - 'wpLoadPhp' => array( + ], + 'wpLoadPhp' => [ 'group_name' => 'CiviCRM Preferences', 'group' => 'core', 'name' => 'wpLoadPhp', @@ -877,18 +877,18 @@ 'is_contact' => 0, 'description' => ts('CiviCRM will use this setting as path to bootstrap WP.'), 'help_text' => NULL, - ), - 'secure_cache_timeout_minutes' => array( + ], + 'secure_cache_timeout_minutes' => [ 'group_name' => 'CiviCRM Preferences', 'group' => 'core', 'name' => 'secure_cache_timeout_minutes', 'type' => 'Integer', 'quick_form_type' => 'Element', 'html_type' => 'text', - 'html_attributes' => array( + 'html_attributes' => [ 'size' => 2, 'maxlength' => 8, - ), + ], 'default' => 20, 'add' => '4.7', 'title' => ts('Secure Cache Timeout'), @@ -896,8 +896,8 @@ 'is_contact' => 0, 'description' => ts('Maximum number of minutes that secure form data should linger'), 'help_text' => NULL, - ), - 'site_id' => array( + ], + 'site_id' => [ 'group_name' => 'CiviCRM Preferences', 'group' => 'core', 'name' => 'site_id', @@ -911,18 +911,18 @@ 'is_contact' => 0, 'description' => NULL, 'help_text' => NULL, - ), - 'recentItemsMaxCount' => array( + ], + 'recentItemsMaxCount' => [ 'group_name' => 'CiviCRM Preferences', 'group' => 'core', 'name' => 'recentItemsMaxCount', 'type' => 'Integer', 'quick_form_type' => 'Element', 'html_type' => 'text', - 'html_attributes' => array( + 'html_attributes' => [ 'size' => 2, 'maxlength' => 3, - ), + ], 'default' => 20, 'add' => '4.7', 'title' => ts('Size of "Recent Items" stack'), @@ -930,18 +930,18 @@ 'is_contact' => 0, 'description' => ts('How many items should CiviCRM store in it\'s "Recently viewed" list.'), 'help_text' => NULL, - ), - 'recentItemsProviders' => array( + ], + 'recentItemsProviders' => [ 'group_name' => 'CiviCRM Preferences', 'group' => 'core', 'name' => 'recentItemsProviders', 'type' => 'Array', 'html_type' => 'Select', 'quick_form_type' => 'Select', - 'html_attributes' => array( + 'html_attributes' => [ 'multiple' => 1, 'class' => 'crm-select2', - ), + ], 'default' => '', 'add' => '4.7', 'title' => ts('Recent Items Providers'), @@ -949,11 +949,11 @@ 'is_contact' => 0, 'description' => ts('What providers may save views in CiviCRM\'s "Recently viewed" list. If empty, all are in.'), 'help_text' => NULL, - 'pseudoconstant' => array( + 'pseudoconstant' => [ 'callback' => 'CRM_Utils_Recent::getProviders', - ), - ), - 'dedupe_default_limit' => array( + ], + ], + 'dedupe_default_limit' => [ 'group_name' => 'CiviCRM Preferences', 'group' => 'core', 'name' => 'dedupe_default_limit', @@ -967,8 +967,8 @@ 'is_contact' => 0, 'description' => ts('Default to only loading matches against this number of contacts'), 'help_text' => ts('Deduping larger databases can crash the server. By configuring a limit other than 0 here the dedupe query will only search for matches against a limited number of contacts.'), - ), - 'syncCMSEmail' => array( + ], + 'syncCMSEmail' => [ 'group_name' => 'CiviCRM Preferences', 'group' => 'core', 'name' => 'syncCMSEmail', @@ -982,8 +982,8 @@ 'is_contact' => 0, 'description' => ts('If enabled, then CMS email id will be synchronised with CiviCRM contacts\'s primary email.'), 'help_text' => NULL, - ), - 'preserve_activity_tab_filter' => array( + ], + 'preserve_activity_tab_filter' => [ 'group_name' => 'CiviCRM Preferences', 'group' => 'core', 'name' => 'preserve_activity_tab_filter', @@ -995,8 +995,8 @@ 'is_domain' => 1, 'is_contact' => 0, 'description' => ts('When enabled, any filter settings a user selects on the contact\'s Activity tab will be remembered as they visit other contacts.'), - ), - 'do_not_notify_assignees_for' => array( + ], + 'do_not_notify_assignees_for' => [ 'group_name' => 'CiviCRM Preferences', 'group' => 'core', 'name' => 'do_not_notify_assignees_for', @@ -1004,20 +1004,20 @@ 'add' => '4.7', 'is_domain' => 1, 'is_contact' => 0, - 'default' => array(), + 'default' => [], 'title' => ts('Do not notify assignees for'), 'description' => ts('These activity types will be excluded from automated email notifications to assignees.'), 'html_type' => 'select', - 'html_attributes' => array( + 'html_attributes' => [ 'multiple' => 1, 'class' => 'huge crm-select2', - ), - 'pseudoconstant' => array( + ], + 'pseudoconstant' => [ 'optionGroupName' => 'activity_type', - ), + ], 'quick_form_type' => 'Select', - ), - 'menubar_position' => array( + ], + 'menubar_position' => [ 'group_name' => 'CiviCRM Preferences', 'group' => 'core', 'name' => 'menubar_position', @@ -1030,14 +1030,14 @@ 'is_contact' => 0, 'description' => ts('Location of the CiviCRM main menu.'), 'help_text' => NULL, - 'options' => array( + 'options' => [ 'over-cms-menu' => ts('Replace website menu'), 'below-cms-menu' => ts('Below website menu'), 'above-crm-container' => ts('Above content area'), 'none' => ts('None - disable menu'), - ), - ), - 'menubar_color' => array( + ], + ], + 'menubar_color' => [ 'group_name' => 'CiviCRM Preferences', 'group' => 'core', 'name' => 'menubar_color', @@ -1051,5 +1051,5 @@ 'description' => ts('Color of the CiviCRM main menu.'), 'help_text' => NULL, 'validate_callback' => 'CRM_Utils_Rule::color', - ), -); + ], +]; diff --git a/settings/Developer.setting.php b/settings/Developer.setting.php index 56f2bda18e99..8f4f543eab5e 100644 --- a/settings/Developer.setting.php +++ b/settings/Developer.setting.php @@ -36,17 +36,17 @@ * Settings metadata file */ -return array( - 'assetCache' => array( +return [ + 'assetCache' => [ 'group_name' => 'Developer Preferences', 'group' => 'developer', 'name' => 'assetCache', 'type' => 'String', 'quick_form_type' => 'Select', 'html_type' => 'Select', - 'html_attributes' => array( + 'html_attributes' => [ //'class' => 'crm-select2', - ), + ], 'default' => 'auto', 'add' => '4.7', 'title' => 'Asset Caching', @@ -54,11 +54,11 @@ 'is_contact' => 0, 'description' => 'Store computed JS/CSS content in cache files? (Note: In "Auto" mode, the "Debug" setting will determine whether to activate the cache.)', 'help_text' => NULL, - 'pseudoconstant' => array( + 'pseudoconstant' => [ 'callback' => '\Civi\Core\AssetBuilder::getCacheModes', - ), - ), - 'userFrameworkLogging' => array( + ], + ], + 'userFrameworkLogging' => [ 'group_name' => 'Developer Preferences', 'group' => 'developer', 'name' => 'userFrameworkLogging', @@ -71,8 +71,8 @@ 'is_contact' => 0, 'description' => "Set this value to Yes if you want CiviCRM error/debugging messages to appear in the Drupal error logs", 'help_text' => "Set this value to Yes if you want CiviCRM error/debugging messages the appear in your CMS' error log. In the case of Drupal, this will cause all CiviCRM error messages to appear in the watchdog (assuming you have Drupal's watchdog enabled)", - ), - 'debug_enabled' => array( + ], + 'debug_enabled' => [ 'group_name' => 'Developer Preferences', 'group' => 'developer', 'name' => 'debug_enabled', @@ -86,8 +86,8 @@ 'is_contact' => 0, 'description' => "Set this value to Yes if you want to use one of CiviCRM's debugging tools. This feature should NOT be enabled for production sites", 'help_text' => 'Do not turn this on on production sites', - ), - 'backtrace' => array( + ], + 'backtrace' => [ 'group_name' => 'Developer Preferences', 'group' => 'developer', 'name' => 'backtrace', @@ -99,8 +99,8 @@ 'is_domain' => 1, 'is_contact' => 0, 'description' => "Set this value to Yes if you want to display a backtrace listing when a fatal error is encountered. This feature should NOT be enabled for production sites", - ), - 'environment' => array( + ], + 'environment' => [ 'group_name' => 'Developer Preferences', 'group' => 'developer', 'name' => 'environment', @@ -108,19 +108,19 @@ 'html_type' => 'Select', 'quick_form_type' => 'Select', 'default' => 'Production', - 'pseudoconstant' => array( + 'pseudoconstant' => [ 'optionGroupName' => 'environment', - ), + ], 'add' => '4.7', 'title' => 'Environment', 'is_domain' => 1, 'is_contact' => 0, 'description' => "Setting to define the environment in which this CiviCRM instance is running.", - 'on_change' => array( + 'on_change' => [ 'CRM_Core_BAO_Setting::onChangeEnvironmentSetting', - ), - ), - 'fatalErrorHandler' => array( + ], + ], + 'fatalErrorHandler' => [ 'group_name' => 'Developer Preferences', 'group' => 'developer', 'name' => 'fatalErrorHandler', @@ -133,5 +133,5 @@ 'is_domain' => 1, 'is_contact' => 0, 'description' => "Enter the path and class for a custom PHP error-handling function if you want to override built-in CiviCRM error handling for your site.", - ), -); + ], +]; diff --git a/settings/Directory.setting.php b/settings/Directory.setting.php index c80aadd5ac80..0396a11a9196 100644 --- a/settings/Directory.setting.php +++ b/settings/Directory.setting.php @@ -36,8 +36,8 @@ * Settings metadata file */ -return array( - 'uploadDir' => array( +return [ + 'uploadDir' => [ 'bootstrap_comment' => 'This is a boot setting which may be loaded during bootstrap. Defaults are loaded via SettingsBag::getSystemDefaults().', 'group_name' => 'Directory Preferences', 'group' => 'directory', @@ -52,8 +52,8 @@ 'is_contact' => 0, 'description' => NULL, 'help_text' => 'File system path where temporary CiviCRM files - such as import data files - are uploaded.', - ), - 'imageUploadDir' => array( + ], + 'imageUploadDir' => [ 'bootstrap_comment' => 'This is a boot setting which may be loaded during bootstrap. Defaults are loaded via SettingsBag::getSystemDefaults().', 'group_name' => 'Directory Preferences', 'group' => 'directory', @@ -68,8 +68,8 @@ 'is_contact' => 0, 'description' => 'File system path where image files are uploaded. Currently, this path is used for images associated with premiums (CiviContribute thank-you gifts).', 'help_text' => NULL, - ), - 'customFileUploadDir' => array( + ], + 'customFileUploadDir' => [ 'bootstrap_comment' => 'This is a boot setting which may be loaded during bootstrap. Defaults are loaded via SettingsBag::getSystemDefaults().', 'group_name' => 'Directory Preferences', 'group' => 'directory', @@ -84,8 +84,8 @@ 'is_contact' => 0, 'description' => 'Path where documents and images which are attachments to contact records are stored (e.g. contact photos, resumes, contracts, etc.). These attachments are defined using \'file\' type custom fields.', 'help_text' => NULL, - ), - 'customTemplateDir' => array( + ], + 'customTemplateDir' => [ 'bootstrap_comment' => 'This is a boot setting which may be loaded during bootstrap. Defaults are loaded via SettingsBag::getSystemDefaults().', 'group_name' => 'Directory Preferences', 'group' => 'directory', @@ -100,8 +100,8 @@ 'is_contact' => 0, 'description' => 'Path where site specific templates are stored if any. This directory is searched first if set. Custom JavaScript code can be added to templates by creating files named templateFile.extra.tpl. (learn more...)', 'help_text' => NULL, - ), - 'customPHPPathDir' => array( + ], + 'customPHPPathDir' => [ 'bootstrap_comment' => 'This is a boot setting which may be loaded during bootstrap. Defaults are loaded via SettingsBag::getSystemDefaults().', 'group_name' => 'Directory Preferences', 'group' => 'directory', @@ -116,8 +116,8 @@ 'is_contact' => 0, 'description' => 'Path where site specific PHP code files are stored if any. This directory is searched first if set.', 'help_text' => NULL, - ), - 'extensionsDir' => array( + ], + 'extensionsDir' => [ 'bootstrap_comment' => 'This is a boot setting which may be loaded during bootstrap. Defaults are loaded via SettingsBag::getSystemDefaults().', 'group_name' => 'Directory Preferences', 'group' => 'directory', @@ -132,6 +132,6 @@ 'is_contact' => 0, 'description' => 'Path where CiviCRM extensions are stored.', 'help_text' => NULL, - ), + ], -); +]; diff --git a/settings/Event.setting.php b/settings/Event.setting.php index c4cef76b023e..f3584cca0c39 100644 --- a/settings/Event.setting.php +++ b/settings/Event.setting.php @@ -34,8 +34,8 @@ /** * Settings metadata file */ -return array( - 'enable_cart' => array( +return [ + 'enable_cart' => [ 'name' => 'enable_cart', 'group_name' => 'Event Preferences', 'settings_pages' => ['event' => ['weight' => 10]], @@ -50,8 +50,8 @@ 'description' => ts('This feature allows users to register for more than one event at a time. When enabled, users will add event(s) to a "cart" and then pay for them all at once. Enabling this setting will affect online registration for all active events. The code is an alpha state, and you will potentially need to have developer resources to debug and fix sections of the codebase while testing and deploying it'), 'help_text' => '', 'documentation_link' => ['page' => 'CiviEvent Cart Checkout', 'resource' => 'wiki'], - ), - 'show_events' => array( + ], + 'show_events' => [ 'name' => 'show_events', 'group_name' => 'Event Preferences', 'group' => 'event', @@ -67,5 +67,5 @@ 'description' => ts('Configure how many events should be shown on the dashboard. This overrides the default value of 10 entries.'), 'help_text' => NULL, 'pseudoconstant' => ['callback' => 'CRM_Core_SelectValues::getDashboardEntriesCount'], - ), -); + ], +]; diff --git a/settings/Extension.setting.php b/settings/Extension.setting.php index 5a93c89a8f05..7868058472c6 100644 --- a/settings/Extension.setting.php +++ b/settings/Extension.setting.php @@ -35,17 +35,17 @@ /* * Settings metadata file */ -return array( - 'ext_repo_url' => array( +return [ + 'ext_repo_url' => [ 'group_name' => 'Extension Preferences', 'group' => 'ext', 'name' => 'ext_repo_url', 'type' => 'String', 'quick_form_type' => 'Element', - 'html_attributes' => array( + 'html_attributes' => [ 'size' => 64, 'maxlength' => 128, - ), + ], 'html_type' => 'text', 'default' => 'https://civicrm.org/extdir/ver={ver}|cms={uf}', 'add' => '4.3', @@ -54,5 +54,5 @@ 'is_contact' => 0, 'description' => '', 'help_text' => '', - ), -); + ], +]; diff --git a/settings/Localization.setting.php b/settings/Localization.setting.php index 3d15ee0f2278..151eb66abe56 100644 --- a/settings/Localization.setting.php +++ b/settings/Localization.setting.php @@ -36,8 +36,8 @@ * Settings metadata file */ -return array( - 'customTranslateFunction' => array( +return [ + 'customTranslateFunction' => [ 'add' => '4.7', 'help_text' => NULL, 'is_domain' => 1, @@ -48,24 +48,24 @@ 'type' => 'String', 'quick_form_type' => 'Element', 'html_type' => 'text', - 'html_attributes' => array( + 'html_attributes' => [ 'size' => '30', 'maxlength' => '100', - ), + ], 'default' => NULL, 'title' => 'Custom Translate Function', 'description' => '', - ), - 'monetaryThousandSeparator' => array( + ], + 'monetaryThousandSeparator' => [ 'group_name' => 'Localization Preferences', 'group' => 'localization', 'name' => 'monetaryThousandSeparator', 'type' => 'String', 'quick_form_type' => 'Element', 'html_type' => 'text', - 'html_attributes' => array( + 'html_attributes' => [ 'size' => 2, - ), + ], 'default' => ',', 'add' => '4.3', 'title' => 'Thousands Separator', @@ -73,17 +73,17 @@ 'is_contact' => 0, 'description' => NULL, 'help_text' => NULL, - ), - 'monetaryDecimalPoint' => array( + ], + 'monetaryDecimalPoint' => [ 'group_name' => 'Localization Preferences', 'group' => 'localization', 'name' => 'monetaryDecimalPoint', 'type' => 'String', 'quick_form_type' => 'Element', 'html_type' => 'text', - 'html_attributes' => array( + 'html_attributes' => [ 'size' => 2, - ), + ], 'default' => '.', 'add' => '4.3', 'title' => 'Decimal Delimiter', @@ -91,8 +91,8 @@ 'is_contact' => 0, 'description' => NULL, 'help_text' => NULL, - ), - 'moneyformat' => array( + ], + 'moneyformat' => [ 'group_name' => 'Localization Preferences', 'group' => 'localization', 'name' => 'moneyformat', @@ -106,8 +106,8 @@ 'is_contact' => 0, 'description' => NULL, 'help_text' => NULL, - ), - 'moneyvalueformat' => array( + ], + 'moneyvalueformat' => [ 'group_name' => 'Localization Preferences', 'group' => 'localization', 'name' => 'moneyvalueformat', @@ -121,17 +121,17 @@ 'is_contact' => 0, 'description' => NULL, 'help_text' => NULL, - ), - 'defaultCurrency' => array( + ], + 'defaultCurrency' => [ 'group_name' => 'Localization Preferences', 'group' => 'localization', 'name' => 'defaultCurrency', 'type' => 'String', 'quick_form_type' => 'Select', 'html_type' => 'Select', - 'html_attributes' => array( + 'html_attributes' => [ 'class' => 'crm-select2', - ), + ], 'default' => 'USD', 'add' => '4.3', 'title' => 'Default Currency', @@ -139,23 +139,23 @@ 'is_contact' => 0, 'description' => 'Default currency assigned to contributions and other monetary transactions.', 'help_text' => NULL, - 'pseudoconstant' => array( + 'pseudoconstant' => [ 'callback' => 'CRM_Admin_Form_Setting_Localization::getCurrencySymbols', - ), - 'on_change' => array( + ], + 'on_change' => [ 'CRM_Admin_Form_Setting_Localization::onChangeDefaultCurrency', - ), - ), - 'defaultContactCountry' => array( + ], + ], + 'defaultContactCountry' => [ 'group_name' => 'Localization Preferences', 'group' => 'localization', 'name' => 'defaultContactCountry', 'type' => 'String', 'quick_form_type' => 'Select', 'html_type' => 'Select', - 'html_attributes' => array( + 'html_attributes' => [ //'class' => 'crm-select2', - ), + ], 'add' => '4.4', 'title' => 'Default Country', 'is_domain' => 1, @@ -163,11 +163,11 @@ 'is_required' => FALSE, 'description' => 'This value is selected by default when adding a new contact address.', 'help_text' => NULL, - 'pseudoconstant' => array( + 'pseudoconstant' => [ 'callback' => 'CRM_Admin_Form_Setting_Localization::getAvailableCountries', - ), - ), - 'defaultContactStateProvince' => array( + ], + ], + 'defaultContactStateProvince' => [ 'add' => '4.7', 'help_text' => NULL, 'is_domain' => 1, @@ -185,54 +185,54 @@ 'default' => NULL, 'title' => 'Default State/Province', 'description' => 'This value is selected by default when adding a new contact address.', - ), - 'countryLimit' => array( + ], + 'countryLimit' => [ 'group_name' => 'Localization Preferences', 'group' => 'localization', 'name' => 'countryLimit', 'type' => 'Array', 'quick_form_type' => 'Element', 'html_type' => 'advmultiselect', - 'html_attributes' => array( + 'html_attributes' => [ 'size' => 5, 'style' => 'width:150px', 'class' => 'advmultiselect', - ), - 'default' => array(), + ], + 'default' => [], 'add' => '4.3', 'title' => 'Available Countries', 'is_domain' => 1, 'is_contact' => 0, 'description' => '', 'help_text' => NULL, - 'pseudoconstant' => array( + 'pseudoconstant' => [ 'callback' => 'CRM_Admin_Form_Setting_Localization::getAvailableCountries', - ), - ), - 'provinceLimit' => array( + ], + ], + 'provinceLimit' => [ 'group_name' => 'Localization Preferences', 'group' => 'localization', 'name' => 'provinceLimit', 'type' => 'Array', 'quick_form_type' => 'Element', 'html_type' => 'advmultiselect', - 'html_attributes' => array( + 'html_attributes' => [ 'size' => 5, 'style' => 'width:150px', 'class' => 'advmultiselect', - ), - 'default' => array(), + ], + 'default' => [], 'add' => '4.3', 'title' => 'Available States and Provinces (by Country)', 'is_domain' => 1, 'is_contact' => 0, 'description' => '', 'help_text' => NULL, - 'pseudoconstant' => array( + 'pseudoconstant' => [ 'callback' => 'CRM_Admin_Form_Setting_Localization::getAvailableCountries', - ), - ), - 'inheritLocale' => array( + ], + ], + 'inheritLocale' => [ 'group_name' => 'Localization Preferences', 'group' => 'localization', 'name' => 'inheritLocale', @@ -245,8 +245,8 @@ 'is_contact' => 0, 'description' => '', 'help_text' => NULL, - ), - 'dateformatDatetime' => array( + ], + 'dateformatDatetime' => [ 'group_name' => 'Localization Preferences', 'group' => 'localization', 'name' => 'dateformatDatetime', @@ -260,8 +260,8 @@ 'is_contact' => 0, 'description' => '', 'help_text' => NULL, - ), - 'dateformatFull' => array( + ], + 'dateformatFull' => [ 'group_name' => 'Localization Preferences', 'group' => 'localization', 'name' => 'dateformatFull', @@ -275,8 +275,8 @@ 'is_contact' => 0, 'description' => '', 'help_text' => NULL, - ), - 'dateformatPartial' => array( + ], + 'dateformatPartial' => [ 'group_name' => 'Localization Preferences', 'group' => 'localization', 'name' => 'dateformatPartial', @@ -290,8 +290,8 @@ 'is_contact' => 0, 'description' => '', 'help_text' => NULL, - ), - 'dateformatTime' => array( + ], + 'dateformatTime' => [ 'add' => '4.7', 'help_text' => NULL, 'is_domain' => 1, @@ -302,15 +302,15 @@ 'type' => 'String', 'quick_form_type' => 'Element', 'html_type' => 'text', - 'html_attributes' => array( + 'html_attributes' => [ 'size' => '12', 'maxlength' => '60', - ), + ], 'default' => '%l:%M %P', 'title' => 'Date Format: Time Only', 'description' => '', - ), - 'dateformatYear' => array( + ], + 'dateformatYear' => [ 'add' => '4.7', 'help_text' => NULL, 'is_domain' => 1, @@ -321,15 +321,15 @@ 'type' => 'String', 'quick_form_type' => 'Element', 'html_type' => 'text', - 'html_attributes' => array( + 'html_attributes' => [ 'size' => '12', 'maxlength' => '60', - ), + ], 'default' => '%Y', 'title' => 'Date Format: Year Only', 'description' => '', - ), - 'dateformatFinancialBatch' => array( + ], + 'dateformatFinancialBatch' => [ 'add' => '4.7', 'help_text' => NULL, 'is_domain' => 1, @@ -340,15 +340,15 @@ 'type' => 'String', 'quick_form_type' => 'Element', 'html_type' => 'text', - 'html_attributes' => array( + 'html_attributes' => [ 'size' => '12', 'maxlength' => '60', - ), + ], 'default' => '%m/%d/%Y', 'title' => 'Date Format: Financial Batch', 'description' => '', - ), - 'dateformatshortdate' => array( + ], + 'dateformatshortdate' => [ 'add' => '4.7', 'help_text' => NULL, 'is_domain' => 1, @@ -359,15 +359,15 @@ 'type' => 'String', 'quick_form_type' => 'Element', 'html_type' => 'text', - 'html_attributes' => array( + 'html_attributes' => [ 'size' => '12', 'maxlength' => '60', - ), + ], 'default' => '%m/%d/%Y', 'title' => 'Date Format: Short date Month Day Year', 'description' => '', - ), - 'dateInputFormat' => array( + ], + 'dateInputFormat' => [ 'add' => '4.7', 'help_text' => NULL, 'is_domain' => 1, @@ -378,14 +378,14 @@ 'type' => 'String', 'quick_form_type' => 'Select', 'html_type' => 'Select', - 'pseudoconstant' => array( + 'pseudoconstant' => [ 'callback' => 'CRM_Core_SelectValues::getDatePluginInputFormats', - ), + ], 'default' => 'mm/dd/yy', 'title' => 'Date Input Format', 'description' => '', - ), - 'fieldSeparator' => array( + ], + 'fieldSeparator' => [ 'add' => '4.7', 'help_text' => NULL, 'is_domain' => 1, @@ -396,15 +396,15 @@ 'type' => 'String', 'quick_form_type' => 'Element', 'html_type' => 'text', - 'html_attributes' => array( + 'html_attributes' => [ 'size' => '2', 'maxlength' => '8', - ), + ], 'default' => ',', 'title' => 'Import / Export Field Separator', 'description' => 'Global CSV separator character. Modify this setting to enable import and export of different kinds of CSV files (for example: \',\' \';\' \':\' \'|\' ).', - ), - 'fiscalYearStart' => array( + ], + 'fiscalYearStart' => [ 'add' => '4.7', 'help_text' => NULL, 'is_domain' => 1, @@ -415,21 +415,21 @@ 'type' => 'Array', 'quick_form_type' => 'MonthDay', 'html_type' => 'MonthDay', - 'default' => array('M' => 1, 'd' => 1), + 'default' => ['M' => 1, 'd' => 1], 'title' => 'Fiscal Year Start', 'description' => '', - ), - 'languageLimit' => array( + ], + 'languageLimit' => [ 'group_name' => 'Localization Preferences', 'group' => 'localization', 'name' => 'languageLimit', 'type' => 'Array', 'quick_form_type' => 'Select', 'html_type' => 'Select', - 'html_attributes' => array( + 'html_attributes' => [ 'multiple' => 1, 'class' => 'crm-select2', - ), + ], 'default' => NULL, 'add' => '4.3', 'title' => 'Available Languages (Multi-lingual)', @@ -437,21 +437,21 @@ 'is_contact' => 0, 'description' => '', 'help_text' => NULL, - 'pseudoconstant' => array( + 'pseudoconstant' => [ 'callback' => 'CRM_Core_I18n::languages', - ), - ), - 'uiLanguages' => array( + ], + ], + 'uiLanguages' => [ 'group_name' => 'Localization Preferences', 'group' => 'localization', 'name' => 'uiLanguages', 'type' => 'Array', 'quick_form_type' => 'Select', 'html_type' => 'select', - 'html_attributes' => array( + 'html_attributes' => [ 'multiple' => 1, 'class' => 'crm-select2', - ), + ], 'default' => NULL, 'add' => '5.9', 'title' => 'Available Languages', @@ -459,20 +459,20 @@ 'is_contact' => 0, 'description' => '', 'help_text' => ts('User Interface languages available to users'), - 'pseudoconstant' => array( + 'pseudoconstant' => [ 'callback' => 'CRM_Core_I18n::languages', - ), - ), - 'lcMessages' => array( + ], + ], + 'lcMessages' => [ 'group_name' => 'Localization Preferences', 'group' => 'localization', 'name' => 'lcMessages', 'type' => 'String', 'quick_form_type' => 'Select', 'html_type' => 'Select', - 'html_attributes' => array( + 'html_attributes' => [ 'class' => 'crm-select2', - ), + ], 'default' => 'en_US', 'add' => '4.3', 'title' => 'Default Language', @@ -480,14 +480,14 @@ 'is_contact' => 0, 'description' => '', 'help_text' => NULL, - 'pseudoconstant' => array( + 'pseudoconstant' => [ 'callback' => 'CRM_Admin_Form_Setting_Localization::getDefaultLocaleOptions', - ), - 'on_change' => array( + ], + 'on_change' => [ 'CRM_Admin_Form_Setting_Localization::onChangeLcMessages', - ), - ), - 'legacyEncoding' => array( + ], + ], + 'legacyEncoding' => [ 'add' => '4.7', 'help_text' => NULL, 'is_domain' => 1, @@ -498,15 +498,15 @@ 'type' => 'String', 'quick_form_type' => 'Element', 'html_type' => 'text', - 'html_attributes' => array( + 'html_attributes' => [ 'size' => '12', 'maxlength' => '30', - ), + ], 'default' => 'Windows-1252', 'title' => 'Legacy Encoding', 'description' => 'If import files are NOT encoded as UTF-8, specify an alternate character encoding for these files. The default of Windows-1252 will work for Excel-created .CSV files on many computers.', - ), - 'timeInputFormat' => array( + ], + 'timeInputFormat' => [ 'add' => '4.7', 'help_text' => NULL, 'is_domain' => 1, @@ -517,26 +517,26 @@ 'type' => 'String', 'quick_form_type' => 'Select', 'html_type' => 'Select', - 'pseudoconstant' => array( + 'pseudoconstant' => [ 'callback' => 'CRM_Core_SelectValues::getTimeFormats', - ), + ], 'default' => '1', 'title' => 'Time Input Format', 'description' => '', - 'on_change' => array( + 'on_change' => [ 'CRM_Core_BAO_PreferencesDate::onChangeSetting', - ), - ), - 'weekBegins' => array( + ], + ], + 'weekBegins' => [ 'group_name' => 'Localization Preferences', 'group' => 'localization', 'name' => 'weekBegins', 'type' => 'String', 'quick_form_type' => 'Select', 'html_type' => 'Select', - 'pseudoconstant' => array( + 'pseudoconstant' => [ 'callback' => 'CRM_Utils_Date::getFullWeekdayNames', - ), + ], 'default' => '0', 'add' => '4.7', 'title' => 'Week begins on', @@ -544,20 +544,20 @@ 'is_contact' => 0, 'description' => "", 'help_text' => NULL, - ), - 'contact_default_language' => array( + ], + 'contact_default_language' => [ 'group_name' => 'Localization Preferences', 'group' => 'localization', 'name' => 'contact_default_language', 'type' => 'String', 'quick_form_type' => 'Select', 'html_type' => 'Select', - 'html_attributes' => array( + 'html_attributes' => [ 'class' => 'crm-select2', - ), - 'pseudoconstant' => array( + ], + 'pseudoconstant' => [ 'callback' => 'CRM_Admin_Form_Setting_Localization::getDefaultLanguageOptions', - ), + ], 'default' => '*default*', 'add' => '4.7', 'title' => 'Default Language for contacts', @@ -566,5 +566,5 @@ 'description' => 'Default language (if any) for contact records', 'help_text' => 'If a contact is created with no language this setting will determine the language data (if any) to save.' . 'You may or may not wish to make an assumption here about whether it matches the site language', - ), -); + ], +]; diff --git a/settings/Mailing.setting.php b/settings/Mailing.setting.php index 949ac6fa9c62..7ea68f55153a 100644 --- a/settings/Mailing.setting.php +++ b/settings/Mailing.setting.php @@ -36,8 +36,8 @@ * Settings metadata file */ -return array( - 'profile_double_optin' => array( +return [ + 'profile_double_optin' => [ 'group_name' => 'Mailing Preferences', 'group' => 'mailing', 'name' => 'profile_double_optin', @@ -50,8 +50,8 @@ 'is_contact' => 0, 'description' => ts('When CiviMail is enabled, users who "subscribe" to a group from a profile Group(s) checkbox will receive a confirmation email. They must respond (opt-in) before they are added to the group.'), 'help_text' => NULL, - ), - 'track_civimail_replies' => array( + ], + 'track_civimail_replies' => [ 'group_name' => 'Mailing Preferences', 'group' => 'mailing', 'name' => 'track_civimail_replies', @@ -65,8 +65,8 @@ 'description' => ts('If checked, mailings will default to tracking replies using VERP-ed Reply-To. '), 'help_text' => NULL, 'validate_callback' => 'CRM_Core_BAO_Setting::validateBoolSetting', - ), - 'civimail_workflow' => array( + ], + 'civimail_workflow' => [ 'group_name' => 'Mailing Preferences', 'group' => 'mailing', 'name' => 'civimail_workflow', @@ -79,8 +79,8 @@ 'is_contact' => 0, 'description' => ts('Drupal-only. Rules module must be enabled (beta feature - use with caution).'), 'help_text' => NULL, - ), - 'civimail_server_wide_lock' => array( + ], + 'civimail_server_wide_lock' => [ 'group_name' => 'Mailing Preferences', 'group' => 'mailing', 'name' => 'civimail_server_wide_lock', @@ -93,8 +93,8 @@ 'is_contact' => 0, 'description' => NULL, 'help_text' => NULL, - ), - 'replyTo' => array( + ], + 'replyTo' => [ 'group_name' => 'Mailing Preferences', 'group' => 'mailing', 'name' => 'replyTo', @@ -107,22 +107,22 @@ 'is_contact' => 0, 'description' => 'Allow CiviMail users to send mailings with a custom Reply-To header', 'help_text' => NULL, - ), - 'mailing_backend' => array( + ], + 'mailing_backend' => [ 'group_name' => 'Mailing Preferences', 'group' => 'mailing', 'name' => 'mailing_backend', 'type' => 'Array', 'html_type' => 'checkbox', - 'default' => array('outBound_option' => '3'), + 'default' => ['outBound_option' => '3'], 'add' => '4.1', 'title' => 'Mailing Backend', 'is_domain' => 1, 'is_contact' => 0, 'description' => NULL, 'help_text' => NULL, - ), - 'profile_add_to_group_double_optin' => array( + ], + 'profile_add_to_group_double_optin' => [ 'group_name' => 'Mailing Preferences', 'group' => 'mailing', 'name' => 'profile_add_to_group_double_optin', @@ -135,8 +135,8 @@ 'is_contact' => 0, 'description' => ts('When CiviMail is enabled, users who "subscribe" to a group from a profile Group(s) checkbox will receive a confirmation email. They must respond (opt-in) before they are added to the group.'), 'help_text' => NULL, - ), - 'disable_mandatory_tokens_check' => array( + ], + 'disable_mandatory_tokens_check' => [ 'group_name' => 'Mailing Preferences', 'group' => 'mailing', 'name' => 'disable_mandatory_tokens_check', @@ -149,8 +149,8 @@ 'is_contact' => 0, 'description' => ts('Don\'t check for presence of mandatory tokens (domain address; unsubscribe/opt-out) before sending mailings. WARNING: Mandatory tokens are a safe-guard which facilitate compliance with the US CAN-SPAM Act. They should only be disabled if your organization adopts other mechanisms for compliance or if your organization is not subject to CAN-SPAM.'), 'help_text' => NULL, - ), - 'dedupe_email_default' => array( + ], + 'dedupe_email_default' => [ 'group_name' => 'Mailing Preferences', 'group' => 'mailing', 'name' => 'dedupe_email_default', @@ -163,8 +163,8 @@ 'is_contact' => 0, 'description' => ts('Set the "dedupe e-mail" option when sending a new mailing to "true" by default.'), 'help_text' => NULL, - ), - 'hash_mailing_url' => array( + ], + 'hash_mailing_url' => [ 'group_name' => 'Mailing Preferences', 'group' => 'mailing', 'name' => 'hash_mailing_url', @@ -177,8 +177,8 @@ 'is_contact' => 0, 'description' => ts('If enabled, a randomized hash key will be used to reference the mailing URL in the mailing.viewUrl token, instead of the mailing ID'), 'help_text' => NULL, - ), - 'civimail_multiple_bulk_emails' => array( + ], + 'civimail_multiple_bulk_emails' => [ 'group_name' => 'Mailing Preferences', 'group' => 'mailing', 'name' => 'civimail_multiple_bulk_emails', @@ -191,8 +191,8 @@ 'is_contact' => 0, 'description' => ts('CiviMail will deliver a copy of the email to each bulk email listed for the contact. Enabling this setting will also change the options for the "Email on Hold" field in Advanced Search.'), 'help_text' => NULL, - ), - 'include_message_id' => array( + ], + 'include_message_id' => [ 'group_name' => 'Mailing Preferences', 'group' => 'mailing', 'name' => 'include_message_id', @@ -205,18 +205,18 @@ 'is_contact' => 0, 'description' => '', 'help_text' => NULL, - ), - 'mailerBatchLimit' => array( + ], + 'mailerBatchLimit' => [ 'group_name' => 'Mailing Preferences', 'group' => 'mailing', 'name' => 'mailerBatchLimit', 'type' => 'Integer', 'quick_form_type' => 'Element', 'html_type' => 'text', - 'html_attributes' => array( + 'html_attributes' => [ 'size' => 4, 'maxlength' => 8, - ), + ], 'default' => 0, 'add' => '4.7', 'title' => 'Mailer Batch Limit', @@ -224,18 +224,18 @@ 'is_contact' => 0, 'description' => 'Throttle email delivery by setting the maximum number of emails sent during each CiviMail run (0 = unlimited).', 'help_text' => NULL, - ), - 'mailerJobSize' => array( + ], + 'mailerJobSize' => [ 'group_name' => 'Mailing Preferences', 'group' => 'mailing', 'name' => 'mailerJobSize', 'type' => 'Integer', 'quick_form_type' => 'Element', 'html_type' => 'text', - 'html_attributes' => array( + 'html_attributes' => [ 'size' => 4, 'maxlength' => 8, - ), + ], 'default' => 0, 'add' => '4.7', 'title' => 'Mailer Job Size', @@ -243,18 +243,18 @@ 'is_contact' => 0, 'description' => 'If you want to utilize multi-threading enter the size you want your sub jobs to be split into. Recommended values are between 1,000 and 10,000. Use a lower value if your server has multiple cron jobs running simultaneously, but do not use values smaller than 1,000. Enter "0" to disable multi-threading and process mail as one single job - batch limits still apply.', 'help_text' => NULL, - ), - 'mailerJobsMax' => array( + ], + 'mailerJobsMax' => [ 'group_name' => 'Mailing Preferences', 'group' => 'mailing', 'name' => 'mailerJobsMax', 'type' => 'Integer', 'quick_form_type' => 'Element', 'html_type' => 'text', - 'html_attributes' => array( + 'html_attributes' => [ 'size' => 4, 'maxlength' => 8, - ), + ], 'default' => 0, 'add' => '4.7', 'title' => 'Mailer Cron Job Limit', @@ -262,18 +262,18 @@ 'is_contact' => 0, 'description' => 'The maximum number of mailer delivery jobs executing simultaneously (0 = allow as many processes to execute as started by cron)', 'help_text' => NULL, - ), - 'mailThrottleTime' => array( + ], + 'mailThrottleTime' => [ 'group_name' => 'Mailing Preferences', 'group' => 'mailing', 'name' => 'mailThrottleTime', 'type' => 'Integer', 'quick_form_type' => 'Element', 'html_type' => 'text', - 'html_attributes' => array( + 'html_attributes' => [ 'size' => 4, 'maxlength' => 8, - ), + ], 'default' => 0, 'add' => '4.7', 'title' => 'Mailer Throttle Time', @@ -281,18 +281,18 @@ 'is_contact' => 0, 'description' => 'The time to sleep in between each e-mail in micro seconds. Setting this above 0 allows you to control the rate at which e-mail messages are sent to the mail server, avoiding filling up the mail queue very quickly. Set to 0 to disable.', 'help_text' => NULL, - ), - 'verpSeparator' => array( + ], + 'verpSeparator' => [ 'group_name' => 'Mailing Preferences', 'group' => 'mailing', 'name' => 'verpSeparator', 'type' => 'String', 'quick_form_type' => 'Element', 'html_type' => 'text', - 'html_attributes' => array( + 'html_attributes' => [ 'size' => 4, 'maxlength' => 32, - ), + ], 'default' => '.', 'add' => '4.7', 'title' => 'VERP Separator', @@ -300,8 +300,8 @@ 'is_contact' => 0, 'description' => 'Separator character used when CiviMail generates VERP (variable envelope return path) Mail-From addresses.', 'help_text' => NULL, - ), - 'write_activity_record' => array( + ], + 'write_activity_record' => [ 'group_name' => 'Mailing Preferences', 'group' => 'mailing', 'name' => 'write_activity_record', @@ -315,26 +315,26 @@ 'is_contact' => 0, 'description' => NULL, 'help_text' => NULL, - ), - 'simple_mail_limit' => array( + ], + 'simple_mail_limit' => [ 'group_name' => 'Mailing Preferences', 'group' => 'mailing', 'name' => 'simple_mail_limit', 'type' => 'Integer', 'quick_form_type' => 'Element', 'html_type' => 'text', - 'html_attributes' => array( + 'html_attributes' => [ 'size' => 4, 'maxlength' => 8, - ), + ], 'default' => 50, 'title' => 'Simple mail limit', 'is_domain' => 1, 'is_contact' => 0, 'description' => 'The number of emails sendable via simple mail. Make sure you understand the implications for your spam reputation and legal requirements for bulk emails before editing. As there is some risk both to your spam reputation and the products if this is misused it is a hidden setting', 'help_text' => 'CiviCRM forces users sending more than this number of mails to use CiviMails. CiviMails have additional precautions: not sending to contacts who do not want bulk mail, adding domain name and opt out links. You should familiarise yourself with the law relevant to you on bulk mailings if changing this setting. For the US https://en.wikipedia.org/wiki/CAN-SPAM_Act_of_2003 is a good place to start.', - ), - 'auto_recipient_rebuild' => array( + ], + 'auto_recipient_rebuild' => [ 'group_name' => 'Mailing Preferences', 'group' => 'mailing', 'name' => 'auto_recipient_rebuild', @@ -347,8 +347,8 @@ 'is_contact' => 0, 'description' => ts('Enable this setting to rebuild recipient list automatically during composing mail. Disable will allow you to rebuild recipient manually.'), 'help_text' => ts('CiviMail automatically fetches recipient list and count whenever mailing groups are included or excluded while composing bulk mail. This phenomena may degrade performance for large sites, so disable this setting to build and fetch recipients for selected groups, manually.'), - ), - 'allow_mail_from_logged_in_contact' => array( + ], + 'allow_mail_from_logged_in_contact' => [ 'group_name' => 'Mailing Preferences', 'group' => 'mailing', 'name' => 'allow_mail_from_logged_in_contact', @@ -360,5 +360,5 @@ 'is_contact' => 0, 'description' => 'Allow sending email from the logged in contact\'s email address', 'help_text' => 'CiviCRM allows you to send email from the domain from email addresses and the logged in contact id addresses by default. Disable this if you only want to allow the domain from addresses to be used.', - ), -); + ], +]; diff --git a/settings/Map.setting.php b/settings/Map.setting.php index 6d2b0464f28d..d89557c77dd5 100644 --- a/settings/Map.setting.php +++ b/settings/Map.setting.php @@ -33,8 +33,8 @@ * * Settings metadata file */ -return array( - 'geoAPIKey' => array( +return [ + 'geoAPIKey' => [ 'add' => '4.7', 'help_text' => NULL, 'is_domain' => 1, @@ -45,15 +45,15 @@ 'type' => 'String', 'quick_form_type' => 'Element', 'html_type' => 'text', - 'html_attributes' => array( + 'html_attributes' => [ 'size' => '32', 'maxlength' => '64', - ), + ], 'default' => NULL, 'title' => 'Geo Provider Key', 'description' => 'Enter the API key or Application ID associated with your geocoding provider (not required for Yahoo).', - ), - 'geoProvider' => array( + ], + 'geoProvider' => [ 'add' => '4.7', 'help_text' => NULL, 'is_domain' => 1, @@ -64,17 +64,17 @@ 'type' => 'String', 'quick_form_type' => 'Select', 'html_type' => 'Select', - 'html_attributes' => array( + 'html_attributes' => [ 'class' => 'crm-select2', - ), - 'pseudoconstant' => array( + ], + 'pseudoconstant' => [ 'callback' => 'CRM_Core_SelectValues::geoProvider', - ), + ], 'default' => NULL, 'title' => 'Geocoding Provider', 'description' => 'This can be the same or different from the mapping provider selected.', - ), - 'mapAPIKey' => array( + ], + 'mapAPIKey' => [ 'add' => '4.7', 'help_text' => NULL, 'is_domain' => 1, @@ -85,15 +85,15 @@ 'type' => 'String', 'quick_form_type' => 'Element', 'html_type' => 'text', - 'html_attributes' => array( + 'html_attributes' => [ 'size' => '32', 'maxlength' => '64', - ), + ], 'default' => NULL, 'title' => 'Map Provider Key', 'description' => 'Enter your API Key or Application ID. An API Key is required for the Google Maps API. Refer to developers.google.com for the latest information.', - ), - 'mapProvider' => array( + ], + 'mapProvider' => [ 'add' => '4.7', 'help_text' => NULL, 'is_domain' => 1, @@ -104,14 +104,14 @@ 'type' => 'String', 'quick_form_type' => 'Select', 'html_type' => 'Select', - 'html_attributes' => array( + 'html_attributes' => [ 'class' => 'crm-select2', - ), - 'pseudoconstant' => array( + ], + 'pseudoconstant' => [ 'callback' => 'CRM_Core_SelectValues::mapProvider', - ), + ], 'default' => NULL, 'title' => 'Mapping Provider', 'description' => 'Choose the mapping provider that has the best coverage for the majority of your contact addresses.', - ), -); + ], +]; diff --git a/settings/Member.setting.php b/settings/Member.setting.php index 37eb7bfc74b4..31d636ee8a57 100644 --- a/settings/Member.setting.php +++ b/settings/Member.setting.php @@ -36,23 +36,23 @@ * Settings metadata file */ -return array( - 'default_renewal_contribution_page' => array( +return [ + 'default_renewal_contribution_page' => [ 'group_name' => 'Member Preferences', 'group' => 'member', 'name' => 'default_renewal_contribution_page', 'type' => 'Integer', 'html_type' => 'select', 'default' => NULL, - 'pseudoconstant' => array( + 'pseudoconstant' => [ // @todo - handle table style pseudoconstants for settings & avoid deprecated function. 'callback' => 'CRM_Contribute_PseudoConstant::contributionPage', - ), + ], 'add' => '4.1', 'title' => 'Default online membership renewal page', 'is_domain' => 1, 'is_contact' => 0, 'description' => ts('If you select a default online contribution page for self-service membership renewals, a "renew" link pointing to that page will be displayed on the Contact Dashboard for memberships which were entered offline. You will need to ensure that the membership block for the selected online contribution page includes any currently available memberships.'), 'help_text' => NULL, - ), -); + ], +]; diff --git a/settings/Multisite.setting.php b/settings/Multisite.setting.php index 6f4770bba199..f82304b91039 100644 --- a/settings/Multisite.setting.php +++ b/settings/Multisite.setting.php @@ -35,8 +35,8 @@ * Settings metadata file */ -return array( - 'is_enabled' => array( +return [ + 'is_enabled' => [ 'group_name' => 'Multi Site Preferences', 'group' => 'multisite', 'name' => 'is_enabled', @@ -50,23 +50,23 @@ 'description' => ts('Make CiviCRM aware of multiple domains. You should configure a domain group if enabled'), 'documentation_link' => ['page' => 'Multi Site Installation', 'resource' => 'wiki'], 'help_text' => NULL, - ), - 'domain_group_id' => array( + ], + 'domain_group_id' => [ 'group_name' => 'Multi Site Preferences', 'group' => 'multisite', 'name' => 'domain_group_id', 'title' => ts('Multisite Domain Group'), 'type' => 'Integer', 'html_type' => 'entity_reference', - 'entity_reference_options' => ['entity' => 'Group', 'select' => array('minimumInputLength' => 0)], + 'entity_reference_options' => ['entity' => 'Group', 'select' => ['minimumInputLength' => 0]], 'default' => '0', 'add' => '4.1', 'is_domain' => 1, 'is_contact' => 0, 'description' => ts('Contacts created on this site are added to this group'), 'help_text' => NULL, - ), - 'event_price_set_domain_id' => array( + ], + 'event_price_set_domain_id' => [ 'group_name' => 'Multi Site Preferences', 'group' => 'multisite', 'name' => 'event_price_set_domain_id', @@ -78,8 +78,8 @@ 'is_contact' => 0, 'description' => '', 'help_text' => NULL, - ), - 'uniq_email_per_site' => array( + ], + 'uniq_email_per_site' => [ 'group_name' => 'Multi Site Preferences', 'group' => 'multisite', 'name' => 'uniq_email_per_site', @@ -91,5 +91,5 @@ 'is_contact' => 0, 'description' => '', 'help_text' => NULL, - ), -); + ], +]; diff --git a/settings/Search.setting.php b/settings/Search.setting.php index f4db966c90d3..043fe559bd22 100644 --- a/settings/Search.setting.php +++ b/settings/Search.setting.php @@ -35,18 +35,18 @@ /* * Settings metadata file */ -return array( - 'search_autocomplete_count' => array( +return [ + 'search_autocomplete_count' => [ 'group_name' => 'Search Preferences', 'group' => 'Search Preferences', 'name' => 'search_autocomplete_count', 'type' => 'Integer', 'quick_form_type' => 'Element', 'html_type' => 'text', - 'html_attributes' => array( + 'html_attributes' => [ 'size' => 2, 'maxlength' => 2, - ), + ], 'default' => 10, 'add' => '4.3', 'title' => 'Autocomplete Results', @@ -54,8 +54,8 @@ 'is_contact' => 0, 'description' => 'The maximum number of contacts to show at a time when typing in an autocomplete field.', 'help_text' => NULL, - ), - 'enable_innodb_fts' => array( + ], + 'enable_innodb_fts' => [ 'group_name' => 'Search Preferences', 'group' => 'Search Preferences', 'name' => 'enable_innodb_fts', @@ -68,20 +68,20 @@ 'is_contact' => 0, 'description' => "Enable InnoDB full-text search optimizations. (Requires MySQL 5.6+)", 'help_text' => NULL, - 'on_change' => array( - array('CRM_Core_InnoDBIndexer', 'onToggleFts'), - ), - ), - 'fts_query_mode' => array( + 'on_change' => [ + ['CRM_Core_InnoDBIndexer', 'onToggleFts'], + ], + ], + 'fts_query_mode' => [ 'group_name' => 'Search Preferences', 'group' => 'Search Preferences', 'name' => 'fts_query_mode', 'type' => 'String', 'quick_form_type' => 'Element', - 'html_attributes' => array( + 'html_attributes' => [ 'size' => 64, 'maxlength' => 64, - ), + ], 'html_type' => 'text', 'default' => 'simple', 'add' => '4.5', @@ -90,8 +90,8 @@ 'is_contact' => 0, 'description' => NULL, 'help_text' => NULL, - ), - 'includeOrderByClause' => array( + ], + 'includeOrderByClause' => [ 'group_name' => 'Search Preferences', 'group' => 'Search Preferences', 'name' => 'includeOrderByClause', @@ -104,8 +104,8 @@ 'is_contact' => 0, 'description' => 'If disabled, the search results will not be ordered. This may improve response time on search results on large datasets', 'help_text' => NULL, - ), - 'includeWildCardInName' => array( + ], + 'includeWildCardInName' => [ 'group_name' => 'Search Preferences', 'group' => 'Search Preferences', 'name' => 'includeWildCardInName', @@ -118,8 +118,8 @@ 'is_contact' => 0, 'description' => "If enabled, wildcards are automatically added to the beginning AND end of the search term when users search for contacts by Name. EXAMPLE: Searching for 'ada' will return any contact whose name includes those letters - e.g. 'Adams, Janet', 'Nadal, Jorge', etc. If disabled, a wildcard is added to the end of the search term only. EXAMPLE: Searching for 'ada' will return any contact whose last name begins with those letters - e.g. 'Adams, Janet' but NOT 'Nadal, Jorge'. Disabling this feature will speed up search significantly for larger databases, but users must manually enter wildcards ('%' or '_') to the beginning of the search term if they want to find all records which contain those letters. EXAMPLE: '%ada' will return 'Nadal, Jorge'.", 'help_text' => NULL, - ), - 'includeEmailInName' => array( + ], + 'includeEmailInName' => [ 'group_name' => 'Search Preferences', 'group' => 'Search Preferences', 'name' => 'includeEmailInName', @@ -132,8 +132,8 @@ 'is_contact' => 0, 'description' => 'If enabled, email addresses are automatically included when users search by Name. Disabling this feature will speed up search significantly for larger databases, but users will need to use the Email search fields (from Advanced Search, Search Builder, or Profiles) to find contacts by email address.', 'help_text' => NULL, - ), - 'includeNickNameInName' => array( + ], + 'includeNickNameInName' => [ 'group_name' => 'Search Preferences', 'group' => 'Search Preferences', 'name' => 'includeNickNameInName', @@ -146,8 +146,8 @@ 'is_contact' => 0, 'description' => 'If enabled, nicknames are automatically included when users search by Name.', 'help_text' => NULL, - ), - 'includeAlphabeticalPager' => array( + ], + 'includeAlphabeticalPager' => [ 'group_name' => 'Search Preferences', 'group' => 'Search Preferences', 'name' => 'includeAlphabeticalPager', @@ -160,8 +160,8 @@ 'is_contact' => 0, 'description' => 'If disabled, the alphabetical pager will not be displayed on the search screens. This will improve response time on search results on large datasets.', 'help_text' => NULL, - ), - 'smartGroupCacheTimeout' => array( + ], + 'smartGroupCacheTimeout' => [ 'group_name' => 'Search Preferences', 'group' => 'Search Preferences', 'name' => 'smartGroupCacheTimeout', @@ -175,20 +175,20 @@ 'is_contact' => 0, 'description' => 'The number of minutes to cache smart group contacts. We strongly recommend that this value be greater than zero, since a value of zero means no caching at all. If your contact data changes frequently, you should set this value to at least 5 minutes.', 'help_text' => NULL, - ), - 'defaultSearchProfileID' => array( + ], + 'defaultSearchProfileID' => [ 'group_name' => 'Search Preferences', 'group' => 'Search Preferences', 'name' => 'defaultSearchProfileID', 'type' => 'Integer', 'quick_form_type' => 'Select', 'html_type' => 'Select', - 'html_attributes' => array( + 'html_attributes' => [ 'class' => 'crm-select2', - ), - 'pseudoconstant' => array( + ], + 'pseudoconstant' => [ 'callback' => 'CRM_Admin_Form_Setting_Search::getAvailableProfiles', - ), + ], 'default' => NULL, 'add' => '4.6', 'title' => 'Default Contact Search Profile', @@ -196,29 +196,29 @@ 'is_contact' => 0, 'description' => 'If set, this will be the default profile used for contact search.', 'help_text' => NULL, - ), - 'prevNextBackend' => array( + ], + 'prevNextBackend' => [ 'group_name' => 'Search Preferences', 'group' => 'Search Preferences', 'name' => 'prevNextBackend', 'type' => 'String', 'quick_form_type' => 'Select', 'html_type' => 'Select', - 'html_attributes' => array( + 'html_attributes' => [ //'class' => 'crm-select2', - ), + ], 'default' => 'default', 'add' => '5.9', 'title' => 'PrevNext Cache', 'is_domain' => 1, 'is_contact' => 0, - 'pseudoconstant' => array( + 'pseudoconstant' => [ 'callback' => 'CRM_Core_BAO_PrevNextCache::getPrevNextBackends', - ), + ], 'description' => 'When performing a search, how should the search-results be cached?', 'help_text' => '', - ), - 'searchPrimaryDetailsOnly' => array( + ], + 'searchPrimaryDetailsOnly' => [ 'group_name' => 'Search Preferences', 'group' => 'Search Preferences', 'name' => 'searchPrimaryDetailsOnly', @@ -231,8 +231,8 @@ 'is_contact' => 0, 'description' => 'If enabled, only primary details (eg contact\'s primary email, phone, etc) will be included in Basic and Advanced Search results. Disabling this feature will allow users to match contacts using any email, phone etc detail.', 'help_text' => NULL, - ), - 'quicksearch_options' => array( + ], + 'quicksearch_options' => [ 'group_name' => 'Search Preferences', 'group' => 'Search Preferences', 'name' => 'quicksearch_options', @@ -240,15 +240,15 @@ 'serialize' => CRM_Core_DAO::SERIALIZE_SEPARATOR_BOOKEND, 'quick_form_type' => 'CheckBoxes', 'html_type' => 'checkboxes', - 'pseudoconstant' => array( + 'pseudoconstant' => [ 'callback' => 'CRM_Core_SelectValues::quicksearchOptions', - ), - 'default' => array('sort_name', 'contact_id', 'external_identifier', 'first_name', 'last_name', 'email', 'phone_numeric', 'street_address', 'city', 'postal_code', 'job_title'), + ], + 'default' => ['sort_name', 'contact_id', 'external_identifier', 'first_name', 'last_name', 'email', 'phone_numeric', 'street_address', 'city', 'postal_code', 'job_title'], 'add' => '5.8', 'title' => ts('Quicksearch options'), 'is_domain' => '1', 'is_contact' => 0, 'description' => ts("Which fields can be searched on in the menubar quicksearch box? Don't see your custom field here? Make sure it is marked as Searchable."), 'help_text' => NULL, - ), -); + ], +]; diff --git a/settings/Url.setting.php b/settings/Url.setting.php index 5aa76c4947ca..01bc414802cf 100644 --- a/settings/Url.setting.php +++ b/settings/Url.setting.php @@ -35,8 +35,8 @@ /* * Settings metadata file */ -return array( - 'userFrameworkResourceURL' => array( +return [ + 'userFrameworkResourceURL' => [ 'bootstrap_comment' => 'This is a boot setting which may be loaded during bootstrap. Defaults are loaded via SettingsBag::getSystemDefaults().', 'group' => 'url', 'group_name' => 'URL Preferences', @@ -52,8 +52,8 @@ 'description' => 'Absolute URL of the location where the civicrm module or component has been installed.', 'help_text' => NULL, 'validate_callback' => 'CRM_Utils_Rule::urlish', - ), - 'imageUploadURL' => array( + ], + 'imageUploadURL' => [ 'bootstrap_comment' => 'This is a boot setting which may be loaded during bootstrap. Defaults are loaded via SettingsBag::getSystemDefaults().', 'group' => 'url', 'group_name' => 'URL Preferences', @@ -69,8 +69,8 @@ 'description' => 'URL of the location for uploaded image files.', 'help_text' => NULL, 'validate_callback' => 'CRM_Utils_Rule::urlish', - ), - 'customCSSURL' => array( + ], + 'customCSSURL' => [ 'bootstrap_comment' => 'This is a boot setting which may be loaded during bootstrap. Defaults are loaded via SettingsBag::getSystemDefaults().', 'group' => 'url', 'group_name' => 'URL Preferences', @@ -86,8 +86,8 @@ 'description' => 'You can modify the look and feel of CiviCRM by adding your own stylesheet. For small to medium sized modifications, use your css file to override some of the styles in civicrm.css. Or if you need to make drastic changes, you can choose to disable civicrm.css completely.', 'help_text' => NULL, 'validate_callback' => 'CRM_Utils_Rule::urlish', - ), - 'extensionsURL' => array( + ], + 'extensionsURL' => [ 'bootstrap_comment' => 'This is a boot setting which may be loaded during bootstrap. Defaults are loaded via SettingsBag::getSystemDefaults().', 'group' => 'url', 'group_name' => 'URL Preferences', @@ -103,5 +103,5 @@ 'description' => 'Base URL for extension resources (images, stylesheets, etc). This should match extensionsDir.', 'help_text' => NULL, 'validate_callback' => 'CRM_Utils_Rule::urlish', - ), -); + ], +]; From 576c8a85880d6c19426be236466a21f6bb3f0f61 Mon Sep 17 00:00:00 2001 From: eileen Date: Tue, 9 Apr 2019 13:56:09 +1200 Subject: [PATCH 117/121] Improve flushing after creating a processor so it can be used for a recurring in the same run Mostly affects tests.... --- Civi/Payment/System.php | 2 ++ tests/phpunit/api/v3/PaymentProcessorTest.php | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/Civi/Payment/System.php b/Civi/Payment/System.php index 536ed5204889..44047cdc4107 100644 --- a/Civi/Payment/System.php +++ b/Civi/Payment/System.php @@ -137,6 +137,8 @@ public function flushProcessors() { if (isset(\Civi::$statics['CRM_Contribute_BAO_ContributionRecur'])) { unset(\Civi::$statics['CRM_Contribute_BAO_ContributionRecur']); } + \CRM_Core_PseudoConstant::flush('paymentProcessor'); + civicrm_api3('PaymentProcessor', 'getfields', ['cache_clear' => 1]); \CRM_Financial_BAO_PaymentProcessor::getAllPaymentProcessors('all', TRUE); \CRM_Financial_BAO_PaymentProcessor::getAllPaymentProcessors('live', TRUE); \CRM_Financial_BAO_PaymentProcessor::getAllPaymentProcessors('test', TRUE); diff --git a/tests/phpunit/api/v3/PaymentProcessorTest.php b/tests/phpunit/api/v3/PaymentProcessorTest.php index 4faf20e9f7c9..c3e16b9a07a1 100644 --- a/tests/phpunit/api/v3/PaymentProcessorTest.php +++ b/tests/phpunit/api/v3/PaymentProcessorTest.php @@ -74,6 +74,15 @@ public function testPaymentProcessorCreate() { $params = $this->_params; $result = $this->callAPIAndDocument('payment_processor', 'create', $params, __FUNCTION__, __FILE__); $this->callAPISuccessGetSingle('EntityFinancialAccount', ['entity_table' => 'civicrm_payment_processor', 'entity_id' => $result['id']]); + + // Test that the option values are flushed so ths can be used straight away. + $this->callAPISuccess('ContributionRecur', 'create', [ + 'contact_id' => $this->individualCreate(), + 'amount' => 5, + 'financial_type_id' => 'Donation', + 'payment_processor_id' => 'API Test PP', + 'frequency_interval' => 1, + ]); $this->getAndCheck($params, $result['id'], 'PaymentProcessor'); } From 62f662b002e4f8b6cfbdbd2b9d0c03712f2441fa Mon Sep 17 00:00:00 2001 From: eileen Date: Thu, 7 Feb 2019 10:48:02 +1300 Subject: [PATCH 118/121] Load hooks during upgrade mode For unknown, svn, reasons extension hooks are not loaded during upgrade (this doesn't apply to drupal modules) - this causes some fairly serious problems 1) settings are re-loaded & cached with settings from extensions being lost 2) trigger alter hooks are lost this means - the summary fields triggers are frequently lost on upgrade - hooks that unset various tables to prevent them from being logged can fail, resulting in those log tables being created - hooks that specify the table should be innodb can fail to run, resulting in archive format. I can't think WHY we do this? Presumably there was some problem that would have been better solved another way but which was solved this way? Fix "Load hooks during upgrade mode" (45312e1e64dd6af0281fe5fb7f96dbd8be39e524) In my testing, the commit doesn't do what it says because the symbols are wrong. --- CRM/Extension/Mapper.php | 6 +++--- CRM/Utils/Hook.php | 11 +++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CRM/Extension/Mapper.php b/CRM/Extension/Mapper.php index 358d3a910323..b9cc7ed18210 100644 --- a/CRM/Extension/Mapper.php +++ b/CRM/Extension/Mapper.php @@ -275,9 +275,9 @@ public function keyToUrl($key) { * array(array('prefix' => $, 'file' => $)) */ public function getActiveModuleFiles($fresh = FALSE) { - $config = CRM_Core_Config::singleton(); - if ($config->isUpgradeMode() || !defined('CIVICRM_DSN')) { - return []; // hmm, ok + if (!defined('CIVICRM_DSN')) { + // hmm, ok + return []; } $moduleExtensions = NULL; diff --git a/CRM/Utils/Hook.php b/CRM/Utils/Hook.php index 8282a89c7ca2..a47f3076d7f7 100644 --- a/CRM/Utils/Hook.php +++ b/CRM/Utils/Hook.php @@ -161,6 +161,17 @@ public function invoke( &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6, $fnSuffix ) { + // Per https://github.com/civicrm/civicrm-core/pull/13551 we have had ongoing significant problems where hooks from modules are + // invoked during upgrade but not those from extensions. The issues are both that an incorrect module list & settings are cached and that + // some hooks REALLY need to run during upgrade - the loss of triggers during upgrade causes significant loss of data + // whereas loss of logTable hooks means that log tables are created for tables specifically excluded - e.g due to large + // quantities of low-importance data or the table not having an id field, which could cause a fatal error. + // Instead of not calling any hooks we only call those we know to be frequently important - if a particular extension wanted + // to avoid this they could do an early return on CRM_Core_Config::singleton()->isUpgradeMode + $upgradeFriendlyHooks = ['civicrm_alterSettingsFolders', 'civicrm_alterSettingsMetaData', 'civicrm_triggerInfo', 'civicrm_alterLogTables', 'civicrm_container']; + if (CRM_Core_Config::singleton()->isUpgradeMode() && !in_array($fnSuffix, $upgradeFriendlyHooks)) { + return; + } if (is_array($names) && !defined('CIVICRM_FORCE_LEGACY_HOOK') && \Civi\Core\Container::isContainerBooted()) { $event = \Civi\Core\Event\GenericHookEvent::createOrdered( $names, From b2a2920623f7963ad645977ba6f5466b756b615f Mon Sep 17 00:00:00 2001 From: Joe Murray Date: Tue, 9 Apr 2019 11:22:26 -0400 Subject: [PATCH 119/121] Added myself --- CONTRIBUTORS.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index c32000ea0158..d4cbb1448672 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -29,7 +29,7 @@ Freeform Solutions - Herb van den Dool Fuzion - Jitendra Purohit Ginkgo Street Labs - Frank Gómez Hossein Amin -JMA Consulting - Monish Deb +JMA Consulting - Joe Murray, Monish Deb Johan Vervloet John Kingsnorth Joinery - Allen Shaw From fb1a4c6f586bcfa88d5016b5977473669c48531c Mon Sep 17 00:00:00 2001 From: CiviCRM Date: Tue, 9 Apr 2019 17:55:28 +0000 Subject: [PATCH 120/121] Set version to 5.13.beta1 --- CRM/Upgrade/Incremental/sql/5.13.beta1.mysql.tpl | 1 + sql/civicrm_generated.mysql | 2 +- xml/version.xml | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 CRM/Upgrade/Incremental/sql/5.13.beta1.mysql.tpl diff --git a/CRM/Upgrade/Incremental/sql/5.13.beta1.mysql.tpl b/CRM/Upgrade/Incremental/sql/5.13.beta1.mysql.tpl new file mode 100644 index 000000000000..8813e5af9b60 --- /dev/null +++ b/CRM/Upgrade/Incremental/sql/5.13.beta1.mysql.tpl @@ -0,0 +1 @@ +{* file to handle db changes in 5.13.beta1 during upgrade *} diff --git a/sql/civicrm_generated.mysql b/sql/civicrm_generated.mysql index 7b21d7d4bf0e..b02e6d5c0333 100644 --- a/sql/civicrm_generated.mysql +++ b/sql/civicrm_generated.mysql @@ -399,7 +399,7 @@ UNLOCK TABLES; LOCK TABLES `civicrm_domain` WRITE; /*!40000 ALTER TABLE `civicrm_domain` DISABLE KEYS */; -INSERT INTO `civicrm_domain` (`id`, `name`, `description`, `config_backend`, `version`, `contact_id`, `locales`, `locale_custom_strings`) VALUES (1,'Default Domain Name',NULL,NULL,'5.13.alpha1',1,NULL,'a:1:{s:5:\"en_US\";a:0:{}}'); +INSERT INTO `civicrm_domain` (`id`, `name`, `description`, `config_backend`, `version`, `contact_id`, `locales`, `locale_custom_strings`) VALUES (1,'Default Domain Name',NULL,NULL,'5.13.beta1',1,NULL,'a:1:{s:5:\"en_US\";a:0:{}}'); /*!40000 ALTER TABLE `civicrm_domain` ENABLE KEYS */; UNLOCK TABLES; diff --git a/xml/version.xml b/xml/version.xml index c80681ece57b..15d607f2695a 100644 --- a/xml/version.xml +++ b/xml/version.xml @@ -1,4 +1,4 @@ - 5.13.alpha1 + 5.13.beta1 From 8b37a74197b0ddf43038a2ee588f440004c02592 Mon Sep 17 00:00:00 2001 From: CiviCRM Date: Tue, 9 Apr 2019 18:01:36 +0000 Subject: [PATCH 121/121] Set version to 5.14.alpha1 --- CRM/Upgrade/Incremental/php/FiveFourteen.php | 87 +++++++++++++++++++ .../Incremental/sql/5.14.alpha1.mysql.tpl | 1 + sql/civicrm_generated.mysql | 2 +- xml/version.xml | 2 +- 4 files changed, 90 insertions(+), 2 deletions(-) create mode 100644 CRM/Upgrade/Incremental/php/FiveFourteen.php create mode 100644 CRM/Upgrade/Incremental/sql/5.14.alpha1.mysql.tpl diff --git a/CRM/Upgrade/Incremental/php/FiveFourteen.php b/CRM/Upgrade/Incremental/php/FiveFourteen.php new file mode 100644 index 000000000000..ad58a8a853ce --- /dev/null +++ b/CRM/Upgrade/Incremental/php/FiveFourteen.php @@ -0,0 +1,87 @@ +' . ts('A new permission, "%1", has been added. This permission is now used to control access to the Manage Tags screen.', array(1 => ts('manage tags'))) . '

      '; + // } + } + + /** + * Compute any messages which should be displayed after upgrade. + * + * @param string $postUpgradeMessage + * alterable. + * @param string $rev + * an intermediate version; note that setPostUpgradeMessage is called repeatedly with different $revs. + */ + public function setPostUpgradeMessage(&$postUpgradeMessage, $rev) { + // Example: Generate a post-upgrade message. + // if ($rev == '5.12.34') { + // $postUpgradeMessage .= '

      ' . ts("By default, CiviCRM now disables the ability to import directly from SQL. To use this feature, you must explicitly grant permission 'import SQL datasource'."); + // } + } + + /* + * Important! All upgrade functions MUST add a 'runSql' task. + * Uncomment and use the following template for a new upgrade version + * (change the x in the function name): + */ + + // /** + // * Upgrade function. + // * + // * @param string $rev + // */ + // public function upgrade_5_0_x($rev) { + // $this->addTask(ts('Upgrade DB to %1: SQL', array(1 => $rev)), 'runSql', $rev); + // $this->addTask('Do the foo change', 'taskFoo', ...); + // // Additional tasks here... + // // Note: do not use ts() in the addTask description because it adds unnecessary strings to transifex. + // // The above is an exception because 'Upgrade DB to %1: SQL' is generic & reusable. + // } + + // public static function taskFoo(CRM_Queue_TaskContext $ctx, ...) { + // return TRUE; + // } + +} diff --git a/CRM/Upgrade/Incremental/sql/5.14.alpha1.mysql.tpl b/CRM/Upgrade/Incremental/sql/5.14.alpha1.mysql.tpl new file mode 100644 index 000000000000..051f6eac085d --- /dev/null +++ b/CRM/Upgrade/Incremental/sql/5.14.alpha1.mysql.tpl @@ -0,0 +1 @@ +{* file to handle db changes in 5.14.alpha1 during upgrade *} diff --git a/sql/civicrm_generated.mysql b/sql/civicrm_generated.mysql index b02e6d5c0333..3305a0d4efc7 100644 --- a/sql/civicrm_generated.mysql +++ b/sql/civicrm_generated.mysql @@ -399,7 +399,7 @@ UNLOCK TABLES; LOCK TABLES `civicrm_domain` WRITE; /*!40000 ALTER TABLE `civicrm_domain` DISABLE KEYS */; -INSERT INTO `civicrm_domain` (`id`, `name`, `description`, `config_backend`, `version`, `contact_id`, `locales`, `locale_custom_strings`) VALUES (1,'Default Domain Name',NULL,NULL,'5.13.beta1',1,NULL,'a:1:{s:5:\"en_US\";a:0:{}}'); +INSERT INTO `civicrm_domain` (`id`, `name`, `description`, `config_backend`, `version`, `contact_id`, `locales`, `locale_custom_strings`) VALUES (1,'Default Domain Name',NULL,NULL,'5.14.alpha1',1,NULL,'a:1:{s:5:\"en_US\";a:0:{}}'); /*!40000 ALTER TABLE `civicrm_domain` ENABLE KEYS */; UNLOCK TABLES; diff --git a/xml/version.xml b/xml/version.xml index 15d607f2695a..07d0df45b405 100644 --- a/xml/version.xml +++ b/xml/version.xml @@ -1,4 +1,4 @@ - 5.13.beta1 + 5.14.alpha1